* 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
<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>
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;
}
}
/**
* 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;
// assign sizes
foreach ($tags as $tag) {
- $tag->setSize($this->calculateSize($tag->counter));
+ $tag->setWeight($this->calculateWeight($tag->counter));
}
// sort alphabetically
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;
}
}
}
@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 */