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

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

Contents

Class file image Download
/*! webfan (C) Till Wehowski, Webfan.de - All rights reserved. */ /*! @ frdl.Frdlweb.js.Compiler.es6 : no */ /*! @ frdl.Frdlweb.js.Compiler.defaultPlugin : frdlcjs */ define(function(require, exports, module){ "use strict"; let webfan = frdl.webfan; frdl.Device(); 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/'; let UI = frdl.extend( { o :{ DBPFX : DBPFX, LOCAL_MACHINE_CURRENT_USER : (JSON.parse( frdl.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 = {}; try{ var c = frdl.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(); }catch(er){ console.warn(err); } 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(err2){ Form[s]=null; } } return true; } Form[s]=el.value || null; }); return Form; } }, new frdl.EventEmitter() ); (function() { 'use strict'; var is_on = true; var Bootstrap = { switchOn : function(a, old){ if(a !== is_on){ this.since = new Date().getTime(); this.timerName = setInterval(this.check, 8); } if(true===a){ is_on=true; }else if(false===a){ is_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); } is_on= (window.name !==frdl.str_replace(__TOK_DEFER__, '', window.name)) ? false : true; } return is_on; }, since : new Date().getTime(), timeout : 10000, check : function(){ if(true === is_on){ clearInterval(this.timerName); }else{ if(new Date().getTime() - 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 UI.Compile()'); } this.switchOn(true); UI.Compile(1); } } }, timerName : 'frdl://Bootstrap.check/' + frdl.microtime() + frdl.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); }; UI.defer(); UI.emitter=new frdl.EventEmitter(); document.addEventListener('readystatechange', function(ev){ Bootstrap.since=frdl.time(); }) ; document.addEventListener("mobileinit", function(){ $.extend( $.mobile , UI.o.jQueryMobile.o); }); $.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); }; }()); (function(){ frdl.hasScope = function(element){ return ($(element).hasClass('ng-scope')) ? true : false; }; 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){ 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)){ 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'; 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;} if(el.hasAttribute('onclick') || 'javascript:;'===el.getAttribute('href')){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(); var __p =false; try{ // if( uHost.getPath() !== location.path ){ frdl.webfan.gui.progress.start(); __p =true; // } }catch(err){ __p =false; } if(true === frdl.Device().isMobile || true === frdl.Device().isTablet){ $.mobile.loading( 'show' ); } var dest=null; var destMeta=document.querySelector('meta[name="frdl-ajax-link-boddystripped.destination"]'); if(null!==destMeta){ dest= destMeta.getAttribute('content') ; } if(null === dest){ dest = document.querySelector( 'body *[role="page"]'); }; if(null === dest){ dest = document.querySelector( 'body *[role="main"]'); }; if(null === dest){ dest = document.querySelector( 'body .content'); }; if(null === dest){ dest = document.querySelector( 'body .content, .ui-content'); }; if(null === dest){ dest = document.querySelector( 'body section[role^="nav"]'); }; if(null === dest){ dest = document.querySelector( 'body section'); }; if(null === dest){ dest = document.querySelector( 'body div'); }; var OnUnload = function(e){ e.preventDefault(); return false; }; window.addEventListener('beforeunload', OnUnload); el.addEventListener('click', 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).children().data('$injector', ''); // $(dest).children().remove(); $(dest).html(''); $(dest).html(html); var newTitle=frdl.explode('-', $('title').text() )[0]; try{ newTitle=$(dest).find('meta[name="document.title"]').getAttribute('content'); }catch(err){ newTitle=document.querySelector('meta[name="document.title"]').getAttribute('content'); } if('undefined'!==typeof newTitle){ $(document.querySelector('title')).text(newTitle); } try{ $(document).scrollTop(0); }catch(err){ } if(true === frdl.Device().isMobile || true === frdl.Device().isTablet){ $(dest).trigger('create'); $.mobile.loading( 'hide' ); } ev.stopPropagation(); var newState = { name : url + '#'+newTitle, url : url, title : newTitle, sha1 : frdl.Sha1.hash(html), l : html.toString().length, fromState : history.state }; // window.history.replaceState({ if(history.state && 'undefined' !== typeof history.state.url && url !== history.state.url ){ history.replaceState(newState, newTitle, url); }else{ history.pushState(newState, newTitle, url); } // ev.stopPropagation(); if(!!__p)frdl.webfan.gui.progress.complete(); $(document).trigger('readystatechange'); frdl.UI.Compile(1); webfan.$Async(frdl.inX.translate); }).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, 5); console.warn(str); location.href=url; }).always(function() { window.removeEventListener('beforeunload', OnUnload); el.removeEventListener('click', OnUnload); frdl.UI.Compile(1); webfan.$Async(function(){ frdl.inX.translate(); },1); }); return false; }); $(element).on('touch', function(ev){ $(element).trigger('click', ev ) ; }); }); (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 }; UI.emit(State); 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 = require.getCompiler('application/typescript'); var AnchorPrefix = '#@ts!'; var module = new frdl.Registry.Types.Classes.TModule(frdl.main); module.sourceURL = (false===src) ? location.href : src; var inlinecode = el.innerHTML; //var hc = require('webfan/frdl.d.ts.txt', false, require.getCompiler('text/plain'), 'text/plain'); require('webfan/frdl.d.ts.txt', function(hc){ var headercode = hc.content; if(false ===src){ (function(){ var module = new frdl.Registry.Types.Classes.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 frdl.Registry.Types.Classes.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'); } }, require.getCompiler('text/plain'), 'text/plain'); } (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', 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); */ frdl.watchFor('body:not([flow-read-header-metadata="true"])').every(function(el){ el.setAttribute('flow-read-header-metadata', 'true'); headerMetadata(document); }).destroy(); if(null !== frdl.$q('link[rel="manifest"]', false)){ UI.isWebApp = true; }else{ UI.isWebApp = false; } }()); (function LoadAngularGUIModule() { 'use strict'; function b(){ /*!* * Binds a TinyMCE widget to <textarea> elements. https://github.com/angular-ui/ui-tinymce/blob/master/LICENSE */ frdl.a.module('ui.tinymce', []) .value('uiTinymceConfig', {}) .directive('uiTinymce', ['$rootScope', '$compile', '$timeout', '$window', '$sce', 'uiTinymceConfig', 'uiTinymceService', function($rootScope, $compile, $timeout, $window, $sce, uiTinymceConfig, uiTinymceService) { uiTinymceConfig = uiTinymceConfig || {}; if (uiTinymceConfig.baseUrl) { tinymce.baseURL = uiTinymceConfig.baseUrl; } return { require: ['ngModel', '^?form'], priority: 599, link: function(scope, element, attrs, ctrls) { if (!$window.tinymce) { return; } var ngModel = ctrls[0], form = ctrls[1] || null; var expression, options = { debounce: true }, tinyInstance, updateView = function(editor) { var content = editor.getContent({format: options.format}).trim(); content = $sce.trustAsHtml(content); ngModel.$setViewValue(content); if (!$rootScope.$$phase) { scope.$digest(); } }; function toggleDisable(disabled) { if (disabled) { ensureInstance(); if (tinyInstance) { tinyInstance.getBody().setAttribute('contenteditable', false); } } else { ensureInstance(); if (tinyInstance && !tinyInstance.settings.readonly && tinyInstance.getDoc()) { tinyInstance.getBody().setAttribute('contenteditable', true); } } } // fetch a unique ID from the service var uniqueId = uiTinymceService.getUniqueId(); attrs.$set('id', uniqueId); expression = {}; frdl.a.extend(expression, scope.$eval(attrs.uiTinymce)); //Debounce update and save action var debouncedUpdate = (function(debouncedUpdateDelay) { var debouncedUpdateTimer; return function(ed) { $timeout.cancel(debouncedUpdateTimer); debouncedUpdateTimer = $timeout(function() { return (function(ed) { if (ed.isDirty()) { ed.save(); updateView(ed); } })(ed); }, debouncedUpdateDelay); }; })(400); var setupOptions = { // Update model when calling setContent // (such as from the source editor popup) setup: function(ed) { ed.on('init', function() { ngModel.$render(); ngModel.$setPristine(); ngModel.$setUntouched(); if (form) { form.$setPristine(); } }); // Update model when: // - a button has been clicked [ExecCommand] // - the editor content has been modified [change] // - the node has changed [NodeChange] // - an object has been resized (table, image) [ObjectResized] ed.on('ExecCommand change NodeChange ObjectResized', function() { if (!options.debounce) { ed.save(); updateView(ed); return; } debouncedUpdate(ed); }); ed.on('blur', function() { element[0].blur(); ngModel.$setTouched(); if (!$rootScope.$$phase) { scope.$digest(); } }); ed.on('remove', function() { element.remove(); }); if (uiTinymceConfig.setup) { uiTinymceConfig.setup(ed, { updateView: updateView }); } if (expression.setup) { expression.setup(ed, { updateView: updateView }); } }, format: expression.format || 'html', selector: '#' + attrs.id }; // extend options with initial uiTinymceConfig and // options from directive attribute value frdl.a.extend(options, uiTinymceConfig, expression, setupOptions); // Wrapped in $timeout due to $tinymce:refresh implementation, requires // element to be present in DOM before instantiating editor when // re-rendering directive $timeout(function() { if (options.baseURL){ tinymce.baseURL = options.baseURL; } var maybeInitPromise = tinymce.init(options); if(maybeInitPromise && typeof maybeInitPromise.then === 'function') { maybeInitPromise.then(function() { toggleDisable(scope.$eval(attrs.ngDisabled)); }); } else { toggleDisable(scope.$eval(attrs.ngDisabled)); } }); ngModel.$formatters.unshift(function(modelValue) { return modelValue ? $sce.trustAsHtml(modelValue) : ''; }); ngModel.$parsers.unshift(function(viewValue) { return viewValue ? $sce.getTrustedHtml(viewValue) : ''; }); ngModel.$render = function() { ensureInstance(); var viewValue = ngModel.$viewValue ? $sce.getTrustedHtml(ngModel.$viewValue) : ''; // instance.getDoc() check is a guard against null value // when destruction & recreation of instances happen if (tinyInstance && tinyInstance.getDoc() ) { tinyInstance.setContent(viewValue); // Triggering change event due to TinyMCE not firing event & // becoming out of sync for change callbacks tinyInstance.fire('change'); } }; attrs.$observe('disabled', toggleDisable); // This block is because of TinyMCE not playing well with removal and // recreation of instances, requiring instances to have different // selectors in order to render new instances properly var unbindEventListener = scope.$on('$tinymce:refresh', function(e, id) { var eid = attrs.id; if (frdl.a.isUndefined(id) || id === eid) { var parentElement = element.parent(); var clonedElement = element.clone(); clonedElement.removeAttr('id'); clonedElement.removeAttr('style'); clonedElement.removeAttr('aria-hidden'); tinymce.execCommand('mceRemoveEditor', false, eid); parentElement.append($compile(clonedElement)(scope)); unbindEventListener(); } }); scope.$on('$destroy', function() { ensureInstance(); if (tinyInstance) { tinyInstance.remove(); tinyInstance = null; } }); function ensureInstance() { if (!tinyInstance) { tinyInstance = tinymce.get(attrs.id); } } } }; }]) .service('uiTinymceService', [ /** * A service is used to create unique ID's, this prevents duplicate ID's if there are multiple editors on screen. */ function() { var UITinymceService = function() { var ID_ATTR = 'ui-tinymce'; // uniqueId keeps track of the latest assigned ID var uniqueId = 0; // getUniqueId returns a unique ID var getUniqueId = function() { uniqueId ++; return ID_ATTR + '-' + uniqueId; }; // return the function as a public method of the service return { getUniqueId: getUniqueId }; }; // return a new instance of the service return new UITinymceService(); } ]); /* 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', 'ui.tinymce']) .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 }; }; }]) */ //http://jsfiddle.net/bYUa3/2/ //http://stackoverflow.com/questions/15417125/submit-form-on-pressing-enter-with-angularjs /** $scope.keylog = []; $scope.keyCount= 0; $scope.handleKeypress = function(key) { $scope.keylog.push(key); }; <h3>detect key in controller</h3> <input on-keyup-fn="handleKeypress"> <br />Key Log: {{keylog}} <hr /> <h3>detect key in directive</h3> <!--27,13 = escape, enter--> <input on-keyup="keyCount = keyCount+1" keys="[27,13]"> <br />Times escape or enter pressed: {{keyCount}} */ .directive('onKeyupFn', function() { return function(scope, elm, attrs) { //Evaluate the variable that was passed //In this case we're just passing a variable that points //to a function we'll call each keyup var keyupFn = scope.$eval(attrs.onKeyupFn); elm.bind('keyup', function(evt) { //$apply makes sure that angular knows //we're changing something scope.$apply(function() { keyupFn.call(scope, evt.which); }); }); }; }) .directive('onKeyup', function() { return function(scope, elm, attrs) { function applyKeyup() { scope.$apply(attrs.onKeyup); }; var allowedKeys = scope.$eval(attrs.keys); elm.bind('keyup', function(evt) { //if no key restriction specified, always fire if (!allowedKeys || allowedKeys.length == 0) { applyKeyup(); } else { angular.forEach(allowedKeys, function(key) { if (key == evt.which) { applyKeyup(); } }); } }); }; }) ; }//eo b() if('undefined'!== typeof frdl.a && 'function'===typeof frdl.a.module && 'function'===typeof frdl.a.bootstrap ){ b(); }else{ webfan.$Async(function(){ LoadAngularGUIModule(); },3); } // webfan.$Async(function(){ // b(); // },1); }()); (function() { function initNgFlows(element) { var delay = 1000; if(true !== frdl.angularBootstrapable())return UI.Compile(delay); // var moduleElements = frdl.$q('*[ng-flows]:not([flow-bootstrap-value="stop"])', true, element); var moduleElements = frdl.$q('*[ng-flows]', true, element); if(0===moduleElements.length)return; for(var i = 0; i < moduleElements.length; i++) { var moduleElement = moduleElements[i]; if(true !== frdl.angularBootstrapable())return 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){ 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') */) { 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', frdl.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; 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() // || true!==frdl.fs5.polyfill.ready ){ Func(function(){ frdl.ready(UI.Compile); }, delay + c); return; } Func(function(){ frdl.ready(function(){ frdl.a.element(document).ready(function() { initNgFlows(document); }); }); }, delay + 1); }; }()); /* (function(){ 'use strict'; function defaultComponents(){ var w = document.createElement('webfan-widget'); w.setAttribute('data-frdl-component', frdl.requirejs.s.contexts._.config.paths.components + '/webfan'); document.querySelector('body').append(w); } frdl.ready(function(){ frdl.require.nextTick(function(){ try{ if('undefined'===typeof frdl.Slim.classOf('frdl-web') || 'undefined'===typeof frdl.de.webfan.cdn.frdl.flow.components.webfan){ defaultComponents(); }else{ } }catch(err){ defaultComponents(); } }); }); }()); */ /* (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'; if('undefined'===typeof frdl.Slim.classOf('webfan-module') ){ var link = document.createElement('link'); link.href = frdl.requirejs.s.contexts._.config.paths.components + '/webfan/import-webfan-components.html'; link.rel = 'import'; link.async = true; document.querySelector('head').append(link); } var uiwidgets = []; 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 || wgt.GUID===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; }; /* UI.widget -> methods (if invoked without argument) UI.widget('<div></div>','frdl/webfan', $('body'), true); */ 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 = 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 = 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 : 'UI.widgetengine.widget' */ } }; return d; } }; 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); url = frdl.requirejs.s.contexts._.config.paths.components + '/' + component; }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 _rewriteUrlCss = function(c, base, ___URL){ var urlMatchingRegex = /[:,\s]\s*url\s*\(\s*(?:'(\S*?)'|"(\S*?)"?|((?:\\\s|\\\)|\\\"|\\\'|\S)*?))\s*\)/gi; c = c.replace(urlMatchingRegex, function(fullMatch, url) { var n = str_replace('"', "'", fullMatch); return n; }); c = c.replace(urlMatchingRegex, function(fullMatch, url) { /// var __U = require('url'); var __U = ___URL; if ('undefined' === typeof url) { var _u = frdl.explode('(', fullMatch, 2)[1]; var url = _u.substr(0, _u.length - 1); } if ('data:' === url.substr(0, 'data:'.length)) { return fullMatch; } try { var nu = __U.parse(base).resolve(url); } catch (err) { var nu = (base) + url; if (1 < frdl.debug.mode()) console.warn(err); } var nt = str_replace(url, nu, fullMatch); return nt; }); return c; }; UI.widget = function(el,_link, dest, invokeIfExistsAlready){ 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); } var WidgetLinks = 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 = UI.getWidget(component); if(null!==___widget && 'object'===typeof ___widget){ // $(___widget.element).trigger('run', ___widget.$scope); ___widget.state.emit('run', [___widget]); return ___widget; } } if('true' === el.getAttribute('data-frdl-component-initiated') ){ return; } el.setAttribute('data-frdl-component-initiated', 'true'); 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; }); } UI.defer(); // frdl.alert.error('@ToDo: Load Widgets: e.g. '+WidgetLinks.config); // require(['frdlcjs!'+WidgetLinks.config], function(Widget){ // alert(JSON.stringify(Widget)); // }); /* let WidgetUrl = new frdl.Url(url) ; // alert(JSON.stringify(WidgetUrl.getHost())); var host = WidgetUrl.getHost(); if( 'example.com'===host || 'components' === host ){ WidgetUrl.setHost('webfan.de'); WidgetUrl.urlMakeNew(); } */ // alert(JSON.stringify(WidgetLinks)); require(['require', 'exports', 'module', 'loadXML!'+WidgetLinks.config], function(require, exports, module,widgetXMLObject){ //alert(JSON.stringify(widgetXMLObject)); // console.log('Widget', widgetXMLObject); UI.defer(); if(!widgetXMLObject.json){ var str = 'Cannot loadXML '+ url_config + JSON.stringify(widgetXMLObject); // alert(str); console.error(str); console.dir(widgetXMLObject); if(0<frdl.debug.mode() && frdl.alert)frdl.alert.error(str); return; } // var module = new frdl.Registry.Types.Classes.TModule(url); //var module = new frdl.Registry.Types.Classes.TModule(url_config); // 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; el.setAttribute('data-frdl-component-widget-id', Widget.id); Object.defineProperty(module, 'Widget', { 'get' : function(){ return Widget; } }); Object.defineProperty(module, 'directory', { 'get' : function(){ return Widget.directory; } }); if(!config.widget.content.length){ config.widget.content=[config.widget.content]; } var c=0; var _state = new frdl.EventEmitter; var _req = _state.required(['prepared'], function(states){ Widget.boot(); var context={ frdl : frdl, Widget : Widget, module : module, exports : new Function(""), WebApp : frdl.webfan.myWebApp }; Widget = Widget.With(context).Widget; }, Widget, false); frdl.each(config.widget.content, function(i, content){ c=++c; UI.defer(); var _url = (''!==new frdl.Url(content._src).getScheme()) ? '' : url; var t = frdl.explode('/', content._type); var file = url + 'config.xml#'+c; if(false !== frdl.strpos(t[1], 'script') ){ if('undefined'!==typeof content.__cdata){ Widget.js({filename: file, js: content.toString()}); } if('string'===typeof content._src){ _req.add('loaded ' + content._src ); require(['loadPlain!'+WidgetLinks.root + content._src], function(js){ Widget.js({filename: WidgetLinks.root + content._src, js: js.content}); // alert(JSON.stringify(Widget.js())); _state.emit('loaded ' + content._src, {content:js.content} ); }); } // console.log('content', content); }else if(false !== frdl.strpos(t[1], 'html')){ if('undefined'!==typeof content.__cdata){ Widget.html(content.toString()); } if('string'===typeof content._src){ _req.add('loaded ' + content._src ); require(['loadPlain!'+WidgetLinks.root + content._src], function(html){ Widget.html( html.content ); _state.emit('loaded ' + content._src, {content:html.content} ); }); } }else if(false !== frdl.strpos(t[1], 'css') ){ if('undefined'!==typeof content.__cdata){ Widget.css(content.toString()); } if('string'===typeof content._src){ _req.add('loaded ' + content._src ); require(['loadPlain!'+WidgetLinks.root + content._src], function(css){ require(['webfan/bootcache!url'], function(___URL){ Widget.css( _rewriteUrlCss(css.content, WidgetLinks.root, ___URL) ); _state.emit('loaded ' + content._src, {content:css.content} ); }); }); } } }); el.setAttribute('data-frdl-component-initiated', 'true'); el.widget = function(){ throw 'Element.widget() setting method on DOMElement here maybe deprecated'; }; 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.once('loaded', function(){ var widget = arguments[0].widget; UI.emitter.emit('widget.loaded', [widget]); //widget.element.setAttribute('data-flow-widget', 'config.loaded'); UI.load(); UI.Compile(10); UI.Compile(100); UI.load(); UI.Compile(1000); webfan.$Async(function(){ UI.load(); widget.state.emit('run', [widget]); $(document).trigger('readystatechange') },500); }); _state.emit('prepared', {Widget:Widget} ); });//require config.xml (WIDGET) }; require(['feature!vm'], function(vm){ var _a_bootstrapped = []; var _i = -1; (function(baseObj, funcName) { funcName = funcName || "Widget"; customElements.whenDefined('webfan-module').then(function() { frdl.Slim.plugin('create', element => { if (element.localName === 'webfan-widget') { element.model = Widget.prototype; } }); frdl.Slim.tag('webfan-widget', ` <frdl></frdl> <slot></slot> `, class extends frdl.Slim { attributeChangedCallback(name, oldValue, newValue) { super.attributeChangedCallback(name, oldValue, newValue); if(0< frdl.debug.mode() ) console.log('attributeChangedCallback',arguments); if(oldValue !== newValue){ this._updateRendering('attributeChangedCallback', name, oldValue, newValue); } } _updateRendering(eventChangeName, name, oldValue, newValue) { // Left as an exercise for the reader. But, you'll probably want to // check this.ownerDocument.defaultView to see if we've been // inserted into a document with a browsing context, and avoid // doing any work if not. if(0< frdl.debug.mode() ) console.log('_updateRendering',this); if(true!== this.initiated){ this.tryInit(); } } onBeforeCreated() { // this.initiated = false; //ERROR IN constructor this.setAttribute('data-role', 'component'); // this.setAttribute('role', 'widget'); } tryInit(el){ if(true=== this.initiated){ return; } if(!el)el=this; if(el.hasAttribute('data-frdl-component-loaded-script') && 'true'===el.getAttribute('data-frdl-component-loaded-script')){ return; } if('true' === el.getAttribute('data-frdl-component-initiated') ){ return; } if(!el.hasAttribute('data-frdl-component') ){ if(el.dataFrdlComponent){ el.setAttribute('data-frdl-component', el.dataFrdlComponent); }else if(this.dataFrdlComponent || this.hasAttribute('data-frdl-component')){ el.setAttribute('data-frdl-component', this.dataFrdlComponent || this.getAttribute('data-frdl-component')); } } this.dataFrdlComponent = el.getAttribute('data-frdl-component'); this.initiated = true; this.debug = (el.hasAttribute('debug') && ('true'=== el.getAttribute('debug') || '1'=== el.getAttribute('debug') || 'yes'=== el.getAttribute('debug') ) ) ? true : false; UI.widget( // $(el).find('slot') el ); } onAdded(){ this.setAttribute('data-role', 'component'); this.setAttribute('role', 'widget'); this.dataset.role = "component"; this.tryInit(); } get useShadow() { return false; } });//webfan-widget });//whenDefined webfan-module function Widget(widgetXMLObject){ var data = {}; var id = id=++_i; this.state = new frdl.EventEmitter(); this.state.emit('init', {id:id}); var WidgetXMLObject = widgetXMLObject; var c = WidgetXMLObject.json; var config; var __getConfig = function () { var c = config; return c; }; var _html = []; var modules = {}; var _css = []; var _js = []; var _Script = false; var __setConfig = function (val) { var _new = val, _old = config; // console.warn('Changing widget config is not supported yet (ToDo)'); throw 'Changing widget config is not supported yet (ToDo)'; var merged = $.extend(_old, _new); /* e.g. config = merged ; */ }; var ReadOnly = function(v){ throw 'Trying to set readonly Widget property FAILED: ' + v; }; Object.defineProperty(this, 'Script', { get : function(){ return _Script; }, set : function(s){ if(false!==_Script){ throw 'Script of Widget already defined!'; } _Script=s; } }); config = c; var settings = {}; Object.defineProperty(this, 'settings', { get : function(){ return settings; } }); Object.defineProperty(this, 'config', { get : function(){ return __getConfig(); } }); 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, '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().widget.name._short; }, set : function(val){ throw 'Illegal set of Widget.name '+val; } }); this.angular = { boot : function(THAT){ // var $app = frdl.a.module(THAT.GUID, [__APP_NS__]); // var $app = frdl.a.module(THAT.GUID, frdl.a.modules); var $app = frdl.a.module(THAT.GUID, ['webfan.gui']); Object.defineProperty(THAT.angular, '$app', { get : function(){ return $app; } }); 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 || 0 < THAT.angular.blocks.provider.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_' + THAT.id; // frdl.a.module(appname, ['webfan.gui']); // THAT.angular.modules.push(appname); }else{ // $(config.element).data('$injector', ''); } }else{ return 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 && 0===THAT.angular.blocks.provider.length){ return UI.load(); } // if(0===THAT.angular.modules.length){ // THAT.angular.modules.push('webfan.gui'); // return; // } // var app = THAT.angular.modules[THAT.angular.modules.length-1]; // var app = THAT.angular.modules[0]; // if(-1!== _a_bootstrapped.indexOf(config.widget._id + '___' + app)) b = false; // _a_bootstrapped.push(config.widget._id + '___' + app); var app = THAT.angular.$app.name; if(-1!== _a_bootstrapped.indexOf(app)) b = false; _a_bootstrapped.push(app); //b=true; // console.dir(app); if(!!b){ frdl.each(THAT.angular.blocks.provider, function(i, block){ frdl.a.module(app).provider(block); }); 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); UI.load(); THAT.state.emit('agularify', { agularify: THAT.angular, app : frdl.a.module(app) }); } b(THAT); }(THAT)); }, modules : [], element : false, blocks : { provider : [], config : [], controller : [], run : [] }, provider : function(block){ THAT.angular.blocks.provider.push(block); return THAT.angular; }, config : function(block){ THAT.angular.blocks.config.push(block); return THAT.angular; }, controller : function(name, block){ THAT.angular.blocks.controller.push([name, block]); return THAT.angular; }, run : function(block){ THAT.angular.blocks.run.push(block); return THAT.angular; }, 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); } c(); }()); return THAT.angular; } }; 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( 1=== 0 && 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.css = function(str){ if(!arguments || 0 === Array.prototype.slice.call(arguments).length)return _css; _css.push(str); this.state.emit('css.append', { css: str }); return this; }; this.js = function(str){ if(!arguments || 0 === Array.prototype.slice.call(arguments).length)return _js; _js.push(str); this.state.emit('js.append', { js: str }); return this; }; 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; } }; this.Config = function(){ var args = Array.prototype.slice.call(arguments), n = false; if(0<args.length && 'string' === typeof args[0]){ n = THAT.settings[args[0]]; if(false !== frdl.strpos(args[0], '.')){ var p = frdl.explode('.', args[0]); n = THAT.settings; frdl.each(p, function(i, seg){ if('undefined'===typeof n[seg]){ n[seg] = (2 === args.length && i === p.length-1) ? args[1] : {}; } n = n[seg]; }); } } //console.log('n', n); if(1 === args.length && 'object' === typeof args[0]){ for(var k in args[0]){ THAT.settings[k]=args[0][k]; } return this; }else if(1 === args.length && 'string' === typeof args[0]){ return n; }else if(2 === args.length && 'string' === typeof args[0]){ n = args[1]; return this; }else if(0 === args.length){ return settings; }else{ return undefined; } }; if('undefined'===typeof config.widget.preference_asArray){ config.widget.preference_asArray = []; } frdl.each(config.widget.preference_asArray,function(k,preference){ var n = preference._name; var _n = THAT.settings; var Value = preference._value; var p = frdl.explode('.', n); _n = THAT.settings; frdl.each(p, function(i, seg){ /* if('undefined'===typeof _n[seg]){ _n[seg] = (i === p.length-1) ? new (class { get () { return Value; } }) : {}; } */ if('undefined'===typeof _n[seg]){ _n[seg] = (i === p.length-1) ? Value : {}; } _n = _n[seg]; }); // settings[preference._name]=preference._value; }); Object.defineProperty(this, 'Plugin', { get : function(){ var Plugin = frdl.ns.plugin(THAT.config.widget._id); if('undefined'===typeof Plugin.Widget){ Object.defineProperty(Plugin, 'Widget', { get : function(){ return THAT; } }); } return Plugin; }, set : function(newPluginContext){ frdl.ns.plugin(THAT.config.widget._id, newPluginContext); } }); /* var widget=frdl.a;frdl.ns.plugin('test.com', function Widget(TEST2){TEST2.hello='world';debug('Plugin', Plugin);debug('TEST2', TEST2.hello);}).exec(function(){Plugin.hest=TEST2;extend(Widget);debug('Plugin', Plugin);debug('Context', widget);}).Widget = widget; */ frdl.ns.plugin(THAT.config.widget._id, function $Component(){ // extend(THAT); // debug('context', context); extend(Plugin.Widget); }, THAT) .exec(function(Component){ extend(Component); }); /* this.Plugin.exec(function(Component){ debug('Plugin', Plugin); debug('{$}Component', Component); debug('context', context); debug('this', this); }); */ Object.defineProperty(this, 'GUID', { get : function(){ return frdl.ns.plugin(THAT.config.widget._id).id; } }); uiwidgets.push(this); } Widget.prototype.boot = function(){ var THAT = this; UI.defer(); function compile_after(code){ return code; } THAT.state.emit('boot', { widget: THAT }); //UI.defer(); // const webfanWidgetElement = document.createElement('webfan-widget'); // const shadowRoot = webfanWidgetElement.attachShadow({mode: 'open'}); // console.log('webfanWidgetElement', webfanWidgetElement); // webfanWidgetElement.setAttribute('test', 'widget-test...'); var _js = ''; frdl.each(THAT.js(), function(i, JS){ //eval(js); _js+= '\n'; _js+=JS.js; _js+= '\n'; }); THAT.Script = vm.createScript(_js, { filename : THAT.directory + '#*.js', compile : compile_after }); Object.defineProperty(THAT, 'With', { get : function(){ var Widget = this; return function(ctx){ var appname = Widget.angular.$app.name + '.$' + Widget.id; // frdl.a.module(appname, ['webfan.gui']); var $app=frdl.a.module(appname, frdl.a.modules); Widget.angular.modules.push(appname); ctx.Widget=Widget; // ctx.$app=Widget.angular.$app; ctx.App=$app; //ctx.global=global; // ctx.window=window; // ctx.angular=frdl.a; ctx.Plugin=Widget.Plugin; if(!Widget.Script)throw 'Widget.With : Script is not prepared'; var HTML = ''; frdl.each(Widget.css(), function(i, css){ HTML += '<style type="text/css">'+css +'</style>'; }); frdl.each(Widget.html(), function(i, html){ //var htm = frdl.ns.org.startpad.string.format(html, ctx); HTML += html; }); /* if(null===frdl.$q('*[ng-flows], *[ng-app], *[ng-module], *[ng-modules], *[ng-flow]', false, Widget.element) && !Widget.element.hasAttribute('ng-flows') ){ var appname = 'WidgetApp_' + Widget.id; frdl.a.module(appname, ['webfan.gui']); Widget.angular.modules.push(appname); }else{ $( Widget.widget.element ).data('$injector', ''); $( Widget.widget.element ).children().data('$injector', ''); } */ $( Widget.widget.element ).data('$injector', ''); $( Widget.widget.element ).children().data('$injector', ''); $( Widget.widget.element ).html(''); var appname = 'WidgetApp_' + Widget.id; var MyHTML = $(HTML); //, *[ng-app], *[ng-module], *[ng-modules], *[ng-flow] initNgFlows(element) var $flows = $(MyHTML).find('*[ng-flows], *[ng-app], *[ng-module], *[ng-modules], *[ng-flow], *[frdl-bind-context], frdl-bind-context'); var _context = ctx; frdl.each( $flows, function(i, $flow){ var $binds = $($flow).find('*[frdl-bind-context], frdl-bind-context'); if($flow.hasAttribute('frdl-bind-context')){ if('undefined'!==typeof global[$bind.getAttribute('frdl-bind-context')]){ _context = global[$bind.getAttribute('frdl-bind-context')]; }else if('undefined'!==typeof frdl[$bind.getAttribute('frdl-bind-context')]){ _context = frdl[$bind.getAttribute('frdl-bind-context')]; }else if('undefined'!==typeof ctx[$bind.getAttribute('frdl-bind-context')]){ _context = ctx[$bind.getAttribute('frdl-bind-context')]; } } $($flow).attr('ng-flows', frdl.ns.org.startpad.string.format($($flow).attr('ng-flows'), _context) ); $($flow).attr('ng-flows', frdl.ns.org.startpad.string.format($($flow).attr('ng-flows'), ctx) ); }); var $binds = $(MyHTML).find('*[frdl-bind-context], frdl-bind-context'); frdl.each($binds, function(i, $bind){ var _context = ctx; if($bind.hasAttribute('frdl-bind-context')){ if('undefined'!==typeof global[$bind.getAttribute('frdl-bind-context')]){ _context = global[$bind.getAttribute('frdl-bind-context')]; }else if('undefined'!==typeof frdl[$bind.getAttribute('frdl-bind-context')]){ _context = frdl[$bind.getAttribute('frdl-bind-context')]; }else if('undefined'!==typeof ctx[$bind.getAttribute('frdl-bind-context')]){ _context = ctx[$bind.getAttribute('frdl-bind-context')]; } } $($bind).html( frdl.ns.org.startpad.string.format( $($bind).html(), _context) ); // $($bind).html( frdl.ns.org.startpad.string.format( $($bind).html(), _context) ); }); var WidgetContext = Widget.Script.runInContext(vm.createContext(ctx)); if(Widget.widget.element.hasAttribute('ng-flows')){ Widget.widget.element.setAttribute('ng-flows', frdl.ns.org.startpad.string.format(Widget.widget.element.getAttribute('ng-flows'), ctx) ) ; } frdl.UI.defer(); $(Widget.widget.element).append(MyHTML); var $flows = $(Widget.widget.element).find('*[ng-flows], *[ng-app], *[ng-module], *[ng-modules], *[ng-flow], *[frdl-bind-context], frdl-bind-context'); var _context = ctx; frdl.each( $flows, function(i, $flow){ var $binds = $($flow).find('*[frdl-bind-context], frdl-bind-context'); if($flow.hasAttribute('frdl-bind-context')){ if('undefined'!==typeof global[$bind.getAttribute('frdl-bind-context')]){ _context = global[$bind.getAttribute('frdl-bind-context')]; }else if('undefined'!==typeof frdl[$bind.getAttribute('frdl-bind-context')]){ _context = frdl[$bind.getAttribute('frdl-bind-context')]; }else if('undefined'!==typeof ctx[$bind.getAttribute('frdl-bind-context')]){ _context = ctx[$bind.getAttribute('frdl-bind-context')]; } } $($flow).attr('ng-flows', frdl.ns.org.startpad.string.format($($flow).attr('ng-flows'), _context) ); $($flow).attr('ng-flows', frdl.ns.org.startpad.string.format($($flow).attr('ng-flows'), ctx) ); }); //vm.createContext(ctx) frdl.UI.load(); frdl.ready(function(){ frdl.webfan.$Async(function(){ frdl.UI.Compile(32); },32); }); return WidgetContext; }; } }); UI.defer(); THAT.angular.boot(THAT); // UI.load(); THAT.state.emit('loaded', { widget: THAT }); 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(){ return this.state.required.apply(this, arguments); }; Widget.prototype.getElement = function(){ return this.element; }; Widget.prototype.getID = function(){ return this.id; }; Widget.prototype.getWidget = function(tok){ return UI.getWidget(tok); }; baseObj[funcName]=Widget; }(frdl, 'Widget')); });//require(['feature!vm'], function(vm){ (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; }); 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')) ); }); customElements.whenDefined('webfan-widget').then(function() { frdl.watchFor('*[data-frdl-component*=":"]:not([data-frdl-component-initiated="true"])').every(function(el){ if(el.hasAttribute('data-frdl-component-initiated'))return; if('webfan-widget'===el.tagName.toLowerCase())return; let widgetComponent = document.createElement('webfan-widget'); widgetComponent.setAttribute('is', 'webfan-widget'); widgetComponent.setAttribute('data-frdl-component', el.getAttribute('data-frdl-component')); el.append(widgetComponent); }); }); }()); //WIDGETS? }()); (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.log('No WebApp Manifest file: '+errResult); manifest = errResult; } ); } this.getManifest = function(){ return manifest; }; 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!'); } }); } 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', frdl.webfan)); (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()) + '-' + frdl.Sha1.hash(new frdl.Url().urlMakeNew()) + '-' + Sha1.hash(document.title) +'" style="top:0px;left:0px;right:0px;bottom:0px;height:auto;width:auto;"></div>' ); } console.log('Prepare for jqm'); if(true===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'); }); 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); $('*[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); UI.isMobileTheme = true; }, '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 * @jquery.inputsearch : 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(){ } }; 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 UI; }; }()); (function(){ 'use strict'; var _DEF = navigator.language; var langs = ['de', 'en', 'fr', 'de_DE', 'en_GB', 'en_US', 'en_EN', 'fr_FR']; if (langs.indexOf(navigator.language) !== -1 && '_' !== _DEF) { _DEF = navigator.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 = navigator.language; if(2 > frdl.explode('_', _DEF).length){ _DEF = _DEF + '_' + _DEF.toUpperCase() } } return _DEF; }; frdl.getLang = function(){ var l = frdl.langDefault(); if(null !== typeof frdl.WebfanReadCookie('lang.user.selected')){ l = frdl.WebfanReadCookie('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.WebfanCreateCookie('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() { UI.emit('exit'); }, true); window.addEventListener("reload", function() { UI.emit('exit'); }, true); window.addEventListener('close', function(){ UI.emit('exit'); }); UI.once('exit', 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()); localStorage.setItem('frdl.debug.mode()', frdl.debug.mode()); }catch(err){ } }); UI.on('exit', sendStateBeacons); function getBeacondata(){ return frdl.$getBeacondata(frdl.plug('DOCUMENT.SESSION.BEACON')); } function sendStateBeacons(){ frdl.state.emit('Session:sendBeacon', getBeacondata() ); } (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(){ '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(){ 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('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(); 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('textarea[class="ed"]').every(function(el){ require('webfan/navigator/bbeditor', function(ed){ ed.edToolbar(el.getAttribute('id')); }); }); }()); (function(){ var Hash = frdl.Hash; function h(){ if('undefined'===typeof frdl.Hash || 'function'!==typeof frdl.Hash.pushState){ setTimeout(function(){ h(); },1); return; } 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{ require.state.once('resolved frdl.Hash', function(){ h(); }); } }()); (function(){ frdl.watchFor('*[name="frdl.inX.dictonary-file"]:not([frdl-processed="true"])').every(function(el){ if(!el.hasAttribute('content'))return true; el.setAttribute('frdl-processed', 'true'); frdl.ready(function(){ var lang = frdl.getLang(); if('_'===lang){ lang='de_DE'; } var uri = el.getAttribute('content'); var url = frdl.str_replace('{{PROTOCOL}}', location.protocol, uri ); url = frdl.str_replace('{{HOST}}', location.host, url ); url = frdl.str_replace('{{LANG}}', lang, url ); require(['frdlcjs!' + url], function(dictonary){ frdl.ready(function(){ frdl.inX.start(); frdl.inX.translate(); }); }); }); }); }()); (function(){ frdl.ready(function(){ webfan.$Async(function(){ UI.load(); 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; UI.widget(el); }, 1); }); */ webfan.$Async(function(){ UI.load(); UI.Compile(250); }, 1); }) ; }); $( window ).on( "mobileinit", function() { $.extend( $.mobile , UI.o.jQueryMobile.o); }); $(document).ready(function(){ if(true===UI.reduced()){ UI.rendering('forMinimal'); }else{ UI.rendering('forFullscreen'); } if( true === frdl.Device().isMobile || true === frdl.Device().isTablet /* || true === navigator.isMobile || true === navigator.isTablet !!require('modernizr').Modernizr.pointerevents && !!require('modernizr').Modernizr.touchevents */ ){ UI.rendering('forMobile'); } }); }()); // Copyright 1999-2017. Parallels IP Holdings GmbH. All Rights Reserved. /* responsive.js */ $(document).ready(function(){ //http://v4.thewatchmakerproject.com/blog/how-to-fix-the-broken-ipad-form-label-click-issue/ if (navigator.userAgent.match(/(iPad|iPhone|iPod)/i)) { $('label[for]').each(function(label) { label.observe('click', function() { var el = $(this).readAttribute('for'); var type = $(el).readAttribute('type'); if ('radio' == type || 'checkbox' == type) { $(el).writeAttribute('selected', !$(el).readAttribute('selected')); } else { $(el).focus(); } }); }); } if (navigator.userAgent.match(/IEMobile\/10\.0/)) { var msViewportStyle = document.createElement("style"); msViewportStyle.appendChild( document.createTextNode( "@-ms-viewport{width:auto!important}" ) ); document.getElementsByTagName("head")[0]. appendChild(msViewportStyle); } }); return UI; });