(function ($) { $.pe = $.pe || { version: '0.3.7' }; $.fn.easydrag = function (h) { return i(this, h, 'd') }; $.fn.easyresize = function (h) { return i(this, h, 'r') }; $.dragandresize = { dragandresize: {}, e: 0, drag: function (v) { if (m.k == 'd') e.css({ left: m.x + v.pagex - m.px, top: m.y + v.pagey - m.py }); else e.css({ width: math.max(v.pagex - m.px + m.w, 0), height: math.max(v.pagey - m.py + m.h, 0) }); return false }, stop: function () { //e.css('opacity', 1); $(document).unbind('mousemove', j.drag).unbind('mouseup', j.stop) } }; var j = $.dragandresize, m = j.dragandresize, e = j.e, i = function (e, h, k) { return e.each(function () { h = (h) ? $(h, e) : e; h.css('cursor', 'move'); h.bind('mousedown', { e: e, k: k }, function (v) { var d = v.data, p = {}; e = d.e; if (e.css('position') != 'relative') { try { e.position(p); } catch (e) { } } m = { x: p.left || f('left') || 0, y: p.top || f('top') || 0, w: f('width') || e[0].scrollwidth || 0, h: f('height') || e[0].scrollheight || 0, px: v.pagex, py: v.pagey, k: d.k }; e.css({ //opacity: 0.8 }); $(document).mousemove($.dragandresize.drag).mouseup($.dragandresize.stop); return false }) }) }, f = function (k) { return parseint(e.css(k)) || false }; var l; l = $.pe.expose = { conf: { maskid: 'expose', loadspeed: 'slow', closespeed: 'fast', closeonclick: true, closeonesc: true, zindex: 9998, opacity: 0.5, startopacity: 0, color: '#000', onload: null, onclose: null } }; function viewport() { if ($.browser.msie) { var d = $(document).height(), w = $(window).height(); return [window.innerwidth || document.documentelement.clientwidth || document.body.clientwidth, d - w < 20 ? w : d] } return [$(document).width(), $(document).height()] } function call(a) { if (a) { return a.call($.mask) } } var m, exposed, loaded, config, overlayindex; $.mask = { load: function (b, c) { if (loaded) { return this } if (typeof b == 'string') { b = { color: b } } b = b || config; config = b = $.extend($.extend({}, l.conf), b); m = $("#" + b.maskid); if (!m.length) { m = $('
').attr("id", b.maskid); $("body").append(m) } var d = viewport(); m.css({ position: 'absolute', top: 0, left: 0, width: d[0], height: d[1], display: 'none', opacity: b.startopacity, zindex: b.zindex }); if (b.color) { m.css("backgroundcolor", b.color) } if (call(b.onbeforeload) === false) { return this } if (b.closeonesc) { $(document).bind("keydown.mask", function (e) { if (e.keycode == 27) { $.mask.close(e) } }) } if (b.closeonclick) { m.bind("click.mask", function (e) { $.mask.close(e) }) } $(window).bind("resize.mask", function () { $.mask.fit() }); if (c && c.length) { overlayindex = c.eq(0).css("zindex"); $.each(c, function () { var a = $(this); if (!/relative|absolute|fixed/i.test(a.css("position"))) { a.css("position", "relative") } }); exposed = c.css({ zindex: math.max(b.zindex + 1, overlayindex == 'auto' ? 0 : overlayindex) }) } m.css({ display: 'block' }).fadeto(b.loadspeed, b.opacity, function () { $.mask.fit(); call(b.onload) }); loaded = true; return this }, close: function () { if (loaded) { if (call(config.onbeforeclose) === false) { return this } m.fadeout(config.closespeed, function () { call(config.onclose); if (exposed) { exposed.css({ zindex: overlayindex }) } }); $(document).unbind("keydown.mask"); m.unbind("click.mask"); $(window).unbind("resize.mask"); loaded = false } return this }, fit: function () { if (loaded) { var a = viewport(); m.css({ width: a[0], height: a[1] }) } }, getmask: function () { return m }, isloaded: function () { return loaded }, getconf: function () { return config }, getexposed: function () { return exposed } }; $.fn.mask = function (a) { $.mask.load(a); return this }; $.fn.expose = function (a) { $.mask.load(a, this); return this }; $.pe.overlay = { addeffect: function (a, b, c) { effects[a] = [b, c] }, conf: { close: null, closeonclick: true, closeonesc: true, closespeed: 'fast', effect: 'default', render: false, width: 500, height: 360, title: '标题', loadurl: 'http://www.powereasy.net', fixed: !$.browser.msie || $.browser.version > 6, left: 'center', load: false, mask: null, oneinstance: true, speed: 'normal', target: null, top: 'center' } }; var n = [], effects = {}; $.pe.overlay.addeffect('default', function (a, b) { var c = this.getconf(), w = $(window); if (!c.fixed) { a.top += w.scrolltop(); a.left += w.scrollleft() } a.position = c.fixed ? 'fixed' : 'absolute'; this.getoverlay().css(a).fadein(c.speed, b) }, function (a) { this.getoverlay().fadeout(this.getconf().closespeed, a) }); function overlay(c, d) { var f = this, fire = c.add(f), w = $(window), closers, overlay, opened, maskconf = $.pe.expose && (d.mask || d.expose), uid = math.random().tostring().slice(10); if (maskconf) { if (typeof maskconf == 'string') { maskconf = { color: maskconf } } maskconf.closeonclick = maskconf.closeonesc = false } var g = d.target || c.attr("rel"); overlay = g ? $(g) : null || c; if (d.render) { overlay.html(''); var h = '