Index: lams_tool_larsrc/web/includes/javascript/rsrcresourceitem.js
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -raa971e902329c8ae01eae531db29bbc1a595f4ff
--- lams_tool_larsrc/web/includes/javascript/rsrcresourceitem.js (.../rsrcresourceitem.js) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_tool_larsrc/web/includes/javascript/rsrcresourceitem.js (.../rsrcresourceitem.js) (revision aa971e902329c8ae01eae531db29bbc1a595f4ff)
@@ -1,26 +1,8 @@
/*
This is Resource Item instruction area.
*/
- var instructionTargetDiv = "instructionArea";
var itemAttachmentTargetDiv = "itemAttachmentArea";
- var singleInstructionHeight = 74;
- function removeInstruction(idx){
- //prepare lams_textarea value to Ajax submit
- $('textarea').trigger('change');
-
- var param = $("#instructionForm").serialize() + "&removeIdx="+idx;
- removeInstructionLoading();
- $.post(
- removeInstructionUrl,
- param,
- function(xml) {
- removeInstructionComplete();
- document.getElementById("instructionArea").innerHTML = xml;
- }
- );
- }
-
function removeItemAttachment(idx){
removeItemAttachmentLoading();
$("#" + itemAttachmentTargetDiv).load(
@@ -32,73 +14,20 @@
);
}
- function addInstruction(){
- //prepare lams_textarea value to Ajax submit
- $('textarea').trigger('change');
-
- var param = $("#instructionForm").serialize();
- disableButtons();
- addInstructionLoading();
-
- $.post(
- addInstructionUrl,
- param,
- function(xml) {
- $('#instructionArea').html(xml);
- enableButtons();
- }
- );
-
- return false;
- }
-
- function upItem(itemIdx){
- //prepare lams_textarea value to Ajax submit
- $('textarea').trigger('change');
-
- if(itemIdx == 0)
- return;
- var currId = "instructionItemDesc" + itemIdx;
- var repId = "instructionItemDesc" + (--itemIdx);
- switchValue(currId,repId);
- }
- function downItem(itemIdx,maxSize){
- //prepare lams_textarea value to Ajax submit
- $('textarea').trigger('change');
-
- if(itemIdx == (maxSize -1))
- return;
- var currId = "instructionItemDesc" + itemIdx;
- var repId = "instructionItemDesc" + (++itemIdx);
- switchValue(currId,repId);
- }
- function switchValue(currId,repId){
- var temp = document.getElementById(repId).value;
- document.getElementById(repId).value = document.getElementById(currId).value;
- document.getElementById(currId).value = temp;
- }
- function removeInstructionLoading(){
- showBusy(instructionTargetDiv);
- }
- function removeInstructionComplete(){
- hideBusy(instructionTargetDiv);
- }
function removeItemAttachmentLoading(){
showBusy(itemAttachmentTargetDiv);
}
function removeItemAttachmentComplete(){
hideBusy(itemAttachmentTargetDiv);
}
- function addInstructionLoading(){
- showBusy(instructionTargetDiv);
- }
- function addInstructionComplete(){
- hideBusy(instructionTargetDiv);
- }
function submitResourceItem(){
- //prepare lams_textarea value to Ajax submit and add instructions to form
- $('textarea').trigger('change');
+ //copy value from CKEditor to textarea before ajax submit
+ $("textarea[id^='instructions']").each(function() {
+ var ckeditorData = CKEDITOR.instances[this.name].getData();
+ //skip out empty values
+ this.value = ((ckeditorData == null) || (ckeditorData.replace(/ | |
|\s|
|<\/p>|\xa0/g, "").length == 0)) ? "" : ckeditorData; + }); // validation will fail with spaces var urlField = document.getElementById("url"); @@ -109,10 +38,8 @@ if ( ! $("#resourceItemForm").valid() ) return false; - document.getElementById("instructionList").value = $("#instructionForm").serialize(); var formData = new FormData(document.getElementById("resourceItemForm")); disableButtons(); - showBusy(instructionTargetDiv); // after submit, it direct to itemlist.jsp, // then refresh "basic tab" resource list and close this window. $.ajax({ // create an AJAX call...