-
Notifications
You must be signed in to change notification settings - Fork 14
/
angular-circular-navigation.js
53 lines (42 loc) · 2.07 KB
/
angular-circular-navigation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
(function () {
'use strict';
/*global define, module, exports, require */
/* istanbul ignore next */
var angular = window.angular ? window.angular : 'undefined' !== typeof require ? require('angular') : undefined;
var circular = angular.module('angularCircularNavigation', [])
.directive('circular', ['$compile', function ($compile) {
return {
restrict: 'EA',
scope: {
options: '='
},
template: '<button ng-click="toggleMenu()" class="cn-button {{options.button.size}}" ng-class="options.button.cssClass" style="background: {{options.button.background ? options.button.background : options.background}}; color: {{options.button.color ? options.button.color :options.color}};">{{options.content}}</button>' +
'<div class="cn-wrapper {{options.size}} items-{{options.items.length}}" ng-class="{\'opened-nav\': options.isOpen}"><ul>' +
'<li ng-repeat="item in options.items">' +
'<a ng-hide="item.empty" ng-click="perform(options, item)" ng-class="{\'is-active\': item.isActive}" class="{{item.cssClass}}" style="background: {{item.background ? item.background : options.background}}; color: {{item.color ? item.color : options.color}};">' +
'<span>{{item.content}}</span>' +
'</a></li></ul></div>',
controller: ['$scope', '$element', '$attrs',
function ($scope, $element, $attrs) {
$scope.toggleMenu = function () {
$scope.options.isOpen = !$scope.options.isOpen;
};
$scope.perform = function (options, item) {
if (typeof item.onclick === 'function') {
item.onclick(options, item);
}
if ($scope.options.toggleOnClick) {
$scope.toggleMenu();
}
};
}
]
};
}]);
/* istanbul ignore next */
if (typeof define === 'function' && define.amd) {
define('circular', ['angular'], circular);
} else if ('undefined' !== typeof exports && 'undefined' !== typeof module) {
module.exports = circular;
}
})();