@@ -89,42 +89,6 @@ I18n.scoped('instructure', function(I18n) {
8989 } ) ;
9090 return result ;
9191 } ;
92-
93-
94- // this is just pulled from jquery 1.6 because jquery 1.5 could not do .map on an object
95- $ . map = function ( elems , callback , arg ) {
96- var value , key , ret = [ ] ,
97- i = 0 ,
98- length = elems . length ,
99-
100-
101- // jquery objects are treated as arrays
102- isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems [ 0 ] && elems [ length - 1 ] ) || length === 0 || jQuery . isArray ( elems ) ) ;
103-
104- // Go through the array, translating each of the items to their
105- if ( isArray ) {
106- for ( ; i < length ; i ++ ) {
107- value = callback ( elems [ i ] , i , arg ) ;
108-
109- if ( value != null ) {
110- ret [ ret . length ] = value ;
111- }
112- }
113-
114- // Go through every key on the object,
115- } else {
116- for ( key in elems ) {
117- value = callback ( elems [ key ] , key , arg ) ;
118-
119- if ( value != null ) {
120- ret [ ret . length ] = value ;
121- }
122- }
123- }
124-
125- // Flatten any nested arrays
126- return ret . concat . apply ( [ ] , ret ) ;
127- }
12892
12993 // add ability to handle css3 opacity transitions on show or hide
13094 // if you want to use this just add the class 'use-css-transitions-for-show-hide' to an element.
@@ -791,7 +755,7 @@ I18n.scoped('instructure', function(I18n) {
791755 val = $input . editorBox ( 'get_code' , false ) ;
792756 }
793757 } catch ( e ) { }
794- var attr = $input . attr ( 'name' ) ;
758+ var attr = $input . prop ( 'name' ) || '' ;
795759 var multiValue = attr . match ( / \[ \] $ / )
796760 if ( inputType == 'hidden' && ! multiValue ) {
797761 if ( $form . find ( "[name='" + attr + "']" ) . filter ( "textarea,:radio:checked,:checkbox:checked,:text,:password,select,:hidden" ) [ 0 ] != $input [ 0 ] ) {
@@ -2853,24 +2817,33 @@ I18n.scoped('instructure', function(I18n) {
28532817 } ) ;
28542818 return $picker ;
28552819 } ;
2820+
2821+ // This is so that if you disable an element, that it also gives it the class disabled.
2822+ // that way you can add css classes for our friend IE6. so rather than using selector:disabled,
2823+ // you can do selector.disabled.
2824+ // works on both $(elem).attr('disabled', ...) AND $(elem).prop('disabled', ...)
2825+ $ . each ( [ "prop" , "attr" ] , function ( i , propOrAttr ) {
2826+ // set the `disabled.set` hook like this so we don't override any existing `get` hook
2827+ $ [ propOrAttr + 'Hooks' ] . disabled = jQuery . extend ( $ [ propOrAttr + 'Hooks' ] . disabled , {
2828+ set : function ( elem , value , name ) {
2829+ $ ( elem ) . toggleClass ( 'disabled' , ! ! value ) ;
28562830
2857- // This is a patch that so that if you disable an element, that it also gives it the class disabled.
2858- // that way you can add css classes for our friend IE6. so rather than using selector:disabled, you can do selector.disabled.
2859- // I patch the $.attr method, not the $.fn.attr method because both $.fn.attr and $.fn.removeAttr use $.attr.
2860- // which means that it will get run trough this both when you disable AND remove the 'disabled' attribute on an element.
2861- $ . attrBeforeHandlingDisabled = $ . attr ;
2862- $ . attr = function ( elem , name , value , pass ) {
2863- if ( typeof ( name ) === "string" && name . toLowerCase ( ) === 'disabled' && value !== undefined ) {
2864- $ ( elem ) [ ( value ? "add" : "remove" ) + "Class" ] ( 'disabled' ) ;
2865- }
2866- return $ . attrBeforeHandlingDisabled . apply ( this , arguments ) ;
2867- } ;
2868-
2831+ // have to replicate wat jQuery's boolHook does because once you define your own hook
2832+ // for an attribute/property it wont fall back to boolHook. and it is not exposed externally.
2833+ elem [ value ? 'setAttribute' : 'removeAttribute' ] ( 'disabled' , 'disabled' ) ;
2834+ if ( 'disabled' in elem ) {
2835+ // Only set the IDL specifically if it already exists on the element
2836+ // ie for an <input> but not a <div>
2837+ elem . disabled = ! ! value ;
2838+ }
2839+ return value ;
2840+ }
2841+ } ) ;
2842+ } ) ;
2843+
28692844 // this is a patch so you can set the "method" atribute on rails' REST-ful forms.
2870- $ . attrBeforeHandlingFormMethod = $ . attr ;
2871- $ . attr = function ( elem , name , value , pass ) {
2872- // if it's an html node and if we are trying to set the 'method' attribute
2873- if ( elem && value && typeof ( name ) === "string" && name . toLowerCase ( ) == 'method' ) {
2845+ $ . attrHooks . method = $ . extend ( $ . attrHooks . method , {
2846+ set : function ( elem , value ) {
28742847 var orginalVal = value ;
28752848 value = value . toUpperCase ( ) === 'GET' ? 'GET' : 'POST' ;
28762849 if ( value === 'POST' ) {
@@ -2880,10 +2853,10 @@ I18n.scoped('instructure', function(I18n) {
28802853 }
28812854 $input . val ( orginalVal ) ;
28822855 }
2856+ elem . setAttribute ( 'method' , value ) ;
2857+ return value ;
28832858 }
2884- // can't do .apply because we need to pas the NEW 'value' that we set above, not the one in 'arguments'
2885- return $ . attrBeforeHandlingFormMethod . call ( this , elem , name , value , pass ) ;
2886- } ;
2859+ } ) ;
28872860
28882861 $ . fn . indicate = function ( options ) {
28892862 options = options || { } ;
0 commit comments