From 430133242f89015f4ffc500fb34eedf2324ec3a1 Mon Sep 17 00:00:00 2001 From: Jayaram Pai Date: Sat, 26 Apr 2014 14:54:09 +0530 Subject: initial commit --- css/scilab_fixer.css | 29 +++++++++ js/scilab_fixer.js | 117 ++++++++++++++++++++++++++++++++++++ scilab_fixer.info | 3 + scilab_fixer.module | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 315 insertions(+) create mode 100644 css/scilab_fixer.css create mode 100644 js/scilab_fixer.js create mode 100755 scilab_fixer.info create mode 100755 scilab_fixer.module diff --git a/css/scilab_fixer.css b/css/scilab_fixer.css new file mode 100644 index 0000000..c001482 --- /dev/null +++ b/css/scilab_fixer.css @@ -0,0 +1,29 @@ +#fix-caption-form #edit-caption { + width: 99% !important; +} +#fix-caption-form .well { + margin-top: 25px; +} +#fix-caption-page #updating, +#fix-caption-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-caption-page #updating { + background: #FF851B; +} +#fix-caption-page #done { + background: #2ECC40; +} diff --git a/js/scilab_fixer.js b/js/scilab_fixer.js new file mode 100644 index 0000000..43450f3 --- /dev/null +++ b/js/scilab_fixer.js @@ -0,0 +1,117 @@ +$(document).ready(function() { + var basePath = Drupal.settings.basePath; + var modPath = basePath + "fix/"; + + $category = $("#fix-caption-form #edit-category"); + $book = $("#fix-caption-form #edit-book"); + $chapter = $("#fix-caption-form #edit-chapter"); + $example = $("#fix-caption-form #edit-example"); + $caption = $("#fix-caption-form #edit-caption"); + $code = $("#fix-caption-form #fix-caption-code"); + $form = $("#scilab-fixer-caption-form"); + $updating = $("#fix-caption-page #updating"); + $done = $("#fix-caption-page #done"); + + function reset() { + for (var i = 0, l = arguments.length; i < l; i ++) { + switch(arguments[i]) { + case "book": + $book.html(""); + break; + + case "chapter": + $chapter.html(""); + break; + + case "example": + $example.html(""); + break; + + } + } + } + + $category.change(function() { + reset("book", "chapter", "example"); + 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"); + 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"); + 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(); + + $.ajax({ + url: modPath + "ajax/example/" + example_id, + type: "POST", + dataType: "html", + success: function(data) { + var code = $(data).filter("#code").html(); + $code.html(code); + var caption = $(data).filter("#caption").html(); + $caption.val(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(); + }); +}); diff --git a/scilab_fixer.info b/scilab_fixer.info new file mode 100755 index 0000000..b8707ea --- /dev/null +++ b/scilab_fixer.info @@ -0,0 +1,3 @@ +name = Scilab fixer +description = Module to fix scilab bugs +core = 6.x diff --git a/scilab_fixer.module b/scilab_fixer.module new file mode 100755 index 0000000..4cfd892 --- /dev/null +++ b/scilab_fixer.module @@ -0,0 +1,166 @@ + "Fix TBC captions", + "page callback" => "scilab_fixer_caption_all", + "access arguments" => array("fix scilab"), + "type" => MENU_NORMAL_ITEM + ); + $items["fix/ajax"] = array( + "page callback" => "scilab_fixer_ajax", + "access callback" => TRUE, + "type" => MENU_CALLBACK + ); + return $items; + } + + function scilab_fixer_perm() { + return array( + "fix scilab", + ); + } + + function scilab_fixer_caption_form($form_state) { + $form = array(); + $form["wrapper"] = array( + "#type" => "fieldset", + "#title"=> "Caption change form", + "#prefix" => "
", + "#suffix" => "