From 54572d1e4a5914e44bcd35fa9406ea72a8f2066f Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 19 Feb 2006 22:25:23 +0000 Subject: Update TRatingList and date picker. --- framework/Web/Javascripts/datepicker/datepicker.js | 36 +- framework/Web/Javascripts/js/datepicker.js | 185 ++- framework/Web/Javascripts/js/prado.js | 1701 ++++++++++---------- framework/Web/Javascripts/ratings/10star_white.gif | Bin 25048 -> 0 bytes framework/Web/Javascripts/ratings/blocks.css | 29 + framework/Web/Javascripts/ratings/blocks.png | Bin 0 -> 29885 bytes framework/Web/Javascripts/ratings/blocks_blank.gif | Bin 0 -> 72 bytes framework/Web/Javascripts/ratings/blocks_half.gif | Bin 0 -> 94 bytes framework/Web/Javascripts/ratings/blocks_hover.gif | Bin 0 -> 75 bytes .../Web/Javascripts/ratings/blocks_selected.gif | Bin 0 -> 75 bytes framework/Web/Javascripts/ratings/default.css | 32 +- .../Web/Javascripts/ratings/default_blank.gif | Bin 0 -> 271 bytes framework/Web/Javascripts/ratings/default_half.gif | Bin 0 -> 619 bytes .../Web/Javascripts/ratings/default_hover.gif | Bin 0 -> 618 bytes .../Web/Javascripts/ratings/default_selected.gif | Bin 0 -> 614 bytes framework/Web/Javascripts/ratings/ratings.js | 70 +- framework/Web/Javascripts/ratings/stars1.png | Bin 0 -> 53016 bytes framework/Web/UI/WebControls/TDatePicker.php | 114 +- framework/Web/UI/WebControls/TRatingList.php | 173 +- 19 files changed, 1250 insertions(+), 1090 deletions(-) delete mode 100644 framework/Web/Javascripts/ratings/10star_white.gif create mode 100644 framework/Web/Javascripts/ratings/blocks.css create mode 100644 framework/Web/Javascripts/ratings/blocks.png create mode 100644 framework/Web/Javascripts/ratings/blocks_blank.gif create mode 100644 framework/Web/Javascripts/ratings/blocks_half.gif create mode 100644 framework/Web/Javascripts/ratings/blocks_hover.gif create mode 100644 framework/Web/Javascripts/ratings/blocks_selected.gif create mode 100644 framework/Web/Javascripts/ratings/default_blank.gif create mode 100644 framework/Web/Javascripts/ratings/default_half.gif create mode 100644 framework/Web/Javascripts/ratings/default_hover.gif create mode 100644 framework/Web/Javascripts/ratings/default_selected.gif create mode 100644 framework/Web/Javascripts/ratings/stars1.png (limited to 'framework/Web') diff --git a/framework/Web/Javascripts/datepicker/datepicker.js b/framework/Web/Javascripts/datepicker/datepicker.js index 49bcfac9..e906120c 100644 --- a/framework/Web/Javascripts/datepicker/datepicker.js +++ b/framework/Web/Javascripts/datepicker/datepicker.js @@ -394,13 +394,19 @@ Prado.WebUI.TDatePicker.prototype = { var day = $(this.options.ID+"_day"); var month = $(this.options.ID+"_month"); - var years = $(this.options.ID+"_year").options; + var year = $(this.options.ID+"_year"); var date = this.selectedDate; - day.selectedIndex = date.getDate()-1; - month.selectedIndex = date.getMonth(); - var currentYear = date.getFullYear(); - for(var i = 0; i < years.length; i++) - years[i].selected = years[i].value.toInteger() == currentYear; + if(day) + day.selectedIndex = date.getDate()-1; + if(month) + month.selectedIndex = date.getMonth(); + if(year) + { + var years = year.options; + var currentYear = date.getFullYear(); + for(var i = 0; i < years.length; i++) + years[i].selected = years[i].value.toInteger() == currentYear; + } } }, @@ -473,7 +479,10 @@ Prado.WebUI.TDatePicker.prototype = if(this.options.InputMode == "TextBox") pos[1] += this.control.offsetHeight; else - pos[1] += $(this.options.ID+"_day").offsetHeight-1; + { + if($(this.options.ID+"_day")) + pos[1] += $(this.options.ID+"_day").offsetHeight-1; + } this._calDiv.style.display = "block"; this._calDiv.style.top = (pos[1]-1) + "px"; @@ -500,9 +509,16 @@ Prado.WebUI.TDatePicker.prototype = return Date.SimpleParse($F(this.control), this.Format); else { - var day = $F(this.options.ID+"_day"); - var month = $F(this.options.ID+"_month"); - var year = $F(this.options.ID+"_year"); + var now=new Date(); + var year=now.getFullYear(); + var month=now.getMonth(); + var date=1; + if($(this.options.ID+"_day")) + day = $F(this.options.ID+"_day"); + if($(this.options.ID+"_month")) + month = $F(this.options.ID+"_month"); + if($(this.options.ID+"_year")) + year = $F(this.options.ID+"_year"); var newdate=new Date(year,month,day, 0, 0, 0); return newdate; } diff --git a/framework/Web/Javascripts/js/datepicker.js b/framework/Web/Javascripts/js/datepicker.js index b9d7b610..58ef5c7c 100644 --- a/framework/Web/Javascripts/js/datepicker.js +++ b/framework/Web/Javascripts/js/datepicker.js @@ -271,30 +271,37 @@ this.control.value=this.formatDate(); }else{ var day=$(this.options.ID+"_day"); var _34=$(this.options.ID+"_month"); -var _35=$(this.options.ID+"_year").options; +var _35=$(this.options.ID+"_year"); var _36=this.selectedDate; +if(day){ day.selectedIndex=_36.getDate()-1; +} +if(_34){ _34.selectedIndex=_36.getMonth(); -var _37=_36.getFullYear(); -for(var i=0;i<_35.length;i++){ -_35[i].selected=_35[i].value.toInteger()==_37; +} +if(_35){ +var _37=_35.options; +var _38=_36.getFullYear(); +for(var i=0;i<_37.length;i++){ +_37[i].selected=_37[i].value.toInteger()==_38; +} } } },formatDate:function(){ return this.selectedDate?this.selectedDate.SimpleFormat(this.Format):""; -},newDate:function(_38){ -if(!_38){ -_38=new Date(); +},newDate:function(_39){ +if(!_39){ +_39=new Date(); } -if(isString(_38)||isNumber(_38)){ -_38=new Date(_38); +if(isString(_39)||isNumber(_39)){ +_39=new Date(_39); } -return new Date(_38.getFullYear(),_38.getMonth(),_38.getDate(),0,0,0); -},setSelectedDate:function(_39){ -if(_39==null){ +return new Date(_39.getFullYear(),_39.getMonth(),_39.getDate(),0,0,0); +},setSelectedDate:function(_40){ +if(_40==null){ return; } -this.selectedDate=this.newDate(_39); +this.selectedDate=this.newDate(_40); this.updateHeader(); this.update(); if(isFunction(this.onchange)){ @@ -304,13 +311,13 @@ this.onchange(); return this._calDiv; },getSelectedDate:function(){ return isNull(this.selectedDate)?null:this.newDate(this.selectedDate); -},setYear:function(_40){ +},setYear:function(_41){ var d=this.newDate(this.selectedDate); -d.setFullYear(_40); +d.setFullYear(_41); this.setSelectedDate(d); -},setMonth:function(_41){ +},setMonth:function(_42){ var d=this.newDate(this.selectedDate); -d.setMonth(_41); +d.setMonth(_42); this.setSelectedDate(d); },nextMonth:function(){ this.setMonth(this.selectedDate.getMonth()+1); @@ -322,7 +329,17 @@ var pos=Position.cumulativeOffset(this.control); if(this.options.InputMode=="TextBox"){ pos[1]+=this.control.offsetHeight; }else{ +if($(this.options.ID+"_day")){ pos[1]+=$(this.options.ID+"_day").offsetHeight-1; +}else{ +if($(this.options.ID+"_month")){ +pos[1]+=$(this.options.ID+"_month").offsetHeight-1; +}else{ +if($(this.options.ID+"_year")){ +pos[1]+=$(this.options.ID+"_year").offsetHeight-1; +} +} +} } this._calDiv.style.display="block"; this._calDiv.style.top=(pos[1]-1)+"px"; @@ -331,10 +348,10 @@ this.ieHack(false); this.documentClickEvent=this.hideOnClick.bindEvent(this); this.documentKeyDownEvent=this.keyPressed.bindEvent(this); Event.observe(document.body,"click",this.documentClickEvent); -var _43=this.getDateFromInput(); -if(!isNull(_43)){ -this.selectedDate=_43; -this.setSelectedDate(_43); +var _44=this.getDateFromInput(); +if(!isNull(_44)){ +this.selectedDate=_44; +this.setSelectedDate(_44); } Event.observe(document,"keydown",this.documentKeyDownEvent); this.showing=true; @@ -343,28 +360,38 @@ this.showing=true; if(this.options.InputMode=="TextBox"){ return Date.SimpleParse($F(this.control),this.Format); }else{ -var day=$F(this.options.ID+"_day"); -var _44=$F(this.options.ID+"_month"); -var _45=$F(this.options.ID+"_year"); -var _46=new Date(_45,_44,day,0,0,0); -return _46; +var now=new Date(); +var _46=now.getFullYear(); +var _47=now.getMonth(); +var _48=1; +if($(this.options.ID+"_day")){ +day=$F(this.options.ID+"_day"); +} +if($(this.options.ID+"_month")){ +_47=$F(this.options.ID+"_month"); +} +if($(this.options.ID+"_year")){ +_46=$F(this.options.ID+"_year"); +} +var _49=new Date(_46,_47,day,0,0,0); +return _49; } },hideOnClick:function(ev){ if(!this.showing){ return; } var el=Event.element(ev); -var _47=false; +var _50=false; do{ -_47=_47||el.className==this.ClassName; -_47=_47||el==this.trigger; -_47=_47||el==this.control; -if(_47){ +_50=_50||el.className==this.ClassName; +_50=_50||el==this.trigger; +_50=_50||el==this.control; +if(_50){ break; } el=el.parentNode; }while(el); -if(!_47){ +if(!_50){ this.hide(); } },hide:function(){ @@ -378,61 +405,61 @@ Event.stopObserving(document.body,"click",this.documentClickEvent); Event.stopObserving(document,"keydown",this.documentKeyDownEvent); } },update:function(){ -var _48=this.selectedDate; -var _49=(this.newDate()).toISODate(); -var _50=_48.toISODate(); -var d1=new Date(_48.getFullYear(),_48.getMonth(),1); -var d2=new Date(_48.getFullYear(),_48.getMonth()+1,1); -var _53=Math.round((d2-d1)/(24*60*60*1000)); -var _54=(d1.getDay()-this.FirstDayOfWeek)%7; -if(_54<0){ -_54+=7; -} -var _55=0; -while(_55<_54){ -this.dateSlot[_55].value=-1; -this.dateSlot[_55].data.data=String.fromCharCode(160); -this.dateSlot[_55].data.parentNode.className="empty"; -_55++; -} -for(i=1;i<=_53;i++,_55++){ -var _56=this.dateSlot[_55]; -var _57=_56.data.parentNode; -_56.value=i; -_56.data.data=i; -_57.className="date"; -if(d1.toISODate()==_49){ -_57.className+=" today"; -} -if(d1.toISODate()==_50){ -_57.className+=" selected"; +var _51=this.selectedDate; +var _52=(this.newDate()).toISODate(); +var _53=_51.toISODate(); +var d1=new Date(_51.getFullYear(),_51.getMonth(),1); +var d2=new Date(_51.getFullYear(),_51.getMonth()+1,1); +var _56=Math.round((d2-d1)/(24*60*60*1000)); +var _57=(d1.getDay()-this.FirstDayOfWeek)%7; +if(_57<0){ +_57+=7; +} +var _58=0; +while(_58<_57){ +this.dateSlot[_58].value=-1; +this.dateSlot[_58].data.data=String.fromCharCode(160); +this.dateSlot[_58].data.parentNode.className="empty"; +_58++; +} +for(i=1;i<=_56;i++,_58++){ +var _59=this.dateSlot[_58]; +var _60=_59.data.parentNode; +_59.value=i; +_59.data.data=i; +_60.className="date"; +if(d1.toISODate()==_52){ +_60.className+=" today"; +} +if(d1.toISODate()==_53){ +_60.className+=" selected"; } d1=new Date(d1.getFullYear(),d1.getMonth(),d1.getDate()+1); } -var _58=_55; -while(_55<42){ -this.dateSlot[_55].value=-1; -this.dateSlot[_55].data.data=String.fromCharCode(160); -this.dateSlot[_55].data.parentNode.className="empty"; -++_55; +var _61=_58; +while(_58<42){ +this.dateSlot[_58].value=-1; +this.dateSlot[_58].data.data=String.fromCharCode(160); +this.dateSlot[_58].data.parentNode.className="empty"; +++_58; } },hover:function(ev){ Element.condClassName(Event.element(ev),"hover",ev.type=="mouseover"); },updateHeader:function(){ -var _59=this._monthSelect.options; +var _62=this._monthSelect.options; var m=this.selectedDate.getMonth(); -for(var i=0;i<_59.length;++i){ -_59[i].selected=false; -if(_59[i].value==m){ -_59[i].selected=true; -} -} -_59=this._yearSelect.options; -var _60=this.selectedDate.getFullYear(); -for(var i=0;i<_59.length;++i){ -_59[i].selected=false; -if(_59[i].value==_60){ -_59[i].selected=true; +for(var i=0;i<_62.length;++i){ +_62[i].selected=false; +if(_62[i].value==m){ +_62[i].selected=true; +} +} +_62=this._yearSelect.options; +var _63=this.selectedDate.getFullYear(); +for(var i=0;i<_62.length;++i){ +_62[i].selected=false; +if(_62[i].value==_63){ +_62[i].selected=true; } } }}; diff --git a/framework/Web/Javascripts/js/prado.js b/framework/Web/Javascripts/js/prado.js index 0ca3c0b1..b7dba8d8 100644 --- a/framework/Web/Javascripts/js/prado.js +++ b/framework/Web/Javascripts/js/prado.js @@ -303,15 +303,17 @@ var _54=m[2]+m[5]; var _55=m[1]+_54.replace(new RegExp("(\\"+_51+")","g"),"")+((_52>0)?"."+m[7]:""); var num=parseFloat(_55); return (isNaN(num)?null:num); +},toDate:function(_56){ +return Date.SimpleParse(this,_56); }}); var $break=new Object(); var $continue=new Object(); -var Enumerable={each:function(_56){ -var _57=0; +var Enumerable={each:function(_57){ +var _58=0; try{ -this._each(function(_58){ +this._each(function(_59){ try{ -_56(_58,_57++); +_57(_59,_58++); } catch(e){ if(e!=$continue){ @@ -325,154 +327,154 @@ if(e!=$break){ throw e; } } -},all:function(_59){ -var _60=true; -this.each(function(_61,_62){ -_60=_60&&!!(_59||Prototype.K)(_61,_62); -if(!_60){ +},all:function(_60){ +var _61=true; +this.each(function(_62,_63){ +_61=_61&&!!(_60||Prototype.K)(_62,_63); +if(!_61){ throw $break; } }); -return _60; -},any:function(_63){ -var _64=true; -this.each(function(_65,_66){ -if(_64=!!(_63||Prototype.K)(_65,_66)){ +return _61; +},any:function(_64){ +var _65=true; +this.each(function(_66,_67){ +if(_65=!!(_64||Prototype.K)(_66,_67)){ throw $break; } }); -return _64; -},collect:function(_67){ -var _68=[]; -this.each(function(_69,_70){ -_68.push(_67(_69,_70)); +return _65; +},collect:function(_68){ +var _69=[]; +this.each(function(_70,_71){ +_69.push(_68(_70,_71)); }); -return _68; -},detect:function(_71){ -var _72; -this.each(function(_73,_74){ -if(_71(_73,_74)){ -_72=_73; +return _69; +},detect:function(_72){ +var _73; +this.each(function(_74,_75){ +if(_72(_74,_75)){ +_73=_74; throw $break; } }); -return _72; -},findAll:function(_75){ -var _76=[]; -this.each(function(_77,_78){ -if(_75(_77,_78)){ -_76.push(_77); +return _73; +},findAll:function(_76){ +var _77=[]; +this.each(function(_78,_79){ +if(_76(_78,_79)){ +_77.push(_78); } }); -return _76; -},grep:function(_79,_80){ -var _81=[]; -this.each(function(_82,_83){ -var _84=_82.toString(); -if(_84.match(_79)){ -_81.push((_80||Prototype.K)(_82,_83)); +return _77; +},grep:function(_80,_81){ +var _82=[]; +this.each(function(_83,_84){ +var _85=_83.toString(); +if(_85.match(_80)){ +_82.push((_81||Prototype.K)(_83,_84)); } }); -return _81; -},include:function(_85){ -var _86=false; -this.each(function(_87){ -if(_87==_85){ -_86=true; +return _82; +},include:function(_86){ +var _87=false; +this.each(function(_88){ +if(_88==_86){ +_87=true; throw $break; } }); -return _86; -},inject:function(_88,_89){ -this.each(function(_90,_91){ -_88=_89(_88,_90,_91); +return _87; +},inject:function(_89,_90){ +this.each(function(_91,_92){ +_89=_90(_89,_91,_92); }); -return _88; -},invoke:function(_92){ -var _93=$A(arguments).slice(1); -return this.collect(function(_94){ -return _94[_92].apply(_94,_93); +return _89; +},invoke:function(_93){ +var _94=$A(arguments).slice(1); +return this.collect(function(_95){ +return _95[_93].apply(_95,_94); }); -},max:function(_95){ -var _96; -this.each(function(_97,_98){ -_97=(_95||Prototype.K)(_97,_98); -if(_97>=(_96||_97)){ -_96=_97; +},max:function(_96){ +var _97; +this.each(function(_98,_99){ +_98=(_96||Prototype.K)(_98,_99); +if(_98>=(_97||_98)){ +_97=_98; } }); -return _96; -},min:function(_99){ -var _100; -this.each(function(_101,_102){ -_101=(_99||Prototype.K)(_101,_102); -if(_101<=(_100||_101)){ -_100=_101; +return _97; +},min:function(_100){ +var _101; +this.each(function(_102,_103){ +_102=(_100||Prototype.K)(_102,_103); +if(_102<=(_101||_102)){ +_101=_102; } }); -return _100; -},partition:function(_103){ -var _104=[],falses=[]; -this.each(function(_105,_106){ -((_103||Prototype.K)(_105,_106)?_104:falses).push(_105); +return _101; +},partition:function(_104){ +var _105=[],falses=[]; +this.each(function(_106,_107){ +((_104||Prototype.K)(_106,_107)?_105:falses).push(_106); }); -return [_104,falses]; -},pluck:function(_107){ -var _108=[]; -this.each(function(_109,_110){ -_108.push(_109[_107]); +return [_105,falses]; +},pluck:function(_108){ +var _109=[]; +this.each(function(_110,_111){ +_109.push(_110[_108]); }); -return _108; -},reject:function(_111){ -var _112=[]; -this.each(function(_113,_114){ -if(!_111(_113,_114)){ -_112.push(_113); +return _109; +},reject:function(_112){ +var _113=[]; +this.each(function(_114,_115){ +if(!_112(_114,_115)){ +_113.push(_114); } }); -return _112; -},sortBy:function(_115){ -return this.collect(function(_116,_117){ -return {value:_116,criteria:_115(_116,_117)}; -}).sort(function(left,_119){ -var a=left.criteria,b=_119.criteria; +return _113; +},sortBy:function(_116){ +return this.collect(function(_117,_118){ +return {value:_117,criteria:_116(_117,_118)}; +}).sort(function(left,_120){ +var a=left.criteria,b=_120.criteria; return ab?1:0; }).pluck("value"); },toArray:function(){ return this.collect(Prototype.K); },zip:function(){ -var _120=Prototype.K,args=$A(arguments); +var _121=Prototype.K,args=$A(arguments); if(typeof args.last()=="function"){ -_120=args.pop(); +_121=args.pop(); } -var _121=[this].concat(args).map($A); -return this.map(function(_122,_123){ -_120(_122=_121.pluck(_123)); -return _122; +var _122=[this].concat(args).map($A); +return this.map(function(_123,_124){ +_121(_123=_122.pluck(_124)); +return _123; }); },inspect:function(){ return "#"; }}; Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray}); -var $A=Array.from=function(_124){ -if(!_124){ +var $A=Array.from=function(_125){ +if(!_125){ return []; } -if(_124.toArray){ -return _124.toArray(); +if(_125.toArray){ +return _125.toArray(); }else{ -var _125=[]; -for(var i=0;i<_124.length;i++){ -_125.push(_124[i]); +var _126=[]; +for(var i=0;i<_125.length;i++){ +_126.push(_125[i]); } -return _125; +return _126; } }; Object.extend(Array.prototype,Enumerable); Array.prototype._reverse=Array.prototype.reverse; -Object.extend(Array.prototype,{_each:function(_126){ +Object.extend(Array.prototype,{_each:function(_127){ for(var i=0;i"; }}; -function $H(_140){ -var hash=Object.extend({},_140||{}); +function $H(_141){ +var hash=Object.extend({},_141||{}); Object.extend(hash,Enumerable); Object.extend(hash,Hash); return hash; } ObjectRange=Class.create(); Object.extend(ObjectRange.prototype,Enumerable); -Object.extend(ObjectRange.prototype,{initialize:function(_141,end,_143){ -this.start=_141; +Object.extend(ObjectRange.prototype,{initialize:function(_142,end,_144){ +this.start=_142; this.end=end; -this.exclusive=_143; -},_each:function(_144){ -var _145=this.start; +this.exclusive=_144; +},_each:function(_145){ +var _146=this.start; do{ -_144(_145); -_145=_145.succ(); -}while(this.include(_145)); -},include:function(_146){ -if(_1460; -})._each(_202); -},set:function(_204){ -this.element.className=_204; -},add:function(_205){ -if(this.include(_205)){ +})._each(_203); +},set:function(_205){ +this.element.className=_205; +},add:function(_206){ +if(this.include(_206)){ return; } -this.set(this.toArray().concat(_205).join(" ")); -},remove:function(_206){ -if(!this.include(_206)){ +this.set(this.toArray().concat(_206).join(" ")); +},remove:function(_207){ +if(!this.include(_207)){ return; } -this.set(this.select(function(_207){ -return _207!=_206; +this.set(this.select(function(_208){ +return _208!=_207; }).join(" ")); },toString:function(){ return this.toArray().join(" "); }}; Object.extend(Element.ClassNames.prototype,Enumerable); -Object.extend(Element,{condClassName:function(_208,_209,cond){ -(cond?Element.addClassName:Element.removeClassName)(_208,_209); +Object.extend(Element,{condClassName:function(_209,_210,cond){ +(cond?Element.addClassName:Element.removeClassName)(_209,_210); }}); var Field={clear:function(){ for(var i=0;i=0){ -opt=_242.options[index]; -_243=opt.value; -if(!_243&&!("value" in opt)){ -_243=opt.text; +opt=_243.options[index]; +_244=opt.value; +if(!_244&&!("value" in opt)){ +_244=opt.text; } } -return [_242.name,_243]; -},selectMany:function(_244){ -var _245=new Array(); -for(var i=0;i<_244.length;i++){ -var opt=_244.options[i]; +return [_243.name,_244]; +},selectMany:function(_245){ +var _246=new Array(); +for(var i=0;i<_245.length;i++){ +var opt=_245.options[i]; if(opt.selected){ -var _247=opt.value; -if(!_247&&!("value" in opt)){ -_247=opt.text; +var _248=opt.value; +if(!_248&&!("value" in opt)){ +_248=opt.text; } -_245.push(_247); +_246.push(_248); } } -return [_244.name,_245]; +return [_245.name,_246]; }}; var $F=Form.Element.getValue; Abstract.TimedObserver=function(){ }; -Abstract.TimedObserver.prototype={initialize:function(_248,_249,_250){ -this.frequency=_249; -this.element=$(_248); -this.callback=_250; +Abstract.TimedObserver.prototype={initialize:function(_249,_250,_251){ +this.frequency=_250; +this.element=$(_249); +this.callback=_251; this.lastValue=this.getValue(); this.registerCallback(); },registerCallback:function(){ setInterval(this.onTimerEvent.bind(this),this.frequency*1000); },onTimerEvent:function(){ -var _251=this.getValue(); -if(this.lastValue!=_251){ -this.callback(this.element,_251); -this.lastValue=_251; +var _252=this.getValue(); +if(this.lastValue!=_252){ +this.callback(this.element,_252); +this.lastValue=_252; } }}; Form.Element.Observer=Class.create(); @@ -990,9 +992,9 @@ return Form.serialize(this.element); }}); Abstract.EventObserver=function(){ }; -Abstract.EventObserver.prototype={initialize:function(_252,_253){ -this.element=$(_252); -this.callback=_253; +Abstract.EventObserver.prototype={initialize:function(_253,_254){ +this.element=$(_253); +this.callback=_254; this.lastValue=this.getValue(); if(this.element.tagName.toLowerCase()=="form"){ this.registerFormCallbacks(); @@ -1000,29 +1002,29 @@ this.registerFormCallbacks(); this.registerCallback(this.element); } },onElementEvent:function(){ -var _254=this.getValue(); -if(this.lastValue!=_254){ -this.callback(this.element,_254); -this.lastValue=_254; +var _255=this.getValue(); +if(this.lastValue!=_255){ +this.callback(this.element,_255); +this.lastValue=_255; } },registerFormCallbacks:function(){ -var _255=Form.getElements(this.element); -for(var i=0;i<_255.length;i++){ -this.registerCallback(_255[i]); +var _256=Form.getElements(this.element); +for(var i=0;i<_256.length;i++){ +this.registerCallback(_256[i]); } -},registerCallback:function(_256){ -if(_256.type){ -switch(_256.type.toLowerCase()){ +},registerCallback:function(_257){ +if(_257.type){ +switch(_257.type.toLowerCase()){ case "checkbox": case "radio": -Event.observe(_256,"click",this.onElementEvent.bind(this)); +Event.observe(_257,"click",this.onElementEvent.bind(this)); break; case "password": case "text": case "textarea": case "select-one": case "select-multiple": -Event.observe(_256,"change",this.onElementEvent.bind(this)); +Event.observe(_257,"change",this.onElementEvent.bind(this)); break; } } @@ -1038,39 +1040,39 @@ return Form.serialize(this.element); if(!window.Event){ var Event=new Object(); } -Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,element:function(_257){ -return _257.target||_257.srcElement; -},isLeftClick:function(_258){ -return (((_258.which)&&(_258.which==1))||((_258.button)&&(_258.button==1))); -},pointerX:function(_259){ -return _259.pageX||(_259.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)); -},pointerY:function(_260){ -return _260.pageY||(_260.clientY+(document.documentElement.scrollTop||document.body.scrollTop)); -},stop:function(_261){ -if(_261.preventDefault){ -_261.preventDefault(); -_261.stopPropagation(); +Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,element:function(_258){ +return _258.target||_258.srcElement; +},isLeftClick:function(_259){ +return (((_259.which)&&(_259.which==1))||((_259.button)&&(_259.button==1))); +},pointerX:function(_260){ +return _260.pageX||(_260.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)); +},pointerY:function(_261){ +return _261.pageY||(_261.clientY+(document.documentElement.scrollTop||document.body.scrollTop)); +},stop:function(_262){ +if(_262.preventDefault){ +_262.preventDefault(); +_262.stopPropagation(); }else{ -_261.returnValue=false; -_261.cancelBubble=true; +_262.returnValue=false; +_262.cancelBubble=true; } -},findElement:function(_262,_263){ -var _264=Event.element(_262); -while(_264.parentNode&&(!_264.tagName||(_264.tagName.toUpperCase()!=_263.toUpperCase()))){ -_264=_264.parentNode; +},findElement:function(_263,_264){ +var _265=Event.element(_263); +while(_265.parentNode&&(!_265.tagName||(_265.tagName.toUpperCase()!=_264.toUpperCase()))){ +_265=_265.parentNode; } -return _264; -},observers:false,_observeAndCache:function(_265,name,_266,_267){ +return _265; +},observers:false,_observeAndCache:function(_266,name,_267,_268){ if(!this.observers){ this.observers=[]; } -if(_265.addEventListener){ -this.observers.push([_265,name,_266,_267]); -_265.addEventListener(name,_266,_267); +if(_266.addEventListener){ +this.observers.push([_266,name,_267,_268]); +_266.addEventListener(name,_267,_268); }else{ -if(_265.attachEvent){ -this.observers.push([_265,name,_266,_267]); -_265.attachEvent("on"+name,_266); +if(_266.attachEvent){ +this.observers.push([_266,name,_267,_268]); +_266.attachEvent("on"+name,_267); } } },unloadCache:function(){ @@ -1082,24 +1084,24 @@ Event.stopObserving.apply(this,Event.observers[i]); Event.observers[i][0]=null; } Event.observers=false; -},observe:function(_268,name,_269,_270){ -var _268=$(_268); -_270=_270||false; -if(name=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||_268.attachEvent)){ +},observe:function(_269,name,_270,_271){ +var _269=$(_269); +_271=_271||false; +if(name=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||_269.attachEvent)){ name="keydown"; } -this._observeAndCache(_268,name,_269,_270); -},stopObserving:function(_271,name,_272,_273){ -var _271=$(_271); -_273=_273||false; -if(name=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||_271.detachEvent)){ +this._observeAndCache(_269,name,_270,_271); +},stopObserving:function(_272,name,_273,_274){ +var _272=$(_272); +_274=_274||false; +if(name=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||_272.detachEvent)){ name="keydown"; } -if(_271.removeEventListener){ -_271.removeEventListener(name,_272,_273); +if(_272.removeEventListener){ +_272.removeEventListener(name,_273,_274); }else{ -if(_271.detachEvent){ -_271.detachEvent("on"+name,_272); +if(_272.detachEvent){ +_272.detachEvent("on"+name,_273); } } }}); @@ -1107,37 +1109,38 @@ Event.observe(window,"unload",Event.unloadCache,false); Object.extend(Event,{OnLoad:function(fn){ var w=document.addEventListener&&!window.addEventListener?document:window; Event.__observe(w,"load",fn); -},observe:function(_276,name,_277,_278){ -if(!isList(_276)){ -return this.__observe(_276,name,_277,_278); +},observe:function(_277,name,_278,_279){ +if(!isList(_277)){ +return this.__observe(_277,name,_278,_279); } -for(var i=0;i<_276.length;i++){ -this.__observe(_276[i],name,_277,_278); +for(var i=0;i<_277.length;i++){ +this.__observe(_277[i],name,_278,_279); } -},__observe:function(_279,name,_280,_281){ -var _279=$(_279); -_281=_281||false; -if(name=="keypress"&&((navigator.appVersion.indexOf("AppleWebKit")>0)||_279.attachEvent)){ +},__observe:function(_280,name,_281,_282){ +var _280=$(_280); +_282=_282||false; +if(name=="keypress"&&((navigator.appVersion.indexOf("AppleWebKit")>0)||_280.attachEvent)){ name="keydown"; } -this._observeAndCache(_279,name,_280,_281); +this._observeAndCache(_280,name,_281,_282); },keyCode:function(e){ return e.keyCode!=null?e.keyCode:e.charCode; },isHTMLEvent:function(type){ -var _284=["abort","blur","change","error","focus","load","reset","resize","scroll","select","submit","unload"]; -return _284.include(type); -},isMouseEvent:function(type){ -var _285=["click","mousedown","mousemove","mouseout","mouseover","mouseup"]; +var _285=["abort","blur","change","error","focus","load","reset","resize","scroll","select","submit","unload"]; return _285.include(type); -},fireEvent:function(_286,type){ +},isMouseEvent:function(type){ +var _286=["click","mousedown","mousemove","mouseout","mouseover","mouseup"]; +return _286.include(type); +},fireEvent:function(_287,type){ +_287=$(_287); if(document.createEvent){ if(Event.isHTMLEvent(type)){ -var _287=document.createEvent("HTMLEvents"); -_287.initEvent(type,true,true); +var _288=document.createEvent("HTMLEvents"); +_288.initEvent(type,true,true); }else{ if(Event.isMouseEvent(type)){ -var _287=document.createEvent("MouseEvents"); -_287.initMouseEvent(type,true,true,document.defaultView,1,0,0,0,0,false,false,false,false,0,null); +var _288=document.createEvent("MouseEvents"); +_288.initMouseEvent(type,true,true,document.defaultView,1,0,0,0,0,false,false,false,false,0,null); }else{ if(Logger){ Logger.error("undefined event",type); @@ -1145,263 +1148,263 @@ Logger.error("undefined event",type); return; } } -_286.dispatchEvent(_287); +_287.dispatchEvent(_288); }else{ -if(_286.fireEvent){ -_286.fireEvent("on"+type); -_286[type](); +if(_287.fireEvent){ +_287.fireEvent("on"+type); +_287[type](); }else{ -_286[type](); +_287[type](); } } }}); var Position={includeScrollOffsets:false,prepare:function(){ this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0; this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0; -},realOffset:function(_288){ -var _289=0,valueL=0; +},realOffset:function(_289){ +var _290=0,valueL=0; do{ -_289+=_288.scrollTop||0; -valueL+=_288.scrollLeft||0; -_288=_288.parentNode; -}while(_288); -return [valueL,_289]; -},cumulativeOffset:function(_290){ -var _291=0,valueL=0; +_290+=_289.scrollTop||0; +valueL+=_289.scrollLeft||0; +_289=_289.parentNode; +}while(_289); +return [valueL,_290]; +},cumulativeOffset:function(_291){ +var _292=0,valueL=0; do{ -_291+=_290.offsetTop||0; -valueL+=_290.offsetLeft||0; -_290=_290.offsetParent; -}while(_290); -return [valueL,_291]; -},positionedOffset:function(_292){ -var _293=0,valueL=0; +_292+=_291.offsetTop||0; +valueL+=_291.offsetLeft||0; +_291=_291.offsetParent; +}while(_291); +return [valueL,_292]; +},positionedOffset:function(_293){ +var _294=0,valueL=0; do{ -_293+=_292.offsetTop||0; -valueL+=_292.offsetLeft||0; -_292=_292.offsetParent; -if(_292){ -p=Element.getStyle(_292,"position"); +_294+=_293.offsetTop||0; +valueL+=_293.offsetLeft||0; +_293=_293.offsetParent; +if(_293){ +p=Element.getStyle(_293,"position"); if(p=="relative"||p=="absolute"){ break; } } -}while(_292); -return [valueL,_293]; -},offsetParent:function(_294){ -if(_294.offsetParent){ -return _294.offsetParent; +}while(_293); +return [valueL,_294]; +},offsetParent:function(_295){ +if(_295.offsetParent){ +return _295.offsetParent; } -if(_294==document.body){ -return _294; +if(_295==document.body){ +return _295; } -while((_294=_294.parentNode)&&_294!=document.body){ -if(Element.getStyle(_294,"position")!="static"){ -return _294; +while((_295=_295.parentNode)&&_295!=document.body){ +if(Element.getStyle(_295,"position")!="static"){ +return _295; } } return document.body; -},within:function(_295,x,y){ +},within:function(_296,x,y){ if(this.includeScrollOffsets){ -return this.withinIncludingScrolloffsets(_295,x,y); +return this.withinIncludingScrolloffsets(_296,x,y); } this.xcomp=x; this.ycomp=y; -this.offset=this.cumulativeOffset(_295); -return (y>=this.offset[1]&&y=this.offset[0]&&x=this.offset[1]&&this.ycomp=this.offset[0]&&this.xcomp=this.offset[1]&&y=this.offset[0]&&x=this.offset[1]&&this.ycomp=this.offset[0]&&this.xcomp"; +_323.innerHTML="<"+_321+">"; } catch(e){ } -var _323=_322.firstChild||null; -if(_323&&(_323.tagName!=_320)){ -_323=_323.getElementsByTagName(_320)[0]; +var _324=_323.firstChild||null; +if(_324&&(_324.tagName!=_321)){ +_324=_324.getElementsByTagName(_321)[0]; } -if(!_323){ -_323=document.createElement(_320); +if(!_324){ +_324=document.createElement(_321); } -if(!_323){ +if(!_324){ return; } if(arguments[1]){ if(this._isStringOrNumber(arguments[1])||(arguments[1] instanceof Array)){ -this._children(_323,arguments[1]); +this._children(_324,arguments[1]); }else{ -var _324=this._attributes(arguments[1]); -if(_324.length){ +var _325=this._attributes(arguments[1]); +if(_325.length){ try{ -_322.innerHTML="<"+_320+" "+_324+">"; +_323.innerHTML="<"+_321+" "+_325+">"; } catch(e){ } -_323=_322.firstChild||null; -if(!_323){ -_323=document.createElement(_320); +_324=_323.firstChild||null; +if(!_324){ +_324=document.createElement(_321); for(attr in arguments[1]){ -_323[attr=="class"?"className":attr]=arguments[1][attr]; +_324[attr=="class"?"className":attr]=arguments[1][attr]; } } -if(_323.tagName!=_320){ -_323=_322.getElementsByTagName(_320)[0]; +if(_324.tagName!=_321){ +_324=_323.getElementsByTagName(_321)[0]; } } } } if(arguments[2]){ -this._children(_323,arguments[2]); +this._children(_324,arguments[2]); } -return _323; +return _324; },_text:function(text){ return document.createTextNode(text); -},_attributes:function(_326){ -var _327=[]; -for(attribute in _326){ -_327.push((attribute=="className"?"class":attribute)+"=\""+_326[attribute].toString().escapeHTML()+"\""); -} -return _327.join(" "); -},_children:function(_328,_329){ -if(typeof _329=="object"){ -_329.flatten().each(function(e){ +},_attributes:function(_327){ +var _328=[]; +for(attribute in _327){ +_328.push((attribute=="className"?"class":attribute)+"=\""+_327[attribute].toString().escapeHTML()+"\""); +} +return _328.join(" "); +},_children:function(_329,_330){ +if(typeof _330=="object"){ +_330.flatten().each(function(e){ if(typeof e=="object"){ -_328.appendChild(e); +_329.appendChild(e); }else{ if(Builder._isStringOrNumber(e)){ -_328.appendChild(Builder._text(e)); +_329.appendChild(Builder._text(e)); } } }); }else{ -if(Builder._isStringOrNumber(_329)){ -_328.appendChild(Builder._text(_329)); +if(Builder._isStringOrNumber(_330)){ +_329.appendChild(Builder._text(_330)); } } -},_isStringOrNumber:function(_330){ -return (typeof _330=="string"||typeof _330=="number"); +},_isStringOrNumber:function(_331){ +return (typeof _331=="string"||typeof _331=="number"); }}; Object.extend(Builder,{exportTags:function(){ var tags=["BUTTON","TT","PRE","H1","H2","H3","BR","CANVAS","HR","LABEL","TEXTAREA","FORM","STRONG","SELECT","OPTION","OPTGROUP","LEGEND","FIELDSET","P","UL","OL","LI","TD","TR","THEAD","TBODY","TFOOT","TABLE","TH","INPUT","SPAN","A","DIV","IMG","CAPTION"]; @@ -1421,7 +1424,7 @@ return Builder.node(tag,args.shift(),args); }); }}); Builder.exportTags(); -Object.extend(Date.prototype,{SimpleFormat:function(_334,data){ +Object.extend(Date.prototype,{SimpleFormat:function(_335,data){ data=data||{}; var bits=new Array(); bits["d"]=this.getDate(); @@ -1434,11 +1437,11 @@ bits["MMM"]=data.AbbreviatedMonthNames[this.getMonth()]; if(data.MonthNames){ bits["MMMM"]=data.MonthNames[this.getMonth()]; } -var _337=""+this.getFullYear(); -_337=(_337.length==2)?"19"+_337:_337; -bits["yyyy"]=_337; +var _338=""+this.getFullYear(); +_338=(_338.length==2)?"19"+_338:_338; +bits["yyyy"]=_338; bits["yy"]=bits["yyyy"].toString().substr(2,2); -var frm=new String(_334); +var frm=new String(_335); for(var sect in bits){ var reg=new RegExp("\\b"+sect+"\\b","g"); frm=frm.replace(reg,bits[sect]); @@ -1450,70 +1453,70 @@ var m=String(this.getMonth()+1).zerofill(2); var d=String(this.getDate()).zerofill(2); return String(y)+String(m)+String(d); }}); -Object.extend(Date,{SimpleParse:function(_341,_342){ -val=String(_341); -_342=String(_342); +Object.extend(Date,{SimpleParse:function(_342,_343){ +val=String(_342); +_343=String(_343); if(val.length<=0){ return null; } -if(_342.length<=0){ -return new Date(_341); +if(_343.length<=0){ +return new Date(_342); } -var _343=function(val){ -var _345="1234567890"; +var _344=function(val){ +var _346="1234567890"; for(var i=0;i=_348;x--){ -var _350=str.substring(i,i+x); -if(_350.length<_348){ +var _347=function(str,i,_349,_350){ +for(var x=_350;x>=_349;x--){ +var _351=str.substring(i,i+x); +if(_351.length<_349){ return null; } -if(_343(_350)){ -return _350; +if(_344(_351)){ +return _351; } } return null; }; -var _351=0; var _352=0; +var _353=0; var c=""; -var _354=""; var _355=""; +var _356=""; var x,y; var now=new Date(); var year=now.getFullYear(); -var _358=now.getMonth()+1; +var _359=now.getMonth()+1; var date=1; -while(_352<_342.length){ -c=_342.charAt(_352); -_354=""; -while((_342.charAt(_352)==c)&&(_352<_342.length)){ -_354+=_342.charAt(_352++); -} -if(_354=="yyyy"||_354=="yy"||_354=="y"){ -if(_354=="yyyy"){ +while(_353<_343.length){ +c=_343.charAt(_353); +_355=""; +while((_343.charAt(_353)==c)&&(_353<_343.length)){ +_355+=_343.charAt(_353++); +} +if(_355=="yyyy"||_355=="yy"||_355=="y"){ +if(_355=="yyyy"){ x=4; y=4; } -if(_354=="yy"){ +if(_355=="yy"){ x=2; y=2; } -if(_354=="y"){ +if(_355=="y"){ x=2; y=4; } -year=_346(val,_351,x,y); +year=_347(val,_352,x,y); if(year==null){ return null; } -_351+=year.length; +_352+=year.length; if(year.length==2){ if(year>70){ year=1900+(year-0); @@ -1522,33 +1525,33 @@ year=2000+(year-0); } } }else{ -if(_354=="MM"||_354=="M"){ -_358=_346(val,_351,_354.length,2); -if(_358==null||(_358<1)||(_358>12)){ +if(_355=="MM"||_355=="M"){ +_359=_347(val,_352,_355.length,2); +if(_359==null||(_359<1)||(_359>12)){ return null; } -_351+=_358.length; +_352+=_359.length; }else{ -if(_354=="dd"||_354=="d"){ -date=_346(val,_351,_354.length,2); +if(_355=="dd"||_355=="d"){ +date=_347(val,_352,_355.length,2); if(date==null||(date<1)||(date>31)){ return null; } -_351+=date.length; +_352+=date.length; }else{ -if(val.substring(_351,_351+_354.length)!=_354){ +if(val.substring(_352,_352+_355.length)!=_355){ return null; }else{ -_351+=_354.length; +_352+=_355.length; } } } } } -if(_351!=val.length){ +if(_352!=val.length){ return null; } -if(_358==2){ +if(_359==2){ if(((year%4==0)&&(year%100!=0))||(year%400==0)){ if(date>29){ return null; @@ -1559,18 +1562,18 @@ return null; } } } -if((_358==4)||(_358==6)||(_358==9)||(_358==11)){ +if((_359==4)||(_359==6)||(_359==9)||(_359==11)){ if(date>30){ return null; } } -var _360=new Date(year,_358-1,date,0,0,0); -return _360; +var _361=new Date(year,_359-1,date,0,0,0); +return _361; }}); var Prado={Version:"3.0a",Browser:function(){ var info={Version:"1.0"}; -var _362=parseInt(navigator.appVersion); -info.nver=_362; +var _363=parseInt(navigator.appVersion); +info.nver=_363; info.ver=navigator.appVersion; info.agent=navigator.userAgent; info.dom=document.getElementById?1:0; @@ -1581,7 +1584,7 @@ info.ie4=(document.all&&!info.dom&&!info.opera)?1:0; info.ie=info.ie4||info.ie5||info.ie6; info.mac=info.agent.indexOf("Mac")>-1; info.ns6=(info.dom&&parseInt(info.ver)>=5)?1:0; -info.ie3=(info.ver.indexOf("MSIE")&&(_362<4)); +info.ie3=(info.ver.indexOf("MSIE")&&(_363<4)); info.hotjava=(info.agent.toLowerCase().indexOf("hotjava")!=-1)?1:0; info.ns4=(document.layers&&!info.dom&&!info.hotjava)?1:0; info.bw=(info.ie6||info.ie5||info.ie4||info.ns4||info.ns6||info.opera); @@ -1589,13 +1592,13 @@ info.ver3=(info.hotjava||info.ie3); info.opera7=((info.agent.toLowerCase().indexOf("opera 7")>-1)||(info.agent.toLowerCase().indexOf("opera/7")>-1)); info.operaOld=info.opera&&!info.opera7; return info; -},ImportCss:function(doc,_364){ +},ImportCss:function(doc,_365){ if(Prado.Browser().ie){ -var _365=doc.createStyleSheet(_364); +var _366=doc.createStyleSheet(_365); }else{ var elm=doc.createElement("link"); elm.rel="stylesheet"; -elm.href=_364; +elm.href=_365; if(headArr=doc.getElementsByTagName("head")){ headArr[0].appendChild(elm); } @@ -1603,50 +1606,50 @@ headArr[0].appendChild(elm); }}; Prado.Focus=Class.create(); Prado.Focus.setFocus=function(id){ -var _368=document.getElementById?document.getElementById(id):document.all[id]; -if(_368&&!Prado.Focus.canFocusOn(_368)){ -_368=Prado.Focus.findTarget(_368); +var _369=document.getElementById?document.getElementById(id):document.all[id]; +if(_369&&!Prado.Focus.canFocusOn(_369)){ +_369=Prado.Focus.findTarget(_369); } -if(_368){ +if(_369){ try{ -_368.focus(); -_368.scrollIntoView(false); +_369.focus(); +_369.scrollIntoView(false); if(window.__smartNav){ -window.__smartNav.ae=_368.id; +window.__smartNav.ae=_369.id; } } catch(e){ } } }; -Prado.Focus.canFocusOn=function(_369){ -if(!_369||!(_369.tagName)){ +Prado.Focus.canFocusOn=function(_370){ +if(!_370||!(_370.tagName)){ return false; } -var _370=_369.tagName.toLowerCase(); -return !_369.disabled&&(!_369.type||_369.type.toLowerCase()!="hidden")&&Prado.Focus.isFocusableTag(_370)&&Prado.Focus.isVisible(_369); +var _371=_370.tagName.toLowerCase(); +return !_370.disabled&&(!_370.type||_370.type.toLowerCase()!="hidden")&&Prado.Focus.isFocusableTag(_371)&&Prado.Focus.isVisible(_370); }; -Prado.Focus.isFocusableTag=function(_371){ -return (_371=="input"||_371=="textarea"||_371=="select"||_371=="button"||_371=="a"); +Prado.Focus.isFocusableTag=function(_372){ +return (_372=="input"||_372=="textarea"||_372=="select"||_372=="button"||_372=="a"); }; -Prado.Focus.findTarget=function(_372){ -if(!_372||!(_372.tagName)){ +Prado.Focus.findTarget=function(_373){ +if(!_373||!(_373.tagName)){ return null; } -var _373=_372.tagName.toLowerCase(); -if(_373=="undefined"){ +var _374=_373.tagName.toLowerCase(); +if(_374=="undefined"){ return null; } -var _374=_372.childNodes; -if(_374){ -for(var i=0;i<_374.length;i++){ +var _375=_373.childNodes; +if(_375){ +for(var i=0;i<_375.length;i++){ try{ -if(Prado.Focus.canFocusOn(_374[i])){ -return _374[i]; +if(Prado.Focus.canFocusOn(_375[i])){ +return _375[i]; }else{ -var _375=Prado.Focus.findTarget(_374[i]); -if(_375){ -return _375; +var _376=Prado.Focus.findTarget(_375[i]); +if(_376){ +return _376; } } } @@ -1656,75 +1659,75 @@ catch(e){ } return null; }; -Prado.Focus.isVisible=function(_376){ -var _377=_376; -while((typeof (_377)!="undefined")&&(_377!=null)){ -if(_377.disabled||(typeof (_377.style)!="undefined"&&((typeof (_377.style.display)!="undefined"&&_377.style.display=="none")||(typeof (_377.style.visibility)!="undefined"&&_377.style.visibility=="hidden")))){ +Prado.Focus.isVisible=function(_377){ +var _378=_377; +while((typeof (_378)!="undefined")&&(_378!=null)){ +if(_378.disabled||(typeof (_378.style)!="undefined"&&((typeof (_378.style.display)!="undefined"&&_378.style.display=="none")||(typeof (_378.style.visibility)!="undefined"&&_378.style.visibility=="hidden")))){ return false; } -if(typeof (_377.parentNode)!="undefined"&&_377.parentNode!=null&&_377.parentNode!=_377&&_377.parentNode.tagName.toLowerCase()!="body"){ -_377=_377.parentNode; +if(typeof (_378.parentNode)!="undefined"&&_378.parentNode!=null&&_378.parentNode!=_378&&_378.parentNode.tagName.toLowerCase()!="body"){ +_378=_378.parentNode; }else{ return true; } } return true; }; -Prado.PostBack=function(_378,_379){ -var form=$(_379["FormID"]); -var _380=true; -if(_379["CausesValidation"]&&Prado.Validation){ -if(_379["ValidationGroup"]){ -Prado.Validation.SetActiveGroup(Event.element(_378),_379["ValidationGroup"]); +Prado.PostBack=function(_379,_380){ +var form=$(_380["FormID"]); +var _381=true; +if(_380["CausesValidation"]&&Prado.Validation){ +if(_380["ValidationGroup"]){ +Prado.Validation.SetActiveGroup(Event.element(_379),_380["ValidationGroup"]); }else{ Prado.Validation.SetActiveGroup(null,null); } if(Prado.Validation.IsValid(form)==false){ -if(_379["StopEvent"]){ -Event.stop(_378); +if(_380["StopEvent"]){ +Event.stop(_379); } return; } } -if(_379["PostBackUrl"]&&_379["PostBackUrl"].length>0){ -form.action=_379["PostBackUrl"]; +if(_380["PostBackUrl"]&&_380["PostBackUrl"].length>0){ +form.action=_380["PostBackUrl"]; } -if(_379["TrackFocus"]){ -var _381=$("PRADO_LASTFOCUS"); -if(_381){ -var _382=document.activeElement; +if(_380["TrackFocus"]){ +var _382=$("PRADO_LASTFOCUS"); if(_382){ -_381.value=_382.id; +var _383=document.activeElement; +if(_383){ +_382.value=_383.id; }else{ -_381.value=_379["EventTarget"]; +_382.value=_380["EventTarget"]; } } } -$("PRADO_POSTBACK_TARGET").value=_379["EventTarget"]; -$("PRADO_POSTBACK_PARAMETER").value=_379["EventParameter"]; +$("PRADO_POSTBACK_TARGET").value=_380["EventTarget"]; +$("PRADO_POSTBACK_PARAMETER").value=_380["EventParameter"]; Event.fireEvent(form,"submit"); -if(_379["StopEvent"]){ -Event.stop(_378); +if(_380["StopEvent"]){ +Event.stop(_379); } }; -Prado.Element={setValue:function(_383,_384){ -var el=$(_383); +Prado.Element={setValue:function(_384,_385){ +var el=$(_384); if(el&&typeof (el.value)!="undefined"){ -el.value=_384; +el.value=_385; } -},select:function(_386,_387,_388){ -var el=$(_386); -var _389=_386.indexOf("[]")>-1; -if(!el&&!_389){ +},select:function(_387,_388,_389){ +var el=$(_387); +var _390=_387.indexOf("[]")>-1; +if(!el&&!_390){ return; } -_387=_389?"check"+_387:el.tagName.toLowerCase()+_387; -var _390=Prado.Element.Selection; -if(isFunction(_390[_387])){ -_390[_387](_389?_386:el,_388); +_388=_390?"check"+_388:el.tagName.toLowerCase()+_388; +var _391=Prado.Element.Selection; +if(isFunction(_391[_388])){ +_391[_388](_390?_387:el,_389); } -},click:function(_391){ -var el=$(_391); +},click:function(_392){ +var el=$(_392); if(!el){ return; } @@ -1740,25 +1743,25 @@ el.onclick(); } } } -},setAttribute:function(_393,_394,_395){ -var el=$(_393); -if(_394=="disabled"&&_395==false){ -el.removeAttribute(_394); +},setAttribute:function(_394,_395,_396){ +var el=$(_394); +if(_395=="disabled"&&_396==false){ +el.removeAttribute(_395); }else{ -el.setAttribute(_394,_395); +el.setAttribute(_395,_396); } -},setOptions:function(_396,_397){ -var el=$(_396); +},setOptions:function(_397,_398){ +var el=$(_397); if(el&&el.tagName.toLowerCase()=="select"){ while(el.length>0){ el.remove(0); } -for(var i=0;i<_397.length;i++){ -el.options[el.options.length]=new Option(_397[i][0],_397[i][1]); +for(var i=0;i<_398.length;i++){ +el.options[el.options.length]=new Option(_398[i][0],_398[i][1]); } } -},focus:function(_398){ -var obj=$(_398); +},focus:function(_399){ +var obj=$(_399); if(isObject(obj)&&isdef(obj.focus)){ setTimeout(function(){ obj.focus(); @@ -1766,22 +1769,22 @@ obj.focus(); } return false; }}; -Prado.Element.Selection={inputValue:function(el,_400){ +Prado.Element.Selection={inputValue:function(el,_401){ switch(el.type.toLowerCase()){ case "checkbox": case "radio": -return el.checked=_400; +return el.checked=_401; } -},selectValue:function(el,_401){ -$A(el.options).each(function(_402){ -_402.selected=_402.value==_401; +},selectValue:function(el,_402){ +$A(el.options).each(function(_403){ +_403.selected=_403.value==_402; }); -},selectIndex:function(el,_403){ +},selectIndex:function(el,_404){ if(el.type=="select-one"){ -el.selectedIndex=_403; +el.selectedIndex=_404; }else{ for(var i=0;i=this.options.total){ -return; +},setRating:function(_447){ +for(var i=0;i<=_447;i++){ +this.radios[i].parentNode.className="rating_selected"; } -var dy=this.options.dy*(pos+1)+this.options.iy; -var dx=_447?this.options.hx+this.options.ix:this.options.ix; -this.element.style.backgroundPosition="-"+dx+"px -"+dy+"px"; -this.options.pos=pos; -this.caption.innerHTML=pos>=0?this.radios[this.options.pos].value:this.options.caption; +this.setCaption(_447); +},setCaption:function(_448){ +this.caption.innerHTML=_448>-1?this.radios[_448].value:this.options.caption; }}; diff --git a/framework/Web/Javascripts/ratings/10star_white.gif b/framework/Web/Javascripts/ratings/10star_white.gif deleted file mode 100644 index 0acdf5c9..00000000 Binary files a/framework/Web/Javascripts/ratings/10star_white.gif and /dev/null differ diff --git a/framework/Web/Javascripts/ratings/blocks.css b/framework/Web/Javascripts/ratings/blocks.css new file mode 100644 index 00000000..2bf2e904 --- /dev/null +++ b/framework/Web/Javascripts/ratings/blocks.css @@ -0,0 +1,29 @@ +.TRatingList_blocks +{ + border-collapse: collapse; +} +.TRatingList_blocks input, .TRatingList_blocks label +{ + display: none; +} +.TRatingList_blocks td +{ + width: 17px; + height: 18px; + background-image: url(blocks_blank.gif); + background-repeat: no-repeat; + cursor: pointer; +} +.TRatingList_blocks td.rating_selected +{ + background-image: url(blocks_selected.gif); +} + +.TRatingList_blocks td.rating_hover +{ + background-image: url(blocks_hover.gif); +} +.TRatingList_blocks td.rating_half +{ + background-image: url(blocks_half.gif); +} diff --git a/framework/Web/Javascripts/ratings/blocks.png b/framework/Web/Javascripts/ratings/blocks.png new file mode 100644 index 00000000..16a2b249 Binary files /dev/null and b/framework/Web/Javascripts/ratings/blocks.png differ diff --git a/framework/Web/Javascripts/ratings/blocks_blank.gif b/framework/Web/Javascripts/ratings/blocks_blank.gif new file mode 100644 index 00000000..a68d0e94 Binary files /dev/null and b/framework/Web/Javascripts/ratings/blocks_blank.gif differ diff --git a/framework/Web/Javascripts/ratings/blocks_half.gif b/framework/Web/Javascripts/ratings/blocks_half.gif new file mode 100644 index 00000000..4cff0148 Binary files /dev/null and b/framework/Web/Javascripts/ratings/blocks_half.gif differ diff --git a/framework/Web/Javascripts/ratings/blocks_hover.gif b/framework/Web/Javascripts/ratings/blocks_hover.gif new file mode 100644 index 00000000..58ad7495 Binary files /dev/null and b/framework/Web/Javascripts/ratings/blocks_hover.gif differ diff --git a/framework/Web/Javascripts/ratings/blocks_selected.gif b/framework/Web/Javascripts/ratings/blocks_selected.gif new file mode 100644 index 00000000..f91873e2 Binary files /dev/null and b/framework/Web/Javascripts/ratings/blocks_selected.gif differ diff --git a/framework/Web/Javascripts/ratings/default.css b/framework/Web/Javascripts/ratings/default.css index 1609ee05..c15a36bd 100644 --- a/framework/Web/Javascripts/ratings/default.css +++ b/framework/Web/Javascripts/ratings/default.css @@ -1,21 +1,29 @@ -.TRatingList_default tr +.TRatingList_default +{ + border-collapse: collapse; +} +.TRatingList_default input, .TRatingList_default label { display: none; } - -.TRatingList_default +.TRatingList_default td { - width: 120px; - height: 20px; - background-image: url(10star_white.gif); - background-position: -0px -4px; + width: 17px; + height: 18px; + background-image: url(default_blank.gif); background-repeat: no-repeat; - margin: 4px; cursor: pointer; } +.TRatingList_default td.rating_selected +{ + background-image: url(default_selected.gif); +} -.TRatingList_default caption +.TRatingList_default td.rating_hover { - padding-left: 4px; - text-align: left; -} \ No newline at end of file + background-image: url(default_hover.gif); +} +.TRatingList_default td.rating_half +{ + background-image: url(default_half.gif); +} diff --git a/framework/Web/Javascripts/ratings/default_blank.gif b/framework/Web/Javascripts/ratings/default_blank.gif new file mode 100644 index 00000000..4e6fda3c Binary files /dev/null and b/framework/Web/Javascripts/ratings/default_blank.gif differ diff --git a/framework/Web/Javascripts/ratings/default_half.gif b/framework/Web/Javascripts/ratings/default_half.gif new file mode 100644 index 00000000..7cecf0ec Binary files /dev/null and b/framework/Web/Javascripts/ratings/default_half.gif differ diff --git a/framework/Web/Javascripts/ratings/default_hover.gif b/framework/Web/Javascripts/ratings/default_hover.gif new file mode 100644 index 00000000..ad0cd28a Binary files /dev/null and b/framework/Web/Javascripts/ratings/default_hover.gif differ diff --git a/framework/Web/Javascripts/ratings/default_selected.gif b/framework/Web/Javascripts/ratings/default_selected.gif new file mode 100644 index 00000000..a19ab39f Binary files /dev/null and b/framework/Web/Javascripts/ratings/default_selected.gif differ diff --git a/framework/Web/Javascripts/ratings/ratings.js b/framework/Web/Javascripts/ratings/ratings.js index c5efc372..e6fd97ba 100644 --- a/framework/Web/Javascripts/ratings/ratings.js +++ b/framework/Web/Javascripts/ratings/ratings.js @@ -8,63 +8,53 @@ Prado.WebUI.TRatingList.prototype = this.options = options; this.element = $(options['ID']); Element.addClassName(this.element,options.cssClass); - var width = options.total * options.dx; - this.element.style.width = width+"px"; - Event.observe(this.element, 'mouseover', this.hover.bindEvent(this)); - Event.observe(this.element, 'mouseout', this.recover.bindEvent(this)); - Event.observe(this.element, 'click', this.click.bindEvent(this)); - this._onMouseMoveEvent = this.mousemoved.bindEvent(this); - this.selectedIndex = options.pos; this.radios = document.getElementsByName(options.field); + for(var i = 0; i= this.options.total) return; - var dy = this.options.dy * (pos+1) + this.options.iy; - var dx = hovering ? this.options.hx + this.options.ix : this.options.ix; - this.element.style.backgroundPosition = "-"+dx+"px -"+dy+"px"; - this.options.pos = pos; - this.caption.innerHTML = pos >= 0 ? - this.radios[this.options.pos].value : this.options.caption; + this.caption.innerHTML = index > -1 ? + this.radios[index].value : this.options.caption; } } \ No newline at end of file diff --git a/framework/Web/Javascripts/ratings/stars1.png b/framework/Web/Javascripts/ratings/stars1.png new file mode 100644 index 00000000..e4dd3c25 Binary files /dev/null and b/framework/Web/Javascripts/ratings/stars1.png differ diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index f563e36e..8d4de13e 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -274,10 +274,26 @@ class TDatePicker extends TTextBox public function render($writer) { if($this->getInputMode() == 'TextBox') + { parent::render($writer); + $this->renderDatePickerButtons($writer); + } else + { $this->renderDropDownListCalendar($writer); - + if($this->hasDayPattern()) + { + $this->registerCalendarClientScript(); + $this->renderDatePickerButtons($writer); + } + } + } + + /** + * Renders the date picker popup buttons. + */ + protected function renderDatePickerButtons($writer) + { if($this->getShowCalendar()) { switch ($this->getMode()) @@ -317,12 +333,26 @@ class TDatePicker extends TTextBox */ protected function getDateFromPostData($key, $values) { - $day = $values[$key.'$day']; - $month = $values[$key.'$month']; - $year = $values[$key.'$year']; - $date = @mktime(0, 0, 0, $month+1, $day, $year); - $formatter = Prado::createComponent('System.Data.TSimpleDateFormatter', - $this->getDateFormat()); + $date = @getdate(); + + if(isset($values[$key.'$day'])) + $day = intval($values[$key.'$day']); + else + $day = 1; + + if(isset($values[$key.'$month'])) + $month = intval($values[$key.'$month']) + 1; + else + $month = $date['mon']; + + if(isset($values[$key.'$year'])) + $year = intval($values[$key.'$year']); + else + $year = $date['year']; + $date = @mktime(0, 0, 0, $month, $day, $year); + $pattern = $this->getDateFormat(); + $pattern = str_replace(array('MMMM', 'MMM'), array('MM','MM'), $pattern); + $formatter = Prado::createComponent('System.Data.TSimpleDateFormatter', $pattern); return $formatter->format($date); } @@ -369,7 +399,8 @@ class TDatePicker extends TTextBox protected function getCurrentCulture() { $app = $this->getApplication()->getGlobalization(); - return $this->getCulture() == '' ? $app->getCulture() : $this->getCulture(); + return $this->getCulture() == '' ? + ($app ? $app->getCulture() : 'en') : $this->getCulture(); } /** @@ -401,21 +432,43 @@ class TDatePicker extends TTextBox $writer->renderBeginTag('span'); $date = $this->getDateFromText(); - - //renders the 3 drop down lists - $this->renderCalendarDayOptions($writer,$date['mday']); - $this->renderCalendarMonthOptions($writer,$date['mon']-1); - $this->renderCalendarYearOptions($writer,$date['year']); - + $this->renderCalendarSelections($writer, $date); + //render a hidden input field $writer->addAttribute('name', $this->getUniqueID()); $writer->addAttribute('type', 'hidden'); $writer->addAttribute('value', $this->getText()); $writer->renderBeginTag('input'); - - $this->registerCalendarClientScript(); + $writer->renderEndTag(); } + + protected function hasDayPattern() + { + $formatter = Prado::createComponent('System.Data.TSimpleDateFormatter', + $this->getDateFormat()); + return !is_null($formatter->getDayPattern()); + } + + /** + * Renders the calendar drop down list depending on the DateFormat pattern. + * @param THtmlWriter the Html writer to render the drop down lists. + * @param array the current selected date + */ + protected function renderCalendarSelections($writer, $date) + { + $formatter = Prado::createComponent('System.Data.TSimpleDateFormatter', + $this->getDateFormat()); + foreach($formatter->getDayMonthYearOrdering() as $type) + { + if($type == 'day') + $this->renderCalendarDayOptions($writer,$date['mday']); + elseif($type == 'month') + $this->renderCalendarMonthOptions($writer,$date['mon']-1); + elseif($type == 'year') + $this->renderCalendarYearOptions($writer,$date['year']); + } + } /** * Gets the date from the text input using TSimpleDateFormatter @@ -423,8 +476,9 @@ class TDatePicker extends TTextBox */ protected function getDateFromText() { - $formatter = Prado::createComponent('System.Data.TSimpleDateFormatter', - $this->getDateFormat()); + $pattern = $this->getDateFormat(); + $pattern = str_replace(array('MMMM', 'MMM'), array('MM','MM'), $pattern); + $formatter = Prado::createComponent('System.Data.TSimpleDateFormatter',$pattern); return $formatter->parse($this->getText()); } @@ -476,10 +530,32 @@ class TDatePicker extends TTextBox $writer->addAttribute('class', 'datepicker_month_options'); $writer->renderBeginTag('select'); $this->renderDropDownListOptions($writer, - $info->getMonthNames(), $selected); + $this->getLocalizedMonthNames($info), $selected); $writer->renderEndTag(); } + /** + * Returns the localized month names that depends on the month format pattern. + * "MMMM" will return the month names, "MM" or "MMM" return abbr. month names + * and "M" return month digits. + * @param DateTimeFormatInfo localized date format information. + * @return array localized month names. + */ + protected function getLocalizedMonthNames($info) + { + $formatter = Prado::createComponent('System.Data.TSimpleDateFormatter', + $this->getDateFormat()); + switch($formatter->getMonthPattern()) + { + case 'MMM': + case 'MM': return $info->getAbbreviatedMonthNames(); + case 'M': + $array = array(); for($i=1;$i<=12;$i++) $array[$i] = $i; + return $array; + default : return $info->getMonthNames(); + } + } + /** * Renders the year drop down list options. * @param THtmlWriter the writer used for the rendering purpose diff --git a/framework/Web/UI/WebControls/TRatingList.php b/framework/Web/UI/WebControls/TRatingList.php index 006391f7..b2861f2b 100644 --- a/framework/Web/UI/WebControls/TRatingList.php +++ b/framework/Web/UI/WebControls/TRatingList.php @@ -12,6 +12,7 @@ Prado::using('System.Web.UI.WebControls.TRadioButtonList'); */ class TRatingList extends TRadioButtonList { + private $_ratingImages = array(); public function __construct() { @@ -19,12 +20,30 @@ class TRatingList extends TRadioButtonList $this->getRepeatInfo()->setRepeatDirection('Horizontal'); } - /** - * @param string the direction (Vertical, Horizontal) of traversing the list - */ - public function setRepeatDirection($value) + public function getAllowInput() + { + return $this->getViewState('AllowInput', true); + } + + public function setAllowInput($value) + { + $this->setViewState('AllowInput', TPropertyValue::ensureBoolean($value), true); + } + + public function getRating() + { + if($this->getAllowInput()) + return $this->getSelectedIndex(); + else + return $this->getViewState('Rating',0); + } + + public function setRating($value) { - throw new TNotSupportedException('ratinglits_repeatdirection_unsupported'); + if($this->getAllowInput()) + $this->setSelectedIndex($value); + else + return $this->setViewState('Rating', TPropertyValue::ensureFloat($value),0); } /** @@ -40,19 +59,13 @@ class TRatingList extends TRadioButtonList */ public function getRatingStyle() { - $style = $this->getViewState('RatingStyle', 'default'); - return is_string($style) ? $this->createRatingStyle($style) : $style; - } - - protected function createRatingStyle($type) - { - return new TRatingListDefaultStyle; + return $this->getViewState('RatingStyle', 'default'); } /** * @return string caption text. Default is "Rate It:". */ - public function getCaptionText() + public function getCaption() { return $this->getViewState('Caption', 'Rate It:'); } @@ -60,40 +73,60 @@ class TRatingList extends TRadioButtonList /** * @param string caption text */ - public function setCaptionText($value) + public function setCaption($value) { $this->setViewState('Caption', $value, 'Rate It:'); } + + public function setHalfRatingLimit($value) + { + $this->setViewState('HalfRating', + TPropertyValue::ensureArray($value), array(0.3, 0.7)); + } + + public function getHalfRatingLimit() + { + return $this->getViewState('HalfRating', array(0.3, 0.7)); + } + public function getRatingClientOptions() { - $options = $this->getRatingStyle()->getOptions(); + $options['cssClass'] = 'TRatingList_'.$this->getRatingStyle(); $options['ID'] = $this->getClientID(); - $options['caption'] = $this->getCaptionText(); + $options['caption'] = $this->getCaption(); $options['field'] = $this->getUniqueID(); - $options['total'] = $this->getItems()->getCount(); - $options['pos'] = $this->getSelectedIndex(); + $options['selectedIndex'] = $this->getSelectedIndex(); return $options; } - protected function publishRatingListStyle() + protected function publishRatingListStyle($style) { $cs = $this->getPage()->getClientScript(); - $style = $this->getRatingStyle()->getStyleSheet(); - $url = $this->publishFilePath($style); + $stylesheet = 'System.Web.Javascripts.ratings.'.$style; + if(($cssFile=Prado::getPathOfNamespace($stylesheet,'.css'))===null) + throw new TConfigurationException('ratinglist_stylesheet_not_found',$style); + $url = $this->publishFilePath($cssFile); if(!$cs->isStyleSheetFileRegistered($style)) $cs->registerStyleSheetFile($style, $url); return $url; } - protected function publishRatingListAssets() + protected function publishRatingListImages($style, $fileExt='.gif') { $cs = $this->getPage()->getClientScript(); - $assets = $this->getRatingStyle()->getAssets(); - $list = array(); - foreach($assets as $file) - $list[] = $this->publishFilePath($file); - return $list; + $images['blank'] = "System.Web.Javascripts.ratings.{$style}_blank"; + $images['hover'] = "System.Web.Javascripts.ratings.{$style}_hover"; + $images['selected'] = "System.Web.Javascripts.ratings.{$style}_selected"; + $images['half'] = "System.Web.Javascripts.ratings.{$style}_half"; + $files = array(); + foreach($images as $type => $image) + { + if(($file=Prado::getPathOfNamespace($image, $fileExt))===null) + throw TConfigurationException('ratinglist_image_not_found',$image); + $files[$type] = $this->publishFilePath($file); + } + return $files; } /** @@ -102,8 +135,21 @@ class TRatingList extends TRadioButtonList public function onPreRender($param) { parent::onPreRender($param); - $this->publishRatingListStyle(); - $this->publishRatingListAssets(); + + $this->publishRatingListStyle($this->getRatingStyle()); + $this->_ratingImages = $this->publishRatingListImages($this->getRatingStyle()); + + if($this->getAllowInput()) + $this->registerRatingListClientScript(); + else + { + $this->getRepeatInfo()->setCaption($this->getCaption()); + $this->setAttribute('title', $this->getRating()); + } + } + + protected function registerRatingListClientScript() + { $id = $this->getClientID(); $scripts = $this->getPage()->getClientScript(); $scripts->registerPradoScript('prado'); @@ -111,65 +157,38 @@ class TRatingList extends TRadioButtonList $code = "new Prado.WebUI.TRatingList($options);"; $scripts->registerEndScript("prado:$id", $code); } -} -abstract class TRatingListStyle -{ - private $_options = array(); - - public function __construct() + public function renderItem($writer,$repeatInfo,$itemType,$index) { - $options['pos'] = -1; - $options['dx'] = 22; - $options['dy'] = 30; - $options['ix'] = 4; - $options['iy'] = 4; - $options['hx'] = 240; - $options['total'] = -1; - $this->_options = $options; + if($this->getAllowInput()) + parent::renderItem($writer, $repeatInfo, $itemType, $index); + else + $this->renderRatingListItem($writer, $repeatInfo, $itemType, $index); } - public function getOptions() + protected function renderRatingListItem($writer, $repeatInfo, $itemType, $index) { - return $this->_options; - } - - public function setOptions($options) - { - $this->_options = $options; - } - - abstract function getStyleSheet(); - - abstract function getAssets(); -} - -class TRatingListDefaultStyle extends TRatingListStyle -{ - public function __construct() - { - parent::__construct(); - $options = $this->getOptions(); - $options['cssClass'] = 'TRatingList_default'; - $this->setOptions($options); + $image = new TImage; + $image->setImageUrl($this->_ratingImages[$this->getRatingImageType($index)]); + $image->setAlternateText($this->getRating()); + $image->render($writer); } - public function getStyleSheet() + protected function getRatingImageType($index) { - $style = 'System.Web.Javascripts.ratings.default'; - if(($cssFile=Prado::getPathOfNamespace($style,'.css'))===null) - throw new TConfigurationException('ratinglist_stylesheet_invalid',$style); - return $cssFile; + $rating = floatval($this->getRating()); + $int = intval($rating); + $limit = $this->getHalfRatingLimit(); + if($index < $int || ($rating < $index + 1 && $rating > $index +$limit[1])) + return 'selected'; + if($rating >= $index+$limit[0] && $rating <= $index+$limit[1]) + return 'half'; + return 'blank'; } - public function getAssets() + public function generateItemStyle($itemType,$index) { - $assets = array(); - $image = 'System.Web.Javascripts.ratings.10star_white'; - if(($file=Prado::getPathOfNamespace($image, '.gif'))===null) - throw TConfigurationException('ratinglist_asset_invalid',$image); - $assets[] = $file; - return $assets; + return new TStyle; } } -- cgit v1.2.3