1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/bower_components/jquery/src/attributes/prop.js

110 lines
2.2 KiB
JavaScript
Raw Normal View History

2016-01-09 13:36:35 -05:00
define( [
2015-06-26 11:53:49 -04:00
"../core",
"../core/access",
2016-01-09 13:36:35 -05:00
"./support",
"../selector"
2015-06-26 11:53:49 -04:00
], function( jQuery, access, support ) {
2016-01-09 13:36:35 -05:00
var rfocusable = /^(?:input|select|textarea|button)$/i,
rclickable = /^(?:a|area)$/i;
2015-06-26 11:53:49 -04:00
2016-01-09 13:36:35 -05:00
jQuery.fn.extend( {
2015-06-26 11:53:49 -04:00
prop: function( name, value ) {
return access( this, jQuery.prop, name, value, arguments.length > 1 );
},
removeProp: function( name ) {
2016-01-09 13:36:35 -05:00
return this.each( function() {
2015-06-26 11:53:49 -04:00
delete this[ jQuery.propFix[ name ] || name ];
2016-01-09 13:36:35 -05:00
} );
2015-06-26 11:53:49 -04:00
}
2016-01-09 13:36:35 -05:00
} );
2015-06-26 11:53:49 -04:00
2016-01-09 13:36:35 -05:00
jQuery.extend( {
2015-06-26 11:53:49 -04:00
prop: function( elem, name, value ) {
2016-01-09 13:36:35 -05:00
var ret, hooks,
2015-06-26 11:53:49 -04:00
nType = elem.nodeType;
// Don't get/set properties on text, comment and attribute nodes
2016-01-09 13:36:35 -05:00
if ( nType === 3 || nType === 8 || nType === 2 ) {
2015-06-26 11:53:49 -04:00
return;
}
2016-01-09 13:36:35 -05:00
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
2015-06-26 11:53:49 -04:00
// Fix name and attach hooks
name = jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ];
}
if ( value !== undefined ) {
2016-01-09 13:36:35 -05:00
if ( hooks && "set" in hooks &&
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
return ret;
}
return ( elem[ name ] = value );
}
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
return ret;
2015-06-26 11:53:49 -04:00
}
2016-01-09 13:36:35 -05:00
return elem[ name ];
2015-06-26 11:53:49 -04:00
},
propHooks: {
tabIndex: {
get: function( elem ) {
2016-01-09 13:36:35 -05:00
// elem.tabIndex doesn't always return the
// correct value when it hasn't been explicitly set
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
// Use proper attribute retrieval(#12072)
var tabindex = jQuery.find.attr( elem, "tabindex" );
return tabindex ?
parseInt( tabindex, 10 ) :
rfocusable.test( elem.nodeName ) ||
rclickable.test( elem.nodeName ) && elem.href ?
0 :
-1;
2015-06-26 11:53:49 -04:00
}
}
2016-01-09 13:36:35 -05:00
},
propFix: {
"for": "htmlFor",
"class": "className"
2015-06-26 11:53:49 -04:00
}
2016-01-09 13:36:35 -05:00
} );
2015-06-26 11:53:49 -04:00
if ( !support.optSelected ) {
jQuery.propHooks.selected = {
get: function( elem ) {
var parent = elem.parentNode;
if ( parent && parent.parentNode ) {
parent.parentNode.selectedIndex;
}
return null;
}
};
}
2016-01-09 13:36:35 -05:00
jQuery.each( [
2015-06-26 11:53:49 -04:00
"tabIndex",
"readOnly",
"maxLength",
"cellSpacing",
"cellPadding",
"rowSpan",
"colSpan",
"useMap",
"frameBorder",
"contentEditable"
], function() {
jQuery.propFix[ this.toLowerCase() ] = this;
2016-01-09 13:36:35 -05:00
} );
2015-06-26 11:53:49 -04:00
2016-01-09 13:36:35 -05:00
} );