effective_form_inputs 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b0698583fd3fbc2109b3e032ce406a4f5e3859a
|
4
|
+
data.tar.gz: a0b8c25ac30aeab92a33a33a6edd07fabeda7505
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cffb5fc00558a5918c750b07b4e5b724eb97ce44c76da8118c7e4e7e9b534fe51dc620a9d90e3d228216f2a91828eab69d35944c3c8d9a769ce17e10e7d2e4f
|
7
|
+
data.tar.gz: fe69fd6459d23126ee871d54d23f60078de897cfbf713a89e6ac5654aa4a4531479d4a960f5f6cadb78563941a21562d1c09172435e8387110581d42def47852
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* Select2 4.0.
|
2
|
+
* Select2 4.0.3
|
3
3
|
* https://select2.github.io
|
4
4
|
*
|
5
5
|
* Released under the MIT license
|
@@ -606,9 +606,23 @@ S2.define('select2/utils',[
|
|
606
606
|
|
607
607
|
Observable.prototype.trigger = function (event) {
|
608
608
|
var slice = Array.prototype.slice;
|
609
|
+
var params = slice.call(arguments, 1);
|
609
610
|
|
610
611
|
this.listeners = this.listeners || {};
|
611
612
|
|
613
|
+
// Params should always come in as an array
|
614
|
+
if (params == null) {
|
615
|
+
params = [];
|
616
|
+
}
|
617
|
+
|
618
|
+
// If there are no arguments to the event, use a temporary object
|
619
|
+
if (params.length === 0) {
|
620
|
+
params.push({});
|
621
|
+
}
|
622
|
+
|
623
|
+
// Set the `_type` of the first object to the event
|
624
|
+
params[0]._type = event;
|
625
|
+
|
612
626
|
if (event in this.listeners) {
|
613
627
|
this.invoke(this.listeners[event], slice.call(arguments, 1));
|
614
628
|
}
|
@@ -842,6 +856,25 @@ S2.define('select2/results',[
|
|
842
856
|
return sorter(data);
|
843
857
|
};
|
844
858
|
|
859
|
+
Results.prototype.highlightFirstItem = function () {
|
860
|
+
var $options = this.$results
|
861
|
+
.find('.select2-results__option[aria-selected]');
|
862
|
+
|
863
|
+
var $selected = $options.filter('[aria-selected=true]');
|
864
|
+
|
865
|
+
// Check if there are any selected options
|
866
|
+
if ($selected.length > 0) {
|
867
|
+
// If there are selected options, highlight the first
|
868
|
+
$selected.first().trigger('mouseenter');
|
869
|
+
} else {
|
870
|
+
// If there are no selected options, highlight the first option
|
871
|
+
// in the dropdown
|
872
|
+
$options.first().trigger('mouseenter');
|
873
|
+
}
|
874
|
+
|
875
|
+
this.ensureHighlightVisible();
|
876
|
+
};
|
877
|
+
|
845
878
|
Results.prototype.setClasses = function () {
|
846
879
|
var self = this;
|
847
880
|
|
@@ -869,17 +902,6 @@ S2.define('select2/results',[
|
|
869
902
|
}
|
870
903
|
});
|
871
904
|
|
872
|
-
var $selected = $options.filter('[aria-selected=true]');
|
873
|
-
|
874
|
-
// Check if there are any selected options
|
875
|
-
if ($selected.length > 0) {
|
876
|
-
// If there are selected options, highlight the first
|
877
|
-
$selected.first().trigger('mouseenter');
|
878
|
-
} else {
|
879
|
-
// If there are no selected options, highlight the first option
|
880
|
-
// in the dropdown
|
881
|
-
$options.first().trigger('mouseenter');
|
882
|
-
}
|
883
905
|
});
|
884
906
|
};
|
885
907
|
|
@@ -990,6 +1012,7 @@ S2.define('select2/results',[
|
|
990
1012
|
|
991
1013
|
if (container.isOpen()) {
|
992
1014
|
self.setClasses();
|
1015
|
+
self.highlightFirstItem();
|
993
1016
|
}
|
994
1017
|
});
|
995
1018
|
|
@@ -1012,6 +1035,7 @@ S2.define('select2/results',[
|
|
1012
1035
|
}
|
1013
1036
|
|
1014
1037
|
self.setClasses();
|
1038
|
+
self.highlightFirstItem();
|
1015
1039
|
});
|
1016
1040
|
|
1017
1041
|
container.on('unselect', function () {
|
@@ -1020,6 +1044,7 @@ S2.define('select2/results',[
|
|
1020
1044
|
}
|
1021
1045
|
|
1022
1046
|
self.setClasses();
|
1047
|
+
self.highlightFirstItem();
|
1023
1048
|
});
|
1024
1049
|
|
1025
1050
|
container.on('open', function () {
|
@@ -1142,11 +1167,7 @@ S2.define('select2/results',[
|
|
1142
1167
|
this.$results.on('mousewheel', function (e) {
|
1143
1168
|
var top = self.$results.scrollTop();
|
1144
1169
|
|
1145
|
-
var bottom = (
|
1146
|
-
self.$results.get(0).scrollHeight -
|
1147
|
-
self.$results.scrollTop() +
|
1148
|
-
e.deltaY
|
1149
|
-
);
|
1170
|
+
var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
|
1150
1171
|
|
1151
1172
|
var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
|
1152
1173
|
var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
|
@@ -1501,6 +1522,12 @@ S2.define('select2/selection/single',[
|
|
1501
1522
|
// User exits the container
|
1502
1523
|
});
|
1503
1524
|
|
1525
|
+
container.on('focus', function (evt) {
|
1526
|
+
if (!container.isOpen()) {
|
1527
|
+
self.$selection.focus();
|
1528
|
+
}
|
1529
|
+
});
|
1530
|
+
|
1504
1531
|
container.on('selection:update', function (params) {
|
1505
1532
|
self.update(params.data);
|
1506
1533
|
});
|
@@ -3332,7 +3359,7 @@ S2.define('select2/data/array',[
|
|
3332
3359
|
var $existingOption = $existing.filter(onlyItem(item));
|
3333
3360
|
|
3334
3361
|
var existingData = this.item($existingOption);
|
3335
|
-
var newData = $.extend(true, {},
|
3362
|
+
var newData = $.extend(true, {}, item, existingData);
|
3336
3363
|
|
3337
3364
|
var $newOption = this.option(newData);
|
3338
3365
|
|
@@ -3440,13 +3467,21 @@ S2.define('select2/data/ajax',[
|
|
3440
3467
|
|
3441
3468
|
callback(results);
|
3442
3469
|
}, function () {
|
3443
|
-
//
|
3470
|
+
// Attempt to detect if a request was aborted
|
3471
|
+
// Only works if the transport exposes a status property
|
3472
|
+
if ($request.status && $request.status === '0') {
|
3473
|
+
return;
|
3474
|
+
}
|
3475
|
+
|
3476
|
+
self.trigger('results:message', {
|
3477
|
+
message: 'errorLoading'
|
3478
|
+
});
|
3444
3479
|
});
|
3445
3480
|
|
3446
3481
|
self._request = $request;
|
3447
3482
|
}
|
3448
3483
|
|
3449
|
-
if (this.ajaxOptions.delay && params.term
|
3484
|
+
if (this.ajaxOptions.delay && params.term != null) {
|
3450
3485
|
if (this._queryTimeout) {
|
3451
3486
|
window.clearTimeout(this._queryTimeout);
|
3452
3487
|
}
|
@@ -3472,6 +3507,12 @@ S2.define('select2/data/tags',[
|
|
3472
3507
|
this.createTag = createTag;
|
3473
3508
|
}
|
3474
3509
|
|
3510
|
+
var insertTag = options.get('insertTag');
|
3511
|
+
|
3512
|
+
if (insertTag !== undefined) {
|
3513
|
+
this.insertTag = insertTag;
|
3514
|
+
}
|
3515
|
+
|
3475
3516
|
decorated.call(this, $element, options);
|
3476
3517
|
|
3477
3518
|
if ($.isArray(tags)) {
|
@@ -3603,6 +3644,29 @@ S2.define('select2/data/tokenizer',[
|
|
3603
3644
|
Tokenizer.prototype.query = function (decorated, params, callback) {
|
3604
3645
|
var self = this;
|
3605
3646
|
|
3647
|
+
function createAndSelect (data) {
|
3648
|
+
// Normalize the data object so we can use it for checks
|
3649
|
+
var item = self._normalizeItem(data);
|
3650
|
+
|
3651
|
+
// Check if the data object already exists as a tag
|
3652
|
+
// Select it if it doesn't
|
3653
|
+
var $existingOptions = self.$element.find('option').filter(function () {
|
3654
|
+
return $(this).val() === item.id;
|
3655
|
+
});
|
3656
|
+
|
3657
|
+
// If an existing option wasn't found for it, create the option
|
3658
|
+
if (!$existingOptions.length) {
|
3659
|
+
var $option = self.option(item);
|
3660
|
+
$option.attr('data-select2-tag', true);
|
3661
|
+
|
3662
|
+
self._removeOldTags();
|
3663
|
+
self.addOptions([$option]);
|
3664
|
+
}
|
3665
|
+
|
3666
|
+
// Select the item, now that we know there is an option for it
|
3667
|
+
select(item);
|
3668
|
+
}
|
3669
|
+
|
3606
3670
|
function select (data) {
|
3607
3671
|
self.trigger('select', {
|
3608
3672
|
data: data
|
@@ -3611,7 +3675,7 @@ S2.define('select2/data/tokenizer',[
|
|
3611
3675
|
|
3612
3676
|
params.term = params.term || '';
|
3613
3677
|
|
3614
|
-
var tokenData = this.tokenizer(params, this.options,
|
3678
|
+
var tokenData = this.tokenizer(params, this.options, createAndSelect);
|
3615
3679
|
|
3616
3680
|
if (tokenData.term !== params.term) {
|
3617
3681
|
// Replace the search term if we have the search box
|
@@ -3876,6 +3940,12 @@ S2.define('select2/dropdown/search',[
|
|
3876
3940
|
self.$search.val('');
|
3877
3941
|
});
|
3878
3942
|
|
3943
|
+
container.on('focus', function () {
|
3944
|
+
if (container.isOpen()) {
|
3945
|
+
self.$search.focus();
|
3946
|
+
}
|
3947
|
+
});
|
3948
|
+
|
3879
3949
|
container.on('results:all', function (params) {
|
3880
3950
|
if (params.query.term == null || params.query.term === '') {
|
3881
3951
|
var showSearch = self.showSearch(params);
|
@@ -4171,7 +4241,6 @@ S2.define('select2/dropdown/attachBody',[
|
|
4171
4241
|
|
4172
4242
|
var newDirection = null;
|
4173
4243
|
|
4174
|
-
var position = this.$container.position();
|
4175
4244
|
var offset = this.$container.offset();
|
4176
4245
|
|
4177
4246
|
offset.bottom = offset.top + this.$container.outerHeight(false);
|
@@ -4200,14 +4269,20 @@ S2.define('select2/dropdown/attachBody',[
|
|
4200
4269
|
top: container.bottom
|
4201
4270
|
};
|
4202
4271
|
|
4203
|
-
//
|
4204
|
-
|
4205
|
-
var parentOffset = this.$dropdownParent.offset();
|
4272
|
+
// Determine what the parent element is to use for calciulating the offset
|
4273
|
+
var $offsetParent = this.$dropdownParent;
|
4206
4274
|
|
4207
|
-
|
4208
|
-
|
4275
|
+
// For statically positoned elements, we need to get the element
|
4276
|
+
// that is determining the offset
|
4277
|
+
if ($offsetParent.css('position') === 'static') {
|
4278
|
+
$offsetParent = $offsetParent.offsetParent();
|
4209
4279
|
}
|
4210
4280
|
|
4281
|
+
var parentOffset = $offsetParent.offset();
|
4282
|
+
|
4283
|
+
css.top -= parentOffset.top;
|
4284
|
+
css.left -= parentOffset.left;
|
4285
|
+
|
4211
4286
|
if (!isCurrentlyAbove && !isCurrentlyBelow) {
|
4212
4287
|
newDirection = 'below';
|
4213
4288
|
}
|
@@ -4220,7 +4295,7 @@ S2.define('select2/dropdown/attachBody',[
|
|
4220
4295
|
|
4221
4296
|
if (newDirection == 'above' ||
|
4222
4297
|
(isCurrentlyAbove && newDirection !== 'below')) {
|
4223
|
-
css.top = container.top - dropdown.height;
|
4298
|
+
css.top = container.top - parentOffset.top - dropdown.height;
|
4224
4299
|
}
|
4225
4300
|
|
4226
4301
|
if (newDirection != null) {
|
@@ -4242,6 +4317,7 @@ S2.define('select2/dropdown/attachBody',[
|
|
4242
4317
|
|
4243
4318
|
if (this.options.get('dropdownAutoWidth')) {
|
4244
4319
|
css.minWidth = css.width;
|
4320
|
+
css.position = 'relative';
|
4245
4321
|
css.width = 'auto';
|
4246
4322
|
}
|
4247
4323
|
|
@@ -4308,12 +4384,22 @@ S2.define('select2/dropdown/selectOnClose',[
|
|
4308
4384
|
|
4309
4385
|
decorated.call(this, container, $container);
|
4310
4386
|
|
4311
|
-
container.on('close', function () {
|
4312
|
-
self._handleSelectOnClose();
|
4387
|
+
container.on('close', function (params) {
|
4388
|
+
self._handleSelectOnClose(params);
|
4313
4389
|
});
|
4314
4390
|
};
|
4315
4391
|
|
4316
|
-
SelectOnClose.prototype._handleSelectOnClose = function () {
|
4392
|
+
SelectOnClose.prototype._handleSelectOnClose = function (_, params) {
|
4393
|
+
if (params && params.originalSelect2Event != null) {
|
4394
|
+
var event = params.originalSelect2Event;
|
4395
|
+
|
4396
|
+
// Don't select an item if the close event was triggered from a select or
|
4397
|
+
// unselect event
|
4398
|
+
if (event._type === 'select' || event._type === 'unselect') {
|
4399
|
+
return;
|
4400
|
+
}
|
4401
|
+
}
|
4402
|
+
|
4317
4403
|
var $highlightedResults = this.getHighlightedResults();
|
4318
4404
|
|
4319
4405
|
// Only select highlighted results
|
@@ -4366,7 +4452,10 @@ S2.define('select2/dropdown/closeOnSelect',[
|
|
4366
4452
|
return;
|
4367
4453
|
}
|
4368
4454
|
|
4369
|
-
this.trigger('close', {
|
4455
|
+
this.trigger('close', {
|
4456
|
+
originalEvent: originalEvent,
|
4457
|
+
originalSelect2Event: evt
|
4458
|
+
});
|
4370
4459
|
};
|
4371
4460
|
|
4372
4461
|
return CloseOnSelect;
|
@@ -4474,7 +4563,7 @@ S2.define('select2/defaults',[
|
|
4474
4563
|
}
|
4475
4564
|
|
4476
4565
|
Defaults.prototype.apply = function (options) {
|
4477
|
-
options = $.extend({}, this.defaults, options);
|
4566
|
+
options = $.extend(true, {}, this.defaults, options);
|
4478
4567
|
|
4479
4568
|
if (options.dataAdapter == null) {
|
4480
4569
|
if (options.ajax != null) {
|
@@ -5038,6 +5127,7 @@ S2.define('select2/core',[
|
|
5038
5127
|
id = Utils.generateChars(4);
|
5039
5128
|
}
|
5040
5129
|
|
5130
|
+
id = id.replace(/(:|\.|\[|\]|,)/g, '');
|
5041
5131
|
id = 'select2-' + id;
|
5042
5132
|
|
5043
5133
|
return id;
|
@@ -5119,10 +5209,15 @@ S2.define('select2/core',[
|
|
5119
5209
|
});
|
5120
5210
|
});
|
5121
5211
|
|
5122
|
-
this.
|
5212
|
+
this.$element.on('focus.select2', function (evt) {
|
5213
|
+
self.trigger('focus', evt);
|
5214
|
+
});
|
5215
|
+
|
5216
|
+
this._syncA = Utils.bind(this._syncAttributes, this);
|
5217
|
+
this._syncS = Utils.bind(this._syncSubtree, this);
|
5123
5218
|
|
5124
5219
|
if (this.$element[0].attachEvent) {
|
5125
|
-
this.$element[0].attachEvent('onpropertychange', this.
|
5220
|
+
this.$element[0].attachEvent('onpropertychange', this._syncA);
|
5126
5221
|
}
|
5127
5222
|
|
5128
5223
|
var observer = window.MutationObserver ||
|
@@ -5132,14 +5227,30 @@ S2.define('select2/core',[
|
|
5132
5227
|
|
5133
5228
|
if (observer != null) {
|
5134
5229
|
this._observer = new observer(function (mutations) {
|
5135
|
-
$.each(mutations, self.
|
5230
|
+
$.each(mutations, self._syncA);
|
5231
|
+
$.each(mutations, self._syncS);
|
5136
5232
|
});
|
5137
5233
|
this._observer.observe(this.$element[0], {
|
5138
5234
|
attributes: true,
|
5235
|
+
childList: true,
|
5139
5236
|
subtree: false
|
5140
5237
|
});
|
5141
5238
|
} else if (this.$element[0].addEventListener) {
|
5142
|
-
this.$element[0].addEventListener(
|
5239
|
+
this.$element[0].addEventListener(
|
5240
|
+
'DOMAttrModified',
|
5241
|
+
self._syncA,
|
5242
|
+
false
|
5243
|
+
);
|
5244
|
+
this.$element[0].addEventListener(
|
5245
|
+
'DOMNodeInserted',
|
5246
|
+
self._syncS,
|
5247
|
+
false
|
5248
|
+
);
|
5249
|
+
this.$element[0].addEventListener(
|
5250
|
+
'DOMNodeRemoved',
|
5251
|
+
self._syncS,
|
5252
|
+
false
|
5253
|
+
);
|
5143
5254
|
}
|
5144
5255
|
};
|
5145
5256
|
|
@@ -5284,6 +5395,46 @@ S2.define('select2/core',[
|
|
5284
5395
|
}
|
5285
5396
|
};
|
5286
5397
|
|
5398
|
+
Select2.prototype._syncSubtree = function (evt, mutations) {
|
5399
|
+
var changed = false;
|
5400
|
+
var self = this;
|
5401
|
+
|
5402
|
+
// Ignore any mutation events raised for elements that aren't options or
|
5403
|
+
// optgroups. This handles the case when the select element is destroyed
|
5404
|
+
if (
|
5405
|
+
evt && evt.target && (
|
5406
|
+
evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP'
|
5407
|
+
)
|
5408
|
+
) {
|
5409
|
+
return;
|
5410
|
+
}
|
5411
|
+
|
5412
|
+
if (!mutations) {
|
5413
|
+
// If mutation events aren't supported, then we can only assume that the
|
5414
|
+
// change affected the selections
|
5415
|
+
changed = true;
|
5416
|
+
} else if (mutations.addedNodes && mutations.addedNodes.length > 0) {
|
5417
|
+
for (var n = 0; n < mutations.addedNodes.length; n++) {
|
5418
|
+
var node = mutations.addedNodes[n];
|
5419
|
+
|
5420
|
+
if (node.selected) {
|
5421
|
+
changed = true;
|
5422
|
+
}
|
5423
|
+
}
|
5424
|
+
} else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
|
5425
|
+
changed = true;
|
5426
|
+
}
|
5427
|
+
|
5428
|
+
// Only re-pull the data if we think there is a change
|
5429
|
+
if (changed) {
|
5430
|
+
this.dataAdapter.current(function (currentData) {
|
5431
|
+
self.trigger('selection:update', {
|
5432
|
+
data: currentData
|
5433
|
+
});
|
5434
|
+
});
|
5435
|
+
}
|
5436
|
+
};
|
5437
|
+
|
5287
5438
|
/**
|
5288
5439
|
* Override the trigger method to automatically trigger pre-events when
|
5289
5440
|
* there are events that can be prevented.
|
@@ -5430,7 +5581,7 @@ S2.define('select2/core',[
|
|
5430
5581
|
this.$container.remove();
|
5431
5582
|
|
5432
5583
|
if (this.$element[0].detachEvent) {
|
5433
|
-
this.$element[0].detachEvent('onpropertychange', this.
|
5584
|
+
this.$element[0].detachEvent('onpropertychange', this._syncA);
|
5434
5585
|
}
|
5435
5586
|
|
5436
5587
|
if (this._observer != null) {
|
@@ -5438,10 +5589,15 @@ S2.define('select2/core',[
|
|
5438
5589
|
this._observer = null;
|
5439
5590
|
} else if (this.$element[0].removeEventListener) {
|
5440
5591
|
this.$element[0]
|
5441
|
-
.removeEventListener('DOMAttrModified', this.
|
5592
|
+
.removeEventListener('DOMAttrModified', this._syncA, false);
|
5593
|
+
this.$element[0]
|
5594
|
+
.removeEventListener('DOMNodeInserted', this._syncS, false);
|
5595
|
+
this.$element[0]
|
5596
|
+
.removeEventListener('DOMNodeRemoved', this._syncS, false);
|
5442
5597
|
}
|
5443
5598
|
|
5444
|
-
this.
|
5599
|
+
this._syncA = null;
|
5600
|
+
this._syncS = null;
|
5445
5601
|
|
5446
5602
|
this.$element.off('.select2');
|
5447
5603
|
this.$element.attr('tabindex', this.$element.data('old-tabindex'));
|
@@ -5514,6 +5670,7 @@ S2.define('jquery.select2',[
|
|
5514
5670
|
return this;
|
5515
5671
|
} else if (typeof options === 'string') {
|
5516
5672
|
var ret;
|
5673
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
5517
5674
|
|
5518
5675
|
this.each(function () {
|
5519
5676
|
var instance = $(this).data('select2');
|
@@ -5525,8 +5682,6 @@ S2.define('jquery.select2',[
|
|
5525
5682
|
);
|
5526
5683
|
}
|
5527
5684
|
|
5528
|
-
var args = Array.prototype.slice.call(arguments, 1);
|
5529
|
-
|
5530
5685
|
ret = instance[options].apply(instance, args);
|
5531
5686
|
});
|
5532
5687
|
|
@@ -184,6 +184,8 @@
|
|
184
184
|
margin: 0;
|
185
185
|
padding: 0 5px;
|
186
186
|
width: 100%; }
|
187
|
+
.select2-container--default .select2-selection--multiple .select2-selection__rendered li {
|
188
|
+
list-style: none; }
|
187
189
|
.select2-container--default .select2-selection--multiple .select2-selection__placeholder {
|
188
190
|
color: #999;
|
189
191
|
margin-top: 5px;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_form_inputs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|