笔记 meta.common.js

 

var metaUtils = {'name': 'meta-utils', 'version': 1.0};

var MetaContent= {};

MetaContent.conf = {

serverStaticUrl: "",

serverUrl: ""

}

 

 

$(document).ready(function(){

    setTimeout(function(){$(".Flash").slideUp("normal")}, 3000);

});

 

/**

 * 创建一个新的StringBuilder实例

 * 

 * @constructor

 * @name StringBuilder

 * @param {Object}

 *            o 要添加到序列首部的对象。

 * @returns {StringBuilder}的新实例。

 */

function StringBuilder(o) {

    this.__s__ = [];

    if (o) this.append(o);

};

StringBuilder.prototype = {

    /**

     * 追加<tt>Object</tt>参数的字符串表示形式。

     * 

     * @param {Object}

     *            obj 一个对像

     * @returns 返回 StringBuilder 对象的一个引用。

     */

    append: function(obj) {

        if (!obj) {

            return this;

        }

        if ($.isArray(obj)) {

            this.__s__.push(obj.join('').toString());

        } else {

            this.__s__.push(obj.toString());

        }

        return this;

    },

    /**

     * 清空StringBuilder字符集。

     */

    clear: function() {

        this.__s__ = [];

    },

    /**

     * 返回此序列中数据的字符串形式。

     * 

     * @return {String} 字符串。

     */

    toString: function() {

        return this.__s__.join('').toString();

    }

};

