Added CSS classes to style font sizes in tag cloud
authorMarcel Werk <burntime@woltlab.com>
Sun, 22 May 2016 21:13:18 +0000 (23:13 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sun, 22 May 2016 21:13:18 +0000 (23:13 +0200)
CHANGELOG.md
com.woltlab.wcf/templates/tagCloudBox.tpl
wcfsetup/install/files/lib/data/tag/TagCloudTag.class.php
wcfsetup/install/files/lib/system/tagging/TagCloud.class.php
wcfsetup/install/files/style/element/list.scss

index 5f0aa747b55004d086c86fbbcf2f3ce78e4fd9e8..a6fbb299b9e81b176934322fba29e7dbf1e66cd1 100644 (file)
 * Added basic grid layout classes
 * Renamed `.pageNavigation` to `.pagination`
 * Renamed `.navigation`/`.navigationIcons` to `.pageNavigation`/`.pageNavigationIcons`
+* Added CSS classes to style font sizes in tag cloud (`tagWeight1` - `tagWeight7`)
 
 #### Deprecated Code
 
index c5f928dcc6de6ed14d9d380cae9ad8d3482335d0..6aaa30d11d62d2d2027b6da7e631821999fe0cdd 100644 (file)
@@ -2,7 +2,7 @@
        <ul class="tagList">
                {content}
                        {foreach from=$tags item=tagObj}
-                               <li><a href="{link controller='Tagged' object=$tagObj}{if !$taggableObjectType|empty}objectType={@$taggableObjectType}{/if}{/link}" rel="tag" style="font-size: {@$tagObj->getSize()}%;">{$tagObj->name}</a></li>
+                               <li><a href="{link controller='Tagged' object=$tagObj}{if !$taggableObjectType|empty}objectType={@$taggableObjectType}{/if}{/link}" rel="tag" class="tagWeight{@$tagObj->getWeight()}">{$tagObj->name}</a></li>
                        {/foreach}
                {/content}
        </ul>
index 16f8bd507265ea6b82fb1de50357d5373b91503b..1c4242c738230418c33861eb1a3b3c4789637169 100644 (file)
@@ -22,26 +22,45 @@ class TagCloudTag extends DatabaseObjectDecorator {
        protected static $baseClass = Tag::class;
        
        /**
-        * size of the tag in a weighted list
-        * @var double
+        * weight of the tag in a weighted list
+        * @var integer
         */
-       protected $size = 0.0;
+       protected $weight = 1;
        
+       /**
+        * Sets the weight of the tag.
+        *
+        * @param       double          $weight
+        * @deprecated  2.2
+        */
+       public function setWeight($weight) {
+               $this->weight = $weight;
+       }
+       
+       /**
+        * Returns the weight of the tag.
+        *
+        * @return      integer
+        */
+       public function getWeight() {
+               return $this->weight;
+       }
+               
        /**
         * Sets the size of the tag.
         * 
         * @param       double          $size
+        * @deprecated  2.2
         */
-       public function setSize($size) {
-               $this->size = $size;
-       }
+       public function setSize($size) {}
        
        /**
         * Returns the size of the tag.
         * 
         * @return      double
+        * @deprecated  2.2
         */
        public function getSize() {
-               return $this->size;
+               return (($this->weight - 1) / 6) * 85 + 85;
        }
 }
index 48f09ac7c32a2b2674d5e55457cc132a4f104566..5a53e9644d887c26ae48a5b0feb9be69416d04cc 100644 (file)
@@ -18,12 +18,14 @@ class TagCloud {
        /**
         * max font size
         * @var integer
+        * @deprecated 2.2
         */
        const MAX_FONT_SIZE = 170;
        
        /**
         * min font size
         * @var integer
+        * @deprecated 2.2
         */
        const MIN_FONT_SIZE = 85;
        
@@ -91,7 +93,7 @@ class TagCloud {
                
                // assign sizes
                foreach ($tags as $tag) {
-                       $tag->setSize($this->calculateSize($tag->counter));
+                       $tag->setWeight($this->calculateWeight($tag->counter));
                }
                
                // sort alphabetically
@@ -101,18 +103,14 @@ class TagCloud {
                return $tags;
        }
        
-       /**
-        * Returns the size of a tag with given number of uses for a weighted list.
-        * 
-        * @param       integer         $counter
-        * @return      double
-        */
-       private function calculateSize($counter) {
+       private function calculateWeight($counter) {
                if ($this->maxCounter == $this->minCounter) {
-                       return 100;
+                       return 2;
                }
                else {
-                       return (self::MAX_FONT_SIZE - self::MIN_FONT_SIZE) / ($this->maxCounter - $this->minCounter) * $counter + self::MIN_FONT_SIZE - ((self::MAX_FONT_SIZE - self::MIN_FONT_SIZE) / ($this->maxCounter - $this->minCounter)) * $this->minCounter;
+                       $weight = round(log($counter) / log($this->maxCounter) * 7);
+                       if ($weight < 1) $weight = 1;
+                       return $weight;
                }
        }
 }
index 4d6a04fb41dffff4f85284507ddea54b53b839bc..6beb95396ea4817b87636180cb6832478af175af 100644 (file)
@@ -23,6 +23,34 @@ ol.nativeList {
        @include inlineList;
        
        align-items: baseline;
+       
+       .tagWeight1 {
+               font-size: 12px;
+       }
+       
+       .tagWeight2 {
+               font-size: 14px;
+       }
+       
+       .tagWeight3 {
+               font-size: 16px;
+       }
+       
+       .tagWeight4 {
+               font-size: 18px;
+       }
+       
+       .tagWeight5 {
+               font-size: 20px;
+       }
+       
+       .tagWeight6 {
+               font-size: 23px;
+       }
+       
+       .tagWeight7 {
+               font-size: 28px;
+       }
 }
 
 /* list of smileys */