You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
17 KiB

11 years ago
/*! Ply 0.3.0 - MIT | git://github.com/rubaxa/Ply.git */
!function(a){window.Ply=a(window)}(function(a){"use strict";function b(a){return"function"==typeof a}function c(a){if(E)return new E(a);var b=D.Deferred();return a(b.resolve,b.reject),b}function d(a){return E?E.all(a):D.when.apply(D,a)}function e(a){return function(){C(a,1)}}function f(a,b){if(a)for(var c in a)a.hasOwnProperty(c)&&b(a[c],c,a)}function g(a){var c={};return f(a,function(a,d){c[d]=b(a)?a:a instanceof Object?g(a):a}),c}function h(a){for(var b=Array.prototype.slice,c=b.call(arguments,1),d=0,e=c.length;e>d;d++)f(c[d],function(b,c){a[c]=b});return a}function i(a,b){try{return(b||B).querySelector(a)}catch(c){return D(a,b)[0]}}function j(a,b){return a.getElementsByTagName(b)}function k(a,b){try{a&&b&&a.appendChild(b)}catch(c){}}function l(a){a&&a.parentNode&&a.parentNode.removeChild(a)}function m(a,b,c){var d=c.handle=c.handle||function(b){b.target||(b.target=b.srcElement||B),3===b.target.nodeType&&(b.target=b.target.parentNode),b.preventDefault||(b.preventDefault=function(){b.returnValue=!1}),b.stopPropagation||(b.stopPropagation=function(){b.cancelBubble=!0}),c.call(a,b)};a.addEventListener?a.addEventListener(b,d,!1):a.attachEvent("on"+b,d)}function n(a,b,c){var d=c.handle;d&&(a.removeEventListener?a.removeEventListener(b,d,!1):a.detachEvent("on"+b,d))}function o(a,b,c){if(a&&a.style&&b)if(b instanceof Object)for(var d in b)o(a,d,b[d]);else{if(void 0===c)return B.defaultView&&B.defaultView.getComputedStyle?c=B.defaultView.getComputedStyle(a,""):a.currentStyle&&(c=a.currentStyle),void 0===b?c:c[b];I[b]?I[b](a.style,c):a.style[G[b]||b]=c}}function p(a){if(null==a&&(a="div"),a.appendChild)return a;if(a.skip)return B.createDocumentFragment();"string"==typeof a&&(a={tag:a});var b,c=a.children,d=F.exec(a.tag||"");return delete a.children,a.tag=d[1]||"div",a.id=a.id||(d[2]||"").substr(1),d=(d[3]||"").split("."),d[0]=a.className||"",a.className=d.join(" "),b=B.createElement(a.tag),delete a.tag,f(a,function(c,d){if(c)if("css"===d)o(b,a.css);else if("text"===d)null!=c&&k(b,B.createTextNode(c));else if("html"===d)null!=c&&(b.innerHTML=c);else if("ply"===d)b.setAttribute(M,c);else if(d in b)try{b[d]=c}catch(e){b.setAttribute(d,c)}else/^data-/.test(d)&&b.setAttribute(d,c)}),c&&c.appendChild?k(b,c):f(c,function(a,c){a&&("string"==typeof a?a={text:a}:"object"!=typeof a&&(a={}),"string"==typeof c&&(a.tag=a.tag||c),k(b,p(a)))}),b}function q(a){for(var b,c,d=j(a,"input"),e=0,f=d.length;f>e;e++)if(b=d[e],"submit"===b.type)!c&&(c=b);else if(!/hidden|check|radio/.test(b.type)&&""==b.value){c=b;break}c||(c=j(a,"button")[0]);try{c.focus()}catch(g){}}function r(a){return s(!0),c(function(b){for(var c,d=j(a,"img"),e=d.length,f=e,g=function(){if(--f<=0){for(e=d.length;e--;)c=d[e],n(c,"load",g),n(c,"error",g);s(!1),b()}};e--;)c=d[e],c.complete?f--:(m(c,"load",g),m(c,"error",g));!f&&g()})}function s(a){var b=s.get();clearTimeout(s.pid),s.pid=a?C(function(){k(B.body,b)},100):C(function(){l(b)},100)}function t(a,b){return p({css:{padding:"20px 20px 40px",display:"inline-block",position:"relative",textAlign:"left",whiteSpace:"normal",verticalAlign:"middle",transform:"translate3d(0, 0, 0)"},children:b.baseHtml?[{ply:":layer",tag:".ply-layer",className:b.mod,css:h({overflow:"hidden",position:"relative",backfaceVisibility:"hidden"},b.layer),children:[b.flags.closeBtn&&{ply:":close",tag:".ply-x",text:x.lang.cross},{tag:".ply-inside",children:a}]}]:a})}function u(a){return p({ply:":overlay",tag:".ply-overlay",css:{top:0,left:0,right:0,bottom:0,position:"fixed"},children:[{tag:"div",css:h({width:"100%",height:"100%"},a)}]})}function v(a,b,c){a.wrapEl=p({tag:"form",css:{whiteSpace:"nowrap",zIndex:b.zIndex}}),c||(a.overlayEl=u(b.overlay),a.overlayBoxEl=a.overlayEl.firstChild,k(a.wrapEl,a.overlayEl));var d=p();o(d,{height:"100%",display:"inline-block",verticalAlign:"middle"}),k(a.wrapEl,d);var e=b.el;return a.el=e&&e.cloneNode?e.cloneNode(!0):p({html:e||""}),a.layerEl=t(a.el,b),a.contentEl=w(a.layerEl),a.context=new y(a.layerEl),k(a.wrapEl,a.layerEl),a.bodyEl=b.body&&i(b.body)||B.body,a.wrapEl.tabIndex=-1,o(a.wrapEl,{top:0,left:0,right:0,bottom:0,po