From 21c565b3ca9de9cc4cfc3fb2e847cc0330921c48 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 16 Oct 2013 18:04:37 +0200 Subject: jquery port --- .../pages/Controls/Samples/TClientSideValidator/Home.page | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'demos/quickstart/protected/pages') diff --git a/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page index 06ed6295..f7d03ea2 100755 --- a/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page @@ -1,6 +1,11 @@

Conditional Validation (client-side + server side)

+ +.required { + background-color: #E77471; +} + -
@@ -22,7 +27,7 @@ Check "optional" to validate both textboxes ErrorMessage="*" ControlCssClass="required"> - sender.enabled = $('<%= $this->check1->ClientID %>').checked; + sender.enabled = jQuery('#<%= $this->check1->ClientID %>').get(0).checked; -- cgit v1.2.3 From 36f481b48d9777963d063e227a10882d318dc8d8 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 3 Nov 2013 19:32:08 +0100 Subject: Fixed TActivePager's demo --- .../pages/ActiveControls/Samples/TActivePager/Home.page | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'demos/quickstart/protected/pages') diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page index e38486d1..79a4f540 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page @@ -15,10 +15,10 @@ Go to page: OnCallBack="RenderCallback" > - Element.show('wait') + jQuery('#wait').show() - Element.hide('wait') + jQuery('#wait').hide() @@ -77,11 +77,11 @@ Total <%# $this->Parent->PageCount %> pages. OnPageIndexChanged="pageChanged" OnCallBack="RenderCallback" > - - Element.show('wait') + + jQuery('#wait').show() - Element.hide('wait') + jQuery('#wait').hide()
@@ -92,11 +92,11 @@ Choose page: OnPageIndexChanged="pageChanged" OnCallBack="RenderCallback" > - - Element.show('wait') + + jQuery('#wait').show() - Element.hide('wait') + jQuery('#wait').hide() -- cgit v1.2.3 From 44844e9dfc4bfdac7ef33e941a09a1597fc50a32 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 3 Nov 2013 19:57:22 +0100 Subject: Ported TCallback + demo --- .../protected/pages/ActiveControls/Samples/TCallback/Home.page | 2 +- framework/Web/UI/ActiveControls/TBaseActiveControl.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'demos/quickstart/protected/pages') diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallback/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallback/Home.page index 04781438..6be81e96 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallback/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallback/Home.page @@ -39,7 +39,7 @@ The third parameter is taken from the textbox; { var request = <%= $this->callback2->ActiveControl->Javascript %>; var param2 = 'value 2'; - var param3 = $('<%= $this->txt1->ClientID %>').value; + var param3 = $('#<%= $this->txt1->ClientID %>').val(); request.setCallbackParameter({'Param1':param1, 'Param2':param2, 'Param3':param3}); request.dispatch(); } diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php index 61230719..f4daec02 100644 --- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php +++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php @@ -332,6 +332,9 @@ class TBaseActiveCallbackControl extends TBaseActiveControl $options['CausesValidation']= $validate ? '' : false; $options['ValidationGroup']=$this->getValidationGroup(); $options['CallbackParameter'] = $this->getCallbackParameter(); + // needed for TCallback + if(!isset($options['EventTarget'])) + $options['EventTarget'] = $this->getControl()->getUniqueID(); return $options; } -- cgit v1.2.3 From 6f515b1ff6f82cef83aa03330e343ce3363419e4 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 21 Nov 2013 17:18:23 +0100 Subject: Ported TSlider --- .../pages/Controls/Samples/TSlider/Home.page | 8 +- framework/Web/Javascripts/packages.php | 2 +- .../Javascripts/source/prado/controls/slider.js | 106 ++++++++++----------- framework/Web/UI/WebControls/TSlider.php | 2 +- 4 files changed, 58 insertions(+), 60 deletions(-) (limited to 'demos/quickstart/protected/pages') diff --git a/demos/quickstart/protected/pages/Controls/Samples/TSlider/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TSlider/Home.page index bfbbe8e3..6c79fae4 100755 --- a/demos/quickstart/protected/pages/Controls/Samples/TSlider/Home.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TSlider/Home.page @@ -16,7 +16,7 @@ Horizontal slider from -50 to 50, Javascript 'onSlide' handler, ServerSide 'onS
- $('slider2value').innerHTML = value; + $('#slider2value').get(0).innerHTML = value; Value : <%=$this->slider2->value%> @@ -28,14 +28,14 @@ Vertical slider from 0 to 1, Javascript 'onSlide' handler, ServerSide 'onSliderC - $('slider3value').innerHTML = value; + $('#slider3value').get(0).innerHTML = value; Value : <%=$this->slider3->value%> -
+ +
\ No newline at end of file diff --git a/framework/Web/Javascripts/packages.php b/framework/Web/Javascripts/packages.php index bebb9394..bc3bae1e 100644 --- a/framework/Web/Javascripts/packages.php +++ b/framework/Web/Javascripts/packages.php @@ -121,9 +121,9 @@ $dependencies = array( 'htmlarea' => array('jquery', 'prado', 'htmlarea'), 'htmlarea4' => array('jquery', 'prado', 'htmlarea4'), 'keyboard' => array('jquery', 'prado', 'keyboard'), + 'slider' => array('jquery', 'prado', 'slider'), /* 'dragdrop' => array('prototype', 'prado', 'effects', 'ajax', 'dragdrop'), - 'slider' => array('prototype', 'prado', 'slider'), 'dragdropextra' => array('prototype', 'prado', 'effects', 'ajax', 'dragdrop','dragdropextra'), 'accordion' => array('prototype', 'prado', 'effects', 'accordion'), 'ratings' => array('prototype', 'prado', 'effects', 'ajax', 'ratings'), diff --git a/framework/Web/Javascripts/source/prado/controls/slider.js b/framework/Web/Javascripts/source/prado/controls/slider.js index 2e26ee51..28d7d4ac 100644 --- a/framework/Web/Javascripts/source/prado/controls/slider.js +++ b/framework/Web/Javascripts/source/prado/controls/slider.js @@ -3,21 +3,21 @@ * This clas is mainly based on Scriptaculous Slider control (http://script.aculo.us) */ -Prado.WebUI.TSlider = Class.extend(Prado.WebUI.PostBackControl, +Prado.WebUI.TSlider = jQuery.klass(Prado.WebUI.PostBackControl, { onInit : function (options) { var slider = this; this.options=options || {}; - this.track = $(options.ID+'_track'); - this.handle =$(options.ID+'_handle'); - this.progress = $(options.ID+'_progress'); + this.track = $('#'+options.ID+'_track').get(0); + this.handle =$('#'+options.ID+'_handle').get(0); + this.progress = $('#'+options.ID+'_progress').get(0); this.axis = this.options.axis || 'horizontal'; - this.range = this.options.range || $R(0,1); + this.range = this.options.range || [0, 1]; this.value = 0; - this.maximum = this.options.maximum || this.range.end; - this.minimum = this.options.minimum || this.range.start; - this.hiddenField=$(this.options.ID+'_1'); + this.maximum = this.options.maximum || this.range[1]; + this.minimum = this.options.minimum || this.range[0]; + this.hiddenField=$('#'+this.options.ID+'_1').get(0); // Will be used to align the handle onto the track, if necessary this.alignX = parseInt(this.options.alignX || - this.track.offsetLeft); @@ -37,19 +37,18 @@ Prado.WebUI.TSlider = Class.extend(Prado.WebUI.PostBackControl, if(this.options.disabled) this.setDisabled(); // Allowed values array - this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false; + this.allowedValues = this.options.values ? this.options.values.sort() : false; if(this.allowedValues) { - this.minimum = this.allowedValues.min(); - this.maximum = this.allowedValues.max(); + this.minimum = Math.min.apply( Math, this.allowedValues ); + this.maximum = Math.max.apply( Math, this.allowedValues ); } - this.eventMouseDown = this.startDrag.bindAsEventListener(this); - this.eventMouseUp = this.endDrag.bindAsEventListener(this); - this.eventMouseMove = this.update.bindAsEventListener(this); + this.eventMouseDown = this.startDrag.bind(this); + this.eventMouseUp = this.endDrag.bind(this); + this.eventMouseMove = this.update.bind(this); // Initialize handle this.setValue(parseFloat(slider.options.sliderValue)); - Element.makePositioned(this.handle); // fix IE this.observe (this.handle, "mousedown", this.eventMouseDown); this.observe (this.track, "mousedown", this.eventMouseDown); @@ -60,10 +59,13 @@ Prado.WebUI.TSlider = Class.extend(Prado.WebUI.PostBackControl, this.initialized=true; - if(this.options['AutoPostBack']==true) - this.observe(this.hiddenField, "change", Prado.PostBack.bindEvent(this,options)); - + this.observe(this.hiddenField, "change", jQuery.proxy(this.doPostback,this,options)); + }, + + doPostback : function(options, event) + { + new Prado.PostBack(options, event); }, setDisabled: function(){ @@ -74,12 +76,14 @@ Prado.WebUI.TSlider = Class.extend(Prado.WebUI.PostBackControl, }, getNearestValue: function(value){ if(this.allowedValues){ - if(value >= this.allowedValues.max()) return(this.allowedValues.max()); - if(value <= this.allowedValues.min()) return(this.allowedValues.min()); + var max = Math.max.apply( Math, this.allowedValues ); + var min = Math.min.apply( Math, this.allowedValues ); + if(value >= max) return(max); + if(value <= min) return(min); var offset = Math.abs(this.allowedValues[0] - value); var newValue = this.allowedValues[0]; - this.allowedValues.each( function(v) { + jQuery.each(this.allowedValues, function(idx, v) { var currentOffset = Math.abs(v - value); if(currentOffset <= offset){ newValue = v; @@ -88,8 +92,8 @@ Prado.WebUI.TSlider = Class.extend(Prado.WebUI.PostBackControl, }); return newValue; } - if(value > this.range.end) return this.range.end; - if(value < this.range.start) return this.range.start; + if(value > this.range[1]) return this.range[1]; + if(value < this.range[0]) return this.range[0]; return value; }, @@ -113,19 +117,13 @@ Prado.WebUI.TSlider = Class.extend(Prado.WebUI.PostBackControl, translateToPx: function(value) { return Math.round( - ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) * (value - this.range.start)) + "px"; + ((this.trackLength-this.handleLength)/(this.range[1]-this.range[0])) * (value - this.range[0])) + "px"; }, translateToValue: function(offset) { - return ((offset/(this.trackLength-this.handleLength) * (this.range.end-this.range.start)) + this.range.start); + return ((offset/(this.trackLength-this.handleLength) * (this.range[1]-this.range[0])) + this.range[0]); }, - - getRange: function(range) { - var v = this.values.sortBy(Prototype.K); - range = range || 0; - return $R(v[range],v[range+1]); - }, - + minimumOffset: function(){ return(this.isVertical() ? this.alignY : this.alignX); }, @@ -144,35 +142,36 @@ Prado.WebUI.TSlider = Class.extend(Prado.WebUI.PostBackControl, updateStyles: function() { if (this.active) - Element.addClassName(this.handle, 'selected'); + jQuery(this.handle).addClass('selected'); else - Element.removeClassName(this.handle, 'selected'); + jQuery(this.handle).removeClass('selected'); }, startDrag: function(event) { - if(Event.isLeftClick(event)) { + if (event.which === 1) { + // left click if(!this.disabled){ this.active = true; - var handle = Event.element(event); - var pointer = [Event.pointerX(event), Event.pointerY(event)]; + var handle = event.target; + var pointer = [event.pageX, event.pageY]; var track = handle; if(track==this.track) { - var offsets = this.track.cumulativeOffset(); + var offsets = jQuery(this.track).offset(); this.event = event; this.setValue(this.translateToValue( - (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2) + (this.isVertical() ? pointer[1]-offsets['top'] : pointer[0]-offsets['left'])-(this.handleLength/2) )); - var offsets = this.handle.cumulativeOffset(); - this.offsetX = (pointer[0] - offsets[0]); - this.offsetY = (pointer[1] - offsets[1]); + var offsets = jQuery(this.handle).offset(); + this.offsetX = (pointer[0] - offsets['left']); + this.offsetY = (pointer[1] - offsets['top']); } else { this.updateStyles(); - var offsets = this.handle.cumulativeOffset(); - this.offsetX = (pointer[0] - offsets[0]); - this.offsetY = (pointer[1] - offsets[1]); + var offsets = jQuery(this.handle).offset(); + this.offsetX = (pointer[0] - offsets['left']); + this.offsetY = (pointer[1] - offsets['top']); } } - Event.stop(event); + event.stopPropagation(); } }, @@ -180,16 +179,15 @@ Prado.WebUI.TSlider = Class.extend(Prado.WebUI.PostBackControl, if(this.active) { if(!this.dragging) this.dragging = true; this.draw(event); - if(Prototype.Browser.WebKit) window.scrollBy(0,0); - Event.stop(event); + event.stopPropagation(); } }, draw: function(event) { - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - var offsets = this.track.cumulativeOffset(); - pointer[0] -= this.offsetX + offsets[0]; - pointer[1] -= this.offsetY + offsets[1]; + var pointer = [event.pageX, event.pageY]; + var offsets = jQuery(this.track).offset(); + pointer[0] -= this.offsetX + offsets['left']; + pointer[1] -= this.offsetY + offsets['top']; this.event = event; this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] )); if(this.initialized && this.options.onSlide) @@ -199,7 +197,7 @@ Prado.WebUI.TSlider = Class.extend(Prado.WebUI.PostBackControl, endDrag: function(event) { if(this.active && this.dragging) { this.finishDrag(event, true); - Event.stop(event); + event.stopPropagation(); } this.active = false; this.dragging = false; @@ -219,7 +217,7 @@ Prado.WebUI.TSlider = Class.extend(Prado.WebUI.PostBackControl, this.event = null; if (this.options['AutoPostBack']==true) { - Event.fireEvent(this.hiddenField,"change"); + jQuery(this.hiddenField).trigger("change"); } } diff --git a/framework/Web/UI/WebControls/TSlider.php b/framework/Web/UI/WebControls/TSlider.php index dcf34bfc..a07c995f 100644 --- a/framework/Web/UI/WebControls/TSlider.php +++ b/framework/Web/UI/WebControls/TSlider.php @@ -457,7 +457,7 @@ class TSlider extends TWebControl implements IPostBackDataHandler, IDataRenderer $options['axis'] = strtolower($this->getDirection()); $options['maximum'] = $maxValue; $options['minimum'] = $minValue; - $options['range'] = TJavascript::quoteJsLiteral('$R('.$minValue.",".$maxValue.")"); + $options['range'] = array($minValue, $maxValue); $options['sliderValue'] = $this->getValue(); $options['disabled'] = !$this->getEnabled(); $values=$this->getValues(); -- cgit v1.2.3