|
| 1 | +var UMaterialApp = angular.module('abMaterial', [ |
| 2 | + 'ngAnimate', |
| 3 | + 'ngMaterial', |
| 4 | + 'ngRoute', |
| 5 | + 'ngMessages', |
| 6 | + 'ngAria', |
| 7 | + 'ngMaterial', |
| 8 | + 'oc.lazyLoad', |
| 9 | + 'ui.bootstrap', |
| 10 | + 'chieffancypants.loadingBar' |
| 11 | +]); |
| 12 | + |
| 13 | + |
| 14 | +UMaterialApp.config(function ($routeProvider, $mdThemingProvider, cfpLoadingBarProvider) { |
| 15 | + cfpLoadingBarProvider.includeSpinner = true; |
| 16 | + |
| 17 | + $mdThemingProvider.theme('yellow') |
| 18 | + .primaryPalette('yellow'); |
| 19 | + $mdThemingProvider.theme('bluegrey') |
| 20 | + .primaryPalette('blue-grey'); |
| 21 | + $mdThemingProvider.theme('teal') |
| 22 | + .primaryPalette('teal'); |
| 23 | + $mdThemingProvider.theme('grey') |
| 24 | + .primaryPalette('grey'); |
| 25 | + $mdThemingProvider.theme('green') |
| 26 | + .primaryPalette('green'); |
| 27 | + $mdThemingProvider.theme('orange') |
| 28 | + .primaryPalette('orange'); |
| 29 | + $mdThemingProvider.theme('blue') |
| 30 | + .primaryPalette('blue'); |
| 31 | + $mdThemingProvider.theme('purple') |
| 32 | + .primaryPalette('purple'); |
| 33 | + $mdThemingProvider.theme('red') |
| 34 | + .primaryPalette('red'); |
| 35 | + $mdThemingProvider.theme('pink') |
| 36 | + .primaryPalette('pink'); |
| 37 | + $mdThemingProvider.theme('indigo') |
| 38 | + .primaryPalette('indigo'); |
| 39 | + |
| 40 | + |
| 41 | + $mdThemingProvider.alwaysWatchTheme(true); |
| 42 | + $mdThemingProvider.setDefaultTheme('blue'); |
| 43 | + |
| 44 | + |
| 45 | +}); |
| 46 | + |
| 47 | +UMaterialApp.controller('UMaterialCtrl', function ($scope, $mdToast, $route, $routeParams, $location, $timeout, cfpLoadingBar) { |
| 48 | + |
| 49 | + var me = this; |
| 50 | + |
| 51 | + cfpLoadingBar.start(); |
| 52 | + |
| 53 | + |
| 54 | + if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { |
| 55 | + angular.element('html').addClass('ismobile'); |
| 56 | + } |
| 57 | + |
| 58 | + $scope.appCfg = { |
| 59 | + title: 'Ultimate Material', |
| 60 | + loading: false, |
| 61 | + specialTheme: '', |
| 62 | + currentTheme: localStorage.getItem('app_current_theme') || 'blue', //default theme |
| 63 | + isFullScreen: localStorage.getItem('app_full_screen') || '0', |
| 64 | + currentLayout: localStorage.getItem('app_current_layout') || '1', |
| 65 | + footerEnabled: localStorage.getItem('app_footer_enabled') || '1', |
| 66 | + openInsetTab: localStorage.getItem('app_open_inset_tab') || '1', |
| 67 | + sidebarToggle: false, |
| 68 | + themeList: [ |
| 69 | + 'yellow', |
| 70 | + 'bluegrey', |
| 71 | + 'teal', |
| 72 | + 'grey', |
| 73 | + 'green', |
| 74 | + 'orange', |
| 75 | + 'blue', |
| 76 | + 'purple', |
| 77 | + 'red', |
| 78 | + 'pink', |
| 79 | + 'indigo' |
| 80 | + ], |
| 81 | + fullScreen: function () { |
| 82 | + if ($scope.appCfg.isFullScreen == '1') { |
| 83 | + $scope.appCfg.isFullScreen = '0'; |
| 84 | + $scope.appCfg.currentLayout = '1'; |
| 85 | + $scope.appCfg.sidebarToggle = true; |
| 86 | + $scope.appCfg.footerEnabled = '1'; |
| 87 | + } else { |
| 88 | + $scope.appCfg.isFullScreen = '1'; |
| 89 | + $scope.appCfg.currentLayout = '0'; |
| 90 | + $scope.appCfg.sidebarToggle = false; |
| 91 | + $scope.appCfg.footerEnabled = '0'; |
| 92 | + $scope.appCfg.openInsetTab = '1'; |
| 93 | + } |
| 94 | + }, |
| 95 | + |
| 96 | + closeSidebar: function (e) { |
| 97 | + $scope.appCfg.sidebarToggle = false; |
| 98 | + }, |
| 99 | + |
| 100 | + switchTheme: function (color) { |
| 101 | + $scope.appCfg.currentTheme = color; |
| 102 | + localStorage.setItem('app_current_theme', color); |
| 103 | + }, |
| 104 | + |
| 105 | + mainMenu: MainMenuConfig |
| 106 | + |
| 107 | + }; |
| 108 | + |
| 109 | + $scope.gotoUrl = function (url) { |
| 110 | + window.location.href = url; |
| 111 | + } |
| 112 | + |
| 113 | + $scope.$watchGroup(['appCfg.currentLayout', 'appCfg.footerEnabled', 'appCfg.isFullScreen', 'appCfg.openInsetTab'], function (newValues, oldValues, scope) { |
| 114 | + localStorage.setItem('app_current_layout', newValues[0]); |
| 115 | + localStorage.setItem('app_footer_enabled', newValues[1]); |
| 116 | + localStorage.setItem('app_full_screen', newValues[2]); |
| 117 | + localStorage.setItem('app_open_inset_tab', newValues[3]); |
| 118 | + if (newValues[3] != oldValues[3]) { |
| 119 | + window.location.href = '#'; |
| 120 | + } |
| 121 | + }); |
| 122 | + |
| 123 | + me.tabManager = TabManager; |
| 124 | + |
| 125 | + $scope.PAGEURL = ''; |
| 126 | + |
| 127 | + $scope.$watch(function pathWatch() { |
| 128 | + return $location.$$url; |
| 129 | + }, function pathWatchAction(path) { |
| 130 | + if (path.base != '#') { |
| 131 | + var search = $location.search(); |
| 132 | + var _path = search.url, title = search.title, theme = search.theme || '', icon = search.icon, hash = '#/?url=' + _path + '&title=' + title; |
| 133 | + if (!icon)icon = "bookmark-outline"; |
| 134 | + if (_path && title && $scope.appCfg.openInsetTab == 1) { |
| 135 | + me.tabManager.addTab(_path, title, icon, hash, theme); |
| 136 | + } else if ($scope.appCfg.openInsetTab != 1 && _path) { |
| 137 | + $scope.PAGEURL = _path; |
| 138 | + if (theme) { |
| 139 | + $scope.appCfg.specialTheme = theme; |
| 140 | + } else { |
| 141 | + $scope.appCfg.specialTheme = ''; |
| 142 | + } |
| 143 | + } |
| 144 | + } |
| 145 | + }); |
| 146 | + |
| 147 | + $scope.$watch( |
| 148 | + function watchIndex() { |
| 149 | + return (me.tabManager.TABS.length + me.tabManager.SELECTEDINDEX); |
| 150 | + }, |
| 151 | + function (current, old) { |
| 152 | + if ($scope.PAGEURL) return; |
| 153 | + var tab = me.tabManager.TABS[me.tabManager.SELECTEDINDEX]; |
| 154 | + $timeout(function () { |
| 155 | + if (tab && tab.theme) { |
| 156 | + $scope.appCfg.specialTheme = tab.theme; |
| 157 | + } else { |
| 158 | + $scope.appCfg.specialTheme = ''; |
| 159 | + } |
| 160 | + }, 350); |
| 161 | + }); |
| 162 | + |
| 163 | + |
| 164 | +}).controller('HeaderCtrl', function ($scope, $mdToast, $mdSidenav, $routeParams, $location, $timeout) { |
| 165 | + |
| 166 | + $scope.header_search_open = false; |
| 167 | + |
| 168 | + $scope.closeHeaderSearch = function () { |
| 169 | + $('.search-widget input').val(''); |
| 170 | + $scope.header_search_open = false; |
| 171 | + }; |
| 172 | + |
| 173 | + $scope.openHeaderSearch = function (ev) { |
| 174 | + $scope.header_search_open = true; |
| 175 | + $timeout(function () { |
| 176 | + $('.search-widget input').focus(); |
| 177 | + }, 300) |
| 178 | + }; |
| 179 | + |
| 180 | + $scope.toggleRight = function () { |
| 181 | + $mdSidenav('right') |
| 182 | + .toggle(); |
| 183 | + } |
| 184 | + |
| 185 | + |
| 186 | +}).controller('SidebarRCtrl', function ($scope, $mdToast, $mdSidenav, $routeParams, $location, $mdDialog) { |
| 187 | + |
| 188 | + $scope.toppings = [ |
| 189 | + {name: 'Pepperoni', wanted: true}, |
| 190 | + {name: 'Sausage', wanted: false}, |
| 191 | + {name: 'Black Olives', wanted: true}, |
| 192 | + {name: 'Green Peppers', wanted: false} |
| 193 | + ]; |
| 194 | + $scope.settings = [ |
| 195 | + {name: 'Wi-Fi', extraScreen: 'Wi-fi menu', icon: 'device:network-wifi', enabled: true}, |
| 196 | + {name: 'Bluetooth', extraScreen: 'Bluetooth menu', icon: 'device:bluetooth', enabled: false}, |
| 197 | + ]; |
| 198 | + |
| 199 | + $scope.people = [ |
| 200 | + {name: 'Janet Perkins', img: 'img/100-0.jpeg', newMessage: true}, |
| 201 | + {name: 'Mary Johnson', img: 'img/100-1.jpeg', newMessage: false}, |
| 202 | + {name: 'Peter Carlsson', img: 'img/100-2.jpeg', newMessage: false} |
| 203 | + ]; |
| 204 | + |
| 205 | + |
| 206 | + $scope.navigateTo = function (action, event) { |
| 207 | + |
| 208 | + } |
| 209 | + |
| 210 | + |
| 211 | +}); |
| 212 | + |
| 213 | + |
| 214 | +angular.element(document).ready(function () { |
| 215 | + angular.bootstrap(document, ['abMaterial']); |
| 216 | +}); |
0 commit comments