Skip to content

Commit b696bda

Browse files
committed
Cleaning up a bunch of jslint errors and warnings.
1 parent 3ca20f8 commit b696bda

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

js/jquery.mobile.navigation.js

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
//get path from current hash, or from a file path
1818
get: function( newPath ){
19-
if( newPath == undefined ){
19+
if( newPath === undefined ){
2020
newPath = location.hash;
2121
}
2222
return path.stripHash( newPath ).replace(/[^\/]*\.[^\/*]+$/, '');
@@ -62,16 +62,16 @@
6262
},
6363

6464
hasProtocol: function( url ){
65-
return /^(:?\w+:)/.test( url );
65+
return (/^(:?\w+:)/).test( url );
6666
},
6767

6868
//check if the url is relative
6969
isRelative: function( url ){
70-
return /^[^\/|#]/.test( url ) && !path.hasProtocol( url );
70+
return (/^[^\/|#]/).test( url ) && !path.hasProtocol( url );
7171
},
7272

7373
isEmbeddedPage: function( url ){
74-
return /^#/.test( url );
74+
return (/^#/).test( url );
7575
}
7676
},
7777

@@ -146,11 +146,11 @@
146146
if ($base.length){
147147
var href = $base.attr("href");
148148
if (href){
149-
if (href.search(/^[^:\/]+:\/\/[^\/]+\/?/) == -1){
149+
if (href.search(/^[^:\/]+:\/\/[^\/]+\/?/) === -1){
150150
//the href is not absolute, we need to turn it into one
151151
//so that we can turn paths stored in our location hash into
152152
//relative paths.
153-
if (href.charAt(0) == '/'){
153+
if (href.charAt(0) === '/'){
154154
//site relative url
155155
docBase = hostURL + href;
156156
}
@@ -167,7 +167,7 @@
167167
}
168168
}
169169
//make sure docBase ends with a slash
170-
docBase = docBase + (docBase.charAt(docBase.length - 1) == '/' ? ' ' : '/');
170+
docBase = docBase + (docBase.charAt(docBase.length - 1) === '/' ? ' ' : '/');
171171
}
172172

173173
//base element management, defined depending on dynamic base tag support
@@ -207,15 +207,15 @@
207207
else{
208208
page.find( focusable ).eq(0).focus();
209209
}
210-
};
210+
}
211211

212212
//remove active classes after page transition or error
213213
function removeActiveLinkClass( forceRemoval ){
214214
if( !!$activeClickedLink && (!$activeClickedLink.closest( '.ui-page-active' ).length || forceRemoval )){
215215
$activeClickedLink.removeClass( $.mobile.activeBtnClass );
216216
}
217217
$activeClickedLink = null;
218-
};
218+
}
219219

220220
//animation complete callback
221221
$.fn.animationComplete = function( callback ){
@@ -255,10 +255,13 @@
255255
//from is always the currently viewed page
256256
var toIsArray = $.type(to) === "array",
257257
toIsObject = $.type(to) === "object",
258-
from = toIsArray ? to[0] : $.mobile.activePage,
259-
to = toIsArray ? to[1] : to,
260-
url = fileUrl = $.type(to) === "string" ? path.stripHash( to ) : "",
261-
data = undefined,
258+
from = toIsArray ? to[0] : $.mobile.activePage;
259+
260+
to = toIsArray ? to[1] : to;
261+
262+
var url = $.type(to) === "string" ? path.stripHash( to ) : "",
263+
fileUrl = url,
264+
data,
262265
type = 'get',
263266
isFormRequest = false,
264267
duplicateCachedPage = null,
@@ -287,7 +290,7 @@
287290
// check if url is in history and if it's ahead or behind current page
288291
$.each( urlHistory.stack, function( i ){
289292
//if the url is in the stack, it's a forward or a back
290-
if( this.url == url ){
293+
if( this.url === url ){
291294
urlIndex = i;
292295
//define back and forward by whether url is older or newer than current page
293296
back = i < urlHistory.activeIndex;
@@ -310,13 +313,13 @@
310313

311314

312315
if( toIsObject && to.url ){
313-
url = to.url,
314-
data = to.data,
315-
type = to.type,
316+
url = to.url;
317+
data = to.data;
318+
type = to.type;
316319
isFormRequest = true;
317320
//make get requests bookmarkable
318-
if( data && type == 'get' ){
319-
if($.type( data ) == "object" ){
321+
if( data && type === 'get' ){
322+
if($.type( data ) === "object" ){
320323
data = $.param(data);
321324
}
322325

@@ -398,28 +401,28 @@
398401
$.mobile.activePage = to;
399402

400403
//if there's a duplicateCachedPage, remove it from the DOM now that it's hidden
401-
if (duplicateCachedPage != null) {
404+
if (duplicateCachedPage !== null) {
402405
duplicateCachedPage.remove();
403406
}
404407

405408
//remove initial build class (only present on first pageshow)
406409
$html.removeClass( "ui-mobile-rendering" );
407410

408411
releasePageTransitionLock();
409-
};
412+
}
410413

411414
function addContainerClass(className){
412415
$.mobile.pageContainer.addClass(className);
413416
pageContainerClasses.push(className);
414-
};
417+
}
415418

416419
function removeContainerClasses(){
417420
$.mobile
418421
.pageContainer
419422
.removeClass(pageContainerClasses.join(" "));
420423

421424
pageContainerClasses = [];
422-
};
425+
}
423426

424427

425428

@@ -455,13 +458,13 @@
455458
to.addClass( $.mobile.activePageClass );
456459
loadComplete();
457460
}
458-
};
461+
}
459462

460463
//shared page enhancements
461464
function enhancePage(){
462465

463466
//set next page role, if defined
464-
if ( nextPageRole || to.data('role') == 'dialog' ) {
467+
if ( nextPageRole || to.data('role') === 'dialog' ) {
465468
url = urlHistory.getActive().url + dialogHashKey;
466469
if(nextPageRole){
467470
to.attr( "data-role", nextPageRole );
@@ -471,7 +474,7 @@
471474

472475
//run page plugin
473476
to.page();
474-
};
477+
}
475478

476479
//if url is a string
477480
if( url ){
@@ -482,7 +485,7 @@
482485
var toID = to.attr('data-url'),
483486
toIDfileurl = path.getFilePath(toID);
484487

485-
if(toID != toIDfileurl){
488+
if(toID !== toIDfileurl){
486489
fileUrl = toIDfileurl;
487490
}
488491
}
@@ -555,7 +558,7 @@
555558
.appendTo( $.mobile.pageContainer );
556559

557560
enhancePage();
558-
setTimeout(function() { transitionPages() }, 0);
561+
setTimeout(function() { transitionPages(); }, 0);
559562
},
560563
error: function() {
561564
$.mobile.pageLoading( true );
@@ -632,7 +635,7 @@
632635
//check for protocol or rel and its not an embedded page
633636
//TODO overlap in logic from isExternal, rel=external check should be
634637
// moved into more comprehensive isExternalLink
635-
isExternal = path.isExternal( url ) || isRelExternal && !isEmbeddedPage,
638+
isExternal = path.isExternal( url ) || (isRelExternal && !isEmbeddedPage),
636639

637640
//if target attr is specified we mimic _blank... for now
638641
hasTarget = $this.is( "[target]" ),
@@ -674,7 +677,7 @@
674677
//use ajax
675678
var transition = $this.data( "transition" ),
676679
direction = $this.data("direction"),
677-
reverse = direction && direction == "reverse" ||
680+
reverse = (direction && direction === "reverse") ||
678681
// deprecated - remove by 1.0
679682
$this.data( "back" );
680683

@@ -703,7 +706,7 @@
703706

704707
//if listening is disabled (either globally or temporarily), or it's a dialog hash
705708
if( !$.mobile.hashListeningEnabled || !urlHistory.ignoreNextHashChange ||
706-
urlHistory.stack.length > 1 && to.indexOf( dialogHashKey ) > -1 && !$.mobile.activePage.is( ".ui-dialog" )
709+
(urlHistory.stack.length > 1 && to.indexOf( dialogHashKey ) > -1 && !$.mobile.activePage.is( ".ui-dialog" ))
707710
){
708711
if( !urlHistory.ignoreNextHashChange ){
709712
urlHistory.ignoreNextHashChange = true;

0 commit comments

Comments
 (0)