/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* init table sorter defaults */
if ( $.tablesorter ) {
$.tablesorter.defaults.cssAsc = 'headerSortUp ui-state-focus';
$.tablesorter.defaults.cssDesc = 'headerSortDown ui-state-focus';
$.tablesorter.defaults.header = 'header ui-widget-header';
$.tablesorter.defaults.widgets = ['zebra'];
$.tablesorter.defaults.widgetZebra = {
css : ["odd ui-state-default", "even ui-state-default"]
};
}
/* initializes static widgets */
function initStaticWidgets(elem) {
// hover states on the static widgets - form elements
var el = elem ? $(elem) : $(document);
el.find('button, input[type!=checkbox], .dynhover').hover(
function() { $(this).addClass('ui-state-hover'); },
function() { $(this).removeClass('ui-state-hover'); }
).addClass('ui-state-default ui-corner-all');
// fix attribute selector in IE
el.find('input[type=text], input[type=password], input[type=file]').addClass('inputText');
// make buttones nicer by applying equal width - not working in IE ;(
el.find('button, input[type=submit], input[type=reset], input[type=button]').not(".ui-dialog-titlebar-close").each(function(i) {
var txt = $(this).text();
var apply = txt && txt.length > 1;
if (apply) $(this).css('min-width', '8em');
});
// add default table styling - colors and fonts from the theme
el.find('table.nicetable').addClass('ui-widget');
el.find('table.nicetable th').addClass('ui-widget-header');
// add default styling for table sorter
el.find("table.tablesorter tbody").addClass("ui-widget-content");
// add theme styling to the status line
el.find('.statline').addClass('ui-state-highlight')
el.find('table.tablesorter').trigger("update").trigger("applyWidgets");
}
/* automatically executed on load */
$(document).ready(function() {
// init table-sorter tables - only once!
var tables = $('table.tablesorter:not(.noauto)');
if (tables.size() > 0) tables.tablesorter();
// init navigation
$('#technav div.ui-state-default').hover(
function() { $(this).addClass('ui-state-hover'); },
function() { $(this).removeClass('ui-state-hover'); }
);
// register global ajax error handler
$(document).ajaxError( function(xevent, req) {
var _t = '';
if (req.responseText) {
_t = req.responseText;
} else if (req.statusText) {
_t = req.statusText;
} else if (req.responseXML) {
_t = req.responseXML;
}
Xalert('The request failed:
' + _t + '', 'AJAX Error'); }); initStaticWidgets(); }); /* A helper function, used together with tablesorter, when the cells contains mixed text and links. As example: elem.tablesorter({ textExtraction: mixedLinksExtraction }); */ function mixedLinksExtraction(node) { var l = node.getElementsByTagName('a'); return l && l.length > 0 ? l[0].innerHTML : node.innerHTML; }; /* Java-like MessageFormat method. Usage: 'hello {0}'.msgFormat('world') */ String.prototype.msgFormat = function(/* variable arguments*/) { var i=0; var s=this; while(i