2015-01-20 19:29:31 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/* Directives */
|
|
|
|
|
|
|
|
|
|
|
|
angular.module('netStatsApp.directives', []).
|
|
|
|
directive('appVersion', ['version', function(version) {
|
|
|
|
return function(scope, elm, attrs) {
|
|
|
|
elm.text(version);
|
|
|
|
};
|
2015-02-08 16:03:05 +01:00
|
|
|
}]).
|
|
|
|
directive('nodemap', ['$compile', function($compile) {
|
|
|
|
return {
|
|
|
|
restrict: 'EA',
|
|
|
|
scope: {
|
|
|
|
data: '='
|
|
|
|
},
|
|
|
|
link: function(scope, element, attrs) {
|
2015-02-08 16:20:43 +01:00
|
|
|
scope.init = function() {
|
|
|
|
element.empty();
|
|
|
|
|
|
|
|
scope.map = new Datamap({
|
|
|
|
element: element[0],
|
|
|
|
scope: 'world',
|
|
|
|
responsive: true,
|
|
|
|
fills: {
|
|
|
|
success: '#7bcc3a',
|
|
|
|
info: '#10a0de',
|
|
|
|
warning: '#FFD162',
|
|
|
|
danger: '#F74B4B',
|
|
|
|
defaultFill: '#282828'
|
|
|
|
},
|
|
|
|
geographyConfig: {
|
|
|
|
borderWidth: 0,
|
|
|
|
borderColor: '#000',
|
|
|
|
highlightOnHover: false,
|
|
|
|
popupOnHover: false
|
|
|
|
},
|
|
|
|
bubblesConfig: {
|
|
|
|
borderWidth: 0,
|
|
|
|
popupOnHover: false,
|
|
|
|
highlightOnHover: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
scope.map.bubbles(scope.data, {
|
2015-02-08 16:03:05 +01:00
|
|
|
borderWidth: 0,
|
|
|
|
popupOnHover: false,
|
|
|
|
highlightOnHover: false
|
2015-02-08 16:20:43 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
scope.init();
|
2015-02-08 16:03:05 +01:00
|
|
|
|
2015-02-08 16:20:43 +01:00
|
|
|
window.onresize = function() {
|
|
|
|
scope.$apply();
|
|
|
|
};
|
2015-02-08 16:03:05 +01:00
|
|
|
|
|
|
|
scope.$watch('data', function() {
|
|
|
|
scope.map.bubbles(scope.data, {
|
|
|
|
borderWidth: 0,
|
|
|
|
popupOnHover: false,
|
|
|
|
highlightOnHover: false
|
|
|
|
});
|
|
|
|
}, true);
|
2015-02-08 16:20:43 +01:00
|
|
|
|
|
|
|
scope.$watch(function() {
|
|
|
|
return angular.element(window)[0].innerWidth;
|
|
|
|
}, function() {
|
|
|
|
scope.init();
|
|
|
|
});
|
2015-02-08 16:03:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}]);
|