Skip to content

Commit df9e809

Browse files
kerstendanielfarrell
authored andcommitted
made uglify compatible
1 parent 69dbdeb commit df9e809

File tree

1 file changed

+101
-101
lines changed

1 file changed

+101
-101
lines changed

js/bootstrap-combobox.js

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
"use strict";
2222

2323
var Combobox = function ( element, options ) {
24-
this.options = $.extend({}, $.fn.combobox.defaults, options)
25-
this.$source = $(element)
26-
this.$container = this.setup()
27-
this.$element = this.$container.find('input[type=text]')
28-
this.$target = this.$container.find('input[type=hidden]')
29-
this.$button = this.$container.find('.dropdown-toggle')
30-
this.$menu = $(this.options.menu).appendTo('body')
31-
this.matcher = this.options.matcher || this.matcher
32-
this.sorter = this.options.sorter || this.sorter
33-
this.highlighter = this.options.highlighter || this.highlighter
34-
this.shown = false
35-
this.selected = false
36-
this.refresh()
37-
this.transferAttributes()
38-
this.listen()
39-
}
24+
this.options = $.extend({}, $.fn.combobox.defaults, options);
25+
this.$source = $(element);
26+
this.$container = this.setup();
27+
this.$element = this.$container.find('input[type=text]');
28+
this.$target = this.$container.find('input[type=hidden]');
29+
this.$button = this.$container.find('.dropdown-toggle');
30+
this.$menu = $(this.options.menu).appendTo('body');
31+
this.matcher = this.options.matcher || this.matcher;
32+
this.sorter = this.options.sorter || this.sorter;
33+
this.highlighter = this.options.highlighter || this.highlighter;
34+
this.shown = false;
35+
this.selected = false;
36+
this.refresh();
37+
this.transferAttributes();
38+
this.listen();
39+
};
4040

4141
/* NOTE: COMBOBOX EXTENDS BOOTSTRAP-TYPEAHEAD.js
4242
========================================== */
@@ -46,105 +46,105 @@
4646
constructor: Combobox
4747

4848
, setup: function () {
49-
var combobox = $(this.options.template)
50-
this.$source.before(combobox)
51-
this.$source.hide()
52-
return combobox
49+
var combobox = $(this.options.template);
50+
this.$source.before(combobox);
51+
this.$source.hide();
52+
return combobox;
5353
}
5454

5555
, parse: function () {
5656
var that = this
5757
, map = {}
5858
, source = []
5959
, selected = false
60-
, selectedValue = ''
60+
, selectedValue = '';
6161
this.$source.find('option').each(function() {
62-
var option = $(this)
62+
var option = $(this);
6363
if (option.val() === '') {
64-
that.options.placeholder = option.text()
65-
return
64+
that.options.placeholder = option.text();
65+
return;
6666
}
67-
map[option.text()] = option.val()
68-
source.push(option.text())
67+
map[option.text()] = option.val();
68+
source.push(option.text());
6969
if (option.prop('selected')) {
70-
selected = option.text()
71-
selectedValue = option.val()
70+
selected = option.text();
71+
selectedValue = option.val();
7272
}
7373
})
74-
this.map = map
74+
this.map = map;
7575
if (selected) {
76-
this.$element.val(selected)
77-
this.$target.val(selectedValue)
78-
this.$container.addClass('combobox-selected')
79-
this.selected = true
76+
this.$element.val(selected);
77+
this.$target.val(selectedValue);
78+
this.$container.addClass('combobox-selected');
79+
this.selected = true;
8080
}
81-
return source
81+
return source;
8282
}
8383

