From b6b52af148284c4ead7cacdbae28c31b04da4b26 Mon Sep 17 00:00:00 2001 From: Vladimir Lugovsky Date: Wed, 16 Dec 2015 01:32:16 +0300 Subject: [PATCH] refactor(themeComponents): move components to separate module --- src/app/components/backTop/backTop.js | 14 -- src/app/components/blurPanel/blurPanel.js | 16 -- src/app/components/contentTop/contentTop.js | 38 ---- src/app/components/msgCenter/msgCenter.js | 113 ---------- src/app/components/pageTop/pageTop.js | 10 - src/app/components/sidebar/sidebar.js | 199 ----------------- src/app/components/widgets/widgets.js | 14 -- .../components/backTop/backTop.directive.js | 25 +++ .../components/backTop/backTop.html | 0 .../backTop/lib/jquery.backTop.min.js | 0 .../blurPanel/blurPanel.directive.js | 24 +++ .../components/blurPanel/blurPanel.html | 0 src/app/theme/components/components.module.js | 14 ++ .../contentTop/contentTop.directive.js | 46 ++++ .../components/contentTop/contentTop.html | 0 .../components/msgCenter/MsgCenterCtrl.js | 116 ++++++++++ .../msgCenter/msgCenter.directive.js | 20 ++ .../components/msgCenter/msgCenter.html | 0 .../components/pageTop/pageTop.directive.js | 19 ++ .../components/pageTop/pageTop.html | 0 .../theme/components/sidebar/SidebarCtrl.js | 203 ++++++++++++++++++ .../components/sidebar/sidebar.directive.js | 20 ++ .../components/sidebar/sidebar.html | 0 .../components/widgets/widgets.directive.js | 23 ++ .../components/widgets/widgets.html | 0 src/app/theme/theme.module.js | 4 +- 26 files changed, 513 insertions(+), 405 deletions(-) delete mode 100644 src/app/components/backTop/backTop.js delete mode 100644 src/app/components/blurPanel/blurPanel.js delete mode 100644 src/app/components/contentTop/contentTop.js delete mode 100644 src/app/components/msgCenter/msgCenter.js delete mode 100644 src/app/components/pageTop/pageTop.js delete mode 100644 src/app/components/sidebar/sidebar.js delete mode 100644 src/app/components/widgets/widgets.js create mode 100644 src/app/theme/components/backTop/backTop.directive.js rename src/app/{ => theme}/components/backTop/backTop.html (100%) rename src/app/{ => theme}/components/backTop/lib/jquery.backTop.min.js (100%) create mode 100644 src/app/theme/components/blurPanel/blurPanel.directive.js rename src/app/{ => theme}/components/blurPanel/blurPanel.html (100%) create mode 100644 src/app/theme/components/components.module.js create mode 100644 src/app/theme/components/contentTop/contentTop.directive.js rename src/app/{ => theme}/components/contentTop/contentTop.html (100%) create mode 100644 src/app/theme/components/msgCenter/MsgCenterCtrl.js create mode 100644 src/app/theme/components/msgCenter/msgCenter.directive.js rename src/app/{ => theme}/components/msgCenter/msgCenter.html (100%) create mode 100644 src/app/theme/components/pageTop/pageTop.directive.js rename src/app/{ => theme}/components/pageTop/pageTop.html (100%) create mode 100644 src/app/theme/components/sidebar/SidebarCtrl.js create mode 100644 src/app/theme/components/sidebar/sidebar.directive.js rename src/app/{ => theme}/components/sidebar/sidebar.html (100%) create mode 100644 src/app/theme/components/widgets/widgets.directive.js rename src/app/{ => theme}/components/widgets/widgets.html (100%) diff --git a/src/app/components/backTop/backTop.js b/src/app/components/backTop/backTop.js deleted file mode 100644 index 2b343ee..0000000 --- a/src/app/components/backTop/backTop.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -blurAdminApp.directive('backTop', function () { - return { - restrict: 'E', - controller: [function () { - $('#backTop').backTop({ - 'position': 200, - 'speed': 100 - }); - }], - templateUrl: 'app/components/backTop/backTop.html' - }; -}); diff --git a/src/app/components/blurPanel/blurPanel.js b/src/app/components/blurPanel/blurPanel.js deleted file mode 100644 index d111815..0000000 --- a/src/app/components/blurPanel/blurPanel.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -blurAdminApp.directive('blurPanel', function () { - return { - restrict: 'E', - transclude: true, - scope: { - title: '@', - classContainer: '@' - }, - controller: ['$scope', function ($scope) { - }], - templateUrl: 'app/components/blurPanel/blurPanel.html' - }; -}); - diff --git a/src/app/components/contentTop/contentTop.js b/src/app/components/contentTop/contentTop.js deleted file mode 100644 index 9d33adf..0000000 --- a/src/app/components/contentTop/contentTop.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -blurAdminApp.directive('contentTop', ['$location', function ($location) { - return { - restrict: 'E', - controller: [function () { - - }], - templateUrl: 'app/components/contentTop/contentTop.html', - link: function($scope) { - $scope.pages = { - '/dashboard': 'Dashboard', - '/page': 'Default Page', - '/404': 'Page Not Found', - '/buttons': 'Buttons', - '/charts': 'Charts', - '/grid': 'Grid', - '/icons': 'Icons', - '/login': 'Authentication', - '/maps': 'Maps', - '/modals': 'Modals', - '/profile': 'User Profile', - '/tables': 'Tables', - '/typography': 'Typography', - '/form-layouts': 'Form Layouts', - '/form-inputs': 'Form Inputs', - '/maps/gmap': 'Google Map', - '/maps/leaflet': 'Leaflet Map', - '/maps/line': 'Line Map', - '/maps/bubble': 'Bubble Map' - }; - - $scope.$watch(function () { - $scope.activePageTitle = $scope.pages[$location.$$url]; - }); - } - }; -}]); diff --git a/src/app/components/msgCenter/msgCenter.js b/src/app/components/msgCenter/msgCenter.js deleted file mode 100644 index 30d7633..0000000 --- a/src/app/components/msgCenter/msgCenter.js +++ /dev/null @@ -1,113 +0,0 @@ -'use strict'; - -blurAdminApp.directive('msgCenter', function () { - return { - restrict: 'E', - templateUrl: 'app/components/msgCenter/msgCenter.html', - controller: ['$scope', '$sce', function($scope, $sce){ - - $scope.users = { - 0: { - name: 'Vladimir', - image: 'img/pic-vova.png' - }, - 1: { - name: 'Konstantin', - image: 'img/pic-kostia.png' - }, - 2: { - name: 'Andrey', - image: 'img/pic-andrey.png' - }, - 3: { - name: 'Anastasiya', - image: 'img/pic-nasta.png' - } - }; - - $scope.notifications = [ - { - userId: 0, - template: '&name posted a new article.', - time: '1 min ago' - }, - { - userId: 1, - template: '&name changed his contact information.', - time: '2 hrs ago' - }, - { - image: 'img/shopping-cart.svg', - template: 'New orders received.', - time: '5 hrs ago' - }, - { - userId: 2, - template: '&name replied to your comment.', - time: '1 day ago' - }, - { - userId: 3, - template: 'Today is &name\'s birthday.', - time: '2 days ago' - }, - { - image: 'img/comments.svg', - template: 'New comments on your post.', - time: '3 days ago' - }, - { - userId: 1, - template: '&name invited you to join the event.', - time: '1 week ago' - } - ]; - - $scope.messages = [ - { - userId: 3, - text: 'After you get up and running, you can place Font Awesome icons just about...', - time: '1 min ago' - }, - { - userId: 0, - text: 'You asked, Font Awesome delivers with 40 shiny new icons in version 4.2.', - time: '2 hrs ago' - }, - { - userId: 1, - text: 'Want to request new icons? Here\'s how. Need vectors or want to use on the...', - time: '10 hrs ago' - }, - { - userId: 2, - text: 'Explore your passions and discover new ones by getting involved. Stretch your...', - time: '1 day ago' - }, - { - userId: 3, - text: 'Get to know who we are - from the inside out. From our history and culture, to the...', - time: '1 day ago' - }, - { - userId: 1, - text: 'Need some support to reach your goals? Apply for scholarships across a variety of...', - time: '2 days ago' - }, - { - userId: 0, - text: 'Wrap the dropdown\'s trigger and the dropdown menu within .dropdown, or...', - time: '1 week ago' - } - ]; - - $scope.getMessage = function(msg) { - var text = msg.template; - if (msg.userId || msg.userId === 0) { - text = text.replace('&name', '' + $scope.users[msg.userId].name + ''); - } - return $sce.trustAsHtml(text); - }; - }] - }; -}); diff --git a/src/app/components/pageTop/pageTop.js b/src/app/components/pageTop/pageTop.js deleted file mode 100644 index abf262f..0000000 --- a/src/app/components/pageTop/pageTop.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -blurAdminApp.directive('pageTop', function () { - return { - restrict: 'E', - templateUrl: 'app/components/pageTop/pageTop.html', - link: function ($scope) { - } - }; -}); \ No newline at end of file diff --git a/src/app/components/sidebar/sidebar.js b/src/app/components/sidebar/sidebar.js deleted file mode 100644 index b4f5e41..0000000 --- a/src/app/components/sidebar/sidebar.js +++ /dev/null @@ -1,199 +0,0 @@ -'use strict'; - -blurAdminApp.directive('sidebar', function () { - return { - restrict: 'E', - templateUrl: 'app/components/sidebar/sidebar.html', - controller: ['$scope', '$element', '$window', '$timeout', '$location', '$rootScope', 'layoutSizes', function ($scope, $element, $window, $timeout, $location, $rootScope, layoutSizes) { - $scope.menuItems = [ - { - title: 'Dashboard', - icon: 'ion-android-home', - root: '#/dashboard' - }, - { - title: 'Charts', - icon: 'ion-stats-bars', - root: '#/charts' - }, - { - title: 'Tables', - icon: 'ion-grid', - root: '#/tables' - }, - { - title: 'Form Elements', - icon: 'ion-compose', - subMenu: [ - { - title: 'Inputs', - root: '#/form-inputs' - }, - { - title: 'Form Layouts', - root: '#/form-layouts' - } - ] - }, - { - title: 'UI Elements', - icon: 'ion-android-laptop', - subMenu: [ - { - title: 'Typography', - root: '#/typography' - }, - { - title: 'Buttons', - root: '#/buttons' - }, - { - title: 'Icons', - root: '#/icons' - }, - { - title: 'Modals', - root: '#/modals' - } - ] - }, - { - title: 'Maps', - icon: 'ion-ios-location-outline', - subMenu: [ - { - title: 'Google Maps', - root: '#/maps/gmap' - }, - { - title: 'Leaflet', - root: '#/maps/leaflet' - }, - { - title: 'Bubble Map', - root: '#/maps/bubble' - }, - { - title: 'Line Map', - root: '#/maps/line' - } - ] - }, - { - title: 'User Profile', - icon: 'ion-person', - root: '#/profile' - }, - { - title: 'Login Page', - icon: 'ion-log-out', - root: 'auth.html' - }, - { - title: '404 Page', - icon: 'ion-document', - root: '404.html' - } - ]; - - function changeSelectElemTopValue() { - $timeout(function () { - var selectedItem = $('.al-sidebar-list-item.selected'); - if (selectedItem) { - $scope.selectElemTop = selectedItem.position().top; - } - }, 101); - } - - function selectMenuItem() { - $.each($scope.menuItems, function (index, value) { - value.selected = value.root === '#' + $location.$$url; - - if (value.subMenu) { - var hasSelectedSubmenu = false; - $.each(value.subMenu, function (subIndex, subValue) { - subValue.selected = subValue.root === '#' + $location.$$url; - if (subValue.selected) { - hasSelectedSubmenu = true; - } - }); - value.selected = hasSelectedSubmenu; - } - }); - changeSelectElemTopValue(); - } - - selectMenuItem(); - - $scope.$on('$locationChangeSuccess', function () { - selectMenuItem(); - }); - - $scope.menuExpand = function () { - $rootScope.$isMenuCollapsed = false; - }; - - $scope.menuCollapse = function () { - $rootScope.$isMenuCollapsed = true; - }; - - $rootScope.$watch('$isMenuCollapsed', function(newValue) { - if (!newValue && !$scope.selectElemTop) { - changeSelectElemTopValue(); - } - }) - - // watch window resize to change menu collapsed state if needed - $(window).resize(function () { - var isMenuShouldCollapsed = $(window).width() <= layoutSizes.resWidthCollapseSidebar; - if ($scope.isMenuShouldCollapsed !== isMenuShouldCollapsed) { - $scope.$apply(function () { - $rootScope.$isMenuCollapsed = isMenuShouldCollapsed; - }); - } - $scope.isMenuShouldCollapsed = isMenuShouldCollapsed; - }); - - $scope.toggleSubMenu = function ($event, item) { - var submenu = $($event.currentTarget).next(); - - if (isMenuCollapsed.$isMenuCollapsed) { - if (!item.slideRight) { - $timeout(function () { - item.slideRight = true; - $scope.anySlideRight = true; - }, 20); - } - } else { - submenu.slideToggle(100); - changeSelectElemTopValue(); - } - }; - - window.onclick = function () { - $timeout(function () { - - if ($scope.anySlideRight) { - $scope.menuItems.map(function (val) { - return val.slideRight = false; - }); - $scope.anySlideRight = false; - } - - }, 10); - }; - - $scope.hoverItem = function ($event) { - $scope.showHoverElem = true; - var menuTopValue = 66; - $scope.hoverElemTop = $event.currentTarget.getBoundingClientRect().top - menuTopValue; - }; - - $scope.collapseSidebarIfSmallRes = function () { - if (window.innerWidth <= layoutSizes.resWidthCollapseSidebar) { - $rootScope.$isMenuCollapsed = true; - } - }; - }] - }; -}); \ No newline at end of file diff --git a/src/app/components/widgets/widgets.js b/src/app/components/widgets/widgets.js deleted file mode 100644 index 1419d5c..0000000 --- a/src/app/components/widgets/widgets.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -blurAdminApp.directive('widgets', function () { - return { - restrict: 'EA', - scope: { - ngModel: '=' - }, - templateUrl: 'app/components/widgets/widgets.html', - replace: true, - link: function () { - } - }; -}); \ No newline at end of file diff --git a/src/app/theme/components/backTop/backTop.directive.js b/src/app/theme/components/backTop/backTop.directive.js new file mode 100644 index 0000000..1f93efc --- /dev/null +++ b/src/app/theme/components/backTop/backTop.directive.js @@ -0,0 +1,25 @@ +/** + * @author v.lugovksy + * created on 16.12.2015 + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme.components') + .directive('backTop', backTop); + + /** @ngInject */ + function backTop() { + return { + restrict: 'E', + templateUrl: 'app/theme/components/backTop/backTop.html', + controller: function () { + $('#backTop').backTop({ + 'position': 200, + 'speed': 100 + }); + } + }; + } + +})(); \ No newline at end of file diff --git a/src/app/components/backTop/backTop.html b/src/app/theme/components/backTop/backTop.html similarity index 100% rename from src/app/components/backTop/backTop.html rename to src/app/theme/components/backTop/backTop.html diff --git a/src/app/components/backTop/lib/jquery.backTop.min.js b/src/app/theme/components/backTop/lib/jquery.backTop.min.js similarity index 100% rename from src/app/components/backTop/lib/jquery.backTop.min.js rename to src/app/theme/components/backTop/lib/jquery.backTop.min.js diff --git a/src/app/theme/components/blurPanel/blurPanel.directive.js b/src/app/theme/components/blurPanel/blurPanel.directive.js new file mode 100644 index 0000000..ecc01de --- /dev/null +++ b/src/app/theme/components/blurPanel/blurPanel.directive.js @@ -0,0 +1,24 @@ +/** + * @author v.lugovksy + * created on 16.12.2015 + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme.components') + .directive('blurPanel', blurPanel); + + /** @ngInject */ + function blurPanel() { + return { + restrict: 'E', + transclude: true, + scope: { + title: '@', + classContainer: '@' + }, + templateUrl: 'app/theme/components/blurPanel/blurPanel.html' + }; + } + +})(); \ No newline at end of file diff --git a/src/app/components/blurPanel/blurPanel.html b/src/app/theme/components/blurPanel/blurPanel.html similarity index 100% rename from src/app/components/blurPanel/blurPanel.html rename to src/app/theme/components/blurPanel/blurPanel.html diff --git a/src/app/theme/components/components.module.js b/src/app/theme/components/components.module.js new file mode 100644 index 0000000..760fe63 --- /dev/null +++ b/src/app/theme/components/components.module.js @@ -0,0 +1,14 @@ +/** + * @author v.lugovksy + * created on 16.12.2015 + */ +/** + * @author v.lugovsky + * created on 16.12.2015 + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme.components', []); + +})(); diff --git a/src/app/theme/components/contentTop/contentTop.directive.js b/src/app/theme/components/contentTop/contentTop.directive.js new file mode 100644 index 0000000..4ea39ae --- /dev/null +++ b/src/app/theme/components/contentTop/contentTop.directive.js @@ -0,0 +1,46 @@ +/** + * @author v.lugovksy + * created on 16.12.2015 + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme.components') + .directive('contentTop', contentTop); + + /** @ngInject */ + function contentTop($location) { + return { + restrict: 'E', + templateUrl: 'app/theme/components/contentTop/contentTop.html', + link: function($scope) { + $scope.pages = { + '/dashboard': 'Dashboard', + '/page': 'Default Page', + '/404': 'Page Not Found', + '/buttons': 'Buttons', + '/charts': 'Charts', + '/grid': 'Grid', + '/icons': 'Icons', + '/login': 'Authentication', + '/maps': 'Maps', + '/modals': 'Modals', + '/profile': 'User Profile', + '/tables': 'Tables', + '/typography': 'Typography', + '/form-layouts': 'Form Layouts', + '/form-inputs': 'Form Inputs', + '/maps/gmap': 'Google Map', + '/maps/leaflet': 'Leaflet Map', + '/maps/line': 'Line Map', + '/maps/bubble': 'Bubble Map' + }; + + $scope.$watch(function () { + $scope.activePageTitle = $scope.pages[$location.$$url]; + }); + } + }; + } + +})(); \ No newline at end of file diff --git a/src/app/components/contentTop/contentTop.html b/src/app/theme/components/contentTop/contentTop.html similarity index 100% rename from src/app/components/contentTop/contentTop.html rename to src/app/theme/components/contentTop/contentTop.html diff --git a/src/app/theme/components/msgCenter/MsgCenterCtrl.js b/src/app/theme/components/msgCenter/MsgCenterCtrl.js new file mode 100644 index 0000000..461f279 --- /dev/null +++ b/src/app/theme/components/msgCenter/MsgCenterCtrl.js @@ -0,0 +1,116 @@ +/** + * @author v.lugovksy + * created on 16.12.2015 + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme.components') + .controller('MsgCenterCtrl', MsgCenterCtrl); + + /** @ngInject */ + function MsgCenterCtrl($scope, $sce) { + $scope.users = { + 0: { + name: 'Vladimir', + image: 'img/pic-vova.png' + }, + 1: { + name: 'Konstantin', + image: 'img/pic-kostia.png' + }, + 2: { + name: 'Andrey', + image: 'img/pic-andrey.png' + }, + 3: { + name: 'Anastasiya', + image: 'img/pic-nasta.png' + } + }; + + $scope.notifications = [ + { + userId: 0, + template: '&name posted a new article.', + time: '1 min ago' + }, + { + userId: 1, + template: '&name changed his contact information.', + time: '2 hrs ago' + }, + { + image: 'img/shopping-cart.svg', + template: 'New orders received.', + time: '5 hrs ago' + }, + { + userId: 2, + template: '&name replied to your comment.', + time: '1 day ago' + }, + { + userId: 3, + template: 'Today is &name\'s birthday.', + time: '2 days ago' + }, + { + image: 'img/comments.svg', + template: 'New comments on your post.', + time: '3 days ago' + }, + { + userId: 1, + template: '&name invited you to join the event.', + time: '1 week ago' + } + ]; + + $scope.messages = [ + { + userId: 3, + text: 'After you get up and running, you can place Font Awesome icons just about...', + time: '1 min ago' + }, + { + userId: 0, + text: 'You asked, Font Awesome delivers with 40 shiny new icons in version 4.2.', + time: '2 hrs ago' + }, + { + userId: 1, + text: 'Want to request new icons? Here\'s how. Need vectors or want to use on the...', + time: '10 hrs ago' + }, + { + userId: 2, + text: 'Explore your passions and discover new ones by getting involved. Stretch your...', + time: '1 day ago' + }, + { + userId: 3, + text: 'Get to know who we are - from the inside out. From our history and culture, to the...', + time: '1 day ago' + }, + { + userId: 1, + text: 'Need some support to reach your goals? Apply for scholarships across a variety of...', + time: '2 days ago' + }, + { + userId: 0, + text: 'Wrap the dropdown\'s trigger and the dropdown menu within .dropdown, or...', + time: '1 week ago' + } + ]; + + $scope.getMessage = function(msg) { + var text = msg.template; + if (msg.userId || msg.userId === 0) { + text = text.replace('&name', '' + $scope.users[msg.userId].name + ''); + } + return $sce.trustAsHtml(text); + }; + } +})(); \ No newline at end of file diff --git a/src/app/theme/components/msgCenter/msgCenter.directive.js b/src/app/theme/components/msgCenter/msgCenter.directive.js new file mode 100644 index 0000000..30c7aed --- /dev/null +++ b/src/app/theme/components/msgCenter/msgCenter.directive.js @@ -0,0 +1,20 @@ +/** + * @author v.lugovksy + * created on 16.12.2015 + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme.components') + .directive('msgCenter', msgCenter); + + /** @ngInject */ + function msgCenter() { + return { + restrict: 'E', + templateUrl: 'app/theme/components/msgCenter/msgCenter.html', + controller: 'MsgCenterCtrl' + }; + } + +})(); \ No newline at end of file diff --git a/src/app/components/msgCenter/msgCenter.html b/src/app/theme/components/msgCenter/msgCenter.html similarity index 100% rename from src/app/components/msgCenter/msgCenter.html rename to src/app/theme/components/msgCenter/msgCenter.html diff --git a/src/app/theme/components/pageTop/pageTop.directive.js b/src/app/theme/components/pageTop/pageTop.directive.js new file mode 100644 index 0000000..ffa79d9 --- /dev/null +++ b/src/app/theme/components/pageTop/pageTop.directive.js @@ -0,0 +1,19 @@ +/** + * @author v.lugovksy + * created on 16.12.2015 + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme.components') + .directive('pageTop', pageTop); + + /** @ngInject */ + function pageTop() { + return { + restrict: 'E', + templateUrl: 'app/theme/components/pageTop/pageTop.html' + }; + } + +})(); \ No newline at end of file diff --git a/src/app/components/pageTop/pageTop.html b/src/app/theme/components/pageTop/pageTop.html similarity index 100% rename from src/app/components/pageTop/pageTop.html rename to src/app/theme/components/pageTop/pageTop.html diff --git a/src/app/theme/components/sidebar/SidebarCtrl.js b/src/app/theme/components/sidebar/SidebarCtrl.js new file mode 100644 index 0000000..c2a7045 --- /dev/null +++ b/src/app/theme/components/sidebar/SidebarCtrl.js @@ -0,0 +1,203 @@ +/** + * @author v.lugovksy + * created on 16.12.2015 + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme.components') + .controller('SidebarCtrl', SidebarCtrl); + + /** @ngInject */ + function SidebarCtrl($scope, $timeout, $location, $rootScope, layoutSizes) { + $scope.menuItems = [ + { + title: 'Dashboard', + icon: 'ion-android-home', + root: '#/dashboard' + }, + { + title: 'Charts', + icon: 'ion-stats-bars', + root: '#/charts' + }, + { + title: 'Tables', + icon: 'ion-grid', + root: '#/tables' + }, + { + title: 'Form Elements', + icon: 'ion-compose', + subMenu: [ + { + title: 'Inputs', + root: '#/form-inputs' + }, + { + title: 'Form Layouts', + root: '#/form-layouts' + } + ] + }, + { + title: 'UI Elements', + icon: 'ion-android-laptop', + subMenu: [ + { + title: 'Typography', + root: '#/typography' + }, + { + title: 'Buttons', + root: '#/buttons' + }, + { + title: 'Icons', + root: '#/icons' + }, + { + title: 'Modals', + root: '#/modals' + } + ] + }, + { + title: 'Maps', + icon: 'ion-ios-location-outline', + subMenu: [ + { + title: 'Google Maps', + root: '#/maps/gmap' + }, + { + title: 'Leaflet', + root: '#/maps/leaflet' + }, + { + title: 'Bubble Map', + root: '#/maps/bubble' + }, + { + title: 'Line Map', + root: '#/maps/line' + } + ] + }, + { + title: 'User Profile', + icon: 'ion-person', + root: '#/profile' + }, + { + title: 'Login Page', + icon: 'ion-log-out', + root: 'auth.html' + }, + { + title: '404 Page', + icon: 'ion-document', + root: '404.html' + } + ]; + + function changeSelectElemTopValue() { + $timeout(function () { + var selectedItem = $('.al-sidebar-list-item.selected'); + if (selectedItem) { + $scope.selectElemTop = selectedItem.position().top; + } + }, 101); + } + + function selectMenuItem() { + $.each($scope.menuItems, function (index, value) { + value.selected = value.root === '#' + $location.$$url; + + if (value.subMenu) { + var hasSelectedSubmenu = false; + $.each(value.subMenu, function (subIndex, subValue) { + subValue.selected = subValue.root === '#' + $location.$$url; + if (subValue.selected) { + hasSelectedSubmenu = true; + } + }); + value.selected = hasSelectedSubmenu; + } + }); + changeSelectElemTopValue(); + } + + selectMenuItem(); + + $scope.$on('$locationChangeSuccess', function () { + selectMenuItem(); + }); + + $scope.menuExpand = function () { + $rootScope.$isMenuCollapsed = false; + }; + + $scope.menuCollapse = function () { + $rootScope.$isMenuCollapsed = true; + }; + + $rootScope.$watch('$isMenuCollapsed', function(newValue) { + if (!newValue && !$scope.selectElemTop) { + changeSelectElemTopValue(); + } + }); + + // watch window resize to change menu collapsed state if needed + $(window).resize(function () { + var isMenuShouldCollapsed = $(window).width() <= layoutSizes.resWidthCollapseSidebar; + if ($scope.isMenuShouldCollapsed !== isMenuShouldCollapsed) { + $scope.$apply(function () { + $rootScope.$isMenuCollapsed = isMenuShouldCollapsed; + }); + } + $scope.isMenuShouldCollapsed = isMenuShouldCollapsed; + }); + + $scope.toggleSubMenu = function ($event, item) { + var submenu = $($event.currentTarget).next(); + + if (isMenuCollapsed.$isMenuCollapsed) { + if (!item.slideRight) { + $timeout(function () { + item.slideRight = true; + $scope.anySlideRight = true; + }, 20); + } + } else { + submenu.slideToggle(100); + changeSelectElemTopValue(); + } + }; + + window.onclick = function () { + $timeout(function () { + + if ($scope.anySlideRight) { + $scope.menuItems.map(function (val) { + return val.slideRight = false; + }); + $scope.anySlideRight = false; + } + + }, 10); + }; + + $scope.hoverItem = function ($event) { + $scope.showHoverElem = true; + var menuTopValue = 66; + $scope.hoverElemTop = $event.currentTarget.getBoundingClientRect().top - menuTopValue; + }; + + $scope.collapseSidebarIfSmallRes = function () { + if (window.innerWidth <= layoutSizes.resWidthCollapseSidebar) { + $rootScope.$isMenuCollapsed = true; + } + }; + } +})(); \ No newline at end of file diff --git a/src/app/theme/components/sidebar/sidebar.directive.js b/src/app/theme/components/sidebar/sidebar.directive.js new file mode 100644 index 0000000..8b97558 --- /dev/null +++ b/src/app/theme/components/sidebar/sidebar.directive.js @@ -0,0 +1,20 @@ +/** + * @author v.lugovksy + * created on 16.12.2015 + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme.components') + .directive('sidebar', sidebar); + + /** @ngInject */ + function sidebar() { + return { + restrict: 'E', + templateUrl: 'app/theme/components/sidebar/sidebar.html', + controller: 'SidebarCtrl' + }; + } + +})(); \ No newline at end of file diff --git a/src/app/components/sidebar/sidebar.html b/src/app/theme/components/sidebar/sidebar.html similarity index 100% rename from src/app/components/sidebar/sidebar.html rename to src/app/theme/components/sidebar/sidebar.html diff --git a/src/app/theme/components/widgets/widgets.directive.js b/src/app/theme/components/widgets/widgets.directive.js new file mode 100644 index 0000000..2600602 --- /dev/null +++ b/src/app/theme/components/widgets/widgets.directive.js @@ -0,0 +1,23 @@ +/** + * @author v.lugovksy + * created on 16.12.2015 + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme.components') + .directive('widgets', widgets); + + /** @ngInject */ + function widgets() { + return { + restrict: 'EA', + scope: { + ngModel: '=' + }, + templateUrl: 'app/theme/components/widgets/widgets.html', + replace: true + }; + } + +})(); \ No newline at end of file diff --git a/src/app/components/widgets/widgets.html b/src/app/theme/components/widgets/widgets.html similarity index 100% rename from src/app/components/widgets/widgets.html rename to src/app/theme/components/widgets/widgets.html diff --git a/src/app/theme/theme.module.js b/src/app/theme/theme.module.js index e853b76..ebffa96 100644 --- a/src/app/theme/theme.module.js +++ b/src/app/theme/theme.module.js @@ -6,7 +6,9 @@ 'use strict'; angular.module('BlurAdmin.theme', [ - 'toastr' + 'toastr', + + 'BlurAdmin.theme.components' ]); })();