Commits

Christoffer Niska committed 3dbc235

changed grid and list view to register popovers and tooltips after each AJAX call

Comments (0)

Files changed (3)

components/Bootstrap.php

 	 */
 	public $enableJS = true;
 	/**
-	 * @var array the plugin options (name=>options).
+	 * @var array plugin initial options (name=>options).
+	 * Each array key-value pair represents the initial options for a single plugin class,
+	 * with the array key being the plugin name, and array value being the initial options array.
 	 * @since 0.9.8
 	 */
 	public $plugins = array();
 	/**
-	 * @var boolean whether to enable debugging mode.
+	 * @var string default popover CSS selector.
+	 * @since 0.10.0
 	 */
-	public $debug = false;
+	public $popoverSelector = 'a[rel="popover"]';
+	/**
+	 * @var string default tooltip CSS selector.
+	 * @since 0.10.0
+	 */
+	public $tooltipSelector = 'a[rel="tooltip"]';
 
 	protected $_assetsUrl;
 
 	public function init()
 	{
 		// Register the bootstrap path alias.
-		if (!Yii::getPathOfAlias('bootstrap'))
+		if (Yii::getPathOfAlias('bootstrap') === false)
 			Yii::setPathOfAlias('bootstrap', realpath(dirname(__FILE__).'/..'));
 
-		// Prevents the extension from registering scripts
-		// and publishing assets when ran from the command line.
+		// Prevents the extension from registering scripts and publishing assets when ran from the command line.
 		if (php_sapi_name() === 'cli')
 			return;
 
 	public function registerPopover($selector = null, $options = array())
 	{
 		$this->registerTooltip(); // Popover requires the tooltip plugin
-		$this->registerPlugin(self::PLUGIN_POPOVER, $selector, $options, 'a[rel="popover"]');
+		$this->registerPlugin(self::PLUGIN_POPOVER, $selector, $options, $this->popoverSelector);
 	}
 
 	/**
 	 */
 	public function registerTooltip($selector = null, $options = array())
 	{
-		$this->registerPlugin(self::PLUGIN_TOOLTIP, $selector, $options, 'a[rel="tooltip"]');
+		$this->registerPlugin(self::PLUGIN_TOOLTIP, $selector, $options, $this->tooltipSelector);
 	}
 
 	/**
 	*/
 	protected function getAssetsUrl()
 	{
-		if ($this->_assetsUrl !== null)
+		if (isset($this->_assetsUrl))
 			return $this->_assetsUrl;
 		else
 		{
 			$assetsPath = Yii::getPathOfAlias('bootstrap.assets');
-
-			if ($this->debug)
-				$assetsUrl = Yii::app()->assetManager->publish($assetsPath, false, -1, true);
-			else
-				$assetsUrl = Yii::app()->assetManager->publish($assetsPath);
-
+			$assetsUrl = Yii::app()->assetManager->publish($assetsPath, false, -1, YII_DEBUG);
 			return $this->_assetsUrl = $assetsUrl;
 		}
 	}

widgets/BootGridView.php

 				$classes[] = 'table-'.$type;
 
 		$this->itemsCssClass .= ' '.implode(' ', $classes);
+
+		$popover = Yii::app()->bootstrap->popoverSelector;
+		$tooltip = Yii::app()->bootstrap->tooltipSelector;
+		
+		$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;
 	}
 
 	/**

widgets/BootListView.php

 	 * Defaults to false, meaning that no CSS will be included.
 	 */
 	public $cssFile = false;
+
+	/**
+	 * Initializes the widget.
+	 */
+	public function init()
+	{
+		parent::init();
+
+		$popover = Yii::app()->bootstrap->popoverSelector;
+		$tooltip = Yii::app()->bootstrap->tooltipSelector;
+
+		$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;
+	}
+
+
 }
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.