﻿/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* $LastChangedDate: 2007-07-22 01:45:56 +0200 (Son, 22 Jul 2007) $
* $Rev: 2447 $
*
* Version 2.1.1
*/
(function($) { $.fn.bgIframe = $.fn.bgiframe = function(s) { if ($.browser.msie && /6.0/.test(navigator.userAgent)) { s = $.extend({ top: 'auto', left: 'auto', width: 'auto', height: 'auto', opacity: true, src: 'javascript:false;' }, s || {}); var prop = function(n) { return n && n.constructor == Number ? n + 'px' : n; }, html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + s.src + '"' + 'style="display:block;position:absolute;z-index:-1;' + (s.opacity !== false ? 'filter:Alpha(Opacity=\'0\');' : '') + 'top:' + (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')' : prop(s.top)) + ';' + 'left:' + (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')' : prop(s.left)) + ';' + 'width:' + (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')' : prop(s.width)) + ';' + 'height:' + (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')' : prop(s.height)) + ';' + '"/>'; return this.each(function() { if ($('> iframe.bgiframe', this).length == 0) this.insertBefore(document.createElement(html), this.firstChild); }); } return this; }; })(jQuery);

/*
* SimpleModal 1.1.1 - jQuery Plugin
* http://www.ericmmartin.com/projects/simplemodal/
* http://plugins.jquery.com/project/SimpleModal
* http://code.google.com/p/simplemodal/
*
* Copyright (c) 2007 Eric Martin - http://ericmmartin.com
*
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* Revision: $Id: jquery.simplemodal.js 93 2008-01-15 16:14:20Z emartin24 $
*
*/
(function($) { $.modal = function(data, options) { return $.modal.impl.init(data, options) }; $.modal.close = function() { $.modal.impl.close(true) }; $.fn.modal = function(options) { return $.modal.impl.init(this, options) }; $.modal.defaults = { overlay: 50, overlayId: 'modalOverlay', overlayCss: {}, containerId: 'modalContainer', containerCss: {}, close: true, closeTitle: 'Close', closeClass: 'modalClose', persist: false, onOpen: null, onShow: null, onClose: null }; $.modal.impl = { opts: null, dialog: {}, init: function(data, options) { if (this.dialog.data) { return false } this.opts = $.extend({}, $.modal.defaults, options); if (typeof data == 'object') { data = data instanceof jQuery ? data : $(data); if (data.parent().parent().size() > 0) { this.dialog.parentNode = data.parent(); if (!this.opts.persist) { this.dialog.original = data.clone(true) } } } else if (typeof data == 'string' || typeof data == 'number') { data = $('<div>').html(data) } else { if (console) { console.log('SimpleModal Error: Unsupported data type: ' + typeof data) } return false } this.dialog.data = data.addClass('modalData'); data = null; this.create(); this.open(); if ($.isFunction(this.opts.onShow)) { this.opts.onShow.apply(this, [this.dialog]) } return this }, create: function() { this.dialog.overlay = $('<div>').attr('id', this.opts.overlayId).addClass('modalOverlay').css($.extend(this.opts.overlayCss, { opacity: this.opts.overlay / 100, height: '100%', width: '100%', position: 'fixed', left: 0, top: 0, zIndex: 3000 })).hide().appendTo('body'); this.dialog.container = $('<div>').attr('id', this.opts.containerId).addClass('modalContainer').css($.extend(this.opts.containerCss, { position: 'fixed', zIndex: 3100 })).append(this.opts.close ? '<a class="modalCloseImg ' + this.opts.closeClass + '" title="' + this.opts.closeTitle + '"></a>' : '').hide().appendTo('body'); if ($.browser.msie && ($.browser.version < 7)) { this.fixIE() } this.dialog.container.append(this.dialog.data.hide()) }, bindEvents: function() { var modal = this; $('.' + this.opts.closeClass).click(function(e) { e.preventDefault(); modal.close() }) }, unbindEvents: function() { $('.' + this.opts.closeClass).unbind('click') }, fixIE: function() { var wHeight = $(document.body).height() + 'px'; var wWidth = $(document.body).width() + 'px'; this.dialog.overlay.css({ position: 'absolute', height: wHeight, width: wWidth }); this.dialog.container.css({ position: 'absolute' }); this.dialog.iframe = $('<iframe src="javascript:false;">').css($.extend(this.opts.iframeCss, { opacity: 0, position: 'absolute', height: wHeight, width: wWidth, zIndex: 1000, width: '100%', top: 0, left: 0 })).hide().appendTo('body') }, open: function() { if (this.dialog.iframe) { this.dialog.iframe.show() } if ($.isFunction(this.opts.onOpen)) { this.opts.onOpen.apply(this, [this.dialog]) } else { this.dialog.overlay.show(); this.dialog.container.show(); this.dialog.data.show() } this.bindEvents() }, close: function(external) { if (!this.dialog.data) { return false } if ($.isFunction(this.opts.onClose) && !external) { this.opts.onClose.apply(this, [this.dialog]) } else { if (this.dialog.parentNode) { if (this.opts.persist) { this.dialog.data.hide().appendTo(this.dialog.parentNode) } else { this.dialog.data.remove(); this.dialog.original.appendTo(this.dialog.parentNode) } } else { this.dialog.data.remove() } this.dialog.container.remove(); this.dialog.overlay.remove(); if (this.dialog.iframe) { this.dialog.iframe.remove() } this.dialog = {} } this.unbindEvents() } } })(jQuery);

/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($) { $.fn.hoverIntent = function(f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function(ev) { cX = ev.pageX; cY = ev.pageY; }; var compare = function(ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]); } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function() { compare(ev, ob); }, cfg.interval); } }; var delay = function(ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]); }; var handleHover = function(e) { var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode; } catch (e) { p = this; } } if (p == this) { return false; } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } if (e.type == "mouseover") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function() { compare(ev, ob); }, cfg.interval); } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function() { delay(ev, ob); }, cfg.timeout); } } }; return this.mouseover(handleHover).mouseout(handleHover); }; })(jQuery);

/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
jQuery.cookie = function(name, value, options) { if (typeof value != 'undefined') { options = options || {}; if (value === null) { value = ''; options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); } var path = options.path ? '; path=' + (options.path) : ''; var domain = options.domain ? '; domain=' + (options.domain) : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } };

/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* $LastChangedDate: 2007-12-20 08:43:48 -0600 (Thu, 20 Dec 2007) $
* $Rev: 4257 $
*
* Version: 1.2
*
* Requires: jQuery 1.2+
*/
(function($) { $.dimensions = { version: '1.2' }; $.each(['Height', 'Width'], function(i, name) { $.fn['inner' + name] = function() { if (!this[0]) return; var torl = name == 'Height' ? 'Top' : 'Left', borr = name == 'Height' ? 'Bottom' : 'Right'; return this.is(':visible') ? this[0]['client' + name] : num(this, name.toLowerCase()) + num(this, 'padding' + torl) + num(this, 'padding' + borr); }; $.fn['outer' + name] = function(options) { if (!this[0]) return; var torl = name == 'Height' ? 'Top' : 'Left', borr = name == 'Height' ? 'Bottom' : 'Right'; options = $.extend({ margin: false }, options || {}); var val = this.is(':visible') ? this[0]['offset' + name] : num(this, name.toLowerCase()) + num(this, 'border' + torl + 'Width') + num(this, 'border' + borr + 'Width') + num(this, 'padding' + torl) + num(this, 'padding' + borr); return val + (options.margin ? (num(this, 'margin' + torl) + num(this, 'margin' + borr)) : 0); }; }); $.each(['Left', 'Top'], function(i, name) { $.fn['scroll' + name] = function(val) { if (!this[0]) return; return val != undefined ? this.each(function() { this == window || this == document ? window.scrollTo(name == 'Left' ? val : $(window)['scrollLeft'](), name == 'Top' ? val : $(window)['scrollTop']()) : this['scroll' + name] = val; }) : this[0] == window || this[0] == document ? self[(name == 'Left' ? 'pageXOffset' : 'pageYOffset')] || $.boxModel && document.documentElement['scroll' + name] || document.body['scroll' + name] : this[0]['scroll' + name]; }; }); $.fn.extend({ position: function() { var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results; if (elem) { offsetParent = this.offsetParent(); offset = this.offset(); parentOffset = offsetParent.offset(); offset.top -= num(elem, 'marginTop'); offset.left -= num(elem, 'marginLeft'); parentOffset.top += num(offsetParent, 'borderTopWidth'); parentOffset.left += num(offsetParent, 'borderLeftWidth'); results = { top: offset.top - parentOffset.top, left: offset.left - parentOffset.left }; } return results; }, offsetParent: function() { var offsetParent = this[0].offsetParent; while (offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && $.css(offsetParent, 'position') == 'static')) offsetParent = offsetParent.offsetParent; return $(offsetParent); } }); function num(el, prop) { return parseInt($.curCSS(el.jquery ? el[0] : el, prop, true)) || 0; }; })(jQuery);

/*
* jQuery Tooltip plugin 1.2
*
* http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
* http://docs.jquery.com/Plugins/Tooltip
*
* Copyright (c) 2006 - 2008 JÃ¶rn Zaefferer
*
* $Id: jquery.tooltip.js 4569 2008-01-31 19:36:35Z joern.zaefferer $
* 
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*/
; (function($) {
    var helper = {}, current, title, tID, IE = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent), track = false; $.tooltip = { blocked: false, defaults: { delay: 200, showURL: true, extraClass: "", top: 15, left: 15, id: "tooltip" }, block: function() { $.tooltip.blocked = !$.tooltip.blocked; } }; $.fn.extend({ tooltip: function(settings) { settings = $.extend({}, $.tooltip.defaults, settings); createHelper(settings); return this.each(function() { $.data(this, "tooltip-settings", settings); this.tooltipText = this.title; $(this).removeAttr("title"); this.alt = ""; }).hover(save, hide).click(hide); }, fixPNG: IE ? function() { return this.each(function() { var image = $(this).css('backgroundImage'); if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) { image = RegExp.$1; $(this).css({ 'backgroundImage': 'none', 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')" }).each(function() { var position = $(this).css('position'); if (position != 'absolute' && position != 'relative') $(this).css('position', 'relative'); }); } }); } : function() { return this; }, unfixPNG: IE ? function() { return this.each(function() { $(this).css({ 'filter': '', backgroundImage: '' }); }); } : function() { return this; }, hideWhenEmpty: function() { return this.each(function() { $(this)[$(this).html() ? "show" : "hide"](); }); }, url: function() { return this.attr('href') || this.attr('src'); } }); function createHelper(settings) { if (helper.parent) return; helper.parent = $('<div id="' + settings.id + '"><h3></h3><div class="body"></div><div class="url"></div></div>').appendTo(document.body).hide(); if ($.fn.bgiframe) helper.parent.bgiframe(); helper.title = $('h3', helper.parent); helper.body = $('div.body', helper.parent); helper.url = $('div.url', helper.parent); } function settings(element) { return $.data(element, "tooltip-settings"); } function handle(event) {
        if (settings(this).delay) tID = setTimeout(show, settings(this).delay); else
            show(); track = !!settings(this).track; $(document.body).bind('mousemove', update); update(event);
    } function save() {
        if ($.tooltip.blocked || this == current || (!this.tooltipText && !settings(this).bodyHandler)) return; current = this; title = this.tooltipText; if (settings(this).bodyHandler) { helper.title.hide(); var bodyContent = settings(this).bodyHandler.call(this); if (bodyContent.nodeType || bodyContent.jquery) { helper.body.empty().append(bodyContent) } else { helper.body.html(bodyContent); } helper.body.show(); } else if (settings(this).showBody) { var parts = title.split(settings(this).showBody); helper.title.html(parts.shift()).show(); helper.body.empty(); for (var i = 0, part; part = parts[i]; i++) { if (i > 0) helper.body.append("<br/>"); helper.body.append(part); } helper.body.hideWhenEmpty(); } else { helper.title.html(title).show(); helper.body.hide(); } if (settings(this).showURL && $(this).url()) helper.url.html($(this).url().replace('http://', '')).show(); else
            helper.url.hide(); helper.parent.addClass(settings(this).extraClass); if (settings(this).fixPNG) helper.parent.fixPNG(); handle.apply(this, arguments);
    } function show() { tID = null; helper.parent.show(); update(); } function update(event) { if ($.tooltip.blocked) return; if (!track && helper.parent.is(":visible")) { $(document.body).unbind('mousemove', update) } if (current == null) { $(document.body).unbind('mousemove', update); return; } helper.parent.removeClass("viewport-right").removeClass("viewport-bottom"); var left = helper.parent[0].offsetLeft; var top = helper.parent[0].offsetTop; if (event) { left = event.pageX + settings(current).left; top = event.pageY + settings(current).top; helper.parent.css({ left: left + 'px', top: top + 'px' }); } var v = viewport(), h = helper.parent[0]; if (v.x + v.cx < h.offsetLeft + h.offsetWidth) { left -= h.offsetWidth + 20 + settings(current).left; helper.parent.css({ left: left + 'px' }).addClass("viewport-right"); } if (v.y + v.cy < h.offsetTop + h.offsetHeight) { top -= h.offsetHeight + 20 + settings(current).top; helper.parent.css({ top: top + 'px' }).addClass("viewport-bottom"); } } function viewport() { return { x: $(window).scrollLeft(), y: $(window).scrollTop(), cx: $(window).width(), cy: $(window).height() }; } function hide(event) { if ($.tooltip.blocked) return; if (tID) clearTimeout(tID); current = null; helper.parent.hide().removeClass(settings(this).extraClass); if (settings(this).fixPNG) helper.parent.unfixPNG(); } $.fn.Tooltip = $.fn.tooltip;
})(jQuery);

/*
* jQuery Form Plugin
* version: 2.12 (06/07/2008)
* @requires jQuery v1.2.2 or later
*
* Examples and documentation at: http://malsup.com/jquery/form/
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id$
*/
(function($) { $.fn.ajaxSubmit = function(options) { if (!this.length) { log('ajaxSubmit: skipping submit process - no element selected'); return this } if (typeof options == 'function') options = { success: options }; options = $.extend({ url: this.attr('action') || window.location.toString(), type: this.attr('method') || 'GET' }, options || {}); var veto = {}; this.trigger('form-pre-serialize', [this, options, veto]); if (veto.veto) { log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); return this } var a = this.formToArray(options.semantic); if (options.data) { options.extraData = options.data; for (var n in options.data) a.push({ name: n, value: options.data[n] }) } if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { log('ajaxSubmit: submit aborted via beforeSubmit callback'); return this } this.trigger('form-submit-validate', [a, this, options, veto]); if (veto.veto) { log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); return this } var q = $.param(a); if (options.type.toUpperCase() == 'GET') { options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; options.data = null } else options.data = q; var $form = this, callbacks = []; if (options.resetForm) callbacks.push(function() { $form.resetForm() }); if (options.clearForm) callbacks.push(function() { $form.clearForm() }); if (!options.dataType && options.target) { var oldSuccess = options.success || function() { }; callbacks.push(function(data) { $(options.target).html(data).each(oldSuccess, arguments) }) } else if (options.success) callbacks.push(options.success); options.success = function(data, status) { for (var i = 0, max = callbacks.length; i < max; i++) callbacks[i](data, status, $form) }; var files = $('input:file', this).fieldValue(); var found = false; for (var j = 0; j < files.length; j++) if (files[j]) found = true; if (options.iframe || found) { if ($.browser.safari && options.closeKeepAlive) $.get(options.closeKeepAlive, fileUpload); else fileUpload() } else $.ajax(options); this.trigger('form-submit-notify', [this, options]); return this; function fileUpload() { var form = $form[0]; if ($(':input[@name=submit]', form).length) { alert('Error: Form elements must not be named "submit".'); return } var opts = $.extend({}, $.ajaxSettings, options); var id = 'jqFormIO' + (new Date().getTime()); var $io = $('<iframe id="' + id + '" name="' + id + '" />'); var io = $io[0]; if ($.browser.msie || $.browser.opera) io.src = 'javascript:false;document.write("");'; $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' }); var xhr = { responseText: null, responseXML: null, status: 0, statusText: 'n/a', getAllResponseHeaders: function() { }, getResponseHeader: function() { }, setRequestHeader: function() { } }; var g = opts.global; if (g && !$.active++) $.event.trigger("ajaxStart"); if (g) $.event.trigger("ajaxSend", [xhr, opts]); var cbInvoked = 0; var timedOut = 0; var sub = form.clk; if (sub) { var n = sub.name; if (n && !sub.disabled) { options.extraData = options.extraData || {}; options.extraData[n] = sub.value; if (sub.type == "image") { options.extraData[name + '.x'] = form.clk_x; options.extraData[name + '.y'] = form.clk_y } } } setTimeout(function() { var t = $form.attr('target'), a = $form.attr('action'); $form.attr({ target: id, encoding: 'multipart/form-data', enctype: 'multipart/form-data', method: 'POST', action: opts.url }); if (opts.timeout) setTimeout(function() { timedOut = true; cb() }, opts.timeout); var extraInputs = []; try { if (options.extraData) for (var n in options.extraData) extraInputs.push($('<input type="hidden" name="' + n + '" value="' + options.extraData[n] + '" />').appendTo(form)[0]); $io.appendTo('body'); io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false); form.submit() } finally { $form.attr('action', a); t ? $form.attr('target', t) : $form.removeAttr('target'); $(extraInputs).remove() } }, 10); function cb() { if (cbInvoked++) return; io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false); var operaHack = 0; var ok = true; try { if (timedOut) throw 'timeout'; var data, doc; doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document; if (doc.body == null && !operaHack && $.browser.opera) { operaHack = 1; cbInvoked--; setTimeout(cb, 100); return } xhr.responseText = doc.body ? doc.body.innerHTML : null; xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc; xhr.getResponseHeader = function(header) { var headers = { 'content-type': opts.dataType }; return headers[header] }; if (opts.dataType == 'json' || opts.dataType == 'script') { var ta = doc.getElementsByTagName('textarea')[0]; xhr.responseText = ta ? ta.value : xhr.responseText } else if (opts.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) { xhr.responseXML = toXml(xhr.responseText) } data = $.httpData(xhr, opts.dataType) } catch (e) { ok = false; $.handleError(opts, xhr, 'error', e) } if (ok) { opts.success(data, 'success'); if (g) $.event.trigger("ajaxSuccess", [xhr, opts]) } if (g) $.event.trigger("ajaxComplete", [xhr, opts]); if (g && ! --$.active) $.event.trigger("ajaxStop"); if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error'); setTimeout(function() { $io.remove(); xhr.responseXML = null }, 100) }; function toXml(s, doc) { if (window.ActiveXObject) { doc = new ActiveXObject('Microsoft.XMLDOM'); doc.async = 'false'; doc.loadXML(s) } else doc = (new DOMParser()).parseFromString(s, 'text/xml'); return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null } } }; $.fn.ajaxForm = function(options) { return this.ajaxFormUnbind().bind('submit.form-plugin', function() { $(this).ajaxSubmit(options); return false }).each(function() { $(":submit,input:image", this).bind('click.form-plugin', function(e) { var $form = this.form; $form.clk = this; if (this.type == 'image') { if (e.offsetX != undefined) { $form.clk_x = e.offsetX; $form.clk_y = e.offsetY } else if (typeof $.fn.offset == 'function') { var offset = $(this).offset(); $form.clk_x = e.pageX - offset.left; $form.clk_y = e.pageY - offset.top } else { $form.clk_x = e.pageX - this.offsetLeft; $form.clk_y = e.pageY - this.offsetTop } } setTimeout(function() { $form.clk = $form.clk_x = $form.clk_y = null }, 10) }) }) }; $.fn.ajaxFormUnbind = function() { this.unbind('submit.form-plugin'); return this.each(function() { $(":submit,input:image", this).unbind('click.form-plugin') }) }; $.fn.formToArray = function(semantic) { var a = []; if (this.length == 0) return a; var form = this[0]; var els = semantic ? form.getElementsByTagName('*') : form.elements; if (!els) return a; for (var i = 0, max = els.length; i < max; i++) { var el = els[i]; var n = el.name; if (!n) continue; if (semantic && form.clk && el.type == "image") { if (!el.disabled && form.clk == el) a.push({ name: n + '.x', value: form.clk_x }, { name: n + '.y', value: form.clk_y }); continue } var v = $.fieldValue(el, true); if (v && v.constructor == Array) { for (var j = 0, jmax = v.length; j < jmax; j++) a.push({ name: n, value: v[j] }) } else if (v !== null && typeof v != 'undefined') a.push({ name: n, value: v }) } if (!semantic && form.clk) { var inputs = form.getElementsByTagName("input"); for (var i = 0, max = inputs.length; i < max; i++) { var input = inputs[i]; var n = input.name; if (n && !input.disabled && input.type == "image" && form.clk == input) a.push({ name: n + '.x', value: form.clk_x }, { name: n + '.y', value: form.clk_y }) } } return a }; $.fn.formSerialize = function(semantic) { return $.param(this.formToArray(semantic)) }; $.fn.fieldSerialize = function(successful) { var a = []; this.each(function() { var n = this.name; if (!n) return; var v = $.fieldValue(this, successful); if (v && v.constructor == Array) { for (var i = 0, max = v.length; i < max; i++) a.push({ name: n, value: v[i] }) } else if (v !== null && typeof v != 'undefined') a.push({ name: this.name, value: v }) }); return $.param(a) }; $.fn.fieldValue = function(successful) { for (var val = [], i = 0, max = this.length; i < max; i++) { var el = this[i]; var v = $.fieldValue(el, successful); if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) continue; v.constructor == Array ? $.merge(val, v) : val.push(v) } return val }; $.fieldValue = function(el, successful) { var n = el.name, t = el.type, tag = el.tagName.toLowerCase(); if (typeof successful == 'undefined') successful = true; if (successful && (!n || el.disabled || t == 'reset' || t == 'button' || (t == 'checkbox' || t == 'radio') && !el.checked || (t == 'submit' || t == 'image') && el.form && el.form.clk != el || tag == 'select' && el.selectedIndex == -1)) return null; if (tag == 'select') { var index = el.selectedIndex; if (index < 0) return null; var a = [], ops = el.options; var one = (t == 'select-one'); var max = (one ? index + 1 : ops.length); for (var i = (one ? index : 0); i < max; i++) { var op = ops[i]; if (op.selected) { var v = $.browser.msie && !(op.attributes['value'].specified) ? op.text : op.value; if (one) return v; a.push(v) } } return a } return el.value }; $.fn.clearForm = function() { return this.each(function() { $('input,select,textarea', this).clearFields() }) }; $.fn.clearFields = $.fn.clearInputs = function() { return this.each(function() { var t = this.type, tag = this.tagName.toLowerCase(); if (t == 'text' || t == 'password' || tag == 'textarea') this.value = ''; else if (t == 'checkbox' || t == 'radio') this.checked = false; else if (tag == 'select') this.selectedIndex = -1 }) }; $.fn.resetForm = function() { return this.each(function() { if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) this.reset() }) }; $.fn.enable = function(b) { if (b == undefined) b = true; return this.each(function() { this.disabled = !b }) }; $.fn.select = function(select) { if (select == undefined) select = true; return this.each(function() { var t = this.type; if (t == 'checkbox' || t == 'radio') this.checked = select; else if (this.tagName.toLowerCase() == 'option') { var $sel = $(this).parent('select'); if (select && $sel[0] && $sel[0].type == 'select-one') { $sel.find('option').select(false) } this.selected = select } }) }; function log() { if ($.fn.ajaxSubmit.debug && window.console && window.console.log) window.console.log('[jquery.form] ' + Array.prototype.join.call(arguments, '')) } })(jQuery);

