(function(global) {
"use strict";
var __TOK_DEFER__ = 'NG_DEFER_BOOTSTRAP!';
frdl.$q('html', false, document).setAttribute('ng-csp', 'no-inline-style;no-unsafe-eval');
frdl.$q('html', false, document).setAttribute('ng-non-bindable', 'non-bindable'); /* !important http://stackoverflow.com/questions/18184617/angularjs-how-to-nest-applications-within-an-angular-app */
var __WIDGET_REL__ = 'widget';
var __APP_NS__ = 'webfan';
var __GUID_ND__ = __APP_NS__ + '.gui';
var preferences = {
URL_SERACHENGINE_PLUGIN : frdl.route('FRDL.URL.SERACHENGINE.PLUGIN'),
URL__MANIFEST_WEBAPP_WEBFAN_MAIN : frdl.route('FRDL.URL.MANIFEST.WEBAPP.WEBFAN.MY')
};
var jQueryMobile = {
autoInitializePage : frdl.route('jQueryMobile.autoInitializePage'),
ajaxEnabled: frdl.route('jQueryMobile.ajaxEnabled'),
linkBindingEnabled : frdl.route('jQueryMobile.linkBindingEnabled'),
hashListeningEnabled : frdl.route('jQueryMobile.hashListeningEnabled'),
pushStateEnabled : frdl.route('jQueryMobile.pushStateEnabled')
};
var DBPFX= 'frdl/WebfanDesktop/';
(function(){
var Bootstrap = (new function(){
var _on = true;
return Object.create( {
switchOn : function(a, old){
if(a !== _on){
this.since = frdl.time();
frdl.cron.add(this.timerName, this.check);
}
if(true===a){
_on=true;
}else if(false===a){
_on=false;
}
if(true===old){
if(true===a){
window.name = str_replace(__TOK_DEFER__, '', window.name);
}else if(false===a){
window.name = __TOK_DEFER__ + str_replace(__TOK_DEFER__, '', window.name);
}
_on= (window.name !== str_replace(__TOK_DEFER__, '', window.name)) ? false : true;
}
return _on;
},
since : frdl.time(),
timeout : 10000,
check : function(){
if(true === _on){
frdl.cron.remove(this.timerName);
}else{
if(frdl.time() - this.since >= this.timeout){
if(0<frdl.debug.mode()){
console.log('Forcing angularBootstrapable(true) due to timeout while sleeping.'+"\n"+'Please refactor the use of frdl.UI.Compile()');
}
this.switchOn(true);
frdl.UI.Compile(1);
}
}
},
timerName : 'frdl://Bootstrap.check/' + frdl.microtime() + mt_rand(1000,9999)
});
});
var loaded$UI=false;
var require$UI = function(callback, args){
if(false!==loaded$UI)return;
loaded$UI=true;
if('object' !== typeof $.ui && false===$.ui instanceof Promise
&& null === frdl.$q('style[src$="jquery-ui.js"]', false)
&& null === frdl.$q('style[src$="jquery-ui.min.js"]', false)
){
if( null === frdl.$q('link[href$="jquery-ui.css"]', false)
&& null === frdl.$q('link[href$="jquery-ui.min.css"]', false)){
frdl.getCSS('http://'+frdl.route('HOST_CDN_PUBLIC_FRDL')+'/cdn/frdl/flow/libraries/jquery/ui/jquery-ui.min.css');
}
frdl.getScript('http://'+frdl.route('HOST_CDN_PUBLIC_FRDL')+'/cdn/frdl/flow/libraries/jquery/ui/jquery-ui.min.js', function(){
callback(args);
});
}else{
callback(args);
}
};
frdl.angularBootstrapable = function(a, old){
return Bootstrap.switchOn(a, old);
};
frdl.UI=frdl.$({
o :{
DBPFX : DBPFX,
LOCAL_MACHINE_CURRENT_USER : (JSON.parse( base64_decode(
localStorage.getItem(DBPFX + 'LOCAL_MACHINE_CURRENT_USER/')
)) || 'anonymous'),
Main : {
StatusBarStyle : 'lightblue'
},
jQueryMobile : {
o: {
loadingMessage : 'Loading...',
pageLoadErrorMessage : 'Error Loading Page',
allowCrossDomainPages : true,
defaultPageTransition : 'fade',
overlayTheme: "d",
theme : 'd',
pageLoadErrorMessageTheme : 'e',
autoInitializePage : frdl.route('jQueryMobile.autoInitializePage'),
ajaxEnabled: frdl.route('jQueryMobile.ajaxEnabled'),
linkBindingEnabled : frdl.route('jQueryMobile.linkBindingEnabled'),
hashListeningEnabled : frdl.route('jQueryMobile.hashListeningEnabled'),
pushStateEnabled : frdl.route('jQueryMobile.pushStateEnabled')
}
},
jQueryUI : {
require : function(callback, args){
return require$UI(callback, args);
}
}
},
defer : function(){
this.$$run('startdefer');
frdl.angularBootstrapable(false, false);
return this;
},
load : function(){
this.$$run('enddefer');
frdl.angularBootstrapable(true, false);
return this;
},
widgetAppData : function(file, component){
var s = {};
var c = explode('\/', component);
s._TOK_ = '*[data-frdl-component$="'+((2===c.length) ? c[0]+'\\/'+c[1] : component)+'"]';
/* s.__FILE__ = file; */
s.Url = new frdl.Url(file);
s.__DIR__ = s.Url.getScheme() + '://' + s.Url.getHost() + '/' + s.Url.getDirectory();
return s;
}
}).defer();
frdl.UI.emitter=new frdl.EventEmitter();
document.addEventListener('readystatechange', function(ev){
Bootstrap.since=frdl.time();
}) ;
document.addEventListener("mobileinit", function(){
$.extend( $.mobile , frdl.UI.o.jQueryMobile.o);
});
}());
(function(){
frdl.hasScope = function(element){
return ($(element).hasClass('ng-scope')) ? true : false;
};
frdl.UI.reduced = function(){
return (
true===frdl.Dom.isFramed()
|| true === frdl.Device().isMobile
|| true === frdl.Device().isTablet
|| true === frdl.Device().isTouchable
|| true === frdl.Device().isApp
/* || true === frdl.Device().frdlApp*/
)
? true: false;
};
}());
(function(){
var obs = frdl.watchFor('frdl').every(function(el){
el.setAttribute('ng-non-bindable', 'non-bindable');
});
}());
/*
(function(){
var obs = frdl.watchFor('*[draggable]').every(function(el){
frdl.UI.o.jQueryUI.require(function(e){
$(e).draggable();
}, el);
});
}());
*/
(function(){
frdl.watchFor('*[resizable]').every(function(el){
frdl.UI.o.jQueryUI.require(function(e){
$(e).resizable();
}, el);
});
}());
/*
(function(){
var obs = frdl.watchFor('.webfan-blue').every(function(el){
try{
frdl.getScript('http://webfan.de/site/site_css/webfan/style.webfan.global.css');
obs.destroy();
}catch(err){
cosnole.warn(err);
}
});
}());
*/
(function(){
function canonicalAttributes(el){
var j = 0,
names = ['ng-app', 'ng-modules', 'ng-module', 'data-ng-modules', 'data-ng-module', 'ng-flow', 'data-ng-flow', 'data-ng-flows'],
a = el.attributes
;
if(!!a) {
for( j = 0; j < a.length; j++) {
var attr = a[j];
if (names.indexOf(attr.name.toLowerCase()) !== -1) {
if('ng-flows' !== attr.name)el.removeAttribute(attr.name);
el.setAttribute('ng-flows', attr.value);
}
}
}
return true;
}
var obs = frdl.watchFor('[ng-app], [ng-modules], [ng-module], [data-ng-modules], [data-ng-module], [ng-flow], [data-ng-flow], [data-ng-flows]')
.every(canonicalAttributes);
}());
(function(){
var obs = frdl.watchFor('intent:not([data-flow-prepared="true"])').every(function(el){
if(!!window.webfanIntent || null !== frdl.$q('intent[data-flow-prepared*="true"]', false) )return true;
frdl.$j(el).attrAdd('data-flow-prepared', 'true');
frdl.getScript('http://frdl.webfan.de/cdn/frdl/flow/components/frdl/intent/webintents.js'
, function(){
console.log('webfanIntents script loaded');
obs.destroy();
}, true, false);
return true;
});
}());
(function(){
var _cloaded = false, obs;
obs = frdl.watchFor(
'*[href^="web\+fan\:"]:not([data-flow-prepared*="true"])'
+ ', *[src^="web\+fan\:"]:not([data-flow-prepared*="true"])'
+ ', *[data-src^="web\+fan\:"]:not([data-flow-prepared*="true"])'
+ ', *[ng-src^="web\+fan\:"]:not([data-flow-prepared*="true"])'
+ ', *[data-href^="web\+fan\:"]:not([data-flow-prepared*="true"])'
+ ', *[ng-href^="web\+fan\:"]:not([data-flow-prepared*="true"])'
)
.every(function(el){
frdl.$j(el).attrAdd('data-flow-prepared', 'true');
if(!!_cloaded || null !== frdl.$q('iframe[id="IFRAME.webfan_proxy"]',false))return;
var iframe = frdl.Dom.create("iframe");
iframe.setAttribute('frdl-nwtrusted', true);
iframe.style.display = "none";
iframe.setAttribute('id', "IFRAME.webfan_proxy");
iframe.setAttribute('src', "http://webfan.de/proxy");
frdl.Dom.add(iframe, frdl.$q('head',false));
_cloaded = true;
return true;
});
}());
(function(){
var obs = frdl.watchFor('webfan[type="widget"]:not([data-flow-prepared*="true"]), *[type^="application/vnd.frdl.flow.widget."]:not([data-flow-prepared*="true"]), *[type$=".wgt"]:not([data-flow-prepared*="true"])').every(function(el){
frdl.$j(el).attrAdd('data-flow-prepared', 'true');
$(el).html('<div data-frdl-component="widget://example.com/'+el.getAttribute('name')+'"></div>') ;
$(document).trigger('readystatechange');
return true;
});
}());
(function(){
var obs = frdl.watchFor('*[webfan-tempelement]').every(function(el){
var duration = el.getAttribute('webfan-tempelement');
if(!isNaN(parseInt(duration))){
setTimeout(function(){
$(el).hide();
$(el).remove();
},duration);
}
});
}());
(function(){
var obs = frdl.watchFor('*[webfan-fadeout]').every(function(el){
try{
var duration = el.getAttribute('webfan-fadeout');
if(!isNaN(parseInt(duration))){
setTimeout(function(){
$(el).fadeOut('slow');
},duration);
}
}catch(err){
console.warn(err);
}
});
}());
frdl.watchFor('*[flow-nav-horizontal]:not([data-flow-prepared*="true"]), *[flow-nav-horizontal]:not([data-flow-prepared*="true"]) > *, *[flow-nav-horizontal]:not([data-flow-prepared*="true"]) > * > *').every(function(el){
el.style.display='inline';
frdl.$j(el).attrAdd('data-flow-prepared', 'true');
});
frdl.watchFor('a[frdl-ajax-link-boddystripped]:not([data-flow-prepared*="true"])').every(function(element){
frdl.$j(element).attrAdd('data-flow-prepared', 'true');
$(element).on('click', function(ev){
var el = ev.target;
if(!el.hasAttribute('href'))return true;
if('undefined'===window.history.pushState)return true;
var url = el.getAttribute('href');
var uHost = new frdl.Url(url).getHost();
if( '' !== uHost && new frdl.Url().getHost() !== uHost)return true;
ev.preventDefault();
if(true === frdl.Device().isMobile || true === frdl.Device().isTablet){
$.mobile.loading( 'show' );
}
var dest = 'body';
var destMeta=document.querySelector('meta[name="frdl-ajax-link-boddystripped.destination"]');
if(null!==destMeta){
dest=destMeta.getAttribute('content');
}
var OnUnload = function(e){
e.preventDefault();
return false;
};
window.addEventListener('beforeunload', OnUnload);
$.ajax({
url: url,
crossDomain:true,
cache:true,
headers: {'X-Requested-With': 'XMLHttpRequest'
, 'X-Flow-Ajax-Link-Boddystripped': 'destination="'+dest+'";'
},
type: 'GET',
dataType:'html'
})
.done(function( html ) {
$(dest).html(html);
window.removeEventListener('beforeunload', OnUnload);
setTimeout(function(){
try{
var newTitle=document.querySelector('meta[name="document.title"]').getAttribute('content');
}catch(err){
}
if('undefined'!==typeof newTitle)$('title').html(newTitle);
try{
$(document).scrollTop(0);
}catch(err){
}
$(document).trigger('readystatechange');
if(true === frdl.Device().isMobile || true === frdl.Device().isTablet){
$(dest).trigger('create');
$.mobile.loading( 'hide' );
}
window.history.pushState({
name : newTitle,
sha1 : Sha1.hash(html),
l : html.toString().length
}, newTitle, url);
ev.stopPropagation();
},1);
}).fail(function(jqXHR, textStatus) {
frdl.alert.error('Error: ' + url + ' ' + jqXHR.status+ ' '+textStatus);
window.location.href=url;
}).always(function() {
});
return false;
});
});
(function(){
var _done_HeaderMetadata = false;
var headerMetadata=function(doc){
var meta, Tags;
if(true===_done_HeaderMetadata)return;
_done_HeaderMetadata=true;
if('undefined' === typeof doc)doc = document;
/*
Tags = frdl.$q('html[manifest]', false, doc);
if(null === Tags){
frdl.$q('html', false, doc).setAttribute('meta', 'http://webfan.de/cdn/frdl/flow/components/frdl/intent/manifest-minimum.appcache');
}
*/
Tags = frdl.$q('meta[name="flow.component.frdl.webfan.api.url.demo"]', true, doc);
if(0 === Tags.length){
meta = frdl.Dom.create('meta');
meta.setAttribute('name', 'flow.component.frdl.webfan.api.url.demo');
meta.setAttribute('content', frdl.route('DEMO_API_CLIENT_URL'));
frdl.Dom.add(meta, frdl.Dom.getTagNames('head')[0]);
}
Tags = frdl.$q('meta[name="flow.component.frdl.webfan.api.url.demo.alt"]', true, doc);
if(0 === Tags.length){
meta = frdl.Dom.create('meta');
meta.setAttribute('name', 'flow.component.frdl.webfan.api.url.demo.alt');
meta.setAttribute('content', frdl.route('DEMO_API_CLIENT_URL_ALT'));
frdl.Dom.add(meta, frdl.Dom.getTagNames('head')[0]);
}
Tags = frdl.$q('meta[name="apple-mobile-web-app-capable"]', true, doc);
if(0 === Tags.length){
meta = frdl.Dom.create('meta');
meta.setAttribute('name', 'apple-mobile-web-app-capable');
meta.setAttribute('content', 'yes');
frdl.Dom.add(meta, frdl.Dom.getTagNames('head')[0]);
}
Tags = frdl.$q('meta[name="application-name"]', true, doc);
if(0 === Tags.length){
meta = frdl.Dom.create('meta');
meta.setAttribute('name', 'application-name');
meta.setAttribute('content', (null!==document.querySelector('title')) ? document.querySelector('title').innerHTML : location);
frdl.Dom.add(meta, frdl.Dom.getTagNames('head')[0]);
}
Tags = frdl.$q('meta[name="apple-mobile-web-app-status-bar-style"]', true, doc);
if(0 === Tags.length){
meta = frdl.Dom.create('meta');
meta.setAttribute('name', 'apple-mobile-web-app-status-bar-style');
meta.setAttribute('content', frdl.UI.o.Main.StatusBarStyle);
frdl.Dom.add(meta, frdl.Dom.getTagNames('head')[0]);
}
Tags = frdl.$q('meta[name="HandheldFriendly"]', true, doc);
if(0 === Tags.length){
meta = frdl.Dom.create('meta');
meta.setAttribute('name', 'HandheldFriendly');
meta.setAttribute('content', 'true');
frdl.Dom.add(meta, frdl.Dom.getTagNames('head')[0]);
}
Tags = frdl.$q('meta[name="MobileOptimized"]', true, doc);
if(0 === Tags.length){
meta = frdl.Dom.create('meta');
meta.setAttribute('name', 'MobileOptimized');
meta.setAttribute('content', '320');
frdl.Dom.add(meta, frdl.Dom.getTagNames('head')[0]);
}
Tags = frdl.$q('meta[name="viewport"]', true, doc);
if(0 === Tags.length){
meta = frdl.Dom.create('meta');
meta.setAttribute('name', 'viewport');
meta.setAttribute('content', 'width=device-width, initial-scale=1.0, user-scalable=yes');
frdl.Dom.add(meta, frdl.Dom.getTagNames('head')[0]);
}
Tags = frdl.$q('meta[http-equiv="http-equiv"]', true, doc);
if(0 === Tags.length){
meta = frdl.Dom.create('meta');
meta.setAttribute('http-equiv', 'http-equiv');
meta.setAttribute('content', 'IE=11');
frdl.Dom.add(meta, frdl.Dom.getTagNames('head')[0]);
}
var lnk;
if(0 === frdl.$q('link[type="application/manifest+json"]', true, doc).length
&& ('www.webfan.de'=== new frdl.Url().getHost()
|| 'webfan.de'=== new frdl.Url().getHost()
|| 'webfan' === explode('.', new frdl.Url().getHost()).reverse()[1]
)){
lnk = frdl.Dom.create('link');
lnk.setAttribute('rel', 'manifest');
lnk.setAttribute('type', 'application/manifest+json');
lnk.setAttribute('href', preferences.URL__MANIFEST_WEBAPP_WEBFAN_MAIN);
frdl.Dom.add(lnk, frdl.Dom.getTagNames('head')[0]);
}
/* "\n<link rel=\"search\" type=\"application/opensearchdescription+xml\" href=\"$this->xml_url\" title=\"$title\" />\n";*/
if(0 === frdl.$q('link[type="application/opensearchdescription+xml"]', true, doc).length){
lnk = frdl.Dom.create('link');
lnk.setAttribute('rel', 'search');
lnk.setAttribute('title', 'Webfan: Search');
lnk.setAttribute('type', 'application/opensearchdescription+xml');
lnk.setAttribute('href', preferences.URL_SERACHENGINE_PLUGIN);
frdl.Dom.add(lnk, frdl.Dom.getTagNames('head')[0]);
}
console.log('Setup MetaData');
};
frdl.whenEver(function(){
return (null!== frdl.$q('body',false)) ? true : false;
}, headerMetadata, document, 1);
if(null !== frdl.$q('link[type="application/manifest+json"]', false)){
frdl.UI.isWebApp = true;
}else{
frdl.UI.isWebApp = false;
}
}());
frdl.ready(function(){
/*
http://stackoverflow.com/questions/22548610/can-i-use-one-ng-app-inside-another-one-in-angularjs
"compile" : function( $compile, $element, $attrs, $rootScope) {
angular.module("ng").directive("ngIsolateApp", function() {
return {
"scope" : {},
"restrict" : "AEC",
"compile" : function(element, attrs) {
var html = element.html();
element.html('');
return function(scope, element) {
scope.$destroy();
setTimeout(function() {
var newRoot = document.createElement("div");
newRoot.innerHTML = html;
angular.bootstrap(newRoot, [attrs["ngIsolateApp"]]);
element.append(newRoot);
});
}
}
}
});
*/
frdl.a.module('frdl', ['ng'])
.directive("frdl", function() {
return {
"scope" : {},
"restrict" : "E",
"compile" : function($compile, element, attrs) {
var html = element.innerHTML;
element.innerHTML='';
if('function'===typeof element.setAttribute){
element.setAttribute('ng-non-bindable', 'non-bindable');
}
return function($scope, $element) {
$scope = $element.isolateScope();
setTimeout(function() {
$element.innerHTML=html;
}, 1500);
}
}
}
})
;
frdl.a.module(__APP_NS__, ['frdl']);
frdl.a.module(__GUID_ND__, [__APP_NS__ , 'ngTouch', 'csrf-cross-domain', 'oc.lazyLoad', 'ui.router'])
/* IE https://github.com/angular/angular.js/issues/6976
* http://plnkr.co/edit/EHfYEeONdOFa6Xu4owUx?p=preview
*/
/*
.config(function ($provide) {
$provide.decorator('$browser', function ($delegate, $log) {
var _url = $delegate.url;
$delegate.url = function () {
if (arguments[0]) {
$log.log('Navgiating to ', arguments[0], arguments[1]);
}
return _url.apply($delegate, arguments);
};
return $delegate;
})
})
.config(['$locationProvider', function ($locationProvider) {
$locationProvider.html5Mode({
enabled: false,
requireBase: false
});
}])
;
frdl.a.module(__GUID_ND__) */
.config(['$compileProvider',
function($compileProvider) {
$compileProvider.imgSrcSanitizationWhitelist(/^\s*((https?|ftp|file|blob|chrome-extension|webfan|frdl|frdlweb|frdl-webkit|app|intent|webfan-intent|wpjct|widget|frdl-css|webkit-webfan|user|webfan-user|help|cli|frdl-cli|filesystem|webfan-sdk|frdl-sdk|webfan-api|frdl-api|api|web+fan|about|debug):|data:image\/)/);
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file:chrome-extension|webfan|frdl|frdlweb|frdl-webkit|app|intent|webfan-intent|wpjct|widget|frdl-css|webkit-webfan|user|webfan-user|help|cli|frdl-cli|filesystem|webfan-sdk|frdl-sdk|webfan-api|frdl-api|api|web+fan|about|debug):/);
}])
.config(['$ocLazyLoadProvider', '$stateProvider', function($ocLazyLoadProvider, $stateProvider) {
$ocLazyLoadProvider.config({
debug: true,
events : true,
serie: false,
cache: true,
rerun: false,
reconfig: false ,
modules: [
{
name: __GUID_ND__+'.sdk',
files: [ 'http://api.webfan.de/api-d/4/js-api/library.js?plugin=sdk']
},
{
name: 'ui.codemirror',
serie: true,
files: [
'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/lib/codemirror.css'
/* , 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/theme/eclipse.css' */
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/theme/blackboard.css'
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/lib/codemirror.js'
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/addon/selection/selection-pointer.js'
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/mode/xml/xml.js'
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/mode/javascript/javascript.js'
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/mode/css/css.js'
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/mode/vbscript/vbscript.js'
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/mode/htmlmixed/htmlmixed.js'
/* , 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/lib/util/http_codemirror.net_2_lib_util_multiplex.js'
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/lib/util/overlay.js'
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/lib/util/foldcode.js' */
/*
additonal... php, sql ?
change mode
$('#mode').change(function(){
editor.setOption("mode", $(this).val() );
});
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/mode/php/php.js'
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/mode/sql/sql.js'
*/
, 'http://webfan.de/cdn/frdl/flow/components/codemirror/codemirror/ui-codemirror/src/ui-codemirror.js'
]
}
]
});
}])
.factory('widgetElement', function() {
return function widgetElement(element, token){
return $(element).closest(token);
};
})
.directive('draggable', function($document) {
return function(scope, element, attr) {
var startX = 0, startY = 0, x = 0, y = 0;
element.css({
position: 'relative',
cursor: 'pointer'
});
element.on('mousedown', function(event) {
startX = event.screenX - x;
startY = event.screenY - y;
$document.on('mousemove', mousemove);
$document.on('mouseup', mouseup);
});
element.children().on('mousedown', function(event) {
if( 'A'===this.tagName || 'INPUT'===this.tagName || 'TEXT'===this.tagName || 'BUTTON'===this.tagName || 'SELECT'===this.tagName || 'PRE'===this.tagName ){
event.stopPropagation();
try{
this.removeEventListener('mousemove', mousemove);
this.removeEventListener('mouseup', mouseup);
}catch(err){
console.warn(err);
}
}
});
function mousemove(event) {
y = event.screenY - startY;
x = event.screenX - startX;
element.css({
top: y + 'px',
left: x + 'px'
});
}
function mouseup() {
$document.off('mousemove', mousemove);
$document.off('mouseup', mouseup);
}
};
})
/**
* try, http://plnkr.co/edit/HL9zaSlApLNMzN6OQlgg?p=preview
modules.json
[{
"name": "applications1",
"url": "^/templates/applications1",
"parent": "authenticated",
"abstract": false,
"views": [{
"name": "",
"templateUrl": "html/templates/basicLayout.html"
},
{
"name": "header@applications1",
"templateUrl": "html/templates/header.html"
}
]},
{
"name": "login",
"url": "/login",
"abstract": false,
"views": [{
"name": "",
"templateUrl": "html/admin/loginForm.html"
}]
}]
.provider('$frdlSMAddState', ['$stateProvider', function $frdlSMAddStateProvider( $stateProvider ) {
this.$get = function ($state, $stateParams, $rootScope){
var newState = $state;
try{
var getExistingState =$stateProvider.get(newState.name);
if(getExistingState !== null){
return getExistingState;
}
}catch(err){
}
var state = {
name : newState.name,
"url": newState.url,
"parent": newState.parent,
"abstract": newState.abstract,
"views": {}
};
frdl.a.forEach(state.views, function(view) {
state.views[view.name] = {
templateUrl: view.templateUrl,
};
});
$stateProvider.state( $.extend(state, newState));
return {
state,
$stateParams,
$rootScope
};
};
}])
*/
;
(function() {
function initNgFlows(element) {
var delay = 1000;
if(true !== frdl.angularBootstrapable())return frdl.UI.Compile(delay);
var moduleElements = frdl.$q('*[ng-flows]:not([flow-bootstrap-value="stop"])', true, element);
if(0===moduleElements.length)return;
for(var i = 0; i < moduleElements.length; i++) {
var moduleElement = moduleElements[i];
if(true !== frdl.angularBootstrapable())return frdl.UI.Compile(delay + 250);
if(moduleElement.hasAttribute('flow-bootstrap-value')){
if(new Date().getTime() - 30 * 1000 < parseInt(moduleElement.getAttribute('flow-bootstrap-value'))){
continue;
}
if(new Date().getTime() - 60 * 1000 > parseInt(moduleElement.getAttribute('flow-bootstrap-value'))){
if(moduleElement.getAttribute('ng-flows') === moduleElement.getAttribute('ng-bootstrapped')){
moduleElement.setAttribute('flow-bootstrap-value', 'stop' );
moduleElement.setAttribute('flow-bootstrap-stopped', new Date().getTime() );
continue;
}
}
if(moduleElement.getAttribute('ng-flows') === moduleElement.getAttribute('ng-bootstrapped')){
continue;
}
}
if(moduleElement.hasAttribute('ng-flow')){
moduleElement.setAttribute('ng-flows', ((moduleElement.hasAttribute('ng-flows')) ? moduleElement.getAttribute('ng-flows') + ',' : '') + moduleElement.getAttribute('ng-flow'));
continue;
}
if(moduleElement.hasAttribute('ng-app')){
moduleElement.setAttribute('ng-flows', ((moduleElement.hasAttribute('ng-flows')) ? moduleElement.getAttribute('ng-flows') + ',' : '') + moduleElement.getAttribute('ng-app'));
continue;
}
if(!moduleElement.hasAttribute('ng-flows'))continue;
var _m = str_replace(' ', '', moduleElement.getAttribute('ng-flows'));
if(''===_m)continue;
if( /* frdl.hasScope(moduleElement)
|| */
(
moduleElement.hasAttribute('ng-bootstrapped')
&& str_replace(' ', '', moduleElement.getAttribute('ng-bootstrapped') ).length >= _m.length
)
) {
continue;
}
var already =str_replace(' ', '', moduleElement.getAttribute('ng-bootstrapped') ).split(",");
/* var module = moduleElement.getAttribute('ng-flows').replace(/ /g,'').split(","); */
var mods = _m.split(","),
module = [];
var f = true, guiFound = false;
frdl.each(mods, function(i,m){
if(''===m)return true;
if(__GUID_ND__ === m)guiFound=true;
try{
if('object'!==typeof frdl.a.module(m))f=false;
}catch(err){
f=false;
if(1 < frdl.debug.mode())console.log('AngularJS Module "'+m+'" not loaded yet, skipping bootstrap...');
}
if(true === f && -1 === already.indexOf(m)){
module.push(m);
}
});
if(false===f){
frdl.UI.Compile(delay);
continue;
}
if(false === guiFound){
if(-1 === mods.indexOf(__GUID_ND__)){
moduleElement.setAttribute('ng-flows', moduleElement.getAttribute('ng-flows') + ',' + __GUID_ND__);
if(-1 === module.indexOf(__GUID_ND__))module.push(__GUID_ND__);
}
}
if( /* frdl.hasScope(moduleElement) || */ true !== frdl.angularBootstrapable()
/* || moduleElement.hasAttribute('ng-bootstrapped') */)
{
frdl.UI.Compile(delay +250);
continue;
}
var b = (moduleElement.hasAttribute('ng-bootstrapped')) ? html_entity_decode(moduleElement.getAttribute('ng-bootstrapped') )+ ',' : '';
$(moduleElement).trigger('beforebootstrap', [module, mods, already]);
moduleElement.setAttribute('ng-bootstrapped', htmlentities(b + module.join(',')));
frdl.a.bootstrap(moduleElement, module);
moduleElement.setAttribute('flow-bootstrap-value', new Date().getTime() );
if(moduleElement.getAttribute('ng-flows') === moduleElement.getAttribute('ng-bootstrapped')){
moduleElement.setAttribute('flow-bootstrap-value', 'stop' );
moduleElement.setAttribute('flow-bootstrap-stopped', new Date().getTime() );
}
$(moduleElement).trigger('bootstrapped', [module, mods, already]);
}
}
var c = 100;
frdl.UI.Compile = function(delay){
var Func = ('undefined' !== typeof webfan && 'function' === typeof webfan.$Async && false === webfan.$Async instanceof Promise)
? webfan.$Async
: setTimeout;
if(!!isNaN(delay))var delay=100;
c = c + 10;
if(100 > c)c=100;
if(5000 < c)c=5000;
if('complete'!==document.readyState || true !== frdl.angularBootstrapable()){
Func(function(){
frdl.ready(frdl.UI.Compile);
}, delay + c);
return;
}
Func(function(){
frdl.ready(function(){
frdl.a.element(document).ready(function() {
initNgFlows(document);
});
});
}, delay + 1);
};
}());
});
(function(){
'use strict';
frdl.UI.widgets = [];
var _i = -1;
(function(baseObj, funcName) {
funcName = funcName || "Widget";
function Widget(c){
var data = {};
var id = id=++_i;
/*
function Widget(config){
this.id=++_i;
return this.__construct(config);
}
Widget.prototype.__construct = function(config){
this.config = config;
return this;
};
*/
var config;
var __getConfig = function () {
var c = config;
return c;
};
var __setConfig = function (val) {
var _new = val, _old = config;
console.warn('Changing widget config is not supported yet (ToDo)');
var merged = $.extend(_old, _new);
/* e.g. config = merged ; */
};
var ReadOnly = function(v){
console.warn('Trying to set readonly Widget property FAILED: ' + v);
};
/* this.instantiated = true;
return this.__construct(config); */
config = c;
var defProp = false;
if(Object.defineProperty) {
defProp = true;
}else if(Object.prototype.__defineGetter__) {
this.__defineGetter__('config', function(){
return __getConfig();
} );
}else{
console.warn('Missing Object.defineProperty and Object.prototype.__defineGetter__ - Fallback to UNSAFE configuration readable!');
this.config = config;
}
if(Object.defineProperty) {
defProp = true;
}else if(Object.prototype.__defineSetter__) {
this.__defineSetter__('config', function(val){
return __setConfig(val);
} );
}else{
console.warn('Missing Object.defineProperty and Object.prototype.__defineSetter__ - Fallback to UNSAFE configuration writeable!');
this.config = config;
}
if(true === defProp){
Object.defineProperty(this, 'config', {
get : function(){ return __getConfig(); },
set : function(val){ return __setConfig(val); }
});
Object.defineProperty(this, 'id', {
get : function(){return id;},
set : function(val){ return ReadOnly(val); }
});
}else{
this.id = id;
}
}
Widget.prototype.getElement = function(){
return config.element;
};
Widget.prototype.getID = function(){
return this.id;
};
Widget.prototype.deploy = function(){
};
Widget.prototype.data = function(){
var args = Array.prototype.slice.call(arguments);
if(1 === args.length && 'object' === typeof args[0]){
for(var k in args[0]){
data[k]=args[0][k];
}
return this;
}else if(1 === args.length && 'string' === typeof args[0]){
return data[args[0]];
}else if(2 === args.length && 'string' === typeof args[0]){
data[args[0]] = args[1];
return this;
}else if(0 === args.length){
return data;
}else{
return undefined;
}
};
/*
Widget.prototype.instantiate = function(){
};
Widget.prototype.config = function(){
};
Widget.prototype.create = function(){
};
.$$on(run)
Widget.prototype.run = function(ev, data){
if(frdl.debug.mode() >0 )console.log(JSON.stringify(ev) +JSON.stringify(data) );
};
Widget.prototype.intent = function(){
};
Widget.prototype.flow = function(){
};
*/
baseObj[funcName]=Widget;
}(frdl, 'Widget'));
frdl.UI.getWidget = function(id){
var w = null;
/*
frdl.UI.widgets = frdl.filter(frdl.UI.widgets, function(w){
return 'undefined' !== typeof w;
}, false);
*/
if(!isNaN(parseInt(id))){
frdl.each(frdl.UI.widgets, function(i,wgt) {
if(parseInt(id)===wgt.getID()){
w = wgt;
return false;
}
});
}else if('string'===typeof id){
frdl.each(frdl.UI.widgets, function(i,wgt) {
var c = wgt.config;
if( id===c.widget.name._short
|| id===c.id
|| id===c.widget.name.__text
|| c.widget._id===id){
w = wgt;
return false;
}
;})
}else if('object' === typeof id || 'function'===typeof id){
w = frdl.UI.widgets[frdl.UI.widgets.indexOf(id)] || null;
if(null===w){
frdl.each(frdl.UI.widgets, function(i,wgt) {
if(id===wgt.getElement()){
w = wgt;
return false;
}
});
}
}
return w;
};
}());
/*
frdl.UI.widget -> methods (if invoked without argument)
frdl.UI.widget('<div></div>','frdl/webfan', $('body'), true);
*/
var _widget = {
createHtmlWrap : function(el, _link, dest, invokeIfExistsAlready){
var u = new frdl.Url(_link);
var tok = u.getScheme() + '://components/', widgetLoaded = false, eLoaded = false;
var url = u.urlMakeNew();
var component = str_replace(tok,'',url);
component = str_replace( u.getScheme() + '://example.com/','',component);
component = str_replace( 'widget://','',component);
if(true===invokeIfExistsAlready){
/*
var widget = frdl.UI.getWidget(component);
if(null!== widget && 'object'===typeof widget){
$(widget.element).trigger('run', widget.$scope);
return widget;
}
*/
var widgetFound = [];
frdl.each(document.querySelectorAll('*[data-frdl-component$="'+component+'"]'),function(i,widgetElement){
var widget = frdl.UI.getWidget(widgetElement.getAttribute('data-frdl-component-widget-id'));
if(null!==widget){
widgetFound.push(widget);
$(widgetElement).trigger('run', widget.$scope);
}
});
if(0<widgetFound.length){
return widgetFound;
}
}
if('undefined'===typeof dest)var dest = document.body/*querySelector('body')*/;
el = $(el)
/* .wrapAll('<frdl></frdl>') */
.attr('data-frdl-component', _link)
.attr('data-frdl-desktop-widget', _link)
.prependTo($(dest))
;
setTimeout(function(){
$(document).trigger('readystatechange');
},1);
}
};
frdl.UI.widget = function(el,_link, dest, invokeIfExistsAlready){
/* todo : move this to event-state !!! */
if('undefined' === typeof jQuery || 'undefined' === typeof $){
setTimeout(function(){
frdl.UI.widget(el,_link, dest, invokeIfExistsAlready);
},125);
console.warn('jQuery still undefined in frdl.UI.widget()');
return _widget;
}
if('object'===typeof el && el.hasAttribute('data-frdl-component-loaded-script') && 'true'===el.getAttribute('data-frdl-component-loaded-script')){
return;
}
if('undefined'===typeof el && 'undefined'===typeof _link && 'undefined'===typeof dest ){
return _widget;
}
if('string'===typeof el && '>' !== el.substr(-1)){
el = document.querySelector(el);
/* if('object'!==typeof el){
console.error('Cannot create widget');
return;
} */
} else if('string'===typeof el && '>' === el.substr(-1)){
return _widget.createHtmlWrap(el, _link, dest, invokeIfExistsAlready);
}
if('true' === el.getAttribute('data-frdl-component-initiated') ){
return;
}
var u = ('string'===typeof _link) ? new frdl.Url(_link) : new frdl.Url(el.getAttribute('data-frdl-component'));
var tok = u.getScheme() + '://components/', widgetLoaded = false, eLoaded = false;
var url = u.urlMakeNew();
var component = str_replace(tok,'',url);
component = str_replace( u.getScheme() + '://example.com/','',component);
component = str_replace( 'widget://','',component);
if(true===invokeIfExistsAlready){
var widget = frdl.UI.getWidget(component);
if(null!==widget && 'object'===typeof widget){
$(widget.element).trigger('run', widget.$scope);
return widget;
}
}
el.setAttribute('data-frdl-component-initiated', 'true');
if('components'===u.getHost() || 'example.com'===u.getHost()){
url = frdl.route('API_COMPONENT_MAIN', null, null, component);
url = str_replace('/app.js', '', url);
}else{
u.setScheme('http');
url = u.urlMakeNew();
}
url = str_replace( 'widget://','http://',url);
if('function'===typeof frdl_webfan_flow_advertising_external_linking){
frdl_webfan_flow_advertising_external_linking(new frdl.Url(url).getHost());
}
var widget_dir = url, createWidgetLink = true;
if(null === frdl.$q('*[href="'+widget_dir+'"]', false)){
createWidgetLink =true;
}else{
frdl.each(frdl.$q('*[href="'+widget_dir+'"]'), function(i,el){
if(__WIDGET_REL__ !== el.getAttribute('rel'))return true;
createWidgetLink=false;
return false;
});
}
if('/' !== url.substr(-1)){
url += '/';
}
frdl.UI.defer();
$.ajax( {
url: url + 'config.xml',
crossDomain: true,
cache:true,
headers: {'X-Requested-With': 'XMLHttpRequest'/*,
'Origin' : new frdl.Url().getScheme() + '://' + new frdl.Url().getHost() */
},
type: 'GET',
dataType: 'XML',
data: {}
} )
.done(function(response) {
frdl.UI.defer();
var module = module || global;
var config = module.widget = wjslX2JS.xml2json(response);
if('undefined'===typeof config.widget){
console.error('Cannot get config file of '+component);
return false;
}
config.directory = url;
/*
$( frdl.UI ).trigger( 'flow:widget:instantiate', [ el, component, config ] );
var widget = frdl.UI.getWidget(el.getAttribute('data-frdl-component-widget-id'));
$(el).on('run', {
widget:widget
}, function( event, data){
if(1<parseInt(frdl.debug.mode())) console.log('widgetElement run event...' + JSON.stringify(data));
});
*/
if(!config.widget.content.length){
config.widget.content=[config.widget.content];
}
var c=0;
frdl.each(config.widget.content, function(i, content){
c++;
frdl.UI.defer();
eLoaded=false;
var _url = (''!==new frdl.Url(content._src).getScheme()) ? '' : url;
if('text/javascript' === content._type || 'application/javascript' === content._type
|| 'application/x-javascript' === content._type ){
if('undefined'!==typeof content.__cdata){
webfan.$Async(function(){
try{
module.sourceUrl = url + 'config.xml#'+c;
eval(content.toString());
if(c===config.widget.content.length)eLoaded=true;
}catch(err){
console.error(err);
}
},1);
}
if('string'===typeof content._src){
/*
frdl.getScript(_url + content._src, function(){
if(c===config.widget.content.length)eLoaded=true;
}, (('once'===content['_data-frdl-require'])?true:false), false);
*/
require('5:'+_url + content._src, function(mod) {
if(c===config.widget.content.length)eLoaded=true;
}, null, 'application/x-javascript');
}
}else if('text/html' === content._type ){
if('undefined'!==typeof content.__cdata){
webfan.$Async(function(){
$( el ).append( content.toString() );
},250);
}
if('string'===typeof content._src){
require('5:'+_url + content._src, function(html) {
$( el ).append( html.content );
if(c===config.widget.content.length) eLoaded=true;
}, null, 'text/html');
}else{
if(c===config.widget.content.length) eLoaded=true;
}
}else if('text/css' === content._type ){
if('undefined'!==typeof content.__cdata){
$( el ).append( '<style type="text/css">'+content.toString() +'</style>');
}
if('string'===typeof content._src){
require('5:'+_url + content._src, function(css) {
if(c===config.widget.content.length)eLoaded=true;
try
{
var blob = new Blob([css.content], {type: 'text/css'});
} catch (e) {
var bb = new (window.WebKitBlobBuilder || window.MozBlobBuilder);
bb.append(css.content);
var blob = bb.getBlob('text/css');
}
var src = (window.webkitURL || window.URL).createObjectURL(blob);
frdl.getCSS( src, el, (('once'===content['_data-frdl-require'])?true:false) );
}, null, 'text/css');
}
if(c===config.widget.content.length)eLoaded=true;
}
});
widgetLoaded=true;
$( frdl.UI ).trigger( 'flow:widget:instantiate', [ el, component, config ] );
var widget = frdl.UI.getWidget(el.getAttribute('data-frdl-component-widget-id'));
$(el).on('run', {
widget:widget
}, function( event, data){
if(1<parseInt(frdl.debug.mode())) console.log('widgetElement run event...' + JSON.stringify(data));
});
if(true===createWidgetLink){
var lnk = frdl.Dom.create('link');
lnk.setAttribute('rel', __WIDGET_REL__);
lnk.setAttribute('href', widget_dir);
frdl.Dom.add(lnk, frdl.Dom.getTagNames('head')[0]);
}
frdl.addReadyCheck(function(){
return (true===widgetLoaded && true === eLoaded) ? true : false;
});
frdl.ready(function(){
/* el.setAttribute('data-frdl-component-loaded-script', 'true'); */
el.setAttribute('data-flow-widget', 'config.loaded');
frdl.UI.load();
frdl.UI.Compile(500);
frdl.UI.Compile(1500);
frdl.UI.load();
frdl.UI.Compile(5000);
webfan.$Async(function(){
$(el).trigger('run', [widget]);
$(document).trigger('readystatechange')
},1500);
});
})
.fail(function(jqXHR, textStatus) {
console.error('Error: ' + url + 'config.xml ' + jqXHR.status);
})
.always(function() {
if(1<parseInt(frdl.debug.mode()))console.log('Loading widget "' + component+'"...');
widgetLoaded=true;
});
};
frdl.ready(function(){
$( frdl.UI ).on( 'flow:widget:instantiate', {
engine : {
origin : new frdl.Url(frdl.__FILE__()).getScheme() + '://' + new frdl.Url(frdl.__FILE__()).getHost(),
state : 'dev'
},
site : {
origin : new frdl.Url().getScheme() + '://' + new frdl.Url().getHost(),
state : 'dev'
}
}, function( event, el, component, config ) {
config.element = el;
config.element.setAttribute('data-frdl-component-initiated', 'true');
/* var widget = f$(config); /* .flow...
if(true===frdl.wd().o.debug)alert(JSON.stringify(widget ));
*/
var Widget = new frdl.Widget(config);
frdl.$(Widget);
frdl.UI.widgets.push(Widget);
config.element.setAttribute('data-frdl-component-widget-id', Widget.id);
el.widget = function(){
return frdl.UI.getWidget(el.getAttribute('data-frdl-component-widget-id'));
};
$(el).on('run', function(ev, data){
Widget.$$run(ev, data);
});
/*
if('undefined'!==typeof frdl.wd() && 'undefined'!==typeof frdl.wd().o && true===frdl.wd().o.debug)console.log('Loading widget://'+JSON.stringify(Widget));
$( config.element ).trigger( 'flow:widget:create', [ component, Widget, event.data ] );
console.log('Test trigger widget event 1'); */
});
});
var renderFuncs = {
'forMobile' : function(){
var initialPageWrap = frdl.$q('body *[data-role="page"]');
if(0 === initialPageWrap.length){
$('body' ).wrapInner( '<div data-dom-cache="false" data-role="page" data-frdl-mod="nodesktop" id="nodesktop-'+ str_replace('.', '-', new frdl.Url().getHost()) + '-' + Sha1.hash(new frdl.Url().urlMakeNew()) + '-' + Sha1.hash(document.title) +'" style="top:0px;left:0px;right:0px;bottom:0px;height:auto;width:auto;"></div>' );
}
try{
console.log('Prepare for jqm');
if(true===frdl.UI.isMobileTheme){
console.warn('REDUNDANT: Prepare for jqm');
return;
}
frdl.watchFor('a[href*=":\/\/"]:not([data-flow-prepared-frdl-ajax-link-boddystripped*="true"]):not([frdl-ajax-link-boddystripped])').every(function(el){
/* frdl.watchFor('a[href]:not([data-flow-prepared="true"]):not([frdl-ajax-link-boddystripped])').every(function(el){*/
el.setAttribute('data-flow-prepared-frdl-ajax-link-boddystripped', 'true');
$(el).attr('rel', 'external');
});
webfan.$Async(function(){
$.mobile.pushStateEnabled = false;
$.mobile.hashListeningEnabled = false;
/* frdl.watchFor('a[ui-sref]:not([data-flow-prepared-ui-sref="true"]):not([frdl-ajax-link-boddystripped])').every(function(el){ */
frdl.watchFor('a[ui-sref]').every(function(el){
setTimeout(function(){
frdl.$j(el).attrAdd('data-flow-prepared', 'true');
$(el)
.attr('href', str_replace('##', '#',$(el).attr('href')))
.attr('href', str_replace('##', '#',$(el).attr('href')))
.attr('href', str_replace('##', '#',$(el).attr('href')))
.attr('href', str_replace('#', '',$(el).attr('href')))
.attr('href', '#'+$(el).attr('href'))
;
},750);
});
},250);
$('*[data-role="page"]').page({
create: function( event, ui ) {
$.mobile.pushStateEnabled = false;
$.mobile.hashListeningEnabled = false;
$.mobile.initializePage();
$.mobile.loading( 'hide' );
}
});
$('*[data-role="page"]').trigger('create');
/**/
setTimeout(function(){
$.mobile.pushStateEnabled = false;
$.mobile.hashListeningEnabled = false;
},800);
frdl.UI.isMobileTheme = true;
}catch(err){
console.error(err);
}
},
'forMinimal' : function(){
/* Deprecated data-mod-framed !!! */
$('*[data-mod-framed="no"]').hide();
$('*[data-mod-framed="yes"]').show();
$('*[data-wd-onreduce="hide"]').hide();
},
'forFullscreen' : function(){
/* Deprecated data-mod-framed !!! */
$('*[data-mod-framed="no"]').show();
$('*[data-mod-framed="yes"]').hide();
},
/*
Roko C. Buljan
http://stackoverflow.com/questions/6258521/clear-icon-inside-input-text
*/
'addClearableInputs' : function(){
console.deprecated('Using the jQuery plugin is prefered instead of addClearableInputs fn!');
frdl.Dom.createCSSClass('.flow-clearable', "background: #fff url('data:image/gif;base64,R0lGODlhBwAHAIAAAP///5KSkiH5BAAAAAAALAAAAAAHAAcAAAIMTICmsGrIXnLxuDMLADs=') no-repeat right -10px center; border: 1px solid #999; padding: 3px 18px 3px 4px; border-radius: 3px; transition: background 0.4s;");
frdl.Dom.createCSSClass('.flow-clearable.x', "background-position: right 5px center;");
frdl.Dom.createCSSClass('.flow-clearable.onX', "cursor: pointer;");
frdl.Dom.createCSSClass('.flow-clearable.-ms-clear', "display: none; width:0; height:0;");
function tog(v){return v?'addClass':'removeClass';}
$(document).on('input', '.flow-clearable', function(){
$(this)[tog(this.value)]('x');
}).on('mousemove', '.x', function( e ){
$(this)[tog(this.offsetWidth-18 < e.clientX-this.getBoundingClientRect().left)]('onX');
}).on('touchstart click', '.onX, .x', function( ev ){
ev.preventDefault();
$(this).removeClass('x onX').val('').change();
});
$('*[data-clear-btn="true"]').addClass("flow-clearable");
$('.flow-clearable').trigger("input");
},
'inputSearchPolyfill':function(){
/*
* https://github.com/dwiyatci/jquery-inputsearch
* License: WTFPL https://raw.githubusercontent.com/dwiyatci/jquery-inputsearch/master/WTFPL-LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
*/
/**
* jQuery plugin for automagically transforming `input[type="text"]` elements
* into `input[type="search"]`-like elements.
* @author Glenn Dwiyatcita
* @date 20.08.2015
* @version 0.2.0
*/
(function ($) {
$.fn.inputSearch = function (options) {
var elements = this,
searchIconImgData = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg' +
'AAABAAAAAQCAQAAAC1+jfqAAAASklEQVR42mNwZcAPGe' +
'itQMn1PxwqYVMAktAHQxALqwJ9V15XDiDWx62AA0hzYF' +
'egjt8ESajjcLhBCsn9WH0BEdTBHQ4gackBigsAp89pbW' +
'KQMm4AAAAASUVORK5CYII=',
clearIconImgData = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg' +
'AAABAAAAAQCAQAAAC1+jfqAAAAdklEQVR42pWRPQ7AIA' +
'iFuVknFk9hwuxZXBwdvCkFa9X607R5Azzel6gICO+C74' +
'DBhFyUxA2Aq+Et1wNmilWmATEPSDqtIJ3W2AAugUb0nP' +
'QAl5CqnwCbnd0BV2hXR4TlJUMDcPlM7BdFU0zjqg/0Nf' +
'Ti/n/WRic9QaXT/imcNgAAAABJRU5ErkJggg==';
options = $.extend({
searchIconVisible: true,
onClear : $.noop
}, options);
var observer = null;
if (window.MutationObserver) {
observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
$(mutation.target).data()
.refreshWrapperVisibility();
});
});
}
return elements
.filter('input')
.each(function () {
var wrapper = $('<div>')
.addClass('jis-input-wrapper')
.css({
display : 'inline-block',
position: 'relative'
});
var icon = $('<img>')
.attr({
src : searchIconImgData,
'class': 'jis-icon-search'
})
.css({
position : 'absolute',
width : 16,
height : 16,
visibility: options.searchIconVisible ?
'visible' : 'hidden'
})
.on('click', function () {
if ($(this).hasClass('jis-icon-clear')) {
i
.val('')
.focus()
.triggerHandler('input');
options.onClear();
}
});
var i = $(this)
.data({
refreshWrapperVisibility: function () {
i.parent('.jis-input-wrapper').css({
display : i.css('display'),
visibility: i.css('visibility'),
opacity : i.css('opacity')
});
}
})
.on('input', function () {
var query = $(this).val(),
src = icon.attr('src');
if (query.length > 0) {
if (src !== clearIconImgData) {
icon
.attr('src', clearIconImgData)
.toggleClass('jis-icon-search', false)
.toggleClass('jis-icon-clear', true)
.css({
cursor : 'pointer',
visibility: 'visible'
});
}
} else {
if (src !== searchIconImgData) {
icon
.attr('src', searchIconImgData)
.toggleClass('jis-icon-search', true)
.toggleClass('jis-icon-clear', false)
.css({
cursor : 'auto',
visibility: options.searchIconVisible ?
'visible' : 'hidden'
});
}
}
})
.wrap(wrapper)
.after(icon);
var visible = i.is(':visible');
i.show();
var gutter = 4,
paddingRight = icon.outerWidth() + gutter,
width = parseFloat(i.css('width')),
adjustedWidth = width - paddingRight,
position = i.position();
i.css({
width : adjustedWidth,
paddingRight: paddingRight
});
icon.css({
top : position.top + (gutter / 2),
left: position.left + adjustedWidth + gutter
});
/*if (null!==observer) {
try{
observer.observe(i, { attributeFilter: ['style'] });
}catch(err){
if(0<frdl.debug.mode()){
console.error(err);
}else{
console.warn(err);
}
}
} else { */
var _I =function () {
try{
if('function'===typeof i.data().refreshWrapperVisibility) i.data().refreshWrapperVisibility();
}catch(err){
clearInterval(_I);
}
};
setInterval(_I, 200);
/*}*/
if (!visible) {
i.hide();
}
i.triggerHandler('input');
});
};
}(jQuery));
frdl.watchFor('*[data-search-btn="true"]:not([data-flow-prepared*="true"])').every(function(el){
frdl.$j(el).attrAdd('data-flow-prepared', 'true');
$(el).inputSearch({ searchIconVisible: true});
});
frdl.watchFor('*[data-clear-btn="true"]:not([data-flow-prepared*="true"])').every(function(el){
frdl.$j(el).attrAdd('data-flow-prepared', 'true');
$(el).inputSearch({ searchIconVisible: false});
});
}
/*eo inputSearchPolyfill */
,'default' : function(){
}
};
frdl.UI.rendering = function(o){
if('string' === typeof o){
o = {
action : o
};
}else if('function' === typeof renderFuncs[o.action]){
o=o;
}else {
o = {
action : 'default'
};
}
renderFuncs[o.action]();
return frdl.UI;
};
frdl.ready(function(){
frdl.UI.rendering('inputSearchPolyfill');
});
if('function' !== typeof frdl.lang){
frdl.lang = function(langStrings, allSelectors, registeredSelectors){
frdl.getScript(frdl.route('API_COMPONENT_MAIN', null, null, 'locale'), function(){
frdl.ready(function(){
frdl.lang(langStrings, allSelectors, registeredSelectors);
});
}, true, false);
};
}
if('function' !== typeof frdl.translate){
frdl.translate = function(lang, allSelectors, registeredSelectors){
frdl.getScript(frdl.route('API_COMPONENT_MAIN', null, null, 'locale'), function(){
frdl.ready(function(){
frdl.translate(lang, allSelectors, registeredSelectors);
});
}, true, false);
};
}
if('function' !== typeof frdl.langstr){
frdl.langstr = function(modul){
frdl.getScript(frdl.route('API_COMPONENT_MAIN', null, null, 'locale'), function(){
frdl.ready(function(){
frdl.langstr(modul);
});
}, true, false);
};
}
window.addEventListener("online", function() {
/* */
console.log('Welcome back online...!');
}, true);
window.addEventListener("offline", function() {
var str = "You're now offline. The application may not work as expected until you go online again.";
if(0<parseInt(frdl.debug.mode())){
alert(str);
}
console.log(str);
}, true);
window.addEventListener("beforeunload", function() {
var debugmode = frdl.debug.mode();
if(null===debugmode || undefined=== debugmode || isNaN(debugmode))debugmode=0;
if('undefined'!==typeof frdl && 'undefined'!==typeof frdl.$DB)frdl.$DB.save('settings/debugmode', parseInt(frdl.debug.mode()));
}, true);
(function(){
frdl.ready(function(){
webfan.$Async(function(){
var debugmode = frdl.$DB.load('settings/debugmode');
if(null===debugmode || undefined=== debugmode || isNaN(debugmode))debugmode=0;
if(!isNaN(debugmode)){
frdl.debug.mode(parseInt(debugmode));
if(0<parseInt(debugmode)){
$(document).ready(function(){
frdl.alert.log('DEBUG ENABLED ('+frdl.debug.mode()+')');
});
}
}
},250);
});
}());
/*
frdl.addReadyCheck(function(){
return ('complete' === document.readyState) ? true : false;
});
*/
(function(){
frdl.watchFor('iframe:not([frdl-nwtrusted])').every(function(el){
frdl.$j(el).attrAdd('data-flow-prepared', 'true');
$(el)
.attr('nwdisable', 'true')
.attr('nwfaketop', 'true')
;
});
frdl.ready(function(){
var obs = frdl.watchFor('*[data-frdl-component*=":"]:not([data-frdl-component-initiated="true"])').every(function(el){
frdl.UI.widget(el);
});
});
/* frdl.UI.rendering('default');
document.addEventListener("mobileinit", function(){
$.extend( $.mobile , frdl.UI.o.jQueryMobile.o);
});*/
$( window ).one( "mobileinit", function() {
$.extend( $.mobile , frdl.UI.o.jQueryMobile.o);
});
frdl.ready(function(){
frdl.UI.load();
var loadComponents = function(opts){
frdl.each(frdl.$q('*[data-frdl-component*=":"]:not([data-frdl-component-initiated="true"])'), function(i,el){
if('true'===el.getAttribute('data-frdl-component-initiated') || 'config.loaded'===el.getAttribute('data-flow-widget')
|| 'true'===el.getAttribute('data-frdl-component-loaded-script') ){
return;
}
var url = null;
var u = new frdl.Url(el.getAttribute('data-frdl-component'));
var tok = u.getScheme() + '://components/';
var component = str_replace(tok,'',el.getAttribute('data-frdl-component'));
var version = el.getAttribute('data-frdl-component-version');
if('string' === typeof version && '' !== version && '*' !== version && 'master' !== version && 'dev-master' !== version)component += '/' + version;
var version_query = el.getAttribute('data-frdl-component-version_query');
/* <a rel="widget"
href="http://example.org/exampleWidget">
The Example Widget
</a>
$( el ).wrapAll( "<frdl></frdl>" );
*/
if(''===u.getScheme()){
url = component + (2>(explode('.',u.getFile()).length) ? '/app.js' : '');
}else if('flow' === u.getScheme()){
url = frdl.route('API_COMPONENT_MAIN', null, null, component);
} else if('widget' === u.getScheme()){
return frdl.UI.widget(el);
}
console.log('You SHOULD use the widget:// flow as the flow:// scheme has limited functionallity! ('+url+')');
var widget_dir = str_replace('/app.js', '', url), createWidgetLink = true;
if(0 === document.querySelectorAll('*[href="'+widget_dir+'"]').length){
createWidgetLink =true;
}else{
frdl.each(frdl.$q('*[href="'+widget_dir+'"]'), function(i,el){
if(__WIDGET_REL__ !== el.getAttribute('rel'))return true;
createWidgetLink=false;
return false;
});
}
if(true===createWidgetLink){
var lnk = frdl.Dom.create('link');
lnk.setAttribute('rel', __WIDGET_REL__);
lnk.setAttribute('href', widget_dir);
frdl.Dom.add(lnk, frdl.Dom.getTagNames('head')[0]);
}
if('string' === typeof version_query && '' !== version_query){
var u=new frdl.Url(url);
u.setParam('version', version_query);
url=u.urlMakeNew();
}
if(null!==url){
frdl.getScript(url, function(){
el.setAttribute('data-frdl-component-loaded-script', 'true');
frdl.ready(function(){frdl.UI.Compile(100)});
}, false, false);
}
});
};
/*
setTimeout(function(){
loadComponents({});
},1);
*/
frdl.Hash.pushState(false);
frdl.Hash.on('/app=([A-Za-z0-9_-]+)', function(path, parts) {
if(frdl.debug.mode() >1 )console.log('Loading workspace, app: '+ parts[1]);
frdl.wd(true);
});
frdl.ready(function(){
frdl.UI.Compile(500);
document.addEventListener('readystatechange', frdl.UI.Compile) ;
setTimeout(function(){
loadComponents({});
},250);
document.addEventListener('readystatechange', function(){
setTimeout(function(){
frdl.ready(loadComponents);
},100);
}) ;
});
});
/*
window.addEventListener("hashchange", function(){
setTimeout(function(){
$(document).trigger('readystatechange') ;
},1);
});
*/
/* frdl.ready(function(){ */
$(document).ready(function(){
if(true===frdl.UI.reduced()){
frdl.UI.rendering('forMinimal');
}else{
frdl.UI.rendering('forFullscreen');
}
if( /* false === frdl.Device().isDesktop
|| true === frdl.Device().frdlApp
|| true === frdl.Device().isApp*/
(true === frdl.Device().isTouchable && 'Explorer' !== frdl.Device().browser)
|| true === frdl.Device().isMobile
|| true === frdl.Device().isTablet
|| true === navigator.isMobile
|| true === navigator.isTablet
/* || false === frdl.Device().isDesktop */
){
frdl.UI.rendering('forMobile');
}
});
/* }); */
}());
frdl.UI.emitter.once('boot gui components', function(){
console.log('boot gui components');
console.dir(this);
console.dir(arguments);
frdl.ready(function(){
webfan.$Async(function(){
if('undefined' === typeof frdl.UI.progress){
$('body').prepend('<webfan name="webfan/progressbar" type="widget"></webfan>');
}
},500);
});
});
(function(){
'use strict';
var _clean_frdl = frdl;
var _clean_webfan = frdl.overload(webfan);
frdl.noConflict = function() {
return _clean_frdl;
};
webfan.noConflict = function() {
return _clean_webfan;
};
}());
require.state.emit('resolved', {
identifier : 'frdl.UI',
module : frdl.UI
});
require.state.emit('resolved frdl.UI', {
identifier : 'frdl.UI',
module : frdl.UI
});
}(typeof exports !== 'undefined' ? global : (typeof this !== 'undefined' ? this : window)));
|