From 2cf8bde6b9e111573c268a2d896de52c294e5f1f Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 6 May 2015 00:34:22 +0200 Subject: [PATCH] Added proper overriding using decorator pattern --- luciexpress/htdocs/js/app.js | 20 +++-- luciexpress/htdocs/js/init.js | 37 ++++----- luciexpress/htdocs/plugins/core/plugin.json | 7 ++ .../core}/widgets/luci.footer.html | 0 .../core}/widgets/luci.footer.js | 4 +- .../core}/widgets/luci.layout.naked.html | 0 .../core}/widgets/luci.layout.naked.js | 4 +- .../widgets/luci.layout.single_column.html | 0 .../widgets/luci.layout.single_column.js | 4 +- .../widgets/luci.layout.with_sidebar.html | 0 .../core}/widgets/luci.layout.with_sidebar.js | 4 +- .../core}/widgets/luci.nav.html | 0 .../core}/widgets/luci.nav.js | 4 +- .../core}/widgets/luci.navbar.html | 0 .../core}/widgets/luci.navbar.js | 4 +- .../core}/widgets/luci.top_bar.html | 0 .../core}/widgets/luci.top_bar.js | 4 +- .../settings/pages/settings.password.js | 1 + .../htdocs/themes/inteno-red/theme.json | 7 -- .../themes/inteno-red/widgets/luci.footer.js | 50 ------------ .../inteno-red/widgets/luci.layout.naked.js | 35 --------- .../widgets/luci.layout.single_column.js | 38 --------- .../widgets/luci.layout.with_sidebar.js | 39 ---------- .../themes/inteno-red/widgets/luci.nav.js | 78 ------------------- .../themes/inteno-red/widgets/luci.navbar.js | 71 ----------------- .../themes/inteno-red/widgets/luci.top_bar.js | 34 -------- .../htdocs/themes/vodaphone/theme.json | 8 +- .../htdocs/themes/vodaphone/vodaphone.js | 19 ++++- .../vodaphone.layout.single_column.html | 22 ------ .../widgets/vodaphone.layout.single_column.js | 0 .../vodaphone.layout.with_sidebar.html | 46 ----------- .../widgets/vodaphone.layout.with_sidebar.js | 48 ------------ 32 files changed, 73 insertions(+), 515 deletions(-) rename luciexpress/htdocs/{themes/inteno-red => plugins/core}/widgets/luci.footer.html (100%) rename luciexpress/htdocs/{themes/vodaphone => plugins/core}/widgets/luci.footer.js (95%) rename luciexpress/htdocs/{themes/inteno-red => plugins/core}/widgets/luci.layout.naked.html (100%) rename luciexpress/htdocs/{themes/vodaphone => plugins/core}/widgets/luci.layout.naked.js (93%) rename luciexpress/htdocs/{themes/inteno-red => plugins/core}/widgets/luci.layout.single_column.html (100%) rename luciexpress/htdocs/{themes/vodaphone => plugins/core}/widgets/luci.layout.single_column.js (93%) rename luciexpress/htdocs/{themes/inteno-red => plugins/core}/widgets/luci.layout.with_sidebar.html (100%) rename luciexpress/htdocs/{themes/vodaphone => plugins/core}/widgets/luci.layout.with_sidebar.js (93%) rename luciexpress/htdocs/{themes/inteno-red => plugins/core}/widgets/luci.nav.html (100%) rename luciexpress/htdocs/{themes/vodaphone => plugins/core}/widgets/luci.nav.js (96%) rename luciexpress/htdocs/{themes/inteno-red => plugins/core}/widgets/luci.navbar.html (100%) rename luciexpress/htdocs/{themes/vodaphone => plugins/core}/widgets/luci.navbar.js (96%) rename luciexpress/htdocs/{themes/inteno-red => plugins/core}/widgets/luci.top_bar.html (100%) rename luciexpress/htdocs/{themes/vodaphone => plugins/core}/widgets/luci.top_bar.js (91%) delete mode 100644 luciexpress/htdocs/themes/inteno-red/widgets/luci.footer.js delete mode 100644 luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.naked.js delete mode 100644 luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.single_column.js delete mode 100644 luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.with_sidebar.js delete mode 100644 luciexpress/htdocs/themes/inteno-red/widgets/luci.nav.js delete mode 100644 luciexpress/htdocs/themes/inteno-red/widgets/luci.navbar.js delete mode 100644 luciexpress/htdocs/themes/inteno-red/widgets/luci.top_bar.js delete mode 100644 luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.single_column.html delete mode 100644 luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.single_column.js delete mode 100644 luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.with_sidebar.html delete mode 100644 luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.with_sidebar.js diff --git a/luciexpress/htdocs/js/app.js b/luciexpress/htdocs/js/app.js index fc2329dd3..8e910e653 100644 --- a/luciexpress/htdocs/js/app.js +++ b/luciexpress/htdocs/js/app.js @@ -91,9 +91,13 @@ angular.module("luci") $juci.controller = $controllerProvider.register; $juci.directive = $compileProvider.directive; $juci.state = $stateProvider.state; + $juci.decorator = function(name, func){ + return $provide.decorator(name, func); + } $juci.config = angular.module("luci").config; $juci.$stateProvider = $stateProvider; + /*$provide.decorator("luciFooterDirective", function($delegate){ console.log(JSON.stringify($delegate[0])); return $delegate; @@ -171,13 +175,15 @@ angular.module("luci") //$state.go("login"); }); }) - .directive("luciFooter", function(){ - var plugin_root = $juci.module("core").plugin_root; - - return { - restrict: "E" - }; -}) + +.directive("luciFooter", function(){ return {} }) +.directive("luciLayoutNaked", function(){ return {} }) +.directive("luciLayoutSingleColumn", function(){ return {} }) +.directive("luciLayoutWithSidebar", function(){ return {} }) +.directive("luciNav", function(){ return {} }) +.directive("luciNavbar", function(){ return {} }) +.directive("luciTopBar", function(){ return {} }) + angular.module("luci") .factory("$hosts", function($rpc, $uci){ var hosts = {}; diff --git a/luciexpress/htdocs/js/init.js b/luciexpress/htdocs/js/init.js index 752344063..ff05738c9 100644 --- a/luciexpress/htdocs/js/init.js +++ b/luciexpress/htdocs/js/init.js @@ -20,24 +20,6 @@ angular.module("luci") // TODO: use rpc next(); }, - function(next){ - // TODO: this will be moved somewhere else. What we want to do is - // pick both a theme and plugins based on the router model. - console.log("Detected hardware model: "+$config.system.hardware); - var themes = { - "CG300A": "inteno-red" - }; - $config.mode = $localStorage.getItem("mode") || "basic"; - $config.theme = $localStorage.getItem("theme") || themes[$config.system.hardware] || "inteno-red"; - - //$config.theme = "default"; - - $theme.changeTheme($config.theme).done(function(){ - next(); - }).fail(function(){ - next(); - }); - }, function(next){ progress("Loading plugins..", 8); var count = 0; @@ -47,6 +29,7 @@ angular.module("luci") var plugin_root = "plugins/"+id; $http.get(plugin_root + "/plugin.json") .success(function(data){ + console.log("found plugin "+id); $juci.module(id, plugin_root, data); if(data && data.scripts){ data.scripts.map(function(x){scripts.push(plugin_root + "/" + x); }); @@ -97,6 +80,24 @@ angular.module("luci") next(); }); }, + function(next){ + // TODO: this will be moved somewhere else. What we want to do is + // pick both a theme and plugins based on the router model. + console.log("Detected hardware model: "+$config.system.hardware); + var themes = { + "CG300A": "inteno-red" + }; + $config.mode = $localStorage.getItem("mode") || "basic"; + $config.theme = $localStorage.getItem("theme") || themes[$config.system.hardware] || "inteno-red"; + + //$config.theme = "default"; + + $theme.changeTheme($config.theme).done(function(){ + next(); + }).fail(function(){ + next(); + }); + }, function(next){ async.each(scripts, function(script, next){ //console.log("...."+script); diff --git a/luciexpress/htdocs/plugins/core/plugin.json b/luciexpress/htdocs/plugins/core/plugin.json index e06ee2beb..3cfbc4782 100644 --- a/luciexpress/htdocs/plugins/core/plugin.json +++ b/luciexpress/htdocs/plugins/core/plugin.json @@ -5,6 +5,13 @@ "widgets/luci.progress", "widgets/luci.table", "widgets/luci.config", + "widgets/luci.layout.naked", + "widgets/luci.layout.single_column", + "widgets/luci.layout.with_sidebar", + "widgets/luci.footer", + "widgets/luci.nav", + "widgets/luci.navbar", + "widgets/luci.top_bar", "widgets/uci.firewall.nat.rule.edit", "widgets/core.modal", "widgets/luci.input.port" diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.footer.html b/luciexpress/htdocs/plugins/core/widgets/luci.footer.html similarity index 100% rename from luciexpress/htdocs/themes/inteno-red/widgets/luci.footer.html rename to luciexpress/htdocs/plugins/core/widgets/luci.footer.html diff --git a/luciexpress/htdocs/themes/vodaphone/widgets/luci.footer.js b/luciexpress/htdocs/plugins/core/widgets/luci.footer.js similarity index 95% rename from luciexpress/htdocs/themes/vodaphone/widgets/luci.footer.js rename to luciexpress/htdocs/plugins/core/widgets/luci.footer.js index fb650cd29..fb53761e6 100644 --- a/luciexpress/htdocs/themes/vodaphone/widgets/luci.footer.js +++ b/luciexpress/htdocs/plugins/core/widgets/luci.footer.js @@ -20,9 +20,9 @@ * 02110-1301 USA */ -$juci.module("vodaphone") +$juci.module("core") .directive("luciFooter", function(){ - var plugin_root = $juci.module("vodaphone").plugin_root; + var plugin_root = $juci.module("core").plugin_root; return { templateUrl: plugin_root+"/widgets/luci.footer.html", diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.naked.html b/luciexpress/htdocs/plugins/core/widgets/luci.layout.naked.html similarity index 100% rename from luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.naked.html rename to luciexpress/htdocs/plugins/core/widgets/luci.layout.naked.html diff --git a/luciexpress/htdocs/themes/vodaphone/widgets/luci.layout.naked.js b/luciexpress/htdocs/plugins/core/widgets/luci.layout.naked.js similarity index 93% rename from luciexpress/htdocs/themes/vodaphone/widgets/luci.layout.naked.js rename to luciexpress/htdocs/plugins/core/widgets/luci.layout.naked.js index 19f4d120a..859ff53bc 100644 --- a/luciexpress/htdocs/themes/vodaphone/widgets/luci.layout.naked.js +++ b/luciexpress/htdocs/plugins/core/widgets/luci.layout.naked.js @@ -20,9 +20,9 @@ * 02110-1301 USA */ -$juci.module("vodaphone") +$juci.module("core") .directive("luciLayoutNaked", function(){ - var plugin_root = $juci.module("vodaphone").plugin_root; + var plugin_root = $juci.module("core").plugin_root; return { templateUrl: plugin_root+"/widgets/luci.layout.naked.html", transclude: true, diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.single_column.html b/luciexpress/htdocs/plugins/core/widgets/luci.layout.single_column.html similarity index 100% rename from luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.single_column.html rename to luciexpress/htdocs/plugins/core/widgets/luci.layout.single_column.html diff --git a/luciexpress/htdocs/themes/vodaphone/widgets/luci.layout.single_column.js b/luciexpress/htdocs/plugins/core/widgets/luci.layout.single_column.js similarity index 93% rename from luciexpress/htdocs/themes/vodaphone/widgets/luci.layout.single_column.js rename to luciexpress/htdocs/plugins/core/widgets/luci.layout.single_column.js index 8559271b8..a340ad83f 100644 --- a/luciexpress/htdocs/themes/vodaphone/widgets/luci.layout.single_column.js +++ b/luciexpress/htdocs/plugins/core/widgets/luci.layout.single_column.js @@ -20,9 +20,9 @@ * 02110-1301 USA */ -$juci.module("vodaphone") +$juci.module("core") .directive("luciLayoutSingleColumn", function(){ - var plugin_root = $juci.module("vodaphone").plugin_root; + var plugin_root = $juci.module("core").plugin_root; return { // accepted parameters for this tag scope: { diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.with_sidebar.html b/luciexpress/htdocs/plugins/core/widgets/luci.layout.with_sidebar.html similarity index 100% rename from luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.with_sidebar.html rename to luciexpress/htdocs/plugins/core/widgets/luci.layout.with_sidebar.html diff --git a/luciexpress/htdocs/themes/vodaphone/widgets/luci.layout.with_sidebar.js b/luciexpress/htdocs/plugins/core/widgets/luci.layout.with_sidebar.js similarity index 93% rename from luciexpress/htdocs/themes/vodaphone/widgets/luci.layout.with_sidebar.js rename to luciexpress/htdocs/plugins/core/widgets/luci.layout.with_sidebar.js index c7f3108c1..ee8efe2c4 100644 --- a/luciexpress/htdocs/themes/vodaphone/widgets/luci.layout.with_sidebar.js +++ b/luciexpress/htdocs/plugins/core/widgets/luci.layout.with_sidebar.js @@ -20,9 +20,9 @@ * 02110-1301 USA */ -$juci.module("vodaphone") +$juci.module("core") .directive("luciLayoutWithSidebar", function(){ - var plugin_root = $juci.module("vodaphone").plugin_root; + var plugin_root = $juci.module("core").plugin_root; return { // accepted parameters for this tag diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.nav.html b/luciexpress/htdocs/plugins/core/widgets/luci.nav.html similarity index 100% rename from luciexpress/htdocs/themes/inteno-red/widgets/luci.nav.html rename to luciexpress/htdocs/plugins/core/widgets/luci.nav.html diff --git a/luciexpress/htdocs/themes/vodaphone/widgets/luci.nav.js b/luciexpress/htdocs/plugins/core/widgets/luci.nav.js similarity index 96% rename from luciexpress/htdocs/themes/vodaphone/widgets/luci.nav.js rename to luciexpress/htdocs/plugins/core/widgets/luci.nav.js index 9d0530a06..24ef47a4f 100644 --- a/luciexpress/htdocs/themes/vodaphone/widgets/luci.nav.js +++ b/luciexpress/htdocs/plugins/core/widgets/luci.nav.js @@ -20,9 +20,9 @@ * 02110-1301 USA */ -$juci.module("vodaphone") +$juci.module("core") .directive("luciNav", function(){ - var plugin_root = $juci.module("vodaphone").plugin_root; + var plugin_root = $juci.module("core").plugin_root; return { // accepted parameters for this tag scope: { diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.navbar.html b/luciexpress/htdocs/plugins/core/widgets/luci.navbar.html similarity index 100% rename from luciexpress/htdocs/themes/inteno-red/widgets/luci.navbar.html rename to luciexpress/htdocs/plugins/core/widgets/luci.navbar.html diff --git a/luciexpress/htdocs/themes/vodaphone/widgets/luci.navbar.js b/luciexpress/htdocs/plugins/core/widgets/luci.navbar.js similarity index 96% rename from luciexpress/htdocs/themes/vodaphone/widgets/luci.navbar.js rename to luciexpress/htdocs/plugins/core/widgets/luci.navbar.js index df88127b8..0b76747f9 100644 --- a/luciexpress/htdocs/themes/vodaphone/widgets/luci.navbar.js +++ b/luciexpress/htdocs/plugins/core/widgets/luci.navbar.js @@ -21,9 +21,9 @@ */ -$juci.module("vodaphone") +$juci.module("core") .directive("luciNavbar", function($location, $rootScope){ - var plugin_root = $juci.module("vodaphone").plugin_root; + var plugin_root = $juci.module("core").plugin_root; function activate(){ var path = $location.path().replace(/^\/+|\/+$/g, ''); var subtree = path.split(".")[0]; diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.top_bar.html b/luciexpress/htdocs/plugins/core/widgets/luci.top_bar.html similarity index 100% rename from luciexpress/htdocs/themes/inteno-red/widgets/luci.top_bar.html rename to luciexpress/htdocs/plugins/core/widgets/luci.top_bar.html diff --git a/luciexpress/htdocs/themes/vodaphone/widgets/luci.top_bar.js b/luciexpress/htdocs/plugins/core/widgets/luci.top_bar.js similarity index 91% rename from luciexpress/htdocs/themes/vodaphone/widgets/luci.top_bar.js rename to luciexpress/htdocs/plugins/core/widgets/luci.top_bar.js index d785ce401..808f38048 100644 --- a/luciexpress/htdocs/themes/vodaphone/widgets/luci.top_bar.js +++ b/luciexpress/htdocs/plugins/core/widgets/luci.top_bar.js @@ -1,6 +1,6 @@ -$juci.module("vodaphone") +$juci.module("core") .directive("luciTopBar", function($compile){ - var plugin_root = $juci.module("vodaphone").plugin_root; + var plugin_root = $juci.module("core").plugin_root; return { templateUrl: plugin_root+"/widgets/luci.top_bar.html", controller: "luciTopBarController", diff --git a/luciexpress/htdocs/plugins/settings/pages/settings.password.js b/luciexpress/htdocs/plugins/settings/pages/settings.password.js index 891a66950..846fa8ae4 100644 --- a/luciexpress/htdocs/plugins/settings/pages/settings.password.js +++ b/luciexpress/htdocs/plugins/settings/pages/settings.password.js @@ -31,3 +31,4 @@ $juci.module("router") }); */ } }); + diff --git a/luciexpress/htdocs/themes/inteno-red/theme.json b/luciexpress/htdocs/themes/inteno-red/theme.json index f92604444..0942b5704 100644 --- a/luciexpress/htdocs/themes/inteno-red/theme.json +++ b/luciexpress/htdocs/themes/inteno-red/theme.json @@ -5,12 +5,5 @@ "css/bootstrap.min.css" ], "scripts": [ - "widgets/luci.layout.naked", - "widgets/luci.layout.single_column", - "widgets/luci.layout.with_sidebar", - "widgets/luci.footer", - "widgets/luci.nav", - "widgets/luci.navbar", - "widgets/luci.top_bar" ] } diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.footer.js b/luciexpress/htdocs/themes/inteno-red/widgets/luci.footer.js deleted file mode 100644 index 21f238d7f..000000000 --- a/luciexpress/htdocs/themes/inteno-red/widgets/luci.footer.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - * juci - javascript universal client interface - * - * Project Author: Martin K. Schröder - * - * Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -$juci.module("inteno-red") -.directive("luciFooter", function(){ - var plugin_root = $juci.module("inteno-red").plugin_root; - - return { - templateUrl: plugin_root+"/widgets/luci.footer.html", - controller: "luciFooterController" - }; -}) -.controller("luciFooterController", function($scope, $rpc, $config, $languages, gettextCatalog, gettext, $tr, $status){ - // TODO: move this into a higher level controller maybe? - $scope.languages = $languages.getLanguages(); - $scope.isActiveLanguage = function(lang){ - return gettextCatalog.currentLanguage == lang.short_code; - } - $scope.setLanguage = function(lang){ - $languages.setLanguage(lang.short_code); - }; - $scope.config = $config; - setInterval(function(){ - try{ - $scope.wanip = $status.ubus.network.interface.wan.status["ipv4-address"][0].ipaddr; - } catch(e) { - $scope.wanip = $tr(gettext("Not connected")); - } - try{ $scope.firmware = $status.ubus.router.info.system.firmware; } catch(e) {} - }, 1000); -}); diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.naked.js b/luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.naked.js deleted file mode 100644 index 4902312e3..000000000 --- a/luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.naked.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * juci - javascript universal client interface - * - * Project Author: Martin K. Schröder - * - * Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -$juci.module("inteno-red") -.directive("luciLayoutNaked", function(){ - var plugin_root = $juci.module("inteno-red").plugin_root; - return { - templateUrl: plugin_root+"/widgets/luci.layout.naked.html", - transclude: true, - controller: "luciLayoutNakedController", - controllerAs: "ctrl" - }; -}) -.controller("luciLayoutNakedController", function($scope, $session){ - -}); diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.single_column.js b/luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.single_column.js deleted file mode 100644 index 719b99411..000000000 --- a/luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.single_column.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - * juci - javascript universal client interface - * - * Project Author: Martin K. Schröder - * - * Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -$juci.module("inteno-red") -.directive("luciLayoutSingleColumn", function(){ - var plugin_root = $juci.module("inteno-red").plugin_root; - return { - // accepted parameters for this tag - scope: { - }, - templateUrl: plugin_root+"/widgets/luci.layout.single_column.html", - transclude: true, - controller: "luciLayoutSingleColumnController", - controllerAs: "ctrl" - }; -}) -.controller("luciLayoutSingleColumnController", function($scope, $session){ - -}); diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.with_sidebar.js b/luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.with_sidebar.js deleted file mode 100644 index 89a6cde61..000000000 --- a/luciexpress/htdocs/themes/inteno-red/widgets/luci.layout.with_sidebar.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * juci - javascript universal client interface - * - * Project Author: Martin K. Schröder - * - * Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -$juci.module("inteno-red") -.directive("luciLayoutWithSidebar", function(){ - var plugin_root = $juci.module("inteno-red").plugin_root; - - return { - // accepted parameters for this tag - scope: { - }, - templateUrl: plugin_root+"/widgets/luci.layout.with_sidebar.html", - transclude: true, - controller: "luciLayoutWithSidebarController", - controllerAs: "ctrl" - }; -}) -.controller("luciLayoutWithSidebarController", function($scope, $session){ - -}); diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.nav.js b/luciexpress/htdocs/themes/inteno-red/widgets/luci.nav.js deleted file mode 100644 index d65d9d63e..000000000 --- a/luciexpress/htdocs/themes/inteno-red/widgets/luci.nav.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - * juci - javascript universal client interface - * - * Project Author: Martin K. Schröder - * - * Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -$juci.module("inteno-red") -.directive("luciNav", function(){ - var plugin_root = $juci.module("inteno-red").plugin_root; - return { - // accepted parameters for this tag - scope: { - }, - templateUrl: plugin_root+"/widgets/luci.nav.html", - replace: true, - controller: "NavCtrl", - controllerAs: "ctrl" - }; -}) -.controller("NavCtrl", function($scope, $navigation, $location, $state, $rootScope, $config){ - var path = $location.path().replace(/^\/+|\/+$/g, ''); - var subtree = path.split(".")[0]; - - $scope.tree = $navigation.tree(subtree); - - $scope.hasChildren = function(menu){ - return Object.keys(menu.children) > 0; - } - $scope.isActive = function (viewLocation) { - return viewLocation === $location.path(); - }; - - $scope.itemVisible = function(item){ - if(!item.modes.length) return true; - else if(item.modes && item.modes.indexOf($config.mode) == -1) { - return false; - } - else return true; - } - - function activate(){ - var path = $location.path().replace(/^\/+|\/+$/g, ''); - var subtree = path.split(".")[0]; - $scope.tree = $navigation.tree(subtree); - - setTimeout(function(){ - $("nav ul a").removeClass("open"); - $("nav ul a[href='#!"+path+"']").parent().addClass("open"); - }, 0); - }; - $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){ - activate(); - }); - activate(); - - /*$scope.$on('$locationChangeSuccess', function () { - var path = $location.path().replace(/^\/+|\/+$/g, ''); - var subtree = path.split(".")[0]; - $scope.tree = $navigation.tree(subtree); - $("nav ul a[href='#!"+path+"']").parent().addClass("open"); - }); */ -}); diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.navbar.js b/luciexpress/htdocs/themes/inteno-red/widgets/luci.navbar.js deleted file mode 100644 index 88ad3c6d4..000000000 --- a/luciexpress/htdocs/themes/inteno-red/widgets/luci.navbar.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * juci - javascript universal client interface - * - * Project Author: Martin K. Schröder - * - * Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - - -$juci.module("inteno-red") -.directive("luciNavbar", function($location, $rootScope){ - var plugin_root = $juci.module("inteno-red").plugin_root; - function activate(){ - var path = $location.path().replace(/^\/+|\/+$/g, ''); - var subtree = path.split(".")[0]; - - setTimeout(function(){ - $("ul.nav li a").parent().removeClass("open"); - $("ul.nav li a[href='#!"+subtree+"']").addClass("open"); - $("ul.nav li a[href='#!"+subtree+"']").parent().addClass("open"); - }, 0); - }; - $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){ - activate(); - }); - return { - restrict: 'E', - templateUrl: plugin_root+"/widgets/luci.navbar.html", - replace: true - }; -}) -.controller("NavigationCtrl", function($scope, $location, $navigation, $rootScope, $config, $rpc){ - $scope.tree = $navigation.tree(); - $scope.hasChildren = function(menu){ - return menu.children_list > 0; - } - $scope.isActive = function (viewLocation) { - return viewLocation === $location.path(); - }; - /* - $(function(){ - var themes = $config.themes; - $config.theme = localStorage.getItem("theme") || "default"; - //var bootstrap = $(''); - var theme = $(''); - //bootstrap.appendTo('head'); - theme.appendTo('head'); - $('.theme-link').click(function(){ - var themename = $(this).attr('data-theme'); - var themeurl = themes[themename]; - $config.theme = themename; - localStorage.setItem("theme", themename); - //bootstrap.attr('href',themeurl+"/css/bootstrap.min.css"); - theme.attr('href',themeurl+"/css/theme.css"); - }); - });*/ -}); diff --git a/luciexpress/htdocs/themes/inteno-red/widgets/luci.top_bar.js b/luciexpress/htdocs/themes/inteno-red/widgets/luci.top_bar.js deleted file mode 100644 index 3f0c250df..000000000 --- a/luciexpress/htdocs/themes/inteno-red/widgets/luci.top_bar.js +++ /dev/null @@ -1,34 +0,0 @@ -$juci.module("inteno-red") -.directive("luciTopBar", function($compile){ - var plugin_root = $juci.module("inteno-red").plugin_root; - return { - templateUrl: plugin_root+"/widgets/luci.top_bar.html", - controller: "luciTopBarController", - replace: true - }; -}) -.controller("luciTopBarController", function($scope, $config, $session, $window, $localStorage, $state, gettext){ - $scope.model = ($config.system.name || "") + " " + ($config.system.hardware || ""); - - $scope.guiModes = [ - {id: "basic", label: gettext("Basic Mode")}, - {id: "expert", label: gettext("Expert Mode")}, - {id: "logout", label: gettext("Log out")} - ]; - Object.keys($scope.guiModes).map(function(k){ - var m = $scope.guiModes[k]; - if(m.id == $config.mode) $scope.selectedMode = m; - }); - $scope.onChangeMode = function(item){ - var selected = item.id; - if(selected == "logout") { - $session.logout().always(function(){ - $window.location.href="/"; - }); - } else { - $localStorage.setItem("mode", selected); - $config.mode = selected; - $state.reload(); - } - }; -}); diff --git a/luciexpress/htdocs/themes/vodaphone/theme.json b/luciexpress/htdocs/themes/vodaphone/theme.json index 137b1d43d..f1b3c8d9d 100644 --- a/luciexpress/htdocs/themes/vodaphone/theme.json +++ b/luciexpress/htdocs/themes/vodaphone/theme.json @@ -6,12 +6,6 @@ "css/theme.css" ], "scripts": [ - "widgets/luci.layout.naked", - "widgets/luci.layout.single_column", - "widgets/luci.layout.with_sidebar", - "widgets/luci.footer", - "widgets/luci.nav", - "widgets/luci.navbar", - "widgets/luci.top_bar" + "vodaphone" ] } diff --git a/luciexpress/htdocs/themes/vodaphone/vodaphone.js b/luciexpress/htdocs/themes/vodaphone/vodaphone.js index 8b1378917..97fd644fa 100644 --- a/luciexpress/htdocs/themes/vodaphone/vodaphone.js +++ b/luciexpress/htdocs/themes/vodaphone/vodaphone.js @@ -1 +1,18 @@ - +(function(){ + var overrides = { + "luciFooterDirective": "/widgets/luci.footer.html", + "luciLayoutNakedDirective": "/widgets/luci.layout.naked.html", + "luciLayoutSingleColumnDirective": "/widgets/luci.layout.single_column.html", + "luciLayoutWithSidebarDirective": "/widgets/luci.layout.with_sidebar.html", + "luciNavDirective": "/widgets/luci.nav.html", + "luciNavbarDirective": "/widgets/luci.navbar.html", + "luciTopBarDirective": "/widgets/luci.top_bar.html" + }; + Object.keys(overrides).map(function(k){ + $juci.decorator(k, function($delegate){ + var plugin_root = $juci.module("vodaphone").plugin_root; + $delegate[1].templateUrl = plugin_root + overrides[k]; + return $delegate; + }); + }); +})(); diff --git a/luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.single_column.html b/luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.single_column.html deleted file mode 100644 index 3ee71281f..000000000 --- a/luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.single_column.html +++ /dev/null @@ -1,22 +0,0 @@ - -
-
- -
- -
-
-
- -
-
-
-
-
-
-
- -
-
-
-
diff --git a/luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.single_column.js b/luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.single_column.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.with_sidebar.html b/luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.with_sidebar.html deleted file mode 100644 index 2cd1db333..000000000 --- a/luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.with_sidebar.html +++ /dev/null @@ -1,46 +0,0 @@ - -
-
-
-
-
-
- -
-
-
- -
-
-
- -
-
- -
-
-
-
-
- -
-
-
-
- -
-
-
-
diff --git a/luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.with_sidebar.js b/luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.with_sidebar.js deleted file mode 100644 index 39dcb1715..000000000 --- a/luciexpress/htdocs/themes/vodaphone/widgets/vodaphone.layout.with_sidebar.js +++ /dev/null @@ -1,48 +0,0 @@ - -$juci.config(function($provide){ - $provide.decorator("luciFooterDirective", function($delegate){ - console.log(JSON.stringify($delegate[0])); - return $delegate; - }) -}); - -$juci.module("vodaphone") -.directive("luciLayoutWithSidebar", function($http, $compile, $templateCache, $config, $provide){ - /*function deleteDirective(name){ - for(var i = 0; i < angular._invokeQueue.length; i++){ - var item = angular._invokeQueue[i]; - if(item[1] == "directive" && item.Arguments[0] == name){ - angular._invokeQueue.splice(i, 1); - } - } - } - deleteDirective("luciLayoutWithSidebar"); - var plugin_root = $juci.module("vodaphone").plugin_root; - - return { - templateUrl: plugin_root + "/widgets/vodaphone.layout.with_sidebar.html", - transclude: true, - controller: "luciLayoutWithSidebarController" - }; - */ - var plugin_root = $juci.module("vodaphone").plugin_root; - var target_tpl = "plugins/core/widgets/luci.layout.with_sidebar.html"; - return { - priority: 100, // give it higher priority than built-in ng-click - //templateUrl: plugin_root+"/widgets/vodaphone.navbar.html", - template: '
', - replace: true, - transclude: true, - link: function(scope, element, attrs){ - scope.templateUrl = plugin_root + "/widgets/vodaphone.layout.with_sidebar.html"; - - if($config.theme == "vodaphone" && !$templateCache.get(plugin_root + "/widgets/vodaphone.layout.with_sidebar.html")){ - var promise = $http.get(plugin_root + "/widgets/vodaphone.layout.with_sidebar.html", {cache: $templateCache}).success(function(html) { - $templateCache.put(target_tpl, html); - }).then(function (response) { - //element.replaceWith($compile($templateCache.get(target_tpl))(scope)); - }); - } - } - }; -});