aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/js_strings.php1
-rw-r--r--mod/prate.php24
-rw-r--r--view/css/mod_directory.css2
-rw-r--r--view/css/mod_events.css5
-rw-r--r--view/js/mod_directory.js28
-rw-r--r--view/theme/redbasic/css/style.css5
-rwxr-xr-xview/tpl/direntry.tpl2
-rwxr-xr-xview/tpl/js_strings.tpl1
8 files changed, 57 insertions, 11 deletions
diff --git a/include/js_strings.php b/include/js_strings.php
index 14293c5ce..56ffa9536 100644
--- a/include/js_strings.php
+++ b/include/js_strings.php
@@ -19,6 +19,7 @@ function js_strings() {
'$rating_desc' => t('Rate This Channel (this is public)'),
'$rating_val' => t('Rating'),
'$rating_text' => t('Describe (optional)'),
+ '$submit' => t('Submit'),
'$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : ''),
'$t02' => ((t('timeago.prefixFromNow') != 'timeago.prefixFromNow') ? t('timeago.prefixFromNow') : ''),
diff --git a/mod/prate.php b/mod/prate.php
index 62f188891..b89d16f42 100644
--- a/mod/prate.php
+++ b/mod/prate.php
@@ -1,5 +1,26 @@
<?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) {
@@ -63,7 +84,7 @@ function prate_post(&$a) {
proc_run('php','include/ratenotif.php','rating',$record);
}
- return;
+ json_return_and_die(array('result' => true));;
}
@@ -75,3 +96,4 @@ function prate_post(&$a) {
+
diff --git a/view/css/mod_directory.css b/view/css/mod_directory.css
index d4cf23b39..c562764ea 100644
--- a/view/css/mod_directory.css
+++ b/view/css/mod_directory.css
@@ -15,7 +15,7 @@
padding: 15px;
}
-.rating-text {
+.rating-text-label {
margin-top: 30px;
}
diff --git a/view/css/mod_events.css b/view/css/mod_events.css
index 0aef13aa6..ba4ec9b61 100644
--- a/view/css/mod_events.css
+++ b/view/css/mod_events.css
@@ -10,8 +10,3 @@
margin-top: 15px;
width: 400px;
}
-
-.required {
- color: #ff0000;
- font-size: 1.2rem;
-} \ No newline at end of file
diff --git a/view/js/mod_directory.js b/view/js/mod_directory.js
index 09b103352..87e4f92b5 100644
--- a/view/js/mod_directory.js
+++ b/view/js/mod_directory.js
@@ -6,14 +6,38 @@ function dirdetails(hash) {
}
+var ratingVal = 0;
+var ratingText = '';
+var currentHash = '';
+
+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);
+}
- 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>';
+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() {
collapseHeight();
diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css
index cebc516da..cb58b6e11 100644
--- a/view/theme/redbasic/css/style.css
+++ b/view/theme/redbasic/css/style.css
@@ -1185,9 +1185,12 @@ nav .acpopup {
.required {
- color: #FF0000;
+ color: #ff0000;
+ font-size: 1.8rem;
+ margin-left: 5px;
}
+
#event-start-text, #event-finish-text {
margin-top: 10px;
margin-bottom: 5px;
diff --git a/view/tpl/direntry.tpl b/view/tpl/direntry.tpl
index 1b84bca56..b0a1084e8 100755
--- a/view/tpl/direntry.tpl
+++ b/view/tpl/direntry.tpl
@@ -17,7 +17,7 @@
{{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}}
-{{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>
{{/if}}
{{if $entry.public_forum}}
diff --git a/view/tpl/js_strings.tpl b/view/tpl/js_strings.tpl
index 9cfd84cf8..4eb9ae844 100755
--- a/view/tpl/js_strings.tpl
+++ b/view/tpl/js_strings.tpl
@@ -19,6 +19,7 @@
'rating_desc' : "{{$rating_desc}}",
'rating_val' : "{{$rating_val}}",
'rating_text' : "{{$rating_text}}",
+ 'submit' : "{{$submit}}",
't01' : "{{$t01}}",
't02' : "{{$t02}}",