File: components/webfan/workspace/js/webfan.gui.MenuCtrl.js

Recommend this page to a friend!
  Classes of Till Wehowski   µ.Flow   components/webfan/workspace/js/webfan.gui.MenuCtrl.js   Download  
File: components/webfan/workspace/js/webfan.gui.MenuCtrl.js
Role: Class source
Content type: text/plain
Description: Class source
Class: µ.Flow
General purpose library of objects
Author: By
Last change: Update webfan.gui.MenuCtrl.js
Date: 8 years ago
Size: 8,144 bytes
 

Contents

Class file image Download
/* webfan (C) Till Wehowski, Webfan.de - All rights reserved. */ /** <ul ng-flows="webfan.gui" ng-controller="MenuCtrl" id="{{main.id}}" role="menu" style="display: inline;"> <li ng-repeat="(id, Menu) in main.menu" id="{{id}}"> <a class="menu_trigger" href="javascript:;" ng-bind-html="Menu.title"></a> <ul class="menu" flow-menu-id="{{id}}-{{Menu.title}}" style="display: none; z-index: 1007;"> <li ng-repeat="item in Menu.items"> <a href="javascript:;" ng-click="item.on(item.url)" ng-bind-html="item.title"></a> </li> </ul> </li> </ul> var _Menu_Webfan = ''; _Menu_Webfan+='<ul ng-flows="webfan.gui" ng-controller="MenuCtrl" id="{{main.id}}" role="menu" style="display: inline;">'; _Menu_Webfan+=' <li ng-repeat="(id, Menu) in main.menu" id="{{id}}"> '; _Menu_Webfan+=' <a class="menu_trigger" href="javascript:;" ng-bind-html="Menu.title"></a> '; _Menu_Webfan+=' <ul class="menu" flow-menu-id="{{id}}-{{Menu.title}}" style="display: none; z-index: 1007;"> '; _Menu_Webfan+=' <li ng-repeat="item in Menu.items">'; _Menu_Webfan+=' <a href="javascript:;" ng-click="item.on(item.url)" ng-bind-html="item.title"></a> '; _Menu_Webfan+=' </li> '; _Menu_Webfan+=' </ul>'; _Menu_Webfan+=' </li>'; _Menu_Webfan+='</ul> '; */ var SCOPE; var mod = frdl.overload(Object.create({}), function(name,args){ if('function' === typeof SCOPE[name])return SCOPE[name].apply(SCOPE, args); if('undefined' !== typeof SCOPE[name])return SCOPE[name]; console.error(__FILE__ + '::' + name + ' is UNRESOLVED!'); }); frdl.a .module('webfan.gui') .controller('MenuCtrl', ['$scope', '$http', '$sce', function($scope, $http, $sce){ var jDialogBox = $('#'+frdl.wd().o.doms.DialogBoxModal.substr(1,frdl.wd().o.doms.DialogBoxModal.length)); var w = window.top || window; var isTabs = function(){ return ('function' === typeof w.Tabs) ? true : false; }; $scope.main = { id : 'menu_top', menu : { 'menu_top_desktop' : { title : $sce.trustAsHtml('<span>Workspace</span>'), items : [ { title : $sce.trustAsHtml('<span>Toggle</span>'), on : function(){ frdl.wd().toggleDesktop(); }, url : '#' }, { title : $sce.trustAsHtml('Exit'), on : function(){ frdl.alert.log('ToDo: Save data and shutdown methods...'); frdl.alert.confirm('Exit now?', function(yes){ if(yes){ if(true === navigator['-webkit-webfan']){ navigator.webfan.quit(); }else{ if(!!window.opener){ window.close(); }else{ frdl.alert.error('Cannot close top window by script. Use your browser please!'); } } }else{ /* frdl.alert.log('Abort.'); */ } }); }, url : '#' } ] }, 'menu_top_program': { title : $sce.trustAsHtml('<span>Program</span>'), items : [ ] }, 'menu_top_open': { title : $sce.trustAsHtml('<span>File</span>'), items : [ ] }, 'menu_top_about': { title : $sce.trustAsHtml('<span>Help</span>'), items : [ { title : $sce.trustAsHtml('<span>About</span>...'), on : function(){ var url = Array.prototype.slice.call(arguments)[0]; if('function'===typeof w.Tabs){ if(true===navigator['-webkit-webfan']){ w.Tabs().addTab('Credits', webfan['$fs --local root']() + 'credits.html', null, 'frame.trusted', true, undefined, true); } setTimeout(function(){ w.Tabs().addTab('About...', url, null, ((true===navigator['-webkit-webfan']) ? 'frame.trusted' : 'browser'), true, undefined, true); }, 250); }else{ jDialogBox.wd_dialogs({loadUrl : url, title : 'About...'}); } }, url : (true===navigator['-webkit-webfan']) ? './about.html' : webfan['$root-app']() + '/cdn/application/webfan/about.html' }, { title : $sce.trustAsHtml('<span>Support</span>'), on : function(){ var url = Array.prototype.slice.call(arguments)[0]; if('function'===typeof w.Tabs){ w.Tabs().addTab('Support', url, null, 'browser', true, undefined, true); }else{ jDialogBox.wd_dialogs({loadUrl : url, title : 'Support'}); } }, url : 'http://www.webfan.de/TicketSystem.html' }, { title : $sce.trustAsHtml('<span>imprint</span>'), on : function(){ var url = Array.prototype.slice.call(arguments)[0]; if('function'===typeof w.Tabs){ w.Tabs().addTab('imprint', url, null, 'browser', true, undefined, true); }else{ jDialogBox.wd_dialogs({loadUrl : url, title : 'imprint'}); } }, url : 'http://www.webfan.de/Impressum.html' } ] } } }; $scope.add = function(parent, menu){ menu.title = $sce.trustAsHtml(menu.title); $scope.main.menu[parent].items.push(menu); return $scope; }; $scope.remove = function(parent, menu){ if('string' === menu){ frdl.each($scope.main.menu[parent], function(i, m){ if(menu === m.title || menu === m.url){ menu = m; } }); } $scope.main.menu[parent].items.splice($scope.main.menu[parent].items.indexOf(menu), 1); return $scope; }; $scope.addOpenedTabs = function(tabs){ var items = []; frdl.each(tabs, function(i, tab){ items.push({ title : $sce.trustAsHtml(tab.title), on : tab.open, url : tab.url }); }); $scope.main.menu.menu_top_open.items = items; $scope.$digest(); }; $scope.getOpenTags = function(apply){ var tabs = [{ title : '<span>My.Webfan</span>', open : function(){ var url = Array.prototype.slice.call(arguments)[0]; try{ if( true === isTabs() ){ w.Tabs().addTab('Start', '/com.webfan.my/' + 'start', '', 'html', false, {name:'start', params:{}}, true, false); }else{ window.location.href = url; } } catch(err){ console.error(err); } }, url : webfan['$root-app']() + '/cdn/application/webfan/app.html' }]; if(true === isTabs())tabs = w.Tabs().tabs; if(0<tabs.length && true === apply){ $scope.addOpenedTabs(tabs); } return tabs; }; /* $scope.$watchCollection(function(scope) { return $scope.getOpenTags(false); }, function(newValue, oldValue) { if(newValue.length !== oldValue.length) { $scope.getOpenTags(true); } }); */ var watchTags = function(){ $scope.getOpenTags(true); frdl.translate(); webfan.$Async(watchTags,4000); }; webfan.$Async(function(){ watchTags(); },1); /* frdl.cron.add('webfan.gui.MenuCtrl.addOpenedTabs-from-getOpenTags', function(){ $scope.getOpenTags(true); }); webfan.$Async(function(){ frdl.ready(frdl.translate); },5000); */ SCOPE = $scope; }]); exports = module.exports = mod;