-switch to visual editor (autoload tinymce so when visual editor button
authorharris wong <hwong@ocad.ca>
Tue, 3 Aug 2010 21:06:55 +0000 (21:06 -0000)
committerharris wong <hwong@ocad.ca>
Tue, 3 Aug 2010 21:06:55 +0000 (21:06 -0000)
is clicked, the page does not reload, like the ATutor content editor)

mods/job_board/admin/edit_post.php
mods/job_board/employer/add_new_post.php
mods/job_board/employer/edit_post.php
mods/job_board/include/html/admin/jb_edit_post.tmpl.php
mods/job_board/include/html/employer/jb_add_new_post.tmpl.php
mods/job_board/include/html/employer/jb_edit_post.tmpl.php
mods/job_board/include/html/jb_view_post.tmpl.php
mods/job_board/include/js/edit.js [new file with mode: 0644]

index 5358659..85cb73f 100644 (file)
 
 define(AT_INCLUDE_PATH, '../../../include/');
 include(AT_INCLUDE_PATH.'vitals.inc.php');
+admin_authenticate(AT_ADMIN_PRIV_JOB_BOARD);
+
 include(AT_JB_INCLUDE.'classes/Job.class.php');
 require(AT_INCLUDE_PATH.'lib/tinymce.inc.php');
 $_custom_css = $_base_path . AT_JB_BASENAME . 'module.css'; // use a custom stylesheet
