From e16c505c25ff0993cd186b8a23b107d4dd6cb875 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Sat, 1 Nov 2014 20:35:23 -0400 Subject: [PATCH] Move to a central key handler This allows for any control to emit key events, and for the Select2 instance to handle them. So now the search box will allow for results to be scrolled and selected, bringing back the old expected functionality. This also stops triggering new queries when the arrow keys are pressed. The container will also be automatically focused when the dropdown is closed, which is consistent with the old Select2. The results will no longer be queried on initialization, but instead will be queried when the dropdown is opened. This is more consistent with the previous version of Select2. The search box will now be cleared when the dropdown is closed. --- dist/js/select2.amd.full.js | 185 +++++++++++++++++------------ dist/js/select2.amd.js | 185 +++++++++++++++++------------ dist/js/select2.full.js | 185 +++++++++++++++++------------ dist/js/select2.full.min.js | 4 +- dist/js/select2.js | 185 +++++++++++++++++------------ dist/js/select2.min.js | 2 +- src/js/select2/core.js | 52 +++++++- src/js/select2/dropdown/search.js | 18 ++- src/js/select2/selection/single.js | 31 +---- src/js/select2/utils.js | 4 + 10 files changed, 513 insertions(+), 338 deletions(-) diff --git a/dist/js/select2.amd.full.js b/dist/js/select2.amd.full.js index 0960dff0..4eb1a4b0 100644 --- a/dist/js/select2.amd.full.js +++ b/dist/js/select2.amd.full.js @@ -107,6 +107,8 @@ window.$ = window.$ || {};(function() { if ($ && $.fn && $.fn.select2 && $.fn.se }; Observable.prototype.on = function (event, callback) { + this.listeners = this.listeners || {}; + if (event in this.listeners) { this.listeners[event].push(callback); } else { @@ -117,6 +119,8 @@ window.$ = window.$ || {};(function() { if ($ && $.fn && $.fn.select2 && $.fn.se Observable.prototype.trigger = function (event) { var slice = Array.prototype.slice; + this.listeners = this.listeners || {}; + if (event in this.listeners) { this.invoke(this.listeners[event], slice.call(arguments, 1)); } @@ -569,51 +573,10 @@ define('select2/selection/base',[ return BaseSelection; }); -define('select2/keys',[ - -], function () { - var KEYS = { - BACKSPACE: 8, - TAB: 9, - ENTER: 13, - SHIFT: 16, - CTRL: 17, - ALT: 18, - ESC: 27, - SPACE: 32, - PAGE_UP: 33, - PAGE_DOWN: 34, - END: 35, - HOME: 36, - LEFT: 37, - UP: 38, - RIGHT: 39, - DOWN: 40, - DELETE: 46, - - isArrow: function (k) { - k = k.which ? k.which : k; - - switch (k) { - case KEY.LEFT: - case KEY.RIGHT: - case KEY.UP: - case KEY.DOWN: - return true; - } - - return false; - } - }; - - return KEYS; -}); - define('select2/selection/single',[ './base', - '../utils', - '../keys' -], function (BaseSelection, Utils, KEYS) { + '../utils' +], function (BaseSelection, Utils) { function SingleSelection () { SingleSelection.__super__.constructor.apply(this, arguments); } @@ -667,6 +630,8 @@ define('select2/selection/single',[ // When the dropdown is closed, aria-expanded="false" self.$selection.attr('aria-expanded', 'false'); self.$selection.removeAttr('aria-activedescendant'); + + self.$selection.focus(); }); this.$selection.on('focus', function (evt) { @@ -678,29 +643,7 @@ define('select2/selection/single',[ }); this.$selection.on('keydown', function (evt) { - var key = evt.which; - - if (container.isOpen()) { - if (key == KEYS.ENTER) { - self.trigger('results:select'); - - evt.preventDefault(); - } else if (key == KEYS.UP) { - self.trigger('results:previous'); - - evt.preventDefault(); - } else if (key == KEYS.DOWN) { - self.trigger('results:next'); - - evt.preventDefault(); - } - } else { - if (key == KEYS.ENTER || key == KEYS.SPACE) { - self.trigger('open'); - - evt.preventDefault(); - } - } + self.trigger('keypress', evt); }); container.on('results:focus', function (params) { @@ -1375,8 +1318,8 @@ define('select2/dropdown',[ }); define('select2/dropdown/search',[ - -], function () { + '../utils' +], function (Utils) { function Search () { } Search.prototype.render = function (decorated) { @@ -1401,8 +1344,14 @@ define('select2/dropdown/search',[ decorated.call(this, container, $container); - this.$search.on('keyup', function () { - container.trigger('query', { + this.$search.on('keyup', function (evt) { + self.trigger('keypress', evt); + + if (evt.isDefaultPrevented()) { + return; + } + + self.trigger('query', { term: $(this).val() }); }); @@ -1413,6 +1362,8 @@ define('select2/dropdown/search',[ container.on('close', function () { self.$search.attr('tabindex', -1); + + self.$search.val(''); }); container.on('results:all', function (params) { @@ -1428,7 +1379,7 @@ define('select2/dropdown/search',[ }); }; - Search.prototype.showSearch = function (params) { + Search.prototype.showSearch = function (_, params) { return true; }; @@ -1642,11 +1593,52 @@ define('select2/options',[ return Options; }); +define('select2/keys',[ + +], function () { + var KEYS = { + BACKSPACE: 8, + TAB: 9, + ENTER: 13, + SHIFT: 16, + CTRL: 17, + ALT: 18, + ESC: 27, + SPACE: 32, + PAGE_UP: 33, + PAGE_DOWN: 34, + END: 35, + HOME: 36, + LEFT: 37, + UP: 38, + RIGHT: 39, + DOWN: 40, + DELETE: 46, + + isArrow: function (k) { + k = k.which ? k.which : k; + + switch (k) { + case KEY.LEFT: + case KEY.RIGHT: + case KEY.UP: + case KEY.DOWN: + return true; + } + + return false; + } + }; + + return KEYS; +}); + define('select2/core',[ 'jquery', './options', - './utils' -], function ($, Options, Utils) { + './utils', + './keys' +], function ($, Options, Utils, KEYS) { var Select2 = function ($element, options) { this.$element = $element; @@ -1700,6 +1692,7 @@ define('select2/core',[ // Register any internal event handlers this._registerSelectionEvents(); + this._registerDropdownEvents(); this._registerResultsEvents(); this._registerEvents(); @@ -1711,8 +1704,6 @@ define('select2/core',[ }); }); - this.trigger('query', {}); - // Hide the original select $element.hide(); @@ -1809,6 +1800,22 @@ define('select2/core',[ self.close(); }); + + this.selection.on('keypress', function (e) { + self.trigger('keypress', e); + }); + }; + + Select2.prototype._registerDropdownEvents = function () { + var self = this; + + this.dropdown.on('query', function (params) { + self.trigger('query', params); + }); + + this.dropdown.on('keypress', function (e) { + self.trigger('keypress', e); + }); }; Select2.prototype._registerResultsEvents = function () { @@ -1850,6 +1857,32 @@ define('select2/core',[ }); }); }); + + this.on('keypress', function (evt) { + var key = evt.which; + + if (self.isOpen()) { + if (key == KEYS.ENTER) { + self.trigger('results:select'); + + evt.preventDefault(); + } else if (key == KEYS.UP) { + self.trigger('results:previous'); + + evt.preventDefault(); + } else if (key == KEYS.DOWN) { + self.trigger('results:next'); + + evt.preventDefault(); + } + } else { + if (key == KEYS.ENTER || key == KEYS.SPACE) { + self.trigger('open'); + + evt.preventDefault(); + } + } + }); }; Select2.prototype.toggleDropdown = function () { @@ -1865,6 +1898,8 @@ define('select2/core',[ return; } + this.trigger('query', {}); + this.trigger('open'); }; diff --git a/dist/js/select2.amd.js b/dist/js/select2.amd.js index 0960dff0..4eb1a4b0 100644 --- a/dist/js/select2.amd.js +++ b/dist/js/select2.amd.js @@ -107,6 +107,8 @@ window.$ = window.$ || {};(function() { if ($ && $.fn && $.fn.select2 && $.fn.se }; Observable.prototype.on = function (event, callback) { + this.listeners = this.listeners || {}; + if (event in this.listeners) { this.listeners[event].push(callback); } else { @@ -117,6 +119,8 @@ window.$ = window.$ || {};(function() { if ($ && $.fn && $.fn.select2 && $.fn.se Observable.prototype.trigger = function (event) { var slice = Array.prototype.slice; + this.listeners = this.listeners || {}; + if (event in this.listeners) { this.invoke(this.listeners[event], slice.call(arguments, 1)); } @@ -569,51 +573,10 @@ define('select2/selection/base',[ return BaseSelection; }); -define('select2/keys',[ - -], function () { - var KEYS = { - BACKSPACE: 8, - TAB: 9, - ENTER: 13, - SHIFT: 16, - CTRL: 17, - ALT: 18, - ESC: 27, - SPACE: 32, - PAGE_UP: 33, - PAGE_DOWN: 34, - END: 35, - HOME: 36, - LEFT: 37, - UP: 38, - RIGHT: 39, - DOWN: 40, - DELETE: 46, - - isArrow: function (k) { - k = k.which ? k.which : k; - - switch (k) { - case KEY.LEFT: - case KEY.RIGHT: - case KEY.UP: - case KEY.DOWN: - return true; - } - - return false; - } - }; - - return KEYS; -}); - define('select2/selection/single',[ './base', - '../utils', - '../keys' -], function (BaseSelection, Utils, KEYS) { + '../utils' +], function (BaseSelection, Utils) { function SingleSelection () { SingleSelection.__super__.constructor.apply(this, arguments); } @@ -667,6 +630,8 @@ define('select2/selection/single',[ // When the dropdown is closed, aria-expanded="false" self.$selection.attr('aria-expanded', 'false'); self.$selection.removeAttr('aria-activedescendant'); + + self.$selection.focus(); }); this.$selection.on('focus', function (evt) { @@ -678,29 +643,7 @@ define('select2/selection/single',[ }); this.$selection.on('keydown', function (evt) { - var key = evt.which; - - if (container.isOpen()) { - if (key == KEYS.ENTER) { - self.trigger('results:select'); - - evt.preventDefault(); - } else if (key == KEYS.UP) { - self.trigger('results:previous'); - - evt.preventDefault(); - } else if (key == KEYS.DOWN) { - self.trigger('results:next'); - - evt.preventDefault(); - } - } else { - if (key == KEYS.ENTER || key == KEYS.SPACE) { - self.trigger('open'); - - evt.preventDefault(); - } - } + self.trigger('keypress', evt); }); container.on('results:focus', function (params) { @@ -1375,8 +1318,8 @@ define('select2/dropdown',[ }); define('select2/dropdown/search',[ - -], function () { + '../utils' +], function (Utils) { function Search () { } Search.prototype.render = function (decorated) { @@ -1401,8 +1344,14 @@ define('select2/dropdown/search',[ decorated.call(this, container, $container); - this.$search.on('keyup', function () { - container.trigger('query', { + this.$search.on('keyup', function (evt) { + self.trigger('keypress', evt); + + if (evt.isDefaultPrevented()) { + return; + } + + self.trigger('query', { term: $(this).val() }); }); @@ -1413,6 +1362,8 @@ define('select2/dropdown/search',[ container.on('close', function () { self.$search.attr('tabindex', -1); + + self.$search.val(''); }); container.on('results:all', function (params) { @@ -1428,7 +1379,7 @@ define('select2/dropdown/search',[ }); }; - Search.prototype.showSearch = function (params) { + Search.prototype.showSearch = function (_, params) { return true; }; @@ -1642,11 +1593,52 @@ define('select2/options',[ return Options; }); +define('select2/keys',[ + +], function () { + var KEYS = { + BACKSPACE: 8, + TAB: 9, + ENTER: 13, + SHIFT: 16, + CTRL: 17, + ALT: 18, + ESC: 27, + SPACE: 32, + PAGE_UP: 33, + PAGE_DOWN: 34, + END: 35, + HOME: 36, + LEFT: 37, + UP: 38, + RIGHT: 39, + DOWN: 40, + DELETE: 46, + + isArrow: function (k) { + k = k.which ? k.which : k; + + switch (k) { + case KEY.LEFT: + case KEY.RIGHT: + case KEY.UP: + case KEY.DOWN: + return true; + } + + return false; + } + }; + + return KEYS; +}); + define('select2/core',[ 'jquery', './options', - './utils' -], function ($, Options, Utils) { + './utils', + './keys' +], function ($, Options, Utils, KEYS) { var Select2 = function ($element, options) { this.$element = $element; @@ -1700,6 +1692,7 @@ define('select2/core',[ // Register any internal event handlers this._registerSelectionEvents(); + this._registerDropdownEvents(); this._registerResultsEvents(); this._registerEvents(); @@ -1711,8 +1704,6 @@ define('select2/core',[ }); }); - this.trigger('query', {}); - // Hide the original select $element.hide(); @@ -1809,6 +1800,22 @@ define('select2/core',[ self.close(); }); + + this.selection.on('keypress', function (e) { + self.trigger('keypress', e); + }); + }; + + Select2.prototype._registerDropdownEvents = function () { + var self = this; + + this.dropdown.on('query', function (params) { + self.trigger('query', params); + }); + + this.dropdown.on('keypress', function (e) { + self.trigger('keypress', e); + }); }; Select2.prototype._registerResultsEvents = function () { @@ -1850,6 +1857,32 @@ define('select2/core',[ }); }); }); + + this.on('keypress', function (evt) { + var key = evt.which; + + if (self.isOpen()) { + if (key == KEYS.ENTER) { + self.trigger('results:select'); + + evt.preventDefault(); + } else if (key == KEYS.UP) { + self.trigger('results:previous'); + + evt.preventDefault(); + } else if (key == KEYS.DOWN) { + self.trigger('results:next'); + + evt.preventDefault(); + } + } else { + if (key == KEYS.ENTER || key == KEYS.SPACE) { + self.trigger('open'); + + evt.preventDefault(); + } + } + }); }; Select2.prototype.toggleDropdown = function () { @@ -1865,6 +1898,8 @@ define('select2/core',[ return; } + this.trigger('query', {}); + this.trigger('open'); }; diff --git a/dist/js/select2.full.js b/dist/js/select2.full.js index f424aaf2..412193d7 100644 --- a/dist/js/select2.full.js +++ b/dist/js/select2.full.js @@ -9642,6 +9642,8 @@ define('select2/utils',[], function () { }; Observable.prototype.on = function (event, callback) { + this.listeners = this.listeners || {}; + if (event in this.listeners) { this.listeners[event].push(callback); } else { @@ -9652,6 +9654,8 @@ define('select2/utils',[], function () { Observable.prototype.trigger = function (event) { var slice = Array.prototype.slice; + this.listeners = this.listeners || {}; + if (event in this.listeners) { this.invoke(this.listeners[event], slice.call(arguments, 1)); } @@ -10104,51 +10108,10 @@ define('select2/selection/base',[ return BaseSelection; }); -define('select2/keys',[ - -], function () { - var KEYS = { - BACKSPACE: 8, - TAB: 9, - ENTER: 13, - SHIFT: 16, - CTRL: 17, - ALT: 18, - ESC: 27, - SPACE: 32, - PAGE_UP: 33, - PAGE_DOWN: 34, - END: 35, - HOME: 36, - LEFT: 37, - UP: 38, - RIGHT: 39, - DOWN: 40, - DELETE: 46, - - isArrow: function (k) { - k = k.which ? k.which : k; - - switch (k) { - case KEY.LEFT: - case KEY.RIGHT: - case KEY.UP: - case KEY.DOWN: - return true; - } - - return false; - } - }; - - return KEYS; -}); - define('select2/selection/single',[ './base', - '../utils', - '../keys' -], function (BaseSelection, Utils, KEYS) { + '../utils' +], function (BaseSelection, Utils) { function SingleSelection () { SingleSelection.__super__.constructor.apply(this, arguments); } @@ -10202,6 +10165,8 @@ define('select2/selection/single',[ // When the dropdown is closed, aria-expanded="false" self.$selection.attr('aria-expanded', 'false'); self.$selection.removeAttr('aria-activedescendant'); + + self.$selection.focus(); }); this.$selection.on('focus', function (evt) { @@ -10213,29 +10178,7 @@ define('select2/selection/single',[ }); this.$selection.on('keydown', function (evt) { - var key = evt.which; - - if (container.isOpen()) { - if (key == KEYS.ENTER) { - self.trigger('results:select'); - - evt.preventDefault(); - } else if (key == KEYS.UP) { - self.trigger('results:previous'); - - evt.preventDefault(); - } else if (key == KEYS.DOWN) { - self.trigger('results:next'); - - evt.preventDefault(); - } - } else { - if (key == KEYS.ENTER || key == KEYS.SPACE) { - self.trigger('open'); - - evt.preventDefault(); - } - } + self.trigger('keypress', evt); }); container.on('results:focus', function (params) { @@ -10910,8 +10853,8 @@ define('select2/dropdown',[ }); define('select2/dropdown/search',[ - -], function () { + '../utils' +], function (Utils) { function Search () { } Search.prototype.render = function (decorated) { @@ -10936,8 +10879,14 @@ define('select2/dropdown/search',[ decorated.call(this, container, $container); - this.$search.on('keyup', function () { - container.trigger('query', { + this.$search.on('keyup', function (evt) { + self.trigger('keypress', evt); + + if (evt.isDefaultPrevented()) { + return; + } + + self.trigger('query', { term: $(this).val() }); }); @@ -10948,6 +10897,8 @@ define('select2/dropdown/search',[ container.on('close', function () { self.$search.attr('tabindex', -1); + + self.$search.val(''); }); container.on('results:all', function (params) { @@ -10963,7 +10914,7 @@ define('select2/dropdown/search',[ }); }; - Search.prototype.showSearch = function (params) { + Search.prototype.showSearch = function (_, params) { return true; }; @@ -11177,11 +11128,52 @@ define('select2/options',[ return Options; }); +define('select2/keys',[ + +], function () { + var KEYS = { + BACKSPACE: 8, + TAB: 9, + ENTER: 13, + SHIFT: 16, + CTRL: 17, + ALT: 18, + ESC: 27, + SPACE: 32, + PAGE_UP: 33, + PAGE_DOWN: 34, + END: 35, + HOME: 36, + LEFT: 37, + UP: 38, + RIGHT: 39, + DOWN: 40, + DELETE: 46, + + isArrow: function (k) { + k = k.which ? k.which : k; + + switch (k) { + case KEY.LEFT: + case KEY.RIGHT: + case KEY.UP: + case KEY.DOWN: + return true; + } + + return false; + } + }; + + return KEYS; +}); + define('select2/core',[ 'jquery', './options', - './utils' -], function ($, Options, Utils) { + './utils', + './keys' +], function ($, Options, Utils, KEYS) { var Select2 = function ($element, options) { this.$element = $element; @@ -11235,6 +11227,7 @@ define('select2/core',[ // Register any internal event handlers this._registerSelectionEvents(); + this._registerDropdownEvents(); this._registerResultsEvents(); this._registerEvents(); @@ -11246,8 +11239,6 @@ define('select2/core',[ }); }); - this.trigger('query', {}); - // Hide the original select $element.hide(); @@ -11344,6 +11335,22 @@ define('select2/core',[ self.close(); }); + + this.selection.on('keypress', function (e) { + self.trigger('keypress', e); + }); + }; + + Select2.prototype._registerDropdownEvents = function () { + var self = this; + + this.dropdown.on('query', function (params) { + self.trigger('query', params); + }); + + this.dropdown.on('keypress', function (e) { + self.trigger('keypress', e); + }); }; Select2.prototype._registerResultsEvents = function () { @@ -11385,6 +11392,32 @@ define('select2/core',[ }); }); }); + + this.on('keypress', function (evt) { + var key = evt.which; + + if (self.isOpen()) { + if (key == KEYS.ENTER) { + self.trigger('results:select'); + + evt.preventDefault(); + } else if (key == KEYS.UP) { + self.trigger('results:previous'); + + evt.preventDefault(); + } else if (key == KEYS.DOWN) { + self.trigger('results:next'); + + evt.preventDefault(); + } + } else { + if (key == KEYS.ENTER || key == KEYS.SPACE) { + self.trigger('open'); + + evt.preventDefault(); + } + } + }); }; Select2.prototype.toggleDropdown = function () { @@ -11400,6 +11433,8 @@ define('select2/core',[ return; } + this.trigger('query', {}); + this.trigger('open'); }; diff --git a/dist/js/select2.full.min.js b/dist/js/select2.full.min.js index e714dbdc..a1768009 100644 --- a/dist/js/select2.full.min.js +++ b/dist/js/select2.full.min.js @@ -1,4 +1,4 @@ window.$=window.$||{},function(){$&&$.fn&&$.fn.select2&&$.fn.select2.amd&&(c=$.fn.select2.amd.define,b=$.fn.select2.amd.require);var a,b,c;!function(d){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(n=n.slice(0,n.length-1),a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.concat(a),k=0;k0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,b){return function(){return n.apply(d,v.call(arguments,0).concat([a,b]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var b=r[a];delete r[a],t[a]=!0,m.apply(d,b)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,b,c,f){var h,k,l,m,n,s,u=[],v=typeof c;if(f=f||a,"undefined"===v||"function"===v){for(b=!b.length&&c.length?["require","exports","module"]:b,n=0;n0&&b-1 in a}function e(a,b,c){if(bb.isFunction(b))return bb.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return bb.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(ib.test(b))return bb.filter(b,a,c);b=bb.filter(b,a)}return bb.grep(a,function(a){return V.call(b,a)>=0!==c})}function f(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}function g(a){var b=pb[a]={};return bb.each(a.match(ob)||[],function(a,c){b[c]=!0}),b}function h(){_.removeEventListener("DOMContentLoaded",h,!1),a.removeEventListener("load",h,!1),bb.ready()}function i(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=bb.expando+Math.random()}function j(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(vb,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:ub.test(c)?bb.parseJSON(c):c}catch(e){}tb.set(a,b,c)}else c=void 0;return c}function k(){return!0}function l(){return!1}function m(){try{return _.activeElement}catch(a){}}function n(a,b){return bb.nodeName(a,"table")&&bb.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function o(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function p(a){var b=Lb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function q(a,b){for(var c=0,d=a.length;d>c;c++)sb.set(a[c],"globalEval",!b||sb.get(b[c],"globalEval"))}function r(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(sb.hasData(a)&&(f=sb.access(a),g=sb.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)bb.event.add(b,e,j[e][c])}tb.hasData(a)&&(h=tb.access(a),i=bb.extend({},h),tb.set(b,i))}}function s(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&bb.nodeName(a,b)?bb.merge([a],c):c}function t(a,b){var c=b.nodeName.toLowerCase();"input"===c&&zb.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}function u(b,c){var d=bb(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:bb.css(d[0],"display");return d.detach(),e}function v(a){var b=_,c=Pb[a];return c||(c=u(a,b),"none"!==c&&c||(Ob=(Ob||bb("