Commit 8c7caaa69c8d8cb0b621e5954a19ceb20179985a
1 parent
475d9f48
Exists in
master
and in
4 other branches
use chosen-rails
Showing
5 changed files
with
7 additions
and
1321 deletions
Show diff stats
Gemfile
Gemfile.lock
| ... | ... | @@ -105,6 +105,9 @@ GEM |
| 105 | 105 | charlock_holmes (0.6.8) |
| 106 | 106 | childprocess (0.3.2) |
| 107 | 107 | ffi (~> 1.0.6) |
| 108 | + chosen-rails (0.9.8) | |
| 109 | + railties (~> 3.0) | |
| 110 | + thor (~> 0.14) | |
| 108 | 111 | coderay (1.0.6) |
| 109 | 112 | coffee-rails (3.2.2) |
| 110 | 113 | coffee-script (>= 2.2.0) |
| ... | ... | @@ -330,6 +333,7 @@ DEPENDENCIES |
| 330 | 333 | capybara |
| 331 | 334 | carrierwave |
| 332 | 335 | charlock_holmes |
| 336 | + chosen-rails | |
| 333 | 337 | coffee-rails (= 3.2.2) |
| 334 | 338 | colored |
| 335 | 339 | database_cleaner | ... | ... |
app/assets/javascripts/application.js
| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | //= require jquery.highlight |
| 15 | 15 | //= require bootstrap-modal |
| 16 | 16 | //= require modernizr |
| 17 | -//= require chosen | |
| 17 | +//= require chosen-jquery | |
| 18 | 18 | //= require raphael |
| 19 | 19 | //= require branch-graph |
| 20 | 20 | //= require_tree . |
| ... | ... | @@ -75,7 +75,7 @@ function slugify(text) { |
| 75 | 75 | return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase(); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | -function showDiff(link) { | |
| 78 | +function showDiff(link) { | |
| 79 | 79 | $(link).next('table').show(); |
| 80 | 80 | $(link).remove(); |
| 81 | 81 | } | ... | ... |
vendor/assets/javascripts/chosen.js
| ... | ... | @@ -1,952 +0,0 @@ |
| 1 | -// Chosen, a Select Box Enhancer for jQuery and Protoype | |
| 2 | -// by Patrick Filler for Harvest, http://getharvest.com | |
| 3 | -// | |
| 4 | -// Version 0.9.8 | |
| 5 | -// Full source at https://github.com/harvesthq/chosen | |
| 6 | -// Copyright (c) 2011 Harvest http://getharvest.com | |
| 7 | - | |
| 8 | -// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md | |
| 9 | -// This file is generated by `cake build`, do not edit it by hand. | |
| 10 | -(function() { | |
| 11 | - var SelectParser; | |
| 12 | - | |
| 13 | - SelectParser = (function() { | |
| 14 | - | |
| 15 | - function SelectParser() { | |
| 16 | - this.options_index = 0; | |
| 17 | - this.parsed = []; | |
| 18 | - } | |
| 19 | - | |
| 20 | - SelectParser.prototype.add_node = function(child) { | |
| 21 | - if (child.nodeName === "OPTGROUP") { | |
| 22 | - return this.add_group(child); | |
| 23 | - } else { | |
| 24 | - return this.add_option(child); | |
| 25 | - } | |
| 26 | - }; | |
| 27 | - | |
| 28 | - SelectParser.prototype.add_group = function(group) { | |
| 29 | - var group_position, option, _i, _len, _ref, _results; | |
| 30 | - group_position = this.parsed.length; | |
| 31 | - this.parsed.push({ | |
| 32 | - array_index: group_position, | |
| 33 | - group: true, | |
| 34 | - label: group.label, | |
| 35 | - children: 0, | |
| 36 | - disabled: group.disabled | |
| 37 | - }); | |
| 38 | - _ref = group.childNodes; | |
| 39 | - _results = []; | |
| 40 | - for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
| 41 | - option = _ref[_i]; | |
| 42 | - _results.push(this.add_option(option, group_position, group.disabled)); | |
| 43 | - } | |
| 44 | - return _results; | |
| 45 | - }; | |
| 46 | - | |
| 47 | - SelectParser.prototype.add_option = function(option, group_position, group_disabled) { | |
| 48 | - if (option.nodeName === "OPTION") { | |
| 49 | - if (option.text !== "") { | |
| 50 | - if (group_position != null) this.parsed[group_position].children += 1; | |
| 51 | - this.parsed.push({ | |
| 52 | - array_index: this.parsed.length, | |
| 53 | - options_index: this.options_index, | |
| 54 | - value: option.value, | |
| 55 | - text: option.text, | |
| 56 | - html: option.innerHTML, | |
| 57 | - selected: option.selected, | |
| 58 | - disabled: group_disabled === true ? group_disabled : option.disabled, | |
| 59 | - group_array_index: group_position, | |
| 60 | - classes: option.className, | |
| 61 | - style: option.style.cssText | |
| 62 | - }); | |
| 63 | - } else { | |
| 64 | - this.parsed.push({ | |
| 65 | - array_index: this.parsed.length, | |
| 66 | - options_index: this.options_index, | |
| 67 | - empty: true | |
| 68 | - }); | |
| 69 | - } | |
| 70 | - return this.options_index += 1; | |
| 71 | - } | |
| 72 | - }; | |
| 73 | - | |
| 74 | - return SelectParser; | |
| 75 | - | |
| 76 | - })(); | |
| 77 | - | |
| 78 | - SelectParser.select_to_array = function(select) { | |
| 79 | - var child, parser, _i, _len, _ref; | |
| 80 | - parser = new SelectParser(); | |
| 81 | - _ref = select.childNodes; | |
| 82 | - for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
| 83 | - child = _ref[_i]; | |
| 84 | - parser.add_node(child); | |
| 85 | - } | |
| 86 | - return parser.parsed; | |
| 87 | - }; | |
| 88 | - | |
| 89 | - this.SelectParser = SelectParser; | |
| 90 | - | |
| 91 | -}).call(this); | |
| 92 | - | |
| 93 | -/* | |
| 94 | -Chosen source: generate output using 'cake build' | |
| 95 | -Copyright (c) 2011 by Harvest | |
| 96 | -*/ | |
| 97 | - | |
| 98 | -(function() { | |
| 99 | - var AbstractChosen, root; | |
| 100 | - | |
| 101 | - root = this; | |
| 102 | - | |
| 103 | - AbstractChosen = (function() { | |
| 104 | - | |
| 105 | - function AbstractChosen(form_field, options) { | |
| 106 | - this.form_field = form_field; | |
| 107 | - this.options = options != null ? options : {}; | |
| 108 | - this.set_default_values(); | |
| 109 | - this.is_multiple = this.form_field.multiple; | |
| 110 | - this.default_text_default = this.is_multiple ? "Select Some Options" : "Select an Option"; | |
| 111 | - this.setup(); | |
| 112 | - this.set_up_html(); | |
| 113 | - this.register_observers(); | |
| 114 | - this.finish_setup(); | |
| 115 | - } | |
| 116 | - | |
| 117 | - AbstractChosen.prototype.set_default_values = function() { | |
| 118 | - var _this = this; | |
| 119 | - this.click_test_action = function(evt) { | |
| 120 | - return _this.test_active_click(evt); | |
| 121 | - }; | |
| 122 | - this.activate_action = function(evt) { | |
| 123 | - return _this.activate_field(evt); | |
| 124 | - }; | |
| 125 | - this.active_field = false; | |
| 126 | - this.mouse_on_container = false; | |
| 127 | - this.results_showing = false; | |
| 128 | - this.result_highlighted = null; | |
| 129 | - this.result_single_selected = null; | |
| 130 | - 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; | |
| 131 | - this.disable_search_threshold = this.options.disable_search_threshold || 0; | |
| 132 | - this.search_contains = this.options.search_contains || false; | |
| 133 | - this.choices = 0; | |
| 134 | - return this.results_none_found = this.options.no_results_text || "No results match"; | |
| 135 | - }; | |
| 136 | - | |
| 137 | - AbstractChosen.prototype.mouse_enter = function() { | |
| 138 | - return this.mouse_on_container = true; | |
| 139 | - }; | |
| 140 | - | |
| 141 | - AbstractChosen.prototype.mouse_leave = function() { | |
| 142 | - return this.mouse_on_container = false; | |
| 143 | - }; | |
| 144 | - | |
| 145 | - AbstractChosen.prototype.input_focus = function(evt) { | |
| 146 | - var _this = this; | |
| 147 | - if (!this.active_field) { | |
| 148 | - return setTimeout((function() { | |
| 149 | - return _this.container_mousedown(); | |
| 150 | - }), 50); | |
| 151 | - } | |
| 152 | - }; | |
| 153 | - | |
| 154 | - AbstractChosen.prototype.input_blur = function(evt) { | |
| 155 | - var _this = this; | |
| 156 | - if (!this.mouse_on_container) { | |
| 157 | - this.active_field = false; | |
| 158 | - return setTimeout((function() { | |
| 159 | - return _this.blur_test(); | |
| 160 | - }), 100); | |
| 161 | - } | |
| 162 | - }; | |
| 163 | - | |
| 164 | - AbstractChosen.prototype.result_add_option = function(option) { | |
| 165 | - var classes, style; | |
| 166 | - if (!option.disabled) { | |
| 167 | - option.dom_id = this.container_id + "_o_" + option.array_index; | |
| 168 | - classes = option.selected && this.is_multiple ? [] : ["active-result"]; | |
| 169 | - if (option.selected) classes.push("result-selected"); | |
| 170 | - if (option.group_array_index != null) classes.push("group-option"); | |
| 171 | - if (option.classes !== "") classes.push(option.classes); | |
| 172 | - style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : ""; | |
| 173 | - return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>'; | |
| 174 | - } else { | |
| 175 | - return ""; | |
| 176 | - } | |
| 177 | - }; | |
| 178 | - | |
| 179 | - AbstractChosen.prototype.results_update_field = function() { | |
| 180 | - this.result_clear_highlight(); | |
| 181 | - this.result_single_selected = null; | |
| 182 | - return this.results_build(); | |
| 183 | - }; | |
| 184 | - | |
| 185 | - AbstractChosen.prototype.results_toggle = function() { | |
| 186 | - if (this.results_showing) { | |
| 187 | - return this.results_hide(); | |
| 188 | - } else { | |
| 189 | - return this.results_show(); | |
| 190 | - } | |
| 191 | - }; | |
| 192 | - | |
| 193 | - AbstractChosen.prototype.results_search = function(evt) { | |
| 194 | - if (this.results_showing) { | |
| 195 | - return this.winnow_results(); | |
| 196 | - } else { | |
| 197 | - return this.results_show(); | |
| 198 | - } | |
| 199 | - }; | |
| 200 | - | |
| 201 | - AbstractChosen.prototype.keyup_checker = function(evt) { | |
| 202 | - var stroke, _ref; | |
| 203 | - stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; | |
| 204 | - this.search_field_scale(); | |
| 205 | - switch (stroke) { | |
| 206 | - case 8: | |
| 207 | - if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) { | |
| 208 | - return this.keydown_backstroke(); | |
| 209 | - } else if (!this.pending_backstroke) { | |
| 210 | - this.result_clear_highlight(); | |
| 211 | - return this.results_search(); | |
| 212 | - } | |
| 213 | - break; | |
| 214 | - case 13: | |
| 215 | - evt.preventDefault(); | |
| 216 | - if (this.results_showing) return this.result_select(evt); | |
| 217 | - break; | |
| 218 | - case 27: | |
| 219 | - if (this.results_showing) this.results_hide(); | |
| 220 | - return true; | |
| 221 | - case 9: | |
| 222 | - case 38: | |
| 223 | - case 40: | |
| 224 | - case 16: | |
| 225 | - case 91: | |
| 226 | - case 17: | |
| 227 | - break; | |
| 228 | - default: | |
| 229 | - return this.results_search(); | |
| 230 | - } | |
| 231 | - }; | |
| 232 | - | |
| 233 | - AbstractChosen.prototype.generate_field_id = function() { | |
| 234 | - var new_id; | |
| 235 | - new_id = this.generate_random_id(); | |
| 236 | - this.form_field.id = new_id; | |
| 237 | - return new_id; | |
| 238 | - }; | |
| 239 | - | |
| 240 | - AbstractChosen.prototype.generate_random_char = function() { | |
| 241 | - var chars, newchar, rand; | |
| 242 | - chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ"; | |
| 243 | - rand = Math.floor(Math.random() * chars.length); | |
| 244 | - return newchar = chars.substring(rand, rand + 1); | |
| 245 | - }; | |
| 246 | - | |
| 247 | - return AbstractChosen; | |
| 248 | - | |
| 249 | - })(); | |
| 250 | - | |
| 251 | - root.AbstractChosen = AbstractChosen; | |
| 252 | - | |
| 253 | -}).call(this); | |
| 254 | - | |
| 255 | -/* | |
| 256 | -Chosen source: generate output using 'cake build' | |
| 257 | -Copyright (c) 2011 by Harvest | |
| 258 | -*/ | |
| 259 | - | |
| 260 | -(function() { | |
| 261 | - var $, Chosen, get_side_border_padding, root, | |
| 262 | - __hasProp = Object.prototype.hasOwnProperty, | |
| 263 | - __extends = 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; }; | |
| 264 | - | |
| 265 | - root = this; | |
| 266 | - | |
| 267 | - $ = jQuery; | |
| 268 | - | |
| 269 | - $.fn.extend({ | |
| 270 | - chosen: function(options) { | |
| 271 | - if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) { | |
| 272 | - return this; | |
| 273 | - } | |
| 274 | - return $(this).each(function(input_field) { | |
| 275 | - if (!($(this)).hasClass("chzn-done")) return new Chosen(this, options); | |
| 276 | - }); | |
| 277 | - } | |
| 278 | - }); | |
| 279 | - | |
| 280 | - Chosen = (function(_super) { | |
| 281 | - | |
| 282 | - __extends(Chosen, _super); | |
| 283 | - | |
| 284 | - function Chosen() { | |
| 285 | - Chosen.__super__.constructor.apply(this, arguments); | |
| 286 | - } | |
| 287 | - | |
| 288 | - Chosen.prototype.setup = function() { | |
| 289 | - this.form_field_jq = $(this.form_field); | |
| 290 | - return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl"); | |
| 291 | - }; | |
| 292 | - | |
| 293 | - Chosen.prototype.finish_setup = function() { | |
| 294 | - return this.form_field_jq.addClass("chzn-done"); | |
| 295 | - }; | |
| 296 | - | |
| 297 | - Chosen.prototype.set_up_html = function() { | |
| 298 | - var container_div, dd_top, dd_width, sf_width; | |
| 299 | - this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id(); | |
| 300 | - this.container_id += "_chzn"; | |
| 301 | - this.f_width = this.form_field_jq.outerWidth(); | |
| 302 | - this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default; | |
| 303 | - container_div = $("<div />", { | |
| 304 | - id: this.container_id, | |
| 305 | - "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''), | |
| 306 | - style: 'width: ' + this.f_width + 'px;' | |
| 307 | - }); | |
| 308 | - if (this.is_multiple) { | |
| 309 | - container_div.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>'); | |
| 310 | - } else { | |
| 311 | - container_div.html('<a href="javascript:void(0)" class="chzn-single chzn-default"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'); | |
| 312 | - } | |
| 313 | - this.form_field_jq.hide().after(container_div); | |
| 314 | - this.container = $('#' + this.container_id); | |
| 315 | - this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single")); | |
| 316 | - this.dropdown = this.container.find('div.chzn-drop').first(); | |
| 317 | - dd_top = this.container.height(); | |
| 318 | - dd_width = this.f_width - get_side_border_padding(this.dropdown); | |
| 319 | - this.dropdown.css({ | |
| 320 | - "width": dd_width + "px", | |
| 321 | - "top": dd_top + "px" | |
| 322 | - }); | |
| 323 | - this.search_field = this.container.find('input').first(); | |
| 324 | - this.search_results = this.container.find('ul.chzn-results').first(); | |
| 325 | - this.search_field_scale(); | |
| 326 | - this.search_no_results = this.container.find('li.no-results').first(); | |
| 327 | - if (this.is_multiple) { | |
| 328 | - this.search_choices = this.container.find('ul.chzn-choices').first(); | |
| 329 | - this.search_container = this.container.find('li.search-field').first(); | |
| 330 | - } else { | |
| 331 | - this.search_container = this.container.find('div.chzn-search').first(); | |
| 332 | - this.selected_item = this.container.find('.chzn-single').first(); | |
| 333 | - sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field); | |
| 334 | - this.search_field.css({ | |
| 335 | - "width": sf_width + "px" | |
| 336 | - }); | |
| 337 | - } | |
| 338 | - this.results_build(); | |
| 339 | - this.set_tab_index(); | |
| 340 | - return this.form_field_jq.trigger("liszt:ready", { | |
| 341 | - chosen: this | |
| 342 | - }); | |
| 343 | - }; | |
| 344 | - | |
| 345 | - Chosen.prototype.register_observers = function() { | |
| 346 | - var _this = this; | |
| 347 | - this.container.mousedown(function(evt) { | |
| 348 | - return _this.container_mousedown(evt); | |
| 349 | - }); | |
| 350 | - this.container.mouseup(function(evt) { | |
| 351 | - return _this.container_mouseup(evt); | |
| 352 | - }); | |
| 353 | - this.container.mouseenter(function(evt) { | |
| 354 | - return _this.mouse_enter(evt); | |
| 355 | - }); | |
| 356 | - this.container.mouseleave(function(evt) { | |
| 357 | - return _this.mouse_leave(evt); | |
| 358 | - }); | |
| 359 | - this.search_results.mouseup(function(evt) { | |
| 360 | - return _this.search_results_mouseup(evt); | |
| 361 | - }); | |
| 362 | - this.search_results.mouseover(function(evt) { | |
| 363 | - return _this.search_results_mouseover(evt); | |
| 364 | - }); | |
| 365 | - this.search_results.mouseout(function(evt) { | |
| 366 | - return _this.search_results_mouseout(evt); | |
| 367 | - }); | |
| 368 | - this.form_field_jq.bind("liszt:updated", function(evt) { | |
| 369 | - return _this.results_update_field(evt); | |
| 370 | - }); | |
| 371 | - this.search_field.blur(function(evt) { | |
| 372 | - return _this.input_blur(evt); | |
| 373 | - }); | |
| 374 | - this.search_field.keyup(function(evt) { | |
| 375 | - return _this.keyup_checker(evt); | |
| 376 | - }); | |
| 377 | - this.search_field.keydown(function(evt) { | |
| 378 | - return _this.keydown_checker(evt); | |
| 379 | - }); | |
| 380 | - if (this.is_multiple) { | |
| 381 | - this.search_choices.click(function(evt) { | |
| 382 | - return _this.choices_click(evt); | |
| 383 | - }); | |
| 384 | - return this.search_field.focus(function(evt) { | |
| 385 | - return _this.input_focus(evt); | |
| 386 | - }); | |
| 387 | - } else { | |
| 388 | - return this.container.click(function(evt) { | |
| 389 | - return evt.preventDefault(); | |
| 390 | - }); | |
| 391 | - } | |
| 392 | - }; | |
| 393 | - | |
| 394 | - Chosen.prototype.search_field_disabled = function() { | |
| 395 | - this.is_disabled = this.form_field_jq[0].disabled; | |
| 396 | - if (this.is_disabled) { | |
| 397 | - this.container.addClass('chzn-disabled'); | |
| 398 | - this.search_field[0].disabled = true; | |
| 399 | - if (!this.is_multiple) { | |
| 400 | - this.selected_item.unbind("focus", this.activate_action); | |
| 401 | - } | |
| 402 | - return this.close_field(); | |
| 403 | - } else { | |
| 404 | - this.container.removeClass('chzn-disabled'); | |
| 405 | - this.search_field[0].disabled = false; | |
| 406 | - if (!this.is_multiple) { | |
| 407 | - return this.selected_item.bind("focus", this.activate_action); | |
| 408 | - } | |
| 409 | - } | |
| 410 | - }; | |
| 411 | - | |
| 412 | - Chosen.prototype.container_mousedown = function(evt) { | |
| 413 | - var target_closelink; | |
| 414 | - if (!this.is_disabled) { | |
| 415 | - target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false; | |
| 416 | - if (evt && evt.type === "mousedown" && !this.results_showing) { | |
| 417 | - evt.stopPropagation(); | |
| 418 | - } | |
| 419 | - if (!this.pending_destroy_click && !target_closelink) { | |
| 420 | - if (!this.active_field) { | |
| 421 | - if (this.is_multiple) this.search_field.val(""); | |
| 422 | - $(document).click(this.click_test_action); | |
| 423 | - this.results_show(); | |
| 424 | - } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chzn-single").length)) { | |
| 425 | - evt.preventDefault(); | |
| 426 | - this.results_toggle(); | |
| 427 | - } | |
| 428 | - return this.activate_field(); | |
| 429 | - } else { | |
| 430 | - return this.pending_destroy_click = false; | |
| 431 | - } | |
| 432 | - } | |
| 433 | - }; | |
| 434 | - | |
| 435 | - Chosen.prototype.container_mouseup = function(evt) { | |
| 436 | - if (evt.target.nodeName === "ABBR") return this.results_reset(evt); | |
| 437 | - }; | |
| 438 | - | |
| 439 | - Chosen.prototype.blur_test = function(evt) { | |
| 440 | - if (!this.active_field && this.container.hasClass("chzn-container-active")) { | |
| 441 | - return this.close_field(); | |
| 442 | - } | |
| 443 | - }; | |
| 444 | - | |
| 445 | - Chosen.prototype.close_field = function() { | |
| 446 | - $(document).unbind("click", this.click_test_action); | |
| 447 | - if (!this.is_multiple) { | |
| 448 | - this.selected_item.attr("tabindex", this.search_field.attr("tabindex")); | |
| 449 | - this.search_field.attr("tabindex", -1); | |
| 450 | - } | |
| 451 | - this.active_field = false; | |
| 452 | - this.results_hide(); | |
| 453 | - this.container.removeClass("chzn-container-active"); | |
| 454 | - this.winnow_results_clear(); | |
| 455 | - this.clear_backstroke(); | |
| 456 | - this.show_search_field_default(); | |
| 457 | - return this.search_field_scale(); | |
| 458 | - }; | |
| 459 | - | |
| 460 | - Chosen.prototype.activate_field = function() { | |
| 461 | - if (!this.is_multiple && !this.active_field) { | |
| 462 | - this.search_field.attr("tabindex", this.selected_item.attr("tabindex")); | |
| 463 | - this.selected_item.attr("tabindex", -1); | |
| 464 | - } | |
| 465 | - this.container.addClass("chzn-container-active"); | |
| 466 | - this.active_field = true; | |
| 467 | - this.search_field.val(this.search_field.val()); | |
| 468 | - return this.search_field.focus(); | |
| 469 | - }; | |
| 470 | - | |
| 471 | - Chosen.prototype.test_active_click = function(evt) { | |
| 472 | - if ($(evt.target).parents('#' + this.container_id).length) { | |
| 473 | - return this.active_field = true; | |
| 474 | - } else { | |
| 475 | - return this.close_field(); | |
| 476 | - } | |
| 477 | - }; | |
| 478 | - | |
| 479 | - Chosen.prototype.results_build = function() { | |
| 480 | - var content, data, _i, _len, _ref; | |
| 481 | - this.parsing = true; | |
| 482 | - this.results_data = root.SelectParser.select_to_array(this.form_field); | |
| 483 | - if (this.is_multiple && this.choices > 0) { | |
| 484 | - this.search_choices.find("li.search-choice").remove(); | |
| 485 | - this.choices = 0; | |
| 486 | - } else if (!this.is_multiple) { | |
| 487 | - this.selected_item.find("span").text(this.default_text); | |
| 488 | - if (this.form_field.options.length <= this.disable_search_threshold) { | |
| 489 | - this.container.addClass("chzn-container-single-nosearch"); | |
| 490 | - } else { | |
| 491 | - this.container.removeClass("chzn-container-single-nosearch"); | |
| 492 | - } | |
| 493 | - } | |
| 494 | - content = ''; | |
| 495 | - _ref = this.results_data; | |
| 496 | - for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
| 497 | - data = _ref[_i]; | |
| 498 | - if (data.group) { | |
| 499 | - content += this.result_add_group(data); | |
| 500 | - } else if (!data.empty) { | |
| 501 | - content += this.result_add_option(data); | |
| 502 | - if (data.selected && this.is_multiple) { | |
| 503 | - this.choice_build(data); | |
| 504 | - } else if (data.selected && !this.is_multiple) { | |
| 505 | - this.selected_item.removeClass("chzn-default").find("span").text(data.text); | |
| 506 | - if (this.allow_single_deselect) this.single_deselect_control_build(); | |
| 507 | - } | |
| 508 | - } | |
| 509 | - } | |
| 510 | - this.search_field_disabled(); | |
| 511 | - this.show_search_field_default(); | |
| 512 | - this.search_field_scale(); | |
| 513 | - this.search_results.html(content); | |
| 514 | - return this.parsing = false; | |
| 515 | - }; | |
| 516 | - | |
| 517 | - Chosen.prototype.result_add_group = function(group) { | |
| 518 | - if (!group.disabled) { | |
| 519 | - group.dom_id = this.container_id + "_g_" + group.array_index; | |
| 520 | - return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>'; | |
| 521 | - } else { | |
| 522 | - return ""; | |
| 523 | - } | |
| 524 | - }; | |
| 525 | - | |
| 526 | - Chosen.prototype.result_do_highlight = function(el) { | |
| 527 | - var high_bottom, high_top, maxHeight, visible_bottom, visible_top; | |
| 528 | - if (el.length) { | |
| 529 | - this.result_clear_highlight(); | |
| 530 | - this.result_highlight = el; | |
| 531 | - this.result_highlight.addClass("highlighted"); | |
| 532 | - maxHeight = parseInt(this.search_results.css("maxHeight"), 10); | |
| 533 | - visible_top = this.search_results.scrollTop(); | |
| 534 | - visible_bottom = maxHeight + visible_top; | |
| 535 | - high_top = this.result_highlight.position().top + this.search_results.scrollTop(); | |
| 536 | - high_bottom = high_top + this.result_highlight.outerHeight(); | |
| 537 | - if (high_bottom >= visible_bottom) { | |
| 538 | - return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0); | |
| 539 | - } else if (high_top < visible_top) { | |
| 540 | - return this.search_results.scrollTop(high_top); | |
| 541 | - } | |
| 542 | - } | |
| 543 | - }; | |
| 544 | - | |
| 545 | - Chosen.prototype.result_clear_highlight = function() { | |
| 546 | - if (this.result_highlight) this.result_highlight.removeClass("highlighted"); | |
| 547 | - return this.result_highlight = null; | |
| 548 | - }; | |
| 549 | - | |
| 550 | - Chosen.prototype.results_show = function() { | |
| 551 | - var dd_top; | |
| 552 | - if (!this.is_multiple) { | |
| 553 | - this.selected_item.addClass("chzn-single-with-drop"); | |
| 554 | - if (this.result_single_selected) { | |
| 555 | - this.result_do_highlight(this.result_single_selected); | |
| 556 | - } | |
| 557 | - } | |
| 558 | - dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1; | |
| 559 | - this.dropdown.css({ | |
| 560 | - "top": dd_top + "px", | |
| 561 | - "left": 0 | |
| 562 | - }); | |
| 563 | - this.results_showing = true; | |
| 564 | - this.search_field.focus(); | |
| 565 | - this.search_field.val(this.search_field.val()); | |
| 566 | - return this.winnow_results(); | |
| 567 | - }; | |
| 568 | - | |
| 569 | - Chosen.prototype.results_hide = function() { | |
| 570 | - if (!this.is_multiple) { | |
| 571 | - this.selected_item.removeClass("chzn-single-with-drop"); | |
| 572 | - } | |
| 573 | - this.result_clear_highlight(); | |
| 574 | - this.dropdown.css({ | |
| 575 | - "left": "-9000px" | |
| 576 | - }); | |
| 577 | - return this.results_showing = false; | |
| 578 | - }; | |
| 579 | - | |
| 580 | - Chosen.prototype.set_tab_index = function(el) { | |
| 581 | - var ti; | |
| 582 | - if (this.form_field_jq.attr("tabindex")) { | |
| 583 | - ti = this.form_field_jq.attr("tabindex"); | |
| 584 | - this.form_field_jq.attr("tabindex", -1); | |
| 585 | - if (this.is_multiple) { | |
| 586 | - return this.search_field.attr("tabindex", ti); | |
| 587 | - } else { | |
| 588 | - this.selected_item.attr("tabindex", ti); | |
| 589 | - return this.search_field.attr("tabindex", -1); | |
| 590 | - } | |
| 591 | - } | |
| 592 | - }; | |
| 593 | - | |
| 594 | - Chosen.prototype.show_search_field_default = function() { | |
| 595 | - if (this.is_multiple && this.choices < 1 && !this.active_field) { | |
| 596 | - this.search_field.val(this.default_text); | |
| 597 | - return this.search_field.addClass("default"); | |
| 598 | - } else { | |
| 599 | - this.search_field.val(""); | |
| 600 | - return this.search_field.removeClass("default"); | |
| 601 | - } | |
| 602 | - }; | |
| 603 | - | |
| 604 | - Chosen.prototype.search_results_mouseup = function(evt) { | |
| 605 | - var target; | |
| 606 | - target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first(); | |
| 607 | - if (target.length) { | |
| 608 | - this.result_highlight = target; | |
| 609 | - return this.result_select(evt); | |
| 610 | - } | |
| 611 | - }; | |
| 612 | - | |
| 613 | - Chosen.prototype.search_results_mouseover = function(evt) { | |
| 614 | - var target; | |
| 615 | - target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first(); | |
| 616 | - if (target) return this.result_do_highlight(target); | |
| 617 | - }; | |
| 618 | - | |
| 619 | - Chosen.prototype.search_results_mouseout = function(evt) { | |
| 620 | - if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) { | |
| 621 | - return this.result_clear_highlight(); | |
| 622 | - } | |
| 623 | - }; | |
| 624 | - | |
| 625 | - Chosen.prototype.choices_click = function(evt) { | |
| 626 | - evt.preventDefault(); | |
| 627 | - if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) { | |
| 628 | - return this.results_show(); | |
| 629 | - } | |
| 630 | - }; | |
| 631 | - | |
| 632 | - Chosen.prototype.choice_build = function(item) { | |
| 633 | - var choice_id, link, | |
| 634 | - _this = this; | |
| 635 | - choice_id = this.container_id + "_c_" + item.array_index; | |
| 636 | - this.choices += 1; | |
| 637 | - this.search_container.before('<li class="search-choice" id="' + choice_id + '"><span>' + item.html + '</span><a href="javascript:void(0)" class="search-choice-close" rel="' + item.array_index + '"></a></li>'); | |
| 638 | - link = $('#' + choice_id).find("a").first(); | |
| 639 | - return link.click(function(evt) { | |
| 640 | - return _this.choice_destroy_link_click(evt); | |
| 641 | - }); | |
| 642 | - }; | |
| 643 | - | |
| 644 | - Chosen.prototype.choice_destroy_link_click = function(evt) { | |
| 645 | - evt.preventDefault(); | |
| 646 | - if (!this.is_disabled) { | |
| 647 | - this.pending_destroy_click = true; | |
| 648 | - return this.choice_destroy($(evt.target)); | |
| 649 | - } else { | |
| 650 | - return evt.stopPropagation; | |
| 651 | - } | |
| 652 | - }; | |
| 653 | - | |
| 654 | - Chosen.prototype.choice_destroy = function(link) { | |
| 655 | - this.choices -= 1; | |
| 656 | - this.show_search_field_default(); | |
| 657 | - if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) { | |
| 658 | - this.results_hide(); | |
| 659 | - } | |
| 660 | - this.result_deselect(link.attr("rel")); | |
| 661 | - return link.parents('li').first().remove(); | |
| 662 | - }; | |
| 663 | - | |
| 664 | - Chosen.prototype.results_reset = function(evt) { | |
| 665 | - this.form_field.options[0].selected = true; | |
| 666 | - this.selected_item.find("span").text(this.default_text); | |
| 667 | - if (!this.is_multiple) this.selected_item.addClass("chzn-default"); | |
| 668 | - this.show_search_field_default(); | |
| 669 | - $(evt.target).remove(); | |
| 670 | - this.form_field_jq.trigger("change"); | |
| 671 | - if (this.active_field) return this.results_hide(); | |
| 672 | - }; | |
| 673 | - | |
| 674 | - Chosen.prototype.result_select = function(evt) { | |
| 675 | - var high, high_id, item, position; | |
| 676 | - if (this.result_highlight) { | |
| 677 | - high = this.result_highlight; | |
| 678 | - high_id = high.attr("id"); | |
| 679 | - this.result_clear_highlight(); | |
| 680 | - if (this.is_multiple) { | |
| 681 | - this.result_deactivate(high); | |
| 682 | - } else { | |
| 683 | - this.search_results.find(".result-selected").removeClass("result-selected"); | |
| 684 | - this.result_single_selected = high; | |
| 685 | - this.selected_item.removeClass("chzn-default"); | |
| 686 | - } | |
| 687 | - high.addClass("result-selected"); | |
| 688 | - position = high_id.substr(high_id.lastIndexOf("_") + 1); | |
| 689 | - item = this.results_data[position]; | |
| 690 | - item.selected = true; | |
| 691 | - this.form_field.options[item.options_index].selected = true; | |
| 692 | - if (this.is_multiple) { | |
| 693 | - this.choice_build(item); | |
| 694 | - } else { | |
| 695 | - this.selected_item.find("span").first().text(item.text); | |
| 696 | - if (this.allow_single_deselect) this.single_deselect_control_build(); | |
| 697 | - } | |
| 698 | - if (!(evt.metaKey && this.is_multiple)) this.results_hide(); | |
| 699 | - this.search_field.val(""); | |
| 700 | - this.form_field_jq.trigger("change"); | |
| 701 | - return this.search_field_scale(); | |
| 702 | - } | |
| 703 | - }; | |
| 704 | - | |
| 705 | - Chosen.prototype.result_activate = function(el) { | |
| 706 | - return el.addClass("active-result"); | |
| 707 | - }; | |
| 708 | - | |
| 709 | - Chosen.prototype.result_deactivate = function(el) { | |
| 710 | - return el.removeClass("active-result"); | |
| 711 | - }; | |
| 712 | - | |
| 713 | - Chosen.prototype.result_deselect = function(pos) { | |
| 714 | - var result, result_data; | |
| 715 | - result_data = this.results_data[pos]; | |
| 716 | - result_data.selected = false; | |
| 717 | - this.form_field.options[result_data.options_index].selected = false; | |
| 718 | - result = $("#" + this.container_id + "_o_" + pos); | |
| 719 | - result.removeClass("result-selected").addClass("active-result").show(); | |
| 720 | - this.result_clear_highlight(); | |
| 721 | - this.winnow_results(); | |
| 722 | - this.form_field_jq.trigger("change"); | |
| 723 | - return this.search_field_scale(); | |
| 724 | - }; | |
| 725 | - | |
| 726 | - Chosen.prototype.single_deselect_control_build = function() { | |
| 727 | - if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) { | |
| 728 | - return this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>"); | |
| 729 | - } | |
| 730 | - }; | |
| 731 | - | |
| 732 | - Chosen.prototype.winnow_results = function() { | |
| 733 | - var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref; | |
| 734 | - this.no_results_clear(); | |
| 735 | - results = 0; | |
| 736 | - searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html(); | |
| 737 | - regexAnchor = this.search_contains ? "" : "^"; | |
| 738 | - regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); | |
| 739 | - zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); | |
| 740 | - _ref = this.results_data; | |
| 741 | - for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
| 742 | - option = _ref[_i]; | |
| 743 | - if (!option.disabled && !option.empty) { | |
| 744 | - if (option.group) { | |
| 745 | - $('#' + option.dom_id).css('display', 'none'); | |
| 746 | - } else if (!(this.is_multiple && option.selected)) { | |
| 747 | - found = false; | |
| 748 | - result_id = option.dom_id; | |
| 749 | - result = $("#" + result_id); | |
| 750 | - if (regex.test(option.html)) { | |
| 751 | - found = true; | |
| 752 | - results += 1; | |
| 753 | - } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) { | |
| 754 | - parts = option.html.replace(/\[|\]/g, "").split(" "); | |
| 755 | - if (parts.length) { | |
| 756 | - for (_j = 0, _len2 = parts.length; _j < _len2; _j++) { | |
| 757 | - part = parts[_j]; | |
| 758 | - if (regex.test(part)) { | |
| 759 | - found = true; | |
| 760 | - results += 1; | |
| 761 | - } | |
| 762 | - } | |
| 763 | - } | |
| 764 | - } | |
| 765 | - if (found) { | |
| 766 | - if (searchText.length) { | |
| 767 | - startpos = option.html.search(zregex); | |
| 768 | - text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length); | |
| 769 | - text = text.substr(0, startpos) + '<em>' + text.substr(startpos); | |
| 770 | - } else { | |
| 771 | - text = option.html; | |
| 772 | - } | |
| 773 | - result.html(text); | |
| 774 | - this.result_activate(result); | |
| 775 | - if (option.group_array_index != null) { | |
| 776 | - $("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item'); | |
| 777 | - } | |
| 778 | - } else { | |
| 779 | - if (this.result_highlight && result_id === this.result_highlight.attr('id')) { | |
| 780 | - this.result_clear_highlight(); | |
| 781 | - } | |
| 782 | - this.result_deactivate(result); | |
| 783 | - } | |
| 784 | - } | |
| 785 | - } | |
| 786 | - } | |
| 787 | - if (results < 1 && searchText.length) { | |
| 788 | - return this.no_results(searchText); | |
| 789 | - } else { | |
| 790 | - return this.winnow_results_set_highlight(); | |
| 791 | - } | |
| 792 | - }; | |
| 793 | - | |
| 794 | - Chosen.prototype.winnow_results_clear = function() { | |
| 795 | - var li, lis, _i, _len, _results; | |
| 796 | - this.search_field.val(""); | |
| 797 | - lis = this.search_results.find("li"); | |
| 798 | - _results = []; | |
| 799 | - for (_i = 0, _len = lis.length; _i < _len; _i++) { | |
| 800 | - li = lis[_i]; | |
| 801 | - li = $(li); | |
| 802 | - if (li.hasClass("group-result")) { | |
| 803 | - _results.push(li.css('display', 'auto')); | |
| 804 | - } else if (!this.is_multiple || !li.hasClass("result-selected")) { | |
| 805 | - _results.push(this.result_activate(li)); | |
| 806 | - } else { | |
| 807 | - _results.push(void 0); | |
| 808 | - } | |
| 809 | - } | |
| 810 | - return _results; | |
| 811 | - }; | |
| 812 | - | |
| 813 | - Chosen.prototype.winnow_results_set_highlight = function() { | |
| 814 | - var do_high, selected_results; | |
| 815 | - if (!this.result_highlight) { | |
| 816 | - selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : []; | |
| 817 | - do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first(); | |
| 818 | - if (do_high != null) return this.result_do_highlight(do_high); | |
| 819 | - } | |
| 820 | - }; | |
| 821 | - | |
| 822 | - Chosen.prototype.no_results = function(terms) { | |
| 823 | - var no_results_html; | |
| 824 | - no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>'); | |
| 825 | - no_results_html.find("span").first().html(terms); | |
| 826 | - return this.search_results.append(no_results_html); | |
| 827 | - }; | |
| 828 | - | |
| 829 | - Chosen.prototype.no_results_clear = function() { | |
| 830 | - return this.search_results.find(".no-results").remove(); | |
| 831 | - }; | |
| 832 | - | |
| 833 | - Chosen.prototype.keydown_arrow = function() { | |
| 834 | - var first_active, next_sib; | |
| 835 | - if (!this.result_highlight) { | |
| 836 | - first_active = this.search_results.find("li.active-result").first(); | |
| 837 | - if (first_active) this.result_do_highlight($(first_active)); | |
| 838 | - } else if (this.results_showing) { | |
| 839 | - next_sib = this.result_highlight.nextAll("li.active-result").first(); | |
| 840 | - if (next_sib) this.result_do_highlight(next_sib); | |
| 841 | - } | |
| 842 | - if (!this.results_showing) return this.results_show(); | |
| 843 | - }; | |
| 844 | - | |
| 845 | - Chosen.prototype.keyup_arrow = function() { | |
| 846 | - var prev_sibs; | |
| 847 | - if (!this.results_showing && !this.is_multiple) { | |
| 848 | - return this.results_show(); | |
| 849 | - } else if (this.result_highlight) { | |
| 850 | - prev_sibs = this.result_highlight.prevAll("li.active-result"); | |
| 851 | - if (prev_sibs.length) { | |
| 852 | - return this.result_do_highlight(prev_sibs.first()); | |
| 853 | - } else { | |
| 854 | - if (this.choices > 0) this.results_hide(); | |
| 855 | - return this.result_clear_highlight(); | |
| 856 | - } | |
| 857 | - } | |
| 858 | - }; | |
| 859 | - | |
| 860 | - Chosen.prototype.keydown_backstroke = function() { | |
| 861 | - if (this.pending_backstroke) { | |
| 862 | - this.choice_destroy(this.pending_backstroke.find("a").first()); | |
| 863 | - return this.clear_backstroke(); | |
| 864 | - } else { | |
| 865 | - this.pending_backstroke = this.search_container.siblings("li.search-choice").last(); | |
| 866 | - return this.pending_backstroke.addClass("search-choice-focus"); | |
| 867 | - } | |
| 868 | - }; | |
| 869 | - | |
| 870 | - Chosen.prototype.clear_backstroke = function() { | |
| 871 | - if (this.pending_backstroke) { | |
| 872 | - this.pending_backstroke.removeClass("search-choice-focus"); | |
| 873 | - } | |
| 874 | - return this.pending_backstroke = null; | |
| 875 | - }; | |
| 876 | - | |
| 877 | - Chosen.prototype.keydown_checker = function(evt) { | |
| 878 | - var stroke, _ref; | |
| 879 | - stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; | |
| 880 | - this.search_field_scale(); | |
| 881 | - if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke(); | |
| 882 | - switch (stroke) { | |
| 883 | - case 8: | |
| 884 | - this.backstroke_length = this.search_field.val().length; | |
| 885 | - break; | |
| 886 | - case 9: | |
| 887 | - if (this.results_showing && !this.is_multiple) this.result_select(evt); | |
| 888 | - this.mouse_on_container = false; | |
| 889 | - break; | |
| 890 | - case 13: | |
| 891 | - evt.preventDefault(); | |
| 892 | - break; | |
| 893 | - case 38: | |
| 894 | - evt.preventDefault(); | |
| 895 | - this.keyup_arrow(); | |
| 896 | - break; | |
| 897 | - case 40: | |
| 898 | - this.keydown_arrow(); | |
| 899 | - break; | |
| 900 | - } | |
| 901 | - }; | |
| 902 | - | |
| 903 | - Chosen.prototype.search_field_scale = function() { | |
| 904 | - var dd_top, div, h, style, style_block, styles, w, _i, _len; | |
| 905 | - if (this.is_multiple) { | |
| 906 | - h = 0; | |
| 907 | - w = 0; | |
| 908 | - style_block = "position:absolute; left: -1000px; top: -1000px; display:none;"; | |
| 909 | - styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing']; | |
| 910 | - for (_i = 0, _len = styles.length; _i < _len; _i++) { | |
| 911 | - style = styles[_i]; | |
| 912 | - style_block += style + ":" + this.search_field.css(style) + ";"; | |
| 913 | - } | |
| 914 | - div = $('<div />', { | |
| 915 | - 'style': style_block | |
| 916 | - }); | |
| 917 | - div.text(this.search_field.val()); | |
| 918 | - $('body').append(div); | |
| 919 | - w = div.width() + 25; | |
| 920 | - div.remove(); | |
| 921 | - if (w > this.f_width - 10) w = this.f_width - 10; | |
| 922 | - this.search_field.css({ | |
| 923 | - 'width': w + 'px' | |
| 924 | - }); | |
| 925 | - dd_top = this.container.height(); | |
| 926 | - return this.dropdown.css({ | |
| 927 | - "top": dd_top + "px" | |
| 928 | - }); | |
| 929 | - } | |
| 930 | - }; | |
| 931 | - | |
| 932 | - Chosen.prototype.generate_random_id = function() { | |
| 933 | - var string; | |
| 934 | - string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char(); | |
| 935 | - while ($("#" + string).length > 0) { | |
| 936 | - string += this.generate_random_char(); | |
| 937 | - } | |
| 938 | - return string; | |
| 939 | - }; | |
| 940 | - | |
| 941 | - return Chosen; | |
| 942 | - | |
| 943 | - })(AbstractChosen); | |
| 944 | - | |
| 945 | - get_side_border_padding = function(elmt) { | |
| 946 | - var side_border_padding; | |
| 947 | - return side_border_padding = elmt.outerWidth() - elmt.width(); | |
| 948 | - }; | |
| 949 | - | |
| 950 | - root.get_side_border_padding = get_side_border_padding; | |
| 951 | - | |
| 952 | -}).call(this); |
vendor/assets/stylesheets/chosen.css
| ... | ... | @@ -1,367 +0,0 @@ |
| 1 | -/* @group Base */ | |
| 2 | -.chzn-container { | |
| 3 | - font-size: 13px; | |
| 4 | - position: relative; | |
| 5 | - display: inline-block; | |
| 6 | - zoom: 1; | |
| 7 | - *display: inline; | |
| 8 | -} | |
| 9 | -.chzn-container .chzn-drop { | |
| 10 | - background: #fff; | |
| 11 | - border: 1px solid #aaa; | |
| 12 | - border-top: 0; | |
| 13 | - position: absolute; | |
| 14 | - top: 29px; | |
| 15 | - left: 0; | |
| 16 | - -webkit-box-shadow: 0 4px 5px rgba(0,0,0,.15); | |
| 17 | - -moz-box-shadow : 0 4px 5px rgba(0,0,0,.15); | |
| 18 | - -o-box-shadow : 0 4px 5px rgba(0,0,0,.15); | |
| 19 | - box-shadow : 0 4px 5px rgba(0,0,0,.15); | |
| 20 | - z-index: 999; | |
| 21 | -} | |
| 22 | -/* @end */ | |
| 23 | - | |
| 24 | -/* @group Single Chosen */ | |
| 25 | -.chzn-container-single .chzn-single { | |
| 26 | - background-color: #fff; | |
| 27 | - background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(0.5, white)); | |
| 28 | - background-image: -webkit-linear-gradient(center bottom, #eeeeee 0%, white 50%); | |
| 29 | - background-image: -moz-linear-gradient(center bottom, #eeeeee 0%, white 50%); | |
| 30 | - background-image: -o-linear-gradient(top, #eeeeee 0%,#ffffff 50%); | |
| 31 | - background-image: -ms-linear-gradient(top, #eeeeee 0%,#ffffff 50%); | |
| 32 | - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff',GradientType=0 ); | |
| 33 | - background-image: linear-gradient(top, #eeeeee 0%,#ffffff 50%); | |
| 34 | - -webkit-border-radius: 4px; | |
| 35 | - -moz-border-radius : 4px; | |
| 36 | - border-radius : 4px; | |
| 37 | - -moz-background-clip : padding; | |
| 38 | - -webkit-background-clip: padding-box; | |
| 39 | - background-clip : padding-box; | |
| 40 | - border: 1px solid #aaa; | |
| 41 | - display: block; | |
| 42 | - overflow: hidden; | |
| 43 | - white-space: nowrap; | |
| 44 | - position: relative; | |
| 45 | - height: 26px; | |
| 46 | - line-height: 26px; | |
| 47 | - padding: 0 0 0 8px; | |
| 48 | - color: #444; | |
| 49 | - text-decoration: none; | |
| 50 | -} | |
| 51 | -.chzn-container-single .chzn-single span { | |
| 52 | - margin-right: 26px; | |
| 53 | - display: block; | |
| 54 | - overflow: hidden; | |
| 55 | - white-space: nowrap; | |
| 56 | - -o-text-overflow: ellipsis; | |
| 57 | - -ms-text-overflow: ellipsis; | |
| 58 | - text-overflow: ellipsis; | |
| 59 | -} | |
| 60 | -.chzn-container-single .chzn-single abbr { | |
| 61 | - display: block; | |
| 62 | - position: absolute; | |
| 63 | - right: 26px; | |
| 64 | - top: 8px; | |
| 65 | - width: 12px; | |
| 66 | - height: 13px; | |
| 67 | - font-size: 1px; | |
| 68 | - background: url(chosen-sprite.png) right top no-repeat; | |
| 69 | -} | |
| 70 | -.chzn-container-single .chzn-single abbr:hover { | |
| 71 | - background-position: right -11px; | |
| 72 | -} | |
| 73 | -.chzn-container-single .chzn-single div { | |
| 74 | - -webkit-border-radius: 0 4px 4px 0; | |
| 75 | - -moz-border-radius : 0 4px 4px 0; | |
| 76 | - border-radius : 0 4px 4px 0; | |
| 77 | - -moz-background-clip : padding; | |
| 78 | - -webkit-background-clip: padding-box; | |
| 79 | - background-clip : padding-box; | |
| 80 | - background: #ccc; | |
| 81 | - background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee)); | |
| 82 | - background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%); | |
| 83 | - background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%); | |
| 84 | - background-image: -o-linear-gradient(bottom, #ccc 0%, #eee 60%); | |
| 85 | - background-image: -ms-linear-gradient(top, #cccccc 0%,#eeeeee 60%); | |
| 86 | - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cccccc', endColorstr='#eeeeee',GradientType=0 ); | |
| 87 | - background-image: linear-gradient(top, #cccccc 0%,#eeeeee 60%); | |
| 88 | - border-left: 1px solid #aaa; | |
| 89 | - position: absolute; | |
| 90 | - right: 0; | |
| 91 | - top: 0; | |
| 92 | - display: block; | |
| 93 | - height: 100%; | |
| 94 | - width: 18px; | |
| 95 | -} | |
| 96 | -.chzn-container-single .chzn-single div b { | |
| 97 | - background: url('chosen-sprite.png') no-repeat 0 1px; | |
| 98 | - display: block; | |
| 99 | - width: 100%; | |
| 100 | - height: 100%; | |
| 101 | -} | |
| 102 | -.chzn-container-single .chzn-search { | |
| 103 | - padding: 3px 4px; | |
| 104 | - position: relative; | |
| 105 | - margin: 0; | |
| 106 | - white-space: nowrap; | |
| 107 | - z-index: 1010; | |
| 108 | -} | |
| 109 | -.chzn-container-single .chzn-search input { | |
| 110 | - background: #fff url('chosen-sprite.png') no-repeat 100% -21px; | |
| 111 | - background: url('chosen-sprite.png') no-repeat 100% -21px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee)); | |
| 112 | - background: url('chosen-sprite.png') no-repeat 100% -21px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%); | |
| 113 | - background: url('chosen-sprite.png') no-repeat 100% -21px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%); | |
| 114 | - background: url('chosen-sprite.png') no-repeat 100% -21px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%); | |
| 115 | - background: url('chosen-sprite.png') no-repeat 100% -21px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%); | |
| 116 | - background: url('chosen-sprite.png') no-repeat 100% -21px, linear-gradient(top, #ffffff 85%,#eeeeee 99%); | |
| 117 | - margin: 1px 0; | |
| 118 | - padding: 4px 20px 4px 5px; | |
| 119 | - outline: 0; | |
| 120 | - border: 1px solid #aaa; | |
| 121 | - font-family: sans-serif; | |
| 122 | - font-size: 1em; | |
| 123 | -} | |
| 124 | -.chzn-container-single .chzn-drop { | |
| 125 | - -webkit-border-radius: 0 0 4px 4px; | |
| 126 | - -moz-border-radius : 0 0 4px 4px; | |
| 127 | - border-radius : 0 0 4px 4px; | |
| 128 | - -moz-background-clip : padding; | |
| 129 | - -webkit-background-clip: padding-box; | |
| 130 | - background-clip : padding-box; | |
| 131 | -} | |
| 132 | -/* @end */ | |
| 133 | - | |
| 134 | -.chzn-container-single-nosearch .chzn-search input { | |
| 135 | - position: absolute; | |
| 136 | - left: -9000px; | |
| 137 | -} | |
| 138 | - | |
| 139 | -/* @group Multi Chosen */ | |
| 140 | -.chzn-container-multi .chzn-choices { | |
| 141 | - background-color: #fff; | |
| 142 | - background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee)); | |
| 143 | - background-image: -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%); | |
| 144 | - background-image: -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%); | |
| 145 | - background-image: -o-linear-gradient(bottom, white 85%, #eeeeee 99%); | |
| 146 | - background-image: -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%); | |
| 147 | - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee',GradientType=0 ); | |
| 148 | - background-image: linear-gradient(top, #ffffff 85%,#eeeeee 99%); | |
| 149 | - border: 1px solid #aaa; | |
| 150 | - margin: 0; | |
| 151 | - padding: 0; | |
| 152 | - cursor: text; | |
| 153 | - overflow: hidden; | |
| 154 | - height: auto !important; | |
| 155 | - height: 1%; | |
| 156 | - position: relative; | |
| 157 | -} | |
| 158 | -.chzn-container-multi .chzn-choices li { | |
| 159 | - float: left; | |
| 160 | - list-style: none; | |
| 161 | -} | |
| 162 | -.chzn-container-multi .chzn-choices .search-field { | |
| 163 | - white-space: nowrap; | |
| 164 | - margin: 0; | |
| 165 | - padding: 0; | |
| 166 | -} | |
| 167 | -.chzn-container-multi .chzn-choices .search-field input { | |
| 168 | - color: #666; | |
| 169 | - background: transparent !important; | |
| 170 | - border: 0 !important; | |
| 171 | - padding: 5px; | |
| 172 | - margin: 1px 0; | |
| 173 | - outline: 0; | |
| 174 | - -webkit-box-shadow: none; | |
| 175 | - -moz-box-shadow : none; | |
| 176 | - -o-box-shadow : none; | |
| 177 | - box-shadow : none; | |
| 178 | -} | |
| 179 | -.chzn-container-multi .chzn-choices .search-field .default { | |
| 180 | - color: #999; | |
| 181 | -} | |
| 182 | -.chzn-container-multi .chzn-choices .search-choice { | |
| 183 | - -webkit-border-radius: 3px; | |
| 184 | - -moz-border-radius : 3px; | |
| 185 | - border-radius : 3px; | |
| 186 | - -moz-background-clip : padding; | |
| 187 | - -webkit-background-clip: padding-box; | |
| 188 | - background-clip : padding-box; | |
| 189 | - background-color: #e4e4e4; | |
| 190 | - background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #e4e4e4), color-stop(0.7, #eeeeee)); | |
| 191 | - background-image: -webkit-linear-gradient(center bottom, #e4e4e4 0%, #eeeeee 70%); | |
| 192 | - background-image: -moz-linear-gradient(center bottom, #e4e4e4 0%, #eeeeee 70%); | |
| 193 | - background-image: -o-linear-gradient(bottom, #e4e4e4 0%, #eeeeee 70%); | |
| 194 | - background-image: -ms-linear-gradient(top, #e4e4e4 0%,#eeeeee 70%); | |
| 195 | - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e4e4e4', endColorstr='#eeeeee',GradientType=0 ); | |
| 196 | - background-image: linear-gradient(top, #e4e4e4 0%,#eeeeee 70%); | |
| 197 | - color: #333; | |
| 198 | - border: 1px solid #b4b4b4; | |
| 199 | - line-height: 13px; | |
| 200 | - padding: 3px 19px 3px 6px; | |
| 201 | - margin: 3px 0 3px 5px; | |
| 202 | - position: relative; | |
| 203 | -} | |
| 204 | -.chzn-container-multi .chzn-choices .search-choice span { | |
| 205 | - cursor: default; | |
| 206 | -} | |
| 207 | -.chzn-container-multi .chzn-choices .search-choice-focus { | |
| 208 | - background: #d4d4d4; | |
| 209 | -} | |
| 210 | -.chzn-container-multi .chzn-choices .search-choice .search-choice-close { | |
| 211 | - display: block; | |
| 212 | - position: absolute; | |
| 213 | - right: 3px; | |
| 214 | - top: 4px; | |
| 215 | - width: 12px; | |
| 216 | - height: 13px; | |
| 217 | - font-size: 1px; | |
| 218 | - background: url(chosen-sprite.png) right top no-repeat; | |
| 219 | -} | |
| 220 | -.chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover { | |
| 221 | - background-position: right -11px; | |
| 222 | -} | |
| 223 | -.chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close { | |
| 224 | - background-position: right -11px; | |
| 225 | -} | |
| 226 | -/* @end */ | |
| 227 | - | |
| 228 | -/* @group Results */ | |
| 229 | -.chzn-container .chzn-results { | |
| 230 | - margin: 0 4px 4px 0; | |
| 231 | - max-height: 190px; | |
| 232 | - padding: 0 0 0 4px; | |
| 233 | - position: relative; | |
| 234 | - overflow-x: hidden; | |
| 235 | - overflow-y: auto; | |
| 236 | -} | |
| 237 | -.chzn-container-multi .chzn-results { | |
| 238 | - margin: -1px 0 0; | |
| 239 | - padding: 0; | |
| 240 | -} | |
| 241 | -.chzn-container .chzn-results li { | |
| 242 | - display: none; | |
| 243 | - line-height: 80%; | |
| 244 | - padding: 7px 7px 8px; | |
| 245 | - margin: 0; | |
| 246 | - list-style: none; | |
| 247 | -} | |
| 248 | -.chzn-container .chzn-results .active-result { | |
| 249 | - cursor: pointer; | |
| 250 | - display: list-item; | |
| 251 | -} | |
| 252 | -.chzn-container .chzn-results .highlighted { | |
| 253 | - background: #3875d7; | |
| 254 | - color: #fff; | |
| 255 | -} | |
| 256 | -.chzn-container .chzn-results li em { | |
| 257 | - background: #feffde; | |
| 258 | - font-style: normal; | |
| 259 | -} | |
| 260 | -.chzn-container .chzn-results .highlighted em { | |
| 261 | - background: transparent; | |
| 262 | -} | |
| 263 | -.chzn-container .chzn-results .no-results { | |
| 264 | - background: #f4f4f4; | |
| 265 | - display: list-item; | |
| 266 | -} | |
| 267 | -.chzn-container .chzn-results .group-result { | |
| 268 | - cursor: default; | |
| 269 | - color: #999; | |
| 270 | - font-weight: bold; | |
| 271 | -} | |
| 272 | -.chzn-container .chzn-results .group-option { | |
| 273 | - padding-left: 20px; | |
| 274 | -} | |
| 275 | -.chzn-container-multi .chzn-drop .result-selected { | |
| 276 | - display: none; | |
| 277 | -} | |
| 278 | -/* @end */ | |
| 279 | - | |
| 280 | -/* @group Active */ | |
| 281 | -.chzn-container-active .chzn-single { | |
| 282 | - -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3); | |
| 283 | - -moz-box-shadow : 0 0 5px rgba(0,0,0,.3); | |
| 284 | - -o-box-shadow : 0 0 5px rgba(0,0,0,.3); | |
| 285 | - box-shadow : 0 0 5px rgba(0,0,0,.3); | |
| 286 | - border: 1px solid #5897fb; | |
| 287 | -} | |
| 288 | -.chzn-container-active .chzn-single-with-drop { | |
| 289 | - border: 1px solid #aaa; | |
| 290 | - -webkit-box-shadow: 0 1px 0 #fff inset; | |
| 291 | - -moz-box-shadow : 0 1px 0 #fff inset; | |
| 292 | - -o-box-shadow : 0 1px 0 #fff inset; | |
| 293 | - box-shadow : 0 1px 0 #fff inset; | |
| 294 | - background-color: #eee; | |
| 295 | - background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, white), color-stop(0.5, #eeeeee)); | |
| 296 | - background-image: -webkit-linear-gradient(center bottom, white 0%, #eeeeee 50%); | |
| 297 | - background-image: -moz-linear-gradient(center bottom, white 0%, #eeeeee 50%); | |
| 298 | - background-image: -o-linear-gradient(bottom, white 0%, #eeeeee 50%); | |
| 299 | - background-image: -ms-linear-gradient(top, #ffffff 0%,#eeeeee 50%); | |
| 300 | - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee',GradientType=0 ); | |
| 301 | - background-image: linear-gradient(top, #ffffff 0%,#eeeeee 50%); | |
| 302 | - -webkit-border-bottom-left-radius : 0; | |
| 303 | - -webkit-border-bottom-right-radius: 0; | |
| 304 | - -moz-border-radius-bottomleft : 0; | |
| 305 | - -moz-border-radius-bottomright: 0; | |
| 306 | - border-bottom-left-radius : 0; | |
| 307 | - border-bottom-right-radius: 0; | |
| 308 | -} | |
| 309 | -.chzn-container-active .chzn-single-with-drop div { | |
| 310 | - background: transparent; | |
| 311 | - border-left: none; | |
| 312 | -} | |
| 313 | -.chzn-container-active .chzn-single-with-drop div b { | |
| 314 | - background-position: -18px 1px; | |
| 315 | -} | |
| 316 | -.chzn-container-active .chzn-choices { | |
| 317 | - -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3); | |
| 318 | - -moz-box-shadow : 0 0 5px rgba(0,0,0,.3); | |
| 319 | - -o-box-shadow : 0 0 5px rgba(0,0,0,.3); | |
| 320 | - box-shadow : 0 0 5px rgba(0,0,0,.3); | |
| 321 | - border: 1px solid #5897fb; | |
| 322 | -} | |
| 323 | -.chzn-container-active .chzn-choices .search-field input { | |
| 324 | - color: #111 !important; | |
| 325 | -} | |
| 326 | -/* @end */ | |
| 327 | - | |
| 328 | -/* @group Disabled Support */ | |
| 329 | -.chzn-disabled { | |
| 330 | - cursor: default; | |
| 331 | - opacity:0.5 !important; | |
| 332 | -} | |
| 333 | -.chzn-disabled .chzn-single { | |
| 334 | - cursor: default; | |
| 335 | -} | |
| 336 | -.chzn-disabled .chzn-choices .search-choice .search-choice-close { | |
| 337 | - cursor: default; | |
| 338 | -} | |
| 339 | - | |
| 340 | -/* @group Right to Left */ | |
| 341 | -.chzn-rtl { direction:rtl;text-align: right; } | |
| 342 | -.chzn-rtl .chzn-single { padding-left: 0; padding-right: 8px; } | |
| 343 | -.chzn-rtl .chzn-single span { margin-left: 26px; margin-right: 0; } | |
| 344 | -.chzn-rtl .chzn-single div { | |
| 345 | - left: 0; right: auto; | |
| 346 | - border-left: none; border-right: 1px solid #aaaaaa; | |
| 347 | - -webkit-border-radius: 4px 0 0 4px; | |
| 348 | - -moz-border-radius : 4px 0 0 4px; | |
| 349 | - border-radius : 4px 0 0 4px; | |
| 350 | -} | |
| 351 | -.chzn-rtl .chzn-choices li { float: right; } | |
| 352 | -.chzn-rtl .chzn-choices .search-choice { padding: 3px 6px 3px 19px; margin: 3px 5px 3px 0; } | |
| 353 | -.chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 5px; right: auto; background-position: right top;} | |
| 354 | -.chzn-rtl.chzn-container-single .chzn-results { margin-left: 4px; margin-right: 0; padding-left: 0; padding-right: 4px; } | |
| 355 | -.chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 20px; } | |
| 356 | -.chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; } | |
| 357 | -.chzn-rtl .chzn-search input { | |
| 358 | - background: url('chosen-sprite.png') no-repeat -38px -22px, #ffffff; | |
| 359 | - background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee)); | |
| 360 | - background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%); | |
| 361 | - background: url('chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%); | |
| 362 | - background: url('chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%); | |
| 363 | - background: url('chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%); | |
| 364 | - background: url('chosen-sprite.png') no-repeat -38px -22px, linear-gradient(top, #ffffff 85%,#eeeeee 99%); | |
| 365 | - padding: 4px 5px 4px 20px; | |
| 366 | -} | |
| 367 | -/* @end */ |