-
-admin_authenticate(AT_ADMIN_PRIV_JOB_BOARD);
+$_custom_head .= '
+    <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-layout.css" />
+    <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-text.css" />
+    <script type="text/javascript" src="'.$_base_path.'mods/job_board/include/js/edit.js"></script>
+    ';
 
 /* 
  * Add the submenu on this page so that user can go back to the listing.
index 5319706..622a83f 100644 (file)
@@ -18,6 +18,11 @@ include(AT_JB_INCLUDE.'classes/Job.class.php');
 include(AT_JB_INCLUDE.'classes/Employer.class.php');
 require(AT_INCLUDE_PATH.'lib/tinymce.inc.php');
 $_custom_css = $_base_path . AT_JB_BASENAME . 'module.css'; // use a custom stylesheet
+$_custom_head .= '
+    <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-layout.css" />
+    <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-text.css" />
+    <script type="text/javascript" src="'.$_base_path.'mods/job_board/include/js/edit.js"></script>
+    ';
 
 if (!Employer::authenticate()){
        $msg->addError('ACCESS_DENIED');
index 4d722cc..437b958 100644 (file)
@@ -18,6 +18,11 @@ include(AT_JB_INCLUDE.'classes/Job.class.php');
 include(AT_JB_INCLUDE.'classes/Employer.class.php');
 require(AT_INCLUDE_PATH.'lib/tinymce.inc.php');
 $_custom_css = $_base_path . AT_JB_BASENAME . 'module.css'; // use a custom stylesheet
+$_custom_head .= '
+    <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-layout.css" />
+    <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-text.css" />
+    <script type="text/javascript" src="'.$_base_path.'mods/job_board/include/js/edit.js"></script>
+    ';
 
 if (!Employer::authenticate()){
        $msg->addError('ACCESS_DENIED');
index be68375..91735d8 100644 (file)
@@ -1,7 +1,9 @@
-<?php 
-if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']) {
-       load_editor();
+<?php
+$simple = true;
+if ($_POST['complexeditor'] == '1') {
+       $simple = false;
 }
+load_editor($simple, false, "none");
 ?>
 <div class="input-form">
        <form action="" method="post" name="form">
@@ -52,23 +54,16 @@ if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']) {
                        ?>
                </div>
                <div class="row">
-                       <?php echo _AT('formatting'); ?><br />
-                       <input type="radio" name="formatting" value="0" id="text" <?php if ($_POST['formatting'] == 0) { echo 'checked="checked"'; } ?> onclick="javascript: document.form.setvisual.disabled=true;" <?php if ($_POST['setvisual'] && !$_POST['settext']) { echo 'disabled="disabled"'; } ?> />
+                       <span class="nowrap">
+                               <label for="formatting_radios"><span class="required" title="<?php echo _AT('required_field'); ?>">*</span><?php echo _AT('formatting'); ?></label>
+                               <span id="formatting_radios">
+                                       <input type="radio" name="formatting" value="0" id="text" <?php if ($_POST['formatting'] == 0) { echo 'checked="checked"'; } ?> />
+                                       <label for="text"><?php echo _AT('plain_text'); ?></label>
 
-                       <label for="text"><?php echo _AT('plain_text'); ?></label>
-                       <input type="radio" name="formatting" value="1" id="html" <?php if ($_POST['formatting'] == 1 || $_POST['setvisual']) { echo 'checked="checked"'; } ?> onclick="javascript: document.form.setvisual.disabled=false;"/>
-
-                       <label for="html"><?php echo _AT('html'); ?></label>
-                       <?php   //Button for enabling/disabling visual editor
-                               if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']){
-                                       echo '<input type="hidden" name="setvisual" value="'.$_POST['setvisual'].'" />';
-                                       echo '<input type="submit" name="settext" value="'._AT('switch_text').'" class="button"/>';
-                               } else {
-                                       echo '<input type="submit" name="setvisual" value="'._AT('switch_visual').'"  ';
-                                       if ($_POST['formatting']==0) { echo 'disabled="disabled"'; }
-                                       echo ' class="button" />';
-                               }
-                       ?>
+                                       <input type="radio" name="formatting" value="1" id="html" <?php if ($_POST['formatting'] == 1) { echo 'checked="checked"'; } ?> />
+                                       <label for="html"><?php echo _AT('html'); ?></label>
+                          </span>
+                  </span>
                </div>
                <div class="row">
                        <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="jb_description"><?php echo _AT('jb_post_description'); ?></label><br />
index bc11bd2..8493167 100644 (file)
@@ -1,7 +1,9 @@
 <?php
-if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']) {
-       load_editor();
+$simple = true;
+if ($_POST['complexeditor'] == '1') {
+       $simple = false;
 }
+load_editor($simple, false, "none");
 ?>
 <div class="input-form">
        <form name="form" action="" method="post">
@@ -41,23 +43,16 @@ if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']) {
                        ?>
                </div>
                <div class="row">
-                       <?php echo _AT('formatting'); ?><br />
-                       <input type="radio" name="formatting" value="0" id="text" <?php if ($_POST['formatting'] == 0) { echo 'checked="checked"'; } ?> onclick="javascript: document.form.setvisual.disabled=true;" <?php if ($_POST['setvisual'] && !$_POST['settext']) { echo 'disabled="disabled"'; } ?> />
+                       <span class="nowrap">
+                               <label for="formatting_radios"><span class="required" title="<?php echo _AT('required_field'); ?>">*</span><?php echo _AT('formatting'); ?></label>
+                               <span id="formatting_radios">
+                                       <input type="radio" name="formatting" value="0" id="text" <?php if ($_POST['formatting'] == 0) { echo 'checked="checked"'; } ?> />
+                                       <label for="text"><?php echo _AT('plain_text'); ?></label>
 
-                       <label for="text"><?php echo _AT('plain_text'); ?></label>
-                       <input type="radio" name="formatting" value="1" id="html" <?php if ($_POST['formatting'] == 1 || $_POST['setvisual']) { echo 'checked="checked"'; } ?> onclick="javascript: document.form.setvisual.disabled=false;"/>
-
-                       <label for="html"><?php echo _AT('html'); ?></label>
-                       <?php   //Button for enabling/disabling visual editor
-                               if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']){
-                                       echo '<input type="hidden" name="setvisual" value="'.$_POST['setvisual'].'" />';
-                                       echo '<input type="submit" name="settext" value="'._AT('switch_text').'" class="button"/>';
-                               } else {
-                                       echo '<input type="submit" name="setvisual" value="'._AT('switch_visual').'"  ';
-                                       if ($_POST['formatting']==0) { echo 'disabled="disabled"'; }
-                                       echo ' class="button" />';
-                               }
-                       ?>
+                                       <input type="radio" name="formatting" value="1" id="html" <?php if ($_POST['formatting'] == 1) { echo 'checked="checked"'; } ?> />
+                                       <label for="html"><?php echo _AT('html'); ?></label>
+                          </span>
+                  </span>
                </div>
                <div class="row">
                        <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="jb_description"><?php echo _AT('jb_post_description'); ?></label><br />
index aa13e90..9b13c3f 100644 (file)
@@ -1,7 +1,9 @@
 <?php
-if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']) {
-       load_editor();
+$simple = true;
+if ($_POST['complexeditor'] == '1') {
+       $simple = false;
 }
+load_editor($simple, false, "none");
 ?>
 
 <div class="input-form">
@@ -47,23 +49,16 @@ if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']) {
                </div>
 
                <div class="row">
-                       <?php echo _AT('formatting'); ?><br />
-                       <input type="radio" name="formatting" value="0" id="text" <?php if ($_POST['formatting'] == 0) { echo 'checked="checked"'; } ?> onclick="javascript: document.form.setvisual.disabled=true;" <?php if ($_POST['setvisual'] && !$_POST['settext']) { echo 'disabled="disabled"'; } ?> />
+                       <span class="nowrap">
+                               <label for="formatting_radios"><span class="required" title="<?php echo _AT('required_field'); ?>">*</span><?php echo _AT('formatting'); ?></label>
+                               <span id="formatting_radios">
+                                       <input type="radio" name="formatting" value="0" id="text" <?php if ($_POST['formatting'] == 0) { echo 'checked="checked"'; } ?> />
+                                       <label for="text"><?php echo _AT('plain_text'); ?></label>
 
-                       <label for="text"><?php echo _AT('plain_text'); ?></label>
-                       <input type="radio" name="formatting" value="1" id="html" <?php if ($_POST['formatting'] == 1 || $_POST['setvisual']) { echo 'checked="checked"'; } ?> onclick="javascript: document.form.setvisual.disabled=false;"/>
-
-                       <label for="html"><?php echo _AT('html'); ?></label>
-                       <?php   //Button for enabling/disabling visual editor
-                               if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']){
-                                       echo '<input type="hidden" name="setvisual" value="'.$_POST['setvisual'].'" />';
-                                       echo '<input type="submit" name="settext" value="'._AT('switch_text').'" class="button"/>';
-                               } else {
-                                       echo '<input type="submit" name="setvisual" value="'._AT('switch_visual').'"  ';
-                                       if ($_POST['formatting']==0) { echo 'disabled="disabled"'; }
-                                       echo ' class="button" />';
-                               }
-                       ?>
+                                       <input type="radio" name="formatting" value="1" id="html" <?php if ($_POST['formatting'] == 1) { echo 'checked="checked"'; } ?> />
+                                       <label for="html"><?php echo _AT('html'); ?></label>
+                          </span>
+                  </span>
                </div>
                <div class="row">
                        <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="jb_description"><?php echo _AT('jb_post_description'); ?></label><br />
index 5487449..ffea015 100644 (file)
@@ -8,9 +8,14 @@
        <div>
                <label><?php echo _AT('categories'); ?></label>
                <?php if(is_array($this->job_post['categories'])):
-                               foreach($this->job_post['categories'] as $category): ?>
-               <span><?php echo $this->job_obj->getCategoryNameById($category);?></span>
-               <?php endforeach; else: ?>
+                                       $category_str = '';
+                                               foreach($this->job_post['categories'] as $category){
+                                                   $category_str .= $this->job_obj->getCategoryNameById($category).', ';
+                        }
+                        $category_str = substr($category_str, 0, -2);
+                               ?>
+                               <span><?php echo $category_str;?></span>
+               <?php else: ?>
                <span><?php echo $this->job_obj->getCategoryNameById($this->job_post['categories']);?></span>
                <?php endif; ?>
        </div>
diff --git a/mods/job_board/include/js/edit.js b/mods/job_board/include/js/edit.js
new file mode 100644 (file)
index 0000000..17536ec
--- /dev/null
@@ -0,0 +1,48 @@
+/***********************************************************************/\r
+/* ATutor                                                                                                                         */\r
+/***********************************************************************/\r
+/* Copyright (c) 2002-2010                                             */\r
+/* Inclusive Design Institute                                         */\r
+/* http://atutor.ca                                                                                                       */\r
+/*                                                                                                                                        */\r
+/* This program is free software. You can redistribute it and/or          */\r
+/* modify it under the terms of the GNU General Public License            */\r
+/* as published by the Free Software Foundation.                                          */\r
+/***********************************************************************/\r
+// $Id$\r
+\r
+/*global jQuery*/\r
+/*global ATutor */\r
+/*global tinyMCE */\r
+/*global window */\r
+\r
+ATutor = ATutor || {};\r
+ATutor.mods = ATutor.mods || {};\r
+ATutor.mods.editor = ATutor.mods.editor || {};\r
+\r
+(function () {\r
+    //initialises values to show or hide them\r
+    var setupPage = function () {\r
+        var textArea = jQuery("#textSpan");\r
+        var textAreaId = "jb_description";\r
+        if (jQuery("#html").attr("checked")) {\r
+            if (ATutor.mods.editor.editor_pref !== '1' && !tinyMCE.get(textAreaId)) {\r
+                       tinyMCE.execCommand('mceAddControl', false, textAreaId);\r
+            }\r
+            textArea.show();\r
+        } else {\r
+            if (tinyMCE.get(textAreaId)) {\r
+               tinyMCE.execCommand('mceRemoveControl', false, textAreaId);\r
+            }\r
+            textArea.show();\r
+        }      \r
+    };\r
+\r
+    //set up click handlers and show/hide appropriate tools via setupPage\r
+    var initialize = function () {\r
+        jQuery("#formatting_radios > input").click(setupPage);\r
+        setupPage();\r
+    };\r
+    \r
+    jQuery(document).ready(initialize);\r
+})();
\ No newline at end of file