Вход Регистрация
Файл: adultscript-2.0.3-pro/files/misc/jquery-guillotine/jquery.guillotine.min.js
Строк: 333
<?php
/*
 * jQuery Guillotine Plugin v1.3.0
 * http://matiasgagliano.github.com/guillotine/
 *
 * Copyright 2014, Matías Gagliano.
 * Dual licensed under the MIT or GPLv3 licenses.
 * http://opensource.org/licenses/MIT
 * http://opensource.org/licenses/GPL-3.0
 *
 */

(function(){"use strict";var t,i,e,h,s,n,o,r,a,l,d,u,g,p=function(t,i){return function(){return t.apply(i,arguments)}},c=[].indexOf||function(t){for(var i=0,e=this.length;e>i;i++)if(i in this&&this[i]===t)return i;return-1};t=jQuery,a="guillotine",l="guillotine",s={start:"touchstart."+l+" mousedown."+l,move:"touchmove."+l+" mousemove."+l,stop:"touchend."+l+" mouseup."+l},h={width:400,height:300,zoomStep:.1,init:null,eventOnChange:null,onChange:null},d=/touch/i,r=function(t){return d.test(t.type)},u=function(t){return r(t)?1===t.originalEvent.changedTouches.length:1===t.which},n=function(t){return r(t)&&(t=t.originalEvent.touches[0]),{x:t.pageX,y:t.pageY}},e=function(){var t,i,h,s,n,o,r,a,l,d;for(t=!1,s=["webkit","Moz","O","ms","Khtml"],r={transform:"transform"},l=0,d=s.length;d>l;l++)h=s[l],r[h+"Transform"]="-"+h.toLowerCase()+"-transform";i=document.createElement("img"),document.body.insertBefore(i,null);for(o in r)if(n=r[o],void 0!==i.style[o]&&(i.style[o]="rotate(90deg)",a=window.getComputedStyle(i).getPropertyValue(n),null!=a&&a.length&&"none"!==a)){t=!0;break}return document.body.removeChild(i),(e=t?function(){return!0}:function(){return!1})()},o=function(i){return t(i).css({"-webkit-perspective":1e3,perspective:1e3,"-webkit-backface-visibility":"hidden","backface-visibility":"hidden"})},i=function(){function i(i,e){this._drag=p(this._drag,this),this._unbind=p(this._unbind,this),this._start=p(this._start,this),this.op=t.extend(!0,{},h,e,t(i).data(a)),this.enabled=!0,this.zoomInFactor=1+this.op.zoomStep,this.zoomOutFactor=1/this.zoomInFactor,this.glltRatio=this.op.height/this.op.width,this.width=this.height=this.left=this.top=this.angle=0,this.data={scale:1,angle:0,x:0,y:0,w:this.op.width,h:this.op.height},this._wrap(i),null!=this.op.init&&this._init(),(this.width<1||this.height<1)&&this._fit()&&this._center(),o(this.$el),this.$el.on(s.start,this._start)}return i.prototype._wrap=function(i){var e,h,s,n,o,r;return h=t(i),"IMG"===i.tagName?i.naturalWidth?(r=i.naturalWidth,n=i.naturalHeight):(h.addClass("guillotine-sample"),r=h.width(),n=h.height(),h.removeClass("guillotine-sample")):(r=h.width(),n=h.height()),this.width=r/this.op.width,this.height=n/this.op.height,e=t("<div>").addClass("guillotine-canvas"),e.css({width:100*this.width+"%",height:100*this.height+"%",top:0,left:0}),e=h.wrap(e).parent(),o=this.op.height/this.op.width*100+"%",s=t("<div>").addClass("guillotine-window"),s.css({width:"100%",height:"auto","padding-top":o}),s=e.wrap(s).parent(),this.$el=h,this.el=h[0],this.$canvas=e,this.canvas=e[0],this.$gllt=s,this.gllt=s[0],this.$document=t(i.ownerDocument),this.$body=t("body",this.$document)},i.prototype._unwrap=function(){return this.$el.removeAttr("style"),this.$el.insertBefore(this.gllt),this.$gllt.remove()},i.prototype._init=function(){var t,i,e;return i=this.op.init,(e=parseFloat(i.scale))&&this._zoom(e),(t=parseInt(i.angle))&&this._rotate(t),this._offset(parseInt(i.x)/this.op.width||0,parseInt(i.y)/this.op.height||0)},i.prototype._start=function(t){return this.enabled&&u(t)?(t.preventDefault(),t.stopImmediatePropagation(),this.p=n(t),this._bind()):void 0},i.prototype._bind=function(){return this.$body.addClass("guillotine-dragging"),this.$document.on(s.move,this._drag),this.$document.on(s.stop,this._unbind)},i.prototype._unbind=function(t){return this.$body.removeClass("guillotine-dragging"),this.$document.off(s.move,this._drag),this.$document.off(s.stop,this._unbind),null!=t?this._trigger("drag"):void 0},i.prototype._trigger=function(t){return null!=this.op.eventOnChange&&this.$el.trigger(this.op.eventOnChange,[this.data,t]),"function"==typeof this.op.onChange?this.op.onChange.call(this.el,this.data,t):void 0},i.prototype._drag=function(t){var i,e,h,s,o;return t.preventDefault(),t.stopImmediatePropagation(),s=n(t),i=s.x-this.p.x,e=s.y-this.p.y,this.p=s,h=0===i?null:this.left-i/this.gllt.clientWidth,o=0===e?null:this.top-e/this.gllt.clientHeight,this._offset(h,o)},i.prototype._offset=function(t,i){return(t||0===t)&&(0>t&&(t=0),t>this.width-1&&(t=this.width-1),this.canvas.style.left=(100*-t).toFixed(2)+"%",this.left=t,this.data.x=Math.round(t*this.op.width)),i||0===i?(0>i&&(i=0),i>this.height-1&&(i=this.height-1),this.canvas.style.top=(100*-i).toFixed(2)+"%",this.top=i,this.data.y=Math.round(i*this.op.height)):void 0},i.prototype._zoom=function(t){var i,e,h,s;if(!(0>=t||1===t))return s=this.width,i=this.height,s*t>1&&i*t>1?(this.width*=t,this.height*=t,this.canvas.style.width=(100*this.width).toFixed(2)+"%",this.canvas.style.height=(100*this.height).toFixed(2)+"%",this.data.scale*=t):(this._fit(),t=this.width/s),e=(this.left+.5)*t-.5,h=(this.top+.5)*t-.5,this._offset(e,h)},i.prototype._fit=function(){var t,i;return t=this.width,i=this.height/this.width,i>1?(this.width=1,this.height=i):(this.width=1/i,this.height=1),this.canvas.style.width=(100*this.width).toFixed(2)+"%",this.canvas.style.height=(100*this.height).toFixed(2)+"%",this.data.scale*=this.width/t},i.prototype._center=function(){return this._offset((this.width-1)/2,(this.height-1)/2)},i.prototype._rotate=function(t){var i,h,s,n,o,r,a;if(e()&&0!==t&&t%90===0)return this.angle=(this.angle+t)%360,this.angle<0&&(this.angle=360+this.angle),t%180!==0&&(h=this.op.height/this.op.width,o=[this.height*h,this.width/h],this.width=o[0],this.height=o[1],this.width>=1&&this.height>=1?(this.canvas.style.width=100*this.width+"%",this.canvas.style.height=100*this.height+"%"):this._fit()),r=[1,1],n=r[0],s=r[1],this.angle%180!==0&&(i=this.height/this.width*h,a=[i,1/i],n=a[0],s=a[1]),this.el.style.width=100*n+"%",this.el.style.height=100*s+"%",this.el.style.left=(1-n)/2*100+"%",this.el.style.top=(1-s)/2*100+"%",this.$el.css({transform:"rotate("+this.angle+"deg)"}),this._center(),this.data.angle=this.angle},i.prototype.rotateLeft=function(){return this.enabled&&(this._rotate(-90),this._trigger("rotateLeft"))},i.prototype.rotateRight=function(){return this.enabled&&(this._rotate(90),this._trigger("rotateRight"))},i.prototype.center=function(){return this.enabled&&(this._center(),this._trigger("center"))},i.prototype.fit=function(){return this.enabled&&(this._fit(),this._center(),this._trigger("fit"))},i.prototype.zoomIn=function(){return this.enabled&&(this._zoom(this.zoomInFactor),this._trigger("zoomIn"))},i.prototype.zoomOut=function(){return this.enabled&&(this._zoom(this.zoomOutFactor),this._trigger("zoomOut"))},i.prototype.getData=function(){return this.data},i.prototype.enable=function(){return this.enabled=!0},i.prototype.disable=function(){return this.enabled=!1},i.prototype.remove=function(){return this._unbind(),this._unwrap(),this.disable(),this.$el.off(s.start,this._start),this.$el.removeData(a+"Instance")},i}(),g=["rotateLeft","rotateRight","center","fit","zoomIn","zoomOut","instance","getData","enable","disable","remove"],t.fn[a]=function(e){return"string"!=typeof e?this.each(function(){var h;return t.data(this,a+"Instance")?void 0:(h=new i(this,e),t.data(this,a+"Instance",h))}):c.call(g,e)>=0?"instance"===e?t.data(this[0],a+"Instance"):"getData"===e?t.data(this[0],a+"Instance")[e]():this.each(function(){var i;return i=t.data(this,a+"Instance"),i?i[e]():void 0}):void 0}}).call(this);
?>
Онлайн: 0
Реклама