(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 = '