File: api-d/4/js-api/library.js/plugins/plugin.win.js

Recommend this page to a friend!
  Classes of Till Wehowski   µ.Flow   api-d/4/js-api/library.js/plugins/plugin.win.js   Download  
File: api-d/4/js-api/library.js/plugins/plugin.win.js
Role: Class source
Content type: text/plain
Description: Class source
Class: µ.Flow
General purpose library of objects
Author: By
Last change: Update plugin.win.js
Date: 8 years ago
Size: 18,444 bytes
 

Contents

Class file image Download
(function( $ ) { "use strict"; var ___FN___ = 'frdlWin'; var __id = 0; frdl.UI.defer(); /* frdl.ready(function(){ frdl.UI.defer(); angular.module('webfan') .controller('frdlWinCtrl', ['$scope', function($scope, $element) { }]) .controller('frdlWinBrowserCtrl', ['$scope', function($scope, $element) { $scope.url = $element.find('iframe').attr('src'); }]) ; }); */ /* .controller('frdlWinBrowserCtrl', ['$scope', function($scope) { $scope = angular.element('[ng-controller=CtrlName]').scope(); }]) */ $.fn[___FN___] = function(){ var T = $(this), args = arguments, method; this.child_ids = []; this.options = { browser_showurlinput : false, browser_showmenu : false, browser_savehistory : false }; var _win = function( w, id ) { if('undefined' === typeof id)var id = this.id; w.title = ('string' === typeof w.title) ? w.title : '<span>UNTITLED</span> [' + frdl.wd().Registry.Windows.length + ']'; if('string' === typeof w.html_aside)w.aside = w.html_aside; if('string' === typeof w.html_main)w.main = w.html_main; if('string' === typeof w.html_bottom)w.bottom = w.html_bottom; var win = { mid : id, img : ('string' === typeof w.img) ? w.img : 'http://static.webfan.de/icons/icons-3/page.gif', title : w.title, html_aside : ('string' === typeof w.aside) ? w.aside : '', html_main : ('string' === typeof w.main) ? w.main : '', html_bottom : ('string' === typeof w.bottom) ? w.bottom : w.title, pages : ('array' === typeof w.pages) ? w.pages : [], exec : function(ev){ }, parent : ('undefined' !== typeof w.parent) ? w.parent : null, parent_modul : ('undefined' !== typeof w.parent_modul) ? w.parent_modul : null, parent_window : ('undefined' !== typeof w.parent_window) ? w.parent_window : null, parent_icon : ('undefined' !== typeof w.parent_icon) ? w.parent_icon : null, childs : ('undefined' !== typeof w.childs) ? w.childs : {}, refs : ('undefined' !== typeof w.refs) ? w.refs : [], data : ('undefined' !== typeof w.data) ? w.data : null , Graph : ('undefined' !== typeof w.Graph) ? w.Graph : null, openByDefault : ('undefined' !== typeof w.openByDefault) ? w.openByDefault : false, opened : ('undefined' !== typeof w.opened) ? w.opened : false , persistent : ('undefined' !== typeof w.persistent) ? w.persistent : true }; return win; }; var _s = { persistent : function(v, THIS){ $('#window_' + THIS.id).attr('data-window-persistent', v.toString()); return v; }, title : function(v, THIS){ $('#window_' + THIS.id).find('.window_top').find('.window-top-title-span').html(v); frdl.wd().translate(); return v; }, img : function(v, THIS){ $('#window_' + THIS.id).find('.window_top').find('.wd-frdl-desktop-window-image-icon').attr('src', v); frdl.wd().translate(); return v; }, html_aside : function(v, THIS){ $('#window_aside_' + THIS.id).html(v); frdl.wd().translate(); return v; }, html_main : function(v, THIS){ $('#window_main_' + THIS.id).html(v); frdl.wd().translate(); return v; }, html_bottom : function(v, THIS){ $('#window_bottom_' + THIS.id).html(v); frdl.wd().translate(); return v; } }; this.addScreen = function(div){ if('object' === typeof div){ Dom.add(div, Dom.g('window_main_' + this.id), true); return this; }else if ('string' === typeof div){ } }; this.addRef = function(r, id){ if('undefined' !== typeof id && 'object' === typeof r)r.id = id; this.w.refs.push(r); return this; }; this.removeRefWith = function(id){ var ID = id; frdl.filterObject( this.w.refs, function(r){ return (null !== r && 'undefined' !== typeof r && r.id !== ID); }); return this; }; this.removeRefAt = function(ix){ this.w.refs.splice(ix,1); frdl.filterObject( this.w.refs, function(r){ return (null !== r && 'undefined' !== typeof r ); }); return this; }; this.addChild = function(id, c){ if(null === id)id = 'wd-window-child-element-' + Guid.newGuid(); if('object' === typeof c)c.id = id; this.w.childs[id] = c; return this; }; this.removeChild = function(id){ var ID = id; delete this.w.childs[id]; frdl.filterObject( this.w.childs , function(c){ return (null !== c && 'undefined' !== typeof c && c.id !== ID); }); return this; }; this.get = function(k){ return (this.w.hasOwnProperty(k)) ? this.w[k] : null; }; this.set = function(k,v){ var THIS = this; if(THIS.w.hasOwnProperty(k) || 'function' === typeof THIS.w[k]){ THIS.w[k] = ('function' === typeof _s[k]) ? _s[k](v, THIS) : v; }else{ console.warn('Warning: Cannot set undefined property $.fn.frdlWin.w.' + k ); } frdl.wd().translate(); return THIS; }; this.add = function( win, Desktop ) { var THIS = this; if('undefined' === typeof Desktop)var Desktop = frdl.wd(); if('undefined' === typeof win)var win = this.w; function render(Desktop, win){ var _width_sitebar = '120px', T = THIS, WIN =win; var toggleFunc = function(ev){ $('#window_aside_' + WIN.mid).toggle(); }; var div = Dom.create("div"); $(div).wrapAll('<frdl></frdl>'); div.setAttribute("id", "window_" + win.mid); div.setAttribute("role", "window"); div.setAttribute("class", "abs window"); div.setAttribute("data-isloaded", "false"); div.setAttribute("data-window-id", win.mid); div.setAttribute("data-window-persistent", win.persistent.toString()); /* div.setAttribute("ng-flows", "webfan, csrf-cross-domain"); div.setAttribute("ng-controller", "frdlWinCtrl as win"+__id+'n'+mt_rand(10000000,9999999999999999)); */ /* div.setAttribute("data-role", "page"); div.setAttribute("data-dom-cache", "false"); div.setAttribute("data-title", T.get('title')); frdlWinCtrl */ div.style.height = "750px"; div.style.width = "950px"; if(true === BrowserDetect.isTablet || true === BrowserDetect.isMobile){ div.style.width = "90%"; div.style.height = "90%"; } var div_inner = Dom.create("div"); div_inner.setAttribute("class", "window_inner"); Dom.add(div_inner, div); var div_top = Dom.create("div"); div_top.setAttribute("class", "window_top"); Dom.add(div_top, div_inner); var span = Dom.create("span"); span.setAttribute("class", "float_left"); Dom.add(span, div_top); var img = Dom.create("img"); img.setAttribute("src", win.img); img.setAttribute("class", 'wd-frdl-desktop-window-image-icon'); img.setAttribute("title", 'Toggle Menu'); Dom.add(img, span); $(span).append('<span class="window-top-title-span">' + win.title + '</span>'); $(div_top).append('<span class="mlink" style="font-size:0.7em;padding-left:15px;cursor:pointer;">[<u>Menu</u>]</span> <span class="float_right"> <a href="#" class="window_min"></a> <a href="#" class="window_resize"></a> <a href="#icon_dock_' + win.mid + '" class="window_close"></a> </span>'); $(div_inner).append(' <div class="abs window_content"> <div id="window_aside_' + win.mid + '" class="window_aside"> ' + win.html_aside + ' </div> <div id="window_main_' + win.mid + '" class="window_main">' + win.html_main + '</div> </div> '); $(div_inner).append(' <div id="window_bottom_' + win.mid + '" class="abs window_bottom">' + win.html_bottom + '</div> '); frdl.ready(function(){ $(div).find('span.window-top-title-span, span.mlink, img.wd-frdl-desktop-window-image-icon').on('click', function(ev){ ev.stopPropagation(); ev.preventDefault(); $('.window_top').css('padding-top', '0px'); $('.window_top').css('top', '0px'); frdl.Dom.bringToFront($('window_main_' + WIN.mid)); toggleFunc(); return false; }); }); $(div).append('<span class="abs ui-resizable-handle ui-resizable-se"></span>'); Dom.add(div, Desktop.desktop); $(Desktop.dock).prepend('<li id="icon_dock_' + win.mid + '"> <a href="#window_' + win.mid + '"> <img src="' + win.img + '" /> ' + win.title + ' </a> </li>'); $(div).bind('show', function(event, e_args){ var x = '#icon_dock_' + win.mid; if ($(x).is(':hidden')) { $(x).remove().appendTo('#dock'); $(x).fadeIn('slow'); } $.JQD.util.window_flat(); $($(this)).addClass('window_stack'); if(!Dom.isVisible('desktop')){ frdl.wd().toggleDesktop(); } }); $(div).bind('hide', function(event, e_args){ var x = '#icon_dock_' + win.mid, t = T; if ($(x).is(':hidden')) { try{ if('false' === this.getAttribute('data-window-persistent') && 'closed' === this.getAttribute('data-state') && 'undefined' !== typeof t.parent && 'undefined' !== typeof t.parent.id){ frdl.wd().kill(t.parent.id); $(this).remove(); } }catch(err){ if(true===frdl.wd().o.debug)console.notice('Notice: Cannot kill window parent task: ' + err); } } }); /* $(div).on('show', function(e){ var x = '#icon_dock_' + win.mid; var y = $(x).find('a').attr('href'); if ($(x).is(':hidden')) { $(x).remove().appendTo('#dock'); $(x).show('slow'); } $.JQD.util.window_flat(); $(y).addClass('window_stack').show(); Dom.bringToFront($(this)); }); */ /* $(div).trigger('pagecreate'); */ if(true===frdl.UI.reduced()){ toggleFunc(); } /* frdl.ready(function(){ angular.element(document).ready(function() { angular.bootstrap(div, ['frdl']); }); }); */ /* angular.bootstrap(div, ['frdl']); */ } Desktop.Registry.Windows.push(this); render(Desktop, win); if(true === win.openByDefault)win.exec(); frdl.UI.load(); $(document).trigger('readystatechange'); Desktop.desktop_html = $('#desktop').html(); return this; }; this.create = function(){ /* document.dispatchEvent(new Event('readystatechange'), document); */ frdl.UI.defer(); __id++; var W = Object.create(this, {}); var w = ('undefined' !== typeof arguments[0]) ? arguments[0] : null; W.options = ('undefined' !== typeof arguments[1]) ? $.extend(W.options, arguments[1]) : W.options; do{w = w.shift()}while('array' === typeof w); if('string' === typeof w){ w = { title : w }; } W.id =(('undefined' !== typeof w.mid) ? w.mid : 'frdl-webfan-desktop-window-' + Sha1.hash(w.title) ) + (('undefined' === typeof w.mutex || false === w.mutex) ? '-' + Guid.newGuid() :'' ) ; W.w = _win( w, W.id ) ; if(true === W.w.openByDefault)W.w.opened = true; if(false === W.w.openByDefault)W.w.opened = false; var THIS = W;/* frdl.wd().resetReady('Loading...',25, function(){ var t = THIS; var r= ( 'undefined' !== typeof Dom.g('window_' + t.id) && null !== typeof Dom.g('window_' + t.id) /* && (true !== t.w.opened || Dom.isVisible('window_' + t.id)) * /) ? true : false; if(true !== r) return r; if(true === t.w.opened){ Dom.bringToFront('#window_' + t.id); } return true; } ); */ if(true !== w.mutex || false === frdl.wd().getWin(W.id)) W.add(); if('undefined'!==typeof $.JQD) if('undefined'!== typeof $.JQD.init) if('function'!== typeof $.JQD.init.desktop) $.JQD.init.desktop(frdl.wd()); if(true === W.w.opened){ $('#window_' + W.id ).show(); } frdl.UI.load(); /* return Object.create(this, {}); */ return W; }; this.browser = function(url, options){ frdl.UI.defer(); window.location.href='#'; var THIS = this, loading = true, s = false; var opts = ('undefined' !== typeof options) ? $.extend(THIS.options, options) : THIS.options; var DIV = Dom.g('window_main_' + THIS.id); if('undefined' === DIV || null === DIV){ var msg = 'Fatal error: The frdl.win.browser window-ID or its window is undefined!'; alert(msg); return console.error(msg); } var loader = '<img src="http://images.webfan.de/ajax-loader_2.gif" alt="lade..." style="border:none;" class="img-ajax-loader" />'; $('#window_main_' + THIS.id).html(loader); $('#window_bottom_' + THIS.id).html('<span>If you like to open a new window, press shift while clicking the link</span>'); /* $(DIV).wrapInner('<frdl><div></div></frdl>'); */ var wrap = frdl.Dom.create('div'); /* wrap.setAttribute("ng-flows", "webfan, csrf-cross-domain"); */ /* wrap.setAttribute('ng-controller', 'frdlWinBrowserCtrl as browser'+__id+'n'+mt_rand(10000000,9999999999999999));*/ frdl.Dom.add(wrap, DIV); var idFrame = 'wd-frame-browser-' + Sha1.hash(url) + '-' + Guid.newGuid(); var frame = Dom.create('iframe'); frame.style.width='100%'; frame.setAttribute('src', 'about:blank'); var inp = Dom.create('input'); inp.setAttribute('type', 'text'); /* inp.setAttribute('ng-model', 'url'); inp.setAttribute('ng-value', 'url'); inp.setAttribute('ng-model-options', '{ updateOn: \'blur, keypress\' }'); */ inp.setAttribute('data-frdl-mod', 'browserbar'); inp.setAttribute('id', 'INPUT-BROWSER-URL-' + THIS.id); inp.style.width='99%'; inp.style.display='inline'; $(inp).on('keypress', function(e){ var keycode = e.which || e.keyCode; switch( keycode ) { case 13: case 9: frame.setAttribute('src', this.value); break; } }); $(inp).on('onblur', function(e){ $(this).trigger('keypress', e); }); Dom.add(inp, wrap); if(true === opts.browser_showurlinput){ inp.style.display='inline'; } else{ inp.style.display='none'; } $(frame).on('load', function(ev){ if(this.readyState === "loaded" || this.readyState === "complete"){ loading = false; } }); $(frame).on('unload', function(ev){ loading = true; var t = THIS, i = inp; frdl.wd().resetReady('Loading...',45, function(){ if(false !== loading) return false; return true; } ); }); $(frame).on('readystatechange', function(ev){ loading = true; if(this.readyState === "loaded" || this.readyState === "complete"){ loading = false; } if(false===s) { s=true; frdl.wd().resetReady('Loading...',45, function(){ if(false !== loading) return false; s=false; $(document).trigger('readystatechange'); return true; } ); } }); frame.style.width='100%'; frame.style.height='100%'; frame.style.minHeight='750px'; frame.setAttribute('src', url); /*frame.setAttribute('ng-src', '{{url}}');*/ frame.setAttribute('data-id-desktop-window', THIS.id); Dom.add(frame, wrap); frdl.UI.load(); }; if(args.length > 0){ var a = $(args).toArray(); method = a.shift(); if('function' === typeof this[method] && '_' !== method.substr(1))return this[method](a); } return this; }; }( jQuery ));