/* jqGrid 3.5.3 locale-en */
(function(a) { a.jgrid = { defaults: { recordtext: "View {0} - {1} of {2}", emptyrecords: "No records to view", loadtext: "Loading...", pgtext: "Page {0} of {1}" }, search: { caption: "Search...", Find: "Find", Reset: "Reset", odata: ["equal", "not equal", "less", "less or equal", "greater", "greater or equal", "begins with", "does not begin with", "is in", "is not in", "ends with", "does not end with", "contains", "does not contain"], groupOps: [{ op: "AND", text: "all" }, { op: "OR", text: "any"}], matchText: " match", rulesText: " rules" }, edit: { addCaption: "Add Record", editCaption: "Edit Record", bSubmit: "Submit", bCancel: "Cancel", bClose: "Close", saveData: "Data has been changed! Save changes?", bYes: "Yes", bNo: "No", bExit: "Cancel", msg: { required: "Field is required", number: "Please, enter valid number", minValue: "value must be greater than or equal to ", maxValue: "value must be less than or equal to", email: "is not a valid e-mail", integer: "Please, enter valid integer value", date: "Please, enter valid date value", url: "is not a valid URL. Prefix required ('http://' or 'https://')"} }, view: { caption: "View Record", bClose: "Close" }, del: { caption: "Delete", msg: "Delete selected record(s)?", bSubmit: "Delete", bCancel: "Cancel" }, nav: { edittext: "", edittitle: "Edit selected row", addtext: "", addtitle: "Add new row", deltext: "", deltitle: "Delete selected row", searchtext: "", searchtitle: "Find records", refreshtext: "", refreshtitle: "Reload Grid", alertcap: "Warning", alerttext: "Please, select row", viewtext: "", viewtitle: "View selected row" }, col: { caption: "Show/Hide Columns", bSubmit: "Submit", bCancel: "Cancel" }, errors: { errcap: "Error", nourl: "No url is set", norecords: "No records to process", model: "Length of colNames <> colModel!" }, formatter: { integer: { thousandsSeparator: " ", defaultValue: "0" }, number: { decimalSeparator: ".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: "0.00" }, currency: { decimalSeparator: ".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix: "", defaultValue: "0.00" }, date: { dayNames: ["Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], AmPm: ["am", "pm", "AM", "PM"], S: function(b) { return b < 11 || b > 13 ? ["st", "nd", "rd", "th"][Math.min((b - 1) % 10, 3)] : "th" }, srcformat: "Y-m-d", newformat: "d/m/Y", masks: { ISO8601Long: "Y-m-d H:i:s", ISO8601Short: "Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit: false }, baseLinkUrl: "", showAction: "", target: "", checkbox: { disabled: true }, idName: "id"}} })(jQuery);

/* 
* jqGrid  3.5.3 - jQuery Grid 
* Copyright (c) 2008, Tony Tomov, tony@trirand.com 
* Dual licensed under the MIT and GPL licenses 
* http://www.opensource.org/licenses/mit-license.php 
* http://www.gnu.org/licenses/gpl.html 
* Date:2009-09-06 
* Modules: grid.base.js; jquery.fmatter.js; grid.custom.js; grid.import.js; JsonXml.js; 
*/
(function($) { $.jgrid = $.jgrid || {}; $.extend($.jgrid, { htmlDecode: function(value) { if (value == "&nbsp;" || value == "&#160;" || (value.length == 1 && value.charCodeAt(0) == 160)) { return "" } return !value ? value : String(value).replace(/&amp;/g, "&").replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"') }, htmlEncode: function(value) { return !value ? value : String(value).replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/\"/g, "&quot;") }, format: function(format) { var args = $.makeArray(arguments).slice(1); return format.replace(/\{(\d+)\}/g, function(m, i) { return args[i] }) }, getAbsoluteIndex: function(t, rInd) { var cntnotv = 0, cntv = 0, cell, i; if ($.browser.version > 7) { return rInd } for (i = 0; i < t.cells.length; i++) { cell = t.cells(i); if (cell.style.display == "none") { cntnotv++ } else { cntv++ } if (cntv > rInd) { return i } } return i }, stripHtml: function(v) { var regexp = /<("[^"]*"|'[^']*'|[^'">])*>/gi; if (v) { return v.replace(regexp, "") } else { return v } }, stringToDoc: function(xmlString) { var xmlDoc; if (typeof xmlString !== "string") { return xmlString } try { var parser = new DOMParser(); xmlDoc = parser.parseFromString(xmlString, "text/xml") } catch (e) { xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; xmlDoc.loadXML(xmlString) } return (xmlDoc && xmlDoc.documentElement && xmlDoc.documentElement.tagName != "parsererror") ? xmlDoc : null }, parse: function(jsonString) { var js = jsonString; if (js.substr(0, 9) == "while(1);") { js = js.substr(9) } if (js.substr(0, 2) == "/*") { js = js.substr(2, js.length - 4) } if (!js) { js = "{}" } with (window) { return eval("(" + js + ")") } }, empty: function() { while (this.firstChild) { this.removeChild(this.firstChild) } } }); $.fn.jqGrid = function(p) { p = $.extend(true, { url: "", height: 150, page: 1, rowNum: 20, records: 0, pager: "", pgbuttons: true, pginput: true, colModel: [], rowList: [], colNames: [], sortorder: "asc", sortname: "", datatype: "xml", mtype: "GET", altRows: false, selarrrow: [], savedRow: [], shrinkToFit: true, xmlReader: {}, jsonReader: {}, subGrid: false, subGridModel: [], reccount: 0, lastpage: 0, lastsort: 0, selrow: null, beforeSelectRow: null, onSelectRow: null, onSortCol: null, ondblClickRow: null, onRightClickRow: null, onPaging: null, onSelectAll: null, loadComplete: null, gridComplete: null, loadError: null, loadBeforeSend: null, afterInsertRow: null, beforeRequest: null, onHeaderClick: null, viewrecords: false, loadonce: false, multiselect: false, multikey: false, editurl: null, search: false, caption: "", hidegrid: true, hiddengrid: false, postData: {}, userData: {}, treeGrid: false, treeGridModel: "nested", treeReader: {}, treeANode: -1, ExpandColumn: null, tree_root_level: 0, prmNames: { page: "page", rows: "rows", sort: "sidx", order: "sord", search: "_search", nd: "nd" }, forceFit: false, gridstate: "visible", cellEdit: false, cellsubmit: "remote", nv: 0, loadui: "enable", toolbar: [false, ""], scroll: false, multiboxonly: false, deselectAfterSort: true, scrollrows: false, autowidth: false, scrollOffset: 18, cellLayout: 5, subGridWidth: 20, multiselectWidth: 20, gridview: false, rownumWidth: 25, rownumbers: false, pagerpos: "center", recordpos: "right", footerrow: false, userDataOnFooter: false, hoverrows: true, altclass: "ui-priority-secondary", viewsortcols: [false, "vertical", true], resizeclass: "", autoencode: false }, $.jgrid.defaults, p || {}); var grid = { headers: [], cols: [], footers: [], dragStart: function(i, x, y) { this.resizing = { idx: i, startX: x.clientX, sOL: y[0] }; this.hDiv.style.cursor = "col-resize"; this.curGbox = $("#rs_m" + p.id, "#gbox_" + p.id); this.curGbox.css({ display: "block", left: y[0], top: y[1], height: y[2] }); document.onselectstart = new Function("return false") }, dragMove: function(x) { if (this.resizing) { var diff = x.clientX - this.resizing.startX, h = this.headers[this.resizing.idx], newWidth = h.width + diff, hn, nWn; if (newWidth > 33) { this.curGbox.css({ left: this.resizing.sOL + diff }); if (p.forceFit === true) { hn = this.headers[this.resizing.idx + p.nv]; nWn = hn.width - diff; if (nWn > 33) { h.newWidth = newWidth; hn.newWidth = nWn; this.newWidth = p.tblwidth } } else { this.newWidth = p.tblwidth + diff; h.newWidth = newWidth } } } }, dragEnd: function() { this.hDiv.style.cursor = "default"; if (this.resizing) { var idx = this.resizing.idx, nw = this.headers[idx].newWidth || this.headers[idx].width; this.resizing = false; $("#rs_m" + p.id).css("display", "none"); p.colModel[idx].width = nw; this.headers[idx].width = nw; this.headers[idx].el.style.width = nw + "px"; if (this.cols.length > 0) { this.cols[idx].style.width = nw + "px" } if (this.footers.length > 0) { this.footers[idx].style.width = nw + "px" } if (p.forceFit === true) { nw = this.headers[idx + p.nv].newWidth || this.headers[idx + p.nv].width; this.headers[idx + p.nv].width = nw; this.headers[idx + p.nv].el.style.width = nw + "px"; if (this.cols.length > 0) { this.cols[idx + p.nv].style.width = nw + "px" } if (this.footers.length > 0) { this.footers[idx + p.nv].style.width = nw + "px" } p.colModel[idx + p.nv].width = nw } else { p.tblwidth = this.newWidth; $("table:first", this.bDiv).css("width", p.tblwidth + "px"); $("table:first", this.hDiv).css("width", p.tblwidth + "px"); this.hDiv.scrollLeft = this.bDiv.scrollLeft; if (p.footerrow) { $("table:first", this.sDiv).css("width", p.tblwidth + "px"); this.sDiv.scrollLeft = this.bDiv.scrollLeft } } } this.curGbox = null; document.onselectstart = new Function("return true") }, scrollGrid: function() { if (p.scroll === true) { var scrollTop = this.bDiv.scrollTop; if (scrollTop != this.scrollTop) { this.scrollTop = scrollTop; if ((this.bDiv.scrollHeight - scrollTop - $(this.bDiv).height()) <= 0) { if (parseInt(p.page, 10) + 1 <= parseInt(p.lastpage, 10)) { p.page = parseInt(p.page, 10) + 1; this.populate() } } } } this.hDiv.scrollLeft = this.bDiv.scrollLeft; if (p.footerrow) { this.sDiv.scrollLeft = this.bDiv.scrollLeft } } }; return this.each(function() { if (this.grid) { return } this.p = p; var i; if (this.p.colNames.length === 0) { for (i = 0; i < this.p.colModel.length; i++) { this.p.colNames[i] = this.p.colModel[i].label || this.p.colModel[i].name } } if (this.p.colNames.length !== this.p.colModel.length) { alert($.jgrid.errors.model); return } var gv = $("<div class='ui-jqgrid-view'></div>"), ii, isMSIE = $.browser.msie ? true : false, isSafari = $.browser.safari ? true : false; $(gv).insertBefore(this); $(this).appendTo(gv).removeClass("scroll"); var eg = $("<div class='ui-jqgrid ui-widget ui-widget-content ui-corner-all'></div>"); $(eg).insertBefore(gv).attr("id", "gbox_" + this.id); $(gv).appendTo(eg).attr("id", "gview_" + this.id); if (isMSIE && $.browser.version <= 6) { ii = '<iframe style="display:block;position:absolute;z-index:-1;filter:Alpha(Opacity=\'0\');" src="javascript:false;"></iframe>' } else { ii = "" } $("<div class='ui-widget-overlay jqgrid-overlay' id='lui_" + this.id + "'></div>").append(ii).insertBefore(gv); $("<div class='loading ui-state-default ui-state-active' id='load_" + this.id + "'>" + this.p.loadtext + "</div>").insertBefore(gv); $(this).attr({ cellSpacing: "0", cellPadding: "0", border: "0", role: "grid", "aria-multiselectable": this.p.multiselect, "aria-labelledby": "gbox_" + this.id }); var ts = this, bSR = $.isFunction(this.p.beforeSelectRow) ? this.p.beforeSelectRow : false, ondblClickRow = $.isFunction(this.p.ondblClickRow) ? this.p.ondblClickRow : false, onSortCol = $.isFunction(this.p.onSortCol) ? this.p.onSortCol : false, loadComplete = $.isFunction(this.p.loadComplete) ? this.p.loadComplete : false, loadError = $.isFunction(this.p.loadError) ? this.p.loadError : false, loadBeforeSend = $.isFunction(this.p.loadBeforeSend) ? this.p.loadBeforeSend : false, onRightClickRow = $.isFunction(this.p.onRightClickRow) ? this.p.onRightClickRow : false, afterInsRow = $.isFunction(this.p.afterInsertRow) ? this.p.afterInsertRow : false, onHdCl = $.isFunction(this.p.onHeaderClick) ? this.p.onHeaderClick : false, beReq = $.isFunction(this.p.beforeRequest) ? this.p.beforeRequest : false, onSC = $.isFunction(this.p.onCellSelect) ? this.p.onCellSelect : false, sortkeys = ["shiftKey", "altKey", "ctrlKey"], IntNum = function(val, defval) { val = parseInt(val, 10); if (isNaN(val)) { return defval ? defval : 0 } else { return val } }, formatCol = function(pos, rowInd) { var ral = ts.p.colModel[pos].align, result = 'style="'; if (ral) { result += "text-align:" + ral + ";" } if (ts.p.colModel[pos].hidden === true) { result += "display:none;" } if (rowInd === 0) { result += "width: " + grid.headers[pos].width + "px;" } return result + '"' }, addCell = function(rowId, cell, pos, irow, srvr) { var v, prp; v = formatter(rowId, cell, pos, srvr, "add"); prp = formatCol(pos, irow); return '<td role="gridcell" ' + prp + ' title="' + $.jgrid.stripHtml(v) + '">' + v + "</td>" }, formatter = function(rowId, cellval, colpos, rwdat, _act) { var cm = ts.p.colModel[colpos], v; if (typeof cm.formatter !== "undefined") { var opts = { rowId: rowId, colModel: cm }; if ($.isFunction(cm.formatter)) { v = cm.formatter(cellval, opts, rwdat, _act) } else { if ($.fmatter) { v = $.fn.fmatter(cm.formatter, cellval, opts, rwdat, _act) } else { v = cellVal(cellval) } } } else { v = cellVal(cellval) } return v }, cellVal = function(val) { return val === undefined || val === null || val === "" ? "&#160;" : ts.p.autoencode ? $.jgrid.htmlEncode(val + "") : val + "" }, addMulti = function(rowid, pos, irow) { var v = '<input type="checkbox" id="jqg_' + rowid + '" class="cbox" name="jqg_' + rowid + '"/>', prp = formatCol(pos, irow); return "<td role='gridcell' " + prp + ">" + v + "</td>" }, addRowNum = function(pos, irow, pG, rN) { var v = (parseInt(pG) - 1) * parseInt(rN) + 1 + irow, prp = formatCol(pos, irow); return '<td role="gridcell" class="ui-state-default jqgrid-rownum" ' + prp + ">" + v + "</td>" }, reader = function(datatype) { var field, f = [], j = 0, i; for (i = 0; i < ts.p.colModel.length; i++) { field = ts.p.colModel[i]; if (field.name !== "cb" && field.name !== "subgrid" && field.name !== "rn") { f[j] = (datatype == "xml") ? field.xmlmap || field.name : field.jsonmap || field.name; j++ } } return f }, addXmlData = function(xml, t, rcnt) { var startReq = new Date(); ts.p.reccount = 0; if ($.isXMLDoc(xml)) { if (ts.p.treeANode === -1 && ts.p.scroll === false) { var tBody = $("tbody:first", t); if (!ts.p.gridview) { $("*", tBody).children().unbind() } if (isMSIE) { $.jgrid.empty.apply(tBody[0]) } else { tBody[0].innerHTML = "" } tBody = null; rcnt = 0 } else { rcnt = rcnt > 0 ? rcnt : 0 } } else { return } var i, fpos, ir = 0, v, row, gi = 0, si = 0, ni = 0, idn, getId, f = [], rd = {}, rl = ts.rows.length, xmlr, rid, rowData = [], ari = 0, cn = (ts.p.altRows === true) ? ts.p.altclass : "", cn1; if (!ts.p.xmlReader.repeatitems) { f = reader("xml") } if (ts.p.keyIndex === false) { idn = ts.p.xmlReader.id; if (idn.indexOf("[") === -1) { getId = function(trow, k) { return $(idn, trow).text() || k } } else { getId = function(trow, k) { return trow.getAttribute(idn.replace(/[\[\]]/g, "")) || k } } } else { getId = function(trow) { return (f.length - 1 >= ts.p.keyIndex) ? $(f[ts.p.keyIndex], trow).text() : $(ts.p.xmlReader.cell + ":eq(" + ts.p.keyIndex + ")", trow).text() } } $(ts.p.xmlReader.page, xml).each(function() { ts.p.page = this.textContent || this.text || 1 }); $(ts.p.xmlReader.total, xml).each(function() { ts.p.lastpage = this.textContent || this.text || 1 }); $(ts.p.xmlReader.records, xml).each(function() { ts.p.records = this.textContent || this.text || 0 }); $(ts.p.xmlReader.userdata, xml).each(function() { ts.p.userData[this.getAttribute("name")] = this.textContent || this.text }); var gxml = $(ts.p.xmlReader.root + " " + ts.p.xmlReader.row, xml), gl = gxml.length, j = 0; if (gxml && gl) { var rn = ts.p.rowNum; while (j < gl) { xmlr = gxml[j]; rid = getId(xmlr, j + 1); cn1 = j % 2 == 1 ? cn : ""; rowData[ari++] = '<tr id="' + rid + '" role="row" class ="ui-widget-content jqgrow ' + cn1 + '">'; if (ts.p.rownumbers === true) { rowData[ari++] = addRowNum(0, j, ts.p.page, ts.p.rowNum); ni = 1 } if (ts.p.multiselect === true) { rowData[ari++] = addMulti(rid, ni, j); gi = 1 } if (ts.p.subGrid === true) { rowData[ari++] = $(ts).addSubGridCell(gi + ni, j + rcnt); si = 1 } if (ts.p.xmlReader.repeatitems === true) { $(ts.p.xmlReader.cell, xmlr).each(function(k) { v = this.textContent || this.text; rd[ts.p.colModel[k + gi + si + ni].name] = v; rowData[ari++] = addCell(rid, v, k + gi + si + ni, j + rcnt, xmlr) }) } else { for (i = 0; i < f.length; i++) { v = $(f[i], xmlr).text(); rd[ts.p.colModel[i + gi + si + ni].name] = v; rowData[ari++] = addCell(rid, v, i + gi + si + ni, j + rcnt, xmlr) } } rowData[ari++] = "</tr>"; if (ts.p.gridview === false) { if (ts.p.treeGrid === true) { fpos = ts.p.treeANode >= -1 ? ts.p.treeANode : 0; row = $(rowData.join(""))[0]; try { $(ts).setTreeNode(rd, row) } catch (e) { } rl === 0 ? $("tbody:first", t).append(row) : $(ts.rows[j + fpos + rcnt]).after(row) } else { $("tbody:first", t).append(rowData.join("")) } if (ts.p.subGrid === true) { try { $(ts).addSubGrid(ts.rows[ts.rows.length - 1], gi + ni) } catch (e) { } } if (afterInsRow) { ts.p.afterInsertRow(rid, rd, xmlr) } rowData = []; ari = 0 } rd = {}; ir++; j++; if (rn != -1 && ir > rn) { break } } } if (ts.p.gridview === true) { $("table:first", t).append(rowData.join("")) } ts.p.totaltime = new Date() - startReq; if (ir > 0) { ts.grid.cols = ts.rows[0].cells; if (ts.p.records === 0) { ts.p.records = gl } } rowData = null; if (!ts.p.treeGrid && !ts.p.scroll) { ts.grid.bDiv.scrollTop = 0; ts.p.reccount = ir } ts.p.treeANode = -1; if (ts.p.userDataOnFooter) { $(ts).footerData("set", ts.p.userData, true) } updatepager(false) }, addJSONData = function(data, t, rcnt) { var startReq = new Date(); ts.p.reccount = 0; if (data) { if (ts.p.treeANode === -1 && ts.p.scroll === false) { var tBody = $("tbody:first", t); if (!ts.p.gridview) { $("*", tBody).children().unbind() } if (isMSIE) { $.jgrid.empty.apply(tBody[0]) } else { tBody[0].innerHTML = "" } tBody = null; rcnt = 0 } else { rcnt = rcnt > 0 ? rcnt : 0 } } else { return } var ir = 0, v, i, j, row, f = [], cur, gi = 0, si = 0, ni = 0, len, drows, idn, rd = {}, fpos, rl = ts.rows.length, idr, rowData = [], ari = 0, cn = (ts.p.altRows === true) ? ts.p.altclass : "", cn1; ts.p.page = data[ts.p.jsonReader.page] || 1; ts.p.lastpage = data[ts.p.jsonReader.total] || 1; ts.p.records = data[ts.p.jsonReader.records] || 0; ts.p.userData = data[ts.p.jsonReader.userdata] || {}; if (!ts.p.jsonReader.repeatitems) { f = reader("json") } if (ts.p.keyIndex === false) { idn = ts.p.jsonReader.id; if (f.length > 0 && !isNaN(idn)) { idn = f[idn] } } else { idn = f.length > 0 ? f[ts.p.keyIndex] : ts.p.keyIndex } drows = data[ts.p.jsonReader.root]; if (drows) { len = drows.length, i = 0; var rn = ts.p.rowNum; while (i < len) { cur = drows[i]; idr = cur[idn]; if (idr === undefined) { if (f.length === 0) { if (ts.p.jsonReader.cell) { var ccur = cur[ts.p.jsonReader.cell]; idr = ccur[idn] || i + 1; ccur = null } else { idr = i + 1 } } else { idr = i + 1 } } cn1 = i % 2 == 1 ? cn : ""; rowData[ari++] = '<tr id="' + idr + '" role="row" class= "ui-widget-content jqgrow ' + cn1 + '">'; if (ts.p.rownumbers === true) { rowData[ari++] = addRowNum(0, i, ts.p.page, ts.p.rowNum); ni = 1 } if (ts.p.multiselect) { rowData[ari++] = addMulti(idr, ni, i); gi = 1 } if (ts.p.subGrid) { rowData[ari++] = $(ts).addSubGridCell(gi + ni, i + rcnt); si = 1 } if (ts.p.jsonReader.repeatitems === true) { if (ts.p.jsonReader.cell) { cur = cur[ts.p.jsonReader.cell] } for (j = 0; j < cur.length; j++) { rowData[ari++] = addCell(idr, cur[j], j + gi + si + ni, i + rcnt, cur); rd[ts.p.colModel[j + gi + si + ni].name] = cur[j] } } else { for (j = 0; j < f.length; j++) { v = cur[f[j]]; if (v === undefined) { try { v = eval("cur." + f[j]) } catch (e) { } } rowData[ari++] = addCell(idr, v, j + gi + si + ni, i + rcnt, cur); rd[ts.p.colModel[j + gi + si + ni].name] = cur[f[j]] } } rowData[ari++] = "</tr>"; if (ts.p.gridview === false) { if (ts.p.treeGrid === true) { fpos = ts.p.treeANode >= -1 ? ts.p.treeANode : 0; row = $(rowData.join(""))[0]; try { $(ts).setTreeNode(rd, row) } catch (e) { } rl === 0 ? $("tbody:first", t).append(row) : $(ts.rows[i + fpos + rcnt]).after(row) } else { $("tbody:first", t).append(rowData.join("")) } if (ts.p.subGrid === true) { try { $(ts).addSubGrid(ts.rows[ts.rows.length - 1], gi + ni) } catch (e) { } } if (afterInsRow) { ts.p.afterInsertRow(idr, rd, cur) } rowData = []; ari = 0 } rd = {}; ir++; i++; if (rn != -1 && ir > rn) { break } } if (ts.p.gridview === true) { $("table:first", t).append(rowData.join("")) } ts.p.totaltime = new Date() - startReq; if (ir > 0) { ts.grid.cols = ts.rows[0].cells; if (ts.p.records === 0) { ts.p.records = len } } } if (!ts.p.treeGrid && !ts.p.scroll) { ts.grid.bDiv.scrollTop = 0; ts.p.reccount = ir } ts.p.treeANode = -1; if (ts.p.userDataOnFooter) { $(ts).footerData("set", ts.p.userData, true) } updatepager(false) }, updatepager = function(rn) { var cp, last, base, bs, from, to, tot, fmt; base = (parseInt(ts.p.page) - 1) * parseInt(ts.p.rowNum); if (ts.p.pager) { if (ts.p.loadonce) { cp = last = 1; ts.p.lastpage = ts.page = 1; $(".selbox", ts.p.pager).attr("disabled", true) } else { cp = IntNum(ts.p.page); last = IntNum(ts.p.lastpage); $(".selbox", ts.p.pager).attr("disabled", false) } if (ts.p.pginput === true) { $(".ui-pg-input", ts.p.pager).val(ts.p.page); $("#sp_1", ts.p.pager).html(ts.p.lastpage) } if (ts.p.viewrecords) { bs = ts.p.scroll === true ? 0 : base; if (ts.p.reccount === 0) { $(".ui-paging-info", ts.p.pager).html(ts.p.emptyrecords) } else { from = bs + 1; to = base + ts.p.reccount; tot = ts.p.records; if ($.fmatter) { fmt = $.jgrid.formatter.integer || {}; from = $.fmatter.util.NumberFormat(from, fmt); to = $.fmatter.util.NumberFormat(to, fmt); tot = $.fmatter.util.NumberFormat(tot, fmt) } $(".ui-paging-info", ts.p.pager).html($.jgrid.format(ts.p.recordtext, from, to, tot)) } } if (ts.p.pgbuttons === true) { if (cp <= 0) { cp = last = 1 } if (cp == 1) { $("#first, #prev", ts.p.pager).addClass("ui-state-disabled").removeClass("ui-state-hover") } else { $("#first, #prev", ts.p.pager).removeClass("ui-state-disabled") } if (cp == last) { $("#next, #last", ts.p.pager).addClass("ui-state-disabled").removeClass("ui-state-hover") } else { $("#next, #last", ts.p.pager).removeClass("ui-state-disabled") } } } if (rn === true && ts.p.rownumbers === true) { $("td.jqgrid-rownum", ts.rows).each(function(i) { $(this).html(base + 1 + i) }) } if ($.isFunction(ts.p.gridComplete)) { ts.p.gridComplete() } }, populate = function() { if (!ts.grid.hDiv.loading) { var prm = {}, dt, dstr, pN = ts.p.prmNames; if (pN.search !== null) { prm[pN.search] = ts.p.search } if (pN.nd != null) { prm[pN.nd] = new Date().getTime() } if (pN.rows !== null) { prm[pN.rows] = ts.p.rowNum } if (pN.page !== null) { prm[pN.page] = ts.p.page } if (pN.sort !== null) { prm[pN.sort] = ts.p.sortname } if (pN.order !== null) { prm[pN.order] = ts.p.sortorder } $.extend(ts.p.postData, prm); var rcnt = ts.p.scroll === false ? 0 : ts.rows.length - 1; if ($.isFunction(ts.p.datatype)) { ts.p.datatype(ts.p.postData, "load_" + ts.p.id); return } else { if (beReq) { ts.p.beforeRequest() } } dt = ts.p.datatype.toLowerCase(); switch (dt) { case "json": case "jsonp": case "xml": case "script": $.ajax({ url: ts.p.url, type: ts.p.mtype, dataType: dt, data: ts.p.postData, complete: function(req, st) { if (st == "success" || (req.statusText == "OK" && req.status == "200")) { if (dt === "xml") { addXmlData(req.responseXML, ts.grid.bDiv, rcnt) } else { addJSONData($.jgrid.parse(req.responseText), ts.grid.bDiv, rcnt) } if (loadComplete) { loadComplete(req) } } req = null; endReq() }, error: function(xhr, st, err) { if (loadError) { loadError(xhr, st, err) } endReq(); xhr = null }, beforeSend: function(xhr) { beginReq(); if (loadBeforeSend) { loadBeforeSend(xhr) } } }); if (ts.p.loadonce || ts.p.treeGrid) { ts.p.datatype = "local" } break; case "xmlstring": beginReq(); addXmlData(dstr = $.jgrid.stringToDoc(ts.p.datastr), ts.grid.bDiv); ts.p.datatype = "local"; if (loadComplete) { loadComplete(dstr) } ts.p.datastr = null; endReq(); break; case "jsonstring": beginReq(); if (typeof ts.p.datastr == "string") { dstr = $.jgrid.parse(ts.p.datastr) } else { dstr = ts.p.datastr } addJSONData(dstr, ts.grid.bDiv); ts.p.datatype = "local"; if (loadComplete) { loadComplete(dstr) } ts.p.datastr = null; endReq(); break; case "local": case "clientside": beginReq(); ts.p.datatype = "local"; sortArrayData(); endReq(); break } } }, beginReq = function() { ts.grid.hDiv.loading = true; if (ts.p.hiddengrid) { return } switch (ts.p.loadui) { case "disable": break; case "enable": $("#load_" + ts.p.id).show(); break; case "block": $("#lui_" + ts.p.id).show(); $("#load_" + ts.p.id).show(); break } }, endReq = function() { ts.grid.hDiv.loading = false; switch (ts.p.loadui) { case "disable": break; case "enable": $("#load_" + ts.p.id).hide(); break; case "block": $("#lui_" + ts.p.id).hide(); $("#load_" + ts.p.id).hide(); break } }, sortArrayData = function() { var stripNum = /[\$,%]/g; var rows = [], col = 0, st, sv, findSortKey, newDir = (ts.p.sortorder == "asc") ? 1 : -1; $.each(ts.p.colModel, function(i, v) { if (this.index == ts.p.sortname || this.name == ts.p.sortname) { col = ts.p.lastsort = i; st = this.sorttype; return false } }); if (st == "float" || st == "number" || st == "currency") { findSortKey = function($cell) { var key = parseFloat($cell.replace(stripNum, "")); return isNaN(key) ? 0 : key } } else { if (st == "int" || st == "integer") { findSortKey = function($cell) { return IntNum($cell.replace(stripNum, "")) } } else { if (st == "date") { findSortKey = function($cell) { var fd = ts.p.colModel[col].datefmt || "Y-m-d"; return parseDate(fd, $cell).getTime() } } else { findSortKey = function($cell) { return $.trim($cell.toUpperCase()) } } } } $.each(ts.rows, function(index, row) { try { sv = $.unformat($(row).children("td").eq(col), { colModel: ts.p.colModel[col] }, col, true) } catch (_) { sv = $(row).children("td").eq(col).text() } row.sortKey = findSortKey(sv); rows[index] = this }); if (ts.p.treeGrid) { $(ts).SortTree(newDir) } else { rows.sort(function(a, b) { if (a.sortKey < b.sortKey) { return -newDir } if (a.sortKey > b.sortKey) { return newDir } return 0 }); if (rows[0]) { $("td", rows[0]).each(function(k) { $(this).css("width", grid.headers[k].width + "px") }); grid.cols = rows[0].cells } $.each(rows, function(index, row) { $("tbody", ts.grid.bDiv).append(row); row.sortKey = null }) } if (ts.p.multiselect) { $("tbody tr", ts.grid.bDiv).removeClass("ui-state-highlight"); $("[id^=jqg_]", ts.rows).attr("checked", false); $("#cb_jqg", ts.grid.hDiv).attr("checked", false); ts.p.selarrrow = [] } ts.grid.bDiv.scrollTop = 0 }, parseDate = function(format, date) { var tsp = { m: 1, d: 1, y: 1970, h: 0, i: 0, s: 0 }, k, hl, dM; date = date.split(/[\\\/:_;.\t\T\s-]/); format = format.split(/[\\\/:_;.\t\T\s-]/); var dfmt = $.jgrid.formatter.date.monthNames; for (k = 0, hl = format.length; k < hl; k++) { if (format[k] == "M") { dM = $.inArray(date[k], dfmt); if (dM !== -1 && dM < 12) { date[k] = dM + 1 } } if (format[k] == "F") { dM = $.inArray(date[k], dfmt); if (dM !== -1 && dM > 11) { date[k] = dM + 1 - 12 } } tsp[format[k].toLowerCase()] = parseInt(date[k], 10) } tsp.m = parseInt(tsp.m, 10) - 1; var ty = tsp.y; if (ty >= 70 && ty <= 99) { tsp.y = 1900 + tsp.y } else { if (ty >= 0 && ty <= 69) { tsp.y = 2000 + tsp.y } } return new Date(tsp.y, tsp.m, tsp.d, tsp.h, tsp.i, tsp.s, 0) }, setPager = function() { var sep = "<td class='ui-pg-button ui-state-disabled' style='width:4px;'><span class='ui-separator'></span></td>", pgid = $(ts.p.pager).attr("id") || "pager", pginp = (ts.p.pginput === true) ? "<td>" + $.jgrid.format(ts.p.pgtext || "", "<input class='ui-pg-input' type='text' size='2' maxlength='7' value='0' role='textbox'/>", "<span id='sp_1'></span>") + "</td>" : "", pgl = "<table cellspacing='0' cellpadding='0' border='0' style='table-layout:auto;' class='ui-pg-table'><tbody><tr>", str, pgcnt, lft, cent, rgt, twd, tdw, i, clearVals = function(onpaging) { if ($.isFunction(ts.p.onPaging)) { ts.p.onPaging(onpaging) } ts.p.selrow = null; if (ts.p.multiselect) { ts.p.selarrrow = []; $("#cb_jqg", ts.grid.hDiv).attr("checked", false) } ts.p.savedRow = [] }; pgcnt = "pg_" + pgid; lft = pgid + "_left"; cent = pgid + "_center"; rgt = pgid + "_right"; $(ts.p.pager).addClass("ui-jqgrid-pager corner-bottom").append("<div id='" + pgcnt + "' class='ui-pager-control' role='group'><table cellspacing='0' cellpadding='0' border='0' class='ui-pg-table' style='width:100%;table-layout:fixed;' role='row'><tbody><tr><td id='" + lft + "' align='left'></td><td id='" + cent + "' align='center' style='white-space:nowrap;'></td><td id='" + rgt + "' align='right'></td></tr></tbody></table></div>"); if (ts.p.pgbuttons === true) { pgl += "<td id='first' class='ui-pg-button ui-corner-all'><span class='ui-icon ui-icon-seek-first'></span></td>"; pgl += "<td id='prev' class='ui-pg-button ui-corner-all'><span class='ui-icon ui-icon-seek-prev'></span></td>"; pgl += pginp != "" ? sep + pginp + sep : ""; pgl += "<td id='next' class='ui-pg-button ui-corner-all'><span class='ui-icon ui-icon-seek-next'></span></td>"; pgl += "<td id='last' class='ui-pg-button ui-corner-all'><span class='ui-icon ui-icon-seek-end'></span></td>" } else { if (pginp != "") { pgl += pginp } } if (ts.p.rowList.length > 0) { str = "<select class='ui-pg-selbox' role='listbox'>"; for (i = 0; i < ts.p.rowList.length; i++) { str += "<option role='option' value=" + ts.p.rowList[i] + ((ts.p.rowNum == ts.p.rowList[i]) ? " selected" : "") + ">" + ts.p.rowList[i] } str += "</select>"; pgl += "<td>" + str + "</td>" } pgl += "</tr></tbody></table>"; if (ts.p.viewrecords === true) { $("td#" + pgid + "_" + ts.p.recordpos, "#" + pgcnt).append("<div style='text-align:" + ts.p.recordpos + "' class='ui-paging-info'></div>") } $("td#" + pgid + "_" + ts.p.pagerpos, "#" + pgcnt).append(pgl); tdw = $(".ui-jqgrid").css("font-size") || "11px"; $("body").append("<div id='testpg' class='ui-jqgrid ui-widget ui-widget-content' style='font-size:" + tdw + ";visibility:hidden;' ></div>"); twd = $(pgl).clone().appendTo("#testpg").width(); $("#testpg").remove(); if (twd > 0) { twd += 25; $("td#" + pgid + "_" + ts.p.pagerpos, "#" + pgcnt).width(twd) } ts.p._nvtd = []; ts.p._nvtd[0] = twd ? Math.floor((ts.p.width - twd) / 2) : Math.floor(ts.p.width / 3); ts.p._nvtd[1] = 0; pgl = null; $(".ui-pg-selbox", "#" + pgcnt).bind("change", function() { ts.p.page = Math.round(ts.p.rowNum * (ts.p.page - 1) / this.value - 0.5) + 1; ts.p.rowNum = this.value; clearVals("records"); populate(); return false }); if (ts.p.pgbuttons === true) { $(".ui-pg-button", "#" + pgcnt).hover(function(e) { if ($(this).hasClass("ui-state-disabled")) { this.style.cursor = "default" } else { $(this).addClass("ui-state-hover"); this.style.cursor = "pointer" } }, function(e) { if ($(this).hasClass("ui-state-disabled")) { } else { $(this).removeClass("ui-state-hover"); this.style.cursor = "default" } }); $("#first, #prev, #next, #last", ts.p.pager).click(function(e) { var cp = IntNum(ts.p.page), last = IntNum(ts.p.lastpage), selclick = false, fp = true, pp = true, np = true, lp = true; if (last === 0 || last === 1) { fp = false; pp = false; np = false; lp = false } else { if (last > 1 && cp >= 1) { if (cp === 1) { fp = false; pp = false } else { if (cp > 1 && cp < last) { } else { if (cp === last) { np = false; lp = false } } } } else { if (last > 1 && cp === 0) { np = false; lp = false; cp = last - 1 } } } if (this.id === "first" && fp) { ts.p.page = 1; selclick = true } if (this.id === "prev" && pp) { ts.p.page = (cp - 1); selclick = true } if (this.id === "next" && np) { ts.p.page = (cp + 1); selclick = true } if (this.id === "last" && lp) { ts.p.page = last; selclick = true } if (selclick) { clearVals(this.id); populate() } return false }) } if (ts.p.pginput === true) { $("input.ui-pg-input", "#" + pgcnt).keypress(function(e) { var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; if (key == 13) { ts.p.page = ($(this).val() > 0) ? $(this).val() : ts.p.page; clearVals("user"); populate(); return false } return this }) } }, sortData = function(index, idxcol, reload, sor) { if (!ts.p.colModel[idxcol].sortable) { return } var imgs, so; if (ts.p.savedRow.length > 0) { return } if (!reload) { if (ts.p.lastsort == idxcol) { if (ts.p.sortorder == "asc") { ts.p.sortorder = "desc" } else { if (ts.p.sortorder == "desc") { ts.p.sortorder = "asc" } } } else { ts.p.sortorder = "asc" } ts.p.page = 1 } if (sor) { if (ts.p.lastsort == idxcol && ts.p.sortorder == sor) { return } else { ts.p.sortorder = sor } } var thd = $("thead:first", ts.grid.hDiv).get(0); $("tr th:eq(" + ts.p.lastsort + ") span.ui-grid-ico-sort", thd).addClass("ui-state-disabled"); $("tr th:eq(" + ts.p.lastsort + ")", thd).attr("aria-selected", "false"); $("tr th:eq(" + idxcol + ") span.ui-icon-" + ts.p.sortorder, thd).removeClass("ui-state-disabled"); $("tr th:eq(" + idxcol + ")", thd).attr("aria-selected", "true"); if (!ts.p.viewsortcols[0]) { if (ts.p.lastsort != idxcol) { $("tr th:eq(" + ts.p.lastsort + ") span.s-ico", thd).hide(); $("tr th:eq(" + idxcol + ") span.s-ico", thd).show() } } ts.p.lastsort = idxcol; index = index.substring(5); ts.p.sortname = ts.p.colModel[idxcol].index || index; so = ts.p.sortorder; if (onSortCol) { onSortCol(index, idxcol, so) } if (ts.p.datatype == "local") { if (ts.p.deselectAfterSort) { $(ts).resetSelection() } } else { ts.p.selrow = null; if (ts.p.multiselect) { $("#cb_jqg", ts.grid.hDiv).attr("checked", false) } ts.p.selarrrow = []; ts.p.savedRow = [] } if (ts.p.scroll === true) { $("tbody tr", ts.grid.bDiv).remove() } if (ts.p.subGrid && ts.p.datatype == "local") { $("td.sgexpanded", "#" + ts.p.id).each(function() { $(this).trigger("click") }) } populate(); if (ts.p.sortname != index && idxcol) { ts.p.lastsort = idxcol } }, setColWidth = function() { var initwidth = 0, brd = ts.p.cellLayout, vc = 0, lvc, scw = ts.p.scrollOffset, cw, hs = false, aw, tw = 0, gw = 0, msw = ts.p.multiselectWidth, sgw = ts.p.subGridWidth, rnw = ts.p.rownumWidth, cl = ts.p.cellLayout, cr; $.each(ts.p.colModel, function(i) { if (typeof this.hidden === "undefined") { this.hidden = false } if (this.hidden === false) { initwidth += IntNum(this.width); vc++ } }); if (isNaN(ts.p.width)) { ts.p.width = grid.width = initwidth } else { grid.width = ts.p.width } ts.p.tblwidth = initwidth; if (ts.p.shrinkToFit === false && ts.p.forceFit === true) { ts.p.forceFit = false } if (ts.p.shrinkToFit === true) { if (isSafari) { brd = 0; msw += cl; sgw += cl; rnw += cl } if (ts.p.multiselect) { tw = msw; gw = msw + brd; vc-- } if (ts.p.subGrid) { tw += sgw; gw += sgw + brd; vc-- } if (ts.p.rownumbers) { tw += rnw; gw += rnw + brd; vc-- } aw = grid.width - brd * vc - gw; if (isNaN(ts.p.height)) { } else { aw -= scw; hs = true } initwidth = 0; $.each(ts.p.colModel, function(i) { if (this.hidden === false && this.name !== "cb" && this.name !== "subgrid" && this.name !== "rn") { cw = Math.floor(aw / (ts.p.tblwidth - tw) * this.width); this.width = cw; initwidth += cw; lvc = i } }); cr = 0; if (hs && grid.width - gw - (initwidth + brd * vc) !== scw) { cr = grid.width - gw - (initwidth + brd * vc) - scw } else { if (!hs && Math.abs(grid.width - gw - (initwidth + brd * vc)) !== 1) { cr = grid.width - gw - (initwidth + brd * vc) } } ts.p.colModel[lvc].width += cr; ts.p.tblwidth = initwidth + tw + cr } }, nextVisible = function(iCol) { var ret = iCol, j = iCol, i; for (i = iCol + 1; i < ts.p.colModel.length; i++) { if (ts.p.colModel[i].hidden !== true) { j = i; break } } return j - ret }, getOffset = function(iCol) { var i, ret = {}, brd1 = isSafari ? 0 : ts.p.cellLayout; ret[0] = ret[1] = ret[2] = 0; for (i = 0; i <= iCol; i++) { if (ts.p.colModel[i].hidden === false) { ret[0] += ts.p.colModel[i].width + brd1 } } ret[0] = ret[0] - ts.grid.bDiv.scrollLeft; if ($(ts.grid.cDiv).is(":visible")) { ret[1] += $(ts.grid.cDiv).height() + parseInt($(ts.grid.cDiv).css("padding-top")) + parseInt($(ts.grid.cDiv).css("padding-bottom")) } if (ts.p.toolbar[0] == true && (ts.p.toolbar[1] == "top" || ts.p.toolbar[1] == "both")) { ret[1] += $(ts.grid.uDiv).height() + parseInt($(ts.grid.uDiv).css("border-top-width")) + parseInt($(ts.grid.uDiv).css("border-bottom-width")) } ret[2] += $(ts.grid.bDiv).height() + $(ts.grid.hDiv).height(); return ret }; this.p.id = this.id; if ($.inArray(ts.p.multikey, sortkeys) == -1) { ts.p.multikey = false } ts.p.keyIndex = false; for (i = 0; i < ts.p.colModel.length; i++) { if (ts.p.colModel[i].key === true) { ts.p.keyIndex = i; break } } ts.p.sortorder = ts.p.sortorder.toLowerCase(); if (this.p.treeGrid === true) { try { $(this).setTreeGrid() } catch (_) { } } if (this.p.subGrid) { try { $(ts).setSubGrid() } catch (_) { } } if (this.p.multiselect) { this.p.colNames.unshift("<input id='cb_jqg' class='cbox' type='checkbox'/>"); this.p.colModel.unshift({ name: "cb", width: isSafari ? ts.p.multiselectWidth + ts.p.cellLayout : ts.p.multiselectWidth, sortable: false, resizable: false, hidedlg: true, search: false, align: "center" }) } if (this.p.rownumbers) { this.p.colNames.unshift(""); this.p.colModel.unshift({ name: "rn", width: ts.p.rownumWidth, sortable: false, resizable: false, hidedlg: true, search: false, align: "center" }) } ts.p.xmlReader = $.extend({ root: "rows", row: "row", page: "rows>page", total: "rows>total", records: "rows>records", repeatitems: true, cell: "cell", id: "[id]", userdata: "userdata", subgrid: { root: "rows", row: "row", repeatitems: true, cell: "cell"} }, ts.p.xmlReader); ts.p.jsonReader = $.extend({ root: "rows", page: "page", total: "total", records: "records", repeatitems: true, cell: "cell", id: "id", userdata: "userdata", subgrid: { root: "rows", repeatitems: true, cell: "cell"} }, ts.p.jsonReader); if (ts.p.scroll === true) { ts.p.pgbuttons = false; ts.p.pginput = false; ts.p.rowList = [] } var thead = "<thead><tr class='ui-jqgrid-labels' role='rowheader'>", tdc, idn, w, res, sort, td, ptr, tbody, imgs, iac = "", idc = ""; if (ts.p.shrinkToFit === true && ts.p.forceFit === true) { for (i = ts.p.colModel.length - 1; i >= 0; i--) { if (!ts.p.colModel[i].hidden) { ts.p.colModel[i].resizable = false; break } } } if (ts.p.viewsortcols[1] == "horizontal") { iac = " ui-i-asc"; idc = " ui-i-desc" } tdc = isMSIE ? "class='ui-th-div-ie'" : ""; imgs = "<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc" + iac + " ui-state-disabled ui-icon ui-icon-triangle-1-n'></span>"; imgs += "<span sort='desc' class='ui-grid-ico-sort ui-icon-desc" + idc + " ui-state-disabled ui-icon ui-icon-triangle-1-s'></span></span>"; for (i = 0; i < this.p.colNames.length; i++) { thead += "<th role='columnheader' class='ui-state-default ui-th-column'>"; idn = ts.p.colModel[i].index || ts.p.colModel[i].name; thead += "<div id='jqgh_" + ts.p.colModel[i].name + "' " + tdc + ">" + ts.p.colNames[i]; if (idn == ts.p.sortname) { ts.p.lastsort = i } thead += imgs + "</div></th>" } thead += "</tr></thead>"; $(this).append(thead); $("thead tr:first th", this).hover(function() { $(this).addClass("ui-state-hover") }, function() { $(this).removeClass("ui-state-hover") }); if (this.p.multiselect) { var onSA = true, emp = [], chk; if (typeof ts.p.onSelectAll !== "function") { onSA = false } $("#cb_jqg", this).bind("click", function() { if (this.checked) { $("[id^=jqg_]", ts.rows).attr("checked", true); $(ts.rows).each(function(i) { if (!$(this).hasClass("subgrid")) { $(this).addClass("ui-state-highlight").attr("aria-selected", "true"); ts.p.selarrrow[i] = ts.p.selrow = this.id } }); chk = true; emp = [] } else { $("[id^=jqg_]", ts.rows).attr("checked", false); $(ts.rows).each(function(i) { if (!$(this).hasClass("subgrid")) { $(this).removeClass("ui-state-highlight").attr("aria-selected", "false"); emp[i] = this.id } }); ts.p.selarrrow = []; ts.p.selrow = null; chk = false } if (onSA) { ts.p.onSelectAll(chk ? ts.p.selarrrow : emp, chk) } }) } $.each(ts.p.colModel, function(i) { if (!this.width) { this.width = 150 } }); if (ts.p.autowidth === true) { var pw = $(eg).innerWidth(); ts.p.width = pw > 0 ? pw : "nw" } setColWidth(); $(eg).css("width", grid.width + "px").append("<div class='ui-jqgrid-resize-mark' id='rs_m" + ts.p.id + "'>&nbsp;</div>"); $(gv).css("width", grid.width + "px"); thead = $("thead:first", ts).get(0); var tfoot = "<table role='grid' style='width:" + ts.p.tblwidth + "px' class='ui-jqgrid-ftable' cellspacing='0' cellpadding='0' border='0'><tbody><tr role='row' class='ui-widget-content footrow'>"; $("tr:first th", thead).each(function(j) { var ht = $("div", this)[0]; w = ts.p.colModel[j].width; if (typeof ts.p.colModel[j].resizable === "undefined") { ts.p.colModel[j].resizable = true } res = document.createElement("span"); $(res).html("&#160;"); if (ts.p.colModel[j].resizable) { $(this).addClass(ts.p.resizeclass); $(res).mousedown(function(e) { if (ts.p.forceFit === true) { ts.p.nv = nextVisible(j) } grid.dragStart(j, e, getOffset(j)); return false }).addClass("ui-jqgrid-resize") } else { res = "" } $(this).css("width", w + "px").prepend(res); if (ts.p.colModel[j].hidden) { $(this).css("display", "none") } grid.headers[j] = { width: w, el: this }; sort = ts.p.colModel[j].sortable; if (typeof sort !== "boolean") { ts.p.colModel[j].sortable = true; sort = true } var nm = ts.p.colModel[j].name; if (!(nm == "cb" || nm == "subgrid" || nm == "rn")) { if (ts.p.viewsortcols[2] == false) { $(".ui-grid-ico-sort", this).click(function() { sortData(ht.id, j, true, $(this).attr("sort")); return false }) } else { $("div", this).addClass("ui-jqgrid-sortable").click(function() { sortData(ht.id, j); return false }) } } if (sort) { if (ts.p.viewsortcols[0]) { $("div span.s-ico", this).show(); if (j == ts.p.lastsort) { $("div span.ui-icon-" + ts.p.sortorder, this).removeClass("ui-state-disabled") } } else { if (j == ts.p.lastsort) { $("div span.s-ico", this).show(); $("div span.ui-icon-" + ts.p.sortorder, this).removeClass("ui-state-disabled") } } } tfoot += "<td role='gridcell' " + formatCol(j, 0) + ">&nbsp;</td>" }); tfoot += "</tr></tbody></table>"; tbody = document.createElement("tbody"); this.appendChild(tbody); $(this).addClass("ui-jqgrid-btable"); var hTable = $("<table class='ui-jqgrid-htable' style='width:" + ts.p.tblwidth + "px' role='grid' aria-labelledby='gbox_" + this.id + "' cellspacing='0' cellpadding='0' border='0'></table>").append(thead), hg = (ts.p.caption && ts.p.hiddengrid === true) ? true : false, hb = $("<div class='ui-jqgrid-hbox'></div>"); grid.hDiv = document.createElement("div"); $(grid.hDiv).css({ width: grid.width + "px" }).addClass("ui-state-default ui-jqgrid-hdiv").append(hb); $(hb).append(hTable); if (hg) { $(grid.hDiv).hide() } ts.p._height = 0; if (ts.p.pager) { if (typeof ts.p.pager == "string") { if (ts.p.pager.substr(0, 1) != "#") { ts.p.pager = "#" + ts.p.pager } } $(ts.p.pager).css({ width: grid.width + "px" }).appendTo(eg).addClass("ui-state-default ui-jqgrid-pager"); ts.p._height += parseInt($(ts.p.pager).height(), 10); if (hg) { $(ts.p.pager).hide() } setPager() } if (ts.p.cellEdit === false && ts.p.hoverrows === true) { $(ts).bind("mouseover", function(e) { ptr = $(e.target).parents("tr.jqgrow"); if ($(ptr).attr("class") !== "subgrid") { $(ptr).addClass("ui-state-hover") } return false }).bind("mouseout", function(e) { ptr = $(e.target).parents("tr.jqgrow"); $(ptr).removeClass("ui-state-hover"); return false }) } var ri, ci; $(ts).before(grid.hDiv).click(function(e) { td = e.target; var scb = $(td).hasClass("cbox"); ptr = $(td, ts.rows).parents("tr.jqgrow"); if ($(ptr).length === 0) { return this } var cSel = true; if (bSR) { cSel = bSR(ptr[0].id, e) } if (td.tagName == "A" || ((td.tagName == "INPUT" || td.tagName == "TEXTAREA" || td.tagName == "OPTION" || td.tagName == "SELECT") && !scb)) { return true } if (cSel === true) { if (ts.p.cellEdit === true) { if (ts.p.multiselect && scb) { $(ts).setSelection(ptr[0].id, true) } else { ri = ptr[0].rowIndex; ci = !$(td).is("td") ? $(td).parents("td:first")[0].cellIndex : td.cellIndex; if (isMSIE) { ci = $.jgrid.getAbsoluteIndex(ptr[0], ci) } try { $(ts).editCell(ri, ci, true) } catch (e) { } } } else { if (!ts.p.multikey) { if (ts.p.multiselect && ts.p.multiboxonly) { if (scb) { $(ts).setSelection(ptr[0].id, true) } else { $(ts.p.selarrrow).each(function(i, n) { var ind = ts.rows.namedItem(n); $(ind).removeClass("ui-state-highlight"); $("#jqg_" + n.replace(".", "\\."), ind).attr("checked", false) }); ts.p.selarrrow = []; $("#cb_jqg", ts.grid.hDiv).attr("checked", false); $(ts).setSelection(ptr[0].id, true) } } else { $(ts).setSelection(ptr[0].id, true) } } else { if (e[ts.p.multikey]) { $(ts).setSelection(ptr[0].id, true) } else { if (ts.p.multiselect && scb) { scb = $("[id^=jqg_]", ptr).attr("checked"); $("[id^=jqg_]", ptr).attr("checked", !scb) } } } } if (onSC) { ri = ptr[0].id; ci = !$(td).is("td") ? $(td).parents("td:first")[0].cellIndex : td.cellIndex; if (isMSIE) { ci = $.jgrid.getAbsoluteIndex(ptr[0], ci) } onSC(ri, ci, $(td).html(), td) } } e.stopPropagation() }).bind("reloadGrid", function(e) { if (ts.p.treeGrid === true) { ts.p.datatype = ts.p.treedatatype } if (ts.p.datatype == "local") { $(ts).resetSelection() } else { if (!ts.p.treeGrid) { ts.p.selrow = null; if (ts.p.multiselect) { ts.p.selarrrow = []; $("#cb_jqg", ts.grid.hDiv).attr("checked", false) } if (ts.p.cellEdit) { ts.p.savedRow = [] } } } if (ts.p.scroll === true) { $("tbody tr", ts.grid.bDiv).remove() } ts.grid.populate(); return false }); if (ondblClickRow) { $(this).dblclick(function(e) { td = (e.target); ptr = $(td, ts.rows).parents("tr.jqgrow"); if ($(ptr).length === 0) { return false } ri = ptr[0].rowIndex; ci = !$(td).is("td") ? $(td).parents("td:first")[0].cellIndex : td.cellIndex; if (isMSIE) { ci = $.jgrid.getAbsoluteIndex(ptr[0], ci) } ts.p.ondblClickRow($(ptr).attr("id"), ri, ci); return false }) } if (onRightClickRow) { $(this).bind("contextmenu", function(e) { td = e.target; ptr = $(td, ts.rows).parents("tr.jqgrow"); if ($(ptr).length === 0) { return false } if (!ts.p.multiselect) { $(ts).setSelection(ptr[0].id, true) } ri = ptr[0].rowIndex; ci = !$(td).is("td") ? $(td).parents("td:first")[0].cellIndex : td.cellIndex; if (isMSIE) { ci = $.jgrid.getAbsoluteIndex(ptr[0], ci) } ts.p.onRightClickRow($(ptr).attr("id"), ri, ci); return false }) } grid.bDiv = document.createElement("div"); $(grid.bDiv).append(this).addClass("ui-jqgrid-bdiv").css({ height: ts.p.height + (isNaN(ts.p.height) ? "" : "px"), width: (grid.width) + "px" }).scroll(function(e) { grid.scrollGrid() }); $("table:first", grid.bDiv).css({ width: ts.p.tblwidth + "px" }); if (isMSIE) { if ($("tbody", this).size() == 2) { $("tbody:first", this).remove() } if (ts.p.multikey) { $(grid.bDiv).bind("selectstart", function() { return false }) } } else { if (ts.p.multikey) { $(grid.bDiv).bind("mousedown", function() { return false }) } } if (hg) { $(grid.bDiv).hide() } grid.cDiv = document.createElement("div"); var arf = ts.p.hidegrid === true ? $("<a role='link' href='javascript:void(0)'/>").addClass("ui-jqgrid-titlebar-close HeaderButton").hover(function() { arf.addClass("ui-state-hover") }, function() { arf.removeClass("ui-state-hover") }).append("<span class='ui-icon ui-icon-circle-triangle-n'></span>") : ""; $(grid.cDiv).append(arf).append("<span class='ui-jqgrid-title'>" + ts.p.caption + "</span>").addClass("ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"); $(grid.cDiv).insertBefore(grid.hDiv); if (ts.p.toolbar[0]) { grid.uDiv = document.createElement("div"); if (ts.p.toolbar[1] == "top") { $(grid.uDiv).insertBefore(grid.hDiv) } else { if (ts.p.toolbar[1] == "bottom") { $(grid.uDiv).insertAfter(grid.hDiv) } } if (ts.p.toolbar[1] == "both") { grid.ubDiv = document.createElement("div"); $(grid.uDiv).insertBefore(grid.hDiv).addClass("ui-userdata ui-state-default").attr("id", "t_" + this.id); $(grid.ubDiv).insertAfter(grid.hDiv).addClass("ui-userdata ui-state-default").attr("id", "tb_" + this.id); ts.p._height += IntNum($(grid.ubDiv).height()); if (hg) { $(grid.ubDiv).hide() } } else { $(grid.uDiv).width(grid.width).addClass("ui-userdata ui-state-default").attr("id", "t_" + this.id) } ts.p._height += IntNum($(grid.uDiv).height()); if (hg) { $(grid.uDiv).hide() } } if (ts.p.footerrow) { grid.sDiv = document.createElement("div"); hb = $("<div class='ui-jqgrid-hbox'></div>"); $(grid.sDiv).addClass("ui-jqgrid-sdiv").append(hb).insertAfter(grid.hDiv).width(grid.width); $(hb).append(tfoot); grid.footers = $(".ui-jqgrid-ftable", grid.sDiv)[0].rows[0].cells; if (ts.p.rownumbers) { grid.footers[0].className = "ui-state-default jqgrid-rownum" } if (hg) { $(grid.sDiv).hide() } } if (ts.p.caption) { ts.p._height += parseInt($(grid.cDiv, ts).height(), 10); var tdt = ts.p.datatype; if (ts.p.hidegrid === true) { $(".ui-jqgrid-titlebar-close", grid.cDiv).click(function() { if (ts.p.gridstate == "visible") { $(".ui-jqgrid-bdiv, .ui-jqgrid-hdiv", "#gview_" + ts.p.id).slideUp("fast"); if (ts.p.pager) { $(ts.p.pager).slideUp("fast") } if (ts.p.toolbar[0] === true) { if (ts.p.toolbar[1] == "both") { $(grid.ubDiv).slideUp("fast") } $(grid.uDiv).slideUp("fast") } if (ts.p.footerrow) { $(".ui-jqgrid-sdiv", "#gbox_" + ts.p.id).slideUp("fast") } $("span", this).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s"); ts.p.gridstate = "hidden"; if (onHdCl) { if (!hg) { ts.p.onHeaderClick(ts.p.gridstate) } } } else { if (ts.p.gridstate == "hidden") { $(".ui-jqgrid-hdiv, .ui-jqgrid-bdiv", "#gview_" + ts.p.id).slideDown("fast"); if (ts.p.pager) { $(ts.p.pager).slideDown("fast") } if (ts.p.toolbar[0] === true) { if (ts.p.toolbar[1] == "both") { $(grid.ubDiv).slideDown("fast") } $(grid.uDiv).slideDown("fast") } if (ts.p.footerrow) { $(".ui-jqgrid-sdiv", "#gbox_" + ts.p.id).slideDown("fast") } $("span", this).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n"); if (hg) { ts.p.datatype = tdt; populate(); hg = false } ts.p.gridstate = "visible"; if (onHdCl) { ts.p.onHeaderClick(ts.p.gridstate) } } } return false }); if (hg) { ts.p.datatype = "local"; $(".ui-jqgrid-titlebar-close", grid.cDiv).trigger("click") } } } else { $(grid.cDiv).hide() } $(grid.hDiv).after(grid.bDiv); $(".ui-jqgrid-labels", grid.hDiv).bind("selectstart", function() { return false }).mousemove(function(e) { if (grid.resizing) { grid.dragMove(e) } return false }); ts.p._height += parseInt($(grid.hDiv).height(), 10); $(document).mouseup(function(e) { if (grid.resizing) { grid.dragEnd(); return false } return true }); this.updateColumns = function() { var r = this.rows[0], self = this; if (r) { $("td", r).each(function(k) { $(this).css("width", self.grid.headers[k].width + "px") }); this.grid.cols = r.cells } return this }; ts.formatCol = function(a, b) { return formatCol(a, b) }; ts.sortData = function(a, b, c) { sortData(a, b, c) }; ts.updatepager = function(a) { updatepager(a) }; ts.formatter = function(rowId, cellval, colpos, rwdat, act) { return formatter(rowId, cellval, colpos, rwdat, act) }; $.extend(grid, { populate: function() { populate() } }); this.grid = grid; ts.addXmlData = function(d) { addXmlData(d, ts.grid.bDiv) }; ts.addJSONData = function(d) { addJSONData(d, ts.grid.bDiv) }; populate(); ts.p.hiddengrid = false; $(window).unload(function() { $(this).empty(); this.grid = null; this.p = null }) }) }; $.fn.extend({ getGridParam: function(pName) { var $t = this[0]; if (!$t.grid) { return } if (!pName) { return $t.p } else { return $t.p[pName] ? $t.p[pName] : null } }, setGridParam: function(newParams) { return this.each(function() { if (this.grid && typeof (newParams) === "object") { $.extend(true, this.p, newParams) } }) }, getDataIDs: function() { var ids = [], i = 0, len; this.each(function() { len = this.rows.length; if (len && len > 0) { while (i < len) { ids[i] = this.rows[i].id; i++ } } }); return ids }, setSelection: function(selection, onsr) { return this.each(function() { var $t = this, stat, pt, olr, ner, ia, tpsr; if (selection === undefined) { return } onsr = onsr === false ? false : true; pt = $t.rows.namedItem(selection); if (pt == null) { return } if ($t.p.selrow && $t.p.scrollrows === true) { olr = $t.rows.namedItem($t.p.selrow).rowIndex; ner = $t.rows.namedItem(selection).rowIndex; if (ner >= 0) { if (ner > olr) { scrGrid(ner, "d") } else { scrGrid(ner, "u") } } } if (!$t.p.multiselect) { if ($(pt).attr("class") !== "subgrid") { if ($t.p.selrow) { $("tr#" + $t.p.selrow.replace(".", "\\."), $t.grid.bDiv).removeClass("ui-state-highlight").attr("aria-selected", "false") } $t.p.selrow = selection; $(pt).addClass("ui-state-highlight").attr("aria-selected", "true"); if ($t.p.onSelectRow && onsr) { $t.p.onSelectRow($t.p.selrow, true) } } } else { $t.p.selrow = selection; ia = $.inArray($t.p.selrow, $t.p.selarrrow); if (ia === -1) { if ($(pt).attr("class") !== "subgrid") { $(pt).addClass("ui-state-highlight").attr("aria-selected", "true") } stat = true; $("#jqg_" + $t.p.selrow.replace(".", "\\."), $t.rows).attr("checked", stat); $t.p.selarrrow.push($t.p.selrow); if ($t.p.onSelectRow && onsr) { $t.p.onSelectRow($t.p.selrow, stat) } } else { if ($(pt).attr("class") !== "subgrid") { $(pt).removeClass("ui-state-highlight").attr("aria-selected", "false") } stat = false; $("#jqg_" + $t.p.selrow.replace(".", "\\."), $t.rows).attr("checked", stat); $t.p.selarrrow.splice(ia, 1); if ($t.p.onSelectRow && onsr) { $t.p.onSelectRow($t.p.selrow, stat) } tpsr = $t.p.selarrrow[0]; $t.p.selrow = (tpsr === undefined) ? null : tpsr } } function scrGrid(iR, tp) { var ch = $($t.grid.bDiv)[0].clientHeight, st = $($t.grid.bDiv)[0].scrollTop, nROT = $t.rows[iR].offsetTop + $t.rows[iR].clientHeight, pROT = $t.rows[iR].offsetTop; if (tp == "d") { if (nROT >= ch) { $($t.grid.bDiv)[0].scrollTop = st + nROT - pROT } } if (tp == "u") { if (pROT < st) { $($t.grid.bDiv)[0].scrollTop = st - nROT + pROT } } } }) }, resetSelection: function() { return this.each(function() { var t = this, ind; if (!t.p.multiselect) { if (t.p.selrow) { $("tr#" + t.p.selrow.replace(".", "\\."), t.grid.bDiv).removeClass("ui-state-highlight").attr("aria-selected", "false"); t.p.selrow = null } } else { $(t.p.selarrrow).each(function(i, n) { ind = t.rows.namedItem(n); $(ind).removeClass("ui-state-highlight").attr("aria-selected", "false"); $("#jqg_" + n.replace(".", "\\."), ind).attr("checked", false) }); $("#cb_jqg", t.grid.hDiv).attr("checked", false); t.p.selarrrow = [] } t.p.savedRow = [] }) }, getRowData: function(rowid) { var res = {}; this.each(function() { var $t = this, nm, ind; ind = $t.rows.namedItem(rowid); if (!ind) { return res } $("td", ind).each(function(i) { nm = $t.p.colModel[i].name; if (nm !== "cb" && nm !== "subgrid") { if ($t.p.treeGrid === true && nm == $t.p.ExpandColumn) { res[nm] = $.jgrid.htmlDecode($("span:first", this).html()) } else { try { res[nm] = $.unformat(this, { colModel: $t.p.colModel[i] }, i) } catch (e) { res[nm] = $.jgrid.htmlDecode($(this).html()) } } } }) }); return res }, delRowData: function(rowid) { var success = false, rowInd, ia, ri; this.each(function() { var $t = this; rowInd = $t.rows.namedItem(rowid); if (!rowInd) { return false } else { ri = rowInd.rowIndex; $(rowInd).remove(); $t.p.records--; $t.p.reccount--; $t.updatepager(true); success = true; if (rowid == $t.p.selrow) { $t.p.selrow = null } ia = $.inArray(rowid, $t.p.selarrrow); if (ia != -1) { $t.p.selarrrow.splice(ia, 1) } } if (ri == 0 && success) { $t.updateColumns() } if ($t.p.altRows === true && success) { var cn = $t.p.altclass; $($t.rows).each(function(i) { if (i % 2 == 1) { $(this).addClass(cn) } else { $(this).removeClass(cn) } }) } }); return success }, setRowData: function(rowid, data) { var nm, success = false; this.each(function() { var t = this, vl, ind; if (!t.grid) { return false } ind = t.rows.namedItem(rowid); if (!ind) { return false } if (data) { $(this.p.colModel).each(function(i) { nm = this.name; if (data[nm] != undefined) { vl = t.formatter(rowid, data[nm], i, data, "edit"); if (t.p.treeGrid === true && nm == t.p.ExpandColumn) { $("td:eq(" + i + ") > span:first", ind).html(vl).attr("title", $.jgrid.stripHtml(vl)) } else { $("td:eq(" + i + ")", ind).html(vl).attr("title", $.jgrid.stripHtml(vl)) } success = true } }) } }); return success }, addRowData: function(rowid, data, pos, src) { if (!pos) { pos = "last" } var success = false, nm, row, gi = 0, si = 0, ni = 0, sind, i, v, prp = ""; if (data) { this.each(function() { var t = this; rowid = typeof (rowid) != "undefined" ? rowid + "" : t.p.records + 1; row = '<tr id="' + rowid + '" role="row" class="ui-widget-content jqgrow">'; if (t.p.rownumbers === true) { prp = t.formatCol(ni, 1); row += '<td role="gridcell" class="ui-state-default jqgrid-rownum" ' + prp + ">0</td>"; ni = 1 } if (t.p.multiselect) { v = '<input type="checkbox" id="jqg_' + rowid + '" class="cbox"/>'; prp = t.formatCol(ni, 1); row += '<td role="gridcell" ' + prp + ">" + v + "</td>"; gi = 1 } if (t.p.subGrid === true) { row += $(t).addSubGridCell(gi + ni, 1); si = 1 } for (i = gi + si + ni; i < this.p.colModel.length; i++) { nm = this.p.colModel[i].name; v = t.formatter(rowid, data[nm], i, data, "add"); prp = t.formatCol(i, 1); row += '<td role="gridcell" ' + prp + ' title="' + $.jgrid.stripHtml(v) + '">' + v + "</td>" } row += "</tr>"; if (t.p.subGrid === true) { row = $(row)[0]; $(t).addSubGrid(row, gi + ni) } if (t.rows.length === 0) { $("table:first", t.grid.bDiv).append(row) } else { switch (pos) { case "last": $(t.rows[t.rows.length - 1]).after(row); break; case "first": $(t.rows[0]).before(row); break; case "after": sind = t.rows.namedItem(src); sind != null ? $(t.rows[sind.rowIndex + 1]).hasClass("ui-subgrid") ? $(t.rows[sind.rowIndex + 1]).after(row) : $(sind).after(row) : ""; break; case "before": sind = t.rows.namedItem(src); if (sind != null) { $(sind).before(row); sind = sind.rowIndex } break } } t.p.records++; t.p.reccount++; if (pos === "first" || (pos === "before" && sind == 0) || t.rows.length === 1) { t.updateColumns() } if (t.p.altRows === true) { var cn = t.p.altclass; if (pos == "last") { if (t.rows.length % 2 == 1) { $(t.rows[t.rows.length - 1]).addClass(cn) } } else { $(t.rows).each(function(i) { if (i % 2 == 1) { $(this).addClass(cn) } else { $(this).removeClass(cn) } }) } } try { t.p.afterInsertRow(rowid, data) } catch (e) { } t.updatepager(true); success = true }) } return success }, footerData: function(action, data, format) { var nm, success = false, res = {}; function isEmpty(obj) { for (var i in obj) { return false } return true } if (typeof (action) == "undefined") { action = "get" } if (typeof (format) != "boolean") { format = true } action = action.toLowerCase(); this.each(function() { var t = this, vl, ind; if (!t.grid || !t.p.footerrow) { return false } if (action == "set") { if (isEmpty(data)) { return false } } success = true; $(this.p.colModel).each(function(i) { nm = this.name; if (action == "set") { if (data[nm] != undefined) { vl = format ? t.formatter("", data[nm], i, data, "edit") : data[nm]; $("tr.footrow td:eq(" + i + ")", t.grid.sDiv).html(vl).attr("title", $.jgrid.stripHtml(vl)); success = true } } else { if (action == "get") { res[nm] = $("tr.footrow td:eq(" + i + ")", t.grid.sDiv).html() } } }) }); return action == "get" ? res : success }, ShowHideCol: function(colname, show) { return this.each(function() { var $t = this, fndh = false; if (!$t.grid) { return } if (typeof colname === "string") { colname = [colname] } show = show != "none" ? "" : "none"; var sw = show == "" ? true : false; $(this.p.colModel).each(function(i) { if ($.inArray(this.name, colname) !== -1 && this.hidden === sw) { $("tr", $t.grid.hDiv).each(function() { $("th:eq(" + i + ")", this).css("display", show) }); $($t.rows).each(function(j) { $("td:eq(" + i + ")", $t.rows[j]).css("display", show) }); if ($t.p.footerrow) { $("td:eq(" + i + ")", $t.grid.sDiv).css("display", show) } if (show == "none") { $t.p.tblwidth -= this.width } else { $t.p.tblwidth += this.width } this.hidden = !sw; fndh = true } }); if (fndh === true) { $("table:first", $t.grid.hDiv).width($t.p.tblwidth); $("table:first", $t.grid.bDiv).width($t.p.tblwidth); $t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft; if ($t.p.footerrow) { $("table:first", $t.grid.sDiv).width($t.p.tblwidth); $t.grid.sDiv.scrollLeft = $t.grid.bDiv.scrollLeft } } }) }, hideCol: function(colname) { return this.each(function() { $(this).ShowHideCol(colname, "none") }) }, showCol: function(colname) { return this.each(function() { $(this).ShowHideCol(colname, "") }) }, setGridWidth: function(nwidth, shrink) { return this.each(function() { var $t = this, cw, initwidth = 0, brd = $t.p.cellLayout, lvc, vc = 0, isSafari, hs = false, scw = $t.p.scrollOffset, aw, gw = 0, tw = 0, msw = $t.p.multiselectWidth, sgw = $t.p.subGridWidth, rnw = $t.p.rownumWidth, cl = $t.p.cellLayout, cr; if (!$t.grid) { return } if (typeof shrink != "boolean") { shrink = $t.p.shrinkToFit } if (isNaN(nwidth)) { return } if (nwidth == $t.grid.width) { return } else { $t.grid.width = $t.p.width = nwidth } $("#gbox_" + $t.p.id).css("width", nwidth + "px"); $("#gview_" + $t.p.id).css("width", nwidth + "px"); $($t.grid.bDiv).css("width", nwidth + "px"); $($t.grid.hDiv).css("width", nwidth + "px"); if ($t.p.pager) { $($t.p.pager).css("width", nwidth + "px") } if ($t.p.toolbar[0] === true) { $($t.grid.uDiv).css("width", nwidth + "px"); if ($t.p.toolbar[1] == "both") { $($t.grid.ubDiv).css("width", nwidth + "px") } } if ($t.p.footerrow) { $($t.grid.sDiv).css("width", nwidth + "px") } if (shrink === false && $t.p.forceFit == true) { $t.p.forceFit = false } if (shrink === true) { $.each($t.p.colModel, function(i) { if (this.hidden === false) { initwidth += parseInt(this.width, 10); vc++ } }); isSafari = $.browser.safari ? true : false; if (isSafari) { brd = 0; msw += cl; sgw += cl; rnw += cl } if ($t.p.multiselect) { tw = msw; gw = msw + brd; vc-- } if ($t.p.subGrid) { tw += sgw; gw += sgw + brd; vc-- } if ($t.p.rownumbers) { tw += rnw; gw += rnw + brd; vc-- } $t.p.tblwidth = initwidth; aw = nwidth - brd * vc - gw; if (!isNaN($t.p.height)) { if ($($t.grid.bDiv)[0].clientHeight < $($t.grid.bDiv)[0].scrollHeight) { hs = true; aw -= scw } } initwidth = 0; var cle = $t.grid.cols.length > 0; $.each($t.p.colModel, function(i) { var tn = this.name; if (this.hidden === false && tn !== "cb" && tn !== "subgrid" && tn !== "rn") { cw = Math.floor((aw) / ($t.p.tblwidth - tw) * this.width); this.width = cw; initwidth += cw; $t.grid.headers[i].width = cw; $t.grid.headers[i].el.style.width = cw + "px"; if ($t.p.footerrow) { $t.grid.footers[i].style.width = cw + "px" } if (cle) { $t.grid.cols[i].style.width = cw + "px" } lvc = i } }); cr = 0; if (hs && nwidth - gw - (initwidth + brd * vc) !== scw) { cr = nwidth - gw - (initwidth + brd * vc) - scw } else { if (Math.abs(nwidth - gw - (initwidth + brd * vc)) !== 1) { cr = nwidth - gw - (initwidth + brd * vc) } } $t.p.colModel[lvc].width += cr; cw = $t.p.colModel[lvc].width; $t.grid.headers[lvc].width = cw; $t.grid.headers[lvc].el.style.width = cw + "px"; if (cl > 0) { $t.grid.cols[lvc].style.width = cw + "px" } $t.p.tblwidth = initwidth + tw + cr; $("table:first", $t.grid.bDiv).css("width", initwidth + tw + cr + "px"); $("table:first", $t.grid.hDiv).css("width", initwidth + tw + cr + "px"); $t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft; if ($t.p.footerrow) { $t.grid.footers[lvc].style.width = cw + "px"; $("table:first", $t.grid.sDiv).css("width", initwidth + tw + cr + "px") } } }) }, setGridHeight: function(nh) { return this.each(function() { var $t = this; if (!$t.grid) { return } $($t.grid.bDiv).css({ height: nh + (isNaN(nh) ? "" : "px") }); $t.p.height = nh }) }, setCaption: function(newcap) { return this.each(function() { this.p.caption = newcap; $("span.ui-jqgrid-title", this.grid.cDiv).html(newcap); $(this.grid.cDiv).show() }) }, setLabel: function(colname, nData, prop, attrp) { return this.each(function() { var $t = this, pos = -1; if (!$t.grid) { return } if (isNaN(colname)) { $($t.p.colModel).each(function(i) { if (this.name == colname) { pos = i; return false } }) } else { pos = parseInt(colname, 10) } if (pos >= 0) { var thecol = $("tr.ui-jqgrid-labels th:eq(" + pos + ")", $t.grid.hDiv); if (nData) { $("div", thecol).html(nData); $t.p.colNames[pos] = nData } if (prop) { if (typeof prop === "string") { $(thecol).addClass(prop) } else { $(thecol).css(prop) } } if (typeof attrp === "object") { $(thecol).attr(attrp) } } }) }, setCell: function(rowid, colname, nData, cssp, attrp) { return this.each(function() { var $t = this, pos = -1, v; if (!$t.grid) { return } if (isNaN(colname)) { $($t.p.colModel).each(function(i) { if (this.name == colname) { pos = i; return false } }) } else { pos = parseInt(colname, 10) } if (pos >= 0) { var ind = $t.rows.namedItem(rowid); if (ind) { var tcell = $("td:eq(" + pos + ")", ind); if (nData !== "") { v = $t.formatter(rowid, nData, pos, ind, "edit"); $(tcell).html(v).attr("title", $.jgrid.stripHtml(v)) } if (cssp) { if (typeof cssp === "string") { $(tcell).addClass(cssp) } else { $(tcell).css(cssp) } } if (typeof attrp === "object") { $(tcell).attr(attrp) } } } }) }, getCell: function(rowid, col) { var ret = false; this.each(function() { var $t = this, pos = -1; if (!$t.grid) { return } if (isNaN(col)) { $($t.p.colModel).each(function(i) { if (this.name === col) { pos = i; return false } }) } else { pos = parseInt(col, 10) } if (pos >= 0) { var ind = $t.rows.namedItem(rowid); if (ind) { try { ret = $.unformat($("td:eq(" + pos + ")", ind), { colModel: $t.p.colModel[pos] }, pos) } catch (e) { ret = $.jgrid.htmlDecode($("td:eq(" + pos + ")", ind).html()) } } } }); return ret }, getCol: function(col, obj) { var ret = [], val; obj = obj == false ? false : true; this.each(function() { var $t = this, pos = -1; if (!$t.grid) { return } if (isNaN(col)) { $($t.p.colModel).each(function(i) { if (this.name === col) { pos = i; return false } }) } else { pos = parseInt(col, 10) } if (pos >= 0) { var ln = $t.rows.length, i = 0; if (ln && ln > 0) { while (i < ln) { val = $t.rows[i].cells[pos].innerHTML; obj ? ret.push({ id: $t.rows[i].id, value: val }) : ret[i] = val; i++ } } } }); return ret }, clearGridData: function(clearfooter) { return this.each(function() { var $t = this; if (!$t.grid) { return } if (typeof clearfooter != "boolean") { clearfooter = false } $("tbody:first tr", $t.grid.bDiv).remove(); if ($t.p.footerrow && clearfooter) { $(".ui-jqgrid-ftable td", $t.grid.sDiv).html("&nbsp;") } $t.p.selrow = null; $t.p.selarrrow = []; $t.p.savedRow = []; $t.p.records = 0; $t.p.page = "0"; $t.p.lastpage = "0"; $t.p.reccount = 0; $t.updatepager(true) }) }, getInd: function(rowid, rc) { var ret = false, rw; this.each(function() { rw = this.rows.namedItem(rowid); if (rw) { ret = rc === true ? rw : rw.rowIndex } }); return ret } }) })(jQuery); (function(c) { c.fmatter = {}; c.fn.fmatter = function(g, h, f, d, e) { f = c.extend({}, c.jgrid.formatter, f); return a(g, h, f, d, e) }; c.fmatter.util = { NumberFormat: function(f, d) { if (!isNumber(f)) { f *= 1 } if (isNumber(f)) { var h = (f < 0); var n = f + ""; var k = (d.decimalSeparator) ? d.decimalSeparator : "."; var l; if (isNumber(d.decimalPlaces)) { var m = d.decimalPlaces; var g = Math.pow(10, m); n = Math.round(f * g) / g + ""; l = n.lastIndexOf("."); if (m > 0) { if (l < 0) { n += k; l = n.length - 1 } else { if (k !== ".") { n = n.replace(".", k) } } while ((n.length - 1 - l) < m) { n += "0" } } } if (d.thousandsSeparator) { var p = d.thousandsSeparator; l = n.lastIndexOf(k); l = (l > -1) ? l : n.length; var o = n.substring(l); var e = -1; for (var j = l; j > 0; j--) { e++; if ((e % 3 === 0) && (j !== l) && (!h || (j > 1))) { o = p + o } o = n.charAt(j - 1) + o } n = o } n = (d.prefix) ? d.prefix + n : n; n = (d.suffix) ? n + d.suffix : n; return n } else { return f } }, DateFormat: function(I, L, O, x) { var m = /\\.|[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g, C = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, K = /[^-+\dA-Z]/g, J = function(j, i) { j = String(j); i = parseInt(i) || 2; while (j.length < i) { j = "0" + j } return j }, d = { m: 1, d: 1, y: 1970, h: 0, i: 0, s: 0 }, g = 0, q, E, f, D = ["i18n"]; D.i18n = { dayNames: x.dayNames, monthNames: x.monthNames }; if (I in x.masks) { I = x.masks[I] } L = L.split(/[\\\/:_;.\t\T\s-]/); I = I.split(/[\\\/:_;.\t\T\s-]/); for (E = 0, f = I.length; E < f; E++) { if (I[E] == "M") { q = c.inArray(L[E], D.i18n.monthNames); if (q !== -1 && q < 12) { L[E] = q + 1 } } if (I[E] == "F") { q = c.inArray(L[E], D.i18n.monthNames); if (q !== -1 && q > 11) { L[E] = q + 1 - 12 } } d[I[E].toLowerCase()] = parseInt(L[E], 10) } d.m = parseInt(d.m) - 1; var M = d.y; if (M >= 70 && M <= 99) { d.y = 1900 + d.y } else { if (M >= 0 && M <= 69) { d.y = 2000 + d.y } } g = new Date(d.y, d.m, d.d, d.h, d.i, d.s, 0); if (O in x.masks) { O = x.masks[O] } else { if (!O) { O = "Y-m-d" } } var t = g.getHours(), H = g.getMinutes(), F = g.getDate(), B = g.getMonth() + 1, A = g.getTimezoneOffset(), y = g.getSeconds(), v = g.getMilliseconds(), r = g.getDay(), e = g.getFullYear(), l = (r + 6) % 7 + 1, p = (new Date(e, B - 1, F) - new Date(e, 0, 1)) / 86400000, h = { d: J(F), D: D.i18n.dayNames[r], j: F, l: D.i18n.dayNames[r + 7], N: l, S: x.S(F), w: r, z: p, W: l < 5 ? Math.floor((p + l - 1) / 7) + 1 : Math.floor((p + l - 1) / 7) || ((new Date(e - 1, 0, 1).getDay() + 6) % 7 < 4 ? 53 : 52), F: D.i18n.monthNames[B - 1 + 12], m: J(B), M: D.i18n.monthNames[B - 1], n: B, t: "?", L: "?", o: "?", Y: e, y: String(e).substring(2), a: t < 12 ? x.AmPm[0] : x.AmPm[1], A: t < 12 ? x.AmPm[2] : x.AmPm[3], B: "?", g: t % 12 || 12, G: t, h: J(t % 12 || 12), H: J(t), i: J(H), s: J(y), u: v, e: "?", I: "?", O: (A > 0 ? "-" : "+") + J(Math.floor(Math.abs(A) / 60) * 100 + Math.abs(A) % 60, 4), P: "?", T: (String(g).match(C) || [""]).pop().replace(K, ""), Z: "?", c: "?", r: "?", U: Math.floor(g / 1000) }; return O.replace(m, function(i) { return i in h ? h[i] : i.substring(1) }) } }; c.fn.fmatter.defaultFormat = function(e, d) { return (isValue(e) && e !== "") ? e : d.defaultValue ? d.defaultValue : "&#160;" }; c.fn.fmatter.email = function(e, d) { if (!isEmpty(e)) { return '<a href="mailto:' + e + '">' + e + "</a>" } else { return c.fn.fmatter.defaultFormat(e, d) } }; c.fn.fmatter.checkbox = function(g, e) { var h = c.extend({}, e.checkbox), f; if (!isUndefined(e.colModel.formatoptions)) { h = c.extend({}, h, e.colModel.formatoptions) } if (h.disabled === true) { f = "disabled" } else { f = "" } g = g + ""; g = g.toLowerCase(); var d = g.search(/(false|0|no|off)/i) < 0 ? " checked='checked' " : ""; return '<input type="checkbox" ' + d + ' value="' + g + '" offval="no" ' + f + "/>" }, c.fn.fmatter.link = function(f, d) { var g = { target: d.target }; var e = ""; if (!isUndefined(d.colModel.formatoptions)) { g = c.extend({}, g, d.colModel.formatoptions) } if (g.target) { e = "target=" + g.target } if (!isEmpty(f)) { return "<a " + e + ' href="' + f + '">' + f + "</a>" } else { return c.fn.fmatter.defaultFormat(f, d) } }; c.fn.fmatter.showlink = function(f, d) { var g = { baseLinkUrl: d.baseLinkUrl, showAction: d.showAction, addParam: d.addParam || "", target: d.target, idName: d.idName }, e = ""; if (!isUndefined(d.colModel.formatoptions)) { g = c.extend({}, g, d.colModel.formatoptions) } if (g.target) { e = "target=" + g.target } idUrl = g.baseLinkUrl + g.showAction + "?" + g.idName + "=" + d.rowId + g.addParam; if (isString(f)) { return "<a " + e + ' href="' + idUrl + '">' + f + "</a>" } else { return c.fn.fmatter.defaultFormat(f, d) } }; c.fn.fmatter.integer = function(e, d) { var f = c.extend({}, d.integer); if (!isUndefined(d.colModel.formatoptions)) { f = c.extend({}, f, d.colModel.formatoptions) } if (isEmpty(e)) { return f.defaultValue } return c.fmatter.util.NumberFormat(e, f) }; c.fn.fmatter.number = function(e, d) { var f = c.extend({}, d.number); if (!isUndefined(d.colModel.formatoptions)) { f = c.extend({}, f, d.colModel.formatoptions) } if (isEmpty(e)) { return f.defaultValue } return c.fmatter.util.NumberFormat(e, f) }; c.fn.fmatter.currency = function(e, d) { var f = c.extend({}, d.currency); if (!isUndefined(d.colModel.formatoptions)) { f = c.extend({}, f, d.colModel.formatoptions) } if (isEmpty(e)) { return f.defaultValue } return c.fmatter.util.NumberFormat(e, f) }; c.fn.fmatter.date = function(f, e, d) { var g = c.extend({}, e.date); if (!isUndefined(e.colModel.formatoptions)) { g = c.extend({}, g, e.colModel.formatoptions) } if (!g.reformatAfterEdit && d == "edit") { return c.fn.fmatter.defaultFormat(f, e) } else { if (!isEmpty(f)) { return c.fmatter.util.DateFormat(g.srcformat, f, g.newformat, g) } else { return c.fn.fmatter.defaultFormat(f, e) } } }; c.fn.fmatter.select = function(h, d, m) { if (!h) { h = "" } var f = false; if (!isUndefined(d.colModel.editoptions)) { f = d.colModel.editoptions.value } if (f) { var l = [], p = d.colModel.editoptions.multiple === true ? true : false, n = [], o; if (p) { n = h.split(","); n = c.map(n, function(i) { return c.trim(i) }) } if (isString(f)) { var e = f.split(";"), g = 0; for (var k = 0; k < e.length; k++) { o = e[k].split(":"); if (p) { if (jQuery.inArray(o[0], n) > -1) { l[g] = o[1]; g++ } } else { if (c.trim(o[0]) == c.trim(h)) { l[0] = o[1]; break } } } } else { if (isObject(f)) { if (p) { l = jQuery.map(n, function(q, j) { return f[q] }) } else { l[0] = f[h] || "" } } } return l.join(", ") } }; c.unformat = function(g, n, k, e) { var j, h = n.colModel.formatter, i = n.colModel.formatoptions || {}, o, m = /([\.\*\_\'\(\)\{\}\+\?\\])/g; unformatFunc = n.colModel.unformat || (c.fn.fmatter[h] && c.fn.fmatter[h].unformat); if (typeof unformatFunc !== "undefined" && isFunction(unformatFunc)) { j = unformatFunc(c(g).text(), n) } else { if (typeof h !== "undefined" && isString(h)) { var d = c.jgrid.formatter || {}, l; switch (h) { case "integer": i = c.extend({}, d.integer, i); o = i.thousandsSeparator.replace(m, "\\$1"); l = new RegExp(o, "g"); j = c(g).text().replace(l, ""); break; case "number": i = c.extend({}, d.number, i); o = i.thousandsSeparator.replace(m, "\\$1"); l = new RegExp(o, "g"); j = c(g).text().replace(i.decimalSeparator, ".").replace(l, ""); break; case "currency": i = c.extend({}, d.currency, i); o = i.thousandsSeparator.replace(m, "\\$1"); l = new RegExp(o, "g"); j = c(g).text().replace(i.decimalSeparator, ".").replace(i.prefix, "").replace(i.suffix, "").replace(l, ""); break; case "checkbox": var f = (n.colModel.editoptions) ? n.colModel.editoptions.value.split(":") : ["Yes", "No"]; j = c("input", g).attr("checked") ? f[0] : f[1]; break; case "select": j = c.unformat.select(g, n, k, e); break; default: j = c(g).text(); break } } } return j ? j : e === true ? c(g).text() : c.jgrid.htmlDecode(c(g).html()) }; c.unformat.select = function(h, s, n, e) { var m = []; var q = c(h).text(); if (e == true) { return q } var l = c.extend({}, s.colModel.editoptions); if (l.value) { var f = l.value, r = l.multiple === true ? true : false, p = [], o; if (r) { p = q.split(","); p = c.map(p, function(i) { return c.trim(i) }) } if (isString(f)) { var d = f.split(";"), g = 0; for (var k = 0; k < d.length; k++) { o = d[k].split(":"); if (r) { if (jQuery.inArray(o[1], p) > -1) { m[g] = o[0]; g++ } } else { if (c.trim(o[1]) == c.trim(q)) { m[0] = o[0]; break } } } } else { if (isObject(f)) { if (!r) { p[0] = q } m = jQuery.map(p, function(j) { var i; c.each(f, function(t, u) { if (u == j) { i = t; return false } }); if (i) { return i } }) } } return m.join(", ") } else { return q || "" } }; function a(h, i, g, d, e) { h = h.toLowerCase(); var f = i; if (c.fn.fmatter[h]) { f = c.fn.fmatter[h](i, g, e) } return f } function b(d) { if (window.console && window.console.log) { window.console.log(d) } } isValue = function(d) { return (isObject(d) || isString(d) || isNumber(d) || isBoolean(d)) }; isBoolean = function(d) { return typeof d === "boolean" }; isNull = function(d) { return d === null }; isNumber = function(d) { return typeof d === "number" && isFinite(d) }; isString = function(d) { return typeof d === "string" }; isEmpty = function(d) { if (!isString(d) && isValue(d)) { return false } else { if (!isValue(d)) { return true } } d = c.trim(d).replace(/\&nbsp\;/ig, "").replace(/\&#160\;/ig, ""); return d === "" }; isUndefined = function(d) { return typeof d === "undefined" }; isObject = function(d) { return (d && (typeof d === "object" || isFunction(d))) || false }; isFunction = function(d) { return typeof d === "function" } })(jQuery); (function(a) { a.fn.extend({ getColProp: function(d) { var b = {}, f = this[0]; if (!f.grid) { return } var e = f.p.colModel; for (var c = 0; c < e.length; c++) { if (e[c].name == d) { b = e[c]; break } } return b }, setColProp: function(c, b) { return this.each(function() { if (this.grid) { if (b) { var e = this.p.colModel; for (var d = 0; d < e.length; d++) { if (e[d].name == c) { a.extend(this.p.colModel[d], b); break } } } } }) }, sortGrid: function(c, b) { return this.each(function() { var g = this, d = -1; if (!g.grid) { return } if (!c) { c = g.p.sortname } for (var f = 0; f < g.p.colModel.length; f++) { if (g.p.colModel[f].index == c || g.p.colModel[f].name == c) { d = f; break } } if (d != -1) { var e = g.p.colModel[d].sortable; if (typeof e !== "boolean") { e = true } if (typeof b !== "boolean") { b = false } if (e) { g.sortData("jqgh_" + c, d, b) } } }) }, GridDestroy: function() { return this.each(function() { if (this.grid) { if (this.p.pager) { a(this.p.pager).remove() } var c = this.id; try { a("#gbox_" + c).remove() } catch (b) { } } }) }, GridUnload: function() { return this.each(function() { if (!this.grid) { return } var d = { id: a(this).attr("id"), cl: a(this).attr("class") }; if (this.p.pager) { a(this.p.pager).empty().removeClass("ui-state-default ui-jqgrid-pager corner-bottom") } var b = document.createElement("table"); a(b).attr({ id: d.id }); b.className = d.cl; var c = this.id; a(b).removeClass("ui-jqgrid-btable"); if (a(this.p.pager).parents("#gbox_" + c).length === 1) { a(b).insertBefore("#gbox_" + c).show(); a(this.p.pager).insertBefore("#gbox_" + c) } else { a(b).insertBefore("#gbox_" + c).show() } a("#gbox_" + c).remove() }) }, setGridState: function(b) { return this.each(function() { if (!this.grid) { return } $t = this; if (b == "hidden") { a(".ui-jqgrid-bdiv, .ui-jqgrid-hdiv", "#gview_" + $t.p.id).slideUp("fast"); if ($t.p.pager) { a($t.p.pager).slideUp("fast") } if ($t.p.toolbar[0] === true) { if ($t.p.toolbar[1] == "both") { a($t.grid.ubDiv).slideUp("fast") } a($t.grid.uDiv).slideUp("fast") } if ($t.p.footerrow) { a(".ui-jqgrid-sdiv", "#gbox_" + $s.p.id).slideUp("fast") } a(".ui-jqgrid-titlebar-close span", $t.grid.cDiv).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s"); $t.p.gridstate = "hidden" } else { if (b == "visible") { a(".ui-jqgrid-hdiv, .ui-jqgrid-bdiv", "#gview_" + $t.p.id).slideDown("fast"); if ($t.p.pager) { a($t.p.pager).slideDown("fast") } if ($t.p.toolbar[0] === true) { if ($t.p.toolbar[1] == "both") { a($t.grid.ubDiv).slideDown("fast") } a($t.grid.uDiv).slideDown("fast") } if ($t.p.footerrow) { a(".ui-jqgrid-sdiv", "#gbox_" + $t.p.id).slideDown("fast") } a(".ui-jqgrid-titlebar-close span", $t.grid.cDiv).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n"); $t.p.gridstate = "visible" } } }) }, updateGridRows: function(e, c, d) { var b, f = false; this.each(function() { var h = this, j, k, i, g; if (!h.grid) { return false } if (!c) { c = "id" } if (e && e.length > 0) { a(e).each(function(m) { i = this; k = h.rows.namedItem(i[c]); if (k) { g = i[c]; if (d === true) { if (h.p.jsonReader.repeatitems === true) { if (h.p.jsonReader.cell) { i = i[h.p.jsonReader.cell] } for (var l = 0; l < i.length; l++) { j = h.formatter(g, i[l], l, i, "edit"); if (h.p.treeGrid === true && b == h.p.ExpandColumn) { a("td:eq(" + l + ") > span:first", k).html(j).attr("title", a.jgrid.stripHtml(j)) } else { a("td:eq(" + l + ")", k).html(j).attr("title", a.jgrid.stripHtml(j)) } } f = true; return true } } a(h.p.colModel).each(function(n) { b = d === true ? this.jsonmap || this.name : this.name; if (i[b] != undefined) { j = h.formatter(g, i[b], n, i, "edit"); if (h.p.treeGrid === true && b == h.p.ExpandColumn) { a("td:eq(" + n + ") > span:first", k).html(j).attr("title", a.jgrid.stripHtml(j)) } else { a("td:eq(" + n + ")", k).html(j).attr("title", a.jgrid.stripHtml(j)) } f = true } }) } }) } }); return f }, filterGrid: function(c, b) { b = a.extend({ gridModel: false, gridNames: false, gridToolbar: false, filterModel: [], formtype: "horizontal", autosearch: true, formclass: "filterform", tableclass: "filtertable", buttonclass: "filterbutton", searchButton: "Search", clearButton: "Clear", enableSearch: false, enableClear: false, beforeSearch: null, afterSearch: null, beforeClear: null, afterClear: null, url: "", marksearched: true }, b || {}); return this.each(function() { var l = this; this.p = b; if (this.p.filterModel.length == 0 && this.p.gridModel === false) { alert("No filter is set"); return } if (!c) { alert("No target grid is set!"); return } this.p.gridid = c.indexOf("#") != -1 ? c : "#" + c; var d = a(this.p.gridid).getGridParam("colModel"); if (d) { if (this.p.gridModel === true) { var e = a(this.p.gridid)[0]; var g; a.each(d, function(o, p) { var m = []; this.search = this.search === false ? false : true; if (this.editrules && this.editrules.searchhidden === true) { g = true } else { if (this.hidden === true) { g = false } else { g = true } } if (this.search === true && g === true) { if (l.p.gridNames === true) { m.label = e.p.colNames[o] } else { m.label = "" } m.name = this.name; m.index = this.index || this.name; m.stype = this.edittype || "text"; if (m.stype != "select") { m.stype = "text" } m.defval = this.defval || ""; m.surl = this.surl || ""; m.sopt = this.editoptions || {}; m.width = this.width; l.p.filterModel.push(m) } }) } else { a.each(l.p.filterModel, function(o, p) { for (var m = 0; m < d.length; m++) { if (this.name == d[m].name) { this.index = d[m].index || this.name; break } } if (!this.index) { this.index = this.name } }) } } else { alert("Could not get grid colModel"); return } var h = function() { var q = {}, p = 0, n; var o = a(l.p.gridid)[0], m; o.p.searchdata = {}; if (a.isFunction(l.p.beforeSearch)) { l.p.beforeSearch() } a.each(l.p.filterModel, function(t, v) { m = this.index; switch (this.stype) { case "select": n = a("select[name=" + m + "]", l).val(); if (n) { q[m] = n; if (l.p.marksearched) { a("#jqgh_" + this.name, o.grid.hDiv).addClass("dirty-cell") } p++ } else { if (l.p.marksearched) { a("#jqgh_" + this.name, o.grid.hDiv).removeClass("dirty-cell") } try { delete o.p.postData[this.index] } catch (u) { } } break; default: n = a("input[name=" + m + "]", l).val(); if (n) { q[m] = n; if (l.p.marksearched) { a("#jqgh_" + this.name, o.grid.hDiv).addClass("dirty-cell") } p++ } else { if (l.p.marksearched) { a("#jqgh_" + this.name, o.grid.hDiv).removeClass("dirty-cell") } try { delete o.p.postData[this.index] } catch (u) { } } } }); var r = p > 0 ? true : false; a.extend(o.p.postData, q); var s; if (l.p.url) { s = a(o).getGridParam("url"); a(o).setGridParam({ url: l.p.url }) } a(o).setGridParam({ search: r, page: 1 }).trigger("reloadGrid"); if (s) { a(o).setGridParam({ url: s }) } if (a.isFunction(l.p.afterSearch)) { l.p.afterSearch() } }; var k = function() { var q = {}, n, p = 0; var o = a(l.p.gridid)[0], m; if (a.isFunction(l.p.beforeClear)) { l.p.beforeClear() } a.each(l.p.filterModel, function(t, w) { m = this.index; n = (this.defval) ? this.defval : ""; if (!this.stype) { this.stype == "text" } switch (this.stype) { case "select": var v; a("select[name=" + m + "] option", l).each(function(x) { if (x == 0) { this.selected = true } if (a(this).text() == n) { this.selected = true; v = a(this).val(); return false } }); if (v) { q[m] = v; if (l.p.marksearched) { a("#jqgh_" + this.name, o.grid.hDiv).addClass("dirty-cell") } p++ } else { if (l.p.marksearched) { a("#jqgh_" + this.name, o.grid.hDiv).removeClass("dirty-cell") } try { delete o.p.postData[this.index] } catch (u) { } } break; case "text": a("input[name=" + m + "]", l).val(n); if (n) { q[m] = n; if (l.p.marksearched) { a("#jqgh_" + this.name, o.grid.hDiv).addClass("dirty-cell") } p++ } else { if (l.p.marksearched) { a("#jqgh_" + this.name, o.grid.hDiv).removeClass("dirty-cell") } try { delete o.p.postData[this.index] } catch (u) { } } break } }); var r = p > 0 ? true : false; a.extend(o.p.postData, q); var s; if (l.p.url) { s = a(o).getGridParam("url"); a(o).setGridParam({ url: l.p.url }) } a(o).setGridParam({ search: r, page: 1 }).trigger("reloadGrid"); if (s) { a(o).setGridParam({ url: s }) } if (a.isFunction(l.p.afterClear)) { l.p.afterClear() } }; var i = function() { var q = document.createElement("tr"); var n, s, m, o, r, p; if (l.p.formtype == "horizontal") { a(f).append(q) } a.each(l.p.filterModel, function(A, v) { o = document.createElement("td"); a(o).append("<label for='" + this.name + "'>" + this.label + "</label>"); r = document.createElement("td"); var z = this; if (!this.stype) { this.stype = "text" } switch (this.stype) { case "select": if (this.surl) { a(r).load(this.surl, function() { if (z.defval) { a("select", this).val(z.defval) } a("select", this).attr({ name: z.index || z.name, id: "sg_" + z.name }); if (z.sopt) { a("select", this).attr(z.sopt) } if (l.p.gridToolbar === true && z.width) { a("select", this).width(z.width) } if (l.p.autosearch === true) { a("select", this).change(function(E) { h(); return false }) } }) } else { if (z.sopt.value) { var t = z.sopt.value; var w = document.createElement("select"); a(w).attr({ name: z.index || z.name, id: "sg_" + z.name }).attr(z.sopt); if (typeof t === "string") { var u = t.split(";"), D, x; for (var y = 0; y < u.length; y++) { D = u[y].split(":"); x = document.createElement("option"); x.value = D[0]; x.innerHTML = D[1]; if (D[1] == z.defval) { x.selected = "selected" } w.appendChild(x) } } else { if (typeof t === "object") { for (var C in t) { A++; x = document.createElement("option"); x.value = C; x.innerHTML = t[C]; if (t[C] == z.defval) { x.selected = "selected" } w.appendChild(x) } } } if (l.p.gridToolbar === true && z.width) { a(w).width(z.width) } a(r).append(w); if (l.p.autosearch === true) { a(w).change(function(E) { h(); return false }) } } } break; case "text": var B = this.defval ? this.defval : ""; a(r).append("<input type='text' name='" + (this.index || this.name) + "' id='sg_" + this.name + "' value='" + B + "'/>"); if (z.sopt) { a("input", r).attr(z.sopt) } if (l.p.gridToolbar === true && z.width) { if (a.browser.msie) { a("input", r).width(z.width - 4) } else { a("input", r).width(z.width - 2) } } if (l.p.autosearch === true) { a("input", r).keypress(function(F) { var E = F.charCode ? F.charCode : F.keyCode ? F.keyCode : 0; if (E == 13) { h(); return false } return this }) } break } if (l.p.formtype == "horizontal") { if (l.p.gridToolbar === true && l.p.gridNames === false) { a(q).append(r) } else { a(q).append(o).append(r) } a(q).append(r) } else { n = document.createElement("tr"); a(n).append(o).append(r); a(f).append(n) } }); r = document.createElement("td"); if (l.p.enableSearch === true) { s = "<input type='button' id='sButton' class='" + l.p.buttonclass + "' value='" + l.p.searchButton + "'/>"; a(r).append(s); a("input#sButton", r).click(function() { h(); return false }) } if (l.p.enableClear === true) { m = "<input type='button' id='cButton' class='" + l.p.buttonclass + "' value='" + l.p.clearButton + "'/>"; a(r).append(m); a("input#cButton", r).click(function() { k(); return false }) } if (l.p.enableClear === true || l.p.enableSearch === true) { if (l.p.formtype == "horizontal") { a(q).append(r) } else { n = document.createElement("tr"); a(n).append("<td>&nbsp;</td>").append(r); a(f).append(n) } } }; var j = a("<form name='SearchForm' style=display:inline;' class='" + this.p.formclass + "'></form>"); var f = a("<table class='" + this.p.tableclass + "' cellspacing='0' cellpading='0' border='0'><tbody></tbody></table>"); a(j).append(f); i(); a(this).append(j); this.triggerSearch = function() { h() }; this.clearSearch = function() { k() } }) }, filterToolbar: function(b) { b = a.extend({ autosearch: true, beforeSearch: null, afterSearch: null, beforeClear: null, afterClear: null, searchurl: "" }, b || {}); return this.each(function() { var g = this; var c = function() { var o = {}, n = 0, m, l; g.p.searchdata = {}; if (a.isFunction(b.beforeSearch)) { b.beforeSearch() } a.each(g.p.colModel, function(r, t) { l = this.index || this.name; switch (this.stype) { case "select": m = a("select[name=" + l + "]", g.grid.hDiv).val(); if (m) { o[l] = m; n++ } else { try { delete g.p.postData[l] } catch (s) { } } break; case "text": m = a("input[name=" + l + "]", g.grid.hDiv).val(); if (m) { o[l] = m; n++ } else { try { delete g.p.postData[l] } catch (s) { } } break } }); var p = n > 0 ? true : false; a.extend(g.p.postData, o); var q; if (g.p.searchurl) { q = g.p.url; a(g).setGridParam({ url: g.p.searchurl }) } a(g).setGridParam({ search: p, page: 1 }).trigger("reloadGrid"); if (q) { a(g).setGridParam({ url: q }) } if (a.isFunction(b.afterSearch)) { b.afterSearch() } }; var j = function() { var o = {}, m, n = 0, l; if (a.isFunction(b.beforeClear)) { b.beforeClear() } a.each(g.p.colModel, function(r, u) { m = (this.searchoptions && this.searchoptions.defaultValue) ? this.searchoptions.defaultValue : ""; l = this.index || this.name; switch (this.stype) { case "select": var t; a("select[name=" + l + "] option", g.grid.hDiv).each(function(v) { if (v == 0) { this.selected = true } if (a(this).text() == m) { this.selected = true; t = a(this).val(); return false } }); if (t) { o[l] = t; n++ } else { try { delete g.p.postData[l] } catch (s) { } } break; case "text": a("input[name=" + l + "]", g.grid.hDiv).val(m); if (m) { o[l] = m; n++ } else { try { delete g.p.postData[l] } catch (s) { } } break } }); var p = n > 0 ? true : false; a.extend(g.p.postData, o); var q; if (g.p.searchurl) { q = g.p.url; a(g).setGridParam({ url: g.p.searchurl }) } a(g).setGridParam({ search: p, page: 1 }).trigger("reloadGrid"); if (q) { a(g).setGridParam({ url: q }) } if (a.isFunction(b.afterClear)) { b.afterClear() } }; var k = function() { var l = a("tr.ui-search-toolbar", g.grid.hDiv); if (l.css("display") == "none") { l.show() } else { l.hide() } }; function f(l, n) { var m = a(l); if (m[0] != null) { jQuery.each(n, function() { if (this.data != null) { m.bind(this.type, this.data, this.fn) } else { m.bind(this.type, this.fn) } }) } } var h = a("<tr class='ui-search-toolbar' role='rowheader'></tr>"), d, i, e; a.each(g.p.colModel, function(s, o) { var u = this; d = a("<th role='columnheader' class='ui-state-default ui-th-column'></th>"); i = a("<div style='width:100%;position:relative;height:100%;padding-right:0.3em;'></div>"); if (this.hidden === true) { a(d).css("display", "none") } this.search = this.search === false ? false : true; if (typeof this.stype == "undefined") { this.stype = "text" } e = a.extend({}, this.searchoptions || {}); if (this.search) { switch (this.stype) { case "select": if (this.surl) { a(i).load(this.surl, { _nsd: (new Date().getTime()) }, function() { if (e.defaultValue) { a("select", this).val(e.defaultValue) } a("select", this).attr({ name: u.index || u.name, id: "gs_" + u.name }); if (e.attr) { a("select", this).attr(e.attr) } a("select", this).css({ width: "100%" }); if (e.dataInit != null) { e.dataInit(a("select", this)[0]) } if (e.dataEvents != null) { f(a("select", this)[0], e.dataEvents) } if (b.autosearch === true) { a("select", this).change(function(n) { c(); return false }) } }) } else { if (u.editoptions && u.editoptions.value) { var l = u.editoptions.value, p = document.createElement("select"); p.style.width = "100%"; a(p).attr({ name: u.index || u.name, id: "gs_" + u.name }); if (typeof l === "string") { var m = l.split(";"), w, q; for (var r = 0; r < m.length; r++) { w = m[r].split(":"); q = document.createElement("option"); q.value = w[0]; q.innerHTML = w[1]; p.appendChild(q) } } else { if (typeof l === "object") { for (var v in l) { s++; q = document.createElement("option"); q.value = v; q.innerHTML = l[v]; p.appendChild(q) } } } if (e.defaultValue) { a(p).val(e.defaultValue) } if (e.attr) { a(p).attr(e.attr) } if (e.dataInit != null) { e.dataInit(p) } if (e.dataEvents != null) { f(p, e.dataEvents) } a(i).append(p); if (b.autosearch === true) { a(p).change(function(n) { c(); return false }) } } } break; case "text": var t = e.defaultValue ? e.defaultValue : ""; a(i).append("<input type='text' style='width:95%;padding:0px;' name='" + (u.index || u.name) + "' id='gs_" + u.name + "' value='" + t + "'/>"); if (e.attr) { a("input", i).attr(e.attr) } if (e.dataInit != null) { e.dataInit(a("input", i)[0]) } if (e.dataEvents != null) { f(a("input", i)[0], e.dataEvents) } if (b.autosearch === true) { a("input", i).keypress(function(x) { var n = x.charCode ? x.charCode : x.keyCode ? x.keyCode : 0; if (n == 13) { c(); return false } return this }) } break } } a(d).append(i); a(h).append(d) }); a("table thead", g.grid.hDiv).append(h); this.triggerToolbar = function() { c() }; this.clearToolbar = function() { j() }; this.toggleToolbar = function() { k() } }) } }) })(jQuery); (function(a) { a.fn.extend({ jqGridImport: function(b) { b = a.extend({ imptype: "xml", impstring: "", impurl: "", mtype: "GET", impData: {}, xmlGrid: { config: "roots>grid", data: "roots>rows" }, jsonGrid: { config: "grid", data: "data"} }, b || {}); return this.each(function() { var f = this; var d = function(h, m) { var g = a(m.xmlGrid.config, h)[0]; var l = a(m.xmlGrid.data, h)[0]; if (xmlJsonClass.xml2json && a.jgrid.parse) { var n = xmlJsonClass.xml2json(g, " "); var n = a.jgrid.parse(n); for (var i in n) { var j = n[i] } if (l) { var k = n.grid.datatype; n.grid.datatype = "xmlstring"; n.grid.datastr = h; a(f).jqGrid(j).setGridParam({ datatype: k }) } else { a(f).jqGrid(j) } n = null; j = null } else { alert("xml2json or parse are not present") } }; var e = function(h, k) { if (h && typeof h == "string") { var g = a.jgrid.parse(h); var l = g[k.jsonGrid.config]; var i = g[k.jsonGrid.data]; if (i) { var j = l.datatype; l.datatype = "jsonstring"; l.datastr = i; a(f).jqGrid(l).setGridParam({ datatype: j }) } else { a(f).jqGrid(l) } } }; switch (b.imptype) { case "xml": a.ajax({ url: b.impurl, type: b.mtype, data: b.impData, dataType: "xml", complete: function(g, h) { if (h == "success") { d(g.responseXML, b); if (a.isFunction(b.importComplete)) { b.importComplete(g) } } g = null } }); break; case "xmlstring": if (b.impstring && typeof b.impstring == "string") { var c = a.jgrid.stringToDoc(b.impstring); if (c) { d(c, b); if (a.isFunction(b.importComplete)) { b.importComplete(c) } b.impstring = null } c = null } break; case "json": a.ajax({ url: b.impurl, type: b.mtype, data: b.impData, dataType: "json", complete: function(g, h) { if (h == "success") { e(g.responseText, b); if (a.isFunction(b.importComplete)) { b.importComplete(g) } } g = null } }); break; case "jsonstring": if (b.impstring && typeof b.impstring == "string") { e(b.impstring, b); if (a.isFunction(b.importComplete)) { b.importComplete(b.impstring) } b.impstring = null } break } }) }, jqGridExport: function(c) { c = a.extend({ exptype: "xmlstring", root: "grid", ident: "\t" }, c || {}); var b = null; this.each(function() { if (!this.grid) { return } var e = a(this).getGridParam(); if (e.rownumbers) { e.colNames.splice(0); e.colModel.splice(0) } if (e.multiselect) { e.colNames.splice(0); e.colModel.splice(0) } if (e.subgrid) { e.colNames.splice(0); e.colModel.splice(0) } if (e.treeGrid) { for (var d in e.treeReader) { e.colNames.splice(e.colNames.length - 1); e.colModel.splice(e.colModel.length - 1) } } switch (c.exptype) { case "xmlstring": b = "<" + c.root + ">" + xmlJsonClass.json2xml(e, c.ident) + "</" + c.root + ">"; break; case "jsonstring": b = "{" + xmlJsonClass.toJson(e, c.root, c.ident) + "}"; break } }); return b } }) })(jQuery); var xmlJsonClass = { xml2json: function(b, d) { if (b.nodeType === 9) { b = b.documentElement } var a = this.removeWhite(b); var e = this.toObj(a); var c = this.toJson(e, b.nodeName, "\t"); return "{\n" + d + (d ? c.replace(/\t/g, d) : c.replace(/\t|\n/g, "")) + "\n}" }, json2xml: function(d, c) { var e = function(q, f, h) { var o = ""; var l, g; if (q instanceof Array) { if (q.length === 0) { o += h + "<" + f + ">__EMPTY_ARRAY_</" + f + ">\n" } else { for (l = 0, g = q.length; l < g; l += 1) { var p = h + e(q[l], f, h + "\t") + "\n"; o += p } } } else { if (typeof (q) === "object") { var k = false; o += h + "<" + f; var j; for (j in q) { if (q.hasOwnProperty(j)) { if (j.charAt(0) === "@") { o += " " + j.substr(1) + '="' + q[j].toString() + '"' } else { k = true } } } o += k ? ">" : "/>"; if (k) { for (j in q) { if (q.hasOwnProperty(j)) { if (j === "#text") { o += q[j] } else { if (j === "#cdata") { o += "<![CDATA[" + q[j] + "]]>" } else { if (j.charAt(0) !== "@") { o += e(q[j], j, h + "\t") } } } } } o += (o.charAt(o.length - 1) === "\n" ? h : "") + "</" + f + ">" } } else { if (typeof (q) === "function") { o += h + "<" + f + "><![CDATA[" + q + "]]></" + f + ">" } else { if (q.toString() === '""' || q.toString().length === 0) { o += h + "<" + f + ">__EMPTY_STRING_</" + f + ">" } else { o += h + "<" + f + ">" + q.toString() + "</" + f + ">" } } } } return o }; var b = ""; var a; for (a in d) { if (d.hasOwnProperty(a)) { b += e(d[a], a, "") } } return c ? b.replace(/\t/g, c) : b.replace(/\t|\n/g, "") }, toObj: function(b) { var g = {}; var f = /function/i; if (b.nodeType === 1) { if (b.attributes.length) { var e; for (e = 0; e < b.attributes.length; e += 1) { g["@" + b.attributes[e].nodeName] = (b.attributes[e].nodeValue || "").toString() } } if (b.firstChild) { var a = 0, d = 0, c = false; var h; for (h = b.firstChild; h; h = h.nextSibling) { if (h.nodeType === 1) { c = true } else { if (h.nodeType === 3 && h.nodeValue.match(/[^ \f\n\r\t\v]/)) { a += 1 } else { if (h.nodeType === 4) { d += 1 } } } } if (c) { if (a < 2 && d < 2) { this.removeWhite(b); for (h = b.firstChild; h; h = h.nextSibling) { if (h.nodeType === 3) { g["#text"] = this.escape(h.nodeValue) } else { if (h.nodeType === 4) { if (f.test(h.nodeValue)) { g[h.nodeName] = [g[h.nodeName], h.nodeValue] } else { g["#cdata"] = this.escape(h.nodeValue) } } else { if (g[h.nodeName]) { if (g[h.nodeName] instanceof Array) { g[h.nodeName][g[h.nodeName].length] = this.toObj(h) } else { g[h.nodeName] = [g[h.nodeName], this.toObj(h)] } } else { g[h.nodeName] = this.toObj(h) } } } } } else { if (!b.attributes.length) { g = this.escape(this.innerXml(b)) } else { g["#text"] = this.escape(this.innerXml(b)) } } } else { if (a) { if (!b.attributes.length) { g = this.escape(this.innerXml(b)); if (g === "__EMPTY_ARRAY_") { g = "[]" } else { if (g === "__EMPTY_STRING_") { g = "" } } } else { g["#text"] = this.escape(this.innerXml(b)) } } else { if (d) { if (d > 1) { g = this.escape(this.innerXml(b)) } else { for (h = b.firstChild; h; h = h.nextSibling) { if (f.test(b.firstChild.nodeValue)) { g = b.firstChild.nodeValue; break } else { g["#cdata"] = this.escape(h.nodeValue) } } } } } } } if (!b.attributes.length && !b.firstChild) { g = null } } else { if (b.nodeType === 9) { g = this.toObj(b.documentElement) } else { alert("unhandled node type: " + b.nodeType) } } return g }, toJson: function(b, a, d) { var j = a ? ('"' + a + '"') : ""; if (b === "[]") { j += (a ? ":[]" : "[]") } else { if (b instanceof Array) { var c, f; for (f = 0, c = b.length; f < c; f += 1) { b[f] = this.toJson(b[f], "", d + "\t") } j += (a ? ":[" : "[") + (b.length > 1 ? ("\n" + d + "\t" + b.join(",\n" + d + "\t") + "\n" + d) : b.join("")) + "]" } else { if (b === null) { j += (a && ":") + "null" } else { if (typeof (b) === "object") { var g = []; var e; for (e in b) { if (b.hasOwnProperty(e)) { g[g.length] = this.toJson(b[e], e, d + "\t") } } j += (a ? ":{" : "{") + (g.length > 1 ? ("\n" + d + "\t" + g.join(",\n" + d + "\t") + "\n" + d) : g.join("")) + "}" } else { if (typeof (b) === "string") { var h = /(^-?\d+\.?\d*$)/; var k = /function/i; b = b.toString(); if (h.test(b) || k.test(b) || b === "false" || b === "true") { j += (a && ":") + b } else { j += (a && ":") + '"' + b + '"' } } else { j += (a && ":") + b.toString() } } } } } return j }, innerXml: function(d) { var b = ""; if ("innerHTML" in d) { b = d.innerHTML } else { var a = function(j) { var g = "", f; if (j.nodeType === 1) { g += "<" + j.nodeName; for (f = 0; f < j.attributes.length; f += 1) { g += " " + j.attributes[f].nodeName + '="' + (j.attributes[f].nodeValue || "").toString() + '"' } if (j.firstChild) { g += ">"; for (var h = j.firstChild; h; h = h.nextSibling) { g += a(h) } g += "</" + j.nodeName + ">" } else { g += "/>" } } else { if (j.nodeType === 3) { g += j.nodeValue } else { if (j.nodeType === 4) { g += "<![CDATA[" + j.nodeValue + "]]>" } } } return g }; for (var e = d.firstChild; e; e = e.nextSibling) { b += a(e) } } return b }, escape: function(a) { return a.replace(/[\\]/g, "\\\\").replace(/[\"]/g, '\\"').replace(/[\n]/g, "\\n").replace(/[\r]/g, "\\r") }, removeWhite: function(b) { b.normalize(); var c; for (c = b.firstChild; c; ) { if (c.nodeType === 3) { if (!c.nodeValue.match(/[^ \f\n\r\t\v]/)) { var a = c.nextSibling; b.removeChild(c); c = a } else { c = c.nextSibling } } else { if (c.nodeType === 1) { this.removeWhite(c); c = c.nextSibling } else { c = c.nextSibling } } } return b } };

/*
This license is based on the new BSD template found here 
(http://www.opensource.org/licenses/bsd-license.php)
  
-----------------------------------------------------------------
CodeIncubator (http://codeincubator.com)
Copyright (c) 2009 
by Steven Harman (http://stevenharman.net)
  
All rights reserved.
  
Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:
  
*	Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.
*	Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation 
and/or other materials provided with the distribution.
*	Neither the name of the CodeIncubator nor the names of its contributors 
may be used to endorse or promote products derived from this software 
without specific prior written permission.
  
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/*
Options:
example - a valid jQuery selector for the DOM element the grid will use to get a new base size
offset - the number of pixels added to the width of the example element, giving the grid its new width

Usage:
  
// make #theGrid 10 pixles smaller than #grid_wrapper
$("#theGrid").fluidGrid({ example:"#grid_wrapper", offset:-10 });
  
More Info: http://stevenharman.net/blog/archive/2009/08/21/creating-a-fluid-jquery-jqgrid.aspx
  
*/

jQuery.jgrid.fluid = { fluidGrid: function(a) { var b = $(this); var c = $.extend({ example: b.closest('.ui-jqgrid').parent(), offset: 0 }, a || {}); var d = $(c.example).innerWidth() + c.offset; b.setGridWidth(d) } }
$.fn.extend({ fluidGrid: jQuery.jgrid.fluid.fluidGrid });

/**
* jQuery.ScrollTo - Easy element scrolling using jQuery.
* Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 5/25/2009
* @author Ariel Flesler
* @version 1.4.2
*
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
*/
; (function(d) { var k = d.scrollTo = function(a, i, e) { d(window).scrollTo(a, i, e) }; k.defaults = { axis: 'xy', duration: parseFloat(d.fn.jquery) >= 1.3 ? 0 : 1 }; k.window = function(a) { return d(window)._scrollable() }; d.fn._scrollable = function() { return this.map(function() { var a = this, i = !a.nodeName || d.inArray(a.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1; if (!i) return a; var e = (a.contentWindow || a).document || a.ownerDocument || a; return d.browser.safari || e.compatMode == 'BackCompat' ? e.body : e.documentElement }) }; d.fn.scrollTo = function(n, j, b) { if (typeof j == 'object') { b = j; j = 0 } if (typeof b == 'function') b = { onAfter: b }; if (n == 'max') n = 9e9; b = d.extend({}, k.defaults, b); j = j || b.speed || b.duration; b.queue = b.queue && b.axis.length > 1; if (b.queue) j /= 2; b.offset = p(b.offset); b.over = p(b.over); return this._scrollable().each(function() { var q = this, r = d(q), f = n, s, g = {}, u = r.is('html,body'); switch (typeof f) { case 'number': case 'string': if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)) { f = p(f); break } f = d(f, this); case 'object': if (f.is || f.style) s = (f = d(f)).offset() } d.each(b.axis.split(''), function(a, i) { var e = i == 'x' ? 'Left' : 'Top', h = e.toLowerCase(), c = 'scroll' + e, l = q[c], m = k.max(q, i); if (s) { g[c] = s[h] + (u ? 0 : l - r.offset()[h]); if (b.margin) { g[c] -= parseInt(f.css('margin' + e)) || 0; g[c] -= parseInt(f.css('border' + e + 'Width')) || 0 } g[c] += b.offset[h] || 0; if (b.over[h]) g[c] += f[i == 'x' ? 'width' : 'height']() * b.over[h] } else { var o = f[h]; g[c] = o.slice && o.slice(-1) == '%' ? parseFloat(o) / 100 * m : o } if (/^\d+$/.test(g[c])) g[c] = g[c] <= 0 ? 0 : Math.min(g[c], m); if (!a && b.queue) { if (l != g[c]) t(b.onAfterFirst); delete g[c] } }); t(b.onAfter); function t(a) { r.animate(g, j, b.easing, a && function() { a.call(this, n, b) }) } }).end() }; k.max = function(a, i) { var e = i == 'x' ? 'Width' : 'Height', h = 'scroll' + e; if (!d(a).is('html,body')) return a[h] - d(a)[e.toLowerCase()](); var c = 'client' + e, l = a.ownerDocument.documentElement, m = a.ownerDocument.body; return Math.max(l[h], m[h]) - Math.min(l[c], m[c]) }; function p(a) { return typeof a == 'object' ? a : { top: a, left: a} } })(jQuery);

/**
* jQuery.LocalScroll - Animated scrolling navigation, using anchors.
* Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 3/11/2009
* @author Ariel Flesler
* @version 1.2.7
**/
; (function($) { var l = location.href.replace(/#.*/, ''); var g = $.localScroll = function(a) { $('body').localScroll(a) }; g.defaults = { duration: 1e3, axis: 'y', event: 'click', stop: true, target: window, reset: true }; g.hash = function(a) { if (location.hash) { a = $.extend({}, g.defaults, a); a.hash = false; if (a.reset) { var e = a.duration; delete a.duration; $(a.target).scrollTo(0, a); a.duration = e } i(0, location, a) } }; $.fn.localScroll = function(b) { b = $.extend({}, g.defaults, b); return b.lazy ? this.bind(b.event, function(a) { var e = $([a.target, a.target.parentNode]).filter(d)[0]; if (e) i(a, e, b) }) : this.find('a,area').filter(d).bind(b.event, function(a) { i(a, this, b) }).end().end(); function d() { return !!this.href && !!this.hash && this.href.replace(this.hash, '') == l && (!b.filter || $(this).is(b.filter)) } }; function i(a, e, b) { var d = e.hash.slice(1), f = document.getElementById(d) || document.getElementsByName(d)[0]; if (!f) return; if (a) a.preventDefault(); var h = $(b.target); if (b.lock && h.is(':animated') || b.onBefore && b.onBefore.call(b, a, f, h) === false) return; if (b.stop) h.stop(true); if (b.hash) { var j = f.id == d ? 'id' : 'name', k = $('<a> </a>').attr(j, d).css({ position: 'absolute', top: $(window).scrollTop(), left: $(window).scrollLeft() }); f[j] = ''; $('body').prepend(k); location = e.hash; k.remove(); f[j] = d } h.scrollTo(f, b).trigger('notify.serialScroll', [f]) } })(jQuery);
/**
* jQuery.timers - Timer abstractions for jQuery
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
* Date: 2009/08/13
*
* @author Blair Mitchelmore
* @version 1.1.3
*
**/
jQuery.fn.extend({ everyTime: function(a, b, c, d, e) { return this.each(function() { jQuery.timer.add(this, a, b, c, d, e) }) }, oneTime: function(a, b, c) { return this.each(function() { jQuery.timer.add(this, a, b, c, 1) }) }, stopTime: function(a, b) { return this.each(function() { jQuery.timer.remove(this, a, b) }) } }); jQuery.extend({ timer: { global: [], guid: 1, dataKey: "jQuery.timer", regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/, powers: { 'ms': 1, 'cs': 10, 'ds': 100, 's': 1000, 'das': 10000, 'hs': 100000, 'ks': 1000000 }, timeParse: function(a) { if (a == undefined || a == null) return null; var b = this.regex.exec(jQuery.trim(a.toString())); if (b[2]) { var c = parseFloat(b[1]); var d = this.powers[b[2]] || 1; return c * d } else { return a } }, add: function(a, b, c, d, e, f) { var g = 0; if (jQuery.isFunction(c)) { if (!e) e = d; d = c; c = b } b = jQuery.timer.timeParse(b); if (typeof b != 'number' || isNaN(b) || b <= 0) return; if (e && e.constructor != Number) { f = !!e; e = 0 } e = e || 0; f = f || false; var h = jQuery.data(a, this.dataKey) || jQuery.data(a, this.dataKey, {}); if (!h[c]) h[c] = {}; d.timerID = d.timerID || this.guid++; var i = function() { if (f && this.inProgress) return; this.inProgress = true; if ((++g > e && e !== 0) || d.call(a, g) === false) jQuery.timer.remove(a, c, d); this.inProgress = false }; i.timerID = d.timerID; if (!h[c][d.timerID]) h[c][d.timerID] = window.setInterval(i, b); this.global.push(a) }, remove: function(a, b, c) { var d = jQuery.data(a, this.dataKey), ret; if (d) { if (!b) { for (b in d) this.remove(a, b, c) } else if (d[b]) { if (c) { if (c.timerID) { window.clearInterval(d[b][c.timerID]); delete d[b][c.timerID] } } else { for (var c in d[b]) { window.clearInterval(d[b][c]); delete d[b][c] } } for (ret in d[b]) break; if (!ret) { ret = null; delete d[b] } } for (ret in d) break; if (!ret) jQuery.removeData(a, this.dataKey) } } } }); jQuery(window).bind("unload", function() { jQuery.each(jQuery.timer.global, function(a, b) { jQuery.timer.remove(b) }) });
/*
* jQuery Disable On Submit Plugin
* http://www.evanbot.com/article/jquery-disable-on-submit-plugin/13
*
* Copyright (c) 2009 Evan Byrne (http://www.evanbot.com)     
*/
$.fn.disableOnSubmit = function(a) { if (a == null) { var b = 'input[type=submit],input[type=button],input[type=reset],button' } else { var b = a } $(this).find(b).removeAttr('disabled'); $(this).submit(function() { $(this).find(b).attr('disabled', 'disabled') }); return this };


/* stopwatch */
/**
* This file defines the Stopwatch class.
* Note that it knows nothing about instances and how those instances are used.
*/
var Stopwatch;
if (!Stopwatch)
    Stopwatch = {};

/**
* Constructs a new Stopwatch instance.
* @param {Object} displayTime the strategy for displaying the time
*/
function Stopwatch(displayTime, txtBoxSelector) {
    this.runtime = 0; // milliseconds
    this.timer = null; // nonnull iff runnig
    this.displayTime = displayTime; // not showing runtime anywhere
    this.txtBoxSelector = txtBoxSelector;
}

/**
* The increment in milliseconds.
* (This is a class variable shared by all Stopwatch instances.)
*/
Stopwatch.INCREMENT = 200

/**
* Displays the time using the appropriate display strategy.
*/
Stopwatch.prototype.doDisplay = function() {
    if (!this.laptime)
        this.displayTime(this.runtime);
    else
        this.displayTime(this.laptime);
}

/**
* Handles an incoming start/stop event.
*/
Stopwatch.prototype.startStop = function() {
    if (!this.timer) {
        var instance = this;
        this.timer = window.setInterval(function() {
            instance.runtime += Stopwatch.INCREMENT;
            instance.doDisplay();
        }, Stopwatch.INCREMENT);
    }
    else {
        window.clearInterval(this.timer);
        this.timer = null;
        this.doDisplay();
    }
}

/**
* Handles an incoming reset/lap event.
*/
Stopwatch.prototype.resetLap = function() {
    if (!this.laptime) {
        if (this.timer) {
            this.laptime = this.runtime;
        }
        else {
            this.runtime = 0;
        }
    }
    else {
        delete this.laptime;
    }
    this.doDisplay();
}
