@Ghazascanner
_2019runbot
Ghazascanner File Manager
server :Linux phosweb009 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64
Current Path :
/
homepage
/
v-mt
/
mt-static
/
js
/
tc
/
Path :
Upload File :
New :
File
Dir
//homepage/v-mt/mt-static/js/tc/focus.js
/* # Movable Type (r) (C) 2003-2008 Six Apart, Ltd. All Rights Reserved. # This code cannot be redistributed without permission from www.sixapart.com. # For more information, consult your Movable Type license. # # $Id: focus.js 1174 2008-01-08 21:02:50Z bchoate $ */ /* -------------------------------------------------------------------------------- TC.Focus focus handling class -------------------------------------------------------------------------------- */ /* constructor */ TC.Focus = function( rootElement, className, tagNames ) { this.rootElement = TC.elementOrId( rootElement ); if( className ) this.className = className; if( tagNames ) this.tagNames = tagNames; this.elements = []; // create closures var self = this; this.focusClosure = function( evt ) { return self.focus( evt ); }; // attach event handlers TC.attachDocumentEvent( window, "focus", this.focusClosure, true ); TC.attachDocumentEvent( window, "focusin", this.focusClosure, true ); // ie TC.attachDocumentEvent( window, "mousedown", this.focusClosure, true ); } /* focus */ TC.Focus.prototype.className = "focus"; TC.Focus.prototype.tagNames = []; /* instance methods */ TC.Focus.prototype.focus = function( evt ) { evt = evt || event; var element = evt.target || evt.srcElement; if (!element) return; // skip document elements or get parent of text nodes if( element.nodeType == 9 ) return; if( element.nodeType == 3 ) element = element.parentNode; // unfocus? var unfocus = false; if( this.tagNames.length ) { unfocus = true; var tagName = element.tagName.toLowerCase(); for( var i = 0; i < this.tagNames.length; i++ ) { if( tagName == this.tagNames[ i ] ) { unfocus = false; break; } } } // create element list var elements = []; while( element ) { elements[ elements.length ] = element; if( element == this.rootElement ) break; element = element.parentNode; } // ignore if root not found if( this.rootElement && element != this.rootElement ) return; // walk element lists var length = elements.length > this.elements.length ? elements.length : this.elements.length; for( var i = 1; i <= length; i++ ) { // get new and old elements from end of list // they should match up initially var newElement = unfocus ? null : elements[ elements.length - i ]; var oldElement = this.elements[ this.elements.length - i ]; // set/remove focus classname if( oldElement && oldElement != newElement ) TC.removeClassName( oldElement, this.className ); if( newElement ) TC.addClassName( newElement, this.className ); } // use new list this.elements = elements; // normal event processing return true; }