Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update croppic.js #170

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions croppic.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* CROPPIC
* dependancy: jQuery
* author: Ognjen "Zmaj Džedaj" Božičković and Mat Steinlin
* dependency: jQuery
* authors: Ognjen "Zmaj Džedaj" Božičković and Mat Steinlin
*/

(function (window, document) {
Expand All @@ -13,13 +13,14 @@
that.obj = $('#' + id);
that.outputDiv = that.obj;

// DEFAULT OPTIONS
// default options
that.options = {
uploadUrl:'',
uploadData:{},
cropUrl:'',
cropData:{},
outputUrlId:'',

//styles
imgEyecandy:true,
imgEyecandyOpacity:0.2,
Expand Down Expand Up @@ -50,10 +51,10 @@

};

// OVERWRITE DEFAULT OPTIONS
// overwrite the default options
for (i in options) that.options[i] = options[i];

// INIT THE WHOLE DAMN THING!!!
// initialize croppic
that.init();

};
Expand Down Expand Up @@ -138,21 +139,22 @@

var that = this;

// CREATE UPLOAD IMG FORM
// create image upload form
var formHtml = '<form class="' + that.id + '_imgUploadForm" style="visibility: hidden;"> <input type="file" name="img" id="' + that.id + '_imgUploadField"> </form>';
that.outputDiv.append(formHtml);
that.form = that.outputDiv.find('.'+that.id+'_imgUploadForm');


// CREATE FALLBACK IE9 IFRAME
// create a fallback for Internet Explorer 9 iFrames
var fileUploadId = that.CreateFallbackIframe();

that.imgUploadControl.off('click');
that.imgUploadControl.on('click',function(){
if (fileUploadId === "") {
that.form.find('input[type="file"]').trigger('click');
} else {
//Trigger iframe file input click, otherwise access restriction error

//trigger iframe file input click, otherwise access restriction error
that.iframeform.find('input[type="file"]').trigger('click');
}
});
Expand Down Expand Up @@ -225,7 +227,7 @@
// other modern browsers
formData = new FormData(that.form[0]);
} catch(e) {
// IE10 MUST have all form items appended as individual form key / value pairs
// Internet Explorer 10 MUST have all form items appended as individual form key / value pairs
formData = new FormData();
formData.append('img', that.form.find("input[type=file]")[0].files[0]);

Expand Down Expand Up @@ -349,12 +351,10 @@
},
initCropper: function(){
var that = this;

/*SET UP SOME VARS*/
that.img = that.obj.find('img');
that.img.wrap('<div class="cropImgWrapper" style="overflow:hidden; z-index:1; position:absolute; width:'+that.objW+'px; height:'+that.objH+'px;"></div>');

/*INIT DRAGGING*/
// initialize dragging
that.createCropControls();

if(that.options.imgEyecandy){ that.createEyecandy(); }
Expand All @@ -376,7 +376,7 @@
that.zoom(-that.imgInitW);
that.zoom(40);

// Adding mousewheel zoom capabilities
// adding mousewheel zoom capabilities
if (that.options.enableMousescroll){
that.img.on('mousewheel', function(event) {
event.preventDefault();
Expand All @@ -393,7 +393,7 @@
createCropControls: function(){
var that = this;

// CREATE CONTROLS
// create croppic controls
var cropControlZoomMuchIn = '';
var cropControlZoomIn = '<i class="cropControlZoomIn"></i>';
var cropControlZoomOut = '<i class="cropControlZoomOut"></i>';
Expand All @@ -420,7 +420,7 @@

that.cropControlsCrop = that.obj.find('.cropControlsCrop');

// CACHE AND BIND CONTROLS
// cache and bind the controls
if(that.options.doubleZoomControls){
that.cropControlZoomMuchIn = that.cropControlsCrop.find('.cropControlZoomMuchIn');
that.cropControlZoomMuchIn.on('click',function(){ that.zoom( that.options.zoomFactor*10 ); });
Expand Down Expand Up @@ -453,7 +453,7 @@

that.img.on("mousedown touchstart", function(e) {

e.preventDefault(); // disable selection
e.preventDefault();

var pageX;
var pageY;
Expand Down