Skip to content

Commit

Permalink
Create fabricUtilities.js
Browse files Browse the repository at this point in the history
  • Loading branch information
clouddueling committed Jul 21, 2014
1 parent c5376db commit 043e101
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions assets/fabricUtilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
angular.module('common.fabric.utilities', [])

.directive('parentClick', ['$timeout', function($timeout) {
return {
scope: {
parentClick: '&'
},
link: function(scope, element) {
element.mousedown(function() {
$timeout(function() {
scope.parentClick();
});
})
.children()
.mousedown(function(e) {
e.stopPropagation();
});
}
};
}])

.factory('Keypress', [function() {
var self = {};

self.onSave = function(cb) {
$(document).keydown(function(event) {
// If Control or Command key is pressed and the S key is pressed
// run save function. 83 is the key code for S.
if((event.ctrlKey || event.metaKey) && event.which === 83) {
// Save Function
event.preventDefault();

cb();

return false;
}
});
};

return self;
}])

.filter('reverse', [function() {
return function(items) {
if (items) {
return items.slice().reverse();
}
};
}]);

0 comments on commit 043e101

Please sign in to comment.