Commit bfa5fde8 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1648628: Eliminate MochiKit from Artefacts"

parents 27ff3d4b 97dc9b4f
......@@ -54,14 +54,14 @@ function modifyAnnotationFeedbackSuccess(form, data) {
tinyMCE.triggerSave();
sendjsonrequest('../artefact/annotation/annotations.json.php',
{
'annotationid' : $(formname + '_annotationid').value,
'viewid' : $(formname + '_viewid').value,
'artefactid' : $(formname + '_artefactid').value,
'blockid' : $(formname + '_blockid').value,
'annotationid' : jQuery('#' + formname + '_annotationid').val(),
'viewid' : jQuery('#' + formname + '_viewid').val(),
'artefactid' : jQuery('#' + formname + '_artefactid').val(),
'blockid' : jQuery('#' + formname + '_blockid').val(),
'limit' : limit,
'offset' : offset,
}, 'GET', function (data) {
var blockid = $(formname + '_blockid').value;
var blockid = jQuery('#' + formname + '_blockid').val();
// Populate the div.
(function($) {
......@@ -72,7 +72,7 @@ function modifyAnnotationFeedbackSuccess(form, data) {
})(jQuery);
});
// if we are in a modal close it
if (jQuery('#annotation_feedbacktable_' + $(formname + '_blockid').value).hasClass('modal-docked')) {
if (jQuery('#annotation_feedbacktable_' + jQuery('#' + formname + '_blockid').val()).hasClass('modal-docked')) {
dock.hide();
}
formSuccess(form, data);
......@@ -80,10 +80,10 @@ function modifyAnnotationFeedbackSuccess(form, data) {
function addAnnotationFeedbackSuccess(form, data) {
var formname = form.name;
var blockid = $(formname + '_blockid').value;
var blockid = jQuery('#' + formname + '_blockid').val();
var limit = getURLParameter('limit');
var offset = getURLParameter('offset');
var tinymce = $(form.id + '_message');
var tinymce = jQuery('#' + form.id + '_message');
if (limit === false && offset === false) {
// Pagination is not used.
......@@ -104,14 +104,14 @@ function addAnnotationFeedbackSuccess(form, data) {
tinyMCE.triggerSave();
sendjsonrequest('../artefact/annotation/annotations.json.php',
{
'annotationid' : $(formname + '_annotationid').value,
'viewid' : $(formname + '_viewid').value,
'artefactid' : $(formname + '_artefactid').value,
'blockid' : $(formname + '_blockid').value,
'annotationid' : jQuery('#' + formname + '_annotationid').val(),
'viewid' : jQuery('#' + formname + '_viewid').val(),
'artefactid' : jQuery('#' + formname + '_artefactid').val(),
'blockid' : jQuery('#' + formname + '_blockid').val(),
'limit' : limit,
'offset' : offset,
}, 'GET', function (data) {
var blockid = $(formname + '_blockid').value;
var blockid = jQuery('#' + formname + '_blockid').val();
// Populate the div
(function($) {
var scope = $('#annotationfeedbackview_' + blockid);
......@@ -131,7 +131,7 @@ function addAnnotationFeedbackSuccess(form, data) {
if (data.fieldnames && data.fieldnames.message) {
messageid = data.fieldnames.message;
}
$(formname + '_' + messageid).value = '';
jQuery('#' + formname + '_' + messageid).val('');
formSuccess(form, data);
}
......
......@@ -143,7 +143,7 @@ $feedback = ArtefactTypeComment::get_comments($commentoptions);
$inlinejavascript = <<<EOF
var viewid = {$viewid};
var artefactid = {$artefactid};
addLoadEvent(function () {
jQuery(function () {
paginator = {$feedback->pagination_js}
});
EOF;
......
function addNewTaggedPostShortcut(blockid) {
forEach(
getElementsByTagAndClassName('a', 'btnshortcut', 'blockinstance_' + blockid),
function(a) {
disconnectAll(a);
connect(a, 'onclick', function(e) {
e.stop();
var p = getFirstParentByTagAndClassName(a, 'div', 'shortcut');
var selectedBlog = getFirstElementByTagAndClassName('select','select', p);
var currentTag = getFirstElementByTagAndClassName('input','select', p);
var BlogIDInput = INPUT({'name': 'blog', 'type': 'text', 'value': selectedBlog.value});
var TagInput = INPUT({'name': 'tagselect', 'type': 'text', 'value': currentTag.value});
var myForm = FORM(
{'action': config.wwwroot + 'artefact/blog/post.php', 'method': 'POST'},
BlogIDInput,
TagInput
);
document.body.appendChild(myForm);
myForm.submit();
});
}
);
}
var addNewTaggedPostShortcut = (function($) {
return function (blockid) {
$('#blockinstance_' + blockid + ' a.btnshortcut').each(function() {
$(this).off();
$(this).on('click', function(e) {
e.preventDefault();
var p = $(this).closest('div.shortcut');
var selectedBlog = p.find('select.select').first();
var currentTag = p.find('input.select').first();
var BlogIDInput = $('<input>', {'name': 'blog', 'type': 'text', 'value': selectedBlog.value});
var TagInput = $('<input>', {'name': 'tagselect', 'type': 'text', 'value': currentTag.value});
var myForm = $('<form>', {'action': config.wwwroot + 'artefact/blog/post.php', 'method': 'POST'})
.append(BlogIDInput, TagInput);
document.body.appendChild(myForm);
myForm.submit();
});
}
);
};
}(jQuery));
......@@ -103,7 +103,7 @@ $smarty->assign('institutionname', $institutionname);
$smarty->assign('group', $groupid);
$js = '';
if ($blogs->pagination_js) {
$js .= 'addLoadEvent(function() {' . $blogs->pagination_js . '});';
$js .= 'jQuery(function() {' . $blogs->pagination_js . '});';
}
if (!empty($institutionname) && ($institutionname != 'mahara')) {
$smarty->assign('institution', $institutionname);
......
......@@ -156,32 +156,32 @@ $strchangepoststatusunpublish = json_encode(get_string('unpublish', 'artefact.bl
$js = <<<EOF
function changepoststatus_success(form, data) {
if ($('changepoststatus_' + data.id + '_currentpoststatus').value === "0") {
removeElementClass($('posttitle_' + data.id), 'draft');
addElementClass($('posttitle_' + data.id), 'published');
$('poststatus' + data.id).innerHTML = {$strpublished};
$('changepoststatus_' + data.id + '_submit').innerHTML = '<span class="icon icon-times icon-lg left text-danger" role="presentation" aria-hidden="true"></span> ' + {$strchangepoststatusunpublish} +
'<span class="sr-only">' + {$strchangepoststatusunpublish} + ' "' + data.title + '"</span>';
if (jQuery('#changepoststatus_' + data.id + '_currentpoststatus').val() === "0") {
jQuery('#posttitle_' + data.id).removeClass( 'draft');
jQuery('#posttitle_' + data.id).addClass('published');
jQuery('#poststatus' + data.id).html({$strpublished});
jQuery('#changepoststatus_' + data.id + '_submit').html('<span class="icon icon-times icon-lg left text-danger" role="presentation" aria-hidden="true"></span> ' + {$strchangepoststatusunpublish} +
'<span class="sr-only">' + {$strchangepoststatusunpublish} + ' "' + data.title + '"</span>');
}
else {
removeElementClass($('posttitle_' + data.id), 'published');
addElementClass($('posttitle_' + data.id), 'draft');
$('poststatus' + data.id).innerHTML = {$strdraft};
$('changepoststatus_' + data.id + '_submit').innerHTML = '<span class="icon icon-check icon-lg left text-success" role="presentation" aria-hidden="true"></span>' + {$strchangepoststatuspublish} +
'<span class="sr-only">' + {$strchangepoststatuspublish} + ' "' + data.title + '"</span>';
jQuery('#posttitle_' + data.id).removeClass('published');
jQuery('#posttitle_' + data.id).addClass('draft');
jQuery('#poststatus' + data.id).html({$strdraft});
jQuery('#changepoststatus_' + data.id + '_submit').html('<span class="icon icon-check icon-lg left text-success" role="presentation" aria-hidden="true"></span>' + {$strchangepoststatuspublish} +
'<span class="sr-only">' + {$strchangepoststatuspublish} + ' "' + data.title + '"</span>');
}
}
function delete_success(form, data) {
addElementClass('postdetails_' + data.id, 'hidden');
if ($('postfiles_' + data.id)) {
addElementClass('postfiles_' + data.id, 'hidden');
jQuery('#postdetails_' + data.id).addClass('hidden');
if (jQuery('#postfiles_' + data.id).length) {
jQuery('#postfiles_' + data.id).addClass('hidden');
}
addElementClass('postdescription_' + data.id, 'hidden');
addElementClass('posttitle_' + data.id, 'hidden');
var results = \$j('#blogpost_pagination div.results').html();
jQuery('#postdescription_' + data.id).addClass('hidden');
jQuery('#posttitle_' + data.id).addClass('hidden');
var results = jQuery('#blogpost_pagination div.results').html();
var oldcount = parseInt(results, 10);
var newcount = oldcount - 1;
\$j('#blogpost_pagination div.results').html(results.replace(oldcount, newcount));
jQuery('#blogpost_pagination div.results').html(results.replace(oldcount, newcount));
progressbarUpdate('blogpost', true);
}
EOF;
......
......@@ -129,18 +129,18 @@ class PluginBlocktypeTextbox extends MaharaCoreBlocktype {
return <<<EOF
formchangemanager.setFormStateById('instconf', FORM_CHANGED);
function updateTextContent(a) {
setNodeAttribute('instconf_title', 'value', a.title);
jQuery('#instconf_title').prop('value', a.title);
if (typeof(tinyMCE) != 'undefined') {
tinyMCE.activeEditor.setContent(a.description);
}
setNodeAttribute('instconf_license', 'value', a.license);
setNodeAttribute('instconf_licensor', 'value', a.licensor);
setNodeAttribute('instconf_licensorurl', 'value', a.licensorurl);
jQuery('#instconf_textreadonly_display').innerHTML = a.safedescription;
jQuery('#instconf_licensereadonly_display').innerHTML = a.safelicense;
setNodeAttribute('instconf_tags', 'value', a.tags);
jQuery('#instconf_textreadonly_display').innerHTML = a.safedescription;
jQuery('#instconf_tagsreadonly_display').innerHTML = a.safetags;
jQuery('#instconf_license').prop('value', a.license);
jQuery('#instconf_licensor').prop('value', a.licensor);
jQuery('#instconf_licensorurl').prop('value', a.licensorurl);
jQuery('#instconf_textreadonly_display').html(a.safedescription);
jQuery('#instconf_licensereadonly_display').html(a.safelicense);
jQuery('#instconf_tags').prop('value', a.tags);
jQuery('#instconf_textreadonly_display').html(a.safedescription);
jQuery('#instconf_tagsreadonly_display').html(a.safetags);
jQuery('#instconf_makecopy').prop('checked', false);
if (a.editable == 1) {
jQuery('#instconf_textreadonly_container').addClass('hidden');
......@@ -167,7 +167,7 @@ function updateTextContent(a) {
}
}
if (otherblockcount) {
replaceChildNodes('textbox_blockcount', otherblockcount);
jQuery('#textbox_blockcount').empty().append(otherblockcount);
jQuery(blockcountmsg).removeClass('hidden');
}
else {
......@@ -178,7 +178,7 @@ function updateTextContent(a) {
if (typeof a.attachments != 'undefined') {
// remove any attached files
for (var key in instconf_artefactids.selecteddata) {
signal($('instconf_artefactids_unselect_' + key), 'onclick', instconf_artefactids.unselect);
jQuery('#instconf_artefactids_unselect_' + key).triggerHandler('click', instconf_artefactids.unselect);
}
// add in ones we need
if (a.attachments.length > 0) {
......@@ -205,23 +205,23 @@ function updateTextContent(a) {
jQuery('#instconf_tagsreadonly_container').removeClass('hidden');
}
}
connect('chooseartefactlink', 'onclick', function(e) {
e.stop();
jQuery('#chooseartefactlink').on('click', function(e) {
e.preventDefault();
// if the artefact chooser is hidden, use paginator p to populate it, then toggle its visibility
if (hasElementClass(getElement('instconf_artefactid_container'), 'hidden')) {
if (jQuery('#instconf_artefactid_container').hasClass('hidden')) {
var queryData = [];
queryData.extradata = serializeJSON(p.extraData);
p.sendQuery(queryData, true);
}
toggleElementClass('hidden', 'instconf_artefactid_container');
toggleElementClass('hidden', 'instconf_managenotes_container');
jQuery('#instconf_artefactid_container').toggleClass('hidden');
jQuery('#instconf_managenotes_container').toggleClass('hidden');
});
forEach(getElementsByTagAndClassName('a', 'copytextboxnote', 'instconf'), function(link) {
connect(link, 'onclick', function(e) {
e.stop();
forEach(getElementsByTagAndClassName('input', 'radio', 'artefactid_data'), function(i) {
if (i.checked) {
i.checked = false;
jQuery('#instconf a.copytextboxnote').each(function() {
jQuery(this).on('click', function(e) {
e.preventDefault();
jQuery('#artefactid_data input.radio').each(function() {
if (jQuery(this).prop('checked')) {
jQuery(this).prop('checked', false);
}
});
jQuery('#instconf_makecopy').prop('checked', true);
......
function rewriteTaskTitles(blockid) {
forEach(
getElementsByTagAndClassName('a', 'task-title', 'tasktable_' + blockid),
function(element) {
disconnectAll(element);
connect(element, 'onclick', function(e) {
e.stop();
var description = getFirstElementByTagAndClassName('div', 'task-desc', element.parentNode);
toggleElementClass('hidden', description);
});
}
);
jQuery('tasktable_' + blockid + ' a.task-title').each(function() {
jQuery(this).off();
jQuery(this).on('click', function(e) {
e.preventDefault();
var description = jQuery(this).parent().find('div.task-desc');
description.toggleClass('hidden');
});
});
}
function TaskPager(blockid) {
var self = this;
paginatorProxy.addObserver(self);
connect(self, 'pagechanged', partial(rewriteTaskTitles, blockid));
jQuery(self).on('pagechanged', rewriteTaskTitles.bind(null, blockid));
}
var taskPagers = [];
function initNewPlansBlock(blockid) {
if ($('plans_page_container_' + blockid)) {
if (jQuery('#plans_page_container_' + blockid)) {
new Paginator('block' + blockid + '_pagination', 'tasktable_' + blockid, null, 'artefact/plans/viewtasks.json.php', null);
taskPagers.push(new TaskPager(blockid));
}
......
......@@ -33,7 +33,7 @@ $plans = ArtefactTypePlan::get_plans($offset, $limit);
ArtefactTypePlan::build_plans_list_html($plans);
$js = <<< EOF
addLoadEvent(function () {
jQuery(function () {
{$plans['pagination_js']}
});
EOF;
......
......@@ -40,7 +40,7 @@ $tasks = ArtefactTypeTask::get_tasks($plan->get('id'), $offset, $limit);
ArtefactTypeTask::build_tasks_list_html($tasks);
$js = <<< EOF
addLoadEvent(function () {
jQuery(function () {
{$tasks['pagination_js']}
});
EOF;
......
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