1 2// /** 3// * @preserve jQuery Autocomplete plugin v1.2.6 4// * @homepage http://xdsoft.net/jqplugins/autocomplete/ 5// * @license MIT - MIT-LICENSE.txt 6// * (c) 2014, Chupurnov Valeriy <[email protected]> 7// */ 8// (function ($) { 9// 'use strict'; 10// var ARROWLEFT = 37, 11// ARROWRIGHT = 39, 12// ARROWUP = 38, 13// ARROWDOWN = 40, 14// TAB = 9, 15// CTRLKEY = 17, 16// SHIFTKEY = 16, 17// DEL = 46, 18// ENTER = 13, 19// ESC = 27, 20// BACKSPACE = 8, 21// AKEY = 65, 22// CKEY = 67, 23// VKEY = 86, 24// ZKEY = 90, 25// YKEY = 89, 26// defaultSetting = {}, 27// //currentInput = false, 28// ctrlDown = false, 29// shiftDown = false, 30// publics = {}, 31// accent_map = { 32// 'áº':'a','Ã':'a','á':'a','Ã':'a','à ':'a','Ä':'a','Ä':'a','Ắ':'a','ắ':'a','Ằ':'a','ằ':'a','Ẵ':'a','ẵ':'a','Ẳ':'a', 33// 'Ẫ':'a','ẫ':'a','Ẩ':'a','ẩ':'a','Ç':'a','Ç':'a','à ':'a','Ã¥':'a','Ǻ':'a','Ç»':'a','Ã':'a','ä':'a','Ç':'a','Ç':'a', 34// 'Ã':'a','ã':'a','Ȧ':'a','ȧ':'a','Ç ':'a','Ç¡':'a','Ä':'a','Ä ':'a','Ä':'a','Ä':'a','Ả':'a','ả':'a','È':'a','È':'a', 35// 'È':'a','È':'a','Ạ':'a','ạ':'a','Ặ':'a','ặ':'a','Ậ':'a','áº':'a','á¸':'a','á¸':'a','Ⱥ':'a','â±¥':'a','Ǽ':'a','ǽ':'a', 36// 'Ç¢':'a','Ç£':'a','á¸':'b','á¸':'b','á¸':'b','Ḡ':'b','á¸':'b','á¸':'b','É':'b','Æ':'b','ᵬ':'b','Æ':'b','É':'b','Æ':'b', 37// 'Æ':'b','Ä':'c','Ä':'c','Ä':'c','Ä':'c','Ä':'c','Ä':'c','Ä':'c','Ä':'c','Ã':'c','ç':'c','á¸':'c','á¸':'c','È»':'c', 38// 'ȼ':'c','Æ':'c','Æ':'c','É':'c','Ä':'d','Ä':'d','á¸':'d','á¸':'d','á¸':'d','á¸':'d','á¸':'d','á¸':'d','á¸':'d','á¸':'d', 39// 'á¸':'d','á¸':'d','Ä':'d','Ä':'d','áµ':'d','Æ':'d','É':'d','Æ':'d','É':'d','Æ':'d','Æ':'d','È¡':'d','ð':'d','Ã':'e', 40// 'Æ':'e','Æ':'e','Ç':'e','é':'e','Ã':'e','è':'e','Ä':'e','Ä':'e','Ã':'e','ê':'e','Ế':'e','ế':'e','á»':'e','á»':'e', 41// 'á»':'e','á» ':'e','á»':'e','á»':'e','Ä':'e','Ä':'e','Ã':'e','ë':'e','Ẽ':'e','ẽ':'e','Ä':'e','Ä':'e','Ȩ':'e','È©':'e', 42// 'á¸':'e','á¸':'e','Ä':'e','Ä':'e','Ä':'e','Ä':'e','á¸':'e','á¸':'e','á¸':'e','á¸':'e','Ẻ':'e','ẻ':'e','È':'e','È ':'e', 43// 'È':'e','È':'e','Ẹ':'e','ẹ':'e','á»':'e','á»':'e','á¸':'e','á¸':'e','á¸':'e','á¸':'e','É':'e','É':'e','É':'e','É':'e', 44// 'á¸':'f','á¸':'f','áµ®':'f','Æ':'f','Æ':'f','Ç´':'g','ǵ':'g','Ä':'g','Ä':'g','Ä':'g','Ä':'g','Ǧ':'g','ǧ':'g','Ä ':'g', 45// 'Ä¡':'g','Ä¢':'g','Ä£':'g','Ḡ':'g','ḡ':'g','Ǥ':'g','Ç¥':'g','Æ':'g','É ':'g','Ĥ':'h','Ä¥':'h','È':'h','È':'h','Ḧ':'h', 46// 'ḧ':'h','Ḣ':'h','ḣ':'h','Ḩ':'h','ḩ':'h','Ḥ':'h','ḥ':'h','Ḫ':'h','ḫ':'h','H':'h','̱':'h','áº':'h','Ħ':'h','ħ':'h', 47// 'â±§':'h','ⱨ':'h','Ã':'i','Ã':'i','Ã':'i','ì':'i','Ĭ':'i','Ä':'i','Ã':'i','î':'i','Ç':'i','Ç':'i','Ã':'i','ï':'i', 48// 'Ḯ':'i','ḯ':'i','Ĩ':'i','Ä©':'i','İ':'i','i':'i','Ä®':'i','į':'i','Ī':'i','Ä«':'i','á»':'i','á»':'i','È':'i','È':'i', 49// 'È':'i','È':'i','á»':'i','á»':'i','Ḭ':'i','á¸':'i','I':'i','ı':'i','Æ':'i','ɨ':'i','Ä´':'j','ĵ':'j','J':'j','Ì':'j', 50// 'ǰ':'j','È·':'j','É':'j','É':'j','Ê':'j','É':'j','Ê':'j','Ḱ':'k','ḱ':'k','Ǩ':'k','Ç©':'k','Ķ':'k','Ä·':'k','Ḳ':'k', 51// 'ḳ':'k','Ḵ':'k','ḵ':'k','Æ':'k','Æ':'k','Ⱪ':'k','ⱪ':'k','Ĺ':'a','ĺ':'l','Ľ':'l','ľ':'l','Ä»':'l','ļ':'l','Ḷ':'l', 52// 'ḷ':'l','Ḹ':'l','ḹ':'l','Ḽ':'l','ḽ':'l','Ḻ':'l','ḻ':'l','Å':'l','Å':'l','Ì£':'l','Ä¿':'l', 53// 'Å':'l','Ƚ':'l','Æ':'l','â± ':'l','ⱡ':'l','â±¢':'l','É«':'l','ɬ':'l','É':'l','È´':'l','Ḿ':'m','ḿ':'m','á¹':'m','á¹':'m', 54// 'á¹':'m','á¹':'m','ɱ':'m','Å':'n','Å':'n','Ǹ':'n','ǹ':'n','Å':'n','Å':'n','Ã':'n','ñ':'n','á¹':'n','á¹ ':'n','Å ':'n', 55// 'Å':'n','á¹':'n','á¹':'n','á¹':'n','á¹':'n','á¹':'n','á¹':'n','Æ':'n','ɲ':'n','È ':'n','Æ':'n','ɳ':'n','ȵ':'n','N':'n', 56// 'Ì':'n','n':'n','Ã':'o','ó':'o','Ã':'o','ò':'o','Å':'o','Å':'o','Ã':'o','ô':'o','á»':'o','á»':'o','á»':'o', 57// 'á»':'o','á»':'o','á»':'o','á»':'o','á»':'o','Ç':'o','Ç':'o','Ã':'o','ö':'o','Ȫ':'o','È«':'o','Å':'o','Å':'o','Ã':'o', 58// 'õ':'o','á¹':'o','á¹':'o','á¹':'o','á¹':'o','Ȭ':'o','È':'o','È®':'o','ȯ':'o','Ȱ':'o','ȱ':'o','Ã':'o','ø':'o','Ǿ':'o', 59// 'Ç¿':'o','Ǫ':'o','Ç«':'o','Ǭ':'o','Ç':'o','Å':'o','Å':'o','á¹':'o','á¹':'o','á¹':'o','á¹':'o','á»':'o','á»':'o','È':'o', 60// 'È':'o','È':'o','È':'o','Æ ':'o','Æ¡':'o','á»':'o','á»':'o','á»':'o','á»':'o','á» ':'o','ỡ':'o','á»':'o','á»':'o','Ợ':'o', 61// 'ợ':'o','á»':'o','á»':'o','á»':'o','á»':'o','Æ':'o','ɵ':'o','á¹':'p','á¹':'p','á¹':'p','á¹':'p','â±£':'p','Ƥ':'p','Æ¥':'p', 62// 'P':'p','Ì':'p','p':'p','Ê ':'q','É':'q','É':'q','Å':'r','Å':'r','Å':'r','Å':'r','á¹':'r','á¹':'r','Å':'r', 63// 'Å':'r','È':'r','È':'r','È':'r','È':'r','á¹':'r','á¹':'r','á¹':'r','á¹':'r','á¹':'r','á¹':'r','É':'r','É':'r','áµ²':'r', 64// 'ɼ':'r','Ɽ':'r','ɽ':'r','ɾ':'r','áµ³':'r','Ã':'s','Å':'s','Å':'s','Ṥ':'s','á¹¥':'s','Å':'s','Å':'s','Å ':'s','Å¡':'s', 65// 'Ṧ':'s','á¹§':'s','á¹ ':'s','ṡ':'s','áº':'s','Å':'s','Å':'s','á¹¢':'s','á¹£':'s','Ṩ':'s','ṩ':'s','È':'s','È':'s','Ê':'s', 66// 'S':'s','Ì©':'s','s':'s','Ã':'t','þ':'t','Ť':'t','Å¥':'t','T':'t','áº':'t','Ṫ':'t','ṫ':'t','Å¢':'t','Å£':'t','Ṭ':'t', 67// 'á¹':'t','È':'t','È':'t','á¹°':'t','á¹±':'t','á¹®':'t','ṯ':'t','Ŧ':'t','ŧ':'t','Ⱦ':'t','ⱦ':'t','áµµ':'t', 68// 'Æ«':'t','Ƭ':'t','Æ':'t','Æ®':'t','Ê':'t','ȶ':'t','Ã':'u','ú':'u','Ã':'u','ù':'u','Ŭ':'u','Å':'u','Ã':'u','û':'u', 69// 'Ç':'u','Ç':'u','Å®':'u','ů':'u','Ã':'u','ü':'u','Ç':'u','Ç':'u','Ç'
69:'u','Ç':'u','Ç':'u','Ç':'u','Ç':'u','Ç':'u', 70// 'Ű':'u','ű':'u','Ũ':'u','Å©':'u','Ṹ':'u','á¹¹':'u','Ų':'u','ų':'u','Ū':'u','Å«':'u','Ṻ':'u','á¹»':'u','Ủ':'u','á»§':'u', 71// 'È':'u','È':'u','È':'u','È':'u','Ư':'u','ư':'u','Ứ':'u','ứ':'u','Ừ':'u','ừ':'u','á»®':'u','ữ':'u','Ử':'u','á»':'u', 72// 'á»°':'u','á»±':'u','Ụ':'u','ụ':'u','á¹²':'u','á¹³':'u','á¹¶':'u','á¹·':'u','á¹´':'u','á¹µ':'u','É':'u','Ê':'u','á¹¼':'v','á¹½':'v', 73// 'á¹¾':'v','ṿ':'v','Ʋ':'v','Ê':'v','áº':'w','áº':'w','áº':'w','áº':'w','Å´':'w','ŵ':'w','W':'w','Ì':'w','áº':'w','áº':'w', 74// 'Ạ':'w','áº':'w','áº':'w','áº':'w','áº':'w','áº':'x','áº':'x','áº':'x','áº':'x','Ã':'y','ý':'y','Ỳ':'y','ỳ':'y','Ŷ':'y', 75// 'Å·':'y','Y':'y','áº':'y','Ÿ':'y','ÿ':'y','Ỹ':'y','ỹ':'y','áº':'y','áº':'y','Ȳ':'y','ȳ':'y','á»¶':'y','á»·':'y', 76// 'á»´':'y','ỵ':'y','Ê':'y','É':'y','É':'y','Ƴ':'y','Æ´':'y','Ź':'z','ź':'z','áº':'z','áº':'z','Ž':'z','ž':'z','Å»':'z', 77// 'ż':'z','áº':'z','áº':'z','áº':'z','áº':'z','Ƶ':'z','ƶ':'z','Ȥ':'z','È¥':'z','Ê':'z','Ê':'z','Ⱬ':'z','ⱬ':'z','Ç®':'z', 78// 'ǯ':'z','ƺ':'z','ï¼':'2','ï¼':'6','ï¼¢':'B','F':'F','J':'J','ï¼®':'N','ï¼²':'R','ï¼¶':'V','Z':'Z','ï½':'b','ï½':'f','ï½':'j', 79// 'ï½':'n','ï½':'r','ï½':'v','ï½':'z','ï¼':'1','ï¼':'5','ï¼':'9','A':'A','ï¼¥':'E','I':'I','ï¼':'M','ï¼±':'Q','ï¼µ':'U','ï¼¹':'Y', 80// 'ï½':'a','ï½ ':'e','ï½':'i','ï½':'m','ï½':'q','ï½':'u','ï½':'y','ï¼':'0','ï¼':'4','ï¼':'8','D':'D','H':'H','L':'L','ï¼°':'P', 81// 'ï¼´':'T','X':'X','ï½':'d','ï½':'h','ï½':'l','ï½':'p','ï½':'t','ï½':'x','ï¼':'3','ï¼':'7','ï¼£':'C','ï¼§':'G','K':'K','O':'O', 82// 'ï¼³':'S','ï¼·':'W','ï½':'c','ï½':'g','ï½':'k','ï½':'o','ï½':'s','ï½':'w','ẳ':'a','Ã':'a','â':'a','Ấ':'a','ấ':'a','Ầ':'a','ầ':'a' 83// }; 84 85// if (window.getComputedStyle === undefined) { 86// window.getComputedStyle = (function () { 87// function getPixelSize(element, style, property, fontSize) { 88// var sizeWithSuffix = style[property], 89// size = parseFloat(sizeWithSuffix), 90// suffix = sizeWithSuffix.split(/\d/)[0], 91// rootSize; 92 93// fontSize = fontSize !== null ? fontSize : /%|em/.test(suffix) && element.parentElement ? getPixelSize(element.parentElement, element.parentElement.currentStyle, 'fontSize', null) : 16; 94// rootSize = property === 'fontSize' ? fontSize : /width/i.test(property) ? element.clientWidth : element.clientHeight; 95 96// return (suffix === 'em') ? size * fontSize : (suffix === 'in') ? size * 96 : (suffix === 'pt') ? size * 96 / 72 : (suffix === '%') ? size / 100 * rootSize : size; 97// } 98 99// function setShortStyleProperty(style, property) { 100// var borderSuffix = property === 'border' ? 'Width' : '', 101// t = property + 'Top' + borderSuffix, 102// r = property + 'Right' + borderSuffix, 103// b = property + 'Bottom' + borderSuffix, 104// l = property + 'Left' + borderSuffix; 105 106// style[property] = (style[t] === style[r] === style[b] === style[l] ? [style[t]] 107// : style[t] === style[b] && style[l] === style[r] ? [style[t], style[r]] 108// : style[l] === style[r] ? [style[t], style[r], style[b]] 109// : [style[t], style[r], style[b], style[l]]).join(' '); 110// } 111 112// function CSSStyleDeclaration(element) { 113// var currentStyle = element.currentStyle, 114// style = this, 115// property, 116// fontSize = getPixelSize(element, currentStyle, 'fontSize', null); 117 118// for (property in currentStyle) { 119// if (Object.prototype.hasOwnProperty.call(currentStyle, property)) { 120// if (/width|height|margin.|padding.|border.+W/.test(property) && style[property] !== 'auto') { 121// style[property] = getPixelSize(element, currentStyle, property, fontSize) + 'px'; 122// } else if (property === 'styleFloat') { 123// style.float = currentStyle[property]; 124// } else { 125// style[property] = currentStyle[property]; 126// } 127// } 128// } 129 130// setShortStyleProperty(style, 'margin'); 131// setShortStyleProperty(style, 'padding'); 132// setShortStyleProperty(style, 'border'); 133 134// style.fontSize = fontSize + 'px'; 135 136// return style; 137// } 138 139// CSSStyleDeclaration.prototype = { 140// constructor: CSSStyleDeclaration, 141// getPropertyPriority: function () {}, 142// getPropertyValue: function (prop) { 143// return this[prop] || ''; 144// }, 145// item: function () {}, 146// removeProperty: function () {}, 147// setProperty: function () {}, 148// getPropertyCSSValue: function () {} 149// }; 150 151// function getComputedStyle(element) { 152// return new CSSStyleDeclaration(element); 153// } 154 155// return getComputedStyle; 156// }(this)); 157// } 158 159 160// $(document) 161// .on('keydown.xdsoftctrl', function (e) { 162// if (e.keyCode === CTRLKEY) { 163// ctrlDown = true; 164// } 165// if (e.keyCode === SHIFTKEY) { 166// ctrlDown = true; 167// } 168// }) 169// .on('keyup.xdsoftctrl', function (e) { 170// if (e.keyCode === CTRLKEY) { 171// ctrlDown = false;
172// } 173// if (e.keyCode === SHIFTKEY) { 174// ctrlDown = false; 175// } 176// }); 177 178// function accentReplace (s) { 179// if (!s) { return ''; } 180// var ret = '',i; 181// for (i=0; i < s.length; i+=1) { 182// ret += accent_map[s.charAt(i)] || s.charAt(i); 183// } 184// return ret; 185// } 186 187// function escapeRegExp (str) { 188// return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 189// } 190 191// function getCaretPosition(input) { 192// if (!input) { 193// return; 194// } 195// if (input.selectionStart) { 196// return input.selectionStart; 197// } 198// if (document.selection) { 199// input.focus(); 200// var sel = document.selection.createRange(), 201// selLen = document.selection.createRange().text.length; 202// sel.moveStart('character', -input.value.length); 203// return sel.text.length - selLen; 204// } 205// } 206 207// function setCaretPosition(input, pos) { 208// if (input.setSelectionRange) { 209// input.focus(); 210// input.setSelectionRange(pos, pos); 211// } else if (input.createTextRange) { 212// var range = input.createTextRange(); 213// range.collapse(true); 214// range.moveEnd('character', pos); 215// range.moveStart('character', pos); 216// range.select(); 217// } 218// } 219 220// function isset(value) { 221// return value !== undefined; 222// } 223 224// function safe_call(callback, args, callback2, defaultValue) { 225// if (isset(callback) && !$.isArray(callback)) { 226// return $.isFunction(callback) ? callback.apply(this,args):defaultValue; 227// } 228// if(isset(callback2)) { 229// return safe_call.call(this,callback2,args); 230// } 231// return defaultValue; 232// }; 233 234// function __safe( callbackName,source,args,defaultValue ){ 235// var undefinedVar; 236// return safe_call.call( this, (isset(this.source[source])&& 237// Object.prototype.hasOwnProperty.call(this.source[source], callbackName)) ? this.source[source][callbackName] : undefinedVar, args, function(){ 238// return safe_call.call(this, 239// isset(this[callbackName][source])? 240// this[callbackName][source]:( 241// isset(this[callbackName][0])? 242// this[callbackName][0]:( 243// Object.prototype.hasOwnProperty.call(this, callbackName)? 244// this[callbackName]: 245// undefinedVar 246// ) 247// ), 248// args, 249// defaultSetting[callbackName][source]||defaultSetting[callbackName][0]||defaultSetting[callbackName], 250// defaultValue 251// ); 252// },defaultValue); 253// }; 254 255// function __get( property,source ){ 256// if(!isset(source)) 257// source = 0; 258 259// if( $.isArray(this.source) && isset(this.source[source]) && isset(this.source[source][property])) 260// return this.source[source][property]; 261 262// if( isset(this[property]) ){ 263// if( $.isArray(this[property]) ){ 264// if( isset(this[property][source]) ) 265// return this[property][source]; 266// if( isset(this[property][0]) ) 267// return this[property][0]; 268// return null; 269// } 270// return this[property]; 271// } 272 273// return null; 274// }; 275 276// function loadRemote( url,sourceObject,done,debug ){ 277// if (sourceObject.xhr) { 278// sourceObject.xhr.abort(); 279// } 280// sourceObject.xhr = $.ajax($.extend(true,{ 281// url : url, 282// type : 'GET' , 283// async:true, 284// cache :false, 285// dataType : 'json' 286// },sourceObject.ajax)) 287 288// .done(function( data ){ 289// done&&done.apply(this,$.makeArray(arguments)); 290// }) 291 292// .fail(function( jqXHR, textStatus ){ 293// if( debug ) 294// console.log("Request failed: " + textStatus); 295// }); 296// } 297 298 299// function findRight( data,query ){ 300// var right = false,source; 301 302// for (source = 0;source < data.length;source += 1) { 303// if( right = __safe.call(this,"findRight",source,[data[source],query,source]) ){ 304// return {right:right,source:source}; 305// } 306// } 307 308// return false; 309// } 310 311// function processData( data,query ){ 312// var source; 313// preparseData 314// .call( this,data,query ); 315 316// for (source = 0;source < data.length;source += 1) { 317// data[source] = __safe.call(this, 318// 'filter', 319// source, 320// [data[source], query, source], 321// data[source] 322// ); 323// } 324// }; 325 326 327// function collectData( query,datasource,callback ){ 328// var options = this,source; 329 330// if( $.isFunction(options.source) ){ 331// options.source.apply(options,[query,function(items){ 332// datasource = [items]; 333// safe_call.call(options,callback,[query]); 334// },datasource,0]); 335// }else{ 336// for (source = 0;source < options.source.length;source += 1) { 337// if ($.isArray(options.source[source])) { 338// datasource[source] = options.source[source]; 339// } else if ($.isFunction(options.source[source])) { 340// (function (source) { 341// options.source[source].apply(options,[query, function(items){ 342// if (!datasource[source]) { 343// datasource[source] = []; 344// } 345 346// if (items && $.isArray(items)) { 347// switch (options.appendMethod) { 348// case 'replace': 349// datasource[source] = items; 350// break; 351// default: 352// datasource[source] = datasource[source].concat(items); 353// } 354// } 355 356// safe_call.call(options,callback,[query]); 357// }, datasource,source]); 358// }(source)); 359// } else { 360// switch (options.source[source].type) { 361// case 'remote': 362// if (isset(options.source[source].url)) { 363// if (!isset(options.source[source].minLength) || query.length >= options.source[source].minLength){ 364// var url = __safe.call(options,'replace',source,[options.source[source].url,query],''); 365// if (!datasource[source]) { 366// datasource[source] = []; 367// } 368// (function (source) { 369// loadRemote(url,options.source[source], function(resp){ 370// datasource[source] = resp; 371// safe_call.call(options,callback,[query]); 372// },options.debug); 373// }(source)); 374// } 375// } 376// break; 377// default: 378// if( isset(options.source[source]['data']) ){ 379// datasource[source] = options.source[source]['data']; 380// }else{ 381// datasource[source] = options.source[source]; 382// } 383// } 384// } 385// } 386// } 387// safe_call.call(options,callback,[query]); 388// }; 389 390// function preparseData( data,query ){ 391// for( var source=0;source<data.length;source++ ){ 392// data[source] = __safe.call(this, 393// 'preparse', 394// source, 395// [data[source],query], 396// data[source] 397// ); 398// } 399// }; 400 401// function renderData( data,query ){ 402// var source, i, $div, $divs = []; 403 404// for (source = 0;source < data.length;source += 1) { 405// for (i = 0;i < data[source].length;i += 1) { 406// if( $divs.length>=this.limit ) 407// break; 408 409// $div = $(__safe.call(this, 410// 'render',source, 411// [data[source][i],source,i,query], 412// '' 413// )); 414 415// $div.data('source',source); 416// $div.data('pid',i); 417// $div.data('item',data[source][i]); 418 419// $divs.push($div); 420// } 421// } 422 423// return $divs; 424// }; 425 426// function getItem( $div,dataset ){ 427// if( isset($div.data('source')) && 428// isset($div.data('pid')) && 429// isset(dataset[$div.data('source')]) && 430// isset(dataset[$div.data('source')][$div.data('pid')]) 431// ){ 432// return dataset[$div.data('source')][$div.data('pid')]; 433// } 434// return false;
435// }; 436 437// function getValue( $div,dataset ){ 438// var item = getItem($div,dataset); 439 440// if( item ){ 441// return __safe.call(this, 442// 'getValue',$div.data('source'), 443// [item,$div.data('source')] 444// ); 445// }else{ 446// if( isset($div.data('value')) ){ 447// return decodeURIComponent($div.data('value')); 448// }else{ 449// return $div.html(); 450// } 451// } 452// }; 453 454// defaultSetting = { 455// minLength: 0, 456// valueKey: 'value', 457// titleKey: 'title', 458// highlight: true, 459 460// showHint: true, 461 462// dropdownWidth: '100%', 463// dropdownStyle: {}, 464// itemStyle: {}, 465// hintStyle: false, 466// style: false, 467 468// debug: true, 469// openOnFocus: false, 470// closeOnBlur: true, 471 472// autoselect: false, 473 474// accents: true, 475// replaceAccentsForRemote: true, 476 477// limit: 20, 478// visibleLimit: 20, 479// visibleHeight: 0, 480// defaultHeightItem: 30, 481 482// timeoutUpdate: 10, 483 484// get: function (property, source) { 485// return __get.call(this,property,source); 486// }, 487 488// replace: [ 489// function (url, query) { 490// if (this.replaceAccentsForRemote) { 491// query = accentReplace(query); 492// } 493// return url.replace('%QUERY%',encodeURIComponent(query)); 494// } 495// ], 496 497// equal:function( value,query ){ 498// return query.toLowerCase()==value.substr(0,query.length).toLowerCase(); 499// }, 500 501// findRight:[ 502// function(items,query,source){ 503// var results = [],value = '',i; 504// if (items) { 505// for (i = 0;i < items.length;i += 1) { 506// value = __safe.call(this,'getValue',source,[items[i],source]); 507// if (__safe.call(this, 'equal', source, [value,query,source], false)) { 508// return items[i]; 509// } 510// } 511// } 512// return false; 513// } 514// ], 515 516// valid:[ 517// function (value, query) { 518// if (this.accents) { 519// value = accentReplace(value); 520// query = accentReplace(query); 521// } 522// return value.toLowerCase().indexOf(query.toLowerCase())!=-1; 523 524// } 525// ], 526 527// filter:[ 528// function (items, query, source) { 529// var results = [], value = '',i; 530// if (items) { 531// for (i = 0;i < items.length;i += 1) { 532// value = isset(items[i][this.get('valueKey', source)]) ? items[i][this.get('valueKey', source)] : items[i].toString(); 533// if (__safe.call(this, 'valid', source, [value, query])) { 534// results.push(items[i]); 535// } 536// } 537// } 538// return results; 539// } 540// ], 541 542// preparse:function(items){ 543// return items; 544// }, 545 546// getValue: [ 547// function (item, source) { 548// return isset(item[this.get('valueKey',source)])?item[this.get('valueKey',source)]:item.toString(); 549// } 550// ], 551 552// getTitle: [ 553// function (item, source) { 554// return isset(item[this.get('titleKey',source)])?item[this.get('titleKey',source)]:item.toString(); 555// } 556// ], 557 558// render: [ 559// function (item, source, pid, query) { 560// var value = __safe.call(this, "getValue", source, [item, source], defaultSetting.getValue[0].call(this, item, source)), 561// title = __safe.call(this, "getTitle", source, [item, source], defaultSetting.getTitle[0].call(this, item, source)), 562// _value = '', 563// _query = '', 564// _title = '', 565// hilite_hints = '', 566// highlighted = '', 567// c, h, i, 568// spos = 0; 569 570// if (this.highlight) { 571// if (!this.accents) { 572// title = title.replace(new RegExp('('+escapeRegExp(query)+')','i'),'<b>$1</b>'); 573// }else{ 574// _title = accentReplace(title).toLowerCase().replace(/[<>]+/g, ''), 575// _query = accentReplace(query).toLowerCase().replace(/[<>]+/g, ''); 576 577// hilite_hints = _title.replace(new RegExp(escapeRegExp(_query), 'g'), '<'+_query+'>'); 578// for (i=0;i < hilite_hints.length;i += 1) { 579// c = title.charAt(spos); 580// h = hilite_hints.charAt(i); 581// if (h === '<') { 582// highlighted += '<b>'; 583// } else if (h === '>') { 584// highlighted += '</b>'; 585// } else { 586// spos += 1; 587// highlighted += c; 588// } 589// } 590// title = highlighted; 591// } 592// } 593 594// return '<div '+(value==query?'class="active"':'')+' data-value="'+encodeURIComponent(value)+'">' 595// +title+ 596// '</div>'; 597// } 598// ], 599// appendMethod: 'concat', // supported merge and replace 600// source:[], 601// afterSelected: function() { 602// } 603// }; 604// function init( that,options ){ 605// if( $(that).hasClass('xdsoft_input') ) 606// return; 607 608// var $box = $('<div class="xdsoft_autocomplete"></div>'), 609// $dropdown = $('<div class="xdsoft_autocomplete_dropdown"></div>'), 610// $hint = $('<input readonly class="xdsoft_autocomplete_hint"/>'),
611// $input = $(that), 612// timer1 = 0, 613// intervalForVisibility, 614// dataset = [], 615// iOpen = false, 616// value = '', 617// currentValue = '', 618// currentSelect = '', 619// active = null, 620// pos = 0; 621 622// //it can be used to access settings 623// $input.data('autocomplete_options', options); 624 625// $dropdown 626// .on('mousedown', function(e) { 627// e.preventDefault(); 628// e.stopPropagation(); 629// }) 630// .on('updatescroll.xdsoft', function() { 631// var _act = $dropdown.find('.active'); 632// if (!_act.length) { 633// return; 634// } 635 636// var top = _act.position().top, 637// actHght = _act.outerHeight(true), 638// scrlTop = $dropdown.scrollTop(), 639// hght = $dropdown.height(); 640 641// if (top <0) { 642// $dropdown.scrollTop(scrlTop-Math.abs(top)); 643// } else if (top+actHght>hght) { 644// $dropdown.scrollTop(scrlTop+top+actHght-hght); 645// } 646// }); 647 648// $box 649// .css({ 650// 'display':$input.css('display'), 651// 'width':$input.css('width') 652// }); 653 654// if( options.style ) 655// $box.css(options.style); 656 657// $input 658// .addClass('xdsoft_input') 659// .attr('autocomplete','off'); 660 661// var xDown = null; 662// var yDown = null; 663// var isSwipe = false; 664// $dropdown 665// .on('mousemove','div',function(){ 666// if( $(this).hasClass('active') ) 667// return true; 668// $dropdown.find('div').removeClass('active'); 669// $(this).addClass('active'); 670// }) 671// .on('mousedown','div',function(e){ 672// $dropdown.find('div').removeClass('active'); 673// $(this).addClass('active'); 674// $input.trigger('pick.xdsoft'); 675// }) 676// .on('touchstart','div',function(e){ 677// xDown = e.originalEvent.touches[0].clientX; 678// yDown = e.originalEvent.touches[0].clientY; 679// }) 680// .on('touchend','div',function(e){ 681// if(isSwipe === false) { 682// $dropdown.find('div').removeClass('active'); 683// $(this).addClass('active'); 684// $input.trigger('pick.xdsoft'); 685// } 686 687// isSwipe = false; 688// }) 689// .on('touchmove','div',function(e){ 690// if ( ! xDown || ! yDown ) { 691// return; 692// } 693 694// var xUp = e.originalEvent.touches[0].clientX; 695// var yUp = e.originalEvent.touches[0].clientY; 696 697// var xDiff = xDown - xUp; 698// var yDiff = yDown - yUp; 699 700// if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) { 701// if ( xDiff > 0 ) { 702// isSwipe = 'left'; 703// } else { 704// isSwipe = 'right'; 705// } 706// } else { 707// if ( yDiff > 0 ) { 708// isSwipe = 'top'; 709// } else { 710// isSwipe = 'bottm'; 711// } 712// } 713 714// xDown = null; 715// yDown = null; 716// }); 717 718// function manageData(){ 719// if ($input.val()!=currentValue){ 720// currentValue = $input.val(); 721// } else { 722// return; 723// } 724// if (currentValue.length < options.minLength) { 725// $input.trigger('close.xdsoft'); 726// return; 727// } 728// collectData.call(options,currentValue,dataset,function( query ){ 729// if (query != currentValue) { 730// return; 731// } 732// var right; 733// processData.call(options, dataset,query); 734 735// $input.trigger('updateContent.xdsoft'); 736 737// if (options.showHint && currentValue.length && currentValue.length<=$input.prop('size') && (right = findRight.call(options,dataset,currentValue))) { 738// var title = __safe.call(options,'getTitle',right.source,[right.right,right.source]); 739// title = query + title.substr(query.length); 740// $hint.val(title); 741// } else { 742// $hint.val(''); 743// } 744// }); 745 746// return; 747// } 748 749// function manageKey (event) { 750// var key = event.keyCode, right; 751 752// switch( key ){ 753// case AKEY: case CKEY: case VKEY: case ZKEY: case YKEY: 754// if (event.shiftKey || event.ctrlKey) { 755// return true; 756// } 757// break; 758// case SHIFTKEY: 759// case CTRLKEY: 760// return true; 761// break; 762// case ARROWRIGHT: 763// case ARROWLEFT: 764// if (ctrlDown || shiftDown || event.shiftKey || event.ctrlKey) { 765// return true; 766// } 767// value = $input.val(); 768// pos = getCaretPosition($input[0]); 769// if (key === ARROWRIGHT && pos === value.length) { 770// if (right = findRight.call(options, dataset, value)){ 771// $input.trigger('pick.xdsoft', [ 772// __safe.call(options, 773// 'getValue', right.source, 774// [right.right, right.source] 775// ) 776// ]); 777// } else { 778// $input.trigger('pick.xdsoft'); 779// } 780// event.preventDefault(); 781// return false;
782// } 783// return true; 784// case TAB: 785// return true; 786// case ENTER: 787// if (iOpen) { 788// $input.trigger('pick.xdsoft'); 789// event.preventDefault(); 790// return false; 791// } else { 792// return true; 793// } 794// break; 795// case ESC: 796// $input 797// .val(currentValue) 798// .trigger('close.xdsoft'); 799// event.preventDefault(); 800// return false; 801// case ARROWDOWN: 802// case ARROWUP: 803// if (!iOpen) { 804// $input.trigger('open.xdsoft'); 805// $input.trigger('updateContent.xdsoft'); 806// event.preventDefault(); 807// return false; 808// } 809 810// active = $dropdown.find('div.active'); 811 812// var next = key==ARROWDOWN?'next':'prev', timepick = true; 813 814// if( active.length ){ 815// active.removeClass('active'); 816// if( active[next]().length ){ 817// active[next]().addClass('active'); 818// }else{ 819// $input.val(currentValue); 820// timepick = false; 821// } 822// }else{ 823// $dropdown.children().eq(key==ARROWDOWN?0:-1).addClass('active'); 824// } 825 826// if( timepick ){ 827// $input.trigger('timepick.xdsoft'); 828// } 829 830// $dropdown 831// .trigger('updatescroll.xdsoft'); 832 833// event.preventDefault(); 834// return false; 835// } 836// return; 837// } 838 839// $input 840// .data('xdsoft_autocomplete',dataset) 841// .after($box) 842// .on('pick.xdsoft', function( event,_value ){ 843 844// $input.trigger('timepick.xdsoft',_value); 845 846// currentSelect = currentValue = $input.val(); 847 848// $input.trigger('close.xdsoft'); 849 850// //currentInput = false; 851 852// active = $dropdown.find('div.active').eq(0); 853 854// if( !active.length ) 855// active = $dropdown.children().first(); 856 857// $input.trigger('selected.xdsoft',[getItem(active,dataset)]); 858 859// if (options.afterSelected) 860// options.afterSelected(); 861// }) 862// .on('timepick.xdsoft', function( event,_value ){ 863// active = $dropdown.find('div.active'); 864 865// if( !active.length ) 866// active = $dropdown.children().first(); 867 868// if( active.length ){ 869// if( !isset(_value) ){ 870// $input.val(getValue.call(options,active,dataset)); 871// }else{ 872// $input.val(_value); 873// } 874// $input.trigger('autocompleted.xdsoft',[getItem(active,dataset)]); 875// $hint.val(''); 876// setCaretPosition($input[0],$input.val().length); 877// } 878// }) 879// .on('keydown.xdsoft input.xdsoft cut.xdsoft paste.xdsoft', function( event ){ 880// var ret = manageKey(event); 881 882// if (ret === false || ret === true) { 883// return ret; 884// } 885 886// setTimeout(function(){ 887// manageData(); 888// },1); 889 890// manageData(); 891// }) 892// .on('change.xdsoft', function( event ){ 893// currentValue = $input.val(); 894// }); 895 896// currentValue = $input.val(); 897 898// collectData.call(options, $input.val(),dataset,function( query ){ 899// processData.call(options,dataset,query); 900// }); 901 902// if( options.openOnFocus ){ 903// $input.on('focusin.xdsoft',function(){ 904// $input.trigger('open.xdsoft'); 905// $input.trigger('updateContent.xdsoft'); 906// }); 907// } 908 909// if( options.closeOnBlur ) 910// $input.on('focusout.xdsoft',function(){ 911// $input.trigger('close.xdsoft'); 912// }); 913 914// $box 915// .append($input) 916// .append($dropdown); 917 918 919// var olderBackground = false, 920// timerUpdate = 0; 921 922// $input 923// .on('updateHelperPosition.xdsoft',function(){ 924// clearTimeout(timerUpdate); 925// timerUpdate = setTimeout(function(){ 926// $box.css({ 927// 'display':$input.css('display'), 928// 'width':$input.css('width') 929// }); 930// $dropdown.css($.extend(true,{ 931// left:$input.position().left, 932// top:$input.position().top + parseInt($input.css('marginTop'))+parseInt($input[0].offsetHeight), 933// marginLeft:$input.css('marginLeft'), 934// marginRight:$input.css('marginRight'), 935// width:options.dropdownWidth=='100%'?$input[0].offsetWidth:options.dropdownWidth 936// },options.dropdownStyle)); 937 938// if (options.showHint) { 939// var style = getComputedStyle($input[0], ""); 940 941// $hint[0].style.cssText = style.cssText; 942 943// $hint.css({ 944// 'box-sizing':style.boxSizing, 945// borderStyle:'solid', 946// borderCollapse:style.borderCollapse, 947// borderLeftWidth:style.borderLeftWidth, 948// borderRightWidth:style.borderRightWidth, 949// borderTopWidth:style.borderTopWidth, 950// borderBottomWidth:style.borderBottomWidth, 951// paddingBottom:style.paddingBottom, 952// marginBottom:style.marginBottom, 953// paddingTop:style.paddingTop, 954// marginTop:style.marginTop, 955// paddingLeft:style.paddingLeft, 956// marginLeft:style.marginLeft, 957// paddingRight:style.paddingRight, 958// marginRight:style.marginRight, 959// maxHeight:style.maxHeight, 960// minHeight:style.minHeight, 961// maxWidth:style.maxWidth, 962// minWidth:style.minWidth, 963// width:style.width, 964// letterSpacing:style.letterSpacing, 965// lineHeight:style.lineHeight, 966// outlineWidth:style.outlineWidth, 967// fontFamily:style.fontFamily, 968// fontVariant:style.fontVariant, 969// fontStyle:$input.css('fontStyle'), 970// fontSize:$input.css('fontSize'), 971// fontWeight:$input.css('fontWeight'), 972// flex:style.flex, 973// justifyContent:style.justifyContent, 974// borderRadius:style.borderRadius, 975// '-webkit-box-shadow':'none', 976// 'box-shadow':'none' 977// }); 978 979// $input.css('font-size',$input.css('fontSize'))// fix bug with em font size 980
981// $hint.innerHeight($input.innerHeight()); 982 983// $hint.css($.extend(true,{ 984// position:'absolute', 985// zIndex:'1', 986// borderColor:'transparent', 987// outlineColor:'transparent', 988// left:$input.position().left, 989// top:$input.position().top, 990// background:$input.css('background') 991// },options.hintStyle)); 992 993 994// if( olderBackground!==false ){ 995// $hint.css('background',olderBackground); 996// }else{ 997// olderBackground = $input.css('background'); 998// } 999 1000// try{ 1001// $input[0].style.setProperty('background', 'transparent', 'important'); 1002// } catch(e) { 1003// $input.css('background','transparent') 1004// } 1005 1006// $box 1007// .append($hint); 1008// } 1009// }, options.timeoutUpdate||1); 1010// }); 1011 1012// if ($input.is(':visible')) { 1013// $input 1014// .trigger('updateHelperPosition.xdsoft'); 1015// } else { 1016// intervalForVisibility = setInterval(function () { 1017// if ($input.is(':visible')) { 1018// $input 1019// .trigger('updateHelperPosition.xdsoft'); 1020// clearInterval(intervalForVisibility); 1021// } 1022// },100); 1023// } 1024 1025// $(window).on('resize',function () { 1026// $box.css({ 1027// 'width':'auto' 1028// }); 1029// $input 1030// .trigger('updateHelperPosition.xdsoft'); 1031// }) 1032 1033// $input 1034// .on('close.xdsoft',function(){ 1035// if (!iOpen) { 1036// return; 1037// } 1038 1039// $dropdown 1040// .hide(); 1041 1042// $hint 1043// .val(''); 1044 1045// if (!options.autoselect) { 1046// $input.val(currentValue); 1047// } 1048 1049// iOpen = false; 1050 1051// //currentInput = false; 1052// }) 1053 1054// .on('updateContent.xdsoft',function(){ 1055// var out = renderData.call(options,dataset,$input.val()), 1056// hght = 10; 1057 1058// if (out.length) { 1059// $input.trigger('open.xdsoft'); 1060// } else { 1061// $input.trigger('close.xdsoft'); 1062// return; 1063// } 1064 1065// $(out).each(function(){ 1066// this.css($.extend(true,{ 1067// paddingLeft:$input.css('paddingLeft'), 1068// paddingRight:$input.css('paddingRight') 1069// },options.itemStyle)); 1070// }); 1071 1072// $dropdown 1073// .html(out); 1074 1075// if (options.visibleHeight){ 1076// hght = options.visibleHeight; 1077// } else { 1078// hght = options.visibleLimit * ((out[0] ? out[0].outerHeight(true) : 0) || options.defaultHeightItem) + 5; 1079// } 1080 1081// $dropdown 1082// .css('maxHeight', hght+'px') 1083// }) 1084 1085// .on('open.xdsoft',function(){
1086// if( iOpen ) 1087// return; 1088 1089// $dropdown 1090// .show(); 1091 1092// iOpen = true; 1093 1094// //currentInput = $input; 1095// }) 1096// .on('destroy.xdsoft',function(){ 1097// $input.removeClass('xdsoft'); 1098// $box.after($input); 1099// $box.remove(); 1100// clearTimeout(timer1); 1101// clearTimeout(intervalForVisibility); 1102// //currentInput = false; 1103// $input.data('xdsoft_autocomplete',null); 1104// $input 1105// .off('.xdsoft') 1106// }); 1107// }; 1108 1109// publics = { 1110// destroy: function () { 1111// return this.trigger('destroy.xdsoft'); 1112// }, 1113// update: function () { 1114// return this.trigger('updateHelperPosition.xdsoft'); 1115// }, 1116// options: function (_options) { 1117// if (this.data('autocomplete_options') && $.isPlainObject(_options)) { 1118// this.data('autocomplete_options', $.extend(true, this.data('autocomplete_options'), _options)); 1119// } 1120// return this; 1121// }, 1122// setSource: function (_newsource, id) { 1123// if(this.data('autocomplete_options') && ($.isPlainObject(_newsource) || $.isFunction(_newsource) || $.isArray(_newsource))) { 1124// var options = this.data('autocomplete_options'), 1125// dataset = this.data('xdsoft_autocomplete'), 1126// source = options.source; 1127// if (id!==undefined && !isNaN(id)) { 1128// if ($.isPlainObject(_newsource) || $.isArray(_newsource)) { 1129// source[id] = $.extend(true,$.isArray(_newsource) ? [] : {}, _newsource); 1130// } else { 1131// source[id] = _newsource;
vendor: 2,831 bytes, lines 1132-1241
1132// } 1133// } else { 1134// if ($.isFunction(_newsource)) { 1135// this.data('autocomplete_options').source = _newsource; 1136// } else { 1137// $.extend(true, source, _newsource); 1138// } 1139// } 1140 1141// collectData.call(options, this.val(), dataset,function( query ){ 1142// processData.call(options,dataset,query); 1143// }); 1144// } 1145// return this; 1146// }, 1147// getSource: function (id) { 1148// if (this.data('autocomplete_options')) { 1149// var source = this.data('autocomplete_options').source; 1150// if (id!==undefined && !isNaN(id) &&source[id]) { 1151// return source[id]; 1152// } else { 1153// return source; 1154// } 1155// } 1156// return null; 1157// } 1158// }; 1159 1160// $.fn.autocomplete = function(_options, _second, _third){ 1161// if ($.type(_options) === 'string' && publics[_options]) { 1162// return publics[_options].call(this, _second, _third); 1163// } 1164// return this.each(function () { 1165// var options = $.extend(true, {}, defaultSetting, _options); 1166// init(this, options); 1167// }); 1168// }; 1169// }(jQuery)); 1170// ; 1171 1172 1173/*! jQuery UI - v1.13.2 - 2022-09-28 1174* http://jqueryui.com 1175* Includes: widget.js, position.js, keycode.js, unique-id.js, widgets/autocomplete.js, widgets/menu.js 1176* Copyright jQuery Foundation and other contributors; Licensed MIT */ 1177 1178( function( factory ) { 1179 "use strict"; 1180 1181 if ( typeof define === "function" && define.amd ) { 1182 1183 // AMD. Register as an anonymous module. 1184 define( [ "jquery" ], factory ); 1185 } else { 1186 1187 // Browser globals 1188 factory( jQuery ); 1189 } 1190} )( function( $ ) { 1191"use strict"; 1192 1193$.ui = $.ui || {}; 1194 1195var version = $.ui.version = "1.13.2"; 1196 1197 1198/*! 1199 * jQuery UI Widget 1.13.2 1200 * http://jqueryui.com 1201 * 1202 * Copyright jQuery Foundation and other contributors 1203 * Released under the MIT license. 1204 * http://jquery.org/license 1205 */ 1206 1207//>>label: Widget 1208//>>group: Core 1209//>>description: Provides a factory for creating stateful widgets with a common API. 1210//>>docs: http://api.jqueryui.com/jQuery.widget/ 1211//>>demos: http://jqueryui.com/widget/ 1212 1213 1214var widgetUuid = 0; 1215var widgetHasOwnProperty = Array.prototype.hasOwnProperty; 1216var widgetSlice = Array.prototype.slice; 1217 1218$.cleanData = ( function( orig ) { 1219 return function( elems ) { 1220 var events, elem, i; 1221 for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) { 1222 1223 // Only trigger remove when necessary to save time 1224 events = $._data( elem, "events" ); 1225 if ( events && events.remove ) { 1226 $( elem ).triggerHandler( "remove" ); 1227 } 1228 } 1229 orig( elems ); 1230 }; 1231} )( $.cleanData ); 1232 1233$.widget = function( name, base, prototype ) { 1234 var existingConstructor, constructor, basePrototype; 1235 1236 // ProxiedPrototype allows the provided prototype to remain unmodified 1237 // so that it can be used as a mixin for multiple widgets (#8876) 1238 var proxiedPrototype = {}; 1239 1240 var namespace = name.split( "." )[ 0 ]; 1241 name = name.split( "." )[ 1 ];
vendor: 18,823 bytes, lines 1241-1941
1241 1242 var fullName = namespace + "-" + name; 1243 1244 if ( !prototype ) { 1245 prototype = base; 1246 base = $.Widget; 1247 } 1248 1249 if ( Array.isArray( prototype ) ) { 1250 prototype = $.extend.apply( null, [ {} ].concat( prototype ) ); 1251 } 1252 1253 // Create selector for plugin 1254 $.expr.pseudos[ fullName.toLowerCase() ] = function( elem ) { 1255 return !!$.data( elem, fullName ); 1256 }; 1257 1258 $[ namespace ] = $[ namespace ] || {}; 1259 existingConstructor = $[ namespace ][ name ]; 1260 constructor = $[ namespace ][ name ] = function( options, element ) { 1261 1262 // Allow instantiation without "new" keyword 1263 if ( !this || !this._createWidget ) { 1264 return new constructor( options, element ); 1265 } 1266 1267 // Allow instantiation without initializing for simple inheritance 1268 // must use "new" keyword (the code above always passes args) 1269 if ( arguments.length ) { 1270 this._createWidget( options, element ); 1271 } 1272 }; 1273 1274 // Extend with the existing constructor to carry over any static properties 1275 $.extend( constructor, existingConstructor, { 1276 version: prototype.version, 1277 1278 // Copy the object used to create the prototype in case we need to 1279 // redefine the widget later 1280 _proto: $.extend( {}, prototype ), 1281 1282 // Track widgets that inherit from this widget in case this widget is 1283 // redefined after a widget inherits from it 1284 _childConstructors: [] 1285 } ); 1286 1287 basePrototype = new base(); 1288 1289 // We need to make the options hash a property directly on the new instance 1290 // otherwise we'll modify the options hash on the prototype that we're 1291 // inheriting from 1292 basePrototype.options = $.widget.extend( {}, basePrototype.options ); 1293 $.each( prototype, function( prop, value ) { 1294 if ( typeof value !== "function" ) { 1295 proxiedPrototype[ prop ] = value; 1296 return; 1297 } 1298 proxiedPrototype[ prop ] = ( function() { 1299 function _super() { 1300 return base.prototype[ prop ].apply( this, arguments ); 1301 } 1302 1303 function _superApply( args ) { 1304 return base.prototype[ prop ].apply( this, args ); 1305 } 1306 1307 return function() { 1308 var __super = this._super; 1309 var __superApply = this._superApply; 1310 var returnValue; 1311 1312 this._super = _super; 1313 this._superApply = _superApply; 1314 1315 returnValue = value.apply( this, arguments ); 1316 1317 this._super = __super; 1318 this._superApply = __superApply; 1319 1320 return returnValue; 1321 }; 1322 } )(); 1323 } ); 1324 constructor.prototype = $.widget.extend( basePrototype, { 1325 1326 // TODO: remove support for widgetEventPrefix 1327 // always use the name + a colon as the prefix, e.g., draggable:start 1328 // don't prefix for widgets that aren't DOM-based 1329 widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name 1330 }, proxiedPrototype, { 1331 constructor: constructor, 1332 namespace: namespace, 1333 widgetName: name, 1334 widgetFullName: fullName 1335 } ); 1336 1337 // If this widget is being redefined then we need to find all widgets that 1338 // are inheriting from it and redefine all of them so that they inherit from 1339 // the new version of this widget. We're essentially trying to replace one 1340 // level in the prototype chain. 1341 if ( existingConstructor ) { 1342 $.each( existingConstructor._childConstructors, function( i, child ) { 1343 var childPrototype = child.prototype; 1344 1345 // Redefine the child widget using the same prototype that was 1346 // originally used, but inherit from the new version of the base 1347 $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, 1348 child._proto ); 1349 } ); 1350 1351 // Remove the list of existing child constructors from the old constructor 1352 // so the old child constructors can be garbage collected 1353 delete existingConstructor._childConstructors; 1354 } else { 1355 base._childConstructors.push( constructor ); 1356 } 1357 1358 $.widget.bridge( name, constructor ); 1359 1360 return constructor; 1361}; 1362 1363$.widget.extend = function( target ) { 1364 var input = widgetSlice.call( arguments, 1 ); 1365 var inputIndex = 0; 1366 var inputLength = input.length; 1367 var key; 1368 var value; 1369 1370 for ( ; inputIndex < inputLength; inputIndex++ ) { 1371 for ( key in input[ inputIndex ] ) { 1372 value = input[ inputIndex ][ key ]; 1373 if ( widgetHasOwnProperty.call( input[ inputIndex ], key ) && value !== undefined ) { 1374 1375 // Clone objects 1376 if ( $.isPlainObject( value ) ) { 1377 target[ key ] = $.isPlainObject( target[ key ] ) ? 1378 $.widget.extend( {}, target[ key ], value ) : 1379 1380 // Don't extend strings, arrays, etc. with objects 1381 $.widget.extend( {}, value ); 1382 1383 // Copy everything else by reference 1384 } else { 1385 target[ key ] = value; 1386 } 1387 } 1388 } 1389 } 1390 return target; 1391}; 1392 1393$.widget.bridge = function( name, object ) { 1394 var fullName = object.prototype.widgetFullName || name; 1395 $.fn[ name ] = function( options ) { 1396 var isMethodCall = typeof options === "string"; 1397 var args = widgetSlice.call( arguments, 1 ); 1398 var returnValue = this; 1399 1400 if ( isMethodCall ) { 1401 1402 // If this is an empty collection, we need to have the instance method 1403 // return undefined instead of the jQuery instance 1404 if ( !this.length && options === "instance" ) { 1405 returnValue = undefined; 1406 } else { 1407 this.each( function() { 1408 var methodValue; 1409 var instance = $.data( this, fullName ); 1410 1411 if ( options === "instance" ) { 1412 returnValue = instance; 1413 return false; 1414 } 1415 1416 if ( !instance ) { 1417 return $.error( "cannot call methods on " + name + 1418 " prior to initialization; " + 1419 "attempted to call method '" + options + "'" ); 1420 } 1421 1422 if ( typeof instance[ options ] !== "function" || 1423 options.charAt( 0 ) === "_" ) { 1424 return $.error( "no such method '" + options + "' for " + name + 1425 " widget instance" ); 1426 } 1427 1428 methodValue = instance[ options ].apply( instance, args ); 1429 1430 if ( methodValue !== instance && methodValue !== undefined ) { 1431 returnValue = methodValue && methodValue.jquery ? 1432 returnValue.pushStack( methodValue.get() ) : 1433 methodValue; 1434 return false; 1435 } 1436 } ); 1437 } 1438 } else { 1439 1440 // Allow multiple hashes to be passed on init 1441 if ( args.length ) { 1442 options = $.widget.extend.apply( null, [ options ].concat( args ) ); 1443 } 1444 1445 this.each( function() { 1446 var instance = $.data( this, fullName ); 1447 if ( instance ) { 1448 instance.option( options || {} ); 1449 if ( instance._init ) { 1450 instance._init(); 1451 } 1452 } else { 1453 $.data( this, fullName, new object( options, this ) ); 1454 } 1455 } ); 1456 } 1457 1458 return returnValue; 1459 }; 1460}; 1461 1462$.Widget = function( /* options, element */ ) {}; 1463$.Widget._childConstructors = []; 1464 1465$.Widget.prototype = { 1466 widgetName: "widget", 1467 widgetEventPrefix: "", 1468 defaultElement: "<div>", 1469 1470 options: { 1471 classes: {}, 1472 disabled: false, 1473 1474 // Callbacks 1475 create: null 1476 }, 1477 1478 _createWidget: function( options, element ) { 1479 element = $( element || this.defaultElement || this )[ 0 ]; 1480 this.element = $( element ); 1481 this.uuid = widgetUuid++; 1482 this.eventNamespace = "." + this.widgetName + this.uuid; 1483 1484 this.bindings = $(); 1485 this.hoverable = $(); 1486 this.focusable = $(); 1487 this.classesElementLookup = {}; 1488 1489 if ( element !== this ) { 1490 $.data( element, this.widgetFullName, this ); 1491 this._on( true, this.element, { 1492 remove: function( event ) { 1493 if ( event.target === element ) { 1494 this.destroy(); 1495 } 1496 } 1497 } ); 1498 this.document = $( element.style ? 1499 1500 // Element within the document 1501 element.ownerDocument : 1502 1503 // Element is window or document 1504 element.document || element ); 1505 this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow ); 1506 } 1507 1508 this.options = $.widget.extend( {}, 1509 this.options, 1510 this._getCreateOptions(), 1511 options ); 1512 1513 this._create(); 1514 1515 if ( this.options.disabled ) { 1516 this._setOptionDisabled( this.options.disabled ); 1517 } 1518 1519 this._trigger( "create", null, this._getCreateEventData() ); 1520 this._init(); 1521 }, 1522 1523 _getCreateOptions: function() { 1524 return {}; 1525 }, 1526 1527 _getCreateEventData: $.noop, 1528 1529 _create: $.noop, 1530 1531 _init: $.noop, 1532 1533 destroy: function() { 1534 var that = this; 1535 1536 this._destroy(); 1537 $.each( this.classesElementLookup, function( key, value ) { 1538 that._removeClass( value, key ); 1539 } ); 1540 1541 // We can probably remove the unbind calls in 2.0 1542 // all event bindings should go through this._on() 1543 this.element 1544 .off( this.eventNamespace ) 1545 .removeData( this.widgetFullName ); 1546 this.widget() 1547 .off( this.eventNamespace ) 1548 .removeAttr( "aria-disabled" ); 1549 1550 // Clean up events and states 1551 this.bindings.off( this.eventNamespace ); 1552 }, 1553 1554 _destroy: $.noop, 1555 1556 widget: function() { 1557 return this.element; 1558 }, 1559 1560 option: function( key, value ) { 1561 var options = key; 1562 var parts; 1563 var curOption; 1564 var i; 1565 1566 if ( arguments.length === 0 ) { 1567 1568 // Don't return a reference to the internal hash 1569 return $.widget.extend( {}, this.options ); 1570 } 1571 1572 if ( typeof key === "string" ) { 1573 1574 // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } 1575 options = {}; 1576 parts = key.split( "." ); 1577 key = parts.shift(); 1578 if ( parts.length ) { 1579 curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); 1580 for ( i = 0; i < parts.length - 1; i++ ) { 1581 curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; 1582 curOption = curOption[ parts[ i ] ]; 1583 } 1584 key = parts.pop(); 1585 if ( arguments.length === 1 ) { 1586 return curOption[ key ] === undefined ? null : curOption[ key ]; 1587 } 1588 curOption[ key ] = value; 1589 } else { 1590 if ( arguments.length === 1 ) { 1591 return this.options[ key ] === undefined ? null : this.options[ key ]; 1592 } 1593 options[ key ] = value; 1594 } 1595 } 1596 1597 this._setOptions( options ); 1598 1599 return this; 1600 }, 1601 1602 _setOptions: function( options ) { 1603 var key; 1604 1605 for ( key in options ) { 1606 this._setOption( key, options[ key ] ); 1607 } 1608 1609 return this; 1610 }, 1611 1612 _setOption: function( key, value ) { 1613 if ( key === "classes" ) { 1614 this._setOptionClasses( value ); 1615 } 1616 1617 this.options[ key ] = value; 1618 1619 if ( key === "disabled" ) { 1620 this._setOptionDisabled( value ); 1621 } 1622 1623 return this; 1624 }, 1625 1626 _setOptionClasses: function( value ) { 1627 var classKey, elements, currentElements; 1628 1629 for ( classKey in value ) { 1630 currentElements = this.classesElementLookup[ classKey ]; 1631 if ( value[ classKey ] === this.options.classes[ classKey ] || 1632 !currentElements || 1633 !currentElements.length ) { 1634 continue; 1635 } 1636 1637 // We are doing this to create a new jQuery object because the _removeClass() call 1638 // on the next line is going to destroy the reference to the current elements being 1639 // tracked. We need to save a copy of this collection so that we can add the new classes 1640 // below. 1641 elements = $( currentElements.get() ); 1642 this._removeClass( currentElements, classKey ); 1643 1644 // We don't use _addClass() here, because that uses this.options.classes 1645 // for generating the string of classes. We want to use the value passed in from 1646 // _setOption(), this is the new value of the classes option which was passed to 1647 // _setOption(). We pass this value directly to _classes(). 1648 elements.addClass( this._classes( { 1649 element: elements, 1650 keys: classKey, 1651 classes: value, 1652 add: true 1653 } ) ); 1654 } 1655 }, 1656 1657 _setOptionDisabled: function( value ) { 1658 this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value ); 1659 1660 // If the widget is becoming disabled, then nothing is interactive 1661 if ( value ) { 1662 this._removeClass( this.hoverable, null, "ui-state-hover" ); 1663 this._removeClass( this.focusable, null, "ui-state-focus" ); 1664 } 1665 }, 1666 1667 enable: function() { 1668 return this._setOptions( { disabled: false } ); 1669 }, 1670 1671 disable: function() { 1672 return this._setOptions( { disabled: true } ); 1673 }, 1674 1675 _classes: function( options ) { 1676 var full = []; 1677 var that = this; 1678 1679 options = $.extend( { 1680 element: this.element, 1681 classes: this.options.classes || {} 1682 }, options ); 1683 1684 function bindRemoveEvent() { 1685 var nodesToBind = []; 1686 1687 options.element.each( function( _, element ) { 1688 var isTracked = $.map( that.classesElementLookup, function( elements ) { 1689 return elements; 1690 } ) 1691 .some( function( elements ) { 1692 return elements.is( element ); 1693 } ); 1694 1695 if ( !isTracked ) { 1696 nodesToBind.push( element ); 1697 } 1698 } ); 1699 1700 that._on( $( nodesToBind ), { 1701 remove: "_untrackClassesElement" 1702 } ); 1703 } 1704 1705 function processClassString( classes, checkOption ) { 1706 var current, i; 1707 for ( i = 0; i < classes.length; i++ ) { 1708 current = that.classesElementLookup[ classes[ i ] ] || $(); 1709 if ( options.add ) { 1710 bindRemoveEvent(); 1711 current = $( $.uniqueSort( current.get().concat( options.element.get() ) ) ); 1712 } else { 1713 current = $( current.not( options.element ).get() ); 1714 } 1715 that.classesElementLookup[ classes[ i ] ] = current; 1716 full.push( classes[ i ] ); 1717 if ( checkOption && options.classes[ classes[ i ] ] ) { 1718 full.push( options.classes[ classes[ i ] ] ); 1719 } 1720 } 1721 } 1722 1723 if ( options.keys ) { 1724 processClassString( options.keys.match( /\S+/g ) || [], true ); 1725 } 1726 if ( options.extra ) { 1727 processClassString( options.extra.match( /\S+/g ) || [] ); 1728 } 1729 1730 return full.join( " " ); 1731 }, 1732 1733 _untrackClassesElement: function( event ) { 1734 var that = this; 1735 $.each( that.classesElementLookup, function( key, value ) { 1736 if ( $.inArray( event.target, value ) !== -1 ) { 1737 that.classesElementLookup[ key ] = $( value.not( event.target ).get() ); 1738 } 1739 } ); 1740 1741 this._off( $( event.target ) ); 1742 }, 1743 1744 _removeClass: function( element, keys, extra ) { 1745 return this._toggleClass( element, keys, extra, false ); 1746 }, 1747 1748 _addClass: function( element, keys, extra ) { 1749 return this._toggleClass( element, keys, extra, true ); 1750 }, 1751 1752 _toggleClass: function( element, keys, extra, add ) { 1753 add = ( typeof add === "boolean" ) ? add : extra; 1754 var shift = ( typeof element === "string" || element === null ), 1755 options = { 1756 extra: shift ? keys : extra, 1757 keys: shift ? element : keys, 1758 element: shift ? this.element : element, 1759 add: add 1760 }; 1761 options.element.toggleClass( this._classes( options ), add ); 1762 return this; 1763 }, 1764 1765 _on: function( suppressDisabledCheck, element, handlers ) { 1766 var delegateElement; 1767 var instance = this; 1768 1769 // No suppressDisabledCheck flag, shuffle arguments 1770 if ( typeof suppressDisabledCheck !== "boolean" ) { 1771 handlers = element; 1772 element = suppressDisabledCheck; 1773 suppressDisabledCheck = false; 1774 } 1775 1776 // No element argument, shuffle and use this.element 1777 if ( !handlers ) { 1778 handlers = element; 1779 element = this.element; 1780 delegateElement = this.widget(); 1781 } else { 1782 element = delegateElement = $( element ); 1783 this.bindings = this.bindings.add( element ); 1784 } 1785 1786 $.each( handlers, function( event, handler ) { 1787 function handlerProxy() { 1788 1789 // Allow widgets to customize the disabled handling 1790 // - disabled as an array instead of boolean 1791 // - disabled class as method for disabling individual parts 1792 if ( !suppressDisabledCheck && 1793 ( instance.options.disabled === true || 1794 $( this ).hasClass( "ui-state-disabled" ) ) ) { 1795 return; 1796 } 1797 return ( typeof handler === "string" ? instance[ handler ] : handler ) 1798 .apply( instance, arguments ); 1799 } 1800 1801 // Copy the guid so direct unbinding works 1802 if ( typeof handler !== "string" ) { 1803 handlerProxy.guid = handler.guid = 1804 handler.guid || handlerProxy.guid || $.guid++; 1805 } 1806 1807 var match = event.match( /^([\w:-]*)\s*(.*)$/ ); 1808 var eventName = match[ 1 ] + instance.eventNamespace; 1809 var selector = match[ 2 ]; 1810 1811 if ( selector ) { 1812 delegateElement.on( eventName, selector, handlerProxy ); 1813 } else { 1814 element.on( eventName, handlerProxy ); 1815 } 1816 } ); 1817 }, 1818 1819 _off: function( element, eventName ) { 1820 eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) + 1821 this.eventNamespace; 1822 element.off( eventName ); 1823 1824 // Clear the stack to avoid memory leaks (#10056) 1825 this.bindings = $( this.bindings.not( element ).get() ); 1826 this.focusable = $( this.focusable.not( element ).get() ); 1827 this.hoverable = $( this.hoverable.not( element ).get() ); 1828 }, 1829 1830 _delay: function( handler, delay ) { 1831 function handlerProxy() { 1832 return ( typeof handler === "string" ? instance[ handler ] : handler ) 1833 .apply( instance, arguments ); 1834 } 1835 var instance = this; 1836 return setTimeout( handlerProxy, delay || 0 ); 1837 }, 1838 1839 _hoverable: function( element ) { 1840 this.hoverable = this.hoverable.add( element ); 1841 this._on( element, { 1842 mouseenter: function( event ) { 1843 this._addClass( $( event.currentTarget ), null, "ui-state-hover" ); 1844 }, 1845 mouseleave: function( event ) { 1846 this._removeClass( $( event.currentTarget ), null, "ui-state-hover" ); 1847 } 1848 } ); 1849 }, 1850 1851 _focusable: function( element ) { 1852 this.focusable = this.focusable.add( element ); 1853 this._on( element, { 1854 focusin: function( event ) { 1855 this._addClass( $( event.currentTarget ), null, "ui-state-focus" ); 1856 }, 1857 focusout: function( event ) { 1858 this._removeClass( $( event.currentTarget ), null, "ui-state-focus" ); 1859 } 1860 } ); 1861 }, 1862 1863 _trigger: function( type, event, data ) { 1864 var prop, orig; 1865 var callback = this.options[ type ]; 1866 1867 data = data || {}; 1868 event = $.Event( event ); 1869 event.type = ( type === this.widgetEventPrefix ? 1870 type : 1871 this.widgetEventPrefix + type ).toLowerCase(); 1872 1873 // The original event may come from any element 1874 // so we need to reset the target on the new event 1875 event.target = this.element[ 0 ]; 1876 1877 // Copy original event properties over to the new event 1878 orig = event.originalEvent; 1879 if ( orig ) { 1880 for ( prop in orig ) { 1881 if ( !( prop in event ) ) { 1882 event[ prop ] = orig[ prop ]; 1883 } 1884 } 1885 } 1886 1887 this.element.trigger( event, data ); 1888 return !( typeof callback === "function" && 1889 callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false || 1890 event.isDefaultPrevented() ); 1891 } 1892}; 1893 1894$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { 1895 $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { 1896 if ( typeof options === "string" ) { 1897 options = { effect: options }; 1898 } 1899 1900 var hasOptions; 1901 var effectName = !options ? 1902 method : 1903 options === true || typeof options === "number" ? 1904 defaultEffect : 1905 options.effect || defaultEffect; 1906 1907 options = options || {}; 1908 if ( typeof options === "number" ) { 1909 options = { duration: options }; 1910 } else if ( options === true ) { 1911 options = {}; 1912 } 1913 1914 hasOptions = !$.isEmptyObject( options ); 1915 options.complete = callback; 1916 1917 if ( options.delay ) { 1918 element.delay( options.delay ); 1919 } 1920 1921 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { 1922 element[ method ]( options ); 1923 } else if ( effectName !== method && element[ effectName ] ) { 1924 element[ effectName ]( options.duration, options.easing, callback ); 1925 } else { 1926 element.queue( function( next ) { 1927 $( this )[ method ](); 1928 if ( callback ) { 1929 callback.call( element[ 0 ] ); 1930 } 1931 next(); 1932 } ); 1933 } 1934 }; 1935} ); 1936 1937var widget = $.widget; 1938 1939 1940/*! 1941 * jQuery UI Position 1.1
vendor: 3,858 bytes, lines 1941-2084
19413.2 1942 * http://jqueryui.com 1943 * 1944 * Copyright jQuery Foundation and other contributors 1945 * Released under the MIT license. 1946 * http://jquery.org/license 1947 * 1948 * http://api.jqueryui.com/position/ 1949 */ 1950 1951//>>label: Position 1952//>>group: Core 1953//>>description: Positions elements relative to other elements. 1954//>>docs: http://api.jqueryui.com/position/ 1955//>>demos: http://jqueryui.com/position/ 1956 1957 1958( function() { 1959var cachedScrollbarWidth, 1960 max = Math.max, 1961 abs = Math.abs, 1962 rhorizontal = /left|center|right/, 1963 rvertical = /top|center|bottom/, 1964 roffset = /[\+\-]\d+(\.[\d]+)?%?/, 1965 rposition = /^\w+/, 1966 rpercent = /%$/, 1967 _position = $.fn.position; 1968 1969function getOffsets( offsets, width, height ) { 1970 return [ 1971 parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), 1972 parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) 1973 ]; 1974} 1975 1976function parseCss( element, property ) { 1977 return parseInt( $.css( element, property ), 10 ) || 0; 1978} 1979 1980function isWindow( obj ) { 1981 return obj != null && obj === obj.window; 1982} 1983 1984function getDimensions( elem ) { 1985 var raw = elem[ 0 ]; 1986 if ( raw.nodeType === 9 ) { 1987 return { 1988 width: elem.width(), 1989 height: elem.height(), 1990 offset: { top: 0, left: 0 } 1991 }; 1992 } 1993 if ( isWindow( raw ) ) { 1994 return { 1995 width: elem.width(), 1996 height: elem.height(), 1997 offset: { top: elem.scrollTop(), left: elem.scrollLeft() } 1998 }; 1999 } 2000 if ( raw.preventDefault ) { 2001 return { 2002 width: 0, 2003 height: 0, 2004 offset: { top: raw.pageY, left: raw.pageX } 2005 }; 2006 } 2007 return { 2008 width: elem.outerWidth(), 2009 height: elem.outerHeight(), 2010 offset: elem.offset() 2011 }; 2012} 2013 2014$.position = { 2015 scrollbarWidth: function() { 2016 if ( cachedScrollbarWidth !== undefined ) { 2017 return cachedScrollbarWidth; 2018 } 2019 var w1, w2, 2020 div = $( "<div style=" + 2021 "'display:block;position:absolute;width:200px;height:200px;overflow:hidden;'>" + 2022 "<div style='height:300px;width:auto;'></div></div>" ), 2023 innerDiv = div.children()[ 0 ]; 2024 2025 $( "body" ).append( div ); 2026 w1 = innerDiv.offsetWidth; 2027 div.css( "overflow", "scroll" ); 2028 2029 w2 = innerDiv.offsetWidth; 2030 2031 if ( w1 === w2 ) { 2032 w2 = div[ 0 ].clientWidth; 2033 } 2034 2035 div.remove(); 2036 2037 return ( cachedScrollbarWidth = w1 - w2 ); 2038 }, 2039 getScrollInfo: function( within ) { 2040 var overflowX = within.isWindow || within.isDocument ? "" : 2041 within.element.css( "overflow-x" ), 2042 overflowY = within.isWindow || within.isDocument ? "" : 2043 within.element.css( "overflow-y" ), 2044 hasOverflowX = overflowX === "scroll" || 2045 ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ), 2046 hasOverflowY = overflowY === "scroll" || 2047 ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight ); 2048 return { 2049 width: hasOverflowY ? $.position.scrollbarWidth() : 0, 2050 height: hasOverflowX ? $.position.scrollbarWidth() : 0 2051 }; 2052 }, 2053 getWithinInfo: function( element ) { 2054 var withinElement = $( element || window ), 2055 isElemWindow = isWindow( withinElement[ 0 ] ), 2056 isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9, 2057 hasOffset = !isElemWindow && !isDocument; 2058 return { 2059 element: withinElement, 2060 isWindow: isElemWindow, 2061 isDocument: isDocument, 2062 offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 }, 2063 scrollLeft: withinElement.scrollLeft(), 2064 scrollTop: withinElement.scrollTop(), 2065 width: withinElement.outerWidth(), 2066 height: withinElement.outerHeight() 2067 }; 2068 } 2069}; 2070 2071$.fn.position = function( options ) { 2072 if ( !options || !options.of ) { 2073 return _position.apply( this, arguments ); 2074 } 2075 2076 // Make a copy, we don't want to modify arguments 2077 options = $.extend( {}, options ); 2078 2079 var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions, 2080 2081 // Make sure string options are treated as CSS selectors 2082 target = typeof options.of === "string" ? 2083 $( document ).find( options.of ) : 2084 $( options.of ),
vendor: 10,983 bytes, lines 2085-2438
2085 2086 within = $.position.getWithinInfo( options.within ), 2087 scrollInfo = $.position.getScrollInfo( within ), 2088 collision = ( options.collision || "flip" ).split( " " ), 2089 offsets = {}; 2090 2091 dimensions = getDimensions( target ); 2092 if ( target[ 0 ].preventDefault ) { 2093 2094 // Force left top to allow flipping 2095 options.at = "left top"; 2096 } 2097 targetWidth = dimensions.width; 2098 targetHeight = dimensions.height; 2099 targetOffset = dimensions.offset; 2100 2101 // Clone to reuse original targetOffset later 2102 basePosition = $.extend( {}, targetOffset ); 2103 2104 // Force my and at to have valid horizontal and vertical positions 2105 // if a value is missing or invalid, it will be converted to center 2106 $.each( [ "my", "at" ], function() { 2107 var pos = ( options[ this ] || "" ).split( " " ), 2108 horizontalOffset, 2109 verticalOffset; 2110 2111 if ( pos.length === 1 ) { 2112 pos = rhorizontal.test( pos[ 0 ] ) ? 2113 pos.concat( [ "center" ] ) : 2114 rvertical.test( pos[ 0 ] ) ? 2115 [ "center" ].concat( pos ) : 2116 [ "center", "center" ]; 2117 } 2118 pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center"; 2119 pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center"; 2120 2121 // Calculate offsets 2122 horizontalOffset = roffset.exec( pos[ 0 ] ); 2123 verticalOffset = roffset.exec( pos[ 1 ] ); 2124 offsets[ this ] = [ 2125 horizontalOffset ? horizontalOffset[ 0 ] : 0, 2126 verticalOffset ? verticalOffset[ 0 ] : 0 2127 ]; 2128 2129 // Reduce to just the positions without the offsets 2130 options[ this ] = [ 2131 rposition.exec( pos[ 0 ] )[ 0 ], 2132 rposition.exec( pos[ 1 ] )[ 0 ] 2133 ]; 2134 } ); 2135 2136 // Normalize collision option 2137 if ( collision.length === 1 ) { 2138 collision[ 1 ] = collision[ 0 ]; 2139 } 2140 2141 if ( options.at[ 0 ] === "right" ) { 2142 basePosition.left += targetWidth; 2143 } else if ( options.at[ 0 ] === "center" ) { 2144 basePosition.left += targetWidth / 2; 2145 } 2146 2147 if ( options.at[ 1 ] === "bottom" ) { 2148 basePosition.top += targetHeight; 2149 } else if ( options.at[ 1 ] === "center" ) { 2150 basePosition.top += targetHeight / 2; 2151 } 2152 2153 atOffset = getOffsets( offsets.at, targetWidth, targetHeight ); 2154 basePosition.left += atOffset[ 0 ]; 2155 basePosition.top += atOffset[ 1 ]; 2156 2157 return this.each( function() { 2158 var collisionPosition, using, 2159 elem = $( this ), 2160 elemWidth = elem.outerWidth(), 2161 elemHeight = elem.outerHeight(), 2162 marginLeft = parseCss( this, "marginLeft" ), 2163 marginTop = parseCss( this, "marginTop" ), 2164 collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + 2165 scrollInfo.width, 2166 collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + 2167 scrollInfo.height, 2168 position = $.extend( {}, basePosition ), 2169 myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ); 2170 2171 if ( options.my[ 0 ] === "right" ) { 2172 position.left -= elemWidth; 2173 } else if ( options.my[ 0 ] === "center" ) { 2174 position.left -= elemWidth / 2; 2175 } 2176 2177 if ( options.my[ 1 ] === "bottom" ) { 2178 position.top -= elemHeight; 2179 } else if ( options.my[ 1 ] === "center" ) { 2180 position.top -= elemHeight / 2; 2181 } 2182 2183 position.left += myOffset[ 0 ]; 2184 position.top += myOffset[ 1 ]; 2185 2186 collisionPosition = { 2187 marginLeft: marginLeft, 2188 marginTop: marginTop 2189 }; 2190 2191 $.each( [ "left", "top" ], function( i, dir ) { 2192 if ( $.ui.position[ collision[ i ] ] ) { 2193 $.ui.position[ collision[ i ] ][ dir ]( position, { 2194 targetWidth: targetWidth, 2195 targetHeight: targetHeight, 2196 elemWidth: elemWidth, 2197 elemHeight: elemHeight, 2198 collisionPosition: collisionPosition, 2199 collisionWidth: collisionWidth, 2200 collisionHeight: collisionHeight, 2201 offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ], 2202 my: options.my, 2203 at: options.at, 2204 within: within, 2205 elem: elem 2206 } ); 2207 } 2208 } ); 2209 2210 if ( options.using ) { 2211 2212 // Adds feedback as second argument to using callback, if present 2213 using = function( props ) { 2214 var left = targetOffset.left - position.left, 2215 right = left + targetWidth - elemWidth, 2216 top = targetOffset.top - position.top, 2217 bottom = top + targetHeight - elemHeight, 2218 feedback = { 2219 target: { 2220 element: target, 2221 left: targetOffset.left, 2222 top: targetOffset.top, 2223 width: targetWidth, 2224 height: targetHeight 2225 }, 2226 element: { 2227 element: elem, 2228 left: position.left, 2229 top: position.top, 2230 width: elemWidth, 2231 height: elemHeight 2232 }, 2233 horizontal: right < 0 ? "left" : left > 0 ? "right" : "center", 2234 vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle" 2235 }; 2236 if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) { 2237 feedback.horizontal = "center"; 2238 } 2239 if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) { 2240 feedback.vertical = "middle"; 2241 } 2242 if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) { 2243 feedback.important = "horizontal"; 2244 } else { 2245 feedback.important = "vertical"; 2246 } 2247 options.using.call( this, props, feedback ); 2248 }; 2249 } 2250 2251 elem.offset( $.extend( position, { using: using } ) ); 2252 } ); 2253}; 2254 2255$.ui.position = { 2256 fit: { 2257 left: function( position, data ) { 2258 var within = data.within, 2259 withinOffset = within.isWindow ? within.scrollLeft : within.offset.left, 2260 outerWidth = within.width, 2261 collisionPosLeft = position.left - data.collisionPosition.marginLeft, 2262 overLeft = withinOffset - collisionPosLeft, 2263 overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, 2264 newOverRight; 2265 2266 // Element is wider than within 2267 if ( data.collisionWidth > outerWidth ) { 2268 2269 // Element is initially over the left side of within 2270 if ( overLeft > 0 && overRight <= 0 ) { 2271 newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - 2272 withinOffset; 2273 position.left += overLeft - newOverRight; 2274 2275 // Element is initially over right side of within 2276 } else if ( overRight > 0 && overLeft <= 0 ) { 2277 position.left = withinOffset; 2278 2279 // Element is initially over both left and right sides of within 2280 } else { 2281 if ( overLeft > overRight ) { 2282 position.left = withinOffset + outerWidth - data.collisionWidth; 2283 } else { 2284 position.left = withinOffset; 2285 } 2286 } 2287 2288 // Too far left -> align with left edge 2289 } else if ( overLeft > 0 ) { 2290 position.left += overLeft; 2291 2292 // Too far right -> align with right edge 2293 } else if ( overRight > 0 ) { 2294 position.left -= overRight; 2295 2296 // Adjust based on position and margin 2297 } else { 2298 position.left = max( position.left - collisionPosLeft, position.left ); 2299 } 2300 }, 2301 top: function( position, data ) { 2302 var within = data.within, 2303 withinOffset = within.isWindow ? within.scrollTop : within.offset.top, 2304 outerHeight = data.within.height, 2305 collisionPosTop = position.top - data.collisionPosition.marginTop, 2306 overTop = withinOffset - collisionPosTop, 2307 overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset, 2308 newOverBottom; 2309 2310 // Element is taller than within 2311 if ( data.collisionHeight > outerHeight ) { 2312 2313 // Element is initially over the top of within 2314 if ( overTop > 0 && overBottom <= 0 ) { 2315 newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - 2316 withinOffset; 2317 position.top += overTop - newOverBottom; 2318 2319 // Element is initially over bottom of within 2320 } else if ( overBottom > 0 && overTop <= 0 ) { 2321 position.top = withinOffset; 2322 2323 // Element is initially over both top and bottom of within 2324 } else { 2325 if ( overTop > overBottom ) { 2326 position.top = withinOffset + outerHeight - data.collisionHeight; 2327 } else { 2328 position.top = withinOffset; 2329 } 2330 } 2331 2332 // Too far up -> align with top 2333 } else if ( overTop > 0 ) { 2334 position.top += overTop; 2335 2336 // Too far down -> align with bottom edge 2337 } else if ( overBottom > 0 ) { 2338 position.top -= overBottom; 2339 2340 // Adjust based on position and margin 2341 } else { 2342 position.top = max( position.top - collisionPosTop, position.top ); 2343 } 2344 } 2345 }, 2346 flip: { 2347 left: function( position, data ) { 2348 var within = data.within, 2349 withinOffset = within.offset.left + within.scrollLeft, 2350 outerWidth = within.width, 2351 offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left, 2352 collisionPosLeft = position.left - data.collisionPosition.marginLeft, 2353 overLeft = collisionPosLeft - offsetLeft, 2354 overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft, 2355 myOffset = data.my[ 0 ] === "left" ? 2356 -data.elemWidth : 2357 data.my[ 0 ] === "right" ? 2358 data.elemWidth : 2359 0, 2360 atOffset = data.at[ 0 ] === "left" ? 2361 data.targetWidth : 2362 data.at[ 0 ] === "right" ? 2363 -data.targetWidth : 2364 0, 2365 offset = -2 * data.offset[ 0 ], 2366 newOverRight, 2367 newOverLeft; 2368 2369 if ( overLeft < 0 ) { 2370 newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - 2371 outerWidth - withinOffset; 2372 if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) { 2373 position.left += myOffset + atOffset + offset; 2374 } 2375 } else if ( overRight > 0 ) { 2376 newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + 2377 atOffset + offset - offsetLeft; 2378 if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) { 2379 position.left += myOffset + atOffset + offset; 2380 } 2381 } 2382 }, 2383 top: function( position, data ) { 2384 var within = data.within, 2385 withinOffset = within.offset.top + within.scrollTop, 2386 outerHeight = within.height, 2387 offsetTop = within.isWindow ? within.scrollTop : within.offset.top, 2388 collisionPosTop = position.top - data.collisionPosition.marginTop, 2389 overTop = collisionPosTop - offsetTop, 2390 overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop, 2391 top = data.my[ 1 ] === "top", 2392 myOffset = top ? 2393 -data.elemHeight : 2394 data.my[ 1 ] === "bottom" ? 2395 data.elemHeight : 2396 0, 2397 atOffset = data.at[ 1 ] === "top" ? 2398 data.targetHeight : 2399 data.at[ 1 ] === "bottom" ? 2400 -data.targetHeight : 2401 0, 2402 offset = -2 * data.offset[ 1 ], 2403 newOverTop, 2404 newOverBottom; 2405 if ( overTop < 0 ) { 2406 newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - 2407 outerHeight - withinOffset; 2408 if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) { 2409 position.top += myOffset + atOffset + offset; 2410 } 2411 } else if ( overBottom > 0 ) { 2412 newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + 2413 offset - offsetTop; 2414 if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) { 2415 position.top += myOffset + atOffset + offset; 2416 } 2417 } 2418 } 2419 }, 2420 flipfit: { 2421 left: function() { 2422 $.ui.position.flip.left.apply( this, arguments ); 2423 $.ui.position.fit.left.apply( this, arguments ); 2424 }, 2425 top: function() { 2426 $.ui.position.flip.top.apply( this, arguments ); 2427 $.ui.position.fit.top.apply( this, arguments ); 2428 } 2429 } 2430}; 2431 2432} )(); 2433 2434var position = $.ui.position; 2435 2436 2437/*! 2438 * jQuery UI
vendor: 6,652 bytes, lines 2438-2713
2438Keycode 1.13.2 2439 * http://jqueryui.com 2440 * 2441 * Copyright jQuery Foundation and other contributors 2442 * Released under the MIT license. 2443 * http://jquery.org/license 2444 */ 2445 2446//>>label: Keycode 2447//>>group: Core 2448//>>description: Provide keycodes as keynames 2449//>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/ 2450 2451 2452var keycode = $.ui.keyCode = { 2453 BACKSPACE: 8, 2454 COMMA: 188, 2455 DELETE: 46, 2456 DOWN: 40, 2457 END: 35, 2458 ENTER: 13, 2459 ESCAPE: 27, 2460 HOME: 36, 2461 LEFT: 37, 2462 PAGE_DOWN: 34, 2463 PAGE_UP: 33, 2464 PERIOD: 190, 2465 RIGHT: 39, 2466 SPACE: 32, 2467 TAB: 9, 2468 UP: 38 2469}; 2470 2471 2472/*! 2473 * jQuery UI Unique ID 1.13.2 2474 * http://jqueryui.com 2475 * 2476 * Copyright jQuery Foundation and other contributors 2477 * Released under the MIT license. 2478 * http://jquery.org/license 2479 */ 2480 2481//>>label: uniqueId 2482//>>group: Core 2483//>>description: Functions to generate and remove uniqueId's 2484//>>docs: http://api.jqueryui.com/uniqueId/ 2485 2486 2487var uniqueId = $.fn.extend( { 2488 uniqueId: ( function() { 2489 var uuid = 0; 2490 2491 return function() { 2492 return this.each( function() { 2493 if ( !this.id ) { 2494 this.id = "ui-id-" + ( ++uuid ); 2495 } 2496 } ); 2497 }; 2498 } )(), 2499 2500 removeUniqueId: function() { 2501 return this.each( function() { 2502 if ( /^ui-id-\d+$/.test( this.id ) ) { 2503 $( this ).removeAttr( "id" ); 2504 } 2505 } ); 2506 } 2507} ); 2508 2509 2510 2511var safeActiveElement = $.ui.safeActiveElement = function( document ) { 2512 var activeElement; 2513 2514 // Support: IE 9 only 2515 // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> 2516 try { 2517 activeElement = document.activeElement; 2518 } catch ( error ) { 2519 activeElement = document.body; 2520 } 2521 2522 // Support: IE 9 - 11 only 2523 // IE may return null instead of an element 2524 // Interestingly, this only seems to occur when NOT in an iframe 2525 if ( !activeElement ) { 2526 activeElement = document.body; 2527 } 2528 2529 // Support: IE 11 only 2530 // IE11 returns a seemingly empty object in some cases when accessing 2531 // document.activeElement from an <iframe> 2532 if ( !activeElement.nodeName ) { 2533 activeElement = document.body; 2534 } 2535 2536 return activeElement; 2537}; 2538 2539 2540/*! 2541 * jQuery UI Menu 1.13.2 2542 * http://jqueryui.com 2543 * 2544 * Copyright jQuery Foundation and other contributors 2545 * Released under the MIT license. 2546 * http://jquery.org/license 2547 */ 2548 2549//>>label: Menu 2550//>>group: Widgets 2551//>>description: Creates nestable menus. 2552//>>docs: http://api.jqueryui.com/menu/ 2553//>>demos: http://jqueryui.com/menu/ 2554//>>css.structure: ../../themes/base/core.css 2555//>>css.structure: ../../themes/base/menu.css 2556//>>css.theme: ../../themes/base/theme.css 2557 2558 2559var widgetsMenu = $.widget( "ui.menu", { 2560 version: "1.13.2", 2561 defaultElement: "<ul>", 2562 delay: 300, 2563 options: { 2564 icons: { 2565 submenu: "ui-icon-caret-1-e" 2566 }, 2567 items: "> *", 2568 menus: "ul", 2569 position: { 2570 my: "left top", 2571 at: "right top" 2572 }, 2573 role: "menu", 2574 2575 // Callbacks 2576 blur: null, 2577 focus: null, 2578 select: null 2579 }, 2580 2581 _create: function() { 2582 this.activeMenu = this.element; 2583 2584 // Flag used to prevent firing of the click handler 2585 // as the event bubbles up through nested menus 2586 this.mouseHandled = false; 2587 this.lastMousePosition = { x: null, y: null }; 2588 this.element 2589 .uniqueId() 2590 .attr( { 2591 role: this.options.role, 2592 tabIndex: 0 2593 } ); 2594 2595 this._addClass( "ui-menu", "ui-widget ui-widget-content" ); 2596 this._on( { 2597 2598 // Prevent focus from sticking to links inside menu after clicking 2599 // them (focus should always stay on UL during navigation). 2600 "mousedown .ui-menu-item": function( event ) { 2601 event.preventDefault(); 2602 2603 this._activateItem( event ); 2604 }, 2605 "click .ui-menu-item": function( event ) { 2606 var target = $( event.target ); 2607 var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) ); 2608 if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) { 2609 this.select( event ); 2610 2611 // Only set the mouseHandled flag if the event will bubble, see #9469. 2612 if ( !event.isPropagationStopped() ) { 2613 this.mouseHandled = true; 2614 } 2615 2616 // Open submenu on click 2617 if ( target.has( ".ui-menu" ).length ) { 2618 this.expand( event ); 2619 } else if ( !this.element.is( ":focus" ) && 2620 active.closest( ".ui-menu" ).length ) { 2621 2622 // Redirect focus to the menu 2623 this.element.trigger( "focus", [ true ] ); 2624 2625 // If the active item is on the top level, let it stay active. 2626 // Otherwise, blur the active item since it is no longer visible. 2627 if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) { 2628 clearTimeout( this.timer ); 2629 } 2630 } 2631 } 2632 }, 2633 "mouseenter .ui-menu-item": "_activateItem", 2634 "mousemove .ui-menu-item": "_activateItem", 2635 mouseleave: "collapseAll", 2636 "mouseleave .ui-menu": "collapseAll", 2637 focus: function( event, keepActiveItem ) { 2638 2639 // If there's already an active item, keep it active 2640 // If not, activate the first item 2641 var item = this.active || this._menuItems().first(); 2642 2643 if ( !keepActiveItem ) { 2644 this.focus( event, item ); 2645 } 2646 }, 2647 blur: function( event ) { 2648 this._delay( function() { 2649 var notContained = !$.contains( 2650 this.element[ 0 ], 2651 $.ui.safeActiveElement( this.document[ 0 ] ) 2652 ); 2653 if ( notContained ) { 2654 this.collapseAll( event ); 2655 } 2656 } ); 2657 }, 2658 keydown: "_keydown" 2659 } ); 2660 2661 this.refresh(); 2662 2663 // Clicks outside of a menu collapse any open menus 2664 this._on( this.document, { 2665 click: function( event ) { 2666 if ( this._closeOnDocumentClick( event ) ) { 2667 this.collapseAll( event, true ); 2668 } 2669 2670 // Reset the mouseHandled flag 2671 this.mouseHandled = false; 2672 } 2673 } ); 2674 }, 2675 2676 _activateItem: function( event ) { 2677 2678 // Ignore mouse events while typeahead is active, see #10458. 2679 // Prevents focusing the wrong item when typeahead causes a scroll while the mouse 2680 // is over an item in the menu 2681 if ( this.previousFilter ) { 2682 return; 2683 } 2684 2685 // If the mouse didn't actually move, but the page was scrolled, ignore the event (#9356) 2686 if ( event.clientX === this.lastMousePosition.x && 2687 event.clientY === this.lastMousePosition.y ) { 2688 return; 2689 } 2690 2691 this.lastMousePosition = { 2692 x: event.clientX, 2693 y: event.clientY 2694 }; 2695 2696 var actualTarget = $( event.target ).closest( ".ui-menu-item" ), 2697 target = $( event.currentTarget ); 2698 2699 // Ignore bubbled events on parent items, see #11641 2700 if ( actualTarget[ 0 ] !== target[ 0 ] ) { 2701 return; 2702 } 2703 2704 // If the item is already active, there's nothing to do 2705 if ( target.is( ".ui-state-active" ) ) { 2706 return; 2707 } 2708 2709 // Remove ui-state-active class from siblings of the newly focused menu item 2710 // to avoid a jump caused by adjacent elements both having a class with a border 2711 this._removeClass( target.siblings().children( ".ui-state-active" ), 2712 null, "ui-state-active" ); 2713 this.focus( event, target
vendor: 8,513 bytes, lines 2713-3028
2713 ); 2714 }, 2715 2716 _destroy: function() { 2717 var items = this.element.find( ".ui-menu-item" ) 2718 .removeAttr( "role aria-disabled" ), 2719 submenus = items.children( ".ui-menu-item-wrapper" ) 2720 .removeUniqueId() 2721 .removeAttr( "tabIndex role aria-haspopup" ); 2722 2723 // Destroy (sub)menus 2724 this.element 2725 .removeAttr( "aria-activedescendant" ) 2726 .find( ".ui-menu" ).addBack() 2727 .removeAttr( "role aria-labelledby aria-expanded aria-hidden aria-disabled " + 2728 "tabIndex" ) 2729 .removeUniqueId() 2730 .show(); 2731 2732 submenus.children().each( function() { 2733 var elem = $( this ); 2734 if ( elem.data( "ui-menu-submenu-caret" ) ) { 2735 elem.remove(); 2736 } 2737 } ); 2738 }, 2739 2740 _keydown: function( event ) { 2741 var match, prev, character, skip, 2742 preventDefault = true; 2743 2744 switch ( event.keyCode ) { 2745 case $.ui.keyCode.PAGE_UP: 2746 this.previousPage( event ); 2747 break; 2748 case $.ui.keyCode.PAGE_DOWN: 2749 this.nextPage( event ); 2750 break; 2751 case $.ui.keyCode.HOME: 2752 this._move( "first", "first", event ); 2753 break; 2754 case $.ui.keyCode.END: 2755 this._move( "last", "last", event ); 2756 break; 2757 case $.ui.keyCode.UP: 2758 this.previous( event ); 2759 break; 2760 case $.ui.keyCode.DOWN: 2761 this.next( event ); 2762 break; 2763 case $.ui.keyCode.LEFT: 2764 this.collapse( event ); 2765 break; 2766 case $.ui.keyCode.RIGHT: 2767 if ( this.active && !this.active.is( ".ui-state-disabled" ) ) { 2768 this.expand( event ); 2769 } 2770 break; 2771 case $.ui.keyCode.ENTER: 2772 case $.ui.keyCode.SPACE: 2773 this._activate( event ); 2774 break; 2775 case $.ui.keyCode.ESCAPE: 2776 this.collapse( event ); 2777 break; 2778 default: 2779 preventDefault = false; 2780 prev = this.previousFilter || ""; 2781 skip = false; 2782 2783 // Support number pad values 2784 character = event.keyCode >= 96 && event.keyCode <= 105 ? 2785 ( event.keyCode - 96 ).toString() : String.fromCharCode( event.keyCode ); 2786 2787 clearTimeout( this.filterTimer ); 2788 2789 if ( character === prev ) { 2790 skip = true; 2791 } else { 2792 character = prev + character; 2793 } 2794 2795 match = this._filterMenuItems( character ); 2796 match = skip && match.index( this.active.next() ) !== -1 ? 2797 this.active.nextAll( ".ui-menu-item" ) : 2798 match; 2799 2800 // If no matches on the current filter, reset to the last character pressed 2801 // to move down the menu to the first item that starts with that character 2802 if ( !match.length ) { 2803 character = String.fromCharCode( event.keyCode ); 2804 match = this._filterMenuItems( character ); 2805 } 2806 2807 if ( match.length ) { 2808 this.focus( event, match ); 2809 this.previousFilter = character; 2810 this.filterTimer = this._delay( function() { 2811 delete this.previousFilter; 2812 }, 1000 ); 2813 } else { 2814 delete this.previousFilter; 2815 } 2816 } 2817 2818 if ( preventDefault ) { 2819 event.preventDefault(); 2820 } 2821 }, 2822 2823 _activate: function( event ) { 2824 if ( this.active && !this.active.is( ".ui-state-disabled" ) ) { 2825 if ( this.active.children( "[aria-haspopup='true']" ).length ) { 2826 this.expand( event ); 2827 } else { 2828 this.select( event ); 2829 } 2830 } 2831 }, 2832 2833 refresh: function() { 2834 var menus, items, newSubmenus, newItems, newWrappers, 2835 that = this, 2836 icon = this.options.icons.submenu, 2837 submenus = this.element.find( this.options.menus ); 2838 2839 this._toggleClass( "ui-menu-icons", null, !!this.element.find( ".ui-icon" ).length ); 2840 2841 // Initialize nested menus 2842 newSubmenus = submenus.filter( ":not(.ui-menu)" ) 2843 .hide() 2844 .attr( { 2845 role: this.options.role, 2846 "aria-hidden": "true", 2847 "aria-expanded": "false" 2848 } ) 2849 .each( function() { 2850 var menu = $( this ), 2851 item = menu.prev(), 2852 submenuCaret = $( "<span>" ).data( "ui-menu-submenu-caret", true ); 2853 2854 that._addClass( submenuCaret, "ui-menu-icon", "ui-icon " + icon ); 2855 item 2856 .attr( "aria-haspopup", "true" ) 2857 .prepend( submenuCaret ); 2858 menu.attr( "aria-labelledby", item.attr( "id" ) ); 2859 } ); 2860 2861 this._addClass( newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front" ); 2862 2863 menus = submenus.add( this.element ); 2864 items = menus.find( this.options.items ); 2865 2866 // Initialize menu-items containing spaces and/or dashes only as dividers 2867 items.not( ".ui-menu-item" ).each( function() { 2868 var item = $( this ); 2869 if ( that._isDivider( item ) ) { 2870 that._addClass( item, "ui-menu-divider", "ui-widget-content" ); 2871 } 2872 } ); 2873 2874 // Don't refresh list items that are already adapted 2875 newItems = items.not( ".ui-menu-item, .ui-menu-divider" ); 2876 newWrappers = newItems.children() 2877 .not( ".ui-menu" ) 2878 .uniqueId() 2879 .attr( { 2880 tabIndex: -1, 2881 role: this._itemRole() 2882 } ); 2883 this._addClass( newItems, "ui-menu-item" ) 2884 ._addClass( newWrappers, "ui-menu-item-wrapper" ); 2885 2886 // Add aria-disabled attribute to any disabled menu item 2887 items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" ); 2888 2889 // If the active item has been removed, blur the menu 2890 if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { 2891 this.blur(); 2892 } 2893 }, 2894 2895 _itemRole: function() { 2896 return { 2897 menu: "menuitem", 2898 listbox: "option" 2899 }[ this.options.role ]; 2900 }, 2901 2902 _setOption: function( key, value ) { 2903 if ( key === "icons" ) { 2904 var icons = this.element.find( ".ui-menu-icon" ); 2905 this._removeClass( icons, null, this.options.icons.submenu ) 2906 ._addClass( icons, null, value.submenu ); 2907 } 2908 this._super( key, value ); 2909 }, 2910 2911 _setOptionDisabled: function( value ) { 2912 this._super( value ); 2913 2914 this.element.attr( "aria-disabled", String( value ) ); 2915 this._toggleClass( null, "ui-state-disabled", !!value ); 2916 }, 2917 2918 focus: function( event, item ) { 2919 var nested, focused, activeParent; 2920 this.blur( event, event && event.type === "focus" ); 2921 2922 this._scrollIntoView( item ); 2923 2924 this.active = item.first(); 2925 2926 focused = this.active.children( ".ui-menu-item-wrapper" ); 2927 this._addClass( focused, null, "ui-state-active" ); 2928 2929 // Only update aria-activedescendant if there's a role 2930 // otherwise we assume focus is managed elsewhere 2931 if ( this.options.role ) { 2932 this.element.attr( "aria-activedescendant", focused.attr( "id" ) ); 2933 } 2934 2935 // Highlight active parent menu item, if any 2936 activeParent = this.active 2937 .parent() 2938 .closest( ".ui-menu-item" ) 2939 .children( ".ui-menu-item-wrapper" ); 2940 this._addClass( activeParent, null, "ui-state-active" ); 2941 2942 if ( event && event.type === "keydown" ) { 2943 this._close(); 2944 } else { 2945 this.timer = this._delay( function() { 2946 this._close(); 2947 }, this.delay ); 2948 } 2949 2950 nested = item.children( ".ui-menu" ); 2951 if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) { 2952 this._startOpening( nested ); 2953 } 2954 this.activeMenu = item.parent(); 2955 2956 this._trigger( "focus", event, { item: item } ); 2957 }, 2958 2959 _scrollIntoView: function( item ) { 2960 var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight; 2961 if ( this._hasScroll() ) { 2962 borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0; 2963 paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0; 2964 offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop; 2965 scroll = this.activeMenu.scrollTop(); 2966 elementHeight = this.activeMenu.height(); 2967 itemHeight = item.outerHeight(); 2968 2969 if ( offset < 0 ) { 2970 this.activeMenu.scrollTop( scroll + offset ); 2971 } else if ( offset + itemHeight > elementHeight ) { 2972 this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight ); 2973 } 2974 } 2975 }, 2976 2977 blur: function( event, fromFocus ) { 2978 if ( !fromFocus ) { 2979 clearTimeout( this.timer ); 2980 } 2981 2982 if ( !this.active ) { 2983 return; 2984 } 2985 2986 this._removeClass( this.active.children( ".ui-menu-item-wrapper" ), 2987 null, "ui-state-active" ); 2988 2989 this._trigger( "blur", event, { item: this.active } ); 2990 this.active = null; 2991 }, 2992 2993 _startOpening: function( submenu ) { 2994 clearTimeout( this.timer ); 2995 2996 // Don't open if already open fixes a Firefox bug that caused a .5 pixel 2997 // shift in the submenu position when mousing over the caret icon 2998 if ( submenu.attr( "aria-hidden" ) !== "true" ) { 2999 return; 3000 } 3001 3002 this.timer = this._delay( function() { 3003 this._close(); 3004 this._open( submenu ); 3005 }, this.delay ); 3006 }, 3007 3008 _open: function( submenu ) { 3009 var position = $.extend( { 3010 of: this.active 3011 }, this.options.position ); 3012 3013 clearTimeout( this.timer ); 3014 this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) ) 3015 .hide() 3016 .attr( "aria-hidden", "true" ); 3017 3018 submenu 3019 .show() 3020 .removeAttr( "aria-hidden" ) 3021 .attr( "aria-expanded", "true" ) 3022 .position( position ); 3023 }, 3024 3025 collapseAll: function( event, all ) { 3026 clearTimeout( this.timer ); 3027 this.timer = this._delay( function() { 3028
vendor: 5,432 bytes, lines 3029-3232
3029 // If we were passed an event, look for the submenu that contains the event 3030 var currentMenu = all ? this.element : 3031 $( event && event.target ).closest( this.element.find( ".ui-menu" ) ); 3032 3033 // If we found no valid submenu ancestor, use the main menu to close all 3034 // sub menus anyway 3035 if ( !currentMenu.length ) { 3036 currentMenu = this.element; 3037 } 3038 3039 this._close( currentMenu ); 3040 3041 this.blur( event ); 3042 3043 // Work around active item staying active after menu is blurred 3044 this._removeClass( currentMenu.find( ".ui-state-active" ), null, "ui-state-active" ); 3045 3046 this.activeMenu = currentMenu; 3047 }, all ? 0 : this.delay ); 3048 }, 3049 3050 // With no arguments, closes the currently active menu - if nothing is active 3051 // it closes all menus. If passed an argument, it will search for menus BELOW 3052 _close: function( startMenu ) { 3053 if ( !startMenu ) { 3054 startMenu = this.active ? this.active.parent() : this.element; 3055 } 3056 3057 startMenu.find( ".ui-menu" ) 3058 .hide() 3059 .attr( "aria-hidden", "true" ) 3060 .attr( "aria-expanded", "false" ); 3061 }, 3062 3063 _closeOnDocumentClick: function( event ) { 3064 return !$( event.target ).closest( ".ui-menu" ).length; 3065 }, 3066 3067 _isDivider: function( item ) { 3068 3069 // Match hyphen, em dash, en dash 3070 return !/[^\-\u2014\u2013\s]/.test( item.text() ); 3071 }, 3072 3073 collapse: function( event ) { 3074 var newItem = this.active && 3075 this.active.parent().closest( ".ui-menu-item", this.element ); 3076 if ( newItem && newItem.length ) { 3077 this._close(); 3078 this.focus( event, newItem ); 3079 } 3080 }, 3081 3082 expand: function( event ) { 3083 var newItem = this.active && this._menuItems( this.active.children( ".ui-menu" ) ).first(); 3084 3085 if ( newItem && newItem.length ) { 3086 this._open( newItem.parent() ); 3087 3088 // Delay so Firefox will not hide activedescendant change in expanding submenu from AT 3089 this._delay( function() { 3090 this.focus( event, newItem ); 3091 } ); 3092 } 3093 }, 3094 3095 next: function( event ) { 3096 this._move( "next", "first", event ); 3097 }, 3098 3099 previous: function( event ) { 3100 this._move( "prev", "last", event ); 3101 }, 3102 3103 isFirstItem: function() { 3104 return this.active && !this.active.prevAll( ".ui-menu-item" ).length; 3105 }, 3106 3107 isLastItem: function() { 3108 return this.active && !this.active.nextAll( ".ui-menu-item" ).length; 3109 }, 3110 3111 _menuItems: function( menu ) { 3112 return ( menu || this.element ) 3113 .find( this.options.items ) 3114 .filter( ".ui-menu-item" ); 3115 }, 3116 3117 _move: function( direction, filter, event ) { 3118 var next; 3119 if ( this.active ) { 3120 if ( direction === "first" || direction === "last" ) { 3121 next = this.active 3122 [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" ) 3123 .last(); 3124 } else { 3125 next = this.active 3126 [ direction + "All" ]( ".ui-menu-item" ) 3127 .first(); 3128 } 3129 } 3130 if ( !next || !next.length || !this.active ) { 3131 next = this._menuItems( this.activeMenu )[ filter ](); 3132 } 3133 3134 this.focus( event, next ); 3135 }, 3136 3137 nextPage: function( event ) { 3138 var item, base, height; 3139 3140 if ( !this.active ) { 3141 this.next( event ); 3142 return; 3143 } 3144 if ( this.isLastItem() ) { 3145 return; 3146 } 3147 if ( this._hasScroll() ) { 3148 base = this.active.offset().top; 3149 height = this.element.innerHeight(); 3150 3151 // jQuery 3.2 doesn't include scrollbars in innerHeight, add it back. 3152 if ( $.fn.jquery.indexOf( "3.2." ) === 0 ) { 3153 height += this.element[ 0 ].offsetHeight - this.element.outerHeight(); 3154 } 3155 3156 this.active.nextAll( ".ui-menu-item" ).each( function() { 3157 item = $( this ); 3158 return item.offset().top - base - height < 0; 3159 } ); 3160 3161 this.focus( event, item ); 3162 } else { 3163 this.focus( event, this._menuItems( this.activeMenu ) 3164 [ !this.active ? "first" : "last" ]() ); 3165 } 3166 }, 3167 3168 previousPage: function( event ) { 3169 var item, base, height; 3170 if ( !this.active ) { 3171 this.next( event ); 3172 return; 3173 } 3174 if ( this.isFirstItem() ) { 3175 return; 3176 } 3177 if ( this._hasScroll() ) { 3178 base = this.active.offset().top; 3179 height = this.element.innerHeight(); 3180 3181 // jQuery 3.2 doesn't include scrollbars in innerHeight, add it back. 3182 if ( $.fn.jquery.indexOf( "3.2." ) === 0 ) { 3183 height += this.element[ 0 ].offsetHeight - this.element.outerHeight(); 3184 } 3185 3186 this.active.prevAll( ".ui-menu-item" ).each( function() { 3187 item = $( this ); 3188 return item.offset().top - base + height > 0; 3189 } ); 3190 3191 this.focus( event, item ); 3192 } else { 3193 this.focus( event, this._menuItems( this.activeMenu ).first() ); 3194 } 3195 }, 3196 3197 _hasScroll: function() { 3198 return this.element.outerHeight() < this.element.prop( "scrollHeight" ); 3199 }, 3200 3201 select: function( event ) { 3202 3203 // TODO: It should never be possible to not have an active item at this 3204 // point, but the tests don't trigger mouseenter before click. 3205 this.active = this.active || $( event.target ).closest( ".ui-menu-item" ); 3206 var ui = { item: this.active }; 3207 if ( !this.active.has( ".ui-menu" ).length ) { 3208 this.collapseAll( event, true ); 3209 } 3210 this._trigger( "select", event, ui ); 3211 }, 3212 3213 _filterMenuItems: function( character ) { 3214 var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ), 3215 regex = new RegExp( "^" + escapedCharacter, "i" ); 3216 3217 return this.activeMenu 3218 .find( this.options.items ) 3219 3220 // Only match on items, not dividers or other content (#10571) 3221 .filter( ".ui-menu-item" ) 3222 .filter( function() { 3223 return regex.test( 3224 String.prototype.trim.call( 3225 $( this ).children( ".ui-menu-item-wrapper" ).text() ) ); 3226 } ); 3227 } 3228} ); 3229 3230 3231/*! 3232 * jQuery UI Autocomplete 1.1
32323.2 3233 * http://jqueryui.com 3234 * 3235 * Copyright jQuery Foundation and other contributors 3236 * Released under the MIT license. 3237 * http://jquery.org/license 3238 */ 3239 3240//>>label: Autocomplete 3241//>>group: Widgets 3242//>>description: Lists suggested words as the user is typing. 3243//>>docs: http://api.jqueryui.com/autocomplete/ 3244//>>demos: http://jqueryui.com/autocomplete/ 3245//>>css.structure: ../../themes/base/core.css 3246//>>css.structure: ../../themes/base/autocomplete.css 3247//>>css.theme: ../../themes/base/theme.css 3248 3249 3250$.widget( "ui.autocomplete", { 3251 version: "1.13.2
vendor: 16,586 bytes, lines 3251-3886
3251", 3252 defaultElement: "<input>", 3253 options: { 3254 appendTo: null, 3255 autoFocus: false, 3256 delay: 300, 3257 minLength: 1, 3258 position: { 3259 my: "left top", 3260 at: "left bottom", 3261 collision: "none" 3262 }, 3263 source: null, 3264 3265 // Callbacks 3266 change: null, 3267 close: null, 3268 focus: null, 3269 open: null, 3270 response: null, 3271 search: null, 3272 select: null 3273 }, 3274 3275 requestIndex: 0, 3276 pending: 0, 3277 liveRegionTimer: null, 3278 3279 _create: function() { 3280 3281 // Some browsers only repeat keydown events, not keypress events, 3282 // so we use the suppressKeyPress flag to determine if we've already 3283 // handled the keydown event. #7269 3284 // Unfortunately the code for & in keypress is the same as the up arrow, 3285 // so we use the suppressKeyPressRepeat flag to avoid handling keypress 3286 // events when we know the keydown event was used to modify the 3287 // search term. #7799 3288 var suppressKeyPress, suppressKeyPressRepeat, suppressInput, 3289 nodeName = this.element[ 0 ].nodeName.toLowerCase(), 3290 isTextarea = nodeName === "textarea", 3291 isInput = nodeName === "input"; 3292 3293 // Textareas are always multi-line 3294 // Inputs are always single-line, even if inside a contentEditable element 3295 // IE also treats inputs as contentEditable 3296 // All other element types are determined by whether or not they're contentEditable 3297 this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element ); 3298 3299 this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ]; 3300 this.isNewMenu = true; 3301 3302 this._addClass( "ui-autocomplete-input" ); 3303 this.element.attr( "autocomplete", "off" ); 3304 3305 this._on( this.element, { 3306 keydown: function( event ) { 3307 if ( this.element.prop( "readOnly" ) ) { 3308 suppressKeyPress = true; 3309 suppressInput = true; 3310 suppressKeyPressRepeat = true; 3311 return; 3312 } 3313 3314 suppressKeyPress = false; 3315 suppressInput = false; 3316 suppressKeyPressRepeat = false; 3317 var keyCode = $.ui.keyCode; 3318 switch ( event.keyCode ) { 3319 case keyCode.PAGE_UP: 3320 suppressKeyPress = true; 3321 this._move( "previousPage", event ); 3322 break; 3323 case keyCode.PAGE_DOWN: 3324 suppressKeyPress = true; 3325 this._move( "nextPage", event ); 3326 break; 3327 case keyCode.UP: 3328 suppressKeyPress = true; 3329 this._keyEvent( "previous", event ); 3330 break; 3331 case keyCode.DOWN: 3332 suppressKeyPress = true; 3333 this._keyEvent( "next", event ); 3334 break; 3335 case keyCode.ENTER: 3336 3337 // when menu is open and has focus 3338 if ( this.menu.active ) { 3339 3340 // #6055 - Opera still allows the keypress to occur 3341 // which causes forms to submit 3342 suppressKeyPress = true; 3343 event.preventDefault(); 3344 this.menu.select( event ); 3345 } 3346 break; 3347 case keyCode.TAB: 3348 if ( this.menu.active ) { 3349 this.menu.select( event ); 3350 } 3351 break; 3352 case keyCode.ESCAPE: 3353 if ( this.menu.element.is( ":visible" ) ) { 3354 if ( !this.isMultiLine ) { 3355 this._value( this.term ); 3356 } 3357 this.close( event ); 3358 3359 // Different browsers have different default behavior for escape 3360 // Single press can mean undo or clear 3361 // Double press in IE means clear the whole form 3362 event.preventDefault(); 3363 } 3364 break; 3365 default: 3366 suppressKeyPressRepeat = true; 3367 3368 // search timeout should be triggered before the input value is changed 3369 this._searchTimeout( event ); 3370 break; 3371 } 3372 }, 3373 keypress: function( event ) { 3374 if ( suppressKeyPress ) { 3375 suppressKeyPress = false; 3376 if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) { 3377 event.preventDefault(); 3378 } 3379 return; 3380 } 3381 if ( suppressKeyPressRepeat ) { 3382 return; 3383 } 3384 3385 // Replicate some key handlers to allow them to repeat in Firefox and Opera 3386 var keyCode = $.ui.keyCode; 3387 switch ( event.keyCode ) { 3388 case keyCode.PAGE_UP: 3389 this._move( "previousPage", event ); 3390 break; 3391 case keyCode.PAGE_DOWN: 3392 this._move( "nextPage", event ); 3393 break; 3394 case keyCode.UP: 3395 this._keyEvent( "previous", event ); 3396 break; 3397 case keyCode.DOWN: 3398 this._keyEvent( "next", event ); 3399 break; 3400 } 3401 }, 3402 input: function( event ) { 3403 if ( suppressInput ) { 3404 suppressInput = false; 3405 event.preventDefault(); 3406 return; 3407 } 3408 this._searchTimeout( event ); 3409 }, 3410 focus: function() { 3411 this.selectedItem = null; 3412 this.previous = this._value(); 3413 }, 3414 blur: function( event ) { 3415 clearTimeout( this.searching ); 3416 this.close( event ); 3417 this._change( event ); 3418 } 3419 } ); 3420 3421 this._initSource(); 3422 this.menu = $( "<ul>" ) 3423 .appendTo( this._appendTo() ) 3424 .menu( { 3425 3426 // disable ARIA support, the live region takes care of that 3427 role: null 3428 } ) 3429 .hide() 3430 3431 // Support: IE 11 only, Edge <= 14 3432 // For other browsers, we preventDefault() on the mousedown event 3433 // to keep the dropdown from taking focus from the input. This doesn't 3434 // work for IE/Edge, causing problems with selection and scrolling (#9638) 3435 // Happily, IE and Edge support an "unselectable" attribute that 3436 // prevents an element from receiving focus, exactly what we want here. 3437 .attr( { 3438 "unselectable": "on" 3439 } ) 3440 .menu( "instance" ); 3441 3442 this._addClass( this.menu.element, "ui-autocomplete", "ui-front" ); 3443 this._on( this.menu.element, { 3444 mousedown: function( event ) { 3445 3446 // Prevent moving focus out of the text field 3447 event.preventDefault(); 3448 }, 3449 menufocus: function( event, ui ) { 3450 var label, item; 3451 3452 // support: Firefox 3453 // Prevent accidental activation of menu items in Firefox (#7024 #9118) 3454 if ( this.isNewMenu ) { 3455 this.isNewMenu = false; 3456 if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) { 3457 this.menu.blur(); 3458 3459 this.document.one( "mousemove", function() { 3460 $( event.target ).trigger( event.originalEvent ); 3461 } ); 3462 3463 return; 3464 } 3465 } 3466 3467 item = ui.item.data( "ui-autocomplete-item" ); 3468 if ( false !== this._trigger( "focus", event, { item: item } ) ) { 3469 3470 // use value to match what will end up in the input, if it was a key event 3471 if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) { 3472 this._value( item.value ); 3473 } 3474 } 3475 3476 // Announce the value in the liveRegion 3477 label = ui.item.attr( "aria-label" ) || item.value; 3478 if ( label && String.prototype.trim.call( label ).length ) { 3479 clearTimeout( this.liveRegionTimer ); 3480 this.liveRegionTimer = this._delay( function() { 3481 this.liveRegion.html( $( "<div>" ).text( label ) ); 3482 }, 100 ); 3483 } 3484 }, 3485 menuselect: function( event, ui ) { 3486 var item = ui.item.data( "ui-autocomplete-item" ), 3487 previous = this.previous; 3488 3489 // Only trigger when focus was lost (click on menu) 3490 if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) { 3491 this.element.trigger( "focus" ); 3492 this.previous = previous; 3493 3494 // #6109 - IE triggers two focus events and the second 3495 // is asynchronous, so we need to reset the previous 3496 // term synchronously and asynchronously :-( 3497 this._delay( function() { 3498 this.previous = previous; 3499 this.selectedItem = item; 3500 } ); 3501 } 3502 3503 if ( false !== this._trigger( "select", event, { item: item } ) ) { 3504 this._value( item.value ); 3505 } 3506 3507 // reset the term after the select event 3508 // this allows custom select handling to work properly 3509 this.term = this._value(); 3510 3511 this.close( event ); 3512 this.selectedItem = item; 3513 } 3514 } ); 3515 3516 this.liveRegion = $( "<div>", { 3517 role: "status", 3518 "aria-live": "assertive", 3519 "aria-relevant": "additions" 3520 } ) 3521 .appendTo( this.document[ 0 ].body ); 3522 3523 this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" ); 3524 3525 // Turning off autocomplete prevents the browser from remembering the 3526 // value when navigating through history, so we re-enable autocomplete 3527 // if the page is unloaded before the widget is destroyed. #7790 3528 this._on( this.window, { 3529 beforeunload: function() { 3530 this.element.removeAttr( "autocomplete" ); 3531 } 3532 } ); 3533 }, 3534 3535 _destroy: function() { 3536 clearTimeout( this.searching ); 3537 this.element.removeAttr( "autocomplete" ); 3538 this.menu.element.remove(); 3539 this.liveRegion.remove(); 3540 }, 3541 3542 _setOption: function( key, value ) { 3543 this._super( key, value ); 3544 if ( key === "source" ) { 3545 this._initSource(); 3546 } 3547 if ( key === "appendTo" ) { 3548 this.menu.element.appendTo( this._appendTo() ); 3549 } 3550 if ( key === "disabled" && value && this.xhr ) { 3551 this.xhr.abort(); 3552 } 3553 }, 3554 3555 _isEventTargetInWidget: function( event ) { 3556 var menuElement = this.menu.element[ 0 ]; 3557 3558 return event.target === this.element[ 0 ] || 3559 event.target === menuElement || 3560 $.contains( menuElement, event.target ); 3561 }, 3562 3563 _closeOnClickOutside: function( event ) { 3564 if ( !this._isEventTargetInWidget( event ) ) { 3565 this.close(); 3566 } 3567 }, 3568 3569 _appendTo: function() { 3570 var element = this.options.appendTo; 3571 3572 if ( element ) { 3573 element = element.jquery || element.nodeType ? 3574 $( element ) : 3575 this.document.find( element ).eq( 0 ); 3576 } 3577 3578 if ( !element || !element[ 0 ] ) { 3579 element = this.element.closest( ".ui-front, dialog" ); 3580 } 3581 3582 if ( !element.length ) { 3583 element = this.document[ 0 ].body; 3584 } 3585 3586 return element; 3587 }, 3588 3589 _initSource: function() { 3590 var array, url, 3591 that = this; 3592 if ( Array.isArray( this.options.source ) ) { 3593 array = this.options.source; 3594 this.source = function( request, response ) { 3595 response( $.ui.autocomplete.filter( array, request.term ) ); 3596 }; 3597 } else if ( typeof this.options.source === "string" ) { 3598 url = this.options.source; 3599 this.source = function( request, response ) { 3600 if ( that.xhr ) { 3601 that.xhr.abort(); 3602 } 3603 that.xhr = $.ajax( { 3604 url: url, 3605 data: request, 3606 dataType: "json", 3607 success: function( data ) { 3608 response( data ); 3609 }, 3610 error: function() { 3611 response( [] ); 3612 } 3613 } ); 3614 }; 3615 } else { 3616 this.source = this.options.source; 3617 } 3618 }, 3619 3620 _searchTimeout: function( event ) { 3621 clearTimeout( this.searching ); 3622 this.searching = this._delay( function() { 3623 3624 // Search if the value has changed, or if the user retypes the same value (see #7434) 3625 var equalValues = this.term === this._value(), 3626 menuVisible = this.menu.element.is( ":visible" ), 3627 modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey; 3628 3629 if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) { 3630 this.selectedItem = null; 3631 this.search( null, event ); 3632 } 3633 }, this.options.delay ); 3634 }, 3635 3636 search: function( value, event ) { 3637 value = value != null ? value : this._value(); 3638 3639 // Always save the actual value, not the one passed as an argument 3640 this.term = this._value(); 3641 3642 if ( value.length < this.options.minLength ) { 3643 return this.close( event ); 3644 } 3645 3646 if ( this._trigger( "search", event ) === false ) { 3647 return; 3648 } 3649 3650 return this._search( value ); 3651 }, 3652 3653 _search: function( value ) { 3654 this.pending++; 3655 this._addClass( "ui-autocomplete-loading" ); 3656 this.cancelSearch = false; 3657 3658 this.source( { term: value }, this._response() ); 3659 }, 3660 3661 _response: function() { 3662 var index = ++this.requestIndex; 3663 3664 return function( content ) { 3665 if ( index === this.requestIndex ) { 3666 this.__response( content ); 3667 } 3668 3669 this.pending--; 3670 if ( !this.pending ) { 3671 this._removeClass( "ui-autocomplete-loading" ); 3672 } 3673 }.bind( this ); 3674 }, 3675 3676 __response: function( content ) { 3677 if ( content ) { 3678 content = this._normalize( content ); 3679 } 3680 this._trigger( "response", null, { content: content } ); 3681 if ( !this.options.disabled && content && content.length && !this.cancelSearch ) { 3682 this._suggest( content ); 3683 this._trigger( "open" ); 3684 } else { 3685 3686 // use ._close() instead of .close() so we don't cancel future searches 3687 this._close(); 3688 } 3689 }, 3690 3691 close: function( event ) { 3692 this.cancelSearch = true; 3693 this._close( event ); 3694 }, 3695 3696 _close: function( event ) { 3697 3698 // Remove the handler that closes the menu on outside clicks 3699 this._off( this.document, "mousedown" ); 3700 3701 if ( this.menu.element.is( ":visible" ) ) { 3702 this.menu.element.hide(); 3703 this.menu.blur(); 3704 this.isNewMenu = true; 3705 this._trigger( "close", event ); 3706 } 3707 }, 3708 3709 _change: function( event ) { 3710 if ( this.previous !== this._value() ) { 3711 this._trigger( "change", event, { item: this.selectedItem } ); 3712 } 3713 }, 3714 3715 _normalize: function( items ) { 3716 3717 // assume all items have the right format when the first item is complete 3718 if ( items.length && items[ 0 ].label && items[ 0 ].value ) { 3719 return items; 3720 } 3721 return $.map( items, function( item ) { 3722 if ( typeof item === "string" ) { 3723 return { 3724 label: item, 3725 value: item 3726 }; 3727 } 3728 return $.extend( {}, item, { 3729 label: item.label || item.value, 3730 value: item.value || item.label 3731 } ); 3732 } ); 3733 }, 3734 3735 _suggest: function( items ) { 3736 var ul = this.menu.element.empty(); 3737 this._renderMenu( ul, items ); 3738 this.isNewMenu = true; 3739 this.menu.refresh(); 3740 3741 // Size and position menu 3742 ul.show(); 3743 this._resizeMenu(); 3744 ul.position( $.extend( { 3745 of: this.element 3746 }, this.options.position ) ); 3747 3748 if ( this.options.autoFocus ) { 3749 this.menu.next(); 3750 } 3751 3752 // Listen for interactions outside of the widget (#6642) 3753 this._on( this.document, { 3754 mousedown: "_closeOnClickOutside" 3755 } ); 3756 }, 3757 3758 _resizeMenu: function() { 3759 var ul = this.menu.element; 3760 ul.outerWidth( Math.max( 3761 3762 // Firefox wraps long text (possibly a rounding bug) 3763 // so we add 1px to avoid the wrapping (#7513) 3764 ul.width( "" ).outerWidth() + 1, 3765 this.element.outerWidth() 3766 ) ); 3767 }, 3768 3769 _renderMenu: function( ul, items ) { 3770 var that = this; 3771 $.each( items, function( index, item ) { 3772 that._renderItemData( ul, item ); 3773 } ); 3774 }, 3775 3776 _renderItemData: function( ul, item ) { 3777 return this._renderItem( ul, item ).data( "ui-autocomplete-item", item ); 3778 }, 3779 3780 _renderItem: function( ul, item ) { 3781 return $( "<li>" ) 3782 .append( $( "<div>" ).text( item.label ) ) 3783 .appendTo( ul ); 3784 }, 3785 3786 _move: function( direction, event ) { 3787 if ( !this.menu.element.is( ":visible" ) ) { 3788 this.search( null, event ); 3789 return; 3790 } 3791 if ( this.menu.isFirstItem() && /^previous/.test( direction ) || 3792 this.menu.isLastItem() && /^next/.test( direction ) ) { 3793 3794 if ( !this.isMultiLine ) { 3795 this._value( this.term ); 3796 } 3797 3798 this.menu.blur(); 3799 return; 3800 } 3801 this.menu[ direction ]( event ); 3802 }, 3803 3804 widget: function() { 3805 return this.menu.element; 3806 }, 3807 3808 _value: function() { 3809 return this.valueMethod.apply( this.element, arguments ); 3810 }, 3811 3812 _keyEvent: function( keyEvent, event ) { 3813 if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) { 3814 this._move( keyEvent, event ); 3815 3816 // Prevents moving cursor to beginning/end of the text field in some browsers 3817 event.preventDefault(); 3818 } 3819 }, 3820 3821 // Support: Chrome <=50 3822 // We should be able to just use this.element.prop( "isContentEditable" ) 3823 // but hidden elements always report false in Chrome. 3824 // https://code.google.com/p/chromium/issues/detail?id=313082 3825 _isContentEditable: function( element ) { 3826 if ( !element.length ) { 3827 return false; 3828 } 3829 3830 var editable = element.prop( "contentEditable" ); 3831 3832 if ( editable === "inherit" ) { 3833 return this._isContentEditable( element.parent() ); 3834 } 3835 3836 return editable === "true"; 3837 } 3838} ); 3839 3840$.extend( $.ui.autocomplete, { 3841 escapeRegex: function( value ) { 3842 return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ); 3843 }, 3844 filter: function( array, term ) { 3845 var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" ); 3846 return $.grep( array, function( value ) { 3847 return matcher.test( value.label || value.value || value ); 3848 } ); 3849 } 3850} ); 3851 3852// Live region extension, adding a `messages` option 3853// NOTE: This is an experimental API. We are still investigating 3854// a full solution for string manipulation and internationalization. 3855$.widget( "ui.autocomplete", $.ui.autocomplete, { 3856 options: { 3857 messages: { 3858 noResults: "No search results.", 3859 results: function( amount ) { 3860 return amount + ( amount > 1 ? " results are" : " result is" ) + 3861 " available, use up and down arrow keys to navigate."; 3862 } 3863 } 3864 }, 3865 3866 __response: function( content ) { 3867 var message; 3868 this._superApply( arguments ); 3869 if ( this.options.disabled || this.cancelSearch ) { 3870 return; 3871 } 3872 if ( content && content.length ) { 3873 message = this.options.messages.results( content.length ); 3874 } else { 3875 message = this.options.messages.noResults; 3876 } 3877 clearTimeout( this.liveRegionTimer ); 3878 this.liveRegionTimer = this._delay( function() { 3879 this.liveRegion.html( $( "<div>" ).text( message ) ); 3880 }, 100 ); 3881 } 3882} ); 3883 3884var widgetsAutocomplete = $.ui.autocomplete; 3885 3886
3887 3888 3889} );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.