/*
* @by ambar
* @create 2010-10-20
* @update 2010-10-25
*/
(함수($) {
var html = '
확대 축소
'
$.widget("wo.divZoom",{
_init : function() {
var self = this, opt = self.options, tgt = opt.target, $el = self.element
// 初始一次
if($('div ; .icon-zoom',$el).length) return
$el.append(html)
self.target = ( tgt == '' ? $el : $el.find(tgt) ) ;
// 检测初始值
var level = self.target.attr(opt.dataPrefix);
self.target.attr(opt.dataPrefix,level || opt.level[0]);
self.btnZoomIn = $el.find('span.zoom-in').click( $.proxy(self.zoomIn,self) )
self.btnZoomOut = $el.find('span. Zoom-out').click( $.proxy(self.zoomOut,self) );
},
destroy : function(){
this.element.find('div.icon-zoom' ).remove();
},
옵션 : {
레벨 : [120,160,200],
대상 : '',
속도 : 'normal',
dataPrefix : 'data -zoom-level',
zooming : null,
select : null,
show : null
},
currentLevel : function(){
var self = this, opt = self.options, lvl = Number(self.target.attr(opt.dataPrefix));
return $.inArray(lvl,opt.level);
},
zoomIn : function() {
this.zoom(this.currentLevel() 1);
},
zoomOut : function() {
this.zoom(this.currentLevel() - 1);
},
zoom : function(i){
var self = this, opt = self.options,lvls = opt.level,$tgt = self.target;
if( i<=-1 || i>=lvls.length ) return;
var value = lvls[i],
originalValue = lvls[self.currentLevel()],
style = { 너비:값, 높이:값 };
var data = { 대상 : $tgt, css : 스타일, originalCss : {width:originalValue,height:originalValue} };
var goon = self._trigger('start',null,data);
if(!goon) return;
$tgt.animate(style,
{
기간 : opt.speed,
단계 : function(val) {
var css = { width:val, height:val };
self._trigger('zooming',null,$.extend({},data,{css:css}))
},
complete : function(){
$tgt.attr (opt.dataPrefix,value);
self._trigger('stop',null,data)
}
});
}
});
})(jQuery)
현재