Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

The router was patched to change the fragment in order to retain hash…

… parameters.
  • Loading branch information...
commit b1e00651b511f1adf55bdc92f8e504740cfe6b20 1 parent d9c19b3
@azicchetti authored
Showing with 5 additions and 1 deletion.
  1. +4 −0 js/jquery.mobile.router.js
  2. +1 −1  js/jquery.mobile.router.min.js
View
4 js/jquery.mobile.router.js
@@ -57,6 +57,10 @@ $(document).on("mobileinit", function(){
previousUrl = nextUrl;
nextUrl = u;
+ if (u.hash.indexOf("?") != -1){
+ data.options.dataUrl = u.hash.replace(/^#/,"");
+ }
+
// conditions to possibly set allowSamePageTransitions: we have a "?" or we're transitioning from
// #foo?params to #foo
var noparamsRE = /^#|\?.*$/g;
View
2  js/jquery.mobile.router.min.js
@@ -7,4 +7,4 @@
* http://github.com/azicchetti/jquerymobile-router/blob/master/MIT-LICENSE.txt
* http://github.com/azicchetti/jquerymobile-router/blob/master/GPL-LICENSE.txt
*/
-(function(a,b){if(typeof define==="function"&&define.amd){define(["jquery"],b)}else{b(jQuery)}}(this,function(a){a(document).on("mobileinit",function(){var e=a.extend({fixFirstPageDataUrl:false,firstPageDataUrl:"index.html",ajaxApp:false,firstMatchOnly:false},a.mobile.jqmRouter||{});var c=true;function b(h){if(c){console.log(h);if(h.stack){console.log(h.stack)}}}var f=null,g=null,d=false;a(document).on("pagebeforechange",function(l,k){var j=(typeof k.toPage==="string")?k.toPage:k.toPage.jqmData("url")||"";if(k.options.hasOwnProperty("_jqmrouter_handled")){return}k.options._jqmrouter_handled=true;if(k.options.data&&(k.options.type+"").toLowerCase()=="get"){j+="?"+k.options.data}var i=a.mobile.path.parseUrl(j);f=g;g=i;var h=/^#|\?.*$/g;if(f&&i.hash!=f.hash&&i.hash.replace(h,"")==f.hash.replace(h,"")){k.options.allowSamePageTransition=true&&!d}d=false;if(window.location.hash.indexOf("&ui-state=dialog")!=-1){d=true}});if(e.fixFirstPageDataUrl){a(document).ready(function(){if(!window.location.pathname.match("/$")){return}var i=a(":jqmData(role='page')").first();var j=i.jqmData("url"),h=window.location.pathname+e.firstPageDataUrl+window.location.search+window.location.hash;if(j!=h){i.attr("data-url",h).jqmData("url",h)}})}a.mobile.Router=function(l,j,k){this.routes={pagebeforecreate:null,pagecreate:null,pagebeforeshow:null,pageshow:null,pagebeforehide:null,pagehide:null,pageinit:null,pageremove:null,pagebeforechange:null,pagebeforeload:null,pageload:null,popupbeforeposition:null,popupafteropen:null,popupafterclose:null};this.evtLookup={bC:"pagebeforechange",bl:"pagebeforeload",l:"pageload",bc:"pagebeforecreate",c:"pagecreate",bs:"pagebeforeshow",s:"pageshow",bh:"pagebeforehide",h:"pagehide",i:"pageinit",rm:"pageremove",pbp:"popupbeforeposition",pao:"popupafteropen",pac:"popupafterclose"};this.routesRex={};this.conf=a.extend({},e,k||{});this.defaultHandlerEvents={};if(this.conf.defaultHandlerEvents){var h=this.conf.defaultHandlerEvents.split(",");for(var m=0;m<h.length;m++){this.defaultHandlerEvents[this.evtLookup[h[m]]]=h[m]}}this.add(l,j)};a.extend(a.mobile.Router.prototype,{documentEvts:{pagebeforechange:1,pagebeforeload:1,pageload:1},add:function(k,j,m){if(!k){return}var h=this,i=[],n=[];if(k instanceof Array){a.each(k,a.proxy(function(p,o){this.add(o,j,true)},this))}else{a.each(k,function(t,q){if(typeof(q)=="string"||typeof(q)=="function"){if(h.routes.pagebeforeshow===null){h.routes.pagebeforeshow={}}h.routes.pagebeforeshow[t]=q;if(!h.routesRex.hasOwnProperty(t)){h.routesRex[t]=new RegExp(t)}}else{var p,s=q.events.split(","),o;for(p=0;p<s.length;p++){o=h.evtLookup[s[p]];if(h.routes.hasOwnProperty(o)){if(h.routes[o]===null){h.routes[o]={}}h.routes[o][t]=q.handler;if(!h.routesRex.hasOwnProperty(t)){h.routesRex[t]=new RegExp(t)}}else{b("can't set unsupported route "+s[p])}}}})}if(m===true){return}if(!this.userHandlers){this.userHandlers=j||{}}else{a.extend(this.userHandlers,j||{})}a.each(h.routes,function(o,p){if(p!==null){if(!h.documentEvts[o]){i.push(o)}else{n.push(o)}}});this._detachEvents();var l=function(p,o){h._processRoutes(p,o,this)};if(i.length>0){this._eventData={events:i.join(" "),selectors:":jqmData(role='page'),:jqmData(role='dialog')",handler:l};a(document).on(this._eventData.events,this._eventData.selectors,this._eventData.handler)}if(n.length>0){this._docEventData={events:n.join(" "),handler:l};a(document).on(this._docEventData.events,this._docEventData.handler)}},_processRoutes:function(m,q,n){var o=this,p,i,l,h=0;if(m.type in {pagebeforehide:true,pagehide:true,pageremove:true}){p=f}else{p=g}do{if(!p){if(n){l=a(n);p=l.jqmData("url");if(p){if(l.attr("id")==p){p="#"+p}p=a.mobile.path.parseUrl(p)}}}else{if(!this.documentEvts[m.type]&&n&&!a(n).jqmData("url")){return}}if(!p){return}i=(!this.conf.ajaxApp?p.hash:p.pathname+p.search+p.hash);if(i.length==0){p=""}h++}while(i.length==0&&h<=1);var k=false;a.each(this.routes[m.type],function(r,t){var s,v;if((s=i.match(o.routesRex[r]))){if(typeof(t)=="function"){v=t}else{if(typeof(o.userHandlers[t])=="function"){v=o.userHandlers[t]}}if(v){try{v.apply(o.userHandlers,[m.type,s,q,n,m]);k=true}catch(u){b(u)}}}if(k&&o.conf.firstMatchOnly){return false}});if(!k&&this.conf.defaultHandler&&this.defaultHandlerEvents[m.type]){if(typeof(this.conf.defaultHandler)=="function"){try{this.conf.defaultHandler.apply(o.userHandlers,[m.type,q,n,m])}catch(j){b(j)}}}},_detachEvents:function(){if(this._eventData){a(document).off(this._eventData.events,this._eventData.selectors,this._eventData.handler)}if(this._docEventData){a(document).off(this._docEventData.events,this._docEventData.handler)}},destroy:function(){this._detachEvents();this.routes=this.routesRex=null},getParams:function(h){if(!h){return null}var k={},i;var j=h.slice(h.indexOf("?")+1).split("&");a.each(j,function(m,l){i=l.split("=");i[0]=decodeURIComponent(i[0]);if(k[i[0]]){if(!(k[i[0]] instanceof Array)){k[i[0]]=[k[i[0]]]}k[i[0]].push(decodeURIComponent(i[1]))}else{k[i[0]]=decodeURIComponent(i[1])}});if(a.isEmptyObject(k)){return null}return k}})});return{}}));
+(function(a,b){if(typeof define==="function"&&define.amd){define(["jquery"],b)}else{b(jQuery)}}(this,function(a){a(document).on("mobileinit",function(){var e=a.extend({fixFirstPageDataUrl:false,firstPageDataUrl:"index.html",ajaxApp:false,firstMatchOnly:false},a.mobile.jqmRouter||{});var c=true;function b(h){if(c){console.log(h);if(h.stack){console.log(h.stack)}}}var f=null,g=null,d=false;a(document).on("pagebeforechange",function(l,k){var j=(typeof k.toPage==="string")?k.toPage:k.toPage.jqmData("url")||"";if(k.options.hasOwnProperty("_jqmrouter_handled")){return}k.options._jqmrouter_handled=true;if(k.options.data&&(k.options.type+"").toLowerCase()=="get"){j+="?"+k.options.data}var i=a.mobile.path.parseUrl(j);f=g;g=i;if(i.hash.indexOf("?")!=-1){k.options.dataUrl=i.hash.replace(/^#/,"")}var h=/^#|\?.*$/g;if(f&&i.hash!=f.hash&&i.hash.replace(h,"")==f.hash.replace(h,"")){k.options.allowSamePageTransition=true&&!d}d=false;if(window.location.hash.indexOf("&ui-state=dialog")!=-1){d=true}});if(e.fixFirstPageDataUrl){a(document).ready(function(){if(!window.location.pathname.match("/$")){return}var i=a(":jqmData(role='page')").first();var j=i.jqmData("url"),h=window.location.pathname+e.firstPageDataUrl+window.location.search+window.location.hash;if(j!=h){i.attr("data-url",h).jqmData("url",h)}})}a.mobile.Router=function(l,j,k){this.routes={pagebeforecreate:null,pagecreate:null,pagebeforeshow:null,pageshow:null,pagebeforehide:null,pagehide:null,pageinit:null,pageremove:null,pagebeforechange:null,pagebeforeload:null,pageload:null,popupbeforeposition:null,popupafteropen:null,popupafterclose:null};this.evtLookup={bC:"pagebeforechange",bl:"pagebeforeload",l:"pageload",bc:"pagebeforecreate",c:"pagecreate",bs:"pagebeforeshow",s:"pageshow",bh:"pagebeforehide",h:"pagehide",i:"pageinit",rm:"pageremove",pbp:"popupbeforeposition",pao:"popupafteropen",pac:"popupafterclose"};this.routesRex={};this.conf=a.extend({},e,k||{});this.defaultHandlerEvents={};if(this.conf.defaultHandlerEvents){var h=this.conf.defaultHandlerEvents.split(",");for(var m=0;m<h.length;m++){this.defaultHandlerEvents[this.evtLookup[h[m]]]=h[m]}}this.add(l,j)};a.extend(a.mobile.Router.prototype,{documentEvts:{pagebeforechange:1,pagebeforeload:1,pageload:1},add:function(k,j,m){if(!k){return}var h=this,i=[],n=[];if(k instanceof Array){a.each(k,a.proxy(function(p,o){this.add(o,j,true)},this))}else{a.each(k,function(t,q){if(typeof(q)=="string"||typeof(q)=="function"){if(h.routes.pagebeforeshow===null){h.routes.pagebeforeshow={}}h.routes.pagebeforeshow[t]=q;if(!h.routesRex.hasOwnProperty(t)){h.routesRex[t]=new RegExp(t)}}else{var p,s=q.events.split(","),o;for(p=0;p<s.length;p++){o=h.evtLookup[s[p]];if(h.routes.hasOwnProperty(o)){if(h.routes[o]===null){h.routes[o]={}}h.routes[o][t]=q.handler;if(!h.routesRex.hasOwnProperty(t)){h.routesRex[t]=new RegExp(t)}}else{b("can't set unsupported route "+s[p])}}}})}if(m===true){return}if(!this.userHandlers){this.userHandlers=j||{}}else{a.extend(this.userHandlers,j||{})}a.each(h.routes,function(o,p){if(p!==null){if(!h.documentEvts[o]){i.push(o)}else{n.push(o)}}});this._detachEvents();var l=function(p,o){h._processRoutes(p,o,this)};if(i.length>0){this._eventData={events:i.join(" "),selectors:":jqmData(role='page'),:jqmData(role='dialog')",handler:l};a(document).on(this._eventData.events,this._eventData.selectors,this._eventData.handler)}if(n.length>0){this._docEventData={events:n.join(" "),handler:l};a(document).on(this._docEventData.events,this._docEventData.handler)}},_processRoutes:function(m,q,n){var o=this,p,i,l,h=0;if(m.type in {pagebeforehide:true,pagehide:true,pageremove:true}){p=f}else{p=g}do{if(!p){if(n){l=a(n);p=l.jqmData("url");if(p){if(l.attr("id")==p){p="#"+p}p=a.mobile.path.parseUrl(p)}}}else{if(!this.documentEvts[m.type]&&n&&!a(n).jqmData("url")){return}}if(!p){return}i=(!this.conf.ajaxApp?p.hash:p.pathname+p.search+p.hash);if(i.length==0){p=""}h++}while(i.length==0&&h<=1);var k=false;a.each(this.routes[m.type],function(r,t){var s,v;if((s=i.match(o.routesRex[r]))){if(typeof(t)=="function"){v=t}else{if(typeof(o.userHandlers[t])=="function"){v=o.userHandlers[t]}}if(v){try{v.apply(o.userHandlers,[m.type,s,q,n,m]);k=true}catch(u){b(u)}}}if(k&&o.conf.firstMatchOnly){return false}});if(!k&&this.conf.defaultHandler&&this.defaultHandlerEvents[m.type]){if(typeof(this.conf.defaultHandler)=="function"){try{this.conf.defaultHandler.apply(o.userHandlers,[m.type,q,n,m])}catch(j){b(j)}}}},_detachEvents:function(){if(this._eventData){a(document).off(this._eventData.events,this._eventData.selectors,this._eventData.handler)}if(this._docEventData){a(document).off(this._docEventData.events,this._docEventData.handler)}},destroy:function(){this._detachEvents();this.routes=this.routesRex=null},getParams:function(h){if(!h){return null}var k={},i;var j=h.slice(h.indexOf("?")+1).split("&");a.each(j,function(m,l){i=l.split("=");i[0]=decodeURIComponent(i[0]);if(k[i[0]]){if(!(k[i[0]] instanceof Array)){k[i[0]]=[k[i[0]]]}k[i[0]].push(decodeURIComponent(i[1]))}else{k[i[0]]=decodeURIComponent(i[1])}});if(a.isEmptyObject(k)){return null}return k}})});return{}}));
Please sign in to comment.
Something went wrong with that request. Please try again.