File: cdn/frdl/flow/ui/frdlui.js

Recommend this page to a friend!
  Classes of Till Wehowski   .Flow   cdn/frdl/flow/ui/frdlui.js   Download  
File: cdn/frdl/flow/ui/frdlui.js
Role: Class source
Content type: text/plain
Description: Class source
Class: .Flow
General purpose library of objects
Author: By
Last change: Update frdlui.js
Date: 6 years ago
Size: 100,977 bytes
 

Contents

Class file image Download
/* webfan (C) Till Wehowski, Webfan.de - All rights reserved. */ (function () { "use strict"; (function () { 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'), pushStateEnabled : frdl.route('jQueryMobile.pushStateEnabled'), ajaxEnabled: frdl.route('jQueryMobile.ajaxEnabled'), linkBindingEnabled : frdl.route('jQueryMobile.linkBindingEnabled'), hashListeningEnabled : frdl.route('jQueryMobile.hashListeningEnabled') }; 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 = frdl.str_replace(__TOK_DEFER__, '', window.name); }else if(false===a){ window.name = __TOK_DEFER__ + frdl.str_replace(__TOK_DEFER__, '', window.name); } _on= (window.name !==frdl.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 reqUI = 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.$( $.extend(new frdl.EventEmitter(), { o :{ DBPFX : DBPFX, LOCAL_MACHINE_CURRENT_USER : (JSON.parse( base64_decode( localStorage.getItem(DBPFX + 'LOCAL_MACHINE_CURRENT_USER/') )) || 'anonymous'), Main : { StatusBarStyle : 'lightblue' }, jQueryMobile : { o: $.extend({ loadingMessage : 'Loading...', pageLoadErrorMessage : 'Error Loading Page', allowCrossDomainPages : true, defaultPageTransition : 'fade', overlayTheme: "d", theme : 'd', pageLoadErrorMessageTheme : 'e' }, jQueryMobile) }, jQueryUI : { req : function(callback, args){ return reqUI(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.Url = new frdl.Url(file); s.__DIR__ = s.Url.getScheme() + '://' + s.Url.getHost() + '/' + s.Url.getDirectory(); return s; }, browse : function(url, title){ var jDialogBox = frdl.$q('*[id="wd-dialogs-box"]', false); if('function'===typeof window.Tabs){ window.Tabs().addTab((title || ''), url, null, 'browser', true, undefined, true); }else if('function'===typeof window.top.Tabs && 'function'===typeof window.top.Tabs().addTab){ window.top.Tabs().addTab((title || ''), url, null, 'browser', true, undefined, true); }else if(null!==jDialogBox){ $(jDialogBox).wd_dialogs({loadUrl : url, title : (title || '')}); }else{ webfan['$win open'](url); } }, fetchAngularFrdlForm : function(id, scopeOffset){ //<frdl-form frdl-form-id="newproject"><select ng-model="newproject.type"> var Form = {}; frdl.each(frdl.$q('*[ng-model]', true, frdl.$q('*[frdl-form-id="'+id+'"]', false)), function(i, el){ var a = el.getAttribute('ng-model'); var m = frdl.explode('.',a); if(null!==m && !isNaN(scopeOffset) && scopeOffset>0){ m.slice(0, scopeOffset); } var s = (null!==m) ? m.join('.') : a; if('SELECT'===$(el).prop('tagName')){ try{ Form[s]=el.options[el.selectedIndex].value || null; }catch(err){ try{ Form[s]=el.options[0].value || null; }catch(err){ Form[s]=null; } } return true; } Form[s]=el.value || null; }); return Form; } }) ).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($) { $.fn.getAngularApp = function(el, isolateFrdlTag){ var at = 'ng-flows', n; if(el && 'boolean'!==typeof el){ n = el; }else{ n = this; } if('boolean'!==typeof isolateFrdlTag && 'boolean'===typeof el){ var isolateFrdlTag = el; } if(true===isolateFrdlTag && 'FRDL' === $(n).prop("tagName")){ var _flows = $(n).getAngularApp(false); var _has = $(n).attr('ng-flows'); $(n).data('$injector', ''); if('string'!==typeof _has || ''=== _has)frdl.$j(n).attrAdd('ng-flows',_flows.flows||'webfan.gui'); } var flows = $(n).attr(at); if('string' ===typeof flows && '' !== flows){ return { element : n, flows : flows }; } if('HTML' === $(n).prop("tagName")) return false; return $(n).parent().getAngularApp(isolateFrdlTag); }; }(jQuery)); }()); (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(){ 'use strict'; var obs = frdl.watchFor('frdl').every(function(el){ el.setAttribute('ng-non-bindable', 'non-bindable'); }); }()); (function(){ 'use strict'; frdl.watchFor('*[resizable]').every(function(el){ frdl.UI.o.jQueryUI.req(function(e){ $(e).resizable(); }, el); }); }()); (function(){ 'use strict'; function cmd_webfan(cmd){ frdl.c(cmd, function(err, data){ if(err){ frdl.alert.error(err); return; } var util = require('util'); frdl.alert.log('<div>'+util.inspect(data)+'</div>'); }, true, frdl); } frdl.watchFor('*[flow-mod="command-line"]:not([data-flow-prepared*="listeners"])').every(function(el){ frdl.$j(el).attrAdd('data-flow-prepared', 'listeners'); var _onKeySubmit = function(event){ if(event.which === 13) { event.preventDefault(); event.stopPropagation(); frdl.each(['http', 'https', 'filesystem:'], function(i, scheme){ if(scheme===el.value.substr(0,scheme.length)){ frdl.UI.browse(el.value,new frdl.Url(el.value).getHost() ); el.value=''; return false; } }); if('string'===typeof el.value && ''!==el.value.trim()){ cmd_webfan(el.value); el.setAttribute('placeholder', el.value); el.value=''; return false; } return false; } }; el.addEventListener('keydown', _onKeySubmit); el.addEventListener('keypress', _onKeySubmit); }); }()); /* browse : function(url, title) (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(){ 'use strict'; 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); frdl.$j(el).attrAdd('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(){ 'use strict'; 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(){ 'use strict'; 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'); var n = el.getAttribute('name'); if(''=== new frdl.Url(n).getScheme()){ $(el).html('<div data-frdl-component="widget://example.com/'+el.getAttribute('name')+'"></div>') ; }else{ $(el).html('<div data-frdl-component="'+el.getAttribute('name')+'"></div>') ; } // $(document).trigger('readystatechange'); return true; }); }()); (function(){ 'use strict'; 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; if(el.hasAttribute('target') && '_blank' === el.getAttribute('target'))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); webfan.$Async(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) { var str = 'Cannot frdl-ajax-link-boddystripped: ' + url + ' ' + jqXHR.status+ ' '+textStatus; if(1 < frdl.debug.mode() && frdl.alert)frdl.alert.error(str); console.warn(str); window.location.href=url; }).always(function() { }); return false; }); }); (function(){ 'use strict'; (function(){ var scriptNodes = {}; function ky(src, inline){ return src.toString().length + '.' + inline.length + '.' + frdl.Sha1.hash(src.toString() + inline); } function emitState(type, error, state, k, stateId, stateTag, module, moduleStateTag, scriptNode){ var _state = { state : state, error : error, 'id ts s' : k, stateTag : { 'id ts c' : stateId, error : error, moduleStateTag : module } }; var State = { type : type, state : _state, scriptNode : scriptNode }; frdl.UI.emit(State); frdl.UI.emit('html-tag-typescript', type, State); } function compileTypeScriptElement(){ var el = arguments[0]; if('true' === el.getAttribute('data-flow-prepared'))return; if('true' === el.getAttribute('data-flow-parsed'))return; el.setAttribute('data-flow-prepared', 'true'); el.setAttribute('data-flow-parsed', 'true'); console.log('compileTypeScriptElement()'); var src = (el.hasAttribute('src') ) ? el.getAttribute('src') : false; if(''===el.innerHTML && false ===src){ if(0< frdl.debug.mode())console.notice('Empty typescript tag ignored'); return; } var k = ky(src, el.innerHTML); if('undefined'===typeof scriptNodes[k])scriptNodes[k] = []; var scriptNode = { hash : k, 'id ts s' : k, element : el }; scriptNodes[k].push(scriptNode); emitState('html-tag-typescript before compile', false,'pending', k, ky(location.href, el.innerHTML), 'state before', '@hidden', 'global scope', scriptNode); var compiler = frdl.require.getCompiler('application/typescript'); var AnchorPrefix = '#@ts!'; var module = new TModule(frdl.main); module.sourceURL = (false===src) ? location.href : src; var inlinecode = el.innerHTML; var headercode = frdl.require('5:http://'+frdl.route('HOST_CDN_PUBLIC_FRDL')+'/cdn/application/webfan/node_modules/webfan/frdl.d.ts.txt', false, frdl.require.getCompiler('text/plain'), 'text/plain').content; if(false ===src){ (function(){ var module = new TModule(location.href); module.descriptor = module.resolve(location.href); module.parent = arguments[0]; module.sourceURL = location.href + AnchorPrefix +k; module.source = compiler('\n' + headercode + '\n' +inlinecode, module); try{ module = eval(module.source); var error = false; var state = 'resolved'; }catch(err) { module = undefined; console.error(err); var error = err; var state = 'rejected'; } emitState('html-tag-typescript after finaly', error, state, k, ky(location.href + '#@' + module.sourceURL, inlinecode), 'state after', module, 'module exports : Void', scriptNode); }(frdl.main)); }else{ module.require('5:'+src, function(){ var module = new TModule(location.href); module.descriptor = module.resolve(location.href); module.parent = arguments[0]; module.sourceURL = location.href + AnchorPrefix +k; module.source = compiler('\n' + headercode + '\n' + inlinecode, module); try{ module = eval(module.source); var error = false; var state = 'resolved'; }catch(err) { module = undefined; console.error(err); var error = err; var state = 'rejected'; } emitState('html-tag-typescript after finaly', error, state, k, ky(location.href + '#@' + module.sourceURL, arguments[0].source + inlinecode), 'state after', module, 'module exports : Void', scriptNode); }, compiler, 'application/typescript'); } } (function o(){ frdl.each(frdl.$q('script[type*="typescript"]:not([data-flow-parsed="true"])'), function(i, el){ compileTypeScriptElement(el); }); webfan.$Async(function(){ o(); },10000); }()); var obs = frdl.watchFor('script[type*="typescript"]:not([data-flow-parsed="true"])').every(function(el){ compileTypeScriptElement(el); }); }()); }()); (function(){ 'use strict'; 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(1===2&&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[rel="manifest"]', false)){ frdl.UI.isWebApp = true; }else{ frdl.UI.isWebApp = false; } }()); (function() { 'use strict'; function b(){ /* 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; }, 1); }; } }; }); frdl.a.module(__APP_NS__, ['frdl']); frdl.a.module(__GUID_ND__, [__APP_NS__ , 'ngTouch', 'csrf-cross-domain', 'oc.lazyLoad', 'ui.router']) .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 }; }; }]) */ ; }//eo b() if('undefined'!== typeof frdl.a && 'function'===typeof frdl.a.module && 'function'===typeof frdl.a.bootstrap){ b(); }else{ frdl.require.state.once('resolved 1:libraries/angular/angular', function(){ webfan.$Async(function() { b(); },1); }); } }()); (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 = frdl.str_replace(' ', '', moduleElement.getAttribute('ng-flows')); if(''===_m)continue; if( /* frdl.hasScope(moduleElement) || */ ( moduleElement.hasAttribute('ng-bootstrapped') && frdl.str_replace(' ', '', moduleElement.getAttribute('ng-bootstrapped') ).length >= _m.length ) ) { continue; } // var already =frdl.str_replace(' ', '', moduleElement.getAttribute('ng-bootstrapped') ).split(","); var already =(true===moduleElement.hasAttribute('ng-bootstrapped'))?moduleElement.getAttribute('ng-bootstrapped').split(/\s+|,/):[]; /* var module = moduleElement.getAttribute('ng-flows').replace(/ /g,'').split(","); */ var mods = ('string'===typeof _m) ? _m.split(/\s+|,/) : [], 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'; var uiwidgets = []; try { Object.defineProperty(frdl.UI, 'widgets', { 'get':function() { console.deprecated('direct access of frdl.UI.widgets is deprecated, use the wrappers instead'); return uiwidgets; } }); }catch (e){ frdl.UI.widgets = uiwidgets; } var _a_bootstrapped = []; var _i = -1; (function(baseObj, funcName) { funcName = funcName || "Widget"; function Widget(widgetXMLObject){ var data = {}; var id = id=++_i; this.state = new frdl.EventEmitter(); /* function Widget(config){ this.id=++_i; return this.__construct(config); } Widget.prototype.__construct = function(config){ this.config = config; return this; }; */ this.state.emit('init', {id:id}); var WidgetXMLObject = widgetXMLObject; var c = WidgetXMLObject.json; var config; var _installed = false; var __getConfig = function () { var c = config; return c; }; var _html = []; var modules = {}; 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); }; config = c; var defProp = (Object.defineProperty) ? true : false; try{ if(!!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); } }); Object.defineProperty(this, 'modules', { get : function(){return modules;}, set : function(val){ throw 'Unexpected set of Widget.modules from external'; //modules = val; } }); Object.defineProperty(this, 'installed', { get : function(){ return _installed; } }); Object.defineProperty(this, 'XMLDom', { get : function(){ return WidgetXMLObject.dom; } }); Object.defineProperty(this, 'directory', { get : function(){ return config.directory; } }); Object.defineProperty(this, 'widget', { get : function(){ return __getConfig(); }/*, set : function(val){ return __setConfig(val); } */ }); Object.defineProperty(this, 'element', { get : function(){ return config.element; }, set : function(val){ config.element=val; } }); Object.defineProperty(this, 'name', { get : function(){ return __getConfig().name._short; }, set : function(val){ throw 'Illegal set of Widget.name '+val; } }); } }catch(err){ defProp = false; } if(true !== defProp){ if(Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) { this.__defineGetter__('config', function(){ return __getConfig(); } ); /* this.__defineSetter__('config', function(val){ return __setConfig(val); } ); */ this.__defineGetter__('installed', function(){ return installed; } ); this.__defineGetter__('id', function(){ return id; } ); this.__defineGetter__('modules', function(){ return modules; } ); this.__defineSetter__('modules', function(val){ // modules=val; throw 'Unexpected set of Widget.modules from external'; } ); this.__defineGetter__('XMLDom', function(){ return WidgetXMLObject.dom; } ); this.__defineGetter__('directory', function(){ return config.directory; } ); this.__defineGetter__('widget', function(){ return __getConfig(); } ); this.__defineGetter__('element', function(){ return config.element; } ); this.__defineSetter__('element', function(val){ config.element=val; } ); this.__defineGetter__('name', function(){ return __getConfig().name._short; } ); this.__defineSetter__('name', function(val){ throw 'Illegal set of Widget.name '+val; } ); }else{ console.warn('Missing Object.defineProperty and Object.prototype.__defineGetter__ - Fallback to UNSAFE configuration readable!'); this.config = config; this.id = id; this.XMLDom = WidgetXMLObject.dom; this.directory = config.directory; this.widget=config; this.element = config.element; this.modules=modules; this.name=__getConfig().name._short; } } this.angular = { boot : function(THAT){ frdl.UI.defer(); if(0 === THAT.angular.modules.length){ if(0 < THAT.angular.blocks.config.length || 0 < THAT.angular.blocks.controller.length || 0 < THAT.angular.blocks.run.length ){ // console.warn('Widget angular blocks defined but no parent ng-flows found'); if(null===frdl.$q('*[ng-flows]', false, THAT.element)){ var appname = 'WidgetApp' + frdl.str_replace('-', '', frdl.Guid.newGuid()); frdl.a.module(appname, ['webfan.gui']); THAT.angular.modules.push(appname); }else{ // $(config.element).data('$injector', ''); } }else{ return frdl.UI.load(); } } (function(THAT){ function b(THAT){ // if( !!frdl.hasScope(config.element) )return; var b = true; if(0===THAT.angular.blocks.config.length && 0===THAT.angular.blocks.controller.length && 0===THAT.angular.blocks.run.length){ return frdl.UI.load(); } if(0===THAT.angular.modules.length){ THAT.angular.modules.push('webfan.gui'); // return; } var app = THAT.angular.modules[0]; if(-1!== _a_bootstrapped.indexOf(config.widget._id + '___' + app)) b = false; _a_bootstrapped.push(config.widget._id + '___' + app); //b=true; // console.dir(app); if(!!b){ frdl.each(THAT.angular.blocks.config, function(i, block){ frdl.a.module(app).config(block); }); frdl.each(THAT.angular.blocks.controller, function(i, block){ frdl.a.module(app).controller(block[0], block[1]); }); frdl.each(THAT.angular.blocks.run, function(i, block){ frdl.a.module(app).run(block); }); } $(THAT.element).data('$injector', ''); // config.element.setAttribute('ng-flows', THAT.angular.modules.join(',')); THAT.element.setAttribute('ng-bootstrapped', frdl.htmlentities(THAT.angular.modules.join(','))); frdl.a.bootstrap(THAT.element, THAT.angular.modules); frdl.UI.load(); THAT.state.emit('agularify', { agularify: THAT.angular, app : frdl.a.module(app) }); } b(THAT); }(THAT)); }, modules : [], element : false, blocks : { config : [], controller : [], run : [] }, config : function(block){ THAT.angular.blocks.config.push(block); }, controller : function(name, block){ THAT.angular.blocks.controller.push([name, block]); }, run : function(block){ THAT.angular.blocks.run.push(block); }, flow : function(app){ THAT.angular.modules.unshift(app); var args = Array.prototype.slice.call(arguments); (function(){ function c(){ frdl.a.module.apply(frdl.a, args); } if(frdl.a && 'function'===typeof frdl.a.module){ c(); }else{ frdl.require.state.once('resolved 1:libraries/angular/angular', function(){ c(); }); } }()); } }; var THAT = this; //var _angularApp = $(config.element).getAngularApp(true); var _angularApp = $(config.element).getAngularApp(false); // console.dir(_angularApp); if(false !== _angularApp){ this.angular.element = _angularApp.element; var _appstr = _angularApp.flows; if(false !== _appstr){ frdl.each(_appstr.split(/s+|,/), function(i, appname){ appname = appname.trim(); THAT.angular.modules.push(appname); }); } }else{ // this.angular.element = config.element; } this.state.emit('agularify.init', { agularify: this.angular }); this.html = function(str){ if(!arguments || 0 === Array.prototype.slice.call(arguments).length)return _html; _html.push(str); this.state.emit('html.append', { html: str }); return this; }; this.modul = function(){ var args = Array.prototype.slice.call(arguments); if(0 === args.length || 2 < args.length) throw 'WebApp.modul() expects 1 or 2 arguments!'; if(1===args.length){ return modules[args[0]]; }else if(2 === args.length){ modules[args[0]] = args[1]; this.state.emit('modul', { modul: modules[args[0]] }); return this; } return this; }; this.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; } }; uiwidgets.push(this); } Widget.prototype.boot = function(){ function b(_THAT){ var THAT = _THAT; frdl.UI.defer(); frdl.UI.defer(); THAT.state.emit('boot', { widget: THAT }); frdl.UI.defer(); frdl.each(THAT.html(), function(i, html){ $(THAT.widget.element).append(html); }); frdl.UI.defer(); THAT.angular.boot(THAT); frdl.UI.load(); THAT.state.emit('loaded', { widget: THAT }); } if(frdl.a && 'function'===typeof frdl.a.module && 'function'===typeof frdl.a.bootstrap){ b(this); }else{ var T = this; frdl.require.state.once('resolved 1:libraries/angular/angular', function(){ b(T); }); } return this; }; Widget.prototype.on = function(){ this.state.on.call(this, arguments); return this; }; Widget.prototype.once = function(){ this.state.once.call(this, arguments); return this; }; Widget.prototype.emit = function(){ this.state.emit.call(this, arguments); return this; }; Widget.prototype.dependency = function(){ this.state.required.call(this, arguments); return this; }; Widget.prototype.getElement = function(){ return this.element; }; Widget.prototype.getID = function(){ return this.id; }; /* Widget.prototype.deploy = function(){ }; */ Widget.prototype.install = function(WebAppManifest, userSelectedConfig){ frdl.alert.log('todo Widget.prototype.install'); var newConfig = false /* this.widget */; this.emit('install', {newConfig:newConfig, userSelectedConfig:userSelectedConfig,WebAppManifest:WebAppManifest}); return this; }; Widget.prototype.register = function(WebAppManifest, userSelectedConfig){ frdl.alert.log('todo Widget.prototype.register'); var regInfo = false /* this.widget */; this.emit('register', {regInfo:regInfo, userSelectedConfig:userSelectedConfig,WebAppManifest:WebAppManifest}); return this; }; Widget.prototype.download = function(){ frdl.alert.log('todo Widget.prototype.download'); this.emit('download'); return this; }; Widget.prototype.getWidget = function(tok){ return frdl.UI.getWidget(tok); }; baseObj[funcName]=Widget; }(frdl, 'Widget')); frdl.UI.getWidget = function(id){ var w = null; if(!isNaN(parseInt(id))){ frdl.each(uiwidgets, function(i,wgt) { if(parseInt(id)===wgt.getID()){ w = wgt; return false; } }); }else if('string'===typeof id){ frdl.each(uiwidgets, function(i,wgt) { var c = wgt.config; if( id===c.id || c.widget._id===id || id===c.widget.name._short || id===c.widget.name.__text || id===c.name ){ w = wgt; return false; } }); }else if('object' === typeof id || 'function'===typeof id){ w = uiwidgets[uiwidgets.indexOf(id)] || null; if(null===w){ frdl.each(uiwidgets, function(i,wgt) { if(id===wgt.getElement()){ w = wgt; return false; } }); } } return w; }; (function(baseObj, funcName, mutex) { 'use strict'; function _getManifestUrl(){ var manifestMetaTag = frdl.$q('link[rel="manifest"]', false); return (null!==manifestMetaTag) ? manifestMetaTag.getAttribute('href') : false ; } function WebApp(){ var _fetchedFromUrl = false; var _manifestUrl = false; var args = Array.prototype.slice.call(arguments); var load = function (){ var args = Array.prototype.slice.call(arguments); if(0===args.length){ return load.apply(this, [_getManifestUrl()]); }else if(1 === args.length && 'string' === typeof args[0]){ _manifestUrl = ('string'===typeof args[0]) ? args[0] : undefined; return new Promise(function(resolve, reject){ if('string' !==typeof _manifestUrl){ _fetchedFromUrl = false; _manifestUrl = undefined; reject(false); return; } $.ajax( { url: _manifestUrl, crossDomain: true, cache:false, headers: { 'X-Requested-With': 'XMLHttpRequest' }, type: 'GET', dataType: 'JSON', data: { } } ) .done(function(response) { _fetchedFromUrl = true; resolve(response); }) .fail(function(jqXHR, textStatus) { _fetchedFromUrl = true; reject(false); if(1<frdl.debug.mode()) frdl.alert.error('Could not get manifest: ' + jqXHR.status); }) .always(function() { _manifestUrl = args[0]; }); }); }else if(1 === args.length && null !== args[0] && 'object' === typeof args[0]){ //@ToDo: validate manifest... _fetchedFromUrl = false; return args[0]; } }; var manifest = load.apply(this, args); if(true === manifest instanceof Promise){ manifest.then( function(result) { manifest = result; }, function(errResult){ if(1<frdl.debug.mode()) console.error(errResult); manifest = errResult; } ); } this.getManifest = function(){ return manifest; }; try{ Object.defineProperty(this, 'manifest', { get : function(){ return manifest; }, set : function(val){ // manifest=val; console.deprecated('Do not set WebApp.manifest manually!'); } }); Object.defineProperty(this, 'manifestUrl', { get : function(){ return { onPageUrl : _getManifestUrl(), fetched : _fetchedFromUrl, fetchedFrom : _manifestUrl, inManifest : manifest.manifestUrl }; }, set : function(val){ // manifest=val; console.deprecated('Do not set WebApp.manifestUrl manually!'); } }); }catch(err){ if(Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) { this.__defineGetter__('manifest', function(){ return manifest; } ); this.__defineSetter__('manifest', function(val){ // manifest=val; console.deprecated('Do not set WebApp.manifest manually!'); } ); this.__defineGetter__('manifestUrl', function(){ return { onPageUrl : _getManifestUrl(), fetched : _fetchedFromUrl, fetchedFrom : _manifestUrl, inManifest : manifest.manifestUrl }; } ); this.__defineSetter__('manifestUrl', function(val){ // manifest=val; console.deprecated('Do not set WebApp.manifestUrl manually!'); } ); }else{ console.deprecated('Missing Object.defineProperty and Object.prototype.__defineGetter__ - Fallback to UNSAFE configuration readable!'); this.manifest = manifest; this.manifestUrl = { onPageUrl : _getManifestUrl(), fetched : _fetchedFromUrl, fetchedFrom : _manifestUrl, inManifest : manifest.manifestUrl }; } } } WebApp.prototype.getManifestUrl = function(){ return this.manifestUrl; }; var myWebApp = new WebApp(); try{ Object.defineProperty(mutex, 'myWebApp', { get : function(){ return myWebApp; }, set : function(val){ console.deprecated('Do not set WebApp.myWebApp manually!'); } }); }catch(err){ if(Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) { mutex.__defineGetter__('myWebApp', function(){ return myWebApp; } ); mutex.__defineSetter__('myWebApp', function(val){ console.deprecated('Do not set WebApp.myWebApp manually!'); } ); }else{ console.deprecated('Missing Object.defineProperty and Object.prototype.__defineGetter__ - Fallback to UNSAFE configuration readable!'); mutex.myWebApp = myWebApp; } } baseObj[funcName || "WebApp"]=WebApp; }(frdl, 'WebApp', webfan)); /* frdl.UI.widget -> methods (if invoked without argument) frdl.UI.widget('<div></div>','frdl/webfan', $('body'), true); */ (function(){ 'use strict'; var _widget = { createHtmlWrap : function(el, _link, dest, invokeIfExistsAlready){ // invokeIfExistsAlready=false; var u = new frdl.Url(_link); var tok = u.getScheme() + '://components/', widgetLoaded = false, eLoaded = false; var url = u.urlMakeNew(); var component = frdl.str_replace(tok,'',url); component = frdl.str_replace( u.getScheme() + '://example.com/','',component); component = frdl.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); }, getPostdata : function(){ var d = { method : 'POST', sendData : { /* specialcontext : 'frdl.ui.widgetengine.widget' */ } }; return d; } }; frdl.UI.getWidgetLinks = function(uri){ var u2 = new frdl.Url(uri); var u = new frdl.Url(uri); var tok = u.getScheme() + '://components/'; var url = u.urlMakeNew(); var component = frdl.str_replace(tok,'',url); var isExtern = ('components'!==u2.getHost() && 'example.com'!==u2.getHost() && ('http' === u2.getScheme() || 'https' === u2.getScheme() ) ) ? true : false; component = frdl.str_replace( 'widget://example.com/','',component); component = frdl.str_replace( u.getScheme() + '://example.com/','',component); component = frdl.str_replace( 'widget://','',component); if(!!isExtern) { url = component; }else if('components'===u.getHost() || 'example.com'===u.getHost()){ url = frdl.route('WIDGET_STORE_URL', undefined, './'+component, undefined); }else{ u.setScheme('http'); url = u.urlMakeNew(); } u = new frdl.Url(url); if('http:'===location.protocol || 'https:'===location.protocol || 'web+'===location.protocol.substr(0,4) || 'filesystem:'===location.protocol.substr(0,'filesystem:'.length) ){ u.setScheme( location.protocol.substr(0,location.protocol.length-1) ); } url = u.urlMakeNew(); var widget_dir = url; if('/' !== url.substr(-1)){ url += '/'; } return { url : widget_dir, root : url, component : component, config : url + 'config.xml', isExtern : isExtern }; }; var TWidget = function(widget){ this.widget=widget; }; TWidget.prototype.get = function(){ return this.widget; }; var _warnedDependany = false; frdl.UI.widget = function(el,_link, dest, invokeIfExistsAlready){ // invokeIfExistsAlready=false; /* todo : move this to event-state !!! */ if('undefined' === typeof jQuery || 'undefined' === typeof $ || 'undefined' === typeof global.angular){ if(!_warnedDependany)console.warn('jQuery and angular is needed for the widget engine'); _warnedDependany=true; webfan.$Async(function(){ frdl.UI.widget(el,_link, dest, invokeIfExistsAlready); },10); return _widget; } if('object'===typeof el && null!==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); } 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 WidgetLinks = frdl.UI.getWidgetLinks(('string'===typeof _link) ? _link : el.getAttribute('data-frdl-component')); var url = WidgetLinks.root; var url_config = WidgetLinks.config; var component = WidgetLinks.component; var widget_dir = WidgetLinks.url; var isExtern = WidgetLinks.isExtern; if(true===invokeIfExistsAlready){ var ___widget = frdl.UI.getWidget(component); if(null!==___widget && 'object'===typeof ___widget){ $(___widget.element).trigger('run', ___widget.$scope); ___widget.state.emit('run', [___widget]); return ___widget; } } el.setAttribute('data-frdl-component-initiated', 'true'); if('function'===typeof frdl_webfan_flow_advertising_external_linking){ frdl_webfan_flow_advertising_external_linking(new frdl.Url(url).getHost()); } var createWidgetLink = true, widgetLoaded = false, eLoaded = false; 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; }); } frdl.UI.defer(); frdl.require(url_config, function(widgetXMLObject){ frdl.UI.defer(); if(!widgetXMLObject.json){ var str = 'Cannot loadXML '+ url_config; console.error(str); console.dir(widgetXMLObject); if(0<frdl.debug.mode() && frdl.alert)frdl.alert.error(str); return; } var module = new TModule(url); module.sourceURL = url_config + '#'; if('undefined'===typeof widgetXMLObject.json.widget){ ((0 === frdl.debug.mode()) ? console.warn : console.error)('Cannot get config file of '+component); return false; } widgetXMLObject.json.directory = url; widgetXMLObject.json.element = el; var config = widgetXMLObject.json; var Widget = new frdl.Widget(widgetXMLObject); module.Widget = Widget; try{ Object.defineProperty(Widget, 'module', { get : function(){ return module; }, set : function(val){ console.deprecated('Do not set Widget.module manually!'); } }); }catch(err){ if(Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) { Widget.__defineGetter__('module', function(){ return module; } ); Widget.__defineSetter__('module', function(val){ console.deprecated('Do not set Widget.module manually!'); } ); }else{ console.deprecated('Missing Object.defineProperty and Object.prototype.__defineGetter__ - Fallback to UNSAFE configuration readable!'); Widget.module = module; } } if(!config.widget.content.length){ config.widget.content=[config.widget.content]; } var c=0; if(null===config.widget.content){ eLoaded=true; } frdl.each(config.widget.content, function(i, content){ c=++c; frdl.UI.defer(); if(c<config.widget.content)eLoaded=false; try{ var _url = (''!==new frdl.Url(content._src).getScheme()) ? '' : url; var t = frdl.explode('/', content._type); module.file = url + 'config.xml#'+c; if(false !== strpos(t[1], 'javascript') ){ if('undefined'!==typeof content.__cdata){ module.sourceURL = url + 'config.xml#'+c; try{ eval( content.toString()); }catch(err){ console.warn(err); } } if('string'===typeof content._src){ var js = require('5:'+_url + content._src,false, frdl.require.getCompiler('text/plain'), 'text/plain').content; module.sourceURL = _url + content._src; module.file = _url + content._src; try{ eval(js); }catch(err){ console.warn(err); } } webfan.$Async(function(){ if(c>=config.widget.content.length)eLoaded=true; },1); }else if( false !== strpos(t[1], 'script') ){ (function(){ webfan.$Async(function(){ var mod = new TModule(module.sourceURL + '#'+c+'-' + (content._src || '')); mod.descriptor = mod.resolve(module.sourceURL + '#'+c+'-' + (content._src || '')); mod.parent = module; mod.sourceURL = module.sourceURL + '#'+c+'-' + (content._src || ''); mod.Widget =Widget; mod.Widget.element = el; var ts = ''; var CbsN = '__getWidget_' + frdl.str_replace('-', '', frdl.Guid.newGuid()); frdl.cbs[CbsN] = function(){ return mod.Widget; }; ts+=''; ts+=' var CbsN = "' + CbsN + '";'; ts+=' var WidgetEngine = new TWidget( '; ts+=' frdl.cbs[CbsN]() '; ts+=' );'; ts+=' frdl.cbs[CbsN] = undefined; '; ts+=' var Widget = WidgetEngine.get();'; ts+=' if(0<frdl.debug.mode()) console.dir(Widget);'; if('string'===typeof content._src){ if(''!==new frdl.Url(_url + content._src).getScheme()){ var _u_ = _url + content._src; }else{ var _u_ = 'http://' + _url + content._src; } ts += module.require('5:'+ _u_, false, frdl.require.getCompiler('text/plain'), 'text/plain').content; } if('undefined'!==typeof content.__cdata){ ts += content.toString(); } frdl.UI.once('html-tag-typescript after finaly', function(){ webfan.$Async(function(){ if(c>=config.widget.content.length)eLoaded=true; },1); }); var s = frdl.Dom.create('script'); s.setAttribute('type', 'text/typescript'); s.setAttribute('src', 'http://'+frdl.route('HOST_CDN_PUBLIC_FRDL')+'/cdn/frdl/flow/ui/widget.ts'); s.innerHTML = ' (function(){ ' + ts + '}());'; frdl.Dom.add(s,el); },1); }()); }else if(false !== strpos(t[1], 'html')){ if('undefined'!==typeof content.__cdata){ webfan.$Async(function(){ Widget.html(content.toString()); if(c>=config.widget.content.length) eLoaded=true; },200); } if('string'===typeof content._src){ require('5:'+_url + content._src, function(html) { Widget.html( html.content ); if(c>=Widget.config.widget.content.length) eLoaded=true; }, frdl.require.getCompiler('text/html'), 'text/html'); } }else if(false !== strpos(t[1], 'css') ){ if('undefined'!==typeof content.__cdata){ try{ module.sourceURL = url + 'config.xml#'+c; module.file = url + 'config.xml#'+c; var css = frdl.require.getCompiler('text/css')(content.toString(), module); webfan.$Async(function(){ $( el ).append( '<style type="text/css">'+css.content +'</style>'); },550); }catch(err){ console.warn(err); } } if('string'===typeof content._src){ try{ module.sourceURL = _url + content._src; module.file = _url + content._src; frdl.requireCSS(_url + content._src, false, el, module); }catch(err){ console.warn(err); } } webfan.$Async(function(){ if(c>=config.widget.content.length)eLoaded=true; },1); } }catch(err){ console.warn(err); if(c>=config.widget.content.length)eLoaded=true; } }); el.setAttribute('data-frdl-component-initiated', 'true'); el.setAttribute('data-frdl-component-widget-id', Widget.id); el.widget = function(){ console.deprecated('Element.widget() setting method on DOMElement here maybe deprecated'); return frdl.UI.getWidget(el.getAttribute('data-frdl-component-widget-id')); }; webfan.$Async(function(){ widgetLoaded=true; },30); 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]); } Widget.state.on('loaded', function(){ var widget = arguments[0].widget; frdl.UI.emitter.emit('widget.loaded', [widget]); //widget.element.setAttribute('data-flow-widget', 'config.loaded'); frdl.UI.load(); frdl.UI.Compile(250); frdl.UI.Compile(500); frdl.UI.load(); frdl.UI.Compile(2000); webfan.$Async(function(){ frdl.UI.load(); widget.state.emit('run', [widget]); $(document).trigger('readystatechange') },1500); }); var fin = function(i){ if(isNaN(i))var i =10; i++; if( i < 10000 && (c<config.widget.content || true!==widgetLoaded || true !== eLoaded)){ webfan.$Async(function(){ fin(i); },i); return; } if(i>=10000-1){ console.warn('Could not load all Widget.content elements of ' + url_config); } webfan.$Async(function(){ Widget.boot(); },250); }; fin(5); }, frdl.require.getCompiler('application/xml'), 'application/xml', frdl.UI.widget().getPostdata()); }; }()); }()); (function(){ 'use strict'; 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-'+ frdl.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){ el.setAttribute('data-flow-prepared-frdl-ajax-link-boddystripped', 'true'); $(el).attr('rel', 'external'); }); try{ webfan.$Async(function(){ $.mobile.pushStateEnabled = false; $.mobile.hashListeningEnabled = false; frdl.watchFor('a[ui-sref]').every(function(el){ setTimeout(function(){ frdl.$j(el).attrAdd('data-flow-prepared', 'true'); $(el).attr('href', frdl.str_replace('##', '#',$(el).attr('href'))).attr('href', frdl.str_replace('##', '#',$(el).attr('href'))).attr('href', frdl.str_replace('##', '#',$(el).attr('href'))).attr('href', frdl.str_replace('#', '',$(el).attr('href'))).attr('href', '#'+$(el).attr('href')); },750); }); },250); }catch(err){ console.warn(err); } try{ $('*[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); }catch(err){ console.warn(err); } 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; }; }()); (function(){ 'use strict'; var _DEF = frdl.Device().language; var langs = ['de', 'en', 'fr', 'de_DE', 'en_GB', 'en_US', 'en_EN', 'fr_FR']; if (langs.indexOf(frdl.Device().language) !== -1 && '_' !== _DEF) { _DEF = frdl.Device().language; if(2 > frdl.explode('_', _DEF).length){ _DEF = _DEF + '_' + _DEF.toUpperCase() } } var LanguageOptionSelectors = []; var _loaded=false; var widgetsSelector = '*[data-frdl-component$="locale"] > ul[data-frdl-component-id*="locale"]'; frdl.langGetClassSelector = function(){ return widgetsSelector; }; frdl.getLanguageOptionSelectors = function(){ return LanguageOptionSelectors; }; frdl.addLanguageOptionSelector = function(id){ LanguageOptionSelectors.push(id); return this; }; frdl.removeLanguageOptionSelector = function(id){ LanguageOptionSelectors = frdl.filter(LanguageOptionSelectors, function(v,i){ if(v !== id)return true; return false; }, false); return this; }; frdl.isLanguageOptionSelector = function(id){ var found = false; frdl.getLanguageOptionSelectors() .forEach(function(element, ix, array){ if(id===array[ix]){ found=true; return false; } }); return found; }; frdl.localeUrl = function(m, lang){ if(null === lang || 'undefined' === typeof lang){ lang = frdl.getLang(); } if('function'===typeof m){ return m(lang); }else if('string' === typeof m){ return '/locale/'+m+'/'+frdl.getLang()+'/'+frdl.getLang()+'.properties'; }else{ return '/locale/'+frdl.getLang()+'/'+frdl.getLang()+'.properties'; } }; frdl.langDefault=function(lang,trans){ if (langs.indexOf(frdl.Device().language) !== -1 && '_' !== _DEF) { _DEF = frdl.Device().language; if(2 > frdl.explode('_', _DEF).length){ _DEF = _DEF + '_' + _DEF.toUpperCase() } } return _DEF; }; frdl.getLang = function(){ var l = frdl.langDefault(); if(null !== typeof frdl.cookie.read('lang.user.selected')){ l =frdl.cookie.read('lang.user.selected'); } l = frdl.str_replace('-','_',l); if(2 > frdl.explode('_', l).length && 'default' !== l && '_' !== l){ l = l + '_' + l.toUpperCase() } if('en_EN' === l || 'en_US' === l )l='en_GB'; return l; }; frdl.langstr = function(modul){ var url = frdl.route('API_TRANSLATION_MAIN', null, null, modul); frdl.getScript(url, function(){ },false, false); }; frdl.lang = function(langStrings){ var allSelectors=true, registeredSelectors=true; var languageStrings = langStrings,l = frdl.getLang(); if(false!==registeredSelectors){ frdl.getLanguageOptionSelectors() .forEach(function(element, ix, array){ try{ $(array[ix]).locale('loadLangs', languageStrings) ; }catch(err){ console.error(err); } }); } if(true===allSelectors){ $(frdl.langGetClassSelector()).locale('loadLangs', languageStrings) ; } frdl.translate(); }; frdl.translate = function(lang, allSelectors, registeredSelectors){ try{ if('undefined' === typeof allSelectors)var allSelectors=false; if('undefined' === typeof registeredSelectors)var registeredSelectors=true; if( !lang ){ var l = frdl.getLang(); }else{ var l = lang; } if('default' !== l && '_' !== l) { if(true===frdl.Dom.isVisible('desktop') &&'function'===typeof $.WebfanDesktop.save){ $.WebfanDesktop.Registry.User.lang = l; $.WebfanDesktop.save('user'); } frdl.cookie.write('lang.user.selected',l,31); }else if('_' === l){ return; } wUser.lang = l; var url = frdl.localeUrl(null,l); var pfx = ''; if(null!==frdl.$q('base', false)){ var base = frdl.$q('base', false).getAttribute('href'); pfx += new frdl.Url(base).getScheme() + '://' + new frdl.Url(base).getHost() + '/' + new frdl.Url(base).getDirectory(); if('/' === pfx.substr(pfx.length-1,pfx.length) && true === navigator['-webkit-webfan'])pfx = pfx.substr(0,pfx.length-1); url = pfx + url; } if( null === document.querySelector('link[href="'+url+'"]')){ $(document.head).append('<link type="application/l10n" lang="'+l+'" href="'+url+'"></link>'); } if(false!==registeredSelectors){ frdl.getLanguageOptionSelectors() .forEach(function(element, ix, array){ try{ $(array[ix]).locale('translate', l); }catch(err){ console.warn(err); } }); } if(true===allSelectors){ $(frdl.langGetClassSelector()).locale('translate', l); } webfan.$Async(function(){ frdl.inX.translate(); }, 500); }catch(err){ console.warn(err); } }; }()); window.addEventListener("online", function() { console.log('Welcome back online...!'); try{ frdl.alert.sucess('ONline'); }catch(err){ } }, true); window.addEventListener("offline", function() { try{ frdl.alert.error('OFFline'); }catch(err){ } 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() { try{ var debugmode = frdl.debug.mode(); if(null===debugmode || undefined=== debugmode || isNaN(debugmode))debugmode=0; frdl.$DB.save('settings/debugmode', frdl.debug.mode().toString()); }catch(err){ } }, true); (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.watchFor('*[data-frdl-component^="flow:\/\/"]:not([data-frdl-component-initiated="true"])').every(function(el){ console.deprecated('The widgets flow:// protocol is deprecated! ('+el.getAttribute('data-frdl-component')+')'); el.setAttribute('data-frdl-component', frdl.str_replace('flow://components/', 'widget://example.com/', el.getAttribute('data-frdl-component')) ); el.setAttribute('data-frdl-component', frdl.str_replace('flow://', 'widget://', el.getAttribute('data-frdl-component')) ); }); frdl.watchFor('*[data-frdl-component*=":"]:not([data-frdl-component-initiated="true"])').every(function(el){ if(el.hasAttribute('data-frdl-component-initiated'))return; frdl.UI.widget(el); }); frdl.watchFor('a[frdl-browse-to]:not([data-flow-prepared*="frdl-browse-to"])').every(function(el){ frdl.$j(el).attrAdd('data-flow-prepared', 'frdl-browse-to'); el.addEventListener('click', function(ev){ ev.stopPropagation(); ev.preventDefault(); frdl.UI.browse(this.getAttribute('frdl-browse-to'), (this.hasAttribute('title')) ? this.getAttribute('title') : frdl.strip_tags(this.innerHTML)); }); el.setAttribute('href', 'javascript:;'); }); }()); (function(){ frdl.watchFor('img[flow-image-load-url]:not([src]), img[data-flow-image-load-url]:not([src])').every(function(el){ if(el.hasAttribute('data-flow-image-load-url') && !el.hasAttribute('flow-image-load-url') ){ el.setAttribute('flow-image-load-url', el.getAttribute('data-flow-image-load-url')); el.removeAttribute('data-flow-image-load-url'); } var url = el.getAttribute('flow-image-load-url'); if('data:' === url.substr(0,'data:'.length)){ el.setAttribute('src', url); return; } var p = frdl.getImageDataUri(url); p.then(function(r){ el.setAttribute('src', r.uri); }, function(err){ console.error(err); }); }); }()); (function(){ function h(){ 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.ready(function(){ webfan.$Async(function(){ frdl.wd(true); }, 750); }); }); } if(frdl.Hash){ h(); }else{ frdl.require.state.once('resolved frdl.Hash', function(){ h(); }); } }()); (function(){ frdl.ready(function(){ webfan.$Async(function(){ frdl.UI.load(); frdl.UI.Compile(500); }, 1); document.addEventListener('readystatechange', function(){ if('complete'!==document.readyState)return true; /* frdl.each(frdl.$q('*[data-frdl-component*=":"]:not([data-frdl-component-initiated="true"])'), function(i, el){ webfan.$Async(function(){ if(el.hasAttribute('data-frdl-component-initiated'))return; frdl.UI.widget(el); }, 1); }); */ webfan.$Async(function(){ frdl.UI.load(); frdl.UI.Compile(250); }, 1); }) ; }); $( window ).on( "mobileinit", function() { $.extend( $.mobile , frdl.UI.o.jQueryMobile.o); }); $(document).ready(function(){ if(true===frdl.UI.reduced()){ frdl.UI.rendering('forMinimal'); }else{ frdl.UI.rendering('forFullscreen'); } if( (true === frdl.Device().isTouchable && 'Explorer' !== frdl.Device().browser) || true === frdl.Device().isMobile || true === frdl.Device().isTablet || true === navigator.isMobile || true === navigator.isTablet ){ frdl.UI.rendering('forMobile'); } }); }()); (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; }; }()); frdl.require.state.emit('resolved', { identifier : 'frdl.UI', module : frdl.UI }); frdl.require.state.emit('resolved frdl.UI', { identifier : 'frdl.UI', module : frdl.UI }); exports = module.exports = frdl.UI; }()); }());