Add rule for 'body' container and QLink property 'target'

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
This commit is contained in:
Jannis Moßhammer 2013-06-20 14:02:58 +02:00 committed by Marius Hein
parent 5c167563fa
commit 34f68856ee
6 changed files with 53 additions and 84 deletions

View File

@ -12,14 +12,6 @@
</div>
<div id="icinga-detail" class="icinga-container " container-id="icinga-detail">
<div class="container-controls">
<a class="container-expand-link" title="expand" target="_self" href="/develop/monitoring/list/services">
<i class="icon-fullscreen"></i>
</a>
<a class="container-detach-link" title="detach" target="popup" href="/develop/develop/monitoring/list/services">
<i class="icon-share"></i>
</a>
</div>
</div>
</div>

View File

@ -21,12 +21,12 @@
ICINGA_DEBUG = true;
</script>
<script src="<?php echo $this->baseUrl('js/vendor/modernizr-2.6.2.min.js') ?>"></script>
<link rel="stylesheet" href="<?php echo $this->baseUrl('css/icinga.css') ?>">
<link rel="stylesheet" href="<?php echo $this->baseUrl('css.php') ?>">
<link rel="stylesheet" href="<?php echo $this->baseUrl('css/vendor/bootstrap-responsive.min.css') ?>">
<script data-main="<?php echo $this->baseUrl('js/main.js')?>" src="<?php echo $this->baseUrl('js/vendor/require.js') ?>"></script>
</head>
<body class="cranberry">
<body class="cranberry">
<?php echo $this->render('parts/topbar.phtml') ?>
<div class="main">
<div class="tabbable tabs-left" style="height:100%;">

View File

@ -5,7 +5,8 @@
$item = $this->navigation->listAll("menu");
?>
<?php if ($this->auth()->isAuthenticated()): ?>
<?php if (true || $this->auth()->isAuthenticated()): ?>
<ul class="nav nav-tabs icinga-navigation" >
<?php
$activeSet = false;

View File

@ -36,6 +36,9 @@ class Zend_View_Helper_Qlink extends Zend_View_Helper_Abstract
$quote = $val;
continue;
}
if ($key === 'target') {
$attibutes[] = 'target="'.$val.'"';
}
if ($key === 'style' && is_array($val)) {
if (empty($val)) {
continue;
@ -93,4 +96,4 @@ class Zend_View_Helper_Qlink extends Zend_View_Helper_Abstract
return is_null($baseUrl) ? $this->view->baseUrl($url) : $baseUrl . $url;
}
}
// @codingStandardsIgnoreEnd
// @codingStandardsIgnoreEnd

View File

@ -16,45 +16,52 @@ define(['jquery','logging','icinga/util/async'],function($,log,async) {
href = a.attr("href");
ev.stopImmediatePropagation();
collapseDetailView();
async.loadToTarget("icinga-main",href);
return false;
};
var onLinkTagClick = function(ev) {
var a = $(ev.currentTarget),
target = a.attr("target"),
href = a.attr("href");
// check for protocol://
if(/^[A-Z]{2,10}\:\/\//i.test(href)) {
window.open(href);
ev.stopImmediatePropagation();
return false;
}
// check for link in table header
if(a.parents('th').length > 0) {
ev.stopImmediatePropagation();
return false;
}
if(typeof target === "undefined") {
if(a.parents("#icinga-detail").length) {
log.debug("Parent is detail, loading into detail");
async.loadToTarget("icinga-detail",href);
} else {
log.debug("Parent is not detail, loading into main");
async.loadToTarget("icinga-main",href);
return false;
};
var onLinkTagClick = function(ev) {
var a = $(ev.currentTarget),
target = a.attr("target"),
href = a.attr("href");
// check for protocol://
if(/^[A-Z]{2,10}\:\/\//i.test(href)) {
window.open(href);
ev.stopImmediatePropagation();
return false;
}
// check for link in table header
if(a.parents('th').length > 0) {
ev.stopImmediatePropagation();
return false;
}
if(typeof target === "undefined") {
if(a.parents("#icinga-detail").length) {
async.loadToTarget("icinga-detail",href);
} else {
async.loadToTarget("icinga-main",href);
}
} else {
switch(target) {
}
} else {
switch(target) {
case "body":
async.loadToTarget("body", href);
break;
case "main":
async.loadToTarget("icinga-main",href);
collapseDetailView();
break;
case "detail":
log.debug("Target: detail");
async.loadToTarget("icinga-detail",href);
break;
case "popup":
log.debug("No target");
async.loadToTarget(null,href);
break;
default:
@ -67,7 +74,7 @@ define(['jquery','logging','icinga/util/async'],function($,log,async) {
var expandDetailView = function() {
$("#icinga-detail").parents(".collapsed").removeClass('collapsed');
};
};
var collapseDetailView = function(elementInDetailView) {
$("#icinga-detail").parents(".layout-main-detail").addClass('collapsed');
@ -88,7 +95,5 @@ define(['jquery','logging','icinga/util/async'],function($,log,async) {
}
};
};
return new MainDetailBehaviour();
});

View File

@ -3,39 +3,11 @@
"use strict";
var asyncMgrInstance = null;
define(['icinga/container','logging','jquery'],function(containerMgr,log,$) {
define(['icinga/container','logging','icinga/behaviour','jquery'],function(containerMgr,log,behaviour,$) {
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") {
@ -47,6 +19,7 @@
};
var handleResponse = function(html) {
if(this.destination) {
containerMgr.updateContainer(this.destination,html,this);
} else {
@ -109,31 +82,26 @@
this.loadToTarget = function(destination,url,data) {
if(destination) {
log.debug("Laoding to container", destination, url);
this.clearPendingRequestsFor(destination);
}
var req = this.createRequest(url,data);
if(destination) {
pending.push({
request: req,
DOM: getDOMForDestination(destination)
DOM: getDOMForDestination(destination)
});
req.destination = destination;
}
if (destination == "icinga-main") {
History.pushState(data, document.title, url);
} else {
url = pushGet("c["+destination+"]", url);
History.pushState(data, document.title, url);
}
console.log("New url: ", url);
return req;
};
this.loadCSS = function(name) {
};
};
return new CallInterface();
});
})();