|
16 | 16 |
|
17 | 17 | //get path from current hash, or from a file path |
18 | 18 | get: function( newPath ){ |
19 | | - if( newPath == undefined ){ |
| 19 | + if( newPath === undefined ){ |
20 | 20 | newPath = location.hash; |
21 | 21 | } |
22 | 22 | return path.stripHash( newPath ).replace(/[^\/]*\.[^\/*]+$/, ''); |
|
62 | 62 | }, |
63 | 63 |
|
64 | 64 | hasProtocol: function( url ){ |
65 | | - return /^(:?\w+:)/.test( url ); |
| 65 | + return (/^(:?\w+:)/).test( url ); |
66 | 66 | }, |
67 | 67 |
|
68 | 68 | //check if the url is relative |
69 | 69 | isRelative: function( url ){ |
70 | | - return /^[^\/|#]/.test( url ) && !path.hasProtocol( url ); |
| 70 | + return (/^[^\/|#]/).test( url ) && !path.hasProtocol( url ); |
71 | 71 | }, |
72 | 72 |
|
73 | 73 | isEmbeddedPage: function( url ){ |
74 | | - return /^#/.test( url ); |
| 74 | + return (/^#/).test( url ); |
75 | 75 | } |
76 | 76 | }, |
77 | 77 |
|
|
146 | 146 | if ($base.length){ |
147 | 147 | var href = $base.attr("href"); |
148 | 148 | if (href){ |
149 | | - if (href.search(/^[^:\/]+:\/\/[^\/]+\/?/) == -1){ |
| 149 | + if (href.search(/^[^:\/]+:\/\/[^\/]+\/?/) === -1){ |
150 | 150 | //the href is not absolute, we need to turn it into one |
151 | 151 | //so that we can turn paths stored in our location hash into |
152 | 152 | //relative paths. |
153 | | - if (href.charAt(0) == '/'){ |
| 153 | + if (href.charAt(0) === '/'){ |
154 | 154 | //site relative url |
155 | 155 | docBase = hostURL + href; |
156 | 156 | } |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | //make sure docBase ends with a slash |
170 | | - docBase = docBase + (docBase.charAt(docBase.length - 1) == '/' ? ' ' : '/'); |
| 170 | + docBase = docBase + (docBase.charAt(docBase.length - 1) === '/' ? ' ' : '/'); |
171 | 171 | } |
172 | 172 |
|
173 | 173 | //base element management, defined depending on dynamic base tag support |
|
207 | 207 | else{ |
208 | 208 | page.find( focusable ).eq(0).focus(); |
209 | 209 | } |
210 | | - }; |
| 210 | + } |
211 | 211 |
|
212 | 212 | //remove active classes after page transition or error |
213 | 213 | function removeActiveLinkClass( forceRemoval ){ |
214 | 214 | if( !!$activeClickedLink && (!$activeClickedLink.closest( '.ui-page-active' ).length || forceRemoval )){ |
215 | 215 | $activeClickedLink.removeClass( $.mobile.activeBtnClass ); |
216 | 216 | } |
217 | 217 | $activeClickedLink = null; |
218 | | - }; |
| 218 | + } |
219 | 219 |
|
220 | 220 | //animation complete callback |
221 | 221 | $.fn.animationComplete = function( callback ){ |
|
255 | 255 | //from is always the currently viewed page |
256 | 256 | var toIsArray = $.type(to) === "array", |
257 | 257 | 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, |
262 | 265 | type = 'get', |
263 | 266 | isFormRequest = false, |
264 | 267 | duplicateCachedPage = null, |
|
287 | 290 | // check if url is in history and if it's ahead or behind current page |
288 | 291 | $.each( urlHistory.stack, function( i ){ |
289 | 292 | //if the url is in the stack, it's a forward or a back |
290 | | - if( this.url == url ){ |
| 293 | + if( this.url === url ){ |
291 | 294 | urlIndex = i; |
292 | 295 | //define back and forward by whether url is older or newer than current page |
293 | 296 | back = i < urlHistory.activeIndex; |
|
310 | 313 |
|
311 | 314 |
|
312 | 315 | 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; |
316 | 319 | isFormRequest = true; |
317 | 320 | //make get requests bookmarkable |
318 | | - if( data && type == 'get' ){ |
319 | | - if($.type( data ) == "object" ){ |
| 321 | + if( data && type === 'get' ){ |
| 322 | + if($.type( data ) === "object" ){ |
320 | 323 | data = $.param(data); |
321 | 324 | } |
322 | 325 |
|
|
398 | 401 | $.mobile.activePage = to; |
399 | 402 |
|
400 | 403 | //if there's a duplicateCachedPage, remove it from the DOM now that it's hidden |
401 | | - if (duplicateCachedPage != null) { |
| 404 | + if (duplicateCachedPage !== null) { |
402 | 405 | duplicateCachedPage.remove(); |
403 | 406 | } |
404 | 407 |
|
405 | 408 | //remove initial build class (only present on first pageshow) |
406 | 409 | $html.removeClass( "ui-mobile-rendering" ); |
407 | 410 |
|
408 | 411 | releasePageTransitionLock(); |
409 | | - }; |
| 412 | + } |
410 | 413 |
|
411 | 414 | function addContainerClass(className){ |
412 | 415 | $.mobile.pageContainer.addClass(className); |
413 | 416 | pageContainerClasses.push(className); |
414 | | - }; |
| 417 | + } |
415 | 418 |
|
416 | 419 | function removeContainerClasses(){ |
417 | 420 | $.mobile |
418 | 421 | .pageContainer |
419 | 422 | .removeClass(pageContainerClasses.join(" ")); |
420 | 423 |
|
421 | 424 | pageContainerClasses = []; |
422 | | - }; |
| 425 | + } |
423 | 426 |
|
424 | 427 |
|
425 | 428 |
|
|
455 | 458 | to.addClass( $.mobile.activePageClass ); |
456 | 459 | loadComplete(); |
457 | 460 | } |
458 | | - }; |
| 461 | + } |
459 | 462 |
|
460 | 463 | //shared page enhancements |
461 | 464 | function enhancePage(){ |
462 | 465 |
|
463 | 466 | //set next page role, if defined |
464 | | - if ( nextPageRole || to.data('role') == 'dialog' ) { |
| 467 | + if ( nextPageRole || to.data('role') === 'dialog' ) { |
465 | 468 | url = urlHistory.getActive().url + dialogHashKey; |
466 | 469 | if(nextPageRole){ |
467 | 470 | to.attr( "data-role", nextPageRole ); |
|
471 | 474 |
|
472 | 475 | //run page plugin |
473 | 476 | to.page(); |
474 | | - }; |
| 477 | + } |
475 | 478 |
|
476 | 479 | //if url is a string |
477 | 480 | if( url ){ |
|
482 | 485 | var toID = to.attr('data-url'), |
483 | 486 | toIDfileurl = path.getFilePath(toID); |
484 | 487 |
|
485 | | - if(toID != toIDfileurl){ |
| 488 | + if(toID !== toIDfileurl){ |
486 | 489 | fileUrl = toIDfileurl; |
487 | 490 | } |
488 | 491 | } |
|
555 | 558 | .appendTo( $.mobile.pageContainer ); |
556 | 559 |
|
557 | 560 | enhancePage(); |
558 | | - setTimeout(function() { transitionPages() }, 0); |
| 561 | + setTimeout(function() { transitionPages(); }, 0); |
559 | 562 | }, |
560 | 563 | error: function() { |
561 | 564 | $.mobile.pageLoading( true ); |
|
632 | 635 | //check for protocol or rel and its not an embedded page |
633 | 636 | //TODO overlap in logic from isExternal, rel=external check should be |
634 | 637 | // moved into more comprehensive isExternalLink |
635 | | - isExternal = path.isExternal( url ) || isRelExternal && !isEmbeddedPage, |
| 638 | + isExternal = path.isExternal( url ) || (isRelExternal && !isEmbeddedPage), |
636 | 639 |
|
637 | 640 | //if target attr is specified we mimic _blank... for now |
638 | 641 | hasTarget = $this.is( "[target]" ), |
|
674 | 677 | //use ajax |
675 | 678 | var transition = $this.data( "transition" ), |
676 | 679 | direction = $this.data("direction"), |
677 | | - reverse = direction && direction == "reverse" || |
| 680 | + reverse = (direction && direction === "reverse") || |
678 | 681 | // deprecated - remove by 1.0 |
679 | 682 | $this.data( "back" ); |
680 | 683 |
|
|
703 | 706 |
|
704 | 707 | //if listening is disabled (either globally or temporarily), or it's a dialog hash |
705 | 708 | 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" )) |
707 | 710 | ){ |
708 | 711 | if( !urlHistory.ignoreNextHashChange ){ |
709 | 712 | urlHistory.ignoreNextHashChange = true; |
|
0 commit comments