diff options
Diffstat (limited to 'program/js/common.js')
-rw-r--r-- | program/js/common.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/program/js/common.js b/program/js/common.js index 48e85558f..5ac4febce 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -281,6 +281,25 @@ cancel: function(evt) return false; }, +/** + * Determine whether the given event was trigered from keyboard + */ +is_keyboard: function(e) +{ + return e && ( + (e.mozInputSource && e.mozInputSource == e.MOZ_SOURCE_KEYBOARD) || + (!e.pageX && (e.pageY || 0) <= 0 && !e.clientX && (e.clientY || 0) <= 0) + ); +}, + +/** + * Accept event if triggered from keyboard action (e.g. <Enter>) + */ +keyboard_only: function(e) +{ + return rcube_event.is_keyboard(e) ? true : rcube_event.cancel(e); +}, + touchevent: function(e) { return { pageX:e.pageX, pageY:e.pageY, offsetX:e.pageX - e.target.offsetLeft, offsetY:e.pageY - e.target.offsetTop, target:e.target, istouch:true }; @@ -593,6 +612,11 @@ if (!String.prototype.startsWith) { }; } +// array utility function +jQuery.last = function(arr) { + return arr && arr.length ? arr[arr.length-1] : undefined; +} + // jQuery plugin to emulate HTML5 placeholder attributes on input elements jQuery.fn.placeholder = function(text) { return this.each(function() { |