Changeset 5746
- Timestamp:
- 04/23/08 15:59:26 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinelz/trunk/compress/javascripts/spinelz_lib/spinelz_util.js
r5735 r5746 243 243 },cutSpaces:function(){ 244 244 return this.normalizeSpaces().gsub(/[\s]/,""); 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(); 245 },getSmartLength:function(){ 246 var r=0; 247 for(var i=0;i<this.length;i++){ 248 var c=this.charCodeAt(i); 249 r+=(((c>=0&&c<129)||(c==63728)||(c>=65377&&c<65440)||(c>=63729&&c<63732))?1:2); 250 } 251 return r; 252 },getPrefix:function(_53){ 253 if(!_53){ 254 _53="_"; 255 } 256 return this.split(_53)[0]; 257 },getSuffix:function(_54){ 258 if(!_54){ 259 _54="_"; 260 } 261 return this.split(_54).pop(); 255 262 },normalizeSpaces:function(){ 256 263 return this.gsub(this._mb_space," "); … … 258 265 return this.strip().gsub(this._rf,"").gsub(this._rb,""); 259 266 },toElement:function(){ 260 var _5 2=document.createElement("div");261 _5 2.innerHTML=this;262 return _5 2.firstChild;267 var _55=document.createElement("div"); 268 _55.innerHTML=this; 269 return _55.firstChild; 263 270 }}); 264 271 var CssUtil=Class.create(); 265 CssUtil.getInstance=function(_5 3,_54){266 var _5 5=CssUtil.appendPrefix(_53,_54);267 return new CssUtil([_5 4,_55]);272 CssUtil.getInstance=function(_56,_57){ 273 var _58=CssUtil.appendPrefix(_56,_57); 274 return new CssUtil([_57,_58]); 268 275 }; 269 CssUtil.appendPrefix=function(_5 6,_57){270 var _5 8={};271 $H(_5 7).each(function(_59){272 _5 8[_59[0]]=_56+_57[_59[0]];273 }); 274 return _5 8;276 CssUtil.appendPrefix=function(_59,_5a){ 277 var _5b={}; 278 $H(_5a).each(function(_5c){ 279 _5b[_5c[0]]=_59+_5a[_5c[0]]; 280 }); 281 return _5b; 275 282 }; 276 CssUtil.getCssRules=function(_5 a){277 return _5 a.rules||_5a.cssRules;283 CssUtil.getCssRules=function(_5d){ 284 return _5d.rules||_5d.cssRules; 278 285 }; 279 CssUtil.getCssRuleBySelectorText=function(_5 b){280 var _5 c=null;286 CssUtil.getCssRuleBySelectorText=function(_5e){ 287 var _5f=null; 281 288 $A(document.styleSheets).each(function(s){ 282 var _ 5e=CssUtil.getCssRules(s);283 _5 c=$A(_5e).detect(function(r){289 var _61=CssUtil.getCssRules(s); 290 _5f=$A(_61).detect(function(r){ 284 291 if(!r.selectorText){ 285 292 return false; 286 293 } 287 return r.selectorText.toLowerCase()==_5 b.toLowerCase();288 }); 289 if(_5 c){294 return r.selectorText.toLowerCase()==_5e.toLowerCase(); 295 }); 296 if(_5f){ 290 297 throw $break; 291 298 } 292 299 }); 293 return _5 c;300 return _5f; 294 301 }; 295 CssUtil.prototype={initialize:function(_6 0){296 if(!((typeof (_6 0)=="object")&&(_60.constructor==Array))){302 CssUtil.prototype={initialize:function(_63){ 303 if(!((typeof (_63)=="object")&&(_63.constructor==Array))){ 297 304 throw "CssUtil#initialize: argument must be a Array object!"; 298 305 } 299 this.styles=_6 0;306 this.styles=_63; 300 307 },getClasses:function(key){ 301 308 return this.styles.collect(function(s){ … … 305 312 return this.getClasses(key).join(" "); 306 313 },allJoinClassNames:function(){ 307 var _6 4={};308 $H(this.styles.first()).each(function(_6 5){309 _6 4[_65.key]=this.joinClassNames(_65.key);314 var _67={}; 315 $H(this.styles.first()).each(function(_68){ 316 _67[_68.key]=this.joinClassNames(_68.key); 310 317 }.bind(this)); 311 return _6 4;312 },addClassNames:function(_6 6,key){318 return _67; 319 },addClassNames:function(_69,key){ 313 320 this.styles.each(function(s){ 314 Element.addClassName(_6 6,s[key]);315 }); 316 },removeClassNames:function(_6 9,key){321 Element.addClassName(_69,s[key]); 322 }); 323 },removeClassNames:function(_6c,key){ 317 324 this.styles.each(function(s){ 318 Element.removeClassName(_6 9,s[key]);319 }); 320 },refreshClassNames:function(_6 c,key){321 _6 c.className="";322 this.addClassNames(_6 c,key);323 },hasClassName:function(_ 6e,key){325 Element.removeClassName(_6c,s[key]); 326 }); 327 },refreshClassNames:function(_6f,key){ 328 _6f.className=""; 329 this.addClassNames(_6f,key); 330 },hasClassName:function(_71,key){ 324 331 return this.styles.any(function(s){ 325 return Element.hasClassName(_ 6e,s[key]);332 return Element.hasClassName(_71,s[key]); 326 333 }); 327 334 }}; 328 335 var Hover=Class.create(); 329 Hover.prototype={initialize:function(_7 1){336 Hover.prototype={initialize:function(_74){ 330 337 this.options=Object.extend({defaultClass:"",hoverClass:"",cssUtil:"",list:false,beforeToggle:function(){ 331 338 return true; 332 339 }},arguments[1]||{}); 333 var _7 1=$(_71);340 var _74=$(_74); 334 341 if(this.options.list){ 335 var _7 2=_71.childNodes;336 for(var i=0;i<_7 2.length;i++){337 if(Element.isElementNode(_7 2[i])){338 this.build(_7 2[i]);339 } 340 } 341 }else{ 342 this.build(_7 1);343 } 344 this.element=_7 1;345 },build:function(_7 4){346 this.normal=this.getNormalClass(_7 4);342 var _75=_74.childNodes; 343 for(var i=0;i<_75.length;i++){ 344 if(Element.isElementNode(_75[i])){ 345 this.build(_75[i]); 346 } 347 } 348 }else{ 349 this.build(_74); 350 } 351 this.element=_74; 352 },build:function(_77){ 353 this.normal=this.getNormalClass(_77); 347 354 this.hover=this.getHoverClass(this.normal); 348 355 if(this.options.cssUtil){ … … 350 357 this.hover=this.options.cssUtil.joinClassNames(hover); 351 358 } 352 this.setHoverEvent(_7 4);353 },setHoverEvent:function(_7 5){354 this.mouseout=this.toggle.bindAsEventListener(this,_7 5,this.normal);355 this.mouseover=this.toggle.bindAsEventListener(this,_7 5,this.hover);356 Event.observe(_7 5,"mouseout",this.mouseout);357 Event.observe(_7 5,"mouseover",this.mouseover);358 },toggle:function(_7 6,_77,_78){359 Event.stop(_7 6);359 this.setHoverEvent(_77); 360 },setHoverEvent:function(_78){ 361 this.mouseout=this.toggle.bindAsEventListener(this,_78,this.normal); 362 this.mouseover=this.toggle.bindAsEventListener(this,_78,this.hover); 363 Event.observe(_78,"mouseout",this.mouseout); 364 Event.observe(_78,"mouseover",this.mouseover); 365 },toggle:function(_79,_7a,_7b){ 366 Event.stop(_79); 360 367 if(this.options.beforeToggle()){ 361 _7 7.className=_78;362 } 363 },getNormalClass:function(_7 9){364 var _7 a=(this.options.defaultClass||_79.className);365 return (_7 a||"");366 },getHoverClass:function(_7 b){367 var _7 c=this.options.hoverClass;368 if(!_7 c){369 _7 c=_7b.split(" ").collect(function(c){368 _7a.className=_7b; 369 } 370 },getNormalClass:function(_7c){ 371 var _7d=(this.options.defaultClass||_7c.className); 372 return (_7d||""); 373 },getHoverClass:function(_7e){ 374 var _7f=this.options.hoverClass; 375 if(!_7f){ 376 _7f=_7e.split(" ").collect(function(c){ 370 377 return c+"Hover"; 371 378 }).join(" "); 372 379 } 373 return _7 c;380 return _7f; 374 381 },destroy:function(){ 375 382 Event.stopObserving(this.element,"mouseout",this.mouseout); … … 383 390 Object.extend(Date.prototype,{msPerDay:function(){ 384 391 return 24*60*60*1000; 385 },advance:function(_ 7e){386 return new Date(this.getTime()+this.msPerDay()*_ 7e.days);392 },advance:function(_81){ 393 return new Date(this.getTime()+this.msPerDay()*_81.days); 387 394 },days:function(){ 388 var _ 7f=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0);389 return Math.round(_ 7f.getTime()/this.msPerDay());395 var _82=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0); 396 return Math.round(_82.getTime()/this.msPerDay()); 390 397 },toHash:function(){ 391 398 return {year:this.getFullYear(),month:this.getMonth(),day:this.getDate(),hour:this.getHours(),min:this.getMinutes(),sec:this.getSeconds()}; 392 },sameYear:function(_8 0){393 return this.getFullYear()==_8 0.getFullYear();394 },sameMonth:function(_8 1){395 return this.sameYear(_8 1)&&this.getMonth()==_81.getMonth();396 },sameDate:function(_8 2){397 return this.sameYear(_8 2)&&this.sameMonth(_82)&&this.getDate()==_82.getDate();398 },betweenDate:function(_8 3,_84){399 var _8 5=this.days();400 return (_8 3.days()<=_85&&_85<=_84.days());401 },betweenTime:function(_8 6,_87){402 var _8 8=this.getTime();403 return (_8 6.getTime()<=_88&&_88<=_87.getTime());404 },strftime:function(_8 9){405 return DateUtil.simpleFormat(_8 9)(this);399 },sameYear:function(_83){ 400 return this.getFullYear()==_83.getFullYear(); 401 },sameMonth:function(_84){ 402 return this.sameYear(_84)&&this.getMonth()==_84.getMonth(); 403 },sameDate:function(_85){ 404 return this.sameYear(_85)&&this.sameMonth(_85)&&this.getDate()==_85.getDate(); 405 },betweenDate:function(_86,_87){ 406 var _88=this.days(); 407 return (_86.days()<=_88&&_88<=_87.days()); 408 },betweenTime:function(_89,_8a){ 409 var _8b=this.getTime(); 410 return (_89.getTime()<=_8b&&_8b<=_8a.getTime()); 411 },strftime:function(_8c){ 412 return DateUtil.simpleFormat(_8c)(this); 406 413 }}); 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(_8 a,_8b){408 return _8 b.days()-_8a.days();409 },isLeapYear:function(_8 c){410 if(((_8 c%4==0)&&(_8c%100!=0))||(_8c%400==0)){414 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(_8d,_8e){ 415 return _8e.days()-_8d.days(); 416 },isLeapYear:function(_8f){ 417 if(((_8f%4==0)&&(_8f%100!=0))||(_8f%400==0)){ 411 418 return true; 412 419 } 413 420 return false; 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(_9 1,_92){421 var _9 3=this.daysOfMonth[_92];422 if((_9 2==1)&&this.isLeapYear(_91)){423 return new Date(_9 1,_92,_93+1);424 } 425 return new Date(_9 1,_92,_93);426 },getFirstDate:function(_9 4,_95){427 if(_9 4.constructor==Date){428 return new Date(_9 4.getFullYear(),_94.getMonth(),1);429 } 430 return new Date(_9 4,_95,1);431 },getWeekTurn:function(_9 6,_97){432 var _9 8=6-_97+1;433 var _9 9=0;434 while(_9 8<_96){435 _9 6-=7;436 _9 9++;437 } 438 return _9 9;439 },toDateString:function(_9 a){440 return _9 a.toDateString();441 },toLocaleDateString:function(_9 b){442 return _9 b.toLocaleDateString();443 },simpleFormat:function(_9 c){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;421 },nextDate:function(_90){ 422 return new Date(_90.getFullYear(),_90.getMonth(),_90.getDate()+1); 423 },previousDate:function(_91){ 424 return new Date(_91.getFullYear(),_91.getMonth(),_91.getDate()-1); 425 },afterDays:function(_92,_93){ 426 return new Date(_92.getFullYear(),_92.getMonth(),_92.getDate()+_93); 427 },getLastDate:function(_94,_95){ 428 var _96=this.daysOfMonth[_95]; 429 if((_95==1)&&this.isLeapYear(_94)){ 430 return new Date(_94,_95,_96+1); 431 } 432 return new Date(_94,_95,_96); 433 },getFirstDate:function(_97,_98){ 434 if(_97.constructor==Date){ 435 return new Date(_97.getFullYear(),_97.getMonth(),1); 436 } 437 return new Date(_97,_98,1); 438 },getWeekTurn:function(_99,_9a){ 439 var _9b=6-_9a+1; 440 var _9c=0; 441 while(_9b<_99){ 442 _99-=7; 443 _9c++; 444 } 445 return _9c; 446 },toDateString:function(_9d){ 447 return _9d.toDateString(); 448 },toLocaleDateString:function(_9e){ 449 return _9e.toLocaleDateString(); 450 },simpleFormat:function(_9f){ 451 return function(_a0){ 452 var _a1=_9f.replace(/M+/g,DateUtil.zerofill((_a0.getMonth()+1).toString(),2)); 453 _a1=_a1.replace(/d+/g,DateUtil.zerofill(_a0.getDate().toString(),2)); 454 _a1=_a1.replace(/y{4}/g,_a0.getFullYear()); 455 _a1=_a1.replace(/y{1,3}/g,new String(_a0.getFullYear()).substr(2)); 456 _a1=_a1.replace(/E+/g,DateUtil.dayOfWeek[_a0.getDay()]); 457 return _a1; 451 458 }; 452 },zerofill:function(_ 9f,_a0){453 var _a 1=_9f;454 if(_ 9f.length<_a0){455 var tmp=_a 0-_9f.length;459 },zerofill:function(_a2,_a3){ 460 var _a4=_a2; 461 if(_a2.length<_a3){ 462 var tmp=_a3-_a2.length; 456 463 for(i=0;i<tmp;i++){ 457 _a 1="0"+_a1;458 } 459 } 460 return _a 1;461 },toDate:function(_a 3){462 return new Date(_a 3.year,_a3.month,_a3.day,_a3.hour||0,_a3.min||0,_a3.sec||0);464 _a4="0"+_a4; 465 } 466 } 467 return _a4; 468 },toDate:function(_a6){ 469 return new Date(_a6.year,_a6.month,_a6.day,_a6.hour||0,_a6.min||0,_a6.sec||0); 463 470 }}; 464 var ZindexManager={zIndex:1000,getIndex:function(_a 4){465 if(_a 4){466 if(isNaN(_a 4)){467 _a 4=Element.getMaxZindex()+1;468 }else{ 469 if(ZindexManager.zIndex>_a 4){470 _a 4=ZindexManager.zIndex;471 } 472 } 473 }else{ 474 _a 4=ZindexManager.zIndex;475 } 476 ZindexManager.zIndex=_a 4+1;477 return _a 4;471 var ZindexManager={zIndex:1000,getIndex:function(_a7){ 472 if(_a7){ 473 if(isNaN(_a7)){ 474 _a7=Element.getMaxZindex()+1; 475 }else{ 476 if(ZindexManager.zIndex>_a7){ 477 _a7=ZindexManager.zIndex; 478 } 479 } 480 }else{ 481 _a7=ZindexManager.zIndex; 482 } 483 ZindexManager.zIndex=_a7+1; 484 return _a7; 478 485 }}; 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(_a 5,_a6,_a7){480 this._mask.callAfterLoading(this,_a 5,_a6,_a7);486 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(_a8,_a9,_aa){ 487 this._mask.callAfterLoading(this,_a8,_a9,_aa); 481 488 this._control_tab_key(); 482 489 },unmask:function(){ … … 485 492 },unmaskAll:function(){ 486 493 var max=10; 487 var _a 9=0;488 while(this._isMasked()&&(_a 9<max)){494 var _ac=0; 495 while(this._isMasked()&&(_ac<max)){ 489 496 this._unmask(); 490 _a 9++;497 _ac++; 491 498 } 492 499 this._control_tab_key(); 493 },addMaskCallback:function(_a a){500 },addMaskCallback:function(_ad){ 494 501 if(!this.maskCallbacks.any(function(c){ 495 return c==_a a;502 return c==_ad; 496 503 })){ 497 this.maskCallbacks.push(_a a);498 } 499 },removeMaskCallback:function(_a c){504 this.maskCallbacks.push(_ad); 505 } 506 },removeMaskCallback:function(_af){ 500 507 this.maskCallbacks=this.maskCallbacks.reject(function(c){ 501 return c==_a c;508 return c==_af; 502 509 }); 503 510 },clearMaskCallback:function(){ 504 511 this.maskCallbacks=[]; 505 },addUnmaskCallback:function(_ ae){512 },addUnmaskCallback:function(_b1){ 506 513 if(!this.unmaskCallbacks.any(function(c){ 507 return c==_ ae;514 return c==_b1; 508 515 })){ 509 this.unmaskCallbacks.push(_ ae);510 } 511 },removeUnmaskCallback:function(_b 0){516 this.unmaskCallbacks.push(_b1); 517 } 518 },removeUnmaskCallback:function(_b3){ 512 519 this.unmaskCallbacks=this.unmaskCallbacks.reject(function(c){ 513 return c==_b 0;520 return c==_b3; 514 521 }); 515 522 },clearUnmaskCallback:function(){ 516 523 this.unmaskCallbacks=[]; 517 },_mask:function(_b 2){518 var _b 3=Object.extend({cssPrefix:"custom_",zIndex:null},arguments[1]||{});519 var _b 4=arguments[2];524 },_mask:function(_b5){ 525 var _b6=Object.extend({cssPrefix:"custom_",zIndex:null},arguments[1]||{}); 526 var _b7=arguments[2]; 520 527 if(Modal.element){ 521 Modal._snap(_b 2);528 Modal._snap(_b5); 522 529 Modal._rebuildMask(); 523 530 }else{ 524 531 Modal.snaps=[]; 525 532 Modal.excepteds=[]; 526 Modal._buildMask(_b 3.cssPrefix);533 Modal._buildMask(_b6.cssPrefix); 527 534 Modal.cover=new IECover(Modal.element,{transparent:true}); 528 535 } 529 if(_b 4){536 if(_b7){ 530 537 Element.setStyle(Modal.element,{position:"absolute"}); 531 538 this._setModalPosition(); … … 534 541 } 535 542 } 536 Modal._setZindex(_b 2,_b3.zIndex);543 Modal._setZindex(_b5,_b6.zIndex); 537 544 Modal._setFullSize(); 538 if(!Modal.hasExcepted(_b 2)){539 Modal.excepteds.push(_b 2);545 if(!Modal.hasExcepted(_b5)){ 546 Modal.excepteds.push(_b5); 540 547 } 541 548 this.count++; 542 this.maskCallbacks.each(function(_b 5){543 _b 5(_b2);549 this.maskCallbacks.each(function(_b8){ 550 _b8(_b5); 544 551 }); 545 552 },_unmask:function(){ … … 557 564 } 558 565 this.count++; 559 this.unmaskCallbacks.each(function(_b 6){560 _b 6();566 this.unmaskCallbacks.each(function(_b9){ 567 _b9(); 561 568 }); 562 569 },_setModalPosition:function(){ … … 588 595 },_isMasked:function(){ 589 596 return Modal.element&&Element.visible(Modal.element); 590 },_snap:function(_b 7){591 var _b 8=Element.getStyle(Modal.element,"zIndex");592 if(_b 8&&Modal._isMasked()&&!Modal.hasExcepted(_b7)){593 Modal.snaps.push(_b 8);594 } 595 },_setZindex:function(_b 9,_ba){596 _b a=ZindexManager.getIndex(_ba);597 Element.setStyle(Modal.element,{zIndex:_b a});598 _b 9=Element.makePositioned($(_b9));599 Element.setStyle(_b 9,{zIndex:++_ba});597 },_snap:function(_ba){ 598 var _bb=Element.getStyle(Modal.element,"zIndex"); 599 if(_bb&&Modal._isMasked()&&!Modal.hasExcepted(_ba)){ 600 Modal.snaps.push(_bb); 601 } 602 },_setZindex:function(_bc,_bd){ 603 _bd=ZindexManager.getIndex(_bd); 604 Element.setStyle(Modal.element,{zIndex:_bd}); 605 _bc=Element.makePositioned($(_bc)); 606 Element.setStyle(_bc,{zIndex:++_bd}); 600 607 },_setFullSize:function(){ 601 608 Modal.element.setStyle({width:Element.getWindowWidth()+"px",height:Element.getWindowHeight()+"px"}); … … 603 610 Modal.cover.resetSize(); 604 611 } 605 },_buildMask:function(_b b){606 var _b c=Builder.node("div",{id:Modal.maskId});607 Modal._setClassNames(_b c,_bb);608 document.body.appendChild(_b c);609 Modal.element=_b c;612 },_buildMask:function(_be){ 613 var _bf=Builder.node("div",{id:Modal.maskId}); 614 Modal._setClassNames(_bf,_be); 615 document.body.appendChild(_bf); 616 Modal.element=_bf; 610 617 Modal._addEvent(); 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);618 },_setClassNames:function(_c0,_c1){ 619 var _c2=(UserAgent.isIE())?Modal.maskClassIE:Modal.maskClass; 620 Element.addClassName(_c0,_c2); 621 Element.addClassName(_c0,_c1+_c2); 615 622 },_rebuildMask:function(){ 616 623 document.body.appendChild(Modal.element); … … 623 630 return src.spinelzMaskResult; 624 631 } 625 var _c 1=false;626 var _c 2=this.excepteds.last();627 var _c 3=src;628 if(_c 2&&Element.descendantOf(src,_c2)){629 _c 1=true;630 }else{ 631 var _c 4=Element.getStyle(Modal.element,"zIndex");632 var _c 5=null;632 var _c4=false; 633 var _c5=this.excepteds.last(); 634 var _c6=src; 635 if(_c5&&Element.descendantOf(src,_c5)){ 636 _c4=true; 637 }else{ 638 var _c7=Element.getStyle(Modal.element,"zIndex"); 639 var _c8=null; 633 640 while((src=src.parentNode)&&src!=document.body){ 634 if(src.style&&(_c 5=Element.getStyle(src,"zIndex"))){635 _c 1=(_c5>_c4);641 if(src.style&&(_c8=Element.getStyle(src,"zIndex"))){ 642 _c4=(_c8>_c7); 636 643 break; 637 644 } 638 645 } 639 646 } 640 _c 3.spinelzMaskCount=this.count;641 _c 3.spinelzMaskResult=_c1;642 return _c 1;643 },_handleEvent:function(_c 6){644 var src=Event.element(_c 6);645 if(!(Modal._isOutOfModal(src)||(_c 6.keyCode&&(_c6.keyCode==this.tabKey)))){646 Event.stop(_c 6);647 } 648 },_onResize:function(_c 8){647 _c6.spinelzMaskCount=this.count; 648 _c6.spinelzMaskResult=_c4; 649 return _c4; 650 },_handleEvent:function(_c9){ 651 var src=Event.element(_c9); 652 if(!(Modal._isOutOfModal(src)||(_c9.keyCode&&(_c9.keyCode==this.tabKey)))){ 653 Event.stop(_c9); 654 } 655 },_onResize:function(_cb){ 649 656 Modal._setFullSize(); 650 },hasExcepted:function(_c 9){651 return (Modal.excepteds||[]).any(function(_c a){652 return _c a.id==_c9.id;653 }); 654 },_control_tab_key:function(_c b){655 if(!_c b){656 _c b=$A(document.body.getElementsByTagName("form"));657 } 658 _c b.each(function(_cc){659 if(!Modal._isOutOfModal(_c c)){660 Form.getElements(_c c).each(function(el){657 },hasExcepted:function(_cc){ 658 return (Modal.excepteds||[]).any(function(_cd){ 659 return _cd.id==_cc.id; 660 }); 661 },_control_tab_key:function(_ce){ 662 if(!_ce){ 663 _ce=$A(document.body.getElementsByTagName("form")); 664 } 665 _ce.each(function(_cf){ 666 if(!Modal._isOutOfModal(_cf)){ 667 Form.getElements(_cf).each(function(el){ 661 668 el.tabIndex=-1; 662 669 }); 663 670 }else{ 664 Form.getElements(_c c).each(function(el){671 Form.getElements(_cf).each(function(el){ 665 672 el.tabIndex=null; 666 673 }); … … 670 677 var IECover=Class.create(); 671 678 IECover.src="javascript:false;"; 672 IECover.prototype={idSuffix:"iecover",initialize:function(_ cf){679 IECover.prototype={idSuffix:"iecover",initialize:function(_d2){ 673 680 this.options=Object.extend({transparent:false,padding:0},arguments[1]||{}); 674 681 if(document.all){ 675 _ cf=$(_cf);676 this.id=_ cf.id.appendSuffix(this.idSuffix);677 this._build(_ cf);682 _d2=$(_d2); 683 this.id=_d2.id.appendSuffix(this.idSuffix); 684 this._build(_d2); 678 685 this.resetSize(); 679 686 } 680 687 },resetSize:function(){ 681 688 if(this.element){ 682 var _d 0=this.element.parentNode;683 var _d 1=this.options.padding;684 this.element.width=_d 0.offsetWidth-_d1+"px";685 this.element.height=Element.getHeight(_d 0)-_d1+"px";686 } 687 },_build:function(_d 2){688 var _d 3=this.options.padding/2;689 var _d 4={position:"absolute",top:_d3+"px",left:_d3+"px"};689 var _d3=this.element.parentNode; 690 var _d4=this.options.padding; 691 this.element.width=_d3.offsetWidth-_d4+"px"; 692 this.element.height=Element.getHeight(_d3)-_d4+"px"; 693 } 694 },_build:function(_d5){ 695 var _d6=this.options.padding/2; 696 var _d7={position:"absolute",top:_d6+"px",left:_d6+"px"}; 690 697 if(this.options.transparent){ 691 _d 4.filter="alpha(opacity=0)";692 } 693 if(_d 2.buildedIECover&&$(this.id)){698 _d7.filter="alpha(opacity=0)"; 699 } 700 if(_d5.buildedIECover&&$(this.id)){ 694 701 this.element=$(this.id); 695 702 }else{ 696 703 this.element=Builder.node("iframe",{src:IECover.src,id:this.id,frameborder:0}); 697 704 } 698 Element.setStyle(this.element,_d 4);699 var _d 5=Element.down(_d2,0);700 if(_d 5){701 Element.makePositioned(_d 5);702 } 703 _d 2.insertBefore(this.element,_d2.firstChild);704 _d 2.buildedIECover=true;705 Element.setStyle(this.element,_d7); 706 var _d8=Element.down(_d5,0); 707 if(_d8){ 708 Element.makePositioned(_d8); 709 } 710 _d5.insertBefore(this.element,_d5.firstChild); 711 _d5.buildedIECover=true; 705 712 }}; 706 713 var UserAgent={getUserAgent:function(){ … … 717 724 var ShortcutManager=Class.create(); 718 725 ShortcutManager.prototype={initialize:function(){ 719 var _d 6={detectKeyup:false,initialStarted:true,preventDefault:true};720 this.options=Object.extend(_d 6,arguments[0]||{});726 var _d9={detectKeyup:false,initialStarted:true,preventDefault:true}; 727 this.options=Object.extend(_d9,arguments[0]||{}); 721 728 this.keydownListener=this.eventKeydown.bindAsEventListener(this); 722 729 if(this.options.detectKeyup){ … … 744 751 Event.observe(document,"keyup",this.keyupListener); 745 752 } 746 },add:function(c1,c2,_d 9){753 },add:function(c1,c2,_dc){ 747 754 if(c1.constructor==Array){ 748 var _d a=this;749 c1.each(function(_d b){750 _d a._add_or_remove_function(_db[0],_db[1],_d9);751 }); 752 }else{ 753 this._add_or_remove_function(c1,c2,_d 9);755 var _dd=this; 756 c1.each(function(_de){ 757 _dd._add_or_remove_function(_de[0],_de[1],_dc); 758 }); 759 }else{ 760 this._add_or_remove_function(c1,c2,_dc); 754 761 } 755 762 },destroy:function(){ … … 758 765 Event.stopObserving(document,"keyup",this.keyupListener); 759 766 } 760 },eventKeydown:function(_d c){767 },eventKeydown:function(_df){ 761 768 if(this.executable){ 762 var _ dd;769 var _e0; 763 770 var key=""; 764 _d c=_dc||window.event;765 if(_d c.keyCode){766 if(_d c.altKey){771 _df=_df||window.event; 772 if(_df.keyCode){ 773 if(_df.altKey){ 767 774 key+="a"; 768 775 } 769 if(_d c.ctrlKey){776 if(_df.ctrlKey){ 770 777 key+="c"; 771 778 } 772 if(_d c.shiftKey){779 if(_df.shiftKey){ 773 780 key+="s"; 774 781 } … … 776 783 key="n"; 777 784 } 778 _dd=this._mergeNumKey(_dc.keyCode);779 if(this.keydownFunc[key][_dd]){780 this.keydownFunc[key][_dd]();781 if(this.options.preventDefault){782 Event.stop(_dc);783 }784 }785 }786 }787 },eventKeyup:function(_df){788 if(this.executable){789 var _e0;790 _df=_df||window.event;791 if(_df.keyCode){792 785 _e0=this._mergeNumKey(_df.keyCode); 793 if(this.key upFunc[_e0]){794 this.key upFunc[_e0]();786 if(this.keydownFunc[key][_e0]){ 787 this.keydownFunc[key][_e0](); 795 788 if(this.options.preventDefault){ 796 789 Event.stop(_df); … … 799 792 } 800 793 } 801 },remove:function(_e1){ 802 this._add_or_remove_function(_e1); 794 },eventKeyup:function(_e2){ 795 if(this.executable){ 796 var _e3; 797 _e2=_e2||window.event; 798 if(_e2.keyCode){ 799 _e3=this._mergeNumKey(_e2.keyCode); 800 if(this.keyupFunc[_e3]){ 801 this.keyupFunc[_e3](); 802 if(this.options.preventDefault){ 803 Event.stop(_e2); 804 } 805 } 806 } 807 } 808 },remove:function(_e4){ 809 this._add_or_remove_function(_e4); 803 810 },start:function(){ 804 811 this.executable=true; 805 812 },stop:function(){ 806 813 this.executable=false; 807 },_add_or_remove_function:function(_e 2,_e3,_e4){808 var _e 5;809 var _e 6=new Array();810 var _e 7=this;811 $A(_e 2.toLowerCase().split("+")).each(function(key){814 },_add_or_remove_function:function(_e5,_e6,_e7){ 815 var _e8; 816 var _e9=new Array(); 817 var _ea=this; 818 $A(_e5.toLowerCase().split("+")).each(function(key){ 812 819 if(key=="alt"){ 813 _e 6.push("a");820 _e9.push("a"); 814 821 }else{ 815 822 if(key=="ctrl"){ 816 _e 6.push("c");823 _e9.push("c"); 817 824 }else{ 818 825 if(key=="shift"){ 819 _e 6.push("s");820 }else{ 821 _e 5=_e7.keyCode[key];822 } 823 } 824 } 825 }); 826 var key=_e 6.sortBy(function(_ea,_eb){827 return _e a;826 _e9.push("s"); 827 }else{ 828 _e8=_ea.keyCode[key]; 829 } 830 } 831 } 832 }); 833 var key=_e9.sortBy(function(_ed,_ee){ 834 return _ed; 828 835 }).join(""); 829 836 if(key==""){ 830 837 key="n"; 831 838 } 832 if(_e 3){833 if(_e 4){834 this.keyupFunc[_e 5]=_e3;835 }else{ 836 this.keydownFunc[key][_e 5]=_e3;837 } 838 }else{ 839 if(_e 4){840 this.keyupFunc[_e 5]=null;841 }else{ 842 this.keydownFunc[key][_e 5]=null;843 } 844 } 845 },_mergeNumKey:function(_e c){846 return (this.numKeys[_e c])?this.numKeys[_ec]:_ec;839 if(_e6){ 840 if(_e7){ 841 this.keyupFunc[_e8]=_e6; 842 }else{ 843 this.keydownFunc[key][_e8]=_e6; 844 } 845 }else{ 846 if(_e7){ 847 this.keyupFunc[_e8]=null; 848 }else{ 849 this.keydownFunc[key][_e8]=null; 850 } 851 } 852 },_mergeNumKey:function(_ef){ 853 return (this.numKeys[_ef])?this.numKeys[_ef]:_ef; 847 854 }}; 848 855 Function.prototype.callAfterLoading=function(){ 849 var _ ed=$A(arguments);850 var _ ee=this;851 var _ ef=_ed.shift()||this;856 var _f0=$A(arguments); 857 var _f1=this; 858 var _f2=_f0.shift()||this; 852 859 if(UserAgent.isIE()&&(document.readyState!="complete")){ 853 860 Event.observe(window,"load",function(){ 854 _ ee.apply(_ef,_ed);855 }); 856 }else{ 857 this.apply(_ ef,_ed);861 _f1.apply(_f2,_f0); 862 }); 863 }else{ 864 this.apply(_f2,_f0); 858 865 } 859 866 }; … … 870 877 document.body.focus(); 871 878 } 872 },concat:function(_f 0,_f1){873 var _f 2={};874 _f 1.each(function(_f3){875 _f 2[_f3]=_f0.appendSuffix(_f3);876 }); 877 return _f 2;878 },getId:function(_f 4){879 _f 4=_f4||"";880 return _f 4.appendSuffix(++SpinelzUtil.idCount);881 },toAttriteString:function(_f 5,_f6){882 var _f 7=_f5.map(function(_f8){883 return _f 8.key+"='"+_f8.value+"'";879 },concat:function(_f3,_f4){ 880 var _f5={}; 881 _f4.each(function(_f6){ 882 _f5[_f6]=_f3.appendSuffix(_f6); 883 }); 884 return _f5; 885 },getId:function(_f7){ 886 _f7=_f7||""; 887 return _f7.appendSuffix(++SpinelzUtil.idCount); 888 },toAttriteString:function(_f8,_f9){ 889 var _fa=_f8.map(function(_fb){ 890 return _fb.key+"='"+_fb.value+"'"; 884 891 }).join(" "); 885 if(_f 6&&(_f7.length>0)){886 _f 7=" "+_f7;887 } 888 return _f 7;889 },_redrawForIE:function(_f 9){892 if(_f9&&(_fa.length>0)){ 893 _fa=" "+_fa; 894 } 895 return _fa; 896 },_redrawForIE:function(_fc){ 890 897 if(UserAgent.isIE()){ 891 _f 9=$(_f9);892 if(_f 9){898 _fc=$(_fc); 899 if(_fc){ 893 900 setTimeout(function(){ 894 Element.classNames(_f 9).set("dummy");901 Element.classNames(_fc).set("dummy"); 895 902 },200); 896 903 } … … 903 910 }); 904 911 } 905 var $A=Array.from=function(_f a){906 if(!_f a){912 var $A=Array.from=function(_fd){ 913 if(!_fd){ 907 914 return []; 908 915 } 909 if(_f a.toArray){910 return _f a.toArray();911 }else{ 912 var _f b=[];913 for(var i=0,len=_f a.length;i<len;i++){914 _f b.push(_fa[i]);915 } 916 return _f b;916 if(_fd.toArray){ 917 return _fd.toArray(); 918 }else{ 919 var _fe=[]; 920 for(var i=0,len=_fd.length;i<len;i++){ 921 _fe.push(_fd[i]); 922 } 923 return _fe; 917 924 } 918 925 }; 919 926 var Color=Class.create(); 920 Color.prototype={initialize:function(_ fe){921 this.color=this.parse(_ fe);922 },toHex:function(_ ff){923 _ ff=_ff||this.color;924 return _ ff.invoke("toColorPart");927 Color.prototype={initialize:function(_101){ 928 this.color=this.parse(_101); 929 },toHex:function(_102){ 930 _102=_102||this.color; 931 return _102.invoke("toColorPart"); 925 932 },invert:function(){ 926 933 return this.toCssStyle(this.color.map(function(c){ 927 934 return 255-c; 928 935 })); 929 },toCssStyle:function(_10 1){930 _10 1=_101||this.color;931 return "#"+this.toHex(_10 1).join("");932 },parse:function(_10 2){933 _10 2=_102||this.color;934 if(_10 2.match(/rgb\(\d+,\s*\d+,\s*\d+\)/)){935 return _10 2.match(/\d+/g).map(function(c){936 },toCssStyle:function(_104){ 937 _104=_104||this.color; 938 return "#"+this.toHex(_104).join(""); 939 },parse:function(_105){ 940 _105=_105||this.color; 941 if(_105.match(/rgb\(\d+,\s*\d+,\s*\d+\)/)){ 942 return _105.match(/\d+/g).map(function(c){ 936 943 return parseInt(c,10); 937 944 }); 938 945 }else{ 939 if(_10 2.match(/#[a-fA-F0-9]{6}/)){940 return _10 2.match(/([a-fA-F0-9]){2}/g).map(function(c){946 if(_105.match(/#[a-fA-F0-9]{6}/)){ 947 return _105.match(/([a-fA-F0-9]){2}/g).map(function(c){ 941 948 return parseInt(c,16); 942 949 }); 943 950 } 944 951 } 945 throw "parse error: "+_10 2;952 throw "parse error: "+_105; 946 953 }}; 947 954 var DebugConsole={_active:false,_basetime:null,_messages:null,activate:function(){ 948 955 this._active=true; 949 },dump:function(_10 5){950 _10 5=_105||{};951 switch(_10 5.type){956 },dump:function(_108){ 957 _108=_108||{}; 958 switch(_108.type){ 952 959 case "alert": 953 960 this._dump_alert(); … … 960 967 break; 961 968 case "update": 962 this._dump_update(_10 5.target);969 this._dump_update(_108.target); 963 970 break; 964 971 default: … … 975 982 this._messages=[]; 976 983 } 977 },log:function(_10 6){984 },log:function(_109){ 978 985 if(this._active){ 979 var _10 7=("00000000"+(new Date()-this._basetime)).slice(-8);980 this._messages.push(_10 7+" : "+_106);986 var _10a=("00000000"+(new Date()-this._basetime)).slice(-8); 987 this._messages.push(_10a+" : "+_109); 981 988 } 982 989 },_dump_alert:function(){ 983 this._messages.each(function(_10 8){984 alert(_10 8);990 this._messages.each(function(_10b){ 991 alert(_10b); 985 992 }); 986 993 },_dump_clipboard:function(){ 987 994 var dump=""; 988 this._messages.each(function(_10 a){989 dump+=_10 a+"\n";995 this._messages.each(function(_10d){ 996 dump+=_10d+"\n"; 990 997 }); 991 998 clipboardData.setData("Text",dump); 992 999 },_dump_console:function(){ 993 this._messages.each(function(_10 b){994 console.log(_10 b);995 }); 996 },_dump_update:function(_10 c){1000 this._messages.each(function(_10e){ 1001 console.log(_10e); 1002 }); 1003 },_dump_update:function(_10f){ 997 1004 var html=""; 998 this._messages.each(function(_1 0e){999 html+="<p>"+_1 0e+"</p>";1000 }); 1001 Element.update(_10 c,html);1005 this._messages.each(function(_111){ 1006 html+="<p>"+_111+"</p>"; 1007 }); 1008 Element.update(_10f,html); 1002 1009 }}; 1003 1010 spinelz/trunk/compress/javascripts/spinelz_lib/spinelz_util_for_rubricks.js
r5735 r5746 4909 4909 },cutSpaces:function(){ 4910 4910 return this.normalizeSpaces().gsub(/[\s]/,""); 4911 },getPrefix:function(_50){ 4912 if(!_50){ 4913 _50="_"; 4914 } 4915 return this.split(_50)[0]; 4916 },getSuffix:function(_51){ 4917 if(!_51){ 4918 _51="_"; 4919 } 4920 return this.split(_51).pop(); 4911 },getSmartLength:function(){ 4912 var r=0; 4913 for(var i=0;i<this.length;i++){ 4914 var c=this.charCodeAt(i); 4915 r+=(((c>=0&&c<129)||(c==63728)||(c>=65377&&c<65440)||(c>=63729&&c<63732))?1:2); 4916 } 4917 return r; 4918 },getPrefix:function(_53){ 4919 if(!_53){ 4920 _53="_"; 4921 } 4922 return this.split(_53)[0]; 4923 },getSuffix:function(_54){ 4924 if(!_54){ 4925 _54="_"; 4926 } 4927 return this.split(_54).pop(); 4921 4928 },normalizeSpaces:function(){ 4922 4929 return this.gsub(this._mb_space," "); … … 4924 4931 return this.strip().gsub(this._rf,"").gsub(this._rb,""); 4925 4932 },toElement:function(){ 4926 var _5 2=document.createElement("div");4927 _5 2.innerHTML=this;4928 return _5 2.firstChild;4933 var _55=document.createElement("div"); 4934 _55.innerHTML=this; 4935 return _55.firstChild; 4929 4936 }}); 4930 4937 var CssUtil=Class.create(); 4931 CssUtil.getInstance=function(_5 3,_54){4932 var _5 5=CssUtil.appendPrefix(_53,_54);4933 return new CssUtil([_5 4,_55]);4934 }; 4935 CssUtil.appendPrefix=function(_5 6,_57){4936 var _5 8={};4937 $H(_5 7).each(function(_59){4938 _5 8[_59[0]]=_56+_57[_59[0]];4939 }); 4940 return _5 8;4941 }; 4942 CssUtil.getCssRules=function(_5 a){4943 return _5 a.rules||_5a.cssRules;4944 }; 4945 CssUtil.getCssRuleBySelectorText=function(_5 b){4946 var _5 c=null;4938 CssUtil.getInstance=function(_56,_57){ 4939 var _58=CssUtil.appendPrefix(_56,_57); 4940 return new CssUtil([_57,_58]); 4941 }; 4942 CssUtil.appendPrefix=function(_59,_5a){ 4943 var _5b={}; 4944 $H(_5a).each(function(_5c){ 4945 _5b[_5c[0]]=_59+_5a[_5c[0]]; 4946 }); 4947 return _5b; 4948 }; 4949 CssUtil.getCssRules=function(_5d){ 4950 return _5d.rules||_5d.cssRules; 4951 }; 4952 CssUtil.getCssRuleBySelectorText=function(_5e){ 4953 var _5f=null; 4947 4954 $A(document.styleSheets).each(function(s){ 4948 var _ 5e=CssUtil.getCssRules(s);4949 _5 c=$A(_5e).detect(function(r){4955 var _61=CssUtil.getCssRules(s); 4956 _5f=$A(_61).detect(function(r){ 4950 4957 if(!r.selectorText){ 4951 4958 return false; 4952 4959 } 4953 return r.selectorText.toLowerCase()==_5 b.toLowerCase();4954 }); 4955 if(_5 c){4960 return r.selectorText.toLowerCase()==_5e.toLowerCase(); 4961 }); 4962 if(_5f){ 4956 4963 throw $break; 4957 4964 } 4958 4965 }); 4959 return _5 c;4960 }; 4961 CssUtil.prototype={initialize:function(_6 0){4962 if(!((typeof (_6 0)=="object")&&(_60.constructor==Array))){4966 return _5f; 4967 }; 4968 CssUtil.prototype={initialize:function(_63){ 4969 if(!((typeof (_63)=="object")&&(_63.constructor==Array))){ 4963 4970 throw "CssUtil#initialize: argument must be a Array object!"; 4964 4971 } 4965 this.styles=_6 0;4972 this.styles=_63; 4966 4973 },getClasses:function(key){ 4967 4974 return this.styles.collect(function(s){ … … 4971 4978 return this.getClasses(key).join(" "); 4972 4979 },allJoinClassNames:function(){ 4973 var _6 4={};4974 $H(this.styles.first()).each(function(_6 5){4975 _6 4[_65.key]=this.joinClassNames(_65.key);4980 var _67={}; 4981 $H(this.styles.first()).each(function(_68){ 4982 _67[_68.key]=this.joinClassNames(_68.key); 4976 4983 }.bind(this)); 4977 return _6 4;4978 },addClassNames:function(_6 6,key){4984 return _67; 4985 },addClassNames:function(_69,key){ 4979 4986 this.styles.each(function(s){ 4980 Element.addClassName(_6 6,s[key]);4981 }); 4982 },removeClassNames:function(_6 9,key){4987 Element.addClassName(_69,s[key]); 4988 }); 4989 },removeClassNames:function(_6c,key){ 4983 4990 this.styles.each(function(s){ 4984 Element.removeClassName(_6 9
