/** * Selection * Built-in selection object */ var Selection = function(){}; $.extend(Selection,{ // defaults: {{{ defaults: { minSize: [ 8, 8 ], maxSize: [ 0, 0 ], aspectRatio: 0, edge: { n: 0, s: 0, e: 0, w: 0 }, bgColor: null, bgOpacity: null, last: null, state: null, active: true, linked: true, canDelete: true, canDrag: true, canResize: true, canSelect: true }, // }}} prototype: { // init: function(core){{{ init: function(core){ this.core = core; this.startup(); this.linked = this.core.opt.linked; this.attach(); this.setOptions(this.core.opt); core.container.trigger('cropcreate',[this]); }, // }}} // attach: function(){{{ attach: function(){ // For extending init() sequence }, // }}} // startup: function(){{{ startup: function(){ var t = this, o = t.core.opt; $.extend(t,Selection.defaults); t.filter = t.core.getDefaultFilters(); t.element = $('
').addClass(o.css_selection).data({ selection: t }); t.frame = $('').addClass(o.css_button).data('ord','move').attr('type','button'); t.element.append(t.frame).appendTo(t.core.container); // IE background/draggable hack if (t.core.opt.is_msie) t.frame.css({ opacity: 0, backgroundColor: 'white' }); t.insertElements(); // Bind focus and blur events for this selection t.frame.on('focus.jcrop',function(e){ t.core.setSelection(t); t.element.trigger('cropfocus',t); t.element.addClass('jcrop-focus'); }).on('blur.jcrop',function(e){ t.element.removeClass('jcrop-focus'); t.element.trigger('cropblur',t); }); }, // }}} // propagate: [{{{ propagate: [ 'canDelete', 'canDrag', 'canResize', 'canSelect', 'minSize', 'maxSize', 'aspectRatio', 'edge' ], // }}} // setOptions: function(opt){{{ setOptions: function(opt){ Jcrop.propagate(this.propagate,opt,this); this.refresh(); return this; }, // }}} // refresh: function(){{{ refresh: function(){ this.allowResize(); this.allowDrag(); this.allowSelect(); this.callFilterFunction('refresh'); this.updateRaw(this.get(),'se'); }, // }}} // callFilterFunction: function(f,args){{{ callFilterFunction: function(f,args){ for(var i=0;i