Christoffer Niska avatar Christoffer Niska committed 313c205

refactored dropup logic

Comments (0)

Files changed (2)

widgets/TbButtonGroup.php

 	 * @var boolean indicates whether to enable button toggling.
 	 */
 	public $toggle;
+	/**
+	 * @var boolean indicates whether dropdowns should be dropups instead.
+	 */
+	public $dropup = false;
 
 	/**
 	 * Initializes the widget.
 	{
 		$classes = array('btn-group');
 
-        foreach ($this->buttons as $button)
-        {
-            if ($this->hasDropdown($button) && $this->isDropup($button))
-            {
-                $classes[] = 'dropup';
-                break;
-            }
-        }
+        if ($this->dropup === true)
+			$classes[] = 'dropup';
 
         if (!empty($classes))
         {
 
 		echo '</div>';
 	}
-
-    /**
-     * Returns whether the given button has a dropdown.
-     * @param array $button the button configuration
-     * @return boolean the result
-     */
-    protected function hasDropdown($button)
-    {
-        return isset($button['items']) && !empty($button['items']);
-    }
-
-    /**
-     * Returns whether the given item is a dropup.
-     * @param array $button the button configuration
-     * @return boolean the result
-     */
-    protected function isDropup($button)
-    {
-        return isset($button['dropup']) && $button['dropup'] === true;
-    }
 }

widgets/TbMenu.php

      */
     public $type;
     /**
-     * @var boolean whether to stack navigation items.
+     * @var boolean indicates whether to stack navigation items.
      */
     public $stacked = false;
     /**
      * @var array the scroll-spy configuration.
      */
     public $scrollspy;
+	/**
+	 * @var boolean indicates whether dropdowns should be dropups instead.
+	 */
+	public $dropup = false;
 
     /**
      * Initializes the widget.
         if (isset($this->type) && in_array($this->type, $validTypes))
             $classes[] = 'nav-'.$this->type;
 
-        if ($this->type !== self::TYPE_LIST && $this->stacked)
+        if ($this->stacked && $this->type !== self::TYPE_LIST)
             $classes[] = 'nav-stacked';
 
-        foreach ($this->items as $item)
-        {
-            if ($this->hasDropdown($item) && $this->isDropup($item))
-            {
-                $classes[] = 'dropup';
-                break;
-            }
-        }
+    	if ($this->dropup === true)
+			$classes[] = 'dropup';
 
         if (!empty($classes))
         {
     }
 
     /**
-     * Returns whether the given item has a dropdown.
-     * @param array $item the item configuration
-     * @return boolean the result
-     */
-    protected function hasDropdown($item)
-    {
-        return isset($item['items']) && !empty($item['items']);
-    }
-
-    /**
-     * Returns whether the given item is a dropup.
-     * @param array $item the item configuration
-     * @return boolean the result
-     */
-    protected function isDropup($item)
-    {
-        return isset($item['dropup']) && $item['dropup'] === true;
-    }
-
-    /**
      * Returns the divider css class.
      * @return string the class name
      */
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.