aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.menu.js
diff options
context:
space:
mode:
authorjzaefferer <joern.zaefferer@gmail.com>2010-10-28 18:12:52 +0200
committerjzaefferer <joern.zaefferer@gmail.com>2010-10-28 18:12:52 +0200
commit1bd57c7421abb93f2fb5b236d08a9400d4f67171 (patch)
tree0a629836cdfaac323362cadc2ff864c3f934b4fb /ui/jquery.ui.menu.js
parent6b3eead894f9c4c40a9350197c6bb14a928d03b4 (diff)
downloadjquery-ui-1bd57c7421abb93f2fb5b236d08a9400d4f67171.tar.gz
jquery-ui-1bd57c7421abb93f2fb5b236d08a9400d4f67171.zip
Menu: Effing coding standards.
Diffstat (limited to 'ui/jquery.ui.menu.js')
-rw-r--r--ui/jquery.ui.menu.js142
1 files changed, 71 insertions, 71 deletions
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index ca6a32633..2b6ebaeae 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -17,12 +17,12 @@ $.widget("ui.menu", {
_create: function() {
var self = this;
this.element
- .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
+ .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.attr({
role: "listbox",
"aria-activedescendant": "ui-active-menuitem"
})
- .bind("click.menu", function( event ) {
+ .bind( "click.menu", function( event ) {
if ( self.options.disabled ) {
return false;
}
@@ -33,7 +33,7 @@ $.widget("ui.menu", {
event.preventDefault();
self.select( event );
})
- .bind("mouseover.menu", function( event ) {
+ .bind( "mouseover.menu", function( event ) {
if ( self.options.disabled ) {
return;
}
@@ -50,17 +50,17 @@ $.widget("ui.menu", {
if ( target.length && target.parent()[0] === self.element[0] ) {
self.deactivate( event );
}
- });;
+ });
this.refresh();
- if (!this.options.input) {
- this.options.input = this.element.attr("tabIndex", 0);
+ if ( !this.options.input ) {
+ this.options.input = this.element.attr( "tabIndex", 0 );
}
- this.options.input.bind("keydown.menu", function(event) {
- if (self.options.disabled) {
+ this.options.input.bind( "keydown.menu", function( event ) {
+ if ( self.options.disabled ) {
return;
}
- switch (event.keyCode) {
+ switch ( event.keyCode ) {
case $.ui.keyCode.PAGE_UP:
self.previousPage();
event.preventDefault();
@@ -91,131 +91,131 @@ $.widget("ui.menu", {
},
destroy: function() {
- $.Widget.prototype.destroy.apply(this, arguments);
+ $.Widget.prototype.destroy.apply( this, arguments );
this.element
- .removeClass("ui-menu ui-widget ui-widget-content ui-corner-all")
- .removeAttr("tabIndex")
- .removeAttr("role")
- .removeAttr("aria-activedescendant");
+ .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
+ .removeAttr( "tabIndex" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-activedescendant" );
- this.element.children(".ui-menu-item")
- .removeClass("ui-menu-item")
- .removeAttr("role")
- .children("a")
- .removeClass("ui-corner-all")
- .removeAttr("tabIndex")
- .unbind(".menu");
+ this.element.children( ".ui-menu-item" )
+ .removeClass( "ui-menu-item" )
+ .removeAttr( "role" )
+ .children( "a" )
+ .removeClass( "ui-corner-all" )
+ .removeAttr( "tabIndex" )
+ .unbind( ".menu" );
},
refresh: function() {
// don't refresh list items that are already adapted
- var items = this.element.children("li:not(.ui-menu-item):has(a)")
- .addClass("ui-menu-item")
- .attr("role", "menuitem");
+ var items = this.element.children( "li:not(.ui-menu-item):has(a)" )
+ .addClass( "ui-menu-item" )
+ .attr( "role", "menuitem" );
- items.children("a")
- .addClass("ui-corner-all")
- .attr("tabIndex", -1);
+ items.children( "a" )
+ .addClass( "ui-corner-all" )
+ .attr( "tabIndex", -1 );
},
activate: function( event, item ) {
this.deactivate();
- if (this._hasScroll()) {
+ if ( this._hasScroll() ) {
var offset = item.offset().top - this.element.offset().top,
- scroll = this.element.attr("scrollTop"),
+ scroll = this.element.attr( "scrollTop" ),
elementHeight = this.element.height();
if (offset < 0) {
- this.element.attr("scrollTop", scroll + offset);
+ this.element.attr( "scrollTop", scroll + offset );
} else if (offset > elementHeight) {
- this.element.attr("scrollTop", scroll + offset - elementHeight + item.height());
+ this.element.attr( "scrollTop", scroll + offset - elementHeight + item.height() );
}
}
- this.active = item.eq(0)
- .children("a")
- .addClass("ui-state-hover")
- .attr("id", "ui-active-menuitem")
+ this.active = item.eq( 0 )
+ .children( "a" )
+ .addClass( "ui-state-hover" )
+ .attr( "id", "ui-active-menuitem" )
.end();
- this._trigger("focus", event, { item: item });
+ this._trigger( "focus", event, { item: item } );
},
deactivate: function(event) {
if (!this.active) { return; }
- this.active.children("a")
- .removeClass("ui-state-hover")
- .removeAttr("id");
- this._trigger("blur", event);
+ this.active.children( "a" )
+ .removeClass( "ui-state-hover" )
+ .removeAttr( "id" );
+ this._trigger( "blur", event );
this.active = null;
},
next: function(event) {
- this._move("next", ".ui-menu-item:first", event);
+ this._move( "next", ".ui-menu-item:first", event );
},
previous: function(event) {
- this._move("prev", ".ui-menu-item:last", event);
+ this._move( "prev", ".ui-menu-item:last", event );
},
first: function() {
- return this.active && !this.active.prevAll(".ui-menu-item").length;
+ return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
},
last: function() {
- return this.active && !this.active.nextAll(".ui-menu-item").length;
+ return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
},
_move: function(direction, edge, event) {
- if (!this.active) {
- this.activate(event, this.element.children(edge));
+ if ( !this.active ) {
+ this.activate( event, this.element.children(edge) );
return;
}
- var next = this.active[direction + "All"](".ui-menu-item").eq(0);
- if (next.length) {
- this.activate(event, next);
+ var next = this.active[ direction + "All" ]( ".ui-menu-item" ).eq( 0 );
+ if ( next.length ) {
+ this.activate( event, next );
} else {
- this.activate(event, this.element.children(edge));
+ this.activate( event, this.element.children(edge) );
}
},
// TODO merge with previousPage
- nextPage: function(event) {
- if (this._hasScroll()) {
+ nextPage: function( event ) {
+ if ( this._hasScroll() ) {
// TODO merge with no-scroll-else
- if (!this.active || this.last()) {
- this.activate(event, this.element.children(":first"));
+ if ( !this.active || this.last() ) {
+ this.activate( event, this.element.children(":first") );
return;
}
var base = this.active.offset().top,
height = this.element.height(),
- result = this.element.children("li").filter(function() {
- var close = $(this).offset().top - base - height + $(this).height();
+ result = this.element.children( "li" ).filter( function() {
+ var close = $( this ).offset().top - base - height + $( this ).height();
// TODO improve approximation
return close < 10 && close > -10;
});
// TODO try to catch this earlier when scrollTop indicates the last page anyway
- if (!result.length) {
- result = this.element.children(":last");
+ if ( !result.length ) {
+ result = this.element.children( ":last" );
}
- this.activate(event, result);
+ this.activate( event, result );
} else {
- this.activate(event, this.element.children(!this.active || this.last() ? ":first" : ":last"));
+ this.activate( event, this.element.children( !this.active || this.last() ? ":first" : ":last" ) );
}
},
// TODO merge with nextPage
- previousPage: function(event) {
- if (this._hasScroll()) {
+ previousPage: function( event ) {
+ if ( this._hasScroll() ) {
// TODO merge with no-scroll-else
- if (!this.active || this.first()) {
- this.activate(event, this.element.children(":last"));
+ if ( !this.active || this.first() ) {
+ this.activate( event, this.element.children(":last") );
return;
}
var base = this.active.offset().top,
height = this.element.height();
- result = this.element.children("li").filter(function() {
+ result = this.element.children( "li" ).filter( function() {
var close = $(this).offset().top - base + height - $(this).height();
// TODO improve approximation
return close < 10 && close > -10;
@@ -223,21 +223,21 @@ $.widget("ui.menu", {
// TODO try to catch this earlier when scrollTop indicates the last page anyway
if (!result.length) {
- result = this.element.children(":first");
+ result = this.element.children( ":first" );
}
- this.activate(event, result);
+ this.activate( event, result );
} else {
- this.activate(event, this.element.children(!this.active || this.first() ? ":last" : ":first"));
+ this.activate( event, this.element.children( !this.active || this.first() ? ":last" : ":first" ) );
}
},
_hasScroll: function() {
- return this.element.height() < this.element.attr("scrollHeight");
+ return this.element.height() < this.element.attr( "scrollHeight" );
},
select: function( event ) {
- this._trigger("select", event, { item: this.active });
+ this._trigger( "select", event, { item: this.active } );
}
});
-}(jQuery));
+}( jQuery ));