mapping
7 years ago
angular-chosen.directive.js
7 years ago
attributes.service.js
7 years ago
autodetect.directive.js
7 years ago
cascade.directive.js
7 years ago
contenteditable.directive.js
7 years ago
currency.service.js
7 years ago
droppable.directive.js
7 years ago
export.service.js
7 years ago
focusMeWhenEnabled.directive.js
7 years ago
googleCategoriesService.js
7 years ago
main.controller.js
7 years ago
styledInput.directive.js
7 years ago
template.service.js
7 years ago
tipsy.directive.js
7 years ago
wpHttp.service.js
7 years ago
styledInput.directive.js
35 lines
| 1 | GoogleMerchants.directive('styledInput', function($timeout) { |
| 2 | return { |
| 3 | priority: -1, |
| 4 | scope: { |
| 5 | 'placeholder' : '=', |
| 6 | 'ngModel' : '=' |
| 7 | }, |
| 8 | |
| 9 | template: '<div class="editable" contenteditable="true" ng-model="ngModel" placeholder="{{placeholder}}"></div>', |
| 10 | link: function(scope, element) { |
| 11 | |
| 12 | var KEY_A = 65; |
| 13 | var KEY_X = 88; |
| 14 | var KEY_C = 67; |
| 15 | var KEY_V = 86; |
| 16 | element.bind('keydown', function(event) { |
| 17 | //Disable bold (Ctrl+B, Command+b), italic (Ctrl+I, Command+I) etc., |
| 18 | // but allow select all (Ctrl+A), copy, cut, past |
| 19 | if((event.ctrlKey || event.metaKey) |
| 20 | && event.which != KEY_A |
| 21 | && event.which != KEY_X |
| 22 | && event.which != KEY_C |
| 23 | && event.which != KEY_V) |
| 24 | { |
| 25 | return false; |
| 26 | } |
| 27 | |
| 28 | // Disable new line |
| 29 | if(event.which == 13) { |
| 30 | return false; |
| 31 | } |
| 32 | }); |
| 33 | } |
| 34 | }; |
| 35 | }); |