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 */
11 years ago
!function(a){window.Ply=a(window)}(function(a,b){"use strict";function c(a){return"function"==typeof a}function d(a){if(G)return new G(a);var b=F.Deferred();return a(b.resolve,b.reject),b}function e(a){return G?G.all(a):F.when.apply(F,a)}function f(a){return d(function(b){return b(a)})}function g(a){return a&&a.then?a:f(a)}function h(a,b){if(a)for(var c in a)a.hasOwnProperty(c)&&b(a[c],c,a)}function i(a){var b={};return h(a,function(a,d){b[d]=c(a)?a:a instanceof Object?i(a):a}),b}function j(a){for(var b=Array.prototype.slice,c=b.call(arguments,1),d=0,e=c.length;e>d;d++)h(c[d],function(b,c){a[c]=b});return a}function k(a,b){try{return(b||D).querySelector(a)}catch(c){return F(a,b)[0]}}function l(a,b){return a.getElementsByTagName(b)}function m(a,b){try{a&&b&&a.appendChild(b)}catch(c){}}function n(a){a&&a.parentNode&&a.parentNode.removeChild(a)}function o(a,b,c){var d=c.handle=c.handle||function(b){b.target||(b.target=b.srcElement||D),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 p(a,b,c){var d=c.handle;d&&(a.removeEventListener?a.removeEventListener(b,d,!1):a.detachEvent("on"+b,d))}function q(a,b,c){if(a&&a.style&&b)if(b instanceof Object)for(var d in b)q(a,d,b[d]);else{if(void 0===c)return D.defaultView&&D.defaultView.getComputedStyle?c=D.defaultView.getComputedStyle(a,""):a.currentStyle&&(c=a.currentStyle),void 0===b?c:c[b];K[b]?K[b](a.style,c):a.style[I[b]||b]=c}}function r(a){if(null==a&&(a="div"),a.appendChild)return a;if(a.skip)return D.createDocumentFragment();"string"==typeof a&&(a={tag:a});var b,c=a.children,d=H.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=D.createElement(a.tag),delete a.tag,h(a,function(c,d){if(c)if("css"===d)q(b,a.css);else if("text"===d)null!=c&&m(b,D.createTextNode(c));else if("html"===d)null!=c&&(b.innerHTML=c);else if("ply"===d)b.setAttribute(O,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?m(b,c):h(c,function(a,c){a&&("string"==typeof a?a={text:a}:"object"!=typeof a&&(a={}),"string"==typeof c&&(a.tag=a.tag||c),m(b,r(a)))}),b}function s(a){for(var b,c,d=l(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=l(a,"button")[0]);try{c.focus()}catch(g){}}function t(a){return u(!0),d(function(b){for(var c,d=l(a,"img"),e=d.length,f=e,g=function(){if(--f<=0){for(e=d.length;e--;)c=d[e],p(c,"load",g),p(c,"error",g);u(!1),b()}};e--;)c=d[e],c.complete?f--:(o(c,"load",g),o(c,"error",g));!f&&g()})}function u(a){var b=u.get();clearTimeout(u.pid),u.pid=a?E(function(){m(D.body,b)},100):E(function(){n(b)},100)}function v(a,b){return r({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:j({overflow:"hidden",position:"relative",backfaceVisibility:"hidden"},b.layer),children:[b.flags.closeBtn&&{ply:":close",tag:".ply-x",text:z.lang.cross},{tag:".ply-inside",children:a}]}]:a})}function w(a){return r({ply:":overlay",tag:".ply-overlay",css:{top:0,left:0,right:0,bottom:0,position:"fixed"},children:[{tag:"div",css:j({width:"100%",height:"100%"},a)}]})}function x(a,b,c){a.wrapEl=r({tag:"form",css:{whiteSpace:"nowrap",zIndex:b.zIndex}}),c||(a.overlayEl=w(b.overlay),a.overlayBoxEl=a.overlayEl.firstChild,m(a.wrapEl,a.overlayEl));var d=r();q(d,{height:"100%",display:"inline-block",verticalAlign:"middle"}),m(a.wrapEl,d);var e=b.el;return a.el=e&&e.cloneNode?e.cloneNode(!0):r({html:e||""}),a.layerEl=v(a.el,b),a.contentEl=y(a.layerEl),a.context=new A(a.layerEl),m(a.wrapEl,a.layerEl),a.bodyEl=b.body&&k(b.body)||D.body,a.wrapEl.tabInde