http://atutor.ca/atutor/mantis/view.php?id=4654
authorcindy li <cli@ocad.ca>
Fri, 10 Dec 2010 16:03:00 +0000 (16:03 -0000)
committercindy li <cli@ocad.ca>
Fri, 10 Dec 2010 16:03:00 +0000 (16:03 -0000)
Added formatting option "html with text area" back onto "edit content" page.

docs/mods/_core/editor/edit_content.php
docs/mods/_core/editor/editor_tabs/edit.inc.php
docs/mods/_core/editor/js/edit.js

index 767ff0e..656b56b 100644 (file)
@@ -161,10 +161,12 @@ if ($cid) {
 if (($current_tab == 0) || ($_current_tab == 3)) {
     if ($_POST['formatting'] == null){ 
         // this is a fresh load from just logged in
-           if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 0) {
+           if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 0) { // plain text in text area
                        $_POST['formatting'] = 0;
-               } else {
+               } else if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 1) { // html with text area
                        $_POST['formatting'] = 1;
+           } else if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 2) { // html with visual editor
+                       $_POST['formatting'] = 3;
                }
     }
 }
index e77e236..6760f4d 100644 (file)
@@ -37,6 +37,9 @@ if (!defined('AT_INCLUDE_PATH')) { exit; }
             <input type="radio" name="formatting" value="1" id="html" <?php if ($_POST['formatting'] == 1) { echo 'checked="checked"'; } ?> />\r
             <label for="html"><?php echo _AT('html'); ?></label>\r
        \r
+            <input type="radio" name="formatting" value="3" id="html_visual_editor" <?php if ($_POST['formatting'] == 3) { echo 'checked="checked"'; } ?> />\r
+            <label for="html"><?php echo _AT('html') . ' - '. _AT('visual_editor'); ?></label>\r
+       \r
             <input type="radio" name="formatting" value="2" id="weblink" <?php if ($_POST['formatting'] == 2) { echo 'checked="checked"'; } ?> />\r
             <label for="weblink"><?php echo _AT('weblink'); ?></label>\r
        </span>\r
index 535c1ba..c3a3a6d 100644 (file)
@@ -23,6 +23,7 @@ ATutor.mods.editor = ATutor.mods.editor || {};
 (function () {\r
     var hiddenClass = "hidden";\r
     var enabledClass = "clickable";\r
+    var textAreaId = "body_text";\r
     \r
     var hideIt = function (theElement, hiddenElement) {\r
         theElement.addClass(hiddenClass);\r
@@ -45,11 +46,19 @@ ATutor.mods.editor = ATutor.mods.editor || {};
 \r
     //click function to launch accessibility validation window\r
     var launchAChecker = function () {\r
+       var body_content;\r
+       \r
+       if (jQuery("#html_visual_editor").attr("checked")) {\r
+               body_content = tinyMCE.activeEditor.getContent();\r
+       } else {\r
+               body_content = jQuery("#"+textAreaId).val();\r
+       }\r
+       \r
        var theCode = '<html><body onLoad="document.accessform.submit();"> \n';\r
                theCode += '<h1>'+ATutor.mods.editor.processing_text+' .....</h1>\n';\r
                theCode += '<form action="'+ATutor.base_href+'mods/_core/editor/accessibility.php?popup=1" name="accessform" method="post"> \n';\r
                theCode += '<input type="hidden" name="cid" value="'+jQuery("input[name=cid]").val()+'" /> \n';\r
-               theCode += '<textarea name="body_text" style="display:none">' + tinyMCE.activeEditor.getContent() + '</textarea>\n';\r
+               theCode += '<textarea name="body_text" style="display:none">' + body_content + '</textarea>\n';\r
                theCode += '<input type="submit" style="display:none" /></form> \n';  \r
                theCode += '</body></html> \n';\r
                accessWin = window.open('', 'accessibilityWin',  'menubar=0,scrollbars=1,resizable=1,width=600,height=600');\r
@@ -147,7 +156,14 @@ ATutor.mods.editor = ATutor.mods.editor || {};
         var displaypaste = jQuery(displaypasteId);\r
         var textArea = jQuery("#textSpan");\r
         var weblink = jQuery("#weblinkSpan");\r
-        var textAreaId = "body_text";\r
+        \r
+        // turn on/off visual editor based on the selected formatting tool\r
+        if (jQuery("#html_visual_editor").attr("checked") && !tinyMCE.get(textAreaId)) {\r
+                       tinyMCE.execCommand('mceAddControl', false, textAreaId);\r
+        } else if (tinyMCE.get(textAreaId)) {\r
+               tinyMCE.execCommand('mceRemoveControl', false, textAreaId);\r
+        }\r
+        \r
         if (jQuery("#weblink").attr("checked")) {\r
             disableTool(accessibilityTool);\r
             disableTool(headTool);\r
@@ -156,12 +172,9 @@ ATutor.mods.editor = ATutor.mods.editor || {};
             \r
             hideIt(head, displayhead);\r
             hideIt(paste, displaypaste);\r
-            if (tinyMCE.get(textAreaId)) {\r
-               tinyMCE.execCommand('mceRemoveControl', false, textAreaId);\r
-            }\r
             textArea.hide();\r
             weblink.show();\r
-        } else if (jQuery("#html").attr("checked")) {\r
+        } else if (jQuery("#html").attr("checked") || jQuery("#html_visual_editor").attr("checked")) {\r
             enableTool(accessibilityTool);\r
             enableTool(headTool);\r
             enableTool(pasteTool);\r
@@ -169,9 +182,6 @@ ATutor.mods.editor = ATutor.mods.editor || {};
             \r
             setDisplay(head, displayhead);\r
             setDisplay(paste, displaypaste);\r
-            if (ATutor.mods.editor.editor_pref !== '1' && !tinyMCE.get(textAreaId)) {\r
-                       tinyMCE.execCommand('mceAddControl', false, textAreaId);\r
-            }\r
             weblink.hide();\r
             textArea.show();\r
         } else {\r
@@ -183,9 +193,6 @@ ATutor.mods.editor = ATutor.mods.editor || {};
             hideIt(head, displayhead);\r
             setDisplay(paste, displaypaste);\r
             weblink.hide();\r
-            if (tinyMCE.get(textAreaId)) {\r
-               tinyMCE.execCommand('mceRemoveControl', false, textAreaId);\r
-            }\r
             textArea.show();\r
         }      \r
     };\r
@@ -203,10 +210,10 @@ ATutor.mods.editor = ATutor.mods.editor || {};
        });\r
         if (jQuery("#weblink").attr("checked")) {\r
                theCode += '<input type="hidden" name="weblink_text" value="'+jQuery("#weblink_text").val()+'" /> \n';\r
-        } else if (jQuery("#html").attr("checked")) {\r
+        } else if (jQuery("#html_visual_editor").attr("checked")) {\r
                theCode += '<textarea name="body_text" style="display:none">' + tinyMCE.activeEditor.getContent() + '</textarea>\n';\r
         } else {\r
-               theCode += '<textarea name="body_text" style="display:none">' + jQuery("#body_text").val() + '</textarea>\n';\r
+               theCode += '<textarea name="body_text" style="display:none">' + jQuery("#"+textAreaId).val() + '</textarea>\n';\r
         }\r
                theCode += '<input type="submit" style="display:none" /></form> \n';  \r
                theCode += '</body></html> \n';\r