Tag cloud implementation in jquery.
[srvgit] / koha-tmpl / opac-tmpl / prog / en / modules / opac-tags.tmpl
1 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><!-- TMPL_VAR NAME="LibraryNameTitle" DEFAULT="Koha Online" --> Catalog &rsaquo; Tags
2 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
3 <style type="text/css">
4         #tagcloud    {background-color: #F3F3F3; text-align: justify;}
5         .tag a       {text-decoration: none;}
6         .tag a:hover {text-decoration: underline;}
7         .tag         {display: block; padding-left: 1em;}
8         .tagcount    {display: none;}
9         .cloudweight {display: none;}
10         .tagweight {
11                 display: none;
12                 position: relative;
13                 bottom: 0.4em;
14                 color: red;
15                 font-size: 12px;
16         }
17 </style>
18 <script type="text/javascript">
19         var fontsizes = new Array (12,14,16,18,20,22,24,26,28,30);
20         var fontcount = fontsizes.length;
21         var maxcloudweight = 1;
22         $(document).ready(function() {
23                 // $('#tagcloud').css('background-color','lightgrey');
24                 // $('#tagcloud .tag').css('border','1px solid black');
25                 $('#tagcloud .tag').each(function() {
26                         if (maxcloudweight < this.title) { maxcloudweight = this.title; }
27                         // have to run through the set of tags once to get the max: cannot be combined w/ 2nd pass
28                 });
29                 $('#tagcloud .tag').each(function(i) {
30                         var pos = this.id;
31                         var weight = this.title;        // "cloudweight"
32                         weight = (! weight) ? 1 : (weight > maxcloudweight) ? maxcloudweight : weight ;
33                         var index = Math.round(fontcount * weight/maxcloudweight) - 1;
34                         index  = (! index ) ? 0 : ( index > fontcount     ) ? fontcount      : index  ;
35                         var newsize = fontsizes[index];
36                         // alert(pos+ " (" +i+ ") weight = " +weight+ " of " +maxcloudweight+ ", fontsize[" +index+ " of " +fontcount+ "] = " +newsize);
37                         $('#' + pos).css({"font-size":(newsize + 'pt'), display:"inline"});
38                 });
39         });
40 </script>
41 </head>
42 <body>
43 <div id="doc3" class="yui-t1">
44 <div id="bd">
45 <!-- TMPL_INCLUDE NAME="masthead.inc" -->
46
47 <div id="yui-main">
48   <div class="yui-b"><div class="yui-g">
49         <div class="container">
50         <!-- TMPL_IF NAME="ERRORS" -->
51         <!-- TMPL_LOOP NAME="ERRORS" -->
52                 <div class="error">There was a problem with this operation:
53                 <!-- TMPL_IF NAME="tagsdisabled" -->Sorry, tags are not enabled on this system.
54                 <!-- TMPL_ELSIF NAME="badparam" -->ERROR: illegal parameter <!-- TMPL_VAR NAME="badparam" -->
55                 <!-- TMPL_ELSIF NAME="login"    -->ERROR: You must log in to complete that action.
56                 <!-- TMPL_ELSIF NAME="failed_delete" -->ERROR: You cannot delete the tag <!-- TMPL_VAR NAME="failed_delete" -->.
57                                         <br />Note: you can only delete your own tags.
58                 <!-- TMPL_ELSIF NAME="scrubbed" -->Note: your tag contained markup code that was removed. 
59                                         <br />The tag was added as &quot;<!-- TMPL_VAR NAME="scrubbed" -->&quot;.
60                 <!-- TMPL_ELSIF NAME="scrubbed_all_bad" -->Note: your tag was entirely markup code.  It was NOT added.
61                                         <br />Please try again with plain text.
62                 <!-- TMPL_ELSE -->Unrecognized error.
63                 <!-- /TMPL_IF -->
64                 </div>
65         <!-- /TMPL_LOOP -->
66         <!-- /TMPL_IF -->
67
68         <!-- TMPL_IF NAME="add_op" -->
69           <!-- TMPL_IF NAME="added_count" -->
70                 <h3><!-- TMPL_VAR NAME="added_count" --> tag(s) successfully added.</h3>
71           <!-- /TMPL_IF -->
72           <!-- TMPL_IF NAME="deleted_count" -->
73                 <h3><!-- TMPL_VAR NAME="deleted_count" --> tag(s) successfully deleted.</h3>
74           <!-- /TMPL_IF -->
75         <!-- /TMPL_IF -->
76
77         <!-- TMPL_UNLESS NAME="hidemytags" -->
78         <!-- TMPL_IF NAME="MY_TAGS" -->
79                 <form method="post" action="opac-tags.pl">
80                 <h2>My Tags</h2>
81                 <table>
82                 <tr><th>Term</th><th>Title</th><th>Date/Time Added</th><th>Delete</th>
83                 </tr>
84         <!-- TMPL_LOOP NAME="MY_TAGS" -->
85                 <tr><td><a href="/cgi-bin/koha/opac-search.pl?tag=<!-- TMPL_VAR NAME="term" ESCAPE="URL" -->&amp;q=<!-- TMPL_VAR NAME="term" ESCAPE="URL" -->">
86                                 <!-- TMPL_VAR NAME="term" ESCAPE="HTML" --></a>
87                         </td>
88                         <td><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">
89                                 <!-- TMPL_VAR NAME="bib_summary" ESCAPE="HTML" --></a></td>
90                         <td><!-- TMPL_VAR NAME="date_created_display" -->
91                                 <span class="time" style="background-color:lightgray;"><!-- TMPL_VAR NAME="time_created_display" --></span></td>
92                         <td><input type="submit" name="del<!-- TMPL_VAR NAME="tag_id" -->" value="Delete" /></td>
93                 </tr>
94         <!-- /TMPL_LOOP -->
95                 </table>
96                 </form>
97         <!-- TMPL_ELSE -->
98                 <div class="msg">To see any of your own saved tags, first log in.</div>
99         <!-- /TMPL_IF -->
100         <!-- /TMPL_UNLESS -->
101
102         <h1>All Tags</h1>
103         <div id="action">
104                 <form method="get" action="opac-tags.pl">
105                 <p>Show up to <input name="limit" style="text-align: right;" maxlength="4" size="4" value="<!-- TMPL_VAR NAME="limit" DEFAULT="100" -->" />
106                         tags from other users.
107                         <input type="hidden" name="hidemytags" value="1" />
108                         <input type="submit" value="OK" />
109                 </p>
110                 </form>
111         </div>
112         <!-- TMPL_IF NAME="TAGLOOP" --> <!-- TMPL_VAR NAME="TAGLOOP_COUNT" --> Results:<div id="tagcloud">
113         <!-- TMPL_LOOP NAME="TAGLOOP" -->
114         <span class="tag" id="tag<!-- TMPL_VAR NAME="__counter__" -->" title="<!-- TMPL_VAR NAME="cloudweight" -->">
115                 <a href="/cgi-bin/koha/opac-search.pl?tag=<!-- TMPL_VAR NAME="term" ESCAPE="URL" -->&amp;q=<!-- TMPL_VAR NAME="term" ESCAPE="URL" -->">
116                 <!-- TMPL_VAR NAME="term" ESCAPE="HTML" --></a>
117                         <span class="tagweight"><!-- TMPL_VAR NAME="weight_total" --></span>
118         </span>
119         <!-- /TMPL_LOOP -->
120         </div>
121         <!-- /TMPL_IF -->
122 </div>
123 </div>
124 </div>
125 </div>
126 <div class="yui-b">
127 <div class="container">
128 <!--TMPL_INCLUDE NAME="navigation.inc" -->
129 <!-- TMPL_INCLUDE name="usermenu.inc" -->
130 </div>
131 </div>
132 </div>
133 <!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->