85 lines
2.3 KiB
JavaScript
85 lines
2.3 KiB
JavaScript
'use strict';
|
|
|
|
var ZeroClipboard = window.ZeroClipboard;
|
|
|
|
angular.module('flosight')
|
|
.directive('scroll', function ($window) {
|
|
return function(scope, element, attrs) {
|
|
angular.element($window).bind('scroll', function() {
|
|
if (this.pageYOffset >= 200) {
|
|
scope.secondaryNavbar = true;
|
|
} else {
|
|
scope.secondaryNavbar = false;
|
|
}
|
|
scope.$apply();
|
|
});
|
|
};
|
|
})
|
|
.directive('whenScrolled', function($window) {
|
|
return {
|
|
restric: 'A',
|
|
link: function(scope, elm, attr) {
|
|
var pageHeight, clientHeight, scrollPos;
|
|
$window = angular.element($window);
|
|
|
|
var handler = function() {
|
|
pageHeight = window.document.documentElement.scrollHeight;
|
|
clientHeight = window.document.documentElement.clientHeight;
|
|
scrollPos = window.pageYOffset;
|
|
|
|
if (pageHeight - (scrollPos + clientHeight) === 0) {
|
|
scope.$apply(attr.whenScrolled);
|
|
}
|
|
};
|
|
|
|
$window.on('scroll', handler);
|
|
|
|
scope.$on('$destroy', function() {
|
|
return $window.off('scroll', handler);
|
|
});
|
|
}
|
|
};
|
|
})
|
|
.directive('dataClipboardText', function() {
|
|
return {
|
|
restric: 'A',
|
|
scope: { dataClipboardText: '=dataClipboardText' },
|
|
template: '<div class="tooltip fade right in"><div class="tooltip-arrow"></div><div class="tooltip-inner">Copied!</div></div>',
|
|
link: function(scope, elm) {
|
|
var clip = new ClipboardJS(elm);
|
|
|
|
// clip.on('load', function(client) {
|
|
// var onMousedown = function(client) {
|
|
// client.setText(scope.clipCopy);
|
|
// };
|
|
|
|
// client.on('mousedown', onMousedown);
|
|
|
|
// scope.$on('$destroy', function() {
|
|
// client.off('mousedown', onMousedown);
|
|
// });
|
|
// });
|
|
|
|
// clip.on('noFlash wrongflash', function() {
|
|
// return elm.remove();
|
|
// });
|
|
}
|
|
};
|
|
})
|
|
.directive('focus', function ($timeout) {
|
|
return {
|
|
scope: {
|
|
trigger: '@focus'
|
|
},
|
|
link: function (scope, element) {
|
|
scope.$watch('trigger', function (value) {
|
|
if (value === "true") {
|
|
$timeout(function () {
|
|
element[0].focus();
|
|
});
|
|
}
|
|
});
|
|
}
|
|
};
|
|
});
|