From 9e2820e98640f4ca262db7279a514826341df3e0 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 8 Oct 2006 05:11:23 +0000 Subject: Fixed #414, #411, #415 --- framework/Web/Javascripts/js/compressed/ajax.js | 48 +++++--- framework/Web/Javascripts/js/debug/ajax.js | 121 +++++++++++++++++---- framework/Web/Javascripts/prado/inlineeditor.js | 36 +++++- framework/Web/Javascripts/ratings/blocks.css | 12 +- framework/Web/Javascripts/ratings/blocks.png | Bin 27953 -> 28700 bytes .../Web/Javascripts/ratings/blocks_combined.gif | Bin 237 -> 289 bytes framework/Web/Javascripts/ratings/default.css | 10 ++ framework/Web/Javascripts/ratings/default.png | Bin 52075 -> 51492 bytes .../Web/Javascripts/ratings/default_combined.gif | Bin 1001 -> 1201 bytes framework/Web/Javascripts/ratings/ratings.js | 85 ++++++++++++--- 10 files changed, 255 insertions(+), 57 deletions(-) (limited to 'framework/Web/Javascripts') diff --git a/framework/Web/Javascripts/js/compressed/ajax.js b/framework/Web/Javascripts/js/compressed/ajax.js index 696968c7..16dacb52 100644 --- a/framework/Web/Javascripts/js/compressed/ajax.js +++ b/framework/Web/Javascripts/js/compressed/ajax.js @@ -262,12 +262,13 @@ this.time=setTimeout(this.checkChanges.bind(this),parseInt(this.options.Interval {var request=new Prado.CallbackRequest(this.options.EventTarget,this.options);var param={'OldValue':oldValue,'NewValue':newValue};request.setCallbackParameter(param);request.dispatch();}},{timers:{},register:function(timer) {Prado.WebUI.TValueTriggeredCallback.timers[timer.options.ID]=timer;},stop:function(id) {Prado.WebUI.TValueTriggeredCallback.timers[id].stopObserving();}});Prado.WebUI.TInPlaceTextBox=Base.extend({isSaving:false,isEditing:false,editField:null,constructor:function(options) -{this.options=Object.extend({LoadTextFromSource:false,TextMode:'SingleLine'},options||{});this.element=$(this.options.ID);this.initializeListeners();},initializeListeners:function() +{this.options=Object.extend({LoadTextFromSource:false,TextMode:'SingleLine'},options||{});this.element=$(this.options.ID);Prado.WebUI.TInPlaceTextBox.register(this);this.initializeListeners();},initializeListeners:function() {this.onclickListener=this.enterEditMode.bindAsEventListener(this);Event.observe(this.element,'click',this.onclickListener);if(this.options.ExternalControl) Event.observe($(this.options.ExternalControl),'click',this.onclickListener);},enterEditMode:function(evt) -{if(this.isSaving)return;if(this.isEditing)return;this.isEditing=true;this.onEnterEditMode();this.createEditorInput();this.showTextBox();this.editField.disabled=false;if(this.options.LoadTextOnEdit) +{if(this.isSaving||this.isEditing)return;this.isEditing=true;this.onEnterEditMode();this.createEditorInput();this.showTextBox();this.editField.disabled=false;if(this.options.LoadTextOnEdit) this.loadExternalText();Prado.Element.focus(this.editField);if(evt) -Event.stop(evt);return false;},showTextBox:function() +Event.stop(evt);return false;},exitEditMode:function(evt) +{this.isEditing=false;this.isSaving=false;this.editField.disabled=false;this.element.innerHTML=this.editField.value;this.showLabel();},showTextBox:function() {Element.hide(this.element);Element.show(this.editField);},showLabel:function() {Element.show(this.element);Element.hide(this.editField);},createEditorInput:function() {if(this.editField==null) @@ -302,28 +303,39 @@ this.showLabel();}},onTextChanged:function(text) {this.isSaving=false;this.isEditing=false;this.showLabel();},onTextChangedSuccess:function(sender,parameter) {this.isSaving=false;this.isEditing=false;if(this.options.AutoHide) this.showLabel();this.element.innerHTML=parameter==null?this.editField.value:parameter;this.editField.disabled=false;},onTextChangedFailure:function(sender,parameter) -{this.editField.disabled=false;this.isSaving=false;this.isEditing=false;}});Prado.WebUI.TRatingList=Base.extend({selectedIndex:-1,enabled:true,readOnly:false,constructor:function(options) -{var cap=$(options.CaptionID);this.options=Object.extend({caption:cap?cap.innerHTML:''},options||{});Prado.WebUI.TRatingList.register(this);this._init();this.selectedIndex=options.SelectedIndex;this.setRating(this.selectedIndex);},_init:function(options) +{this.editField.disabled=false;this.isSaving=false;this.isEditing=false;}},{textboxes:{},register:function(obj) +{Prado.WebUI.TInPlaceTextBox.textboxes[obj.options.TextBoxID]=obj;},setDisplayTextBox:function(id,value) +{var textbox=Prado.WebUI.TInPlaceTextBox.textboxes[id];if(textbox) +{if(value) +textbox.enterEditMode(null);else +{textbox.exitEditMode(null);}}}});Prado.WebUI.TRatingList=Base.extend({selectedIndex:-1,rating:-1,enabled:true,readOnly:false,constructor:function(options) +{var cap=$(options.CaptionID);this.options=Object.extend({caption:cap?cap.innerHTML:''},options||{});Prado.WebUI.TRatingList.register(this);this._init();this.selectedIndex=options.SelectedIndex;this.rating=options.Rating;if(options.Rating<=0&&options.SelectedIndex>=0) +this.rating=options.SelectedIndex+1;this.showRating(this.rating);},_init:function(options) {Element.addClassName($(this.options.ListID),this.options.Style);this.radios=new Array();var index=0;for(var i=0;iindex?'removeClassName':'addClassName' -Element[action](this.radios[i].parentNode,"rating_selected");} -this.setCaption(index);},setCaption:function(index) -{var value=index>-1?this.radios[index].value:this.options.caption;var caption=$(this.options.CaptionID);if(caption)caption.innerHTML=value;$(this.options.ListID).title=value;},setEnabled:function(value) +this.radios[i].checked=(i==index);this.selectedIndex=index;this.setRating(index+1);this.dispatchRequest(ev);},dispatchRequest:function(ev) +{var requestOptions=Object.extend({ID:this.options.ListID+"_c"+this.selectedIndex,EventTarget:this.options.ListName+"$c"+this.selectedIndex},this.options);var request=new Prado.CallbackRequest(requestOptions.EventTarget,requestOptions);if(request.dispatch()==false) +Event.stop(ev);},setRating:function(value) +{this.rating=value;var base=Math.floor(value-1);var remainder=value-base-1;var halfMax=this.options.HalfRating["1"];var index=remainder>halfMax?base+1:base;for(var i=0;ihalfMax?base+1:base;var hasHalf=remainder>=halfMin&&remainder<=halfMax;for(var i=0;iindex?'removeClassName':'addClassName';Element[action](node,"rating_selected");if(i==index+1&&hasHalf) +Element.addClassName(node,"rating_half");else +Element.removeClassName(node,"rating_half");Element.removeClassName(node,"rating_hover");}},getIndexCaption:function(index) +{return index>-1?this.radios[index].value:this.options.caption;},showCaption:function(value) +{var caption=$(this.options.CaptionID);if(caption)caption.innerHTML=value;$(this.options.ListID).title=value;},setCaption:function(value) +{this.options.caption=value;this.showCaption(value);},setEnabled:function(value) {this.enabled=value;for(var i=0;i= 0) + this.rating = options.SelectedIndex+1; + this.showRating(this.rating); }, _init: function(options) @@ -2656,18 +2690,20 @@ Prado.WebUI.TRatingList = Base.extend( if(this.enabled==false) return; for(var i = 0; i halfMax ? base+1 : base; + for(var i = 0; i halfMax ? base+1 : base; + var hasHalf = remainder >= halfMin && remainder <= halfMax; for(var i = 0; i index ? 'removeClassName' : 'addClassName' - Element[action](this.radios[i].parentNode, "rating_selected"); + var action = i > index ? 'removeClassName' : 'addClassName'; + Element[action](node, "rating_selected"); + if(i==index+1 && hasHalf) + Element.addClassName(node, "rating_half"); + else + Element.removeClassName(node, "rating_half"); + Element.removeClassName(node,"rating_hover"); } - this.setCaption(index); }, - setCaption : function(index) + getIndexCaption : function(index) + { + return index > -1 ? this.radios[index].value : this.options.caption; + }, + + showCaption : function(value) { - var value = index > -1 ? this.radios[index].value : this.options.caption; var caption = $(this.options.CaptionID); if(caption) caption.innerHTML = value; $(this.options.ListID).title = value; }, + setCaption : function(value) + { + this.options.caption = value; + this.showCaption(value); + }, + setEnabled : function(value) { this.enabled = value; @@ -2732,7 +2811,11 @@ setEnabled : function(id,value) setRating : function(id,value) { Prado.WebUI.TRatingList.ratings[id].setRating(value); - Prado.WebUI.TRatingList.ratings[id].selectedIndex = value; +}, + +setCaption : function(id,value) +{ + Prado.WebUI.TRatingList.ratings[id].setCaption(value); } }); diff --git a/framework/Web/Javascripts/prado/inlineeditor.js b/framework/Web/Javascripts/prado/inlineeditor.js index 14f4b73c..719c525d 100644 --- a/framework/Web/Javascripts/prado/inlineeditor.js +++ b/framework/Web/Javascripts/prado/inlineeditor.js @@ -13,7 +13,7 @@ Prado.WebUI.TInPlaceTextBox = Base.extend( }, options || {}); this.element = $(this.options.ID); - + Prado.WebUI.TInPlaceTextBox.register(this); this.initializeListeners(); }, @@ -34,8 +34,7 @@ Prado.WebUI.TInPlaceTextBox = Base.extend( */ enterEditMode : function(evt) { - if (this.isSaving) return; - if (this.isEditing) return; + if (this.isSaving || this.isEditing) return; this.isEditing = true; this.onEnterEditMode(); this.createEditorInput(); @@ -49,6 +48,15 @@ Prado.WebUI.TInPlaceTextBox = Base.extend( return false; }, + exitEditMode : function(evt) + { + this.isEditing = false; + this.isSaving = false; + this.editField.disabled = false; + this.element.innerHTML = this.editField.value; + this.showLabel(); + }, + showTextBox : function() { Element.hide(this.element); @@ -225,4 +233,26 @@ Prado.WebUI.TInPlaceTextBox = Base.extend( this.isSaving = false; this.isEditing = false; } +}, +{ + textboxes : {}, + + register : function(obj) + { + Prado.WebUI.TInPlaceTextBox.textboxes[obj.options.TextBoxID] = obj; + }, + + setDisplayTextBox : function(id,value) + { + var textbox = Prado.WebUI.TInPlaceTextBox.textboxes[id]; + if(textbox) + { + if(value) + textbox.enterEditMode(null); + else + { + textbox.exitEditMode(null); + } + } + } }); \ No newline at end of file diff --git a/framework/Web/Javascripts/ratings/blocks.css b/framework/Web/Javascripts/ratings/blocks.css index 5d13a859..b05d9eb6 100644 --- a/framework/Web/Javascripts/ratings/blocks.css +++ b/framework/Web/Javascripts/ratings/blocks.css @@ -26,7 +26,17 @@ background-position: 1px -100px; } +.TRatingList_blocks td.rating_half +{ + background-position: 1px -200px; +} + +.TRatingList_blocks td.rating_hover +{ + background-position: 1px -300px; +} + .TRatingList_blocks td.rating_disabled { cursor: default !important; -} \ No newline at end of file +} diff --git a/framework/Web/Javascripts/ratings/blocks.png b/framework/Web/Javascripts/ratings/blocks.png index 0da75b19..93a5333e 100644 Binary files a/framework/Web/Javascripts/ratings/blocks.png and b/framework/Web/Javascripts/ratings/blocks.png differ diff --git a/framework/Web/Javascripts/ratings/blocks_combined.gif b/framework/Web/Javascripts/ratings/blocks_combined.gif index 04e8f7b8..dfe9da8d 100644 Binary files a/framework/Web/Javascripts/ratings/blocks_combined.gif and b/framework/Web/Javascripts/ratings/blocks_combined.gif differ diff --git a/framework/Web/Javascripts/ratings/default.css b/framework/Web/Javascripts/ratings/default.css index aa7913bf..d404f843 100644 --- a/framework/Web/Javascripts/ratings/default.css +++ b/framework/Web/Javascripts/ratings/default.css @@ -27,6 +27,16 @@ background-position: 0px -100px; } +.TRatingList_default td.rating_half +{ + background-position: 0px -200px; +} + +.TRatingList_default td.rating_hover +{ + background-position: 0px -300px; +} + .TRatingList_default td.rating_disabled { cursor: default !important; diff --git a/framework/Web/Javascripts/ratings/default.png b/framework/Web/Javascripts/ratings/default.png index 17bc39a1..a3148ff4 100644 Binary files a/framework/Web/Javascripts/ratings/default.png and b/framework/Web/Javascripts/ratings/default.png differ diff --git a/framework/Web/Javascripts/ratings/default_combined.gif b/framework/Web/Javascripts/ratings/default_combined.gif index fe02b446..ddab2e8b 100644 Binary files a/framework/Web/Javascripts/ratings/default_combined.gif and b/framework/Web/Javascripts/ratings/default_combined.gif differ diff --git a/framework/Web/Javascripts/ratings/ratings.js b/framework/Web/Javascripts/ratings/ratings.js index 9299d8d8..c8b19511 100644 --- a/framework/Web/Javascripts/ratings/ratings.js +++ b/framework/Web/Javascripts/ratings/ratings.js @@ -1,6 +1,7 @@ Prado.WebUI.TRatingList = Base.extend( { selectedIndex : -1, + rating: -1, enabled : true, readOnly : false, @@ -15,7 +16,10 @@ Prado.WebUI.TRatingList = Base.extend( Prado.WebUI.TRatingList.register(this); this._init(); this.selectedIndex = options.SelectedIndex; - this.setRating(this.selectedIndex); + this.rating = options.Rating; + if(options.Rating <= 0 && options.SelectedIndex >= 0) + this.rating = options.SelectedIndex+1; + this.showRating(this.rating); }, _init: function(options) @@ -44,18 +48,20 @@ Prado.WebUI.TRatingList = Base.extend( if(this.enabled==false) return; for(var i = 0; i halfMax ? base+1 : base; + for(var i = 0; i halfMax ? base+1 : base; + var hasHalf = remainder >= halfMin && remainder <= halfMax; for(var i = 0; i index ? 'removeClassName' : 'addClassName' - Element[action](this.radios[i].parentNode, "rating_selected"); + var action = i > index ? 'removeClassName' : 'addClassName'; + Element[action](node, "rating_selected"); + if(i==index+1 && hasHalf) + Element.addClassName(node, "rating_half"); + else + Element.removeClassName(node, "rating_half"); + Element.removeClassName(node,"rating_hover"); } - this.setCaption(index); }, - setCaption : function(index) + getIndexCaption : function(index) + { + return index > -1 ? this.radios[index].value : this.options.caption; + }, + + showCaption : function(value) { - var value = index > -1 ? this.radios[index].value : this.options.caption; var caption = $(this.options.CaptionID); if(caption) caption.innerHTML = value; $(this.options.ListID).title = value; }, + setCaption : function(value) + { + this.options.caption = value; + this.showCaption(value); + }, + setEnabled : function(value) { this.enabled = value; @@ -120,6 +169,10 @@ setEnabled : function(id,value) setRating : function(id,value) { Prado.WebUI.TRatingList.ratings[id].setRating(value); - Prado.WebUI.TRatingList.ratings[id].selectedIndex = value; +}, + +setCaption : function(id,value) +{ + Prado.WebUI.TRatingList.ratings[id].setCaption(value); } }); \ No newline at end of file -- cgit v1.2.3