Version 3.4.5

This commit is contained in:
Neo committed 2025-12-19 00:38:12 -08:00
1 parent fb6b5baabc
commit e4478369d8
1360 files changed
+228921 -179445

No files matched your search

+2 -2
View File
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2006-2009, David Spurr (http://www.defusion.org.uk/)
* Copyright (c) 2006-2011, David Spurr (http://www.defusion.org.uk/)
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
@@ -14,4 +14,4 @@
* See scriptaculous.js for full scriptaculous licence
*/
var CropDraggable=Class.create(Draggable,{initialize:function(a){this.options=Object.extend({drawMethod:function(){}},arguments[1]||{});this.element=$(a);this.handle=this.element;this.delta=this.currentDelta();this.dragging=false;this.eventMouseDown=this.initDrag.bindAsEventListener(this);Event.observe(this.handle,"mousedown",this.eventMouseDown);Draggables.register(this);},draw:function(a){var e=Element.cumulativeOffset(this.element),c=this.currentDelta();e[0]-=c[0];e[1]-=c[1];var b=[0,1].map(function(d){return(a[d]-e[d]-this.offset[d]);}.bind(this));this.options.drawMethod(b);}});var Cropper={};Cropper.Img=Class.create({initialize:function(c,a){this.options=Object.extend({ratioDim:{x:0,y:0},minWidth:0,minHeight:0,displayOnInit:false,onEndCrop:Prototype.emptyFunction,captureKeys:true,onloadCoords:null,maxWidth:0,maxHeight:0,autoIncludeCSS:true},a||{});this.img=$(c);this.clickCoords={x:0,y:0};this.dragging=false;this.resizing=false;this.isWebKit=/Konqueror|Safari|KHTML/.test(navigator.userAgent);this.isIE=/MSIE/.test(navigator.userAgent);this.isOpera8=/Opera\s[1-8]/.test(navigator.userAgent);this.ratioX=0;this.ratioY=0;this.attached=false;this.fixedWidth=(this.options.maxWidth>0&&(this.options.minWidth>=this.options.maxWidth));this.fixedHeight=(this.options.maxHeight>0&&(this.options.minHeight>=this.options.maxHeight));if(typeof this.img=="undefined"){return;}if(this.options.autoIncludeCSS){$$("script").each(function(e){if(e.src.match(/\/cropper([^\/]*)\.js/)){var f=e.src.replace(/\/cropper([^\/]*)\.js.*/,""),d=document.createElement("link");d.rel="stylesheet";d.type="text/css";d.href=f+"/cropper.css";d.media="screen";document.getElementsByTagName("head")[0].appendChild(d);}});}if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0){var b=this.getGCD(this.options.ratioDim.x,this.options.ratioDim.y);this.ratioX=this.options.ratioDim.x/b;this.ratioY=this.options.ratioDim.y/b;}this.subInitialize();if(this.img.complete||this.isWebKit){this.onLoad();}else{Event.observe(this.img,"load",this.onLoad.bindAsEventListener(this));}},getGCD:function(d,c){if(c===0){return d;}return this.getGCD(c,d%c);},onLoad:function(){var c="imgCrop_";var e=this.img.parentNode;var b="";if(this.isOpera8){b=" opera8";}this.imgWrap=new Element("div",{"class":c+"wrap"+b});this.north=new Element("div",{"class":c+"overlay "+c+"north"}).insert(new Element("span"));this.east=new Element("div",{"class":c+"overlay "+c+"east"}).insert(new Element("span"));this.south=new Element("div",{"class":c+"overlay "+c+"south"}).insert(new Element("span"));this.west=new Element("div",{"class":c+"overlay "+c+"west"}).insert(new Element("span"));var d=[this.north,this.east,this.south,this.west];this.dragArea=new Element("div",{"class":c+"dragArea"});d.each(function(f){this.dragArea.insert(f);},this);this.handleN=new Element("div",{"class":c+"handle "+c+"handleN"});this.handleNE=new Element("div",{"class":c+"handle "+c+"handleNE"});this.handleE=new Element("div",{"class":c+"handle "+c+"handleE"});this.handleSE=new Element("div",{"class":c+"handle "+c+"handleSE"});this.handleS=new Element("div",{"class":c+"handle "+c+"handleS"});this.handleSW=new Element("div",{"class":c+"handle "+c+"handleSW"});this.handleW=new Element("div",{"class":c+"handle "+c+"handleW"});this.handleNW=new Element("div",{"class":c+"handle "+c+"handleNW"});this.selArea=new Element("div",{"class":c+"selArea"});[new Element("div",{"class":c+"marqueeHoriz "+c+"marqueeNorth"}).insert(new Element("span")),new Element("div",{"class":c+"marqueeVert "+c+"marqueeEast"}).insert(new Element("span")),new Element("div",{"class":c+"marqueeHoriz "+c+"marqueeSouth"}).insert(new Element("span")),new Element("div",{"class":c+"marqueeVert "+c+"marqueeWest"}).insert(new Element("span")),this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW,new Element("div",{"class":c+"clickArea"})].each(function(f){this.selArea.insert(f);},this);this.imgWrap.appendChild(this.img);this.imgWrap.appendChild(this.dragArea);this.dragArea.appendChild(this.selArea);this.dragArea.appendChild(new Element("div",{"class":c+"clickArea"}));e.appendChild(this.imgWrap);this.startDragBind=this.startDrag.bindAsEventListener(this);Event.observe(this.dragArea,"mousedown",this.startDragBind);this.onDragBind=this.onDrag.bindAsEventListener(this);Event.observe(document,"mousemove",this.onDragBind);this.endCropBind=this.endCrop.bindAsEventListener(this);Event.observe(document,"mouseup",this.endCropBind);this.resizeBind=this.startResize.bindAsEventListener(this);this.handles=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW];this.registerHandles(true);if(this.options.captureKeys){this.keysBind=this.handleKeys.bindAsEventListener(this);Event.observe(document,"keypress",this.keysBind);}var a=new CropDraggable(this.selArea,{drawMethod:this.moveArea.bindAsEventListener(this)});this.setParams();},registerHandles:function(b){for(var d=0;d<thisLine truncated
var CropDraggable=Class.create(Draggable,{initialize:function(a){this.options=Object.extend({drawMethod:function(){}},arguments[1]||{});this.element=$(a);this.handle=this.element;this.delta=this.currentDelta();this.dragging=false;this.eventMouseDown=this.initDrag.bindAsEventListener(this);Event.observe(this.handle,"mousedown",this.eventMouseDown);Draggables.register(this);},draw:function(a){var e=Element.cumulativeOffset(this.element),c=this.currentDelta();e[0]-=c[0];e[1]-=c[1];var b=[0,1].map(function(d){return(a[d]-e[d]-this.offset[d]);}.bind(this));this.options.drawMethod(b);}});var Cropper={};Cropper.Img=Class.create({initialize:function(c,a){this.options=Object.extend({ratioDim:{x:0,y:0},minWidth:0,minHeight:0,displayOnInit:false,onEndCrop:Prototype.emptyFunction,captureKeys:true,onloadCoords:null,maxWidth:0,maxHeight:0,autoIncludeCSS:true},a||{});this.img=$(c);this.clickCoords={x:0,y:0};this.dragging=false;this.resizing=false;this.isWebKit=/Konqueror|Safari|KHTML/.test(navigator.userAgent);this.isIE=/MSIE/.test(navigator.userAgent);this.isOpera8=/Opera\s[1-8]/.test(navigator.userAgent);this.ratioX=0;this.ratioY=0;this.attached=false;this.fixedWidth=(this.options.maxWidth>0&&(this.options.minWidth>=this.options.maxWidth));this.fixedHeight=(this.options.maxHeight>0&&(this.options.minHeight>=this.options.maxHeight));if(typeof this.img=="undefined"){return;}if(this.options.autoIncludeCSS){$$("script").each(function(e){if(e.src.match(/\/cropper([^\/]*)\.js/)){var f=e.src.replace(/\/cropper([^\/]*)\.js.*/,""),d=document.createElement("link");d.rel="stylesheet";d.type="text/css";d.href=f+"/cropper.css";d.media="screen";document.getElementsByTagName("head")[0].appendChild(d);}});}if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0){var b=this.getGCD(this.options.ratioDim.x,this.options.ratioDim.y);this.ratioX=this.options.ratioDim.x/b;this.ratioY=this.options.ratioDim.y/b;}this.subInitialize();if(this.img.complete||this.isWebKit){this.onLoad();}else{Event.observe(this.img,"load",this.onLoad.bindAsEventListener(this));}},getGCD:function(d,c){if(c===0){return d;}return this.getGCD(c,d%c);},onLoad:function(){var c="imgCrop_";var e=this.img.parentNode;var b="";if(this.isOpera8){b=" opera8";}this.imgWrap=new Element("div",{"class":c+"wrap"+b});this.north=new Element("div",{"class":c+"overlay "+c+"north"}).insert(new Element("span"));this.east=new Element("div",{"class":c+"overlay "+c+"east"}).insert(new Element("span"));this.south=new Element("div",{"class":c+"overlay "+c+"south"}).insert(new Element("span"));this.west=new Element("div",{"class":c+"overlay "+c+"west"}).insert(new Element("span"));var d=[this.north,this.east,this.south,this.west];this.dragArea=new Element("div",{"class":c+"dragArea"});d.each(function(f){this.dragArea.insert(f);},this);this.handleN=new Element("div",{"class":c+"handle "+c+"handleN"});this.handleNE=new Element("div",{"class":c+"handle "+c+"handleNE"});this.handleE=new Element("div",{"class":c+"handle "+c+"handleE"});this.handleSE=new Element("div",{"class":c+"handle "+c+"handleSE"});this.handleS=new Element("div",{"class":c+"handle "+c+"handleS"});this.handleSW=new Element("div",{"class":c+"handle "+c+"handleSW"});this.handleW=new Element("div",{"class":c+"handle "+c+"handleW"});this.handleNW=new Element("div",{"class":c+"handle "+c+"handleNW"});this.selArea=new Element("div",{"class":c+"selArea"});[new Element("div",{"class":c+"marqueeHoriz "+c+"marqueeNorth"}).insert(new Element("span")),new Element("div",{"class":c+"marqueeVert "+c+"marqueeEast"}).insert(new Element("span")),new Element("div",{"class":c+"marqueeHoriz "+c+"marqueeSouth"}).insert(new Element("span")),new Element("div",{"class":c+"marqueeVert "+c+"marqueeWest"}).insert(new Element("span")),this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW,new Element("div",{"class":c+"clickArea"})].each(function(f){this.selArea.insert(f);},this);this.imgWrap.appendChild(this.img);this.imgWrap.appendChild(this.dragArea);this.dragArea.appendChild(this.selArea);this.dragArea.appendChild(new Element("div",{"class":c+"clickArea"}));e.appendChild(this.imgWrap);this.startDragBind=this.startDrag.bindAsEventListener(this);Event.observe(this.dragArea,"mousedown",this.startDragBind);this.onDragBind=this.onDrag.bindAsEventListener(this);Event.observe(document,"mousemove",this.onDragBind);this.endCropBind=this.endCrop.bindAsEventListener(this);Event.observe(document,"mouseup",this.endCropBind);this.resizeBind=this.startResize.bindAsEventListener(this);this.handles=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW];this.registerHandles(true);if(this.options.captureKeys){this.keysBind=this.handleKeys.bindAsEventListener(this);Event.observe(document,"keypress",this.keysBind);}var a=new CropDraggable(this.selArea,{drawMethod:this.moveArea.bindAsEventListener(this)});this.setParams();},registerHandles:function(b){for(var d=0;d<thisLine truncated
+34 -23
View File
@@ -1,6 +1,6 @@
/**
* Image Cropper (v. 1.2.1 - 2009-10-06 )
* Copyright (c) 2006-2009 David Spurr (http://www.defusion.org.uk/)
* Image Cropper (v. 1.2.2 - 2011-07-04 )
* Copyright (c) 2006-2011 David Spurr (http://www.defusion.org.uk/)
*
* The image cropper provides a way to draw a crop area on an image and capture
* the coordinates of the drawn crop area.
@@ -26,12 +26,15 @@
* 10 pixels )
* - All operations stay within bounds of image
* - All functionality & display compatible with most popular browsers supported by Prototype:
* PC: IE 8, 7, 6 & 5.5, Firefox 2, 3, 3.5, Opera 8.5 (see known issues) & 9.0b
* MAC: Camino 1.0, Firefox 2, 3, 3.5, Safari 3.x, 4
* PC: IE 9, 8, 7, 6 & 5.5, Firefox 2+, Opera 8.5 (see known issues) & 9.0b +, Google Chrome
* MAC: Camino 1.0, Firefox 2+, Safari 3.x+, Google Chrome
*
* Requires:
* - Prototype v. 1.5.0_rc0 > (as packaged with Scriptaculous 1.6.1)
* - Scriptaculous v. 1.6.1 > modules: dragdrop
* Recommended (for IE9+ support):
* - Prototype v. 1.7.0 >
* - Scriptaculous v. 1.9.0 >
*
* Known issues:
* - Safari animated gifs, only one of each will animate, this seems to be a known Safari issue
@@ -58,6 +61,10 @@
* See Cropper.Img & Cropper.ImgWithPreview for usage details
*
* Changelog:
* v1.2.2 - 2011-07-04
* + Support for latest versions of Prototype & script.aculo.us (1.7.0 & 1.9.0 respectively)
* + Support notice for IE9
*
* v1.2.1 - 2009-10-06
* + Added support for latest versions of Prototype & script.aculo.us
* (1.6.1.0 & 1.8.2 respectively). Changes provided by Tom Hirashima.
@@ -111,7 +118,7 @@
* + Initial verison
*
*
* Copyright (c) 2006-2009, David Spurr (http://www.defusion.org.uk/)
* Copyright (c) 2006-2011, David Spurr (http://www.defusion.org.uk/)
*
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -586,12 +593,12 @@ Cropper.Img = Class.create({
* @var int
* The image width
*/
this.imgW = this.img.readAttribute('width');
this.imgW = this.img.width;
/**
* @var int
* The image height
*/
this.imgH = this.img.readAttribute('height');
this.imgH = this.img.height;
$( this.north ).setStyle( { height: 0 } );
$( this.east ).setStyle( { width: 0, height: 0 } );
@@ -681,20 +688,24 @@ Cropper.Img = Class.create({
var dir = { x: 0, y: 0 }; // direction to move it in & the amount in pixels
if( !this.dragging ) {
// catch the arrow keys
switch( e.keyCode ) {
case( 37 ) : // left
dir.x = -1;
break;
case( 38 ) : // up
dir.y = -1;
break;
case( 39 ) : // right
dir.x = 1;
break;
case( 40 ) : // down
dir.y = 1;
break;
// IPS modification
if( !e.shiftKey )
{
// catch the arrow keys
switch( e.keyCode ) {
case( 37 ) : // left
dir.x = -1;
break;
case( 38 ) : // up
dir.y = -1;
break;
case( 39 ) : // right
dir.x = 1;
break;
case( 40 ) : // down
dir.y = 1;
break;
}
}
if( dir.x !== 0 || dir.y !== 0 ) {
@@ -1019,8 +1030,8 @@ Cropper.Img = Class.create({
areaHeight + px, // height of the selArea
this.areaCoords.x2 + px, // bottom of the selArea
this.areaCoords.y2 + px, // right of the selArea
(this.img.readAttribute('width') - this.areaCoords.x2) + px, // right edge of selArea
(this.img.readAttribute('height')- this.areaCoords.y2) + px // bottom edge of selArea
(this.img.width - this.areaCoords.x2) + px, // right edge of selArea
(this.img.height - this.areaCoords.y2) + px // bottom edge of selArea
];
// do the select area
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2006-2009, David Spurr (www.defusion.org.uk)
Copyright (c) 2006-2011, David Spurr (www.defusion.org.uk)
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: