JUI is a collection of wrappers which encapsulate the functionality of various jQuery UI widgets.
Working widgets are: datepicker, slider, dialog, tabs, progress bar and accordion
The jQuery UI version used is 1.7.1, which work with jQuery 1.3, which is included with Yii since 1.0.2.
This extension obsoletes both juidatepicker and juislider. Notice that the javascript APIs might have changed (specially the slider) in jquery ui 1.7.x.
Please use the forum if you want to post support requests, problems and so on. Don't use the comments section for those things.
If you'll be using just basic things (like an ocassional datepicker in some form), yes, Yii 1.1 incorporates some jQuery UI widgets. But this extension goes beyond that, even providing a framework for other jQuery based extensions.
protected/extensionsSee the following code examples:
$this->widget('application.extensions.jui.EJqueryUiInclude', array('theme'=>'humanity'));
$this->widget('application.extensions.jui.EDatePicker', array( 'name'=>'cp', 'language'=>'es', 'mode'=>'imagebutton', 'theme'=>'dotluv', 'value'=>date('Y-m-d'), 'options'=>array('beforeShowDay'=>'$.datepicker.noWeekends'), 'htmlOptions'=>array('size'=>10) ) ); $this->widget('application.extensions.jui.EDatePicker', array( 'name'=>'dp', 'language'=>'es', 'mode'=>'button', 'theme'=>'cupertino', 'value'=>date('Y-m-d'), 'htmlOptions'=>array('size'=>10) ) );
echo CHtml::textField('x1'); <br /> <? echo CHtml::textField('x2'); <br /> <? echo CHtml::textField('x3'); <br /> <? $this->widget('application.extensions.jui.ESlider', array( 'name'=>'slider', 'theme'=>'cupertino', 'enabled'=>true, 'minValue'=>-10.0, 'maxValue'=>10.0, 'value'=>array(-10.0,0.0,10.0), 'linkedElements'=>array('x1','x2','x3'), 'numberOfHandlers'=>3, 'range'=>false, 'htmlOptions'=>array('style'=>'width:200px;height:10px;') ) ); <table> <tr> <td> <? echo CHtml::textfield('x4'); </td> <td> <? $this->widget('application.extensions.jui.ESlider', array( 'name'=>'slider1', 'theme'=>'dotluv', 'enabled'=>true, 'minValue'=>-20.0, 'maxValue'=>20.0, 'value'=>10.0, 'linkedElements'=>array('x4'), 'htmlOptions'=>array('style'=>'width:250px;height:10px;') ) ); </td> </tr> </table>
$this->beginWidget('application.extensions.jui.EDialog', array('name'=>'dialogo', 'theme'=>'base', 'compression'=>'packed', 'htmlOptions'=>array('title'=>'Hello dialog'))); <p>Hello world</p> <? $this->endWidget('application.extensions.jui.EDialog'); <? $this->beginWidget('application.extensions.jui.EDialog', array( 'name' => 'myDialog', 'theme' => 'base', 'htmlOptions'=>array('title'=>'Hello dialog'), 'options' => array( 'autoOpen'=>true, 'show'=>'scale', ), 'buttons' => array( "Ok" => 'function(){$(this).dialog("close");}', "Cancel" => 'function(){alert("cancel");}' ) ) ); <p>Farawell, World :(</p> <? $this->endWidget('application.extensions.jui.EDialog'); ?>
"Classic" mode:
$this->widget('application.extensions.jui.EAccordion', array( 'name'=>'accordion', 'theme'=>'redmond', 'panels'=>array( 'Panel 1'=>'Panel 1 Content', 'Panel 2'=>'<p>Panel 2 Content<ul><li>list item 1</li><li>list item 2</li></ul></p>', 'Panel 3'=>'<b>Panel 3 Content</b>', 'Panel 4'=>'<i>Panel 4 Content</i>', ), 'options'=>array( 'active'=>false, 'autoHeight'=>false, 'alwaysOpen'=>false /* 'icons'=>array("header"=>"ui-icon-plus", "headerSelected"=>"ui-icon-minus") */ ) ) );
"Panel" mode:
$this->beginWidget('application.extensions.jui.EAccordion', array( 'name'=>'accordion2', 'useEasing'=>true, 'options'=>array( 'active'=>false, 'autoHeight'=>false, 'alwaysOpen'=>false, ) ) ); <?php $this->beginWidget('application.extensions.jui.EAccordionPanel', array('name'=>'p1', 'title'=>'Panel 1')); <p> Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate. </p> <?php $this->endWidget('application.extensions.jui.EAccordionPanel'); <?php $this->beginWidget('application.extensions.jui.EAccordionPanel', array('name'=>'p2', 'title'=>'Panel 2')); <p> Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna. </p> <?php $this->endWidget('application.extensions.jui.EAccordionPanel'); <?php $this->beginWidget('application.extensions.jui.EAccordionPanel', array('name'=>'p3', 'title'=>'Panel 3')); <p> Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. </p> <ul> <li>List item one</li> <li>List item two</li> <li>List item three</li> </ul> <?php $this->endWidget('application.extensions.jui.EAccordionPanel'); <?php $this->endWidget('application.extensions.jui.EAccordion');
Normal mode:
$this->beginWidget('application.extensions.jui.ETabs', array('name'=>'tabpanel1')); <?php $this->beginWidget('application.extensions.jui.ETab', array('name'=>'tab1', 'title'=>'Tab 1')); <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p> <?php $this->endWidget('application.extensions.jui.ETab'); <?php $this->beginWidget('application.extensions.jui.ETab', array('name'=>'tab2', 'title'=>'Tab 2')); <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p> <?php $this->endWidget('application.extensions.jui.ETab'); <?php $this->beginWidget('application.extensions.jui.ETab', array('name'=>'tab3', 'title'=>'Tab 3')); <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p> <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p> <?php $this->endWidget('application.extensions.jui.ETab'); <?php $this->endWidget('application.extensions.jui.ETabs');
Ajax mode:
$this->widget('application.extensions.jui.ETabs', array( 'name'=>'tabpanel2', 'ajaxTabs'=>array( array('title'=>'Hangman', 'url'=>'http://localhost/yii-svn/demos/hangman'), array('title'=>'Hello World', 'url'=>'http://localhost/yii-svn/demos/helloworld'), array('title'=>'Blog', 'url'=>'http://localhost/yii-svn/demos/blog'), ) ) );
$this->widget('application.extensions.jui.EProgressBar', array( 'name' => 'myProgressBar', 'theme' => 'redmond', 'callbacks' => array( 'change' => 'function(event, ui) { var value = $("#myProgressBar").progressbar("option", "value"); (value >= 100) ? $("#progressBarLabel").text(value+" % complete.") : $("#progressBarLabel").text(value+" %"); }', ), ) ); echo CHtml::button('Start process', array( 'id' => 'startButton', 'class' => 'ui-state-default ui-corner-all', 'style' => 'margin:10px 0px 0px 0px;padding:5px;', ) ); $buttonScript = '$("#startButton").click( function() { $(this).attr("disabled", "true").addClass("ui-state-disabled").blur(); var progress = 0, thread = setInterval( function() { progress += 1; $("#myProgressBar").progressbar("option", "value", progress); if(progress >= 100) clearInterval(thread); }, 100); } ); $("#startButton").hover( function() { $(this).addClass("ui-state-hover"); }, function() { $(this).removeClass("ui-state-hover"); } ); '; Yii::app()->clientScript->registerScript('button', $buttonScript, CClientScript::POS_READY);
Because they both share the jQuery UI library, and the themes from the theme roller. They also share common code on the PHP side.
Because with the default CSS files created by theme roller it is not possible to change this behavior, and making a generic extension with the changes suggested by the jQuery UI developers to provide different themes for each widget is not possible. If you need to apply a different theme to each widget, you need to modify the CSS files to include a selector and extend the extension class to apply this new CSS and the class selector to the widget... and you'll end up with an inconsistent interface :)
Because the widgets might share common code, the file is not so big when minified, and you can use caching and gzip on the server side, and the number of HTTP connections is reduced. You can extend the extension class to change this behavior.
Please report the bug to the jQuery/jQuery UI teams. They should fix the problem better and faster, and then make a general release with the fix included, which I'd include in future versions of the extension. I don't intend to make a fork of jQuery UI, but use the official releases.
No, I don't work on that project. I'm not an expert in jQuery either, I'm just another user. So, I might not be able to answer your questions related to jQuery or jQuery UI. Sorry about that.
Total 15 comments
there is a shit bug, which took a lot of my time and energy. Thebug is so: When you use the ActiveForm with ajax validation, and at the same time when you use any element from jui of this package, it brokes the ajax validation, exactly not brokes, but make hidden the error messages which come from the controller, they comes and are pasted to the page, but error div is hidden, the reason of this is THE EXTENDED TOGGLE FUNCTION which is in the jquery-ui-1.7.1.custom.min.js file. the body of this function is so: toggle:function(){if(!arguments[0]||(arguments[0].constructor==Number||(/(slow|normal|fast)/).test(arguments[0]))||(arguments[0].constructor==Function)){return this.__toggle.apply(this,arguments)}else{return this.effect.apply(this,c(arguments,"toggle"))}} I think it is a populated problem, even in the google, stackoverflow, there are so problems, but without a solution. I cant find the solving in the internet. I think you must figure out the reason. Thanks.
If you use the new version... than you don't need this extension... but... there are still many users that use older version of Yii... so this extension can be useful to them...
Is there any reason to use this now that we can use CJuiWidget since Yii 1.1?
Just used the datePicker, thanks for saving me time!
Picker is rendered very small, but I guess I'll just generate a new stylesheet on the jQuery site.
I'm not very good at javascript,but with this tool , I can do my job better than before!
thank for share!
It has a variable "fontSize" that you can add to datepicker init code
<?php$this->widget('application.extensions.jui.EDatePicker',
array(
/* ... */
'fontSize'=>'0.8em',
/* ... */
?>
I'm using default yii user interface, but when I add a datepicker, his size is a half of normal. It's very small. How can I easily resolve this ploblem?
in EDatePicker.php on 512 you need to check minDate and maxDate separatly, because it can be used separatly:
if (is_string($this->maxDate) && $this->maxDate !== '') { $options['maxDate'] = "'" . $this->maxDate . "'"; } if (is_string($this->minDate) && $this->minDate !== '') { $options['minDate'] = "'" . $this->minDate . "'"; }Nice work I want to avoid typing date on datepicker even for integer, how to change it, it already avoids alphabets and accepts date in dd-mm-yyyy format, give idea Thank you
Wonderful! Thanks!
Hi, thanks for all your reviews. For reporting bugs, please use this thread on the forum system:
Very, very, very nice.
Thanx
Extension helps me to create the feature i want to do. Help me to make my work easy. I like it.
Leave a comment
Please login to leave your comment.