[EXTENSION] Bootstrap

Hi Chris,

could I suggest to add a bool property to TbAlert class that controls the rendering of close button [x] of an alert box?

Hey gdesmedt1,

The quickest fix is to add ‘htmlOptions’=>array(‘class’=>‘slide’) to the widget config, and it should fix the issue. In the upcoming version you won’t need to do this anymore.

That sounds like a good idea. Any particular reason why you want this?

Edit: I accidentally ended up rewriting the whole alert widget because it didn’t really support any configuration at all. Now it’s great. :)

Sure!

stupid example: user clicks on a link and you want to show "please login" in an alert.

on that page you can user Yii::app()->user->setFlash and then TbAlert with an hide class to initially hide the alert box, instead "rebuild" an alert using divs with alert-* classes

Then you can show alert by javascript. If you click (x) to close alert, it will be destroyed forever. In some cases it could be useful that an alert stays on page.

@Chris83

First thanks for the great work I just used the 0.9.x version on a recent project and it ended up wonderfully.

3 questions:

  • Do you plan to integrate widgets with TbActiveForm? for example to be able to use TbButtonGroup as TbActiveForm’s radioButtonRow?

  • Do you plan to integrate this extension to the popular Giix?

  • Is there any way to extend bootstrap’s Gii template, so I can make modification of the template to suit my need without changing the extension’s source code?

Me again

I have finally uploaded the complete redesign of my moms site using yii, user, rights, this awesome TBootstrap and blog… and all working well, excepting 2 issues:

1.) I viewed the site on my mobile phone (Samsung galaxy S1) and all worked well, excepting that I pressed on the menu button and nothing happened, I could not get the menu to slide down… therefore one cannot go anywhere but the home page! (is this a phone issue, or a bootstrap responsive theme issue? (i did have javascript enabled on my phones browser)

2.) When screen in tablet size or smaller… I can’t seem to find the css code that i need to change in order to change the menu colours, and it’s not looking good!

And here’s the site that’s just been uploaded Learn and Play Junior Academy (my mom’s creche in East London in South Africa)

@chris, thanks for that slide help… it’s working great, as you’ll see in above site :)

Hi chris, nice work but on BootGridView and BootListView




                $afterAjaxUpdate = "js:function() {

                        jQuery('.popover').remove();

                        jQuery('{$popover}').popover();

                        jQuery('.tooltip').remove();

                        jQuery('{$tooltip}').tooltip();

                }";


                if (isset($this->afterAjaxUpdate))

                        $this->afterAjaxUpdate .= ' '.$afterAjaxUpdate;

                else

                        $this->afterAjaxUpdate = $afterAjaxUpdate;



this code is wrong because I can’t add any javascript in the afterAjaxUpdate property.

Here is a fix:




		if (isset($this->afterAjaxUpdate) && strpos($this->afterAjaxUpdate, 'js:') !== false) {

			$patterns = array('/^js:\s*function\s*\(\s*\w*\s*,*\s*\w*\s*\)\s*\{/', '/\}\s*;*\s*$/');

			$this->afterAjaxUpdate = preg_replace($patterns, array('',''), $this->afterAjaxUpdate);

		}

		$afterAjaxUpdate = "js:function() {

			jQuery('.popover').remove();

			jQuery('{$popover}').popover();

			jQuery('.tooltip').remove();

			jQuery('{$tooltip}').tooltip();

			{$this->afterAjaxUpdate}

		}";


		$this->afterAjaxUpdate = $afterAjaxUpdate;



And you can’t use CJavaScriptExpression that was added in the latest version.

Hey lightglitch,

The afterAjaxUpdate issue in grid view has already been fixed a while ago.

Ok, I was looking a old version but even in the new one if I use it like:




$this->widget('ext.bootstrap.widgets.TbGridView', array(

	'id' => 'user-grid',

	'type' => 'striped',

	'ajaxUpdate' => 'user-grid,alerts-box',

	'dataProvider' => $model->search(),

	'filter' => $model,

	'afterAjaxUpdate' =>'js:function (id, data) {setTimeout(function () { $(".alert.alert-success [data-dismiss=\"alert\"]").trigger("click");}, 1500);};',

	'columns' => $columns

));



it doesn’t add the tooltips and popovers refresh. My patch does.

Here is optimization to refresh only the grid ones:





                if (isset($this->afterAjaxUpdate) && strpos($this->afterAjaxUpdate, 'js:') !== false) {

                        $patterns = array('/^js:\s*function\s*\(\s*\w*\s*,*\s*\w*\s*\)\s*\{/', '/\}\s*;*\s*$/');

                        $this->afterAjaxUpdate = preg_replace($patterns, array('',''), $this->afterAjaxUpdate);

                }

                $afterAjaxUpdate = "js:function(id, data) {

                        jQuery('#'+ id +'.popover').remove();

                        jQuery('#'+ id +'{$popover}').popover();

                        jQuery('#'+ id +'.tooltip').remove();

                        jQuery('#'+ id +'{$tooltip}').tooltip();

                        {$this->afterAjaxUpdate}

                }";


                $this->afterAjaxUpdate = $afterAjaxUpdate;



