Sha256: 3de99a9c894a3fd6b0d7d286df8ef558110f53ff33c16c72773fef2e74b72e5d
Contents?: true
Size: 1.68 KB
Versions: 15
Compression:
Stored size: 1.68 KB
Contents
$.fn.select2.defaults.set("theme", "bootstrap") decko.slotReady (slot) -> slot.find('select:not(._no-select2)').each (_i) -> decko.initSelect2($(this)) decko.slotDestroy (slot) -> slot.find('select:not(._no-select2)').each (_i) -> $(this).deInitSelect2() $.extend decko, initSelect2: (elem) -> if elem.length > 1 decko.initSelect2($(single_el)) for single_el in elem else opts = { dropdownAutoWidth: "true", containerCssClass: ":all:", width: "auto" } elem.attr "id", decko.uniqSelect2Id(elem.attr("id")) if elem.hasClass("tags") opts.tags = "true" if elem.data("minimum-results-for-search")? opts.minimumResultsForSearch = elem.data("minimum-results-for-search") elem.select2(opts) uniqSelect2Id: (id) -> return id unless $("[data-select2-id=" + id + "]").length > 0 decko.uniqSelect2Id id + "1" $(window).ready -> $('body').on 'select2:select', '._go-to-selected', -> val = $(this).val() if val != '' window.location = decko.path(escape(val)) $('body').on "select2:select", "._submit-on-select", (event) -> $(event.target).closest('form').submit() $.fn.extend cloneSelect2: (withDataAndEvents, deepWithDataAndEvents) -> $old = if this.is('select') then this else this.find('select') $old.deInitSelect2() $cloned = this.clone(withDataAndEvents, deepWithDataAndEvents) decko.initSelect2 $old if $cloned.is('select') decko.initSelect2 $cloned else decko.initSelect2 $cloned.find('select') $cloned deInitSelect2: -> return unless @attr "data-select2-id" @select2 "destroy" @removeAttr "data-select2-id" @find("option").removeAttr "data-select2-id"
Version data entries
15 entries across 15 versions & 1 rubygems