mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update components
This commit is contained in:
parent
84945cabc4
commit
ab2d2eaf94
111 changed files with 4302 additions and 3100 deletions
|
@ -1,6 +1,35 @@
|
|||
define( [
|
||||
"../data/var/dataPriv"
|
||||
], function( dataPriv ) {
|
||||
"../core",
|
||||
"../data/var/dataPriv",
|
||||
"../css/var/isHiddenWithinTree"
|
||||
], function( jQuery, dataPriv, isHiddenWithinTree ) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var defaultDisplayMap = {};
|
||||
|
||||
function getDefaultDisplay( elem ) {
|
||||
var temp,
|
||||
doc = elem.ownerDocument,
|
||||
nodeName = elem.nodeName,
|
||||
display = defaultDisplayMap[ nodeName ];
|
||||
|
||||
if ( display ) {
|
||||
return display;
|
||||
}
|
||||
|
||||
temp = doc.body.appendChild( doc.createElement( nodeName ) ),
|
||||
display = jQuery.css( temp, "display" );
|
||||
|
||||
temp.parentNode.removeChild( temp );
|
||||
|
||||
if ( display === "none" ) {
|
||||
display = "block";
|
||||
}
|
||||
defaultDisplayMap[ nodeName ] = display;
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
function showHide( elements, show ) {
|
||||
var display, elem,
|
||||
|
@ -17,23 +46,30 @@ function showHide( elements, show ) {
|
|||
|
||||
display = elem.style.display;
|
||||
if ( show ) {
|
||||
if ( display === "none" ) {
|
||||
|
||||
// Restore a pre-hide() value if we have one
|
||||
values[ index ] = dataPriv.get( elem, "display" ) || "";
|
||||
// Since we force visibility upon cascade-hidden elements, an immediate (and slow)
|
||||
// check is required in this first loop unless we have a nonempty display value (either
|
||||
// inline or about-to-be-restored)
|
||||
if ( display === "none" ) {
|
||||
values[ index ] = dataPriv.get( elem, "display" ) || null;
|
||||
if ( !values[ index ] ) {
|
||||
elem.style.display = "";
|
||||
}
|
||||
}
|
||||
if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
|
||||
values[ index ] = getDefaultDisplay( elem );
|
||||
}
|
||||
} else {
|
||||
if ( display !== "none" ) {
|
||||
values[ index ] = "none";
|
||||
|
||||
// Remember the value we're replacing
|
||||
// Remember what we're overwriting
|
||||
dataPriv.set( elem, "display", display );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the display of the elements in a second loop
|
||||
// to avoid the constant reflow
|
||||
// Set the display of the elements in a second loop to avoid constant reflow
|
||||
for ( index = 0; index < length; index++ ) {
|
||||
if ( values[ index ] != null ) {
|
||||
elements[ index ].style.display = values[ index ];
|
||||
|
@ -43,6 +79,27 @@ function showHide( elements, show ) {
|
|||
return elements;
|
||||
}
|
||||
|
||||
return showHide;
|
||||
jQuery.fn.extend( {
|
||||
show: function() {
|
||||
return showHide( this, true );
|
||||
},
|
||||
hide: function() {
|
||||
return showHide( this );
|
||||
},
|
||||
toggle: function( state ) {
|
||||
if ( typeof state === "boolean" ) {
|
||||
return state ? this.show() : this.hide();
|
||||
}
|
||||
|
||||
return this.each( function() {
|
||||
if ( isHiddenWithinTree( this ) ) {
|
||||
jQuery( this ).show();
|
||||
} else {
|
||||
jQuery( this ).hide();
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
return showHide;
|
||||
} );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue