Changeset 5700
- Timestamp:
- 03/12/08 13:28:50 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinelz/trunk/compress/javascripts/spinelz_lib/spinelz_util.js
r5693 r5700 18 18 _c=($(_c)||document.body); 19 19 var _f=_c.childNodes; 20 var _10=[]; 21 for(var i=0;i<_f.length;i++){ 20 var _10=_f.length; 21 var _11=[]; 22 for(var i=0;i<_10;i++){ 22 23 if(_f[i].nodeType==_d){ 23 _1 0.push(_f[i]);24 _11.push(_f[i]); 24 25 } 25 26 if(_e&&Element.isElementNode(_f[i])){ 26 _1 0=_10.concat(this.getElementsByNodeType(_f[i],_d,_e));27 } 28 } 29 return _1 0;30 },getParentByClassName:function(_1 2,_13){31 var _1 4=_13.parentNode;32 if(!_1 4||(_14.tagName=="BODY")){27 _11=_11.concat(this.getElementsByNodeType(_f[i],_d,_e)); 28 } 29 } 30 return _11; 31 },getParentByClassName:function(_13,_14){ 32 var _15=_14.parentNode; 33 if(!_15||(_15.tagName=="BODY")){ 33 34 return null; 34 35 }else{ 35 if(!_1 4.className){36 return Element.getParentByClassName(_1 2,_14);37 }else{ 38 if(Element.hasClassName(_1 4,_12)){39 return _1 4;40 }else{ 41 return Element.getParentByClassName(_1 2,_14);42 } 43 } 44 } 45 },getParentByTagName:function(_1 5,_16){46 var _1 7=_16.parentNode;47 if(_1 7.tagName=="BODY"){36 if(!_15.className){ 37 return Element.getParentByClassName(_13,_15); 38 }else{ 39 if(Element.hasClassName(_15,_13)){ 40 return _15; 41 }else{ 42 return Element.getParentByClassName(_13,_15); 43 } 44 } 45 } 46 },getParentByTagName:function(_16,_17){ 47 var _18=_17.parentNode; 48 if(_18.tagName=="BODY"){ 48 49 return null; 49 50 } 50 var _18=_15.join("/").toUpperCase().indexOf(_17.tagName.toUpperCase(),0); 51 if(_18>=0){ 52 return _17; 53 }else{ 54 return Element.getParentByTagName(_15,_17); 55 } 56 },getFirstElementByClassNames:function(_19,_1a,_1b){ 57 if(!_19||!((typeof (_1a)=="object")&&(_1a.constructor==Array))){ 51 var _19=_16.join("/").toUpperCase().indexOf(_18.tagName.toUpperCase(),0); 52 if(_19>=0){ 53 return _18; 54 }else{ 55 return Element.getParentByTagName(_16,_18); 56 } 57 },getFirstElementNode:function(_1a){ 58 return $A(($(_1a)||document.body).childNodes).detect(function(_1b){ 59 return Element.isElementNode(_1b); 60 }); 61 },getFirstElementByClassNames:function(_1c,_1d,_1e){ 62 if(!_1c||!((typeof (_1d)=="object")&&(_1d.constructor==Array))){ 58 63 return; 59 64 } 60 _1 9=(_19||document.body);61 var _1 c=_19.childNodes;62 for(var i=0;i<_1 c.length;i++){63 for(var j=0;j<_1 a.length;j++){64 if(!Element.isElementNode(_1 c[i])){65 _1c=(_1c||document.body); 66 var _1f=_1c.childNodes; 67 for(var i=0;i<_1f.length;i++){ 68 for(var j=0;j<_1d.length;j++){ 69 if(!Element.isElementNode(_1f[i])){ 65 70 continue; 66 71 }else{ 67 if(Element.hasClassName(_1 c[i],_1a[j])){68 return _1 c[i];69 }else{ 70 if(_1 b){71 var _ 1f=this.getFirstElementByClassNames(_1c[i],_1a,_1b);72 if(_ 1f){73 return _ 1f;72 if(Element.hasClassName(_1f[i],_1d[j])){ 73 return _1f[i]; 74 }else{ 75 if(_1e){ 76 var _22=this.getFirstElementByClassNames(_1f[i],_1d,_1e); 77 if(_22){ 78 return _22; 74 79 } 75 80 } … … 79 84 } 80 85 return; 81 },getElementsByClassNames:function(_2 0,_21){82 if(!_2 0||!((typeof (_21)=="object")&&(_21.constructor==Array))){86 },getElementsByClassNames:function(_23,_24){ 87 if(!_23||!((typeof (_24)=="object")&&(_24.constructor==Array))){ 83 88 return; 84 89 } 85 var _2 2=[];86 _2 1.each(function(c){87 _2 2=_22.concat(document.getElementsByClassName(c,_20));88 }); 89 return _2 2;90 var _25=[]; 91 _24.each(function(c){ 92 _25=_25.concat(document.getElementsByClassName(c,_23)); 93 }); 94 return _25; 90 95 },getWindowHeight:function(){ 91 96 if(window.innerHeight){ … … 106 111 } 107 112 return 0; 108 },getMaxZindex:function(_2 4){109 _2 4=$(_24);110 if(!_2 4){111 _2 4=document.body;112 } 113 if(!Element.isElementNode(_2 4)){113 },getMaxZindex:function(_27){ 114 _27=$(_27); 115 if(!_27){ 116 _27=document.body; 117 } 118 if(!Element.isElementNode(_27)){ 114 119 return 0; 115 120 } 116 var _25=0; 117 if(_24.style){ 118 _25=parseInt(Element.getStyle(_24,"z-index")); 119 } 120 if(isNaN(_25)){ 121 _25=0; 122 } 123 var _26=0; 124 var _27=_24.childNodes; 125 for(var i=0;i<_27.length;i++){ 126 if(_27[i]&&_27[i].tagName){ 127 _26=Element.getMaxZindex(_27[i]); 128 if(_25<_26){ 129 _25=_26; 130 } 131 } 132 } 133 return _25; 134 },select:function(_29,_2a){ 135 $A($(_29).options).each(function(opt){ 136 opt.selected=(opt.value==_2a); 137 }); 138 },selectAll:function(_2c){ 121 var _28=0; 122 if(_27.style){ 123 _28=parseInt(Element.getStyle(_27,"z-index")); 124 } 125 if(isNaN(_28)){ 126 _28=0; 127 } 128 var _29=0; 129 var _2a=_27.childNodes; 130 for(var i=0;i<_2a.length;i++){ 131 if(_2a[i]&&_2a[i].tagName){ 132 _29=Element.getMaxZindex(_2a[i]); 133 if(_28<_29){ 134 _28=_29; 135 } 136 } 137 } 138 return _28; 139 },select:function(_2c,_2d){ 139 140 $A($(_2c).options).each(function(opt){ 141 opt.selected=(opt.value==_2d); 142 }); 143 },selectAll:function(_2f){ 144 $A($(_2f).options).each(function(opt){ 140 145 opt.selected=true; 141 146 }); 142 },removeOptions:function(_ 2e){143 $A($(_ 2e).options).each(function(opt){147 },removeOptions:function(_31){ 148 $A($(_31).options).each(function(opt){ 144 149 if(opt.selected){ 145 150 Element.remove(opt); 146 151 } 147 152 }); 148 },getSelectedOptions:function(_3 0){149 return $A($(_3 0).options).select(function(opt){153 },getSelectedOptions:function(_33){ 154 return $A($(_33).options).select(function(opt){ 150 155 return opt.selected; 151 156 }); 152 },check:function(_3 2,id){153 _3 2.each(function(_34){154 _3 4=$(_34);155 if(_3 4){156 _3 4.checked=(_34.id==id);157 } 158 }); 159 },outerHTML:function(_3 5){160 _3 5=$(_35);161 var _3 6="";162 if(Element.isTextNode(_3 5)){163 _3 6=_35.nodeValue;164 }else{ 165 if(Element.isElementNode(_3 5)){166 if(_3 5.outerHTML){167 _3 6=_35.outerHTML;168 }else{ 169 var _3 7=[_35.tagName];170 var _3 8=_35.attributes;171 if(_3 8){172 $A(_3 8).each(function(_39){173 _3 7.push(_39.name+"=\""+_39.value.escapeHTML().replace(/"/,""")+"\"");174 }); 175 } 176 _3 6="<"+_37.join(" ")+">"+_35.innerHTML+"</"+_35.tagName+">";177 } 178 } 179 } 180 return _3 6;181 },eventHTML:function(_3 a){182 return $A(_3 a.attributes).map(function(_3b){183 if(_3 b.name.match(/^on(\w)+/)){184 return _3 b.name+"=\""+_3b.value+"\"";157 },check:function(_35,id){ 158 _35.each(function(_37){ 159 _37=$(_37); 160 if(_37){ 161 _37.checked=(_37.id==id); 162 } 163 }); 164 },outerHTML:function(_38){ 165 _38=$(_38); 166 var _39=""; 167 if(Element.isTextNode(_38)){ 168 _39=_38.nodeValue; 169 }else{ 170 if(Element.isElementNode(_38)){ 171 if(_38.outerHTML){ 172 _39=_38.outerHTML; 173 }else{ 174 var _3a=[_38.tagName]; 175 var _3b=_38.attributes; 176 if(_3b){ 177 $A(_3b).each(function(_3c){ 178 _3a.push(_3c.name+"=\""+_3c.value.escapeHTML().replace(/"/,""")+"\""); 179 }); 180 } 181 _39="<"+_3a.join(" ")+">"+_38.innerHTML+"</"+_38.tagName+">"; 182 } 183 } 184 } 185 return _39; 186 },eventHTML:function(_3d){ 187 return $A(_3d.attributes).map(function(_3e){ 188 if(_3e.name.match(/^on(\w)+/)){ 189 return _3e.name+"=\""+_3e.value+"\""; 185 190 }else{ 186 191 return ""; 187 192 } 188 193 }).join(" "); 189 },attributeHTML:function(_3 c,_3d){190 var _ 3e="";191 if(_3 c[_3d]){192 _ 3e=_3c[_3d].toString().replace(/\'/g,"\"");193 _ 3e=_3d+"='("+_3e+")()'";194 } 195 return _ 3e;196 },replaceOptions:function(_ 3f,_40){197 _ 3f=$(_3f);198 _ 3f.innerHTML="";194 },attributeHTML:function(_3f,_40){ 195 var _41=""; 196 if(_3f[_40]){ 197 _41=_3f[_40].toString().replace(/\'/g,"\""); 198 _41=_40+"='("+_41+")()'"; 199 } 200 return _41; 201 },replaceOptions:function(_42,_43){ 202 _42=$(_42); 203 _42.innerHTML=""; 199 204 var df=document.createDocumentFragment(); 200 _4 0.each(function(_42){201 df.appendChild(Builder.node("option",{value:_4 2.last()},[_42.first().unescapeHTML()]));202 }); 203 $(_ 3f).appendChild(df);205 _43.each(function(_45){ 206 df.appendChild(Builder.node("option",{value:_45.last()},[_45.first().unescapeHTML()])); 207 }); 208 $(_42).appendChild(df); 204 209 },body:function(){ 205 210 return document.documentElement||document.body; … … 208 213 },scrollLeft:function(){ 209 214 return Element.body().scrollLeft; 210 },appendToBody:function(_4 3){211 _4 3=$(_43);212 Element.removeFromBody(_4 3.id);213 document.body.appendChild(_4 3);214 },removeFromBody:function(_4 4){215 $A(document.body.childNodes).each(function(_4 5){216 if(_4 5.id==_44){217 _4 5.remove();215 },appendToBody:function(_46){ 216 _46=$(_46); 217 Element.removeFromBody(_46.id); 218 document.body.appendChild(_46); 219 },removeFromBody:function(_47){ 220 $A(document.body.childNodes).each(function(_48){ 221 if(_48.id==_47){ 222 _48.remove(); 218 223 } 219 224 }); 220 225 }}); 221 Object.extend(Array.prototype,{insert:function(_4 6,_47){222 this.splice(_4 6,0,_47);223 },remove:function(_4 8){224 this.splice(_4 8,1);226 Object.extend(Array.prototype,{insert:function(_49,_4a){ 227 this.splice(_49,0,_4a); 228 },remove:function(_4b){ 229 this.splice(_4b,1); 225 230 }}); 226 Object.extend(String.prototype,{_mb_space:decodeURIComponent("%E3%80%80"),_rb:new RegExp(decodeURIComponent("[%E3%80%80]+$"),"gmi"),_rf:new RegExp(decodeURIComponent("^[%E3%80%80]+"),"gmi"),appendPrefix:function(_4 9,_4a){227 if(!_4 a){228 _4 a="_";229 } 230 return this+_4 a+_49;231 },appendSuffix:function(_4 b,_4c){232 if(!_4 c){233 _4 c="_";234 } 235 return this+_4 c+_4b;231 Object.extend(String.prototype,{_mb_space:decodeURIComponent("%E3%80%80"),_rb:new RegExp(decodeURIComponent("[%E3%80%80]+$"),"gmi"),_rf:new RegExp(decodeURIComponent("^[%E3%80%80]+"),"gmi"),appendPrefix:function(_4c,_4d){ 232 if(!_4d){ 233 _4d="_"; 234 } 235 return this+_4d+_4c; 236 },appendSuffix:function(_4e,_4f){ 237 if(!_4f){ 238 _4f="_"; 239 } 240 return this+_4f+_4e; 236 241 },compressSpaces:function(){ 237 242 return this.normalizeSpaces().gsub(/\s+/," "); 238 243 },cutSpaces:function(){ 239 244 return this.normalizeSpaces().gsub(/[\s]/,""); 240 },getPrefix:function(_ 4d){241 if(!_ 4d){242 _ 4d="_";243 } 244 return this.split(_ 4d)[0];245 },getSuffix:function(_ 4e){246 if(!_ 4e){247 _ 4e="_";248 } 249 return this.split(_ 4e).pop();245 },getPrefix:function(_50){ 246 if(!_50){ 247 _50="_"; 248 } 249 return this.split(_50)[0]; 250 },getSuffix:function(_51){ 251 if(!_51){ 252 _51="_"; 253 } 254 return this.split(_51).pop(); 250 255 },normalizeSpaces:function(){ 251 256 return this.gsub(this._mb_space," "); … … 253 258 return this.strip().gsub(this._rf,"").gsub(this._rb,""); 254 259 },toElement:function(){ 255 var _ 4f=document.createElement("div");256 _ 4f.innerHTML=this;257 return _ 4f.firstChild;260 var _52=document.createElement("div"); 261 _52.innerHTML=this; 262 return _52.firstChild; 258 263 }}); 259 264 var CssUtil=Class.create(); 260 CssUtil.getInstance=function(_5 0,_51){261 var _5 2=CssUtil.appendPrefix(_50,_51);262 return new CssUtil([_5 1,_52]);265 CssUtil.getInstance=function(_53,_54){ 266 var _55=CssUtil.appendPrefix(_53,_54); 267 return new CssUtil([_54,_55]); 263 268 }; 264 CssUtil.appendPrefix=function(_5 3,_54){265 var _5 5={};266 $H(_5 4).each(function(_56){267 _5 5[_56[0]]=_53+_54[_56[0]];268 }); 269 return _5 5;269 CssUtil.appendPrefix=function(_56,_57){ 270 var _58={}; 271 $H(_57).each(function(_59){ 272 _58[_59[0]]=_56+_57[_59[0]]; 273 }); 274 return _58; 270 275 }; 271 CssUtil.getCssRules=function(_5 7){272 return _5 7.rules||_57.cssRules;276 CssUtil.getCssRules=function(_5a){ 277 return _5a.rules||_5a.cssRules; 273 278 }; 274 CssUtil.getCssRuleBySelectorText=function(_5 8){275 var _5 9=null;279 CssUtil.getCssRuleBySelectorText=function(_5b){ 280 var _5c=null; 276 281 $A(document.styleSheets).each(function(s){ 277 var _5 b=CssUtil.getCssRules(s);278 _5 9=$A(_5b).detect(function(r){282 var _5e=CssUtil.getCssRules(s); 283 _5c=$A(_5e).detect(function(r){ 279 284 if(!r.selectorText){ 280 285 return false; 281 286 } 282 return r.selectorText.toLowerCase()==_5 8.toLowerCase();283 }); 284 if(_5 9){287 return r.selectorText.toLowerCase()==_5b.toLowerCase(); 288 }); 289 if(_5c){ 285 290 throw $break; 286 291 } 287 292 }); 288 return _5 9;293 return _5c; 289 294 }; 290 CssUtil.prototype={initialize:function(_ 5d){291 if(!((typeof (_ 5d)=="object")&&(_5d.constructor==Array))){295 CssUtil.prototype={initialize:function(_60){ 296 if(!((typeof (_60)=="object")&&(_60.constructor==Array))){ 292 297 throw "CssUtil#initialize: argument must be a Array object!"; 293 298 } 294 this.styles=_ 5d;299 this.styles=_60; 295 300 },getClasses:function(key){ 296 301 return this.styles.collect(function(s){ … … 300 305 return this.getClasses(key).join(" "); 301 306 },allJoinClassNames:function(){ 302 var _6 1={};303 $H(this.styles.first()).each(function(_6 2){304 _6 1[_62.key]=this.joinClassNames(_62.key);307 var _64={}; 308 $H(this.styles.first()).each(function(_65){ 309 _64[_65.key]=this.joinClassNames(_65.key); 305 310 }.bind(this)); 306 return _6 1;307 },addClassNames:function(_6 3,key){311 return _64; 312 },addClassNames:function(_66,key){ 308 313 this.styles.each(function(s){ 309 Element.addClassName(_6 3,s[key]);310 }); 311 },removeClassNames:function(_6 6,key){314 Element.addClassName(_66,s[key]); 315 }); 316 },removeClassNames:function(_69,key){ 312 317 this.styles.each(function(s){ 313 Element.removeClassName(_6 6,s[key]);314 }); 315 },refreshClassNames:function(_6 9,key){316 _6 9.className="";317 this.addClassNames(_6 9,key);318 },hasClassName:function(_6 b,key){318 Element.removeClassName(_69,s[key]); 319 }); 320 },refreshClassNames:function(_6c,key){ 321 _6c.className=""; 322 this.addClassNames(_6c,key); 323 },hasClassName:function(_6e,key){ 319 324 return this.styles.any(function(s){ 320 return Element.hasClassName(_6 b,s[key]);325 return Element.hasClassName(_6e,s[key]); 321 326 }); 322 327 }}; 323 328 var Hover=Class.create(); 324 Hover.prototype={initialize:function(_ 6e){329 Hover.prototype={initialize:function(_71){ 325 330 this.options=Object.extend({defaultClass:"",hoverClass:"",cssUtil:"",list:false,beforeToggle:function(){ 326 331 return true; 327 332 }},arguments[1]||{}); 328 var _ 6e=$(_6e);333 var _71=$(_71); 329 334 if(this.options.list){ 330 var _ 6f=_6e.childNodes;331 for(var i=0;i<_ 6f.length;i++){332 if(Element.isElementNode(_ 6f[i])){333 this.build(_ 6f[i]);334 } 335 } 336 }else{ 337 this.build(_ 6e);338 } 339 this.element=_ 6e;340 },build:function(_7 1){341 this.normal=this.getNormalClass(_7 1);335 var _72=_71.childNodes; 336 for(var i=0;i<_72.length;i++){ 337 if(Element.isElementNode(_72[i])){ 338 this.build(_72[i]); 339 } 340 } 341 }else{ 342 this.build(_71); 343 } 344 this.element=_71; 345 },build:function(_74){ 346 this.normal=this.getNormalClass(_74); 342 347 this.hover=this.getHoverClass(this.normal); 343 348 if(this.options.cssUtil){ … … 345 350 this.hover=this.options.cssUtil.joinClassNames(hover); 346 351 } 347 this.setHoverEvent(_7 1);348 },setHoverEvent:function(_7 2){349 this.mouseout=this.toggle.bindAsEventListener(this,_7 2,this.normal);350 this.mouseover=this.toggle.bindAsEventListener(this,_7 2,this.hover);351 Event.observe(_7 2,"mouseout",this.mouseout);352 Event.observe(_7 2,"mouseover",this.mouseover);353 },toggle:function(_7 3,_74,_75){354 Event.stop(_7 3);352 this.setHoverEvent(_74); 353 },setHoverEvent:function(_75){ 354 this.mouseout=this.toggle.bindAsEventListener(this,_75,this.normal); 355 this.mouseover=this.toggle.bindAsEventListener(this,_75,this.hover); 356 Event.observe(_75,"mouseout",this.mouseout); 357 Event.observe(_75,"mouseover",this.mouseover); 358 },toggle:function(_76,_77,_78){ 359 Event.stop(_76); 355 360 if(this.options.beforeToggle()){ 356 _7 4.className=_75;357 } 358 },getNormalClass:function(_7 6){359 var _7 7=(this.options.defaultClass||_76.className);360 return (_7 7||"");361 },getHoverClass:function(_7 8){362 var _7 9=this.options.hoverClass;363 if(!_7 9){364 _7 9=_78.split(" ").collect(function(c){361 _77.className=_78; 362 } 363 },getNormalClass:function(_79){ 364 var _7a=(this.options.defaultClass||_79.className); 365 return (_7a||""); 366 },getHoverClass:function(_7b){ 367 var _7c=this.options.hoverClass; 368 if(!_7c){ 369 _7c=_7b.split(" ").collect(function(c){ 365 370 return c+"Hover"; 366 371 }).join(" "); 367 372 } 368 return _7 9;373 return _7c; 369 374 },destroy:function(){ 370 375 Event.stopObserving(this.element,"mouseout",this.mouseout); … … 378 383 Object.extend(Date.prototype,{msPerDay:function(){ 379 384 return 24*60*60*1000; 380 },advance:function(_7 b){381 return new Date(this.getTime()+this.msPerDay()*_7 b.days);385 },advance:function(_7e){ 386 return new Date(this.getTime()+this.msPerDay()*_7e.days); 382 387 },days:function(){ 383 var _7 c=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0);384 return Math.round(_7 c.getTime()/this.msPerDay());388 var _7f=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0); 389 return Math.round(_7f.getTime()/this.msPerDay()); 385 390 },toHash:function(){ 386 391 return {year:this.getFullYear(),month:this.getMonth(),day:this.getDate(),hour:this.getHours(),min:this.getMinutes(),sec:this.getSeconds()}; 387 },sameYear:function(_ 7d){388 return this.getFullYear()==_ 7d.getFullYear();389 },sameMonth:function(_ 7e){390 return this.sameYear(_ 7e)&&this.getMonth()==_7e.getMonth();391 },sameDate:function(_ 7f){392 return this.sameYear(_ 7f)&&this.sameMonth(_7f)&&this.getDate()==_7f.getDate();393 },betweenDate:function(_8 0,_81){394 var _8 2=this.days();395 return (_8 0.days()<=_82&&_82<=_81.days());396 },betweenTime:function(_8 3,_84){397 var _8 5=this.getTime();398 return (_8 3.getTime()<=_85&&_85<=_84.getTime());399 },strftime:function(_8 6){400 return DateUtil.simpleFormat(_8 6)(this);392 },sameYear:function(_80){ 393 return this.getFullYear()==_80.getFullYear(); 394 },sameMonth:function(_81){ 395 return this.sameYear(_81)&&this.getMonth()==_81.getMonth(); 396 },sameDate:function(_82){ 397 return this.sameYear(_82)&&this.sameMonth(_82)&&this.getDate()==_82.getDate(); 398 },betweenDate:function(_83,_84){ 399 var _85=this.days(); 400 return (_83.days()<=_85&&_85<=_84.days()); 401 },betweenTime:function(_86,_87){ 402 var _88=this.getTime(); 403 return (_86.getTime()<=_88&&_88<=_87.getTime()); 404 },strftime:function(_89){ 405 return DateUtil.simpleFormat(_89)(this); 401 406 }}); 402 var DateUtil={dayOfWeek:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],daysOfMonth:[31,28,31,30,31,30,31,31,30,31,30,31],numberOfDays:function(_8 7,_88){403 return _8 8.days()-_87.days();404 },isLeapYear:function(_8 9){405 if(((_8 9%4==0)&&(_89%100!=0))||(_89%400==0)){407 var DateUtil={dayOfWeek:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],daysOfMonth:[31,28,31,30,31,30,31,31,30,31,30,31],numberOfDays:function(_8a,_8b){ 408 return _8b.days()-_8a.days(); 409 },isLeapYear:function(_8c){ 410 if(((_8c%4==0)&&(_8c%100!=0))||(_8c%400==0)){ 406 411 return true; 407 412 } 408 413 return false; 409 },nextDate:function(_8 a){410 return new Date(_8 a.getFullYear(),_8a.getMonth(),_8a.getDate()+1);411 },previousDate:function(_8 b){412 return new Date(_8 b.getFullYear(),_8b.getMonth(),_8b.getDate()-1);413 },afterDays:function(_8 c,_8d){414 return new Date(_8 c.getFullYear(),_8c.getMonth(),_8c.getDate()+_8d);415 },getLastDate:function(_ 8e,_8f){416 var _9 0=this.daysOfMonth[_8f];417 if((_ 8f==1)&&this.isLeapYear(_8e)){418 return new Date(_ 8e,_8f,_90+1);419 } 420 return new Date(_ 8e,_8f,_90);421 },getFirstDate:function(_9 1,_92){422 if(_9 1.constructor==Date){423 return new Date(_9 1.getFullYear(),_91.getMonth(),1);424 } 425 return new Date(_9 1,_92,1);426 },getWeekTurn:function(_9 3,_94){427 var _9 5=6-_94+1;428 var _9 6=0;429 while(_9 5<_93){430 _9 3-=7;431 _9 6++;432 } 433 return _9 6;434 },toDateString:function(_9 7){435 return _9 7.toDateString();436 },toLocaleDateString:function(_9 8){437 return _9 8.toLocaleDateString();438 },simpleFormat:function(_9 9){439 return function(_9 a){440 var _9 b=_99.replace(/M+/g,DateUtil.zerofill((_9a.getMonth()+1).toString(),2));441 _9 b=_9b.replace(/d+/g,DateUtil.zerofill(_9a.getDate().toString(),2));442 _9 b=_9b.replace(/y{4}/g,_9a.getFullYear());443 _9 b=_9b.replace(/y{1,3}/g,new String(_9a.getFullYear()).substr(2));444 _9 b=_9b.replace(/E+/g,DateUtil.dayOfWeek[_9a.getDay()]);445 return _9 b;414 },nextDate:function(_8d){ 415 return new Date(_8d.getFullYear(),_8d.getMonth(),_8d.getDate()+1); 416 },previousDate:function(_8e){ 417 return new Date(_8e.getFullYear(),_8e.getMonth(),_8e.getDate()-1); 418 },afterDays:function(_8f,_90){ 419 return new Date(_8f.getFullYear(),_8f.getMonth(),_8f.getDate()+_90); 420 },getLastDate:function(_91,_92){ 421 var _93=this.daysOfMonth[_92]; 422 if((_92==1)&&this.isLeapYear(_91)){ 423 return new Date(_91,_92,_93+1); 424 } 425 return new Date(_91,_92,_93); 426 },getFirstDate:function(_94,_95){ 427 if(_94.constructor==Date){ 428 return new Date(_94.getFullYear(),_94.getMonth(),1); 429 } 430 return new Date(_94,_95,1); 431 },getWeekTurn:function(_96,_97){ 432 var _98=6-_97+1; 433 var _99=0; 434 while(_98<_96){ 435 _96-=7; 436 _99++; 437 } 438 return _99; 439 },toDateString:function(_9a){ 440 return _9a.toDateString(); 441 },toLocaleDateString:function(_9b){ 442 return _9b.toLocaleDateString(); 443 },simpleFormat:function(_9c){ 444 return function(_9d){ 445 var _9e=_9c.replace(/M+/g,DateUtil.zerofill((_9d.getMonth()+1).toString(),2)); 446 _9e=_9e.replace(/d+/g,DateUtil.zerofill(_9d.getDate().toString(),2)); 447 _9e=_9e.replace(/y{4}/g,_9d.getFullYear()); 448 _9e=_9e.replace(/y{1,3}/g,new String(_9d.getFullYear()).substr(2)); 449 _9e=_9e.replace(/E+/g,DateUtil.dayOfWeek[_9d.getDay()]); 450 return _9e; 446 451 }; 447 },zerofill:function(_9 c,_9d){448 var _ 9e=_9c;449 if(_9 c.length<_9d){450 var tmp=_ 9d-_9c.length;452 },zerofill:function(_9f,_a0){ 453 var _a1=_9f; 454 if(_9f.length<_a0){ 455 var tmp=_a0-_9f.length; 451 456 for(i=0;i<tmp;i++){ 452 _ 9e="0"+_9e;453 } 454 } 455 return _ 9e;456 },toDate:function(_a 0){457 return new Date(_a 0.year,_a0.month,_a0.day,_a0.hour||0,_a0.min||0,_a0.sec||0);457 _a1="0"+_a1; 458 } 459 } 460 return _a1; 461 },toDate:function(_a3){ 462 return new Date(_a3.year,_a3.month,_a3.day,_a3.hour||0,_a3.min||0,_a3.sec||0); 458 463 }}; 459 var ZindexManager={zIndex:1000,getIndex:function(_a 1){460 if(_a 1){461 if(isNaN(_a 1)){462 _a 1=Element.getMaxZindex()+1;463 }else{ 464 if(ZindexManager.zIndex>_a 1){465 _a 1=ZindexManager.zIndex;466 } 467 } 468 }else{ 469 _a 1=ZindexManager.zIndex;470 } 471 ZindexManager.zIndex=_a 1+1;472 return _a 1;464 var ZindexManager={zIndex:1000,getIndex:function(_a4){ 465 if(_a4){ 466 if(isNaN(_a4)){ 467 _a4=Element.getMaxZindex()+1; 468 }else{ 469 if(ZindexManager.zIndex>_a4){ 470 _a4=ZindexManager.zIndex; 471 } 472 } 473 }else{ 474 _a4=ZindexManager.zIndex; 475 } 476 ZindexManager.zIndex=_a4+1; 477 return _a4; 473 478 }}; 474 var Modal={maskId:"modalMask",maskClass:"modal_mask",maskClassIE:"modal_mask_ie",element:null,snaps:null,listener:null,resizeListener:null,cover:null,excepteds:null,maskCallbacks:[],unmaskCallbacks:[],count:0,tabKey:9,timer:null,mask:function(_a 2,_a3,_a4){475 this._mask.callAfterLoading(this,_a 2,_a3,_a4);479 var Modal={maskId:"modalMask",maskClass:"modal_mask",maskClassIE:"modal_mask_ie",element:null,snaps:null,listener:null,resizeListener:null,cover:null,excepteds:null,maskCallbacks:[],unmaskCallbacks:[],count:0,tabKey:9,timer:null,mask:function(_a5,_a6,_a7){ 480 this._mask.callAfterLoading(this,_a5,_a6,_a7); 476 481 this._control_tab_key(); 477 482 },unmask:function(){ … … 480 485 },unmaskAll:function(){ 481 486 var max=10; 482 var _a 6=0;483 while(this._isMasked()&&(_a 6<max)){487 var _a9=0; 488 while(this._isMasked()&&(_a9<max)){ 484 489 this._unmask(); 485 _a 6++;490 _a9++; 486 491 } 487 492 this._control_tab_key(); 488 },addMaskCallback:function(_a 7){493 },addMaskCallback:function(_aa){ 489 494 if(!this.maskCallbacks.any(function(c){ 490 return c==_a 7;495 return c==_aa; 491 496 })){ 492 this.maskCallbacks.push(_a 7);493 } 494 },removeMaskCallback:function(_a 9){497 this.maskCallbacks.push(_aa); 498 } 499 },removeMaskCallback:function(_ac){ 495 500 this.maskCallbacks=this.maskCallbacks.reject(function(c){ 496 return c==_a 9;501 return c==_ac; 497 502 }); 498 503 },clearMaskCallback:function(){ 499 504 this.maskCallbacks=[]; 500 },addUnmaskCallback:function(_a b){505 },addUnmaskCallback:function(_ae){ 501 506 if(!this.unmaskCallbacks.any(function(c){ 502 return c==_a b;507 return c==_ae; 503 508 })){ 504 this.unmaskCallbacks.push(_a b);505 } 506 },removeUnmaskCallback:function(_ ad){509 this.unmaskCallbacks.push(_ae); 510 } 511 },removeUnmaskCallback:function(_b0){ 507 512 this.unmaskCallbacks=this.unmaskCallbacks.reject(function(c){ 508 return c==_ ad;513 return c==_b0; 509 514 }); 510 515 },clearUnmaskCallback:function(){ 511 516 this.unmaskCallbacks=[]; 512 },_mask:function(_ af){513 var _b 0=Object.extend({cssPrefix:"custom_",zIndex:null},arguments[1]||{});514 var _b 1=arguments[2];517 },_mask:function(_b2){ 518 var _b3=Object.extend({cssPrefix:"custom_",zIndex:null},arguments[1]||{}); 519 var _b4=arguments[2]; 515 520 if(Modal.element){ 516 Modal._snap(_ af);521 Modal._snap(_b2); 517 522 Modal._rebuildMask(); 518 523 }else{ 519 524 Modal.snaps=[]; 520 525 Modal.excepteds=[]; 521 Modal._buildMask(_b 0.cssPrefix);526 Modal._buildMask(_b3.cssPrefix); 522 527 Modal.cover=new IECover(Modal.element,{transparent:true}); 523 528 } 524 if(_b 1){529 if(_b4){ 525 530 Element.setStyle(Modal.element,{position:"absolute"}); 526 531 this._setModalPosition(); … … 529 534 } 530 535 } 531 Modal._setZindex(_ af,_b0.zIndex);536 Modal._setZindex(_b2,_b3.zIndex); 532 537 Modal._setFullSize(); 533 if(!Modal.hasExcepted(_ af)){534 Modal.excepteds.push(_ af);538 if(!Modal.hasExcepted(_b2)){ 539 Modal.excepteds.push(_b2); 535 540 } 536 541 this.count++; 537 this.maskCallbacks.each(function(_b 2){538 _b 2(_af);542 this.maskCallbacks.each(function(_b5){ 543 _b5(_b2); 539 544 }); 540 545 },_unmask:function(){ … … 552 557 } 553 558 this.count++; 554 this.unmaskCallbacks.each(function(_b 3){555 _b 3();559 this.unmaskCallbacks.each(function(_b6){ 560 _b6(); 556 561 }); 557 562 },_setModalPosition:function(){ … … 583 588 },_isMasked:function(){ 584 589 return Modal.element&&Element.visible(Modal.element); 585 },_snap:function(_b 4){586 var _b 5=Element.getStyle(Modal.element,"zIndex");587 if(_b 5&&Modal._isMasked()&&!Modal.hasExcepted(_b4)){588 Modal.snaps.push(_b 5);589 } 590 },_setZindex:function(_b 6,_b7){591 _b 7=ZindexManager.getIndex(_b7);592 Element.setStyle(Modal.element,{zIndex:_b 7});593 _b 6=Element.makePositioned($(_b6));594 Element.setStyle(_b 6,{zIndex:++_b7});590 },_snap:function(_b7){ 591 var _b8=Element.getStyle(Modal.element,"zIndex"); 592 if(_b8&&Modal._isMasked()&&!Modal.hasExcepted(_b7)){ 593 Modal.snaps.push(_b8); 594 } 595 },_setZindex:function(_b9,_ba){ 596 _ba=ZindexManager.getIndex(_ba); 597 Element.setStyle(Modal.element,{zIndex:_ba}); 598 _b9=Element.makePositioned($(_b9)); 599 Element.setStyle(_b9,{zIndex:++_ba}); 595 600 },_setFullSize:function(){ 596 601 Modal.element.setStyle({width:Element.getWindowWidth()+"px",height:Element.getWindowHeight()+"px"}); … … 598 603 Modal.cover.resetSize(); 599 604 } 600 },_buildMask:function(_b 8){601 var _b 9=Builder.node("div",{id:Modal.maskId});602 Modal._setClassNames(_b 9,_b8);603 document.body.appendChild(_b 9);604 Modal.element=_b 9;605 },_buildMask:function(_bb){ 606 var _bc=Builder.node("div",{id:Modal.maskId}); 607 Modal._setClassNames(_bc,_bb); 608 document.body.appendChild(_bc); 609 Modal.element=_bc; 605 610 Modal._addEvent(); 606 },_setClassNames:function(_b a,_bb){607 var _b c=(UserAgent.isIE())?Modal.maskClassIE:Modal.maskClass;608 Element.addClassName(_b a,_bc);609 Element.addClassName(_b a,_bb+_bc);611 },_setClassNames:function(_bd,_be){ 612 var _bf=(UserAgent.isIE())?Modal.maskClassIE:Modal.maskClass; 613 Element.addClassName(_bd,_bf); 614 Element.addClassName(_bd,_be+_bf); 610 615 },_rebuildMask:function(){ 611 616 document.body.appendChild(Modal.element); … … 618 623 return src.spinelzMaskResult; 619 624 } 620 var _ be=false;621 var _ bf=this.excepteds.last();622 var _c 0=src;623 if(_ bf&&Element.descendantOf(src,_bf)){624 _ be=true;625 }else{ 626 var _c 1=Element.getStyle(Modal.element,"zIndex");627 var _c 2=null;625 var _c1=false; 626 var _c2=this.excepteds.last(); 627 var _c3=src; 628 if(_c2&&Element.descendantOf(src,_c2)){ 629 _c1=true; 630 }else{ 631 var _c4=Element.getStyle(Modal.element,"zIndex"); 632 var _c5=null; 628 633 while((src=src.parentNode)&&src!=document.body){ 629 if(src.style&&(_c 2=Element.getStyle(src,"zIndex"))){630 _ be=(_c2>_c1);634 if(src.style&&(_c5=Element.getStyle(src,"zIndex"))){ 635 _c1=(_c5>_c4); 631 636 break; 632 637 } 633 638 } 634 639 } 635 _c 0.spinelzMaskCount=this.count;636 _c 0.spinelzMaskResult=_be;637 return _ be;638 },_handleEvent:function(_c 3){639 var src=Event.element(_c 3);640 if(!(Modal._isOutOfModal(src)||(_c 3.keyCode&&(_c3.keyCode==this.tabKey)))){641 Event.stop(_c 3);642 } 643 },_onResize:function(_c 5){640 _c3.spinelzMaskCount=this.count; 641 _c3.spinelzMaskResult=_c1; 642 return _c1; 643 },_handleEvent:function(_c6){ 644 var src=Event.element(_c6); 645 if(!(Modal._isOutOfModal(src)||(_c6.keyCode&&(_c6.keyCode==this.tabKey)))){ 646 Event.stop(_c6); 647 } 648 },_onResize:function(_c8){ 644 649 Modal._setFullSize(); 645 },hasExcepted:function(_c 6){646 return (Modal.excepteds||[]).any(function(_c 7){647 return _c 7.id==_c6.id;648 }); 649 },_control_tab_key:function(_c 8){650 if(!_c 8){651 _c 8=$A(document.body.getElementsByTagName("form"));652 } 653 _c 8.each(function(_c9){654 if(!Modal._isOutOfModal(_c 9)){655 Form.getElements(_c 9).each(function(el){650 },hasExcepted:function(_c9){ 651 return (Modal.excepteds||[]).any(function(_ca){ 652 return _ca.id==_c9.id; 653 }); 654 },_control_tab_key:function(_cb){ 655 if(!_cb){ 656 _cb=$A(document.body.getElementsByTagName("form")); 657 } 658 _cb.each(function(_cc){ 659 if(!Modal._isOutOfModal(_cc)){ 660 Form.getElements(_cc).each(function(el){ 656 661 el.tabIndex=-1; 657 662 }); 658 663 }else{ 659 Form.getElements(_c 9).each(function(el){664 Form.getElements(_cc).each(function(el){ 660 665 el.tabIndex=null; 661 666 }); … … 665 670 var IECover=Class.create(); 666 671 IECover.src="javascript:false;"; 667 IECover.prototype={idSuffix:"iecover",initialize:function(_c c){672 IECover.prototype={idSuffix:"iecover",initialize:function(_cf){ 668 673 this.options=Object.extend({transparent:false,padding:0},arguments[1]||{}); 669 674 if(document.all){ 670 _c c=$(_cc);671 this.id=_c c.id.appendSuffix(this.idSuffix);672 this._build(_c c);675 _cf=$(_cf); 676 this.id=_cf.id.appendSuffix(this.idSuffix); 677 this._build(_cf); 673 678 this.resetSize(); 674 679 } 675 680 },resetSize:function(){ 676 681 if(this.element){ 677 var _ cd=this.element.parentNode;678 var _ ce=this.options.padding;679 this.element.width=_ cd.offsetWidth-_ce+"px";680 this.element.height=Element.getHeight(_ cd)-_ce+"px";681 } 682 },_build:function(_ cf){683 var _d 0=this.options.padding/2;684 var _d 1={position:"absolute",top:_d0+"px",left:_d0+"px"};682 var _d0=this.element.parentNode; 683 var _d1=this.options.padding; 684 this.element.width=_d0.offsetWidth-_d1+"px"; 685 this.element.height=Element.getHeight(_d0)-_d1+"px"; 686 } 687 },_build:function(_d2){ 688 var _d3=this.options.padding/2; 689 var _d4={position:"absolute",top:_d3+"px",left:_d3+"px"}; 685 690 if(this.options.transparent){ 686 _d 1.filter="alpha(opacity=0)";687 } 688 if(_ cf.buildedIECover&&$(this.id)){691 _d4.filter="alpha(opacity=0)"; 692 } 693 if(_d2.buildedIECover&&$(this.id)){ 689 694 this.element=$(this.id); 690 695 }else{ 691 696 this.element=Builder.node("iframe",{src:IECover.src,id:this.id,frameborder:0}); 692 697 } 693 Element.setStyle(this.element,_d 1);694 var _d 2=Element.down(_cf,0);695 if(_d 2){696 Element.makePositioned(_d 2);697 } 698 _ cf.insertBefore(this.element,_cf.firstChild);699 _ cf.buildedIECover=true;698 Element.setStyle(this.element,_d4); 699 var _d5=Element.down(_d2,0); 700 if(_d5){ 701 Element.makePositioned(_d5); 702 } 703 _d2.insertBefore(this.element,_d2.firstChild); 704 _d2.buildedIECover=true; 700 705 }}; 701 706 var UserAgent={getUserAgent:function(){ … … 712 717 var ShortcutManager=Class.create(); 713 718 ShortcutManager.prototype={initialize:function(){ 714 var _d 3={detectKeyup:false,initialStarted:true,preventDefault:true};715 this.options=Object.extend(_d 3,arguments[0]||{});719 var _d6={detectKeyup:false,initialStarted:true,preventDefault:true}; 720 this.options=Object.extend(_d6,arguments[0]||{}); 716 721 this.keydownListener=this.eventKeydown.bindAsEventListener(this); 717 722 if(this.options.detectKeyup){ … … 739 744 Event.observe(document,"keyup",this.keyupListener); 740 745 } 741 },add:function(c1,c2,_d 6){746 },add:function(c1,c2,_d9){ 742 747 if(c1.constructor==Array){ 743 var _d 7=this;744 c1.each(function(_d 8){745 _d 7._add_or_remove_function(_d8[0],_d8[1],_d6);746 }); 747 }else{ 748 this._add_or_remove_function(c1,c2,_d 6);748 var _da=this; 749 c1.each(function(_db){ 750 _da._add_or_remove_function(_db[0],_db[1],_d9); 751 }); 752 }else{ 753 this._add_or_remove_function(c1,c2,_d9); 749 754 } 750 755 },destroy:function(){ … … 753 758 Event.stopObserving(document,"keyup",this.keyupListener); 754 759 } 755 },eventKeydown:function(_d 9){760 },eventKeydown:function(_dc){ 756 761 if(this.executable){ 757 var _d a;762 var _dd; 758 763 var key=""; 759 _d 9=_d9||window.event;760 if(_d 9.keyCode){761 if(_d 9.altKey){764 _dc=_dc||window.event; 765 if(_dc.keyCode){ 766 if(_dc.altKey){ 762 767 key+="a"; 763 768 } 764 if(_d 9.ctrlKey){769 if(_dc.ctrlKey){ 765 770 key+="c"; 766 771 } 767 if(_d 9.shiftKey){772 if(_dc.shiftKey){ 768 773 key+="s"; 769 774 } … … 771 776 key="n"; 772 777 } 773 _da=this._mergeNumKey(_d9.keyCode);774 if(this.keydownFunc[key][_da]){775 this.keydownFunc[key][_da]();776 if(this.options.preventDefault){777 Event.stop(_d9);778 }779 }780 }781 }782 },eventKeyup:function(_dc){783 if(this.executable){784 var _dd;785 _dc=_dc||window.event;786 if(_dc.keyCode){787 778 _dd=this._mergeNumKey(_dc.keyCode); 788 if(this.key upFunc[_dd]){789 this.key upFunc[_dd]();779 if(this.keydownFunc[key][_dd]){ 780 this.keydownFunc[key][_dd](); 790 781 if(this.options.preventDefault){ 791 782 Event.stop(_dc); … … 794 785 } 795 786 } 796 },remove:function(_de){ 797 this._add_or_remove_function(_de); 787 },eventKeyup:function(_df){ 788 if(this.executable){ 789 var _e0; 790 _df=_df||window.event; 791 if(_df.keyCode){ 792 _e0=this._mergeNumKey(_df.keyCode); 793 if(this.keyupFunc[_e0]){ 794 this.keyupFunc[_e0](); 795 if(this.options.preventDefault){ 796 Event.stop(_df); 797 } 798 } 799 } 800 } 801 },remove:function(_e1){ 802 this._add_or_remove_function(_e1); 798 803 },start:function(){ 799 804 this.executable=true; 800 805 },stop:function(){ 801 806 this.executable=false; 802 },_add_or_remove_function:function(_ df,_e0,_e1){803 var _e 2;804 var _e 3=new Array();805 var _e 4=this;806 $A(_ df.toLowerCase().split("+")).each(function(key){807 },_add_or_remove_function:function(_e2,_e3,_e4){ 808 var _e5; 809 var _e6=new Array(); 810 var _e7=this; 811 $A(_e2.toLowerCase().split("+")).each(function(key){ 807 812 if(key=="alt"){ 808 _e 3.push("a");813 _e6.push("a"); 809 814 }else{ 810 815 if(key=="ctrl"){ 811 _e 3.push("c");816 _e6.push("c"); 812 817 }else{ 813 818 if(key=="shift"){ 814 _e 3.push("s");815 }else{ 816 _e 2=_e4.keyCode[key];817 } 818 } 819 } 820 }); 821 var key=_e 3.sortBy(function(_e7,_e8){822 return _e 7;819 _e6.push("s"); 820 }else{ 821 _e5=_e7.keyCode[key]; 822 } 823 } 824 } 825 }); 826 var key=_e6.sortBy(function(_ea,_eb){ 827 return _ea; 823 828 }).join(""); 824 829 if(key==""){ 825 830 key="n"; 826 831 } 827 if(_e 0){828 if(_e 1){829 this.keyupFunc[_e 2]=_e0;830 }else{ 831 this.keydownFunc[key][_e 2]=_e0;832 } 833 }else{ 834 if(_e 1){835 this.keyupFunc[_e 2]=null;836 }else{ 837 this.keydownFunc[key][_e 2]=null;838 } 839 } 840 },_mergeNumKey:function(_e 9){841 return (this.numKeys[_e 9])?this.numKeys[_e9]:_e9;832 if(_e3){ 833 if(_e4){ 834 this.keyupFunc[_e5]=_e3; 835 }else{ 836 this.keydownFunc[key][_e5]=_e3; 837 } 838 }else{ 839 if(_e4){ 840 this.keyupFunc[_e5]=null; 841 }else{ 842 this.keydownFunc[key][_e5]=null; 843 } 844 } 845 },_mergeNumKey:function(_ec){ 
