Allow container-based url in history api
When a url is now loaded for an non-main container, the url for the container is appended to the GET part of the URL refs #4303
This commit is contained in:
parent
e8d7971531
commit
fa5c499733
|
@ -71,7 +71,6 @@ define([
|
|||
loadUrl: function(url, target, params) {
|
||||
target = target || "icinga-main";
|
||||
async.loadToTarget(target, url, params);
|
||||
History.pushState(params, document.title, url);
|
||||
},
|
||||
|
||||
getFailedModules: function() {
|
||||
|
|
|
@ -9,7 +9,33 @@
|
|||
var pending = {
|
||||
|
||||
};
|
||||
|
||||
|
||||
var getCurrentGETParameters = function() {
|
||||
var currentGET = window.location.search.substring(1).split("&");
|
||||
var params = {};
|
||||
if(currentGET.length > 0) {
|
||||
$.each(currentGET, function(idx, elem) {
|
||||
var keyVal = elem.split("=");
|
||||
params[encodeURIComponent(keyVal[0])] = encodeURIComponent(keyVal[1]);
|
||||
});
|
||||
}
|
||||
return params;
|
||||
}
|
||||
;
|
||||
var pushGet = function(param, value, url) {
|
||||
url = url || (window.location.origin+window.location.pathname);
|
||||
var params = getCurrentGETParameters();
|
||||
params[encodeURIComponent(param)] = encodeURIComponent(value);
|
||||
var search = "?";
|
||||
for (var name in params) {
|
||||
if(search != "?")
|
||||
search += "&";
|
||||
search += name+"="+params[name];
|
||||
}
|
||||
|
||||
return url+search+"#"+window.location.hash;
|
||||
};
|
||||
|
||||
var getDOMForDestination = function(destination) {
|
||||
var target = destination;
|
||||
if(typeof destination === "string") {
|
||||
|
@ -96,14 +122,13 @@
|
|||
if (destination == "icinga-main") {
|
||||
History.pushState(data, document.title, url);
|
||||
} else {
|
||||
data = data || {};
|
||||
data[destination] = url;
|
||||
History.pushState(data, document.title, document.location.href);
|
||||
url = pushGet("c["+destination+"]", url);
|
||||
History.pushState(data, document.title, url);
|
||||
}
|
||||
console.log("New url: ", url);
|
||||
return req;
|
||||
|
||||
};
|
||||
|
||||
|
||||
this.loadCSS = function(name) {
|
||||
|
||||
};
|
||||
|
|
|
@ -44,12 +44,16 @@ var onSecondLink = function() {
|
|||
casper.page.evaluate(function() {
|
||||
requirejs(["icinga/icinga"], function(icinga) {
|
||||
icinga.loadUrl("/fragments/testFragment3.html?this=is_a_param", "icinga-detail");
|
||||
console.log(document.location.href);
|
||||
|
||||
});
|
||||
});
|
||||
console.log(casper.page.evaluate(function() {
|
||||
return document.location.href;
|
||||
}));
|
||||
this.wait(400, function() {
|
||||
console.log(casper.page.evaluate(function() {
|
||||
return window.location.href;
|
||||
}));
|
||||
|
||||
this.test.assertUrlMatch(/testFragment2.html.*testFragment3.html/);
|
||||
});
|
||||
};
|
||||
|
||||
casper.run(function() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div>
|
||||
<h1>Test fragment</h1>
|
||||
<a href="/fragments/testFragment2.html">Fragment 2</a>
|
||||
<a href="/fragments/testFragment2.html?this=istesting">Fragment 2</a>
|
||||
<a href="/fragments/testFragment3.html">Fragment 3</a>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/Users/moja/git/icinga2-web/test/frontend/../../public
|
Loading…
Reference in New Issue