Permalink
Browse files

Defaults: Remove global class variables

Fixes gh-6300
Closes gh-8180
  • Loading branch information...
arschmitz committed Jul 3, 2015
1 parent 304533b commit 48e895e99fcd0adb1c9b1c05cd2fa867082ac50b
View
@@ -139,10 +139,10 @@ $.extend( $.mobile, {
},
removeActiveLinkClass: function( forceRemoval ) {
if ( !!$.mobile.activeClickedLink &&
( !$.mobile.activeClickedLink.closest( "." + $.mobile.activePageClass ).length ||
( !$.mobile.activeClickedLink.closest( ".ui-page-active" ).length ||
forceRemoval ) ) {
$.mobile.activeClickedLink.removeClass( $.mobile.activeBtnClass );
$.mobile.activeClickedLink.removeClass( "ui-button-active" );
}
$.mobile.activeClickedLink = null;
},
@@ -222,7 +222,7 @@ $.extend( $.mobile, {
//simply set the active page's minimum height to screen height, depending on orientation
resetActivePageHeight: function( height ) {
var page = $( "." + $.mobile.activePageClass ),
var page = $( ".ui-page-active" ),
pageHeight = page.height(),
pageOuterHeight = page.outerHeight( true );
View
@@ -283,7 +283,7 @@ $.mobile._registerInternalEvents = function() {
theButton.hasClass( "ui-disabled" ) ) ) ) {
$.mobile.removeActiveLinkClass( true );
$.mobile.activeClickedLink = theButton;
$.mobile.activeClickedLink.addClass( $.mobile.activeBtnClass );
$.mobile.activeClickedLink.addClass( "ui-button-active" );
}
} );
@@ -54,7 +54,7 @@ $.extend( $.mobile.Transition.prototype, {
cleanFrom: function() {
this.$from
.removeClass( $.mobile.activePageClass + " out in reverse " + this.name )
.removeClass( "ui-page-active out in reverse " + this.name )
.height( "" );
},
@@ -76,7 +76,7 @@ $.extend( $.mobile.Transition.prototype, {
this.scrollPage();
}
if ( !this.sequential ) {
this.$to.addClass( $.mobile.activePageClass );
this.$to.addClass( "ui-page-active" );
}
this.deferred.resolve( this.name, this.reverse, this.$to, this.$from, true );
},
@@ -110,7 +110,7 @@ $.extend( $.mobile.Transition.prototype, {
startIn: function( screenHeight, reverseClass, none, preventFocus ) {
this.hideIn( function() {
this.$to.addClass( $.mobile.activePageClass + this.toPreClass );
this.$to.addClass( "ui-page-active" + this.toPreClass );
// Send focus to page as it is now display: block
if ( !preventFocus ) {
@@ -89,7 +89,7 @@ $.widget( "mobile.collapsible", {
this._on( ui.heading, {
"tap": function() {
ui.heading.find( "a" ).first().addClass( $.mobile.activeBtnClass );
ui.heading.find( "a" ).first().addClass( "ui-button-active" );
},
"click": function( event ) {
@@ -319,7 +319,7 @@ $.widget( "mobile.collapsible", {
// logic or cause same icon for expanded/collapsed state would remove the ui-icon-class
.toggleClass( "ui-icon-" + opts.collapsedIcon, ( isCollapse || opts.expandedIcon === opts.collapsedIcon ) )
.removeClass( $.mobile.activeBtnClass );
.removeClass( "ui-button-active" );
this.element.toggleClass( "ui-collapsible-collapsed", isCollapse );
ui.content
@@ -362,7 +362,7 @@ return $.widget( "mobile.selectmenu", $.mobile.selectmenu, {
self.setButtonCount();
self.list.find( "li:not(.ui-li-divider)" )
.find( "a" ).removeClass( $.mobile.activeBtnClass ).end()
.find( "a" ).removeClass( "ui-button-active" ).end()
.attr( "aria-selected", false )
.each( function( i ) {
var item = $( this );
@@ -376,9 +376,9 @@ return $.widget( "mobile.selectmenu", $.mobile.selectmenu, {
item.find( "a" ).removeClass( "ui-checkbox-off" ).addClass( "ui-checkbox-on" );
} else {
if ( item.hasClass( "ui-screen-hidden" ) ) {
item.next().find( "a" ).addClass( $.mobile.activeBtnClass );
item.next().find( "a" ).addClass( "ui-button-active" );
} else {
item.find( "a" ).addClass( $.mobile.activeBtnClass );
item.find( "a" ).addClass( "ui-button-active" );
}
}
} else if ( self.isMultiple ) {
@@ -411,7 +411,7 @@ return $.widget( "mobile.selectmenu", $.mobile.selectmenu, {
},
_focusMenuItem: function() {
var selector = this.list.find( "a." + $.mobile.activeBtnClass );
var selector = this.list.find( "a.ui-button-active" );
if ( selector.length === 0 ) {
selector = this.list.find( "li:not(" + unfocusableItemSelector + ") a.ui-button" );
}
View
@@ -183,24 +183,24 @@ return $.widget( "mobile.selectmenu", $.extend( {
.appendTo( self.button )
.bind( "vmousedown", function() {
// Add active class to button
self.button.addClass( $.mobile.activeBtnClass );
self.button.addClass( "ui-button-active" );
} )
.bind( "focus", function() {
self.button.addClass( $.mobile.focusClass );
self.button.addClass( "ui-focus" );
} )
.bind( "blur", function() {
self.button.removeClass( $.mobile.focusClass );
self.button.removeClass( "ui-focus" );
} )
.bind( "focus vmouseover", function() {
self.button.trigger( "vmouseover" );
} )
.bind( "vmousemove", function() {
// Remove active class on scroll/touchmove
self.button.removeClass( $.mobile.activeBtnClass );
self.button.removeClass( "ui-button-active" );
} )
.bind( "change blur vmouseout", function() {
self.button.trigger( "vmouseout" )
.removeClass( $.mobile.activeBtnClass );
.removeClass( "ui-button-active" );
} );
// In many situations, iOS will zoom into the select upon tap, this prevents that from happening
@@ -73,7 +73,7 @@ return $.widget( "mobile.slider", $.extend( {
slider = $( domSlider ),
valuebg = this.options.highlight && !isToggleSwitch ? ( function() {
var bg = document.createElement( "div" );
bg.className = "ui-slider-bg " + $.mobile.activeBtnClass;
bg.className = "ui-slider-bg ui-button-active";
return $( bg ).prependTo( slider );
} )() : false,
options,
@@ -146,7 +146,7 @@ return $.widget( "mobile.slider", $.extend( {
for ( i = 0, optionsCount = options.length; i < optionsCount; i++ ) {
side = !i ? "b" : "a";
activeClass = !i ? "" : " " + $.mobile.activeBtnClass;
activeClass = !i ? "" : " ui-button-active";
sliderImg = document.createElement( "span" );
sliderImg.className = [ "ui-slider-label ui-slider-label-", side, activeClass ].join( "" );
@@ -428,7 +428,7 @@ return $.widget( "mobile.slider", $.extend( {
if ( this.options.highlight && !this.isToggleSwitch && this.slider.find( ".ui-slider-bg" ).length === 0 ) {
this.valuebg = ( function() {
var bg = document.createElement( "div" );
bg.className = "ui-slider-bg " + $.mobile.activeBtnClass;
bg.className = "ui-slider-bg ui-button-active";
return $( bg ).prependTo( self.slider );
} )();
}
View
@@ -61,7 +61,7 @@ return $.widget( "mobile.loader", {
// For non-fixed supportin browsers. Position at y center (if scrollTop supported), above the activeBtn (if defined), or just 100px from top
fakeFixLoader: function() {
var activeBtn = $( "." + $.mobile.activeBtnClass ).first();
var activeBtn = $( ".ui-button-active" ).first();
this.element
.css( {
View
@@ -73,21 +73,21 @@ return $.widget( "mobile.navbar", {
// DEPRECATED as of 1.4.0 - remove after 1.4.0 release
// only ui-state-disabled should be present thereafter
activeBtn.hasClass( "ui-disabled" ) ||
activeBtn.hasClass( $.mobile.activeBtnClass ) ) ) {
activeBtn.hasClass( "ui-button-active" ) ) ) {
$navbuttons.removeClass( $.mobile.activeBtnClass );
activeBtn.addClass( $.mobile.activeBtnClass );
$navbuttons.removeClass( "ui-button-active" );
activeBtn.addClass( "ui-button-active" );
// The code below is a workaround to fix #1181
$( document ).one( "pagehide", function() {
activeBtn.removeClass( $.mobile.activeBtnClass );
activeBtn.removeClass( "ui-button-active" );
} );
}
} );
// Buttons in the navbar with ui-state-persist class should regain their active state before page show
$navbar.closest( ".ui-page" ).bind( "pagebeforeshow", function() {
$navbuttons.filter( ".ui-state-persist" ).addClass( $.mobile.activeBtnClass );
$navbuttons.filter( ".ui-state-persist" ).addClass( "ui-button-active" );
} );
}
} );
View
@@ -122,7 +122,7 @@ return $.widget( "mobile.panel", {
},
_getPage: function() {
var page = this._openedPage || this._parentPage || $( "." + $.mobile.activePageClass );
var page = this._openedPage || this._parentPage || $( ".ui-page-active" );
return page;
},
@@ -257,9 +257,9 @@ return $.widget( "mobile.panel", {
e.preventDefault();
link = $( e.target );
if ( link.hasClass( "ui-button" ) ) {
link.addClass( $.mobile.activeBtnClass );
link.addClass( "ui-button-active" );
this.element.one( "panelopen panelclose", function() {
link.removeClass( $.mobile.activeBtnClass );
link.removeClass( "ui-button-active" );
} );
}
this.toggle();
View
@@ -1043,7 +1043,7 @@ $.mobile.popup.handleLink = function( $link ) {
//remove after delay
setTimeout( function() {
$link.removeClass( $.mobile.activeBtnClass );
$link.removeClass( "ui-button-active" );
}, 300 );
};
@@ -5,10 +5,10 @@ var button = $( "#reset-button" ).click();
expect( 2 );
deepEqual( button.hasClass( $.mobile.activeBtnClass ), true, "When clicked, reset button gets active class" );
deepEqual( button.hasClass( "ui-button-active" ), true, "When clicked, reset button gets active class" );
setTimeout( function() {
deepEqual( button.hasClass( $.mobile.activeBtnClass ), false, "Active class is removed after a while" );
deepEqual( button.hasClass( "ui-button-active" ), false, "Active class is removed after a while" );
start();
}, 700 );
} );
@@ -1039,7 +1039,7 @@ asyncTest( "handling of active button state when navigating", 1, function() {
},
function() {
ok( !$( "#active-state-page1 a" ).hasClass( $.mobile.activeBtnClass ), "No button should not have class " + $.mobile.activeBtnClass );
ok( !$( "#active-state-page1 a" ).hasClass( "ui-button-active" ), "No button should not have class ui-button-active" );
start();
}
] );
@@ -1123,7 +1123,7 @@ asyncTest( "disabling link binding disables navigation via links and highlightin
},
function( timeout ) {
ok( !$.mobile.activePage.find( "a" ).hasClass( $.mobile.activeBtnClass ), "vlick handler doesn't add the activebutton class" );
ok( !$.mobile.activePage.find( "a" ).hasClass( "ui-button-active" ), "vlick handler doesn't add the activebutton class" );
ok( timeout, "no page change was fired" );
start();
}
@@ -1150,7 +1150,7 @@ asyncTest( "handling of button active state when navigating by clicking back but
},
function() {
ok( !$( "#active-state-page2 a" ).hasClass( $.mobile.activeBtnClass ), "No button should not have class " + $.mobile.activeBtnClass );
ok( !$( "#active-state-page2 a" ).hasClass( "ui-button-active" ), "No button should not have class ui-button-active" );
start();
}
] );
@@ -1406,15 +1406,15 @@ asyncTest( "vclicks are ignored where data-ajax='false' parents exist", function
function() {
// force the active button class
$hijacked.addClass( $.mobile.activeBtnClass );
$hijacked.addClass( "ui-button-active" );
$hijacked.trigger( 'vclick' );
ok( $hijacked.hasClass( $.mobile.activeBtnClass ), "active button class is added to the link per normal" );
ok( $hijacked.hasClass( "ui-button-active" ), "active button class is added to the link per normal" );
$disabledByParent.trigger( 'vclick' );
ok( !$disabledByParent.hasClass( $.mobile.activeBtnClass ), "active button class is never added to the link" );
ok( !$disabledByParent.hasClass( "ui-button-active" ), "active button class is never added to the link" );
$disabledByAttr.trigger( 'vclick' );
ok( !$disabledByAttr.hasClass( $.mobile.activeBtnClass ), "active button class is never added to the link" );
ok( !$disabledByAttr.hasClass( "ui-button-active" ), "active button class is never added to the link" );
$.mobile.ignoreContentEnabled = false;
start();
@@ -265,7 +265,7 @@ asyncTest( "selected items are highlighted", function() {
function() {
var firstMenuChoice = $( "#select-choice-few\\.dotTest-menu li:first a" );
ok( firstMenuChoice.hasClass( $.mobile.activeBtnClass ),
ok( firstMenuChoice.hasClass( "ui-button-active" ),
"default menu choice has the active button class" );
$( "#select-choice-few\\.dotTest-menu a:last" ).click();
@@ -278,7 +278,7 @@ asyncTest( "selected items are highlighted", function() {
function() {
var lastMenuChoice = $( "#select-choice-few\\.dotTest-menu li:last a" );
ok( lastMenuChoice.hasClass( $.mobile.activeBtnClass ),
ok( lastMenuChoice.hasClass( "ui-button-active" ),
"previously selected item has the active button class" );
// close the dialog
@@ -6,14 +6,14 @@ test( "navbar button gets active button class when clicked", function() {
var link = $( "#disabled-button-click a:not(.ui-disabled)" ).first();
link.click();
ok( link.hasClass( $.mobile.activeBtnClass ), "link has active button class" );
ok( link.hasClass( "ui-button-active" ), "link has active button class" );
} );
test( "disabled navbar button doesn't add active button class when clicked", function() {
var link = $( "#disabled-button-click a.ui-disabled" ).first();
link.click();
ok( !link.hasClass( $.mobile.activeBtnClass ), "link doesn't have active button class" );
ok( !link.hasClass( "ui-button-active" ), "link doesn't have active button class" );
} );
test( "grids inside an ignored container do not enhance", function() {
@@ -65,7 +65,7 @@ asyncTest( "classes modified by open", function() {
$modal = getModalFromPanel( $panel ),
$openButton = $page.find( "a[href='\\#panel-test-open']" );
ok( !$openButton.hasClass( $.mobile.activeBtnClass ), "button doesn't have active class" );
ok( !$openButton.hasClass( "ui-button-active" ), "button doesn't have active class" );
ok( !$panel.hasClass( defaults.classes.panelClosed ), "closed class removed" );
ok( $panel.hasClass( defaults.classes.panelOpen ), "open class added" );
@@ -110,7 +110,7 @@ asyncTest( "classes modified by close", function() {
$panel.one( "panelopen", function( event ) {
$panel.panel( "close" );
} ).one( "panelclose", function( event ) {
ok( !$openButton.hasClass( $.mobile.activeBtnClass ), "button doesn't have active class" );
ok( !$openButton.hasClass( "ui-button-active" ), "button doesn't have active class" );
ok( !$panel.hasClass( defaults.classes.panelOpen ), "panel not open class" );
ok( !$modal.hasClass( defaults.classes.modalOpen ), "modal without open class" );
@@ -30,10 +30,10 @@ test( "focus/blur adds resp. removes focus class", function( assert ) {
textarea = $( "#focus-class-test-for-textarea" ),
testFocusBlur = function( widget ) {
widget.blur();
assert.lacksClasses( widget.textinput( "widget" )[ 0 ], $.mobile.focusClass,
assert.lacksClasses( widget.textinput( "widget" )[ 0 ], "ui-focus",
widget.attr( "id" ) + ": focus class is absent when the widget is blurred." );
widget.focus();
assert.hasClasses( widget.textinput( "widget" )[ 0 ], $.mobile.focusClass,
assert.hasClasses( widget.textinput( "widget" )[ 0 ], "ui-focus",
widget.attr( "id" ) + ": focus class is present when the widget is focused." );
};
@@ -116,9 +116,9 @@ module( "Transition startIn", {
} );
test( "sets active page class on the dom element", function() {
ok( !$to.hasClass( $.mobile.activePageClass ) );
ok( !$to.hasClass( "ui-page-active" ) );
instance.startIn();
ok( $to.hasClass( $.mobile.activePageClass ) );
ok( $to.hasClass( "ui-page-active" ) );
} );
test( "sets the height", function() {

0 comments on commit 48e895e

Please sign in to comment.