1var PUBG_GL_DOCS = { 2 setupSwagger: function () { 3 try { 4 var $swaggerContainer = $('.swagger-doc'); 5 if (!$swaggerContainer) { 6 return; 7 } 8 var currentLocale = $('#current-locale').data('locale'); 9 var filePath = "/" + currentLocale + "/_static/swagger/" + currentLocale + "/" + $swaggerContainer.data('swaggerdoc'); 10 var id = $swaggerContainer.attr('id'); 11 if (!filePath) { 12 return; 13 } 14 15 // Build a system 16 const ui = SwaggerUIBundle({ 17 url: filePath, 18 dom_id: '#' + id, 19 deepLinking: true, 20 presets: [ 21 SwaggerUIBundle.presets.apis, 22 SwaggerUIStandalonePreset 23 ], 24 // plugins: [ 25 // SwaggerUIBundle.plugins.DownloadUrl 26 // ], 27 // layout: "StandaloneLayout" 28 }) 29 30 window.ui = ui 31 } catch (ex) { 32 console.error(ex); 33 } 34 }, 35 36 cleanupMenu: function () { 37 // hack to get around sphinx inserting empty ul tags 38 $('ul').each(function () { 39 if (!$(this).has('li').length) $(this).toggle(); 40 }); 41 }, 42 43 setLocale: function (localeKey) { 44 var currentLocale = $('#current-locale').data('locale'); 45 window.location = window.location.href.replace('/' + currentLocale + '/', '/' + localeKey + '/'); 46 }, 47 48 handleLocalization: function () { 49 $('#locale-select') 50 .chosen({ disable_search: true }) 51 .change(function () { 52 PUBG_GL_DOCS.setLocale($(this).val()); 53 }); 54 55 $('.burger-locale-select a').click(function () { 56 PUBG_GL_DOCS.setLocale($(this).parent('li').data('locale-option')); 57 }) 58 }, 59 60 verifyRoute: function () { 61 //redirect for playbattlegrounds.com to pubg.com 62 63 if (window.location.hostname == "documentation.playbattlegrounds.com"){ 64 window.location.replace("https://documentation.pubg.com" + window.location.pathname); 65 } 66 67 // if the route tells us to to open the login modal... OPEN IT 68 var location = window.location.hash.substr(1); 69 if (location && location.match(/open-login-modal/)) { 70 openLogin(); 71 } 72 }, 73 74 checkLoginModal: function () { 75 $('#log-in-tab').attr('src', 'https://developer.pubg.com/simple_login?_param=' + Date.now()); 76 $('#sign-up-tab').attr('src', 'https://developer.pubg.com/simple_create_account?_param=' + Date.now()); 77 78 $('#logSignBtn').click(function () { 79 $('html').addClass('modal-open'); 80 $('#logSign').addClass('open'); 81 }); 82 83 $('.modal .close, .modal').click(function () { 84 $('.modal').removeClass('open'); 85 $('html').removeClass('modal-open'); 86 }); 87 88 $('.modal .inner').click(function (e) { e.stopPropagation(); }); 89 90 $('ul.tabs li, .tab-accordion-heading').click(function () { 91 $('.tab-content, ul.tabs li, .tab-accordion-heading').removeClass('active'); 92 var $this = $(this); 93 var activeTab = $this.attr("rel"); 94 $("#" + activeTab).addClass('active'); 95 $(this).addClass("active"); 96 $(".tab-accordion-heading[rel^='" + activeTab + "'], ul.tabs li[rel^='" + activeTab + "']").addClass("active"); 97 $('#' + $this.data('tab')).addClass('active') 98 }); 99 100 window.addEventListener('message', function (e) { 101 if (e && e.data === 'GL-User-Authed') { 102 $('#logSign').remove(); 103 $('#log-sign-link').attr('href', 'https://developer.pubg.com'); 104 } 105 }, false); 106 107 if (location.protocol !== 'https:') { 108 var $btn = $('#logSignBtn'); 109 $btn.unbind('click'); 110 $btn.parent('a').attr('href', 'https://developer.pubg.com'); 111 } 112 }, 113 114 enableBurger: function () { 115 $('#burger').click(function () { 116 $(this).toggleClass('open'); 117 $(this).addClass('close'); 118 $('html').toggleClass('menu-open'); 119 }); 120 }, 121 122 initMobileNav: function () { 123 $( ".sphinxsidebar .toctree-l1.current" ).clone().appendTo( ".mobileNav ul" ); 124 $( ".mobileNav ul ul").remove(); 125 }, 126 127 clickMobileNav: function () { 128 $('.mobileNav').click(function () { 129 $(this).toggleClass('mobileNavExpanded'); 130 $('.sphinxsidebar').toggleClass('mobileNavExpanded'); 131 }); 132 }, 133 134 assetsTosAlert: function () { 135 $('.tosAlert').click(function(event) { 136 event.preventDefault(); 137 if (window.confirm("By continuing, you agree to use the provided assets according to the Terms of Service.")) { 138 window.location.href = "https://github.com/pubg/api-assets"; 139 } 140 }); 141 } 142}; 143 144$(function () { 145 PUBG_GL_DOCS.verifyRoute(); 146 PUBG_GL_DOCS.setupSwagger(); 147 PUBG_GL_DOCS.cleanupMenu(); 148 PUBG_GL_DOCS.handleLocalization(); 149 PUBG_GL_DOCS.checkLoginModal(); 150 PUBG_GL_DOCS.enableBurger(); 151 PUBG_GL_DOCS.initMobileNav(); 152 PUBG_GL_DOCS.clickMobileNav(); 153 PUBG_GL_DOCS.assetsTosAlert(); 154}); 155 156 157/*! 158Chosen, a Select Box Enhancer for jQuery and Prototype 159by Patrick Filler for Harvest, http://getharvest.com 160 161Version 1.8.3 162Full source at https://github.com/harvesthq/chosen 163Copyright (c) 2011-2018 Harvest http://getharvest.com 164 165MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md 166This file is generated by `grunt build`, do not edit it by hand. 167*/ 168(function () { 169 var $, AbstractChosen, Chosen, SelectParser, 170 bind = function (fn, me) { return function () { return fn.apply(me, arguments); }; }, 171 extend = function (child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, 172 hasProp = {}.hasOwnProperty; 173 174 SelectParser = (function () { 175 function SelectParser() { 176 this.options_index = 0; 177 this.parsed = []; 178 } 179 180 SelectParser.prototype.add_node = function (child) { 181 if (child.nodeName.toUpperCase() === "OPTGROUP") { 182 return this.add_group(child); 183 } else { 184 return this.add_option(child); 185 } 186 }; 187 188 SelectParser.prototype.add_group = function (group) { 189 var group_position, i, len, option, ref, results1; 190 group_position = this.parsed.length; 191 this.parsed.push({ 192 array_index: group_position, 193 group: true, 194 label: group.label, 195 title: group.title ? group.title : void 0, 196 children: 0, 197 disabled: group.disabled, 198 classes: group.className 199 }); 200 ref = group.childNodes; 201 results1 = []; 202 for (i = 0, len = ref.length; i < len; i++) { 203 option = ref[i]; 204 results1.push(this.add_option(option, group_position, group.disabled)); 205 } 206 return results1; 207 }; 208 209 SelectParser.prototype.add_option = function (option, group_position, group_disabled) { 210 if (option.nodeName.toUpperCase() === "OPTION") { 211 if (option.text !== "") { 212 if (group_position != null) { 213 this.parsed[group_position].children += 1; 214 } 215 this.parsed.push({ 216 array_index: this.parsed.length, 217 options_index: this.options_index, 218 value: option.value, 219 text: option.text, 220 html: option.innerHTML, 221 title: option.title ? option.title : void 0, 222 selected: option.selected, 223 disabled: group_disabled === true ? group_disabled : option.disabled, 224 group_array_index: group_position, 225 group_label: group_position != null ? this.parsed[group_position].label : null, 226 classes: option.className, 227 style: option.style.cssText 228 }); 229 } else { 230 this.parsed.push({ 231 array_index: this.parsed.length, 232 options_index: this.options_index, 233 empty: true 234 }); 235 } 236 return this.options_index += 1; 237 } 238 }; 239 240 return SelectParser; 241 242 })(); 243 244 SelectParser.select_to_array = function (select) { 245 var child, i, len, parser, ref;
vendor: 40,354 bytes, lines 246-1511
246 parser = new SelectParser(); 247 ref = select.childNodes; 248 for (i = 0, len = ref.length; i < len; i++) { 249 child = ref[i]; 250 parser.add_node(child); 251 } 252 return parser.parsed; 253 }; 254 255 AbstractChosen = (function () { 256 function AbstractChosen(form_field, options1) { 257 this.form_field = form_field; 258 this.options = options1 != null ? options1 : {}; 259 this.label_click_handler = bind(this.label_click_handler, this); 260 if (!AbstractChosen.browser_is_supported()) { 261 return; 262 } 263 this.is_multiple = this.form_field.multiple; 264 this.set_default_text(); 265 this.set_default_values(); 266 this.setup(); 267 this.set_up_html(); 268 this.register_observers(); 269 this.on_ready(); 270 } 271 272 AbstractChosen.prototype.set_default_values = function () { 273 this.click_test_action = (function (_this) { 274 return function (evt) { 275 return _this.test_active_click(evt); 276 }; 277 })(this); 278 this.activate_action = (function (_this) { 279 return function (evt) { 280 return _this.activate_field(evt); 281 }; 282 })(this); 283 this.active_field = false; 284 this.mouse_on_container = false; 285 this.results_showing = false; 286 this.result_highlighted = null; 287 this.is_rtl = this.options.rtl || /\bchosen-rtl\b/.test(this.form_field.className); 288 this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false; 289 this.disable_search_threshold = this.options.disable_search_threshold || 0; 290 this.disable_search = this.options.disable_search || false; 291 this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true; 292 this.group_search = this.options.group_search != null ? this.options.group_search : true; 293 this.search_contains = this.options.search_contains || false; 294 this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true; 295 this.max_selected_options = this.options.max_selected_options || Infinity; 296 this.inherit_select_classes = this.options.inherit_select_classes || false; 297 this.display_selected_options = this.options.display_selected_options != null ? this.options.display_selected_options : true; 298 this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true; 299 this.include_group_label_in_selected = this.options.include_group_label_in_selected || false; 300 this.max_shown_results = this.options.max_shown_results || Number.POSITIVE_INFINITY; 301 this.case_sensitive_search = this.options.case_sensitive_search || false; 302 return this.hide_results_on_select = this.options.hide_results_on_select != null ? this.options.hide_results_on_select : true; 303 }; 304 305 AbstractChosen.prototype.set_default_text = function () { 306 if (this.form_field.getAttribute("data-placeholder")) { 307 this.default_text = this.form_field.getAttribute("data-placeholder"); 308 } else if (this.is_multiple) { 309 this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text; 310 } else { 311 this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text; 312 } 313 this.default_text = this.escape_html(this.default_text); 314 return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text; 315 }; 316 317 AbstractChosen.prototype.choice_label = function (item) { 318 if (this.include_group_label_in_selected && (item.group_label != null)) { 319 return "<b class='group-name'>" + item.group_label + "</b>" + item.html; 320 } else { 321 return item.html; 322 } 323 }; 324 325 AbstractChosen.prototype.mouse_enter = function () { 326 return this.mouse_on_container = true; 327 }; 328 329 AbstractChosen.prototype.mouse_leave = function () { 330 return this.mouse_on_container = false; 331 }; 332 333 AbstractChosen.prototype.input_focus = function (evt) { 334 if (this.is_multiple) { 335 if (!this.active_field) { 336 return setTimeout(((function (_this) { 337 return function () { 338 return _this.container_mousedown(); 339 }; 340 })(this)), 50); 341 } 342 } else { 343 if (!this.active_field) { 344 return this.activate_field(); 345 } 346 } 347 }; 348 349 AbstractChosen.prototype.input_blur = function (evt) { 350 if (!this.mouse_on_container) { 351 this.active_field = false; 352 return setTimeout(((function (_this) { 353 return function () { 354 return _this.blur_test(); 355 }; 356 })(this)), 100); 357 } 358 }; 359 360 AbstractChosen.prototype.label_click_handler = function (evt) { 361 if (this.is_multiple) { 362 return this.container_mousedown(evt); 363 } else { 364 return this.activate_field(); 365 } 366 }; 367 368 AbstractChosen.prototype.results_option_build = function (options) { 369 var content, data, data_content, i, len, ref, shown_results; 370 content = ''; 371 shown_results = 0; 372 ref = this.results_data; 373 for (i = 0, len = ref.length; i < len; i++) { 374 data = ref[i]; 375 data_content = ''; 376 if (data.group) { 377 data_content = this.result_add_group(data); 378 } else { 379 data_content = this.result_add_option(data); 380 } 381 if (data_content !== '') { 382 shown_results++; 383 content += data_content; 384 } 385 if (options != null ? options.first : void 0) { 386 if (data.selected && this.is_multiple) { 387 this.choice_build(data); 388 } else if (data.selected && !this.is_multiple) { 389 this.single_set_selected_text(this.choice_label(data)); 390 } 391 } 392 if (shown_results >= this.max_shown_results) { 393 break; 394 } 395 } 396 return content; 397 }; 398 399 AbstractChosen.prototype.result_add_option = function (option) { 400 var classes, option_el; 401 if (!option.search_match) { 402 return ''; 403 } 404 if (!this.include_option_in_results(option)) { 405 return ''; 406 } 407 classes = []; 408 if (!option.disabled && !(option.selected && this.is_multiple)) { 409 classes.push("active-result"); 410 } 411 if (option.disabled && !(option.selected && this.is_multiple)) { 412 classes.push("disabled-result"); 413 } 414 if (option.selected) { 415 classes.push("result-selected"); 416 } 417 if (option.group_array_index != null) { 418 classes.push("group-option"); 419 } 420 if (option.classes !== "") { 421 classes.push(option.classes); 422 } 423 option_el = document.createElement("li"); 424 option_el.className = classes.join(" "); 425 option_el.style.cssText = option.style; 426 option_el.setAttribute("data-option-array-index", option.array_index); 427 option_el.innerHTML = option.highlighted_html || option.html; 428 if (option.title) { 429 option_el.title = option.title; 430 } 431 return this.outerHTML(option_el); 432 }; 433 434 AbstractChosen.prototype.result_add_group = function (group) { 435 var classes, group_el; 436 if (!(group.search_match || group.group_match)) { 437 return ''; 438 } 439 if (!(group.active_options > 0)) { 440 return ''; 441 } 442 classes = []; 443 classes.push("group-result"); 444 if (group.classes) { 445 classes.push(group.classes); 446 } 447 group_el = document.createElement("li"); 448 group_el.className = classes.join(" "); 449 group_el.innerHTML = group.highlighted_html || this.escape_html(group.label); 450 if (group.title) { 451 group_el.title = group.title; 452 } 453 return this.outerHTML(group_el); 454 }; 455 456 AbstractChosen.prototype.results_update_field = function () { 457 this.set_default_text(); 458 if (!this.is_multiple) { 459 this.results_reset_cleanup(); 460 } 461 this.result_clear_highlight(); 462 this.results_build(); 463 if (this.results_showing) { 464 return this.winnow_results(); 465 } 466 }; 467 468 AbstractChosen.prototype.reset_single_select_options = function () { 469 var i, len, ref, result, results1; 470 ref = this.results_data; 471 results1 = []; 472 for (i = 0, len = ref.length; i < len; i++) { 473 result = ref[i]; 474 if (result.selected) { 475 results1.push(result.selected = false); 476 } else { 477 results1.push(void 0); 478 } 479 } 480 return results1; 481 }; 482 483 AbstractChosen.prototype.results_toggle = function () { 484 if (this.results_showing) { 485 return this.results_hide(); 486 } else { 487 return this.results_show(); 488 } 489 }; 490 491 AbstractChosen.prototype.results_search = function (evt) { 492 if (this.results_showing) { 493 return this.winnow_results(); 494 } else { 495 return this.results_show(); 496 } 497 }; 498 499 AbstractChosen.prototype.winnow_results = function () { 500 var escapedQuery, fix, i, len, option, prefix, query, ref, regex, results, results_group, search_match, startpos, suffix, text; 501 this.no_results_clear(); 502 results = 0; 503 query = this.get_search_text(); 504 escapedQuery = query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); 505 regex = this.get_search_regex(escapedQuery); 506 ref = this.results_data; 507 for (i = 0, len = ref.length; i < len; i++) { 508 option = ref[i]; 509 option.search_match = false; 510 results_group = null; 511 search_match = null; 512 option.highlighted_html = ''; 513 if (this.include_option_in_results(option)) { 514 if (option.group) { 515 option.group_match = false; 516 option.active_options = 0; 517 } 518 if ((option.group_array_index != null) && this.results_data[option.group_array_index]) { 519 results_group = this.results_data[option.group_array_index]; 520 if (results_group.active_options === 0 && results_group.search_match) { 521 results += 1; 522 } 523 results_group.active_options += 1; 524 } 525 text = option.group ? option.label : option.text; 526 if (!(option.group && !this.group_search)) { 527 search_match = this.search_string_match(text, regex); 528 option.search_match = search_match != null; 529 if (option.search_match && !option.group) { 530 results += 1; 531 } 532 if (option.search_match) { 533 if (query.length) { 534 startpos = search_match.index; 535 prefix = text.slice(0, startpos); 536 fix = text.slice(startpos, startpos + query.length); 537 suffix = text.slice(startpos + query.length); 538 option.highlighted_html = (this.escape_html(prefix)) + "<em>" + (this.escape_html(fix)) + "</em>" + (this.escape_html(suffix)); 539 } 540 if (results_group != null) { 541 results_group.group_match = true; 542 } 543 } else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) { 544 option.search_match = true; 545 } 546 } 547 } 548 } 549 this.result_clear_highlight(); 550 if (results < 1 && query.length) { 551 this.update_results_content(""); 552 return this.no_results(query); 553 } else { 554 this.update_results_content(this.results_option_build()); 555 return this.winnow_results_set_highlight(); 556 } 557 }; 558 559 AbstractChosen.prototype.get_search_regex = function (escaped_search_string) { 560 var regex_flag, regex_string; 561 regex_string = this.search_contains ? escaped_search_string : "(^|\\s|\\b)" + escaped_search_string + "[^\\s]*"; 562 if (!(this.enable_split_word_search || this.search_contains)) { 563 regex_string = "^" + regex_string; 564 } 565 regex_flag = this.case_sensitive_search ? "" : "i"; 566 return new RegExp(regex_string, regex_flag); 567 }; 568 569 AbstractChosen.prototype.search_string_match = function (search_string, regex) { 570 var match; 571 match = regex.exec(search_string); 572 if (!this.search_contains && (match != null ? match[1] : void 0)) { 573 match.index += 1; 574 } 575 return match; 576 }; 577 578 AbstractChosen.prototype.choices_count = function () { 579 var i, len, option, ref; 580 if (this.selected_option_count != null) { 581 return this.selected_option_count; 582 } 583 this.selected_option_count = 0; 584 ref = this.form_field.options; 585 for (i = 0, len = ref.length; i < len; i++) { 586 option = ref[i]; 587 if (option.selected) { 588 this.selected_option_count += 1; 589 } 590 } 591 return this.selected_option_count; 592 }; 593 594 AbstractChosen.prototype.choices_click = function (evt) { 595 evt.preventDefault(); 596 this.activate_field(); 597 if (!(this.results_showing || this.is_disabled)) { 598 return this.results_show(); 599 } 600 }; 601 602 AbstractChosen.prototype.keydown_checker = function (evt) { 603 var ref, stroke; 604 stroke = (ref = evt.which) != null ? ref : evt.keyCode; 605 this.search_field_scale(); 606 if (stroke !== 8 && this.pending_backstroke) { 607 this.clear_backstroke(); 608 } 609 switch (stroke) { 610 case 8: 611 this.backstroke_length = this.get_search_field_value().length; 612 break; 613 case 9: 614 if (this.results_showing && !this.is_multiple) { 615 this.result_select(evt); 616 } 617 this.mouse_on_container = false; 618 break; 619 case 13: 620 if (this.results_showing) { 621 evt.preventDefault(); 622 } 623 break; 624 case 27: 625 if (this.results_showing) { 626 evt.preventDefault(); 627 } 628 break; 629 case 32: 630 if (this.disable_search) { 631 evt.preventDefault(); 632 } 633 break; 634 case 38: 635 evt.preventDefault(); 636 this.keyup_arrow(); 637 break; 638 case 40: 639 evt.preventDefault(); 640 this.keydown_arrow(); 641 break; 642 } 643 }; 644 645 AbstractChosen.prototype.keyup_checker = function (evt) { 646 var ref, stroke; 647 stroke = (ref = evt.which) != null ? ref : evt.keyCode; 648 this.search_field_scale(); 649 switch (stroke) { 650 case 8: 651 if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) { 652 this.keydown_backstroke(); 653 } else if (!this.pending_backstroke) { 654 this.result_clear_highlight(); 655 this.results_search(); 656 } 657 break; 658 case 13: 659 evt.preventDefault(); 660 if (this.results_showing) { 661 this.result_select(evt); 662 } 663 break; 664 case 27: 665 if (this.results_showing) { 666 this.results_hide(); 667 } 668 break; 669 case 9: 670 case 16: 671 case 17: 672 case 18: 673 case 38: 674 case 40: 675 case 91: 676 break; 677 default: 678 this.results_search(); 679 break; 680 } 681 }; 682 683 AbstractChosen.prototype.clipboard_event_checker = function (evt) { 684 if (this.is_disabled) { 685 return; 686 } 687 return setTimeout(((function (_this) { 688 return function () { 689 return _this.results_search(); 690 }; 691 })(this)), 50); 692 }; 693 694 AbstractChosen.prototype.container_width = function () { 695 if (this.options.width != null) { 696 return this.options.width; 697 } else { 698 return this.form_field.offsetWidth + "px"; 699 } 700 }; 701 702 AbstractChosen.prototype.include_option_in_results = function (option) { 703 if (this.is_multiple && (!this.display_selected_options && option.selected)) { 704 return false; 705 } 706 if (!this.display_disabled_options && option.disabled) { 707 return false; 708 } 709 if (option.empty) { 710 return false; 711 } 712 return true; 713 }; 714 715 AbstractChosen.prototype.search_results_touchstart = function (evt) { 716 this.touch_started = true; 717 return this.search_results_mouseover(evt); 718 }; 719 720 AbstractChosen.prototype.search_results_touchmove = function (evt) { 721 this.touch_started = false; 722 return this.search_results_mouseout(evt); 723 }; 724 725 AbstractChosen.prototype.search_results_touchend = function (evt) { 726 if (this.touch_started) { 727 return this.search_results_mouseup(evt); 728 } 729 }; 730 731 AbstractChosen.prototype.outerHTML = function (element) { 732 var tmp; 733 if (element.outerHTML) { 734 return element.outerHTML; 735 } 736 tmp = document.createElement("div"); 737 tmp.appendChild(element); 738 return tmp.innerHTML; 739 }; 740 741 AbstractChosen.prototype.get_single_html = function () { 742 return "<a class=\"chosen-single chosen-default\">\n <input class=\"chosen-search-input\" type=\"text\" autocomplete=\"off\" />\n <span>" + this.default_text + "</span>\n <div><b></b></div>\n</a>\n<div class=\"chosen-drop\">\n <div class=\"chosen-search\">\n </div>\n <ul class=\"chosen-results\"></ul>\n</div>"; 743 }; 744 745 AbstractChosen.prototype.get_multi_html = function () { 746 return "<ul class=\"chosen-choices\">\n <li class=\"search-field\">\n <input class=\"chosen-search-input\" type=\"text\" autocomplete=\"off\" value=\"" + this.default_text + "\" />\n </li>\n</ul>\n<div class=\"chosen-drop\">\n <ul class=\"chosen-results\"></ul>\n</div>"; 747 }; 748 749 AbstractChosen.prototype.get_no_results_html = function (terms) { 750 return "<li class=\"no-results\">\n " + this.results_none_found + " <span>" + (this.escape_html(terms)) + "</span>\n</li>"; 751 }; 752 753 AbstractChosen.browser_is_supported = function () { 754 if ("Microsoft Internet Explorer" === window.navigator.appName) { 755 return document.documentMode >= 8; 756 } 757 if (/iP(od|hone)/i.test(window.navigator.userAgent) || /IEMobile/i.test(window.navigator.userAgent) || /Windows Phone/i.test(window.navigator.userAgent) || /BlackBerry/i.test(window.navigator.userAgent) || /BB10/i.test(window.navigator.userAgent) || /Android.*Mobile/i.test(window.navigator.userAgent)) { 758 return false; 759 } 760 return true; 761 }; 762 763 AbstractChosen.default_multiple_text = "Select Some Options"; 764 765 AbstractChosen.default_single_text = "Select an Option"; 766 767 AbstractChosen.default_no_result_text = "No results match"; 768 769 return AbstractChosen; 770 771 })(); 772 773 $ = jQuery; 774 775 $.fn.extend({ 776 chosen: function (options) { 777 if (!AbstractChosen.browser_is_supported()) { 778 return this; 779 } 780 return this.each(function (input_field) { 781 var $this, chosen; 782 $this = $(this); 783 chosen = $this.data('chosen'); 784 if (options === 'destroy') { 785 if (chosen instanceof Chosen) { 786 chosen.destroy(); 787 } 788 return; 789 } 790 if (!(chosen instanceof Chosen)) { 791 $this.data('chosen', new Chosen(this, options)); 792 } 793 }); 794 } 795 }); 796 797 Chosen = (function (superClass) { 798 extend(Chosen, superClass); 799 800 function Chosen() { 801 return Chosen.__super__.constructor.apply(this, arguments); 802 } 803 804 Chosen.prototype.setup = function () { 805 this.form_field_jq = $(this.form_field); 806 return this.current_selectedIndex = this.form_field.selectedIndex; 807 }; 808 809 Chosen.prototype.set_up_html = function () { 810 var container_classes, container_props; 811 container_classes = ["chosen-container"]; 812 container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single")); 813 if (this.inherit_select_classes && this.form_field.className) { 814 container_classes.push(this.form_field.className); 815 } 816 if (this.is_rtl) { 817 container_classes.push("chosen-rtl"); 818 } 819 container_props = { 820 'class': container_classes.join(' '), 821 'title': this.form_field.title 822 }; 823 if (this.form_field.id.length) { 824 container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen"; 825 } 826 this.container = $("<div />", container_props); 827 this.container.width(this.container_width()); 828 if (this.is_multiple) { 829 this.container.html(this.get_multi_html()); 830 } else { 831 this.container.html(this.get_single_html()); 832 } 833 this.form_field_jq.hide().after(this.container); 834 this.dropdown = this.container.find('div.chosen-drop').first(); 835 this.search_field = this.container.find('input').first(); 836 this.search_results = this.container.find('ul.chosen-results').first(); 837 this.search_field_scale(); 838 this.search_no_results = this.container.find('li.no-results').first(); 839 if (this.is_multiple) { 840 this.search_choices = this.container.find('ul.chosen-choices').first(); 841 this.search_container = this.container.find('li.search-field').first(); 842 } else { 843 this.search_container = this.container.find('div.chosen-search').first(); 844 this.selected_item = this.container.find('.chosen-single').first(); 845 } 846 this.results_build(); 847 this.set_tab_index(); 848 return this.set_label_behavior(); 849 }; 850 851 Chosen.prototype.on_ready = function () { 852 return this.form_field_jq.trigger("chosen:ready", { 853 chosen: this 854 }); 855 }; 856 857 Chosen.prototype.register_observers = function () { 858 this.container.on('touchstart.chosen', (function (_this) { 859 return function (evt) { 860 _this.container_mousedown(evt); 861 }; 862 })(this)); 863 this.container.on('touchend.chosen', (function (_this) { 864 return function (evt) { 865 _this.container_mouseup(evt); 866 }; 867 })(this)); 868 this.container.on('mousedown.chosen', (function (_this) { 869 return function (evt) { 870 _this.container_mousedown(evt); 871 }; 872 })(this)); 873 this.container.on('mouseup.chosen', (function (_this) { 874 return function (evt) { 875 _this.container_mouseup(evt); 876 }; 877 })(this)); 878 this.container.on('mouseenter.chosen', (function (_this) { 879 return function (evt) { 880 _this.mouse_enter(evt); 881 }; 882 })(this)); 883 this.container.on('mouseleave.chosen', (function (_this) { 884 return function (evt) { 885 _this.mouse_leave(evt); 886 }; 887 })(this)); 888 this.search_results.on('mouseup.chosen', (function (_this) { 889 return function (evt) { 890 _this.search_results_mouseup(evt); 891 }; 892 })(this)); 893 this.search_results.on('mouseover.chosen', (function (_this) { 894 return function (evt) { 895 _this.search_results_mouseover(evt); 896 }; 897 })(this)); 898 this.search_results.on('mouseout.chosen', (function (_this) { 899 return function (evt) { 900 _this.search_results_mouseout(evt); 901 }; 902 })(this)); 903 this.search_results.on('mousewheel.chosen DOMMouseScroll.chosen', (function (_this) { 904 return function (evt) { 905 _this.search_results_mousewheel(evt); 906 }; 907 })(this)); 908 this.search_results.on('touchstart.chosen', (function (_this) { 909 return function (evt) { 910 _this.search_results_touchstart(evt); 911 }; 912 })(this)); 913 this.search_results.on('touchmove.chosen', (function (_this) { 914 return function (evt) { 915 _this.search_results_touchmove(evt); 916 }; 917 })(this)); 918 this.search_results.on('touchend.chosen', (function (_this) { 919 return function (evt) { 920 _this.search_results_touchend(evt); 921 }; 922 })(this)); 923 this.form_field_jq.on("chosen:updated.chosen", (function (_this) { 924 return function (evt) { 925 _this.results_update_field(evt); 926 }; 927 })(this)); 928 this.form_field_jq.on("chosen:activate.chosen", (function (_this) { 929 return function (evt) { 930 _this.activate_field(evt); 931 }; 932 })(this)); 933 this.form_field_jq.on("chosen:open.chosen", (function (_this) { 934 return function (evt) { 935 _this.container_mousedown(evt); 936 }; 937 })(this)); 938 this.form_field_jq.on("chosen:close.chosen", (function (_this) { 939 return function (evt) { 940 _this.close_field(evt); 941 }; 942 })(this)); 943 this.search_field.on('blur.chosen', (function (_this) { 944 return function (evt) { 945 _this.input_blur(evt); 946 }; 947 })(this)); 948 this.search_field.on('keyup.chosen', (function (_this) { 949 return function (evt) { 950 _this.keyup_checker(evt); 951 }; 952 })(this)); 953 this.search_field.on('keydown.chosen', (function (_this) { 954 return function (evt) { 955 _this.keydown_checker(evt); 956 }; 957 })(this)); 958 this.search_field.on('focus.chosen', (function (_this) { 959 return function (evt) { 960 _this.input_focus(evt); 961 }; 962 })(this)); 963 this.search_field.on('cut.chosen', (function (_this) { 964 return function (evt) { 965 _this.clipboard_event_checker(evt); 966 }; 967 })(this)); 968 this.search_field.on('paste.chosen', (function (_this) { 969 return function (evt) { 970 _this.clipboard_event_checker(evt); 971 }; 972 })(this)); 973 if (this.is_multiple) { 974 return this.search_choices.on('click.chosen', (function (_this) { 975 return function (evt) { 976 _this.choices_click(evt); 977 }; 978 })(this)); 979 } else { 980 return this.container.on('click.chosen', function (evt) { 981 evt.preventDefault(); 982 }); 983 } 984 }; 985 986 Chosen.prototype.destroy = function () { 987 $(this.container[0].ownerDocument).off('click.chosen', this.click_test_action); 988 if (this.form_field_label.length > 0) { 989 this.form_field_label.off('click.chosen'); 990 } 991 if (this.search_field[0].tabIndex) { 992 this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex; 993 } 994 this.container.remove(); 995 this.form_field_jq.removeData('chosen'); 996 return this.form_field_jq.show(); 997 }; 998 999 Chosen.prototype.search_field_disabled = function () { 1000 this.is_disabled = this.form_field.disabled || this.form_field_jq.parents('fieldset').is(':disabled'); 1001 this.container.toggleClass('chosen-disabled', this.is_disabled); 1002 this.search_field[0].disabled = this.is_disabled; 1003 if (!this.is_multiple) { 1004 this.selected_item.off('focus.chosen', this.activate_field); 1005 } 1006 if (this.is_disabled) { 1007 return this.close_field(); 1008 } else if (!this.is_multiple) { 1009 return this.selected_item.on('focus.chosen', this.activate_field); 1010 } 1011 }; 1012 1013 Chosen.prototype.container_mousedown = function (evt) { 1014 var ref; 1015 if (this.is_disabled) { 1016 return; 1017 } 1018 if (evt && ((ref = evt.type) === 'mousedown' || ref === 'touchstart') && !this.results_showing) { 1019 evt.preventDefault(); 1020 } 1021 if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) { 1022 if (!this.active_field) { 1023 if (this.is_multiple) { 1024 this.search_field.val(""); 1025 } 1026 $(this.container[0].ownerDocument).on('click.chosen', this.click_test_action); 1027 this.results_show(); 1028 } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) { 1029 evt.preventDefault(); 1030 this.results_toggle(); 1031 } 1032 return this.activate_field(); 1033 } 1034 }; 1035 1036 Chosen.prototype.container_mouseup = function (evt) { 1037 if (evt.target.nodeName === "ABBR" && !this.is_disabled) { 1038 return this.results_reset(evt); 1039 } 1040 }; 1041 1042 Chosen.prototype.search_results_mousewheel = function (evt) { 1043 var delta; 1044 if (evt.originalEvent) { 1045 delta = evt.originalEvent.deltaY || -evt.originalEvent.wheelDelta || evt.originalEvent.detail; 1046 } 1047 if (delta != null) { 1048 evt.preventDefault(); 1049 if (evt.type === 'DOMMouseScroll') { 1050 delta = delta * 40; 1051 } 1052 return this.search_results.scrollTop(delta + this.search_results.scrollTop()); 1053 } 1054 }; 1055 1056 Chosen.prototype.blur_test = function (evt) { 1057 if (!this.active_field && this.container.hasClass("chosen-container-active")) { 1058 return this.close_field(); 1059 } 1060 }; 1061 1062 Chosen.prototype.close_field = function () { 1063 $(this.container[0].ownerDocument).off("click.chosen", this.click_test_action); 1064 this.active_field = false; 1065 this.results_hide(); 1066 this.container.removeClass("chosen-container-active"); 1067 this.clear_backstroke(); 1068 this.show_search_field_default(); 1069 this.search_field_scale(); 1070 return this.search_field.blur(); 1071 }; 1072 1073 Chosen.prototype.activate_field = function () { 1074 if (this.is_disabled) { 1075 return; 1076 } 1077 this.container.addClass("chosen-container-active"); 1078 this.active_field = true; 1079 this.search_field.val(this.search_field.val()); 1080 return this.search_field.focus(); 1081 }; 1082 1083 Chosen.prototype.test_active_click = function (evt) { 1084 var active_container; 1085 active_container = $(evt.target).closest('.chosen-container'); 1086 if (active_container.length && this.container[0] === active_container[0]) { 1087 return this.active_field = true; 1088 } else { 1089 return this.close_field(); 1090 } 1091 }; 1092 1093 Chosen.prototype.results_build = function () { 1094 this.parsing = true; 1095 this.selected_option_count = null; 1096 this.results_data = SelectParser.select_to_array(this.form_field); 1097 if (this.is_multiple) { 1098 this.search_choices.find("li.search-choice").remove(); 1099 } else if (!this.is_multiple) { 1100 this.single_set_selected_text(); 1101 if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) { 1102 this.search_field[0].readOnly = true; 1103 this.container.addClass("chosen-container-single-nosearch"); 1104 } else { 1105 this.search_field[0].readOnly = false; 1106 this.container.removeClass("chosen-container-single-nosearch"); 1107 } 1108 } 1109 this.update_results_content(this.results_option_build({ 1110 first: true 1111 })); 1112 this.search_field_disabled(); 1113 this.show_search_field_default(); 1114 this.search_field_scale(); 1115 return this.parsing = false; 1116 }; 1117 1118 Chosen.prototype.result_do_highlight = function (el) { 1119 var high_bottom, high_top, maxHeight, visible_bottom, visible_top; 1120 if (el.length) { 1121 this.result_clear_highlight(); 1122 this.result_highlight = el; 1123 this.result_highlight.addClass("highlighted"); 1124 maxHeight = parseInt(this.search_results.css("maxHeight"), 10); 1125 visible_top = this.search_results.scrollTop(); 1126 visible_bottom = maxHeight + visible_top; 1127 high_top = this.result_highlight.position().top + this.search_results.scrollTop(); 1128 high_bottom = high_top + this.result_highlight.outerHeight(); 1129 if (high_bottom >= visible_bottom) { 1130 return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0); 1131 } else if (high_top < visible_top) { 1132 return this.search_results.scrollTop(high_top); 1133 } 1134 } 1135 }; 1136 1137 Chosen.prototype.result_clear_highlight = function () { 1138 if (this.result_highlight) { 1139 this.result_highlight.removeClass("highlighted"); 1140 } 1141 return this.result_highlight = null; 1142 }; 1143 1144 Chosen.prototype.results_show = function () { 1145 if (this.is_multiple && this.max_selected_options <= this.choices_count()) { 1146 this.form_field_jq.trigger("chosen:maxselected", { 1147 chosen: this 1148 }); 1149 return false; 1150 } 1151 if (!this.is_multiple) { 1152 this.search_container.append(this.search_field); 1153 } 1154 this.container.addClass("chosen-with-drop"); 1155 this.results_showing = true; 1156 this.search_field.focus(); 1157 this.search_field.val(this.get_search_field_value()); 1158 this.winnow_results(); 1159 return this.form_field_jq.trigger("chosen:showing_dropdown", { 1160 chosen: this 1161 }); 1162 }; 1163 1164 Chosen.prototype.update_results_content = function (content) { 1165 return this.search_results.html(content); 1166 }; 1167 1168 Chosen.prototype.results_hide = function () { 1169 if (this.results_showing) { 1170 this.result_clear_highlight(); 1171 if (!this.is_multiple) { 1172 this.selected_item.prepend(this.search_field); 1173 this.search_field.focus(); 1174 } 1175 this.container.removeClass("chosen-with-drop"); 1176 this.form_field_jq.trigger("chosen:hiding_dropdown", { 1177 chosen: this 1178 }); 1179 } 1180 return this.results_showing = false; 1181 }; 1182 1183 Chosen.prototype.set_tab_index = function (el) { 1184 var ti; 1185 if (this.form_field.tabIndex) { 1186 ti = this.form_field.tabIndex; 1187 this.form_field.tabIndex = -1; 1188 return this.search_field[0].tabIndex = ti; 1189 } 1190 }; 1191 1192 Chosen.prototype.set_label_behavior = function () { 1193 this.form_field_label = this.form_field_jq.parents("label"); 1194 if (!this.form_field_label.length && this.form_field.id.length) { 1195 this.form_field_label = $("label[for='" + this.form_field.id + "']"); 1196 } 1197 if (this.form_field_label.length > 0) { 1198 return this.form_field_label.on('click.chosen', this.label_click_handler); 1199 } 1200 }; 1201 1202 Chosen.prototype.show_search_field_default = function () { 1203 if (this.is_multiple && this.choices_count() < 1 && !this.active_field) { 1204 this.search_field.val(this.default_text); 1205 return this.search_field.addClass("default"); 1206 } else { 1207 this.search_field.val(""); 1208 return this.search_field.removeClass("default"); 1209 } 1210 }; 1211 1212 Chosen.prototype.search_results_mouseup = function (evt) { 1213 var target; 1214 target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first(); 1215 if (target.length) { 1216 this.result_highlight = target; 1217 this.result_select(evt); 1218 return this.search_field.focus(); 1219 } 1220 }; 1221 1222 Chosen.prototype.search_results_mouseover = function (evt) { 1223 var target; 1224 target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first(); 1225 if (target) { 1226 return this.result_do_highlight(target); 1227 } 1228 }; 1229 1230 Chosen.prototype.search_results_mouseout = function (evt) { 1231 if ($(evt.target).hasClass("active-result") || $(evt.target).parents('.active-result').first()) { 1232 return this.result_clear_highlight(); 1233 } 1234 }; 1235 1236 Chosen.prototype.choice_build = function (item) { 1237 var choice, close_link; 1238 choice = $('<li />', { 1239 "class": "search-choice" 1240 }).html("<span>" + (this.choice_label(item)) + "</span>"); 1241 if (item.disabled) { 1242 choice.addClass('search-choice-disabled'); 1243 } else { 1244 close_link = $('<a />', { 1245 "class": 'search-choice-close', 1246 'data-option-array-index': item.array_index 1247 }); 1248 close_link.on('click.chosen', (function (_this) { 1249 return function (evt) { 1250 return _this.choice_destroy_link_click(evt); 1251 }; 1252 })(this)); 1253 choice.append(close_link); 1254 } 1255 return this.search_container.before(choice); 1256 }; 1257 1258 Chosen.prototype.choice_destroy_link_click = function (evt) { 1259 evt.preventDefault(); 1260 evt.stopPropagation(); 1261 if (!this.is_disabled) { 1262 return this.choice_destroy($(evt.target)); 1263 } 1264 }; 1265 1266 Chosen.prototype.choice_destroy = function (link) { 1267 if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) { 1268 if (this.active_field) { 1269 this.search_field.focus(); 1270 } else { 1271 this.show_search_field_default(); 1272 } 1273 if (this.is_multiple && this.choices_count() > 0 && this.get_search_field_value().length < 1) { 1274 this.results_hide(); 1275 } 1276 link.parents('li').first().remove(); 1277 return this.search_field_scale(); 1278 } 1279 }; 1280 1281 Chosen.prototype.results_reset = function () { 1282 this.reset_single_select_options(); 1283 this.form_field.options[0].selected = true; 1284 this.single_set_selected_text(); 1285 this.show_search_field_default(); 1286 this.results_reset_cleanup(); 1287 this.trigger_form_field_change(); 1288 if (this.active_field) { 1289 return this.results_hide(); 1290 } 1291 }; 1292 1293 Chosen.prototype.results_reset_cleanup = function () { 1294 this.current_selectedIndex = this.form_field.selectedIndex; 1295 return this.selected_item.find("abbr").remove(); 1296 }; 1297 1298 Chosen.prototype.result_select = function (evt) { 1299 var high, item; 1300 if (this.result_highlight) { 1301 high = this.result_highlight; 1302 this.result_clear_highlight(); 1303 if (this.is_multiple && this.max_selected_options <= this.choices_count()) { 1304 this.form_field_jq.trigger("chosen:maxselected", { 1305 chosen: this 1306 }); 1307 return false; 1308 } 1309 if (this.is_multiple) { 1310 high.removeClass("active-result"); 1311 } else { 1312 this.reset_single_select_options(); 1313 } 1314 high.addClass("result-selected"); 1315 item = this.results_data[high[0].getAttribute("data-option-array-index")]; 1316 item.selected = true; 1317 this.form_field.options[item.options_index].selected = true; 1318 this.selected_option_count = null; 1319 this.search_field.val(""); 1320 if (this.is_multiple) { 1321 this.choice_build(item); 1322 } else { 1323 this.single_set_selected_text(this.choice_label(item)); 1324 } 1325 if (this.is_multiple && (!this.hide_results_on_select || (evt.metaKey || evt.ctrlKey))) { 1326 this.winnow_results(); 1327 } else { 1328 this.results_hide(); 1329 this.show_search_field_default(); 1330 } 1331 if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) { 1332 this.trigger_form_field_change({ 1333 selected: this.form_field.options[item.options_index].value 1334 }); 1335 } 1336 this.current_selectedIndex = this.form_field.selectedIndex; 1337 evt.preventDefault(); 1338 return this.search_field_scale(); 1339 } 1340 }; 1341 1342 Chosen.prototype.single_set_selected_text = function (text) { 1343 if (text == null) { 1344 text = this.default_text; 1345 } 1346 if (text === this.default_text) { 1347 this.selected_item.addClass("chosen-default"); 1348 } else { 1349 this.single_deselect_control_build(); 1350 this.selected_item.removeClass("chosen-default"); 1351 } 1352 return this.selected_item.find("span").html(text); 1353 }; 1354 1355 Chosen.prototype.result_deselect = function (pos) { 1356 var result_data; 1357 result_data = this.results_data[pos]; 1358 if (!this.form_field.options[result_data.options_index].disabled) { 1359 result_data.selected = false; 1360 this.form_field.options[result_data.options_index].selected = false; 1361 this.selected_option_count = null; 1362 this.result_clear_highlight(); 1363 if (this.results_showing) { 1364 this.winnow_results(); 1365 } 1366 this.trigger_form_field_change({ 1367 deselected: this.form_field.options[result_data.options_index].value 1368 }); 1369 this.search_field_scale(); 1370 return true; 1371 } else { 1372 return false; 1373 } 1374 }; 1375 1376 Chosen.prototype.single_deselect_control_build = function () { 1377 if (!this.allow_single_deselect) { 1378 return; 1379 } 1380 if (!this.selected_item.find("abbr").length) { 1381 this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>"); 1382 } 1383 return this.selected_item.addClass("chosen-single-with-deselect"); 1384 }; 1385 1386 Chosen.prototype.get_search_field_value = function () { 1387 return this.search_field.val(); 1388 }; 1389 1390 Chosen.prototype.get_search_text = function () { 1391 return $.trim(this.get_search_field_value()); 1392 }; 1393 1394 Chosen.prototype.escape_html = function (text) { 1395 return $('<div/>').text(text).html(); 1396 }; 1397 1398 Chosen.prototype.winnow_results_set_highlight = function () { 1399 var do_high, selected_results; 1400 selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : []; 1401 do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first(); 1402 if (do_high != null) { 1403 return this.result_do_highlight(do_high); 1404 } 1405 }; 1406 1407 Chosen.prototype.no_results = function (terms) { 1408 var no_results_html; 1409 no_results_html = this.get_no_results_html(terms); 1410 this.search_results.append(no_results_html); 1411 return this.form_field_jq.trigger("chosen:no_results", { 1412 chosen: this 1413 }); 1414 }; 1415 1416 Chosen.prototype.no_results_clear = function () { 1417 return this.search_results.find(".no-results").remove(); 1418 }; 1419 1420 Chosen.prototype.keydown_arrow = function () { 1421 var next_sib; 1422 if (this.results_showing && this.result_highlight) { 1423 next_sib = this.result_highlight.nextAll("li.active-result").first(); 1424 if (next_sib) { 1425 return this.result_do_highlight(next_sib); 1426 } 1427 } else { 1428 return this.results_show(); 1429 } 1430 }; 1431 1432 Chosen.prototype.keyup_arrow = function () { 1433 var prev_sibs; 1434 if (!this.results_showing && !this.is_multiple) { 1435 return this.results_show(); 1436 } else if (this.result_highlight) { 1437 prev_sibs = this.result_highlight.prevAll("li.active-result"); 1438 if (prev_sibs.length) { 1439 return this.result_do_highlight(prev_sibs.first()); 1440 } else { 1441 if (this.choices_count() > 0) { 1442 this.results_hide(); 1443 } 1444 return this.result_clear_highlight(); 1445 } 1446 } 1447 }; 1448 1449 Chosen.prototype.keydown_backstroke = function () { 1450 var next_available_destroy; 1451 if (this.pending_backstroke) { 1452 this.choice_destroy(this.pending_backstroke.find("a").first()); 1453 return this.clear_backstroke(); 1454 } else { 1455 next_available_destroy = this.search_container.siblings("li.search-choice").last(); 1456 if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) { 1457 this.pending_backstroke = next_available_destroy; 1458 if (this.single_backstroke_delete) { 1459 return this.keydown_backstroke(); 1460 } else { 1461 return this.pending_backstroke.addClass("search-choice-focus"); 1462 } 1463 } 1464 } 1465 }; 1466 1467 Chosen.prototype.clear_backstroke = function () { 1468 if (this.pending_backstroke) { 1469 this.pending_backstroke.removeClass("search-choice-focus"); 1470 } 1471 return this.pending_backstroke = null; 1472 }; 1473 1474 Chosen.prototype.search_field_scale = function () { 1475 var div, i, len, style, style_block, styles, width; 1476 if (!this.is_multiple) { 1477 return; 1478 } 1479 style_block = { 1480 position: 'absolute', 1481 left: '-1000px', 1482 top: '-1000px', 1483 display: 'none', 1484 whiteSpace: 'pre' 1485 }; 1486 styles = ['fontSize', 'fontStyle', 'fontWeight', 'fontFamily', 'lineHeight', 'textTransform', 'letterSpacing']; 1487 for (i = 0, len = styles.length; i < len; i++) { 1488 style = styles[i]; 1489 style_block[style] = this.search_field.css(style); 1490 } 1491 div = $('<div />').css(style_block); 1492 div.text(this.get_search_field_value()); 1493 $('body').append(div); 1494 width = div.width() + 25; 1495 div.remove(); 1496 if (this.container.is(':visible')) { 1497 width = Math.min(this.container.outerWidth() - 10, width); 1498 } 1499 return this.search_field.width(width); 1500 }; 1501 1502 Chosen.prototype.trigger_form_field_change = function (extra) { 1503 this.form_field_jq.trigger("input", extra); 1504 return this.form_field_jq.trigger("change", extra); 1505 }; 1506 1507 return Chosen; 1508 1509 })(AbstractChosen); 1510 1511}).call(this);
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.