8484
, transferAttributes: function() {
85-
this.options.placeholder = this.$source.attr('data-placeholder') || this.options.placeholder
86-
this.$element.attr('placeholder', this.options.placeholder)
87-
this.$target.prop('name', this.$source.prop('name'))
88-
this.$target.val(this.$source.val())
89-
this.$source.removeAttr('name') // Remove from source otherwise form will pass parameter twice.
90-
this.$element.attr('required', this.$source.attr('required'))
91-
this.$element.attr('rel', this.$source.attr('rel'))
92-
this.$element.attr('title', this.$source.attr('title'))
93-
this.$element.attr('class', this.$source.attr('class'))
94-
this.$element.attr('tabindex', this.$source.attr('tabindex'))
95-
this.$source.removeAttr('tabindex')
85+
this.options.placeholder = this.$source.attr('data-placeholder') || this.options.placeholder;
86+
this.$element.attr('placeholder', this.options.placeholder);
87+
this.$target.prop('name', this.$source.prop('name'));
88+
this.$target.val(this.$source.val());
89+
this.$source.removeAttr('name'); // Remove from source otherwise form will pass parameter twice.
90+
this.$element.attr('required', this.$source.attr('required'));
91+
this.$element.attr('rel', this.$source.attr('rel'));
92+
this.$element.attr('title', this.$source.attr('title'));
93+
this.$element.attr('class', this.$source.attr('class'));
94+
this.$element.attr('tabindex', this.$source.attr('tabindex'));
95+
this.$source.removeAttr('tabindex');
9696
}
9797

9898
, toggle: function () {
9999
if (this.$container.hasClass('combobox-selected')) {
100-
this.clearTarget()
101-
this.triggerChange()
102-
this.clearElement()
100+
this.clearTarget();
101+
this.triggerChange();
102+
this.clearElement();
103103
} else {
104104
if (this.shown) {
105-
this.hide()
105+
this.hide();
106106
} else {
107-
this.clearElement()
108-
this.lookup()
107+
this.clearElement();
108+
this.lookup();
109109
}
110110
}
111111
}
112112

113113
, clearElement: function () {
114-
this.$element.val('').focus()
114+
this.$element.val('').focus();
115115
}
116116

117117
, clearTarget: function () {
118-
this.$source.val('')
119-
this.$target.val('')
120-
this.$container.removeClass('combobox-selected')
121-
this.selected = false
118+
this.$source.val('');
119+
this.$target.val('');
120+
this.$container.removeClass('combobox-selected');
121+
this.selected = false;
122122
}
123123

124124
, triggerChange: function () {
125-
this.$source.trigger('change')
125+
this.$source.trigger('change');
126126
}
127127

128128
, refresh: function () {
129-
this.source = this.parse()
130-
this.options.items = this.source.length
129+
this.source = this.parse();
130+
this.options.items = this.source.length;
131131
}
132132

133133
// modified typeahead function adding container and target handling
134134
, select: function () {
135-
var val = this.$menu.find('.active').attr('data-value')
136-
this.$element.val(this.updater(val)).trigger('change')
137-
this.$source.val(this.map[val]).trigger('change')
138-
this.$target.val(this.map[val]).trigger('change')
139-
this.$container.addClass('combobox-selected')
140-
this.selected = true
141-
return this.hide()
135+
var val = this.$menu.find('.active').attr('data-value');
136+
this.$element.val(this.updater(val)).trigger('change');
137+
this.$source.val(this.map[val]).trigger('change');
138+
this.$target.val(this.map[val]).trigger('change');
139+
this.$container.addClass('combobox-selected');
140+
this.selected = true;
141+
return this.hide();
142142
}
143143

144144
// modified typeahead function removing the blank handling and source function handling
145145
, lookup: function (event) {
146-
this.query = this.$element.val()
147-
return this.process(this.source)
146+
this.query = this.$element.val();
147+
return this.process(this.source);
148148
}
149149

150150
// modified typeahead function adding button handling and remove mouseleave
@@ -153,19 +153,19 @@
153153
.on('focus', $.proxy(this.focus, this))
154154
.on('blur', $.proxy(this.blur, this))
155155
.on('keypress', $.proxy(this.keypress, this))
156-
.on('keyup', $.proxy(this.keyup, this))
156+
.on('keyup', $.proxy(this.keyup, this));
157157

