source: trunk/admin/themes/default/template/rating_user.tpl @ 29053

Last change on this file since 29053 was 29053, checked in by rvelices, 10 years ago

rating user improvements: faster javascript, by default sorted by last rate date, better tooltips ...

  • Property svn:eol-style set to LF
File size: 6.2 KB
Line 
1{combine_script id='jquery.dataTables' load='footer' path='themes/default/js/plugins/jquery.dataTables.js'}
2{html_style}
3.sorting { background: url({$ROOT_URL}themes/default/js/plugins/datatables/images/sort_both.png) no-repeat center right; cursor:pointer; }
4.sorting_asc { background: url({$ROOT_URL}themes/default/js/plugins/datatables/images/sort_asc.png) no-repeat center right; }
5.sorting_desc { background: url({$ROOT_URL}themes/default/js/plugins/datatables/images/sort_desc.png) no-repeat center right; }
6
7.sorting, .sorting_asc, .sorting_desc {
8        padding: 3px 18px 3px 10px;
9}
10.sorting_asc_disabled { background: url({$ROOT_URL}themes/default/js/plugins/datatables/images/sort_asc_disabled.png) no-repeat center right; }
11.sorting_desc_disabled { background: url({$ROOT_URL}themes/default/js/plugins/datatables/images/sort_desc_disabled.png) no-repeat center right; }
12
13.dtBar {
14        text-align:left;
15        padding: 10px 0 10px 20px
16}
17.dtBar DIV{
18        display:inline;
19        padding-right: 5px;
20}
21
22.dataTables_paginate A {
23        padding-left: 3px;
24}
25
26.ui-tooltip {
27        padding: 8px;
28        position: absolute;
29        z-index: 9999;
30        max-width: {3*$TN_WIDTH}px;
31        -webkit-box-shadow: 0 0 5px #aaa;
32        box-shadow: 0 0 5px #aaa;
33}
34body .ui-tooltip {
35        border-width: 2px;
36}
37
38{/html_style}
39
40<h2>{$ratings|@count} {'Users'|@translate}</h2>
41
42<form action="{$F_ACTION}" method="GET">
43<fieldset>
44<noscript>
45        <label>{'Sort by'|@translate}
46                <select name="order_by">
47                        {html_options options=$order_by_options selected=$order_by_options_selected}
48                </select>
49        </label>
50</noscript>
51        <label>{'Number of rates'|@translate}&gt;
52        <input type="text" size="5" name="f_min_rates" value="{$F_MIN_RATES}">
53        </label>
54        <label>{'Consensus deviation'|@translate}
55        <input type="text" size="5" name="consensus_top_number" value="{$CONSENSUS_TOP_NUMBER}">
56        {'Best rated'|@translate}
57        </label>
58
59        <input type="submit" value="{'Submit'|@translate}">
60        </label>
61        <input type="hidden" name="page" value="rating_user">
62</fieldset>
63</form>
64
65{combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'}
66{combine_script id='jquery.geoip' load='async' path='admin/themes/default/js/jquery.geoip.js'}
67{footer_script}
68var oTable = jQuery('#rateTable').dataTable({
69        sDom : '<"dtBar"filp>rt<"dtBar"ilp>',
70        iDisplayLength: 100,
71        aLengthMenu: [ [25, 50, 100, 500, -1], [25, 50, 100, 500, "All"]],
72        aaSorting: [], //[[1,'desc']],
73        bAutoWidth: false,
74        bSortClasses: false,
75        aoColumnDefs: [
76                {
77                        aTargets: ["dtc_user"],
78                        sType: "string",
79                        sClass: null
80                },
81                {
82                        aTargets: ["dtc_date"],
83                        asSorting: ["desc","asc"],
84                        sType: "string",
85                        sClass: null
86                },
87                {
88                        aTargets: ["dtc_stat"],
89                        asSorting: ["desc","asc"],
90                        bSearchable: false,
91                        sType: "numeric",
92                        sClass: null
93                },
94                {
95                        aTargets: ["dtc_rate"],
96                        asSorting: ["desc","asc"],
97                        bSearchable: false,
98                        sType: "html",
99                        sClass: null
100                },
101                {
102                        aTargets: ["dtc_del"],
103                        bSortable: false,
104                        bSearchable: false,
105                        sType: "string",
106                        sClass: null
107                }
108        ]
109});
110
111
112function uidFromCell(cell){
113        var tr = cell;
114        while ( tr.nodeName != "TR") tr = tr.parentNode;
115        return $(tr).data("usr");
116}
117
118{* -----DELETE----- *}
119$(document).ready( function(){
120        $("#rateTable").on( "click", ".del", function(e) {
121                e.preventDefault();
122                if (!confirm('{'Are you sure?'|@translate|@escape:'javascript'}'))
123                        return;
124                var cell = e.target.parentNode,
125                        tr = cell;
126                while ( tr.nodeName != "TR") tr = tr.parentNode;
127                tr = jQuery(tr).fadeTo(1000, 0.4);
128
129                var data=uidFromCell(cell);
130               
131                (new PwgWS('{$ROOT_URL|@escape:javascript}')).callService(
132                        'pwg.rates.delete', { user_id:data.uid, anonymous_id:data.aid},
133                        {
134                                method: 'POST',
135                                onFailure: function(num, text) { tr.stop(); tr.fadeTo(0,1); alert(num + " " + text); },
136                                onSuccess: function(result){
137                                        if (result)
138                                                oTable.fnDeleteRow(tr[0]);
139                                        else
140                                                alert(result);
141                                }
142                        }
143                );
144
145        });
146});
147
148{/footer_script}
149<table id="rateTable">
150<thead>
151<tr class="throw">
152        <th class="dtc_user">{'Username'|@translate}</th>
153        <th class="dtc_date">{'Last'|@translate}</th>
154        <th class="dtc_stat">{'Number of rates'|@translate}</th>
155        <th class="dtc_stat">{'Average rate'|@translate}</th>
156        <th class="dtc_stat">{'Variation'|@translate}</th>
157        <th class="dtc_stat">{'Consensus deviation'|@translate|@replace:' ':'<br>'}</th>
158        <th class="dtc_stat">{'Consensus deviation'|@translate|@replace:' ':'<br>'} {$CONSENSUS_TOP_NUMBER}</th>
159{foreach from=$available_rates item=rate}
160        <th class="dtc_rate">{$rate}</th>
161{/foreach}
162        <th class="dtc_del"></th>
163</tr>
164</thead>
165{foreach from=$ratings item=rating key=user}
166<tr data-usr='{ldelim}"uid":{$rating.uid},"aid":"{$rating.aid}"}'>
167{strip}
168<td class=usr>{$user}</td><td title="First: {$rating.first_date}">{$rating.last_date}</td>
169<td>{$rating.count}</td><td>{$rating.avg|@number_format:2}</td>
170<td>{$rating.cv|@number_format:3}</td><td>{$rating.cd|@number_format:3}</td><td>{if !empty($rating.cdtop)}{$rating.cdtop|@number_format:3}{/if}</td>
171{foreach from=$rating.rates item=rates key=rate}
172<td>{if !empty($rates)}
173{capture assign=rate_over}{foreach $rates as $rate_arr}{if $rate_arr@index>29}{break}{/if}<img src="{$image_urls[$rate_arr.id].tn}" alt="thumb-{$rate_arr.id}" width="{$TN_WIDTH}" height="{$TN_WIDTH}">{/foreach}{/capture}
174<a title="{$rate_over|@htmlspecialchars}">{$rates|@count}</a>
175{/if}</td>
176{/foreach}
177<td><a class="del icon-trash"></a></td>
178</tr>
179{/strip}
180{/foreach}
181</table>
182
183{combine_script id='jquery.ui.tooltip' load='footer'}
184{footer_script require='jquery.ui.tooltip'}
185jQuery(document).ready(function(){
186        jQuery("#rateTable").tooltip({
187                items: ".usr,[title]",
188                content: function(callback) {
189                        var t = $(this).attr("title");
190                        if (t)
191                                return t;
192                        var that = $(this),
193                                udata = uidFromCell(this);
194                        if (!udata.aid)
195                                return;
196                        that
197                                .data("isOver", true)
198                                .one("mouseleave", function() {
199                                        that.removeData("isOver");
200                                });
201
202                        GeoIp.get( udata.aid + ".1", function(data) {
203                                if (!data.fullName) return;
204                                var content = data.fullName;
205                                if (data.latitude && data.region_name) {
206                                        content += "<br><img width=300 height=220 src=\"http://maps.googleapis.com/maps/api/staticmap?sensor=false&size=300x220&zoom=6"
207                                                + "&markers=size:tiny%7C" + data.latitude + "," + data.longitude
208                                                + "\">";
209                                }
210                                if (that.data("isOver"))
211                                        callback(content);
212                        });
213                }
214        });
215})
216{/footer_script}
Note: See TracBrowser for help on using the repository browser.