-
+ B18433B4A5013CF3800ABFCE4BB5B2CA458D36C56C1A23686C00E7380E577CB8F68262F95E63CD174C085E861CF046734172402EDA594A3550609A1310AC4C73
mp-wp/wp-includes/js/jquery/jquery.hotkeys.js
(0 . 0)(1 . 128)
102214 /******************************************************************************************************************************
102215
102216 * @ Original idea by by Binny V A, Original version: 2.00.A
102217 * @ http://www.openjs.com/scripts/events/keyboard_shortcuts/
102218 * @ Original License : BSD
102219
102220 * @ jQuery Plugin by Tzury Bar Yochay
102221 mail: tzury.by@gmail.com
102222 blog: evalinux.wordpress.com
102223 face: facebook.com/profile.php?id=513676303
102224
102225 (c) Copyrights 2007
102226
102227 * @ jQuery Plugin version Beta (0.0.2)
102228 * @ License: jQuery-License.
102229
102230 TODO:
102231 add queue support (as in gmail) e.g. 'x' then 'y', etc.
102232 add mouse + mouse wheel events.
102233
102234 USAGE:
102235 $.hotkeys.add('Ctrl+c', function(){ alert('copy anyone?');});
102236 $.hotkeys.add('Ctrl+c', {target:'div#editor', type:'keyup', propagate: true},function(){ alert('copy anyone?');});>
102237 $.hotkeys.remove('Ctrl+c');
102238 $.hotkeys.remove('Ctrl+c', {target:'div#editor', type:'keypress'});
102239
102240 ******************************************************************************************************************************/
102241 (function (jQuery){
102242 this.version = '(beta)(0.0.3)';
102243 this.all = {};
102244 this.special_keys = {
102245 27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll', 20: 'capslock',
102246 144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del',35:'end', 33: 'pageup',
102247 34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down', 112:'f1',113:'f2', 114:'f3',
102248 115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8', 120:'f9', 121:'f10', 122:'f11', 123:'f12'};
102249
102250 this.shift_nums = { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&",
102251 "8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<",
102252 ".":">", "/":"?", "\\":"|" };
102253
102254 this.add = function(combi, options, callback) {
102255 if (jQuery.isFunction(options)){
102256 callback = options;
102257 options = {};
102258 }
102259 var opt = {},
102260 defaults = {type: 'keydown', propagate: false, disableInInput: false, target: jQuery('html')[0]},
102261 that = this;
102262 opt = jQuery.extend( opt , defaults, options || {} );
102263 combi = combi.toLowerCase();
102264
102265 // inspect if keystroke matches
102266 var inspector = function(event) {
102267 event = jQuery.event.fix(event); // jQuery event normalization.
102268 var element = event.target;
102269 // @ TextNode -> nodeType == 3
102270 element = (element.nodeType==3) ? element.parentNode : element;
102271
102272 if(opt['disableInInput']) { // Disable shortcut keys in Input, Textarea fields
102273 var target = jQuery(element);
102274 if( target.is("input") || target.is("textarea")){
102275 return;
102276 }
102277 }
102278 var code = event.which,
102279 type = event.type,
102280 character = String.fromCharCode(code).toLowerCase(),
102281 special = that.special_keys[code],
102282 shift = event.shiftKey,
102283 ctrl = event.ctrlKey,
102284 alt= event.altKey,
102285 meta = event.metaKey,
102286 propagate = true, // default behaivour
102287 mapPoint = null;
102288
102289 // in opera + safari, the event.target is unpredictable.
102290 // for example: 'keydown' might be associated with HtmlBodyElement
102291 // or the element where you last clicked with your mouse.
102292 if (jQuery.browser.opera || jQuery.browser.safari){
102293 while (!that.all[element] && element.parentNode){
102294 element = element.parentNode;
102295 }
102296 }
102297 var cbMap = that.all[element].events[type].callbackMap;
102298 if(!shift && !ctrl && !alt && !meta) { // No Modifiers
102299 mapPoint = cbMap[special] || cbMap[character]
102300 }
102301 // deals with combinaitons (alt|ctrl|shift+anything)
102302 else{
102303 var modif = '';
102304 if(alt) modif +='alt+';
102305 if(ctrl) modif+= 'ctrl+';
102306 if(shift) modif += 'shift+';
102307 if(meta) modif += 'meta+';
102308 // modifiers + special keys or modifiers + characters or modifiers + shift characters
102309 mapPoint = cbMap[modif+special] || cbMap[modif+character] || cbMap[modif+that.shift_nums[character]]
102310 }
102311 if (mapPoint){
102312 mapPoint.cb(event);
102313 if(!mapPoint.propagate) {
102314 event.stopPropagation();
102315 event.preventDefault();
102316 return false;
102317 }
102318 }
102319 };
102320 // first hook for this element
102321 if (!this.all[opt.target]){
102322 this.all[opt.target] = {events:{}};
102323 }
102324 if (!this.all[opt.target].events[opt.type]){
102325 this.all[opt.target].events[opt.type] = {callbackMap: {}}
102326 jQuery.event.add(opt.target, opt.type, inspector);
102327 }
102328 this.all[opt.target].events[opt.type].callbackMap[combi] = {cb: callback, propagate:opt.propagate};
102329 return jQuery;
102330 };
102331 this.remove = function(exp, opt) {
102332 opt = opt || {};
102333 target = opt.target || jQuery('html')[0];
102334 type = opt.type || 'keydown';
102335 exp = exp.toLowerCase();
102336 delete this.all[target].events[type].callbackMap[exp]
102337 return jQuery;
102338 };
102339 jQuery.hotkeys = this;
102340 return jQuery;
102341 })(jQuery);