158158
if (this.eventSupported('keydown')) {
159-
this.$element.on('keydown', $.proxy(this.keydown, this))
159+
this.$element.on('keydown', $.proxy(this.keydown, this));
160160
}
161161

162162
this.$menu
163163
.on('click', $.proxy(this.click, this))
164164
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
165-
.on('mouseleave', 'li', $.proxy(this.mouseleave, this))
165+
.on('mouseleave', 'li', $.proxy(this.mouseleave, this));
166166

167167
this.$button
168-
.on('click', $.proxy(this.toggle, this))
168+
.on('click', $.proxy(this.toggle, this));
169169
}
170170

171171
// modified typeahead function to clear on type and prevent on moving around
@@ -180,46 +180,46 @@
180180
case 16: // shift
181181
case 17: // ctrl
182182
case 18: // alt
183-
break
183+
break;
184184

185185
case 9: // tab
186-
case 13: // enter
187-
if (!this.shown) return
188-
this.select()
189-
break
186+
case 13: // enter
187+
if (!this.shown) return;
188+
this.select();
189+
break;
190190

191-
case 27: // escape
192-
if (!this.shown) return
193-
this.hide()
194-
break
191+
case 27: // escape
192+
if (!this.shown) return;
193+
this.hide();
194+
break;
195195

196196
default:
197-
this.clearTarget()
198-
this.lookup()
197+
this.clearTarget();
198+
this.lookup();
199199
}
200200

201-
e.stopPropagation()
202-
e.preventDefault()
201+
e.stopPropagation();
202+
e.preventDefault();
203203
}
204204

205205
// modified typeahead function to force a match and add a delay on hide
206206
, blur: function (e) {
207-
var that = this
208-
this.focused = false
209-
var val = this.$element.val()
207+
var that = this;
208+
this.focused = false;
209+
var val = this.$element.val();
210210
if (!this.selected && val !== '' ) {
211-
this.$element.val('')
212-
this.$source.val('').trigger('change')
213-
this.$target.val('').trigger('change')
211+
this.$element.val('');
212+
this.$source.val('').trigger('change');
213+
this.$target.val('').trigger('change');
214214
}
215-
if (!this.mousedover && this.shown) setTimeout(function () { that.hide() }, 200)
215+
if (!this.mousedover && this.shown) {setTimeout(function () { that.hide(); }, 200);}
216216
}
217217

218218
// modified typeahead function to not hide
219219
, mouseleave: function (e) {
220-
this.mousedover = false
220+
this.mousedover = false;
221221
}
222-
})
222+
});
223223

224224
/* COMBOBOX PLUGIN DEFINITION
225225
* =========================== */
@@ -228,18 +228,18 @@
228228
return this.each(function () {
229229
var $this = $(this)
230230
, data = $this.data('combobox')
231-
, options = typeof option == 'object' && option
232-
if(!data) $this.data('combobox', (data = new Combobox(this, options)))
233-
if (typeof option == 'string') data[option]()
234-
})
235-
}
231+
, options = typeof option == 'object' && option;
232+
if(!data) {$this.data('combobox', (data = new Combobox(this, options)));}
233+
if (typeof option == 'string') {data[option]();}
234+
});
235+
};
236236

237237
$.fn.combobox.defaults = {
238238
template: '<div class="combobox-container"><input type="hidden" /><input type="text" autocomplete="off" /><span class="add-on btn dropdown-toggle" data-dropdown="dropdown"><span class="caret"/><span class="combobox-clear"><i class="icon-remove"/></span></span></div>'
239239
, menu: '<ul class="typeahead typeahead-long dropdown-menu"></ul>'
240240
, item: '<li><a href="#"></a></li>'
241-
}
241+
};
242242

243-
$.fn.combobox.Constructor = Combobox
243+
$.fn.combobox.Constructor = Combobox;
244244

245245
}( window.jQuery );

0 commit comments

Comments
 (0)