diff options
author | prashantsinalkar | 2016-09-01 14:39:48 +0530 |
---|---|---|
committer | prashantsinalkar | 2016-09-01 14:39:48 +0530 |
commit | 090b633219c93987626ad08d37011403b056b8cf (patch) | |
tree | ba53b9517465e346d1362fdc118cc26ff1bcc998 | |
parent | 30d8c7d1272e0c0cb6c20fddf69af42dd4a706f4 (diff) | |
download | textbook_companion_fixer-090b633219c93987626ad08d37011403b056b8cf.tar.gz textbook_companion_fixer-090b633219c93987626ad08d37011403b056b8cf.tar.bz2 textbook_companion_fixer-090b633219c93987626ad08d37011403b056b8cf.zip |
added renamed files
-rwxr-xr-x | css/textbook_companion_fixer.css | 47 | ||||
-rwxr-xr-x | js/textbook_companion_fixer.js | 202 |
2 files changed, 249 insertions, 0 deletions
diff --git a/css/textbook_companion_fixer.css b/css/textbook_companion_fixer.css new file mode 100755 index 0000000..5634290 --- /dev/null +++ b/css/textbook_companion_fixer.css @@ -0,0 +1,47 @@ +#fix-tbc-form #edit-caption { + width: 99% !important; +} +#fix-tbc-form .well { + margin-top: 25px; + width: 620px; + overflow-x: auto; +} +#fix-tbc-form #edit-example { + height: 250px; +} +#fix-tbc-page #updating, +#fix-tbc-page #done { + display: none; + position: fixed; + z-index: 2000; + left: 55%; + top: 45%; + padding: 5px 10px; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + -o-border-radius: 5px; + border-radius: 5px; + -webkit-box-shadow: 0px 0px 10px #cccccc; + -moz-box-shadow: 0px 0px 10px #cccccc; + -obox-shadow: 0px 0px 10px #cccccc; + box-shadow: 0px 0px 10px #cccccc; +} +#fix-tbc-page #updating { + background: #FF851B; +} +#fix-tbc-page #done { + background: #2ECC40; +} +textarea#edit-code { + height: 300px; + width: 650px; +} +.orange { + background: #FF9933 !important; +} +.sync-msg { + font-size: .8em; +} +.messages.success { + background: lightgreen; +} diff --git a/js/textbook_companion_fixer.js b/js/textbook_companion_fixer.js new file mode 100755 index 0000000..7a7e3fe --- /dev/null +++ b/js/textbook_companion_fixer.js @@ -0,0 +1,202 @@ +(function ($) { +$(document).ready(function() { + var basePath = Drupal.settings.basePath; + var modPath = basePath + "fix/"; + var modPath1 = basePath + "fix/aicte/book/"; + + + + $category = $("#fix-tbc-form #edit-category"); + $book = $("#fix-tbc-form #edit-book"); + $chapter = $("#fix-tbc-form #edit-chapter"); + $example = $("#fix-tbc-form #edit-example"); + $caption = $("#fix-tbc-form #edit-caption"); + $code = $("#fix-tbc-form #edit-code"); + $caption_form = $("#scilab-fixer-caption-form"); + $code_form = $("#scilab-fixer-code-form"); + $updating = $("#fix-tbc-page #updating"); + $done = $("#fix-tbc-page #done"); + $example.attr("multiple", "enabled"); + + function reset() { + for (var i = 0, l = arguments.length; i < l; i ++) { + switch(arguments[i]) { + case "book": + $book.html("<option value='0'>Please select a book</option>"); + break; + + case "chapter": + $chapter.html("<option value='0'>Please select a chapter</option>"); + break; + + case "example": + $example.html("<option value='0'>Please select a example</option>"); + break; + + case "caption": + $caption.val(""); + break; + + } + } + } + + $category.change(function() { + reset("book", "chapter", "example", "caption"); + var category_id = $(this).val(); + + $.ajax({ + url: modPath + "ajax/category/" + category_id, + type: "POST", + dataType: "html", + success: function(data) { + $book.html(data); + } + }); + }); + + $book.change(function() { + reset("chapter", "example", "caption"); + var book_id = $(this).val(); + + $.ajax({ + url: modPath + "ajax/book/" + book_id, + type: "POST", + dataType: "html", + success: function(data) { + $chapter.html(data); + } + }); + }); + + $chapter.change(function() { + reset("example", "caption"); + var chapter_id = $(this).val(); + + $.ajax({ + url: modPath + "ajax/chapter/" + chapter_id, + type: "POST", + dataType: "html", + success: function(data) { + $example.html(data); + } + }); + }); + + $example.change(function() { + var example_id = $(this).val(); + reset("caption"); + console.log("########" + example_id); + $.ajax({ + url: modPath + "ajax/example/" + example_id, + type: "POST", + dataType: "html", + success: function(data) { + var code = $(data).filter("#code").html(); + /* checking whether it is for .well or textarea */ + if($code.hasClass("fix-caption-code")) { + $code.html(code); + } else { + $code.val(code); + } + var caption = $(data).filter("#caption").html(); + try { + $caption.val(caption); + } catch(e) { + return; + } + } + }); + }); + + $caption_form.submit(function(e) { + var example_id = $example.val(); + if(example_id != "0") { + var caption = $caption.val(); + $updating.show(); + $.ajax({ + url: modPath + "ajax/update/", + type: "POST", + data: { + example_id: example_id, + caption: caption + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No example selected.") + } + e.preventDefault(); + }); + + $code_form.submit(function(e) { + var example_id = $example.val(); + if(example_id != "0") { + var code = $code.val(); + $.ajax({ + url: modPath + "ajax/code/" + example_id, + type: "POST", + data: { + code: code + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No example selected.") + } + e.preventDefault(); + }); + +$Selected = $(".selected"); + $Selected.click(function (e) { + $(".sync-msg").remove(); + $(this).after("<span class='sync-msg'>Saving...</span>"); + $.ajax({ + url: modPath1 + "ajax/selected/" + $(this).attr("data-bid"), + success: function() { + $(".sync-msg").remove(); + console.log ("success"); + } + }); + + }); + + /* toggle in edition */ + $ind_ed = $(".ind-ed"); + + $ind_ed.click(function(e) { + var aicte_id = $(this).attr("data-aicte"); + $t = $(this); + $.ajax({ + url: modPath + "ajax/ind-ed/" + aicte_id, + type: "GET", + dataType: "html", + success: function(data) { + $tr = $t.parents("tr:first"); + if($tr.hasClass("orange")) { + $t.parents("tr:first").removeClass("orange"); + $t.html("Mark"); + } else { + $t.parents("tr:first").addClass("orange"); + $t.html("Unmark"); + } + console.log(data); + }, + }); + e.preventDefault(); + }); + +}); +})(jQuery); |