diff --git a/src/content/mytinytodo.js b/src/content/mytinytodo.js
index 9af7be3..ac12372 100644
--- a/src/content/mytinytodo.js
+++ b/src/content/mytinytodo.js
@@ -280,8 +280,8 @@ var mytinytodo = window.mytinytodo = _mtt = {
if(_mtt.menus.tagcloud) _mtt.menus.tagcloud.close();
});
- $('#tagcloudcontent').on('click', '.tag', function(){
- addFilterTag( $(this).attr('tag'), $(this).attr('tagid'), (event.metaKey || event.ctrlKey ? true : false) );
+ $('#tagcloudcontent').on('click', '.tag', function(event){
+ addFilterTag( this.dataset.tag, this.dataset.tagId, (event.metaKey || event.ctrlKey ? true : false) );
if(_mtt.menus.tagcloud) _mtt.menus.tagcloud.close();
return false;
});
@@ -362,7 +362,7 @@ var mytinytodo = window.mytinytodo = _mtt = {
});
$('#alltags').on('click', '.tag', function(){
- addEditTag($(this).attr('tag'));
+ addEditTag(this.dataset.tag);
return false;
});
@@ -1796,9 +1796,9 @@ function toggleEditAllTags(show)
function fillEditAllTags()
{
var a = [];
- for(var i=tagsList.length-1; i>=0; i--) {
- a.push(''+tagsList[i].tag+'');
- }
+ tagsList.forEach( (item) => {
+ a.push('' + item.tag + '');
+ });
$('#alltags .tags-list').html(a.join(', '));
$('#alltags').show();
};
@@ -1817,12 +1817,12 @@ function addEditTag(tag)
function loadTags(listId, callback)
{
_mtt.db.request('tagCloud', {list:listId}, function(json){
- if(!parseInt(json.total)) tagsList = [];
- else tagsList = json.cloud;
+ if (!parseInt(json.total)) tagsList = [];
+ else tagsList = json.items;
var cloud = '';
- $.each(tagsList, function(i,item){
+ tagsList.forEach( item => {
// item.tag is escaped with htmlspecialchars()
- cloud += ' '+item.tag+'';
+ cloud += ' ' + item.tag + '';
});
$('#tagcloudcontent').html(cloud)
flag.tagsChanged = false;
diff --git a/src/content/theme/style.css b/src/content/theme/style.css
index 14797a9..4c25ba4 100644
--- a/src/content/theme/style.css
+++ b/src/content/theme/style.css
@@ -739,28 +739,24 @@ h3.page-title a.mtt-back-button {
border:1px solid var(--color-border-default);
padding:5px;
width: 100%;
- max-width: 450px;
+ max-width: 600px;
text-align: center;
box-shadow: var(--color-popup-shadow);
}
#tagcloud.mtt-left-adjusted { margin-left:5px; }
#tagcloud.mtt-right-adjusted { margin-right:5px; }
#tagcloud.mtt-left-adjusted.mtt-right-adjusted { margin-bottom:5px; }
-#tagcloud .tag { margin:1px 0px; padding:2px; line-height:140%; color: var(--color-text-default); }
+#tagcloud .tag {
+ margin: 2px;
+ padding: 2px;
+ line-height:160%;
+ color: var(--color-text-default);
+ white-space: nowrap;
+}
#tagcloud .tag:hover {
background-color:var(--color-taglist-text-hover-bg);
color: var(--color-taglist-text-hover);
}
-#tagcloud .w0 { font-size:80%; }
-#tagcloud .w1 { font-size:90%; }
-#tagcloud .w2 { font-size:100%; }
-#tagcloud .w3 { font-size:110%; }
-#tagcloud .w4 { font-size:120%; }
-#tagcloud .w5 { font-size:130%; }
-#tagcloud .w6 { font-size:140%; }
-#tagcloud .w7 { font-size:150%; }
-#tagcloud .w8 { font-size:160%; }
-#tagcloud .w9 { font-size:170%; }
#tagcloudcancel { float:right; }
#tagcloudcancel span {
diff --git a/src/includes/api/TagsController.php b/src/includes/api/TagsController.php
index cfe1790..1f6567d 100644
--- a/src/includes/api/TagsController.php
+++ b/src/includes/api/TagsController.php
@@ -20,7 +20,7 @@ class TagsController extends ApiController {
$db = DBConnection::instance();
$q = $db->dq("SELECT name,tag_id,COUNT(tag_id) AS tags_count FROM {$db->prefix}tag2task INNER JOIN {$db->prefix}tags ON tag_id=id ".
- "WHERE list_id=$listId GROUP BY (tag_id) ORDER BY tags_count ASC");
+ "WHERE list_id=$listId GROUP BY (tag_id) ORDER BY tags_count DESC");
$at = array();
$ac = array();
while ($r = $q->fetchAssoc()) {
@@ -33,7 +33,7 @@ class TagsController extends ApiController {
$t = array();
$t['total'] = 0;
- $count = sizeof($at);
+ $count = count($at);
if (!$count) {
$this->response->data = $t;
return;
@@ -46,9 +46,10 @@ class TagsController extends ApiController {
$step = ($qmax - $qmin)/$grades;
foreach ($at as $i => $tag)
{
- $t['cloud'][] = array(
+ $t['items'][] = array(
'tag' => htmlspecialchars($tag['name']),
'id' => (int)$tag['id'],
+ 'count' => $ac[$i],
'w' => $this->tagWeight($qmin, $ac[$i], $step)
);
}