1(function() { 2 var MutationObserver; 3 4 if (window.MutationObserver != null) { 5 return; 6 } 7 8 MutationObserver = (function() { 9 function MutationObserver(callBack) { 10 this.callBack = callBack; 11 } 12 13 MutationObserver.prototype.observe = function(element, options) { 14 this.element = element; 15 return this.interval = setInterval((function(_this) { 16 return function() { 17 var html; 18 html = _this.element.innerHTML; 19 if (html !== _this.oldHtml) { 20 _this.oldHtml = html; 21 return _this.callBack.apply(null); 22 } 23 }; 24 })(this), 200); 25 }; 26 27 MutationObserver.prototype.disconnect = function() { 28 return clearInterval(this.interval); 29 }; 30 31 return MutationObserver; 32 33 })(); 34 35 window.MutationObserver = MutationObserver; 36 37}).call(this); 38 39(function() { 40 var __slice = [].slice; 41 42 (function($) { 43 var PrettySelect; 44 PrettySelect = (function() { 45 PrettySelect.prototype.defaults = { 46 wrapClass: 'prettyselect-wrap', 47 labelClass: 'prettyselect-label', 48 dropClass: 'prettyselect-drop', 49 disabledClass: 'prettyselect-disabled', 50 onlyValuedOptions: false 51 }; 52 53 PrettySelect.prototype._ = { 54 populate: function($options) { 55 return $options.map(function() { 56 var cls, rawCls, val; 57 val = escape($(this).attr('value')); 58 rawCls = $(this).attr('class'); 59 cls = typeof rawCls !== 'undefined' ? "class='" + (escape(rawCls)) + "'" : ''; 60 return "<li data-value='" + val + "' " + cls + ">" + ($(this).html()) + "</li>"; 61 }).toArray().join(''); 62 }, 63 getLabel: function($select) { 64 var $pl; 65 if (($pl = $select.find('option[data-placeholder]')).length > 0) { 66 return $pl.text(); 67 } else { 68 return $select.find('option:selected').text(); 69 } 70 }, 71 optionsSelector: { 72 onlyWithValue: 'option[value][value!=""]:not([data-placeholder])', 73 withoutValue: 'option:not([data-placeholder])' 74 } 75 }; 76 77 function PrettySelect(select, options) { 78 var $options, MutationObserver, elements; 79 this.options = $.extend({}, this.defaults, options); 80 this.options.optionsSelector = this.options.onlyValuedOptions ? this._.optionsSelector.onlyWithValue : this._.optionsSelector.withoutValue; 81 this.$select = $(select).hide().wrap("<div class=" + this.options.wrapClass + "/>"); 82 this.$label = $("<div class=" + this.options.labelClass + ">").html(this._.getLabel(this.$select) + "<i class='uk-icon-caret-down'></i>"); 83 $options = this.$select.find(this.options.optionsSelector); 84 elements = this._.populate($options); 85 this.$drop = $("<div class = 'dropwrapper'><ul class=" + this.options.dropClass + ">" + elements + "</ul></div>"); 86 this.closeDrop(); 87 this.$wrap = this.$select.parents('.' + this.options.wrapClass).attr('data-prettyselect-elements', $options.length).append(this.$label).append(this.$drop).on('click', 'li', (function(_this) { 88 return function(e) { 89 var oldVal, value; 90 if (_this.isDisabled()) { 91 return; 92 } 93 value = unescape($(e.currentTarget).attr('data-value')); 94 oldVal = _this.$select.val(); 95 if (oldVal === value) { 96 return; 97 } 98 return _this.$select.val(value).trigger('change'); 99 }; 100 })(this)); 101 this.$select.on('change', (function(_this) { 102 return function(e) { 103 var val; 104 val = _this.$select.val().replace("'", "\\'"); 105 return _this.$label.html(_this.$select.find("option[value = '" + val + "']").html()); 106 }; 107 })(this)); 108 this.$label.on('click', (function(_this) { 109 return function(e) { 110 if (_this.isDropOpen() || _this.isDisabled()) { 111 return; 112 } 113 e.stopPropagation(); 114 _this.showDrop(); 115 setTimeout(function(){ 116 var counter = _this.$select.closest('.prettyselect-wrap').data('counter'); 117 if( $('.prettyselect-wrap[data-counter="'+ counter +'"] .iScrollVerticalScrollbar').length == 0 ){ 118 var iScroll = new IScroll('.prettyselect-wrap[data-counter="'+ counter +'"] .dropwrapper', { 119 mouseWheel: true, 120 preventDefaultException: { tagName: /^(LI|A|SPAN|INPUT)$/ }, 121 scrollbars: true 122 }); 123 } 124 }, 0); 125 return $('html').one('click', function() { 126 return _this.closeDrop(); 127 }); 128 }; 129 })(this)); 130 MutationObserver = window.MutationObserver; 131 this.observer = new MutationObserver((function(_this) { 132 return function(mutations, observer) { 133 $options = _this.$select.find(_this.options.optionsSelector); 134 _this.$wrap.attr('data-prettyselect-elements', $options.length); 135 _this.$drop.html(_this._.populate($options)); 136 if (_this.$select.find('[selected]').length === 0) { 137 return _this.$label.html(_this._.getLabel(_this.$select)); 138 } else { 139 return _this.$label.html(_this.$select.find('option:selected').text()); 140 } 141 }; 142 })(this)); 143 this.observer.observe(this.$select[0], { 144 subtree: true, 145 attributes: true, 146 attributeOldValue: false, 147 attributeFilter: ['class', 'selected'], 148 childList: true 149 }); 150 } 151 152 PrettySelect.prototype.destroy = function() { 153 this.observer.disconnect(); 154 this.$label.detach(); 155 this.$drop.detach(); 156 return this.$select.show().unwrap(this.options.wrapClass).removeData('PrettySelect'); 157 }; 158 159 PrettySelect.prototype.isDisabled = function() { 160 return this.$select.attr('disabled') === 'disabled'; 161 }; 162 163 PrettySelect.prototype.disable = function() { 164 this.$select.attr('disabled', 'disabled'); 165 return this.$wrap.addClass(this.options.disabledClass); 166 }; 167 168 PrettySelect.prototype.enable = function() { 169 this.$select.removeAttr('disabled', 'disabled'); 170 return this.$wrap.removeClass(this.options.disabledClass); 171 }; 172 173 PrettySelect.prototype.closeDrop = function() { 174 return this.$drop.css('display', 'none'); 175 }; 176 177 PrettySelect.prototype.showDrop = function() { 178 return this.$drop.css('display', 'block'); 179 }; 180
181 PrettySelect.prototype.isDropOpen = function() { 182 return this.$drop.css('display') === 'block'; 183 }; 184 185 return PrettySelect; 186 187 })(); 188 return $.fn.prettyselect = function() { 189 var args, option; 190 option = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; 191 return this.each(function() { 192 var $this, data; 193 $this = $(this); 194 data = $this.data('PrettySelect'); 195 if (!data) { 196 $this.data('PrettySelect', (data = new PrettySelect(this, option))); 197 } 198 if (typeof option === 'string') { 199 return data[option].apply(data, args); 200 } 201 }); 202 }; 203 })(window.jQuery || window.Zepto); 204 205}).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.