mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
dca8c0cb6f
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92557 467b73ca-7a2a-4603-9d3b-597d59a354a9
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
(function($){
|
|
|
|
/**
|
|
* Add focusin and focusout support to bind and live for browers other than IE. Designed to be usable in a delegated fashion (like $.live)
|
|
* Copyright (c) 2007 Jörn Zaefferer
|
|
*/
|
|
$.support.focusInOut = !!($.browser.msie);
|
|
if (!$.support.focusInOut) {
|
|
// Emulate focusin and focusout by binding focus and blur in capturing mode
|
|
$.each({focus: 'focusin', blur: 'focusout'}, function(original, fix){
|
|
$.event.special[fix] = {
|
|
setup: function(){
|
|
if (!this.addEventListener) return false;
|
|
this.addEventListener(original, $.event.special[fix].handler, true);
|
|
},
|
|
teardown: function(){
|
|
if (!this.removeEventListener) return false;
|
|
this.removeEventListener(original, $.event.special[fix].handler, true);
|
|
},
|
|
handler: function(e){
|
|
arguments[0] = $.event.fix(e);
|
|
arguments[0].type = fix;
|
|
return $.event.handle.apply(this, arguments);
|
|
}
|
|
};
|
|
});
|
|
}
|
|
|
|
(function(){
|
|
//IE has some trouble with focusout with select and keyboard navigation
|
|
var activeFocus = null;
|
|
|
|
$(document)
|
|
.bind('focusin', function(e){
|
|
var target = e.realTarget || e.target;
|
|
if (activeFocus && activeFocus !== target) {
|
|
e.type = 'focusout';
|
|
$(activeFocus).trigger(e);
|
|
e.type = 'focusin';
|
|
e.target = target;
|
|
}
|
|
activeFocus = target;
|
|
})
|
|
.bind('focusout', function(e){
|
|
activeFocus = null;
|
|
});
|
|
})();
|
|
|
|
})(jQuery); |