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
18 KiB

10 years ago
/*! Ply 0.6.1 - MIT | git://github.com/rubaxa/Ply.git */
10 years ago
!function(a){"use strict";"function"==typeof define&&define.amd?define(a):window.Ply=a()}(function(){"use strict";function a(a){if(Q)return new Q(a);var b=N.Deferred();return a(b.resolve,b.reject),b}function b(a){return Q?Q.all(a):N.when.apply(N,a)}function c(b){return a(function(a){return a(b)})}function d(a){return a&&a.then?a:c(a)}function e(a){return"function"==typeof a}function f(a,b){if(a)for(var c in a)a.hasOwnProperty(c)&&b(a[c],c,a)}function g(a){var b={};return f(a,function(a,c){b[c]=e(a)?a:a instanceof Object?g(a):a}),b}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||H).querySelector(a)}catch(c){return N(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||H),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){if(null==a&&(a="div"),a.appendChild)return a;if(a.skip)return H.createDocumentFragment();"string"==typeof a&&(a={tag:a});var b,c=a.children,d=S.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=H.createElement(a.tag),delete a.tag,f(a,function(c,d){if(c)if("css"===d)r(b,a.css);else if("text"===d)null!=c&&k(b,H.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,o(a)))}),b}function p(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 q(b){return s(!0),a(function(a){for(var c,d=j(b,"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),a()}};e--;)c=d[e],c.complete?f--:(m(c,"load",g),m(c,"error",g));!f&&g()})}function r(a,b,c){if(a&&a.style&&b)if(b instanceof Object)for(var d in b)r(a,d,b[d]);else{if(void 0===c)return H.defaultView&&H.defaultView.getComputedStyle?c=H.defaultView.getComputedStyle(a,""):a.currentStyle&&(c=a.currentStyle),void 0===b?c:c[b];T[b]?T[b](a.style,c):a.style[K[b]||b]=c}}function s(a){var b=s.get();clearTimeout(s.pid),s.pid=a?I(function(){k(H.body,b)},100):I(function(){l(b)},100)}function t(a,b){return o({css:h({padding:"20px 20px 40px",display:"inline-block",position:"relative",textAlign:"left",whiteSpace:"normal",verticalAlign:"middle",transform:"translate3d(0, 0, 0)"},b.wrapper),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:J.cross},{tag:".ply-inside",children:a}]}]:a})}function u(a){return o({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=o({tag:b.rootTag,css:{whiteSpace:"nowrap",zIndex:b.zIndex},method:"post",action:"/"}),c||(a.overlayEl=u(b.overlay),a.overlayBoxEl=a.overlayEl.firstChild,k(a.wrapEl,a.overlayEl));var d=o();r(d,{height:"100%",display:"inline-block",verticalAlign:"middle"}),k(a.wrapEl,d);var e=b.el;return a.el=e&&e.cloneNode?b.clone?e.cloneNode(!0):e:o({html:e||""}),a.layerEl=t(a.el,b),a.contentEl=w(a.layerEl),a.