summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJayaram Pai2014-03-28 11:46:40 +0530
committerJayaram Pai2014-03-28 11:46:40 +0530
commit303993f4c18af271841737c4cf5f9c985379f168 (patch)
tree36ab5ddc5ad6de30f2cd4f3bcca99160d1e9a67d /js
parent0b14019f05f0160cd5ab89ae49ef6a04c3b32a7b (diff)
downloadtbc-external-review-303993f4c18af271841737c4cf5f9c985379f168.tar.gz
tbc-external-review-303993f4c18af271841737c4cf5f9c985379f168.tar.bz2
tbc-external-review-303993f4c18af271841737c4cf5f9c985379f168.zip
fixed missed chapter bugs, permalink changes
Diffstat (limited to 'js')
-rwxr-xr-xjs/tbc_external_review.js28
1 files changed, 26 insertions, 2 deletions
diff --git a/js/tbc_external_review.js b/js/tbc_external_review.js
index 14bc100..2533b17 100755
--- a/js/tbc_external_review.js
+++ b/js/tbc_external_review.js
@@ -1,3 +1,16 @@
+// Javascript format string
+// First, checks if it isn't implemented yet.
+if (!String.prototype.format) {
+ String.prototype.format = function() {
+ var args = arguments;
+ return this.replace(/{(\d+)}/g, function(match, number) {
+ return typeof args[number] != 'undefined'
+ ? args[number]
+ : match
+ ;
+ });
+ };
+}
$(document).ready(function() {
var basePath = Drupal.settings.basePath;
@@ -122,25 +135,36 @@ $(document).ready(function() {
$jq("#edit-missing-0").click(function() {
$more.hide();
$missed.hide();
+ $jq("div").filter(function() {
+ return this.id.match(/missed-list-.*/);
+ }).hide();
});
$jq("#edit-missing-1").click(function() {
$more.show();
$missed.show();
+ $jq("div").filter(function() {
+ return this.id.match(/missed-list-.*/);
+ }).show();
});
+
/* review complete form */
$more.click(function(e) {
$dupe = $missed.clone();
+ $dupe.attr("id", "missed-list-" + count);
$dupe.find("select[name='missed_chapter']").attr("id", "missed_chapter_" + count);
$dupe.find("select[name='missed_chapter']").attr("name", "missed_chapters[]");
$dupe.find("select[name='missed_example']").attr("id", "missed_example_" + count);
$dupe.find("select[name='missed_example']").attr("name", "missed_examples[]");
$dupe.insertBefore($more);
- $dupe.append("<a href='#' class='delete-missed'>Delete</a>");
+ $dupe.append("<a href='#' class='delete-missed' data-target='{0}'>Delete</a>".format(count));
+ count++;
e.preventDefault();
});
$jq("#review-completion-form").on("click", ".delete-missed", function(e) {
- $jq(this).closest("#missed-list").remove();
+ var target = $jq(this).data("target");
+ $("#review-completion-form #missed-list-" + target).remove();
+ count--;
e.preventDefault();
});