Skip to content

Commit abc8a56

Browse files
committed
Released 0.12.3.
1 parent f8aeefb commit abc8a56

15 files changed

+195
-57
lines changed

dist/css/selectize.bootstrap2.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* selectize.bootstrap2.css (v0.12.2) - Bootstrap 2 Theme
2+
* selectize.bootstrap2.css (v0.12.3) - Bootstrap 2 Theme
33
* Copyright (c) 2013–2015 Brian Reavis & contributors
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this

dist/css/selectize.bootstrap3.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* selectize.bootstrap3.css (v0.12.2) - Bootstrap 3 Theme
2+
* selectize.bootstrap3.css (v0.12.3) - Bootstrap 3 Theme
33
* Copyright (c) 2013–2015 Brian Reavis & contributors
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this

dist/css/selectize.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* selectize.css (v0.12.2)
2+
* selectize.css (v0.12.3)
33
* Copyright (c) 2013–2015 Brian Reavis & contributors
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this

dist/css/selectize.default.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* selectize.default.css (v0.12.2) - Default Theme
2+
* selectize.default.css (v0.12.3) - Default Theme
33
* Copyright (c) 2013–2015 Brian Reavis & contributors
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this

dist/css/selectize.legacy.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* selectize.legacy.css (v0.12.2) - Default Theme
2+
* selectize.legacy.css (v0.12.3) - Default Theme
33
* Copyright (c) 2013–2015 Brian Reavis & contributors
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this

dist/js/selectize.js

Lines changed: 89 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* selectize.js (v0.12.2)
2+
* selectize.js (v0.12.3)
33
* Copyright (c) 2013–2015 Brian Reavis & contributors
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
@@ -60,6 +60,20 @@
6060
});
6161
};
6262

