}
$tags = $this->store->retrieveTagsByEntry($id);
$all_tags = $this->store->retrieveAllTags($this->user->getId());
+ $maximus = 0;
+ foreach ($all_tags as $eachtag) { // search for the most times a tag is present
+ if ($eachtag["entriescount"] > $maximus) $maximus = $eachtag["entriescount"];
+ }
+ foreach ($all_tags as $key => $eachtag) { // get the percentage of presence of each tag
+ $percent = floor(($eachtag["entriescount"] / $maximus) * 100);
+
+ if ($percent < 20): // assign a css class, depending on the number of entries count
+ $cssclass = 'smallesttag';
+ elseif ($percent >= 20 and $percent < 40):
+ $cssclass = 'smalltag';
+ elseif ($percent >= 40 and $percent < 60):
+ $cssclass = 'mediumtag';
+ elseif ($percent >= 60 and $percent < 80):
+ $cssclass = 'largetag';
+ else:
+ $cssclass = 'largesttag';
+ endif;
+ $all_tags[$key]['cssclass'] = $cssclass;
+ }
$tpl_vars = array(
'entry_id' => $id,
'tags' => $tags,
var value = input.val();
var tag = $(this).text();
var terms = value.split(','); // tags into the <input>
+ $(".alreadytagged").each(function(index) {
+ terms.push($(this).text() );
+ });
if (jQuery.inArray(tag, terms) == -1 ) { // if the tag hasn't already been added
value += tag + ",";
input.val(value);
font-size: 0.96em;
}
+/* ==========================================================================
+ 5.1 = Tags-related styles
+ ========================================================================== */
+
+.suggestedtag {
+ padding: 4px;
+ cursor: pointer;
+ display: inline-block;
+}
+
+#tagcloud .smallesttag {
+ font-size: x-small;
+}
+
+#tagcloud .smalltag {
+ font-size: small;
+}
+
+#tagcloud .mediumtag {
+ font-size:medium;
+}
+
+#tagcloud .largetag {
+ font-size:large;
+}
+
+#tagcloud .largesttag {
+ font-size:larger;
+}
/* ==========================================================================
6 = Media Queries
{% trans "You can enter multiple tags, separated by commas." %}</p>
</form>
All existing tags :
-<ul>{% for eachtag in alltags %}<li class="suggestedtag" style="display: inline-block; margin:10px;">{{ eachtag.value }}</li>{% endfor %}</ul>
+<ul id="tagcloud">{% for eachtag in alltags %}<li class="suggestedtag {{ eachtag.cssclass }}">{{ eachtag.value }}</li>{% endfor %}</ul>
<a class="icon icon-reply return" href="./?view=view&id={{ entry_id }}">{% trans "return to article" %}</a>
{% endblock %}
border: 1px solid #ddd;
font-size: 0.96em;
}
+
+/* ==========================================================================
+ Tags-related styles
+ ========================================================================== */
+
+.suggestedtag {
+ padding: 4px;
+ cursor: pointer;
+ display: inline-block;
+}
+
+#tagcloud .smallesttag {
+ font-size: x-small;
+}
+
+#tagcloud .smalltag {
+ font-size: small;
+}
+
+#tagcloud .mediumtag {
+ font-size:medium;
+}
+
+#tagcloud .largetag {
+ font-size:large;
+}
+
+#tagcloud .largesttag {
+ font-size:larger;
+}
{% trans "no tags" %}
{% endif %}
<ul>
-{% for tag in tags %}<li>{{ tag.value }} <a href="./?action=remove_tag&tag_id={{ tag.id }}&id={{ entry_id }}">✘</a></li>{% endfor %}
+{% for tag in tags %}<li><span class="alreadytagged">{{ tag.value }}</span> <a href="./?action=remove_tag&tag_id={{ tag.id }}&id={{ entry_id }}">✘</a></li>{% endfor %}
</ul>
<form method="post" action="./?action=add_tag" id="editTags">
<input type="hidden" name="entry_id" value="{{ entry_id }}" />
{% trans "You can enter multiple tags, separated by commas." %}</p>
</form>
-<br>
+All existing tags :
+<ul id="tagcloud">{% for eachtag in alltags %}<li class="suggestedtag {{ eachtag.cssclass }}">{{ eachtag.value }}</li>{% endfor %}</ul>
<a href="./?view=view&id={{ entry_id }}">« {% trans "return to article" %}</a>
{% endblock %}