refactor(themeComponents): move components to separate module

pull/3/head
Vladimir Lugovsky 2015-12-16 01:32:16 +03:00
parent 81adb6fd2f
commit b6b52af148
26 changed files with 513 additions and 405 deletions

View File

@ -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'
};
});

View File

@ -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'
};
});

View File

@ -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];
});
}
};
}]);

View File

@ -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', '<strong>' + $scope.users[msg.userId].name + '</strong>');
}
return $sce.trustAsHtml(text);
};
}]
};
});

View File

@ -1,10 +0,0 @@
'use strict';
blurAdminApp.directive('pageTop', function () {
return {
restrict: 'E',
templateUrl: 'app/components/pageTop/pageTop.html',
link: function ($scope) {
}
};
});

View File

@ -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;
}
};
}]
};
});

View File

@ -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 () {
}
};
});

View File

@ -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
});
}
};
}
})();

View File

@ -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'
};
}
})();

View File

@ -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', []);
})();

View File

@ -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];
});
}
};
}
})();

View File

@ -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', '<strong>' + $scope.users[msg.userId].name + '</strong>');
}
return $sce.trustAsHtml(text);
};
}
})();

View File

@ -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'
};
}
})();

View File

@ -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'
};
}
})();

View File

@ -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;
}
};
}
})();

View File

@ -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'
};
}
})();

View File

@ -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
};
}
})();

View File

@ -6,7 +6,9 @@
'use strict';
angular.module('BlurAdmin.theme', [
'toastr'
'toastr',
'BlurAdmin.theme.components'
]);
})();