/*! jQuery v1.6.4 http://jquery.com/ | http://jquery.org/license */ (function(a,b){function cu(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cr(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"":"")+""),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cq(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cp(){cn=b}function co(){setTimeout(cp,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bv(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bl(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bd,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bk(a){f.nodeName(a,"input")?bj(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bj)}function bj(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bi(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bh(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bg(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i=0===c})}function U(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function M(a,b){return(a&&a!=="*"?a+".":"")+b.replace(y,"`").replace(z,"&")}function L(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;ic)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function J(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function D(){return!0}function C(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function K(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(K,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z]|[0-9])/ig,x=/^-ms-/,y=function(a,b){return(b+"").toUpperCase()},z=d.userAgent,A,B,C,D=Object.prototype.toString,E=Object.prototype.hasOwnProperty,F=Array.prototype.push,G=Array.prototype.slice,H=String.prototype.trim,I=Array.prototype.indexOf,J={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.4",length:0,size:function(){return this.length},toArray:function(){return G.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?F.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),B.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(G.apply(this,arguments),"slice",G.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:F,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;B.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!B){B=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",C,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",C),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&K()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):J[D.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!E.call(a,"constructor")&&!E.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||E.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(x,"ms-").replace(w,y)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c
a",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},m&&f.extend(p,{position:"absolute",left:"-1000px",top:"-1000px"});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
t
",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0),o.innerHTML="",n.removeChild(o);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i=f.expando,j=typeof c=="string",k=a.nodeType,l=k?f.cache:a,m=k?a[f.expando]:a[f.expando]&&f.expando;if((!m||e&&m&&l[m]&&!l[m][i])&&j&&d===b)return;m||(k?a[f.expando]=m=++f.uuid:m=f.expando),l[m]||(l[m]={},k||(l[m].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?l[m][i]=f.extend(l[m][i],c):l[m]=f.extend(l[m],c);g=l[m],e&&(g[i]||(g[i]={}),g=g[i]),d!==b&&(g[f.camelCase(c)]=d);if(c==="events"&&!g[c])return g[i]&&g[i].events;j?(h=g[c],h==null&&(h=g[f.camelCase(c)])):h=g;return h}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e=f.expando,g=a.nodeType,h=g?f.cache:a,i=g?a[f.expando]:f.expando;if(!h[i])return;if(b){d=c?h[i][e]:h[i];if(d){d[b]||(b=f.camelCase(b)),delete d[b];if(!l(d))return}}if(c){delete h[i][e];if(!l(h[i]))return}var j=h[i][e];f.support.deleteExpando||!h.setInterval?delete h[i]:h[i]=null,j?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=j):g&&(f.support.deleteExpando?delete a[f.expando]:a.removeAttribute?a.removeAttribute(f.expando):a[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;d=e.value;return typeof d=="string"?d.replace(p,""):d==null?"":d}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);j&&(c=f.attrFix[c]||c,i=f.attrHooks[c],i||(t.test(c)?i=v:u&&(i=u)));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j&&(h=i.get(a,c))!==null)return h;h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.attr(a,b,""),a.removeAttribute(b),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},value:{get:function(a,b){if(u&&f.nodeName(a,"button"))return u.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(u&&f.nodeName(a,"button"))return u.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);i&&(c=f.propFix[c]||c,h=f.propHooks[c]);return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==null?g:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}}}}),f.attrHooks.tabIndex=f.propHooks.tabIndex,v={get:function(a,c){var d;return f.prop(a,c)===!0||(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},f.support.getSetAttribute||(u=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,d){var e=a.getAttributeNode(d);e||(e=c.createAttribute(d),a.setAttributeNode(e));return e.nodeValue=b+""}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex);return null}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var w=/\.(.*)$/,x=/^(?:textarea|input|select)$/i,y=/\./g,z=/ /g,A=/[^\w\s.|`]/g,B=function(a){return a.replace(A,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=C;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=C);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),B).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d!=null?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},I=function(c){var d=c.target,e,g;if(!!x.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=H(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:I,beforedeactivate:I,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&I.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&I.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",H(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in G)f.event.add(this,c+".specialChange",G[c]);return x.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return x.test(this.nodeName)}},G=f.event.special.change.filters,G.focus=G.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(h=g;h0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=S.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(U(c[0])||U(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=R.call(arguments);N.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!T[a]?f.unique(e):e,(this.length>1||P.test(d))&&O.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};be.optgroup=be.option,be.tbody=be.tfoot=be.colgroup=be.caption=be.thead,be.th=be.td,f.support.htmlSerialize||(be._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!be[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bh(a,d),e=bi(a),g=bi(d);for(h=0;e[h];++h)g[h]&&bh(e[h],g[h])}if(b){bg(a,d);if(c){e=bi(a),g=bi(d);for(h=0;e[h];++h)bg(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=be[l]||be._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bn.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bm,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bm.test(g)?g.replace(bm,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bv(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bw=function(a,c){var d,e,g;c=c.replace(bo,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bx=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bp.test(d)&&bq.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bv=bw||bx,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bz=/%20/g,bA=/\[\]$/,bB=/\r?\n/g,bC=/#.*$/,bD=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bE=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bF=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bG=/^(?:GET|HEAD)$/,bH=/^\/\//,bI=/\?/,bJ=/)<[^<]*)*<\/script>/gi,bK=/^(?:select|textarea)/i,bL=/\s+/,bM=/([?&])_=[^&]*/,bN=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bO=f.fn.load,bP={},bQ={},bR,bS,bT=["*/"]+["*"];try{bR=e.href}catch(bU){bR=c.createElement("a"),bR.href="",bR=bR.href}bS=bN.exec(bR.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bO)return bO.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bJ,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bK.test(this.nodeName)||bE.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bB,"\r\n")}}):{name:b.name,value:c.replace(bB,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?bX(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),bX(a,b);return a},ajaxSettings:{url:bR,isLocal:bF.test(bS[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bT},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bV(bP),ajaxTransport:bV(bQ),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?bZ(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=b$(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bD.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bC,"").replace(bH,bS[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bL),d.crossDomain==null&&(r=bN.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bS[1]&&r[2]==bS[2]&&(r[3]||(r[1]==="http:"?80:443))==(bS[3]||(bS[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bW(bP,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bG.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bI.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bM,"$1_="+x);d.url=y+(y===d.url?(bI.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bT+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bW(bQ,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){s<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bY(g,a[g],c,e);return d.join("&").replace(bz,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var b_=f.now(),ca=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+b_++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ca.test(b.url)||e&&ca.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ca,l),b.url===j&&(e&&(k=k.replace(ca,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cb=a.ActiveXObject?function(){for(var a in cd)cd[a](0,1)}:!1,cc=0,cd;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ce()||cf()}:ce,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cb&&delete cd[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cc,cb&&(cd||(cd={},f(a).unload(cb)),cd[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cg={},ch,ci,cj=/^(?:toggle|show|hide)$/,ck=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cl,cm=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cn;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cq("show",3),a,b,c);for(var g=0,h=this.length;g=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b
";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=ct.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!ct.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cu(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cu(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a&&a.style?parseFloat(f.css(a,d,"padding")):null},f.fn["outer"+c]=function(a){var b=this[0];return b&&b.style?parseFloat(f.css(b,d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNaN(j)?i:j}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window);; /*! * jQuery UI 1.8.17 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI */(function(a,b){function d(b){return!a(b).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}function c(b,c){var e=b.nodeName.toLowerCase();if("area"===e){var f=b.parentNode,g=f.name,h;if(!b.href||!g||f.nodeName.toLowerCase()!=="map")return!1;h=a("img[usemap=#"+g+"]")[0];return!!h&&d(h)}return(/input|select|textarea|button|object/.test(e)?!b.disabled:"a"==e?b.href||c:c)&&d(b)}a.ui=a.ui||{};a.ui.version||(a.extend(a.ui,{version:"1.8.17",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(b,c){return typeof b=="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus(),c&&c.call(d)},b)}):this._focus.apply(this,arguments)},scrollParent:function(){var b;a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?b=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):b=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return this.css("zIndex",c);if(this.length){var d=a(this[0]),e,f;while(d.length&&d[0]!==document){e=d.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){f=parseInt(d.css("zIndex"),10);if(!isNaN(f)&&f!==0)return f}d=d.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(c,d){function h(b,c,d,f){a.each(e,function(){c-=parseFloat(a.curCSS(b,"padding"+this,!0))||0,d&&(c-=parseFloat(a.curCSS(b,"border"+this+"Width",!0))||0),f&&(c-=parseFloat(a.curCSS(b,"margin"+this,!0))||0)});return c}var e=d==="Width"?["Left","Right"]:["Top","Bottom"],f=d.toLowerCase(),g={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){if(c===b)return g["inner"+d].call(this);return this.each(function(){a(this).css(f,h(this,c)+"px")})},a.fn["outer"+d]=function(b,c){if(typeof b!="number")return g["outer"+d].call(this,b);return this.each(function(){a(this).css(f,h(this,b,!0,c)+"px")})}}),a.extend(a.expr[":"],{data:function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){return c(b,!isNaN(a.attr(b,"tabindex")))},tabbable:function(b){var d=a.attr(b,"tabindex"),e=isNaN(d);return(e||d>=0)&&c(b,!e)}}),a(function(){var b=document.body,c=b.appendChild(c=document.createElement("div"));a.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),a.support.minHeight=c.offsetHeight===100,a.support.selectstart="onselectstart"in c,b.removeChild(c).style.display="none"}),a.extend(a.ui,{plugin:{add:function(b,c,d){var e=a.ui[b].prototype;for(var f in d)e.plugins[f]=e.plugins[f]||[],e.plugins[f].push([c,d[f]])},call:function(a,b,c){var d=a.plugins[b];if(!!d&&!!a.element[0].parentNode)for(var e=0;e0)return!0;b[d]=1,e=b[d]>0,b[d]=0;return e},isOverAxis:function(a,b,c){return a>b&&a=9)&&!b.button)return this._mouseUp(b);if(this._mouseStarted){this._mouseDrag(b);return b.preventDefault()}this._mouseDistanceMet(b)&&this._mouseDelayMet(b)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,b)!==!1,this._mouseStarted?this._mouseDrag(b):this._mouseUp(b));return!this._mouseStarted},_mouseUp:function(b){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,b.target==this._mouseDownEvent.target&&a.data(b.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(b));return!1},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(a){return this.mouseDelayMet},_mouseStart:function(a){},_mouseDrag:function(a){},_mouseStop:function(a){},_mouseCapture:function(a){return!0}})})(jQuery);/* * jQuery UI Draggable 1.8.17 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Draggables * * Depends: * jquery.ui.core.js * jquery.ui.mouse.js * jquery.ui.widget.js */ (function( $, undefined ) { $.widget("ui.draggable", $.ui.mouse, { widgetEventPrefix: "drag", options: { addClasses: true, appendTo: "parent", axis: false, connectToSortable: false, containment: false, cursor: "auto", cursorAt: false, grid: false, handle: false, helper: "original", iframeFix: false, opacity: false, refreshPositions: false, revert: false, revertDuration: 500, scope: "default", scroll: true, scrollSensitivity: 20, scrollSpeed: 20, snap: false, snapMode: "both", snapTolerance: 20, stack: false, zIndex: false, concernAngle: false }, _create: function() { if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) this.element[0].style.position = 'relative'; (this.options.addClasses && this.element.addClass("ui-draggable")); (this.options.disabled && this.element.addClass("ui-draggable-disabled")); this._mouseInit(); }, destroy: function() { if(!this.element.data('draggable')) return; this.element .removeData("draggable") .unbind(".draggable") .removeClass("ui-draggable" + " ui-draggable-dragging" + " ui-draggable-disabled"); this._mouseDestroy(); return this; }, _mouseCapture: function(event) { var o = this.options; // among others, prevent a drag on a resizable-handle if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle,.ui-resizable-handle>.knob')) return false; //Quit if we're not on a valid handle this.handle = this._getHandle(event); if (!this.handle) return false; if ( o.iframeFix ) { $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() { $('
') .css({ width: this.offsetWidth+"px", height: this.offsetHeight+"px", position: "absolute", opacity: "0.001", zIndex: 1000 }) .css($(this).offset()) .appendTo("body"); }); } return true; }, _mouseStart: function(event) { var o = this.options; //Create and append the visible helper this.helper = this._createHelper(event); //Cache the helper size this._cacheHelperProportions(); //If ddmanager is used for droppables, set the global draggable if($.ui.ddmanager) $.ui.ddmanager.current = this; /* * - Position generation - * This block generates everything position related - it's the core of draggables. */ //Cache the margins of the original element this._cacheMargins(); //Store the helper's css position this.cssPosition = this.helper.css("position"); this.scrollParent = this.helper.scrollParent(); //The element's absolute position on the page minus margins this.offset = this.positionAbs = this.element.offset(); if(o.concernAngle){ var parentoffset=this.element.parent().offset(); this.offset = this.positionAbs = { left:parentoffset.left+$.parseInteger(this.element.parent().css("borderLeftWidth"))+$.parseInteger(this.element.css('left')), top:parentoffset.top+$.parseInteger(this.element.parent().css("borderTopWidth"))+$.parseInteger(this.element.css('top')) } } this.offset = { top: this.offset.top - this.margins.top, left: this.offset.left - this.margins.left }; $.extend(this.offset, { click: { //Where the click happened, relative to the element left: event.pageX - this.offset.left, top: event.pageY - this.offset.top }, parent: this._getParentOffset(), relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper }); //Generate the original position this.originalPosition = this.position = this._generatePosition(event); this.originalPageX = event.pageX; this.originalPageY = event.pageY; //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); //Set a containment if given in the options if(o.containment) this._setContainment(); //Trigger event + callbacks if(this._trigger("start", event) === false) { this._clear(); return false; } //Recache the helper size this._cacheHelperProportions(); //Prepare the droppable offsets if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, event); this.helper.addClass("ui-draggable-dragging"); this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003) if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event); return true; }, _mouseDrag: function(event, noPropagation) { //Compute the helpers position this.position = this._generatePosition(event); this.positionAbs = this._convertPositionTo("absolute"); //Call plugins and callbacks and use the resulting position if something is returned if (!noPropagation) { var ui = this._uiHash(); if(this._trigger('drag', event, ui) === false) { this._mouseUp({}); return false; } this.position = ui.position; } if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); return false; }, _mouseStop: function(event) { //If we are using droppables, inform the manager about the drop var dropped = false; if ($.ui.ddmanager && !this.options.dropBehaviour) dropped = $.ui.ddmanager.drop(this, event); //if a drop comes from outside (a sortable) if(this.dropped) { dropped = this.dropped; this.dropped = false; } //if the original element is removed, don't bother to continue if helper is set to "original" if((!this.element[0] || !this.element[0].parentNode) && this.options.helper == "original") return false; if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) { var self = this; $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { if(self._trigger("stop", event) !== false) { self._clear(); } }); } else { if(this._trigger("stop", event) !== false) { this._clear(); } } return false; }, _mouseUp: function(event) { if (this.options.iframeFix === true) { $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers } //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003) if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event); return $.ui.mouse.prototype._mouseUp.call(this, event); }, cancel: function() { if(this.helper.is(".ui-draggable-dragging")) { this._mouseUp({}); } else { this._clear(); } return this; }, _getHandle: function(event) { var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; $(this.options.handle, this.element) .find("*") .andSelf() .each(function() { if(this == event.target) handle = true; }); return handle; }, _createHelper: function(event) { var o = this.options; var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element); if(!helper.parents('body').length) helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo)); if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) helper.css("position", "absolute"); return helper; }, _adjustOffsetFromHelper: function(obj) { if (typeof obj == 'string') { obj = obj.split(' '); } if ($.isArray(obj)) { obj = {left: +obj[0], top: +obj[1] || 0}; } if ('left' in obj) { this.offset.click.left = obj.left + this.margins.left; } if ('right' in obj) { this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; } if ('top' in obj) { this.offset.click.top = obj.top + this.margins.top; } if ('bottom' in obj) { this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; } }, _getParentOffset: function() { //Get the offsetParent and cache its position this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); // This is a special case where we need to modify a offset calculated on start, since the following happened: // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) { po.left += this.scrollParent.scrollLeft(); po.top += this.scrollParent.scrollTop(); } if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix po = { top: 0, left: 0 }; return { top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) }; }, _getRelativeOffset: function() { if(this.cssPosition == "relative") { var p = this.element.position(); return { top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() }; } else { return { top: 0, left: 0 }; } }, _cacheMargins: function() { this.margins = { left: (parseInt(this.element.css("marginLeft"),10) || 0), top: (parseInt(this.element.css("marginTop"),10) || 0), right: (parseInt(this.element.css("marginRight"),10) || 0), bottom: (parseInt(this.element.css("marginBottom"),10) || 0) }; }, _cacheHelperProportions: function() { this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() }; }, _setContainment: function() { var o = this.options; if(o.containment == 'parent') o.containment = this.helper[0].parentNode; if(o.containment == 'document' || o.containment == 'window') this.containment = [ o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left, o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top, (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top ]; if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) { var c = $(o.containment); var ce = c[0]; if(!ce) return; var co = c.offset(); var over = ($(ce).css("overflow") != 'hidden'); this.containment = [ (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0), (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0), (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right, (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom ]; this.relative_container = c; } else if(o.containment.constructor == Array) { this.containment = o.containment; } }, _convertPositionTo: function(d, pos) { if(!pos) pos = this.position; var mod = d == "absolute" ? 1 : -1; var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); return { top: ( pos.top // The absolute mouse position + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) ), left: ( pos.left // The absolute mouse position + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) ) }; }, _generatePosition: function(event) { var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); var pageX = event.pageX; var pageY = event.pageY; /* * - Position constraining - * Constrain the position to a mix of grid, containment. */ if(this.originalPosition) { //If we are not dragging yet, we won't check for options var containment; if(this.containment) { if (this.relative_container){ var co = this.relative_container.offset(); containment = [ this.containment[0] + co.left, this.containment[1] + co.top, this.containment[2] + co.left, this.containment[3] + co.top ]; } else { containment = this.containment; } if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left; if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top; if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left; if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top; } if(o.grid) { //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950) var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY; pageY = containment ? (!(top - this.offset.click.top < containment[1] || top - this.offset.click.top > containment[3]) ? top : (!(top - this.offset.click.top < containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX; pageX = containment ? (!(left - this.offset.click.left < containment[0] || left - this.offset.click.left > containment[2]) ? left : (!(left - this.offset.click.left < containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; } } return { top: ( pageY // The absolute mouse position - this.offset.click.top // Click offset (relative to the element) - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.top // The offsetParent's offset without borders (offset + border) + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) ), left: ( pageX // The absolute mouse position - this.offset.click.left // Click offset (relative to the element) - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.left // The offsetParent's offset without borders (offset + border) + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) ) }; }, _clear: function() { this.helper.removeClass("ui-draggable-dragging"); if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove(); //if($.ui.ddmanager) $.ui.ddmanager.current = null; this.helper = null; this.cancelHelperRemoval = false; }, // From now on bulk stuff - mainly helpers _trigger: function(type, event, ui) { ui = ui || this._uiHash(); $.ui.plugin.call(this, type, [event, ui]); if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins return $.Widget.prototype._trigger.call(this, type, event, ui); }, plugins: {}, _uiHash: function(event) { return { helper: this.helper, position: this.position, originalPosition: this.originalPosition, offset: this.positionAbs }; } }); $.extend($.ui.draggable, { version: "1.8.17" }); $.ui.plugin.add("draggable", "connectToSortable", { start: function(event, ui) { var inst = $(this).data("draggable"), o = inst.options, uiSortable = $.extend({}, ui, { item: inst.element }); inst.sortables = []; $(o.connectToSortable).each(function() { var sortable = $.data(this, 'sortable'); if (sortable && !sortable.options.disabled) { inst.sortables.push({ instance: sortable, shouldRevert: sortable.options.revert }); sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page). sortable._trigger("activate", event, uiSortable); } }); }, stop: function(event, ui) { //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper var inst = $(this).data("draggable"), uiSortable = $.extend({}, ui, { item: inst.element }); $.each(inst.sortables, function() { if(this.instance.isOver) { this.instance.isOver = 0; inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work) //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid' if(this.shouldRevert) this.instance.options.revert = true; //Trigger the stop of the sortable this.instance._mouseStop(event); this.instance.options.helper = this.instance.options._helper; //If the helper has been the original item, restore properties in the sortable if(inst.options.helper == 'original') this.instance.currentItem.css({ top: 'auto', left: 'auto' }); } else { this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance this.instance._trigger("deactivate", event, uiSortable); } }); }, drag: function(event, ui) { var inst = $(this).data("draggable"), self = this; var checkPos = function(o) { var dyClick = this.offset.click.top, dxClick = this.offset.click.left; var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left; var itemHeight = o.height, itemWidth = o.width; var itemTop = o.top, itemLeft = o.left; return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth); }; $.each(inst.sortables, function(i) { //Copy over some variables to allow calling the sortable's native _intersectsWith this.instance.positionAbs = inst.positionAbs; this.instance.helperProportions = inst.helperProportions; this.instance.offset.click = inst.offset.click; if(this.instance._intersectsWith(this.instance.containerCache)) { //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once if(!this.instance.isOver) { this.instance.isOver = 1; //Now we fake the start of dragging for the sortable instance, //by cloning the list group item, appending it to the sortable and using it as inst.currentItem //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one) this.instance.currentItem = $(self).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true); this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it this.instance.options.helper = function() { return ui.helper[0]; }; event.target = this.instance.currentItem[0]; this.instance._mouseCapture(event, true); this.instance._mouseStart(event, true, true); //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes this.instance.offset.click.top = inst.offset.click.top; this.instance.offset.click.left = inst.offset.click.left; this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left; this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top; inst._trigger("toSortable", event); inst.dropped = this.instance.element; //draggable revert needs that //hack so receive/update callbacks work (mostly) inst.currentItem = inst.element; this.instance.fromOutside = inst; } //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable if(this.instance.currentItem) this.instance._mouseDrag(event); } else { //If it doesn't intersect with the sortable, and it intersected before, //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval if(this.instance.isOver) { this.instance.isOver = 0; this.instance.cancelHelperRemoval = true; //Prevent reverting on this forced stop this.instance.options.revert = false; // The out event needs to be triggered independently this.instance._trigger('out', event, this.instance._uiHash(this.instance)); this.instance._mouseStop(event, true); this.instance.options.helper = this.instance.options._helper; //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size this.instance.currentItem.remove(); if(this.instance.placeholder) this.instance.placeholder.remove(); inst._trigger("fromSortable", event); inst.dropped = false; //draggable revert needs that } }; }); } }); $.ui.plugin.add("draggable", "cursor", { start: function(event, ui) { var t = $('body'), o = $(this).data('draggable').options; if (t.css("cursor")) o._cursor = t.css("cursor"); t.css("cursor", o.cursor); }, stop: function(event, ui) { var o = $(this).data('draggable').options; if (o._cursor) $('body').css("cursor", o._cursor); } }); $.ui.plugin.add("draggable", "opacity", { start: function(event, ui) { var t = $(ui.helper), o = $(this).data('draggable').options; if(t.css("opacity")) o._opacity = t.css("opacity"); t.css('opacity', o.opacity); }, stop: function(event, ui) { var o = $(this).data('draggable').options; if(o._opacity) $(ui.helper).css('opacity', o._opacity); } }); $.ui.plugin.add("draggable", "scroll", { start: function(event, ui) { var i = $(this).data("draggable"); if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset(); }, drag: function(event, ui) { var i = $(this).data("draggable"), o = i.options, scrolled = false; if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') { if(!o.axis || o.axis != 'x') { if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed; else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed; } if(!o.axis || o.axis != 'y') { if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed; else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed; } } else { if(!o.axis || o.axis != 'x') { if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); } if(!o.axis || o.axis != 'y') { if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); } } if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(i, event); } }); $.ui.plugin.add("draggable", "snap", { start: function(event, ui) { var i = $(this).data("draggable"), o = i.options; i.snapElements = []; $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() { var $t = $(this); var $o = $t.offset(); if(this != i.element[0]) i.snapElements.push({ item: this, width: $t.outerWidth(), height: $t.outerHeight(), top: $o.top, left: $o.left }); }); }, drag: function(event, ui) { var inst = $(this).data("draggable"), o = inst.options; var d = o.snapTolerance; var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height; for (var i = inst.snapElements.length - 1; i >= 0; i--){ var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, t = inst.snapElements[i].top, b = t + inst.snapElements[i].height; //Yes, I know, this is insane ;) if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) { if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); inst.snapElements[i].snapping = false; continue; } if(o.snapMode != 'inner') { var ts = Math.abs(t - y2) <= d; var bs = Math.abs(b - y1) <= d; var ls = Math.abs(l - x2) <= d; var rs = Math.abs(r - x1) <= d; if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top; if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top; if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left; if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left; } var first = (ts || bs || ls || rs); if(o.snapMode != 'outer') { var ts = Math.abs(t - y1) <= d; var bs = Math.abs(b - y2) <= d; var ls = Math.abs(l - x1) <= d; var rs = Math.abs(r - x2) <= d; if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top; if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top; if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left; if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left; } if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); inst.snapElements[i].snapping = (ts || bs || ls || rs || first); }; } }); $.ui.plugin.add("draggable", "stack", { start: function(event, ui) { var o = $(this).data("draggable").options; var group = $.makeArray($(o.stack)).sort(function(a,b) { return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0); }); if (!group.length) { return; } var min = parseInt(group[0].style.zIndex) || 0; $(group).each(function(i) { this.style.zIndex = min + i; }); this[0].style.zIndex = min + group.length; } }); $.ui.plugin.add("draggable", "zIndex", { start: function(event, ui) { var t = $(ui.helper), o = $(this).data("draggable").options; if(t.css("zIndex")) o._zIndex = t.css("zIndex"); t.css('zIndex', o.zIndex); }, stop: function(event, ui) { var o = $(this).data("draggable").options; if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex); } }); })(jQuery); /* jQuery UI Droppable 1.8.17 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Droppables * * Depends: * jquery.ui.core.js * jquery.ui.widget.js * jquery.ui.mouse.js * jquery.ui.draggable.js */(function(a,b){a.widget("ui.droppable",{widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect"},_create:function(){var b=this.options,c=b.accept;this.isover=0,this.isout=1,this.accept=a.isFunction(c)?c:function(a){return a.is(c)},this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},a.ui.ddmanager.droppables[b.scope]=a.ui.ddmanager.droppables[b.scope]||[],a.ui.ddmanager.droppables[b.scope].push(this),b.addClasses&&this.element.addClass("ui-droppable")},destroy:function(){var b=a.ui.ddmanager.droppables[this.options.scope];for(var c=0;c=k&&g<=l||h>=k&&h<=l||gl)&&(e>=i&&e<=j||f>=i&&f<=j||ej);default:return!1}},a.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(b,c){var d=a.ui.ddmanager.droppables[b.options.scope]||[],e=c?c.type:null,f=(b.currentItem||b.element).find(":data(droppable)").andSelf();droppablesLoop:for(var g=0;g').css({ position: this.element.css('position'), width: this.element.outerWidth(), height: this.element.outerHeight(), top: this.element.css('top'), left: this.element.css('left') }) ); //Overwrite the original this.element this.element = this.element.parent().data( "resizable", this.element.data('resizable') ); this.elementIsWrapper = true; //Move margins to the wrapper this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") }); this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0}); //Prevent Safari textarea resize this.originalResizeStyle = this.originalElement.css('resize'); this.originalElement.css('resize', 'none'); //Push the actual element to our proportionallyResize internal array this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' })); // avoid IE jump (hard set the margin) this.originalElement.css({ margin: this.originalElement.css('margin') }); // fix handlers offset this._proportionallyResize(); } this.handles = o.handles || (!$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' }); if(this.handles.constructor == String) { if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw'; var n = this.handles.split(","); this.handles = {}; for(var i = 0; i < n.length; i++) { var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle; var axis = $('
'); // increase zIndex of sw, se, ne, nw axis //TODO : this modifies original option if(/sw|se|ne|nw/.test(handle)) axis.css({ zIndex: ++o.zIndex }); //TODO : What's going on here? if ('se' == handle) { axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se'); }; //Insert into internal handles object and append to element this.handles[handle] = '.ui-resizable-'+handle; this.element.append(axis); } } this._renderAxis = function(target) { target = target || this.element; for(var i in this.handles) { if(this.handles[i].constructor == String) this.handles[i] = $(this.handles[i], this.element).show(); //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls) if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) { var axis = $(this.handles[i], this.element), padWrapper = 0; //Checking the correct pad and border padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); //The padding type i have to apply... var padPos = [ 'padding', /ne|nw|n/.test(i) ? 'Top' : /se|sw|s/.test(i) ? 'Bottom' : /^e$/.test(i) ? 'Right' : 'Left' ].join(""); target.css(padPos, padWrapper); this._proportionallyResize(); } //TODO: What's that good for? There's not anything to be executed left if(!$(this.handles[i]).length) continue; } }; //TODO: make renderAxis a prototype function this._renderAxis(this.element); this._handles = $('.ui-resizable-handle', this.element) .disableSelection(); //Matching axis name this._handles.mouseover(function() { if (!self.resizing) { if (this.className) var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i); //Axis, default = se self.axis = axis && axis[1] ? axis[1] : 'se'; } }); //If we want to auto hide the elements if (o.autoHide) { this._handles.hide(); $(this.element) .addClass("ui-resizable-autohide") .hover(function() { if (o.disabled) return; $(this).removeClass("ui-resizable-autohide"); self._handles.show(); }, function(){ if (o.disabled) return; if (!self.resizing) { $(this).addClass("ui-resizable-autohide"); self._handles.hide(); } }); } //Initialize the mouse interaction this._mouseInit(); }, destroy: function() { this._mouseDestroy(); var _destroy = function(exp) { $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing") .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove(); }; //TODO: Unwrap at same DOM position if (this.elementIsWrapper) { _destroy(this.element); var wrapper = this.element; wrapper.after( this.originalElement.css({ position: wrapper.css('position'), width: wrapper.outerWidth(), height: wrapper.outerHeight(), top: wrapper.css('top'), left: wrapper.css('left') }) ).remove(); } this.originalElement.css('resize', this.originalResizeStyle); _destroy(this.originalElement); return this; }, _mouseCapture: function(event) { var handle = false; for (var i in this.handles) { if ($(this.handles[i])[0] == event.target || $(this.handles[i])[0] == event.target.parentNode) { handle = true; } } var lockcondition=true; if(this.options.concernLock && this.element.data('cstlayerstatus') == 'unlock'){ lockcondition=false; } return !this.options.disabled && handle && lockcondition; }, _mouseStart: function(event) { var o = this.options, iniPos = this.element.position(), el = this.element; this.resizing = true; this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() }; // bugfix for http://dev.jquery.com/ticket/1749 if(!o.concernAngle&&!o.noinit){ if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) { el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left }); } } //Opera fixing relative position if ($.browser.opera && (/relative/).test(el.css('position'))) el.css({ position: 'relative', top: 'auto', left: 'auto' }); this._renderProxy(); var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top')); if (o.containment) { curleft += $(o.containment).scrollLeft() || 0; curtop += $(o.containment).scrollTop() || 0; } //Store needed variables this.offset = this.helper.offset(); this.position = { left: curleft, top: curtop }; if($.browser.msie && $.browser.version < 9 && el.data('deg') % 360 != 0) this.size = {width:el.data('IEWidth'),height:el.data('IEHeight')}; else this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; this.originalPosition = { left: curleft, top: curtop }; this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() }; this.originalMousePosition = { left: event.pageX, top: event.pageY }; if(o.scroll &&(!o.concernAngle||o.concernAngle&&!this.element.data('deg'))){ this.scrollParent =this.element.scrollParent(); this.originalMousePosition.top+=this.scrollParent.scrollTop(); } //Aspect Ratio this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1); if(o.concernAngle){ //处理旋转模块Resize鼠标cursor样式 $.divrotate.getDegreeResizeCursor(this.element); } var cursor = this.element.find('.ui-resizable-' + this.axis).css('cursor'); $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor); el.addClass("ui-resizable-resizing"); this._propagate("start", event); return true; }, _mouseDrag: function(event) { //Increase performance, avoid regex var el = this.helper, o = this.options, props = {}, self = this, smp = this.originalMousePosition, a = this.axis; var ypos=event.pageY; if(o.scroll &&(!o.concernAngle||o.concernAngle&&!this.element.data('deg'))){ ypos+=this.scrollParent.scrollTop(); } var dx = (event.pageX-smp.left)||0, dy = (ypos-smp.top)||0; var trigger = this._change[a]; if (!trigger) return false; // Calculate the attrs that will be change var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff; // Put this in the mouseDrag handler since the user can start pressing shift while resizing this._updateVirtualBoundaries(event.shiftKey); if (!$.isFunction(o.aspectFunc)&&(this._aspectRatio || event.shiftKey)){ data = this._updateRatio(data, event); }else if($.isFunction(o.aspectFunc)){ data = this._updateAFunc(data, event); } data = this._respectSize(data, event); // plugins callbacks need to be called first this._propagate("resize", event); el.css({ top: this.position.top + "px", left: this.position.left + "px", width: this.size.width + "px", height: this.size.height + "px" }); if (!this._helper && this._proportionallyResizeElements.length) this._proportionallyResize(); this._updateCache(data); // calling the user callback at the end this._trigger('resize', event, this.ui()); return false; }, _mouseStop: function(event) { this.resizing = false; var o = this.options, self = this; if(this._helper) { var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName), soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, soffsetw = ista ? 0 : self.sizeDiff.width; var s = { width: (self.helper.width() - soffsetw), height: (self.helper.height() - soffseth) }, left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; if (!o.animate) this.element.css($.extend(s, { top: top, left: left })); self.helper.height(self.size.height); self.helper.width(self.size.width); if (this._helper && !o.animate) this._proportionallyResize(); } $('body').css('cursor', 'auto'); this.element.removeClass("ui-resizable-resizing"); this._propagate("stop", event); if (this._helper) this.helper.remove(); return false; }, _updateVirtualBoundaries: function(forceAspectRatio) { var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b; b = { minWidth: isNumber(o.minWidth) ? o.minWidth : 0, maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity, minHeight: isNumber(o.minHeight) ? o.minHeight : 0, maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity }; if(this._aspectRatio || forceAspectRatio) { // We want to create an enclosing box whose aspect ration is the requested one // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension pMinWidth = b.minHeight * this.aspectRatio; pMinHeight = b.minWidth / this.aspectRatio; pMaxWidth = b.maxHeight * this.aspectRatio; pMaxHeight = b.maxWidth / this.aspectRatio; if(pMinWidth > b.minWidth) b.minWidth = pMinWidth; if(pMinHeight > b.minHeight) b.minHeight = pMinHeight; if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth; if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight; } this._vBoundaries = b; }, _updateCache: function(data) { var o = this.options; this.offset = this.helper.offset(); if (isNumber(data.left)) this.position.left = data.left; if (isNumber(data.top)) this.position.top = data.top; if (isNumber(data.height)) this.size.height = data.height; if (isNumber(data.width)) this.size.width = data.width; }, _updateRatio: function(data, event) { var o = this.options, cpos = this.position, csize = this.size, a = this.axis; if (isNumber(data.height)) data.width = (data.height * this.aspectRatio); else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio); if (a == 'sw') { data.left = cpos.left + (csize.width - data.width); data.top = null; } if (a == 'nw') { data.top = cpos.top + (csize.height - data.height); data.left = cpos.left + (csize.width - data.width); } return data; }, _updateAFunc: function(data, event) { var o = this.options, cpos = this.position, csize = this.size, a = this.axis; var el=this.element;var aspectFunc=o.aspectFunc; if (isNumber(data.height)) data.width = aspectFunc(el,data.height,'height'); else if (isNumber(data.width)) data.height = aspectFunc(el,data.width,'width'); if (a == 'sw') { data.left = cpos.left + (csize.width - data.width); data.top = null; } if (a == 'nw') { data.top = cpos.top + (csize.height - data.height); data.left = cpos.left + (csize.width - data.width); } return data; }, _respectSize: function(data, event) { var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis, ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height); if (isminw) data.width = o.minWidth; if (isminh) data.height = o.minHeight; if (ismaxw) data.width = o.maxWidth; if (ismaxh) data.height = o.maxHeight; var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height; var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); if (isminw && cw) data.left = dw - o.minWidth; if (ismaxw && cw) data.left = dw - o.maxWidth; if (isminh && ch) data.top = dh - o.minHeight; if (ismaxh && ch) data.top = dh - o.maxHeight; // fixing jump error on top/left - bug #2330 var isNotwh = !data.width && !data.height; if (isNotwh && !data.left && data.top) data.top = null; else if (isNotwh && !data.top && data.left) data.left = null; return data; }, _proportionallyResize: function() { var o = this.options; if (!this._proportionallyResizeElements.length) return; var element = this.helper || this.element; for (var i=0; i < this._proportionallyResizeElements.length; i++) { var prel = this._proportionallyResizeElements[i]; if (!this.borderDif) { var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')], p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')]; this.borderDif = $.map(b, function(v, i) { var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0; return border + padding; }); } if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length))) continue; prel.css({ height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0, width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0 }); }; }, _renderProxy: function() { var el = this.element, o = this.options; this.elementOffset = el.offset(); if(this._helper) { this.helper = this.helper || $('
'); // fix ie6 offset TODO: This seems broken var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0), pxyoffset = ( ie6 ? 2 : -1 ); this.helper.addClass(this._helper).css({ width: this.element.outerWidth() + pxyoffset, height: this.element.outerHeight() + pxyoffset, position: 'absolute', left: this.elementOffset.left - ie6offset +'px', top: this.elementOffset.top - ie6offset +'px', zIndex: ++o.zIndex //TODO: Don't modify option }); this.helper .appendTo("body") .disableSelection(); } else { this.helper = this.element; } }, _change: { e: function(event, dx, dy) { var o = this.options, cs = this.originalSize, sp = this.originalPosition; if(o.concernAngle&&this.element.data('deg')){ return $.divrotate.getDegreeResizeChange(this.element,[dx,dy],sp,cs,'e'); } return { width: this.originalSize.width + dx }; }, w: function(event, dx, dy) { var o = this.options, cs = this.originalSize, sp = this.originalPosition; if(o.concernAngle&&this.element.data('deg')){ return $.divrotate.getDegreeResizeChange(this.element,[dx,dy],sp,cs,'w'); } return { left: sp.left + dx, width: cs.width - dx }; }, n: function(event, dx, dy) { var o = this.options, cs = this.originalSize, sp = this.originalPosition; if(o.concernAngle&&this.element.data('deg')){ return $.divrotate.getDegreeResizeChange(this.element,[dx,dy],sp,cs,'n'); } else return { top: sp.top + dy, height: cs.height - dy }; }, s: function(event, dx, dy) { var o = this.options, cs = this.originalSize, sp = this.originalPosition; if(o.concernAngle&&this.element.data('deg')){ return $.divrotate.getDegreeResizeChange(this.element,[dx,dy],sp,cs,'s'); } return { height: this.originalSize.height + dy }; }, se: function(event, dx, dy) { return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy])); }, sw: function(event, dx, dy) { return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy])); }, ne: function(event, dx, dy) { return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy])); }, nw: function(event, dx, dy) { var o = this.options, cs = this.originalSize, sp = this.originalPosition; if(o.concernAngle&&this.element.data('deg')){ var l=sp.left,t=sp.top; var nchange=this._change.n.apply(this, arguments); var wchange=this._change.w.apply(this, arguments); var nwchange=$.extend({},nchange,wchange); nwchange.left=nchange.left+wchange.left-l; nwchange.top=nchange.top+wchange.top-t; return nwchange; } return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy])); } }, _propagate: function(n, event) { $.ui.plugin.call(this, n, [event, this.ui()]); (n != "resize" && this._trigger(n, event, this.ui())); }, plugins: {}, ui: function() { return { originalElement: this.originalElement, element: this.element, helper: this.helper, position: this.position, size: this.size, originalSize: this.originalSize, originalPosition: this.originalPosition }; } }); $.extend($.ui.resizable, { version: "1.8.17" }); /* * Resizable Extensions */ $.ui.plugin.add("resizable", "alsoResize", { start: function (event, ui) { var self = $(this).data("resizable"), o = self.options; var _store = function (exp) { $(exp).each(function() { var el = $(this); el.data("resizable-alsoresize", { width: parseInt(el.width(), 10), height: parseInt(el.height(), 10), left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10), position: el.css('position') // to reset Opera on stop() }); }); }; if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) { if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } else { $.each(o.alsoResize, function (exp) { _store(exp); }); } }else{ _store(o.alsoResize); } }, resize: function (event, ui) { var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition; var delta = { height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0, top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0 }, _alsoResize = function (exp, c) { $(exp).each(function() { var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left']; $.each(css, function (i, prop) { var sum = (start[prop]||0) + (delta[prop]||0); if (sum && sum >= 0) style[prop] = sum || null; }); // Opera fixing relative position if ($.browser.opera && /relative/.test(el.css('position'))) { self._revertToRelativePosition = true; el.css({ position: 'absolute', top: 'auto', left: 'auto' }); } el.css(style); }); }; if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) { $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); }); }else{ _alsoResize(o.alsoResize); } }, stop: function (event, ui) { var self = $(this).data("resizable"), o = self.options; var _reset = function (exp) { $(exp).each(function() { var el = $(this); // reset position for Opera - no need to verify it was changed el.css({ position: el.data("resizable-alsoresize").position }); }); }; if (self._revertToRelativePosition) { self._revertToRelativePosition = false; if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) { $.each(o.alsoResize, function (exp) { _reset(exp); }); }else{ _reset(o.alsoResize); } } $(this).removeData("resizable-alsoresize"); } }); $.ui.plugin.add("resizable", "animate", { stop: function(event, ui) { var self = $(this).data("resizable"), o = self.options; var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName), soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, soffsetw = ista ? 0 : self.sizeDiff.width; var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; self.element.animate( $.extend(style, top && left ? { top: top, left: left } : {}), { duration: o.animateDuration, easing: o.animateEasing, step: function() { var data = { width: parseInt(self.element.css('width'), 10), height: parseInt(self.element.css('height'), 10), top: parseInt(self.element.css('top'), 10), left: parseInt(self.element.css('left'), 10) }; if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height }); // propagating resize, and updating values for each animation step self._updateCache(data); self._propagate("resize", event); } } ); } }); $.ui.plugin.add("resizable", "containment", { start: function(event, ui) { var self = $(this).data("resizable"), o = self.options, el = self.element; var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc; if (!ce) return; self.containerElement = $(ce); if (/document/.test(oc) || oc == document) { self.containerOffset = { left: 0, top: 0 }; self.containerPosition = { left: 0, top: 0 }; self.parentData = { element: $(document), left: 0, top: 0, width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight }; } // i'm a node, so compute top, left, right, bottom else { var element = $(ce), p = []; $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); }); self.containerOffset = element.offset(); self.containerPosition = element.position(); self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) }; var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width, width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch); self.parentData = { element: ce, left: co.left, top: co.top, width: width, height: height }; } }, resize: function(event, ui) { var self = $(this).data("resizable"), o = self.options, ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position, pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement; if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co; if (cp.left < (self._helper ? co.left : 0)) { self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left)); if (pRatio) self.size.height = self.size.width / o.aspectRatio; self.position.left = o.helper ? co.left : 0; } if (cp.top < (self._helper ? co.top : 0)) { self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top); if (pRatio) self.size.width = self.size.height * o.aspectRatio; self.position.top = self._helper ? co.top : 0; } self.offset.left = self.parentData.left+self.position.left; self.offset.top = self.parentData.top+self.position.top; var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ), hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height ); var isParent = self.containerElement.get(0) == self.element.parent().get(0), isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position')); if(isParent && isOffsetRelative) woset -= self.parentData.left; if (woset + self.size.width >= self.parentData.width) { self.size.width = self.parentData.width - woset; if (pRatio) self.size.height = self.size.width / self.aspectRatio; } if (hoset + self.size.height >= self.parentData.height) { self.size.height = self.parentData.height - hoset; if (pRatio) self.size.width = self.size.height * self.aspectRatio; } }, stop: function(event, ui){ var self = $(this).data("resizable"), o = self.options, cp = self.position, co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement; var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height; if (self._helper && !o.animate && (/relative/).test(ce.css('position'))) $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); if (self._helper && !o.animate && (/static/).test(ce.css('position'))) $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); } }); $.ui.plugin.add("resizable", "scroll", { start: function(event, ui) { var i = $(this).data("resizable");o=i.options; if(o.scroll &&(!o.concernAngle||o.concernAngle&&!i.element.data('deg'))){ i.scrollout=1; if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset(); } }, resize: function(event, ui) { var i = $(this).data("resizable"), o = i.options, scrolled = false; if(o.scroll &&(!o.concernAngle||o.concernAngle&&!i.element.data('deg'))){ if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') { var oriscrolltop= i.scrollParent[0].scrollTop; i.element.data('resize_oriscrolltop',oriscrolltop); var lastheightval=i.lastheightval||0; if((i.axis=='s' || i.axis=='n')&&lastheightval-i.size.height !=0){ i.lastheightval=i.size.height; var delta=0; var func=function(type){ delta=i.scrollParent[0].scrollTop-oriscrolltop; if(i.axis=='s'){ if(i.scrollout==1){ i.size.height +=delta; i.scrollout=type; }else{ i.size.height +=delta*2; } }else{ if(i.scrollout==1){ i.size.height -=delta; i.position.top+=delta; i.scrollout=type; }else{ i.size.height -=delta*2; i.position.top+=delta*2; } } } if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity){ i.scrollParent[0].scrollTop = scrolled =oriscrolltop + o.scrollSpeed; func(2); }else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity){ i.scrollParent[0].scrollTop = scrolled = oriscrolltop - o.scrollSpeed; func(3); }else{ i.scrollout=1; } } } } } }); $.ui.plugin.add("resizable", "ghost", { start: function(event, ui) { var self = $(this).data("resizable"), o = self.options, cs = self.size; self.ghost = self.originalElement.clone(); self.ghost .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 }) .addClass('ui-resizable-ghost') .addClass(typeof o.ghost == 'string' ? o.ghost : ''); self.ghost.appendTo(self.helper); }, resize: function(event, ui){ var self = $(this).data("resizable"), o = self.options; if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width }); }, stop: function(event, ui){ var self = $(this).data("resizable"), o = self.options; if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0)); } }); $.ui.plugin.add("resizable", "grid", { resize: function(event, ui) { var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey; o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid; var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1); if (/^(se|s|e)$/.test(a)) { self.size.width = os.width + ox; self.size.height = os.height + oy; } else if (/^(ne)$/.test(a)) { self.size.width = os.width + ox; self.size.height = os.height + oy; self.position.top = op.top - oy; } else if (/^(sw)$/.test(a)) { self.size.width = os.width + ox; self.size.height = os.height + oy; self.position.left = op.left - ox; } else { self.size.width = os.width + ox; self.size.height = os.height + oy; self.position.top = op.top - oy; self.position.left = op.left - ox; } } }); var num = function(v) { return parseInt(v, 10) || 0; }; var isNumber = function(value) { return !isNaN(parseInt(value, 10)); }; })(jQuery); /* * jQuery UI Slider 1.8.17 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Slider * * Depends: * jquery.ui.core.js * jquery.ui.mouse.js * jquery.ui.widget.js */(function(a,b){var c=5;a.widget("ui.slider",a.ui.mouse,{widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null},_create:function(){var b=this,d=this.options,e=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),f="",g=d.values&&d.values.length||1,h=[];this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"+(d.disabled?" ui-slider-disabled ui-disabled":"")),this.range=a([]),d.range&&(d.range===!0&&(d.values||(d.values=[this._valueMin(),this._valueMin()]),d.values.length&&d.values.length!==2&&(d.values=[d.values[0],d.values[0]])),this.range=a("
").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(d.range==="min"||d.range==="max"?" ui-slider-range-"+d.range:"")));for(var i=e.length;ic&&(f=c,g=a(this),i=b)}),c.range===!0&&this.values(1)===c.min&&(i+=1,g=a(this.handles[i])),j=this._start(b,i);if(j===!1)return!1;this._mouseSliding=!0,h._handleIndex=i,g.addClass("ui-state-active").focus(),k=g.offset(),l=!a(b.target).parents().andSelf().is(".ui-slider-handle"),this._clickOffset=l?{left:0,top:0}:{left:b.pageX-k.left-g.width()/2,top:b.pageY-k.top-g.height()/2-(parseInt(g.css("borderTopWidth"),10)||0)-(parseInt(g.css("borderBottomWidth"),10)||0)+(parseInt(g.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(b,i,e),this._animateOff=!0;return!0},_mouseStart:function(a){return!0},_mouseDrag:function(a){var b={x:a.pageX,y:a.pageY},c=this._normValueFromMouse(b);this._slide(a,this._handleIndex,c);return!1},_mouseStop:function(a){this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(a,this._handleIndex),this._change(a,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1;return!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(a){var b,c,d,e,f;this.orientation==="horizontal"?(b=this.elementSize.width,c=a.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(b=this.elementSize.height,c=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),d=c/b,d>1&&(d=1),d<0&&(d=0),this.orientation==="vertical"&&(d=1-d),e=this._valueMax()-this._valueMin(),f=this._valueMin()+d*e;return this._trimAlignValue(f)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values());return this._trigger("start",a,c)},_slide:function(a,b,c){var d,e,f;this.options.values&&this.options.values.length?(d=this.values(b?0:1),this.options.values.length===2&&this.options.range===!0&&(b===0&&c>d||b===1&&c1)this.options.values[b]=this._trimAlignValue(c),this._refreshValue(),this._change(null,b);else{if(!arguments.length)return this._values();if(!a.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(b):this.value();d=this.options.values,e=arguments[0];for(f=0;f=this._valueMax())return this._valueMax();var b=this.options.step>0?this.options.step:1,c=(a-this._valueMin())%b,d=a-c;Math.abs(c)*2>=b&&(d+=c>0?b:-b);return parseFloat(d.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var b=this.options.range,c=this.options,d=this,e=this._animateOff?!1:c.animate,f,g={},h,i,j,k;this.options.values&&this.options.values.length?this.handles.each(function(b,i){f=(d.values(b)-d._valueMin())/(d._valueMax()-d._valueMin())*100,g[d.orientation==="horizontal"?"left":"bottom"]=f+"%",a(this).stop(1,1)[e?"animate":"css"](g,c.animate),d.options.range===!0&&(d.orientation==="horizontal"?(b===0&&d.range.stop(1,1)[e?"animate":"css"]({left:f+"%"},c.animate),b===1&&d.range[e?"animate":"css"]({width:f-h+"%"},{queue:!1,duration:c.animate})):(b===0&&d.range.stop(1,1)[e?"animate":"css"]({bottom:f+"%"},c.animate),b===1&&d.range[e?"animate":"css"]({height:f-h+"%"},{queue:!1,duration:c.animate}))),h=f}):(i=this.value(),j=this._valueMin(),k=this._valueMax(),f=k!==j?(i-j)/(k-j)*100:0,g[d.orientation==="horizontal"?"left":"bottom"]=f+"%",this.handle.stop(1,1)[e?"animate":"css"](g,c.animate),b==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[e?"animate":"css"]({width:f+"%"},c.animate),b==="max"&&this.orientation==="horizontal"&&this.range[e?"animate":"css"]({width:100-f+"%"},{queue:!1,duration:c.animate}),b==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[e?"animate":"css"]({height:f+"%"},c.animate),b==="max"&&this.orientation==="vertical"&&this.range[e?"animate":"css"]({height:100-f+"%"},{queue:!1,duration:c.animate}))}}),a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery); /* * jQuery UI Position 1.8.17 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Position */(function(a,b){a.ui=a.ui||{};var c=/left|center|right/,d=/top|center|bottom/,e="center",f={},g=a.fn.position,h=a.fn.offset;a.fn.position=function(b){if(!b||!b.of)return g.apply(this,arguments);b=a.extend({},b);var h=a(b.of),i=h[0],j=(b.collision||"flip").split(" "),k=b.offset?b.offset.split(" "):[0,0],l,m,n;i.nodeType===9?(l=h.width(),m=h.height(),n={top:0,left:0}):i.setTimeout?(l=h.width(),m=h.height(),n={top:h.scrollTop(),left:h.scrollLeft()}):i.preventDefault?(b.at="left top",l=m=0,n={top:b.of.pageY,left:b.of.pageX}):(l=h.outerWidth(),m=h.outerHeight(),n=h.offset()),a.each(["my","at"],function(){var a=(b[this]||"").split(" ");a.length===1&&(a=c.test(a[0])?a.concat([e]):d.test(a[0])?[e].concat(a):[e,e]),a[0]=c.test(a[0])?a[0]:e,a[1]=d.test(a[1])?a[1]:e,b[this]=a}),j.length===1&&(j[1]=j[0]),k[0]=parseInt(k[0],10)||0,k.length===1&&(k[1]=k[0]),k[1]=parseInt(k[1],10)||0,b.at[0]==="right"?n.left+=l:b.at[0]===e&&(n.left+=l/2),b.at[1]==="bottom"?n.top+=m:b.at[1]===e&&(n.top+=m/2),n.left+=k[0],n.top+=k[1];return this.each(function(){var c=a(this),d=c.outerWidth(),g=c.outerHeight(),h=parseInt(a.curCSS(this,"marginLeft",!0))||0,i=parseInt(a.curCSS(this,"marginTop",!0))||0,o=d+h+(parseInt(a.curCSS(this,"marginRight",!0))||0),p=g+i+(parseInt(a.curCSS(this,"marginBottom",!0))||0),q=a.extend({},n),r;b.my[0]==="right"?q.left-=d:b.my[0]===e&&(q.left-=d/2),b.my[1]==="bottom"?q.top-=g:b.my[1]===e&&(q.top-=g/2),f.fractions||(q.left=Math.round(q.left),q.top=Math.round(q.top)),r={left:q.left-h,top:q.top-i},a.each(["left","top"],function(c,e){a.ui.position[j[c]]&&a.ui.position[j[c]][e](q,{targetWidth:l,targetHeight:m,elemWidth:d,elemHeight:g,collisionPosition:r,collisionWidth:o,collisionHeight:p,offset:k,my:b.my,at:b.at})}),a.fn.bgiframe&&c.bgiframe(),c.offset(a.extend(q,{using:b.using}))})},a.ui.position={fit:{left:function(b,c){var d=a(window),e=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft();b.left=e>0?b.left-e:Math.max(b.left-c.collisionPosition.left,b.left)},top:function(b,c){var d=a(window),e=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop();b.top=e>0?b.top-e:Math.max(b.top-c.collisionPosition.top,b.top)}},flip:{left:function(b,c){if(c.at[0]!==e){var d=a(window),f=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft(),g=c.my[0]==="left"?-c.elemWidth:c.my[0]==="right"?c.elemWidth:0,h=c.at[0]==="left"?c.targetWidth:-c.targetWidth,i=-2*c.offset[0];b.left+=c.collisionPosition.left<0?g+h+i:f>0?g+h+i:0}},top:function(b,c){if(c.at[1]!==e){var d=a(window),f=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop(),g=c.my[1]==="top"?-c.elemHeight:c.my[1]==="bottom"?c.elemHeight:0,h=c.at[1]==="top"?c.targetHeight:-c.targetHeight,i=-2*c.offset[1];b.top+=c.collisionPosition.top<0?g+h+i:f>0?g+h+i:0}}}},a.offset.setOffset||(a.offset.setOffset=function(b,c){/static/.test(a.curCSS(b,"position"))&&(b.style.position="relative");var d=a(b),e=d.offset(),f=parseInt(a.curCSS(b,"top",!0),10)||0,g=parseInt(a.curCSS(b,"left",!0),10)||0,h={top:c.top-e.top+f,left:c.left-e.left+g};"using"in c?c.using.call(b,h):d.css(h)},a.fn.offset=function(b){var c=this[0];if(!c||!c.ownerDocument)return null;if(b)return this.each(function(){a.offset.setOffset(this,b)});return h.call(this)}),function(){var b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d,e,g,h,i;d=document.createElement(b?"div":"body"),g={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},b&&jQuery.extend(g,{position:"absolute",left:"-1000px",top:"-1000px"});for(var j in g)d.style[j]=g[j];d.appendChild(c),e=b||document.documentElement,e.insertBefore(d,e.firstChild),c.style.cssText="position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;",h=a(c).offset(function(a,b){return b}).offset(),d.innerHTML="",e.removeChild(d),i=h.top+h.left+(b?2e3:0),f.fractions=i>21&&i<22}()})(jQuery); /******************************************** * */ /* * jQuery UI Autocomplete 1.8.17 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Autocomplete * * Depends: * jquery.ui.core.js * jquery.ui.widget.js * jquery.ui.position.js */ (function(B,C){var A=0;B.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:false,delay:300,minLength:1,width:"auto",position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var F=this,D=this.element[0].ownerDocument,E;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(H){if(F.options.disabled||F.element.propAttr("readOnly")){return}E=false;var G=B.ui.keyCode;switch(H.keyCode){case G.PAGE_UP:F._move("previousPage",H);break;case G.PAGE_DOWN:F._move("nextPage",H);break;case G.UP:F._move("previous",H);H.preventDefault();break;case G.DOWN:F._move("next",H);H.preventDefault();break;case G.ENTER:case G.NUMPAD_ENTER:if(F.menu.active){E=true;H.preventDefault()}case G.TAB:if(!F.menu.active){return}F.menu.select(H);break;case G.ESCAPE:F.element.val(F.term);F.close(H);break;default:clearTimeout(F.searching);F.searching=setTimeout(function(){if(F.term!=F.element.val()){F.selectedItem=null;F.search(null,H)}},F.options.delay);break}}).bind("keypress.autocomplete",function(G){if(E){E=false;G.preventDefault()}}).bind("focus.autocomplete",function(){if(F.options.disabled){return}F.selectedItem=null;F.previous=F.element.val()}).bind("blur.autocomplete",function(G){if(F.options.disabled){return}clearTimeout(F.searching);F.closing=setTimeout(function(){F.close(G);F._change(G)},150)});this._initSource();this.response=function(){return F._response.apply(F,arguments)};this.menu=B("
    ").addClass("ui-autocomplete").appendTo(B(this.options.appendTo||"body",D)[0]).mousedown(function(G){var H=F.menu.element[0];if(!B(G.target).closest(".ui-menu-item").length){setTimeout(function(){B(document).one("mousedown",function(I){if(I.target!==F.element[0]&&I.target!==H&&!B.ui.contains(H,I.target)){F.close()}})},1)}setTimeout(function(){clearTimeout(F.closing)},13)}).menu({focus:function(H,G){var I=G.item.data("item.autocomplete");if(false!==F._trigger("focus",H,{item:I})){if(/^key/.test(H.originalEvent.type)){F.element.val(I.value)}}},selected:function(H,G){var J=G.item.data("item.autocomplete"),I=F.previous;if(F.element[0]!==D.activeElement){F.element.focus();F.previous=I;setTimeout(function(){F.previous=I;F.selectedItem=J},1)}if(false!==F._trigger("select",H,{item:J})){F.element.val(J.value)}F.term=F.element.val();F.close(H);F.selectedItem=J},blur:function(H,G){if(F.menu.element.is(":visible")&&(F.element.val()!==F.term)){F.element.val(F.term)}}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");if(B.fn.bgiframe){this.menu.element.bgiframe()}F.beforeunloadHandler=function(){F.element.removeAttr("autocomplete")};B(window).bind("beforeunload",F.beforeunloadHandler)},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");this.menu.element.remove();B(window).unbind("beforeunload",this.beforeunloadHandler);B.Widget.prototype.destroy.call(this)},_setOption:function(E,D){B.Widget.prototype._setOption.apply(this,arguments);if(E==="source"){this._initSource()}if(E==="appendTo"){this.menu.element.appendTo(B(D||"body",this.element[0].ownerDocument)[0])}if(E==="disabled"&&D&&this.xhr){this.xhr.abort()}},_initSource:function(){var E=this,F,D;if(B.isArray(this.options.source)){F=this.options.source;this.source=function(H,G){G(B.ui.autocomplete.filter(F,H.term))}}else{if(typeof this.options.source==="string"){D=this.options.source;this.source=function(H,G){if(E.xhr){E.xhr.abort()}E.xhr=B.ajax({url:D,data:H,dataType:"json",autocompleteRequest:++A,success:function(J,I){if(this.autocompleteRequest===A){G(J)}},error:function(){if(this.autocompleteRequest===A){G([])}}})}}else{this.source=this.options.source}}},search:function(D,E){D=D!=null?D:this.element.val();this.term=this.element.val();if(D.length").data("item.autocomplete",D).append(B("").text(D.label)).appendTo(E)},_move:function(D,E){if(!this.menu.element.is(":visible")){this.search(null,E);return}if(this.menu.first()&&/^previous/.test(D)||this.menu.last()&&/^next/.test(D)){this.element.val(this.term);this.menu.deactivate();return}this.menu[D](E)},widget:function(){return this.menu.element}});B.extend(B.ui.autocomplete,{escapeRegex:function(D){return D.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},filter:function(F,E){var D=new RegExp(B.ui.autocomplete.escapeRegex(E),"i");return B.grep(F,function(G){return D.test(G.label||G.value||G)})}})}(jQuery)); /* * jQuery UI Menu (not officially released) * * This widget isn't yet finished and the API is subject to change. We plan to finish * it for the next release. You're welcome to give it a try anyway and give us feedback, * as long as you're okay with migrating your code later on. We can help with that, too. * * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Menu * * Depends: * jquery.ui.core.js * jquery.ui.widget.js */ (function(A){A.widget("ui.menu",{_create:function(){var B=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(C){if(!A(C.target).closest(".ui-menu-item a").length){return}C.preventDefault();B.select(C)});this.refresh()},refresh:function(){var C=this;var B=this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem");B.children("a").addClass("ui-corner-all").attr("tabindex",-1).mouseenter(function(D){C.activate(D,A(this).parent())}).mouseleave(function(){C.deactivate()})},activate:function(C,F){this.deactivate();if(this.hasScroll()){var D=F.offset().top-this.element.offset().top,E=this.element.scrollTop(),B=this.element.height();if(D<0){this.element.scrollTop(E+D)}else{if(D>=B){this.element.scrollTop(E+D-B+F.height())}}}this.active=F.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",C,{item:F})},deactivate:function(){if(!this.active){return}this.active.children("a").removeClass("ui-state-hover").removeAttr("id");this._trigger("blur");this.active=null},next:function(B){this.move("next",".ui-menu-item:first",B)},previous:function(B){this.move("prev",".ui-menu-item:last",B)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(C,B,D){if(!this.active){this.activate(D,this.element.children(B));return}var E=this.active[C+"All"](".ui-menu-item").eq(0);if(E.length){this.activate(D,E)}else{this.activate(D,this.element.children(B))}},nextPage:function(E){if(this.hasScroll()){if(!this.active||this.last()){this.activate(E,this.element.children(".ui-menu-item:first"));return}var B=this.active.offset().top,D=this.element.height(),C=this.element.children(".ui-menu-item").filter(function(){var F=A(this).offset().top-B-D+A(this).height();return F<10&&F>-10});if(!C.length){C=this.element.children(".ui-menu-item:last")}this.activate(E,C)}else{this.activate(E,this.element.children(".ui-menu-item").filter(!this.active||this.last()?":first":":last"))}},previousPage:function(D){if(this.hasScroll()){if(!this.active||this.first()){this.activate(D,this.element.children(".ui-menu-item:last"));return}var B=this.active.offset().top,C=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var E=A(this).offset().top-B+C-A(this).height();return E<10&&E>-10});if(!result.length){result=this.element.children(".ui-menu-item:first")}this.activate(D,result)}else{this.activate(D,this.element.children(".ui-menu-item").filter(!this.active||this.first()?":last":":first"))}},hasScroll:function(){return this.element.height()"); }, destroy: function() { this.selectees .removeClass("ui-selectee") .removeData("selectable-item"); this.element .removeClass("ui-selectable ui-selectable-disabled") .removeData("selectable") .unbind(".selectable"); this._mouseDestroy(); return this; }, _mouseStart: function(event) { var self = this; this.opos = [event.pageX, event.pageY]; if (this.options.disabled) return; var options = this.options; this.selectees = $(options.filter, this.element[0]); this._trigger("start", event); $(options.appendTo).append(this.helper); // position helper (lasso) this.helper.css({ "left": event.clientX, "top": event.clientY, "width": 0, "height": 0 }); if (options.autoRefresh) { this.refresh(); } this.selectees.filter('.ui-selected').each(function() { var selectee = $.data(this, "selectable-item"); selectee.startselected = true; if (!event.metaKey && !event.ctrlKey) { selectee.$element.removeClass('ui-selected'); selectee.selected = false; selectee.$element.addClass('ui-unselecting'); selectee.unselecting = true; // selectable UNSELECTING callback self._trigger("unselecting", event, { unselecting: selectee.element }); } }); $(event.target).parents().andSelf().each(function() { var selectee = $.data(this, "selectable-item"); if (selectee) { var doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass('ui-selected'); selectee.$element .removeClass(doSelect ? "ui-unselecting" : "ui-selected") .addClass(doSelect ? "ui-selecting" : "ui-unselecting"); selectee.unselecting = !doSelect; selectee.selecting = doSelect; selectee.selected = doSelect; // selectable (UN)SELECTING callback if (doSelect) { self._trigger("selecting", event, { selecting: selectee.element }); } else { self._trigger("unselecting", event, { unselecting: selectee.element }); } return false; } }); }, _mouseDrag: function(event) { var self = this; this.dragged = true; if (this.options.disabled) return; var options = this.options; var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY; if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; } if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; } this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1}); this.selectees.each(function() { var selectee = $.data(this, "selectable-item"); //prevent helper from being selected if appendTo: selectable if (!selectee || selectee.element == self.element[0]) return; var hit = false; if (options.tolerance == 'touch') { hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) ); } else if (options.tolerance == 'fit') { hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2); } if (hit) { // SELECT if (selectee.selected) { selectee.$element.removeClass('ui-selected'); selectee.selected = false; } if (selectee.unselecting) { selectee.$element.removeClass('ui-unselecting'); selectee.unselecting = false; } if (!selectee.selecting) { selectee.$element.addClass('ui-selecting'); selectee.selecting = true; // selectable SELECTING callback self._trigger("selecting", event, { selecting: selectee.element }); } } else { // UNSELECT if (selectee.selecting) { if ((event.metaKey || event.ctrlKey) && selectee.startselected) { selectee.$element.removeClass('ui-selecting'); selectee.selecting = false; selectee.$element.addClass('ui-selected'); selectee.selected = true; } else { selectee.$element.removeClass('ui-selecting'); selectee.selecting = false; if (selectee.startselected) { selectee.$element.addClass('ui-unselecting'); selectee.unselecting = true; } // selectable UNSELECTING callback self._trigger("unselecting", event, { unselecting: selectee.element }); } } if (selectee.selected) { if (!event.metaKey && !event.ctrlKey && !selectee.startselected) { selectee.$element.removeClass('ui-selected'); selectee.selected = false; selectee.$element.addClass('ui-unselecting'); selectee.unselecting = true; // selectable UNSELECTING callback self._trigger("unselecting", event, { unselecting: selectee.element }); } } } }); return false; }, _mouseStop: function(event) { var self = this; this.dragged = false; var options = this.options; $('.ui-unselecting', this.element[0]).each(function() { var selectee = $.data(this, "selectable-item"); selectee.$element.removeClass('ui-unselecting'); selectee.unselecting = false; selectee.startselected = false; self._trigger("unselected", event, { unselected: selectee.element }); }); $('.ui-selecting', this.element[0]).each(function() { var selectee = $.data(this, "selectable-item"); selectee.$element.removeClass('ui-selecting').addClass('ui-selected'); selectee.selecting = false; selectee.selected = true; selectee.startselected = true; self._trigger("selected", event, { selected: selectee.element }); }); this._trigger("stop", event); this.helper.remove(); return false; } }); $.extend($.ui.selectable, { version: "1.8.17" }); })(jQuery);; /* * Lazy Load - jQuery plugin for lazy loading images * * Copyright (c) 2007-2013 Mika Tuupola * * Licensed under the MIT license: * http://www.opensource.org/licenses/mit-license.php * * Project home: * http://www.appelsiini.net/projects/lazyload * * Version: 1.9.3 * */ (function($, window, document, undefined) { var $window = $(window); $.fn.lazyload = function(options) { var elements = this; var $container; var settings = { threshold : 0, failure_limit : 0, event : "scroll", effect : "show", container : window, data_attribute : "original", skip_invisible : true, appear : null, load : null, placeholder : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" }; function update() { var counter = 0; elements.each(function() { var $this = $(this); if (settings.skip_invisible && !$this.is(":visible")) { return; } if($('.fullpage_alllist').length){ $this.trigger("appear"); counter = 0; }else{ if ($.abovethetop(this, settings) || $.leftofbegin(this, settings)) { /* Nothing. */ } else if (!$.belowthefold(this, settings) && !$.rightoffold(this, settings)) { $this.trigger("appear"); /* if we found an image we'll load, reset the counter */ counter = 0; } else { if (++counter > settings.failure_limit) { return false; } } } }); } if(options) { /* Maintain BC for a couple of versions. */ if (undefined !== options.failurelimit) { options.failure_limit = options.failurelimit; delete options.failurelimit; } if (undefined !== options.effectspeed) { options.effect_speed = options.effectspeed; delete options.effectspeed; } $.extend(settings, options); } /* Cache container as jQuery as object. */ $container = (settings.container === undefined || settings.container === window) ? $window : $(settings.container); /* Fire one scroll event per scroll. Not one scroll event per image. */ if (0 === settings.event.indexOf("scroll")) { $container.bind(settings.event, function() { return update(); }); } this.each(function() { var self = this; var $self = $(self); self.loaded = false; /* If no src attribute given use data:uri. */ if ($self.attr("src") === undefined || $self.attr("src") === false) { if ($self.is("img")) { $self.attr("src", settings.placeholder); } } /* fixed bug#1630 */ //if(parseInt($self.css("top"))<-100) $self.css("top",""); /* When appear is triggered load original image. */ $self.one("appear", function() { if (!this.loaded) { if (settings.appear) { var elements_left = elements.length; settings.appear.call(self, elements_left, settings); } $("") .bind("load", function() { var original = $self.attr("data-" + settings.data_attribute); $self.hide(); if ($self.is("img")) { $self.attr("src", original); } else { $self.css("background-image", "url('" + original + "')"); } $self[settings.effect](settings.effect_speed); self.loaded = true; /* Remove image from array so it is not looped next time. */ var temp = $.grep(elements, function(element) { return !element.loaded; }); elements = $(temp); if (settings.load) { var elements_left = elements.length; settings.load.call(self, elements_left, settings); } }) .attr("src", $self.attr("data-" + settings.data_attribute)); } }); /* When wanted event is triggered load original image */ /* by triggering appear. */ if (0 !== settings.event.indexOf("scroll")) { $self.bind(settings.event, function() { if (!self.loaded) { $self.trigger("appear"); } }); } }); /* Check if something appears when window is resized. */ $window.bind("resize", function() { update(); }); /* With IOS5 force loading images when navigating with back button. */ /* Non optimal workaround. */ if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) { $window.bind("pageshow", function(event) { if (event.originalEvent && event.originalEvent.persisted) { elements.each(function() { $(this).trigger("appear"); }); } }); } /* Force initial check if images should appear. */ $(document).ready(function() { update(); }); return this; }; /* Convenience methods in jQuery namespace. */ /* Use as $.belowthefold(element, {threshold : 100, container : window}) */ $.belowthefold = function(element, settings) { var fold; if (settings.container === undefined || settings.container === window) { fold = (window.innerHeight ? window.innerHeight : $window.height()) + $window.scrollTop(); } else { fold = $(settings.container).offset().top + $(settings.container).height(); } return fold <= $(element).offset().top - settings.threshold; }; $.rightoffold = function(element, settings) { var fold; if (settings.container === undefined || settings.container === window) { fold = $window.width() + $window.scrollLeft(); } else { fold = $(settings.container).offset().left + $(settings.container).width(); } return fold <= $(element).offset().left - settings.threshold; }; $.abovethetop = function(element, settings) { var fold; if (settings.container === undefined || settings.container === window) { fold = $window.scrollTop(); } else { fold = $(settings.container).offset().top; } //bug#2660 var eleparwid = $(element).height(); if(eleparwid==0&&$(element).parents().parents().attr('class')=='img_over'){ var eleparwid = $(element).parents().parents().height(); } return fold >= $(element).offset().top + settings.threshold + eleparwid; }; $.leftofbegin = function(element, settings) { var fold; if (settings.container === undefined || settings.container === window) { fold = $window.scrollLeft(); } else { fold = $(settings.container).offset().left; } return fold >= Math.max($(element).offset().left + $(element).width(),2)+ settings.threshold ; }; $.inviewport = function(element, settings) { return !$.rightoffold(element, settings) && !$.leftofbegin(element, settings) && !$.belowthefold(element, settings) && !$.abovethetop(element, settings); }; /* Custom selectors for your convenience. */ /* Use as $("img:below-the-fold").something() or */ /* $("img").filter(":below-the-fold").something() which is faster */ $.extend($.expr[":"], { "below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); }, "above-the-top" : function(a) { return !$.belowthefold(a, {threshold : 0}); }, "right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); }, "left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); }, "in-viewport" : function(a) { return $.inviewport(a, {threshold : 0}); }, /* Maintain BC for couple of versions. */ "above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); }, "right-of-fold" : function(a) { return $.rightoffold(a, {threshold : 0}); }, "left-of-fold" : function(a) { return !$.rightoffold(a, {threshold : 0}); } }); })(jQuery, window, document);; (function( $, undefined ) { var sin_cache={0:0}; var cos_cache={0:1}; var tan_cache={0:0}; $.math={}; $.math.sin=function(degree){ if(degree<0) degree=degree+360; if(degree>=360) degree=degree%360; if(sin_cache[degree]==undefined){ var value=Math.sin(degree*Math.PI/180); sin_cache[degree]=value; } return sin_cache[degree]; } $.math.cos=function(degree){ if(degree<0) degree=degree+360; if(degree>=360) degree=degree%360; if(cos_cache[degree]==undefined){ var value=Math.cos(degree*Math.PI/180); cos_cache[degree]=value; } return cos_cache[degree]; } $.math.tan=function(degree){ if(degree<0) degree=degree+360; if(degree>=360) degree=degree%360; if(tan_cache[degree]==undefined){ var value=Math.tan(degree*Math.PI/180); tan_cache[degree]=value; } return tan_cache[degree]; } $.math.acos=function(cosdegree){ var deg=Math.acos(cosdegree); return Math.round(deg*180/Math.PI); } $.parseInteger = function(str){ var i = parseInt(str); if(isNaN(i)) return 0; return i; } //跨浏览器旋转css设置 $.divrotate=function(dom,degree,initpos,sizearr){ dom=$(dom); var w=dom.width(); var h=dom.height(); if(sizearr){ w=sizearr[0]; h=sizearr[1]; } if(initpos){ var left=initpos[0]; var top=initpos[1]; if($.browser.msie && $.browser.version < 9){ w = parseInt(dom.data('IEWidth')); h = parseInt(dom.data('IEHeight')); left = dom.data('IELeft'); if(left == undefined) { left = initpos[0]; dom.data('IELeft',left); } top = dom.data('IETop'); if(top == undefined) { top = initpos[1]; dom.data('IETop',top); } ieRotate({ degree:degree, left:left, top:top, width:w, height:h, dom:dom }); }else{ dom[0].style.left=Math.round(left)+'px'; dom[0].style.top=Math.round(top)+'px'; } } if($.browser.safari || $.browser.mozilla || $.browser.opera || ($.browser.msie && $.browser.version == '9.0')){ ieRotate({ degree:degree, dom:dom }); } } $.fn.modattr=function(keyname,value){ if(keyname=='leftpos'){ var oldpos=this.data('prop_leftpos'); if(!oldpos){ oldpos=[parseInt(this.css('left')),parseInt(this.css('top'))]; } if(value!=undefined) this.data('prop_leftpos',value); return oldpos; } if(keyname=='degree'){ var oldpos=this.data('deg'); if(!oldpos){ oldpos=0; } if(value!=undefined) this.data('deg',value); return oldpos; } if(keyname=='size'){ var oldpos=this.data('prop_size'); if(!oldpos){ oldpos=[this.width(),this.height()]; } if(value!=undefined) this.data('prop_size',value); return oldpos; } } //IE实际左点和定位的左点转换函数 $.divrotate.reversePos=function(pos,degree,w,h){ var left=pos[0]; var top=pos[1]; var costheta = $.math.cos(degree); var sintheta = $.math.sin(degree); if($.browser.msie && $.browser.version < 9){ var newl=left; if(degree<90) newl=left+h*sintheta; else if(degree<180) newl=left+h*sintheta-w*costheta; else if(degree<270) newl=left-w*costheta; else newl=left; var newt=top; if(degree<90) newt=top; else if(degree<180) newt=top-h*costheta; else if(degree<270) newt=top-h*costheta-w*sintheta; else newt=top-w*sintheta; return [newl,newt]; }else{ return pos; } } //计算旋转模块离各个边界的距离 $.divrotate.getMaxDistance=function(dom){ var degree=dom.data('deg'); var left=parseInt(dom.css('left')); var top=parseInt(dom.css('top')); var w=dom.width(); var h=dom.height(); var canvaswidth = canv.width(); var maxleft,maxright,maxtop; //没有旋转 if(!degree){ maxleft=left; maxright=canvaswidth-w-left; maxtop=top; }else{ if(degree>360) degree=degree%360; var cosa=$.math.cos(degree); var sina=$.math.sin(degree); if(degree<=90){ maxleft=left-h*sina; maxright=canvaswidth-left-w*cosa; maxtop=top; }else if(degree>90 && degree<=180){ maxleft=left-h*sina+w*cosa; maxright=canvaswidth-left; maxtop=top+h*cosa; }else if(degree>180 && degree<=270){ maxleft=left+w*cosa; maxright=canvaswidth-left+h*sina; maxtop=top+h*cosa+w*sina; }else if(degree>270 && degree<=360){ maxleft=left; maxright=canvaswidth-left+h*sina-w*cosa; maxtop=top+w*sina; } } return {left:maxleft,right:maxright,top:maxtop}; } //计算旋转模块 //postype: left right,top, buttom $.divrotate.getDegreeModMaxPointOrigin=function(dom,degree,pos,sizearr,postype){ var fatherid=$.getElementFatherid(dom); var fathertoppos=$('#'+fatherid).ab_pos_cnter('top'); var degree=degree; //没有旋转 if(!degree){ var maxval=0; var w=sizearr[0]; var h=sizearr[1]; switch (postype) { case 'left': maxval=pos[0]; break; case 'right': maxval=pos[0]+w; break; case 'top': maxval=pos[1]+fathertoppos; break; case 'buttom': maxval=pos[1]+h+fathertoppos; break; } return maxval; }else{ if($.browser.msie && $.browser.version < 9){ var maxval=0; switch (postype) { case 'left': maxval = dom.position().left; break; case 'right': maxval = dom.position().left+dom.width(); break; case 'top': maxval = dom.position().top; break; case 'buttom': maxval = dom.position().top+dom.height(); break; } return maxval; } var maxval=0; var w=sizearr[0]; var h=sizearr[1]; var l=pos[0]; var t=pos[1]; if(degree>360) degree=degree%360; var cosa=$.math.cos(degree); var sina=$.math.sin(degree); switch (postype) { case 'left': if(degree<=90){ maxval=l-h*sina; }else if(degree>90 && degree<=180){ maxval=l-h*sina+w*cosa; }else if(degree>180 && degree<=270){ maxval=l+w*cosa; }else if(degree>270 && degree<=360){ maxval=l; } break; case 'right': if(degree<=90){ maxval=l+w*cosa; }else if(degree>90 && degree<=180){ maxval=l; }else if(degree>180 && degree<=270){ maxval=l-h*sina; }else if(degree>270 && degree<=360){ maxval=l-h*sina+w*cosa; } break; case 'top': if(degree<=90){ maxval=t; }else if(degree>90 && degree<=180){ maxval=t+h*cosa; }else if(degree>180 && degree<=270){ maxval=t+h*cosa+w*sina; }else if(degree>270 && degree<=360){ maxval=t+w*sina; } maxval=maxval+fathertoppos; break; case 'buttom': if(degree<=90){ maxval=t+h*cosa+w*sina; }else if(degree>90 && degree<=180){ maxval=t+w*sina; }else if(degree>180 && degree<=270){ maxval=t; }else if(degree>270 && degree<=360){ maxval=t+h*cosa; } maxval=maxval+fathertoppos; break; } return maxval; } } //计算旋转模块 //postype: left right,top, buttom $.divrotate.getDegreeModMaxPoint=function(dom,pos,postype){ var degree=dom.data('deg'); if(pos==null) pos=[$.parseInteger(dom.css('left')),$.parseInteger(dom.css('top'))] var w=dom.width(); var h=dom.height(); return $.divrotate.getDegreeModMaxPointOrigin(dom,degree,pos,[w,h],postype); } //计算旋转模块 //postype: left right,top, buttom $.divrotate.getDegreeModMaxPointForRotate=function(dom,degree,pos,postype){ var w=dom.width(); var h=dom.height(); return $.divrotate.getDegreeModMaxPointOrigin(dom,degree,pos,[w,h],postype); } // Get Resize Mouse Cursor $.divrotate.getDegreeResizeCursor=function(dom){ var degree=dom.data('deg'); if(degree==null) degree=0; if(degree>360) degree=degree%360; if(degree<=22||degree>=338){ dom.find('.ui-resizable-n').css('cursor','n-resize'); dom.find('.ui-resizable-e').css('cursor','e-resize'); dom.find('.ui-resizable-w').css('cursor','w-resize'); dom.find('.ui-resizable-s').css('cursor','s-resize'); dom.find('.ui-resizable-ne').css('cursor','ne-resize'); dom.find('.ui-resizable-se').css('cursor','se-resize'); dom.find('.ui-resizable-nw').css('cursor','nw-resize'); dom.find('.ui-resizable-sw').css('cursor','sw-resize'); }else if(degree>22&°ree<=67){ dom.find('.ui-resizable-n').css('cursor','ne-resize'); dom.find('.ui-resizable-e').css('cursor','se-resize'); dom.find('.ui-resizable-w').css('cursor','nw-resize'); dom.find('.ui-resizable-s').css('cursor','sw-resize'); dom.find('.ui-resizable-ne').css('cursor','e-resize'); dom.find('.ui-resizable-se').css('cursor','s-resize'); dom.find('.ui-resizable-nw').css('cursor','n-resize'); dom.find('.ui-resizable-sw').css('cursor','w-resize'); }else if(degree>67&°ree<=112){ dom.find('.ui-resizable-n').css('cursor','e-resize'); dom.find('.ui-resizable-e').css('cursor','s-resize'); dom.find('.ui-resizable-w').css('cursor','n-resize'); dom.find('.ui-resizable-s').css('cursor','w-resize'); dom.find('.ui-resizable-ne').css('cursor','se-resize'); dom.find('.ui-resizable-se').css('cursor','sw-resize'); dom.find('.ui-resizable-nw').css('cursor','ne-resize'); dom.find('.ui-resizable-sw').css('cursor','nw-resize'); }else if(degree>112&°ree<=157){ dom.find('.ui-resizable-n').css('cursor','se-resize'); dom.find('.ui-resizable-e').css('cursor','sw-resize'); dom.find('.ui-resizable-w').css('cursor','ne-resize'); dom.find('.ui-resizable-s').css('cursor','nw-resize'); dom.find('.ui-resizable-ne').css('cursor','s-resize'); dom.find('.ui-resizable-se').css('cursor','w-resize'); dom.find('.ui-resizable-nw').css('cursor','e-resize'); dom.find('.ui-resizable-sw').css('cursor','n-resize'); }else if(degree>157&°ree<=202){ dom.find('.ui-resizable-n').css('cursor','s-resize'); dom.find('.ui-resizable-e').css('cursor','w-resize'); dom.find('.ui-resizable-w').css('cursor','e-resize'); dom.find('.ui-resizable-s').css('cursor','n-resize'); dom.find('.ui-resizable-ne').css('cursor','sw-resize'); dom.find('.ui-resizable-se').css('cursor','nw-resize'); dom.find('.ui-resizable-nw').css('cursor','se-resize'); dom.find('.ui-resizable-sw').css('cursor','ne-resize'); }else if(degree>202&°ree<=247){ dom.find('.ui-resizable-n').css('cursor','sw-resize'); dom.find('.ui-resizable-e').css('cursor','nw-resize'); dom.find('.ui-resizable-w').css('cursor','se-resize'); dom.find('.ui-resizable-s').css('cursor','ne-resize'); dom.find('.ui-resizable-ne').css('cursor','w-resize'); dom.find('.ui-resizable-se').css('cursor','n-resize'); dom.find('.ui-resizable-nw').css('cursor','s-resize'); dom.find('.ui-resizable-sw').css('cursor','e-resize'); }else if(degree>247&°ree<=292){ dom.find('.ui-resizable-n').css('cursor','w-resize'); dom.find('.ui-resizable-e').css('cursor','n-resize'); dom.find('.ui-resizable-w').css('cursor','s-resize'); dom.find('.ui-resizable-s').css('cursor','e-resize'); dom.find('.ui-resizable-ne').css('cursor','nw-resize'); dom.find('.ui-resizable-se').css('cursor','ne-resize'); dom.find('.ui-resizable-nw').css('cursor','sw-resize'); dom.find('.ui-resizable-sw').css('cursor','se-resize'); }else if(degree>292&°ree<=337){ dom.find('.ui-resizable-n').css('cursor','nw-resize'); dom.find('.ui-resizable-e').css('cursor','ne-resize'); dom.find('.ui-resizable-w').css('cursor','sw-resize'); dom.find('.ui-resizable-s').css('cursor','se-resize'); dom.find('.ui-resizable-ne').css('cursor','n-resize'); dom.find('.ui-resizable-se').css('cursor','e-resize'); dom.find('.ui-resizable-nw').css('cursor','w-resize'); dom.find('.ui-resizable-sw').css('cursor','s-resize'); } } // Get Resize Change Property $.divrotate.getDegreeResizeChange=function(dom,pos,oriPos,oriSize,postype){ //pos[dx,dy]鼠标移动时与刚开始拉伸鼠标相对偏移量,oriPos[l,t]鼠标拖动前模块坐标,oriSize[w,h]鼠标拖动前模块宽高 var degree=dom.data('deg'); if(degree>360) degree=degree%360; var sinx = Math.sin(degree*Math.PI/180); var cosx = Math.cos(degree*Math.PI/180); if($.browser.msie && $.browser.version < 9) { //模块宽高 var w = dom.data('IEWidth'); var h = dom.data('IEHeight'); //左上顶点坐标 if(degree >= 0 && degree < 90) var l = oriPos.left + h*sinx,t = oriPos.top; else if(degree >= 90 && degree < 180) var l = h*sinx - w*cosx + oriPos.left,t = oriPos.top - h*cosx; else if(degree > 180 && degree <= 270) var l = oriPos.left - w*cosx,t = oriPos.top - w*sinx - h*cosx; else if(degree > 270 && degree < 360) var l = oriPos.left,t = w*cosx + oriPos.top; } else { var w=oriSize.width; var h=oriSize.height; var l=oriPos.left,t=oriPos.top; } //鼠标滑行偏移量 var dx=pos[0]; var dy=pos[1]; var tana=$.math.tan(degree); var bgree,height,rotateOrigin; var heplerfunc=function(ypos){ bgree=$.math.acos((dx+ypos*dy)/(Math.sqrt(dx*dx+dy*dy)*Math.sqrt(1+ypos*ypos))); height=Math.sqrt(dx*dx+dy*dy)*$.math.sin(bgree); rotateOrigin=dx*ypos-dy; } var heplerfunc2=function(ypos){ bgree=$.math.acos((dx-ypos*dy)/(Math.sqrt(dx*dx+dy*dy)*Math.sqrt(1+ypos*ypos))); height=Math.sqrt(dx*dx+dy*dy)*$.math.sin(bgree); rotateOrigin=0-(dx*ypos+dy); } if($.browser.msie && $.browser.version < 9) { var return_str = null; switch (postype) { case 'n': heplerfunc(tana); if(rotateOrigin==0) return {}; if(degree <= 90) { if(rotateOrigin>0){ return_str = {height:Math.round(h+height),left:Math.round(l+height*$.math.sin(degree)-(h+height)*$.math.sin(degree)),top:Math.round(t-height*$.math.cos(degree))} }else if(rotateOrigin<0){ return_str = {height:Math.round(h-height),left:Math.round(l-height*$.math.sin(degree)-(h-height)*$.math.sin(degree)),top:Math.round(t+height*$.math.cos(degree))} } } else if(degree>270 && degree<360) { if(rotateOrigin>0){ return_str = {height:Math.round(h+height),left:Math.round(l+height*$.math.sin(degree)),top:Math.round(t-height*$.math.cos(degree)-w*$.math.cos(degree))} }else if(rotateOrigin<0){ return_str = {height:Math.round(h-height),left:Math.round(l-height*$.math.sin(degree)),top:Math.round(t+height*$.math.cos(degree)-w*$.math.cos(degree))} } } else if(degree > 90 && degree <= 180) { if(rotateOrigin>0){ return_str = {height:Math.round(h-height),left:Math.round(l-height*$.math.sin(degree)-(h-height)*$.math.sin(degree)+w*$.math.cos(degree)),top:Math.round(t+height*$.math.cos(degree)+(h-height)*$.math.cos(degree))} }else if(rotateOrigin<0){ return_str = {height:Math.round(h+height),left:Math.round(l+height*$.math.sin(degree)-(h+height)*$.math.sin(degree)+w*$.math.cos(degree)),top:Math.round(t-height*$.math.cos(degree)+(h+height)*$.math.cos(degree))} } } else if(degree > 180 && degree <= 270) { if(rotateOrigin>0){ return_str = {height:Math.round(h-height),left:Math.round(l-height*$.math.sin(degree)+w*$.math.cos(degree)),top:Math.round(t+height*$.math.cos(degree)+(h-height)*$.math.cos(degree)+w*$.math.sin(degree))} }else if(rotateOrigin<0){ return_str = {height:Math.round(h+height),left:Math.round(l+height*$.math.sin(degree)+w*$.math.cos(degree)),top:Math.round(t-height*$.math.cos(degree)+(h+height)*$.math.cos(degree)+w*$.math.sin(degree))} } } break; case 's': heplerfunc(tana); if(rotateOrigin==0) return {}; if(degree <= 90) { if(rotateOrigin>0){ return_str = {width:w,height:Math.round(h-height),left:Math.round(l-(h-height)*$.math.sin(degree)),top:t} }else if(rotateOrigin<0){ return_str = {width:w,height:Math.round(h+height),left:Math.round(l-(h+height)*$.math.sin(degree)),top:t} } } else if(degree > 90 && degree <= 180) { if(rotateOrigin>0){ return_str = {width:w,height:Math.round(h+height),left:Math.round(l-(h+height)*$.math.sin(degree)+w*$.math.cos(degree)),top:Math.round(t+(h+height)*$.math.cos(degree))} }else if(rotateOrigin<0){ return_str = {width:w,height:Math.round(h-height),left:Math.round(l-(h-height)*$.math.sin(degree)+w*$.math.cos(degree)),top:Math.round(t+(h-height)*$.math.cos(degree))} } } else if(degree > 180 && degree <= 270) { if(rotateOrigin>0){ return_str = {width:w,height:Math.round(h+height),left:Math.round(l+w*$.math.cos(degree)),top:Math.round(t+(h+height)*$.math.cos(degree)+w*$.math.sin(degree))} }else if(rotateOrigin<0){ return_str = {width:w,height:Math.round(h-height),left:Math.round(l+w*$.math.cos(degree)),top:Math.round(t+(h-height)*$.math.cos(degree)+w*$.math.sin(degree))} } } else if(degree>270 && degree<360) { if(rotateOrigin>0){ return_str = {width:w,height:Math.round(h-height),left:l,top:Math.round(t-w*$.math.cos(degree))} }else if(rotateOrigin<0){ return_str = {width:w,height:Math.round(h+height),left:l,top:Math.round(t-w*$.math.cos(degree))} } } break; case 'w': heplerfunc2(1/tana); if(rotateOrigin==0) return {}; if(degree <= 90) { if(rotateOrigin>0){ return_str = {width:Math.round(w+height),height:h,left:Math.round(l-height*$.math.cos(degree)-h*$.math.sin(degree)),top:Math.round(t-height*$.math.sin(degree))} }else if(rotateOrigin<0){ return_str = {width:Math.round(w-height),height:h,left:Math.round(l+height*$.math.cos(degree)-h*$.math.sin(degree)),top:Math.round(t+height*$.math.sin(degree))} } } else if(degree > 90 && degree <= 180) { if(rotateOrigin>0){ return_str = {width:Math.round(w+height),height:h,left:Math.round(l-height*$.math.cos(degree)-h*$.math.sin(degree)+(w+height)*$.math.cos(degree)),top:Math.round(t-height*$.math.sin(degree)+h*$.math.cos(degree))} }else if(rotateOrigin<0){ return_str = {width:Math.round(w-height),height:h,left:Math.round(l+height*$.math.cos(degree)-h*$.math.sin(degree)+(w-height)*$.math.cos(degree)),top:Math.round(t+height*$.math.sin(degree)+h*$.math.cos(degree))} } } else if(degree > 180 && degree <= 270) { if(rotateOrigin>0){ return_str = {width:Math.round(w-height),height:h,left:Math.round(l+height*$.math.cos(degree)+(w-height)*$.math.cos(degree)),top:Math.round(t+height*$.math.sin(degree)+(w-height)*$.math.sin(degree)+h*$.math.cos(degree))} }else if(rotateOrigin<0){ return_str = {width:Math.round(w+height),height:h,left:Math.round(l-height*$.math.cos(degree)+(w+height)*$.math.cos(degree)),top:Math.round(t-height*$.math.sin(degree)+(w+height)*$.math.sin(degree)+h*$.math.cos(degree))} } } else if(degree > 270 && degree < 360) { if(rotateOrigin>0){ return_str = {width:Math.round(w-height),height:h,left:Math.round(l+height*$.math.cos(degree)),top:Math.round(t+height*$.math.sin(degree)-(w-height)*$.math.cos(degree))} }else if(rotateOrigin<0){ return_str = {width:Math.round(w+height),height:h,left:Math.round(l-height*$.math.cos(degree)),top:Math.round(t-height*$.math.sin(degree)-(w+height)*$.math.cos(degree))} } } break; case 'e': heplerfunc2(1/tana); if(rotateOrigin==0) return {}; if(degree <= 90) { if(rotateOrigin>0){ return_str = {width:Math.round(w-height),height:h,left:l-h*$.math.sin(degree),top:t} }else if(rotateOrigin<0){ return_str = {width:Math.round(w+height),height:h,left:l-h*$.math.sin(degree),top:t} } } else if(degree > 90 && degree <= 180) { if(rotateOrigin>0){ return_str = {width:Math.round(w-height),height:h,left:l-h*$.math.sin(degree)+(w-height)*$.math.cos(degree),top:t+h*$.math.cos(degree)} }else if(rotateOrigin<0){ return_str = {width:Math.round(w+height),height:h,left:l-h*$.math.sin(degree)+(w+height)*$.math.cos(degree),top:t+h*$.math.cos(degree)} } } else if(degree > 180 && degree <= 270) { if(rotateOrigin>0){ return_str = {width:Math.round(w+height),height:h,left:l+(w+height)*$.math.cos(degree),top:t+(w+height)*$.math.sin(degree)+h*$.math.cos(degree)} }else if(rotateOrigin<0){ return_str = {width:Math.round(w-height),height:h,left:l+(w-height)*$.math.cos(degree),top:t+(w-height)*$.math.sin(degree)+h*$.math.cos(degree)} } } else if(degree > 270 && degree < 360) { if(rotateOrigin>0){ return_str = {width:Math.round(w+height),height:h,left:l,top:t-(w+height)*$.math.cos(degree)} }else if(rotateOrigin<0){ return_str = {width:Math.round(w-height),height:h,left:l,top:t-(w-height)*$.math.cos(degree)} } } break; } dom.data('IEWidth_tmp',return_str.width||w).data('IEHeight_tmp',return_str.height||h); $('.propblk,.posblk').remove(); return return_str; } else { switch (postype) { case 'n': heplerfunc(tana); if(rotateOrigin==0) return {}; if(degree<=90||(degree>270 && degree<=360)){ if(rotateOrigin>0){ return {height:Math.round(h+height),left:Math.round(l+height*$.math.sin(degree)),top:Math.round(t-height*$.math.cos(degree))} }else if(rotateOrigin<0){ return {height:Math.round(h-height),left:Math.round(l-height*$.math.sin(degree)),top:Math.round(t+height*$.math.cos(degree))} } }else if(degree>90 && degree<=270){ if(rotateOrigin>0){ return {height:Math.round(h-height),left:Math.round(l-height*$.math.sin(degree)),top:Math.round(t+height*$.math.cos(degree))} }else if(rotateOrigin<0){ return {height:Math.round(h+height),left:Math.round(l+height*$.math.sin(degree)),top:Math.round(t-height*$.math.cos(degree))} } } break; case 's': heplerfunc(tana); if(rotateOrigin==0) return {}; if(degree<=90||(degree>270 && degree<=360)){ if(rotateOrigin>0){ return {height:Math.round(h-height)} }else if(rotateOrigin<0){ return {height:Math.round(h+height)} } }else if(degree>90 && degree<=270){ if(rotateOrigin>0){ return {height:Math.round(h+height)} }else if(rotateOrigin<0){ return {height:Math.round(h-height)} } } break; case 'w': heplerfunc2(1/tana); if(rotateOrigin==0) return {}; if(degree<=180){ if(rotateOrigin>0){ return {width:Math.round(w+height),left:Math.round(l-height*$.math.cos(degree)),top:Math.round(t-height*$.math.sin(degree))} }else if(rotateOrigin<0){ return {width:Math.round(w-height),left:Math.round(l+height*$.math.cos(degree)),top:Math.round(t+height*$.math.sin(degree))} } }else if(degree>180 && degree<=360){ if(rotateOrigin>0){ return {width:Math.round(w-height),left:Math.round(l+height*$.math.cos(degree)),top:Math.round(t+height*$.math.sin(degree))} }else if(rotateOrigin<0){ return {width:Math.round(w+height),left:Math.round(l-height*$.math.cos(degree)),top:Math.round(t-height*$.math.sin(degree))} } } break; case 'e': heplerfunc2(1/tana); if(rotateOrigin==0) return {}; if(degree<=180){ if(rotateOrigin>0){ return {width:Math.round(w-height)} }else if(rotateOrigin<0){ return {width:Math.round(w+height)} } }else if(degree>180 && degree<=360){ if(rotateOrigin>0){ return {width:Math.round(w+height)} }else if(rotateOrigin<0){ return {width:Math.round(w-height)} } } break; } } } })(jQuery); function rotateWithCenter(dom,degree){ dom=$(dom); var oldpos=dom.modattr('leftpos'); var oldleft=oldpos[0]; var oldtop=oldpos[1]; var olddegree=dom.modattr('degree'); var w=dom.width(); var h=dom.height(); var sinolddegree=$.math.sin(olddegree); var cosolddegree=$.math.cos(olddegree); var centerPoint=[oldleft+w/2*cosolddegree-h/2*sinolddegree,oldtop+h/2*cosolddegree+w/2*sinolddegree]; var sinnewdegree=$.math.sin(degree); var cosnewdegree=$.math.cos(degree); var newleft=centerPoint[0]+h/2*sinnewdegree-w/2*cosnewdegree; var newtop=centerPoint[1]-w/2*sinnewdegree-h/2*cosnewdegree; //dom.modattr('leftpos',[newleft,newtop]); //dom.modattr('size',[w,h]); $.divrotate(dom,degree,[newleft,newtop]); toolbarRotate(dom,degree,{w:w,h:h}); } function toolbarRotate(dom,degree,domSize){ if($(".propblk").length==0) return; dom=$(dom); var sizearr=dom.data('toolbarsize'); if(!sizearr){ sizearr=[$(".propblk").width(),$(".propblk").height()]; dom.data('toolbarsize',sizearr); } if($.browser.msie && $.browser.version < 9) { var pw = sizearr[0]; var ph = sizearr[1]; var w = $("#"+dom.attr('id')).width(); var h = $("#"+dom.attr('id')).height(); var left = $.resetModToolbarLeft($("#"+dom.attr('id')).position().left); var top = $("#"+dom.attr('id')).position().top; var angle = degree % 360; var oldModW = dom.data('IEWidth'); var oldModH = dom.data('IEHeight'); if(dom.data('sinx') == undefined) { var rotation = Math.PI * angle / 180; var cosx = Math.cos(rotation); var sinx = Math.sin(rotation); dom.data('sinx',sinx); dom.data('cosx',cosx); } else//获取模块三角函数值,不需要在属性栏旋转重新计算 { var cosx = dom.data('cosx'); var sinx = dom.data('sinx'); } if(angle > 0 && angle <= 90) { var propLeftNew = (w+left)-ph*sinx; var propTopNew = top+(h-oldModH*cosx); } else if(angle > 90 && angle <= 180) { var propLeftNew = w + left - (ph*sinx-pw*cosx) - (-1*cosx*oldModW); var propTopNew =h + top + ph*cosx; } else if(angle > 180 && angle <= 270) { var propLeftNew = left+pw*cosx; var propTopNew = top-oldModH*cosx+ph*cosx+pw*sinx; } else if(angle > 270 && angle < 360) { var propLeftNew = left+oldModW*cosx; var propTopNew = top+pw*sinx; } $(".propblk").css({filter : "progid:DXImageTransform.Microsoft.Matrix(M11="+cosx+",M12="+(-sinx)+",M21="+sinx+",M22="+cosx+",SizingMethod='auto expand')",'left':propLeftNew+'px','top':propTopNew+'px'}); } else { var oldsize=dom.data('prop_size'); var w=0; if(oldsize){ w=oldsize[0]; }else{ w=dom.width(); } if(!degree) degree=0; var oldpos=dom.data('prop_leftpos'); var oldleft=parseInt(dom.css('left')); var oldtop=parseInt(dom.css('top')); if(oldpos){ oldleft=oldpos[0]; oldtop=oldpos[1]; } var h=35; var left1 = $.math.sin(degree)*h + $.resetModToolbarLeft(parseInt(oldleft))+canv.offset().left-(window.MobileOffsetLeft||0); var top1 = parseInt(oldtop)-$.math.cos(degree)*h+$('#'+$.getElementFatherid(dom)).ab_pos_cnter('top'); $.divrotate($(".propblk"),degree,[left1,top1],sizearr); } } function modPosRotate(dom,degree,domSize){ if($(".posblk").length==0) return; dom=$(dom); var sizearr=dom.data('modpossize'); if(!sizearr){ sizearr=[$(".posblk").width(),$(".posblk").height()]; dom.data('modpossize',sizearr); } if(!degree) degree=0; var oldpos=dom.data('prop_leftpos'); var oldleft=parseInt(dom.css('left')); var oldtop=parseInt(dom.css('top')); if(oldpos){ oldleft=oldpos[0]; oldtop=oldpos[1]; } dom.data('deg',degree); $(".posblk").find('.posblk-position').html(Math.round(oldleft)+","+Math.round(oldtop)).andSelf().find('.posblk-deg').html(dom.data('deg')%360); if($.browser.msie && $.browser.version < 9) { var pow = sizearr[0]; var poh = sizearr[1]; var w = $("#"+dom.attr('id')).width(); var h = $("#"+dom.attr('id')).height(); var left = $("#"+dom.attr('id')).position().left; var top = $("#"+dom.attr('id')).position().top; var angle = degree % 360; var oldModW = dom.data('IEWidth'); var oldModH = dom.data('IEHeight'); if(dom.data('sinx') == undefined) { var rotation = Math.PI * angle / 180; var cosx = Math.cos(rotation); var sinx = Math.sin(rotation); dom.data('sinx',sinx); dom.data('cosx',cosx); } else//获取模块三角函数值,不需要在属性栏旋转重新计算 { var cosx = dom.data('cosx'); var sinx = dom.data('sinx'); } if(angle >= 0 && angle <= 90) { var posLeftNew = left + oldModH*sinx; var posTopNew = top - poh*cosx; } else if(angle > 90 && angle <= 180) { var posLeftNew = left + w + pow*cosx; var posTopNew = top - oldModH*cosx; } else if(angle > 180 && angle <= 270) { var posLeftNew = left - oldModW*cosx + pow*cosx + poh*sinx; var posTopNew = top + h + pow*sinx; } else if(angle > 270 && angle < 360) { var posLeftNew = left + poh*sinx; var posTopNew = top - oldModW*sinx-poh*cosx+pow*sinx; } $(".posblk").css({filter : "progid:DXImageTransform.Microsoft.Matrix(M11="+cosx+",M12="+(-sinx)+",M21="+sinx+",M22="+cosx+",SizingMethod='auto expand')",'left':posLeftNew+'px','top':posTopNew+'px'}); } else { // var h=$(".posblk").height()+2; // var left1 = $.math.sin(degree)*h + parseInt(oldleft)+canv.offset().left; // var top1 = parseInt(oldtop)-$.math.cos(degree)*h+$('#'+$.getElementFatherid(dom)).ab_pos_cnter('top'); // $.divrotate($(".posblk"),degree,[left1,top1],sizearr); var oldsize=dom.data('prop_size'); var w=0; if(oldsize){ w=oldsize[0] + 10; }else{ w=dom.width() + 10; } var left1 = $.math.cos(degree)*w + parseInt(oldleft)+canv.offset().left-(window.MobileOffsetLeft||0); var top1 = $.math.sin(degree)*w + parseInt(oldtop)+$('#'+$.getElementFatherid(dom)).ab_pos_cnter('top'); $.divrotate($(".posblk"),degree,[left1,top1],sizearr); } } //ie下根据模块实际宽高获取模块在0度时的左上顶点 function getOldProxyFromSize(dom,degree,w,h) { var angle = degree % 360; var oldX = $("#"+dom.attr('id')).position().left; var oldY = $("#"+dom.attr('id')).position().top; var newDom = $("#"+dom.attr('id')); if(dom.data('sinx') == undefined) { var rotation = Math.PI * angle / 180; var cosx = Math.cos(rotation); var sinx = Math.sin(rotation); dom.data('sinx',sinx); dom.data('cosx',cosx); } else { var sinx = dom.data('sinx'); var cosx = dom.data('cosx'); } if(angle == 0) { var x = oldX; var y = oldY; } else if(angle >= 0 && angle <= 90) { var x = (h*sinx+w*cosx-w)/2+oldX; var y = (w*sinx+h*cosx-h)/2+oldY; } else if(angle > 90 && angle <= 180) { var x = (h*sinx-w*cosx-w)/2+oldX; var y = (w*sinx-h*cosx-h)/2+oldY; } else if(angle > 180 && angle <= 270) { var x = (-1*h*sinx-w*cosx-w)/2+oldX; var y = (-1*w*sinx-h*cosx-h)/2+oldY; } else if(angle > 270 && angle < 360) { var x = (-1*h*sinx+w*cosx-w)/2+oldX; var y = (-1*w*sinx+h*cosx-h)/2+oldY; } return [x,y]; } //ie下获取左上顶点与标准浏览器兼容 function getLeftPointProxy(dom,degree) { var angle = degree % 360; var x0 = dom.position().left,y0 = dom.position().top;//[x0,y0]ie下面的左上顶点需要转换成标准浏览器顶点 var reg = Math.PI * angle / 180; var sinx = Math.sin(reg),cosx = Math.cos(reg); var w = dom.data('IEWidth'),h = dom.data('IEHeight'); if(angle >= 0 && angle < 90) return [Math.round(x0+h*sinx),Math.round(y0)]; else if(angle >= 90 && angle < 180) return [Math.round(x0+h*sinx-w*cosx),Math.round(y0-h*cosx)]; else if(angle > 180 && angle <= 270) return [Math.round(x0-w*cosx),Math.round(y0-h*cosx-w*sinx)]; else if(angle > 270 && angle < 360) return [Math.round(x0),Math.round(y0-w*sinx)]; }; // Loading And Blocking JavaScript (function(o){var K=o.$LAB,y="UseLocalXHR",z="AlwaysPreserveOrder",u="AllowDuplicates",A="CacheBust",B="BasePath",C=/^[^?#]*\//.exec(location.href)[0],D=/^\w+\:\/\/\/?[^\/]+/.exec(C)[0],i=document.head||document.getElementsByTagName("head"),L=(o.opera&&Object.prototype.toString.call(o.opera)=="[object Opera]")||("MozAppearance"in document.documentElement.style),q=document.createElement("script"),E=typeof q.preload=="boolean",r=E||(q.readyState&&q.readyState=="uninitialized"),F=!r&&q.async===true,M=!r&&!F&&!L;function G(a){return Object.prototype.toString.call(a)=="[object Function]"}function H(a){return Object.prototype.toString.call(a)=="[object Array]"}function N(a,c){var b=/^\w+\:\/\//;if(/^\/\/\/?/.test(a)){a=location.protocol+a}else if(!b.test(a)&&a.charAt(0)!="index.html"){a=(c||"")+a}return b.test(a)?a:((a.charAt(0)=="/"?D:C)+a)}function s(a,c){for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c}function O(a){var c=false;for(var b=0;b0){for(var a=0;a=0;){d=n.shift();a=a[d.type].apply(null,d.args)}return a},noConflict:function(){o.$LAB=K;return m},sandbox:function(){return J()}};return m}o.$LAB=J();(function(a,c,b){if(document.readyState==null&&document[a]){document.readyState="loading";document[a](c,b=function(){document.removeEventListener(c,b,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this);; var mclick = 'click',mtouchstart = 'mousedown',mtouchend = 'mouseup',mtouchmove = 'mousemove'; if (window.ontouchstart !== undefined) { mclick = 'click';mtouchstart = 'touchstart';mtouchend = 'touchend';mtouchmove = 'touchmove'; } /**Global Function**/ function getSessionExpiredUrl() { $(window).unbind('beforeunload'); alert(translate('page.sessionTimeout')); window.close(); return null; } function initCanvasHeight(){ var maxheight=0; var helperfunc=function(dom){ var degree=dom.data('deg')||dom.attr('deg'); var pos=[parseInt(dom.css('left')),parseInt(dom.css('top'))] var w=dom.width(); var h=dom.height(); if(dom.hasClass('cstlayer')){ var buttompos=$.divrotate.getDegreeModMaxPointOrigin(dom,degree,pos,[w,h],'buttom'); }else{ var buttompos=dom.ab_pos_cnter('top')+parseInt(dom.css('height')); } return buttompos; } var filterfunc=function(){ return $(this).is(":not(div[deleted='deleted'])") && $(this).attr('childdel') != 'del'; } $('#canvas .cstlayer,#canvas .full_column').filter(filterfunc).each(function(){ var canvheight=helperfunc($(this)); if(canvheight>maxheight) maxheight=canvheight; }) $("#canvas").data('layermaxheight',maxheight); } /**document ready js**/ $(document).bind('lastexec',function(){ // Mobile device 2014/01/06 if (window.MobileModel) { var $scontainer = $('#scroll_container'),canvaswidth = $('#canvas').width(); $scontainer.unbind(".mbprevredhat.tmpredhat"); if ($('#wp-mobile-device-header').length > 0) { // 手机模型定位 var screenWidth = window.innerWidth||self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth, deviceOtherHeight = $('#wp-mobile-device-header').closest('.wp-new-manage-toolbar-position').height() + $('#wp-mobile-device-footer').height(); var onlyOnce_resize_width = false; $(window).bind("resize.mbeditor", function(e, status){ var screenHeight = window.innerHeight||self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight; $('#wp-mobile-device-sides').height(screenHeight - deviceOtherHeight).children('.mwrapper').height(screenHeight - deviceOtherHeight - 2); // 自定义滚动条样式 var sidewidth = 14;/* 手机模型边缘宽度 */ var mbtimer = setTimeout(function(){ var newleft = ($._parseFloat($('#wp-mobile-device-header').css("left"))||0) + sidewidth; $scontainer.css({"left": (newleft - 10)+'px',"width": function(){/*-10是为了修复"缩放句柄被遮"问题*/ if( onlyOnce_resize_width == false ){ onlyOnce_resize_width = true; return ($(this).width() + (status?(sidewidth + 15 + 10):0))+'px'; }else{ return ; } },"margin": '0',"padding-left": '11px',"top": '-6px',"overflow-y": 'scroll'}); $('#site_footer').css("left", '11px');/*11px是为了修复"缩放句柄被遮"问题*/ if (status == undefined) $scontainer.mscroll("destroy"); $scontainer.mscroll({difleft: 10,maskbg: '#ccc'});clearTimeout(mbtimer); }, 100); }).triggerHandler("resize.mbeditor", ['init']); $('#wp-mobile-device-header,#wp-mobile-device-sides,#wp-mobile-device-footer').css({"left": function(){ return ((screenWidth - $(this).width()) / 2)+'px'; }, "visibility": 'visible'}); // 保存布局 $('#wp-mobile-device-footer > span').click(function(){ wp_floatpanel(parseToURL('wp_widgets','save_page'),{ title: translate('page.saveLayout'),width: 418,overlay: true,isCenter: true, contentClass: 'wp-site-set_panel_c',id: 'wp-page_save',zIndex: 9999 }); }); } else {/* 预览模式 */ $scontainer.css("visibility", 'visible'); $(window).load(function(){ var $win = $(this),frmwidth = $win.width(),frmheight = window.getdeviceheight||565; $scontainer.height(frmheight); var mprevtimer = setTimeout(function(){ $scontainer.mscroll({"maskcname": 'wp-mobile-device-premask',"difleft": -6, "height": frmheight,"barcname": 'wp-mobile-prescrollbar',"maskleft": frmwidth,"barleft": frmwidth}); $win.triggerHandler("pageloaded");clearTimeout(mprevtimer); // 模拟“触屏”模式 var maxtop = frmheight - $('.wp-mobile-prescrollbar > span.pane').height(); $scontainer.bind("mousedown.mbprevredhat", function(e){ e.preventDefault(); var $prebar = $('.wp-mobile-prescrollbar'),pagey = e.pageY; $scontainer.bind("mousemove.tmpredhat", function(e){ e.preventDefault(); var scrltop = $scontainer.scrollTop(),movey = e.pageY - pagey; if (scrltop < 0) scrltop = 0; $scontainer.scrollTop(scrltop - movey); }).bind("mouseup.tmpredhat", function(e){ e.preventDefault();$scontainer.unbind(".tmpredhat"); $(parent.document).unbind(".rmredhat"); }); $(parent.document).bind("mouseup.rmredhat",function(){$scontainer.unbind(".tmpredhat")}); }); }, 150); }); } $('#site_footer,#footer_content').width(canvaswidth); } function resizeCanvasHeight(){ window.canv = $("#canvas"); var container=$('#scroll_container'); // 画布高度 var cvhgt = window.innerHeight || self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;//$(window).height(); if (window.isHandheld) cvhgt = Math.min(cvhgt, MobileUtils.getScreenHeight()); cvhgt -= container.offset().top,mfooterheight = $('#wp-mobile-device-footer').height()||0; container.height(cvhgt - mfooterheight); if($('#site_footer').length>0){ var canvheight=Math.max($("#canvas").data('layermaxheight'),cvhgt-$('#site_footer').height()-mfooterheight); if($('#site_footer:not(.only_copyright)').length>0){ canvheight=Math.max(canvheight,$("#canvas").height()); } }else{ var canvheight=Math.max($("#canvas").data('layermaxheight'),cvhgt); } // 重置bSlider模块高度 2013/03/25 $('.cstlayer[type="bslider"]:not(.isplate)').each(function(i, dom){ $(dom).triggerHandler('resetbsliderheight', [canvheight]); }); canv.css('height',canvheight+'px'); $('#scroll_container_bg').css('height',(canvheight+$('#site_footer').height())+'px'); if($(window).width()-canv.width()<0) $('#scroll_container_bg').width(canv.width()); else $('#scroll_container_bg').css('width','100%'); // 更新标尺位置Start 2012/3/2 var canvleft = canv.offset().left; if (typeof $.fn.ruler_locate != 'undefined') { $.fn.ruler_locate({ x : {left:canvleft+'px'}, y : {height:canvheight+'px', left:(canvleft>17?canvleft-17:0)+'px'} }); $('.line_y').height(canvheight);// 辅助线高度 } // 在手机设备上访问 2014/02/08 if (window.isHandheld) { var $container = $('#scroll_container'),$footer = $('#site_footer'), maxheight = $('#scroll_container_bg').height() + $('>.mblank_placeholder',$container).height(); $container.css({"height": maxheight+'px',"overflow-x": 'hidden',"overflow-y": 'hidden'}); if($footer.length) $footer.find('#footer_content').andSelf().width($('#canvas').width()); /*adpHandheld();*/$('.mloading-mask').remove(); $container.css("visibility", 'visible');$(window).triggerHandler("pageloaded"); } // 修复ipad中iframe touchmove冲突问题(bug#97) 2014/09/16 if (/ipad/.test(navigator.userAgent.toLowerCase())) { $(document.body).parent().andSelf().css({"overflow-x": 'hidden',"overflow-y": 'auto'}); container.css({"height": 'auto',"overflow-y": 'auto'}); } } function correctFooterPos(){ var canvheight=canv.height(); var canvwidth=canv.width(); var containerOffsetLeft = $('#scroll_container').offset().left; $('#site_footer').css({left:canv.offset().left-containerOffsetLeft+$('#scroll_container').scrollLeft()+$.parseInteger($('#canvas').css("borderLeftWidth")),top:canvheight}); $('#site_footer >.full_width').css({left:0-canv.offset().left+containerOffsetLeft-$('#scroll_container').scrollLeft()-$.parseInteger($('#canvas').css("borderLeftWidth")),width:$(window.MobileModel?'#canvas':'#scroll_container_bg').width()}); if($('#wp-mobile-device-header').length) $('#site_footer >.full_width').css("left", '0px'); } window.correctFooterPos=correctFooterPos; window.scroll_container_adjust=function(){ initCanvasHeight(); resizeCanvasHeight(); correctFooterPos(); } window.scroll_container_adjust(); $('.full_column>.full_width').css({left:0-canv.offset().left+$('#scroll_container').offset().left-$('#scroll_container').scrollLeft()-$.parseInteger($('#canvas').css("borderLeftWidth")),width:$('#scroll_container_bg').width()}); //浏览器缩放是自动调整高度 var me = "orientation" in window && "onorientationchange" in window ? "orientationchange" : "resize" $(window).bind(me, function(e){ if(e.target==window||e.target==document){ resizeCanvasHeight(); correctFooterPos(); $('.full_column>.full_width').css({left:0-canv.offset().left+$('#scroll_container').offset().left-$('#scroll_container').scrollLeft()-$.parseInteger($('#canvas').css("borderLeftWidth")),width:$('#scroll_container_bg').width()}); } }) if (!window.isHandheld) rotateDom($('.cstlayer')); //Preview need resize window if(window.opener){ var winH = screen.availHeight || 768,winW = screen.availWidth || 1024; window.resizeTo(winW, winH); } // 新窗口打开超链接 $.extend({ openNewWin: function(URI){ var win = window.open(URI,'_blank'); win.focus; } }); }); jQuery.cookie=function(B,F,E){if(arguments.length>1&&(F===null||typeof F!=="object")){E=jQuery.extend({},E);if(F===null){E.expires=-1}if(typeof E.expires==="number"){var D=E.expires,G=E.expires=new Date();G.setDate(G.getDate()+D)}return(document.cookie=[encodeURIComponent(B),"=",E.raw?String(F):encodeURIComponent(String(F)),E.expires?"; expires="+E.expires.toUTCString():"",E.path?"; path="+E.path:"",E.domain?"; domain="+E.domain:"",E.secure?"; secure":""].join(""))}E=F||{};var A,C=E.raw?function(H){return H}:decodeURIComponent;return(A=new RegExp("(?:^|; )"+encodeURIComponent(B)+"=([^;]*)").exec(document.cookie))?C(A[1]):null};; /* * SimpleModal 1.4.1 - jQuery Plugin * http://www.ericmmartin.com/projects/simplemodal/ * Copyright (c) 2010 Eric Martin (http://twitter.com/ericmmartin) * Dual licensed under the MIT and GPL licenses * Revision: $Id: jquery.simplemodal.js 261 2010-11-05 21:16:20Z emartin24 $ */ (function(d){var k=d.browser.msie&&parseInt(d.browser.version)===6&&typeof window.XMLHttpRequest!=="object",m=d.browser.msie&&parseInt(d.browser.version)===7,l=null,f=[];d.modal=function(a,b){return d.modal.impl.init(a,b)};d.modal.close=function(){d.modal.impl.close()};d.modal.focus=function(a){d.modal.impl.focus(a)};d.modal.setContainerDimensions=function(){d.modal.impl.setContainerDimensions()};d.modal.setPosition=function(){d.modal.impl.setPosition()};d.modal.update=function(a,b){d.modal.impl.update(a, b)};d.fn.modal=function(a){return d.modal.impl.init(this,a)};d.modal.defaults={appendTo:"body",focus:true,opacity:50,overlayId:"simplemodal-overlay",overlayCss:{},containerId:"simplemodal-container",containerCss:{},dataId:"simplemodal-data",dataCss:{},minHeight:null,minWidth:null,maxHeight:null,maxWidth:null,autoResize:false,autoPosition:true,zIndex:1E3,close:true,closeHTML:'',closeClass:"simplemodal-close",escClose:true,overlayClose:false,position:null, persist:false,modal:true,onOpen:null,onShow:null,onClose:null};d.modal.impl={d:{},init:function(a,b){var c=this;if(c.d.data)return false;l=d.browser.msie&&!d.boxModel;c.o=d.extend({},d.modal.defaults,b);c.zIndex=c.o.zIndex;c.occb=false;if(typeof a==="object"){a=a instanceof jQuery?a:d(a);c.d.placeholder=false;if(a.parent().parent().size()>0){a.before(d("").attr("id","simplemodal-placeholder").css({display:"none"}));c.d.placeholder=true;c.display=a.css("display");if(!c.o.persist)c.d.orig= a.clone(true)}}else if(typeof a==="string"||typeof a==="number")a=d("
    ").html(a);else{alert("SimpleModal Error: Unsupported data type: "+typeof a);return c}c.create(a);c.open();d.isFunction(c.o.onShow)&&c.o.onShow.apply(c,[c.d]);return c},create:function(a){var b=this;f=b.getDimensions();if(b.o.modal&&k)b.d.iframe=d('').css(d.extend(b.o.iframeCss,{display:"none",opacity:0,position:"fixed",height:f[0],width:f[1],zIndex:b.o.zIndex,top:0,left:0})).appendTo(b.o.appendTo); b.d.overlay=d("
    ").attr("id",b.o.overlayId).addClass("simplemodal-overlay").css(d.extend(b.o.overlayCss,{display:"none",opacity:b.o.opacity/100,height:b.o.modal?f[0]:0,width:b.o.modal?f[1]:0,position:"fixed",left:0,top:0,zIndex:b.o.zIndex+1})).appendTo(b.o.appendTo);b.d.container=d("
    ").attr("id",b.o.containerId).addClass("simplemodal-container").css(d.extend(b.o.containerCss,{display:"none",position:"fixed",zIndex:b.o.zIndex+2})).append(b.o.close&&b.o.closeHTML?d(b.o.closeHTML).addClass(b.o.closeClass): "").appendTo(b.o.appendTo);b.d.wrap=d("
    ").attr("tabIndex",-1).addClass("simplemodal-wrap").css({height:"100%",outline:0,width:"100%"}).appendTo(b.d.container);b.d.data=a.attr("id",a.attr("id")||b.o.dataId).addClass("simplemodal-data").css(d.extend(b.o.dataCss,{display:"none"})).appendTo("body");b.setContainerDimensions();b.d.data.appendTo(b.d.wrap);if(k||l)b.fixIE()},bindEvents:function(){var a=this;d("."+a.o.closeClass).bind("click.simplemodal",function(b){b.preventDefault();a.close()}); a.o.modal&&a.o.close&&a.o.overlayClose&&a.d.overlay.bind("click.simplemodal",function(b){b.preventDefault();a.close()});d(document).bind("keydown.simplemodal",function(b){if(a.o.modal&&b.keyCode===9)a.watchTab(b);else if(a.o.close&&a.o.escClose&&b.keyCode===27){b.preventDefault();a.close()}});d(window).bind("resize.simplemodal",function(){f=a.getDimensions();a.o.autoResize?a.setContainerDimensions():a.o.autoPosition&&a.setPosition();if(k||l)a.fixIE();else if(a.o.modal){a.d.iframe&&a.d.iframe.css({height:f[0], width:f[1]});a.d.overlay.css({height:f[0],width:f[1]})}})},unbindEvents:function(){d("."+this.o.closeClass).unbind("click.simplemodal");d(document).unbind("keydown.simplemodal");d(window).unbind("resize.simplemodal");this.d.overlay.unbind("click.simplemodal")},fixIE:function(){var a=this,b=a.o.position;d.each([a.d.iframe||null,!a.o.modal?null:a.d.overlay,a.d.container],function(c,h){if(h){var g=h[0].style;g.position="absolute";if(c<2){g.removeExpression("height");g.removeExpression("width");g.setExpression("height", 'document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight : document.body.clientHeight + "px"');g.setExpression("width",'document.body.scrollWidth > document.body.clientWidth ? document.body.scrollWidth : document.body.clientWidth + "px"')}else{var e;if(b&&b.constructor===Array){c=b[0]?typeof b[0]==="number"?b[0].toString():b[0].replace(/px/,""):h.css("top").replace(/px/,"");c=c.indexOf("%")===-1?c+' + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"': parseInt(c.replace(/%/,""))+' * ((document.documentElement.clientHeight || document.body.clientHeight) / 100) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"';if(b[1]){e=typeof b[1]==="number"?b[1].toString():b[1].replace(/px/,"");e=e.indexOf("%")===-1?e+' + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"':parseInt(e.replace(/%/,""))+' * ((document.documentElement.clientWidth || document.body.clientWidth) / 100) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"'}}else{c= '(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"';e='(document.documentElement.clientWidth || document.body.clientWidth) / 2 - (this.offsetWidth / 2) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"'}g.removeExpression("top");g.removeExpression("left");g.setExpression("top", c);g.setExpression("left",e)}}})},focus:function(a){var b=this;a=a&&d.inArray(a,["first","last"])!==-1?a:"first";var c=d(":input:enabled:visible:"+a,b.d.wrap);setTimeout(function(){c.length>0?c.focus():b.d.wrap.focus()},10)},getDimensions:function(){var a=d(window);return[d.browser.opera&&d.browser.version>"9.5"&&d.fn.jquery<"1.3"||d.browser.opera&&d.browser.version<"9.5"&&d.fn.jquery>"1.2.6"?a[0].innerHeight:a.height(),a.width()]},getVal:function(a,b){return a?typeof a==="number"?a:a==="auto"?0: a.indexOf("%")>0?parseInt(a.replace(/%/,""))/100*(b==="h"?f[0]:f[1]):parseInt(a.replace(/px/,"")):null},update:function(a,b){var c=this;if(!c.d.data)return false;c.d.origHeight=c.getVal(a,"h");c.d.origWidth=c.getVal(b,"w");c.d.data.hide();a&&c.d.container.css("height",a);b&&c.d.container.css("width",b);c.setContainerDimensions();c.d.data.show();c.o.focus&&c.focus();c.unbindEvents();c.bindEvents()},setContainerDimensions:function(){var a=this,b=k||m,c=a.d.origHeight?a.d.origHeight:d.browser.opera? a.d.container.height():a.getVal(b?a.d.container[0].currentStyle.height:a.d.container.css("height"),"h");b=a.d.origWidth?a.d.origWidth:d.browser.opera?a.d.container.width():a.getVal(b?a.d.container[0].currentStyle.width:a.d.container.css("width"),"w");var h=a.d.data.outerHeight(true),g=a.d.data.outerWidth(true);a.d.origHeight=a.d.origHeight||c;a.d.origWidth=a.d.origWidth||b;var e=a.o.maxHeight?a.getVal(a.o.maxHeight,"h"):null,i=a.o.maxWidth?a.getVal(a.o.maxWidth,"w"):null;e=e&&ee?e:ce?e:a.o.minHeight&&j!=="auto"&&hi?i:bi?i:a.o.minWidth&&e!=="auto"&&gc||g>b?"auto":"visible"});a.o.autoPosition&&a.setPosition()},setPosition:function(){var a=this,b,c;b=f[0]/2-a.d.container.outerHeight(true)/2;c=f[1]/2-a.d.container.outerWidth(true)/ 2;if(a.o.position&&Object.prototype.toString.call(a.o.position)==="[object Array]"){b=a.o.position[0]||b;c=a.o.position[1]||c}else{b=b;c=c}a.d.container.css({left:c,top:b})},watchTab:function(a){var b=this;if(d(a.target).parents(".simplemodal-container").length>0){b.inputs=d(":input:enabled:visible:first, :input:enabled:visible:last",b.d.data[0]);if(!a.shiftKey&&a.target===b.inputs[b.inputs.length-1]||a.shiftKey&&a.target===b.inputs[0]||b.inputs.length===0){a.preventDefault();b.focus(a.shiftKey?"last": "first")}}else{a.preventDefault();b.focus()}},open:function(){var a=this;a.d.iframe&&a.d.iframe.show();if(d.isFunction(a.o.onOpen))a.o.onOpen.apply(a,[a.d]);else{a.d.overlay.show();a.d.container.show();a.d.data.show()}a.o.focus&&a.focus();a.bindEvents()},close:function(){var a=this;if(!a.d.data)return false;a.unbindEvents();if(d.isFunction(a.o.onClose)&&!a.occb){a.occb=true;a.o.onClose.apply(a,[a.d])}else{if(a.d.placeholder){var b=d("#simplemodal-placeholder");if(a.o.persist)b.replaceWith(a.d.data.removeClass("simplemodal-data").css("display", a.display));else{a.d.data.hide().remove();b.replaceWith(a.d.orig)}}else a.d.data.hide().remove();a.d.container.hide().remove();a.d.overlay.hide();a.d.iframe&&a.d.iframe.hide().remove();setTimeout(function(){a.d.overlay.remove();a.d={}},10)}}}})(jQuery); /** * Confirm对话框 * (String)message - 欲显示的内容 * (Function)callback - 回调函数 */ function wp_confirm(message, callback, cancelBack){ if ($('#wp-confirmpnl_overlay,#wp-confirm_panel').size()) return; var width = 286,pnl = '',ol = '
    '; pnl = ''; $(ol+pnl).appendTo('body'); var $cpnl = $('#wp-confirm_panel'); $cpnl.bind('rename',function(e,name){ if (name.length) {var self = this; $('a.wp-alert-sure',self).html(name); var timerid = setTimeout(function(){ var newidth = $('a.wp-alert-sure',self).outerWidth(true) + $('a.wp-alert-cancel',self).outerWidth(true); $('.wp-alert_button',self).width(newidth);newidth = null;clearTimeout(timerid); }, 50); } }); // 动态设置wp-alert_button宽度 var resetWtimer = setTimeout(function(){ var $altbtn = $cpnl.find('.wp-alert_button'); $altbtn.width($altbtn.outerWidth()); // var maxw = 0,$altbtn = $cpnl.find('.wp-alert_button'); // $altbtn.children('a').each(function(i,a){ // maxw += $(this).outerWidth(true); // }); // if(maxw) $altbtn.width(maxw); },30); // 定位Dialog panel_position($cpnl,width,'auto',true,'wp-confirmpnl_overlay'); // Bind window resize $(window).resize(function(){ panel_position($cpnl,width,'auto',true,'wp-confirmpnl_overlay'); }); // 绑定"OK|Cancel"按钮 $cpnl.find('a.wp-alert-sure').click(function(e){ if(callback && $.isFunction(callback)) callback(); $cpnl.add('#wp-confirmpnl_overlay').remove(); if(resetWtimer) clearTimeout(resetWtimer); e.preventDefault(); }).end().find('a.wp-alert-cancel').click(function(e){ if(cancelBack && $.isFunction(cancelBack)) cancelBack(); $cpnl.add('#wp-confirmpnl_overlay').remove(); if(resetWtimer) clearTimeout(resetWtimer); e.preventDefault(); }); // 绑定Enter事件 $(document).keydown(function(e){ if(e.keyCode == 13) $cpnl.find('a.wp-alert-sure').trigger('click'); }); return false; } function wp_editPicOnline(param) { var imgtype=parseInt(getImageProcessType())||0; //图片处理 0 使用aviary处理 1 使用美图秀秀处理 var imgprocess=['feather','xiuxiu']; if(imgtype >= imgprocess.length) imgtype=0; var imgtypestr=imgprocess[imgtype]; $LAB.script(relativeToAbsoluteURL('script/wopop2_'+imgtypestr+'.js')) .wait(function(){ wp_editPicOnlineActual(param); }) } /** * Alert对话框 * (String)message - 欲显示的内容 */ function wp_alert(message,callback){ if ($('#wp-alertpnl_overlay,#wp-alert_panel').size()) return; var width = 286,pnl = '',ol = '
    '; pnl = '
    ' +'
    ' +'
    '; $(ol+pnl).appendTo('body'); var $apnl = $('#wp-alert_panel'); // 定位Dialog panel_position($apnl,width,'auto',true,'wp-alertpnl_overlay'); // Bind window resize $(window).resize(function(){ panel_position($apnl,width,'auto',true,'wp-alertpnl_overlay'); }); // 绑定"OK"按钮 $apnl.find('a.wp-alert-sure').click(function(e){ $apnl.add('#wp-alertpnl_overlay').remove(); if($.isFunction(callback)) callback(); e.preventDefault(); }); // 绑定Enter事件 $(document).keydown(function(e){ if(e.keyCode == 13) $apnl.find('a.wp-alert-sure').trigger('click'); }); return false; } /** * -------------------------------------------------------- * Popup对话框(临时函数) * -------------------------------------------------------- */ function show_dialog(load_url, title, width, height, callback, opentype){ var fn = $.extend({}, { open: function(d){}, close: function(d){} }, callback || {}); $('#osx-modal-content').modal({ overlayId: 'osx-overlay', containerId: 'osx-container', closeHTML: null, zIndex: 1000, opacity: 25, onOpen: function(d){ fn.open(d); var self = this, $container = d.container, container = $container[0]; var $data = $('#osx-modal-data', container); if (opentype == 'iframe') { $data.html(''); d.overlay.show(); $data.show(); $('#osx-modal-content,div.close', container).show(); $('#osx-modal-title', container).html(title).show(); $container.fadeTo('fast',1).draggable({handle: '#osx-modal-title',cursor: 'move'}); } else { var $ajaxload = $('#wp-ajaxsend_loading2'),$win = $(window); if($ajaxload.size()==0) $('
    ').appendTo('body'); $.get(load_url, function(data){ $data.html(data); d.overlay.show(); $data.show(); $('#osx-modal-content,div.close', container).show(); $('#osx-modal-title', container).html(title).show(); $container.fadeTo('fast',1).draggable({handle: '#osx-modal-title',cursor: 'move'}); self.setPosition(); $('#wp-ajaxsend_loading2').remove(); }).error(function(){ $('#wp-ajaxsend_loading2').remove(); alert(translate('Request failed!')); self.close();return; }); } if(width > 0) $container.css('width', width); $container.css('height', height || ''); $('#osx-modal-content').bind('add_loading',function(){ var loading=$data.children('.loading'); if(loading.size()) loading.remove(); $('
    ').appendTo($data); }) // d.overlay.fadeIn('slow', function(){ // $data.show(); // $('#osx-modal-content,div.close', container).show(); // $('#osx-modal-title', container).html(title).show(); // // $container.fadeTo('fast',1).draggable({handle: '#osx-modal-title',cursor: 'move'}); // }); }, onClose: function(d){ fn.close(d); var self = this; d.container.hide(); d.overlay.hide(); $("#osx-modal-content").triggerHandler('dialogclose', d); $("#osx-modal-content").unbind('dialogclose'); $('#osx-modal-content').unbind('add_loading'); setTimeout(function(){ self.close(); },500) // d.container.fadeOut('slow', function(){ // d.overlay.fadeOut('slow', function(){ // $("#osx-modal-content").triggerHandler('dialogclose', d); // $("#osx-modal-content").unbind('dialogclose'); // self.close(); // }); // }); } }); } /*获取样式*/ function get_plugin_css(tagid,css){ var setcss=$("#page_set_css").html(); setcss=setcss.replace(/'); } (function( $, undefined ) { var callbackhash={}; var mod_property={}; $.modplugin={ addCallBack:function(type,funcname,func){ if($.isFunction(func)){ if(!callbackhash[type]) callbackhash[type]={}; callbackhash[type][funcname]=func; } }, fireCallBack:function(type,funcname,dom,data){ var func=callbackhash[type]; if(!func) return false; func=func[funcname]; if($.isFunction(func)){ return func(dom,data); }else{ return false; } } } $.fn.execPluginCallBack=function(funcname,data){ return $.modplugin.fireCallBack(this.attr('type'),funcname,this,data); } $.fn.mod_property=function(key,val){ if($.isPlainObject(key)){ for(var inkey in key){ this.mod_property(inkey,key[inkey]); } return ; } var id=this.prop('id'); if(!id) return null; var propertydata=mod_property[id]; if(!propertydata){ mod_property[id]=propertydata={}; } if(val !== undefined){ propertydata[key]=val; return val; }else{ return propertydata[key]; } } var PropertyCommand=null; function initPropCommand(){ if(PropertyCommand) return; PropertyCommand=Undo.Command.createModuleCommand(function(blockid,val){ var blockel=$('#'+blockid); if(val.propval!=undefined) blockel.mod_property(val.propkey,val.propval); else blockel.del_mod_property(val.propkey); blockel.execPluginCallBack('property_undo',val); },null,{returntype:'class'}); } $.fn.autoundo_mod_property=function(key,val){ if(val === undefined) return this.mod_property(key); initPropCommand(); var oldval=this.mod_property(key); this.mod_property(key,val); var oldvalue={propkey:key,propval:oldval,act:'set',cmdtype:'undo'} var newvalue={propkey:key,propval:val,act:'set',cmdtype:'redo'} if(!Undo.Command.DefaultEqAct(oldval,val)) new PropertyCommand(this.attr('id')).insertWithVals(oldvalue, newvalue); } $.fn.autoundo_del_mod_property=function(key){ initPropCommand(); var oldval=this.mod_property(key); this.del_mod_property(key); var oldvalue={propkey:key,propval:oldval,act:'del',cmdtype:'undo'} var newvalue={propkey:key,act:'del',cmdtype:'redo'} if(oldval != undefined) new PropertyCommand(this.attr('id')).insertWithVals(oldvalue, newvalue); } $.fn.del_mod_property=function(key){ var id=this.prop('id'); if(!id) return null; var propertydata=mod_property[id]; if($.isPlainObject(propertydata)){ var oldval=propertydata[key]; delete propertydata[key]; return oldval; } } $.fn.get_mod_property=function(){ var id=this.prop('id'); if(!id) return null; var propertydata=mod_property[id]; return propertydata||{}; } })(jQuery);; function footerinit(){ footerdrag(); footerresize(); $.showSiteFooterTips(); $('.full_column').each(function(){ fullcolumninit($(this)); }) } function fullcolumninit(dom){ dom.children('.full_width').css({left:0-canv.offset().left-$.parseInteger($('#canvas').css("borderLeftWidth")),width:$('#scroll_container_bg').width()}); dom.wp_rightkey(); if(dom.is(':not(.isplate)')){ fullcolumndrag(dom); fullcolumnresize(dom); fullcolumndrop(dom); } } function footerdrag(){ var maxminusheight=0; var curcanvheight=canv.height(); var Command=Undo.Command.createModuleCommand(function(blockid,val){ var blockel=$('#'+blockid); blockel.css('top',val.top); canv.height(val.canvheight); $('#scroll_container_bg').css('height',(val.canvheight+blockel.height())+'px'); $.updateselectbgopt(); $.updatepospropblk(); $.canvasHeightChange(); },null,{returntype:'class'}); var undoobj=null; $('#site_footer').draggable({ cursor: 'move', axis: "y", start: function(event, ui){ initCanvasHeight(); var canvasminheight=canv.data('layermaxheight')||0; curcanvheight=canv.height(); maxminusheight=curcanvheight-canvasminheight; undoobj=new Command('site_footer'); undoobj.setOldVal({top:$.parseInteger($(this).css('top')),canvheight:curcanvheight}); }, drag: function(event, ui){ var topmovepx = ui.position.top - ui.originalPosition.top; if(topmovepx<0){ var delta=0-topmovepx; if(delta>maxminusheight){ var canvasminheight=canv.data('layermaxheight')||0; ui.position.top=ui.originalPosition.top-maxminusheight; canv.height(canvasminheight); $('#scroll_container_bg').css('height',(canvasminheight+$(this).height()+100)+'px'); $.showselectbgopt($(this)); $(this).triggerHandler('drag_progress',[{left:0,top:ui.position.top}]); return; } } $(this).triggerHandler('drag_progress',[{left:0,top:ui.position.top}]); canv.height(curcanvheight+topmovepx); $.showselectbgopt($(this)); $('#scroll_container_bg').css('height',(curcanvheight+topmovepx+$(this).height()+100)+'px'); }, stop:function(event, ui){ var topmovepx = ui.position.top - ui.originalPosition.top; canv.height(curcanvheight+topmovepx); $('#scroll_container_bg').css('height',(curcanvheight+topmovepx+$(this).height()+100)+'px'); $.canvasHeightChange(); correctFooterPos(); undoobj.insertWithNewVal({top:$.parseInteger($(this).css('top')),canvheight:curcanvheight+topmovepx}); undoobj=null; $(this).trigger('drag_stop',[{left:parseInt($(this).css('left')),top:parseInt($(this).css('top'))}]); } }); } function fullcolumndrag(dom){ dom.wp_drag(); } function fullcolumnresize(dom){ var createhandlefunc=function(handle){ dom.each(function(){ var hname = 'ui-resizable-'+handle; var axis = $('

    '); axis.css({zIndex: 1000}); $(this).children('.full_width').append(axis); }) } var createplaceholderfunc=function(handle){ dom.each(function(){ var hname = 'placeholder-'+handle; var axis = $('
    '); axis.css({zIndex: 1000}).hide(); $(this).children('.full_width').append(axis); }) } createhandlefunc('n'); createhandlefunc('s'); createplaceholderfunc('w'); createplaceholderfunc('e'); var fullcolumnbuttompos; dom.resizable({ handles: {n: '>.full_width .ui-resizable-n',s: '>.full_width .ui-resizable-s'}, noinit:true, canvascontain: '#canvas', distance: 0, concernLock:true, scroll: true, create:function(){ $(this).children('.full_width').find('.ui-resizable-handle').hide(); }, start: function(event, ui){ fullcolumnbuttompos=$.getFullColChildMaxButtom(dom); var self=$(this); var resizeundo=new ResizeCommand(self.attr('id')); var oldcssarr=['top','height']; var oldval={}; for(var i=0;i

    '); axis.css({zIndex: 1000}); $('#site_footer >.full_width').append(axis); } var createplaceholderfunc=function(handle){ var hname = 'placeholder-'+handle; var axis = $('
    '); axis.css({zIndex: 1000}); $('#site_footer> .full_width').append(axis); } createhandlefunc('n'); createhandlefunc('s'); createplaceholderfunc('w'); createplaceholderfunc('e'); var maxminusheight=0; var curcanvheight=canv.height(); var canvasminheight=0; var Command=Undo.Command.createModuleCommand(function(blockid,val){ var blockel=$('#'+blockid); blockel.css('top',val.top); blockel.css('height',val.height); canv.height(val.canvheight); blockel.children('.full_content,.full_width').height(val.height); $('#scroll_container_bg').css('height',(val.canvheight+blockel.height())+'px'); $.updateselectbgopt(); $.updatepospropblk(); $.canvasHeightChange(); },null,{returntype:'class'}); var undoobj=null; var resizertimer=null; $('#site_footer').resizable({ handles: {n: '>.full_width .ui-resizable-n',s: '>.full_width .ui-resizable-s'}, noinit:true, distance: 0, scroll: true, create:function(){ $(this).children('.full_width').find('.ui-resizable-handle').hide(); }, start: function(event, ui){ initCanvasHeight(); if(resizertimer){ clearTimeout(resizertimer); resizertimer=null; } canvasminheight=canv.data('layermaxheight')||0; curcanvheight=canv.height(); maxminusheight=curcanvheight-canvasminheight; undoobj=new Command('site_footer'); undoobj.setOldVal({top:$.parseInteger($(this).css('top')),canvheight:curcanvheight,height:$(this).height()}); $(this).triggerHandler('resize_progress',[{ui:ui}]); }, resize: function(event, ui){ var resizeobj=$(this).data('resizable'); var theaxis=resizeobj.axis; if(theaxis=='n'){ var changey= $(this).height()-ui.originalSize.height; if(changey>maxminusheight){ var mintop=canvasminheight; $(this).css({top:mintop,height:ui.originalSize.height+maxminusheight}); var oriscrolltop=$(this).data('resize_oriscrolltop'); $(this).scrollParent().scrollTop(oriscrolltop); $(this).children('.full_content,.full_width').height($(this).height()); canv.height(canvasminheight); $('#scroll_container_bg').css('height',(canvasminheight+$(this).height()+100)+'px'); $.showselectbgopt($(this)); return; } canv.height(curcanvheight-changey); $(this).children('.full_content,.full_width').height($(this).height()); $('#scroll_container_bg').css('height',(canv.height()+$(this).height()+100)+'px'); }else{ $(this).children('.full_content,.full_width').height($(this).height()); $('#scroll_container_bg').css('height',(canv.height()+$(this).height()+100)+'px'); } $.showselectbgopt($(this)); $(this).triggerHandler('resize_stop',[{ui:ui}]); }, stop:function(event, ui){ var self=$(this); undoobj.insertWithNewVal({top:$.parseInteger(self.css('top')),canvheight:canv.height(),height:self.height()}); undoobj=null; $.canvasHeightChange(); } }); } function fullcolumndrop(dom){ var createplaceholderfunc=function(handle){ dom.each(function(){ var hname = 'placeholder-'+handle; var axis = $('
    '); axis.css({zIndex: 1000}); $(this).children('.full_content').append(axis); }) } createplaceholderfunc('n'); createplaceholderfunc('s'); createplaceholderfunc('w'); createplaceholderfunc('e'); var contentblock=dom.children('.full_content'); contentblock.children('.li-placeholder').hide(); contentblock.children('.placeholder-n').css({'border-top':'#FF9900 dashed 4px'}); contentblock.children('.placeholder-s').css({'border-bottom':'#FF9900 dashed 4px'}); contentblock.children('.placeholder-e').css({'border-right':'#FF9900 dashed 4px'}); contentblock.children('.placeholder-w').css({'border-left':'#FF9900 dashed 4px'}); contentblock.droppable({ tolerance: 'pointer', accept:'.full_column,.cstlayer', drop: function( event, ui ) { var draggable = $.ui.ddmanager.current; if($.getElementAreaInf($(draggable.element))==$.getElementAreaInf(dom)){ if(!dom.hasClass('ui-modselected')){ $(this).children('.li-placeholder').hide(); var existcolumn=$(document).data('layer_final_drop_id'); var biggercolumn=$.chooseBiggerColumn(existcolumn,dom.attr('id')); $(document).data('layer_final_drop_id',biggercolumn); } } }, over: function(event, ui){ //判断是否包含锁定元素 var has_layer_lock=false; $('.ui-modselected').each(function(){ if($(this).data('cstlayerstatus') == 'unlock' ){ has_layer_lock=true; } }); if(has_layer_lock) return; var draggable = $.ui.ddmanager.current; if($.getElementAreaInf($(draggable.element))==$.getElementAreaInf(dom)){ if(!dom.hasClass('ui-modselected')){ var thisid=dom.attr('id'); var existid=$(document).data('layer_drop_over_id'); if(thisid != existid){ var biggerid=$.chooseBiggerColumn(existid,thisid); if(biggerid == thisid){ var $this=$(this); $(this).children('.li-placeholder').show(); if(existid){ var existcolumnel = $('#'+existid); var dropobj=existcolumnel.children('.full_content').data('droppable'); dropobj['isover'] = 0; dropobj['isout'] = 1; dropobj._out.call(dropobj, event); } $(document).data('layer_drop_over_id', thisid); }else{ var dropobj1=$(this).data('droppable'); dropobj1['isover'] = 0; dropobj1['isout'] = 1; } } } } }, out: function(event, ui){ //判断是否包含锁定元素 var has_layer_lock=false; $('.ui-modselected').each(function(){ if($(this).data('cstlayerstatus') == 'unlock' ){ has_layer_lock=true; } }); if(has_layer_lock) return; var draggable = $.ui.ddmanager.current; if($.getElementAreaInf($(draggable.element))==$.getElementAreaInf(dom)){ if(!dom.hasClass('ui-modselected') ){ $(this).children('.li-placeholder').hide(); var curoverid=$(document).data('layer_drop_over_id'); if(curoverid == dom.attr('id')) $(document).removeData('layer_drop_over_id'); } } } }); } function fullcolumn_propblk_init(){ var lvtimer; for(var key in $.backgroundPropDefaults){ (function(){ var curkey=key; var otherfunc=null; if($.inArray(curkey,['bg_moveto_prevop','bg_moveto_nextop']) != -1){ var innertxt ='', lvtype = ''; switch(curkey){ case 'bg_moveto_prevop': lvtype = 'top'; innertxt = ''; break; case 'bg_moveto_nextop': lvtype = 'bottom'; innertxt = ''; break; } otherfunc={ mousedown:function(){ var $target = $(this) var apos =$target.offset(); var scrollctner=$('#scroll_container'); var scrolltop=scrollctner.scrollTop(); $(innertxt).appendTo(scrollctner).css({ top: function(){ return (apos.top+scrolltop - 25-39)+'px' },left: apos.left+'px' }).click(function(e){ $('#'+$.bgselectedid).wp_setorder(lvtype,$.bgselectedid); $(this).remove(); $target.removeClass('local'); e.preventDefault(); }); }, mouseup:function(){ } } } $('#'+curkey).mousedown(function(e){ var $target = $(this); $target.addClass('local'); if($('.wp-moveto_fstlevel,.wp-moveto_lstlevel').size()) $('.wp-moveto_fstlevel,.wp-moveto_lstlevel').remove(); if(otherfunc != null){ otherfunc.mousedown.apply(this); } e.preventDefault(); }).mouseup(function(e){ var self = this,$target = $(self); $target.removeClass('local'); $.backgroundPropDefaults[curkey].apply(this); if(otherfunc != null){ otherfunc.mouseup.apply(this); } e.preventDefault(); }) })(); } } (function($){ function getAllParents(el){ var parents={}; parents[el.prop('id')]='null'; var curel=el; while(true){ var parentid=$.getElementFatherid(curel); if(parentid =='none') break; parents[parentid]=curel.prop('id'); curel=$('#'+parentid); } return parents; } $.chooseBiggerColumn=function(existcolumnid,newcolumnid){ var biggercolumnid=newcolumnid; if(existcolumnid==newcolumnid) return biggercolumnid; if(existcolumnid){ var existcolumnel=$('#'+existcolumnid); var newcolumnel=$('#'+newcolumnid); var existcolumnfathers=getAllParents(existcolumnel); var newcolumnfathers=getAllParents(newcolumnel); var rootid='canvas'; if(!existcolumnfathers[rootid]) rootid='site_footer'; var existdifffather=rootid; var newdifffather=rootid; while(existdifffather == newdifffather){ existdifffather =existcolumnfathers[existdifffather]; newdifffather =newcolumnfathers[newdifffather]; if(existdifffather=='null' || newdifffather=='null') break; } if(existdifffather=='null') biggercolumnid=newcolumnid; else if(newdifffather=='null') biggercolumnid=existcolumnid; else{ var existfatherzindex=$.parseInteger($('#'+existdifffather).css('z-index')); var newfatherzindex=$.parseInteger($('#'+newdifffather).css('z-index')); if(existfatherzindex > newfatherzindex) biggercolumnid=existcolumnid; } } return biggercolumnid; } $.transferToColumn=function(dom,fathercolid){ var oldfatherid=$.getElementFatherid(dom); if(oldfatherid!=fathercolid){ var newfatherel=$('#'+fathercolid); var domabpos=dom.ab_pos('top'); var newfatherabpos=newfatherel.ab_pos('top'); var contentblock=newfatherel; if(fathercolid!='canvas') contentblock=newfatherel.children('.full_content'); dom.detach().attr('fatherid',fathercolid).css('top',(domabpos-newfatherabpos)).appendTo(contentblock); if(fathercolid=='site_footer'||fathercolid=='canvas') dom.removeAttr('fatherid'); } } $.getElementAreaInf=function(dom){ return dom.attr('inbuttom')=='1'?'site_footer':'canvas'; } $.transferToArea=function(dom,from,to,isInUndo){ var domabpos=dom.ab_pos('top'); var footertop=$.parseInteger($('#site_footer').css('top')); if(to=='site_footer'){ var curmodtop=domabpos-footertop; dom.css('top',curmodtop); dom.attr('inbuttom','1'); dom.detach().removeAttr('fatherid').appendTo($('#site_footer').children('.full_content')); if(dom.hasClass('full_column')) dom.find('.cstlayer,.full_column').attr('inbuttom','1'); }else{ var curmodtop=domabpos+footertop; dom.css('top',curmodtop); var canvheight=$('#canvas').height(); if(canvheight 0){ wp_alert(translate('fullpage.already can not add fullcolumn')); return false; } var successfunc=function(resp,needchangeid){ var fullcolumnhtml=resp; if(needchangeid){ var fullcolumnels=$(fullcolumnhtml).filter('.full_column'); var nowid=fullcolumnels.prop('id'); var newid='layer'+fGuid(); fullcolumnhtml=fullcolumnhtml.replace(new RegExp(nowid,"g"),newid); } var fullcolumnel=$(fullcolumnhtml).appendTo('#canvas').css('top',top); fullcolumnel=fullcolumnel.filter('.full_column'); fullcolumninit(fullcolumnel); fullcolumnel.css('z-index',100); $('.ui-modselected').each(function(){ $.hidWidgetBorder($(this)); // 图文模块相关 2012/2/14 if($(this).hasClass('graphic_edited')) actived_graphic(); }); $.selectbgdiv(fullcolumnel); new AddCommand(fullcolumnel.prop('id')).insert(); var objarray=new Array(); objarray[0]=new Array(parseInt($('#'+fullcolumnel.prop('id')).css('z-index')),fullcolumnel.prop('id')); $.zindexsort_new(objarray); } if($.addFullColumn.html_cache){ successfunc($.addFullColumn.html_cache,true); return; } $.ajax({ type: "GET", url: parseToURL("wp_widgets","gtfullcolumn"), success: function(response){ $.addFullColumn.html_cache=response; successfunc(response,false); }, error: function(xhr, textStatus, errorThrown){ wp_alert((errorThrown||textStatus)+"(add a fullcolumn).
    "+translate("Request failed!")); return false; } }); } $.curSelectableFather=function(){ var selmods=$('.ui-modselected'); if(selmods.length==0){ $(document).data('cur_selectable_father',null); return null; }else{ var fatherid=$.getElementFatherid(selmods.filter(':first')); $(document).data('cur_selectable_father',fatherid); return fatherid; } } $.getElementFatherid=function(dom){ if(dom.prop('id')=='canvas'||dom.prop('id')=='site_footer') return 'none'; var fatherid=dom.attr('fatherid'); if(!fatherid||fatherid==''){ if(dom.closest('#canvas').length>0){ fatherid='canvas'; }else if(dom.closest('#site_footer').length>0){ fatherid='site_footer'; } } return fatherid; } $.fn.ab_pos=function(direct){ var dom=$(this); if(dom.prop('id')=='canvas'||dom.prop('id')=='site_footer') return 0; if(direct=='left'||direct=='top'){ if(!dom.attr('fatherid')||dom.attr('fatherid')=='') return dom.rel_pos(direct); return dom.rel_pos(direct)+$('#'+dom.attr('fatherid')).ab_pos(direct); } } $.fn.ab_pos_cnter=function(direct){ var abpos=$(this).ab_pos(direct); if($(this).closest('#site_footer').length>0&&direct=='top'){ return abpos+$.parseInteger($('#site_footer').css(direct)); } return abpos; } $.fn.rel_pos=function(direct){ if(direct=='left'||direct=='top'){ return $.parseInteger($(this).css(direct)); } } $.getFullColChildMaxButtom=function(dom){ var parenttoppos=dom.ab_pos_cnter('top'); var maxbuttompos=parenttoppos; dom.find('.cstlayer,.full_column').each(function(){ var el=$(this); var buttompos=0; if(el.hasClass('cstlayer')) buttompos=$.divrotate.getDegreeModMaxPoint(el,null,'buttom'); else buttompos=el.ab_pos_cnter('top')+$.parseInteger(el.css('height')); if(maxbuttompos settings.failure_limit) { return false; } } } }); } if(options) { /* Maintain BC for a couple of versions. */ if (undefined !== options.failurelimit) { options.failure_limit = options.failurelimit; delete options.failurelimit; } if (undefined !== options.effectspeed) { options.effect_speed = options.effectspeed; delete options.effectspeed; } $.extend(settings, options); } /* Cache container as jQuery as object. */ $container = (settings.container === undefined || settings.container === window) ? $window : $(settings.container); /* Fire one scroll event per scroll. Not one scroll event per image. */ if (0 === settings.event.indexOf("scroll")) { $container.bind(settings.event, function() { return update(); }); } this.each(function() { var self = this; var $self = $(self); self.loaded = false; /* If no src attribute given use data:uri. */ if ($self.attr("src") === undefined || $self.attr("src") === false) { if ($self.is("img")) { $self.attr("src", settings.placeholder); } } /* fixed bug#1630 */ //if(parseInt($self.css("top"))<-100) $self.css("top",""); /* When appear is triggered load original image. */ $self.one("appear", function() { if (!this.loaded) { if (settings.appear) { var elements_left = elements.length; settings.appear.call(self, elements_left, settings); } $("") .bind("load", function() { var original = $self.attr("data-" + settings.data_attribute); $self.hide(); if ($self.is("img")) { $self.attr("src", original); } else { $self.css("background-image", "url('" + original + "')"); } $self[settings.effect](settings.effect_speed); self.loaded = true; /* Remove image from array so it is not looped next time. */ var temp = $.grep(elements, function(element) { return !element.loaded; }); elements = $(temp); if (settings.load) { var elements_left = elements.length; settings.load.call(self, elements_left, settings); } }) .attr("src", $self.attr("data-" + settings.data_attribute)); } }); /* When wanted event is triggered load original image */ /* by triggering appear. */ if (0 !== settings.event.indexOf("scroll")) { $self.bind(settings.event, function() { if (!self.loaded) { $self.trigger("appear"); } }); } }); /* Check if something appears when window is resized. */ $window.bind("resize", function() { update(); }); /* With IOS5 force loading images when navigating with back button. */ /* Non optimal workaround. */ if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) { $window.bind("pageshow", function(event) { if (event.originalEvent && event.originalEvent.persisted) { elements.each(function() { $(this).trigger("appear"); }); } }); } /* Force initial check if images should appear. */ $(document).ready(function() { update(); }); return this; }; /* Convenience methods in jQuery namespace. */ /* Use as $.belowthefold(element, {threshold : 100, container : window}) */ $.belowthefold = function(element, settings) { var fold; if (settings.container === undefined || settings.container === window) { fold = (window.innerHeight ? window.innerHeight : $window.height()) + $window.scrollTop(); } else { fold = $(settings.container).offset().top + $(settings.container).height(); } return fold <= $(element).offset().top - settings.threshold; }; $.rightoffold = function(element, settings) { var fold; if (settings.container === undefined || settings.container === window) { fold = $window.width() + $window.scrollLeft(); } else { fold = $(settings.container).offset().left + $(settings.container).width(); } return fold <= $(element).offset().left - settings.threshold; }; $.abovethetop = function(element, settings) { var fold; if (settings.container === undefined || settings.container === window) { fold = $window.scrollTop(); } else { fold = $(settings.container).offset().top; } //bug#2660 var eleparwid = $(element).height(); if(eleparwid==0&&$(element).parents().parents().attr('class')=='img_over'){ var eleparwid = $(element).parents().parents().height(); } return fold >= $(element).offset().top + settings.threshold + eleparwid; }; $.leftofbegin = function(element, settings) { var fold; if (settings.container === undefined || settings.container === window) { fold = $window.scrollLeft(); } else { fold = $(settings.container).offset().left; } return fold >= Math.max($(element).offset().left + $(element).width(),2)+ settings.threshold ; }; $.inviewport = function(element, settings) { return !$.rightoffold(element, settings) && !$.leftofbegin(element, settings) && !$.belowthefold(element, settings) && !$.abovethetop(element, settings); }; /* Custom selectors for your convenience. */ /* Use as $("img:below-the-fold").something() or */ /* $("img").filter(":below-the-fold").something() which is faster */ $.extend($.expr[":"], { "below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); }, "above-the-top" : function(a) { return !$.belowthefold(a, {threshold : 0}); }, "right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); }, "left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); }, "in-viewport" : function(a) { return $.inviewport(a, {threshold : 0}); }, /* Maintain BC for couple of versions. */ "above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); }, "right-of-fold" : function(a) { return $.rightoffold(a, {threshold : 0}); }, "left-of-fold" : function(a) { return !$.rightoffold(a, {threshold : 0}); } }); })(jQuery, window, document);; eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('F S(s){4 g=s.g;4 e=s.e;4 d=s.d;4 w=s.D;4 h=s.C;4 a=s.a;4 n=g+\'n\';4 k="M("+n+")";6($.j.Q){6($.j.T>=9){a.5(\'-z-c\',k);a.5("-z-c-p","b b")}f{4 H=v.Z*g/I; 4 7=v.13(H);4 8=v.10(H);4 m=g%J;a.x(\'8\',8);a.x(\'7\',7);6(m>=0&&m<=K){4 t=e-((h*8+w*7)/2-w/2);4 r=d-((w*8+h*7)/2-h/2)}6(m>K&&m<=I){6(h*8+w*7*-1>w)4 t=e-((h*8+w*7*-1)/2-w/2);f 4 t=e+(w/2-(h*8+w*7*-1)/2);6((h*7*-1+w*8)>h)4 r=d-((h*7*-1+w*8)/2-h/2);f 4 r=d+(h/2-(h*7*-1+w*8)/2)}6(m>I&&m<=N){4 t=e-((-1*h*8+-1*w*7)/2-w/2);4 r=d-((-1*w*8+-1*h*7)/2-h/2)}6(m>N&&mh)4 r=d-(-1*w*8+h*7-h)/2;f 4 r=d+(h-(-1*w*8+h*7))/2}a.5({V:"W:X.Y.14(1b="+7+",1d="+(-8)+",1e="+8+",1f="+7+",16=\'15 17\')"});a.5({\'e\':t+\'L\',\'d\':r+\'L\'})}}f 6($.j.P){a.5(\'-B-c\',k);a.5("-B-c-p","b b")}f 6($.j.U){a.5(\'-A-c\',k);a.5("-A-c-p","b b")}f 6($.j.R){a.5(\'-o-c\',k);a.5("-o-c-p","b b")}}F 1a(a){a.19(F(){4 g=11($(3).i(\'n\'))||0;$(3).x(\'n\',g);6(g!=0){4 n=g+\'n\';4 k="M("+n+")";6($.j.U){$(3).5(\'-A-c\',k);$(3).5("-A-c-p","b b")}f 6($.j.P){$(3).5(\'-B-c\',k);$(3).5("-B-c-p","b b")}f 6($.j.R){$(3).5(\'-o-c\',k);$(3).5("-o-c-p","b b")}f 6($.j.Q){6($.j.T>=9){$(3).5(\'-z-c\',k);$(3).5("-z-c-p","b b")}f{$(3).x(\'1c\',$(3).D()).x(\'12\',$(3).C());4 y=[$(3).q().e,$(3).q().d],u=[];S({g:g,e:$(3).q().e,d:$(3).q().d,D:$(3).D(),C:$(3).C(),a:$(3)});u=18($("#"+$(3).i(\'l\')),g);4 G=v.O(y[0]-u[0]),E=v.O(y[1]-u[1]);6(y[0]>u[0])$("#"+$(3).i(\'l\')).5(\'e\',$("#"+$(3).i(\'l\')).q().e+G);f $("#"+$(3).i(\'l\')).5(\'e\',$("#"+$(3).i(\'l\')).q().e-G);6(y[1]>u[1])$("#"+$(3).i(\'l\')).5(\'d\',$("#"+$(3).i(\'l\')).q().d+E);f $("#"+$(3).i(\'l\')).5(\'d\',$("#"+$(3).i(\'l\')).q().d-E)}}}})}',62,78,'|||this|var|css|if|cosx|sinx||dom|0px|transform|top|left|else|degree||attr|browser|degp|id|angle|deg||origin|position|topNew|json|leftNew|arr1|Math||data|arr|ms|moz|webkit|height|width|relativeTop|function|relativeLeft|rotation|180|360|90|px|rotate|270|abs|safari|msie|opera|ieRotate|version|mozilla|filter|progid|DXImageTransform|Microsoft|PI|sin|parseInt|IEHeight|cos|Matrix|auto|SizingMethod|expand|getLeftPointProxy|each|rotateDom|M11|IEWidth|M12|M21|M22'.split('|'),0,{}));; /*! VelocityJS.org (1.1.0). (C) 2014 Julian Shapiro. MIT @license: en.wikipedia.org/wiki/MIT_License */ /************************* Velocity jQuery Shim *************************/ /*! VelocityJS.org jQuery Shim (1.0.1). (C) 2014 The jQuery Foundation. MIT @license: en.wikipedia.org/wiki/MIT_License. */ /* This file contains the jQuery functions that Velocity relies on, thereby removing Velocity's dependency on a full copy of jQuery, and allowing it to work in any environment. */ /* These shimmed functions are only used if jQuery isn't present. If both this shim and jQuery are loaded, Velocity defaults to jQuery proper. */ /* Browser support: Using this shim instead of jQuery proper removes support for IE8. */ ;(function (window) { /*************** Setup ***************/ /* If jQuery is already loaded, there's no point in loading this shim. */ if (window.jQuery) { return; } /* jQuery base. */ var $ = function (selector, context) { return new $.fn.init(selector, context); }; /******************** Private Methods ********************/ /* jQuery */ $.isWindow = function (obj) { /* jshint eqeqeq: false */ return obj != null && obj == obj.window; }; /* jQuery */ $.type = function (obj) { if (obj == null) { return obj + ""; } return typeof obj === "object" || typeof obj === "function" ? class2type[toString.call(obj)] || "object" : typeof obj; }; /* jQuery */ $.isArray = Array.isArray || function (obj) { return $.type(obj) === "array"; }; /* jQuery */ function isArraylike (obj) { var length = obj.length, type = $.type(obj); if (type === "function" || $.isWindow(obj)) { return false; } if (obj.nodeType === 1 && length) { return true; } return type === "array" || length === 0 || typeof length === "number" && length > 0 && (length - 1) in obj; } /*************** $ Methods ***************/ /* jQuery: Support removed for IE<9. */ $.isPlainObject = function (obj) { var key; if (!obj || $.type(obj) !== "object" || obj.nodeType || $.isWindow(obj)) { return false; } try { if (obj.constructor && !hasOwn.call(obj, "constructor") && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) { return false; } } catch (e) { return false; } for (key in obj) {} return key === undefined || hasOwn.call(obj, key); }; /* jQuery */ $.each = function(obj, callback, args) { var value, i = 0, length = obj.length, isArray = isArraylike(obj); if (args) { if (isArray) { for (; i < length; i++) { value = callback.apply(obj[i], args); if (value === false) { break; } } } else { for (i in obj) { value = callback.apply(obj[i], args); if (value === false) { break; } } } } else { if (isArray) { for (; i < length; i++) { value = callback.call(obj[i], i, obj[i]); if (value === false) { break; } } } else { for (i in obj) { value = callback.call(obj[i], i, obj[i]); if (value === false) { break; } } } } return obj; }; /* Custom */ $.data = function (node, key, value) { /* $.getData() */ if (value === undefined) { var id = node[$.expando], store = id && cache[id]; if (key === undefined) { return store; } else if (store) { if (key in store) { return store[key]; } } /* $.setData() */ } else if (key !== undefined) { var id = node[$.expando] || (node[$.expando] = ++$.uuid); cache[id] = cache[id] || {}; cache[id][key] = value; return value; } }; /* Custom */ $.removeData = function (node, keys) { var id = node[$.expando], store = id && cache[id]; if (store) { $.each(keys, function(_, key) { delete store[key]; }); } }; /* jQuery */ $.extend = function () { var src, copyIsArray, copy, name, options, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; if (typeof target === "boolean") { deep = target; target = arguments[i] || {}; i++; } if (typeof target !== "object" && $.type(target) !== "function") { target = {}; } if (i === length) { target = this; i--; } for (; i < length; i++) { if ((options = arguments[i]) != null) { for (name in options) { src = target[name]; copy = options[name]; if (target === copy) { continue; } if (deep && copy && ($.isPlainObject(copy) || (copyIsArray = $.isArray(copy)))) { if (copyIsArray) { copyIsArray = false; clone = src && $.isArray(src) ? src : []; } else { clone = src && $.isPlainObject(src) ? src : {}; } target[name] = $.extend(deep, clone, copy); } else if (copy !== undefined) { target[name] = copy; } } } } return target; }; /* jQuery 1.4.3 */ $.queue = function (elem, type, data) { function $makeArray (arr, results) { var ret = results || []; if (arr != null) { if (isArraylike(Object(arr))) { /* $.merge */ (function(first, second) { var len = +second.length, j = 0, i = first.length; while (j < len) { first[i++] = second[j++]; } if (len !== len) { while (second[j] !== undefined) { first[i++] = second[j++]; } } first.length = i; return first; })(ret, typeof arr === "string" ? [arr] : arr); } else { [].push.call(ret, arr); } } return ret; } if (!elem) { return; } type = (type || "fx") + "queue"; var q = $.data(elem, type); if (!data) { return q || []; } if (!q || $.isArray(data)) { q = $.data(elem, type, $makeArray(data)); } else { q.push(data); } return q; }; /* jQuery 1.4.3 */ $.dequeue = function (elems, type) { /* Custom: Embed element iteration. */ $.each(elems.nodeType ? [ elems ] : elems, function(i, elem) { type = type || "fx"; var queue = $.queue(elem, type), fn = queue.shift(); if (fn === "inprogress") { fn = queue.shift(); } if (fn) { if (type === "fx") { queue.unshift("inprogress"); } fn.call(elem, function() { $.dequeue(elem, type); }); } }); }; /****************** $.fn Methods ******************/ /* jQuery */ $.fn = $.prototype = { init: function (selector) { /* Just return the element wrapped inside an array; don't proceed with the actual jQuery node wrapping process. */ if (selector.nodeType) { this[0] = selector; return this; } else { throw new Error("Not a DOM node."); } }, offset: function () { /* jQuery altered code: Dropped disconnected DOM node checking. */ var box = this[0].getBoundingClientRect ? this[0].getBoundingClientRect() : { top: 0, left: 0 }; return { top: box.top + (window.pageYOffset || document.scrollTop || 0) - (document.clientTop || 0), left: box.left + (window.pageXOffset || document.scrollLeft || 0) - (document.clientLeft || 0) }; }, position: function () { /* jQuery */ function offsetParent() { var offsetParent = this.offsetParent || document; while (offsetParent && (!offsetParent.nodeType.toLowerCase === "html" && offsetParent.style.position === "static")) { offsetParent = offsetParent.offsetParent; } return offsetParent || document; } /* Zepto */ var elem = this[0], offsetParent = offsetParent.apply(elem), offset = this.offset(), parentOffset = /^(?:body|html)$/i.test(offsetParent.nodeName) ? { top: 0, left: 0 } : $(offsetParent).offset() offset.top -= parseFloat(elem.style.marginTop) || 0; offset.left -= parseFloat(elem.style.marginLeft) || 0; if (offsetParent.style) { parentOffset.top += parseFloat(offsetParent.style.borderTopWidth) || 0 parentOffset.left += parseFloat(offsetParent.style.borderLeftWidth) || 0 } return { top: offset.top - parentOffset.top, left: offset.left - parentOffset.left }; } }; /********************** Private Variables **********************/ /* For $.data() */ var cache = {}; $.expando = "velocity" + (new Date().getTime()); $.uuid = 0; /* For $.queue() */ var class2type = {}, hasOwn = class2type.hasOwnProperty, toString = class2type.toString; var types = "Boolean Number String Function Array Date RegExp Object Error".split(" "); for (var i = 0; i < types.length; i++) { class2type["[object " + types[i] + "]"] = types[i].toLowerCase(); } /* Makes $(node) possible, without having to call init. */ $.fn.init.prototype = $.fn; /* Globalize Velocity onto the window, and assign its Utilities property. */ window.Velocity = { Utilities: $ }; })(window); /****************** Velocity.js ******************/ ;(function (factory) { /* CommonJS module. */ if (typeof module === "object" && typeof module.exports === "object") { module.exports = factory(); /* AMD module. */ } else if (typeof define === "function" && define.amd) { define(factory); /* Browser globals. */ } else { factory(); } }(function() { return function (global, window, document, undefined) { /*************** Summary ***************/ /* - CSS: CSS stack that works independently from the rest of Velocity. - animate(): Core animation method that iterates over the targeted elements and queues the incoming call onto each element individually. - Pre-Queueing: Prepare the element for animation by instantiating its data cache and processing the call's options. - Queueing: The logic that runs once the call has reached its point of execution in the element's $.queue() stack. Most logic is placed here to avoid risking it becoming stale (if the element's properties have changed). - Pushing: Consolidation of the tween data followed by its push onto the global in-progress calls container. - tick(): The single requestAnimationFrame loop responsible for tweening all in-progress calls. - completeCall(): Handles the cleanup process for each Velocity call. */ /********************* Helper Functions *********************/ /* IE detection. Gist: https://gist.github.com/julianshapiro/9098609 */ var IE = (function() { if (document.documentMode) { return document.documentMode; } else { for (var i = 7; i > 4; i--) { var div = document.createElement("div"); div.innerHTML = ""; if (div.getElementsByTagName("span").length) { div = null; return i; } } } return undefined; })(); /* rAF shim. Gist: https://gist.github.com/julianshapiro/9497513 */ var rAFShim = (function() { var timeLast = 0; return window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { var timeCurrent = (new Date()).getTime(), timeDelta; /* Dynamically set delay on a per-tick basis to match 60fps. */ /* Technique by Erik Moller. MIT license: https://gist.github.com/paulirish/1579671 */ timeDelta = Math.max(0, 16 - (timeCurrent - timeLast)); timeLast = timeCurrent + timeDelta; return setTimeout(function() { callback(timeCurrent + timeDelta); }, timeDelta); }; })(); /* Array compacting. Copyright Lo-Dash. MIT License: https://github.com/lodash/lodash/blob/master/LICENSE.txt */ function compactSparseArray (array) { var index = -1, length = array ? array.length : 0, result = []; while (++index < length) { var value = array[index]; if (value) { result.push(value); } } return result; } function sanitizeElements (elements) { /* Unwrap jQuery/Zepto objects. */ if (Type.isWrapped(elements)) { elements = [].slice.call(elements); /* Wrap a single element in an array so that $.each() can iterate with the element instead of its node's children. */ } else if (Type.isNode(elements)) { elements = [ elements ]; } return elements; } var Type = { isString: function (variable) { return (typeof variable === "string"); }, isArray: Array.isArray || function (variable) { return Object.prototype.toString.call(variable) === "[object Array]"; }, isFunction: function (variable) { return Object.prototype.toString.call(variable) === "[object Function]"; }, isNode: function (variable) { return variable && variable.nodeType; }, /* Copyright Martin Bohm. MIT License: https://gist.github.com/Tomalak/818a78a226a0738eaade */ isNodeList: function (variable) { return typeof variable === "object" && /^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(variable)) && variable.length !== undefined && (variable.length === 0 || (typeof variable[0] === "object" && variable[0].nodeType > 0)); }, /* Determine if variable is a wrapped jQuery or Zepto element. */ isWrapped: function (variable) { return variable && (variable.jquery || (window.Zepto && window.Zepto.zepto.isZ(variable))); }, isSVG: function (variable) { return window.SVGElement && (variable instanceof window.SVGElement); }, isEmptyObject: function (variable) { for (var name in variable) { return false; } return true; } }; /***************** Dependencies *****************/ var $, isJQuery = false; if (global.fn && global.fn.jquery) { $ = global; isJQuery = true; } else { $ = window.Velocity.Utilities; } if (IE <= 8 && !isJQuery) { throw new Error("Velocity: IE8 and below require jQuery to be loaded before Velocity."); } else if (IE <= 7) { /* Revert to jQuery's $.animate(), and lose Velocity's extra features. */ jQuery.fn.velocity = jQuery.fn.animate; /* Now that $.fn.velocity is aliased, abort this Velocity declaration. */ return; } /***************** Constants *****************/ var DURATION_DEFAULT = 400, EASING_DEFAULT = "swing"; /************* State *************/ /* Note: The global object also doubles as a publicly-accessible data store for the purposes of unit testing. */ /* Note: Alias the lowercase and uppercase variants of "velocity" to minimize user confusion due to the lowercase nature of the $.fn extension. */ var Velocity = { /* Container for page-wide Velocity state data. */ State: { /* Detect mobile devices to determine if mobileHA should be turned on. */ isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), /* The mobileHA option's behavior changes on older Android devices (Gingerbread, versions 2.3.3-2.3.7). */ isAndroid: /Android/i.test(navigator.userAgent), isGingerbread: /Android 2\.3\.[3-7]/i.test(navigator.userAgent), isChrome: window.chrome, isFirefox: /Firefox/i.test(navigator.userAgent), /* Create a cached element for re-use when checking for CSS property prefixes. */ prefixElement: document.createElement("div"), /* Cache every prefix match to avoid repeating lookups. */ prefixMatches: {}, /* Cache the anchor used for animating window scrolling. */ scrollAnchor: null, /* Cache the property names associated with the scroll anchor. */ scrollPropertyLeft: null, scrollPropertyTop: null, /* Keep track of whether our RAF tick is running. */ isTicking: false, /* Container for every in-progress call to Velocity. */ calls: [] }, /* Velocity's custom CSS stack. Made global for unit testing. */ CSS: { /* Defined below. */ }, /* Defined by Velocity's optional jQuery shim. */ Utilities: $, /* Container for the user's custom animation redirects that are referenced by name in place of a properties map object. */ Redirects: { /* Manually registered by the user. */ }, Easings: { /* Defined below. */ }, /* Attempt to use ES6 Promises by default. Users can override this with a third-party promises library. */ Promise: window.Promise, /* Page-wide option defaults, which can be overriden by the user. */ defaults: { queue: "", duration: DURATION_DEFAULT, easing: EASING_DEFAULT, begin: undefined, complete: undefined, progress: undefined, display: undefined, visibility: undefined, loop: false, delay: false, mobileHA: true, /* Set to false to prevent property values from being cached between consecutive Velocity-initiated chain calls. */ _cacheValues: true }, /* A design goal of Velocity is to cache data wherever possible in order to avoid DOM requerying. Accordingly, each element has a data cache instantiated on it. */ init: function (element) { $.data(element, "velocity", { /* Store whether this is an SVG element, since its properties are retrieved and updated differently than standard HTML elements. */ isSVG: Type.isSVG(element), /* Keep track of whether the element is currently being animated by Velocity. This is used to ensure that property values are not transferred between non-consecutive (stale) calls. */ isAnimating: false, /* A reference to the element's live computedStyle object. Learn more here: https://developer.mozilla.org/en/docs/Web/API/window.getComputedStyle */ computedStyle: null, /* Tween data is cached for each animation on the element so that data can be passed across calls -- in particular, end values are used as subsequent start values in consecutive Velocity calls. */ tweensContainer: null, /* The full root property values of each CSS hook being animated on this element are cached so that: 1) Concurrently-animating hooks sharing the same root can have their root values' merged into one while tweening. 2) Post-hook-injection root values can be transferred over to consecutively chained Velocity calls as starting root values. */ rootPropertyValueCache: {}, /* A cache for transform updates, which must be manually flushed via CSS.flushTransformCache(). */ transformCache: {} }); }, /* A parallel to jQuery's $.css(), used for getting/setting Velocity's hooked CSS properties. */ hook: null, /* Defined below. */ /* Velocity-wide animation time remapping for testing purposes. */ mock: false, version: { major: 1, minor: 1, patch: 0 }, /* Set to 1 or 2 (most verbose) to output debug info to console. */ debug: false }; /* Retrieve the appropriate scroll anchor and property name for the browser: https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY */ if (window.pageYOffset !== undefined) { Velocity.State.scrollAnchor = window; Velocity.State.scrollPropertyLeft = "pageXOffset"; Velocity.State.scrollPropertyTop = "pageYOffset"; } else { Velocity.State.scrollAnchor = document.documentElement || document.body.parentNode || document.body; Velocity.State.scrollPropertyLeft = "scrollLeft"; Velocity.State.scrollPropertyTop = "scrollTop"; } /* Shorthand alias for jQuery's $.data() utility. */ function Data (element) { /* Hardcode a reference to the plugin name. */ var response = $.data(element, "velocity"); /* jQuery <=1.4.2 returns null instead of undefined when no match is found. We normalize this behavior. */ return response === null ? undefined : response; }; /************** Easing **************/ /* Step easing generator. */ function generateStep (steps) { return function (p) { return Math.round(p * steps) * (1 / steps); }; } /* Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */ function generateBezier (mX1, mY1, mX2, mY2) { var NEWTON_ITERATIONS = 4, NEWTON_MIN_SLOPE = 0.001, SUBDIVISION_PRECISION = 0.0000001, SUBDIVISION_MAX_ITERATIONS = 10, kSplineTableSize = 11, kSampleStepSize = 1.0 / (kSplineTableSize - 1.0), float32ArraySupported = "Float32Array" in window; /* Must contain four arguments. */ if (arguments.length !== 4) { return false; } /* Arguments must be numbers. */ for (var i = 0; i < 4; ++i) { if (typeof arguments[i] !== "number" || isNaN(arguments[i]) || !isFinite(arguments[i])) { return false; } } /* X values must be in the [0, 1] range. */ mX1 = Math.min(mX1, 1); mX2 = Math.min(mX2, 1); mX1 = Math.max(mX1, 0); mX2 = Math.max(mX2, 0); var mSampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize); function A (aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; } function B (aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1; } function C (aA1) { return 3.0 * aA1; } function calcBezier (aT, aA1, aA2) { return ((A(aA1, aA2)*aT + B(aA1, aA2))*aT + C(aA1))*aT; } function getSlope (aT, aA1, aA2) { return 3.0 * A(aA1, aA2)*aT*aT + 2.0 * B(aA1, aA2) * aT + C(aA1); } function newtonRaphsonIterate (aX, aGuessT) { for (var i = 0; i < NEWTON_ITERATIONS; ++i) { var currentSlope = getSlope(aGuessT, mX1, mX2); if (currentSlope === 0.0) return aGuessT; var currentX = calcBezier(aGuessT, mX1, mX2) - aX; aGuessT -= currentX / currentSlope; } return aGuessT; } function calcSampleValues () { for (var i = 0; i < kSplineTableSize; ++i) { mSampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2); } } function binarySubdivide (aX, aA, aB) { var currentX, currentT, i = 0; do { currentT = aA + (aB - aA) / 2.0; currentX = calcBezier(currentT, mX1, mX2) - aX; if (currentX > 0.0) { aB = currentT; } else { aA = currentT; } } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS); return currentT; } function getTForX (aX) { var intervalStart = 0.0, currentSample = 1, lastSample = kSplineTableSize - 1; for (; currentSample != lastSample && mSampleValues[currentSample] <= aX; ++currentSample) { intervalStart += kSampleStepSize; } --currentSample; var dist = (aX - mSampleValues[currentSample]) / (mSampleValues[currentSample+1] - mSampleValues[currentSample]), guessForT = intervalStart + dist * kSampleStepSize, initialSlope = getSlope(guessForT, mX1, mX2); if (initialSlope >= NEWTON_MIN_SLOPE) { return newtonRaphsonIterate(aX, guessForT); } else if (initialSlope == 0.0) { return guessForT; } else { return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize); } } var _precomputed = false; function precompute() { _precomputed = true; if (mX1 != mY1 || mX2 != mY2) calcSampleValues(); } var f = function (aX) { if (!_precomputed) precompute(); if (mX1 === mY1 && mX2 === mY2) return aX; if (aX === 0) return 0; if (aX === 1) return 1; return calcBezier(getTForX(aX), mY1, mY2); }; f.getControlPoints = function() { return [{ x: mX1, y: mY1 }, { x: mX2, y: mY2 }]; }; var str = "generateBezier(" + [mX1, mY1, mX2, mY2] + ")"; f.toString = function () { return str; }; return f; } /* Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */ /* Given a tension, friction, and duration, a simulation at 60FPS will first run without a defined duration in order to calculate the full path. A second pass then adjusts the time delta -- using the relation between actual time and duration -- to calculate the path for the duration-constrained animation. */ var generateSpringRK4 = (function () { function springAccelerationForState (state) { return (-state.tension * state.x) - (state.friction * state.v); } function springEvaluateStateWithDerivative (initialState, dt, derivative) { var state = { x: initialState.x + derivative.dx * dt, v: initialState.v + derivative.dv * dt, tension: initialState.tension, friction: initialState.friction }; return { dx: state.v, dv: springAccelerationForState(state) }; } function springIntegrateState (state, dt) { var a = { dx: state.v, dv: springAccelerationForState(state) }, b = springEvaluateStateWithDerivative(state, dt * 0.5, a), c = springEvaluateStateWithDerivative(state, dt * 0.5, b), d = springEvaluateStateWithDerivative(state, dt, c), dxdt = 1.0 / 6.0 * (a.dx + 2.0 * (b.dx + c.dx) + d.dx), dvdt = 1.0 / 6.0 * (a.dv + 2.0 * (b.dv + c.dv) + d.dv); state.x = state.x + dxdt * dt; state.v = state.v + dvdt * dt; return state; } return function springRK4Factory (tension, friction, duration) { var initState = { x: -1, v: 0, tension: null, friction: null }, path = [0], time_lapsed = 0, tolerance = 1 / 10000, DT = 16 / 1000, have_duration, dt, last_state; tension = parseFloat(tension) || 500; friction = parseFloat(friction) || 20; duration = duration || null; initState.tension = tension; initState.friction = friction; have_duration = duration !== null; /* Calculate the actual time it takes for this animation to complete with the provided conditions. */ if (have_duration) { /* Run the simulation without a duration. */ time_lapsed = springRK4Factory(tension, friction); /* Compute the adjusted time delta. */ dt = time_lapsed / duration * DT; } else { dt = DT; } while (true) { /* Next/step function .*/ last_state = springIntegrateState(last_state || initState, dt); /* Store the position. */ path.push(1 + last_state.x); time_lapsed += 16; /* If the change threshold is reached, break. */ if (!(Math.abs(last_state.x) > tolerance && Math.abs(last_state.v) > tolerance)) { break; } } /* If duration is not defined, return the actual time required for completing this animation. Otherwise, return a closure that holds the computed path and returns a snapshot of the position according to a given percentComplete. */ return !have_duration ? time_lapsed : function(percentComplete) { return path[ (percentComplete * (path.length - 1)) | 0 ]; }; }; }()); /* jQuery easings. */ Velocity.Easings = { linear: function(p) { return p; }, swing: function(p) { return 0.5 - Math.cos( p * Math.PI ) / 2 }, /* Bonus "spring" easing, which is a less exaggerated version of easeInOutElastic. */ spring: function(p) { return 1 - (Math.cos(p * 4.5 * Math.PI) * Math.exp(-p * 6)); } }; /* CSS3 and Robert Penner easings. */ $.each( [ [ "ease", [ 0.25, 0.1, 0.25, 1.0 ] ], [ "ease-in", [ 0.42, 0.0, 1.00, 1.0 ] ], [ "ease-out", [ 0.00, 0.0, 0.58, 1.0 ] ], [ "ease-in-out", [ 0.42, 0.0, 0.58, 1.0 ] ], [ "easeInSine", [ 0.47, 0, 0.745, 0.715 ] ], [ "easeOutSine", [ 0.39, 0.575, 0.565, 1 ] ], [ "easeInOutSine", [ 0.445, 0.05, 0.55, 0.95 ] ], [ "easeInQuad", [ 0.55, 0.085, 0.68, 0.53 ] ], [ "easeOutQuad", [ 0.25, 0.46, 0.45, 0.94 ] ], [ "easeInOutQuad", [ 0.455, 0.03, 0.515, 0.955 ] ], [ "easeInCubic", [ 0.55, 0.055, 0.675, 0.19 ] ], [ "easeOutCubic", [ 0.215, 0.61, 0.355, 1 ] ], [ "easeInOutCubic", [ 0.645, 0.045, 0.355, 1 ] ], [ "easeInQuart", [ 0.895, 0.03, 0.685, 0.22 ] ], [ "easeOutQuart", [ 0.165, 0.84, 0.44, 1 ] ], [ "easeInOutQuart", [ 0.77, 0, 0.175, 1 ] ], [ "easeInQuint", [ 0.755, 0.05, 0.855, 0.06 ] ], [ "easeOutQuint", [ 0.23, 1, 0.32, 1 ] ], [ "easeInOutQuint", [ 0.86, 0, 0.07, 1 ] ], [ "easeInExpo", [ 0.95, 0.05, 0.795, 0.035 ] ], [ "easeOutExpo", [ 0.19, 1, 0.22, 1 ] ], [ "easeInOutExpo", [ 1, 0, 0, 1 ] ], [ "easeInCirc", [ 0.6, 0.04, 0.98, 0.335 ] ], [ "easeOutCirc", [ 0.075, 0.82, 0.165, 1 ] ], [ "easeInOutCirc", [ 0.785, 0.135, 0.15, 0.86 ] ] ], function(i, easingArray) { Velocity.Easings[easingArray[0]] = generateBezier.apply(null, easingArray[1]); }); /* Determine the appropriate easing type given an easing input. */ function getEasing(value, duration) { var easing = value; /* The easing option can either be a string that references a pre-registered easing, or it can be a two-/four-item array of integers to be converted into a bezier/spring function. */ if (Type.isString(value)) { /* Ensure that the easing has been assigned to jQuery's Velocity.Easings object. */ if (!Velocity.Easings[value]) { easing = false; } } else if (Type.isArray(value) && value.length === 1) { easing = generateStep.apply(null, value); } else if (Type.isArray(value) && value.length === 2) { /* springRK4 must be passed the animation's duration. */ /* Note: If the springRK4 array contains non-numbers, generateSpringRK4() returns an easing function generated with default tension and friction values. */ easing = generateSpringRK4.apply(null, value.concat([ duration ])); } else if (Type.isArray(value) && value.length === 4) { /* Note: If the bezier array contains non-numbers, generateBezier() returns false. */ easing = generateBezier.apply(null, value); } else { easing = false; } /* Revert to the Velocity-wide default easing type, or fall back to "swing" (which is also jQuery's default) if the Velocity-wide default has been incorrectly modified. */ if (easing === false) { if (Velocity.Easings[Velocity.defaults.easing]) { easing = Velocity.defaults.easing; } else { easing = EASING_DEFAULT; } } return easing; } /***************** CSS Stack *****************/ /* The CSS object is a highly condensed and performant CSS stack that fully replaces jQuery's. It handles the validation, getting, and setting of both standard CSS properties and CSS property hooks. */ /* Note: A "CSS" shorthand is aliased so that our code is easier to read. */ var CSS = Velocity.CSS = { /************* RegEx *************/ RegEx: { isHex: /^#([A-f\d]{3}){1,2}$/i, /* Unwrap a property value's surrounding text, e.g. "rgba(4, 3, 2, 1)" ==> "4, 3, 2, 1" and "rect(4px 3px 2px 1px)" ==> "4px 3px 2px 1px". */ valueUnwrap: /^[A-z]+\((.*)\)$/i, wrappedValueAlreadyExtracted: /[0-9.]+ [0-9.]+ [0-9.]+( [0-9.]+)?/, /* Split a multi-value property into an array of subvalues, e.g. "rgba(4, 3, 2, 1) 4px 3px 2px 1px" ==> [ "rgba(4, 3, 2, 1)", "4px", "3px", "2px", "1px" ]. */ valueSplit: /([A-z]+\(.+\))|(([A-z0-9#-.]+?)(?=\s|$))/ig }, /************ Lists ************/ Lists: { colors: [ "fill", "stroke", "stopColor", "color", "backgroundColor", "borderColor", "borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor", "outlineColor" ], transformsBase: [ "translateX", "translateY", "scale", "scaleX", "scaleY", "skewX", "skewY", "rotateZ" ], transforms3D: [ "transformPerspective", "translateZ", "scaleZ", "rotateX", "rotateY" ] }, /************ Hooks ************/ /* Hooks allow a subproperty (e.g. "boxShadowBlur") of a compound-value CSS property (e.g. "boxShadow: X Y Blur Spread Color") to be animated as if it were a discrete property. */ /* Note: Beyond enabling fine-grained property animation, hooking is necessary since Velocity only tweens properties with single numeric values; unlike CSS transitions, Velocity does not interpolate compound-values. */ Hooks: { /******************** Registration ********************/ /* Templates are a concise way of indicating which subproperties must be individually registered for each compound-value CSS property. */ /* Each template consists of the compound-value's base name, its constituent subproperty names, and those subproperties' default values. */ templates: { "textShadow": [ "Color X Y Blur", "black 0px 0px 0px" ], /* Todo: Add support for inset boxShadows. (webkit places it last whereas IE places it first.) */ "boxShadow": [ "Color X Y Blur Spread", "black 0px 0px 0px 0px" ], "clip": [ "Top Right Bottom Left", "0px 0px 0px 0px" ], "backgroundPosition": [ "X Y", "0% 0%" ], "transformOrigin": [ "X Y Z", "50% 50% 0px" ], "perspectiveOrigin": [ "X Y", "50% 50%" ] }, /* A "registered" hook is one that has been converted from its template form into a live, tweenable property. It contains data to associate it with its root property. */ registered: { /* Note: A registered hook looks like this ==> textShadowBlur: [ "textShadow", 3 ], which consists of the subproperty's name, the associated root property's name, and the subproperty's position in the root's value. */ }, /* Convert the templates into individual hooks then append them to the registered object above. */ register: function () { /* Color hooks registration: Colors are defaulted to white -- as opposed to black -- since colors that are currently set to "transparent" default to their respective template below when color-animated, and white is typically a closer match to transparent than black is. An exception is made for text ("color"), which is almost always set closer to black than white. */ for (var i = 0; i < CSS.Lists.colors.length; i++) { var rgbComponents = (CSS.Lists.colors[i] === "color") ? "0 0 0 1" : "255 255 255 1"; CSS.Hooks.templates[CSS.Lists.colors[i]] = [ "Red Green Blue Alpha", rgbComponents ]; } var rootProperty, hookTemplate, hookNames; /* In IE, color values inside compound-value properties are positioned at the end the value instead of at the beginning. Thus, we re-arrange the templates accordingly. */ if (IE) { for (rootProperty in CSS.Hooks.templates) { hookTemplate = CSS.Hooks.templates[rootProperty]; hookNames = hookTemplate[0].split(" "); var defaultValues = hookTemplate[1].match(CSS.RegEx.valueSplit); if (hookNames[0] === "Color") { /* Reposition both the hook's name and its default value to the end of their respective strings. */ hookNames.push(hookNames.shift()); defaultValues.push(defaultValues.shift()); /* Replace the existing template for the hook's root property. */ CSS.Hooks.templates[rootProperty] = [ hookNames.join(" "), defaultValues.join(" ") ]; } } } /* Hook registration. */ for (rootProperty in CSS.Hooks.templates) { hookTemplate = CSS.Hooks.templates[rootProperty]; hookNames = hookTemplate[0].split(" "); for (var i in hookNames) { var fullHookName = rootProperty + hookNames[i], hookPosition = i; /* For each hook, register its full name (e.g. textShadowBlur) with its root property (e.g. textShadow) and the hook's position in its template's default value string. */ CSS.Hooks.registered[fullHookName] = [ rootProperty, hookPosition ]; } } }, /***************************** Injection and Extraction *****************************/ /* Look up the root property associated with the hook (e.g. return "textShadow" for "textShadowBlur"). */ /* Since a hook cannot be set directly (the browser won't recognize it), style updating for hooks is routed through the hook's root property. */ getRoot: function (property) { var hookData = CSS.Hooks.registered[property]; if (hookData) { return hookData[0]; } else { /* If there was no hook match, return the property name untouched. */ return property; } }, /* Convert any rootPropertyValue, null or otherwise, into a space-delimited list of hook values so that the targeted hook can be injected or extracted at its standard position. */ cleanRootPropertyValue: function(rootProperty, rootPropertyValue) { /* If the rootPropertyValue is wrapped with "rgb()", "clip()", etc., remove the wrapping to normalize the value before manipulation. */ if (CSS.RegEx.valueUnwrap.test(rootPropertyValue)) { rootPropertyValue = rootPropertyValue.match(CSS.RegEx.valueUnwrap)[1]; } /* If rootPropertyValue is a CSS null-value (from which there's inherently no hook value to extract), default to the root's default value as defined in CSS.Hooks.templates. */ /* Note: CSS null-values include "none", "auto", and "transparent". They must be converted into their zero-values (e.g. textShadow: "none" ==> textShadow: "0px 0px 0px black") for hook manipulation to proceed. */ if (CSS.Values.isCSSNullValue(rootPropertyValue)) { rootPropertyValue = CSS.Hooks.templates[rootProperty][1]; } return rootPropertyValue; }, /* Extracted the hook's value from its root property's value. This is used to get the starting value of an animating hook. */ extractValue: function (fullHookName, rootPropertyValue) { var hookData = CSS.Hooks.registered[fullHookName]; if (hookData) { var hookRoot = hookData[0], hookPosition = hookData[1]; rootPropertyValue = CSS.Hooks.cleanRootPropertyValue(hookRoot, rootPropertyValue); /* Split rootPropertyValue into its constituent hook values then grab the desired hook at its standard position. */ return rootPropertyValue.toString().match(CSS.RegEx.valueSplit)[hookPosition]; } else { /* If the provided fullHookName isn't a registered hook, return the rootPropertyValue that was passed in. */ return rootPropertyValue; } }, /* Inject the hook's value into its root property's value. This is used to piece back together the root property once Velocity has updated one of its individually hooked values through tweening. */ injectValue: function (fullHookName, hookValue, rootPropertyValue) { var hookData = CSS.Hooks.registered[fullHookName]; if (hookData) { var hookRoot = hookData[0], hookPosition = hookData[1], rootPropertyValueParts, rootPropertyValueUpdated; rootPropertyValue = CSS.Hooks.cleanRootPropertyValue(hookRoot, rootPropertyValue); /* Split rootPropertyValue into its individual hook values, replace the targeted value with hookValue, then reconstruct the rootPropertyValue string. */ rootPropertyValueParts = rootPropertyValue.toString().match(CSS.RegEx.valueSplit); rootPropertyValueParts[hookPosition] = hookValue; rootPropertyValueUpdated = rootPropertyValueParts.join(" "); return rootPropertyValueUpdated; } else { /* If the provided fullHookName isn't a registered hook, return the rootPropertyValue that was passed in. */ return rootPropertyValue; } } }, /******************* Normalizations *******************/ /* Normalizations standardize CSS property manipulation by pollyfilling browser-specific implementations (e.g. opacity) and reformatting special properties (e.g. clip, rgba) to look like standard ones. */ Normalizations: { /* Normalizations are passed a normalization target (either the property's name, its extracted value, or its injected value), the targeted element (which may need to be queried), and the targeted property value. */ registered: { clip: function (type, element, propertyValue) { switch (type) { case "name": return "clip"; /* Clip needs to be unwrapped and stripped of its commas during extraction. */ case "extract": var extracted; /* If Velocity also extracted this value, skip extraction. */ if (CSS.RegEx.wrappedValueAlreadyExtracted.test(propertyValue)) { extracted = propertyValue; } else { /* Remove the "rect()" wrapper. */ extracted = propertyValue.toString().match(CSS.RegEx.valueUnwrap); /* Strip off commas. */ extracted = extracted ? extracted[1].replace(/,(\s+)?/g, " ") : propertyValue; } return extracted; /* Clip needs to be re-wrapped during injection. */ case "inject": return "rect(" + propertyValue + ")"; } }, blur: function(type, element, propertyValue) { switch (type) { case "name": return "-webkit-filter"; case "extract": var extracted = parseFloat(propertyValue); /* If extracted is NaN, meaning the value isn't already extracted. */ if (!(extracted || extracted === 0)) { var blurComponent = propertyValue.toString().match(/blur\(([0-9]+[A-z]+)\)/i); /* If the filter string had a blur component, return just the blur value and unit type. */ if (blurComponent) { extracted = blurComponent[1]; /* If the component doesn't exist, default blur to 0. */ } else { extracted = 0; } } return extracted; /* Blur needs to be re-wrapped during injection. */ case "inject": /* For the blur effect to be fully de-applied, it needs to be set to "none" instead of 0. */ if (!parseFloat(propertyValue)) { return "none"; } else { return "blur(" + propertyValue + ")"; } } }, /* <=IE8 do not support the standard opacity property. They use filter:alpha(opacity=INT) instead. */ opacity: function (type, element, propertyValue) { if (IE <= 8) { switch (type) { case "name": return "filter"; case "extract": /* <=IE8 return a "filter" value of "alpha(opacity=\d{1,3})". Extract the value and convert it to a decimal value to match the standard CSS opacity property's formatting. */ var extracted = propertyValue.toString().match(/alpha\(opacity=(.*)\)/i); if (extracted) { /* Convert to decimal value. */ propertyValue = extracted[1] / 100; } else { /* When extracting opacity, default to 1 since a null value means opacity hasn't been set. */ propertyValue = 1; } return propertyValue; case "inject": /* Opacified elements are required to have their zoom property set to a non-zero value. */ element.style.zoom = 1; /* Setting the filter property on elements with certain font property combinations can result in a highly unappealing ultra-bolding effect. There's no way to remedy this throughout a tween, but dropping the value altogether (when opacity hits 1) at leasts ensures that the glitch is gone post-tweening. */ if (parseFloat(propertyValue) >= 1) { return ""; } else { /* As per the filter property's spec, convert the decimal value to a whole number and wrap the value. */ return "alpha(opacity=" + parseInt(parseFloat(propertyValue) * 100, 10) + ")"; } } /* With all other browsers, normalization is not required; return the same values that were passed in. */ } else { switch (type) { case "name": return "opacity"; case "extract": return propertyValue; case "inject": return propertyValue; } } } }, /***************************** Batched Registrations *****************************/ /* Note: Batched normalizations extend the CSS.Normalizations.registered object. */ register: function () { /***************** Transforms *****************/ /* Transforms are the subproperties contained by the CSS "transform" property. Transforms must undergo normalization so that they can be referenced in a properties map by their individual names. */ /* Note: When transforms are "set", they are actually assigned to a per-element transformCache. When all transform setting is complete complete, CSS.flushTransformCache() must be manually called to flush the values to the DOM. Transform setting is batched in this way to improve performance: the transform style only needs to be updated once when multiple transform subproperties are being animated simultaneously. */ /* Note: IE9 and Android Gingerbread have support for 2D -- but not 3D -- transforms. Since animating unsupported transform properties results in the browser ignoring the *entire* transform string, we prevent these 3D values from being normalized for these browsers so that tweening skips these properties altogether (since it will ignore them as being unsupported by the browser.) */ if (!(IE <= 9) && !Velocity.State.isGingerbread) { /* Note: Since the standalone CSS "perspective" property and the CSS transform "perspective" subproperty share the same name, the latter is given a unique token within Velocity: "transformPerspective". */ CSS.Lists.transformsBase = CSS.Lists.transformsBase.concat(CSS.Lists.transforms3D); } for (var i = 0; i < CSS.Lists.transformsBase.length; i++) { /* Wrap the dynamically generated normalization function in a new scope so that transformName's value is paired with its respective function. (Otherwise, all functions would take the final for loop's transformName.) */ (function() { var transformName = CSS.Lists.transformsBase[i]; CSS.Normalizations.registered[transformName] = function (type, element, propertyValue) { switch (type) { /* The normalized property name is the parent "transform" property -- the property that is actually set in CSS. */ case "name": return "transform"; /* Transform values are cached onto a per-element transformCache object. */ case "extract": /* If this transform has yet to be assigned a value, return its null value. */ if (Data(element) === undefined || Data(element).transformCache[transformName] === undefined) { /* Scale CSS.Lists.transformsBase default to 1 whereas all other transform properties default to 0. */ return /^scale/i.test(transformName) ? 1 : 0; /* When transform values are set, they are wrapped in parentheses as per the CSS spec. Thus, when extracting their values (for tween calculations), we strip off the parentheses. */ } else { return Data(element).transformCache[transformName].replace(/[()]/g, ""); } case "inject": var invalid = false; /* If an individual transform property contains an unsupported unit type, the browser ignores the *entire* transform property. Thus, protect users from themselves by skipping setting for transform values supplied with invalid unit types. */ /* Switch on the base transform type; ignore the axis by removing the last letter from the transform's name. */ switch (transformName.substr(0, transformName.length - 1)) { /* Whitelist unit types for each transform. */ case "translate": invalid = !/(%|px|em|rem|vw|vh|\d)$/i.test(propertyValue); break; /* Since an axis-free "scale" property is supported as well, a little hack is used here to detect it by chopping off its last letter. */ case "scal": case "scale": /* Chrome on Android has a bug in which scaled elements blur if their initial scale value is below 1 (which can happen with forcefeeding). Thus, we detect a yet-unset scale property and ensure that its first value is always 1. More info: http://stackoverflow.com/questions/10417890/css3-animations-with-transform-causes-blurred-elements-on-webkit/10417962#10417962 */ if (Velocity.State.isAndroid && Data(element).transformCache[transformName] === undefined && propertyValue < 1) { propertyValue = 1; } invalid = !/(\d)$/i.test(propertyValue); break; case "skew": invalid = !/(deg|\d)$/i.test(propertyValue); break; case "rotate": invalid = !/(deg|\d)$/i.test(propertyValue); break; } if (!invalid) { /* As per the CSS spec, wrap the value in parentheses. */ Data(element).transformCache[transformName] = "(" + propertyValue + ")"; } /* Although the value is set on the transformCache object, return the newly-updated value for the calling code to process as normal. */ return Data(element).transformCache[transformName]; } }; })(); } /************* Colors *************/ /* Since Velocity only animates a single numeric value per property, color animation is achieved by hooking the individual RGBA components of CSS color properties. Accordingly, color values must be normalized (e.g. "#ff0000", "red", and "rgb(255, 0, 0)" ==> "255 0 0 1") so that their components can be injected/extracted by CSS.Hooks logic. */ for (var i = 0; i < CSS.Lists.colors.length; i++) { /* Wrap the dynamically generated normalization function in a new scope so that colorName's value is paired with its respective function. (Otherwise, all functions would take the final for loop's colorName.) */ (function () { var colorName = CSS.Lists.colors[i]; /* Note: In IE<=8, which support rgb but not rgba, color properties are reverted to rgb by stripping off the alpha component. */ CSS.Normalizations.registered[colorName] = function(type, element, propertyValue) { switch (type) { case "name": return colorName; /* Convert all color values into the rgb format. (Old IE can return hex values and color names instead of rgb/rgba.) */ case "extract": var extracted; /* If the color is already in its hookable form (e.g. "255 255 255 1") due to having been previously extracted, skip extraction. */ if (CSS.RegEx.wrappedValueAlreadyExtracted.test(propertyValue)) { extracted = propertyValue; } else { var converted, colorNames = { black: "rgb(0, 0, 0)", blue: "rgb(0, 0, 255)", gray: "rgb(128, 128, 128)", green: "rgb(0, 128, 0)", red: "rgb(255, 0, 0)", white: "rgb(255, 255, 255)" }; /* Convert color names to rgb. */ if (/^[A-z]+$/i.test(propertyValue)) { if (colorNames[propertyValue] !== undefined) { converted = colorNames[propertyValue] } else { /* If an unmatched color name is provided, default to black. */ converted = colorNames.black; } /* Convert hex values to rgb. */ } else if (CSS.RegEx.isHex.test(propertyValue)) { converted = "rgb(" + CSS.Values.hexToRgb(propertyValue).join(" ") + ")"; /* If the provided color doesn't match any of the accepted color formats, default to black. */ } else if (!(/^rgba?\(/i.test(propertyValue))) { converted = colorNames.black; } /* Remove the surrounding "rgb/rgba()" string then replace commas with spaces and strip repeated spaces (in case the value included spaces to begin with). */ extracted = (converted || propertyValue).toString().match(CSS.RegEx.valueUnwrap)[1].replace(/,(\s+)?/g, " "); } /* So long as this isn't <=IE8, add a fourth (alpha) component if it's missing and default it to 1 (visible). */ if (!(IE <= 8) && extracted.split(" ").length === 3) { extracted += " 1"; } return extracted; case "inject": /* If this is IE<=8 and an alpha component exists, strip it off. */ if (IE <= 8) { if (propertyValue.split(" ").length === 4) { propertyValue = propertyValue.split(/\s+/).slice(0, 3).join(" "); } /* Otherwise, add a fourth (alpha) component if it's missing and default it to 1 (visible). */ } else if (propertyValue.split(" ").length === 3) { propertyValue += " 1"; } /* Re-insert the browser-appropriate wrapper("rgb/rgba()"), insert commas, and strip off decimal units on all values but the fourth (R, G, and B only accept whole numbers). */ return (IE <= 8 ? "rgb" : "rgba") + "(" + propertyValue.replace(/\s+/g, ",").replace(/\.(\d)+(?=,)/g, "") + ")"; } }; })(); } } }, /************************ CSS Property Names ************************/ Names: { /* Camelcase a property name into its JavaScript notation (e.g. "background-color" ==> "backgroundColor"). Camelcasing is used to normalize property names between and across calls. */ camelCase: function (property) { return property.replace(/-(\w)/g, function (match, subMatch) { return subMatch.toUpperCase(); }); }, /* For SVG elements, some properties (namely, dimensional ones) are GET/SET via the element's HTML attributes (instead of via CSS styles). */ SVGAttribute: function (property) { var SVGAttributes = "width|height|x|y|cx|cy|r|rx|ry|x1|x2|y1|y2"; /* Certain browsers require an SVG transform to be applied as an attribute. (Otherwise, application via CSS is preferable due to 3D support.) */ if (IE || (Velocity.State.isAndroid && !Velocity.State.isChrome)) { SVGAttributes += "|transform"; } return new RegExp("^(" + SVGAttributes + ")$", "i").test(property); }, /* Determine whether a property should be set with a vendor prefix. */ /* If a prefixed version of the property exists, return it. Otherwise, return the original property name. If the property is not at all supported by the browser, return a false flag. */ prefixCheck: function (property) { /* If this property has already been checked, return the cached value. */ if (Velocity.State.prefixMatches[property]) { return [ Velocity.State.prefixMatches[property], true ]; } else { var vendors = [ "", "Webkit", "Moz", "ms", "O" ]; for (var i = 0, vendorsLength = vendors.length; i < vendorsLength; i++) { var propertyPrefixed; if (i === 0) { propertyPrefixed = property; } else { /* Capitalize the first letter of the property to conform to JavaScript vendor prefix notation (e.g. webkitFilter). */ propertyPrefixed = vendors[i] + property.replace(/^\w/, function(match) { return match.toUpperCase(); }); } /* Check if the browser supports this property as prefixed. */ if (Type.isString(Velocity.State.prefixElement.style[propertyPrefixed])) { /* Cache the match. */ Velocity.State.prefixMatches[property] = propertyPrefixed; return [ propertyPrefixed, true ]; } } /* If the browser doesn't support this property in any form, include a false flag so that the caller can decide how to proceed. */ return [ property, false ]; } } }, /************************ CSS Property Values ************************/ Values: { /* Hex to RGB conversion. Copyright Tim Down: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb */ hexToRgb: function (hex) { var shortformRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, longformRegex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i, rgbParts; hex = hex.replace(shortformRegex, function (m, r, g, b) { return r + r + g + g + b + b; }); rgbParts = longformRegex.exec(hex); return rgbParts ? [ parseInt(rgbParts[1], 16), parseInt(rgbParts[2], 16), parseInt(rgbParts[3], 16) ] : [ 0, 0, 0 ]; }, isCSSNullValue: function (value) { /* The browser defaults CSS values that have not been set to either 0 or one of several possible null-value strings. Thus, we check for both falsiness and these special strings. */ /* Null-value checking is performed to default the special strings to 0 (for the sake of tweening) or their hook templates as defined as CSS.Hooks (for the sake of hook injection/extraction). */ /* Note: Chrome returns "rgba(0, 0, 0, 0)" for an undefined color whereas IE returns "transparent". */ return (value == 0 || /^(none|auto|transparent|(rgba\(0, ?0, ?0, ?0\)))$/i.test(value)); }, /* Retrieve a property's default unit type. Used for assigning a unit type when one is not supplied by the user. */ getUnitType: function (property) { if (/^(rotate|skew)/i.test(property)) { return "deg"; } else if (/(^(scale|scaleX|scaleY|scaleZ|alpha|flexGrow|flexHeight|zIndex|fontWeight)$)|((opacity|red|green|blue|alpha)$)/i.test(property)) { /* The above properties are unitless. */ return ""; } else { /* Default to px for all other properties. */ return "px"; } }, /* HTML elements default to an associated display type when they're not set to display:none. */ /* Note: This function is used for correctly setting the non-"none" display value in certain Velocity redirects, such as fadeIn/Out. */ getDisplayType: function (element) { var tagName = element && element.tagName.toString().toLowerCase(); if (/^(b|big|i|small|tt|abbr|acronym|cite|code|dfn|em|kbd|strong|samp|var|a|bdo|br|img|map|object|q|script|span|sub|sup|button|input|label|select|textarea)$/i.test(tagName)) { return "inline"; } else if (/^(li)$/i.test(tagName)) { return "list-item"; } else if (/^(tr)$/i.test(tagName)) { return "table-row"; /* Default to "block" when no match is found. */ } else { return "block"; } }, /* The class add/remove functions are used to temporarily apply a "velocity-animating" class to elements while they're animating. */ addClass: function (element, className) { if (element.classList) { element.classList.add(className); } else { element.className += (element.className.length ? " " : "") + className; } }, removeClass: function (element, className) { if (element.classList) { element.classList.remove(className); } else { element.className = element.className.toString().replace(new RegExp("(^|\\s)" + className.split(" ").join("|") + "(\\s|$)", "gi"), " "); } } }, /**************************** Style Getting & Setting ****************************/ /* The singular getPropertyValue, which routes the logic for all normalizations, hooks, and standard CSS properties. */ getPropertyValue: function (element, property, rootPropertyValue, forceStyleLookup) { /* Get an element's computed property value. */ /* Note: Retrieving the value of a CSS property cannot simply be performed by checking an element's style attribute (which only reflects user-defined values). Instead, the browser must be queried for a property's *computed* value. You can read more about getComputedStyle here: https://developer.mozilla.org/en/docs/Web/API/window.getComputedStyle */ function computePropertyValue (element, property) { /* When box-sizing isn't set to border-box, height and width style values are incorrectly computed when an element's scrollbars are visible (which expands the element's dimensions). Thus, we defer to the more accurate offsetHeight/Width property, which includes the total dimensions for interior, border, padding, and scrollbar. We subtract border and padding to get the sum of interior + scrollbar. */ var computedValue = 0; /* IE<=8 doesn't support window.getComputedStyle, thus we defer to jQuery, which has an extensive array of hacks to accurately retrieve IE8 property values. Re-implementing that logic here is not worth bloating the codebase for a dying browser. The performance repercussions of using jQuery here are minimal since Velocity is optimized to rarely (and sometimes never) query the DOM. Further, the $.css() codepath isn't that slow. */ if (IE <= 8) { computedValue = $.css(element, property); /* GET */ /* All other browsers support getComputedStyle. The returned live object reference is cached onto its associated element so that it does not need to be refetched upon every GET. */ } else { /* Browsers do not return height and width values for elements that are set to display:"none". Thus, we temporarily toggle display to the element type's default value. */ var toggleDisplay = false; if (/^(width|height)$/.test(property) && CSS.getPropertyValue(element, "display") === 0) { toggleDisplay = true; CSS.setPropertyValue(element, "display", CSS.Values.getDisplayType(element)); } function revertDisplay () { if (toggleDisplay) { CSS.setPropertyValue(element, "display", "none"); } } if (!forceStyleLookup) { if (property === "height" && CSS.getPropertyValue(element, "boxSizing").toString().toLowerCase() !== "border-box") { var contentBoxHeight = element.offsetHeight - (parseFloat(CSS.getPropertyValue(element, "borderTopWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "borderBottomWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingTop")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingBottom")) || 0); revertDisplay(); return contentBoxHeight; } else if (property === "width" && CSS.getPropertyValue(element, "boxSizing").toString().toLowerCase() !== "border-box") { var contentBoxWidth = element.offsetWidth - (parseFloat(CSS.getPropertyValue(element, "borderLeftWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "borderRightWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingLeft")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingRight")) || 0); revertDisplay(); return contentBoxWidth; } } var computedStyle; /* For elements that Velocity hasn't been called on directly (e.g. when Velocity queries the DOM on behalf of a parent of an element its animating), perform a direct getComputedStyle lookup since the object isn't cached. */ if (Data(element) === undefined) { computedStyle = window.getComputedStyle(element, null); /* GET */ /* If the computedStyle object has yet to be cached, do so now. */ } else if (!Data(element).computedStyle) { computedStyle = Data(element).computedStyle = window.getComputedStyle(element, null); /* GET */ /* If computedStyle is cached, use it. */ } else { computedStyle = Data(element).computedStyle; } /* IE and Firefox do not return a value for the generic borderColor -- they only return individual values for each border side's color. As a polyfill for querying individual border side colors, just return the top border's color. */ if ((IE || Velocity.State.isFirefox) && property === "borderColor") { property = "borderTopColor"; } /* IE9 has a bug in which the "filter" property must be accessed from computedStyle using the getPropertyValue method instead of a direct property lookup. The getPropertyValue method is slower than a direct lookup, which is why we avoid it by default. */ if (IE === 9 && property === "filter") { computedValue = computedStyle.getPropertyValue(property); /* GET */ } else { computedValue = computedStyle[property]; } /* Fall back to the property's style value (if defined) when computedValue returns nothing, which can happen when the element hasn't been painted. */ if (computedValue === "" || computedValue === null) { computedValue = element.style[property]; } revertDisplay(); } /* For top, right, bottom, and left (TRBL) values that are set to "auto" on elements of "fixed" or "absolute" position, defer to jQuery for converting "auto" to a numeric value. (For elements with a "static" or "relative" position, "auto" has the same effect as being set to 0, so no conversion is necessary.) */ /* An example of why numeric conversion is necessary: When an element with "position:absolute" has an untouched "left" property, which reverts to "auto", left's value is 0 relative to its parent element, but is often non-zero relative to its *containing* (not parent) element, which is the nearest "position:relative" ancestor or the viewport (and always the viewport in the case of "position:fixed"). */ if (computedValue === "auto" && /^(top|right|bottom|left)$/i.test(property)) { var position = computePropertyValue(element, "position"); /* GET */ /* For absolute positioning, jQuery's $.position() only returns values for top and left; right and bottom will have their "auto" value reverted to 0. */ /* Note: A jQuery object must be created here since jQuery doesn't have a low-level alias for $.position(). Not a big deal since we're currently in a GET batch anyway. */ if (position === "fixed" || (position === "absolute" && /top|left/i.test(property))) { /* Note: jQuery strips the pixel unit from its returned values; we re-add it here to conform with computePropertyValue's behavior. */ computedValue = $(element).position()[property] + "px"; /* GET */ } } return computedValue; } var propertyValue; /* If this is a hooked property (e.g. "clipLeft" instead of the root property of "clip"), extract the hook's value from a normalized rootPropertyValue using CSS.Hooks.extractValue(). */ if (CSS.Hooks.registered[property]) { var hook = property, hookRoot = CSS.Hooks.getRoot(hook); /* If a cached rootPropertyValue wasn't passed in (which Velocity always attempts to do in order to avoid requerying the DOM), query the DOM for the root property's value. */ if (rootPropertyValue === undefined) { /* Since the browser is now being directly queried, use the official post-prefixing property name for this lookup. */ rootPropertyValue = CSS.getPropertyValue(element, CSS.Names.prefixCheck(hookRoot)[0]); /* GET */ } /* If this root has a normalization registered, peform the associated normalization extraction. */ if (CSS.Normalizations.registered[hookRoot]) { rootPropertyValue = CSS.Normalizations.registered[hookRoot]("extract", element, rootPropertyValue); } /* Extract the hook's value. */ propertyValue = CSS.Hooks.extractValue(hook, rootPropertyValue); /* If this is a normalized property (e.g. "opacity" becomes "filter" in <=IE8) or "translateX" becomes "transform"), normalize the property's name and value, and handle the special case of transforms. */ /* Note: Normalizing a property is mutually exclusive from hooking a property since hook-extracted values are strictly numerical and therefore do not require normalization extraction. */ } else if (CSS.Normalizations.registered[property]) { var normalizedPropertyName, normalizedPropertyValue; normalizedPropertyName = CSS.Normalizations.registered[property]("name", element); /* Transform values are calculated via normalization extraction (see below), which checks against the element's transformCache. At no point do transform GETs ever actually query the DOM; initial stylesheet values are never processed. This is because parsing 3D transform matrices is not always accurate and would bloat our codebase; thus, normalization extraction defaults initial transform values to their zero-values (e.g. 1 for scaleX and 0 for translateX). */ if (normalizedPropertyName !== "transform") { normalizedPropertyValue = computePropertyValue(element, CSS.Names.prefixCheck(normalizedPropertyName)[0]); /* GET */ /* If the value is a CSS null-value and this property has a hook template, use that zero-value template so that hooks can be extracted from it. */ if (CSS.Values.isCSSNullValue(normalizedPropertyValue) && CSS.Hooks.templates[property]) { normalizedPropertyValue = CSS.Hooks.templates[property][1]; } } propertyValue = CSS.Normalizations.registered[property]("extract", element, normalizedPropertyValue); } /* If a (numeric) value wasn't produced via hook extraction or normalization, query the DOM. */ if (!/^[\d-]/.test(propertyValue)) { /* For SVG elements, dimensional properties (which SVGAttribute() detects) are tweened via their HTML attribute values instead of their CSS style values. */ if (Data(element) && Data(element).isSVG && CSS.Names.SVGAttribute(property)) { /* Since the height/width attribute values must be set manually, they don't reflect computed values. Thus, we use use getBBox() to ensure we always get values for elements with undefined height/width attributes. */ if (/^(height|width)$/i.test(property)) { propertyValue = element.getBBox()[property]; /* Otherwise, access the attribute value directly. */ } else { propertyValue = element.getAttribute(property); } } else { propertyValue = computePropertyValue(element, CSS.Names.prefixCheck(property)[0]); /* GET */ } } /* Since property lookups are for animation purposes (which entails computing the numeric delta between start and end values), convert CSS null-values to an integer of value 0. */ if (CSS.Values.isCSSNullValue(propertyValue)) { propertyValue = 0; } if (Velocity.debug >= 2) console.log("Get " + property + ": " + propertyValue); return propertyValue; }, /* The singular setPropertyValue, which routes the logic for all normalizations, hooks, and standard CSS properties. */ setPropertyValue: function(element, property, propertyValue, rootPropertyValue, scrollData) { var propertyName = property; /* In order to be subjected to call options and element queueing, scroll animation is routed through Velocity as if it were a standard CSS property. */ if (property === "scroll") { /* If a container option is present, scroll the container instead of the browser window. */ if (scrollData.container) { scrollData.container["scroll" + scrollData.direction] = propertyValue; /* Otherwise, Velocity defaults to scrolling the browser window. */ } else { if (scrollData.direction === "Left") { window.scrollTo(propertyValue, scrollData.alternateValue); } else { window.scrollTo(scrollData.alternateValue, propertyValue); } } } else { /* Transforms (translateX, rotateZ, etc.) are applied to a per-element transformCache object, which is manually flushed via flushTransformCache(). Thus, for now, we merely cache transforms being SET. */ if (CSS.Normalizations.registered[property] && CSS.Normalizations.registered[property]("name", element) === "transform") { /* Perform a normalization injection. */ /* Note: The normalization logic handles the transformCache updating. */ CSS.Normalizations.registered[property]("inject", element, propertyValue); propertyName = "transform"; propertyValue = Data(element).transformCache[property]; } else { /* Inject hooks. */ if (CSS.Hooks.registered[property]) { var hookName = property, hookRoot = CSS.Hooks.getRoot(property); /* If a cached rootPropertyValue was not provided, query the DOM for the hookRoot's current value. */ rootPropertyValue = rootPropertyValue || CSS.getPropertyValue(element, hookRoot); /* GET */ propertyValue = CSS.Hooks.injectValue(hookName, propertyValue, rootPropertyValue); property = hookRoot; } /* Normalize names and values. */ if (CSS.Normalizations.registered[property]) { propertyValue = CSS.Normalizations.registered[property]("inject", element, propertyValue); property = CSS.Normalizations.registered[property]("name", element); } /* Assign the appropriate vendor prefix before performing an official style update. */ propertyName = CSS.Names.prefixCheck(property)[0]; /* A try/catch is used for IE<=8, which throws an error when "invalid" CSS values are set, e.g. a negative width. Try/catch is avoided for other browsers since it incurs a performance overhead. */ if (IE <= 8) { try { element.style[propertyName] = propertyValue; } catch (error) { if (Velocity.debug) console.log("Browser does not support [" + propertyValue + "] for [" + propertyName + "]"); } /* SVG elements have their dimensional properties (width, height, x, y, cx, etc.) applied directly as attributes instead of as styles. */ /* Note: IE8 does not support SVG elements, so it's okay that we skip it for SVG animation. */ } else if (Data(element) && Data(element).isSVG && CSS.Names.SVGAttribute(property)) { /* Note: For SVG attributes, vendor-prefixed property names are never used. */ /* Note: Not all CSS properties can be animated via attributes, but the browser won't throw an error for unsupported properties. */ element.setAttribute(property, propertyValue); } else { element.style[propertyName] = propertyValue; } if (Velocity.debug >= 2) console.log("Set " + property + " (" + propertyName + "): " + propertyValue); } } /* Return the normalized property name and value in case the caller wants to know how these values were modified before being applied to the DOM. */ return [ propertyName, propertyValue ]; }, /* To increase performance by batching transform updates into a single SET, transforms are not directly applied to an element until flushTransformCache() is called. */ /* Note: Velocity applies transform properties in the same order that they are chronogically introduced to the element's CSS styles. */ flushTransformCache: function(element) { var transformString = ""; /* Certain browsers require that SVG transforms be applied as an attribute. However, the SVG transform attribute takes a modified version of CSS's transform string (units are dropped and, except for skewX/Y, subproperties are merged into their master property -- e.g. scaleX and scaleY are merged into scale(X Y). */ if ((IE || (Velocity.State.isAndroid && !Velocity.State.isChrome)) && Data(element).isSVG) { /* Since transform values are stored in their parentheses-wrapped form, we use a helper function to strip out their numeric values. Further, SVG transform properties only take unitless (representing pixels) values, so it's okay that parseFloat() strips the unit suffixed to the float value. */ function getTransformFloat (transformProperty) { return parseFloat(CSS.getPropertyValue(element, transformProperty)); } /* Create an object to organize all the transforms that we'll apply to the SVG element. To keep the logic simple, we process *all* transform properties -- even those that may not be explicitly applied (since they default to their zero-values anyway). */ var SVGTransforms = { translate: [ getTransformFloat("translateX"), getTransformFloat("translateY") ], skewX: [ getTransformFloat("skewX") ], skewY: [ getTransformFloat("skewY") ], /* If the scale property is set (non-1), use that value for the scaleX and scaleY values (this behavior mimics the result of animating all these properties at once on HTML elements). */ scale: getTransformFloat("scale") !== 1 ? [ getTransformFloat("scale"), getTransformFloat("scale") ] : [ getTransformFloat("scaleX"), getTransformFloat("scaleY") ], /* Note: SVG's rotate transform takes three values: rotation degrees followed by the X and Y values defining the rotation's origin point. We ignore the origin values (default them to 0). */ rotate: [ getTransformFloat("rotateZ"), 0, 0 ] }; /* Iterate through the transform properties in the user-defined property map order. (This mimics the behavior of non-SVG transform animation.) */ $.each(Data(element).transformCache, function(transformName) { /* Except for with skewX/Y, revert the axis-specific transform subproperties to their axis-free master properties so that they match up with SVG's accepted transform properties. */ if (/^translate/i.test(transformName)) { transformName = "translate"; } else if (/^scale/i.test(transformName)) { transformName = "scale"; } else if (/^rotate/i.test(transformName)) { transformName = "rotate"; } /* Check that we haven't yet deleted the property from the SVGTransforms container. */ if (SVGTransforms[transformName]) { /* Append the transform property in the SVG-supported transform format. As per the spec, surround the space-delimited values in parentheses. */ transformString += transformName + "(" + SVGTransforms[transformName].join(" ") + ")" + " "; /* After processing an SVG transform property, delete it from the SVGTransforms container so we don't re-insert the same master property if we encounter another one of its axis-specific properties. */ delete SVGTransforms[transformName]; } }); } else { var transformValue, perspective; /* Transform properties are stored as members of the transformCache object. Concatenate all the members into a string. */ $.each(Data(element).transformCache, function(transformName) { transformValue = Data(element).transformCache[transformName]; /* Transform's perspective subproperty must be set first in order to take effect. Store it temporarily. */ if (transformName === "transformPerspective") { perspective = transformValue; return true; } /* IE9 only supports one rotation type, rotateZ, which it refers to as "rotate". */ if (IE === 9 && transformName === "rotateZ") { transformName = "rotate"; } transformString += transformName + transformValue + " "; }); /* If present, set the perspective subproperty first. */ if (perspective) { transformString = "perspective" + perspective + " " + transformString; } } CSS.setPropertyValue(element, "transform", transformString); } }; /* Register hooks and normalizations. */ CSS.Hooks.register(); CSS.Normalizations.register(); /* Allow hook setting in the same fashion as jQuery's $.css(). */ Velocity.hook = function (elements, arg2, arg3) { var value = undefined; elements = sanitizeElements(elements); $.each(elements, function(i, element) { /* Initialize Velocity's per-element data cache if this element hasn't previously been animated. */ if (Data(element) === undefined) { Velocity.init(element); } /* Get property value. If an element set was passed in, only return the value for the first element. */ if (arg3 === undefined) { if (value === undefined) { value = Velocity.CSS.getPropertyValue(element, arg2); } /* Set property value. */ } else { /* sPV returns an array of the normalized propertyName/propertyValue pair used to update the DOM. */ var adjustedSet = Velocity.CSS.setPropertyValue(element, arg2, arg3); /* Transform properties don't automatically set. They have to be flushed to the DOM. */ if (adjustedSet[0] === "transform") { Velocity.CSS.flushTransformCache(element); } value = adjustedSet; } }); return value; }; /***************** Animation *****************/ var animate = function() { /****************** Call Chain ******************/ /* Logic for determining what to return to the call stack when exiting out of Velocity. */ function getChain () { /* If we are using the utility function, attempt to return this call's promise. If no promise library was detected, default to null instead of returning the targeted elements so that utility function's return value is standardized. */ if (isUtility) { return promiseData.promise || null; /* Otherwise, if we're using $.fn, return the jQuery-/Zepto-wrapped element set. */ } else { return elementsWrapped; } } /************************* Arguments Assignment *************************/ /* To allow for expressive CoffeeScript code, Velocity supports an alternative syntax in which "properties" and "options" objects are defined on a container object that's passed in as Velocity's sole argument. */ /* Note: Some browsers automatically populate arguments with a "properties" object. We detect it by checking for its default "names" property. */ var syntacticSugar = (arguments[0] && (($.isPlainObject(arguments[0].properties) && !arguments[0].properties.names) || Type.isString(arguments[0].properties))), /* Whether Velocity was called via the utility function (as opposed to on a jQuery/Zepto object). */ isUtility, /* When Velocity is called via the utility function ($.Velocity()/Velocity()), elements are explicitly passed in as the first parameter. Thus, argument positioning varies. We normalize them here. */ elementsWrapped, argumentIndex; var elements, propertiesMap, options; /* Detect jQuery/Zepto elements being animated via the $.fn method. */ if (Type.isWrapped(this)) { isUtility = false; argumentIndex = 0; elements = this; elementsWrapped = this; /* Otherwise, raw elements are being animated via the utility function. */ } else { isUtility = true; argumentIndex = 1; elements = syntacticSugar ? arguments[0].elements : arguments[0]; } elements = sanitizeElements(elements); if (!elements) { return; } if (syntacticSugar) { propertiesMap = arguments[0].properties; options = arguments[0].options; } else { propertiesMap = arguments[argumentIndex]; options = arguments[argumentIndex + 1]; } /* The length of the element set (in the form of a nodeList or an array of elements) is defaulted to 1 in case a single raw DOM element is passed in (which doesn't contain a length property). */ var elementsLength = elements.length, elementsIndex = 0; /*************************** Argument Overloading ***************************/ /* Support is included for jQuery's argument overloading: $.animate(propertyMap [, duration] [, easing] [, complete]). Overloading is detected by checking for the absence of an object being passed into options. */ /* Note: The stop action does not accept animation options, and is therefore excluded from this check. */ if (propertiesMap !== "stop" && !$.isPlainObject(options)) { /* The utility function shifts all arguments one position to the right, so we adjust for that offset. */ var startingArgumentPosition = argumentIndex + 1; options = {}; /* Iterate through all options arguments */ for (var i = startingArgumentPosition; i < arguments.length; i++) { /* Treat a number as a duration. Parse it out. */ /* Note: The following RegEx will return true if passed an array with a number as its first item. Thus, arrays are skipped from this check. */ if (!Type.isArray(arguments[i]) && (/^(fast|normal|slow)$/i.test(arguments[i]) || /^\d/.test(arguments[i]))) { options.duration = arguments[i]; /* Treat strings and arrays as easings. */ } else if (Type.isString(arguments[i]) || Type.isArray(arguments[i])) { options.easing = arguments[i]; /* Treat a function as a complete callback. */ } else if (Type.isFunction(arguments[i])) { options.complete = arguments[i]; } } } /*************** Promises ***************/ var promiseData = { promise: null, resolver: null, rejecter: null }; /* If this call was made via the utility function (which is the default method of invocation when jQuery/Zepto are not being used), and if promise support was detected, create a promise object for this call and store references to its resolver and rejecter methods. The resolve method is used when a call completes naturally or is prematurely stopped by the user. In both cases, completeCall() handles the associated call cleanup and promise resolving logic. The reject method is used when an invalid set of arguments is passed into a Velocity call. */ /* Note: Velocity employs a call-based queueing architecture, which means that stopping an animating element actually stops the full call that triggered it -- not that one element exclusively. Similarly, there is one promise per call, and all elements targeted by a Velocity call are grouped together for the purposes of resolving and rejecting a promise. */ if (isUtility && Velocity.Promise) { promiseData.promise = new Velocity.Promise(function (resolve, reject) { promiseData.resolver = resolve; promiseData.rejecter = reject; }); } /********************* Action Detection *********************/ /* Velocity's behavior is categorized into "actions": Elements can either be specially scrolled into view, or they can be started, stopped, or reversed. If a literal or referenced properties map is passed in as Velocity's first argument, the associated action is "start". Alternatively, "scroll", "reverse", or "stop" can be passed in instead of a properties map. */ var action; switch (propertiesMap) { case "scroll": action = "scroll"; break; case "reverse": action = "reverse"; break; case "stop": /******************* Action: Stop *******************/ /* Clear the currently-active delay on each targeted element. */ $.each(elements, function(i, element) { if (Data(element) && Data(element).delayTimer) { /* Stop the timer from triggering its cached next() function. */ clearTimeout(Data(element).delayTimer.setTimeout); /* Manually call the next() function so that the subsequent queue items can progress. */ if (Data(element).delayTimer.next) { Data(element).delayTimer.next(); } delete Data(element).delayTimer; } }); var callsToStop = []; /* When the stop action is triggered, the elements' currently active call is immediately stopped. The active call might have been applied to multiple elements, in which case all of the call's elements will be subjected to stopping. When an element is stopped, the next item in its animation queue is immediately triggered. */ /* An additional argument may be passed in to clear an element's remaining queued calls. Either true (which defaults to the "fx" queue) or a custom queue string can be passed in. */ /* Note: The stop command runs prior to Queueing since its behavior is intended to take effect *immediately*, regardless of the element's current queue state. */ /* Iterate through every active call. */ $.each(Velocity.State.calls, function(i, activeCall) { /* Inactive calls are set to false by the logic inside completeCall(). Skip them. */ if (activeCall) { /* Iterate through the active call's targeted elements. */ $.each(activeCall[1], function(k, activeElement) { var queueName = Type.isString(options) ? options : ""; if (options !== undefined && activeCall[2].queue !== queueName) { return true; } /* Iterate through the calls targeted by the stop command. */ $.each(elements, function(l, element) { /* Check that this call was applied to the target element. */ if (element === activeElement) { /* Optionally clear the remaining queued calls. */ if (options !== undefined) { /* Iterate through the items in the element's queue. */ $.each($.queue(element, queueName), function(_, item) { /* The queue array can contain an "inprogress" string, which we skip. */ if (Type.isFunction(item)) { /* Pass the item's callback a flag indicating that we want to abort from the queue call. (Specifically, the queue will resolve the call's associated promise then abort.) */ item(null, true); } }); /* Clearing the $.queue() array is achieved by resetting it to []. */ $.queue(element, queueName, []); } if (Data(element) && queueName === "") { /* Since "reverse" uses cached start values (the previous call's endValues), these values must be changed to reflect the final value that the elements were actually tweened to. */ $.each(Data(element).tweensContainer, function(m, activeTween) { activeTween.endValue = activeTween.currentValue; }); } callsToStop.push(i); } }); }); } }); /* Prematurely call completeCall() on each matched active call, passing an additional flag to indicate that the complete callback and display:none setting should be skipped since we're completing prematurely. */ $.each(callsToStop, function(i, j) { completeCall(j, true); }); if (promiseData.promise) { /* Immediately resolve the promise associated with this stop call since stop runs synchronously. */ promiseData.resolver(elements); } /* Since we're stopping, and not proceeding with queueing, exit out of Velocity. */ return getChain(); default: /* Treat a non-empty plain object as a literal properties map. */ if ($.isPlainObject(propertiesMap) && !Type.isEmptyObject(propertiesMap)) { action = "start"; /**************** Redirects ****************/ /* Check if a string matches a registered redirect (see Redirects above). */ } else if (Type.isString(propertiesMap) && Velocity.Redirects[propertiesMap]) { var opts = $.extend({}, options), durationOriginal = opts.duration, delayOriginal = opts.delay || 0; /* If the backwards option was passed in, reverse the element set so that elements animate from the last to the first. */ if (opts.backwards === true) { elements = $.extend(true, [], elements).reverse(); } /* Individually trigger the redirect for each element in the set to prevent users from having to handle iteration logic in their redirect. */ $.each(elements, function(elementIndex, element) { /* If the stagger option was passed in, successively delay each element by the stagger value (in ms). Retain the original delay value. */ if (parseFloat(opts.stagger)) { opts.delay = delayOriginal + (parseFloat(opts.stagger) * elementIndex); } else if (Type.isFunction(opts.stagger)) { opts.delay = delayOriginal + opts.stagger.call(element, elementIndex, elementsLength); } /* If the drag option was passed in, successively increase/decrease (depending on the presense of opts.backwards) the duration of each element's animation, using floors to prevent producing very short durations. */ if (opts.drag) { /* Default the duration of UI pack effects (callouts and transitions) to 1000ms instead of the usual default duration of 400ms. */ opts.duration = parseFloat(durationOriginal) || (/^(callout|transition)/.test(propertiesMap) ? 1000 : DURATION_DEFAULT); /* For each element, take the greater duration of: A) animation completion percentage relative to the original duration, B) 75% of the original duration, or C) a 200ms fallback (in case duration is already set to a low value). The end result is a baseline of 75% of the redirect's duration that increases/decreases as the end of the element set is approached. */ opts.duration = Math.max(opts.duration * (opts.backwards ? 1 - elementIndex/elementsLength : (elementIndex + 1) / elementsLength), opts.duration * 0.75, 200); } /* Pass in the call's opts object so that the redirect can optionally extend it. It defaults to an empty object instead of null to reduce the opts checking logic required inside the redirect. */ Velocity.Redirects[propertiesMap].call(element, element, opts || {}, elementIndex, elementsLength, elements, promiseData.promise ? promiseData : undefined); }); /* Since the animation logic resides within the redirect's own code, abort the remainder of this call. (The performance overhead up to this point is virtually non-existant.) */ /* Note: The jQuery call chain is kept intact by returning the complete element set. */ return getChain(); } else { var abortError = "Velocity: First argument (" + propertiesMap + ") was not a property map, a known action, or a registered redirect. Aborting."; if (promiseData.promise) { promiseData.rejecter(new Error(abortError)); } else { console.log(abortError); } return getChain(); } } /************************** Call-Wide Variables **************************/ /* A container for CSS unit conversion ratios (e.g. %, rem, and em ==> px) that is used to cache ratios across all elements being animated in a single Velocity call. Calculating unit ratios necessitates DOM querying and updating, and is therefore avoided (via caching) wherever possible. This container is call-wide instead of page-wide to avoid the risk of using stale conversion metrics across Velocity animations that are not immediately consecutively chained. */ var callUnitConversionData = { lastParent: null, lastPosition: null, lastFontSize: null, lastPercentToPxWidth: null, lastPercentToPxHeight: null, lastEmToPx: null, remToPx: null, vwToPx: null, vhToPx: null }; /* A container for all the ensuing tween data and metadata associated with this call. This container gets pushed to the page-wide Velocity.State.calls array that is processed during animation ticking. */ var call = []; /************************ Element Processing ************************/ /* Element processing consists of three parts -- data processing that cannot go stale and data processing that *can* go stale (i.e. third-party style modifications): 1) Pre-Queueing: Element-wide variables, including the element's data storage, are instantiated. Call options are prepared. If triggered, the Stop action is executed. 2) Queueing: The logic that runs once this call has reached its point of execution in the element's $.queue() stack. Most logic is placed here to avoid risking it becoming stale. 3) Pushing: Consolidation of the tween data followed by its push onto the global in-progress calls container. */ function processElement () { /************************* Part I: Pre-Queueing *************************/ /*************************** Element-Wide Variables ***************************/ var element = this, /* The runtime opts object is the extension of the current call's options and Velocity's page-wide option defaults. */ opts = $.extend({}, Velocity.defaults, options), /* A container for the processed data associated with each property in the propertyMap. (Each property in the map produces its own "tween".) */ tweensContainer = {}, elementUnitConversionData; /****************** Element Init ******************/ if (Data(element) === undefined) { Velocity.init(element); } /****************** Option: Delay ******************/ /* Since queue:false doesn't respect the item's existing queue, we avoid injecting its delay here (it's set later on). */ /* Note: Velocity rolls its own delay function since jQuery doesn't have a utility alias for $.fn.delay() (and thus requires jQuery element creation, which we avoid since its overhead includes DOM querying). */ if (parseFloat(opts.delay) && opts.queue !== false) { $.queue(element, opts.queue, function(next) { /* This is a flag used to indicate to the upcoming completeCall() function that this queue entry was initiated by Velocity. See completeCall() for further details. */ Velocity.velocityQueueEntryFlag = true; /* The ensuing queue item (which is assigned to the "next" argument that $.queue() automatically passes in) will be triggered after a setTimeout delay. The setTimeout is stored so that it can be subjected to clearTimeout() if this animation is prematurely stopped via Velocity's "stop" command. */ Data(element).delayTimer = { setTimeout: setTimeout(next, parseFloat(opts.delay)), next: next }; }); } /********************* Option: Duration *********************/ /* Support for jQuery's named durations. */ switch (opts.duration.toString().toLowerCase()) { case "fast": opts.duration = 200; break; case "normal": opts.duration = DURATION_DEFAULT; break; case "slow": opts.duration = 600; break; default: /* Remove the potential "ms" suffix and default to 1 if the user is attempting to set a duration of 0 (in order to produce an immediate style change). */ opts.duration = parseFloat(opts.duration) || 1; } /************************ Global Option: Mock ************************/ if (Velocity.mock !== false) { /* In mock mode, all animations are forced to 1ms so that they occur immediately upon the next rAF tick. Alternatively, a multiplier can be passed in to time remap all delays and durations. */ if (Velocity.mock === true) { opts.duration = opts.delay = 1; } else { opts.duration *= parseFloat(Velocity.mock) || 1; opts.delay *= parseFloat(Velocity.mock) || 1; } } /******************* Option: Easing *******************/ opts.easing = getEasing(opts.easing, opts.duration); /********************** Option: Callbacks **********************/ /* Callbacks must functions. Otherwise, default to null. */ if (opts.begin && !Type.isFunction(opts.begin)) { opts.begin = null; } if (opts.progress && !Type.isFunction(opts.progress)) { opts.progress = null; } if (opts.complete && !Type.isFunction(opts.complete)) { opts.complete = null; } /********************************* Option: Display & Visibility *********************************/ /* Refer to Velocity's documentation (VelocityJS.org/#displayAndVisibility) for a description of the display and visibility options' behavior. */ /* Note: We strictly check for undefined instead of falsiness because display accepts an empty string value. */ if (opts.display !== undefined && opts.display !== null) { opts.display = opts.display.toString().toLowerCase(); /* Users can pass in a special "auto" value to instruct Velocity to set the element to its default display value. */ if (opts.display === "auto") { opts.display = Velocity.CSS.Values.getDisplayType(element); } } if (opts.visibility !== undefined && opts.visibility !== null) { opts.visibility = opts.visibility.toString().toLowerCase(); } /********************** Option: mobileHA **********************/ /* When set to true, and if this is a mobile device, mobileHA automatically enables hardware acceleration (via a null transform hack) on animating elements. HA is removed from the element at the completion of its animation. */ /* Note: Android Gingerbread doesn't support HA. If a null transform hack (mobileHA) is in fact set, it will prevent other tranform subproperties from taking effect. */ /* Note: You can read more about the use of mobileHA in Velocity's documentation: VelocityJS.org/#mobileHA. */ opts.mobileHA = (opts.mobileHA && Velocity.State.isMobile && !Velocity.State.isGingerbread); /*********************** Part II: Queueing ***********************/ /* When a set of elements is targeted by a Velocity call, the set is broken up and each element has the current Velocity call individually queued onto it. In this way, each element's existing queue is respected; some elements may already be animating and accordingly should not have this current Velocity call triggered immediately. */ /* In each queue, tween data is processed for each animating property then pushed onto the call-wide calls array. When the last element in the set has had its tweens processed, the call array is pushed to Velocity.State.calls for live processing by the requestAnimationFrame tick. */ function buildQueue (next) { /******************* Option: Begin *******************/ /* The begin callback is fired once per call -- not once per elemenet -- and is passed the full raw DOM element set as both its context and its first argument. */ if (opts.begin && elementsIndex === 0) { /* We throw callbacks in a setTimeout so that thrown errors don't halt the execution of Velocity itself. */ try { opts.begin.call(elements, elements); } catch (error) { setTimeout(function() { throw error; }, 1); } } /***************************************** Tween Data Construction (for Scroll) *****************************************/ /* Note: In order to be subjected to chaining and animation options, scroll's tweening is routed through Velocity as if it were a standard CSS property animation. */ if (action === "scroll") { /* The scroll action uniquely takes an optional "offset" option -- specified in pixels -- that offsets the targeted scroll position. */ var scrollDirection = (/^x$/i.test(opts.axis) ? "Left" : "Top"), scrollOffset = parseFloat(opts.offset) || 0, scrollPositionCurrent, scrollPositionCurrentAlternate, scrollPositionEnd; /* Scroll also uniquely takes an optional "container" option, which indicates the parent element that should be scrolled -- as opposed to the browser window itself. This is useful for scrolling toward an element that's inside an overflowing parent element. */ if (opts.container) { /* Ensure that either a jQuery object or a raw DOM element was passed in. */ if (Type.isWrapped(opts.container) || Type.isNode(opts.container)) { /* Extract the raw DOM element from the jQuery wrapper. */ opts.container = opts.container[0] || opts.container; /* Note: Unlike other properties in Velocity, the browser's scroll position is never cached since it so frequently changes (due to the user's natural interaction with the page). */ scrollPositionCurrent = opts.container["scroll" + scrollDirection]; /* GET */ /* $.position() values are relative to the container's currently viewable area (without taking into account the container's true dimensions -- say, for example, if the container was not overflowing). Thus, the scroll end value is the sum of the child element's position *and* the scroll container's current scroll position. */ /* Note: jQuery does not offer a utility alias for $.position(), so we have to incur jQuery object conversion here. This syncs up with an ensuing batch of GETs, so it fortunately does not trigger layout thrashing. */ scrollPositionEnd = (scrollPositionCurrent + $(element).position()[scrollDirection.toLowerCase()]) + scrollOffset; /* GET */ /* If a value other than a jQuery object or a raw DOM element was passed in, default to null so that this option is ignored. */ } else { opts.container = null; } } else { /* If the window itself is being scrolled -- not a containing element -- perform a live scroll position lookup using the appropriate cached property names (which differ based on browser type). */ scrollPositionCurrent = Velocity.State.scrollAnchor[Velocity.State["scrollProperty" + scrollDirection]]; /* GET */ /* When scrolling the browser window, cache the alternate axis's current value since window.scrollTo() doesn't let us change only one value at a time. */ scrollPositionCurrentAlternate = Velocity.State.scrollAnchor[Velocity.State["scrollProperty" + (scrollDirection === "Left" ? "Top" : "Left")]]; /* GET */ /* Unlike $.position(), $.offset() values are relative to the browser window's true dimensions -- not merely its currently viewable area -- and therefore end values do not need to be compounded onto current values. */ scrollPositionEnd = $(element).offset()[scrollDirection.toLowerCase()] + scrollOffset; /* GET */ } /* Since there's only one format that scroll's associated tweensContainer can take, we create it manually. */ tweensContainer = { scroll: { rootPropertyValue: false, startValue: scrollPositionCurrent, currentValue: scrollPositionCurrent, endValue: scrollPositionEnd, unitType: "", easing: opts.easing, scrollData: { container: opts.container, direction: scrollDirection, alternateValue: scrollPositionCurrentAlternate } }, element: element }; if (Velocity.debug) console.log("tweensContainer (scroll): ", tweensContainer.scroll, element); /****************************************** Tween Data Construction (for Reverse) ******************************************/ /* Reverse acts like a "start" action in that a property map is animated toward. The only difference is that the property map used for reverse is the inverse of the map used in the previous call. Thus, we manipulate the previous call to construct our new map: use the previous map's end values as our new map's start values. Copy over all other data. */ /* Note: Reverse can be directly called via the "reverse" parameter, or it can be indirectly triggered via the loop option. (Loops are composed of multiple reverses.) */ /* Note: Reverse calls do not need to be consecutively chained onto a currently-animating element in order to operate on cached values; there is no harm to reverse being called on a potentially stale data cache since reverse's behavior is simply defined as reverting to the element's values as they were prior to the previous *Velocity* call. */ } else if (action === "reverse") { /* Abort if there is no prior animation data to reverse to. */ if (!Data(element).tweensContainer) { /* Dequeue the element so that this queue entry releases itself immediately, allowing subsequent queue entries to run. */ $.dequeue(element, opts.queue); return; } else { /********************* Options Parsing *********************/ /* If the element was hidden via the display option in the previous call, revert display to "auto" prior to reversal so that the element is visible again. */ if (Data(element).opts.display === "none") { Data(element).opts.display = "auto"; } if (Data(element).opts.visibility === "hidden") { Data(element).opts.visibility = "visible"; } /* If the loop option was set in the previous call, disable it so that "reverse" calls aren't recursively generated. Further, remove the previous call's callback options; typically, users do not want these to be refired. */ Data(element).opts.loop = false; Data(element).opts.begin = null; Data(element).opts.complete = null; /* Since we're extending an opts object that has already been extended with the defaults options object, we remove non-explicitly-defined properties that are auto-assigned values. */ if (!options.easing) { delete opts.easing; } if (!options.duration) { delete opts.duration; } /* The opts object used for reversal is an extension of the options object optionally passed into this reverse call plus the options used in the previous Velocity call. */ opts = $.extend({}, Data(element).opts, opts); /************************************* Tweens Container Reconstruction *************************************/ /* Create a deepy copy (indicated via the true flag) of the previous call's tweensContainer. */ var lastTweensContainer = $.extend(true, {}, Data(element).tweensContainer); /* Manipulate the previous tweensContainer by replacing its end values and currentValues with its start values. */ for (var lastTween in lastTweensContainer) { /* In addition to tween data, tweensContainers contain an element property that we ignore here. */ if (lastTween !== "element") { var lastStartValue = lastTweensContainer[lastTween].startValue; lastTweensContainer[lastTween].startValue = lastTweensContainer[lastTween].currentValue = lastTweensContainer[lastTween].endValue; lastTweensContainer[lastTween].endValue = lastStartValue; /* Easing is the only option that embeds into the individual tween data (since it can be defined on a per-property basis). Accordingly, every property's easing value must be updated when an options object is passed in with a reverse call. The side effect of this extensibility is that all per-property easing values are forcefully reset to the new value. */ if (!Type.isEmptyObject(options)) { lastTweensContainer[lastTween].easing = opts.easing; } if (Velocity.debug) console.log("reverse tweensContainer (" + lastTween + "): " + JSON.stringify(lastTweensContainer[lastTween]), element); } } tweensContainer = lastTweensContainer; } /***************************************** Tween Data Construction (for Start) *****************************************/ } else if (action === "start") { /************************* Value Transferring *************************/ /* If this queue entry follows a previous Velocity-initiated queue entry *and* if this entry was created while the element was in the process of being animated by Velocity, then this current call is safe to use the end values from the prior call as its start values. Velocity attempts to perform this value transfer process whenever possible in order to avoid requerying the DOM. */ /* If values aren't transferred from a prior call and start values were not forcefed by the user (more on this below), then the DOM is queried for the element's current values as a last resort. */ /* Note: Conversely, animation reversal (and looping) *always* perform inter-call value transfers; they never requery the DOM. */ var lastTweensContainer; /* The per-element isAnimating flag is used to indicate whether it's safe (i.e. the data isn't stale) to transfer over end values to use as start values. If it's set to true and there is a previous Velocity call to pull values from, do so. */ if (Data(element).tweensContainer && Data(element).isAnimating === true) { lastTweensContainer = Data(element).tweensContainer; } /*************************** Tween Data Calculation ***************************/ /* This function parses property data and defaults endValue, easing, and startValue as appropriate. */ /* Property map values can either take the form of 1) a single value representing the end value, or 2) an array in the form of [ endValue, [, easing] [, startValue] ]. The optional third parameter is a forcefed startValue to be used instead of querying the DOM for the element's current value. Read Velocity's docmentation to learn more about forcefeeding: VelocityJS.org/#forcefeeding */ function parsePropertyValue (valueData, skipResolvingEasing) { var endValue = undefined, easing = undefined, startValue = undefined; /* Handle the array format, which can be structured as one of three potential overloads: A) [ endValue, easing, startValue ], B) [ endValue, easing ], or C) [ endValue, startValue ] */ if (Type.isArray(valueData)) { /* endValue is always the first item in the array. Don't bother validating endValue's value now since the ensuing property cycling logic does that. */ endValue = valueData[0]; /* Two-item array format: If the second item is a number, function, or hex string, treat it as a start value since easings can only be non-hex strings or arrays. */ if ((!Type.isArray(valueData[1]) && /^[\d-]/.test(valueData[1])) || Type.isFunction(valueData[1]) || CSS.RegEx.isHex.test(valueData[1])) { startValue = valueData[1]; /* Two or three-item array: If the second item is a non-hex string or an array, treat it as an easing. */ } else if ((Type.isString(valueData[1]) && !CSS.RegEx.isHex.test(valueData[1])) || Type.isArray(valueData[1])) { easing = skipResolvingEasing ? valueData[1] : getEasing(valueData[1], opts.duration); /* Don't bother validating startValue's value now since the ensuing property cycling logic inherently does that. */ if (valueData[2] !== undefined) { startValue = valueData[2]; } } /* Handle the single-value format. */ } else { endValue = valueData; } /* Default to the call's easing if a per-property easing type was not defined. */ if (!skipResolvingEasing) { easing = easing || opts.easing; } /* If functions were passed in as values, pass the function the current element as its context, plus the element's index and the element set's size as arguments. Then, assign the returned value. */ if (Type.isFunction(endValue)) { endValue = endValue.call(element, elementsIndex, elementsLength); } if (Type.isFunction(startValue)) { startValue = startValue.call(element, elementsIndex, elementsLength); } /* Allow startValue to be left as undefined to indicate to the ensuing code that its value was not forcefed. */ return [ endValue || 0, easing, startValue ]; } /* Cycle through each property in the map, looking for shorthand color properties (e.g. "color" as opposed to "colorRed"). Inject the corresponding colorRed, colorGreen, and colorBlue RGB component tweens into the propertiesMap (which Velocity understands) and remove the shorthand property. */ $.each(propertiesMap, function(property, value) { /* Find shorthand color properties that have been passed a hex string. */ if (RegExp("^" + CSS.Lists.colors.join("$|^") + "$").test(property)) { /* Parse the value data for each shorthand. */ var valueData = parsePropertyValue(value, true), endValue = valueData[0], easing = valueData[1], startValue = valueData[2]; if (CSS.RegEx.isHex.test(endValue)) { /* Convert the hex strings into their RGB component arrays. */ var colorComponents = [ "Red", "Green", "Blue" ], endValueRGB = CSS.Values.hexToRgb(endValue), startValueRGB = startValue ? CSS.Values.hexToRgb(startValue) : undefined; /* Inject the RGB component tweens into propertiesMap. */ for (var i = 0; i < colorComponents.length; i++) { var dataArray = [ endValueRGB[i] ]; if (easing) { dataArray.push(easing); } if (startValueRGB !== undefined) { dataArray.push(startValueRGB[i]); } propertiesMap[property + colorComponents[i]] = dataArray; } /* Remove the intermediary shorthand property entry now that we've processed it. */ delete propertiesMap[property]; } } }); /* Create a tween out of each property, and append its associated data to tweensContainer. */ for (var property in propertiesMap) { /************************** Start Value Sourcing **************************/ /* Parse out endValue, easing, and startValue from the property's data. */ var valueData = parsePropertyValue(propertiesMap[property]), endValue = valueData[0], easing = valueData[1], startValue = valueData[2]; /* Now that the original property name's format has been used for the parsePropertyValue() lookup above, we force the property to its camelCase styling to normalize it for manipulation. */ property = CSS.Names.camelCase(property); /* In case this property is a hook, there are circumstances where we will intend to work on the hook's root property and not the hooked subproperty. */ var rootProperty = CSS.Hooks.getRoot(property), rootPropertyValue = false; /* Properties that are not supported by the browser (and do not have an associated normalization) will inherently produce no style changes when set, so they are skipped in order to decrease animation tick overhead. Property support is determined via prefixCheck(), which returns a false flag when no supported is detected. */ /* Note: Since SVG elements have some of their properties directly applied as HTML attributes, there is no way to check for their explicit browser support, and so we skip skip this check for them. */ if (!Data(element).isSVG && CSS.Names.prefixCheck(rootProperty)[1] === false && CSS.Normalizations.registered[rootProperty] === undefined) { if (Velocity.debug) console.log("Skipping [" + rootProperty + "] due to a lack of browser support."); continue; } /* If the display option is being set to a non-"none" (e.g. "block") and opacity (filter on IE<=8) is being animated to an endValue of non-zero, the user's intention is to fade in from invisible, thus we forcefeed opacity a startValue of 0 if its startValue hasn't already been sourced by value transferring or prior forcefeeding. */ if (((opts.display !== undefined && opts.display !== null && opts.display !== "none") || (opts.visibility !== undefined && opts.visibility !== "hidden")) && /opacity|filter/.test(property) && !startValue && endValue !== 0) { startValue = 0; } /* If values have been transferred from the previous Velocity call, extract the endValue and rootPropertyValue for all of the current call's properties that were *also* animated in the previous call. */ /* Note: Value transferring can optionally be disabled by the user via the _cacheValues option. */ if (opts._cacheValues && lastTweensContainer && lastTweensContainer[property]) { if (startValue === undefined) { startValue = lastTweensContainer[property].endValue + lastTweensContainer[property].unitType; } /* The previous call's rootPropertyValue is extracted from the element's data cache since that's the instance of rootPropertyValue that gets freshly updated by the tweening process, whereas the rootPropertyValue attached to the incoming lastTweensContainer is equal to the root property's value prior to any tweening. */ rootPropertyValue = Data(element).rootPropertyValueCache[rootProperty]; /* If values were not transferred from a previous Velocity call, query the DOM as needed. */ } else { /* Handle hooked properties. */ if (CSS.Hooks.registered[property]) { if (startValue === undefined) { rootPropertyValue = CSS.getPropertyValue(element, rootProperty); /* GET */ /* Note: The following getPropertyValue() call does not actually trigger a DOM query; getPropertyValue() will extract the hook from rootPropertyValue. */ startValue = CSS.getPropertyValue(element, property, rootPropertyValue); /* If startValue is already defined via forcefeeding, do not query the DOM for the root property's value; just grab rootProperty's zero-value template from CSS.Hooks. This overwrites the element's actual root property value (if one is set), but this is acceptable since the primary reason users forcefeed is to avoid DOM queries, and thus we likewise avoid querying the DOM for the root property's value. */ } else { /* Grab this hook's zero-value template, e.g. "0px 0px 0px black". */ rootPropertyValue = CSS.Hooks.templates[rootProperty][1]; } /* Handle non-hooked properties that haven't already been defined via forcefeeding. */ } else if (startValue === undefined) { startValue = CSS.getPropertyValue(element, property); /* GET */ } } /************************** Value Data Extraction **************************/ var separatedValue, endValueUnitType, startValueUnitType, operator = false; /* Separates a property value into its numeric value and its unit type. */ function separateValue (property, value) { var unitType, numericValue; numericValue = (value || "0") .toString() .toLowerCase() /* Match the unit type at the end of the value. */ .replace(/[%A-z]+$/, function(match) { /* Grab the unit type. */ unitType = match; /* Strip the unit type off of value. */ return ""; }); /* If no unit type was supplied, assign one that is appropriate for this property (e.g. "deg" for rotateZ or "px" for width). */ if (!unitType) { unitType = CSS.Values.getUnitType(property); } return [ numericValue, unitType ]; } /* Separate startValue. */ separatedValue = separateValue(property, startValue); startValue = separatedValue[0]; startValueUnitType = separatedValue[1]; /* Separate endValue, and extract a value operator (e.g. "+=", "-=") if one exists. */ separatedValue = separateValue(property, endValue); endValue = separatedValue[0].replace(/^([+-\/*])=/, function(match, subMatch) { operator = subMatch; /* Strip the operator off of the value. */ return ""; }); endValueUnitType = separatedValue[1]; /* Parse float values from endValue and startValue. Default to 0 if NaN is returned. */ startValue = parseFloat(startValue) || 0; endValue = parseFloat(endValue) || 0; /*************************************** Property-Specific Value Conversion ***************************************/ /* Custom support for properties that don't actually accept the % unit type, but where pollyfilling is trivial and relatively foolproof. */ if (endValueUnitType === "%") { /* A %-value fontSize/lineHeight is relative to the parent's fontSize (as opposed to the parent's dimensions), which is identical to the em unit's behavior, so we piggyback off of that. */ if (/^(fontSize|lineHeight)$/.test(property)) { /* Convert % into an em decimal value. */ endValue = endValue / 100; endValueUnitType = "em"; /* For scaleX and scaleY, convert the value into its decimal format and strip off the unit type. */ } else if (/^scale/.test(property)) { endValue = endValue / 100; endValueUnitType = ""; /* For RGB components, take the defined percentage of 255 and strip off the unit type. */ } else if (/(Red|Green|Blue)$/i.test(property)) { endValue = (endValue / 100) * 255; endValueUnitType = ""; } } /*************************** Unit Ratio Calculation ***************************/ /* When queried, the browser returns (most) CSS property values in pixels. Therefore, if an endValue with a unit type of %, em, or rem is animated toward, startValue must be converted from pixels into the same unit type as endValue in order for value manipulation logic (increment/decrement) to proceed. Further, if the startValue was forcefed or transferred from a previous call, startValue may also not be in pixels. Unit conversion logic therefore consists of two steps: 1) Calculating the ratio of %/em/rem/vh/vw relative to pixels 2) Converting startValue into the same unit of measurement as endValue based on these ratios. */ /* Unit conversion ratios are calculated by inserting a sibling node next to the target node, copying over its position property, setting values with the target unit type then comparing the returned pixel value. */ /* Note: Even if only one of these unit types is being animated, all unit ratios are calculated at once since the overhead of batching the SETs and GETs together upfront outweights the potential overhead of layout thrashing caused by re-querying for uncalculated ratios for subsequently-processed properties. */ /* Todo: Shift this logic into the calls' first tick instance so that it's synced with RAF. */ function calculateUnitRatios () { /************************ Same Ratio Checks ************************/ /* The properties below are used to determine whether the element differs sufficiently from this call's previously iterated element to also differ in its unit conversion ratios. If the properties match up with those of the prior element, the prior element's conversion ratios are used. Like most optimizations in Velocity, this is done to minimize DOM querying. */ var sameRatioIndicators = { myParent: element.parentNode || document.body, /* GET */ position: CSS.getPropertyValue(element, "position"), /* GET */ fontSize: CSS.getPropertyValue(element, "fontSize") /* GET */ }, /* Determine if the same % ratio can be used. % is based on the element's position value and its parent's width and height dimensions. */ samePercentRatio = ((sameRatioIndicators.position === callUnitConversionData.lastPosition) && (sameRatioIndicators.myParent === callUnitConversionData.lastParent)), /* Determine if the same em ratio can be used. em is relative to the element's fontSize. */ sameEmRatio = (sameRatioIndicators.fontSize === callUnitConversionData.lastFontSize); /* Store these ratio indicators call-wide for the next element to compare against. */ callUnitConversionData.lastParent = sameRatioIndicators.myParent; callUnitConversionData.lastPosition = sameRatioIndicators.position; callUnitConversionData.lastFontSize = sameRatioIndicators.fontSize; /*************************** Element-Specific Units ***************************/ /* Note: IE8 rounds to the nearest pixel when returning CSS values, thus we perform conversions using a measurement of 100 (instead of 1) to give our ratios a precision of at least 2 decimal values. */ var measurement = 100, unitRatios = {}; if (!sameEmRatio || !samePercentRatio) { var dummy = Data(element).isSVG ? document.createElementNS("http://www.w3.org/2000/svg", "rect") : document.createElement("div"); Velocity.init(dummy); sameRatioIndicators.myParent.appendChild(dummy); /* To accurately and consistently calculate conversion ratios, the element's cascaded overflow and box-sizing are stripped. Similarly, since width/height can be artificially constrained by their min-/max- equivalents, these are controlled for as well. */ /* Note: Overflow must be also be controlled for per-axis since the overflow property overwrites its per-axis values. */ $.each([ "overflow", "overflowX", "overflowY" ], function(i, property) { Velocity.CSS.setPropertyValue(dummy, property, "hidden"); }); Velocity.CSS.setPropertyValue(dummy, "position", sameRatioIndicators.position); Velocity.CSS.setPropertyValue(dummy, "fontSize", sameRatioIndicators.fontSize); Velocity.CSS.setPropertyValue(dummy, "boxSizing", "content-box"); /* width and height act as our proxy properties for measuring the horizontal and vertical % ratios. */ $.each([ "minWidth", "maxWidth", "width", "minHeight", "maxHeight", "height" ], function(i, property) { Velocity.CSS.setPropertyValue(dummy, property, measurement + "%"); }); /* paddingLeft arbitrarily acts as our proxy property for the em ratio. */ Velocity.CSS.setPropertyValue(dummy, "paddingLeft", measurement + "em"); /* Divide the returned value by the measurement to get the ratio between 1% and 1px. Default to 1 since working with 0 can produce Infinite. */ unitRatios.percentToPxWidth = callUnitConversionData.lastPercentToPxWidth = (parseFloat(CSS.getPropertyValue(dummy, "width", null, true)) || 1) / measurement; /* GET */ unitRatios.percentToPxHeight = callUnitConversionData.lastPercentToPxHeight = (parseFloat(CSS.getPropertyValue(dummy, "height", null, true)) || 1) / measurement; /* GET */ unitRatios.emToPx = callUnitConversionData.lastEmToPx = (parseFloat(CSS.getPropertyValue(dummy, "paddingLeft")) || 1) / measurement; /* GET */ sameRatioIndicators.myParent.removeChild(dummy); } else { unitRatios.emToPx = callUnitConversionData.lastEmToPx; unitRatios.percentToPxWidth = callUnitConversionData.lastPercentToPxWidth; unitRatios.percentToPxHeight = callUnitConversionData.lastPercentToPxHeight; } /*************************** Element-Agnostic Units ***************************/ /* Whereas % and em ratios are determined on a per-element basis, the rem unit only needs to be checked once per call since it's exclusively dependant upon document.body's fontSize. If this is the first time that calculateUnitRatios() is being run during this call, remToPx will still be set to its default value of null, so we calculate it now. */ if (callUnitConversionData.remToPx === null) { /* Default to browsers' default fontSize of 16px in the case of 0. */ callUnitConversionData.remToPx = parseFloat(CSS.getPropertyValue(document.body, "fontSize")) || 16; /* GET */ } /* Similarly, viewport units are %-relative to the window's inner dimensions. */ if (callUnitConversionData.vwToPx === null) { callUnitConversionData.vwToPx = parseFloat(window.innerWidth) / 100; /* GET */ callUnitConversionData.vhToPx = parseFloat(window.innerHeight) / 100; /* GET */ } unitRatios.remToPx = callUnitConversionData.remToPx; unitRatios.vwToPx = callUnitConversionData.vwToPx; unitRatios.vhToPx = callUnitConversionData.vhToPx; if (Velocity.debug >= 1) console.log("Unit ratios: " + JSON.stringify(unitRatios), element); return unitRatios; } /******************** Unit Conversion ********************/ /* The * and / operators, which are not passed in with an associated unit, inherently use startValue's unit. Skip value and unit conversion. */ if (/[\/*]/.test(operator)) { endValueUnitType = startValueUnitType; /* If startValue and endValue differ in unit type, convert startValue into the same unit type as endValue so that if endValueUnitType is a relative unit (%, em, rem), the values set during tweening will continue to be accurately relative even if the metrics they depend on are dynamically changing during the course of the animation. Conversely, if we always normalized into px and used px for setting values, the px ratio would become stale if the original unit being animated toward was relative and the underlying metrics change during the animation. */ /* Since 0 is 0 in any unit type, no conversion is necessary when startValue is 0 -- we just start at 0 with endValueUnitType. */ } else if ((startValueUnitType !== endValueUnitType) && startValue !== 0) { /* Unit conversion is also skipped when endValue is 0, but *startValueUnitType* must be used for tween values to remain accurate. */ /* Note: Skipping unit conversion here means that if endValueUnitType was originally a relative unit, the animation won't relatively match the underlying metrics if they change, but this is acceptable since we're animating toward invisibility instead of toward visibility, which remains past the point of the animation's completion. */ if (endValue === 0) { endValueUnitType = startValueUnitType; } else { /* By this point, we cannot avoid unit conversion (it's undesirable since it causes layout thrashing). If we haven't already, we trigger calculateUnitRatios(), which runs once per element per call. */ elementUnitConversionData = elementUnitConversionData || calculateUnitRatios(); /* The following RegEx matches CSS properties that have their % values measured relative to the x-axis. */ /* Note: W3C spec mandates that all of margin and padding's properties (even top and bottom) are %-relative to the *width* of the parent element. */ var axis = (/margin|padding|left|right|width|text|word|letter/i.test(property) || /X$/.test(property) || property === "x") ? "x" : "y"; /* In order to avoid generating n^2 bespoke conversion functions, unit conversion is a two-step process: 1) Convert startValue into pixels. 2) Convert this new pixel value into endValue's unit type. */ switch (startValueUnitType) { case "%": /* Note: translateX and translateY are the only properties that are %-relative to an element's own dimensions -- not its parent's dimensions. Velocity does not include a special conversion process to account for this behavior. Therefore, animating translateX/Y from a % value to a non-% value will produce an incorrect start value. Fortunately, this sort of cross-unit conversion is rarely done by users in practice. */ startValue *= (axis === "x" ? elementUnitConversionData.percentToPxWidth : elementUnitConversionData.percentToPxHeight); break; case "px": /* px acts as our midpoint in the unit conversion process; do nothing. */ break; default: startValue *= elementUnitConversionData[startValueUnitType + "ToPx"]; } /* Invert the px ratios to convert into to the target unit. */ switch (endValueUnitType) { case "%": startValue *= 1 / (axis === "x" ? elementUnitConversionData.percentToPxWidth : elementUnitConversionData.percentToPxHeight); break; case "px": /* startValue is already in px, do nothing; we're done. */ break; default: startValue *= 1 / elementUnitConversionData[endValueUnitType + "ToPx"]; } } } /********************* Relative Values *********************/ /* Operator logic must be performed last since it requires unit-normalized start and end values. */ /* Note: Relative *percent values* do not behave how most people think; while one would expect "+=50%" to increase the property 1.5x its current value, it in fact increases the percent units in absolute terms: 50 points is added on top of the current % value. */ switch (operator) { case "+": endValue = startValue + endValue; break; case "-": endValue = startValue - endValue; break; case "*": endValue = startValue * endValue; break; case "/": endValue = startValue / endValue; break; } /************************** tweensContainer Push **************************/ /* Construct the per-property tween object, and push it to the element's tweensContainer. */ tweensContainer[property] = { rootPropertyValue: rootPropertyValue, startValue: startValue, currentValue: startValue, endValue: endValue, unitType: endValueUnitType, easing: easing }; if (Velocity.debug) console.log("tweensContainer (" + property + "): " + JSON.stringify(tweensContainer[property]), element); } /* Along with its property data, store a reference to the element itself onto tweensContainer. */ tweensContainer.element = element; } /***************** Call Push *****************/ /* Note: tweensContainer can be empty if all of the properties in this call's property map were skipped due to not being supported by the browser. The element property is used for checking that the tweensContainer has been appended to. */ if (tweensContainer.element) { /* Apply the "velocity-animating" indicator class. */ CSS.Values.addClass(element, "velocity-animating"); /* The call array houses the tweensContainers for each element being animated in the current call. */ call.push(tweensContainer); /* Store the tweensContainer and options if we're working on the default effects queue, so that they can be used by the reverse command. */ if (opts.queue === "") { Data(element).tweensContainer = tweensContainer; Data(element).opts = opts; } /* Switch on the element's animating flag. */ Data(element).isAnimating = true; /* Once the final element in this call's element set has been processed, push the call array onto Velocity.State.calls for the animation tick to immediately begin processing. */ if (elementsIndex === elementsLength - 1) { /* To speed up iterating over this array, it is compacted (falsey items -- calls that have completed -- are removed) when its length has ballooned to a point that can impact tick performance. This only becomes necessary when animation has been continuous with many elements over a long period of time; whenever all active calls are completed, completeCall() clears Velocity.State.calls. */ if (Velocity.State.calls.length > 10000) { Velocity.State.calls = compactSparseArray(Velocity.State.calls); } /* Add the current call plus its associated metadata (the element set and the call's options) onto the global call container. Anything on this call container is subjected to tick() processing. */ Velocity.State.calls.push([ call, elements, opts, null, promiseData.resolver ]); /* If the animation tick isn't running, start it. (Velocity shuts it off when there are no active calls to process.) */ if (Velocity.State.isTicking === false) { Velocity.State.isTicking = true; /* Start the tick loop. */ tick(); } } else { elementsIndex++; } } } /* When the queue option is set to false, the call skips the element's queue and fires immediately. */ if (opts.queue === false) { /* Since this buildQueue call doesn't respect the element's existing queue (which is where a delay option would have been appended), we manually inject the delay property here with an explicit setTimeout. */ if (opts.delay) { setTimeout(buildQueue, opts.delay); } else { buildQueue(); } /* Otherwise, the call undergoes element queueing as normal. */ /* Note: To interoperate with jQuery, Velocity uses jQuery's own $.queue() stack for queuing logic. */ } else { $.queue(element, opts.queue, function(next, clearQueue) { /* If the clearQueue flag was passed in by the stop command, resolve this call's promise. (Promises can only be resolved once, so it's fine if this is repeatedly triggered for each element in the associated call.) */ if (clearQueue === true) { if (promiseData.promise) { promiseData.resolver(elements); } /* Do not continue with animation queueing. */ return true; } /* This flag indicates to the upcoming completeCall() function that this queue entry was initiated by Velocity. See completeCall() for further details. */ Velocity.velocityQueueEntryFlag = true; buildQueue(next); }); } /********************* Auto-Dequeuing *********************/ /* As per jQuery's $.queue() behavior, to fire the first non-custom-queue entry on an element, the element must be dequeued if its queue stack consists *solely* of the current call. (This can be determined by checking for the "inprogress" item that jQuery prepends to active queue stack arrays.) Regardless, whenever the element's queue is further appended with additional items -- including $.delay()'s or even $.animate() calls, the queue's first entry is automatically fired. This behavior contrasts that of custom queues, which never auto-fire. */ /* Note: When an element set is being subjected to a non-parallel Velocity call, the animation will not begin until each one of the elements in the set has reached the end of its individually pre-existing queue chain. */ /* Note: Unfortunately, most people don't fully grasp jQuery's powerful, yet quirky, $.queue() function. Lean more here: http://stackoverflow.com/questions/1058158/can-somebody-explain-jquery-queue-to-me */ if ((opts.queue === "" || opts.queue === "fx") && $.queue(element)[0] !== "inprogress") { $.dequeue(element); } } /************************** Element Set Iteration **************************/ /* If the "nodeType" property exists on the elements variable, we're animating a single element. Place it in an array so that $.each() can iterate over it. */ $.each(elements, function(i, element) { /* Ensure each element in a set has a nodeType (is a real element) to avoid throwing errors. */ if (Type.isNode(element)) { processElement.call(element); } }); /****************** Option: Loop ******************/ /* The loop option accepts an integer indicating how many times the element should loop between the values in the current call's properties map and the element's property values prior to this call. */ /* Note: The loop option's logic is performed here -- after element processing -- because the current call needs to undergo its queue insertion prior to the loop option generating its series of constituent "reverse" calls, which chain after the current call. Two reverse calls (two "alternations") constitute one loop. */ var opts = $.extend({}, Velocity.defaults, options), reverseCallsCount; opts.loop = parseInt(opts.loop); reverseCallsCount = (opts.loop * 2) - 1; if (opts.loop) { /* Double the loop count to convert it into its appropriate number of "reverse" calls. Subtract 1 from the resulting value since the current call is included in the total alternation count. */ for (var x = 0; x < reverseCallsCount; x++) { /* Since the logic for the reverse action occurs inside Queueing and therefore this call's options object isn't parsed until then as well, the current call's delay option must be explicitly passed into the reverse call so that the delay logic that occurs inside *Pre-Queueing* can process it. */ var reverseOptions = { delay: opts.delay, progress: opts.progress }; /* If a complete callback was passed into this call, transfer it to the loop redirect's final "reverse" call so that it's triggered when the entire redirect is complete (and not when the very first animation is complete). */ if (x === reverseCallsCount - 1) { reverseOptions.display = opts.display; reverseOptions.visibility = opts.visibility; reverseOptions.complete = opts.complete; } animate(elements, "reverse", reverseOptions); } } /*************** Chaining ***************/ /* Return the elements back to the call chain, with wrapped elements taking precedence in case Velocity was called via the $.fn. extension. */ return getChain(); }; /* Turn Velocity into the animation function, extended with the pre-existing Velocity object. */ Velocity = $.extend(animate, Velocity); /* For legacy support, also expose the literal animate method. */ Velocity.animate = animate; /************** Timing **************/ /* Ticker function. */ var ticker = window.requestAnimationFrame || rAFShim; /* Inactive browser tabs pause rAF, which results in all active animations immediately sprinting to their completion states when the tab refocuses. To get around this, we dynamically switch rAF to setTimeout (which the browser *doesn't* pause) when the tab loses focus. We skip this for mobile devices to avoid wasting battery power on inactive tabs. */ /* Note: Tab focus detection doesn't work on older versions of IE, but that's okay since they don't support rAF to begin with. */ if (!Velocity.State.isMobile && document.hidden !== undefined) { document.addEventListener("visibilitychange", function() { /* Reassign the rAF function (which the global tick() function uses) based on the tab's focus state. */ if (document.hidden) { ticker = function(callback) { /* The tick function needs a truthy first argument in order to pass its internal timestamp check. */ return setTimeout(function() { callback(true) }, 16); }; /* The rAF loop has been paused by the browser, so we manually restart the tick. */ tick(); } else { ticker = window.requestAnimationFrame || rAFShim; } }); } /************ Tick ************/ /* Note: All calls to Velocity are pushed to the Velocity.State.calls array, which is fully iterated through upon each tick. */ function tick (timestamp) { /* An empty timestamp argument indicates that this is the first tick occurence since ticking was turned on. We leverage this metadata to fully ignore the first tick pass since RAF's initial pass is fired whenever the browser's next tick sync time occurs, which results in the first elements subjected to Velocity calls being animated out of sync with any elements animated immediately thereafter. In short, we ignore the first RAF tick pass so that elements being immediately consecutively animated -- instead of simultaneously animated by the same Velocity call -- are properly batched into the same initial RAF tick and consequently remain in sync thereafter. */ if (timestamp) { /* We ignore RAF's high resolution timestamp since it can be significantly offset when the browser is under high stress; we opt for choppiness over allowing the browser to drop huge chunks of frames. */ var timeCurrent = (new Date).getTime(); /******************** Call Iteration ********************/ /* Iterate through each active call. */ for (var i = 0, callsLength = Velocity.State.calls.length; i < callsLength; i++) { /* When a Velocity call is completed, its Velocity.State.calls entry is set to false. Continue on to the next call. */ if (!Velocity.State.calls[i]) { continue; } /************************ Call-Wide Variables ************************/ var callContainer = Velocity.State.calls[i], call = callContainer[0], opts = callContainer[2], timeStart = callContainer[3], firstTick = !!timeStart; /* If timeStart is undefined, then this is the first time that this call has been processed by tick(). We assign timeStart now so that its value is as close to the real animation start time as possible. (Conversely, had timeStart been defined when this call was added to Velocity.State.calls, the delay between that time and now would cause the first few frames of the tween to be skipped since percentComplete is calculated relative to timeStart.) */ /* Further, subtract 16ms (the approximate resolution of RAF) from the current time value so that the first tick iteration isn't wasted by animating at 0% tween completion, which would produce the same style value as the element's current value. */ if (!timeStart) { timeStart = Velocity.State.calls[i][3] = timeCurrent - 16; } /* The tween's completion percentage is relative to the tween's start time, not the tween's start value (which would result in unpredictable tween durations since JavaScript's timers are not particularly accurate). Accordingly, we ensure that percentComplete does not exceed 1. */ var percentComplete = Math.min((timeCurrent - timeStart) / opts.duration, 1); /********************** Element Iteration **********************/ /* For every call, iterate through each of the elements in its set. */ for (var j = 0, callLength = call.length; j < callLength; j++) { var tweensContainer = call[j], element = tweensContainer.element; /* Check to see if this element has been deleted midway through the animation by checking for the continued existence of its data cache. If it's gone, skip animating this element. */ if (!Data(element)) { continue; } var transformPropertyExists = false; /********************************** Display & Visibility Toggling **********************************/ /* If the display option is set to non-"none", set it upfront so that the element can become visible before tweening begins. (Otherwise, display's "none" value is set in completeCall() once the animation has completed.) */ if (opts.display !== undefined && opts.display !== null && opts.display !== "none") { if (opts.display === "flex") { var flexValues = [ "-webkit-box", "-moz-box", "-ms-flexbox", "-webkit-flex" ]; $.each(flexValues, function(i, flexValue) { CSS.setPropertyValue(element, "display", flexValue); }); } CSS.setPropertyValue(element, "display", opts.display); } /* Same goes with the visibility option, but its "none" equivalent is "hidden". */ if (opts.visibility !== undefined && opts.visibility !== "hidden") { CSS.setPropertyValue(element, "visibility", opts.visibility); } /************************ Property Iteration ************************/ /* For every element, iterate through each property. */ for (var property in tweensContainer) { /* Note: In addition to property tween data, tweensContainer contains a reference to its associated element. */ if (property !== "element") { var tween = tweensContainer[property], currentValue, /* Easing can either be a pre-genereated function or a string that references a pre-registered easing on the Velocity.Easings object. In either case, return the appropriate easing *function*. */ easing = Type.isString(tween.easing) ? Velocity.Easings[tween.easing] : tween.easing; /****************************** Current Value Calculation ******************************/ /* If this is the last tick pass (if we've reached 100% completion for this tween), ensure that currentValue is explicitly set to its target endValue so that it's not subjected to any rounding. */ if (percentComplete === 1) { currentValue = tween.endValue; /* Otherwise, calculate currentValue based on the current delta from startValue. */ } else { currentValue = tween.startValue + ((tween.endValue - tween.startValue) * easing(percentComplete)); /* If no value change is occurring, don't proceed with DOM updating. */ if (!firstTick && (currentValue === tween.currentValue)) { continue; } } tween.currentValue = currentValue; /****************** Hooks: Part I ******************/ /* For hooked properties, the newly-updated rootPropertyValueCache is cached onto the element so that it can be used for subsequent hooks in this call that are associated with the same root property. If we didn't cache the updated rootPropertyValue, each subsequent update to the root property in this tick pass would reset the previous hook's updates to rootPropertyValue prior to injection. A nice performance byproduct of rootPropertyValue caching is that subsequently chained animations using the same hookRoot but a different hook can use this cached rootPropertyValue. */ if (CSS.Hooks.registered[property]) { var hookRoot = CSS.Hooks.getRoot(property), rootPropertyValueCache = Data(element).rootPropertyValueCache[hookRoot]; if (rootPropertyValueCache) { tween.rootPropertyValue = rootPropertyValueCache; } } /***************** DOM Update *****************/ /* setPropertyValue() returns an array of the property name and property value post any normalization that may have been performed. */ /* Note: To solve an IE<=8 positioning bug, the unit type is dropped when setting a property value of 0. */ var adjustedSetData = CSS.setPropertyValue(element, /* SET */ property, tween.currentValue + (parseFloat(currentValue) === 0 ? "" : tween.unitType), tween.rootPropertyValue, tween.scrollData); /******************* Hooks: Part II *******************/ /* Now that we have the hook's updated rootPropertyValue (the post-processed value provided by adjustedSetData), cache it onto the element. */ if (CSS.Hooks.registered[property]) { /* Since adjustedSetData contains normalized data ready for DOM updating, the rootPropertyValue needs to be re-extracted from its normalized form. ?? */ if (CSS.Normalizations.registered[hookRoot]) { Data(element).rootPropertyValueCache[hookRoot] = CSS.Normalizations.registered[hookRoot]("extract", null, adjustedSetData[1]); } else { Data(element).rootPropertyValueCache[hookRoot] = adjustedSetData[1]; } } /*************** Transforms ***************/ /* Flag whether a transform property is being animated so that flushTransformCache() can be triggered once this tick pass is complete. */ if (adjustedSetData[0] === "transform") { transformPropertyExists = true; } } } /**************** mobileHA ****************/ /* If mobileHA is enabled, set the translate3d transform to null to force hardware acceleration. It's safe to override this property since Velocity doesn't actually support its animation (hooks are used in its place). */ if (opts.mobileHA) { /* Don't set the null transform hack if we've already done so. */ if (Data(element).transformCache.translate3d === undefined) { /* All entries on the transformCache object are later concatenated into a single transform string via flushTransformCache(). */ Data(element).transformCache.translate3d = "(0px, 0px, 0px)"; transformPropertyExists = true; } } if (transformPropertyExists) { CSS.flushTransformCache(element); } } /* The non-"none" display value is only applied to an element once -- when its associated call is first ticked through. Accordingly, it's set to false so that it isn't re-processed by this call in the next tick. */ if (opts.display !== undefined && opts.display !== "none") { Velocity.State.calls[i][2].display = false; } if (opts.visibility !== undefined && opts.visibility !== "hidden") { Velocity.State.calls[i][2].visibility = false; } /* Pass the elements and the timing data (percentComplete, msRemaining, and timeStart) into the progress callback. */ if (opts.progress) { opts.progress.call(callContainer[1], callContainer[1], percentComplete, Math.max(0, (timeStart + opts.duration) - timeCurrent), timeStart); } /* If this call has finished tweening, pass its index to completeCall() to handle call cleanup. */ if (percentComplete === 1) { completeCall(i); } } } /* Note: completeCall() sets the isTicking flag to false when the last call on Velocity.State.calls has completed. */ if (Velocity.State.isTicking) { ticker(tick); } } /********************** Call Completion **********************/ /* Note: Unlike tick(), which processes all active calls at once, call completion is handled on a per-call basis. */ function completeCall (callIndex, isStopped) { /* Ensure the call exists. */ if (!Velocity.State.calls[callIndex]) { return false; } /* Pull the metadata from the call. */ var call = Velocity.State.calls[callIndex][0], elements = Velocity.State.calls[callIndex][1], opts = Velocity.State.calls[callIndex][2], resolver = Velocity.State.calls[callIndex][4]; var remainingCallsExist = false; /************************* Element Finalization *************************/ for (var i = 0, callLength = call.length; i < callLength; i++) { var element = call[i].element; /* If the user set display to "none" (intending to hide the element), set it now that the animation has completed. */ /* Note: display:none isn't set when calls are manually stopped (via Velocity("stop"). */ /* Note: Display gets ignored with "reverse" calls and infinite loops, since this behavior would be undesirable. */ if (!isStopped && !opts.loop) { if (opts.display === "none") { CSS.setPropertyValue(element, "display", opts.display); } if (opts.visibility === "hidden") { CSS.setPropertyValue(element, "visibility", opts.visibility); } } /* If the element's queue is empty (if only the "inprogress" item is left at position 0) or if its queue is about to run a non-Velocity-initiated entry, turn off the isAnimating flag. A non-Velocity-initiatied queue entry's logic might alter an element's CSS values and thereby cause Velocity's cached value data to go stale. To detect if a queue entry was initiated by Velocity, we check for the existence of our special Velocity.queueEntryFlag declaration, which minifiers won't rename since the flag is assigned to jQuery's global $ object and thus exists out of Velocity's own scope. */ if (opts.loop !== true && ($.queue(element)[1] === undefined || !/\.velocityQueueEntryFlag/i.test($.queue(element)[1]))) { /* The element may have been deleted. Ensure that its data cache still exists before acting on it. */ if (Data(element)) { Data(element).isAnimating = false; /* Clear the element's rootPropertyValueCache, which will become stale. */ Data(element).rootPropertyValueCache = {}; var transformHAPropertyExists = false; /* If any 3D transform subproperty is at its default value (regardless of unit type), remove it. */ $.each(CSS.Lists.transforms3D, function(i, transformName) { var defaultValue = /^scale/.test(transformName) ? 1 : 0, currentValue = Data(element).transformCache[transformName]; if (Data(element).transformCache[transformName] !== undefined && new RegExp("^\\(" + defaultValue + "[^.]").test(currentValue)) { transformHAPropertyExists = true; delete Data(element).transformCache[transformName]; } }); /* Mobile devices have hardware acceleration removed at the end of the animation in order to avoid hogging the GPU's memory. */ if (opts.mobileHA) { transformHAPropertyExists = true; delete Data(element).transformCache.translate3d; } /* Flush the subproperty removals to the DOM. */ if (transformHAPropertyExists) { CSS.flushTransformCache(element); } /* Remove the "velocity-animating" indicator class. */ CSS.Values.removeClass(element, "velocity-animating"); } } /********************* Option: Complete *********************/ /* Complete is fired once per call (not once per element) and is passed the full raw DOM element set as both its context and its first argument. */ /* Note: Callbacks aren't fired when calls are manually stopped (via Velocity("stop"). */ if (!isStopped && opts.complete && !opts.loop && (i === callLength - 1)) { /* We throw callbacks in a setTimeout so that thrown errors don't halt the execution of Velocity itself. */ try { opts.complete.call(elements, elements); } catch (error) { setTimeout(function() { throw error; }, 1); } } /********************** Promise Resolving **********************/ /* Note: Infinite loops don't return promises. */ if (resolver && opts.loop !== true) { resolver(elements); } /**************************** Option: Loop (Infinite) ****************************/ if (opts.loop === true && !isStopped) { /* If a rotateX/Y/Z property is being animated to 360 deg with loop:true, swap tween start/end values to enable continuous iterative rotation looping. (Otherise, the element would just rotate back and forth.) */ $.each(Data(element).tweensContainer, function(propertyName, tweenContainer) { if (/^rotate/.test(propertyName) && parseFloat(tweenContainer.endValue) === 360) { tweenContainer.endValue = 0; tweenContainer.startValue = 360; } }); Velocity(element, "reverse", { loop: true, delay: opts.delay }); } /*************** Dequeueing ***************/ /* Fire the next call in the queue so long as this call's queue wasn't set to false (to trigger a parallel animation), which would have already caused the next call to fire. Note: Even if the end of the animation queue has been reached, $.dequeue() must still be called in order to completely clear jQuery's animation queue. */ if (opts.queue !== false) { $.dequeue(element, opts.queue); } } /************************ Calls Array Cleanup ************************/ /* Since this call is complete, set it to false so that the rAF tick skips it. This array is later compacted via compactSparseArray(). (For performance reasons, the call is set to false instead of being deleted from the array: http://www.html5rocks.com/en/tutorials/speed/v8/) */ Velocity.State.calls[callIndex] = false; /* Iterate through the calls array to determine if this was the final in-progress animation. If so, set a flag to end ticking and clear the calls array. */ for (var j = 0, callsLength = Velocity.State.calls.length; j < callsLength; j++) { if (Velocity.State.calls[j] !== false) { remainingCallsExist = true; break; } } if (remainingCallsExist === false) { /* tick() will detect this flag upon its next iteration and subsequently turn itself off. */ Velocity.State.isTicking = false; /* Clear the calls array so that its length is reset. */ delete Velocity.State.calls; Velocity.State.calls = []; } } /****************** Frameworks ******************/ /* Both jQuery and Zepto allow their $.fn object to be extended to allow wrapped elements to be subjected to plugin calls. If either framework is loaded, register a "velocity" extension pointing to Velocity's core animate() method. Velocity also registers itself onto a global container (window.jQuery || window.Zepto || window) so that certain features are accessible beyond just a per-element scope. This master object contains an .animate() method, which is later assigned to $.fn (if jQuery or Zepto are present). Accordingly, Velocity can both act on wrapped DOM elements and stand alone for targeting raw DOM elements. */ global.Velocity = Velocity; if (global !== window) { /* Assign the element function to Velocity's core animate() method. */ global.fn.velocity = animate; /* Assign the object function's defaults to Velocity's global defaults object. */ global.fn.velocity.defaults = Velocity.defaults; } /*********************** Packaged Redirects ***********************/ /* slideUp, slideDown */ $.each([ "Down", "Up" ], function(i, direction) { Velocity.Redirects["slide" + direction] = function (element, options, elementsIndex, elementsSize, elements, promiseData) { var opts = $.extend({}, options), begin = opts.begin, complete = opts.complete, computedValues = { height: "", marginTop: "", marginBottom: "", paddingTop: "", paddingBottom: "" }, inlineValues = {}; if (opts.display === undefined) { /* Show the element before slideDown begins and hide the element after slideUp completes. */ /* Note: Inline elements cannot have dimensions animated, so they're reverted to inline-block. */ opts.display = (direction === "Down" ? (Velocity.CSS.Values.getDisplayType(element) === "inline" ? "inline-block" : "block") : "none"); } opts.begin = function() { /* If the user passed in a begin callback, fire it now. */ begin && begin.call(elements, elements); /* Cache the elements' original vertical dimensional property values so that we can animate back to them. */ for (var property in computedValues) { /* Cache all inline values, we reset to upon animation completion. */ inlineValues[property] = element.style[property]; /* For slideDown, use forcefeeding to animate all vertical properties from 0. For slideUp, use forcefeeding to start from computed values and animate down to 0. */ var propertyValue = Velocity.CSS.getPropertyValue(element, property); computedValues[property] = (direction === "Down") ? [ propertyValue, 0 ] : [ 0, propertyValue ]; } /* Force vertical overflow content to clip so that sliding works as expected. */ inlineValues.overflow = element.style.overflow; element.style.overflow = "hidden"; } opts.complete = function() { /* Reset element to its pre-slide inline values once its slide animation is complete. */ for (var property in inlineValues) { element.style[property] = inlineValues[property]; } /* If the user passed in a complete callback, fire it now. */ complete && complete.call(elements, elements); promiseData && promiseData.resolver(elements); }; Velocity(element, computedValues, opts); }; }); /* fadeIn, fadeOut */ $.each([ "In", "Out" ], function(i, direction) { Velocity.Redirects["fade" + direction] = function (element, options, elementsIndex, elementsSize, elements, promiseData) { var opts = $.extend({}, options), propertiesMap = { opacity: (direction === "In") ? 1 : 0 }, originalComplete = opts.complete; /* Since redirects are triggered individually for each element in the animated set, avoid repeatedly triggering callbacks by firing them only when the final element has been reached. */ if (elementsIndex !== elementsSize - 1) { opts.complete = opts.begin = null; } else { opts.complete = function() { if (originalComplete) { originalComplete.call(elements, elements); } promiseData && promiseData.resolver(elements); } } /* If a display was passed in, use it. Otherwise, default to "none" for fadeOut or the element-specific default for fadeIn. */ /* Note: We allow users to pass in "null" to skip display setting altogether. */ if (opts.display === undefined) { opts.display = (direction === "In" ? "auto" : "none"); } Velocity(this, propertiesMap, opts); }; }); return Velocity; }((window.jQuery || window.Zepto || window), window, document); })); /****************** Known Issues ******************/ /* The CSS spec mandates that the translateX/Y/Z transforms are %-relative to the element itself -- not its parent. Velocity, however, doesn't make this distinction. Thus, converting to or from the % unit with these subproperties will produce an inaccurate conversion value. The same issue exists with the cx/cy attributes of SVG circles and ellipses. */; (function(A){$.WOPOP_EFFECTS={};$.WOPOP_EFFECTS["fromleft"]=function(H,J){var L=parseInt($(H).css("left"))||0;var I=$.WOPOP_EFFECTS._parseNum(J["delay"],1);var K=$.WOPOP_EFFECTS._parseNum(J["duration"],1);C(H).done(function(M){$(M).css("left",0-$(M).width());M.velocity({left:L+"px"},{delay:(I*1000),duration:(K*1000),display:"block",easing:"ease",complete:D(J)})})};$.WOPOP_EFFECTS["frombottom"]=function(H,J){var K=parseInt($(H).css("top"))||0;var L=$.WOPOP_EFFECTS._parseNum(J["delay"],1);var M=$.WOPOP_EFFECTS._parseNum(J["duration"],1);if(!$.wismobile||$.WOPOP_EFFECTS._isEditMode()){var I=$("#scroll_container")}else{var I=$(A)}C(H).done(function(N){$(N).css("top",I.scrollTop()+I.height()+$(N).height());N.velocity({top:K+"px"},{delay:(L*1000),duration:(M*1000),display:"block",easing:"ease",complete:D(J)})})};$.WOPOP_EFFECTS["fromright"]=function(H,K){var M=parseInt($(H).css("left"))||0;var I=$.WOPOP_EFFECTS._parseNum(K["delay"],1);var L=$.WOPOP_EFFECTS._parseNum(K["duration"],1);if(!$.wismobile||$.WOPOP_EFFECTS._isEditMode()){var J=$("#scroll_container")}else{var J=$(A)}C(H).done(function(N){$(N).css("left",J.width()-$(N).width());N.velocity({left:M+"px"},{delay:(I*1000),duration:(L*1000),display:"block",easing:"ease",complete:D(K)})})};$.WOPOP_EFFECTS["fromtop"]=function(H,J){var K=parseInt($(H).css("top"))||0;var L=$.WOPOP_EFFECTS._parseNum(J["delay"],1);var M=$.WOPOP_EFFECTS._parseNum(J["duration"],1);if(!$.wismobile||$.WOPOP_EFFECTS._isEditMode()){var I=$("#scroll_container")}else{var I=$(A)}C(H).done(function(N){$(N).css("top",I.scrollTop()-$(N).height());N.velocity({top:K+"px"},{delay:(L*1000),duration:(M*1000),display:"block",easing:"ease",complete:D(J)})})};$.WOPOP_EFFECTS["fade"]=function(H,J){var I=parseInt($(H).css("opacity"))||1;var L=$.WOPOP_EFFECTS._parseNum(J["delay"],1);var K=$.WOPOP_EFFECTS._parseNum(J["duration"],1);C(H).done(function(M){$(M).css("opacity",0);M.velocity({opacity:I},{delay:(L*1000),duration:(K*1000),display:"block",easing:"ease-out",complete:D(J)})})};$.WOPOP_EFFECTS["rotation"]=function(H,I){var K=$.WOPOP_EFFECTS._parseNum(I["delay"],1);var J=$.WOPOP_EFFECTS._parseNum(I["duration"],1);$.Velocity.hook($(H),"rotateY","180deg");$(H).show();C(H).done(function(L){L.velocity({rotateY:["0deg","180deg"]},{delay:(K*1000),duration:(J*1000),display:"block",easing:"ease",complete:D(I)})})};$.WOPOP_EFFECTS["rotation2d"]=function(H,I){var K=$.WOPOP_EFFECTS._parseNum(I["delay"],1);var J=$.WOPOP_EFFECTS._parseNum(I["duration"],1);$(H).show();C(H).done(function(L){L.velocity({rotateZ:["360deg","0deg"]},{delay:(K*1000),duration:(J*1000),display:"block",easing:"linear"}).velocity({rotateZ:["360deg","0deg"]},{delay:0,duration:(J*1000),display:"block",loop:true,easing:"linear",complete:D(I)})})};$.WOPOP_EFFECTS["bounceIn"]=function(H,I){var K=$.WOPOP_EFFECTS._parseNum(I["delay"],1);var J=$.WOPOP_EFFECTS._parseNum(I["duration"],1);$.Velocity.hook($(H),"scale","0.3");$(H).css("opacity",0);C(H).done(function(L){L.velocity({scale:[1.05,0.3],opacity:[1,0]},{delay:(K*1000),duration:(J*333),display:"block"}).velocity({scale:[0.7,1.05]},{delay:0,duration:(J*333),display:"block"}).velocity({scale:[1,0.7]},{delay:0,duration:(J*333),display:"block",complete:D(I)})})};$.WOPOP_EFFECTS["big2small"]=function(H,I){var K=$.WOPOP_EFFECTS._parseNum(I["delay"],1);var J=$.WOPOP_EFFECTS._parseNum(I["duration"],1);$.Velocity.hook($(H),"scale","2");C(H).done(function(L){L.velocity({scale:[1,2],opacity:[1,0]},{delay:(K*1000),duration:(J*1000),display:"block",easing:"ease-in",complete:D(I)})})};$.WOPOP_EFFECTS["small2big"]=function(H,I){var K=$.WOPOP_EFFECTS._parseNum(I["delay"],1);var J=$.WOPOP_EFFECTS._parseNum(I["duration"],1);$.Velocity.hook($(H),"scale","0.5");C(H).done(function(L){L.velocity({scale:[1,0.5],opacity:[1,0]},{delay:(K*1000),duration:(J*1000),display:"block",easing:"ease-in",complete:D(I)})})};$.WOPOP_EFFECTS["fadeFromLeft"]=function(H,K){var M=parseInt($(H).css("left"))||0;var I=parseInt($(H).css("opacity"))||1;var J=$.WOPOP_EFFECTS._parseNum(K["delay"],1);var L=$.WOPOP_EFFECTS._parseNum(K["duration"],1);C(H).done(function(N){$(N).css("left",0-$(N).width());$(N).css("opacity",0);N.velocity({left:M+"px",opacity:I},{delay:(J*1000),duration:(L*1000),display:"block",easing:"ease",complete:D(K)})})};$.WOPOP_EFFECTS["fadeFromBottom"]=function(H,K){var L=parseInt($(H).css("top"))||0;var I=parseInt($(H).css("opacity"))||1;var M=$.WOPOP_EFFECTS._parseNum(K["delay"],1);var N=$.WOPOP_EFFECTS._parseNum(K["duration"],1);if(!$.wismobile||$.WOPOP_EFFECTS._isEditMode()){var J=$("#scroll_container")}else{var J=$(A)}C(H).done(function(O){$(O).css("top",J.scrollTop()+J.height()+$(O).height());$(O).css("opacity",0);O.velocity({top:L+"px",opacity:I},{delay:(M*1000),duration:(N*1000),display:"block",easing:"ease",complete:D(K)})})};$.WOPOP_EFFECTS["fadeFromRight"]=function(H,L){var N=parseInt($(H).css("left"))||0;var I=parseInt($(H).css("opacity"))||1;var K=$.WOPOP_EFFECTS._parseNum(L["delay"],1);var M=$.WOPOP_EFFECTS._parseNum(L["duration"],1);if(!$.wismobile||$.WOPOP_EFFECTS._isEditMode()){var J=$("#scroll_container")}else{var J=$(A)}C(H).done(function(O){$(O).css("left",J.width()-$(O).width());O.velocity({left:N+"px",opacity:I},{delay:(K*1000),duration:(M*1000),display:"block",easing:"ease",complete:D(L)})})};$.WOPOP_EFFECTS["fadeFromTop"]=function(H,K){var L=parseInt($(H).css("top"))||0;var I=parseInt($(H).css("opacity"))||1;var M=$.WOPOP_EFFECTS._parseNum(K["delay"],1);var N=$.WOPOP_EFFECTS._parseNum(K["duration"],1);if(!$.wismobile||$.WOPOP_EFFECTS._isEditMode()){var J=$("#scroll_container")}else{var J=$(A)}C(H).done(function(O){$(O).css("top",J.scrollTop()-$(O).height());O.velocity({top:L+"px",opacity:I},{delay:(M*1000),duration:(N*1000),display:"block",easing:"ease",complete:D(K)})})};$.WOPOP_EFFECTS["light"]=function(H,I){var K=$.WOPOP_EFFECTS._parseNum(I["delay"],1);var J=$.WOPOP_EFFECTS._parseNum(I["duration"],1);C(H).done(function(L){L.velocity({opacity:1},{delay:(K*1000),duration:(J*500),display:"block",easing:"ease-in-out"}).velocity({opacity:[0,1]},{delay:0,duration:(J*500),display:"block",loop:true,easing:"ease-in-out",complete:D(I)})})};function D(H){return function(){var I=$(this);if(I.data("wopop_effect_oristyle")){I.attr("style",I.data("wopop_effect_oristyle")).show();I.removeData("wopop_effect_oristyle")}I.trigger("effect_complete");I.removeClass("now_effecting")}}$.fn.showEffects=function(I,J){$.Velocity.defaults.mobileHA=false;var K=$(".fullpage_alllist");var H=!($.browser.msie&&$.browser.version<9);if(!K.length||I){return this.each(function(){var L=$(this);var M=J;if(!(M&&M.effect)){M=L.data("wopop_effects")}if(M&&M.effect){var O=L.data("deg")||0;var N=L.attr("style").replace(/display:\s*none\s*;?/,"");if(!O){N=N.replace(/ (-\w+-)?transform-origin:[^;]+;/g,"")}if(!L.data("wopop_effect_oristyle")){L.data("wopop_effect_oristyle",N)}$.Velocity.hook($(L),"rotateZ",O+"deg");L.hide();if($.WOPOP_EFFECTS[M.effect]&&H){L.addClass("now_effecting");$.WOPOP_EFFECTS[M.effect](L,M)}else{L.show()}}})}};$.fn.wopop_effect_command=function(H,I){if(H=="stop"){return this.each(function(){E($(this))})}};$.WOPOP_EFFECTS._parseNum=function(I,H){if(I==0){return 0}return I||H};function E(H){H.velocity("stop",true);if(H.data("wopop_effect_oristyle")){$.Velocity.hook($(H),"scale","1");$.Velocity.hook($(H),"rotateY","0deg");var I=H.data("deg")||0;$.Velocity.hook($(H),"rotateZ",I+"deg");H.attr("style",H.data("wopop_effect_oristyle"))}H.removeData("wopop_effect_oristyle");H.removeClass("now_effecting");H.trigger("effect_complete")}function C(H){var K=$(".fullpage_alllist");var I=$.Deferred();if(K.length){I.resolve($(H))}else{if(!$.wismobile){var J=$("#scroll_container")}else{var J=A}if(F($(H),J)){I.resolve($(H))}else{$(J).bind("scroll",function(L){if(F($(H),J)){I.resolve($(H));$(this).unbind(L)}})}}return I}function F(H,J){var L=0;var I=0;if(J===undefined||J===A){L=$(A).scrollTop();I=$(A).height()}else{L=$(J).scrollTop();I=$(J).height()}var K=$("#wp-mobile_navhandler").height()+$("#wp-mobile_navhandler").height();return L+I-K>parseInt(H.css("top"))}$.WOPOP_EFFECTS._hasEffectFilter=function(){var H=$(this);if(H.attr("deleted")=="deleted"){return false}var I=H.data("wopop_effects");if(I&&I.effect){return true}return false};$.WOPOP_EFFECTS._isEditMode=function(){if($.saveLayout&&$.isFunction($.saveLayout.save)){return true}return false};var G;$.WOPOP_EFFECTS._setindex=function(H){G=H};$.WOPOP_EFFECTS._getindex=function(){return G};var B={fromleft:{delay:0,duration:1.2},frombottom:{delay:0,duration:1.2},fromright:{delay:0,duration:1.2},fromtop:{delay:0,duration:1.2},fade:{delay:0,duration:0.9},rotation:{delay:0,duration:1.2},rotation2d:{delay:0,duration:1.2},bounceIn:{delay:0,duration:2.2},big2small:{delay:0,duration:1.2},small2big:{delay:0,duration:1.2},fadeFromLeft:{delay:0,duration:1.2},fadeFromBottom:{delay:0,duration:1.2},fadeFromRight:{delay:0,duration:1.2},fadeFromTop:{delay:0,duration:1.2},light:{delay:0,duration:1.2}};$.WOPOP_EFFECTS._getDefaultParam=function(I){var H=B[I];if(!H){H={delay:0,duration:1.2}}return H}})(window);; function fullpagefooterinit(){ //fullpagefooterdrag(); //fullpagefooterresize(); //$.showSiteFooterTips(); $('.fullpage_alllist').each(function(){ if($('.full_column:not([deleted="deleted"])').length > 0){ wp_alert(translate('full_column.already in backplane')); } }) $('.full_pagescroll').each(function(){ fullpagescrollinit($(this)); }) //点亮滚亮操作 $(document).bind('fullpage_scroll_pro',function(e,section){ setTimeout(function(){ if($('#wp-property_settings2').length){ //var index=$.parseInteger(section.replace('page','')); var index=''; $('#canvas #fullPage-nav li').each(function(e){ // if($(this).find('a.active').length>0) index = e + 1; }) $('.fullpage_alllist .section').each(function(e){ if($(this).hasClass('active')) index = e + 1; }) if(index>0){ //$('#wp-property_settings2 .wp-manage-panel-album-img:eq('+(index-1)+')').css('border-color','red'); $('#all_extra_img_div .wp-manage-panel-album-img').each(function(i){ var j = i + 1; if(j==index) $(this).addClass('action'); else $(this).removeClass('action'); }) } } },100) }) } function fullpagescrollinit(dom){ dom.children('.full_width').css({left:0-canv.offset().left-$.parseInteger($('#canvas').css("borderLeftWidth")),width:$('#scroll_container_bg').width()}); dom.wp_rightkey(); if(dom.is(':not(.isplate)')){ // fullpagescrolldrag(dom); fullpagescrollresize(dom); setTimeout(function(){ fullpagescrolldrop(dom); },1300); //fullpagescrolldrop(dom); } } /* function fullpagefooterdrag(){ var maxminusheight=0; var curcanvheight=canv.height(); var Command=Undo.Command.createModuleCommand(function(blockid,val){ var blockel=$('#'+blockid); blockel.css('top',val.top); canv.height(val.canvheight); $('#scroll_container_bg').css('height',(val.canvheight+blockel.height())+'px'); $.fullpageupdateselectbgopt(); $.updatepospropblk(); $.canvasHeightChange(); },null,{returntype:'class'}); var undoobj=null; $('#site_footer').draggable({ cursor: 'move', axis: "y", start: function(event, ui){ initCanvasHeight(); var canvasminheight=canv.data('layermaxheight')||0; curcanvheight=canv.height(); maxminusheight=curcanvheight-canvasminheight; undoobj=new Command('site_footer'); undoobj.setOldVal({top:$.parseInteger($(this).css('top')),canvheight:curcanvheight}); }, drag: function(event, ui){ var topmovepx = ui.position.top - ui.originalPosition.top; if(topmovepx<0){ var delta=0-topmovepx; if(delta>maxminusheight){ var canvasminheight=canv.data('layermaxheight')||0; ui.position.top=ui.originalPosition.top-maxminusheight; canv.height(canvasminheight); $('#scroll_container_bg').css('height',(canvasminheight+$(this).height()+100)+'px'); $.fullpageshowselectbgopt($(this)); $(this).triggerHandler('drag_progress',[{left:0,top:ui.position.top}]); return; } } $(this).triggerHandler('drag_progress',[{left:0,top:ui.position.top}]); canv.height(curcanvheight+topmovepx); $.fullpageshowselectbgopt($(this)); $('#scroll_container_bg').css('height',(curcanvheight+topmovepx+$(this).height()+100)+'px'); }, stop:function(event, ui){ var topmovepx = ui.position.top - ui.originalPosition.top; canv.height(curcanvheight+topmovepx); $('#scroll_container_bg').css('height',(curcanvheight+topmovepx+$(this).height()+100)+'px'); $.canvasHeightChange(); correctFooterPos(); undoobj.insertWithNewVal({top:$.parseInteger($(this).css('top')),canvheight:curcanvheight+topmovepx}); undoobj=null; $(this).trigger('drag_stop',[{left:parseInt($(this).css('left')),top:parseInt($(this).css('top'))}]); } }); } */ function fullpagescrolldrag(dom){ dom.wp_drag(); } function fullpagescrollresize(dom){ var createhandlefunc=function(handle){ dom.each(function(){ var hname = 'ui-resizable-'+handle; var axis = $('

    '); axis.css({zIndex: 1000}); $(this).children('.full_width').append(axis); }) } var createplaceholderfunc=function(handle){ dom.each(function(){ var hname = 'placeholder-'+handle; var axis = $('
    '); axis.css({zIndex: 1000}).hide(); $(this).children('.full_width').append(axis); }) } createhandlefunc('n'); createhandlefunc('s'); createplaceholderfunc('w'); createplaceholderfunc('e'); var fullpagescrollbuttompos; dom.resizable({ handles: {n: '>.full_width .ui-resizable-n',s: '>.full_width .ui-resizable-s'}, noinit:true, canvascontain: '#canvas', distance: 0, concernLock:true, scroll: true, create:function(){ $(this).children('.full_width').find('.ui-resizable-handle').hide(); }, start: function(event, ui){ fullpagescrollbuttompos=$.getFullColChildMaxButtomfullpage(dom); var self=$(this); var resizeundo=new ResizeCommand(self.attr('id')); var oldcssarr=['top','height']; var oldval={}; for(var i=0;i img'); // var maxjson = {width:$(window).width(),height:$(window).height()}; // var json = {width:$paragraph_image.width(),height:$paragraph_image.height()}; // $.wp_fullpagezoom($(this),maxjson,json,'noresize'); } /* function fullpagefooterresize(){ var createhandlefunc=function(handle){ var hname = 'ui-resizable-'+handle; var axis = $('

    '); axis.css({zIndex: 1000}); $('#site_footer >.full_width').append(axis); } var createplaceholderfunc=function(handle){ var hname = 'placeholder-'+handle; var axis = $('
    '); axis.css({zIndex: 1000}); $('#site_footer> .full_width').append(axis); } createhandlefunc('n'); createhandlefunc('s'); createplaceholderfunc('w'); createplaceholderfunc('e'); var maxminusheight=0; var curcanvheight=canv.height(); var canvasminheight=0; var Command=Undo.Command.createModuleCommand(function(blockid,val){ var blockel=$('#'+blockid); blockel.css('top',val.top); blockel.css('height',val.height); canv.height(val.canvheight); blockel.children('.full_content,.full_width').height(val.height); $('#scroll_container_bg').css('height',(val.canvheight+blockel.height())+'px'); $.fullpageupdateselectbgopt(); $.updatepospropblk(); $.canvasHeightChange(); },null,{returntype:'class'}); var undoobj=null; var resizertimer=null; $('#site_footer').resizable({ handles: {n: '>.full_width .ui-resizable-n',s: '>.full_width .ui-resizable-s'}, noinit:true, distance: 0, scroll: true, create:function(){ $(this).children('.full_width').find('.ui-resizable-handle').hide(); }, start: function(event, ui){ initCanvasHeight(); if(resizertimer){ clearTimeout(resizertimer); resizertimer=null; } canvasminheight=canv.data('layermaxheight')||0; curcanvheight=canv.height(); maxminusheight=curcanvheight-canvasminheight; undoobj=new Command('site_footer'); undoobj.setOldVal({top:$.parseInteger($(this).css('top')),canvheight:curcanvheight,height:$(this).height()}); $(this).triggerHandler('resize_progress',[{ui:ui}]); }, resize: function(event, ui){ var resizeobj=$(this).data('resizable'); var theaxis=resizeobj.axis; if(theaxis=='n'){ var changey= $(this).height()-ui.originalSize.height; if(changey>maxminusheight){ var mintop=canvasminheight; $(this).css({top:mintop,height:ui.originalSize.height+maxminusheight}); var oriscrolltop=$(this).data('resize_oriscrolltop'); $(this).scrollParent().scrollTop(oriscrolltop); $(this).children('.full_content,.full_width').height($(this).height()); canv.height(canvasminheight); $('#scroll_container_bg').css('height',(canvasminheight+$(this).height()+100)+'px'); $.fullpageshowselectbgopt($(this)); return; } canv.height(curcanvheight-changey); $(this).children('.full_content,.full_width').height($(this).height()); $('#scroll_container_bg').css('height',(canv.height()+$(this).height()+100)+'px'); }else{ $(this).children('.full_content,.full_width').height($(this).height()); $('#scroll_container_bg').css('height',(canv.height()+$(this).height()+100)+'px'); } $.fullpageshowselectbgopt($(this)); $(this).triggerHandler('resize_stop',[{ui:ui}]); }, stop:function(event, ui){ var self=$(this); undoobj.insertWithNewVal({top:$.parseInteger(self.css('top')),canvheight:canv.height(),height:self.height()}); undoobj=null; $.canvasHeightChange(); } }); } */ function fullpagescrolldrop(dom){ if($.wismobile!=1) dom.css({'border':'dashed #AF6935 2px'}); var createplaceholderfunc=function(handle){ dom.each(function(){ var hname = 'placeholder-'+handle; var axis = $('
    '); axis.css({zIndex: 1000}); $(this).children('.full_content').append(axis); }) } createplaceholderfunc('n'); createplaceholderfunc('s'); createplaceholderfunc('w'); createplaceholderfunc('e'); var contentblock=dom.children('.full_content'); contentblock.children('.li-placeholder').hide(); contentblock.children('.placeholder-n').css({'border-top':'#FF9900 dashed 4px'}); contentblock.children('.placeholder-s').css({'border-bottom':'#FF9900 dashed 4px'}); contentblock.children('.placeholder-e').css({'border-right':'#FF9900 dashed 4px'}); contentblock.children('.placeholder-w').css({'border-left':'#FF9900 dashed 4px'}); contentblock.droppable({ tolerance: 'pointer', accept:'.full_pagescroll,.cstlayer,.wp-new-tool-second-link,.wp-manage-plugin-block',//fullpage拖拽即时响应 drop: function( event, ui ) { var draggable = $.ui.ddmanager.current; if($.getElementAreaInf($(draggable.element))==$.getElementAreaInf(dom)){ if(!dom.hasClass('ui-modselected')||$(draggable.element).is('.wp-new-tool-second-link')||$(draggable.element).is('.wp-manage-plugin-block')){//fullpage拖拽即时响应 $(this).children('.li-placeholder').hide(); var existcolumn=$(document).data('layer_final_drop_id'); var biggercolumn=$.chooseBiggerColumn(existcolumn,dom.attr('id')); $(document).data('layer_final_drop_id',biggercolumn); } } }, over: function(event, ui){ //判断是否包含锁定元素 var has_layer_lock=false; $('.ui-modselected').each(function(){ if($(this).data('cstlayerstatus') == 'unlock' ){ has_layer_lock=true; } }); if(has_layer_lock) return; var draggable = $.ui.ddmanager.current; if($.getElementAreaInf($(draggable.element))==$.getElementAreaInf(dom) ||$(draggable.element).is('.wp-new-tool-second-link')||$(draggable.element).is('.wp-manage-plugin-block')){//fullpage拖拽即时响应 if(!dom.hasClass('ui-modselected')||$(draggable.element).is('.wp-new-tool-second-link')||$(draggable.element).is('.wp-manage-plugin-block')){//fullpage拖拽即时响应 var thisid=dom.attr('id'); var existid=$(document).data('layer_drop_over_id'); if(thisid != existid){ var biggerid=$.chooseBiggerColumn(existid,thisid); if(biggerid == thisid){ var $this=$(this); $(this).children('.li-placeholder').show(); if(existid){ var existcolumnel = $('#'+existid); var dropobj=existcolumnel.children('.full_content').data('droppable'); dropobj['isover'] = 0; dropobj['isout'] = 1; dropobj._out.call(dropobj, event); } $(document).data('layer_drop_over_id', thisid); }else{ var dropobj1=$(this).data('droppable'); dropobj1['isover'] = 0; dropobj1['isout'] = 1; } } } } }, out: function(event, ui){ //判断是否包含锁定元素 var has_layer_lock=false; $('.ui-modselected').each(function(){ if($(this).data('cstlayerstatus') == 'unlock' ){ has_layer_lock=true; } }); if(has_layer_lock) return; var draggable = $.ui.ddmanager.current; if($.getElementAreaInf($(draggable.element))==$.getElementAreaInf(dom)){ if(!dom.hasClass('ui-modselected')||$(draggable.element).is('.wp-new-tool-second-link')||$(draggable.element).is('.wp-manage-plugin-block')){//fullpage拖拽即时响应 $(this).children('.li-placeholder').hide(); var curoverid=$(document).data('layer_drop_over_id'); if(curoverid == dom.attr('id')) $(document).removeData('layer_drop_over_id'); } } } }); } function full_page_block_drop(contentBlock){ var dom=contentBlock.closest('.full_pagescroll'); contentBlock.droppable({ tolerance: 'pointer', accept:'.full_pagescroll,.cstlayer,.wp-new-tool-second-link,.wp-manage-plugin-block',//fullpage拖拽即时响应 drop: function( event, ui ) { var draggable = $.ui.ddmanager.current; if($.getElementAreaInf($(draggable.element))==$.getElementAreaInf(dom)){ if(!dom.hasClass('ui-modselected')||$(draggable.element).is('.wp-new-tool-second-link')||$(draggable.element).is('.wp-manage-plugin-block')){ $(this).children('.li-placeholder').hide(); var existcolumn=$(document).data('layer_final_drop_id'); var biggercolumn=$.chooseBiggerColumn(existcolumn,dom.attr('id')); $(document).data('layer_final_drop_id',biggercolumn); } } }, over: function(event, ui){ //判断是否包含锁定元素 var has_layer_lock=false; $('.ui-modselected').each(function(){ if($(this).data('cstlayerstatus') == 'unlock' ){ has_layer_lock=true; } }); if(has_layer_lock) return; var draggable = $.ui.ddmanager.current; if($.getElementAreaInf($(draggable.element))==$.getElementAreaInf(dom) ||$(draggable.element).is('.wp-new-tool-second-link')||$(draggable.element).is('.wp-manage-plugin-block')){ if(!dom.hasClass('ui-modselected')||$(draggable.element).is('.wp-new-tool-second-link')||$(draggable.element).is('.wp-manage-plugin-block')){ var thisid=dom.attr('id'); var existid=$(document).data('layer_drop_over_id'); if(thisid != existid){ var biggerid=$.chooseBiggerColumn(existid,thisid); if(biggerid == thisid){ var $this=$(this); $(this).children('.li-placeholder').show(); if(existid){ var existcolumnel = $('#'+existid); var dropobj=existcolumnel.children('.full_content').data('droppable'); dropobj['isover'] = 0; dropobj['isout'] = 1; dropobj._out.call(dropobj, event); } $(document).data('layer_drop_over_id', thisid); }else{ var dropobj1=$(this).data('droppable'); dropobj1['isover'] = 0; dropobj1['isout'] = 1; } } } } }, out: function(event, ui){ //判断是否包含锁定元素 var has_layer_lock=false; $('.ui-modselected').each(function(){ if($(this).data('cstlayerstatus') == 'unlock' ){ has_layer_lock=true; } }); if(has_layer_lock) return; var draggable = $.ui.ddmanager.current; if($.getElementAreaInf($(draggable.element))==$.getElementAreaInf(dom)){ if(!dom.hasClass('ui-modselected')||$(draggable.element).is('.wp-new-tool-second-link')||$(draggable.element).is('.wp-manage-plugin-block')){ $(this).children('.li-placeholder').hide(); var curoverid=$(document).data('layer_drop_over_id'); if(curoverid == dom.attr('id')) $(document).removeData('layer_drop_over_id'); } } } }); } function fullpagescroll_propblk_init(){ var lvtimer; for(var key in $.fullpagebackgroundPropDefaults){ (function(){ var curkey=key; var otherfunc=null; if($.inArray(curkey,['fullpage_moveto_prevop','fullpage_moveto_nextop']) != -1){ var innertxt ='', lvtype = ''; switch(curkey){ case 'fullpage_moveto_prevop': lvtype = 'top'; innertxt = ''; break; case 'fullpage_moveto_nextop': lvtype = 'bottom'; innertxt = ''; break; } otherfunc={ mousedown:function(){ var $target = $(this) var apos =$target.offset(); var scrollctner=$('#scroll_container'); var scrolltop=scrollctner.scrollTop(); $(innertxt).appendTo(scrollctner).css({ top: function(){ return (apos.top+scrolltop - 25-39)+'px' },left: apos.left+'px' }).click(function(e){ $('#'+$.bgselectedid).wp_setorder(lvtype,$.bgselectedid); $(this).remove(); $target.removeClass('local'); e.preventDefault(); }); }, mouseup:function(){ } } } $('#'+curkey).mousedown(function(e){ var $target = $(this); $target.addClass('local'); if($('.wp-moveto_fstlevel,.wp-moveto_lstlevel').size()) $('.wp-moveto_fstlevel,.wp-moveto_lstlevel').remove(); if(otherfunc != null){ otherfunc.mousedown.apply(this); } e.preventDefault(); }).mouseup(function(e){ var self = this,$target = $(self); $target.removeClass('local'); $.fullpagebackgroundPropDefaults[curkey].apply(this); if(otherfunc != null){ otherfunc.mouseup.apply(this); } e.preventDefault(); }) })(); } } (function($){ function fullpagegetAllParents(el){ var parents={}; parents[el.prop('id')]='null'; var curel=el; while(true){ var parentid=$.getElementFatherid(curel); if(parentid =='none') break; parents[parentid]=curel.prop('id'); curel=$('#'+parentid); } return parents; } $.chooseBiggerColumn=function(existcolumnid,newcolumnid){ var biggercolumnid=newcolumnid; if(existcolumnid==newcolumnid) return biggercolumnid; if(existcolumnid){ var existcolumnel=$('#'+existcolumnid); var newcolumnel=$('#'+newcolumnid); var existcolumnfathers=fullpagegetAllParents(existcolumnel); var newcolumnfathers=fullpagegetAllParents(newcolumnel); var rootid='canvas'; if(!existcolumnfathers[rootid]) rootid='site_footer'; var existdifffather=rootid; var newdifffather=rootid; while(existdifffather == newdifffather){ existdifffather =existcolumnfathers[existdifffather]; newdifffather =newcolumnfathers[newdifffather]; if(existdifffather=='null' || newdifffather=='null') break; } if(existdifffather=='null') biggercolumnid=newcolumnid; else if(newdifffather=='null') biggercolumnid=existcolumnid; else{ var existfatherzindex=$.parseInteger($('#'+existdifffather).css('z-index')); var newfatherzindex=$.parseInteger($('#'+newdifffather).css('z-index')); if(existfatherzindex > newfatherzindex) biggercolumnid=existcolumnid; } } return biggercolumnid; } $.transferToColumn=function(dom,fathercolid){ var oldfatherid=$.getElementFatherid(dom); if(oldfatherid!=fathercolid){ var newfatherel=$('#'+fathercolid); var domabpos=dom.ab_pos('top'); var newfatherabpos=newfatherel.ab_pos('top'); var contentblock=newfatherel; if(fathercolid!='canvas') contentblock=newfatherel.children('.full_content'); dom.detach().attr('fatherid',fathercolid).css('top',(domabpos-newfatherabpos)).appendTo(contentblock); if(fathercolid=='site_footer'||fathercolid=='canvas') dom.removeAttr('fatherid'); } } $.getElementAreaInf=function(dom){ return dom.attr('inbuttom')=='1'?'site_footer':'canvas'; } $.transferToArea=function(dom,from,to,isInUndo){ var domabpos=dom.ab_pos('top'); var footertop=$.parseInteger($('#site_footer').css('top')); if(to=='site_footer'){ var curmodtop=domabpos-footertop; dom.css('top',curmodtop); dom.attr('inbuttom','1'); dom.detach().removeAttr('fatherid').appendTo($('#site_footer').children('.full_content')); if(dom.hasClass('full_pagescroll')) dom.find('.cstlayer,.full_pagescroll').attr('inbuttom','1'); }else{ var curmodtop=domabpos+footertop; dom.css('top',curmodtop); var canvheight=$('#canvas').height(); if(canvheight 0){ wp_alert(translate('fullpage.already plugin')); return false; } if($('.full_column:not([deleted="deleted"])').length > 0){ wp_alert(translate('full_column.already Please remove')); return false; } //存在页脚元素时移除处理 if($.wismobile){ if($('#site_footer').length > 0){ var fullpageClass='fullpage'; if($.wismobile) fullpageClass='mfullpage'; if (confirm(translate('fullpage.Please hide site_footer'))) { $.post(parseToURL(fullpageClass,"prosf"), {pid:$.page_id},function(response){ var o_result = $.parseJSON(response); if(o_result.result == "OK") { $('#site_footer').remove(); }else{ location.reload(); return false; } }).error(function() { location.reload(); return false; }); }else{ return false; } } } var successfunc=function(resp,needchangeid){ var fullpagescrollhtml=resp; if(needchangeid){ var fullpagescrollels=$(fullpagescrollhtml).filter('.full_pagescroll'); var nowid=fullpagescrollels.prop('id'); var newid='layer'+fGuid(); fullpagescrollhtml=fullpagescrollhtml.replace(new RegExp(nowid,"g"),newid); } var fullpagescrollel=$(fullpagescrollhtml).appendTo('#canvas'); // fullpagescrollel=fullpagescrollel.filter('.full_pagescroll'); fullpagescrollel.find('.full_pagescroll').each(function(){ fullpagescrollinit($(this)); }) //初始化加截 默认模块内,内容模块加载样式 fullpagescrollel.css('z-index',100); var titlecss=relativeToAbsoluteURL('plugin/title/css/title.css'); if($('body').data('title') !=titlecss){ $('body').data('title',titlecss); var head = document.getElementsByTagName('head').item(0); var css = document.createElement('link'); css.href = titlecss; css.rel = 'stylesheet'; css.type = 'text/css'; head.appendChild(css); } $('.ui-modselected').each(function(){ $.hidWidgetBorder($(this)); // 图文模块相关 2012/2/14 if($(this).hasClass('graphic_edited')) actived_graphic(); }); $.fullpageunselectbgdiv(fullpagescrollel); //显示属性 初始显示属性.ui-modselected绑定至第一屏上.再根id .fullpage_alllist初始存在问题 $.fullpageselectbgdiv(fullpagescrollel.find('.full_pagescroll:eq(0)')); // $.showWidgetBorder(fullpagescrollel); new AddCommand(fullpagescrollel.prop('id')).insert(); var objarray=new Array(); objarray[0]=new Array(parseInt($('#'+fullpagescrollel.prop('id')).css('z-index')),fullpagescrollel.prop('id')); $.zindexsort_new(objarray); } //使用缓存有问题 停用 if($.addFullPagescroll.html_cache){ successfunc($.addFullPagescroll.html_cache,true); return; } $.ajax({ type: "GET", url: parseToURL("wp_widgets","gtfullpagescroll"), success: function(response){ // $.addFullPagescroll.html_cache=response; successfunc(response,false); }, error: function(xhr, textStatus, errorThrown){ wp_alert((errorThrown||textStatus)+"(add a fullpagescroll).
    "+translate("Request failed!")); return false; } }); } $.curSelectableFather=function(){ var selmods=$('.ui-modselected'); if(selmods.length==0){ $(document).data('cur_selectable_father',null); return null; }else{ var fatherid=$.getElementFatherid(selmods.filter(':first')); $(document).data('cur_selectable_father',fatherid); return fatherid; } } $.getElementFatherid=function(dom){ if(dom.prop('id')=='canvas'||dom.prop('id')=='site_footer') return 'none'; var fatherid=dom.attr('fatherid'); if(!fatherid||fatherid==''){ if(dom.closest('#canvas').length>0){ fatherid='canvas'; }else if(dom.closest('#site_footer').length>0){ fatherid='site_footer'; } } return fatherid; } /* $.fn.ab_pos=function(direct){ var dom=$(this); if(dom.prop('id')=='canvas'||dom.prop('id')=='site_footer') return 0; if(direct=='left'||direct=='top'){ if(!dom.attr('fatherid')||dom.attr('fatherid')=='') return dom.rel_pos(direct); return dom.rel_pos(direct)+$('#'+dom.attr('fatherid')).ab_pos(direct); } } $.fn.ab_pos_cnter=function(direct){ var abpos=$(this).ab_pos(direct); if($(this).closest('#site_footer').length>0&&direct=='top'){ return abpos+$.parseInteger($('#site_footer').css(direct)); } return abpos; } $.fn.rel_pos=function(direct){ if(direct=='left'||direct=='top'){ return $.parseInteger($(this).css(direct)); } } */ $.getFullColChildMaxButtomfullpage=function(dom){ var parenttoppos=dom.ab_pos_cnter('top'); var maxbuttompos=parenttoppos; dom.find('.cstlayer,.full_pagescroll').each(function(){ var el=$(this); var buttompos=0; if(el.hasClass('cstlayer')) buttompos=$.divrotate.getDegreeModMaxPoint(el,null,'buttom'); else buttompos=el.ab_pos_cnter('top')+$.parseInteger(el.css('height')); if(maxbuttompos difh)) { $img.width(lastw).height('auto'); // 自动修复高度 curdifh = lasth - $img.height(); // if(curdifh < 0) $img.css({top:Math.ceil(curdifh/2)+'px',left:'0px',position:'relative'}); if(curdifh < 0) $img.css({top:Math.ceil(curdifh/2)+'px',left:'0px'}); else if(curdifh > 0){ $img.height(lasth).width('auto'); curdifw = lastw - $img.width(); // $img.css({top:'0px',left:Math.ceil(curdifw/2)+'px',position:'relative'}); $img.css({top:'0px',left:Math.ceil(curdifw/2)+'px'}); }else $img.css({top:'',left:'',position:''}); } else if (difh || (difw < difh)) { $img.height(lasth).width('auto'); // 自动修复宽度 curdifw = lastw - $img.width(); //if(curdifw < 0) $img.css({top:'0px',left:Math.ceil(curdifw/2)+'px',position:'relative'}); if(curdifw < 0) $img.css({top:'0px',left:Math.ceil(curdifw/2)+'px'}); else if(curdifw > 0){ $img.width(lastw).height('auto'); curdifh = lasth - $img.height(); //$img.css({top:Math.ceil(curdifh/2)+'px',left:'0px',position:'relative'}); $img.css({top:Math.ceil(curdifh/2)+'px',left:'0px'}); }else $img.css({top:'',left:'',position:''}); } } //判断浏览(PC|手机) $.wp_fullpag_mobile=function(){ return (/iphone|ipod|ipad|Macintosh|android|Windows phone/i.test(navigator.userAgent.toLowerCase())); } })(jQuery); /* * To change this template, choose Tools | Templates * and open the template in the editor. */ function openImageChooserDialog(options){ window._imageChooserDefered=new $.Deferred(); options=$.extend({},options); var title=options.title||translate('fileManager.selectImage'); var width=options.width||850; var filetype=options.filetype||'pic'; var dialogid=options.id||'wp-picmanage_panel'; var zindex=options.zIndex||1003; var multi=options.multi||0; var mask = options.overlay; if (typeof mask === 'undefined') mask = true; //show_dialog(parseToURL("wp_widgets","common_pic_chooser",{filetype:filetype}), title,width, 0); wp_floatpanel(parseToURL('wp_widgets','common_pic_chooser',{filetype:filetype,multi:multi}),{ title: title, id: dialogid, width: width, overlay: mask, isCenter: true, swfFix: true, zIndex: zindex }); if(!options.cancelNotCloseDialog){ window._imageChooserDefered.fail(function(){ $.modal.close(); }) } return window._imageChooserDefered.promise(); } // Add 'link to file' function 2013/02/25 function openMyDocChooserDialog(options){ window._myDocChooserDefered = new $.Deferred();options = $.extend({},options); var title = options.title||translate('fileManager.myFile'),dwidth = options.width||850,icenter = options.isCenter||true, dialogid = options.id||'wp-file_explore',zindex = options.zIndex||1003,mask = options.overlay; if (typeof mask === 'undefined') mask = true; wp_floatpanel(parseToURL('wp_fileexplore', 'file_explore', {"geturl": '1'}), {swfFix: true, title: title,width: dwidth,isCenter: icenter,id: dialogid,zIndex: zindex,overlay: mask }); return window._myDocChooserDefered.promise(); } function transferToPageSetDialog(showdiv,hidediv,options){ window._pagesetDefered=new $.Deferred(); options=$.extend({},options); var dialogwin=window; if(options.iframe) dialogwin=parent; var title=options.title||translate('page.add'); var mode=options.mode||'create'; var url =''; if(mode=='edit'){ var pageid=options.pageid; url =parseToURL("wp_page","editpage",{id:pageid}); }else{ var additionparam=options.createparam||{}; url =parseToURL("wp_page","addpage",additionparam); } $.get(url, function(data) { $(showdiv).html(data).show(); $(hidediv).hide(); wp_update_floatpanel($('#wp-manage_menu'),title,376,function(dom){ dom.find('.wp-panel_button').hide(); dom.find('#page_set_prop_div .wp-panel_button').show(); }); }).error(function(xhr, textStatus, errorThrown) { wp_alert((errorThrown||textStatus)+"(edit/add a page).
    "+translate("Request failed!")); }) return window._pagesetDefered.promise(); } function transferToPageSetDialogcur(showdiv,hidediv,options){ window._pagesetDefered=new $.Deferred(); options=$.extend({},options); var dialogwin=window; if(options.iframe) dialogwin=parent; var title=options.title||translate('page.add'); var mode=options.mode||'create'; var url =''; var pageid=options.pageid; var modact=options.modact||'navigation'; var page_id=options.page_id; var supid=options.blockid; if(mode=='edit'){ url =parseToURL(modact,"editpage",{id:pageid,page_id:page_id,blockid:supid}); }else{ var additionparam=options.createparam||{}; url =parseToURL(modact,"addpage",{page_id:page_id,blockid:supid,parentid:pageid}); } $.post(url, {menudata:$("#"+supid).data("menudata")}, function(data) { $(showdiv).html(data).show(); $(hidediv).hide(); /* dialogwin.$('#osx-container').css('width',500); if(options.iframe) dialogwin.$('#osx-modal-data').find('iframe').width(500).height(480); dialogwin.$("#osx-modal-title").data('origin_title',dialogwin.$("#osx-modal-title").html()); dialogwin.$("#osx-modal-title").html(title); dialogwin.$.modal.setPosition(); */ }).error(function(xhr, textStatus, errorThrown) { wp_alert((errorThrown||textStatus)+"(edit/add a navigation page).
    "+translate("Request failed!")); }) return window._pagesetDefered.promise(); } function openPageSetDialog(options){ window._pagesetDefered=new $.Deferred(); options=$.extend({},options); var title=options.title||translate('page.add'); var width=options.width||400; var mode=options.mode||'create'; var url =''; if(mode=='edit'){ var pageid=options.pageid; url =parseToURL("wp_page","editpage",{id:pageid}); }else{ width = 400; var opts={}; if(options.mtype) opts._mtype=options.mtype; if(options.parentid) opts.parentid=options.parentid; url =parseToURL("wp_page","addpage",opts); } //show_dialog(url, title,width, 0); wp_floatpanel(url,{ title: title, contentClass: 'wp-site-set_panel_c', id: 'wp-add_page', overlay: true, isCenter: true, width: width, zIndex: 1002, cache:false, open: function(dom){ if(options.callback && $.isFunction(options.callback)){ $(dom).bind('addPageLink',function(e,url){ options.callback(url); }); } } }); if(!options.cancelDefaultOp){ window._pagesetDefered.done(function(data){ if(data.refresh){ $.saveLayout.save(true); window.location.reload(); $('#wp-add_page').triggerHandler('wpdialogclose'); }else{ setTimeout(function(){ $.saveLayout.save(true); window.location.href=data.forward; },100); } }) window._pagesetDefered.fail(function(){ $('#wp-add_page').triggerHandler('wpdialogclose'); }) } return window._pagesetDefered.promise(); } // 创建“文章/产品分类、列表”链接相关 2012/07/16 function setModuleLink(mtype,callback){ openPageSetDialog({"mtype":mtype,"callback":callback}); } // IFRAME自适应高度 2012/07/12 function initFrame(frame,contentClass,height){ var self = frame,bh = self.contentWindow.document.body.scrollHeight, dh = self.contentWindow.document.documentElement.scrollHeight,max = Math.max; var $parent = $(self).closest('.wp-floatpanel_dialog'),otherh = 0,temph = max(bh,dh); temph+=1; if($.browser.msie){ temph = temph+25; } $parent.find('.'+contentClass).siblings().each(function(i,dom){ otherh += $(dom).outerHeight(true); }); var _float = function(numString){ var number = parseFloat(numString); if(isNaN(number)) return 0; return number; }; var seth = _float(height),maxh = seth ? seth : $(document).height(), difw = maxh - otherh - 10;// 上下间隔5像素 if(difw < temph) temph = difw; frame.height = max(temph,200); $(self).closest('.wp-floatpanel_dialog').triggerHandler('wpdialogsetpos'); } (function($){ var cachedtimer={}; $.multi_exec_once=function(key,func,interval){ var timer=cachedtimer[key]; if(timer != null){ clearTimeout(timer); delete cachedtimer[key]; } timer=setTimeout(func, interval); cachedtimer[key]=timer; } // 注册beforeLoaded方法 2012/07/11 var loadedhash = {}; $.beforeLoaded = { add: function(type, event, func){ if ($.isFunction(func)) { if(!loadedhash[type]) loadedhash[type] = {}; loadedhash[type][event] = func; } }, run: function(type, event, data){ var func = loadedhash[type]; if(typeof func == 'undefined') return false; func = func[event]; if($.isFunction(func)) return func(data); return false; } }; })(jQuery); // 更新并定位浮动窗口 function wp_update_floatpanel(dom, title, width, callback){ var $title = dom.find('.wp-title > h2'),curtitle = $title.html(); dom.width(width); if(title) $title.data('origin_title',curtitle); else title = curtitle; $title.html(title); if(callback && $.isFunction(callback)) callback(dom); // setPosition var win = window,winw = $(win).width(),winh = $(win).height(), floor = Math.floor,newh = dom.outerHeight(true); dom.css({'left': floor((winw-width)/2),'top': floor((winh-newh)/2)}); } /** * 个性化下拉框 */ ;(function($,undefined){ var namespace = '.wpcstselect'; $.widget('wp.cstselect',{ options : { selectclass:'wp-diy-selected'//样式 }, // 配置项 _create : function(){ var self = this; var selectclass=self.options.selectclass; if(selectclass.length==0){ selectclass='wp-diy-selected';} // 忽略多选的SELECT控件 if(self.element.prop("multiple")) return; self._doinit(self).done(function(dom,selopts){ var $ctarget = dom,$diysel = $ctarget.next('.'+selectclass+'-outside').find('.'+selectclass+''); // 设置默认值 setTimeout(function(){ var $cursel = $diysel.children('.'+selectclass+'-left'),difw = $cursel.siblings('.'+selectclass+'-button').outerWidth() + 2, pad = self._int($cursel.css("paddingLeft")) + self._int($cursel.css("paddingRight")),finalw = $diysel.width() - difw - pad; if (finalw <= 0) finalw = Math.max(65, $ctarget.width()) - pad - 16; $cursel.width(finalw).attr("val",$ctarget.val()).html($ctarget.find('option:selected').html());$cursel = difw = finalw = null; },50); // 绑定CLICK事件 $diysel.bind('click'+namespace,function(e){ if(self.options.disabled || !selopts.length) return; var $selectedcnt = $(selopts).appendTo('body'),maxheight = $selectedcnt.outerHeight(true); self._selected($selectedcnt, $ctarget.val()); // 设置默认值 // 绑定LI:HOVER及CLICK事件 if ($selectedcnt.is(':hidden')) { var $target = $(this); $selectedcnt.find('li').bind('mouseenter'+namespace, function(e){ $(this).addClass('local').siblings().removeClass('local'); }).bind('mouseleave'+namespace, function(e){ $(this).removeClass('local'); }).bind('click'+namespace, function(e){ var $li = $(this),selval = $li.attr("val"); $target.children('.'+selectclass+'-left').html($li.html()).attr("val", selval); $ctarget.val(selval).trigger('change');// 捕获已绑定SELECT事件 }).end().slideDown('slow',function(){ var $selcnt = $(this); // 定位滚动条 2012/11/09 var selcnt = $selcnt[0],clienth = selcnt.clientHeight,$selected = $selcnt.find('li.local'); if ($selected.size() > 0) { var seltop = $._parseFloat($selcnt.css("top")), litop = seltop + $selected[0].offsetTop - selcnt.offsetTop + $selected.height(); if(clienth < litop) selcnt.scrollTop = litop - clienth; } // End $(document).one('click'+namespace,function(e){ $selcnt.slideUp().remove(); return false; }); }); setSeloptsPos($target,$selectedcnt,maxheight); // 绑定RESIZE事件 $(window).resize(function(){ setSeloptsPos($target,$selectedcnt,maxheight); }); } }); function setSeloptsPos(target,dom,maxh){ var $target = target,pos = $target.offset(); dom.css({ "top": function(i,val){ var wnh = window.innerHeight||self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight, _top = self._int(pos.top),_oh = $target.outerHeight(true),newtop = 0; if (wnh < _top + maxh + _oh) { newtop = Math.max(0, _top - maxh - 1); $(this).css({"border-bottom": 'none',"border-top": '1px solid #B5B5B5'}); } else newtop = _top + _oh + 1; wnh = _top = _oh = null; return newtop+'px'; },"left": function(i,val){ return self._int(pos.left)+'px'; } }); } }); }, value : function(value){ var self = this; var selectclass=self.options.selectclass; if(selectclass.length==0){ selectclass='wp-diy-selected';} var $target = self.element,$select = $target.next('.'+selectclass+'-outside'); $target.val(value); $select.find('.'+selectclass+'-left').attr("val",value).html($target.children('option:selected').html()); }, _doinit : function(dom){ var dtd = $.Deferred(),self = dom,$target = self.element; var selectclass=self.options.selectclass,_stripslashes = function(str){ return (str + '').replace(/\\(.?)/g, function(s, $1){ switch ($1) { case '\\': return '\\'; case '0': return '\u0000'; case '': return ''; default: return $1; } }); }; if(selectclass.length==0){ selectclass='wp-diy-selected';} $target.hide();// 隐藏SELECT控件 // 自定义类SELECT var selopt = '',selw = Math.max($target.width(), 65); var selhtm = '
    '; $target.children('option').each(function(i,c){ var self = c; selopt += '
  • '+_stripslashes(self.innerHTML)+'
  • '; }); selhtm += '
     
    '; $target.after(selhtm); dtd.resolve($target,'
      '+selopt+'
    '); return dtd.promise(); }, _int : function(numstr){ var number = parseInt(numstr); if(isNaN(number)) return 0; return number; }, _selected : function(dom,value){ dom.find('li').each(function(i,c){ var $target = $(c),ent = ''; ent = ($target.attr("val") == value)?'addClass':'removeClass'; $target[ent]('local'); }); return true; }, enable : function(){ var self = this; var selectclass=self.options.selectclass; if(selectclass.length==0){ selectclass='wp-diy-selected';} var $select = self.element.next('.'+selectclass+'-outside'); $select.find('.'+selectclass+'-left').css("color","#5A5A5A"); $select.find('.'+selectclass+'-button > a').removeClass('disabled'); $.Widget.prototype.enable.call(self); }, disable : function(){ var self = this; var selectclass=self.options.selectclass; if(selectclass.length==0){ selectclass='wp-diy-selected';} var $target = self.element,$select = $target.next('.'+selectclass+'-outside'); // 还原SELECT控件默认值 var firstopt = $target.find('option')[0]; $target[0].selectedIndex = 0; $select.find('.'+selectclass+'-left').css("color","#7C7C7C").attr("val",firstopt.value).html(firstopt.innerHTML); $select.find('.'+selectclass+'-button > a').addClass('disabled'); $.Widget.prototype.disable.call(self); }, destroy : function(){ var self = this; var selectclass=self.options.selectclass; if(selectclass.length==0){ selectclass='wp-diy-selected';} $(document).unbind(namespace); self.element.next('.'+selectclass+'-outside').unbind(namespace).remove(); $.Widget.prototype.destroy.call(self); } }); })(jQuery); /** * 文本框绑定的事件 * event(参数) - 触发回调的本地事件对象 * -> onkeydown: function(event){ * -> // do something * -> } * -> onkeyup: function(event){ * -> // do something * -> } * -> onchange: function(event){ * -> // do something * -> } * -> onfocus: function(event){ * -> // do something * -> } * -> onblur: function(event){ * -> // do something * -> } */ ;(function($,undefined){ var readyToOnBlur = true, eventNamespace = '.wpcstinput'; $.widget('wp.cstinput',{ options : { value : '', // 文本默认值, regexp : /^\d+(\.\d+)?$/, // 输入值验证正则 range : [0], // 可输入值范围[min,max](大于0) maxlength : 4, // 可输入值长度 unit : 'px', // 可输入值单位(像素) step : 1, // 递增/减步长 style : '', // 显示区域样式 nmnode_style : '', // 文本框父节点样式 btnnode_style : '', // 箭头父节点样式 upbtn_style : '', // 上箭头节点样式 downbtn_style : '', // 下箭头节点样式 complete : function(){} // 方向键的回调函数(第一个参数为当前对象,第二个参数为递增/减的值) }, _create : function(){ var $this = this, $input = $this.element, options = $this.options; var uistyle = (options.hasOwnProperty('style') && options.style.length) ? ' style="'+options.style+'"' : '', nmstyle = (options.hasOwnProperty('nmnode_style') && options.nmnode_style.length) ? ' style="'+options.nmnode_style+'"' : '', btnstyle = (options.hasOwnProperty('btnnode_style') && options.btnnode_style.length) ? ' style="'+options.btnnode_style+'"' : '', upstyle = (options.hasOwnProperty('upbtn_style') && options.upbtn_style.length) ? ' style="'+options.upbtn_style+'"' : '', downstyle = (options.hasOwnProperty('downbtn_style') && options.downbtn_style.length) ? ' style="'+options.downbtn_style+'"' : ''; $input.wrap('
    ' +'
    '); // Default value if(options.hasOwnProperty('value') && options.regexp.test(options.value)) $input.focus().val(options.value); // Maxlength if(options.hasOwnProperty('maxlength') && /^[1-9]{1}\d*$/.test(options.maxlength)) $input.attr('maxlength',options.maxlength); // Unit(像素) if(options.hasOwnProperty('unit') && options.unit.length) $input.closest('.wp_cstinput_helper').after('
    '+options.unit+'
    '); // Bind input events $.each(['keydown','keyup','change','focus','blur'],function(i,event){ $input.bind(event+eventNamespace,function(e){ if(!readyToOnBlur && (event == 'blur')) return false; $this._trigger('on'+event, e, null); }); }); // Bind buttons events var $buttons, upbtn, downbtn; $buttons = $this.buttons = $input.closest('.wp_cstinput_helper').find('.minplus_helper > span'); upbtn = $buttons[0]; downbtn = $buttons[1]; $buttons.mousedown(mouseDown).mouseup(mouseUp).mouseout(mouseUp); function mouseDown(){ if(options.disabled) return; var step = (this === upbtn) ? options.step : -options.step; $input.focus(); $input.select(); readyToOnBlur = false; $this._doCount(step); return false; } function mouseUp(){ if (!readyToOnBlur) { // $this._stopCount(); readyToOnBlur = true; } return false; } }, _doCount : function(step){ var newval, range = this.options.range, curval = this.element[0].value; if(!curval.length){ // input值为空时,点击值变为0 leiminglin 2014/4/22 curval = this.element[0].value = 0; } newval = this._parseValue(curval) + step; // 范围限定 if ($.isArray(range) && (range.length > 0)) { var min,max; if(typeof range[0] != 'undefined') min = range[0]; if(typeof range[1] != 'undefined') max = range[1]; // 溢出判断 if((step < 0) && (typeof min === 'number') && (newval < min)) newval = min; if((step > 0) && (typeof max === 'number') && (newval > max)) newval = max; } this.element[0].value = newval; // 绑定方向键的回调函数 if($.isFunction(this.options.complete)) this.options.complete(this.element,newval); }, _parseValue : function(numString){ var number = parseFloat(numString); if(isNaN(number)) return 0; return number; }, enable : function(){ this.buttons.removeClass('cstinput_disabled'); $.Widget.prototype.enable.call(this); }, disable : function(){ this.buttons.addClass('cstinput_disabled'); $.Widget.prototype.disable.call(this); }, destroy : function(){ var $this = this.element, $cstinput_helper = $this.closest('.wp_cstinput_helper'); $this.removeAttr('maxlength').unbind(eventNamespace); $cstinput_helper.before($this[0]); $cstinput_helper.siblings('.wp_cstunit_helper').remove().end().remove(); $.Widget.prototype.destroy.call(this); } }); })(jQuery); // 自定义垂直滚动条 2014/02/07 ;(function($, undefined){ var namespace = 'simroll', getMscrollWidth = function(){ var noScroll,scroll,oDiv = document.createElement("DIV"); oDiv.style.cssText = "position:absolute;top:-1000px;width:100px;height:100px;overflow:hidden;"; noScroll = document.body.appendChild(oDiv).clientWidth; oDiv.style.overflowY = "scroll"; scroll = oDiv.clientWidth; document.body.removeChild(oDiv); return noScroll - scroll; }; $.widget('wp.mscroll', { options : { difleft: 0,/*滚动条自定义偏移量*/ maskleft: 0,/*滚动条遮罩层left*/ barleft: 0,/*滚动条滑块left*/ height: 0,/*滚动条height*/ maskbg: '#fff', maskcname: 'wp-mobile-device-mask',/*滚动条遮罩层class*/ barcname: 'wp-mobile-scrollbar'/*滚动条滑块class*/ }, _create : function(){ var self = this,creatid = '-'+self._getRandomStr(),maskbg = (self.options.maskbg||'').length?'background:'+self.options.maskbg:'', barstr = '
    '; barstr += '
    '; self.options.creatid = creatid; self.element.before(barstr); self._setScrollPos(creatid); self._bindScroll(creatid); }, _setScrollPos : function(id){ var prefid = namespace+id,barleft = 0,self = this,$target = self.element, $mask = $target.prevAll('#'+prefid+'-mask'),$bar = $target.prevAll('#'+prefid+'-bar'); $mask.add($bar).css({"left": function(){ var curtype = $(this).attr("id").replace(prefid+'-', ''); if (self.options[curtype+'left']) barleft = self.options[curtype+'left']; else { var swidth = getMscrollWidth() || 16; barleft = self._parseFloat($target.css("left")) + $target.width() - swidth; } return barleft+'px'; },"height": ($target.height() + 1)+'px',"visibility": 'visible'}); $bar.css("left", function(){return (barleft + self._parseFloat(self.options.difleft||0))+'px'}); }, _bindScroll : function(id){ var self = this,$target = self.element,$bar = $target.prevAll('#'+namespace+id+'-bar'),paneH = 0, $spane = $bar.children('span.pane'),containerH = $target.height(),paneContainerH = 0; $target.bind("scroll."+namespace, function(e){ var contentH = this.scrollHeight;$bar.height(self.options.height||containerH); if (containerH < contentH) paneH = self._parseFloat(containerH*containerH / contentH); $spane.height(paneH); var maxtop = containerH - paneH, movey = self._parseFloat(this.scrollTop * containerH / contentH); $spane.css("top", Math.min(movey, maxtop)+'px'); }).triggerHandler("scroll."+namespace); // Pane Handler (function(){ var curtop,curpagey; $spane.bind("mousedown."+namespace, function(e){ e.preventDefault();curpagey = e.pageY; curtop = self._parseFloat($spane.css("top")); $spane.addClass("scrolling"); $(document).bind("mousemove."+namespace, function(e){ if (! $spane.hasClass("scrolling")) return; var newtop = curtop + e.pageY - curpagey,panetop = Math.max(0, newtop), target = $target.get(0),contentH = target.scrollHeight; // Reset pane-top var scrltop = self._parseFloat(panetop * contentH / containerH), maxtop = containerH - $spane.height(); if (panetop >= maxtop) scrltop = contentH - target.clientHeight; $target.scrollTop(scrltop);return false; }).bind("mouseup."+namespace, function(e){ e.preventDefault();$(document).unbind("."+namespace); $(parent.document).unbind(".rmscroll"); if (! $spane.hasClass("scrolling")) return; $spane.removeClass("scrolling"); }); $(parent.document).bind("mouseup.rmscroll",function(){$(document).unbind("."+namespace)}); }).bind("mouseup."+namespace, function(e){ $(document).unbind("."+namespace); $(parent.document).unbind(".rmscroll");return false; }); })(); }, _getRandomStr : function(len){ len = len || 16; var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', maxlen = chars.length,result = ''; for(var i = 0; i < len; i++){ result += chars.charAt(Math.floor(Math.random() * maxlen)); } return result; }, _parseFloat : function(numstr){ var number = parseFloat(numstr); if (isNaN(number)) return 0; return number; }, destroy : function(){ var self = this,prefid = '#'+namespace+self.options.creatid; $(document).add(self.element).unbind("."+namespace); self.element.prevAll(prefid+'-mask,'+prefid+'-bar').remove(); $.Widget.prototype.destroy.call(self); } }); })(jQuery); //js生成guid function fGuid(bOrg) { // try // { // var sGuid=new ActiveXObject('scriptlet.typelib').GUID // } // catch(e) // { // var sGuid=fGuidCst(); // } var sGuid=fGuidCst(); if(bOrg) return sGuid; return (sGuid+'').replace(/\{|\}|-/g,''); function fGuidCst() { var sGuid=''; for(var i=1; i<=32; i++) { var nNum=0; nNum=parseInt(Math.random()*16); sGuid+=nNum.toString(16); if(i==8||i==12||i==16||i==20)sGuid+='-'; } return '{'+sGuid.toUpperCase()+'}'; } } (function(window){ /** * 对话框缓存ajax请求 */ var html_caches={}; /** * Float对话框 * (String)load_url - 加载的地址 * (Object)option - 配置项(title|titlebg|contentClass|id|width|height|left|top|isCenter|overlay|showBottom|zIndex|open|close) */ function wp_floatpanel(load_url,option){ var config = $.extend({},{ title: 'Title', titlebg: true, contentClass: 'wp-panel_outpadding', id: 'wp-float_panel', width: 286, height: 'auto', left: 5, top: 60, isCenter: false, overlay: false, isIframe: false, contain:$('body'), zIndex: 1000, showBottom: false, cache: true, postbody:false, swfFix: false, open: function(){}, close: function(){}, data: option['data']||"{}", },option||{}); // Remove old panel var pnl,$pnl,wp_timer,id = config.id,$target = id?$('#'+id):$('.wp-floatpanel_dialog'),$contain=config.contain; // Init parameters var rgx = /^\d+$/i,plw = config.width,plh = config.height,pllt = config.left,pltp = config.top,cc = config.contentClass, ct = config.isCenter,ol = config.overlay,z = config.zIndex,sm = config.showBottom,isfrm = config.isIframe; if (!$target.size()) { // Init overlay var ols = ''; if (ol) { var $overlay = $('#wp-floatpanel_overlay'); if($overlay.size() > 0) $overlay.remove(); ols = '
    '; z += 1; } // Show or not bottom var sms = ''; if (sm) { sms += '
    '+translate('property.showInBottom')+'
    ' + '
    x:' + 'y:' + 'w:' + 'h:' + '
    '; } // Loading area var $tmpwin = $(window),$load = $('#wp-floatpanel_loading'),loadstr = '
    '; if($load.size() > 0) $load.remove(); // Create panel var superid = $.options ? $.options.superid : 0; // var $ap = $(''+ols+loadstr).appendTo($contain); pnl = $ap[0];$pnl = $(pnl); // Loading position var winWidth = $tmpwin.width(),pnlWidth = $pnl.width(); $('#wp-floatpanel_loading').width(winWidth).height($tmpwin.height()); // Events $pnl.draggable({handle: '.wp-title',cancel: '.wp-icon',cursor: 'move',scroll: false,iframeFix: true,start: function(e,ui){ var $target = $(this),titleH = $target.find('.wp-title').outerHeight(); $('.wp-diy-selected-content').slideUp().remove();// 拖拽弹窗时注销“自定义SELECT下拉框” 2012/11/09 // SWF object ghost lines if (config.swfFix) { var $swf = $target.find('object'); if ($swf.length > 0) { $swf.parent().data("wpswfsize",{"width": $swf.width(),"height": $swf.height()}); $swf.css({"height": '0',"width": '0',"visibility": 'hidden'}); } $swf = null; } if ($target.find('iframe').length > 0) { var $innerfrm = $target.find('.ui-resizable-innerIframeFix'); ($innerfrm.length > 0) && $innerfrm.remove(); $('
    ').css({ left: 0,top: titleH+'px',position: 'absolute',opacity: '0.001',zIndex: 1000, width: $target.width()+'px', height: ($target.height() - titleH)+'px' }).appendTo($target); } },drag: function(e,ui){ var pos = ui.position;// 防溢出 2012/10/29 if(pos.top < 0) pos.top = 0; if(pos.left <0) pos.left = 0; if(winWidth < pnlWidth + pos.left) pos.left = winWidth - pnlWidth; },stop: function(){ var $innerfrm = $('.ui-resizable-innerIframeFix', this); ($innerfrm.length > 0) && $innerfrm.remove(); // SWF object ghost lines if (config.swfFix) { var $swf = $(this).find('object'); if ($swf.length > 0) { var $swfprt = $swf.parent(),swfsize = $swfprt.data('wpswfsize'); $swf.css({"height": (swfsize.height||24)+'px',"width": (swfsize.width||82)+'px',"visibility": 'visible'}); $swfprt.removeData('wpswfsize');$swfprt = swfsize = null; } $swf = null; } }}).bind('wpdialogclose',function(e){ $pnl = {};// 注销$pnl对象 clearTimeout(wp_timer); var dom = $(e.target); if(ol) dom = dom.add('#wp-floatpanel_overlay'); if($.isFunction(config.close)) config.close(dom[0]); $(document).trigger('click');//IE8中无法移除cstselect插件的div.wp-diy-selected-content return dom.add('#wp-floatpanel_loading').remove(); }); } else { $pnl = $target; pnl = $target[0]; } // Load content $.Deferred(function(dtd){ // Modal setting if (isfrm == false) { if(config.cache && html_caches[load_url]){ var data=html_caches[load_url]; dtd.resolve(data); }else{ var ajaxopts={}; if(config.postbody) ajaxopts={data:config.postbody}; $.ajax($.extend({ type: "POST",url: load_url, data: config.data, beforeSend: function(){ // 取消全局设置属性以修复IE“闪屏”问题 2012/10/30 },success: function(data){ if(data.length > 0){ if(data == 'Session expired') window.location.href = getSessionExpiredUrl(); dtd.resolve(data); if(config.cache) html_caches[load_url]=data; } else dtd.reject(); },error: function(xhr, textStatus, errorThrown){ wp_alert((errorThrown||textStatus)+'('+config.title+')'+".
    "+translate('Request failed!')); $pnl.triggerHandler('wpdialogclose'); return false; } },ajaxopts)); } } else { var frmw = plw - 26/*左右padding值为2*13px*/,frame = '
    ' +''; dtd.resolve(frame); } return dtd.promise(); }).done(function(data){ $('#wp-floatpanel_loading').remove(); // Append innerHTML var ocs = {}; $('.'+cc,pnl).html(data); if(rgx.test(plw)) ocs['width'] = plw+'px'; if(rgx.test(plh)) ocs['height'] = plh+'px'; // Reset position if (ct || ol) { $pnl.show().css(ocs); wp_timer = setTimeout(function(){ $pnl.triggerHandler('wpdialogsetpos'); },30); // Bind window resize $(window).resize(function(){ panel_position($pnl,plw,plh,ol,'wp-floatpanel_overlay'); }); $pnl.bind('wpdialogsetpos',function(e){ panel_position($pnl,plw,plh,ol,'wp-floatpanel_overlay'); }); } else { if(rgx.test(pllt)) ocs['left'] = pllt+'px'; if(rgx.test(pltp)) ocs['top'] = pltp+'px'; $pnl.css(ocs).show();//.animate(ocs,'slow'); } config.open(pnl); }).fail(function(){ wp_alert(config.title+"(deferred fail).
    "+translate('Request failed!')); $pnl.triggerHandler('wpdialogclose'); return false; }); // Bind close events $('.wp-title a.close',pnl).bind('click',function(e){ $pnl.triggerHandler('wpdialogclose'); // IE下禁止触发onbeforeunload e.preventDefault(); }); return null; } window.wp_floatpanel=wp_floatpanel; })(window); // Dialog定位 function panel_position(dom,width,height,isoverlay,overlayid){ if(dom instanceof jQuery == false) return; var $target = dom,/*$win = $(window),*/tpw = $target.outerWidth(true),tph = $target.outerHeight(true), floor = Math.floor,rgx = /^\d+$/i,ocs = {}; var scrolltop=$(document).scrollTop(); // Parse if(rgx.test(height)) tph = height; tpw = Math.max(tpw,width); // var wnw = $win.width(),wnh = $win.height(); var wnw = window.innerWidth || self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, wnh = window.innerHeight || self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; pltp = floor((wnh - tph)/2); pllt = floor((wnw - tpw)/2); // Overlay if(isoverlay) $('#'+overlayid).width(wnw).height(wnh); // Panel ocs['left'] = pllt+'px'; ocs['top'] = ((pltp>0?pltp:0)+scrolltop)+'px'; $target.css(ocs);//animate(ocs,'slow'); // return ocs; } $._parseFloat = function(numString){ var number = parseFloat(numString); if(isNaN(number)) return 0; return number; } function fix_img_url_path(imgurl){ var escapeRegExp = (function () { var specials = [ '-','[',']', 'index.html','{', '}', '(',')', '*','+','?', '.','\\', '^','$', '|' ]; var regex = new RegExp('[' + specials.join('\\') + ']', 'g'); return function escapeRegExp(str) { return str.replace(regex, '\\$&'); }; })(); var imgfilenameregxp=/\/([^\/]+)$/; var matches=imgurl.match(imgfilenameregxp); var codedimgurl=''; if(matches){ var oldfilename=matches[1]; var newfilename=encodeURIComponent(oldfilename); var oldfileregexp=new RegExp(escapeRegExp(oldfilename)+'$'); codedimgurl=imgurl.replace(oldfileregexp,newfilename); }else{ codedimgurl=encodeURIComponent(imgurl); } return codedimgurl; } /** * 图片自适应 居中显示 */ function set_pic(obj) { var img = new Image(); img.src =$(obj).attr("src"); var width=img.width; var height=img.height; if(width==0){ width=107; } if(height==0){ height=107; } var W=107; var H=107; var _width=107; var _height=107; var _top=0; if(width>height){ _height=(height*H)/width; _top= (W-_height)/2; $(obj).attr('style','width: ' + _width + 'px;height:'+_height+'px;'); $(obj).parent().css('top', _top); }else{ _width=(width*H)/height; _top= (W-_width)/2; $(obj).attr('style','width: ' + _width + 'px;height:'+_height+'px;left:'+_top+'px;'); $(obj).parent().css({'top':0,'left':_top}); } } /** * 手机站弹窗(模拟新窗口打开) 2014/06/09 */ function msite_popup(url){ var $container = $('#scroll_container'),maxh = $(window).height(), bgimg = relativeToAbsoluteURL('template/default/images/loading.gif'), css = 'position:absolute;top:0;left:0;width:320px;overflow:hidden;z-index:10000', ihtml = '
    '; var $mask = $container.children('.mspopup_mask'); if(! $mask.length) $container.append(ihtml).attr("data-height", $container.height()).height(maxh); } function mspopup_onload(win){ win.height = 'auto'; var bodh = win.contentWindow.document.body.scrollHeight, doch = win.contentWindow.document.documentElement.scrollHeight, maxheight = Math.max(bodh, doch); // Reset height win.height = maxheight; $(win).parent('.mspopup_mask').height(maxheight) .parent('#scroll_container').height(maxheight); }