diff options
author | Cyrill von Wattenwyl <cvw@adfinis.com> | 2014-09-02 11:20:52 +0200 |
---|---|---|
committer | Cyrill von Wattenwyl <cvw@adfinis.com> | 2014-09-02 11:20:52 +0200 |
commit | 11a40dd1fef6c5b78b054617caba4325f95ee386 (patch) | |
tree | de2e1d7efd6423ef4d1256dd5c90a972ad172719 /program/js/common.js | |
parent | 187fd666aa2f32dedfe544d69b7cb213698197f2 (diff) | |
parent | ba084313bfc9c7a5a83e0611fe4376543cc1653d (diff) |
Merge branch 'master' of https://github.com/roundcube/roundcubemail
Conflicts:
plugins/password/config.inc.php.dist
Diffstat (limited to 'program/js/common.js')
-rw-r--r-- | program/js/common.js | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/program/js/common.js b/program/js/common.js index 48e85558f..76643068d 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -31,7 +31,6 @@ var CONTROL_KEY = 1; var SHIFT_KEY = 2; var CONTROL_SHIFT_KEY = 3; - /** * Default browser check class * @constructor @@ -281,6 +280,28 @@ cancel: function(evt) return false; }, +/** + * Determine whether the given event was trigered from keyboard + */ +is_keyboard: function(e) +{ + return e && ( + (e.pointerType !== undefined && e.pointerType !== 'mouse') || // IE 11+ + (e.mozInputSource && e.mozInputSource == e.MOZ_SOURCE_KEYBOARD) || // Firefox + (e.offsetX === 0 && e.offsetY === 0) || // Opera + (!e.pageX && (e.pageY || 0) <= 0 && !e.clientX && (e.clientY || 0) <= 0) || // others + (bw.ie && rcube_event._last_keyboard_event && rcube_event._last_keyboard_event.target == e.target) // hack for IE <= 10 + ); +}, + +/** + * 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 +614,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() { |