Commit 1eb96a3d authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Json-encode strings included in viewacl javascript (bug #817342)



Adds a new dwoo function to json-encode strings for inclusion in
template javascript, and uses the function in the viewacl template.

Change-Id: Ie632061fe94a2adc2943a3d830695a44650847af
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 921930ee
......@@ -39,5 +39,6 @@ function Dwoo_Plugin_str(Dwoo $dwoo, $tag, $section = 'mahara', $args = null, $a
return $ret;
}
?>
function Dwoo_Plugin_jstr(Dwoo $dwoo, $tag, $section = 'mahara', $args = null, $arg1 = null, $arg2 = null, $arg3 = null, $assign = null) {
return json_encode(Dwoo_Plugin_str($dwoo, $tag, $section, $args, $arg1, $arg2, $arg3, $assign));
}
......@@ -53,7 +53,7 @@ var count = 0;
// Given a row, render it on the left hand side
function renderPotentialPresetItem(item) {
var addButton = BUTTON({'type': 'button'}, '{{str tag=add}}');
var addButton = BUTTON({'type': 'button'}, {{jstr tag=add}});
var attribs = {};
if (item.preset) {
attribs = {'class': 'preset'};
......@@ -84,7 +84,7 @@ function renderPotentialPresetItem(item) {
// Given a row, render it on the right hand side
function renderAccessListItem(item) {
var removeButton = BUTTON({'type': 'button', 'title': '{{str tag=remove}}'});
var removeButton = BUTTON({'type': 'button', 'title': {{jstr tag=remove}}});
var allowfdbk = INPUT({
'type': 'checkbox',
'name': 'accesslist[' + count + '][allowcomments]',
......@@ -241,8 +241,8 @@ function setupCalendar(item, type) {
return;
}
Calendar.setup({
"ifFormat" :"{{str tag=strftimedatetimeshort}}",
"daFormat" :"{{str tag=strftimedatetimeshort}}",
"ifFormat" :{{jstr tag=strftimedatetimeshort}},
"daFormat" :{{jstr tag=strftimedatetimeshort}},
"inputField": type + 'date_' + count,
"button" : type + 'date_' + count + '_btn',
//"dateStatusFunc" : dateStatusFunc,
......@@ -261,13 +261,13 @@ forEach(potentialPresets, function(preset) {
var allGroups = {{$allgroups|safe}};
var myGroups = {{$mygroups|safe}};
if (myGroups) {
appendChildNodes('potentialpresetitems', H6(null, '{{str tag=sharewithmygroups section=view}}'));
appendChildNodes('potentialpresetitems', H6(null, {{jstr tag=sharewithmygroups section=view}}));
renderPotentialPresetItem(allGroups);
var i = 0;
var maxGroups = 10;
forEach(myGroups, function(preset) {
if (i == maxGroups) {
var more = A({'href':''}, '{{str tag=moregroups section=group}} »');
var more = A({'href':''}, {{jstr tag=moregroups section=group}} + ' »');
connect(more, 'onclick', function(e) {
e.stop();
forEach(getElementsByTagAndClassName('div', 'moregroups', 'potentialpresetitems'), partial(toggleElementClass, 'hidden'));
......@@ -283,7 +283,7 @@ if (myGroups) {
}
var faves = {{$faves|safe}};
if (faves) {
appendChildNodes('potentialpresetitems', H6(null, '{{str tag=sharewithusers section=view}}'));
appendChildNodes('potentialpresetitems', H6(null, {{jstr tag=sharewithusers section=view}}));
forEach(faves, renderPotentialPresetItem);
}
var loggedinindex = {{$loggedinindex}};
......@@ -343,7 +343,7 @@ searchTable.rowfunction = function(rowdata, rownumber, globaldata) {
rowdata.type = searchTable.type;
var buttonTD = TD({'style': 'white-space:nowrap;'});
var addButton = BUTTON({'type': 'button', 'class': 'button'}, '{{str tag=add}}');
var addButton = BUTTON({'type': 'button', 'class': 'button'}, {{jstr tag=add}});
connect(addButton, 'onclick', function() {
appendChildNodes('accesslist', renderAccessListItem(rowdata));
});
......@@ -356,7 +356,7 @@ searchTable.rowfunction = function(rowdata, rownumber, globaldata) {
}
else if (rowdata.type == 'group') {
rowdata.role = null;
var options = [OPTION({'value':null, 'selected':true}, '{{str tag=everyoneingroup section=view}}')];
var options = [OPTION({'value':null, 'selected':true}, {{jstr tag=everyoneingroup section=view}})];
for (r in globaldata.roles[rowdata.grouptype]) {
options.push(OPTION({'value':globaldata.roles[rowdata.grouptype][r].name}, globaldata.roles[rowdata.grouptype][r].display));
}
......
Supports Markdown
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