From 87b34295eb3e5930ea54c76d39d847cf17c824e9 Mon Sep 17 00:00:00 2001 From: alekseybobkov Date: Fri, 24 Apr 2015 21:08:07 -0700 Subject: [PATCH] Refactored hotkey plugin for the better memory handling. Added dispose-control event support. --- modules/backend/assets/js/october-min.js | 71 +++--- modules/backend/assets/js/october.hotkey.js | 231 ++++++++++++-------- 2 files changed, 180 insertions(+), 122 deletions(-) diff --git a/modules/backend/assets/js/october-min.js b/modules/backend/assets/js/october-min.js index 83e2ec6e2..0ac75a987 100644 --- a/modules/backend/assets/js/october-min.js +++ b/modules/backend/assets/js/october-min.js @@ -1139,34 +1139,37 @@ data[option].apply(data,methodArgs)}})} $.fn.fileList.Constructor=FileList $.fn.fileList.noConflict=function(){$.fn.fileList=old return this} -$(document).ready(function(){$('[data-control=filelist]').fileList()})}(window.jQuery);+function($){"use strict";var HotKey=function(element,options){var $el=this.$el=$(element) -var $target=this.$target=$(options.hotkeyTarget) +$(document).ready(function(){$('[data-control=filelist]').fileList()})}(window.jQuery);+function($){"use strict";var Base=$.oc.foundation.base,BaseProto=Base.prototype +var HotKey=function(element,options){if(!options.hotkey) +throw new Error('No hotkey has been defined.');this.$el=$(element) +this.$target=$(options.hotkeyTarget) this.options=options||{} -if(!options.hotkey) -throw new Error('No hotkey has been defined.');if(options.hotkeyMac)options.hotkey+=', '+options.hotkeyMac -var -keys=options.hotkey.toLowerCase().split(','),keysCount=keys.length,keyConditions=[],keyPressed={shift:false,ctrl:false,cmd:false,alt:false},keyMap={'esc':27,'tab':9,'space':32,'return':13,'enter':13,'backspace':8,'scroll':145,'capslock':20,'numlock':144,'pause':19,'break':19,'insert':45,'home':36,'delete':46,'suppr':46,'end':35,'pageup':33,'pagedown':34,'left':37,'up':38,'right':39,'down':40,'f1':112,'f2':113,'f3':114,'f4':115,'f5':116,'f6':117,'f7':118,'f8':119,'f9':120,'f10':121,'f11':122,'f12':123} -for(var i=0;i