Christoffer Niska avatar Christoffer Niska committed 5fb5100 Merge

merged default to BootDatePicker

Comments (0)

Files changed (5)

components/Bootstrap.php

 			$this->registerYiiCss();
 
 		if ($this->enableJS)
-			$this->registerCorePlugins();
+			$this->registerCoreScripts();
 	}
 
 	/**
 	}
 
 	/**
-	 * Registers the core JavaScript plugins.
+	 * Registers the core JavaScript.
 	 * @since 0.9.8
 	 */
-	public function registerCorePlugins()
+	public function registerCoreScripts()
+	{
+		$this->registerJS();
+		$this->registerTooltip();
+		$this->registerPopover();
+	}
+
+	/**
+	 * Registers the Bootstrap JavaScript.
+	 * @param int $position the position of the JavaScript code.
+	 * @see CClientScript::registerScriptFile
+	 */
+	public function registerJS($position = CClientScript::POS_HEAD)
 	{
 		/** @var CClientScript $cs */
 		$cs = Yii::app()->getClientScript();
 		$cs->registerCoreScript('jquery');
-		$cs->registerScriptFile($this->getAssetsUrl().'/js/bootstrap.min.js');
-
-		$this->registerTooltip();
-		$this->registerPopover();
+		$cs->registerScriptFile($this->getAssetsUrl().'/js/bootstrap.min.js', $position);
 	}
 
 	/**

widgets/BootBreadcrumbs.php

 	 */
 	public function run()
 	{
-		if (empty($this->links))
-			return;
-		
 		$links = array();
 
-		if ($this->homeLink === null)
+		if (!isset($this->homeLink))
 			$this->homeLink = array('label'=>Yii::t('bootstrap', 'Home'), 'url'=>Yii::app()->homeUrl);
 
 		if ($this->homeLink !== false)
 			if (is_array($this->homeLink))
 				$this->homeLink = CHtml::link($this->homeLink['label'], $this->homeLink['url']);
 			
-			$links[] = $this->renderItem($this->homeLink);
+			$links[] = $this->renderItem($this->homeLink, Yii::app()->request->requestUri === Yii::app()->homeUrl);
 		}
 		
 		foreach ($this->links as $label=>$url)

widgets/input/BootInput.php

 		else
 			return '';
 	}
+	
+	/**
+	 * Returns the id that should be used for the specified attribute
+	 * @param string $attribute the attribute
+	 * @return string the id 
+	 */
+	protected function getAttributeId($attribute) 
+	{
+		return isset($this->htmlOptions['id']) ? $this->htmlOptions['id'] : 
+			CHtml::getIdByName(CHtml::resolveName($this->model, $attribute));
+	}
 
 	/**
 	 * Returns the input container CSS classes.

widgets/input/BootInputHorizontal.php

 			$htmlOptions['class'] .= ' '.$classes;
 		else
 			$htmlOptions['class'] = $classes;
+		
+		if(isset($this->htmlOptions['id']))
+			$htmlOptions['for'] = $this->htmlOptions['id'];
 
 		return parent::getLabel($htmlOptions);
 	}
 	{
 		$attribute = $this->attribute;
 		echo '<div class="controls">';
-		echo '<label class="checkbox" for="'.CHtml::getIdByName(CHtml::resolveName($this->model, $attribute)).'">';
+		echo '<label class="checkbox" for="'.$this->getAttributeId($attribute).'">';
 		echo $this->form->checkBox($this->model, $attribute, $this->htmlOptions).PHP_EOL;
 		echo $this->model->getAttributeLabel($attribute);
 		echo $this->getError().$this->getHint();

widgets/input/BootInputVertical.php

 	protected function checkBox()
 	{
 		$attribute = $this->attribute;
-		echo '<label class="checkbox" for="'.CHtml::getIdByName(CHtml::resolveName($this->model, $attribute)).'">';
+		echo '<label class="checkbox" for="'.$this->getAttributeId($attribute).'">';
 		echo $this->form->checkBox($this->model, $this->attribute, $this->htmlOptions).PHP_EOL;
 		echo $this->model->getAttributeLabel($attribute);
 		echo $this->getError().$this->getHint();
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.