63+
/**
64+
* removeHighlight fn copied from highlight v5 and
65+
* edited to remove with() and pass js strict mode
66+
*/
67+
jQuery.fn.removeHighlight = function() {
68+
return this.find("span.highlight").each(function() {
69+
this.parentNode.firstChild.nodeName;
70+
var parent = this.parentNode;
71+
parent.replaceChild(this.firstChild, this);
72+
parent.normalize();
73+
}).end();
74+
};
75+
76+
6377
var MicroEvent = function() {};
6478
MicroEvent.prototype = {
6579
on: function(event, fct){
@@ -122,7 +136,8 @@
122136
var TAG_INPUT = 2;
123137

124138
// for now, android support in general is too spotty to support validity
125-
var SUPPORTS_VALIDITY_API = !/android/i.test(window.navigator.userAgent) && !!document.createElement('form').validity;
139+
var SUPPORTS_VALIDITY_API = !/android/i.test(window.navigator.userAgent) && !!document.createElement('input').validity;
140+
126141

127142
var isset = function(object) {
128143
return typeof object !== 'undefined';
@@ -452,6 +467,20 @@
452467
return tmp.innerHTML;
453468
};
454469

470+
var logError = function(message, options){
471+
if(!options) options = {};
472+
var component = "Selectize";
473+
474+
console.error(component + ": " + message)
475+
476+
if(options.explanation){
477+
// console.group is undefined in <IE11
478+
if(console.group) console.group();
479+
console.error(options.explanation);
480+
if(console.group) console.groupEnd();
481+
}
482+
}
483+
455484

456485
var Selectize = function($input, settings) {
457486
var key, i, n, dir, input, self = this;
@@ -541,7 +570,18 @@
541570
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
542571

543572
MicroEvent.mixin(Selectize);
544-
MicroPlugin.mixin(Selectize);
573+
574+
if(typeof MicroPlugin !== "undefined"){
575+
MicroPlugin.mixin(Selectize);
576+
}else{
577+
logError("Dependency MicroPlugin is missing",
578+
{explanation:
579+
"Make sure you either: (1) are using the \"standalone\" "+
580+
"version of Selectize, or (2) require MicroPlugin before you "+
581+
"load Selectize."}
582+
);
583+
}
584+
545585

546586
// methods
547587
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -570,6 +610,7 @@
570610
var timeout_focus;
571611
var classes;
572612
var classes_plugins;
613+
var inputId;
573614

574615
inputMode = self.settings.mode;
575616
classes = $input.attr('class') || '';
@@ -581,6 +622,11 @@
581622
$dropdown = $('<div>').addClass(settings.dropdownClass).addClass(inputMode).hide().appendTo($dropdown_parent);
582623
$dropdown_content = $('<div>').addClass(settings.dropdownContentClass).appendTo($dropdown);
583624

625+
if(inputId = $input.attr('id')) {
626+
$control_input.attr('id', inputId + '-selectized');
627+
$("label[for='"+inputId+"']").attr('for', inputId + '-selectized');
628+
}
629+
584630
if(self.settings.copyClassesToDropdown) {
585631
$dropdown.addClass(classes);
586632
}
@@ -856,19 +902,26 @@
856902
*/
857903
onPaste: function(e) {
858904
var self = this;
905+
859906
if (self.isFull() || self.isInputHidden || self.isLocked) {
860907
e.preventDefault();
861-
} else {
862-
// If a regex or string is included, this will split the pasted
863-
// input and create Items for each separate value
864-
if (self.settings.splitOn) {
865-
setTimeout(function() {
866-
var splitInput = $.trim(self.$control_input.val() || '').split(self.settings.splitOn);
867-
for (var i = 0, n = splitInput.length; i < n; i++) {
868-
self.createItem(splitInput[i]);
869-
}
870-
}, 0);
871-
}
908+
return;
909+
}
910+
911+
// If a regex or string is included, this will split the pasted
912+
// input and create Items for each separate value
913+
if (self.settings.splitOn) {
914+
915+
// Wait for pasted text to be recognized in value
916+
setTimeout(function() {
917+
var pastedText = self.$control_input.val();
918+
if(!pastedText.match(self.settings.splitOn)){ return }
919+
920+
var splitInput = $.trim(pastedText).split(self.settings.splitOn);
921+
for (var i = 0, n = splitInput.length; i < n; i++) {
922+
self.createItem(splitInput[i]);
923+
}
924+
}, 0);
872925
}
873926
},
874927

@@ -1555,6 +1608,7 @@
15551608

15561609
// highlight matching terms inline
15571610
if (self.settings.highlight && results.query.length && results.tokens.length) {
1611+
$dropdown_content.removeHighlight();
15581612
for (i = 0, n = results.tokens.length; i < n; i++) {
15591613
highlight($dropdown_content, results.tokens[i].regex);
15601614
}
@@ -2052,12 +2106,26 @@
20522106
* and CSS classes.
20532107
*/
20542108
refreshState: function() {
2055-
var invalid, self = this;
2056-
if (self.isRequired) {
2057-
if (self.items.length) self.isInvalid = false;
2058-
self.$control_input.prop('required', invalid);
2059-
}
2060-
self.refreshClasses();
2109+
this.refreshValidityState();
2110+
this.refreshClasses();
2111+
},
2112+
2113+
/**
2114+
* Update the `required` attribute of both input and control input.
2115+
*
2116+
* The `required` property needs to be activated on the control input
2117+
* for the error to be displayed at the right place. `required` also
2118+
* needs to be temporarily deactivated on the input since the input is
2119+
* hidden and can't show errors.
2120+
*/
2121+
refreshValidityState: function() {
2122+
if (!this.isRequired) return false;
2123+
2124+
var invalid = !this.items.length;
2125+
2126+
this.isInvalid = invalid;
2127+
this.$control_input.prop('required', invalid);
2128+
this.$input.prop('required', !invalid);
20612129
},
20622130

20632131
/**
@@ -2168,6 +2236,7 @@
21682236

21692237
if (self.settings.mode === 'single' && self.items.length) {
21702238
self.hideInput();
2239+
self.$control_input.blur(); // close keyboard on iOS
21712240
}
21722241

21732242
self.isOpen = false;

dist/js/selectize.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)