(function() { var supportsCanvas = document.createElement('canvas'); supportsCanvas = !!(supportsCanvas.getContext && supportsCanvas.getContext('2d')); // helper functions function is_touch_device() { return 'ontouchstart' in window || // works on most browsers 'onmsgesturechange' in window; // works on ie10 } function fill(value, target, container) { if (value + target < container) value = container - target; return value > 0 ? 0 : value; } function uri2blob(dataURI) { var uriComponents = dataURI.split(','); var byteString = atob(uriComponents[1]); var mimeString = uriComponents[0].split(':')[1].split(';')[0]; var ab = new ArrayBuffer(byteString.length); var ia = new Uint8Array(ab); for (var i = 0; i < byteString.length; i++) ia[i] = byteString.charCodeAt(i); return new Blob([ab], { type: mimeString }); } var pluginName = 'cropbox'; function factory($) { function Crop($image, options, on_load) { this.width = null; this.height = null; this.img_width = null; this.img_height = null; this.img_left = 0; this.img_top = 0; this.minPercent = null; this.options = options; this.$image = $image; this.$image.hide().prop('draggable', false).addClass('cropImage').wrap('
'); // wrap image in frame; this.$frame = this.$image.parent(); this.on_load = on_load || function() {}; this.init(); } Crop.prototype = { init: function () { var self = this; var defaultControls = $('
', { 'class' : 'cropControls' }) .append($(''+this.options.label+'')) .append($('