mtl 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/mtl/dropdown.coffee +1 -1
- data/app/assets/stylesheets/mtl/extend/_chips.scss +20 -0
- data/app/assets/stylesheets/mtl/extend/_side-nav.scss +4 -2
- data/lib/generators/mtl/templates/_variables.scss +5 -0
- data/lib/mtl/version.rb +2 -2
- data/mtl.gemspec +11 -0
- data/package.json +1 -1
- data/vendor/assets/javascripts/materialize/animation.js +8 -9
- data/vendor/assets/javascripts/materialize/carousel.js +51 -24
- data/vendor/assets/javascripts/materialize/character_counter.js +2 -2
- data/vendor/assets/javascripts/materialize/chips.js +40 -11
- data/vendor/assets/javascripts/materialize/dropdown.js +12 -12
- data/vendor/assets/javascripts/materialize/forms.js +131 -35
- data/vendor/assets/javascripts/materialize/global.js +55 -0
- data/vendor/assets/javascripts/materialize/init.js +40 -3
- data/vendor/assets/javascripts/materialize/materialbox.js +93 -77
- data/vendor/assets/javascripts/materialize/modal.js +12 -12
- data/vendor/assets/javascripts/materialize/parallax.js +48 -48
- data/vendor/assets/javascripts/materialize/scrollFire.js +40 -37
- data/vendor/assets/javascripts/materialize/scrollspy.js +2 -53
- data/vendor/assets/javascripts/materialize/sideNav.js +46 -40
- data/vendor/assets/javascripts/materialize/slider.js +15 -12
- data/vendor/assets/javascripts/materialize/tabs.js +104 -35
- data/vendor/assets/javascripts/materialize/toasts.js +122 -123
- data/vendor/assets/javascripts/materialize/tooltip.js +15 -13
- data/vendor/assets/javascripts/materialize/transitions.js +24 -24
- data/vendor/assets/stylesheets/materialize/_badges.scss +46 -0
- data/vendor/assets/stylesheets/materialize/_buttons.scss +29 -17
- data/vendor/assets/stylesheets/materialize/_cards.scss +9 -3
- data/vendor/assets/stylesheets/materialize/_carousel.scss +1 -1
- data/vendor/assets/stylesheets/materialize/_collapsible.scss +3 -7
- data/vendor/assets/stylesheets/materialize/_global.scss +5 -61
- data/vendor/assets/stylesheets/materialize/_materialbox.scss +13 -12
- data/vendor/assets/stylesheets/materialize/_navbar.scss +26 -7
- data/vendor/assets/stylesheets/materialize/_sideNav.scss +5 -5
- data/vendor/assets/stylesheets/materialize/_table_of_contents.scss +2 -2
- data/vendor/assets/stylesheets/materialize/_toast.scss +1 -1
- data/vendor/assets/stylesheets/materialize/_tooltip.scss +2 -3
- data/vendor/assets/stylesheets/materialize/_transitions.scss +13 -0
- data/vendor/assets/stylesheets/materialize/_variables.scss +7 -1
- data/vendor/assets/stylesheets/materialize/_waves.scss +80 -143
- data/vendor/assets/stylesheets/materialize/forms/_input-fields.scss +4 -4
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58be2225ba79d3bbbb74d40af9f194ef4f841e73
|
4
|
+
data.tar.gz: 0ef8ff2feb48bd40ab7af804238575f52f3e8a5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a3d69bb43e9b7abef1f5f6adcb7dd9f42fb1d1ae8ce560f2a5e19421b542b9d2f8ffd7e069549a7fa939544250f5e9a35f7c0ded7950505018bb1327bb917ef
|
7
|
+
data.tar.gz: 89c4eba164571e5aa964f5f8e8a727b5110c51e1eea6b889f72b284a8c7d4a00f5dafd2cdcdb7a9bcd5951fe20c736c54cc84d889e95db0bd9bb6a0b98922468
|
@@ -14,7 +14,7 @@ activator = ($el) ->
|
|
14
14
|
init = ->
|
15
15
|
$('[data-mtl-dropdown]').each ->
|
16
16
|
$el = $(this)
|
17
|
-
updateAttrs($el).dropdown(
|
17
|
+
updateAttrs($el).dropdown(constrainWidth: false)
|
18
18
|
$el.siblings('input.select-dropdown').on 'mousedown', (e) ->
|
19
19
|
e.preventDefault() if e.clientX >= e.target.clientWidth || e.clientY >= e.target.clientHeight
|
20
20
|
|
@@ -1,3 +1,23 @@
|
|
1
1
|
.chip {
|
2
|
+
border-radius: $chip-border-radius;
|
3
|
+
height: $chip-height;
|
4
|
+
line-height: $chip-line-height;
|
5
|
+
font-size: $chip-font-size;
|
6
|
+
font-weight: $chip-font-weight;
|
2
7
|
white-space: nowrap;
|
8
|
+
padding-right: $chip-height / 2;
|
9
|
+
|
10
|
+
> img {
|
11
|
+
border-radius: $chip-border-radius;
|
12
|
+
height: $chip-height;
|
13
|
+
margin-right: $chip-height / 4;
|
14
|
+
width: $chip-height;
|
15
|
+
}
|
16
|
+
|
17
|
+
.close {
|
18
|
+
font-size: $chip-font-size + 3px;
|
19
|
+
height: $chip-height;
|
20
|
+
line-height: $chip-line-height;
|
21
|
+
padding-left: ($chip-font-size + 3px) / 2;
|
22
|
+
}
|
3
23
|
}
|
@@ -2,11 +2,13 @@
|
|
2
2
|
.side-nav {
|
3
3
|
|
4
4
|
// scss-lint:disable QualifyingElement
|
5
|
-
li.active > a
|
6
|
-
li.active > a i.material-icons {
|
5
|
+
li.active > a {
|
7
6
|
// scss-lint:enable QualifyingElement
|
8
7
|
background-color: $mtl-sidenav-bg-active-color;
|
9
8
|
color: $mtl-sidenav-font-active-color;
|
9
|
+
.material-icons {
|
10
|
+
color: $mtl-sidenav-font-active-color;
|
11
|
+
}
|
10
12
|
}
|
11
13
|
|
12
14
|
ul {
|
@@ -108,6 +108,11 @@ $chip-bg-color: #e4e4e4 !default;
|
|
108
108
|
$chip-border-color: #9e9e9e !default;
|
109
109
|
$chip-selected-color: #26a69a !default;
|
110
110
|
$chip-margin: 5px !default;
|
111
|
+
$chip-height: 32px !default;
|
112
|
+
$chip-line-height: 32px !default;
|
113
|
+
$chip-font-size: 13px !default;
|
114
|
+
$chip-font-weight: 500 !default;
|
115
|
+
$chip-border-radius: 16px !default;
|
111
116
|
|
112
117
|
|
113
118
|
// 7. Date Picker ===========================================================
|
data/lib/mtl/version.rb
CHANGED
data/mtl.gemspec
CHANGED
@@ -32,4 +32,15 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency 'rspec', '> 3.0'
|
33
33
|
spec.add_development_dependency 'actionview'
|
34
34
|
spec.add_development_dependency 'simple_form', '>= 3.3'
|
35
|
+
|
36
|
+
spec.post_install_message = %q{
|
37
|
+
Some component have been extend with configuration variables, don't forget to re-generate the scss configuration or
|
38
|
+
add the following values to your existing one:
|
39
|
+
|
40
|
+
$chip-height: 32px !default;
|
41
|
+
$chip-line-height: 32px !default;
|
42
|
+
$chip-font-size: 13px !default;
|
43
|
+
$chip-font-weight: 500 !default;
|
44
|
+
$chip-border-radius: 16px !default;
|
45
|
+
}
|
35
46
|
end
|
data/package.json
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
// Custom Easing
|
2
|
+
jQuery.extend( jQuery.easing,
|
3
|
+
{
|
4
|
+
easeInOutMaterial: function (x, t, b, c, d) {
|
5
|
+
if ((t/=d/2) < 1) return c/2*t*t + b;
|
6
|
+
return c/4*((t-=2)*t*t + 2) + b;
|
7
|
+
}
|
8
|
+
});
|
@@ -4,19 +4,20 @@
|
|
4
4
|
|
5
5
|
init : function(options) {
|
6
6
|
var defaults = {
|
7
|
-
|
7
|
+
duration: 200, // ms
|
8
8
|
dist: -100, // zoom scale TODO: make this more intuitive as an option
|
9
9
|
shift: 0, // spacing for center image
|
10
10
|
padding: 0, // Padding between non center items
|
11
|
-
|
11
|
+
fullWidth: false, // Change to full width styles
|
12
12
|
indicators: false, // Toggle indicators
|
13
|
-
|
13
|
+
noWrap: false, // Don't wrap around and cycle through items.
|
14
|
+
onCycleTo: null // Callback for when a new slide is cycled to.
|
14
15
|
};
|
15
16
|
options = $.extend(defaults, options);
|
16
17
|
|
17
18
|
return this.each(function() {
|
18
19
|
|
19
|
-
var images, offset, center, pressed, dim, count,
|
20
|
+
var images, item_width, item_height, offset, center, pressed, dim, count,
|
20
21
|
reference, referenceY, amplitude, target, velocity,
|
21
22
|
xform, frame, timestamp, ticker, dragged, vertical_dragged;
|
22
23
|
var $indicators = $('<ul class="indicators"></ul>');
|
@@ -35,7 +36,7 @@
|
|
35
36
|
|
36
37
|
|
37
38
|
// Options
|
38
|
-
if (options.
|
39
|
+
if (options.fullWidth) {
|
39
40
|
options.dist = 0;
|
40
41
|
var firstImage = view.find('.carousel-item img').first();
|
41
42
|
if (firstImage.length) {
|
@@ -59,6 +60,7 @@
|
|
59
60
|
offset = target = 0;
|
60
61
|
images = [];
|
61
62
|
item_width = view.find('.carousel-item').first().innerWidth();
|
63
|
+
item_height = view.find('.carousel-item').first().innerHeight();
|
62
64
|
dim = item_width * 2 + options.padding;
|
63
65
|
|
64
66
|
view.find('.carousel-item').each(function (i) {
|
@@ -72,7 +74,9 @@
|
|
72
74
|
}
|
73
75
|
|
74
76
|
// Handle clicks on indicators.
|
75
|
-
$indicator.click(function () {
|
77
|
+
$indicator.click(function (e) {
|
78
|
+
e.stopPropagation();
|
79
|
+
|
76
80
|
var index = $(this).index();
|
77
81
|
cycleTo(index);
|
78
82
|
});
|
@@ -125,6 +129,7 @@
|
|
125
129
|
|
126
130
|
function scroll(x) {
|
127
131
|
var i, half, delta, dir, tween, el, alignment, xTranslation;
|
132
|
+
var lastCenter = center;
|
128
133
|
|
129
134
|
offset = (typeof x === 'number') ? x : offset;
|
130
135
|
center = Math.floor((offset + dim / 2) / dim);
|
@@ -133,9 +138,9 @@
|
|
133
138
|
tween = -dir * delta * 2 / dim;
|
134
139
|
half = count >> 1;
|
135
140
|
|
136
|
-
if (!options.
|
141
|
+
if (!options.fullWidth) {
|
137
142
|
alignment = 'translateX(' + (view[0].clientWidth - item_width) / 2 + 'px) ';
|
138
|
-
alignment += 'translateY(' + (view[0].clientHeight -
|
143
|
+
alignment += 'translateY(' + (view[0].clientHeight - item_height) / 2 + 'px)';
|
139
144
|
} else {
|
140
145
|
alignment = 'translateX(0)';
|
141
146
|
}
|
@@ -152,14 +157,20 @@
|
|
152
157
|
|
153
158
|
// center
|
154
159
|
// Don't show wrapped items.
|
155
|
-
if (!options.
|
160
|
+
if (!options.noWrap || (center >= 0 && center < count)) {
|
156
161
|
el = images[wrap(center)];
|
162
|
+
|
163
|
+
// Add active class to center item.
|
164
|
+
if (!$(el).hasClass('active')) {
|
165
|
+
view.find('.carousel-item').removeClass('active');
|
166
|
+
$(el).addClass('active');
|
167
|
+
}
|
157
168
|
el.style[xform] = alignment +
|
158
169
|
' translateX(' + (-delta / 2) + 'px)' +
|
159
170
|
' translateX(' + (dir * options.shift * tween * i) + 'px)' +
|
160
171
|
' translateZ(' + (options.dist * tween) + 'px)';
|
161
172
|
el.style.zIndex = 0;
|
162
|
-
if (options.
|
173
|
+
if (options.fullWidth) { tweenedOpacity = 1; }
|
163
174
|
else { tweenedOpacity = 1 - 0.2 * tween; }
|
164
175
|
el.style.opacity = tweenedOpacity;
|
165
176
|
el.style.display = 'block';
|
@@ -167,7 +178,7 @@
|
|
167
178
|
|
168
179
|
for (i = 1; i <= half; ++i) {
|
169
180
|
// right side
|
170
|
-
if (options.
|
181
|
+
if (options.fullWidth) {
|
171
182
|
zTranslation = options.dist;
|
172
183
|
tweenedOpacity = (i === half && delta < 0) ? 1 - tween : 1;
|
173
184
|
} else {
|
@@ -175,7 +186,7 @@
|
|
175
186
|
tweenedOpacity = 1 - 0.2 * (i * 2 + tween * dir);
|
176
187
|
}
|
177
188
|
// Don't show wrapped items.
|
178
|
-
if (!options.
|
189
|
+
if (!options.noWrap || center + i < count) {
|
179
190
|
el = images[wrap(center + i)];
|
180
191
|
el.style[xform] = alignment +
|
181
192
|
' translateX(' + (options.shift + (dim * i - delta) / 2) + 'px)' +
|
@@ -187,7 +198,7 @@
|
|
187
198
|
|
188
199
|
|
189
200
|
// left side
|
190
|
-
if (options.
|
201
|
+
if (options.fullWidth) {
|
191
202
|
zTranslation = options.dist;
|
192
203
|
tweenedOpacity = (i === half && delta > 0) ? 1 - tween : 1;
|
193
204
|
} else {
|
@@ -195,7 +206,7 @@
|
|
195
206
|
tweenedOpacity = 1 - 0.2 * (i * 2 - tween * dir);
|
196
207
|
}
|
197
208
|
// Don't show wrapped items.
|
198
|
-
if (!options.
|
209
|
+
if (!options.noWrap || center - i >= 0) {
|
199
210
|
el = images[wrap(center - i)];
|
200
211
|
el.style[xform] = alignment +
|
201
212
|
' translateX(' + (-options.shift + (-dim * i - delta) / 2) + 'px)' +
|
@@ -208,18 +219,25 @@
|
|
208
219
|
|
209
220
|
// center
|
210
221
|
// Don't show wrapped items.
|
211
|
-
if (!options.
|
222
|
+
if (!options.noWrap || (center >= 0 && center < count)) {
|
212
223
|
el = images[wrap(center)];
|
213
224
|
el.style[xform] = alignment +
|
214
225
|
' translateX(' + (-delta / 2) + 'px)' +
|
215
226
|
' translateX(' + (dir * options.shift * tween) + 'px)' +
|
216
227
|
' translateZ(' + (options.dist * tween) + 'px)';
|
217
228
|
el.style.zIndex = 0;
|
218
|
-
if (options.
|
229
|
+
if (options.fullWidth) { tweenedOpacity = 1; }
|
219
230
|
else { tweenedOpacity = 1 - 0.2 * tween; }
|
220
231
|
el.style.opacity = tweenedOpacity;
|
221
232
|
el.style.display = 'block';
|
222
233
|
}
|
234
|
+
|
235
|
+
// onCycleTo callback
|
236
|
+
if (lastCenter !== center &&
|
237
|
+
typeof(options.onCycleTo) === "function") {
|
238
|
+
var $curr_item = view.find('.carousel-item').eq(wrap(center));
|
239
|
+
options.onCycleTo.call(this, $curr_item, dragged);
|
240
|
+
}
|
223
241
|
}
|
224
242
|
|
225
243
|
function track() {
|
@@ -240,7 +258,7 @@
|
|
240
258
|
|
241
259
|
if (amplitude) {
|
242
260
|
elapsed = Date.now() - timestamp;
|
243
|
-
delta = amplitude * Math.exp(-elapsed / options.
|
261
|
+
delta = amplitude * Math.exp(-elapsed / options.duration);
|
244
262
|
if (delta > 2 || delta < -2) {
|
245
263
|
scroll(target - delta);
|
246
264
|
requestAnimationFrame(autoScroll);
|
@@ -257,7 +275,7 @@
|
|
257
275
|
e.stopPropagation();
|
258
276
|
return false;
|
259
277
|
|
260
|
-
} else if (!options.
|
278
|
+
} else if (!options.fullWidth) {
|
261
279
|
var clickedIndex = $(e.target).closest('.carousel-item').index();
|
262
280
|
var diff = (center % count) - clickedIndex;
|
263
281
|
|
@@ -274,7 +292,7 @@
|
|
274
292
|
var diff = (center % count) - n;
|
275
293
|
|
276
294
|
// Account for wraparound.
|
277
|
-
if (!options.
|
295
|
+
if (!options.noWrap) {
|
278
296
|
if (diff < 0) {
|
279
297
|
if (Math.abs(diff + count) < Math.abs(diff)) { diff += count; }
|
280
298
|
|
@@ -358,7 +376,7 @@
|
|
358
376
|
target = Math.round(target / dim) * dim;
|
359
377
|
|
360
378
|
// No wrap of items.
|
361
|
-
if (options.
|
379
|
+
if (options.noWrap) {
|
362
380
|
if (target >= dim * (count - 1)) {
|
363
381
|
target = dim * (count - 1);
|
364
382
|
} else if (target < 0) {
|
@@ -387,8 +405,17 @@
|
|
387
405
|
});
|
388
406
|
|
389
407
|
|
390
|
-
|
391
|
-
|
408
|
+
$(window).on('resize.carousel', function() {
|
409
|
+
if (options.fullWidth) {
|
410
|
+
item_width = view.find('.carousel-item').first().innerWidth();
|
411
|
+
item_height = view.find('.carousel-item').first().innerHeight();
|
412
|
+
dim = item_width * 2 + options.padding;
|
413
|
+
offset = center * 2 * item_width;
|
414
|
+
target = offset;
|
415
|
+
} else {
|
416
|
+
scroll();
|
417
|
+
}
|
418
|
+
});
|
392
419
|
|
393
420
|
setupEvents();
|
394
421
|
scroll(offset);
|
@@ -397,7 +424,7 @@
|
|
397
424
|
if (n === undefined) {
|
398
425
|
n = 1;
|
399
426
|
}
|
400
|
-
target = offset + dim * n;
|
427
|
+
target = (dim * Math.round(offset / dim)) + (dim * n);
|
401
428
|
if (offset !== target) {
|
402
429
|
amplitude = target - offset;
|
403
430
|
timestamp = Date.now();
|
@@ -409,7 +436,7 @@
|
|
409
436
|
if (n === undefined) {
|
410
437
|
n = 1;
|
411
438
|
}
|
412
|
-
target = offset - dim * n;
|
439
|
+
target = (dim * Math.round(offset / dim)) - (dim * n);
|
413
440
|
if (offset !== target) {
|
414
441
|
amplitude = target - offset;
|
415
442
|
timestamp = Date.now();
|
@@ -10,7 +10,7 @@
|
|
10
10
|
return;
|
11
11
|
}
|
12
12
|
|
13
|
-
var itHasLengthAttribute = $input.attr('length') !== undefined;
|
13
|
+
var itHasLengthAttribute = $input.attr('data-length') !== undefined;
|
14
14
|
|
15
15
|
if(itHasLengthAttribute){
|
16
16
|
$input.on('input', updateCounter);
|
@@ -24,7 +24,7 @@
|
|
24
24
|
};
|
25
25
|
|
26
26
|
function updateCounter(){
|
27
|
-
var maxLength = +$(this).attr('length'),
|
27
|
+
var maxLength = +$(this).attr('data-length'),
|
28
28
|
actualLength = +$(this).val().length,
|
29
29
|
isValidLength = actualLength <= maxLength;
|
30
30
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
(function ($) {
|
2
|
-
var chipsHandleEvents = false;
|
3
2
|
var materialChipsDefaults = {
|
4
3
|
data: [],
|
5
4
|
placeholder: '',
|
6
5
|
secondaryPlaceholder: '',
|
6
|
+
autocompleteData: {},
|
7
|
+
autocompleteLimit: Infinity,
|
7
8
|
};
|
8
9
|
|
9
10
|
$(document).ready(function() {
|
@@ -34,7 +35,7 @@
|
|
34
35
|
}
|
35
36
|
|
36
37
|
var curr_options = $.extend({}, materialChipsDefaults, options);
|
37
|
-
|
38
|
+
self.hasAutocomplete = !$.isEmptyObject(curr_options.autocompleteData);
|
38
39
|
|
39
40
|
// Initialize
|
40
41
|
this.init = function() {
|
@@ -43,6 +44,7 @@
|
|
43
44
|
self.$el.each(function(){
|
44
45
|
var $chips = $(this);
|
45
46
|
var chipId = Materialize.guid();
|
47
|
+
self.chipId = chipId;
|
46
48
|
|
47
49
|
if (!curr_options.data || !(curr_options.data instanceof Array)) {
|
48
50
|
curr_options.data = [];
|
@@ -60,7 +62,7 @@
|
|
60
62
|
});
|
61
63
|
};
|
62
64
|
|
63
|
-
this.handleEvents = function(){
|
65
|
+
this.handleEvents = function() {
|
64
66
|
var SELS = self.SELS;
|
65
67
|
|
66
68
|
self.$document.off('click.chips-focus', SELS.CHIPS).on('click.chips-focus', SELS.CHIPS, function(e){
|
@@ -68,8 +70,16 @@
|
|
68
70
|
});
|
69
71
|
|
70
72
|
self.$document.off('click.chips-select', SELS.CHIP).on('click.chips-select', SELS.CHIP, function(e){
|
71
|
-
$(
|
72
|
-
$
|
73
|
+
var $chip = $(e.target);
|
74
|
+
if ($chip.length) {
|
75
|
+
var wasSelected = $chip.hasClass('selected');
|
76
|
+
var $chips = $chip.closest(SELS.CHIPS);
|
77
|
+
$(SELS.CHIP).removeClass('selected');
|
78
|
+
|
79
|
+
if (!wasSelected) {
|
80
|
+
self.selectChip($chip.index(), $chips);
|
81
|
+
}
|
82
|
+
}
|
73
83
|
});
|
74
84
|
|
75
85
|
self.$document.off('keydown.chips').on('keydown.chips', function(e){
|
@@ -153,6 +163,13 @@
|
|
153
163
|
|
154
164
|
// enter
|
155
165
|
if (13 === e.which) {
|
166
|
+
// Override enter if autocompleting.
|
167
|
+
if (self.hasAutocomplete &&
|
168
|
+
$chips.find('.autocomplete-content.dropdown-content').length &&
|
169
|
+
$chips.find('.autocomplete-content.dropdown-content').children().length) {
|
170
|
+
return;
|
171
|
+
}
|
172
|
+
|
156
173
|
e.preventDefault();
|
157
174
|
self.addChip({tag: $target.val()}, $chips);
|
158
175
|
$target.val('');
|
@@ -160,7 +177,8 @@
|
|
160
177
|
}
|
161
178
|
|
162
179
|
// delete or left
|
163
|
-
|
180
|
+
if ((8 === e.keyCode || 37 === e.keyCode) && '' === $target.val() && chipsLength) {
|
181
|
+
e.preventDefault();
|
164
182
|
self.selectChip(chipsLength - 1, $chips);
|
165
183
|
$target.blur();
|
166
184
|
return;
|
@@ -196,6 +214,20 @@
|
|
196
214
|
label.addClass('active');
|
197
215
|
}
|
198
216
|
}
|
217
|
+
|
218
|
+
// Setup autocomplete if needed.
|
219
|
+
var input = $('#' + chipId);
|
220
|
+
if (self.hasAutocomplete) {
|
221
|
+
input.autocomplete({
|
222
|
+
data: curr_options.autocompleteData,
|
223
|
+
limit: curr_options.autocompleteLimit,
|
224
|
+
onAutocomplete: function(val) {
|
225
|
+
self.addChip({tag: val}, $chips);
|
226
|
+
input.val('');
|
227
|
+
input.focus();
|
228
|
+
},
|
229
|
+
})
|
230
|
+
}
|
199
231
|
};
|
200
232
|
|
201
233
|
this.renderChip = function(elem) {
|
@@ -281,9 +313,6 @@
|
|
281
313
|
// init
|
282
314
|
this.init();
|
283
315
|
|
284
|
-
|
285
|
-
this.handleEvents();
|
286
|
-
chipsHandleEvents = true;
|
287
|
-
}
|
316
|
+
this.handleEvents();
|
288
317
|
};
|
289
|
-
}( jQuery ));
|
318
|
+
}( jQuery ));
|
@@ -11,7 +11,7 @@
|
|
11
11
|
var defaults = {
|
12
12
|
inDuration: 300,
|
13
13
|
outDuration: 225,
|
14
|
-
|
14
|
+
constrainWidth: true, // Constrains width of dropdown to the activator
|
15
15
|
hover: false,
|
16
16
|
gutter: 0, // Spacing from edge
|
17
17
|
belowOrigin: false,
|
@@ -49,7 +49,7 @@
|
|
49
49
|
if (origin.data('outduration') !== undefined)
|
50
50
|
curr_options.outDuration = origin.data('outduration');
|
51
51
|
if (origin.data('constrainwidth') !== undefined)
|
52
|
-
curr_options.
|
52
|
+
curr_options.constrainWidth = origin.data('constrainwidth');
|
53
53
|
if (origin.data('hover') !== undefined)
|
54
54
|
curr_options.hover = origin.data('hover');
|
55
55
|
if (origin.data('gutter') !== undefined)
|
@@ -85,7 +85,7 @@
|
|
85
85
|
origin.addClass('active');
|
86
86
|
|
87
87
|
// Constrain width
|
88
|
-
if (curr_options.
|
88
|
+
if (curr_options.constrainWidth === true) {
|
89
89
|
activates.css('width', origin.outerWidth());
|
90
90
|
|
91
91
|
} else {
|
@@ -174,6 +174,14 @@
|
|
174
174
|
}
|
175
175
|
})
|
176
176
|
.animate( {opacity: 1}, {queue: false, duration: curr_options.inDuration, easing: 'easeOutSine'});
|
177
|
+
|
178
|
+
// Add click close handler to document
|
179
|
+
$(document).bind('click.'+ activates.attr('id') + ' touchstart.' + activates.attr('id'), function (e) {
|
180
|
+
if (!activates.is(e.target) && !origin.is(e.target) && (!origin.find(e.target).length) ) {
|
181
|
+
hideDropdown();
|
182
|
+
$(document).unbind('click.'+ activates.attr('id') + ' touchstart.' + activates.attr('id'));
|
183
|
+
}
|
184
|
+
});
|
177
185
|
}
|
178
186
|
|
179
187
|
function hideDropdown() {
|
@@ -182,6 +190,7 @@
|
|
182
190
|
activates.fadeOut(curr_options.outDuration);
|
183
191
|
activates.removeClass('active');
|
184
192
|
origin.removeClass('active');
|
193
|
+
$(document).unbind('click.'+ activates.attr('id') + ' touchstart.' + activates.attr('id'));
|
185
194
|
setTimeout(function() { activates.css('max-height', ''); }, curr_options.outDuration);
|
186
195
|
}
|
187
196
|
|
@@ -235,15 +244,6 @@
|
|
235
244
|
hideDropdown();
|
236
245
|
$(document).unbind('click.'+ activates.attr('id') + ' touchstart.' + activates.attr('id'));
|
237
246
|
}
|
238
|
-
// If menu open, add click close handler to document
|
239
|
-
if (activates.hasClass('active')) {
|
240
|
-
$(document).bind('click.'+ activates.attr('id') + ' touchstart.' + activates.attr('id'), function (e) {
|
241
|
-
if (!activates.is(e.target) && !origin.is(e.target) && (!origin.find(e.target).length) ) {
|
242
|
-
hideDropdown();
|
243
|
-
$(document).unbind('click.'+ activates.attr('id') + ' touchstart.' + activates.attr('id'));
|
244
|
-
}
|
245
|
-
});
|
246
|
-
}
|
247
247
|
}
|
248
248
|
});
|
249
249
|
|