90 lines
2.3 KiB
JavaScript
90 lines
2.3 KiB
JavaScript
$.extend(prototype, {
|
|
bind: function () {
|
|
var options = this.options;
|
|
var $this = this.$element;
|
|
var $cropper = this.$cropper;
|
|
|
|
if ($.isFunction(options.cropstart)) {
|
|
$this.on(EVENT_CROP_START, options.cropstart);
|
|
}
|
|
|
|
if ($.isFunction(options.cropmove)) {
|
|
$this.on(EVENT_CROP_MOVE, options.cropmove);
|
|
}
|
|
|
|
if ($.isFunction(options.cropend)) {
|
|
$this.on(EVENT_CROP_END, options.cropend);
|
|
}
|
|
|
|
if ($.isFunction(options.crop)) {
|
|
$this.on(EVENT_CROP, options.crop);
|
|
}
|
|
|
|
if ($.isFunction(options.zoom)) {
|
|
$this.on(EVENT_ZOOM, options.zoom);
|
|
}
|
|
|
|
$cropper.on(EVENT_MOUSE_DOWN, $.proxy(this.cropStart, this));
|
|
|
|
if (options.zoomable && options.mouseWheelZoom) {
|
|
$cropper.on(EVENT_WHEEL, $.proxy(this.wheel, this));
|
|
}
|
|
|
|
if (options.doubleClickToggle) {
|
|
$cropper.on(EVENT_DBLCLICK, $.proxy(this.dblclick, this));
|
|
}
|
|
|
|
$document.
|
|
on(EVENT_MOUSE_MOVE, (this._cropMove = proxy(this.cropMove, this))).
|
|
on(EVENT_MOUSE_UP, (this._cropEnd = proxy(this.cropEnd, this)));
|
|
|
|
if (options.responsive) {
|
|
$window.on(EVENT_RESIZE, (this._resize = proxy(this.resize, this)));
|
|
}
|
|
},
|
|
|
|
unbind: function () {
|
|
var options = this.options;
|
|
var $this = this.$element;
|
|
var $cropper = this.$cropper;
|
|
|
|
if ($.isFunction(options.cropstart)) {
|
|
$this.off(EVENT_CROP_START, options.cropstart);
|
|
}
|
|
|
|
if ($.isFunction(options.cropmove)) {
|
|
$this.off(EVENT_CROP_MOVE, options.cropmove);
|
|
}
|
|
|
|
if ($.isFunction(options.cropend)) {
|
|
$this.off(EVENT_CROP_END, options.cropend);
|
|
}
|
|
|
|
if ($.isFunction(options.crop)) {
|
|
$this.off(EVENT_CROP, options.crop);
|
|
}
|
|
|
|
if ($.isFunction(options.zoom)) {
|
|
$this.off(EVENT_ZOOM, options.zoom);
|
|
}
|
|
|
|
$cropper.off(EVENT_MOUSE_DOWN, this.cropStart);
|
|
|
|
if (options.zoomable && options.mouseWheelZoom) {
|
|
$cropper.off(EVENT_WHEEL, this.wheel);
|
|
}
|
|
|
|
if (options.doubleClickToggle) {
|
|
$cropper.off(EVENT_DBLCLICK, this.dblclick);
|
|
}
|
|
|
|
$document.
|
|
off(EVENT_MOUSE_MOVE, this._cropMove).
|
|
off(EVENT_MOUSE_UP, this._cropEnd);
|
|
|
|
if (options.responsive) {
|
|
$window.off(EVENT_RESIZE, this._resize);
|
|
}
|
|
}
|
|
});
|