From 5538e4824fb7beed14338fc418379a2edc03e84e Mon Sep 17 00:00:00 2001 From: rvelices Date: Thu, 17 Jul 2014 19:06:05 +0000 Subject: rating user improvements: faster javascript, by default sorted by last rate date, better tooltips ... git-svn-id: http://piwigo.org/svn/trunk@29053 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/themes/default/template/rating_user.tpl | 194 ++++++++++++++++++-------- 1 file changed, 133 insertions(+), 61 deletions(-) (limited to 'admin/themes/default') diff --git a/admin/themes/default/template/rating_user.tpl b/admin/themes/default/template/rating_user.tpl index 5f0952c94..bc2b29ad6 100644 --- a/admin/themes/default/template/rating_user.tpl +++ b/admin/themes/default/template/rating_user.tpl @@ -12,8 +12,29 @@ .dtBar { text-align:left; - padding-left: 20px; + padding: 10px 0 10px 20px } +.dtBar DIV{ + display:inline; + padding-right: 5px; +} + +.dataTables_paginate A { + padding-left: 3px; +} + +.ui-tooltip { + padding: 8px; + position: absolute; + z-index: 9999; + max-width: {3*$TN_WIDTH}px; + -webkit-box-shadow: 0 0 5px #aaa; + box-shadow: 0 0 5px #aaa; +} +body .ui-tooltip { + border-width: 2px; +} + {/html_style}

{$ratings|@count} {'Users'|@translate}

