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

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

Contents

Class file image Download
/* webfan (C) Till Wehowski, Webfan.de - All rights reserved. */ (function() { "use strict"; exports = module.exports = 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'), ajaxEnabled: frdl.route('jQueryMobile.ajaxEnabled'), linkBindingEnabled : frdl.route('jQueryMobile.linkBindingEnabled'), hashListeningEnabled : frdl.route('jQueryMobile.hashListeningEnabled'), pushStateEnabled : frdl.route('jQueryMobile.pushStateEnabled') }; var DBPFX= 'frdl/WebfanDesktop/'; /* var mt_rand = require('php-functional/php-functions').mt_rand; */ (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 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.$( $.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: { 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; }, 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(null!==jDialogBox){ $(jDialogBox).wd_dialogs({loadUrl : url, title : (title || '')}); }else{ webfan['$win open'](url); } } }) ).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(){ '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); } } } 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'; webfan.$Async(function(){ var obs, iframe = null, port = 0; var wPoster = new frdl.wPoster(port); var _proxy = function(){ if(null===iframe){ iframe = frdl.Dom.create("iframe"); iframe.setAttribute('frdl-nwtrusted', true); iframe.style.display = "none"; iframe.setAttribute('id', "IFRAME.webfan_proxy"); iframe.addEventListener('load', function(){ var me = this; webfan.$Async(function(){ frdl.webfanProxy().poster.wpm(me, { origin : document.origin, my_port : 0, your_port : Infinity }, document.origin, 'webfan.open.proxy', 'open port' , false ); },250); }); frdl.Dom.add(iframe, frdl.$q('head',false)); iframe.setAttribute('src', "http://webfan.de/proxy"); } return iframe; }; frdl.webfanProxy = function(){ return { poster : wPoster, source : _proxy() }; }; obs = frdl.watchFor( '*[href^="web\+fan\:"]:not([data-flow-prepared*="true"])' + ', *[src^="web\+fan\:"]:not([data-flow-prepared*="true"])' + ', *[rel^="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"])' + ', *[href^="urn:"]:not([data-flow-prepared*="true"])' + ', *[src^="urn:"]:not([data-flow-prepared*="true"])' + ', *[rel^="urn:"]:not([data-flow-prepared*="true"])' + ', *[data-src^="urn:"]:not([data-flow-prepared*="true"])' + ', *[ng-src^="urn:"]:not([data-flow-prepared*="true"])' + ', *[data-href^="urn:"]:not([data-flow-prepared*="true"])' + ', *[ng-href^="urn:"]:not([data-flow-prepared*="true"])' ) .every(function(el){ frdl.$j(el).attrAdd('data-flow-prepared', 'true'); /* (target, message, origin, type, cmd, cert) */ frdl.webfanProxy().poster.wpm(frdl.webfanProxy().source, { protocol : 'web+fan', url : 'http://webfan.de/url?uri=%s', name : 'Webfan protocol handler [web+fan:]' }, document.origin, 'protocol-handler', 'register-protocol-handler' , false ); frdl.webfanProxy().poster.wpm(frdl.webfanProxy().source, { protocol : 'urn', url : 'http://webfan.de/url?urn=%s', name : 'Webfan urn lookup handler [urn:]' }, document.origin, 'protocol-handler', 'register-protocol-handler' , false ); return true; }); },1); }()); (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.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, _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; frdl.$j(el).attrAdd('data-flow-prepared', 'true'); frdl.$j(el).attrAdd('data-flow-parsed', 'true'); 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://cdn.webfan.de/cdn/application/webfan/node_modules/webfan/frdl.d.ts.txt', false, frdl.require.getCompiler('text/plain'), 'text/plain').content; if(false ===src){ (function(module){ var module = new TModule(location.href); module.descriptor = module.resolve(location.href); module.parent = module; 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); }(module)); }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'); } } 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(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 = 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 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); */ (function(){ 'use strict'; 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 = 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); } }; 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); } 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 u2 = new frdl.Url(el.getAttribute('data-frdl-component')); 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 = 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(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(!!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(); 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 config = wjslX2JS.xml2json(response); if('undefined'===typeof config.widget){ ((0 === frdl.debug.mode()) ? console.warn : console.error)('Cannot get config file of '+component); return false; } var module = module || global; module.sourceURL = url + 'config.xml#'; module.Widget = config; config.directory = url; 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; var t = frdl.explode('/', content._type); if(/*'text/javascript' === content._type || 'application/javascript' === content._type || 'application/x-javascript' === content._type */ false !== strpos(t[1], 'javascript') ){ if('undefined'!==typeof content.__cdata){ webfan.$Async(function(){ try{ /* module.sourceUrl = */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){ require('5:'+_url + content._src, function(mod) { if(c===config.widget.content.length)eLoaded=true; }, frdl.require.getCompiler('application/javascript'), 'application/javascript'); } }else if( false !== strpos(t[1], 'script') ){ if('undefined'!==typeof content.__cdata){ webfan.$Async(function(){ try{ /* module.sourceUrl = */module.sourceURL = url + 'config.xml#'+c; eval(frdl.require.getCompiler('application/typescript')(content.toString(), module)); if(c===config.widget.content.length)eLoaded=true; }catch(err){ console.error(err); } },1); } if('string'===typeof content._src){ require('5:'+_url + content._src, function(mod) { if(c===config.widget.content.length)eLoaded=true; }, frdl.require.getCompiler('application/typescript'), 'application/typescript'); } }else if(/* 'text/html' === content._type */ false !== strpos(t[1], 'html')){ 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 */ false !== strpos(t[1], 'css') ){ if('undefined'!==typeof content.__cdata){ $( el ).append( '<style type="text/css">'+content.toString() +'</style>'); } if('string'===typeof content._src){ frdl.requireCSS(_url + content._src, false, el); } 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; }); }; }()); (function(){ 'use strict'; $( 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 = 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); }); }); }()); (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 = 'default'; 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; /* _DEF = frdl.str_replace('-','_',_DEF); */ if(false === frdl.strpos(_DEF, '_')){ _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('undefined'!==typeof lang && 'string'===typeof lang){ if(_DEF!==lang){ if(true===frdl.Dom.isVisible('desktop') && true !== $.WebfanDesktop.o.debug){ return frdl.Throw('framework', 'DefaultLanguage SHOULD only be changed in Debug Mode!'); } } _DEF = lang; if(true===trans){ frdl.translate(lang); } }*/ 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'); }/* else if(true===frdl.Dom.isVisible('desktop') && ('undefined' !== typeof $.WebfanDesktop && 'undefined' !== typeof $.WebfanDesktop.o && 'undefined' !== typeof $.WebfanDesktop.Registry && 'undefined' !== typeof $.WebfanDesktop.Registry.User && 'string' === typeof $.WebfanDesktop.Registry.User.lang) ){ l = $.WebfanDesktop.Registry.User.lang; }else if('string' === typeof wUser.lang){ l = wUser.lang; }*/else{ l = frdl.Device().language; } l = frdl.str_replace('-','_',l); if(false === frdl.strpos(l, '_') && '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; allSelectors=true; registeredSelectors=true; if( 'undefined' === typeof lang || null === 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); } 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); } /* if(frdl.getLang()!==lang){ $(window).trigger('languagechange'); } */ webfan.$Async(function(){ frdl.inX.translate(); /* webfan.$Async(function(){ // todo/deprecated __() use gettext instead (above frdl.inX) require('webfan/navigator/l10n', function(mod){ }); },1000); */ }, 500); }catch(err){ console.warn(err); } }; }()); 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() { 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); /* 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.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.ready(function(){ // frdl.UI.widget(el); // }); }); 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 = frdl.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'); if('flow' === u.getScheme()){ console.deprecated('The widgets flow:// protocol is deprecated!'); /* http://example.com/ */ el.setAttribute('data-frdl-component', frdl.str_replace('flow://components/', 'widget://example.com/', el.getAttribute('data-frdl-component')) ); u = new frdl.Url(el.getAttribute('data-frdl-component')); return frdl.UI.widget(el); } 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 = frdl.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); } }); }; 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); }) ; }); }); /* 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'); } }); /* }); */ }()); (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 }); return exports; }(); }());