Refactored code so that Javascripts are loaded on demand
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6766 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
da61fe960e
commit
87cdcc6df6
@ -56,7 +56,7 @@ function getConfigTab() {
|
||||
*/
|
||||
function loadConfigPage() {
|
||||
// If the configure page has already been loaded
|
||||
if ($('#configure_page').children().length) {
|
||||
if ($('#content').children().length) {
|
||||
// Do not reload configure page
|
||||
return;
|
||||
}
|
||||
@ -65,7 +65,7 @@ function loadConfigPage() {
|
||||
var tab = new Tab();
|
||||
setConfigTab(tab);
|
||||
tab.init();
|
||||
$('#configure_page').append(tab.object());
|
||||
$('#content').append(tab.object());
|
||||
|
||||
// Create loader
|
||||
var loader = createLoader();
|
||||
|
@ -40,13 +40,13 @@ function loadMonitorPage() {
|
||||
var tab = new Tab();
|
||||
setConfigTab(tab);
|
||||
tab.init();
|
||||
$('#monitor_page').append(tab.object());
|
||||
$('#content').append(tab.object());
|
||||
|
||||
// Create provision tab
|
||||
var tab = new Tab();
|
||||
setMonitorTab(tab);
|
||||
tab.init();
|
||||
$('#monitor_page').append(tab.object());
|
||||
$('#content').append(tab.object());
|
||||
|
||||
/**
|
||||
* Monitor nodes
|
||||
|
@ -57,8 +57,8 @@ function loadNodesPage() {
|
||||
// Create a groups division
|
||||
groupDIV = $('<div id="groups"></div>');
|
||||
nodesDIV = $('<div id="nodes"></div>');
|
||||
$('#nodes_page').append(groupDIV);
|
||||
$('#nodes_page').append(nodesDIV);
|
||||
$('#content').append(groupDIV);
|
||||
$('#content').append(nodesDIV);
|
||||
|
||||
// Create info bar
|
||||
var info = createInfoBar('Select a group to view its nodes');
|
||||
|
@ -31,7 +31,7 @@ function getProvisionTab() {
|
||||
*/
|
||||
function loadProvisionPage() {
|
||||
// If the page is loaded
|
||||
if ($('#provision_page').children().length) {
|
||||
if ($('#content').children().length) {
|
||||
// Do not load again
|
||||
return;
|
||||
}
|
||||
@ -43,7 +43,7 @@ function loadProvisionPage() {
|
||||
|
||||
// Create info bar
|
||||
var infoBar = createInfoBar('Provision a node');
|
||||
$('#provision_page').append(infoBar);
|
||||
$('#content').append(infoBar);
|
||||
|
||||
// Create provision form
|
||||
provForm = $('<div class="provision"></div>');
|
||||
@ -54,7 +54,7 @@ function loadProvisionPage() {
|
||||
var tab = new Tab();
|
||||
setProvisionTab(tab);
|
||||
tab.init();
|
||||
$('#provision_page').append(tab.object());
|
||||
$('#content').append(tab.object());
|
||||
|
||||
// Create drop-down menu
|
||||
// Hardware available to provision - ipmi, blade, hmc, ivm, fsp, and zvm
|
||||
|
@ -29,7 +29,7 @@ Tab.prototype.init = function() {
|
||||
this.tab.append(tabList);
|
||||
|
||||
// Create a template
|
||||
var $tabs = this.tab
|
||||
var tabs = this.tab
|
||||
.tabs( {
|
||||
tabTemplate : "<li><a href=\"#{href}\">#{label}</a><span class=\"tab-close ui-icon ui-icon-close\"></span></li>"
|
||||
});
|
||||
@ -42,11 +42,11 @@ Tab.prototype.init = function() {
|
||||
|
||||
// Append close button to tabs
|
||||
$("#" + this.tabId + " span.tab-close").live("click", function() {
|
||||
var index = $('li', $tabs).index($(this).parent());
|
||||
var index = $('li', tabs).index($(this).parent());
|
||||
|
||||
// Do not remove first tab
|
||||
if (index != 0) {
|
||||
$tabs.tabs('remove', index);
|
||||
tabs.tabs('remove', index);
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -386,6 +386,23 @@ function createMenu(items) {
|
||||
* @return Nothing
|
||||
*/
|
||||
function initPage() {
|
||||
// Load javascripts
|
||||
includeJs("js/jquery/jquery.dataTables.min.js");
|
||||
includeJs("js/jquery/jquery.form.js");
|
||||
includeJs("js/jquery/jquery.jeditable.js");
|
||||
includeJs("js/jquery/jquery.autocomplete.js");
|
||||
includeJs("js/jquery/jquery.contextmenu.js");
|
||||
includeJs("js/jquery/jquery.cookie.js");
|
||||
includeJs("js/jquery/jquery-impromptu.3.0.min.js");
|
||||
includeJs("js/jquery/superfish.js");
|
||||
includeJs("js/jquery/hoverIntent.js");
|
||||
includeJs("js/jquery/jquery.tree.js");
|
||||
includeJs("js/configure/configure.js");
|
||||
includeJs("js/monitor/monitor.js");
|
||||
includeJs("js/nodes/nodes.js");
|
||||
includeJs("js/provision/provision.js");
|
||||
includeJs("js/custom/zUtils.js");
|
||||
|
||||
// Get the page being loaded
|
||||
var url = window.location.pathname;
|
||||
var page = url.replace('/xcat/', '');
|
||||
@ -393,25 +410,20 @@ function initPage() {
|
||||
var headers = $('#header ul li a');
|
||||
|
||||
// Show the page
|
||||
$('div.content').hide();
|
||||
$("#content").children().remove();
|
||||
if (page == 'index.php') {
|
||||
$("#nodes_page").show();
|
||||
headers.eq(0).css('background-color', '#A9D0F5');
|
||||
loadNodesPage();
|
||||
} else if (page == 'configure.php') {
|
||||
$('#configure_page').show();
|
||||
headers.eq(1).css('background-color', '#A9D0F5');
|
||||
loadConfigPage();
|
||||
} else if (page == 'provision.php') {
|
||||
$('#provision_page').show();
|
||||
headers.eq(2).css('background-color', '#A9D0F5');
|
||||
loadProvisionPage();
|
||||
} else if (page == 'monitor.php') {
|
||||
$('#monitor_page').show();
|
||||
headers.eq(3).css('background-color', '#A9D0F5');
|
||||
loadMonitorPage();
|
||||
} else {
|
||||
$("#nodes_page").show();
|
||||
headers.eq(0).css('background-color', '#A9D0F5');
|
||||
loadNodesPage();
|
||||
}
|
||||
@ -424,8 +436,7 @@ function initPage() {
|
||||
|
||||
if (title == 'Nodes') {
|
||||
link.bind('click', function(event) {
|
||||
$('div.content').hide();
|
||||
$('#nodes_page').show();
|
||||
$("#content").children().remove();
|
||||
headers.css('background-color', '');
|
||||
$(this).css('background-color', '#A9D0F5');
|
||||
|
||||
@ -433,8 +444,7 @@ function initPage() {
|
||||
});
|
||||
} else if (title == 'Configure') {
|
||||
link.bind('click', function(event) {
|
||||
$('div.content').hide();
|
||||
$('#configure_page').show();
|
||||
$("#content").children().remove();
|
||||
headers.css('background-color', '');
|
||||
$(this).css('background-color', '#A9D0F5');
|
||||
|
||||
@ -442,8 +452,7 @@ function initPage() {
|
||||
});
|
||||
} else if (title == 'Provision') {
|
||||
link.bind('click', function(event) {
|
||||
$('div.content').hide();
|
||||
$('#provision_page').show();
|
||||
$("#content").children().remove();
|
||||
headers.css('background-color', '');
|
||||
$(this).css('background-color', '#A9D0F5');
|
||||
|
||||
@ -451,8 +460,7 @@ function initPage() {
|
||||
});
|
||||
} else if (title == 'Monitor') {
|
||||
link.bind('click', function(event) {
|
||||
$('div.content').hide();
|
||||
$('#monitor_page').show();
|
||||
$("#content").children().remove();
|
||||
headers.css('background-color', '');
|
||||
$(this).css('background-color', '#A9D0F5');
|
||||
|
||||
@ -460,4 +468,23 @@ function initPage() {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Include javascript file
|
||||
*
|
||||
* @param file
|
||||
* File to include
|
||||
* @return Nothing
|
||||
*/
|
||||
function includeJs(file) {
|
||||
// Create script
|
||||
var script = $('<script></script>');
|
||||
script.attr({
|
||||
type : 'text/javascript',
|
||||
src : file
|
||||
})
|
||||
|
||||
// Append to head
|
||||
$('head').append(script);
|
||||
}
|
@ -19,22 +19,7 @@ function loadPage(){
|
||||
<link href="css/style.css" rel=stylesheet type="text/css">
|
||||
<script type="text/javascript" src="js/jquery/jquery-1.4.2.min.js"></script>
|
||||
<script type="text/javascript" src="js/jquery/jquery-ui-1.8.custom.min.js"></script>
|
||||
<script type="text/javascript" src="js/jquery/jquery.dataTables.min.js"></script>
|
||||
<script type="text/javascript" src="js/jquery/jquery.form.js"></script>
|
||||
<script type="text/javascript" src="js/jquery/jquery.jeditable.js"></script>
|
||||
<script type="text/javascript" src="js/jquery/jquery.autocomplete.js"></script>
|
||||
<script type="text/javascript" src="js/jquery/jquery.contextmenu.js"></script>
|
||||
<script type="text/javascript" src="js/jquery/jquery.cookie.js"></script>
|
||||
<script type="text/javascript" src="js/jquery/jquery-impromptu.3.0.min.js"></script>
|
||||
<script type="text/javascript" src="js/jquery/superfish.js"></script>
|
||||
<script type="text/javascript" src="js/jquery/hoverIntent.js"></script>
|
||||
<script type="text/javascript" src="js/jquery/jquery.tree.js"></script>
|
||||
<script type="text/javascript" src="js/ui.js"></script>
|
||||
<script type="text/javascript" src="js/configure/configure.js"></script>
|
||||
<script type="text/javascript" src="js/monitor/monitor.js"></script>
|
||||
<script type="text/javascript" src="js/nodes/nodes.js"></script>
|
||||
<script type="text/javascript" src="js/provision/provision.js"></script>
|
||||
<script type="text/javascript" src="js/custom/zUtils.js"></script>
|
||||
</head>';
|
||||
|
||||
// Header menu
|
||||
@ -50,14 +35,8 @@ function loadPage(){
|
||||
</ul>
|
||||
</div>';
|
||||
|
||||
// Nodes section
|
||||
echo '<div class="content" id="nodes_page"></div>';
|
||||
// Configure section
|
||||
echo '<div class="content" id="configure_page"></div>';
|
||||
// Provision section
|
||||
echo '<div class="content" id="provision_page"></div>';
|
||||
// Monitor section
|
||||
echo '<div class="content" id="monitor_page"></div>';
|
||||
// Content
|
||||
echo '<div class="content" id="content"></div>';
|
||||
|
||||
// End of page
|
||||
echo
|
||||
|
Loading…
x
Reference in New Issue
Block a user