|
53 | 53 | return combobox; |
54 | 54 | } |
55 | 55 |
|
| 56 | + , disable: function() { |
| 57 | + this.$element.prop('disabled', true) |
| 58 | + this.$button.attr('disabled', true) |
| 59 | + this.disabled = true |
| 60 | + } |
| 61 | + |
| 62 | + , enable: function() { |
| 63 | + this.$element.prop('disabled', false) |
| 64 | + this.$button.attr('disabled', false) |
| 65 | + this.disabled = false |
| 66 | + } |
56 | 67 | , parse: function () { |
57 | 68 | var that = this |
58 | 69 | , map = {} |
|
83 | 94 | } |
84 | 95 |
|
85 | 96 | , transferAttributes: function() { |
86 | | - this.options.placeholder = this.$source.attr('data-placeholder') || this.options.placeholder; |
87 | | - this.$element.attr('placeholder', this.options.placeholder); |
88 | | - this.$target.prop('name', this.$source.prop('name')); |
89 | | - this.$target.val(this.$source.val()); |
90 | | - this.$source.removeAttr('name'); // Remove from source otherwise form will pass parameter twice. |
91 | | - this.$element.attr('required', this.$source.attr('required')); |
92 | | - this.$element.attr('rel', this.$source.attr('rel')); |
93 | | - this.$element.attr('title', this.$source.attr('title')); |
94 | | - this.$element.attr('class', this.$source.attr('class')); |
95 | | - this.$element.attr('tabindex', this.$source.attr('tabindex')); |
96 | | - this.$source.removeAttr('tabindex'); |
| 97 | + this.options.placeholder = this.$source.attr('data-placeholder') || this.options.placeholder |
| 98 | + this.$element.attr('placeholder', this.options.placeholder) |
| 99 | + this.$target.prop('name', this.$source.prop('name')) |
| 100 | + this.$target.val(this.$source.val()) |
| 101 | + this.$source.removeAttr('name') // Remove from source otherwise form will pass parameter twice. |
| 102 | + this.$element.attr('required', this.$source.attr('required')) |
| 103 | + this.$element.attr('rel', this.$source.attr('rel')) |
| 104 | + this.$element.attr('title', this.$source.attr('title')) |
| 105 | + this.$element.attr('class', this.$source.attr('class')) |
| 106 | + this.$element.attr('tabindex', this.$source.attr('tabindex')) |
| 107 | + this.$source.removeAttr('tabindex') |
| 108 | + if (this.$source.attr('disabled')!==undefined) |
| 109 | + this.disable(); |
97 | 110 | } |
98 | 111 |
|
99 | 112 | , select: function () { |
|
225 | 238 | } |
226 | 239 |
|
227 | 240 | , toggle: function () { |
228 | | - if (this.$container.hasClass('combobox-selected')) { |
229 | | - this.clearTarget(); |
230 | | - this.triggerChange(); |
231 | | - this.clearElement(); |
232 | | - } else { |
233 | | - if (this.shown) { |
234 | | - this.hide(); |
235 | | - } else { |
| 241 | + if (!this.disabled) { |
| 242 | + if (this.$container.hasClass('combobox-selected')) { |
| 243 | + this.clearTarget(); |
| 244 | + this.triggerChange(); |
236 | 245 | this.clearElement(); |
237 | | - this.lookup(); |
| 246 | + } else { |
| 247 | + if (this.shown) { |
| 248 | + this.hide(); |
| 249 | + } else { |
| 250 | + this.clearElement(); |
| 251 | + this.lookup(); |
| 252 | + } |
238 | 253 | } |
239 | 254 | } |
240 | 255 | } |
|
391 | 406 |
|
392 | 407 | /* COMBOBOX PLUGIN DEFINITION |
393 | 408 | * =========================== */ |
394 | | - |
395 | 409 | $.fn.combobox = function ( option ) { |
396 | 410 | return this.each(function () { |
397 | 411 | var $this = $(this) |
|
0 commit comments