(function($) {

    //fix bug for jquery browser

    var uaMatch = function() {

        var ua = navigator.userAgent.toLowerCase();

        var match = /(webkit)[ //]([/w.]+)/.exec( ua ) ||

            /(opera)(?:.*version)?[ //]([/w.]+)/.exec( ua ) ||

            /(msie) ([/w.]+)/.exec( ua ) ||

            !/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([/w.]+))?/.exec( ua ) ||

            [];

 

        return { browser: match[1] || "", version: match[2] || "0" };

    }

    browserMatch = uaMatch();

    if (browserMatch.browser) {

        $.browser[browserMatch.browser] = true;

        $.browser.version = browserMatch.version;

    }

 

    var __s__ = Object.prototype.toString;

    /**

     * 将给定的对象,转换成JSON格式字符串。

     * 

     * @param {Object}

     *            o 要转换成JSON的Javascript对象。

     * @returns {String} 返回给定的Javascript对象的JSON格式的字符串。

     */

    Object.toJSON = function(o) {

        var t = typeof o;

        switch (t) {

        case 'undefined':

        case 'function':

        case 'unknown':

            return 'null';

        case 'boolean':

            return o.toString();

        }

        if (o === null || (o && o.nodeType == 1))

            return 'null';

        if (typeof o.toJSON === 'function')

            return o.toJSON();

        var ret = [], name, val;

        for ( var key in o) {

            t = typeof key;

            if (t === 'number')

                name = '"' + key + '"';

            else if (t === 'string')

                name = key.quote();

            else

                continue;

            val = Object.toJSON(o[key]);

            if (typeof val !== 'undefined')

                ret.push(name + ':' + val);

        }

        return '{' + ret.join(',') + '}';

    };

    /**

     * 捕捉script标签的正则表达式常量。

     * 

     * @type RegExp

     */

    RegExp.ScriptExpr = /<script[^>]*>([/S/s]*?)<//script>/igm;

    /**

     * 表示为&quot;null&quot;的字符串常量。

     * 

     * @type String

     */

    String.Null = 'null';

    /**

     * 表示为空字符串 &quot;&quot;的字符串常量。

     * 

     * @type String

     */

    String.Empty = '';

    /**

     * 表示为特殊字符的字符串Hash组。

     * 

     * @type Object

     */

    String.SpecialChars = {

        '/b': '//b',

        '/t': '//t',

        '/n': '//n',

        '/f': '//f',

        '/r': '//r',

        '"' : '//"',

        '//': ''

    };

 

    String.prototype.len = function() {

        var regex = /[/u0391-/uFFE5]/g;

        return this.replace(regex, "xx" ).length;

    }

 

    /**

    * length 表示要截取的长度

    * ellipseText 表示要添加省略的后缀

    *

    */

    String.prototype.truncate = function (length, ellipseText) {

        if(length <= 0){

            return "";

        }

        var ELLIPSE_TEXT  = "...";

        if(metaUtils.isUndef(ellipseText)){

            ellipseText = ELLIPSE_TEXT;

        }

        length = length - ellipseText.length;

        if(length <= 0){

            return ellipseText.escapeHTML();

        }

        if (this.len() <= length) {

            return this.escapeHTML();  

        }

        var middle = Math.floor(length / 2);       

        for (var i = middle; i < this.length;i++) {        

            if (this.substr(0, i).len() > length) {        

                return (this.substr(0, i-1) + ellipseText).escapeHTML() ; 

            }        

        }  

        return this.escapeHTML() ;       

    };  

    Object.extend = function(target, /* optional */source, /* optional */deep) {

        target = target || {};

        var sType = typeof source, i = 1, options;

        if (sType == 'undefined' || sType == 'boolean') {

            deep = sType == 'boolean' ? source : false;

            source = target;

            target = this;

        }

        if (typeof source != 'object' && __tostr__.call(source) != '[object Function]')

            source = {};

        while (i <= 2) {

            options = i == 1 ? target : source;

            if (options != null) {

                for ( var name in options) {

                    var src = target[name], copy = options[name];

                    if (target == copy)

                        continue;

                    if (deep && copy && typeof copy == 'object' && !copy.nodeType)

                        target[name] = this.extend(src || (copy.length != null ? [] : {}), copy,

                                deep);

                    else if (copy != undefined)

                        target[name] = copy;

                }

            }

            i++;

        }

        return target;

    };

    Object.extend(String.prototype,

    {

        /**

         * 返回字符串的副本,用引号引用此字符串。

         * 

         * @returns {String} 被双引号引用的字符串。

         */

        quote: function() {

            var string = this;

            var _escapeable = /["///x00-/x1f/x7f-/x9f]/g;

            if (string.match(_escapeable)) {

                return '"' + string.replace(_escapeable, function (a) {

                    var c = String.SpecialChars[a];

                    if (typeof c === 'string') return c;

                    c = a.charCodeAt();

                    return '//u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);

                }) + '"';

            }

            return '"' + string + '"';

        },

        /**

         * 返回字符串的副本,忽略前导空白和尾部空白。

         * 

         * @returns {String} 此字符串移除了前导和尾部空白,如果没有前导和尾部空白字符,则返回此字符串。

         */

        trim: function() {

            return this.replace(/^/s+|/s+$/g, '');

        },

        /**

         * 返回字符串的副本,忽略前导空白。

         * 

         * @returns {String} 此字符串移除了前导空白,如果没有前导空白字符,则返回此字符串。

         */

        ltrim: function() {

            return this.replace(/^/s+/g, '');

        },

        /**

         * 返回字符串的副本,忽略尾部空白。

         * 

         * @returns {String} 此字符串移除了尾部空白,如果没有尾部空白字符,则返回此字符串。

         */

        rtrim: function() {

            return this.replace(//s+$/g, '');

        },

        /**

         * 返回字符串的副本,忽略前导空白和尾部空白。

         * 

         * @returns {String}

         * @see 见<a href="#trim">trim()<a>

         */

        strip: function() {

            return this.trim();

        },

        /**

         * 返回字符串的副本,忽略字符串内部的含有的所有标签字符串包括忽略标签里有一些JS事件。

         * 

         * @param {String}

         *            replacement 用于替换标签的指定字符串。

         * @returns {String} 此字符串移除了所有的表为HTML标签的字符,如没有标签字符,则返回此字符串。

         */

        stripTags: function(replacement) {

            return this.replace(/<(?:/"[^/"]*/"|/'[^/']*/'|[^><])*>/igm, (replacement || ''));

        },

        /**

         * 返回字符串的副本,忽略字符串的HTML的Script标签字符串。

         * 

         * @param {String}

         *            replacement 用于替换标签的指定字符串。

         * @returns {String} 此字符串移除了所有的表示为HTML的Script标签的字符,如没有Script标签,则返回此字符串。

         */

        stripScript: function(replacement) {

            return this.replace(new RegExp(RegExp.ScriptExpr), (replacement || ''));

        },

        /**

         * 返回字符串的副本,字符串中的特定字符将被转换。unescapeHTML方法可还原经该方法转换的字符串。

         * 

         * @returns {String} 此字符串将转换特定的字符,如没有那些字符,则返回此字符串。

         */

        escapeHTML: function() {

            return this.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(

                    //"/g, '&quot;').replace(//'/g, '&#39;');

        },

        /**

         * 返回字符串的副本,字符串中的特定字符将被转换,escapeHTML方法可还原经该方法转换的字符串

         * 

         * @returns {String} 此字符串将转换特定的字符,如没有那些字符,则返回此字符串。

         */

        unescapeHTML: function() {

            return this.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(

                    /&quot;/g, '"').replace(/&#39;/g, '/'');

        },

        /**

         * 返回字符串的副本,字符串中的格式字符将被转换。

         * 

         * @param {Boolean}

         *            reverse 指示是否使用反向转换。

         * @returns {String} 此字符串将转换格式字符,如没有格式字符,则返回此字符串。

         */

        formatHTML: function(reverse) {

            var str = this.toString();

            if (reverse) {

                str = str.replace(/<br[^>]*>/gm, '/n').replace(/&nbsp;/gm, ' ').replace(/&/gm,

                        '&amp;');

            } else {

                str = str.replace(/&amp;/gm, '&').replace(/ /gm, '&nbsp;').replace(//r/n/gm, '/n')

                        .replace(//n/gm, '<br />');

            }

            return str;

        },

        /**

         * 返回字符串的长度,若指定 <tt>b</tt> ,则返回UTF-8编码的字符串长度。

         * 

         * @param {boolean}

         *            b 是否返回UTF-8编码的字符串长度。

         * @returns {Number} 返回字符串的长度。

         */

        len: function(b) {

            var t = typeof b === 'boolean';

            var s = this.toString();

            if (t == true || (typeof b === 'string' && b.toLowerCase() === 'utf8')) {

                return s.replace(/[^/x00-/xFF]/g, '***').length;

            } else if (t == false && typeof b === 'string' && b.toLowerCase() === 'gbk') {

                return s.replace(/[^/x00-/xFF]/g, '**').length;

            }

            return this.length;

        },

        /**

         * 测试此字符串是否以指定的前缀开始。

         * 

         * @param {String}

         *            p 指定的前缀。

         * @returns {boolean}

         */

        startsWith: function(p) {

            return p === '' ? true : (this.indexOf(p) === 0);

        },

        /**

         * 测试此字符串是否以指定的后缀结束。

         * 

         * @param {String}

         *            p 指定的后缀。

         * @returns {boolean}

         */

        endsWith: function(p) {

            if (p === '') return true;

            var d = this.length - p.length;

            return d >= 0 && this.lastIndexOf(p) === d;

        },

        /**

         * 替换所有模式匹配字符串。

         * 

         * @param {String}

         *            p 模式

         * @param {String}

         *            str 替换字符串

         * @returns {String}

         */

        replaceAll: function(p,str){

            var regExp = new RegExp(p,"gm");

            return this.replace(regExp, str);

        },

        /**

         * 测试此字符串是否是一串空格组成的空字符串。

         * 

         * @returns {boolean}

         */

        isBlank: function() {

            return this.length > 0 && /^/s*$/.test(this);

        },

        /**

         * 测试此字符串是否是一个正确格式的Email。

         * 

         * @returns {boolean}

         */

        isEmail: function() {

            return (/^(?:/w+/.?)*/w+@(?:/w+/.?)*[a-zA-Z]{2,3}$/i).test(this.trim());

        },

        /**

         * 测试此字符串是否是空字符串。

         * 

         * @returns {boolean} 如果该字符串是空字符串,则为true,否则为false。

         */

        isEmpty: function() {

            return this === String.Empty;

        },

        /**

         * 测试此字符串是否全部由数字组成。

         * 

         * @returns {boolean}

         */

        isNumber: function() {

            return /^/d+$/.test(this);

        },

        /**

         * 测试此字符串是否为合法的变量命名。

         * 

         * @returns {boolean}

         */

        isVar: function() {

            return /^[a-zA-Z_]/w*$/.test(this);

        },

        /**

         * 将此字符串转换成JSON格式。

         * 

         * @returns {String} 此字符串的JSON格式的副本。

         */

        toJSON: function() {

            return this.quote();

        }

    }, true);

    /**

     * 将此Date对象,转换成JSON格式字符串。

     * 

     * @return (String) 返回此Date的JSON格式字符串。

     */

    Date.prototype.toJSON = function() {

        return this.getFullYear() + '-' + this.getMonth().filled() + '-' + this.getDate().filled

                + ' ' + this.getHours().filled() + ':' + this.getMinutes().filled() + ':'

                + this.getSeconds().filled() + ',' + this.getMilliseconds().filled();

    };

 

    /**

     * 将此Date对象转换成字符串。

     * @example

     * new Date().format("yyyy-MM-dd hh:mm:ss")

     * 

     * @return (String) 返回此Date的格式字符串。

     */

    Date.prototype.format = function(format) {   

        var o = {   

            "M+" : this.getMonth() + 1, //month  

            "d+" : this.getDate(),    //day  

            "h+" : this.getHours(),   //hour  

            "m+" : this.getMinutes(), //minute  

            "s+" : this.getSeconds(), //second

            //quarter  

            "q+" : Math.floor((this.getMonth() + 3) / 3), 

            "S" : this.getMilliseconds() //millisecond  

        }   

        if(/(y+)/.test(format)) format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length));   

        for(var k in o) { 

            if(new RegExp("(" + k + ")").test(format)) {   

                format = format.replace(

                        RegExp.$1, RegExp.$1.length == 1 ? 

                                o[k] : ("00"+ o[k]).substr(("" + o[k]).length));

            }

        }

        return format;

     }  

 

    metaUtils.EmptyFn = function() {};

    /**

     * 若指定的对象 o 是一个布尔值对象,则返回 true,否则返回 false。

     * 

     * @param {Object}

     *            o 要检查的对象。

     * @type Boolean

     */

    metaUtils.isBool = function(o) {

        return typeof o === 'boolean';

    };

    /**

     * 若指定的对象 o 是一个HTMLElement对象,则返回 true,否则返回 false。

     * 

     * @param {Object}

     *            o 要检查的对象。

     */

    metaUtils.isElement = function(o) {

        return o && o.nodeType === 1;

    };

    /**

     * 若指定的对象 o 是一个空字符串或者是一个长度为0的数组,则返回 true,否则返回 false .

     * 

     * @param {Object}

     *            o 要检查的对象 .

     */

    metaUtils.isEmpty = function(o) {

        return meta.isArray(o) ? o.length === 0 : (meta.isString(o) ? o === String.Empty : false);

    };

    /**

     * 若指定的对象 o 是一个null值或者空字符串或者是一个长度为0的数组,则返回 true,否则返回 false .

     * 

     * @param {Object}

     *            o 要检查的对象 .

     */

    metaUtils.isNullOrEmpty = function(o) {

        return (o == null || this.isEmpty(o));

    };

    /**

     * 若指定的对象 o 是一个字符串,则返回 true,否则返回 false。

     * 

     * @param {Object}

     *            o 要检查的对象。

     */

    metaUtils.isString = function(o) {

        return typeof o === 'string';

    };

    /**

     * 若指定的对象 o 是一个数组,则返回 true,否则返回 false。

     * 

     * @param {Object}

     *            o 要检查的对象。

     */

    metaUtils.isArray = function(o) {

        return __s__.call(o) === '[object Array]';

    };

    /**

     * 若指定的对象 o 是一个函数,则返回 true,否则返回 false。

     * 

     * @param {Object}

     *            o 要检查的对象。

     */

    metaUtils.isFunction = function(o) {

        return __s__.call(o) === '[object Function]';

    };

    /**

     * 若指定的对象 o 是一个数字,则返回 true,否则返回 false。

     * 

     * @param {Object}

     *            o 要检查的对象。

     * @type Boolean

     */

    metaUtils.isNumber = function(o) {

        return typeof o === "number" && isFinite(o);

    };

    /**

     * 若指定的对象o是一个undefined,则返回 true,否则返回false。

     * 

     * @param {Object}

     *            o 要检查的对象。

     * @type Boolean

     */

    metaUtils.isUndef = function(o) {

        return typeof o === 'undefined';

    };

})(jQuery);

 

/*

 * Copyright (C) woyo.com, Inc. All rights reserved.

 *

 * Depend on jQuery 1.3.x

 */

var metaPopup = {name: 'meta-popup', version: 1.0};

window.metaPopup = metaPopup = {ERROR:0, SUCCESS:1, CONFIRM:2, NORMAL:3};

(function($) {

    $.fn.extend({

        overlay: function(ops,id){

            var ops = $.extend({

                    position: 'fixed', top: 0, left: 0,

                    width: '100%',height: '100%',

                    opacity: 0.2, background: '#eeeeee', zIndex: 99

                }, ops),

            id = id || 'overlay';

            if( $.browser.msie && $.browser.version < 7 ) ops = $.extend(ops, {

                position: 'absolute',

                width: Math.max($(window).width(),$(document.body).width()),

                height: Math.max($(window).height(),$(document.body).height()) });

 

            return $('<div class="overlay" id="'+id+'"/>').appendTo(document.body).css(ops);

        },

 

        pos: function(ops){

            var ops = $.extend({

                    fixx: 0,

                    fixy: 0

                }, ops),

                mod = (this.css("position")=="fixed") ? 0 : 1,

                t = $(document).scrollTop()*mod,

                l = $(document).scrollLeft()*mod,

                mt = t;

 

            l += ($(window).width() - this.width()) / 2;

            t += ($(window).height() - this.height()) / 2;

 

            l += ops.fixx;

            t = Math.max(t, mt)+ops.fixy;

 

            if(t<0) t = 0;

            if(l<0) l = 0;

 

            return this.css({top: t, left: l});

        },

 

        close: function(id){

            var id = id || 'popup';

            $('#_overlay').add([document, window]).unbind('._overlay');

            $('#'+id).add([document, window]).unbind('._darg');

            $('#_overlay').remove();

            var select = $('select').ie6fix(true);

            if(select)select.ie6fix(false);

            $('#'+id).fadeOut('fast',function(){$(this).remove()});

        },

 

        dragdrop:function(ops,callback) {

            if(typeof(ops)=='function')callback=ops;

            this.css('position','absolute');

            var ops = $.extend({

                }, ops),handle=ops.handle ? $(ops.handle, this) : this,

                flag =false,_o={left:0,top:0},self=this;

 

            function pos(e){

                if (flag) {self.css( {left : e.pageX - _o.left + 'px',top : e.pageY - _o.top + 'px'});}

            }

            handle.mousedown(function(e){

                flag = true;

                self.css('z-index',parseInt(new Date().getTime()/1000));

                var offset = self.offset();

                _o = { left: e.pageX - offset.left, top: e.pageY - offset.top };

                $(document).mousemove(pos);

            }).mouseup(function(e){

                pos(e);

                flag = false;

                $(document).unbind('mousemove');

                if(callback)callback.apply(this,[self]);

            }).css('cursor','move');

            return self;

        },

 

        popup: function(ops,callback){

            var ops = $.extend({

                    buttons:{}, esc: true, id: 'popup', iframe: false, scrolling:'no',

                    //overlay: { opacity: 0.2, background: '#eeeeee' },

                    text: '', title: '系统消息', type: metaPopup.SUCCESS, zIndex:1000

                }, ops),

                self = this;

 

            if (typeof ops.modal !== 'undefined' && ops.modal == true) {

                ops.overlay = { opacity: 0.2, background: '#eeeeee' };

            }

 

            function close(){

                self.close(ops.id);

            }

 

            var o = $('#'+ops.id);

 

            switch(ops.action){

                case -1://resize

                    $('.pcontent', o).animate(callback,function(){o.ie6fix(false);}).find('iframe').css(callback);

                    return;

                case 0://retitle

                    $('.title', o).text(ops.text);

                    return;

                case 1://first btn

                    $('.center_btn', o).children('a:nth-child(1)').trigger('click');

                    return;

                case 2://second btn

                    $('.center_btn', o).children('a:nth-child(2)').trigger('click');

                    return;

                case 9://close

                    $('.close', o).trigger('click',callback);

                    return;

                case 8:

                    callback.apply(this, arguments);

                    return;

                default:

                    (o.length==1) && close(); 

            }

 

            var pHtm;

 

            if(ops.iframe){

                pHtm = $('<iframe src="'+ops.url+'" marginwidth="0" id="popup_iframe" marginheight="0" frameborder="0" hspace="0" vspace="0" scrolling="'+ops.scrolling+'" />')

                .css({ width: ops.width-16, height: ops.height==0 ? 'auto' : ops.height-74 });

            }else{

                pHtm = $('<p>'+ops.text+'</p>');

 

            }

 

            var pContent = $('<div class="bd "/>').append(pHtm)

                .wrap('<div class="thickbox box "/>')

                .wrap('<div class="pop_box"/>'),

 

            pContainer = pContent.parent(),

 

            pClose = $('<div class="hd title"/>')

                .append('<h2>' + ops.title + '</h2>')

                .append('<a href="javascript:void(0);" class="close" title="关闭">关闭</a>')

                .prependTo(pContainer),

 

            _p = ($.fn.ie6) ? 'absolute' : 'fixed'; 

            popup = pContainer.parent()

                .css({

                    position: _p, zIndex: 99+ops.zIndex,

                    top: ops.iframe?($(window).height()-ops.height) / 2-60:($(window).height()-ops.height) / 2, left:($(window).width()-ops.width)/ 2, width: ops.width, height: ops.height==0 ? 'auto' : ops.height, outline: 0

                })

                .attr({ id: ops.id, tabIndex: '-1' }).appendTo(document.body).hide()

                .keydown(function(ev) {

                    if (ops.esc) {

                        (ev.keyCode && ev.keyCode == 27 && close());

                    }

                })

                .dragdrop({handle:'.hd'}),

 

            btnPane = $('<div class="center_btn"/>').appendTo(pContent);

            pContainer.parent().append("<div class=/"iframe_box/"><iframe scrolling=/"no/" frameborder=/"no/" src=/"about:blank/" class=/"pop_iframe/"></iframe></div>");

            $('.close', pClose)

                .mousedown(function(ev) {

                    ev.stopPropagation();

                })

                .click(function(event, callback) {

                    if(callback) callback.apply(this, arguments);

                    close();

                    return false;

                });

 

            var hasBtns = false, genBtns = [];

            function newBtns(btns) {

                btnPane.empty().hide(); 

                $.each(btns, function() { return !(hasBtns = true); });

                if (hasBtns) {

                    btnPane.show();

                    $.each(btns, function(name, fn) {

                        //genBtns.push($('<a href="javascript:;"/>')

                        genBtns.push($('<input type="submit" class="btn" />')

                            .attr("value", name)

                            .appendTo(btnPane)

                            .bind('click', function() { fn.apply(this, arguments);return false;}));

                    });

                }

            }

            newBtns(ops.buttons);

 

            if(ops.overlay){

                var _overlay = $().overlay( $.extend(ops.overlay, { position: _p }),'_overlay' );

                if (ops.esc) {

                    $(document).bind('keydown._overlay', function(e) {

                        (e.keyCode && e.keyCode == 27 && close()); 

                    });

                }

            }

            popup.pos( ops.iframe ? { fixy: -60 } : {} ).show();       

            var select = $('select').ie6fix(true);

            if(window.event){event.returnValue = false;}

        },

 

        ie6fix: function(flag){

            return ($.fn.ie6)?this.css('visibility', flag ? 'hidden':'visible'):this;

        }

    });

 

    /**

     * 增强window默认的alert对话框

     * @example

     * 

     * <pre>

     * alert({

     *     title: '对话框标题',

     *     text: '正文的内容可以是HTML',

     *     modal: false,

     *     ok: function() {

     *         // 点击确定后调用

     *     }

     * });

     * </pre>

     * @param {object} ops  alert相关参数<br>

     *    ops.text --对话框的内容 (必选)<br/>

     *    ops.modal --是否是模态框 (可选)<br>

     *    ops.type --对话框中的图标类型(可选)<br>

     *    ops.ok --确定后的回调函数(可选)<br>

     */

    window.alert = function(ops) {

        var ops = (typeof ops === 'string' ? {text:ops} : ops);

        $(document.body).popup( $.extend({

            buttons: {

                确定: function(){

                    $(document.body).popup( { action: 9, id: ops.id }, ops.ok||function(){});

                }

            },

            modal: true,

width: 240,

            height: 0,

            type: metaPopup.SUCCESS //0:error 1:success 3:normal 

        }, ops));

    };

 

    /**

     * 增强window默认的confirm对话框

     * @example

     * 

     * <pre>

     * confirm({

     *     title: '确认框标题',

     *     text: '正文的内容可以是HTML',

     *     modal: false,

     *     ok: function() {

     *         // 点击确定后调用

     *     },

     *     cancel: function() {

     *         //点击取消后调用

     *     }

     * });

     * </pre>

     * @param {object} ops  confirm相关参数<br>

     *    ops.text --对话框的内容 (必选)<br/>

     *    ops.modal --是否是模态框 (可选)<br>

     *    ops.ok --确定后的回调函数(可选)<br>

     *    ops.cancel --取消后的回调函数(可选)<br>

     */

    window.confirm = function(ops) {

        var ops = (typeof ops === 'string' ? {text:ops} : ops);

        $(document.body).popup( $.extend({

            buttons: {

                确定: function(){

                    $(document.body).popup( { action: 9, id: ops.id }, ops.ok||function(){});

                },

                取消: function(){

                    $(document.body).popup( { action: 9, id: ops.id }, ops.cancel||function(){});

                }

            },

            modal: true,

width: 240,

            height: 0,

            type: metaPopup.CONFIRM //2:confirm 

        }, ops));

    };

 

    /**

     * 打开对话框

     * @example

     * 

     * <pre>

     * dialog({

     *     text: '内容<form action=/'http://localhost//'><input type=text value=sina><input type=submit value=提交></form>',

     *     title: '对话框标题',

     *     width: 480,

     *     height: 320,

     *     modal: true,

     *     scrolling: 'auto'

     * });

     * </pre>

     * @param {object} ops dialog相关参数<br>

     *    ops.url --网页地址(必须)<br>

     *    ops.title --对话框标题(可选)<br>

     *    ops.modal --是否是模态框 (可选)<br>

     *    ops.scrolling --是否滚动(可选)<br>

     */

    window.dialog = function(ops) {

        return $(document.body).popup( $.extend({

            type: metaPopup.NORMAL,

            iframe: false,

            type: 9,

           modal: true,

            width: 480,

            height: 320

        }, ops));

    }

 

    /**

     * 打开一张页面

     * @example

     * 

     * <pre>

     * openPage({

     *     url: '网页地址',

     *     title: '对话框标题',

     *     widht: 800,

     *     height: 600,

     *     modal: true,

     *     scrolling: 'auto'

     * });

     * </pre>

     * @param {object} ops  openPage相关参数<br>

     *    ops.url --网页地址(必须)<br>

     *    ops.title --对话框标题<br>

     *    ops.scrolling: --滚动样式<br>

     */

    window.openPage = function(ops) {

        $(document.body).popup( $.extend({

            //buttons: {},

            scrolling: 'no',

            iframe: true,

            type: 9,

            width: 480,

            height: 120

        }, ops));

    };

    //$.fn.popup({iframe:true,url:'xxx.action',title:'xxx',type:9,width:480,height:320});   

})(jQuery);

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值