final cleanup on ratings feature
This commit is contained in:
parent
86771547e6
commit
4ead2cd79d
@ -19,6 +19,7 @@ function js_strings() {
|
|||||||
'$rating_desc' => t('Rate This Channel (this is public)'),
|
'$rating_desc' => t('Rate This Channel (this is public)'),
|
||||||
'$rating_val' => t('Rating'),
|
'$rating_val' => t('Rating'),
|
||||||
'$rating_text' => t('Describe (optional)'),
|
'$rating_text' => t('Describe (optional)'),
|
||||||
|
'$submit' => t('Submit'),
|
||||||
|
|
||||||
'$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : ''),
|
'$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : ''),
|
||||||
'$t02' => ((t('timeago.prefixFromNow') != 'timeago.prefixFromNow') ? t('timeago.prefixFromNow') : ''),
|
'$t02' => ((t('timeago.prefixFromNow') != 'timeago.prefixFromNow') ? t('timeago.prefixFromNow') : ''),
|
||||||
|
@ -1,5 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
function prate_init(&$a) {
|
||||||
|
if($_SERVER['REQUEST_METHOD'] === 'post')
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(! local_channel())
|
||||||
|
return;
|
||||||
|
|
||||||
|
$channel = $a->get_channel();
|
||||||
|
|
||||||
|
$target = argv(1);
|
||||||
|
if(! $target)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1",
|
||||||
|
dbesc($channel['channel_hash']),
|
||||||
|
dbesc($target)
|
||||||
|
);
|
||||||
|
if($r)
|
||||||
|
json_return_and_die(array('rating' => $r[0]['xlink_rating'],'rating_text' => $r[0]['xlink_rating_text']));
|
||||||
|
killme();
|
||||||
|
}
|
||||||
|
|
||||||
function prate_post(&$a) {
|
function prate_post(&$a) {
|
||||||
|
|
||||||
@ -63,7 +84,7 @@ function prate_post(&$a) {
|
|||||||
proc_run('php','include/ratenotif.php','rating',$record);
|
proc_run('php','include/ratenotif.php','rating',$record);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
json_return_and_die(array('result' => true));;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,3 +96,4 @@ function prate_post(&$a) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
padding: 15px;
|
padding: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rating-text {
|
.rating-text-label {
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,8 +10,3 @@
|
|||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
width: 400px;
|
width: 400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.required {
|
|
||||||
color: #ff0000;
|
|
||||||
font-size: 1.2rem;
|
|
||||||
}
|
|
@ -6,15 +6,39 @@ function dirdetails(hash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function doRatings(hash) {
|
var ratingVal = 0;
|
||||||
|
var ratingText = '';
|
||||||
var html = '<form action="prate" method="post"><input type="hidden" name="target" value="'+hash+'" /><div class="rating-desc">'+aStr['rating_desc']+'</div><input id="dir-rating-range" class="directory-slider" type="text" value="0" name="rating" style="display: none;" /><div class="rating-text">'+aStr['rating_text']+'<input type="text" name="rating-text" class="directory-rating-text" /><br /><input name="submit" class="directory-rating-submit" type="submit" value="submit" ></form><div class="clear"></div><script>$("#dir-rating-range").jRange({ from: -10, to: 10, step: 1, showLabels: false, showScale: true, scale : [ "-10","-5","0","5","10" ], onstatechange: function(v) { $("#dir-rating-range").val(v); } });</script>';
|
var currentHash = '';
|
||||||
|
|
||||||
$.colorbox({maxwidth: "50%", maxHeight: "50%", html: html, close: 'X' });
|
|
||||||
|
|
||||||
|
function fetchRatings(hash) {
|
||||||
|
$.get('prate/'+hash, function(data) {
|
||||||
|
if(typeof(data.rating) !== 'undefined') {
|
||||||
|
ratingVal = data.rating;
|
||||||
|
ratingText = data.rating_text;
|
||||||
|
}
|
||||||
|
buildRatingForm(hash);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function doRatings(hash) {
|
||||||
|
fetchRatings(hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildRatingForm(hash) {
|
||||||
|
var html = '<form id="ratings_form" action="prate" method="post"><input type="hidden" name="target" value="'+hash+'" /><div class="rating-desc">'+aStr['rating_desc']+'</div><input id="dir-rating-range" class="directory-slider" type="text" value="'+ratingVal+'" name="rating" style="display: none;" /><div class="rating-text-label">'+aStr['rating_text']+'<input type="text" name="rating_text" class="directory-rating-text" value="'+ratingText+'" /><br /><input name="submit" class="directory-rating-submit" type="submit" value="'+aStr['submit']+'" onclick="postRatings(); return false;"></form><div class="clear"></div><script>$("#dir-rating-range").jRange({ from: -10, to: 10, step: 1, showLabels: false, showScale: true, scale : [ "-10","-5","0","5","10" ], onstatechange: function(v) { $("#dir-rating-range").val(v); } });</script>';
|
||||||
|
|
||||||
|
$.colorbox({maxwidth: "50%", maxHeight: "50%", html: html, close: 'X' });
|
||||||
|
currentHash = hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
function postRatings() {
|
||||||
|
$.post('prate',$('#ratings_form').serialize(),function(data) {
|
||||||
|
$.colorbox.remove();
|
||||||
|
$('#edited-'+currentHash).show();
|
||||||
|
},'json');
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
collapseHeight();
|
collapseHeight();
|
||||||
});
|
});
|
@ -1185,9 +1185,12 @@ nav .acpopup {
|
|||||||
|
|
||||||
|
|
||||||
.required {
|
.required {
|
||||||
color: #FF0000;
|
color: #ff0000;
|
||||||
|
font-size: 1.8rem;
|
||||||
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#event-start-text, #event-finish-text {
|
#event-start-text, #event-finish-text {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
{{if $entry.viewrate}}
|
{{if $entry.viewrate}}
|
||||||
<div id="dir-rating-wrapper-{{$entry.id}}" class="directory-rating" >{{if $entry.total_ratings}}<a href="ratings/{{$entry.hash}}"><button class="btn btn-default">{{$entry.total_ratings}}</button></a>{{/if}}
|
<div id="dir-rating-wrapper-{{$entry.id}}" class="directory-rating" >{{if $entry.total_ratings}}<a href="ratings/{{$entry.hash}}"><button class="btn btn-default">{{$entry.total_ratings}}</button></a>{{/if}}
|
||||||
{{if $entry.canrate}}<button class="btn btn-default" onclick="doRatings('{{$entry.hash}}'); return false;" ><i class="icon-pencil"></i></button>{{/if}}
|
{{if $entry.canrate}}<button class="btn btn-default" onclick="doRatings('{{$entry.hash}}'); return false;" ><i class="icon-pencil"></i></button><span class="required" id="edited-{{$entry.hash}}" style="display: none;" >*</span>{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{if $entry.public_forum}}
|
{{if $entry.public_forum}}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
'rating_desc' : "{{$rating_desc}}",
|
'rating_desc' : "{{$rating_desc}}",
|
||||||
'rating_val' : "{{$rating_val}}",
|
'rating_val' : "{{$rating_val}}",
|
||||||
'rating_text' : "{{$rating_text}}",
|
'rating_text' : "{{$rating_text}}",
|
||||||
|
'submit' : "{{$submit}}",
|
||||||
|
|
||||||
't01' : "{{$t01}}",
|
't01' : "{{$t01}}",
|
||||||
't02' : "{{$t02}}",
|
't02' : "{{$t02}}",
|
||||||
|
Reference in New Issue
Block a user