Commit 2a0a234a by niskac

Minor bug fixes.

Fixed an issue with hiding alerts created with JS. Fixed a few minor issues in the BootActiveForm. Fixed an issue with the homeLink in BootCrumb. Fixed the password type in both BootActiveForm and BootInputBlock.
parent 04247b75
...@@ -37,16 +37,8 @@ ...@@ -37,16 +37,8 @@
alerts = self.element.find( '.alert-message' ); alerts = self.element.find( '.alert-message' );
for ( var i = 0, l = alerts.length; i < l; ++i ) { for ( var i = 0, l = alerts.length; i < l; ++i ) {
var alert = $( alerts[ i ] ), var alert = $( alerts[ i ] );
closeLink = self._createCloseLink( alert ); self._initAlert( alert );
closeLink.prependTo( alert );
if ( self.options.closeTime > 0 ) {
setTimeout( function() {
self.close( alert );
}, self.options.displayTime );
}
} }
}, },
/** /**
...@@ -56,25 +48,42 @@ ...@@ -56,25 +48,42 @@
*/ */
alert: function( key, message ) { alert: function( key, message ) {
if ( this.options.keys.indexOf( key ) !== -1 ) { if ( this.options.keys.indexOf( key ) !== -1 ) {
var template = this.options.template; var self = this,
template = this.options.template;
template = template.replace( '{key}', key ); template = template.replace( '{key}', key );
template = template.replace( '{message}', message ); template = template.replace( '{message}', message );
var alert = $( template ) var alert = $( template );
.appendTo( this.element ); self._initAlert( alert );
alert.appendTo( self.element );
var closeLink = this._createCloseLink( alert );
closeLink.prependTo( alert );
} }
return this; return this;
}, },
/** /**
* Initializes the alert by appending the close link
* and by setting a time out for the close callback.
* @param {Object} alert The alert element.
*/
_initAlert: function( alert ) {
var self = this,
closeLink = self._createCloseLink( alert );
closeLink.prependTo( alert );
if ( self.options.closeTime > 0 ) {
setTimeout( function() {
self.close( alert );
}, self.options.displayTime );
}
},
/**
* Closes a specific alert message. * Closes a specific alert message.
* @param {Object} alert The alert element. * @param {Object} alert The alert element.
*/ */
close: function( alert ) { close: function( alert ) {
if (alert) { if ( alert ) {
alert.fadeOut( this.options.closeTime, function() { alert.fadeOut( this.options.closeTime, function() {
$( this ).html( '' ); $( this ).html( '' );
}); });
......
...@@ -141,7 +141,7 @@ class BootActiveForm extends CActiveForm ...@@ -141,7 +141,7 @@ class BootActiveForm extends CActiveForm
*/ */
public function passwordFieldBlock($model, $attribute, $htmlOptions = array()) public function passwordFieldBlock($model, $attribute, $htmlOptions = array())
{ {
return $this->inputBlock('passwordfield', $model, $attribute, null, $htmlOptions); return $this->inputBlock('password', $model, $attribute, null, $htmlOptions);
} }
/** /**
...@@ -258,7 +258,7 @@ class BootActiveForm extends CActiveForm ...@@ -258,7 +258,7 @@ class BootActiveForm extends CActiveForm
public function errorSummary($models, $header = null, $footer = null, $htmlOptions = array()) public function errorSummary($models, $header = null, $footer = null, $htmlOptions = array())
{ {
if (!isset($htmlOptions['class'])) if (!isset($htmlOptions['class']))
$htmlOptions['class'] = 'alert-message error'; // Bootstrap error class as default $htmlOptions['class'] = 'alert-message block-message error'; // Bootstrap error class as default
return parent::errorSummary($models, $header, $footer, $htmlOptions); return parent::errorSummary($models, $header, $footer, $htmlOptions);
} }
......
...@@ -25,18 +25,16 @@ class BootCrumb extends CBreadcrumbs ...@@ -25,18 +25,16 @@ class BootCrumb extends CBreadcrumbs
{ {
$links = array(); $links = array();
if ($this->homeLink === null) if ($this->homeLink === null || !(isset($this->homeLink['label']) && isset($this->homeLink['url'])))
{ $this->homeLink = array('label'=>Yii::t('bootstrap', 'Home'),'url'=>Yii::app()->homeUrl);
if (!empty($this->links)) if (!empty($this->links))
{ {
$content = BootHtml::link(Yii::t('bootstrap', 'Home'), Yii::app()->homeUrl); $content = BootHtml::link($this->homeLink['label'], $this->homeLink['url']);
$links[] = $this->renderItem($content); $links[] = $this->renderItem($content);
} }
else else
$links[] = $this->renderItem(Yii::t('bootstrap', 'Home'), true); $links[] = $this->renderItem($this->homeLink['label'], true);
}
else if ($this->homeLink !== false)
$links[] = $this->homeLink;
foreach ($this->links as $label=>$url) foreach ($this->links as $label=>$url)
{ {
......
...@@ -18,7 +18,7 @@ class BootInputBlock extends CInputWidget ...@@ -18,7 +18,7 @@ class BootInputBlock extends CInputWidget
public $label; public $label;
/** /**
* @property string the input type. * @property string the input type.
* Following types are supported: checkbox, checkboxlist, dropdownlist, filefield, passwordfield, * Following types are supported: checkbox, checkboxlist, dropdownlist, filefield, password,
* radiobutton, radiobuttonlist, textarea, textfield and captcha. * radiobutton, radiobuttonlist, textarea, textfield and captcha.
*/ */
public $type; public $type;
...@@ -70,7 +70,7 @@ class BootInputBlock extends CInputWidget ...@@ -70,7 +70,7 @@ class BootInputBlock extends CInputWidget
$input = $this->form->fileField($this->model, $this->attribute, $this->htmlOptions); $input = $this->form->fileField($this->model, $this->attribute, $this->htmlOptions);
break; break;
case 'passwordfield': case 'password':
$input = $this->form->passwordField($this->model, $this->attribute, $this->htmlOptions); $input = $this->form->passwordField($this->model, $this->attribute, $this->htmlOptions);
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment