source: main/trunk/greenstone3/web/interfaces/default_new/js/format_document.js@ 29852

Last change on this file since 29852 was 29852, checked in by Georgiy Litvinov, 9 years ago

Ckeditor integration commit

File size: 3.2 KB
Line 
1
2console.log("Loading format_document.js\n");
3
4$(document).ready(function(){
5
6 $('.sectionHeader').click(function () {
7 console.log('section Header click *');
8 getXSLT("sectionHeader");
9 return false; //don't event bubble
10 });
11
12 $('.sectionContainer').click(function () {
13 console.log('section Container click *');
14 getXSLT("sectionContainer");
15 return false; // don't event bubble
16 });
17 });
18
19/* DOCUMENT SPECIFIC FUNCTIONS */
20
21function displayTOC(checkbox)
22{
23 if (checkbox.checked == true)
24 {
25 console.log("Show the TOC!");
26 displaySideBar(true);
27 $("#tableOfContents").css("display", "block");
28 }
29 else
30 {
31 console.log("Hide the TOC!");
32 $("#tableOfContents").css("display", "none");
33 if ($("#coverImage").css("display") == "none")
34 displaySideBar(false);
35 }
36
37 return;
38}
39
40function displayBookCover(checkbox)
41{
42 if (checkbox.checked == true)
43 {
44 console.log("Show the book cover!");
45 displaySideBar(true);
46 $("#coverImage").css("display", "block");
47 }
48 else
49 {
50 console.log("Hide the book cover!");
51 $("#coverImage").css("display", "none");
52 if ($("#tableOfContents").css("display") == "none")
53 displaySideBar(false);
54 }
55
56 return;
57}
58
59function displaySideBar(toggle)
60{
61 if (toggle == true)
62 {
63 console.log("Show the sidebar!");
64 $("#rightSidebar").css("display", "block");
65 }
66 else
67 {
68 console.log("Hide the sidebar!");
69 $("#rightSidebar").css("display", "none");
70 }
71
72 return;
73}
74
75function checkDocumentRadio()
76{
77 var selection = $('input[name="documentChanges"]'); //document.quiz.colour;
78
79 for (i=0; i<selection.length; i++)
80
81 if (selection[i].checked == true)
82 return selection[i].value;
83
84 return "this";
85}
86
87function saveDocumentChanges()
88{
89 console.log("Saving changes to "+checkDocumentRadio());
90 console.log("TOC="+$('input[name="TOC"]').attr('checked'));
91 console.log("Cover Image="+$('input[name="bookCover"]').attr('checked'));
92
93 var myurl = document.URL;
94
95 //var collection_name = getSubstring(myurl, "&c", "&");
96 var document_id = getSubstring(myurl, "&d", "&");
97 var document_type = getSubstring(myurl, "&dt", "&");
98 var prev_action = getSubstring(myurl, "&p.a", "&");
99 var prev_service = getSubstring(myurl, "&p.s", "&");
100
101 //var post_url = "http://localhost:8383/greenstone3/dev?a=f&sa=saveDocument&c=" + collection_name + "&d=" + document_id + "&dt=" + document_type + "&p.a=" + prev_action + "&p.s=" + prev_service;
102 var post_url = host_info.pre_URL + "?a=f&sa=saveDocument&c=" + host_info.collection_name + "&d=" + document_id + "&dt=" + document_type + "&p.a=" + prev_action + "&p.s=" + prev_service;
103
104 // XML will be automatically wrapped in <display><format> tags when saved to collection config
105 var xml = '<format><gsf:option name="TOC" value="'+$('input[name="TOC"]').attr('checked')+'"/><gsf:option name="coverImage" value="'+$('input[name="bookCover"]').attr('checked')+'"/></format>';
106
107 $.post(post_url, {data: xml}, function(data) {
108 console.log("Success, we have received data");
109 }, 'xml');
110}
111
Note: See TracBrowser for help on using the repository browser.