Skip to content

Commit 27095ef

Browse files
committed
Core: Coding standards.
1 parent 59c9f75 commit 27095ef

File tree

1 file changed

+78
-71
lines changed

1 file changed

+78
-71
lines changed

ui/jquery.ui.core.js

+78-71
Original file line numberDiff line numberDiff line change
@@ -13,68 +13,74 @@
1313
// this is only a problem because we proxy existing functions
1414
// and we don't want to double proxy them
1515
$.ui = $.ui || {};
16-
if ($.ui.version) {
16+
if ( $.ui.version ) {
1717
return;
1818
}
1919

2020
//Helper functions and ui object
21-
$.extend($.ui, {
21+
$.extend( $.ui, {
2222
version: "@VERSION",
2323

2424
// $.ui.plugin is deprecated. Use the proxy pattern instead.
2525
plugin: {
26-
add: function(module, option, set) {
27-
var proto = $.ui[module].prototype;
28-
for(var i in set) {
29-
proto.plugins[i] = proto.plugins[i] || [];
30-
proto.plugins[i].push([option, set[i]]);
26+
add: function( module, option, set ) {
27+
var proto = $.ui[ module ].prototype;
28+
for ( var i in set ) {
29+
proto.plugins[ i ] = proto.plugins[ i ] || [];
30+
proto.plugins[ i ].push( [ option, set[ i ] ] );
3131
}
3232
},
33-
call: function(instance, name, args) {
34-
var set = instance.plugins[name];
35-
if(!set || !instance.element[0].parentNode) { return; }
33+
call: function( instance, name, args ) {
34+
var set = instance.plugins[ name ];
35+
if ( !set || !instance.element[ 0 ].parentNode ) {
36+
return;
37+
}
3638

37-
for (var i = 0; i < set.length; i++) {
38-
if (instance.options[set[i][0]]) {
39-
set[i][1].apply(instance.element, args);
39+
for ( var i = 0; i < set.length; i++ ) {
40+
if ( instance.options[ set[ i ][ 0 ] ] ) {
41+
set[ i ][ 1 ].apply( instance.element, args );
4042
}
4143
}
4244
}
4345
},
4446

45-
contains: function(a, b) {
46-
return document.compareDocumentPosition
47-
? a.compareDocumentPosition(b) & 16
48-
: a !== b && a.contains(b);
47+
contains: function( a, b ) {
48+
return document.compareDocumentPosition ?
49+
a.compareDocumentPosition( b ) & 16 :
50+
a !== b && a.contains( b );
4951
},
5052

51-
hasScroll: function(el, a) {
53+
hasScroll: function( el, a ) {
5254

5355
//If overflow is hidden, the element might have extra content, but the user wants to hide it
54-
if ($(el).css('overflow') == 'hidden') { return false; }
56+
if ( $( el ).css( "overflow" ) === "hidden") {
57+
return false;
58+
}
5559

56-
var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
60+
var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
5761
has = false;
5862

59-
if (el[scroll] > 0) { return true; }
63+
if ( el[ scroll ] > 0 ) {
64+
return true;
65+
}
6066

6167
// TODO: determine which cases actually cause this to happen
6268
// if the element doesn't have the scroll set, see if it's possible to
6369
// set the scroll
64-
el[scroll] = 1;
65-
has = (el[scroll] > 0);
66-
el[scroll] = 0;
70+
el[ scroll ] = 1;
71+
has = ( el[ scroll ] > 0 );
72+
el[ scroll ] = 0;
6773
return has;
6874
},
6975

70-
isOverAxis: function(x, reference, size) {
76+
isOverAxis: function( x, reference, size ) {
7177
//Determines when x coordinate is over "b" element axis
72-
return (x > reference) && (x < (reference + size));
78+
return ( x > reference ) && ( x < ( reference + size ) );
7379
},
7480

75-
isOver: function(y, x, top, left, height, width) {
81+
isOver: function( y, x, top, left, height, width ) {
7682
//Determines when x, y coordinates is over "b" element
77-
return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
83+
return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
7884
},
7985

8086
keyCode: {
@@ -116,33 +122,35 @@ $.extend($.ui, {
116122
//jQuery plugins
117123
$.fn.extend({
118124
_focus: $.fn.focus,
119-
focus: function(delay, fn) {
120-
return typeof delay === 'number'
121-
? this.each(function() {
125+
focus: function( delay, fn ) {
126+
return typeof delay === "number" ?
127+
this.each(function() {
122128
var elem = this;
123129
setTimeout(function() {
124-
$(elem).focus();
125-
(fn && fn.call(elem));
126-
}, delay);
127-
})
128-
: this._focus.apply(this, arguments);
130+
$( elem ).focus();
131+
if ( fn ) {
132+
fn.call( elem );
133+
}
134+
}, delay );
135+
}) :
136+
this._focus.apply( this, arguments );
129137
},
130-
138+
131139
enableSelection: function() {
132140
return this
133-
.attr('unselectable', 'off')
134-
.css('MozUserSelect', '');
141+
.attr( "unselectable", "off" )
142+
.css( "MozUserSelect", "" );
135143
},
136144

137145
disableSelection: function() {
138146
return this
139-
.attr('unselectable', 'on')
140-
.css('MozUserSelect', 'none');
147+
.attr( "unselectable", "on" )
148+
.css( "MozUserSelect", "none" );
141149
},
142150

143151
scrollParent: function() {
144152
var scrollParent;
145-
if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
153+
if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
146154
scrollParent = this.parents().filter(function() {
147155
return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
148156
}).eq(0);
@@ -155,26 +163,25 @@ $.fn.extend({
155163
return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
156164
},
157165

158-
zIndex: function(zIndex) {
159-
if (zIndex !== undefined) {
160-
return this.css('zIndex', zIndex);
166+
zIndex: function( zIndex ) {
167+
if ( zIndex !== undefined ) {
168+
return this.css( "zIndex", zIndex );
161169
}
162-
163-
if (this.length) {
164-
var elem = $(this[0]), position, value;
165-
while (elem.length && elem[0] !== document) {
170+
171+
if ( this.length ) {
172+
var elem = $( this[ 0 ] ), position, value;
173+
while ( elem.length && elem[ 0 ] !== document ) {
166174
// Ignore z-index if position is set to a value where z-index is ignored by the browser
167175
// This makes behavior of this function consistent across browsers
168176
// WebKit always returns auto if the element is positioned
169-
position = elem.css('position');
170-
if (position == 'absolute' || position == 'relative' || position == 'fixed')
171-
{
177+
position = elem.css( "position" );
178+
if ( position === "absolute" || position === "relative" || position === "fixed" ) {
172179
// IE returns 0 when zIndex is not specified
173180
// other browsers return a string
174181
// we ignore the case of nested elements with an explicit value of 0
175182
// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
176-
value = parseInt(elem.css('zIndex'));
177-
if (!isNaN(value) && value != 0) {
183+
value = parseInt( elem.css( "zIndex" ) );
184+
if ( !isNaN( value ) && value != 0 ) {
178185
return value;
179186
}
180187
}
@@ -198,12 +205,12 @@ $.each( [ "Width", "Height" ], function( i, name ) {
198205

199206
function reduce( elem, size, border, margin ) {
200207
$.each( side, function() {
201-
size -= parseFloat( $.curCSS( elem, "padding" + this, true)) || 0;
208+
size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0;
202209
if ( border ) {
203-
size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true)) || 0;
210+
size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0;
204211
}
205212
if ( margin ) {
206-
size -= parseFloat( $.curCSS( elem, "margin" + this, true)) || 0;
213+
size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0;
207214
}
208215
});
209216
return size;
@@ -232,20 +239,20 @@ $.each( [ "Width", "Height" ], function( i, name ) {
232239

233240
//Additional selectors
234241
function visible( element ) {
235-
return !$(element).parents().andSelf().filter(function() {
242+
return !$( element ).parents().andSelf().filter(function() {
236243
return $.curCSS( this, "visibility" ) === "hidden" ||
237244
$.expr.filters.hidden( this );
238245
}).length;
239246
}
240247

241-
$.extend($.expr[':'], {
242-
data: function(elem, i, match) {
243-
return !!$.data(elem, match[3]);
248+
$.extend( $.expr[ ":" ], {
249+
data: function( elem, i, match ) {
250+
return !!$.data( elem, match[ 3 ] );
244251
},
245252

246-
focusable: function(element) {
253+
focusable: function( element ) {
247254
var nodeName = element.nodeName.toLowerCase(),
248-
tabIndex = $.attr(element, 'tabindex');
255+
tabIndex = $.attr( element, "tabindex" );
249256
if ( "area" === nodeName ) {
250257
var map = element.parentNode,
251258
mapName = map.name,
@@ -256,19 +263,19 @@ $.extend($.expr[':'], {
256263
img = $( "img[usemap=#" + mapName + "]" )[0];
257264
return !!img && visible( img );
258265
}
259-
return (/input|select|textarea|button|object/.test(nodeName)
266+
return ( /input|select|textarea|button|object/.test( nodeName )
260267
? !element.disabled
261-
: 'a' == nodeName
262-
? element.href || !isNaN(tabIndex)
263-
: !isNaN(tabIndex))
268+
: "a" == nodeName
269+
? element.href || !isNaN( tabIndex )
270+
: !isNaN( tabIndex ))
264271
// the element and all of its ancestors must be visible
265272
&& visible( element );
266273
},
267274

268-
tabbable: function(element) {
269-
var tabIndex = $.attr(element, 'tabindex');
270-
return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
275+
tabbable: function( element ) {
276+
var tabIndex = $.attr( element, "tabindex" );
277+
return ( isNaN( tabIndex ) || tabIndex >= 0 ) && $( element ).is( ":focusable" );
271278
}
272279
});
273280

274-
})(jQuery);
281+
})( jQuery );

0 commit comments

Comments
 (0)