util.js

jQuery.extend({ parseJSON: function (data) {
    if (typeof data !== "string" || !data) {
        return null;
    }

// Make sure leading/trailing whitespace is removed (IE can‘t handle it)
    data = jQuery.trim(data);

try {
        // Try to use the native JSON parser first
        //return window.JSON && window.JSON.parse ?
        //    window.JSON.parse( data ) : (new Function("return " + data))();
        return (new Function("return " + data))();

} catch (e) {
        alert("无效的JSON数据: " + e);
        jQuery.error("Invalid JSON: " + data);
    }
}
});

//String.prototype.trim=function(){return this.replace(/(^\s+)|\s+$/g,"")}
var PICKER;
function RegisterCallBack() {//for Page Init
    if (typeof (OverrideObject) == "function")
        OverrideObject();
    if (typeof (OverridePostBack) == "function")
        __doPostBack = OverridePostBack;

//    if (typeof (PICKER) == ‘undefined‘ && typeof (Picker) == ‘function‘) {
//        PICKER = new Picker();
//    }
    if (typeof (PageOnLoad) == "function")
        window.setTimeout(function () { PageOnLoad(); }, 100);
    if (window.location.href.indexOf(‘callback=‘) > 0) {
        var timeout = parseInt(UTIL.getUrlParam(‘callbackTimeout‘)); //延时调用
        if (isNaN(timeout)) timeout = 0;

var cb = ‘window.parent.‘ + UTIL.getUrlParam(‘callback‘); //callback父页
        if (cb.indexOf(‘(‘) < 0) cb = cb + ‘(window)‘; //若无参数,自动带入默认参数
        setTimeout(cb, timeout); //eval(cb);
    }
    //UTIL.dev();
}

////重载 __doPostBack
function OverridePostBack(eventTarget, eventArgument) {
    if (document.forms.length > 0) {
        if (typeof eventTarget == ‘object‘) eventTarget = $(eventTarget.target).attr(‘id‘);
        var f = document.forms[0];
        if (typeof f.__EVENTTARGET != ‘undefined‘) {
            f.__EVENTTARGET.value = eventTarget;
            f.__EVENTARGUMENT.value = eventArgument;
        }
        if (GlobalOnSubmit(eventTarget)) {//dispatch
            if (eventTarget.indexOf(‘$‘) < 0 && eventTarget.indexOf(‘E8‘) < 0) {//GridView事件?
                var evt = $(‘#‘ + eventTarget).not(‘INPUT,SELECT‘);
                if (evt.find(‘INPUT:eq(0)‘).length == 0)//内部无INPUT?
                    evt.attr(‘disabled‘, true).css({ ‘color‘: ‘#cccccc‘ }); //disabled它
            }
            f.submit();
        }
    }
}
function GlobalOnSubmit(srcId)//dom el
{
    if (srcId != ‘‘) {//btn_***_D*E*
        if (typeof (PageOnSubmit) == "function" && PageOnSubmit(srcId) == false) return false;

var iD = srcId.lastIndexOf(‘_D‘);
        if (iD > 0)
            var dataTag = parseInt(srcId.substring(iD + 2, iD + 3));
        if (isNaN(dataTag)) dataTag = undefined;

if (srcId.indexOf(‘E0‘) > -1) {//Validate
            return BindingControl.validate(dataTag > 0 ? dataTag : 0);
        }
        else if (srcId.indexOf(‘btn_Del‘) > -1) {
            dataTag = (dataTag > -1) ? dataTag : ‘‘;
            var sId = UTIL.getId(dataTag);
            if (sId && window.confirm(UTIL.getMessage(‘CLTMSG_BE_DELETE_ROW‘))) {
                $(‘#‘ + srcId).after(‘<input type="hidden" name="Id" value="‘ + sId + ‘"/>‘);
                return true;
            } else
                return false;
        }
    }

return true;
}
//-------------------------UTIL control--------------------------------------
var UTIL = new function () {
    this.SetDict = function (obj, dicType) {
        obj.combogrid({
            panelWidth: 250,
            idField: ‘Code‘,
            textField: ‘Name‘,
            url: ‘/Common/EntityJsonList.ashx?_method=dict&dictType=‘ + dicType + "&tmp=" + Math.random(),
            method: ‘get‘,
            columns: [[
                    { field: ‘Name‘, title: ‘名称‘, width: 100 },
                    { field: ‘Code‘, title: ‘编码‘, width: 100 }
                ]]
        });
    }
    this.popupDiv = function (div_id, width, height) {
        var div_obj = $("#" + div_id);
        var windowWidth = document.body.clientWidth;
        var windowHeight = document.body.clientHeight;
        //        var popupHeight = div_obj.height();
        //        var popupWidth = div_obj.width();

var popupHeight = height;
        var popupWidth = width;
        //添加并显示遮罩层   
//        $("<div id=‘mask‘></div>").addClass("mask")
//                                  .width(windowWidth + document.body.scrollWidth)
//                                  .height(windowHeight + document.body.scrollHeight)
//                                  .click(function () { hideDiv(div_id); })
//                                  .appendTo("body")
//                                  .fadeIn(200);
        div_obj.css({ "position": "absolute","overflow":"hidden","width":width+"px","height":height+"px" })
               .animate({ left: ($(window).width() - width) / 2,
                   top:($(window).height()-height)/2, opacity: "show"
               }, "slow");

};
    this.hideDiv = function (div_id) {
        $("#mask").remove();
        $("#" + div_id).animate({ left: 0, top: 0, opacity: "hide" }, "slow");
    };
    this.getJsonByKey = function (obj, key) {
        for (var m in obj) {
            if (m.toLowerCase() == key.toLowerCase()) {
                var exp = new RegExp("\\d{4}-\\d{2}-\\d{2}T*");
                if (exp.test(obj[m])) {
                    obj = obj[m].replace("T", "");
                    obj = obj.substr(10, 5);
                    if (obj.substr(4, 1) == ":") {
                        obj = "0" + obj.substr(0, 4);
                    }
                    return obj;
                }
                return obj[m] == null ? " " : obj[m];
            }

}
        return "";
    };

this.SetEntityCombo = function (obj, entityType, textField, columns, where, idFild, queryFild) {
        var url = ‘/common/EntityJsonList.ashx?entityType=‘ + entityType + ‘&_method=entity&tmp=‘ + Math.random();
        if (where) {
            url += "&where=" + where;
        }
        if (obj.val() != "") {
            url += "&defaultValue=" + obj.val();
        }

var id = ‘Id‘;
        if (idFild) {
            id = idFild;
        }
        url += "&idFild=" + id;
        //        if (queryFild) {
        //            url += "&queryFild=" + queryFild;
        //        }
        obj.combogrid({
            panelWidth: 500,
            idField: id,
            textField: textField,
            url: url,
            method: ‘get‘,
            pagination: true, //是否分页  
            rownumbers: true, //序号
            pageSize: 10, //每页显示的记录条数,默认为10  
            pageList: [10], //可以设置每页记录条数的列表  
            columns: columns,
            mode: ‘remote‘,
            fitColumns: true
        });
    }
    this.MessageBox = function (messageKey, messageType, extend) {
        var key = UTIL.getMessage(messageKey);
        if (extend) {
            key = key + extend;
        }
        $.messager.alert(‘操作提示‘, key, messageType);
    };
    this.Confirm = function (messageKey, isKey, callBack) {
        if (isKey) {
            $.messager.confirm(‘操作提示‘, UTIL.getMessage(messageKey), function (r) {
                if (r) {
                    callBack();
                }
            });
        }
        else {
            $.messager.confirm(‘操作提示‘, messageKey, function (r) {
                if (r) {
                    callBack();
                }
            });
        }
    };

this.msgEnUs = { ‘CLTMSG_NO_SELECTED_ROW‘: ‘Please select a record first!‘
        , ‘CLTMSG_BE_DELETE_ROW‘: ‘Are you sure to delete?‘
        , ‘CLTMSG_NO_MASTER_DATA‘: ‘Please save master data first!‘
        , ‘CLTMSG_BE_SAVE_FIRST‘: ‘Please save current data first!‘
        , ‘CLTMSG_BE_LOST_CHANGE‘: ‘Are you sure to lost changes?‘
        , ‘CLTMSG_LOADING‘: ‘Loading data,please wait...‘
        , ‘V_REQUIRED‘: ‘\‘%FIELDNAME%\‘ can\‘t be empty!‘
        , ‘V_NUMERIC‘: ‘\‘%FIELDNAME%\‘ must be numeric!‘
        , ‘V_DATETIME‘: ‘\‘%FIELDNAME%\‘ must be datetime!‘
        , ‘V_INVALID‘: ‘\‘%FIELDNAME%\‘ is invalid!‘
    };
    this.msgZhCn = { ‘CLTMSG_NO_SELECTED_ROW‘: ‘请先选择一条记录!‘
        , ‘CLTMSG_BE_DELETE_ROW‘: ‘确定要删除该记录?‘
        , ‘CLTMSG_NO_MASTER_DATA‘: ‘请先保存主数据!‘
        , ‘CLTMSG_BE_SAVE_FIRST‘: ‘请先保存该记录!‘
        , ‘CLTMSG_BE_LOST_CHANGE‘: ‘确定要放弃所做的修改吗?‘
        , ‘CLTMSG_LOADING‘: ‘正在加载数据,请稍候...‘
        , ‘Search_Error‘: ‘查询失败!‘
        , ‘Save_Fail‘: ‘保存失败!‘
         , ‘Op_Fail‘: ‘操作失败!‘
           , ‘Op_Sucess‘: ‘操作成功!‘
            , ‘Import_Sucess‘: ‘导入成功!‘
        , ‘Save_Sucess‘: ‘保存成功!‘
         , ‘Del_Sucess‘: ‘删除成功!‘
        , ‘V_REQUIRED‘: ‘%FIELDNAME% 不能为空!‘
        , ‘V_NUMERIC‘: ‘%FIELDNAME% 必须为数值型!‘
        , ‘V_DATETIME‘: ‘%FIELDNAME% 必须为日期型!‘
        , ‘V_INVALID‘: ‘%FIELDNAME% 值无效!‘
         , ‘NO_SELECTED_ROW‘: ‘请选择一条记录!‘
         , ‘LOAD_ERROR‘: ‘数据加载失败!‘
         , ‘Logout_Comfirm‘: ‘确认要退出?‘
    };
    this.linkString = ‘<a class="clickA"></a>‘;
    //getMessage for globalization
    this.getMessage = function (_msgName) {
        if (document.forms[0]) {
            var msgArray = document.forms[0].id == ‘enUS‘ ? this.msgEnUs : this.msgZhCn;
            var msg = msgArray[_msgName];
        }
        if (!msg) msg = "#" + _msgName + "#";

return msg;
    };
    this.isPopup = function (target) {
        if (!target) target = this;
        return (target.frameElement ? (target.frameElement.id ? true : false) : false);
    };
    ///get param from WIN LOCATION or URL
    this.getUrlParam = function (pName, win) {
        var sUrl;
        if (typeof (win) == ‘string‘) {
            sUrl = win;
            if (sUrl.indexOf(‘?‘) < 0) sUrl = ‘?‘ + sUrl;
        } else {
            if (!win) win = window;
            sUrl = win.location.search;
        }
        var iQ = sUrl.indexOf(‘?‘) + 1;
        if (iQ > 0) {
            sUrl = ‘&‘ + sUrl.substring(iQ, sUrl.length);

iQ = sUrl.indexOf(‘?‘); //url参数中还存在url?
            var key = ‘&‘ + pName + ‘=‘;
            var i = sUrl.indexOf(key);
            if (i > -1) {
                var j = sUrl.indexOf(‘&‘, i + 1); //&Key=Val&Key2=...
                if (j < 0 || (iQ > 1 && j > iQ)) j = sUrl.length;
                return unescape(sUrl.substring(i + key.length, j));
            }
        }
        return null;
    };
    this.getAppRoot = function (win) {//取得相对跟路径, 如中括号路径内的值: http://****/[UrbanWeb],http://******[/]
        if (!win) win = window;
        //if (win.APP_ROOT) return win.APP_ROOT; //cached

var c = win.document.getElementsByTagName(‘LINK‘);
        if (c) {//get first css rel file URL
            for (var i = 0; i < c.length; i++) {
                var url = c[i].href;
                var k = url.indexOf(‘App_Themes‘);
                if (k > -1) {
                    url = url.substring(0, k - 1);
                    win.APP_ROOT = url;
                    return url;
                }
            }
        }
        //not default & main
        if (win.top.location.href.indexOf(‘efault.aspx‘) < 0 && win.top.location.href.indexOf(‘ain.aspx‘) < 0) {
            if (win.top.opener)
                win = win.top.opener;
        }
        sUrl = win.top.location.href;
        sUrl = sUrl.substring(0, sUrl.indexOf(‘.aspx‘));
        sUrl = sUrl.substring(0, sUrl.lastIndexOf(‘/‘));
        win.APP_ROOT = sUrl;
        return sUrl;
    };
    this.initTodoUrl = function (sFormType, grdvIdx, grdv) {
        if (!sFormType) sFormType = UTIL.getUrlParam(‘FormType‘);
        var cache = {};
        $.getJSON(UTIL.getAppRoot() + "/ModDev/GetTodoList.ashx?FormType=" + (sFormType ? sFormType : ‘‘),
            function (data) {
                $.each(data, function (i, item) {
                    cache[item[0]] = item[1];
                });

if (!grdv) grdv = ‘grdv‘;
                if (!grdvIdx) grdvIdx = 0;
                $(‘#‘ + grdv + ‘ tr‘).each(function (i, tr) {
                    var td = $(‘td:eq(‘ + grdvIdx + ‘)‘, tr);
                    var id = td.text();
                    if (cache[id])
                        td.attr(‘url‘, cache[id]);
                });
            }
        );
    };
    this.getId = function (dataTag, nocheck, idx) {
        var s;
        if (idx == undefined) idx = 0;
        if (!nocheck && dataTag == -1) nocheck = true; //-1等同于 nocheck
        var isGrid = (dataTag == -2); //-2 仅查找Grid?

if (dataTag < 0) dataTag = undefined;
        if (dataTag == undefined) dataTag = ‘‘;
        var ctl = $(‘#txt_Id_‘ + (dataTag == ‘‘ ? ‘‘ : (‘D‘ + dataTag)));
        if (!isGrid && ctl.length == 1)
            s = ctl.val();
        else
            s = $(‘.selected > td‘, ‘#grdv‘ + dataTag).eq(idx).text(); //从默认grid取Id,必须是首个TD

if (!nocheck) {
            if (s == ‘‘) {
                alert(UTIL.getMessage(‘CLTMSG_NO_SELECTED_ROW‘));
                return false;
            }
        }
        if (s.length == 1 && s.charCodeAt(0) == 160) s = ‘‘;

return s;
    };
    this.setDisabled = function (_array, _condition, _hide)//_hide: null=disabled, true=hide,false=readonly
    {
        if (_condition && $(‘#‘ + _condition).val() != ‘‘)//not null?
            return;
        _array = _array.split(‘,‘); //string ‘btn_A_,btn_B_‘
        for (var i = 0; i < _array.length; i++) {
            if (!_array[i]) continue; //空串?
            var ctl = $(‘#‘ + _array[i]);
            if (ctl.length > 0) {
                if (_hide == null && (ctl.get(0).tagName == ‘INPUT‘ || ctl.get(0).tagName == ‘TEXTAREA‘))
                    _hide = false; //set text to readonly by default.

if (_hide == true)
                    $(‘#‘ + _array[i]).hide();
                else if (_hide == false)
                    $(‘#‘ + _array[i]).attr(‘readOnly‘, ‘readOnly‘).addClass(‘disabled‘);
                else
                    $(‘#‘ + _array[i]).attr(‘disabled‘, ‘disabled‘).addClass(‘disabled‘).css(‘color‘, ‘#cccccc‘);
            }
        }
        $(‘#‘ + _array[i]).css("border", "none");
    };
    this.formatDate = function (dateStr, noHour) {
        if (typeof dateStr == ‘string‘) {
            if (dateStr.indexOf(‘/‘) == 0)
                dateStr = ‘new ‘ + dateStr.replace(‘/‘, ‘‘).replace(‘/‘, ‘‘);
            dateStr = eval(dateStr);
        }
        var mon = (dateStr.getMonth() + 1);
        var date = dateStr.getDate();
        var s = dateStr.getFullYear() + ‘-‘ + (mon < 10 ? ‘0‘ + mon : mon) + ‘-‘ + (date < 10 ? ‘0‘ + date : date);
        if (!noHour) {
            var hour = dateStr.getHours();
            var min = dateStr.getMinutes();
            s += ‘ ‘ + (hour < 10 ? ‘0‘ + hour : hour) + ‘:‘ + (min < 10 ? ‘0‘ + min : min)
        }
        return s;
    };

//通过设置span/td为els样式(对应style.css),显示内容为tooltip
    this.showEllipsis = function (e) {
        var srcElmt = event.srcElement;
        if (!srcElmt.tagName || !srcElmt.innerText || srcElmt.tagName == ‘BODY‘) return;
        if (srcElmt.offsetWidth < srcElmt.scrollWidth) {
            if (!srcElmt.__title) {
                if (srcElmt.title == srcElmt.innerText) return;
                if (srcElmt.title) srcElmt.__title = srcElmt.title;
            }
            if (srcElmt.__title)
                srcElmt.title = srcElmt.innerText;
            else
                srcElmt.title = srcElmt.innerText;
        }
        else {
            if (srcElmt.__title) {
                srcElmt.title = srcElmt.__title;
                srcElmt.__title = null;
            }
            else if (srcElmt.title == srcElmt.innerText)
                srcElmt.title = ‘‘;
        }
    };

//resetByPrefix : reset form elements to default value
    this.resetByPrefix = function (_prefix, dataTag) {
        if (!dataTag || dataTag == -1) dataTag = ‘‘;
        $(‘*[id]‘, ‘#bpQry‘ + dataTag).each(function () {
            ctl = this;
            if (ctl.id.indexOf(_prefix) == 0) {
                if (ctl.type == ‘text‘)
                    ctl.value = ‘‘;
                else
                    if (ctl.type == ‘select-one‘)
                        ctl.selectedIndex = 0;
                    else
                        if (ctl.type == ‘checkbox‘)
                            ctl.checked = false;
            }
        });
    };

this.refreshParent = function () {
        _opener = window.top.opener;
        if (!_opener || _opener.closed) {
            if (window.parent.PICKER.pickerPad)//has PICKER?
                _opener = window.parent;
            else {
                _opener = window.top;
            }
            //return; //parent closed?
        }
        if (_opener.frames[‘main‘] != null) {
            _opener = _opener.frames[‘main‘];
        }
        else {
            _opener = window.top.frames[‘main‘];
            if (_opener == null || _opener == typeof ("undefined")) _opener = window.top;
        }

_opener = _opener.document;
        if ($(‘#btn_Search_‘, _opener).length == 1)
            $(‘#btn_Search_‘, _opener).click();
        else {
            $(‘#__EVENTTARGET‘, _opener).val(‘‘); $(‘#__EVENTARGUMENT‘, _opener).val(‘‘); //防止事件重复提交
            _opener.forms[0].submit();
        }
    };
    this.closePopup = function () {
        UTIL.refreshParent();
        self.close();
    };
    this.dynamicAddHead = function (url) {
        if (!window.$LoadedHead) window.$LoadedHead = {};
        else if (window.$LoadedHead[url]) return;

var filetype = url.indexOf(‘.css‘) > 0 ? ‘css‘ : ‘js‘;
        if (filetype == "js") {
            var fileref = document.createElement(‘script‘);
            fileref.setAttribute("type", "text/javascript");
            fileref.setAttribute("src", url);
        } else if (filetype == "css") {
            var fileref = document.createElement("link");
            fileref.setAttribute("rel", "stylesheet");
            fileref.setAttribute("type", "text/css");
            fileref.setAttribute("href", url);
        }

window.$LoadedHead[url] = true; //loaded
        if (typeof fileref != "undefined")
            document.getElementsByTagName("head")[0].appendChild(fileref);
        else
            alert(‘Dynamic load file [‘ + url + ‘] failed!‘);
    };

this.wrapToBottom = function (cfg) {
        cfg = cfg || { id: ‘trv‘ }; //default

var obj = typeof (cfg.id) == ‘string‘ ? $(‘#‘ + cfg.id) : cfg.id;
        if (obj.length != 1 || obj.css(‘display‘) == ‘none‘) return;

var SCROLLER_BAR_WIDTH = 19;

var offset = obj.offset();
        var height = cfg.height; //已经指定?
        if (!height) {//计算
            var wHeight = $(window).height() + document.body.scrollTop;
            height = wHeight - offset.top - SCROLLER_BAR_WIDTH + 11; //可用高度
        }
        if (cfg.marginBottom) height = height - cfg.marginBottom;
        //宽度
        if (cfg.hbar == ‘OUTER‘ && $(window).width() < 500) { cfg.hbar = ‘INNER‘; } //小窗口显示,滚动条左压
        var width = obj.width();
        if (obj.height() > height) {//出现垂直滚动条
            switch (cfg.hbar) {
                case ‘OUTER‘: //div向右加宽
                    width = width + SCROLLER_BAR_WIDTH;
                    break;
                case ‘INNER‘: //内部元素向左压缩
                    obj.width(width - SCROLLER_BAR_WIDTH);
                    break;
                default: //内部出现横向滚动条
                    break;
            }
        }

if (cfg.addPadding) {//table底部添加一个row,高度到与底边齐平
            var cspan = obj.find(‘tr:first td‘).length;
            if (cspan == 0) cspan = obj.find(‘tr:first th‘).length;

var gHeight = height - obj.height() - 8; //隐藏后重新计算
            if (!$.browser.msie) gHeight = gHeight - 5;
            if (gHeight > 0) {
                if (obj.attr(‘init‘))
                    obj.find(‘td:last‘).css(‘height‘, gHeight);
                else
                    obj.append(‘<tr><td colspan="‘ + cspan + ‘" style="height:‘ + gHeight + ‘px;"></td></tr>‘);
            }
        }

if (obj.get(0).tagName == ‘IFRAME‘ || cfg.nowrap) {//当前元素上设置
            obj.css(‘height‘, height);
        } else {//增加div包裹?
            if (obj.attr(‘init‘)) {
                obj.parent(‘div‘).css(‘height‘, height);
            } else {
                var s = ‘<div style="overflow:auto;overflow-x:hidden;‘;
                if (!$.browser.ie) s += ‘padding:1px;‘;
                if (height > SCROLLER_BAR_WIDTH) s += ‘height:‘ + height + ‘px;‘;
                s += ‘"></div>‘;
                obj.wrap(s);
            }
        }
        obj.attr(‘init‘, ‘1‘);
        return { height: height, width: width };
    };
    this.onAjaxError = function (req, msg) {
        if (req.status == 601)
            alert(req.statusText);
        else {
            var i = req.responseText.indexOf(‘<title>‘);
            if (i > 0) {
                i = i + 7;
                j = req.responseText.indexOf(‘</title>‘);
                alert(req.responseText.substring(i, j));
            }
        }
    }
    this.dev = function () {
        $(‘.toolbar‘).dblclick(function (event) {
            var path = window.location.pathname.substring(1);
            var ModuleUrl = path.substring(path.indexOf(‘/‘));
            var file = path.substring(path.indexOf(‘/‘) + 1);
            var newUrl = window.location.pathname.replace(file, ‘advice/BugManagerInfo.aspx?Module=‘);
            //            var type=file.substring(file,file.indexOf(‘.‘));            
            //            if(type.indexOf(‘Detail‘)==type.length-6)
            //                type=type.substring(0,type.indexOf(‘Detail‘));
            //            type = type.length>20?type.substring(type.length-20):type;
            var TmpnewUrl = UTIL.getAppRoot() + "/advice/BugManagerInfo.aspx?Module=" + ModuleUrl;
            WIN.open(TmpnewUrl, 800, 600);
        });
    };

/*
    * 只读页面转换处理
    * Created by cdh 2011.0824
    */
    this.parseReadonly = function (containerObj) {
        /// <summary>
        /// 只读页面转换处理
        /// </summary>

// -- 功能区
        //$("#divoperate").hide();

// -- 单行输入域
        $.each($(‘input.input01‘, containerObj), function (i, n) {
            if ($(n).css(‘display‘) != ‘none‘) {
                $(n).replaceWith(‘<span>‘ + $(n).val() + ‘</span>‘);
            }
        });

// -- 多行输入域
        $.each($(‘textarea.input02‘, containerObj), function (i, n) {
            if ($(n).css(‘display‘) != ‘none‘) {
                //$(n).replaceWith(‘<p style="height:‘ + $(n).height() + ‘px;width:‘ + $(n).width() + ‘px;">‘ + $(n).val() + ‘</p>‘);
                $(n).replaceWith(‘<p style="height:‘ + $(n).height() + ‘px;width:100%;">‘ + $(n).val() + ‘</p>‘);
            }
        });

// -- 下拉框
        $.each($(‘select‘, containerObj), function (i, n) {
            $(n).replaceWith(‘<span>‘ + $(n).children(‘:selected‘).text() + ‘</span>‘);
        });
    };

///针对必填项附加星号,附加到前面的td 中,td样式为  listleft01
    /// created by cdh 2011.0906
    this.appendRequiredStar = function () {
        $.each($(‘input,select,textarea‘), function (i, e) {
            if (/[\S_]+_V[13]/.test(e.id)) {//带V1,V3的输入域

var star_container = $(e).parent(‘td‘).prev(‘td.listleft01‘);

if (star_container.children(‘.star_container‘).length == 0) {
                    //                    var html = $(e).parent(‘td‘).prev(‘td.listleft01‘).html();
                    //                    $(e).parent(‘td‘).prev(‘td.listleft01‘).html(html.replace(/([^::]+)([::]*)/, ‘$1‘ +
                    //                    ‘<span class="star_container" style="color:red">*</span>‘ + ‘$2‘));
                    //                    
                    $(‘<span class="star_container" style="color:red">*</span>‘).appendTo($(e).parent(‘td‘).prev(‘td.listleft01‘));
                };
            }
        });
    };

/// 限制 textarea  文本长度
    this.limitTextareaLength = function () {
        $.each($(‘textarea‘), function (i, e) {
            var limitlength = $(e).attr(‘limitlength‘);
            if (limitlength && limitlength > 0) {
                $(e).bind(‘blur‘, function () {
                    if (this.value.length > limitlength) {
                        this.value = this.value.substring(0, limitlength);
                        alert(this.title + ‘长度不能大于‘ + limitlength + ‘,将自动截取。‘);
                    }
                });
            }
        });
    };
} ();
//-------------------------window control--------------------------------------
var WIN = new function () {
    this.open = function (_url, _width, _height) {//center
        var winFeature = ‘toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes‘;
        winFeature += ‘,width=‘ + _width + ‘,height=‘ + _height;
        winFeature += ‘,left=‘ + (window.screen.availWidth - _width) / 2 + ‘,top=‘ + (window.screen.availHeight - _height) / 2;
        return window.open(_url, ‘‘, winFeature, ‘‘);
    };

this.redirect = function (_url, _dataTag, _target) {//redirect, _dataTag=-1等同于不对Id做必须
        var _id = UTIL.getId(_dataTag);
        if (_id || (_dataTag == -1)) {
            var oldIdx = _url.indexOf(‘&Id=‘);
            if (oldIdx > 0) _url = _url.substring(_url, oldIdx);
            else {
                oldIdx = _url.indexOf(‘?Id=‘);
                if (oldIdx > 0) _url = _url.substring(_url, oldIdx);
            }

if (_id) {
                _url = _url + (_url.indexOf(‘?‘) > 0 ? ‘&‘ : ‘?‘) + ‘Id=‘ + _id;
            }
            if (!_target) _target = window;
            _target.location.href = _url;
        }
    };

this.openById = function (_url, _width, _height, _dataTag) {//center with Id&Ts
        var _id = UTIL.getId(_dataTag);
        if (_id || (_dataTag == -1)) {
            _url = _url + (_url.indexOf(‘?‘) > 0 ? ‘&‘ : ‘?‘) + ‘Id=‘ + _id;
            return this.open(_url, _width, _height);
        }
    };

this.openAsFull = function (_url)//full & center
    {
        var winFeature = ‘toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes‘;
        winFeature += ‘,width=‘ + (window.screen.availWidth - 12) + ‘,height=‘ + (window.screen.availHeight - 26);
        winFeature += ‘,left=0,top=0‘;
        return window.open(_url, ‘winId‘, winFeature, ‘‘);
    };
    this.openInFrame = function (_url, _frameName) {
        if (_frameName == null) _frameName = "main";
        window.parent.frames[_frameName].document.location.replace(_url);
    };
    this.showCalendar = function (e, src) {
        var txt = e.target ? e.target : e;
        PICKER.inline(UTIL.getAppRoot() + ‘/CommonPage/Calendar.htm‘, null, txt, 200, 186, src);
    };
    this.openCalendar = function (src, target) {
        if (!src) src = event.srcElement;
        if (!target) {
            if (src.previousSibling.tagName == ‘INPUT‘)
                target = src.previousSibling;
            else if (src.previousSibling.previousSibling.tagName == ‘INPUT‘)
                target = src.previousSibling.previousSibling;
        }
        if (target)
            PICKER.show(src.src.replace(‘.ico‘, ‘.htm‘), null, target, 200, 186);
    };
} ();

//-------------------------Tab control Persistantce--------------------------------------
var TAB = new function () {
    this.CTL_TAB_IDS = ‘#txtTabIds‘;
    this.select = function (tabIds) {
        if (!tabIds) tabIds = $(this.CTL_TAB_IDS).val();
        if (tabIds == undefined) alert(‘TextBox "txtTabIds" is required!‘);

ids = tabIds.split(‘,‘);
        for (var i = 0; i < ids.length; i++)
            this.selectById(ids[i]);
    };
    this.selectById = function (id) {
        id = id.split(‘_‘);
        var tabContainer, tab;
        if (id.length == 2) {
            tabContainer = id[0];
            tab = id[1];
        } else {
            tabContainer = ‘#tabs‘;
            tab = id[0];
        }
        tabIdx = tab.substring(tab.indexOf(‘tab‘) + 3);
        tabIdx = parseInt(tabIdx);

$(tabContainer).tabs().tabs(‘select‘, tab).bind(‘tabsselect‘, this.onSelect);
    };
    this.onSelect = function (event, ui) {
        var oldIdx = ui.options.selected;
        var oldId = ui.tab.hash.substring(0, ui.tab.hash.length - 1) + oldIdx;
        var newId = ui.tab.hash;
        var tabIds = $(TAB.CTL_TAB_IDS).val();

if (tabIds.indexOf(oldId) > -1)//exist?
            tabIds = tabIds.replace(oldId, newId);
        else {
            if (tabIds.length > 0)
                tabIds = tabIds + ‘,‘;
            tabIds = tabIds + newId;
        }
        //alert(tabIds);
        $(TAB.CTL_TAB_IDS).val(tabIds); //persist to textbox
    };
} ();
//-------------------------gridview control--------------------------------------
var GRID = new function () {
    this.grid = null;
    this.idIdx = 1;
    this.chkIdx = 0;
    this.selectedRow = null;
    this.oldSelectedClass = null;

this.setup = function (_idIdx, _chkIdx, _grid) {
        if (!_grid) _grid = ‘grdv‘; //default

this.grid = typeof (_grid) == ‘string‘ ? document.getElementById(_grid) : _grid;
        this.idIdx = (!_idIdx) ? 1 : _idIdx;
        this.chkIdx = (!_chkIdx) ? 0 : _chkIdx;
    };
    this.setCheckBoxEnable = function (grdvId) {
        if (!grdvId) grdvId = ‘grdv‘;
        grdvId = ‘#‘ + grdvId;

var ctlOldIDs = $(‘#txtOldIDs‘);
        var _varCheckedIDs = ‘‘;
        $(‘input:checkbox‘, grdvId).each(function (idx, chk) {
            var chk = $(chk);
            if (chk.attr(‘checked‘))
                _varCheckedIDs = _varCheckedIDs + ‘,‘ + chk.parent().parent().next().text(); //td/span/chk

chk.attr(‘disabled‘, ‘‘);
            chk.parent().attr(‘disabled‘, ‘‘);
        });

if (_varCheckedIDs.length > 0)// at lease return a char
            _varCheckedIDs = _varCheckedIDs.substring(1);
        ctlOldIDs.val(_varCheckedIDs);
    };

this.getChecked = function (grdvId) {//gridview,textbox to save ids, id index in grdv, chkbox index in grdv
        if (!grdvId) grdvId = ‘grdv‘;
        grdvId = ‘#‘ + grdvId;

var ctlNewIDs = $(‘#txtIDs‘);
        var _varCheckedIDs = ‘‘;
        $(‘input:checkbox‘, grdvId).each(function (idx, chk) {
            var chk = $(chk);
            if (chk.attr(‘checked‘))
                _varCheckedIDs = _varCheckedIDs + ‘,‘ + chk.parent().parent().next().text();

chk.attr(‘disabled‘, ‘disabled‘);
        });

if (_varCheckedIDs.length > 0)// at lease return a char
            _varCheckedIDs = _varCheckedIDs.substring(1);
        ctlNewIDs.val(_varCheckedIDs);
    };

this.setChecked = function (ctlIDs, idIdx, chkIdx, grid) {//set checkbox status by IDs control
        this.setup(idIdx, chkIdx, grid);
        if (ctlIDs == null) ctlIDs = document.getElementById(‘txtIDs‘);

var _varIDs = ctlIDs.value;
        if (this.grid && _varIDs.length > 1) {
            if (_varIDs.indexOf(‘,‘) != 0) _varIDs = ‘,‘ + _varIDs; //add first ‘,‘ to match each item

for (var i = 1; i < this.grid.rows.length; i++) {//grid/row/cell/span/checkBox
                if (this.grid.rows[i].cells[this.idIdx] && _varIDs.indexOf(‘,‘ + this.grid.rows[i].cells[this.idIdx].innerText) > -1) {//exists?
                    if (this.grid.rows[i].cells[this.chkIdx].childNodes[0].childNodes[0])//span/checkBox in gridview
                        this.grid.rows[i].cells[this.chkIdx].childNodes[0].childNodes[0].checked = true;
                    else
                        this.grid.rows[i].cells[this.chkIdx].childNodes[0].checked = true; //checkBox in datagrid
                }
            } //end for
        }
    };

this.deleteRow = function (autoSubmit, grid) {
        this.setup(null, null, grid);
        if (this.getCellText()) {
            if (window.confirm(UTIL.getMessage(‘CLTMSG_BE_DELETE_ROW‘))) {
                if (autoSubmit && typeof (__doPostBack) == ‘function‘) {
                    event.returnValue = false;
                    __doPostBack(‘DELETE‘, this.getCellText() + ‘,‘ + this.getCellText(this.idIdx + 1));
                }
                return true;
            }
        }
        return false;
    };

this.select = function (grid) {
        if (this.tagName == ‘TR‘)
            var tr = $(this);
        else
            var tr = $(this).parent(‘tr‘);
        var grid = tr.parents(‘table‘);
        $(‘.selected‘, grid).removeClass(‘selected‘);
        tr.addClass(‘selected‘);
    };

///ajax时:drp=DictType, colIdx=IdValue, grid=IsEnum,onSuccess=function
    ///return: check colIdx value? IdValue => NameValue, null=>DictJson
    this.bindDrop = function (drp, colIdx, grid, onSuccess) {
        var cache_key = ‘_CACHED_DICT_‘ + (typeof (drp) == ‘string‘ ? drp : drp.attr(‘id‘));
        var drp = (typeof (drp) == ‘string‘ && typeof (colIdx) == ‘number‘) ? $(‘#‘ + drp) : drp;
        if (!grid) grid = ‘grdv‘;
        var cacheWin = window.top;

//Cache Drop Items
        var json = cacheWin[cache_key];
        if (!json) {
            if (typeof (drp) == ‘object‘) {
                json = {};
                $(‘option‘, drp).each(function (idx, opt) {
                    var opt = $(opt);
                    json[opt.val()] = opt.text();
                });
                cacheWin[cache_key] = json;
            } else {//get ajax data
                var s = grid ? ‘DictType=‘ : ‘EnumType=‘;
                s += drp;
                cacheWin[cache_key] = {}; //阻塞当前key的再次请求
                $.ajax({
                    type: "GET",
                    url: UTIL.getAppRoot() + "/ModDev/BindDropAjax.ashx",
                    data: s,
                    error: function (req, msg) { UTIL.onAjaxError(req, msg); cacheWin[cache_key] = null },
                    success: function (array) {
                        array = $.parseJSON(array);
                        json = {};
                        $.each(array, function (i, row) {
                            json[row[‘Code‘]] = row[‘Name‘];
                        });
                        if (typeof onSuccess == ‘function‘)
                            if (onSuccess(json) == false) return;
                        cacheWin[cache_key] = json;
                    }
                });
            } //end ajax
        }

if (json != null) {
            if (colIdx != null) {
                var bCustomFormat = (typeof PageFormatGrid == ‘function‘);
                //Bind to grid        
                if (typeof (colIdx) == ‘number‘) {
                    $(‘tr‘, ‘#‘ + grid).each(function (idx, tr) {
                        var td = $(‘td‘, tr).eq(colIdx);
                        var dv = td.find(‘div‘); //td内存在div?
                        if (dv.length == 1) td = dv;
                        if (bCustomFormat)
                            td.text(PageFormatGrid(json[td.text()], idx, grid));
                        else
                            td.text(json[td.text()]);
                    });
                } else {///ajax时:drp=DictType, colIdx=oldValue, grid=IsEnum
                    if (bCustomFormat)
                        return PageFormatGrid(json[colIdx]);
                    else
                        return json[colIdx];
                }
            } else {
                if (typeof onSuccess == ‘function‘)
                    if (onSuccess(json) == false) return;
                return json; //all dict
            }
        }
    };

this.getCellText = function (cellIdx, grid) {
        this.setup(null, null, grid);
        if (!cellIdx) cellIdx = this.idIdx;

if (this.selectedRow) {
            if (this.selectedRow.cells[cellIdx])
                return this.selectedRow.cells[cellIdx].innerText;
        }
        else {//serverside select event
            for (var i = 0; i < this.grid.rows.length; i++) {
                if (this.grid.rows[i].className == ‘selected‘)
                    return this.grid.rows[i].cells[cellIdx].innerText;
            }
        }

window.alert(UTIL.getMessage(‘CLTMSG_NO_SELECTED_ROW‘));
        return null;
    };
    //数据为空时加载模板 --EDITED BY BEE
    this.setEmptyDataTemp = function (grdv, _array) {
        if ($("#" + grdv + " td").text() == ‘暂无数据‘ || $("#" + grdv + " td").text() == "") {
            var temp = ‘‘;
            _array = _array.split(‘,‘);
            for (var i = 0; i < _array.length; i++) {
                temp += "<th>" + _array[i] + "</th>";
            }
            temp = ‘<table id="‘ + grdv + ‘" class="Grid_Table" rules="cols" style="width: 100%; border-collapse: collapse" cellspacing="0" cellpadding="3" border="1" info="0,0,0,0"><tr class="header">‘ + temp + ‘</tr></table>‘;
            if ($("#" + grdv).length > 0) {
                $("#" + grdv).parent(‘.bDiv‘).prev().hide();
                $("#" + grdv).replaceWith(temp);
            }
            else {
                $(document.body).append(temp);
            }
        }
    };

this.setEmptyDataMessage = function (grdv, message) {
        if ($("#" + grdv + " tr").length <= 1) {
            var html = ‘<div class="nodata" style="width:60%; padding:4% 2%; margin:auto; margin-top:20%; color: #ED6F08; text-align:center; border: 1px solid #FAD8C1; background:#FCEDE0;">‘ + message + ‘</div>‘;
            //
            $("#" + grdv).replaceWith(html);
        }
    };

} ();
//-------------------------treeview control--------------------------------------
var TREE = new function () {
    //selectedId:设置当前节点父节点;drpSelectedId:设置当前选中节点
    this.createOptions = function (drpId, trvId, selectedId, drpSelectedId) {
        if (!drpId) alert(‘Select control is required!‘);
        if (!trvId) trvId = ‘trv‘;
        if (typeof (trvId) == ‘string‘)
            trvId = $(‘#‘ + trvId); //to object

var drpCached = {};
        var drp = $(‘#‘ + drpId).get(0);

var hasImg = null, hasRoot = null;
        $(‘.trv_0‘, trvId).each(function (i, ohref) {
            if (!ohref.href) return;
            if (hasImg == null) {
                var img = $(ohref).parent().prev().find(‘[onclick*=TreeView_SelectNode]‘);
                hasImg = img.length > 0;
            }

var shref = ohref.href.substring(32, ohref.href.length - 2); //javascript:__doPostBack(‘trv‘,‘s
            var nodes = shref.split(‘\\\\‘);
            if (nodes[0].length < 10)
                nodes[0] = ‘‘;

//取得多级缩进
            var sHirachy = ‘‘;
            var sHirachyText = ‘‘;
            var i = 0;
            while (i < nodes.length) {
                if (nodes[i]) {
                    sHirachy += ‘| - ‘;
                    if (i < nodes.length - 1 && drpCached[nodes[i]])//not current node.
                        sHirachyText += drpCached[nodes[i]].nodeText + ‘/‘;
                }
                i++;
            }
            //添加选项
            var opt = document.createElement(‘OPTION‘);
            if (nodes.length > 1) {
                opt.parentId = nodes[nodes.length - 2];
                if (hasRoot && opt.parentId == ‘‘)
                    opt.parentId = ‘ROOT‘;
            }
            opt.value = nodes[nodes.length - 1];
            opt.text = sHirachy + ohref.innerHTML;
            if (i < 2 && opt.text && !opt.value)//无Id的根节点
                hasRoot = opt.value = ‘ROOT‘;
            opt.nodeText = ohref.innerHTML; //可直接访问文本
            opt.nodePath = sHirachyText + opt.nodeText; //层级文本

drpCached[opt.value] = opt;

if (hasImg) {
                var title = $(ohref).parent().prev().find(‘img‘).attr(‘alt‘);
                if (title == ‘9‘) return; //表示无权限的节点
            }
            drp.options.add(opt);

//title=9 表示无权限的节点
            if (ohref.title == ‘9‘) {//set unselectable.
                $(ohref).css({ ‘color‘: ‘#000000‘ }).attr({ ‘href‘: ‘javascript:void(0);‘, ‘onclick‘: ‘return false;‘ }).removeAttr(‘title‘);
            }
        });

//设定为当前节点父节点
        var sId = selectedId;
        if (sId) {
            if (!drpCached[sId]) alert(‘Selected value is not found in select control.‘);
            else if (drpCached[sId].parentId)
                drpCached[drpCached[sId].parentId].selected = ‘selected‘;
        } else if (drpSelectedId) {//设定为当前节点
            if (!drpCached[drpSelectedId]) alert(‘Dropdown Selected value is not found in select control.‘);
            else drpCached[drpSelectedId].selected = ‘selected‘;
        }
        else {//由树节点设置
            var node = $(‘.trv_1‘, trvId).get(0);
            if (node) {
                var nodes = node.href.split(‘\\\\‘);
                if (nodes.length > 1) {
                    sId = nodes[nodes.length - 1].substring(0, nodes[nodes.length - 1].length - 2); //当前树选中节点
                    var editModeId = UTIL.getId(-1);
                    if (editModeId && editModeId == sId) {//录入编辑状态,当前选中应是父节点
                        if (drpCached[sId] && drpCached[sId].parentId) sId = drpCached[sId].parentId;
                    }
                    if (drpCached[sId])
                        drpCached[sId].selected = ‘selected‘;
                }
            }
        }
        drp.cache = drpCached;
    };
    this.isCirculated = function (drpId, sId) {//当前选中的Id,是当前节点的子节点,构成循环引用?
        if (!sId)
            sId = UTIL.getId(-1);
        if (sId) {
            if (!drpId) drpId = ‘drp_Parent_V8‘;
            var drp = $(‘#‘ + drpId);
            var selectedId = drp.val();
            var drpCache = drp.get(0).cache;
            var bCirculated = false;
            while (drpCache[selectedId]) {
                if (selectedId == sId) {
                    bCirculated = true;
                    break;
                }
                selectedId = drpCache[selectedId].parentId;

if (!selectedId) break;
            }
            if (bCirculated)
                return "\‘%FIELDNAME%\‘设置为循环引用,请重新设置!";
        }
    };
    this.currentNode = null;

this.setup = function () {
        this.attachNodeEvent();
    };
    this.attachNodeEvent = function ()//Add event when Node click
    {
        var nodes = document.getElementsByTagName(‘A‘);
        for (var i = 0; i < nodes.length; i++) {
            if (nodes[i].id.indexOf(‘trvt‘) == 0 && nodes[i].href) {
                nodes[i].onclick = this.selectedNodeChanged;
            }
        }
    };

this.selectedNodeChanged = function (src)//when node click, do something
    {
        if (!src) src = event.srcElement;
        src.className = ‘trv_1‘;
        if (this.currentNode && src != this.currentNode)
            this.currentNode.className = ‘trv_0‘;
        this.currentNode = src;

if (typeof (OnNodeChanged) == "function")
            OnNodeChanged(event, event.srcElement.href.substring(11, event.srcElement.href.length)); //11= length of "javascript:"

return false; //break from href
    };

//将制定对象,添加div包裹到特定的长度,宽度
    this.wrapScroller = function (cfg) {//{id:‘trv‘,height:null,width:null,margin-bottom:20,margin-right:20}
    };
} ();

//-------------------------validate control--------------------------------------
BindingControl = new function () {
    var validateRegex = new RegExp("V(\\d{1,2})");
    var ctlValObjRegex = new RegExp("\\w{3,5}?_(\\w*)_((\\w\\d{1,2})*)$");
    var ctlTypes = [‘input‘, ‘select‘, ‘textarea‘];
    var validateErrors;
    var bpZeroCache;
    function getCVOs(dataTag, panel) {
        var ctn;
        if (dataTag < 1) dataTag = ‘‘;
        if (typeof (panel) == ‘object‘)
            ctn = panel;
        else {
            if (!panel) panel = ‘bpEdit‘;
            ctn = ‘#‘ + panel + dataTag;
            if ($(ctn).length < 1) ctn = ‘.‘ + panel + dataTag;
            if ($(ctn).length < 1) ctn = ‘form‘;

if (dataTag == ‘‘ && bpZeroCache != null && bpZeroCache.length > 0) return bpZeroCache; //get cache
        }

var array = [];
        for (var i = 0; i < ctlTypes.length; i++) {
            $(ctlTypes[i], ctn).each(function (i, ctl) {
                m = ctl.id.match(ctlValObjRegex); //cvo?
                if (m) {
                    ctl = $(ctl);
                    initControl(ctl, m[1], m[2]);
                    array.push(ctl);
                }
            });
        }
        if (dataTag == ‘‘) bpZeroCache = array; //add cache
        return array;
    }
    function initControl(ctl, dataField, actionFlag) {
        if (ctl.attr(‘F‘)) return; //inited

ctl.attr(‘F‘, dataField);
        ctl.attr(‘A‘, actionFlag);

if (!actionFlag) return;
        var mV = actionFlag.match(validateRegex);
        if (mV && mV.length > 1) {//validation control?
            ctl.attr(‘V‘, mV[1]);
            if (!ctl.attr(‘T‘)) {
                if (ctl.parent().get(0).tagName == "TD")
                    ctl.attr(‘T‘, $.trim(ctl.parent().prev().text())); //prev TD
                else
                    ctl.attr(‘T‘, ctl.prev().text()); //text right before cur control
            }
            if (!ctl.attr(‘T‘)) ctl.attr(‘T‘, dataField); //DataField Name
        }
    }
    function clearData(dataTag, panel) {
        var ctlArray = getCVOs(dataTag, panel);
        $.each(ctlArray, function (i, ctl) {
            if (ctl.attr(‘type‘) == ‘checkbox‘)
                ctl.removeAttr(‘checked‘);
            else
                ctl.val(‘‘);
        });
    }
    function setData(data, dataTag, panel) {

}
    function getDataStr(dataTag, panel, field) {
        if (!field) field = ‘F‘; //F or id?
        var s = ‘‘;
        var ctlArray = getCVOs(dataTag, panel);
        $.each(ctlArray, function (i, ctl) {
            val = (ctl.attr(‘type‘) == ‘checkbox‘) ? (ctl.attr(‘checked‘) == true ? 1 : 0) : ctl.val();
            s += ‘&‘ + ctl.attr(field) + ‘=‘ + val;
        });
        return s.substring(1);
    }
    function getData(dataTag, panel, field) {
        if (!field) field = ‘F‘; //F or id?
        var array = new Array();
        var ctlArray = getCVOs(dataTag, panel);
        $.each(ctlArray, function (i, ctl) {
            val = (ctl.attr(‘type‘) == ‘checkbox‘) ? (ctl.attr(‘checked‘) == true ? 1 : 0) : ctl.val();
            array.push({ name: ctl.attr(field), value: val });
        });
        return array;
    }

//////////validate////////
    function validate(dataTag, bAlert) {
        if (bAlert == null) bAlert = true;

validateErrors = ‘‘;
        var ctlArray = getCVOs(dataTag);
        $.each(ctlArray, function (i, ctl) {
            if (ctl.attr(‘V‘))
                val_recheck(ctl);
        });

if (validateErrors.length == 0)
            return true;
        else if (bAlert) {
            validateErrors = validateErrors.replace(/\*/g, "");
            alert(validateErrors);
        }
        return false;
    }
    function val_recheck(control) {
        val_resetError(control);

if ((control.attr(‘V‘) & 1) > 0 && !val_checkRegex(‘V_REQUIRED‘, control))
            val_raiseError(control, UTIL.getMessage(‘V_REQUIRED‘));

if (control.val().length == 0) return;

if ((control.attr(‘V‘) & 2) > 0 && !val_checkRegex(‘V_NUMERIC‘, control))
            val_raiseError(control, UTIL.getMessage(‘V_NUMERIC‘));

if ((control.attr(‘V‘) & 4) > 0 && !val_checkRegex(‘V_DATETIME‘, control))
            val_raiseError(control, UTIL.getMessage(‘V_DATETIME‘));

if ((control.attr(‘V‘) & 8) > 0) {
            if (control.attr(‘rule‘) && !val_checkRegex(control.attr(‘rule‘), control))
                val_raiseError(control, control.attr(‘ruleMsg‘) ? control.attr(‘ruleMsg‘) : UTIL.getMessage(‘V_INVALID‘));
            else if (control.attr(‘ruleFunc‘)) {
                var msg = eval(control.attr(‘ruleFunc‘));
                if (msg) val_raiseError(control, msg);
            }
            if (typeof (PageOnValidate) == "function")//custom per page validate
                if (PageOnValidate(control) === true) return; //if true, just skip other validation
        }
    }
    function val_checkRegex(valType, control) {
        switch (valType) {
            case ‘V_REQUIRED‘:
                control.val(control.val().replace(/(^\s+)|\s+$/g, ‘‘));
                // if(control.get(0).tagName==‘SELECT‘ && control.val()==‘0‘) return false;/edit windshadow
                return (control.val().length > 0); // /.+/
                break;
            case ‘V_NUMERIC‘:
                return !isNaN(control.val()); // /^[-\+]?\d+(\.\d+)?$/
                break;
            case ‘V_DATETIME‘:
                return (/^\d{4}-\d{1,2}-\d{1,2}( \d{1,2}:\d{1,2}){0,1}$/).test(control.val());
                break;
            default:
                var regex = new RegExp(valType, ‘g‘);
                return regex.test(control.val());
                break;
        }
    }
    function val_resetError(control) {
        if (control.attr(‘error‘) == ‘1‘) {
            control.attr(‘error‘, ‘0‘);
            control.removeAttr(‘title‘);
            control.next().remove();
        }
    }
    function val_raiseError(control, resource) {
        var msg = resource.replace(‘%FIELDNAME%‘, control.attr(‘T‘));
        validateErrors += msg + ‘\n‘;
        if (control.attr(‘error‘) != ‘1‘) {
            control.attr(‘error‘, ‘1‘);
            control.attr(‘title‘, msg);
            //control.after("<SPAN style=‘color:red;‘>*</SPAN>"); //"<img title=\""+msg+"\" style=\"vertical-align:middle;\" src=\""+UTIL.getAppRoot()+"/images/button/onError.gif\"/>"
        }
    }

return {
        raiseError: val_raiseError,
        validate: validate,
        getData: getData,
        setData: setData,
        clearData: clearData
    }
} ();

//-------------------------Grid Pager ---------------------------------
var GridPager = function (cfg) {
    //配置项:{id,height,callback,filterId,title}
    cfg.callback = cfg.callback || __doPostBack; //回调函数

var PageInfo = null;
    var pagerBar = null;
    function wrap(cfg) {
        grid = $(‘#‘ + cfg.id);
        grid.find(‘.Grid_Pager‘).hide(); //old pager link
        if (!cfg.marginRight) cfg.marginRight = 2;

if (!cfg.pagerOnly)
            return flexigrid(grid);
        else {
            if (grid.attr(‘info‘)) {
                cfg.marginBottom = 32; //Pager的高度
                cfg.hbar = ‘OUTER‘; //垂直滚动条出现,内容压缩
                cfg.addPadding = true; //底部增加到底的TR
                UTIL.wrapToBottom(cfg);
            }
            addPager(grid);
        }
    }
    function flexigrid(grid) {
        //create table to grid
        var ths = $(‘tr:first th:visible‘, grid);
        if ($.browser.msie) ths = ths.not(ths.filter(‘.hidden‘));
        var widths = new Array();
        ths.each(function () {
            widths.push($(this).width());
        });
        ths.each(function (i) {
            var diff = widths[i] - 13; //padding
            if (i == widths.length - 1) diff -= cfg.marginRight;
            if (diff < 1) diff = 5;
            $(this).attr(‘width‘, diff);
        });

if (!grid.offset()) { return; }

grid.css({ ‘width‘: ‘auto‘, ‘borderCollapse‘: ‘separate‘ }).prepend($(‘<thead>‘).append($(‘tr:eq(0)‘, grid)));
        var height = $(window).height() - 72 - grid.offset().top; //pager,header
        if (widths.length == 0) height += 32; //Empty data,only header?
        if (ths.find(‘input‘).length > 0) height -= 3; //checkbox in header?
        if (cfg.marginBottom) height -= cfg.marginBottom;
        if (cfg.showColumnDrag == null || typeof (cfg.showColumnDrag) == "undefined") cfg.showColumnDrag = false;
        grid.flexigrid({ height: height - 20, showToggleBtn: false, striped: false, showColumnDrag: cfg.showColumnDrag, RestSize: cfg.resetSize });
        return addPager(grid);
    }
    function addPager(grid) {
        //create pager
        var div = grid.parent();
        div.after(‘<div class="pPager"><div>‘);
        PageInfo = getPageInfo(grid);

pagerBar = div.next();
        createPager();
        return grid;
    }

function getPageInfo(grid) {//jqgrid
        var trInfo = grid.attr(‘info‘);
        var iPageIndex = 1, iPageCount = 1, iPageSize = 0, iRecordCount = 0;
        if (trInfo) {
            var c = trInfo.split(‘,‘); //注意:此处和服务端关联!
            if (c && c.length == 4) {
                iRecordCount = c[0];
                iPageCount = c[1];
                iPageSize = c[2];
                iPageIndex = c[3];

iRecordCount = parseInt(iRecordCount);
                iPageIndex = parseInt(iPageIndex);
                iPageCount = parseInt(iPageCount);
                iPageSize = parseInt(iPageSize);
                if (iRecordCount == 0) {//grid无数据
                    iPageIndex = 1; iPageCount = 0;
                }
                if (iPageCount > 0 && iRecordCount % iPageSize == 0)//总页数计算过度
                    iPageCount--;
            }
        }
        return { PageIndex: iPageIndex, PageCount: iPageCount, PageSize: iPageSize, RecordCount: iRecordCount };
    }
    function createPager() {
        var sPager = ‘<div class="pDiv" style="clear:both;height:30px"><div class="pDLeft">‘
            + ‘<div class="pGroup pSetting">&nbsp;每页显示<select id="pPageSize" name="pPageSize" style="width:50px"><option value="5">5  </option><option value="10">10  </option><option value="15">15  </option><option value="20">20  </option><option value="25">25  </option><option value="40">40  </option><option value="50">50  </option></select>条</div>‘
            + ‘<div class="btnseparator"/> <div class="pPageStat"></div> </div>  <div class="pDRight"><span class="pNav">‘
            + ‘<div class="btnseparator"/> <div class="pGroup"> <div class="pFirst pButton"><span/></div><div class="pPrev pButton"><span/></div> </div> <div class="btnseparator"/> <div class="pGroup"> <div class="pNext pButton"><span/></div><div class="pLast pButton"><span/></div> </div> ‘
            + ‘<div class="btnseparator"/> <div class="pGroup"><div class="pcontrol" style="float:left;">第<input type="text" style="width:25px" name="pPageIndex" id="pPageIndex"/>页</div><div class="pReload pButton" title="跳转"><span/></div> </div>‘
            + ‘<div class="btnseparator"/> <div class="pGroup"> <span></span></div>‘
            + ‘</span></div><div style="clear: both;"></div></div>‘;
        pagerBar.wrapInner(sPager);
        //updatePageInfo();
        window.setTimeout(function () { updatePageInfo(); }, 200);
        //centerAlign(pagerBar);//caculate margin

$(‘.pReload‘, pagerBar).click(function () { changePage(‘reload‘); });
        $(‘.pFirst‘, pagerBar).click(function () { changePage(‘first‘); });
        $(‘.pPrev‘, pagerBar).click(function () { changePage(‘prev‘); });
        $(‘.pNext‘, pagerBar).click(function () { changePage(‘next‘); });
        $(‘.pLast‘, pagerBar).click(function () { changePage(‘last‘); });
        $(‘#pPageSize‘, pagerBar).change(function () { changePage(‘reload‘); });
    }
    function centerAlign(pagerBar) {
        var bar = { wleft: 115, wcenter: 95, wright: 222 }; //width of inner div
        var SCROLLER_BAR_WIDTH = 19;
        var width = pagerBar.width();
        var margin = (width - bar.wleft - bar.wright - bar.wcenter - SCROLLER_BAR_WIDTH) / 2 - 6;
        if (margin > 10) {//enough margin?
            $(‘.pDLeft‘, pagerBar).width(bar.wleft + margin);
            $(‘.pPageStat‘, pagerBar).width(bar.wcenter + margin);
            $(‘.pDRight‘, pagerBar).width(bar.wright);
        }
    }
    function changePage(sType) {
        var pageSize = $(‘#pPageSize‘, pagerBar).val();
        switch (sType) {
            case ‘first‘:
                if (PageInfo.PageIndex > 1)
                    callback(cfg.id, ‘Page$First‘, 1, pageSize);
                break;
            case ‘last‘:
                if (PageInfo.PageIndex < PageInfo.PageCount)
                    callback(cfg.id, ‘Page$Last‘, PageInfo.PageCount, pageSize);
                break;
            case ‘next‘:
                if (PageInfo.PageIndex < PageInfo.PageCount)
                    callback(cfg.id, ‘Page$Next‘, PageInfo.PageIndex + 1, pageSize);
                break;
            case ‘prev‘:
                if (PageInfo.PageIndex > 1)
                    callback(cfg.id, ‘Page$Prev‘, PageInfo.PageIndex - 1, pageSize);
                break;
            case ‘reload‘:
                if (cfg.btnSearch) {
                    var idx = $(‘#pPageIndex‘, pagerBar).val();
                    if (idx < 1) idx = 1; if (idx > PageInfo.PageCount) idx = PageInfo.PageCount;
                    callback(cfg.btnSearch, ‘‘, idx, pageSize);
                }
                break;
        }
    }
    function callback(grdv, action, pageIndex, pageSize) {
        $(‘#pPageIndex‘, pagerBar).val(pageIndex); //set input to server for MVC
        cfg.callback(grdv, action, pageIndex, pageSize);
    }
    function updatePageInfo(pInfo) {
        if (pInfo) PageInfo = pInfo;
        if (!PageInfo) return;

if (PageInfo.PageSize < 5) PageInfo.PageSize = 10;
        $(‘select option‘, pagerBar).each(function (idx, opt) {
            if (opt.value == PageInfo.PageSize)
                opt.selected = true;
        });
        $(‘input‘, pagerBar).val(PageInfo.PageIndex);
        $(‘.pPageStat‘, pagerBar).html("<span class=\"pPageInfo\">共 " + PageInfo.PageCount + " 页," + PageInfo.RecordCount + "条记录</span>");
    };
    this.update = updatePageInfo;
    //new GridFilter(cfg);
    return wrap(cfg);
};
var GridFilter = function (cfg) {
    //配置项:{filterId,title}
    //查询区显示头
    cfg.title = cfg.title || ‘查询条件‘;
    function wrap(cfg) {
        var bp = $(‘#‘ + cfg.filterId);

var sFilter = ‘<div class="pFilter" align="center">‘
            + ‘<div class="handle"><img src="../images/grid/magnifier.png" align="absmiddle" />&nbsp;<span class="title">‘ + cfg.title + ‘</span> [已隐藏]<br/></div>‘
            + ‘<div class="content">‘
            + ‘<fieldset align="center">‘
            + ‘    <div class="hcontent"><img src="../images/grid/magnifier.png" align="absmiddle" />&nbsp;<span class="title">‘ + cfg.title + ‘</span> [已显示]</div>‘
            + ‘</fieldset> </div> </div>‘;
        bp.before(sFilter);
        var filter = bp.prev();
        filter.find(‘fieldset‘).append(bp);

$(‘.handle‘, filter).click(function () {
            $(this).hide();
            $(‘.content‘, filter).show();
        });
        $(‘.hcontent‘, filter).click(function () {
            $(‘.content‘, filter).hide();
            $(‘.handle‘, filter).show();
        });
    };

wrap(cfg);
};
//-------------------------Tree Checker-------------------------------------
var TreeChecker = function (cfg) {
    var tree;
    //配置项:{id,type,clientSelect,level,click}
    //type: 限定可选Node类型,null则为全部。 对应服务端Node 的 ToolTip属性.
    //levelIndex: null,0,1,...哪个深度的节点开始需要多级返回?
    //levelText:0,1,2 返回向上几级的文字
    //click 点击事件
    cfg.clientSelect = (cfg.clientSelect == false) ? false : true; //是否客户端选定事件
    cfg.levelText = 1;
    cfg.hideLeaf = window.location.href.indexOf(‘HideLeaf=1‘) > 0;
    cfg.checkedByInput = UTIL.getUrlParam(‘CheckInput‘);

function init(cfg) {
        tree = $(‘#‘ + cfg.id);
        cfg.hasCheckbox = ($(‘:checkbox‘, tree).length > 0);

if (cfg.hasCheckbox && cfg.checkedByInput) {//通过父页面控件,控制勾选
            var v = $(‘#‘ + cfg.checkedByInput, window.parent.document).val();
            if (v) {
                var checkedValues = {};
                var arr = v.split(‘,‘);
                for (var i = 0; i < arr.length; i++) {
                    checkedValues[arr[i]] = true;
                }
            }
        }

cfg.checkedValues = checkedValues;
        $(‘.‘ + cfg.id + ‘_0‘, tree).each(processNode);
        $("img", tree).click(function () {
            window.setTimeout(function () { ShowOrder(); }, 100);
        });
    }
    function processNode(i, n) {//为checkbox设置sName和sId,子结点容器sNode,节点类型sType(服务端ToolTip)
        if (i == 0) cfg.prevNodeId = ‘-‘;

var node = $(n);
        var chk = node.prev(‘:checkbox‘);

var id = node.attr(‘href‘);
        if (id) {
            if (!cfg.hasCheckbox)
                chk = node;

id = id.substring(32, id.length - 2); //javascript:__doPostBack(‘trv‘,‘s
            chk.attr(‘sId‘, id.substring(id.lastIndexOf(‘\\‘) + 1))
            .attr(‘sName‘, node.text());

if (cfg.checkedValues && cfg.hasCheckbox) {//根据父页面值,设置勾选
                if (cfg.checkedValues[chk.attr(‘sId‘)])
                    chk.attr(‘checked‘, true);
            }

var sType = node.attr(‘title‘); //设置节点类型sType
            node.attr(‘sType‘, sType);
            chk.attr(‘sType‘, sType);
            if (sType) {
                if (sType.length == 1) {
                    node.removeAttr(‘title‘);
                    chk.removeAttr(‘title‘); //都拥有相同的title

//title=9 表示无权限的节点
                    if (sType == ‘9‘) {

node.css({ ‘color‘: ‘#000000‘ });
                        node.attr({ ‘href‘: ‘javascript:void(0);‘, ‘onclick‘: ‘return false;‘ });
                        if (node.parent().length > 0 && node.parent().prev().length > 0) {
                            $(node).click(function () {
                                var tmpid = node.attr("id");
                                var ssj = $("a", node.parent().prev()).attr("href").replace("javascript:", "");
                                eval(ssj);
                                window.setTimeout(function () {
                                    ShowOrder();

}, 200);
                            });
                        }
                    }
                    else {//有权限
                        if (cfg.clientSelect) {
                            node.attr({ ‘href‘: ‘javascript:void(0);‘, ‘onclick‘: ‘return false;‘ });
                            if (!cfg.hasCheckbox) clientSelect(node); //bind event
                        }

if (cfg.hideLeaf) {//隐藏叶节点
                            var childDiv = node.parents(‘div:eq(0)‘);
                            var id = childDiv.attr(‘id‘);
                            if (id != cfg.prevNodeId) {
                                var nid = id.substring(0, id.length - 5); //trvn2Nodes=>trvn2
                                $(‘#‘ + nid).attr(‘href‘, ‘#‘).replaceWith(node.parent().prev().children());
                                childDiv.hide();
                                cfg.prevNodeId = id;
                            }
                        } //隐藏节点
                    } //有权限
                } else {//sType长度不为1
                    if (cfg.click && typeof cfg.click == ‘function‘) {
                        node.removeAttr(‘title‘);
                        chk.removeAttr(‘title‘); //都拥有相同的title
                        node.attr(‘href‘, ‘javascript:void(0);‘).click(cfg.click);
                    }
                }
            } else {//sType==null
                if (cfg.clientSelect) {
                    node.attr({ ‘href‘: ‘javascript:void(0);‘, ‘onclick‘: ‘return false;‘ });
                    if (!cfg.hasCheckbox) clientSelect(node); //bind event
                }
            }
        }

if (cfg.hasCheckbox) {//记录子节点div容器的id在sNode
            chk.attr(‘sNode‘, ‘#‘ + chk.attr(‘id‘).replace(‘CheckBox‘, ‘Nodes‘)); //如‘#trv04Nodes‘
            syncClick(chk);
        }
    }
    function syncClick(obj) {
        if (obj == null) obj = $(‘:checkbox‘, tree);
        obj.click(function (e) {
            var chk = $(this);
            if (chk.attr(‘sType‘) == 9 && $(chk.attr(‘sNode‘) + ‘ :checkbox‘).length == 0 || (chk.attr(‘sType‘) == 9 && chk.attr("checked"))) {//异步展开节点
                window.setTimeout(function () {
                    var s = { id: ‘‘, name: ‘‘ };
                    $(‘:checkbox‘, tree).each(function (i, o) {
                        var chk = $(o);
                        if (chk.attr("checked")) {
                            if ((cfg.type == null//未配置
                        || chk.attr(‘sType‘).length > 1 //非配置类型?
                        || cfg.type == chk.attr(‘sType‘))//当前配置类型?
                         && chk.attr(‘sId‘)) {
                                s.id = chk.attr(‘sId‘);
                                s.name = getLevelText(cfg, chk).substring(1);
                                if ($("#" + s.id).length == 0) {
                                    $("#" + cfg.UserList).append("<a href=‘javascript:void(0);‘ style=‘color:blue‘ id=‘" + s.id + "‘><strong>" + s.name + "</strong><img id=‘id" + s.id + "‘ src=‘../images/att_del.gif‘></a>&nbsp;&nbsp;");
                                    $("#" + s.id).click(function () {
                                        var id = $(this).attr("id");
                                        $(this).remove();
                                        $("[type=‘checkbox‘][checked]", tree).each(function (i, o) {
                                            var chk = $(o);
                                            if (chk.attr(‘sId‘) == id) {
                                                chk.attr("checked", false);
                                            }
                                        });
                                    });
                                }
                            }
                        }
                    });
                    ShowOrder();
                }, 100);
            }

if (cfg.type && chk.attr(‘sType‘) == cfg.type) return true; //bug todo:忽略子结点选择,提高性能
            var bChecked = chk.attr(‘checked‘);
            $(chk.attr(‘sNode‘) + ‘ :checkbox‘).each(function (i, o) {
                if (!$(o).attr("checked")) { $(o).click(); }
            }); //同步子节点
            $(chk.attr(‘sNode‘) + ‘ :checkbox‘).attr(‘checked‘, bChecked); //同步子节点

// return true; //bug todo:忽略子结点选择,提高性能
            while ((chk = chk.parents(‘div:eq(0)‘)) && chk.length > 0) {//同步父节点
                $(‘#‘ + chk.attr(‘id‘).replace(‘Nodes‘, ‘CheckBox‘), tree)
                    .attr(‘checked‘,
                    $(‘:checked‘, chk).length == $(‘:checkbox‘, chk).length); //子已经全选?
            }
        });
    }
    function clientSelect(obj) {
        if (typeof pick != ‘function‘) pick = function () { };
        if (obj == null) obj = ‘.‘ + cfg.id + ‘_0‘; //all node
        $(obj).click(function () {
            $(‘.‘ + cfg.id + ‘_1‘).removeClass(cfg.id + ‘_1‘);
            $(this).addClass(cfg.id + ‘_1‘);
        }).dblclick(pick);

}
    function getLevelText(cfg, chk) {
        var val;
        if (!cfg.levelIndex)//未设置
            val = chk.attr(‘sName‘);
        else {
            val = chk.attr(‘sName‘);
            var p = chk.parents(‘div[id]^="trvn"‘);
            if (p.length > cfg.levelIndex) {
                var j = 0;
                while (j < cfg.levelText && j < p.length) {
                    val = p.eq(j).prev().find(‘a‘).text() + ‘/‘ + val;
                    j++;
                }
            }
        }
        return ‘,‘ + val;
    }

init(cfg);
    ShowOrder();
    function ShowOrder() {
        var s = { id: ‘‘, name: ‘‘ };
        if (cfg.hasCheckbox) {
            $(‘:checkbox‘, tree).change(function () {
                var chk = $(this);
                if (chk.attr("checked")) {
                    if ((cfg.type == null//未配置
                        || chk.attr(‘sType‘).length > 1 //非配置类型?
                        || cfg.type == chk.attr(‘sType‘))//当前配置类型?
                         && chk.attr(‘sId‘)) {
                        s.id = chk.attr(‘sId‘);
                        s.name = getLevelText(cfg, chk).substring(1);
                        if ($("#" + s.id).length == 0) {
                            $("#" + cfg.UserList).append("<a href=‘javascript:void(0);‘ style=‘color:blue‘ id=‘" + s.id + "‘><strong>" + s.name + "</strong><img id=‘id" + s.id + "‘ src=‘../images/att_del.gif‘></a>&nbsp;&nbsp;");
                            $("#" + s.id).click(function () {
                                var id = $(this).attr(‘id‘);
                                $(this).remove();
                                $("[type=‘checkbox‘][checked]", tree).each(function (i, o) {
                                    var chk = $(o);
                                    if (chk.attr(‘sId‘) == id) {
                                        chk.attr("checked", false);
                                    }
                                });
                            });
                        }
                    }
                }
                else {
                    s.id = chk.attr(‘sId‘);
                    s.name = getLevelText(cfg, chk);
                    $("#" + s.id).remove();
                }
            });
        }
    };
    return {
        get: function () {//取得选中节点obj:{id:‘11,22‘,name:‘aa,bb‘}
            var s = { id: ‘‘, name: ‘‘ };
            if (cfg.hasCheckbox)
                $(‘:checked‘, tree).each(function (idx, chk) {
                    chk = $(chk);
                    if ((cfg.type == null//未配置
                        || chk.attr(‘sType‘).length > 1 //非配置类型?
                        || cfg.type == chk.attr(‘sType‘))//当前配置类型?
                         && chk.attr(‘sId‘)) {
                        s.id += ‘,‘ + chk.attr(‘sId‘);
                        s.name += getLevelText(cfg, chk);
                    }
                });
            else {
                var node = $(‘.‘ + cfg.id + ‘_1‘);
                if (node.length && (cfg.type == null || node.attr(‘sType‘).length > 1 || cfg.type == node.attr(‘sType‘)) && node.attr(‘sId‘)) {
                    s.id = ‘,‘ + node.attr(‘sId‘);
                    s.name += getLevelText(cfg, node);
                } else
                    alert(‘选定了无效的值! (是否树未加载?)‘);
            }

s.id = s.id.substring(1); //trim ‘,‘
            s.name = s.name.substring(1);
            if (s.id == ‘undefined‘) { s.id = ‘‘; s.name = ‘‘; }
            return s;
        },
        processNode: processNode
    }
};
//-------------------------pop up control--------------------------------------
var Picker = function (cfg) {
    var source, targetID, targetName;
    this.offset = {};
    this.event = {};
    this.pickerPad = null;
    this.targetID = null;
    this.targetName = null;
    this.cfg = cfg;
    function addPickerPad() {
        var ctlPickerPad = document.createElement("DIV");
        ctlPickerPad.className = ‘p_pad‘;
        ctlPickerPad.style.cssText = ‘position:absolute;display:none;z-index:89;‘;
        ctlPickerPad.innerHTML = ‘<div class="p_h"><u class="corner"><u class="l1"></u><u class="l2"></u><u class="l3"></u><u class="l4"></u></u>‘
                + ‘<div class="p_cb"><ul><li title="关闭"><a href="javascript:void(0);" id="p_Close"></a></li>‘
                + ‘<li title="刷新"><a href="javascript:void(0);" id="p_Refresh"></a></li>‘
                + ‘<li title="返回"><a href="javascript:void(0);" id="p_Select"></a></li></ul><div style="clear:both;"></div> </div></div>‘
                + ‘<div class="p_c"><iframe id="p_frm" name="p_frm" scrolling="auto" frameBorder="0"></iframe></div>‘
                 + ‘<div class="mask"></div>‘;
        $(window.document.forms[0] || window.document.body).append(ctlPickerPad);
        return ctlPickerPad;
    }

function setDragable(pickerPad) {
        $(pickerPad).draggable({ iframeFix: false });
    }

function getPosition(source, pickerPad) {
        if (source == null || source == window) {
            if (source == null) source = window;
            var win = $(source);
            pad = $(pickerPad);
            var calTop = (win.height() - pad.height()) / 2 + document.body.scrollTop, calLeft = (win.width() - pad.width()) / 2 + document.body.scrollLeft;
        } else {
            var offset = $(source).offset();
            var avail = { top: offset.top - document.body.scrollTop, left: offset.left - document.body.scrollLeft }; //可见区域
            var calTop = 0, calLeft = 0;

if ((avail.top + pickerPad.height) > document.body.clientHeight) {//下方空间无法放Picker?
                if (avail.top - pickerPad.height < 10)//上方也无法放Picker
                    calTop = offset.top + 10; //下方撑开
                else
                    calTop = offset.top - pickerPad.height - 10;
            } else
                calTop = offset.top + 10; //下方可放下

if ((avail.left + pickerPad.width) > document.body.clientWidth) {//右方空间无法放Picker?
                var srcWidth = $(source).width();
                if (avail.left + srcWidth - pickerPad.width < 1)//左方也无法放Picker
                    calLeft = offset.left; //右方撑开
                else
                    calLeft = offset.left + srcWidth - pickerPad.width;
            } else
                calLeft = offset.left; //右方可放下
        }
        if ($(‘.p_h‘, pickerPad).css(‘display‘) == ‘none‘) calTop += 11;
        return { top: calTop, left: calLeft };
    }

function addCssFile(url) {
        if (!url)
            UTIL.dynamicAddHead(UTIL.getAppRoot() + ‘/App_Themes/Popup/popup.css‘);
    }
    function reset() {
        this.offset.hide = true;
        this.show(‘about:blank‘, null, null, 20, 20);
    }

function setFrame(options, picker) {
        //if(!targetName && !source && !targetID) { alert("Receiver control should be setted!"); return false;}//Verify
        var tID = options.tID, tName = options.tName, source = options.source, url = options.url;
        var pickerPad = options.pickerPad;
        if (tName) {
            options.tName = typeof (tName) == ‘string‘ ? document.getElementById(tName) : tName;
            if (!options.tName) alert("[Name] control can‘t be found.");
        }
        if (tID) {
            options.tID = typeof (tID) == ‘string‘ ? document.getElementById(tID) : tID;
            if (!options.tID) alert("[ID] control can‘t be found.");
        }
        if (options.source) {
            options.source = typeof (source) == ‘string‘ ? document.getElementById(source) : source;
            //if (!source) alert("[source] control can‘t be found.");
        }
        else if (options.tName)
            options.source = options.tName;
        else options.source = options.tID;
        //URL rewrite
        var pickerFrm = $(‘#p_frm‘, pickerPad);

//Place Content
        var bClearOldChecked = options.tID ? true : false; //是否是Picker.pick弹出
        if (typeof (url) == ‘string‘ && url.lastIndexOf(‘.‘) > 0) {//Url string
            if (url.indexOf(‘postback=1‘) > 0 && options.tID)//传递参数
                url = url + ‘&TID=‘ + options.tID.value;

if (pickerFrm.get(0).tagName != ‘IFRAME‘) {
                pickerFrm.replaceWith(‘<iframe id="p_frm" scrolling="auto" frameBorder="0"></iframe>‘);
                pickerFrm = $(‘#p_frm‘, pickerPad); //div=>ifm
            }
            var ifm = pickerFrm.get(0);
            var subUrl = url.substring(2);
            var i = ifm.src.indexOf(subUrl);
            if (i < 0 || ifm.src.length - i > subUrl.length) {//url不同
                ifm.src = url;
                bClearOldChecked = false; //页面已经重载
            }
            if (typeof options.event.load == ‘function‘) {
                pickerFrm.load(function () {
                    options.event.load(this.contentWindow, this.src, picker);
                });
            } else
                pickerFrm.unbind(‘load‘);
            //ifm.src="about:blank";
            pickerPad[‘type‘] = ‘1‘; //标志它已经启用
        } else {
            if (pickerFrm.get(0).tagName != ‘DIV‘)//iframe=>div
                pickerFrm.replaceWith(‘<div id="p_frm" style="overflow:hidden;"/>‘);
            pickerFrm = $(‘#p_frm‘, pickerPad); //ifm=>div
            if (typeof (url) == ‘string‘) {
                url = $(‘#‘ + url, window.document).show(); //find by id            
            } else url = $(url).show();
            pickerFrm.append(url);
            pickerPad[‘type‘] = ‘2‘; //标志它已经启用
        }
        //清除checkbox
        if (bClearOldChecked)
            $("input:checked", pickerPad[‘type‘] == ‘1‘ ? pickerFrm.get(0).contentWindow.document : pickerFrm).attr(‘checked‘, false);

//set Position        
        if (options.width == 0) options.offset.hide = true;
        if (!options.offset.hide) {
            if (options.width == null)//auto width?
                options.width = $(options.source).width();
            pickerFrm.width(options.width);
            if (options.height)//auto height?
                pickerFrm.height(options.height);

var offset = getPosition(options.source, pickerPad); //show picker
            $(pickerPad).css(offset).show();

setDragable(pickerPad);
            $(pickerPad).dblclick(hide);
            $(‘#p_Refresh‘, pickerPad).click(refresh);
        } else {//Firefox: iframe should be display before loading
            $(pickerPad).css({ top: -options.height - 100, left: -options.width - 100 }).show();
        }
    }
    function getTextareaDiv(options, tName) {
        var tbId = ‘taBigtext‘;
        if ($(‘#‘ + tbId).length == 0) {
            var s = ‘<textarea id="‘ + tbId + ‘" class="textarea"></textarea>‘;
            $(window.document.forms).append(s);
        }
        $(‘#‘ + tbId).val($(‘#‘ + tName).val());
        options.overlayClick = function () { PICKER.pick(null, $(‘#‘ + tbId).val()); };
        options.show = function () { $(‘#‘ + tbId).focus(); };
        return tbId;
    }
    function getDropdownDiv(options, drpId, tID, tName) {
        var tbId = ‘tb‘ + drpId;
        if ($(‘#‘ + tbId).length == 0) {
            var s = ‘<table id="‘ + tbId + ‘" class="dropdown">‘;
            $(‘#‘ + drpId + ‘ option‘).each(function (i, opt) {
                if (opt.text)
                    s += ‘<tr><td val="‘ + opt.value + ‘">‘ + opt.text + ‘</td></tr>‘;
            });
            s += ‘<tr><td><a onclick="PICKER.pick(\‘\‘,\‘\‘);" href="#" style="float:left;width:50%;">清空</a><div style="float:right;width:50%;" align="right"><a onclick="PICKER.hide();" href="#">关闭</a></div></td></tr>‘;
            s += ‘</table>‘;
            $(window.document.forms).append(s);

$(‘#‘ + tbId + ‘ td:not(:last)‘).click(function () {
                var ctl = $(this);
                PICKER.pick(ctl.attr(‘val‘), ctl.text());
            }).hover(function () {//over
                $(this).addClass(‘over‘);
            }, function () {//out
                $(this).removeClass(‘over‘);
            });
        }
        $(‘#‘ + tbId + ‘ td.over‘).removeClass(‘over‘);
        return tbId;
    }
    function inline(url, tID, tName, width, height, source, callback) {
        if (!this.pickerPad || this.pickerPad.isWin) { //Init on first load
            addCssFile();
            this.pickerPad = addPickerPad();
        }
        if (this.pickerPad.style.display != "none") { this.hide(); return false; } //Toggle picker
        toggleStyle(this.pickerPad, true);
        var options = { pickerPad: this.pickerPad, url: url
            , tID: tID, tName: tName, width: width, height: height, source: source, callback: callback
            , event: { load: this.event.load }
            , offset: this.offset, overlayClick: function () { PICKER.hide(); }
        };

if (url == tName)
            options.url = getTextareaDiv(options, tName);
        else if (typeof (url) == ‘string‘ && $(‘#‘ + url).length == 1 && $(‘#‘ + url).get(0).tagName == ‘SELECT‘)//options -> inline selection
            options.url = getDropdownDiv(options, url, tID, tName);

this.event.pick = (typeof (callback) == ‘function‘) ? callback : null;

setFrame(options, this);
        if (typeof options.show == ‘function‘) options.show();
        this.offset.hide = false;
        this.targetID = options.tID; //id=>control
        this.targetName = options.tName;
        this.event.load = null;
        this.event.hide = function () { $(‘#PickerOverlay‘).hide(); };
        setStorage(getPadId(this.pickerPad), this);

if ($(‘#PickerOverlay‘).length == 0) {
            var overlayOpacity = 0;
            $(document.body).append(‘<div id="PickerOverlay" style="z-index:59;display:block;position:fixed;width:99%;height:99%;top:0;left:0;filter:alpha(opacity=‘ + overlayOpacity + ‘);-moz-opacity: 0.‘ + overlayOpacity + ‘;opacity: 0.‘ + overlayOpacity + ‘;"></div>‘);
            $(‘#PickerOverlay‘).click(options.overlayClick);
        }
        $(‘#PickerOverlay‘).show();
    }
    function toggleStyle(pickerPad, isInline) {
        if (isInline) {
            $(‘.p_h‘, pickerPad).hide();
            $(‘.p_c‘, pickerPad).addClass(‘p_cInline‘);
        } else {
            $(‘.p_h‘, pickerPad).show();
            $(‘.p_c‘, pickerPad).removeClass(‘p_cInline‘);
        }
    }
    ///show(string url,string/input tID,string/input tName,
    /// int width,int height,string/input source,function callback)
    function show(url, tID, tName, width, height, source, callback) {
        if (!this.pickerPad || this.pickerPad.isWin) { //Init on first load
            addCssFile();
            this.pickerPad = addPickerPad();
        }
        if (this.pickerPad.style.display != "none") { this.hide(); return false; } //Toggle picker
        toggleStyle(this.pickerPad);

if (typeof (callback) == ‘function‘) this.event.pick = callback;
        var options = { pickerPad: this.pickerPad, url: url
            , tID: tID, tName: tName, width: width, height: height, source: source, callback: callback
            , event: { load: this.event.load }
            , offset: this.offset
        };
        setFrame(options, this);

$(‘#p_Close,#p_Select‘, this.pickerPad).unbind(‘click‘);
        $(‘#p_Close‘, this.pickerPad).click(hide);
        $(‘#p_Select‘, this.pickerPad).click(select);
        this.offset.hide = false;
        this.targetID = options.tID; //id=>control
        this.targetName = options.tName;
        this.event.load = null;
        setStorage(getPadId(this.pickerPad), this);
        return this;
    }

///可以仅提供对象{}的url参数。具体项参考dwindow
    ///默认则url为div的Id或者url的字符串
    function open(url, tID, tName, width, height, source, callback) {
        if (!this.offset.multi) {//不允许同时多个?
            var childWins = window.$pickerStorage; //hide child windows
            var curUrl = url.substring(url.indexOf(‘/‘) + 1);
            for (var winId in childWins) {
                var p = childWins[winId];
                if (typeof p.pickerPad.getFrame == ‘function‘) {
                    var u = p.pickerPad.getFrame().attr(‘src‘);
                    if (u && u.indexOf(curUrl) > 0)
                        return this;
                    else if (url.indexOf(‘/‘) < 0 && p.pickerPad.getFrame().find(‘#‘ + url).length > 0)
                        return this;
                }
            }
        }
        var options = { width: width + 20, height: height + 60, left: this.offset.left, top: this.offset.top, maximizable: false, minimizable: false, draggable: false, resizable: false };

if (typeof (url) == ‘string‘) {
            if (url.lastIndexOf(‘.‘) > 0) {//Url string
                //                if (url.indexOf("?") < 0)
                //                    url += "?randtmpurl=1";
                //                url += "&_tmprand=" + Math.random();
                if (url.indexOf(‘postback=1‘) > 0 && tID) {//传递参数
                    var v = $(‘#‘ + tID).val();
                    if (v) url = url + ‘&TID=‘ + v;
                }
                options.url = url;
                var onIframeEnd = null;
                if (typeof this.event.load == ‘function‘) {
                    var oldLoad = this.event.load;
                    options.onIframeEnd = function (me, url) {
                        var win = me.getFrame().get(0).contentWindow;
                        oldLoad(win, url);
                    }
                    this.event.load = null;
                }
                //if (width < 1) this.offset.hide = true;
                if (url.indexOf(‘&AutoAccept=1‘) > 0) this.offset.hide = true;
                if (this.offset.hide) {
                    options.x = -options.width;
                    options.y = -options.height;
                    this.offset.hide = false;
                } else if (!options.title && !options.onIframeEnd) {
                    if (this.offset.max) {
                        options.maxOpen = true;
                        this.offset.max = null;
                    }
                    options.onIframeEnd = function (me, url) {//自动加上窗体标题
                        var win = me.getFrame().get(0).contentWindow;
                        me.setTitle(win.document.title);
                    }
                }
            } else {
                options.content = $(‘#‘ + url); //move obj to window
            }
        } else
            options = url;

options.containerClass = "p_pad"; //getPicker查找方式    
        this.targetID = typeof (tID) == ‘string‘ ? document.getElementById(tID) : tID;
        this.targetName = typeof (tName) == ‘string‘ ? document.getElementById(tName) : tName;
        if (typeof (callback) == ‘function‘) this.event.pick = callback;

options.onClose = function (me) {
            if (options.content) {
                var opts = this;
                if ($(window.document.forms).length > 0)
                    $(window.document.forms).append(opts.content.hide());
                else
                    $(window.document.body).append(opts.content.hide());
            }

var winId = me.getWindowId();
            var picker = getStorage(winId);
            if (typeof picker.event.hide == ‘function‘) {//有关闭事件?
                if (picker.event.hide() == false)
                    return false; //返回false则不关闭
            }
            if (options.url)
                picker.pickerPad.getFrame().attr(‘src‘, ‘javascript:false‘).parent().empty();
            removeStorage(winId);
        };
        if (cfg != null && cfg.checkHide != null) {
            options.checkHide = cfg.checkHide;
        }
        if (cfg != null && cfg.closeParam != null) {
            options.closeParam = cfg.closeParam;
        }
        var win = $.dwindow(options);
        if (win.getContainer().length == 0) { alert(‘窗体容器添加失败,请确认所有HTML标记正确关闭.‘); }

var instance = { event: this.event, hide: this.hide, pick: this.pick, toggle: this.toggle, getPickerId: this.getPickerId, targetID: this.targetID, targetName: this.targetName, closable: true };
        instance.pickerPad = win;
        var pId = win.getWindowId();
        setStorage(pId, instance);

this.pickerPad = { isWin: true, windowId: pId }; //notify popup inited
        return instance;
    }
    function openAt(url, tID, tName, width, height, left, top, callback) {
        if (height > 520) height = 520;
        return this.open(url, tID, tName, width, height, null, callback);
    }

function pick(vID, vName, e) {
        var picker = getPicker(e || this);

if (picker.pickerPad) {
            if (vID != null && picker.targetID) {
                picker.targetID.value = vID; $(picker.targetID).change(); //fireEvent
                picker.targetID.title = vName;
            }
            if (vName != null && picker.targetName) { picker.targetName.value = vName; $(picker.targetName).change(); }

if (typeof picker.event.pick == ‘function‘) picker.event.pick(vID, vName);
            picker.hide();
        } else
            alert("Returning window not found!");
    }

function hide(e) {
        var picker = getPicker(e || this);
        if (!picker) return;
        if (picker.pickerPad) {//已经启用
            if (!picker.pickerPad.tagName) {//picker.pickerPad 与PICKER.pickerpad不同
                picker.pickerPad.getFrame().attr(‘src‘, ‘javascript:false‘).parent().empty();
                picker.pickerPad.close();
            } else {
                if (typeof picker.event.hide == ‘function‘) {//有关闭事件?
                    if (picker.event.hide() == false)
                        return false; //返回false则不关闭
                }

if (picker.pickerPad[‘type‘] == ‘2‘) {//div,hide时将内容重新保存回body,防止其他Picker导致它丢失
                    var ifm = $(‘#p_frm‘, picker.pickerPad);
                    $(window.document.forms).append(ifm.contents().hide());
                } else {
                    $(‘#p_frm‘, picker.pickerPad).attr(‘src‘, ‘about:blank‘);
                }
                picker.pickerPad.style.display = "none";
                picker.event.pick = null;
                picker.event.hide = null;
                removeStorage(getPadId(picker.pickerPad));
            }
        }
    }

function toggle(e, bShow) {
        var picker = getPicker(e || this);
        if (!picker) return;

if (picker.pickerPad && !picker.pickerPad.tagName) {
            var pad = picker.pickerPad.getContainer();
            var offset = pad.offset();
            if (bShow && offset.left > 0) return;
            pad.css({ top: -offset.top - 1000, left: -offset.left - 1000 });
        }
    }

function refresh(e) {
        var picker = getPicker(e || this);

if (picker.pickerPad) {//已经启用
            if (picker.pickerPad[‘type‘] == ‘1‘) {
                var ifm = $(‘#p_frm‘, picker.pickerPad).get(0);
                var _opener = ifm.contentWindow.document;
                if (!$(_opener.forms[0]).hasClass(‘norefresh‘)) {//form 具有norefresh样式,则禁用刷新功能
                    $(‘#__EVENTTARGET‘, _opener).val(‘‘); $(‘#__EVENTARGUMENT‘, _opener).val(‘‘); //防止事件重复提交
                    _opener.forms[0].submit();
                }
            } else
                picker.hide();
        }
    }
    function select(e) {
        var picker = getPicker(e || this);

if (picker.pickerPad) {//已经启用
            if (picker.pickerPad[‘type‘] == ‘1‘) {
                var ifm = $(‘#p_frm‘, picker.pickerPad).get(0);
                if (typeof ifm.contentWindow.pick == ‘function‘)
                    ifm.contentWindow.pick();
                else
                    picker.hide();
            } else
                picker.hide();
        }
    }
    function getPickerId(e) {//从给定控件、事件(默认为window)往上找到容器Picker的Id
        var picker = getPicker(e || this);
        if (picker) {
            if (!picker.pickerPad.tagName)//picker.pickerPad 与PICKER.pickerpad不同
                return picker.pickerPad.getWindowId();
            return $(picker.pickerPad).attr(‘id‘);
        }
    }

///find picker up from eventTarget
    function getPicker(e, win) {
        //inner function
        function getPadFrame(win) {
            var f;
            $(‘iframe‘, win.parent.document).each(function (idx, fm) {
                if (fm.contentWindow == win) {
                    f = fm;
                    return false;
                }
            });
            return f;
        }
        if (e && e.pickerPad && e.pickerPad.isWin) {//pick win时, 操作的是子picker,重新转回源对象. window.parent.PICKER=>PICKER
            var pad = $(‘.p_pad‘);
            if (pad.length == 1) {
                var ifm = pad.find(‘IFRAME‘);
                if (ifm.length == 1) {
                    e = ifm;
                }
            }
        }

var src = e ? (e.target ? e.target : e) : this;
        if (src.pickerPad) {
            if (src.pickerPad.isWin) {
                if (src.pickerPad.windowId) {
                    var p = getStorage(src.pickerPad.windowId);
                    if (p) return p;
                }
            } else
                return src; //real picker
        }

if (!win) win = src.location ? src : window;
        var pad = $(src).parents(‘.p_pad‘); //div?
        while (pad.length == 0) {//iframe
            var ifm = getPadFrame(win);
            if (ifm) {
                pad = $(ifm).parents(‘.p_pad‘);
                if (win != win.parent)
                    win = win.parent;
                else
                    break;
            } else
                break;
        }

if (pad.length == 1) {
            var picker = getStorage(getPadId(pad), win);
            if (!picker) alert("Picker can‘t be found in the Storage.");
            return picker;
        }
    }
    function getPadId(pad) {//内部方法,根据Pad设置并取得id
        pad = $(pad);
        var winId = pad.attr(‘id‘);
        if (!winId) {
            pad.attr(‘id‘, ‘picker_‘ + new Date().getTime());
            winId = pad.attr(‘id‘);
        }
        return winId;
    }

function removeStorage(winId, win) {
        if (win == null) win = window;
        if (win.$pickerStorage)
            delete win.$pickerStorage[winId];
    }
    function setStorage(winId, picker, win) {//将Picker按id索引存储
        if (win == null) win = window;
        if (!win.$pickerStorage)
            win.$pickerStorage = {};
        win.$pickerStorage[winId] = picker;
    }
    function getStorage(winId, win) {//根据id、控件取得Picker
        if (win == null) win = window;
        if (typeof winId != ‘string‘)
            return getPicker(winId || this, win);
        return win.$pickerStorage[winId];
    }

this.reset = reset;
    this.open = open;
    this.show = show;
    this.inline = inline;
    this.hide = hide
    this.pick = pick;
    this.getPickerId = getPickerId; //根据给定控件、事件取得最近的PickerId
    this.getPicker = getStorage; //根据pickerId、控件 取得Picker
    this.toggle = toggle; //更改可见性display
    this.openPosition = openAt; //此方法慎用
};

// -------------------------------------Toolbar---------------------------------------

function setToolbar(imgPath, btnFilter, toolbar) {
    //addCancelButton()
    if (!toolbar) toolbar = ‘.toolbar‘;
    if (typeof (OnToolbarInit) == "function")//toobar额外处理在utils2.js此函数中进行
        OnToolbarInit();

function getButtonKey(id) {
        if (id.indexOf("_Del") > 0)
            return "Del";
        if (id.indexOf("_Edit") > 0)
            return "Edit";
        if (id.indexOf("_Save") > 0)
            return "Save";
        if (id.indexOf("_Accept") > 0)
            return "Accept";
        if (id.indexOf("_New") > 0)
            return "New";
        if (id.indexOf("_Search") > 0)
            return "Search";
        if (id.indexOf("_Reset") > 0)
            return "Reset";
        if (id.indexOf("_Export") > 0)
            return "Export";
        return "tmp";
    }

function getButton(btnKey) {
        var tItem = { name: ‘‘, cls: ‘‘ };
        if (typeof (getToolbarButton) == "function")
            tItem = getToolbarButton(btnKey);
        if (!tItem.name) {
            switch (btnKey) {
                //1. 仅出现3次以下的按钮应在页面直接定义: <button id=‘btn_Name_‘ imgCls=‘image_Class‘ style=‘width:54px‘>按钮名称</button>          
                //2. 非ZA用到的按钮,都写到utils2.js getToolbarButton 方法的switch中          
                //3. 要覆盖ZA里定义的按钮样式, 请在utils2.js中直接再次定义按钮,如: case "Save": tItem.name = ‘我的保存‘; tItem.cls = ‘SM_Save‘;          
                case "Signature": tItem.name = ‘盖章‘; tItem.cls = "Ico_Stamp"; break;
                case "SignatureHand": tItem.name = ‘签章‘; tItem.cls = "Ico_Sign_L"; break;
                case "New": tItem.name = ‘新增‘; tItem.cls = ‘Ico_Add‘; break;
                case "Original": tItem.name = ‘查看原始信息‘; tItem.cls = ‘Ico_Diary‘; break;
                case "Attachment": tItem.name = ‘附件管理‘; tItem.cls = ‘Ico_Upload‘; break;
                case "Del":
                case "MyDel": tItem.name = ‘删除‘; tItem.cls = ‘Ico_Del‘; break;
                case "Edit": tItem.name = ‘编辑‘; tItem.cls = ‘Ico_Edit‘; break;
                case "Submit": tItem.name = ‘提交‘; tItem.cls = ‘Ico_Submit‘; break;
                case "Save": tItem.name = ‘保存‘; tItem.cls = ‘Ico_Save‘; break;
                case "Filter": tItem.name = ‘搜索‘; tItem.cls = ‘Ico_Filter‘; break;
                case "Cut": tItem.name = ‘剪切‘; tItem.cls = ‘Ico_Cut‘; break;
                case "Close": tItem.name = ‘关闭‘; tItem.cls = ‘Ico_Return‘; break;
                case "Return": tItem.name = ‘返回‘; tItem.cls = ‘Ico_Return‘; break;
                case "Select": tItem.name = ‘选择‘; tItem.cls = ‘Ico_Sign_L‘; break;
                case "ViewSelected": tItem.name = ‘查看选中‘; tItem.cls = ‘Ico_Exam‘; break;
                case "ComeIntoBegin": tItem.name = ‘生成借阅申请单‘; tItem.cls = ‘Ico_Slip‘; break;
                case "Reject": tItem.name = ‘退回‘; tItem.cls = ‘Ico_Back‘; break;
                case "Reply": tItem.name = ‘回复‘; tItem.cls = ‘Ico_Reply‘; break;
                case "Send": tItem.name = ‘发送‘; tItem.cls = ‘Ico_Send‘; break;
                case "Revert": tItem.name = ‘还原‘; tItem.cls = ‘Ico_Reback‘; break;
                case "Transfer": tItem.name = ‘转发‘; tItem.cls = ‘Ico_Repeat‘; break;
                case "Hold": tItem.name = ‘暂存‘; tItem.cls = ‘Ico_Hold‘; break;
                case "BorrowBook": tItem.name = ‘借出‘; tItem.cls = ‘Ico_BorrowBook‘; break;
                case "ReturnBook": tItem.name = ‘归还‘; tItem.cls = ‘Ico_ReturnBook‘; break;
                case "LockedBy": tItem.name = ‘签收‘; tItem.cls = ‘Ico_LockedBy‘; break;
                case "Accept": tItem.name = ‘提交‘; tItem.cls = ‘Ico_Submit‘; break;
                case "Print": tItem.name = ‘打印‘; tItem.cls = ‘Ico_Print‘; break;
                case "UpFile": tItem.name = ‘上传附件‘; tItem.cls = ‘Ico_Upload‘; break;
                case "Cancel": tItem.name = ‘撤回‘; tItem.cls = ‘Ico_Slip_Del‘; break;
                case "ShowLog": tItem.name = ‘日志‘; tItem.cls = ‘Ico_Diary‘; break;
                case "EventShowLog": tItem.name = ‘日志‘; tItem.cls = ‘Ico_Diary‘; break;
                case "ExportWord": tItem.name = ‘导出文档‘; tItem.cls = ‘Ico_De_Word‘; break;
                case "NewEmail": tItem.name = ‘新邮件‘; tItem.cls = ‘Ico_New‘; break;
                case "btn_Transfer": tItem.name = ‘转发‘; tItem.cls = ‘Ico_Repeat‘; break;
                case "Move": tItem.name = ‘导出Word‘; tItem.cls = "Ico_Del"; break;
                case "Erase": tItem.name = ‘彻底删除‘; tItem.cls = "Ico_Del"; break;
                case "Sadve": tItem.name = ‘保存‘; tItem.cls = "Ico_Save"; break;
                case "Query":
                case "Search": tItem.name = ‘查询‘; tItem.cls = "Ico_File_S"; break;
                case "Read": tItem.name = ‘阅读‘; tItem.cls = "Ico_Readed"; break;
                case "Temp": tItem.name = ‘模板‘; tItem.cls = "Ico_Save"; break;
                case "Lock": tItem.name = ‘签收‘; tItem.cls = "Ico_Re_Sign"; break;
                case "Cancel": tItem.name = ‘取消‘; tItem.cls = "Ico_Withdraw"; break;
                case "Export": tItem.name = ‘导出‘; tItem.cls = "Ico_De_Excel"; break;
                case "ExportExcel":
                case "Excel": tItem.name = ‘导出表格‘; tItem.cls = "Ico_De_Excel"; break;
                case "ExportWord":
                case "Word": tItem.name = ‘导出Word‘; tItem.cls = "Ico_De_Word"; break;
                case "Reset": tItem.name = ‘重置‘; tItem.cls = "Ico_Clear"; break;
                case "TopTopic": tItem.name = ‘置顶‘; tItem.cls = "Ico_Upload"; break;
                case "TopTopic2": tItem.name = ‘取消置顶‘; tItem.cls = "Ico_Upload"; break;
                case "AccecptUseCarShip": tItem.name = ‘通过‘; tItem.cls = "Submit"; break;
                case "Select": tItem.name = ‘选择‘; tItem.cls = "Ico_Submit"; break;
                case "Drawback": tItem.name = ‘抽取‘; tItem.cls = "Ico_Withdraw"; break;
                case "TemplateDesign": tItem.name = ‘模板设计‘; tItem.cls = "Ico_Workflow"; break;
                case "WorkFlowDesign": tItem.name = ‘工作流设计‘; tItem.cls = "Ico_Workflow"; break;
                case "Open": tItem.name = ‘打开‘; tItem.cls = "Ico_Revision"; break;
                case "SavePwd": tItem.name = ‘保存密码‘; tItem.cls = "Ico_Reset"; break;
                case "ResetPwd": tItem.name = ‘重置密码‘; tItem.cls = "Ico_Reset"; break;
                case "ViewLog": tItem.name = ‘日志‘; tItem.cls = "Ico_Diary"; break;
                case "Week": tItem.name = ‘周日程‘; tItem.cls = "Ico_Calendar"; break;
                case "Month": tItem.name = ‘月日程‘; tItem.cls = "Ico_Calendar"; break;
                case "Last": tItem.name = ‘上周‘; tItem.cls = "Ico_Last"; break;
                case "Next": tItem.name = ‘下周‘; tItem.cls = "Ico_Next"; break;
                case "ClosePage": tItem.name = ‘关闭‘; tItem.cls = ‘Ico_Return‘; break;
                case "SaveUpdateLog": tItem.name = ‘保存‘; tItem.cls = ‘Ico_Exam‘; break;
                case "CheckUpdate": tItem.name = ‘修改痕迹‘; tItem.cls = ‘Ico_Re_Sign‘; break;
                case "Preview": tItem.name = ‘预览‘; tItem.cls = ‘Ico_Preview‘; break;
            }
        }
        if (!tItem.name && !tItem.cls)
            tItem.cls = ‘Ico_Spatial‘;
        return tItem;
    }

function getButtonIcon(imgPath, key, imgType) {
        return imgType != null ? imgPath + key + "." + imgType : imgPath + key + ".ico";
    }

var divFilter = $(‘#bpQry‘); //查询区
    if (divFilter.length == 0) divFilter = $(".filter");
    //    if (divFilter.length > 0) {
    //        if (!btnFilter) btnFilter = ‘btn_Filter_‘; //默认显示查询区按钮
    //        btnFilter = $("#" + btnFilter);
    //        if (btnFilter.length == 0 && !divFilter.hasClass(‘hidden‘)) {//如果toobar上显示查询按钮不存在,自动添加
    //            divFilter.before(‘<button type="button" id="btn_Filter_"></button>‘);
    //            btnFilter = $("#btn_Filter_");
    //        }
    //        btnFilter.click(function() { divFilter.slideToggle("slow"); });
    //    }
    if (!imgPath) imgPath = UTIL.getAppRoot() + ‘/images/‘;
    $(toolbar + " button").each(function (i) {
        var key = getButtonKey($(this).attr("id"));
        if ($(this).text().indexOf("查看") >= 0)
            key = getButtonKey("btn_Search");
        var btnItem = getButton(key);

var btnText = $(this).text().replace(/(^\s*)|(\s*$)/g, ""); //默认取button内文本,去空格
        if (!btnText) btnText = btnItem.name;
        var btnClass = $(this).attr(‘imgCls‘); //在button定义属性imgCls ,设置按钮的图片class
        if (!btnClass) btnClass = btnItem.cls;

var btnImg = $(‘img‘, this);
        if (btnImg.length > 0) {
            var btnIcon = $(‘img‘, this).attr(‘src‘); //默认取button内图片
            if (!btnIcon) btnIcon = getButtonIcon(imgPath, key, $(this).attr("imgType"));
            $(this).html("<img align=‘absMiddle‘ src=‘" + btnIcon + "‘>" + "<label>" + btnText + "</label>");
        } else if ($(‘div‘, this).length == 0) {
            $(this).html(‘<div style="float:left;" class=" + btnClass + "></div><span style="line-height:20px;">‘ + btnText + ‘</span>‘);
        }
        $(this).width(15 * btnText.length + 24);
        $(this).mouseover(function () { $(this).css("color", "blue") }).mouseout(function () { $(this).css("color", "black") });
        //$(this).mouseover(function() { $(this).css({"border":"solid 0.5px #768ebf","color":"blue"}).width(15 * btnText.length + 24); }).mouseout(function() { $(this).css({"border":"0px","color":"black"}).width(15 * btnText.length + 24) });
        $(this).after(" "); //bugfix for toolbar auto wrap.
    });
    $(toolbar + " .split").each(function () { $(this).html("<img class=‘splitImg‘/>") });
    UTIL.wrapToBottom({ id: ‘trv‘, hbar: ‘OUTER‘ }); //扩展,所有树添加Div垂直滚动控制,水平无滚动
}

///////////////////// ///////////////
function RefreshMainPageGridView(url) {
    try {

var ob = window.parent.frames["main"];
        if (ob == null)
            ob = window.parent.parent.frames["main"];
        $("#btn_Search_", ob.document).click();
        if (url != null) {
            window.location.href = UTIL.getAppRoot() + "/" + url;
        }

}
    catch (e) {
    }
}

var AjaxPad = new function () {
    t = null;
    source = null;
    _url = null;
    x = 0;
    y = 0;
    tr = null;
    timer = null;
    function show(div, __url, _x, _y, _tr) {
        if (tr && tr != _tr && timer) {
            clearInterval(timer);
        }
        source = div;
        _url = __url;
        x = _x;
        y = _y;
        tr = _tr;
        if (t == null) {
            t = new Date();
            timer = setInterval(‘AjaxPad.xSleep()‘, 3000);
        }
    };

function xSleep() {
        var v = new Date(t.getFullYear(), t.getMonth(), t.getDate(), t.getHours(), t.getMinutes(), t.getSeconds() + 3);

if (v < t) return;
        clearInterval(timer);

var sH = document.body.offsetHeight; //窗口的高度
        var sW = document.body.scrollWidth; //窗口的宽度

x = 50;
        source.style.display = ‘block‘;
        source.innerHTML = $.ajax({
            url: _url,
            async: false
        }).responseText;

if (source.offsetHeight >= sH) {
            this.y += 10;
        }
        else if ((y + source.offsetHeight) >= sH) //当鼠标点击时的y坐标的值加上div的高度大于窗口的高度
        {
            y = sH - source.offsetHeight - 10;
        }
        else {
            y += 10;
        }
        y = document.body.scrollTop + y; //鼠标Y轴的值
        source.style.position = ‘absolute‘;
        source.style.left = x + "px";
        source.style.top = y + "px";
        t = null;
    };
    return {
        show: show,
        xSleep: xSleep
    }
} ();
//如果formid不为空的话就取formid的值,否则UTIL.getUrlParam("Id");
function GetFormLogs(DivId, Pagesize, OrderbyProperty, FormId) {
    //   if(OrderbyProperty==null||typeof(OrderbyProperty)=="undefined"){
    //        OrderbyProperty="OperateOn";
    //   }
    if (Pagesize == null) Pagesize = 5;
    var id;
    if (FormId == null)
        id = UTIL.getUrlParam("Id");
    else
        id = FormId;
    if (id == null) return;
    var url = UTIL.getAppRoot() + "/EveryOne/GetFormLogs.ashx?Id=" + id;
    if (OrderbyProperty != null) url += "&OrderbyProperty=" + OrderbyProperty;
    $.getJSON(url, function (data) {
        if (data) {
            var table = "<div id=‘workflow‘ style=‘text-align:center; margin:0 auto;clear:both; margin-top:5px;‘><table style=‘margin:auto;‘  align=‘center‘ cellpadding=‘0‘ cellspacing=‘1‘ class=‘table‘ id=‘flowTable‘ >";

var tr = "<tr class=‘header‘ style=‘color:#FFFFFF‘>"
        + "<th>序号</th><th scope=‘col‘>操作人</th>"
        + "<th scope=‘col‘>意见</th>"
        + "<th scope=‘col‘>处理步骤</th>"
        + "<th scope=‘col‘>操作类型</th>"
        + "<th scope=‘col‘>操作时间</th></tr>";
            for (var i = 0; i < data.length; i++) {
                if (i % 2 == 0)
                    tr += "<tr class=‘normal‘ style=‘text-align:center‘>";
                else
                    tr += "<tr class=‘alternate‘ style=‘text-align:center‘>";
                var Rec = data[i].TargetUser;
                if (Rec != null)//userId,,@userName,,
                {
                    Rec = Rec.split(‘@‘);
                    Rec = Rec[1];
                }
                else Rec = "";
                var status = data[i].Status;
                if (status == null || status == "null") status = "&nbsp;";
                Rec = (data[i].OpRemark == null || data[i].OpRemark == null) ? "" : data[i].OpRemark;
                tr += "<td>" + (i + 1) + "</td>";
                tr += "<td>" + data[i].OperateBy + "</td>";
                tr += "<td title=‘" + Rec + "‘>" + ((Rec.length > 20) ? Rec.substring(0, 20) + "。。" : Rec) + "&nbsp;</td>";
                tr += "<td>" + status + "&nbsp;</td>";
                tr += "<td>" + data[i].OpType + "</td>";
                tr += "<td>" + data[i].RequestArgs + "&nbsp;</td></tr>";
            }

var button = "<tr style=‘background:#a1b8d7;border:0px solid #6F725B;color:#FFFFFF;height:21px;line-height:21px;padding-left:0px;‘><td colspan=‘6‘><span style=‘text-align:left;line-height:21px; padding-left:10px; float:left; width:100px;  height:21px;‘><button type=‘button‘ id=‘btn_Nextpage‘>下一页</button><button type=‘button‘ id=‘btn_Prepage‘>上一页</button></span><span style=‘text-align:right; float:right; width:100px;‘><button type=‘button‘ id=‘btn_Grah‘>图形日志</button></span></td></tr>";
            table += button + tr + "</table></div>";
            UTIL.wrapToBottom({ id: ‘workflow‘ });
            var i = 1;

var tmpdiv = $("#bpEdit");
            if (DivId == null || typeof (DivId) == "undefined") {
                if (tmpdiv.length > 0) {
                    $(tmpdiv).append(table);
                }
                else
                    $(document.body).append(table);
            }
            else
                $("#" + DivId).html(table);
            tr = $("#flowTable tr");
            $("#btn_Prepage").hide();
            for (var j = Pagesize + 2; j < tr.length; j++) {
                $(tr[j]).hide();
            }
            if (tr.length <= Pagesize + 2) $("#btn_Nextpage").hide();
            var m = 0;
            $("#btn_Nextpage").click(function () {
                m++;
                for (var jj = 2; jj < tr.length; jj++) {
                    $(tr[jj]).hide();
                }
                for (var k = m * Pagesize + 2; k < tr.length && k < (m + 1) * Pagesize + 2; k++) {
                    $(tr[k]).show();
                }
                if ((m + 1) * Pagesize + 2 >= tr.length) $("#btn_Nextpage").hide();
                $("#btn_Prepage").show();

});
            $("#btn_Prepage").click(function () {
                m--;

for (var jj = 2; jj < tr.length; jj++) {
                    $(tr[jj]).hide();
                }
                for (var k = m * Pagesize + 2; k < tr.length && k < (m + 1) * Pagesize + 2; k++) {
                    $(tr[k]).show();
                }
                if ((m + 1) * Pagesize + 2 >= tr.length) $("#btn_Prepage").hide();
                if (m == 0) {
                    $("#btn_Nextpage").show();
                    $("#btn_Prepage").hide();
                }
                $("#btn_Nextpage").show();

});
            $(document.body).css("overflow", "auto");
            $("#btn_Grah").click(function () {
                var url = UTIL.getAppRoot() + "/ModDev/WorkFlowProgress.aspx?Node=" + UTIL.getUrlParam("Node") + "&FormCode=" + UTIL.getUrlParam("FormCode") + "&FormType=" + UTIL.getUrlParam("FormType") + "&Id=" + id;
                window.top.PICKER.offset.max = true;
                window.top.PICKER.open(url, null, null, 500, 500);
            });
        }
    });

}
function PrintFormByTempalate(FormCode, FlowRemark, Id, subTable, subTableBookMark) {
    var url = UTIL.getAppRoot() + "/CommonPage/PrintFormByDoc.aspx?FormCode=" + FormCode;
    if (FlowRemark != null) url += "&FlowRemark=" + FlowRemark;
    if (Id == null) Id = UTIL.getUrlParam("Id");
    url += "&Id=" + Id;
    if (subTable != null) {
        url += "&subTable=" + subTable;
        if (subTableBookMark != null) {
            url += "&subTableBookMark=" + subTableBookMark;
        }
        else {
            alert("子表书签不能为空");
            return;
        }
    }
    window.open(url, ‘newwindow‘, ‘height=1024, width=1000, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no‘);
}
function addCancelButton() {

if (UTIL.getUrlParam("View") == "TRACK") {
        if ($("#txt_FormType_").length > 0 && $("#txt_Id_").length > 0 && $("#txt_Id_").val() != "") {
            var buttonList = $(".toolbar button");
            var exist = false;
            for (var i = 0; i < buttonList.length; i++) {
                if ($(buttonList[i]).attr("id").indexOf("Cancel") >= 0) {
                    exist = true;
                    break;
                }
            }
            if (!exist) {
                var button = "<button type=‘button‘ id=‘btn_Cancel_‘></button>";
                $(".toolbar").append(button);
                $("#btn_Cancel_").click(function () {
                    var url = window.location.href;
                    var tmpUrl = UTIL.getAppRoot() + "/EveryOne/CancelBack.ashx";
                    $.post(tmpUrl, { "Url": url, "Id": UTIL.getUrlParam("Id"), "FormCode": UTIL.getUrlParam("FormCode"), "FormType": UTIL.getUrlParam("FormType") }, function (data) {
                        alert(data);
                        if (data == "撤回成功")
                            PICKER.hide();

});
                });
            }
        }
    }
}
function WorkFlowAccept(id, formtype, btnId) {
    if (id == typeof ("undefined") || id == null) id = $("#txt_Id_").val();
    if (formtype == typeof ("undefined") || formtype == null) {
        formtype = $("#txt_FormType_").val();
    }
    var url = UTIL.getAppRoot();
    if (btnId == typeof ("undefined") || btnId == null) btnId = "btn_Accept_E0";
    if ($(".IsEndCooparate").val() == "1") {
        url += "/ModDev/CooparetRemark.aspx"
    }
    else {
        url += "/ModDev/FlowNodeSelection.aspx";
    }
    url += "?FormId=" + id;
    url += "&FormType=" + formtype;
    PICKER.open(url, null, null, 500, 350, ‘btn_Accept_E0‘, function (vId, vName) {
        $(‘#txtTargetFlowNode‘).val(vId);
        $(‘#txtTargetFlowRemark‘).val(vName);
        var tmpid = ‘#txt_Remark‘ + UTIL.getUrlParam(‘Node‘) + ‘_‘;
        var obj = $(tmpid);
        if (obj.length > 0) {
            var s = $(obj).val();
            if (s != "") {
                s += "\r\n" + vName;
                $(obj).val(s);
            }
            else $(obj).val(vName);

}
        PageOnSubmit = null; //下次直接提交
        $("#" + btnId).click();
    });
    return false;
}
function setDataFormate() {

var obj = $("input");
    for (var i = 0; i < obj.length; i++) {
        var ob = $(obj[i]).val();
        if (ob.IsDate()) {
            if (ob.indexOf(" 0:00:00") >= 0) {

ob = ob.substr(0, ob.indexOf(" 0:00:00"));
                $(obj[i]).val(ob);
            }
        }
    }

}
String.prototype.IsDate = function () {
    var regexp = /^2[0-9]{3}-([1-9]{1}|0[1-9]{1}|1[12]{1})-[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/g;
    return regexp.test(this);
}
function ShowDialogWindow(url, width, height, SearchId) {
    if (typeof (width) == "undefined") {
        width = document.body.clientWidth;
        height = window.top.document.body.clientHeight;
    }
    var features = "dialogWidth=" + width + "px;dialogHeight=" + height + "px;help=0;scroll=auto;;status=0;resizable=no";
    if (url.indexOf("?") < 0) url += "?tmprad=" + Math.random();
    else url += "&tmprad=" + Math.random();
    var fresh = window.showModalDialog(url, null, features);
    if (!(typeof (SearchId) == "undefined" || SearchId == null)) {
        if (fresh && (fresh == "1" || fresh.indexOf(".aspx") > 0)) {
            if (fresh.indexOf(".aspx") > 0) {
                var url = fresh;
                ShowDialogWindow(url, width, height, SearchId);
            }
            $("#" + SearchId).trigger("click")
        }
    }
    return fresh;

}
function CloseWindow(url) {
    ;
    if ((typeof (url) == "undefined" || url == null)) url = "1";
    window.returnValue = url;
    window.opener = null;
    window.close();
}
function SetTodoView(FormType, IdColumnsIndex, grdv, func) {
    var url = UTIL.getAppRoot() + "/EveryOne/userToDo.ashx?FormType=" + FormType;
    $.getJSON(url, function (data) {
        if (data) {
            $("#" + grdv + " .LinkTitle").each(function (j, o) {
                var obj = $("td", $(o).parent());
                for (var i = 0; i < data.length; i++) {
                    if (data[i].FormId == obj.eq(IdColumnsIndex).text()) {
                        $(o).attr("url", data[i].Properties.Url);
                        break;
                    }
                }
            });
        }
        if (!(func == null || typeof (func) == "undefined")) {
            func();
        }
    });
}
var UserManageCallBack = function (vid, vname) {
}

function BindDrop(value, drp) {
    drp = $("#" + drp).get(0);
    for (var i = 0; i < drp.options.length; i++) {
        if (drp.options[i].value == value) {
            return drp.options[i].text;
        }
    }
    return "";
}
function SetMenuButtonStatus(buttonId) {
    //$(".datagrid-toolbar a").hide();
    if (buttonId != null) {
        buttonId = buttonId.split(‘,‘);
        $(".datagrid-toolbar a").each(function (i, o) {
            o = $(o);
            var id = o.attr("id");
            var exists = false;
            for (var k = 0; k < buttonId.length; k++) {
                var btn = buttonId[k];
                if (id == btn) {
                    exists = true;
                    break;
                }
            }
            if (!exists) {
                o.hide();
            }
        });
    }
    else {
        $(".datagrid-toolbar a").hide();
    }
    $("#btn_close").show();
}
jQuery.validator.addMethod("combogrid", function (value, element) {
    var obj = $("input", $(element).parent().parent()).eq(0);
    var val = $(obj).combogrid(‘getValue‘);
    if (val == null || val == "") {
        return false;
    }
    else {
        return true;
    }
});
$.fn.fileUpLoad = function (option) {
    var html = "<div id=‘uploadControl‘></div>";
    var max_file_size = "5mb";
    var files = [];
    var errors = [];
    var type = ‘file‘;
    var filters = { title: "文档", extensions: "zip,doc,docx,xls,xlsx,ppt,pptx" };
    var chunk = false;
    if (option.filters) {
        filters = option.filters;
    }
    var url = "/upload.ashx";
    if (option.url) {
        url = option.url;
    }
    if (option.max_file_size) {
        max_file_size = max_file_size;
    }
    $(this).pluploadQueue($.extend({
        runtimes: ‘flash,html4,html5‘,
        url: url,
        max_file_size: max_file_size,
        file_data_name: ‘file‘,
        unique_names: true,
        filters: [filters],
        flash_swf_url: ‘/Scripts/plupload/plupload.flash.swf‘,
        init: {
            FileUploaded: function (uploader, file, response) {
                if (response.response) {
                    var rs = $.parseJSON(response.response);
                    if (rs.status) {
                        files.push(file.name);
                    } else {
                        errors.push(file.name);
                    }
                }
            },
            UploadComplete: function (uploader, fs) {
                var e = errors.length ? ",失败" + errors.length + "个(" + errors.join("、") + ")。" : "。";
                $.messager.alert(‘操作提示‘, "上传完成!共" + fs.length + "个。成功" + files.length + e, "info");
                if (option.callBack) {
                    option.callBack();
                }
                artDialog.close();
            }
        }
    }, (chunk ? { chunk_size: ‘1mb‘} : {})));
}

时间: 2024-10-20 17:57:05

util.js的相关文章

使用util.js处理列表

(util.js文件的链接:http://pan.baidu.com/s/1kUMJNrL 密码:fiqs) 1.前言 此处所指的列表,不仅包括<select-/>元素产生列表框.下拉菜单,还包括<ul-/>和<ol-/>列表.操作这种列表当然可直接通过DOM操作来完成,但通过util.js函数将更加简单. 处理列表相关函数主要由dwr.util对象的removeAllOptions()和addOptions()两个函数写成.其中removeAllOptions()函数

使用util.js处理表格

(util.js文件的链接:http://pan.baidu.com/s/1kUMJNrL 密码:fiqs) 1.前言 dwr.util提供了两个函数帮助我们处理HTML表格操作,这两个函数是addRows()和removeAllRows().其中用于向表格添加行,而removeAllRows用于删除表格中的全部行.两个函数的语法格式如下: 1)        dwr.util.removeAllRows(tableId):该函数只有一个参数,该参数是一个HTML表格元素的id属性值. 2)  

百度地图V2.0实践项目开发工具类bmap.util.js V1.4

/** * 百度地图使用工具类-v2.0(大眾版) * * @author boonya * @date 2013-7-7 * @address Chengdu,Sichuan,China * @email [email protected] * @company KWT.Shenzhen.Inc.com * @notice 有些功能需要加入外部JS库才能使用,另外还需要申请地图JS key . * 申请地址:http://developer.baidu.com/map/apply-key.ht

leaflet开源地图库源码研读(五)——extend、Object.create、fn.bind分析(Util.js文件)

一.extend:扩展对象的属性 1 var Util = { 2 extend: function (dest) { 3 var i, j, len, src; 4 for (j = 1, len = arguments.length; j < len; j++) { 5 src = arguments[j]; 6 for (i in src) { 7 dest[i] = src[i]; 8 } 9 } 10 return dest; 11 } 12 } 可以,看出extend方法里有2个fo

记录JavaScript的util.js类库

工作中用到的, 不断做为积累, 以后能用到. 也感谢前辈们.  定义Util对象 var MyUtil = new Object(); 从url中获取参数 //从url中获取参数 function GetQueryString(name) { var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(

util.js(涉及到当前项目的一些公共方法)

var requestSign = require('./requestData.js'); var api = require('./api.js').open_api; var re = require('./request.js'); var header = getApp().header; var app = getApp(); var time = require('../utils/time.js') export function getTemData() { } //检测是否已

javascript util.js

//根据Id获得页面元素 function $(para) {    return document.getElementById(para);} //创建一个新的元素function createElement(type, name) {    if (name) {        var element = null;        try {            element = document.createElement("<" + type + " na

easyui DataGrid 工具类之 util js

var jq;                var tab;                var tabsIndex;                                /**                 * 常用说明                 * @param row                 * @returns {String}                 */                function formatItem(row) {     

spring与dwr整合实现js直接使用java代码

此文章是基于 搭建Jquery+SpringMVC+Spring+Hibernate+MySQL平台 一. 准备工作 1. 点击此下载相关文件,并把文件放到 ims 工程对应的文件夹下 二. jar包介绍 1. dwr-3.0.1.jar,支持 spring 4.3.4 的最低版本 三. 相关文件介绍 1. web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="