I understand what you’re trying to achieve but I wouldn’t go this far. I’d rather keep the logic simple and leave rebinding of plugins up to the developer if they override the afterAjaxUpdate property. Simplicity and usability (for developers) are two key focuses in this extension in order to make it easy for anyone to use.

Hey digitalwingx,

You’re welcome and as I’ve said many times I have really enjoyed working on this project.

To answer your questions quickly:

  1. Maybe (depends on how useful it would - provide me with some use-cases and I’ll consider it)

  2. Probably not (if someone wants to do this feel free to do so)

  3. It should possible to import the class and extend it like any other class (remember to add your generator to gii’s generatorPaths or it won’t find it)

Ok here is an example, see in the first screenshot the form is plain and simple tbform result.

If you look at the 2nd screenshot, the dropdown list and radio button are replaced with widgets (BootButtonGroup in this case).

They function the same but it definitely brings in the bootstrap’s nice look more to the generated form.

More integration could be done for example use modal instead of plain alert on the "Delete" icon click event of admin pages.

Everybody knows and is used to the look of traditional radio buttons and check boxes. It’s not just a matter of design but of user-friendliness. Who’s the target audience? Do they need fancy or what they are used to?

Besides, the distinction between checked and unchecked radios is much higher than the difference between the 2 states (up/down) of a ButtonGroup element.

I must say that I somewhat agree with Don here. I would say that this is a "nice to have" feature (maybe - need to think a bit more about this). However, this got me thinking about using button groups in e.g. grids for actions. I think it could be a nice feature.

@Makro Did you try out the new alert widget in the latest alpha release. If so, please let me know if you like it or not.

I think whether the traditional radio button is more user-friendly vesus buttongroup is arguable: buttongroup brings more colours to the form elements which helps the elements to stand out more. Look at Button Dropdowns for example, I could trigger colour change based on option selected (e.g. look at my screenshot, a (newly) Created job status can be blue, if it’s “Closed” the colour can be green). Some people responde much better to colour than reading the text. And personally I also think the looks fit better on mobile phone.

To me it seems obvious the Twitter’s bootstrap provide very good user-friendliness but it doesn’t stop there, it also brings the “fanciness” to be visually pleasing. Whether it fits my target audience, should be developers and their client’s decision, but the option is there in Twitter’s bootstrap.

And like Chris83 mentioned using buttongroup for action in grids. My point is there is a lot more potential in further integrate bootstrap’s elements to the interface.

Just wanted to provide food for thought.

It clearly is a subjective matter. Especially when it comes to changing basic elements and the use of colors. Of course, I wouldn’t mind having the additional option to use ButtonGroups in TbActiveForm and TbGridView. Maybe one day it’ll come in handy.

Hi! A newbie here… and got stuck already…

I would like to ask if I’d be able to put a sort of login-form as one of navbar’s dropdown items.

In the example/documentation, there is a search form (string-type item). I’ve tried ‘similar’ trick, but it wasn’t even rendered in the html output.




$this->widget('bootstrap.widgets.TbNavbar', array(

    'type'=>null, 

    'brand'=>'HUBris',

    'brandUrl'=>'#',

    'collapse'=>true, // requires bootstrap-responsive.css

    'items'=>array(

        array(

            'class'=>'bootstrap.widgets.TbMenu',

            'items'=>array(

                array('label'=>'Home', 'url'=>'#', 'active'=>true),

                array('label'=>'Link', 'url'=>'#'),

                array('label'=>'Dropdown', 'url'=>'#', 'items'=>array(

                    array('label'=>'Action', 'url'=>'#'),

                    array('label'=>'Another action', 'url'=>'#'),

                    array('label'=>'Something else here', 'url'=>'#'),

                    '---',

                    array('label'=>'NAV HEADER'),


                    array('label'=>'Separated link', 'url'=>'#'),

                    array('label'=>'One more separated link', 'url'=>'#'),

                )),

            ),

        ),

        '<form class="navbar-search pull-left" action=""><input type="text" class="search-query span2" placeholder="Search"></form>',

           

        array(

            'class'=>'bootstrap.widgets.TbMenu',

            'htmlOptions'=>array('class'=>'pull-right'),

            'items'=>array(


                array('label'=>'Link', 'url'=>'#'),

                '---',


              array('label' => 'Hi, '.Yii::app()->user->name, 'url'=>'#',

                   'items' => array(

                       array('label'=> 'Logout',

                       'url' => array('/site/logout'), 

                       'visible'=>!Yii::app()->user->isGuest),

                       

                   )

                   ),

               

                array('label'=>'Login', 'url'=>'#', 

                    'items'=>array(

              

                   /* LOGIN FORM */   

                      '<form><input type="text" placeholder="user id" id="userid"/><input type="password" placeholder="password" name="userpassword"/></form>'




                     ), 'visible' => Yii::app()->user->isGuest),

                

                


            ),

        ),

    ),

)); 



How can I attach a login form in dropdown navbar link?

Thanks.

Hello Newbie Here…

I try Use new release of these extention,

and I got some problem whit this code




echo $form->textFieldRow($model, 'textField', array('class'=>'span3')); 



that code give me error message like this

What I missing whit this error message??

can I see ur code of that example?