corrade-nucleus-nucleons – Blame information for rev 24
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | define([ |
2 | "../core", |
||
3 | "./support", |
||
4 | "../core/init" |
||
5 | ], function( jQuery, support ) { |
||
6 | |||
7 | var rreturn = /\r/g; |
||
8 | |||
9 | jQuery.fn.extend({ |
||
10 | val: function( value ) { |
||
11 | var hooks, ret, isFunction, |
||
12 | elem = this[0]; |
||
13 | |||
14 | if ( !arguments.length ) { |
||
15 | if ( elem ) { |
||
16 | hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; |
||
17 | |||
18 | if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { |
||
19 | return ret; |
||
20 | } |
||
21 | |||
22 | ret = elem.value; |
||
23 | |||
24 | return typeof ret === "string" ? |
||
25 | // handle most common string cases |
||
26 | ret.replace(rreturn, "") : |
||
27 | // handle cases where value is null/undef or number |
||
28 | ret == null ? "" : ret; |
||
29 | } |
||
30 | |||
31 | return; |
||
32 | } |
||
33 | |||
34 | isFunction = jQuery.isFunction( value ); |
||
35 | |||
36 | return this.each(function( i ) { |
||
37 | var val; |
||
38 | |||
39 | if ( this.nodeType !== 1 ) { |
||
40 | return; |
||
41 | } |
||
42 | |||
43 | if ( isFunction ) { |
||
44 | val = value.call( this, i, jQuery( this ).val() ); |
||
45 | } else { |
||
46 | val = value; |
||
47 | } |
||
48 | |||
49 | // Treat null/undefined as ""; convert numbers to string |
||
50 | if ( val == null ) { |
||
51 | val = ""; |
||
52 | |||
53 | } else if ( typeof val === "number" ) { |
||
54 | val += ""; |
||
55 | |||
56 | } else if ( jQuery.isArray( val ) ) { |
||
57 | val = jQuery.map( val, function( value ) { |
||
58 | return value == null ? "" : value + ""; |
||
59 | }); |
||
60 | } |
||
61 | |||
62 | hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; |
||
63 | |||
64 | // If set returns undefined, fall back to normal setting |
||
65 | if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { |
||
66 | this.value = val; |
||
67 | } |
||
68 | }); |
||
69 | } |
||
70 | }); |
||
71 | |||
72 | jQuery.extend({ |
||
73 | valHooks: { |
||
74 | select: { |
||
75 | get: function( elem ) { |
||
76 | var value, option, |
||
77 | options = elem.options, |
||
78 | index = elem.selectedIndex, |
||
79 | one = elem.type === "select-one" || index < 0, |
||
80 | values = one ? null : [], |
||
81 | max = one ? index + 1 : options.length, |
||
82 | i = index < 0 ? |
||
83 | max : |
||
84 | one ? index : 0; |
||
85 | |||
86 | // Loop through all the selected options |
||
87 | for ( ; i < max; i++ ) { |
||
88 | option = options[ i ]; |
||
89 | |||
90 | // IE6-9 doesn't update selected after form reset (#2551) |
||
91 | if ( ( option.selected || i === index ) && |
||
92 | // Don't return options that are disabled or in a disabled optgroup |
||
93 | ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) && |
||
94 | ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { |
||
95 | |||
96 | // Get the specific value for the option |
||
97 | value = jQuery( option ).val(); |
||
98 | |||
99 | // We don't need an array for one selects |
||
100 | if ( one ) { |
||
101 | return value; |
||
102 | } |
||
103 | |||
104 | // Multi-Selects return an array |
||
105 | values.push( value ); |
||
106 | } |
||
107 | } |
||
108 | |||
109 | return values; |
||
110 | }, |
||
111 | |||
112 | set: function( elem, value ) { |
||
113 | var optionSet, option, |
||
114 | options = elem.options, |
||
115 | values = jQuery.makeArray( value ), |
||
116 | i = options.length; |
||
117 | |||
118 | while ( i-- ) { |
||
119 | option = options[ i ]; |
||
120 | if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) { |
||
121 | optionSet = true; |
||
122 | } |
||
123 | } |
||
124 | |||
125 | // force browsers to behave consistently when non-matching value is set |
||
126 | if ( !optionSet ) { |
||
127 | elem.selectedIndex = -1; |
||
128 | } |
||
129 | return values; |
||
130 | } |
||
131 | } |
||
132 | } |
||
133 | }); |
||
134 | |||
135 | // Radios and checkboxes getter/setter |
||
136 | jQuery.each([ "radio", "checkbox" ], function() { |
||
137 | jQuery.valHooks[ this ] = { |
||
138 | set: function( elem, value ) { |
||
139 | if ( jQuery.isArray( value ) ) { |
||
140 | return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); |
||
141 | } |
||
142 | } |
||
143 | }; |
||
144 | if ( !support.checkOn ) { |
||
145 | jQuery.valHooks[ this ].get = function( elem ) { |
||
146 | // Support: Webkit |
||
147 | // "" is returned instead of "on" if a value isn't specified |
||
148 | return elem.getAttribute("value") === null ? "on" : elem.value; |
||
149 | }; |
||
150 | } |
||
151 | }); |
||
152 | |||
153 | }); |