Commit 38b999b1 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Combined three .js files into mahara.js

parent 7a4d4ee3
......@@ -67,7 +67,7 @@ $f = array(
);
$form = form($f);
$js = array('mochikit','messages','get_string','submit_form');
$js = array('mochikit','mahara');
if (use_html_editor()) {
array_unshift($js,'tinymce');
}
......
// Expects strings array
function get_string(s) {
// @todo Still need to sprintf these strings.
var flatargs = flattenArguments(arguments);
if (arguments.length > 1) {
argstr = '(' + flatargs.slice(1).join(',') + ')';
} else {
argstr = '';
}
if (typeof(strings) == 'undefined' || typeof(strings[s]) == 'undefined') {
return '[[[' + s + argstr + ']]]';
}
return strings[s] + argstr;
}
// Expects strings array
function get_string(s) {
// @todo Still need to sprintf these strings.
var flatargs = flattenArguments(arguments);
if (arguments.length > 1) {
argstr = '(' + flatargs.slice(1).join(',') + ')';
} else {
argstr = '';
}
if (typeof(strings) == 'undefined' || typeof(strings[s]) == 'undefined') {
return '[[[' + s + argstr + ']]]';
}
return strings[s] + argstr;
}
// Appends a status message to the end of elemid
function displayMessage(m, /* optional */ elemid) {
var color = 'red';
if (m.type == 'ok') {
color = 'green';
}
else if (m.type == 'info') {
color = '#aa6;';
}
if (typeof(elemid) == 'undefined') {
elemid = 'messages';
}
$(elemid).appendChild(DIV({'style':'color:'+color+';'},m.message));
}
// Tests if elements with the 'required' class have content and
// displays the appropriate message.
// Uses the html output from form.php to find the title of required
// fields: <label for="elementid">Element title</label>
function testRequired(e,formid) {
if (hasElementClass(e,'required') && e.value == '') {
var labels = getElementsByTagAndClassName('label',null,formid);
......@@ -13,6 +49,9 @@ function testRequired(e,formid) {
}
return true;
}
// Gets form elements, submits them to a url via post, and waits for a
// JSON response containing the result of the submission.
function submitForm(formid,url) {
if (typeof(tinyMCE) != 'undefined') {
tinyMCE.triggerSave();
......
function displayMessage(m) {
var color = 'red';
if (m.type == 'ok') {
color = 'green';
}
else if (m.type == 'info') {
color = '#aa6;';
}
var elemid = 'messages';
if (arguments.length > 1 && typeof(arguments[1]) == 'string') {
elemid = arguments[1];
}
$(elemid).appendChild(DIV({'style':'color:'+color+';'},m.message));
}
......@@ -57,8 +57,8 @@ function &smarty($javascript = array(), $headers = array(), $strings = array())
//@todo: Handle dependencies between javascript files.
if (!empty($strings) && !in_array('get_string',$javascript)) {
array_push($javascript,'get_string');
if (!empty($strings) && !in_array('mahara',$javascript)) {
array_push($javascript,'mahara');
}
$jsroot = get_config('wwwroot') . 'js/';
foreach ($javascript as &$value) {
......@@ -72,8 +72,11 @@ function &smarty($javascript = array(), $headers = array(), $strings = array())
throw new Exception ('tinyMCE not initialised.');
}
}
else if ($value == 'mahara') {
$value = $jsroot . 'mahara.js';
}
else {
$value = $jsroot . $value . '.js';
throw new Exception ($value . '.js: unknown');
}
}
if (!empty($strings)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment