select2-rails 3.5.0 → 3.5.1
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.
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
Copyright 2012 Igor Vaynberg
|
3
3
|
|
4
|
-
Version: 3.4.
|
4
|
+
Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
|
5
5
|
|
6
6
|
This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
|
7
7
|
General Public License version 2 (the "GPL License"). You may choose either license to govern your
|
@@ -349,7 +349,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
349
349
|
if (this.indexOf("select2-") !== 0) {
|
350
350
|
adapted = adapter(this);
|
351
351
|
if (adapted) {
|
352
|
-
replacements.push(
|
352
|
+
replacements.push(adapted);
|
353
353
|
}
|
354
354
|
}
|
355
355
|
});
|
@@ -654,7 +654,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
654
654
|
|
655
655
|
// abstract
|
656
656
|
init: function (opts) {
|
657
|
-
var results, search, resultsSelector = ".select2-results"
|
657
|
+
var results, search, resultsSelector = ".select2-results";
|
658
658
|
|
659
659
|
// prepare options
|
660
660
|
this.opts = opts = this.prepareOpts(opts);
|
@@ -726,7 +726,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
726
726
|
// if jquery.mousewheel plugin is installed we can prevent out-of-bounds scrolling of results via mousewheel
|
727
727
|
if ($.fn.mousewheel) {
|
728
728
|
results.mousewheel(function (e, delta, deltaX, deltaY) {
|
729
|
-
var top = results.scrollTop()
|
729
|
+
var top = results.scrollTop();
|
730
730
|
if (deltaY > 0 && top - deltaY <= 0) {
|
731
731
|
results.scrollTop(0);
|
732
732
|
killEvent(e);
|
@@ -852,7 +852,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
852
852
|
|
853
853
|
opts = $.extend({}, {
|
854
854
|
populateResults: function(container, results, query) {
|
855
|
-
var populate,
|
855
|
+
var populate, id=this.opts.id;
|
856
856
|
|
857
857
|
populate=function(results, container, depth) {
|
858
858
|
|
@@ -999,7 +999,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
999
999
|
*/
|
1000
1000
|
// abstract
|
1001
1001
|
monitorSource: function () {
|
1002
|
-
var el = this.opts.element, sync;
|
1002
|
+
var el = this.opts.element, sync, observer;
|
1003
1003
|
|
1004
1004
|
el.on("change.select2", this.bind(function (e) {
|
1005
1005
|
if (this.opts.element.data("select2-change-triggered") !== true) {
|
@@ -1009,8 +1009,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1009
1009
|
|
1010
1010
|
sync = this.bind(function () {
|
1011
1011
|
|
1012
|
-
var enabled, readonly, self = this;
|
1013
|
-
|
1014
1012
|
// sync enabled state
|
1015
1013
|
var disabled = el.prop("disabled");
|
1016
1014
|
if (disabled === undefined) disabled = false;
|
@@ -1028,9 +1026,8 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1028
1026
|
|
1029
1027
|
});
|
1030
1028
|
|
1031
|
-
//
|
1032
|
-
el.on("propertychange.select2
|
1033
|
-
|
1029
|
+
// IE8-10
|
1030
|
+
el.on("propertychange.select2", sync);
|
1034
1031
|
|
1035
1032
|
// hold onto a reference of the callback to work around a chromium bug
|
1036
1033
|
if (this.mutationCallback === undefined) {
|
@@ -1039,10 +1036,11 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1039
1036
|
}
|
1040
1037
|
}
|
1041
1038
|
|
1042
|
-
// safari
|
1043
|
-
|
1039
|
+
// safari, chrome, firefox, IE11
|
1040
|
+
observer = window.MutationObserver || window.WebKitMutationObserver|| window.MozMutationObserver;
|
1041
|
+
if (observer !== undefined) {
|
1044
1042
|
if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; }
|
1045
|
-
this.propertyObserver = new
|
1043
|
+
this.propertyObserver = new observer(this.mutationCallback);
|
1046
1044
|
this.propertyObserver.observe(el.get(0), { attributes:true, subtree:false });
|
1047
1045
|
}
|
1048
1046
|
},
|
@@ -1135,8 +1133,11 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1135
1133
|
height = this.container.outerHeight(false),
|
1136
1134
|
width = this.container.outerWidth(false),
|
1137
1135
|
dropHeight = $dropdown.outerHeight(false),
|
1138
|
-
|
1139
|
-
|
1136
|
+
$window = $(window),
|
1137
|
+
windowWidth = $window.width(),
|
1138
|
+
windowHeight = $window.height(),
|
1139
|
+
viewPortRight = $window.scrollLeft() + windowWidth,
|
1140
|
+
viewportBottom = $window.scrollTop() + windowHeight,
|
1140
1141
|
dropTop = offset.top + height,
|
1141
1142
|
dropLeft = offset.left,
|
1142
1143
|
enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
|
@@ -1146,9 +1147,41 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1146
1147
|
aboveNow = $dropdown.hasClass("select2-drop-above"),
|
1147
1148
|
bodyOffset,
|
1148
1149
|
above,
|
1150
|
+
changeDirection,
|
1149
1151
|
css,
|
1150
1152
|
resultsListNode;
|
1151
1153
|
|
1154
|
+
// always prefer the current above/below alignment, unless there is not enough room
|
1155
|
+
if (aboveNow) {
|
1156
|
+
above = true;
|
1157
|
+
if (!enoughRoomAbove && enoughRoomBelow) {
|
1158
|
+
changeDirection = true;
|
1159
|
+
above = false;
|
1160
|
+
}
|
1161
|
+
} else {
|
1162
|
+
above = false;
|
1163
|
+
if (!enoughRoomBelow && enoughRoomAbove) {
|
1164
|
+
changeDirection = true;
|
1165
|
+
above = true;
|
1166
|
+
}
|
1167
|
+
}
|
1168
|
+
|
1169
|
+
//if we are changing direction we need to get positions when dropdown is hidden;
|
1170
|
+
if (changeDirection) {
|
1171
|
+
$dropdown.hide();
|
1172
|
+
offset = this.container.offset();
|
1173
|
+
height = this.container.outerHeight(false);
|
1174
|
+
width = this.container.outerWidth(false);
|
1175
|
+
dropHeight = $dropdown.outerHeight(false);
|
1176
|
+
viewPortRight = $window.scrollLeft() + windowWidth;
|
1177
|
+
viewportBottom = $window.scrollTop() + windowHeight;
|
1178
|
+
dropTop = offset.top + height;
|
1179
|
+
dropLeft = offset.left;
|
1180
|
+
dropWidth = $dropdown.outerWidth(false);
|
1181
|
+
enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight;
|
1182
|
+
$dropdown.show();
|
1183
|
+
}
|
1184
|
+
|
1152
1185
|
if (this.opts.dropdownAutoWidth) {
|
1153
1186
|
resultsListNode = $('.select2-results', $dropdown)[0];
|
1154
1187
|
$dropdown.addClass('select2-drop-auto-width');
|
@@ -1172,34 +1205,28 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1172
1205
|
dropLeft -= bodyOffset.left;
|
1173
1206
|
}
|
1174
1207
|
|
1175
|
-
// always prefer the current above/below alignment, unless there is not enough room
|
1176
|
-
if (aboveNow) {
|
1177
|
-
above = true;
|
1178
|
-
if (!enoughRoomAbove && enoughRoomBelow) above = false;
|
1179
|
-
} else {
|
1180
|
-
above = false;
|
1181
|
-
if (!enoughRoomBelow && enoughRoomAbove) above = true;
|
1182
|
-
}
|
1183
|
-
|
1184
1208
|
if (!enoughRoomOnRight) {
|
1185
1209
|
dropLeft = offset.left + width - dropWidth;
|
1186
1210
|
}
|
1187
1211
|
|
1212
|
+
css = {
|
1213
|
+
left: dropLeft,
|
1214
|
+
width: width
|
1215
|
+
};
|
1216
|
+
|
1188
1217
|
if (above) {
|
1189
|
-
|
1218
|
+
css.bottom = windowHeight - offset.top;
|
1219
|
+
css.top = 'auto';
|
1190
1220
|
this.container.addClass("select2-drop-above");
|
1191
1221
|
$dropdown.addClass("select2-drop-above");
|
1192
1222
|
}
|
1193
1223
|
else {
|
1224
|
+
css.top = dropTop;
|
1225
|
+
css.bottom = 'auto';
|
1194
1226
|
this.container.removeClass("select2-drop-above");
|
1195
1227
|
$dropdown.removeClass("select2-drop-above");
|
1196
1228
|
}
|
1197
|
-
|
1198
|
-
css = $.extend({
|
1199
|
-
top: dropTop,
|
1200
|
-
left: dropLeft,
|
1201
|
-
width: width
|
1202
|
-
}, evaluate(this.opts.dropdownCss));
|
1229
|
+
css = $.extend(css, evaluate(this.opts.dropdownCss));
|
1203
1230
|
|
1204
1231
|
$dropdown.css(css);
|
1205
1232
|
},
|
@@ -1249,7 +1276,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1249
1276
|
scroll = "scroll." + cid,
|
1250
1277
|
resize = "resize."+cid,
|
1251
1278
|
orient = "orientationchange."+cid,
|
1252
|
-
mask
|
1279
|
+
mask;
|
1253
1280
|
|
1254
1281
|
this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
|
1255
1282
|
|
@@ -1273,7 +1300,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1273
1300
|
if (self.opts.selectOnBlur) {
|
1274
1301
|
self.selectHighlighted({noFocus: true});
|
1275
1302
|
}
|
1276
|
-
self.close({focus:
|
1303
|
+
self.close({focus:true});
|
1277
1304
|
e.preventDefault();
|
1278
1305
|
e.stopPropagation();
|
1279
1306
|
}
|
@@ -1402,7 +1429,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1402
1429
|
|
1403
1430
|
// abstract
|
1404
1431
|
findHighlightableChoices: function() {
|
1405
|
-
return this.results.find(".select2-result-selectable:not(.select2-disabled)");
|
1432
|
+
return this.results.find(".select2-result-selectable:not(.select2-disabled, .select2-selected)");
|
1406
1433
|
},
|
1407
1434
|
|
1408
1435
|
// abstract
|
@@ -1472,7 +1499,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1472
1499
|
var results = this.results,
|
1473
1500
|
more = results.find("li.select2-more-results"),
|
1474
1501
|
below, // pixels the element is below the scroll fold, below==0 is when the element is starting to be visible
|
1475
|
-
offset = -1, // index of first element without data
|
1476
1502
|
page = this.resultsPage + 1,
|
1477
1503
|
self=this,
|
1478
1504
|
term=this.search.val(),
|
@@ -1708,7 +1734,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1708
1734
|
// abstract
|
1709
1735
|
getPlaceholderOption: function() {
|
1710
1736
|
if (this.select) {
|
1711
|
-
var firstOption = this.select.children().first();
|
1737
|
+
var firstOption = this.select.children('option').first();
|
1712
1738
|
if (this.opts.placeholderOption !== undefined ) {
|
1713
1739
|
//Determine the placeholder option based on the specified placeholderOption setting
|
1714
1740
|
return (this.opts.placeholderOption === "first" && firstOption) ||
|
@@ -1729,7 +1755,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1729
1755
|
// abstract
|
1730
1756
|
initContainerWidth: function () {
|
1731
1757
|
function resolveContainerWidth() {
|
1732
|
-
var style, attrs, matches, i, l;
|
1758
|
+
var style, attrs, matches, i, l, attr;
|
1733
1759
|
|
1734
1760
|
if (this.opts.width === "off") {
|
1735
1761
|
return null;
|
@@ -1741,8 +1767,8 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
1741
1767
|
if (style !== undefined) {
|
1742
1768
|
attrs = style.split(';');
|
1743
1769
|
for (i = 0, l = attrs.length; i < l; i = i + 1) {
|
1744
|
-
|
1745
|
-
|
1770
|
+
attr = attrs[i].replace(/\s/g, '');
|
1771
|
+
matches = attr.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i);
|
1746
1772
|
if (matches !== null && matches.length >= 1)
|
1747
1773
|
return matches[1];
|
1748
1774
|
}
|
@@ -2093,7 +2119,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
2093
2119
|
isPlaceholderOptionSelected: function() {
|
2094
2120
|
var placeholderOption;
|
2095
2121
|
if (!this.getPlaceholder()) return false; // no placeholder specified so no option should be considered
|
2096
|
-
return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.
|
2122
|
+
return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.prop("selected"))
|
2097
2123
|
|| (this.opts.element.val() === "")
|
2098
2124
|
|| (this.opts.element.val() === undefined)
|
2099
2125
|
|| (this.opts.element.val() === null);
|
@@ -2107,7 +2133,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
2107
2133
|
if (opts.element.get(0).tagName.toLowerCase() === "select") {
|
2108
2134
|
// install the selection initializer
|
2109
2135
|
opts.initSelection = function (element, callback) {
|
2110
|
-
var selected = element.find("
|
2136
|
+
var selected = element.find("option").filter(function() { return this.selected });
|
2111
2137
|
// a single select box always has a value, no need to null check 'selected'
|
2112
2138
|
callback(self.optionToData(selected));
|
2113
2139
|
};
|
@@ -2277,7 +2303,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
2277
2303
|
if (this.select) {
|
2278
2304
|
this.select
|
2279
2305
|
.val(val)
|
2280
|
-
.find("
|
2306
|
+
.find("option").filter(function() { return this.selected }).each2(function (i, elm) {
|
2281
2307
|
data = self.optionToData(elm);
|
2282
2308
|
return false;
|
2283
2309
|
});
|
@@ -2372,7 +2398,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
2372
2398
|
|
2373
2399
|
var data = [];
|
2374
2400
|
|
2375
|
-
element.find("
|
2401
|
+
element.find("option").filter(function() { return this.selected }).each2(function (i, elm) {
|
2376
2402
|
data.push(self.optionToData(elm));
|
2377
2403
|
});
|
2378
2404
|
callback(data);
|
@@ -2853,9 +2879,17 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
2853
2879
|
this.setVal(val);
|
2854
2880
|
if (this.select) this.postprocessResults();
|
2855
2881
|
}
|
2856
|
-
selected.remove();
|
2857
2882
|
|
2858
|
-
|
2883
|
+
var evt = $.Event("select2-removing");
|
2884
|
+
evt.val = this.id(data);
|
2885
|
+
evt.choice = data;
|
2886
|
+
this.opts.element.trigger(evt);
|
2887
|
+
|
2888
|
+
if (evt.isDefaultPrevented()) {
|
2889
|
+
return;
|
2890
|
+
}
|
2891
|
+
|
2892
|
+
this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
|
2859
2893
|
this.triggerChange({ removed: data });
|
2860
2894
|
},
|
2861
2895
|
|
@@ -2982,7 +3016,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
2982
3016
|
|
2983
3017
|
// multi
|
2984
3018
|
val: function (val, triggerChange) {
|
2985
|
-
var oldData, self=this
|
3019
|
+
var oldData, self=this;
|
2986
3020
|
|
2987
3021
|
if (arguments.length === 0) {
|
2988
3022
|
return this.getVal();
|
@@ -3021,7 +3055,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
3021
3055
|
self.updateSelection(data);
|
3022
3056
|
self.clearSearch();
|
3023
3057
|
if (triggerChange) {
|
3024
|
-
self.triggerChange(self.buildChangeDetails(oldData,
|
3058
|
+
self.triggerChange(self.buildChangeDetails(oldData, self.data()));
|
3025
3059
|
}
|
3026
3060
|
});
|
3027
3061
|
}
|
@@ -8,9 +8,9 @@
|
|
8
8
|
|
9
9
|
$.extend($.fn.select2.defaults, {
|
10
10
|
formatNoMatches: function () { return "Δεν βρέθηκαν αποτελέσματα"; },
|
11
|
-
formatInputTooShort: function (input, min) { var n = min - input.length; return "Παρακαλούμε εισάγετε " + n + "
|
12
|
-
formatInputTooLong: function (input, max) { var n = input.length - max; return "Παρακαλούμε διαγράψτε " + n + "
|
13
|
-
formatSelectionTooBig: function (limit) { return "Μπορείτε να επιλέξετε μόνο " + limit + "
|
11
|
+
formatInputTooShort: function (input, min) { var n = min - input.length; return "Παρακαλούμε εισάγετε " + n + " περισσότερο" + (n == 1 ? "" : "υς") + " χαρακτήρ" + (n == 1 ? "α" : "ες"); },
|
12
|
+
formatInputTooLong: function (input, max) { var n = input.length - max; return "Παρακαλούμε διαγράψτε " + n + " χαρακτήρ" + (n == 1 ? "α" : "ες"); },
|
13
|
+
formatSelectionTooBig: function (limit) { return "Μπορείτε να επιλέξετε μόνο " + limit + " αντικείμεν" + (limit == 1 ? "ο" : "α"); },
|
14
14
|
formatLoadMore: function (pageNumber) { return "Φόρτωση περισσότερων..."; },
|
15
15
|
formatSearching: function () { return "Αναζήτηση..."; }
|
16
16
|
});
|
@@ -9,11 +9,11 @@
|
|
9
9
|
},
|
10
10
|
formatInputTooShort: function (input, min) {
|
11
11
|
var n = min - input.length;
|
12
|
-
return "Ole hyvä ja anna " + n + " merkkiä
|
12
|
+
return "Ole hyvä ja anna " + n + " merkkiä lisää";
|
13
13
|
},
|
14
14
|
formatInputTooLong: function (input, max) {
|
15
15
|
var n = input.length - max;
|
16
|
-
return "Ole hyvä ja
|
16
|
+
return "Ole hyvä ja anna " + n + " merkkiä vähemmän";
|
17
17
|
},
|
18
18
|
formatSelectionTooBig: function (limit) {
|
19
19
|
return "Voit valita ainoastaan " + limit + " kpl";
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: select2-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-10-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
@@ -154,12 +154,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
154
|
- - ! '>='
|
155
155
|
- !ruby/object:Gem::Version
|
156
156
|
version: '0'
|
157
|
+
segments:
|
158
|
+
- 0
|
159
|
+
hash: -3706961845905186501
|
157
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
161
|
none: false
|
159
162
|
requirements:
|
160
163
|
- - ! '>='
|
161
164
|
- !ruby/object:Gem::Version
|
162
165
|
version: '0'
|
166
|
+
segments:
|
167
|
+
- 0
|
168
|
+
hash: -3706961845905186501
|
163
169
|
requirements: []
|
164
170
|
rubyforge_project:
|
165
171
|
rubygems_version: 1.8.25
|
@@ -167,4 +173,3 @@ signing_key:
|
|
167
173
|
specification_version: 3
|
168
174
|
summary: Integrate Select2 javascript library with Rails asset pipeline
|
169
175
|
test_files: []
|
170
|
-
has_rdoc:
|