Commits

Christoffer Niska  committed 5f0f81e

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.

  • Participants
  • Parent commits 3bf32fc

Comments (0)

Files changed (4)

File assets/js/jquery.ui.bootalert.js

 				alerts = self.element.find( '.alert-message' );
 
 			for ( var i = 0, l = alerts.length; i < l; ++i ) {
-				var alert = $( alerts[ i ] ),
-					closeLink = self._createCloseLink( alert );
-
-				closeLink.prependTo( alert );
-
-				if ( self.options.closeTime > 0 ) {
-					setTimeout( function() {
-						self.close( alert );
-					}, self.options.displayTime );
-				}
+				var alert = $( alerts[ i ] );
+				self._initAlert( alert );
 			}
 		},
 		/**
 		 */
 		alert: function( key, message ) {
 			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( '{message}', message );
 
-				var alert = $( template )
-					.appendTo( this.element );
-
-				var closeLink = this._createCloseLink( alert );
-				closeLink.prependTo( alert );
+				var alert = $( template );
+				self._initAlert( alert );
+				alert.appendTo( self.element );
 			}
 
 			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.
 		 * @param {Object} alert The alert element.
 		 */
 		close: function( alert ) {
-			if (alert) {
+			if ( alert ) {
 				alert.fadeOut( this.options.closeTime, function() {
 					$( this ).html( '' );
 				});

File widgets/BootActiveForm.php

 	 */
 	public function passwordFieldBlock($model, $attribute, $htmlOptions = array())
 	{
-		return $this->inputBlock('passwordfield', $model, $attribute, null, $htmlOptions);
+		return $this->inputBlock('password', $model, $attribute, null, $htmlOptions);
 	}
 
 	/**
 	public function errorSummary($models, $header = null, $footer = null, $htmlOptions = array())
 	{
 		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);
 	}

File widgets/BootCrumb.php

 	{
 		$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);
-				$links[] = $this->renderItem($content);
-			}
-			else
-				$links[] = $this->renderItem(Yii::t('bootstrap', 'Home'), true);
+			$content = BootHtml::link($this->homeLink['label'], $this->homeLink['url']);
+			$links[] = $this->renderItem($content);
 		}
-		else if ($this->homeLink !== false)
-			$links[] = $this->homeLink;
+		else
+			$links[] = $this->renderItem($this->homeLink['label'], true);
 
 		foreach ($this->links as $label=>$url)
 		{

File widgets/BootInputBlock.php

 	public $label;
 	/**
 	 * @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.
 	 */
 	public $type;
 				$input = $this->form->fileField($this->model, $this->attribute, $this->htmlOptions);
 				break;
 
-			case 'passwordfield':
+			case 'password':
 				$input = $this->form->passwordField($this->model, $this->attribute, $this->htmlOptions);
 				break;