Skip to content

Commit

Permalink
Add rule for 'body' container and QLink property 'target'
Browse files Browse the repository at this point in the history
QLinks can now define the target for their link. Additionally, the
targte 'body' is now always the <body> tag. This allows the
modulemanager to reload the whole page (with the navigation bar).

refs #4092
  • Loading branch information
Jannis Moßhammer authored and mxhash committed Jun 26, 2013
1 parent e9ade7a commit beaac3a
Showing 1 changed file with 6 additions and 32 deletions.
38 changes: 6 additions & 32 deletions public/js/icinga/util/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,27 @@
"use strict";
var asyncMgrInstance = null;

define(['icinga/container','logging','jquery'],function(containerMgr,log,$) {
var headerListeners = {};
define(['icinga/container','logging','icinga/behaviour','jquery'],function(containerMgr,log,behaviour,$) {

var pending = {

};
var getDOMForDestination = function(destination) {
var target = destination;
if (typeof destination === "string") {
if(typeof destination === "string") {
target = containerMgr.getContainer(destination)[0];
} else if(typeof destination.context !== "undefined") {
target = destination[0];
}
return target;
};

var applyHeaderListeners = function(headers) {
for (var header in headerListeners) {
if (headers.getResponseHeader(header) === null) {
// see if the browser/server converts headers to lowercase
if (headers.getResponseHeader(header.toLowerCase()) === null) {
continue;
}
header = header.toLowerCase();
}
var value = headers.getResponseHeader(header);
var listeners = headerListeners[header];
for (var i=0;i<listeners.length;i++) {
listeners[i].fn.apply(listeners[i].scope, [value, header, headers]);
}
}
};
var handleResponse = function(html) {

var handleResponse = function(html, status, response) {
applyHeaderListeners(response);
if(this.destination) {
containerMgr.updateContainer(this.destination,html,this);
} else {
// tbd
// containerMgr.createPopupContainer(html,this);
containerMgr.createPopupContainer(html,this);
}
};

Expand All @@ -68,8 +49,6 @@

var CallInterface = function() {

this.__internalXHRImplementation = $.ajax;

this.clearPendingRequestsFor = function(destination) {
if(!$.isArray(pending)) {
pending = [];
Expand All @@ -89,7 +68,7 @@
};

this.createRequest = function(url,data) {
var req = this.__internalXHRImplementation({
var req = $.ajax({
type : data ? 'POST' : 'GET',
url : url,
data : data,
Expand All @@ -110,7 +89,7 @@
if(destination) {
pending.push({
request: req,
DOM: getDOMForDestination(destination)
DOM: getDOMForDestination(destination)
});
req.destination = destination;
}
Expand All @@ -122,11 +101,6 @@
this.loadCSS = function(name) {

};

this.registerHeaderListener = function(header, fn, scope) {
headerListeners[header] = headerListeners[header] || [];
headerListeners[header].push({fn: fn, scope:scope});
};
};
return new CallInterface();
});
Expand Down

0 comments on commit beaac3a

Please sign in to comment.