@@ -42,103 +63,154 @@ {combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'} +{combine_script id='jquery.geoip' load='async' path='admin/themes/default/js/jquery.geoip.js'} {footer_script} var oTable = jQuery('#rateTable').dataTable({ - sDom : '<"dtBar"f>rt', - bPaginate: false, - aaSorting: [[5,'desc']], + sDom : '<"dtBar"filp>rt<"dtBar"ilp>', + iDisplayLength: 100, + aLengthMenu: [ [25, 50, 100, 500, -1], [25, 50, 100, 500, "All"]], + aaSorting: [], //[[1,'desc']], + bAutoWidth: false, + bSortClasses: false, aoColumnDefs: [ - /*{ - aTargets: ["dtc_user"] - },*/ + { + aTargets: ["dtc_user"], + sType: "string", + sClass: null + }, { aTargets: ["dtc_date"], - asSorting: ["desc","asc"] + asSorting: ["desc","asc"], + sType: "string", + sClass: null }, { aTargets: ["dtc_stat"], asSorting: ["desc","asc"], - bSearchable: false + bSearchable: false, + sType: "numeric", + sClass: null }, { aTargets: ["dtc_rate"], asSorting: ["desc","asc"], - bSearchable: false + bSearchable: false, + sType: "html", + sClass: null }, { aTargets: ["dtc_del"], bSortable: false, - bSearchable: false + bSearchable: false, + sType: "string", + sClass: null } ] }); -function del(elt,uid,aid){ - if (!confirm('{'Are you sure?'|@translate|@escape:'javascript'}')) - return false; - var tr = elt; + +function uidFromCell(cell){ + var tr = cell; while ( tr.nodeName != "TR") tr = tr.parentNode; - tr = jQuery(tr).fadeTo(1000, 0.4); + return $(tr).data("usr"); +} - (new PwgWS('{$ROOT_URL|@escape:javascript}')).callService( - 'pwg.rates.delete', { user_id:uid, anonymous_id:aid}, - { - method: 'POST', - onFailure: function(num, text) { tr.stop(); tr.fadeTo(0,1); alert(num + " " + text); }, - onSuccess: function(result){ - if (result) - oTable.fnDeleteRow(tr[0]); - else - alert(result); +{* -----DELETE----- *} +$(document).ready( function(){ + $("#rateTable").on( "click", ".del", function(e) { + e.preventDefault(); + if (!confirm('{'Are you sure?'|@translate|@escape:'javascript'}')) + return; + var cell = e.target.parentNode, + tr = cell; + while ( tr.nodeName != "TR") tr = tr.parentNode; + tr = jQuery(tr).fadeTo(1000, 0.4); + + var data=uidFromCell(cell); + + (new PwgWS('{$ROOT_URL|@escape:javascript}')).callService( + 'pwg.rates.delete', { user_id:data.uid, anonymous_id:data.aid}, + { + method: 'POST', + onFailure: function(num, text) { tr.stop(); tr.fadeTo(0,1); alert(num + " " + text); }, + onSuccess: function(result){ + if (result) + oTable.fnDeleteRow(tr[0]); + else + alert(result); + } } - } - ); - - return false; -} + ); + + }); +}); + {/footer_script} - - - - - - - + + + + + + + {foreach from=$available_rates item=rate} - + {/foreach} - + {foreach from=$ratings item=rating key=user} - - - - - - - - - {foreach from=$rating.rates item=rates key=rate} - - {/foreach} - + +{strip} + + + +{foreach from=$rating.rates item=rates key=rate} + +{/foreach} + +{/strip} {/foreach}
{'Username'|@translate}{'Last'|@translate}{'Number of rates'|@translate}{'Average rate'|@translate}{'Variation'|@translate}{'Consensus deviation'|@translate|@replace:' ':'
'}
{'Consensus deviation'|@translate|@replace:' ':'
'} {$CONSENSUS_TOP_NUMBER}
{'Username'|@translate}{'Last'|@translate}{'Number of rates'|@translate}{'Average rate'|@translate}{'Variation'|@translate}{'Consensus deviation'|@translate|@replace:' ':'
'}
{'Consensus deviation'|@translate|@replace:' ':'
'} {$CONSENSUS_TOP_NUMBER}
{$rate}{$rate}
{$user}{$rating.last_date}{$rating.count}{$rating.avg|@number_format:2}{$rating.cv|@number_format:3}{$rating.cd|@number_format:3}{if !empty($rating.cdtop)}{$rating.cdtop|@number_format:3}{/if}{if !empty($rates)} - {capture assign=rate_over}{foreach from=$rates item=rate_arr}thumb-{$rate_arr.id} - {/foreach}{/capture} - {$rates|@count} - {/if}
{$user}{$rating.last_date}{$rating.count}{$rating.avg|@number_format:2}{$rating.cv|@number_format:3}{$rating.cd|@number_format:3}{if !empty($rating.cdtop)}{$rating.cdtop|@number_format:3}{/if}{if !empty($rates)} +{capture assign=rate_over}{foreach $rates as $rate_arr}{if $rate_arr@index>29}{break}{/if}thumb-{$rate_arr.id}{/foreach}{/capture} +{$rates|@count} +{/if}
-{combine_script id='jquery.cluetip' load='footer' require='jquery' path='themes/default/js/plugins/jquery.cluetip.js'} -{footer_script require='jquery.cluetip'} -jQuery(document).ready(function(){ldelim} - jQuery('.cluetip').cluetip({ldelim} - width: {$TN_WIDTH}, showTitle:false, splitTitle: '|' +{combine_script id='jquery.ui.tooltip' load='footer'} +{footer_script require='jquery.ui.tooltip'} +jQuery(document).ready(function(){ + jQuery("#rateTable").tooltip({ + items: ".usr,[title]", + content: function(callback) { + var t = $(this).attr("title"); + if (t) + return t; + var that = $(this), + udata = uidFromCell(this); + if (!udata.aid) + return; + that + .data("isOver", true) + .one("mouseleave", function() { + that.removeData("isOver"); + }); + + GeoIp.get( udata.aid + ".1", function(data) { + if (!data.fullName) return; + var content = data.fullName; + if (data.latitude && data.region_name) { + content += "
"; + } + if (that.data("isOver")) + callback(content); + }); + } }); }) {/footer_script} \ No newline at end of file -- cgit v1.2.3