Blame view

src/main/webapp/libs/jquery-easyui-1.4.1/plugins/jquery.timespinner.js 4.51 KB
caiyongsong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
/**
 * jQuery EasyUI 1.4.1
 * 
 * Copyright (c) 2009-2014 www.jeasyui.com. All rights reserved.
 *
 * Licensed under the GPL license: http://www.gnu.org/licenses/gpl.txt
 * To use it on other terms please contact us at info@jeasyui.com
 *
 */
(function($){
function _1(_2){
var _3=0;
if(_2.selectionStart){
_3=_2.selectionStart;
}else{
if(_2.createTextRange){
var _4=_2.createTextRange();
var s=document.selection.createRange();
s.setEndPoint("StartToStart",_4);
_3=s.text.length;
}
}
return _3;
};
function _5(_6,_7,_8){
if(_6.selectionStart){
_6.setSelectionRange(_7,_8);
}else{
if(_6.createTextRange){
var _9=_6.createTextRange();
_9.collapse();
_9.moveEnd("character",_8);
_9.moveStart("character",_7);
_9.select();
}
}
};
function _a(_b){
var _c=$.data(_b,"timespinner").options;
$(_b).addClass("timespinner-f").spinner(_c);
var _d=_c.formatter.call(_b,_c.parser.call(_b,_c.value));
$(_b).timespinner("initValue",_d);
};
function _e(e){
var _f=e.data.target;
var _10=$.data(_f,"timespinner").options;
var _11=_1(this);
for(var i=0;i<_10.selections.length;i++){
var _12=_10.selections[i];
if(_11>=_12[0]&&_11<=_12[1]){
_13(_f,i);
return;
}
}
};
function _13(_14,_15){
var _16=$.data(_14,"timespinner").options;
if(_15!=undefined){
_16.highlight=_15;
}
var _17=_16.selections[_16.highlight];
if(_17){
var tb=$(_14).timespinner("textbox");
_5(tb[0],_17[0],_17[1]);
tb.focus();
}
};
function _18(_19,_1a){
var _1b=$.data(_19,"timespinner").options;
var _1a=_1b.parser.call(_19,_1a);
var _1c=_1b.formatter.call(_19,_1a);
$(_19).spinner("setValue",_1c);
};
function _1d(_1e,_1f){
var _20=$.data(_1e,"timespinner").options;
var s=$(_1e).timespinner("getValue");
var _21=_20.selections[_20.highlight];
var s1=s.substring(0,_21[0]);
var s2=s.substring(_21[0],_21[1]);
var s3=s.substring(_21[1]);
var v=s1+((parseInt(s2)||0)+_20.increment*(_1f?-1:1))+s3;
$(_1e).timespinner("setValue",v);
_13(_1e);
};
$.fn.timespinner=function(_22,_23){
if(typeof _22=="string"){
var _24=$.fn.timespinner.methods[_22];
if(_24){
return _24(this,_23);
}else{
return this.spinner(_22,_23);
}
}
_22=_22||{};
return this.each(function(){
var _25=$.data(this,"timespinner");
if(_25){
$.extend(_25.options,_22);
}else{
$.data(this,"timespinner",{options:$.extend({},$.fn.timespinner.defaults,$.fn.timespinner.parseOptions(this),_22)});
}
_a(this);
});
};
$.fn.timespinner.methods={options:function(jq){
var _26=jq.data("spinner")?jq.spinner("options"):{};
return $.extend($.data(jq[0],"timespinner").options,{width:_26.width,value:_26.value,originalValue:_26.originalValue,disabled:_26.disabled,readonly:_26.readonly});
},setValue:function(jq,_27){
return jq.each(function(){
_18(this,_27);
});
},getHours:function(jq){
var _28=$.data(jq[0],"timespinner").options;
var vv=jq.timespinner("getValue").split(_28.separator);
return parseInt(vv[0],10);
},getMinutes:function(jq){
var _29=$.data(jq[0],"timespinner").options;
var vv=jq.timespinner("getValue").split(_29.separator);
return parseInt(vv[1],10);
},getSeconds:function(jq){
var _2a=$.data(jq[0],"timespinner").options;
var vv=jq.timespinner("getValue").split(_2a.separator);
return parseInt(vv[2],10)||0;
}};
$.fn.timespinner.parseOptions=function(_2b){
return $.extend({},$.fn.spinner.parseOptions(_2b),$.parser.parseOptions(_2b,["separator",{showSeconds:"boolean",highlight:"number"}]));
};
$.fn.timespinner.defaults=$.extend({},$.fn.spinner.defaults,{inputEvents:$.extend({},$.fn.spinner.defaults.inputEvents,{click:function(e){
_e.call(this,e);
},blur:function(e){
var t=$(e.data.target);
t.timespinner("setValue",t.timespinner("getText"));
},keydown:function(e){
if(e.keyCode==13){
var t=$(e.data.target);
t.timespinner("setValue",t.timespinner("getText"));
}
}}),formatter:function(_2c){
if(!_2c){
return "";
}
var _2d=$(this).timespinner("options");
var tt=[_2e(_2c.getHours()),_2e(_2c.getMinutes())];
if(_2d.showSeconds){
tt.push(_2e(_2c.getSeconds()));
}
return tt.join(_2d.separator);
function _2e(_2f){
return (_2f<10?"0":"")+_2f;
};
},parser:function(s){
var _30=$(this).timespinner("options");
var _31=_32(s);
if(_31){
var min=_32(_30.min);
var max=_32(_30.max);
if(min&&min>_31){
_31=min;
}
if(max&&max<_31){
_31=max;
}
}
return _31;
function _32(s){
if(!s){
return null;
}
var tt=s.split(_30.separator);
return new Date(1900,0,0,parseInt(tt[0],10)||0,parseInt(tt[1],10)||0,parseInt(tt[2],10)||0);
};
if(!s){
return null;
}
var tt=s.split(_30.separator);
return new Date(1900,0,0,parseInt(tt[0],10)||0,parseInt(tt[1],10)||0,parseInt(tt[2],10)||0);
},selections:[[0,2],[3,5],[6,8]],separator:":",showSeconds:false,highlight:0,spin:function(_33){
_1d(this,_33);
}});
})(jQuery);