diff options
-rw-r--r-- | css/tbc_external_review.css | 3 | ||||
-rw-r--r-- | js/tbc_external_review.js | 26 | ||||
-rw-r--r-- | tbc_external_review.module | 37 |
3 files changed, 62 insertions, 4 deletions
diff --git a/css/tbc_external_review.css b/css/tbc_external_review.css index 3cbda22..e5dfa99 100644 --- a/css/tbc_external_review.css +++ b/css/tbc_external_review.css @@ -28,3 +28,6 @@ .error-comment { background: tomato !important; } +.dull { + background: #424242 !important; +} diff --git a/js/tbc_external_review.js b/js/tbc_external_review.js index 99b08b9..8ec72a3 100644 --- a/js/tbc_external_review.js +++ b/js/tbc_external_review.js @@ -2,6 +2,7 @@ $(document).ready(function() { var basePath = Drupal.settings.basePath; var modPath = basePath + "tbc_external_review/"; + /* for "tbc_external_review/comments" page */ $book = $("#edit-book"); $chapter = $("#edit-chapter"); @@ -62,6 +63,31 @@ $(document).ready(function() { e.preventDefault(); }); + /* hide/unhide comments */ + $hide_show= $(".hide-show"); + + $hide_show.click(function(e) { + var comment_id = $(this).attr("data-comment"); + $t = $(this); + $.ajax({ + url: modPath + "ajax/hide-show/" + comment_id, + type: "GET", + dataType: "html", + success: function(data) { + $tr = $t.parents("tr:first"); + if($tr.hasClass("dull")) { + $t.parents("tr:first").removeClass("dull"); + $t.html("Hide"); + } else { + $t.parents("tr:first").addClass("dull"); + $t.html("Show"); + } + console.log(data); + }, + }); + e.preventDefault(); + }); + $(document).ajaxStart(function() { $ajax_loader.show(); }); diff --git a/tbc_external_review.module b/tbc_external_review.module index 1c1c83b..8f89ac9 100644 --- a/tbc_external_review.module +++ b/tbc_external_review.module @@ -681,7 +681,7 @@ while($row = db_fetch_object($result)) { $data .= "<option value='{$row->id}'>{$row->number} {$row->caption}</option>"; } - } else if($item = "comment" && $key) { + } else if($item == "comment" && $key) { $query = " SELECT * FROM external_review_comments erc LEFT JOIN textbook_companion_example_files tcef @@ -711,6 +711,14 @@ $data .= "</table>"; $data .= "<textarea style='width:100%; height:200px; background:#fafafa' readonly>"; $data .= "{$example}</textarea>"; + } else if($item == "hide-show" && $key) { + $query = " + UPDATE external_review_comments + SET hidden = !hidden + WHERE id = %d + "; + $result = db_query($query, $key); + $data .= $key; } echo $data; exit(); @@ -819,7 +827,7 @@ LEFT JOIN textbook_companion_chapter cha ON cha.id = erc.chapter_id LEFT JOIN textbook_companion_example exa ON exa.id = erc.example_id WHERE erc.preference_id = %d - ORDER BY erc.time DESC + ORDER BY erc.chapter_id, erc.example_id "; $result = db_query($query, $preference_id); $headers = array( @@ -828,7 +836,7 @@ ); $rows = array(); while($row = db_fetch_object($result)) { - $options = array( + $view_options = array( /* # linking in drupal l() */ "fragment" => " ", "external" => TRUE, @@ -837,6 +845,15 @@ "data-comment" => "{$row->id}", ) ); + $hide_options= array( + /* # linking in drupal l() */ + "fragment" => " ", + "external" => TRUE, + "attributes" => array( + "class" => "hide-show", + "data-comment" => "{$row->id}", + ) + ); /* scoring comments */ $score = 0; @@ -857,13 +874,24 @@ "{$row->example}", "{$row->time}", "{$score}", - l("View", "", $options), + l("View", "", $view_options), ), ); if($row->sfu == 1 || $row->sum == 0 || $row->amt == 1) { $error_class = array("class" => "error-comment"); $item = array_merge($item, $error_class); } + if($row->hidden) { + $item["class"] .= " dull"; + } + /* hide/unhide link */ + end($item["data"]); + $key= key($item["data"]); + if($row->hidden) { + $item["data"][$key] .= " | " . l("Show", "", $hide_options); + } else { + $item["data"][$key] .= " | " . l("Hide", "", $hide_options); + } array_push($rows, $item); } $page_content .= theme("table", $headers, $rows); @@ -1047,6 +1075,7 @@ function tbc_external_review_test_all() { global $user; $page_content = ""; + /* sending mail */ $to = "rush2jrp@gmail.com"; $from = "jayaram@iitb.ac.in"; |