Merge branch 'master' of github.com:ivaynberg/select2
This commit is contained in:
commit
5d496bd470
78
select2.js
78
select2.js
@ -1092,6 +1092,8 @@
|
|||||||
this makes sure the search field is focussed even if the current event would blur it */
|
this makes sure the search field is focussed even if the current event would blur it */
|
||||||
window.setTimeout(this.bind(function () {
|
window.setTimeout(this.bind(function () {
|
||||||
this.search.focus();
|
this.search.focus();
|
||||||
|
// reset the value so IE places the cursor at the end of the input box
|
||||||
|
this.search.val(this.search.val());
|
||||||
}), 10);
|
}), 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1206,7 +1208,7 @@
|
|||||||
// single
|
// single
|
||||||
focus: function () {
|
focus: function () {
|
||||||
this.close();
|
this.close();
|
||||||
this.search.focus();
|
this.container.focus();
|
||||||
},
|
},
|
||||||
|
|
||||||
// single
|
// single
|
||||||
@ -1217,7 +1219,7 @@
|
|||||||
// single
|
// single
|
||||||
cancel: function () {
|
cancel: function () {
|
||||||
this.parent.cancel.apply(this, arguments);
|
this.parent.cancel.apply(this, arguments);
|
||||||
this.search.focus();
|
this.container.focus();
|
||||||
},
|
},
|
||||||
|
|
||||||
// single
|
// single
|
||||||
@ -1256,7 +1258,47 @@
|
|||||||
killEvent(e);
|
killEvent(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
selection.bind("click", this.bind(function (e) {
|
||||||
|
clickingInside = true;
|
||||||
|
|
||||||
|
if (this.opened()) {
|
||||||
|
this.close();
|
||||||
|
this.container.focus();
|
||||||
|
} else if (this.enabled) {
|
||||||
|
this.open();
|
||||||
|
}
|
||||||
|
killEvent(e);
|
||||||
|
|
||||||
|
clickingInside = false;
|
||||||
|
}));
|
||||||
|
|
||||||
|
dropdown.bind("click", this.bind(function() { this.search.focus(); }));
|
||||||
|
|
||||||
|
container.bind("focus", this.bind(function() {
|
||||||
|
// allows the container to recieve the keyup event
|
||||||
|
this.container.attr("tabindex", 1);
|
||||||
|
}));
|
||||||
|
|
||||||
|
container.bind("blur", this.bind(function() {
|
||||||
|
// remove the tabindex so the tab key works properly
|
||||||
|
this.container.attr("tabindex", -1);
|
||||||
|
}));
|
||||||
|
|
||||||
|
container.bind("keydown", this.bind(function(e) {
|
||||||
|
if (!this.enabled) return;
|
||||||
|
|
||||||
|
this.container.attr("tabindex", -1);
|
||||||
|
|
||||||
|
if (e.which === KEY.PAGE_UP || e.which === KEY.PAGE_DOWN) {
|
||||||
|
// prevent the page from scrolling
|
||||||
|
killEvent(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.opened()) {
|
||||||
if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) {
|
if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1268,32 +1310,24 @@
|
|||||||
killEvent(e);
|
killEvent(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var keyWritten = String.fromCharCode(e.which).toLowerCase();
|
||||||
|
|
||||||
|
if (e.shiftKey) {
|
||||||
|
keyWritten = keyWritten.toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.search.val(keyWritten);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
selection.bind("click", this.bind(function (e) {
|
|
||||||
clickingInside = true;
|
|
||||||
|
|
||||||
if (this.opened()) {
|
|
||||||
this.close();
|
|
||||||
this.search.focus();
|
|
||||||
} else if (this.enabled) {
|
|
||||||
this.open();
|
|
||||||
}
|
|
||||||
killEvent(e);
|
|
||||||
|
|
||||||
clickingInside = false;
|
|
||||||
}));
|
|
||||||
|
|
||||||
dropdown.bind("click", this.bind(function() { this.search.focus(); }));
|
|
||||||
|
|
||||||
selection.delegate("abbr", "click", this.bind(function (e) {
|
selection.delegate("abbr", "click", this.bind(function (e) {
|
||||||
if (!this.enabled) return;
|
if (!this.enabled) return;
|
||||||
this.clear();
|
this.clear();
|
||||||
killEvent(e);
|
killEvent(e);
|
||||||
this.close();
|
this.close();
|
||||||
this.triggerChange();
|
this.triggerChange();
|
||||||
this.search.focus();
|
this.container.focus();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
selection.bind("focus", this.bind(function() { this.search.focus(); }));
|
selection.bind("focus", this.bind(function() { this.search.focus(); }));
|
||||||
@ -1406,7 +1440,7 @@
|
|||||||
this.opts.element.val(this.id(data));
|
this.opts.element.val(this.id(data));
|
||||||
this.updateSelection(data);
|
this.updateSelection(data);
|
||||||
this.close();
|
this.close();
|
||||||
this.search.focus();
|
this.container.focus();
|
||||||
|
|
||||||
if (!equal(old, this.id(data))) { this.triggerChange(); }
|
if (!equal(old, this.id(data))) { this.triggerChange(); }
|
||||||
},
|
},
|
||||||
@ -1700,7 +1734,7 @@
|
|||||||
// multi
|
// multi
|
||||||
focus: function () {
|
focus: function () {
|
||||||
this.close();
|
this.close();
|
||||||
this.search.focus();
|
this.container.focus();
|
||||||
},
|
},
|
||||||
|
|
||||||
// multi
|
// multi
|
||||||
|
Loading…
Reference in New Issue
Block a user