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

Merge "Bug 1649176: Eliminate MochiKit from various PHP files * Auth *...

Merge "Bug 1649176: Eliminate MochiKit from various PHP files * Auth * BlockType * Group, * Interaction * Index.php * module * user * search * selfsearch"
parents 811adcad 741e496d
......@@ -1334,14 +1334,14 @@ function get_login_form_js($form) {
$cookiename = get_config('cookieprefix') . 'ctest';
$js = <<< EOF
<script type="application/javascript">
var loginbox = $('loginform_container');
var loginbox = jQuery('#loginform_container');
document.cookie = "$cookiename=1";
if (document.cookie) {
loginbox.innerHTML = $form;
loginbox.html($form);
document.cookie = '$cookiename=1;expires=1/1/1990 00:00:00';
}
else {
replaceChildNodes(loginbox, P(null, $strcookiesnotenabled));
loginbox.empty().append(jQuery('<p>', { 'text': $strcookiesnotenabled }));
}
</script>
EOF;
......
......@@ -8,24 +8,24 @@
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*/
function toggle_seal() {
freeculture = true;
sealimage = $("freecultureseal");
var toggle_seal = jQuery(function($) {
return function() {
freeculture = true;
sealimage = $("#freecultureseal");
nc_checkboxes = getElementsByTagAndClassName("input", null, $("instconf_noncommercial_container"));
if (!nc_checkboxes[0].checked) {
freeculture = false;
}
if (!$('#instconf_noncommercial_container input').first().prop('checked')) {
freeculture = false;
}
nd_checkboxes = getElementsByTagAndClassName("input", null, $("instconf_noderivatives_container"));
if (nd_checkboxes[2].checked) {
freeculture = false;
}
if ($('#instconf_noderivatives_container input').eq(2).prop('checked')) {
freeculture = false;
}
if (freeculture) {
removeElementClass(sealimage, "hidden");
}
else {
addElementClass(sealimage, "hidden");
}
}
if (freeculture) {
sealimage.removeClass("hidden");
}
else {
sealimage.addClass("hidden");
}
};
});
......@@ -128,7 +128,7 @@ class PluginBlocktypeCreativecommons extends MaharaCoreBlocktype {
// Dirty hack to display the seal just before the table
// TODO: add a way to append stuff to the header in the maharatable pieform renderer
$sealpositionhack = "insertSiblingNodesBefore('instconf', $('freecultureseal')); addElementClass('instconf', 'fl');";
$sealpositionhack = "jQuery('#freecultureseal').insertBefore('#insconf'); jQuery('#instconf').addClass('fl');";
return array(
'seal' => array(
......
......@@ -194,15 +194,15 @@ class PluginBlocktypeWall extends MaharaCoreBlocktype {
public function wallpost_js() {
$js = <<<EOF
function wallpost_success(form, data) {
if ($('wall') && data.posts && data.block) {
var wall = getFirstElementByTagAndClassName('div', 'wall', 'blockinstance_' + data.block);
var temp = DIV();
if (jQuery('#wall').length && data.posts && data.block) {
var wall = jQuery('#blockinstance_' + data.block + ' div.wall').first();
var temp = jQuery('<div>');
var textareaid = 'wallpost_' + data.block + '_text';
temp.innerHTML = data.posts;
newposts = getElementsByTagAndClassName('div', 'wallpost', temp);
replaceChildNodes(wall, newposts);
if ($(textareaid)) {
$(textareaid).value = '';
temp.html(data.posts);
newposts = jQuery(temp).find('div.wallpost');
wall.empty().append(newposts);
if (jQuery('#' + textareaid).length) {
jQuery('#' + textareaid).val('');
// Clear TinyMCE
if (typeof(tinyMCE) != 'undefined' && typeof(tinyMCE.get(textareaid)) != 'undefined') {
tinyMCE.activeEditor.setContent('');
......
......@@ -142,18 +142,18 @@ $searchform = pieform(array(
));
$js = <<< EOF
addLoadEvent(function () {
jQuery(function ($) {
p = {$pagination['javascript']}
connect('search_submit', 'onclick', function (event) {
replaceChildNodes('messages');
var params = {'query': $('search_query').value, 'id':$('search_id').value,
'membershiptype':$('search_membershiptype').value,
'setlimit':$('search_setlimit').value,
'limit':$('setlimitselect').value,
'sortoption':$('search_sortoption').value
$('#search_submit').on('click', function (event) {
$('#messages').empty();
var params = {'query': $('#search_query').val(), 'id':$('#search_id').val(),
'membershiptype':$('#search_membershiptype').val(),
'setlimit':$('#search_setlimit').val(),
'limit':$('#setlimitselect').val(),
'sortoption':$('#search_sortoption').val()
};
p.sendQuery(params);
event.stop();
event.preventDefault();
});
});
EOF;
......
......@@ -43,5 +43,5 @@ $pagination = build_pagination(array(
$smarty = smarty(array('paginator'));
$smarty->assign('topics', $data['data']);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('INLINEJAVASCRIPT', 'addLoadEvent(function() { p = ' . $pagination['javascript'] . '});');
$smarty->assign('INLINEJAVASCRIPT', 'jQuery(function() { p = ' . $pagination['javascript'] . '});');
$smarty->display('group/topics.tpl');
......@@ -76,7 +76,7 @@ if ($group->public) {
$javascript = array('paginator');
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
$inlinejs = "jQuery( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
$headers = array_merge($headers, $view->get_all_blocktype_css());
......
......@@ -60,19 +60,20 @@ if ($USER->is_logged_in()) {
// allow the user to choose never to see the info boxes again
$strhowtodisable = json_encode(get_string('howtodisable', 'mahara', get_config('wwwroot') . 'account'));
$js = <<<JAVASCRIPT
function hideinfo() {
var m = SPAN();
m.innerHTML = {$strhowtodisable};
slideUp('home-info-container', {afterFinish: function() {displayMessage(m, 'ok');}});
}
jQuery(function($) {
function hideinfo() {
var m = $('<span>');
m.html({$strhowtodisable});
$('#home-info-container').slideUp('fast', function() { displayMessage(m, 'ok'); });
}
function nevershow() {
var data = {'showhomeinfo' : 0};
sendjsonrequest('homeinfo.json.php', data, 'POST', hideinfo);
}
addLoadEvent(function () {
if ($('hideinfo')) {
$('hideinfo').onclick = nevershow;
function nevershow() {
var data = {'showhomeinfo' : 0};
sendjsonrequest('homeinfo.json.php', data, 'POST', hideinfo);
}
if ($('#hideinfo').length) {
$('#hideinfo').on('click', nevershow);
}
});
JAVASCRIPT;
......
......@@ -142,24 +142,25 @@ class PluginInteractionForum extends PluginInteraction {
public static function instance_config_js() {
return <<<EOF
function update_maxindent() {
var s = $('edit_interaction_indentmode');
var m = $('edit_interaction_maxindent_container');
var t = $('edit_interaction_maxindent');
if (!m) {
return;
}
if (s.options[s.selectedIndex].value == 'max_indent') {
removeElementClass(m, 'hidden');
removeElementClass(t, 'hidden');
}
else {
addElementClass(m, 'hidden');
addElementClass(t, 'hidden');
jQuery(function($) {
function update_maxindent() {
var s = $('#edit_interaction_indentmode');
var m = $('#edit_interaction_maxindent_container');
var t = $('#edit_interaction_maxindent');
if (!m) {
return;
}
if (s.options[s.selectedIndex].val() == 'max_indent') {
m.removeClass('hidden');
t.removeClass('hidden');
}
else {
m.addClass('hidden');
t.addClass('hidden');
}
}
}
addLoadEvent(function() {
connect('edit_interaction_indentmode', 'onchange', update_maxindent);
$('#edit_interaction_indentmode').on('change', update_maxindent);
});
EOF;
}
......
......@@ -262,26 +262,27 @@ $pagination = build_pagination(array(
));
$inlinejavascript = <<<EOF
addLoadEvent(function() {
forEach(getElementsByTagAndClassName('input', 'topic-checkbox'), function(checkbox) {
var tr = getFirstParentByTagAndClassName(checkbox, 'tr', null);
var origColour = tr.style.backgroundColor;
connect(checkbox, 'onclick', function(e) {
if (tr.style.backgroundColor == origColour) {
tr.style.backgroundColor = '#ffc';
jQuery(function($) {
$('input.topic-checkbox').each(function() {
var tr = $(this).closest('tr');
var origColour = tr.css('backgroundColor');
$(this).on('click', function(e) {
if (tr.css('backgroundColor') === origColour) {
tr.css('backgroundColor', '#ffc');
}
else {
tr.style.backgroundColor = origColour;
tr.css('backgroundColor', origColour);
}
});
});
if (action = document.getElementById('action')) {
connect(action, 'onchange', function(e) {
$(action).on('change', function(e) {
if (this.options[this.selectedIndex].value == 'moveto') {
\$j('#otherforums').removeClass('hidden');
$('#otherforums').removeClass('hidden');
}
else {
\$j('#otherforums').addClass('hidden');
$('#otherforums').addClass('hidden');
}
});
}
......
......@@ -291,7 +291,7 @@ function PaginatorProxy() {
*/
this.alertObservers = function(eventName, data) {
forEach(self.observers, function(o) {
signal(o, eventName, data);
signal(o, eventName, data); // remove when signal/ Mochikit completely eliminated from the App
jQuery(o).triggerHandler(eventName, data);
});
};
......
......@@ -95,24 +95,22 @@ $paginationjavascript = <<<JAVASCRIPT
jQuery(function($) {
// We want the paginator to tell us when a page gets changed.
function PaginatorData() {
var self = this;
var params = {};
this.pageChanged = function(data) {
self.params = {
'offset': data.offset,
'limit': data.limit,
'type': data.type
}
}
paginatorProxy.addObserver(self);
connect(self, 'pagechanged', self.pageChanged);
}
window.paginatorData = new PaginatorData();
addLoadEvent(function () {
window.paginator = {$activitylist['pagination_js']}
});
function PaginatorData() {
var self = this;
var params = {};
this.pageChanged = function(data) {
self.params = {
'offset': data.offset,
'limit': data.limit,
'type': data.type
}
}
paginatorProxy.addObserver(self);
$(self).on('pagechanged', self.pageChanged);
}
window.paginatorData = new PaginatorData();
window.paginator = {$activitylist['pagination_js']}
});
JAVASCRIPT;
......
......@@ -77,24 +77,23 @@ $paginationjavascript = <<<JAVASCRIPT
// this part much more difficult to relocate
jQuery(function($) {
// We want the paginator to tell us when a page gets changed.
function PaginatorData() {
var self = this;
var params = {};
this.pageChanged = function(data) {
self.params = {
'offset': data.offset,
'limit': data.limit,
'type': data.type
}
}
paginatorProxy.addObserver(self);
connect(self, 'pagechanged', self.pageChanged);
}
window.paginatorData = new PaginatorData();
addLoadEvent(function () {
window.paginator = {$activitylist['pagination_js']}
});
// We want the paginator to tell us when a page gets changed.
function PaginatorData() {
var self = this;
var params = {};
this.pageChanged = function(data) {
self.params = {
'offset': data.offset,
'limit': data.limit,
'type': data.type
}
}
paginatorProxy.addObserver(self);
$(self).on('pagechanged', self.pageChanged);
}
window.paginatorData = new PaginatorData();
window.paginator = {$activitylist['pagination_js']}
});
JAVASCRIPT;
......
......@@ -117,51 +117,51 @@ $searchform = array(
$searchform = pieform($searchform);
$js = <<< EOF
addLoadEvent(function () {
jQuery(function ($) {
var firstpage = false;
function SearchPager() {
var self = this;
paginatorProxy.addObserver(self);
connect(self, 'pagechanged', function() {
$(self).on('pagechanged', function() {
if (firstpage) {
firstpage = false;
addElementClass('totalresultsdisplay', 'hidefocus');
setNodeAttribute('totalresultsdisplay', 'tabindex', -1);
$('totalresultsdisplay').focus();
$('#totalresultsdisplay').addClass('hidefocus')
.prop('tabindex', -1)
.focus();
}
else {
getFirstElementByTagAndClassName('a', null, $('universalsearchresults')).focus();
$('#universalsearchresults a:first').focus();
}
});
}
var searchPager = new SearchPager();
p = {$data['pagination_js']}
connect('search_submit', 'onclick', function (event) {
$('#search_submit').on('click', function (event) {
firstpage = true;
replaceChildNodes('messages');
$('#messages').empty();
if ($('search_tagsonly').value === 'tagsonly') {
if ($('#search_tagsonly').val() === 'tagsonly') {
var tagsonly = true;
}
else {
var tagsonly = false;
}
var params = {'query': $('search_query').value, 'tagsonly': tagsonly, 'mainfacetterm': null,'limit': $('setlimitselect').value, 'extradata':serializeJSON({'page':'index'})};
var params = {'query': $('#search_query').val(), 'tagsonly': tagsonly, 'mainfacetterm': null,'limit': $('#setlimitselect').val(), 'extradata':serializeJSON({'page':'index'})};
p.sendQuery(params);
event.stop();
event.preventDefault();
});
});
EOF;
if (!empty($query)) {
$js .= <<< EOF
addLoadEvent(function() {
addElementClass('totalresultsdisplay', 'hidefocus');
setNodeAttribute('totalresultsdisplay', 'tabindex', -1);
$('totalresultsdisplay').focus();
jQuery(function($) {
$('#totalresultsdisplay').addClass('hidefocus')
.prop('tabindex', -1)
.focus();
});
EOF;
}
......
......@@ -33,39 +33,38 @@ results.rowfunction = function (r, rownumber, d) {
var titleElement;
if (r.links && r.links._default) {
titleElement = [H3({'class': 'title'}, A({'href': r.links._default}, r.title))];
titleElement = [jQuery('<h3>',{'class': 'title'}), jQuery('<a>', {'href': r.links._default, 'text': r.title}))];
delete r.links._default;
}
else {
titleElement = [H3({'class': 'title'}, r.title)];
titleElement = [jQuery('<h3>', {'class': 'title', 'text': r.title})];
}
for ( var k in r.links ) {
var link = A({'href': r.links[k]}, k);
var link = jQuery('<a>', {'href': r.links[k], 'text': k});
titleElement.push(link);
}
if (r.views) {
var viewsList = UL(null);
var viewsElement = DIV(null, LABEL(null, $enc_pages), viewsList);
var viewsList = jQuery('<ul>');
var viewsElement = jQuery('<div>').append(jQuery('<label>').append($enc_pages), viewsList);
for ( var k in r.views ) {
var link = A({'href': r.views[k]}, k);
viewsList.appendChild(LI(null, link));
var link = jQuery('<a>',{'href': r.views[k]}).append(k);
viewsList.append(jQuery('<li>').append(link));
}
}
var descriptionElement = P(null);
descriptionElement.innerHTML = r.summary;
var descriptionElement = jQuery('<p>');
descriptionElement.html(r.summary);
return TR({'class': 'r' + (rownumber % 2)}, TD(null,
titleElement,
descriptionElement,
viewsElement
));
return jQuery('<tr>', {'class': 'r' + (rownumber % 2)}).append(
jQuery('<td>').append(
titleElement, descriptionElement, viewsElement
))[0];
};
function dosearch(e) {
results.query = $('search_query').value;
results.query = jQuery('#search_query').val();
results.offset = 0;
results.doupdate();
......
......@@ -115,16 +115,16 @@ if ($USER->get('institutions')) {
$searchform = pieform($searchform);
$js = <<< EOF
addLoadEvent(function () {
jQuery(function ($) {
p = {$data['pagination_js']}
connect('search_submit', 'onclick', function (event) {
replaceChildNodes('messages');
var params = {'query': $('search_query').value, 'extradata':serializeJSON({'page':'find'})};
if ($('search_filter')) {
params.filter = $('search_filter').value;
$('#search_submit').on('click', function (event) {
$('#messages').empty();
var params = {'query': $('#search_query').val(), 'extradata':serializeJSON({'page':'find'})};
if ($('#search_filter').length) {
params.filter = $('#search_filter').val();
}
p.sendQuery(params);
event.stop();
event.preventDefault();
});
});
EOF;
......
......@@ -68,13 +68,13 @@ $filterform = pieform(array(
));
$js = <<< EOF
addLoadEvent(function () {
jQuery(function ($) {
p = {$data['pagination_js']}
connect('filter_submit', 'onclick', function (event) {
replaceChildNodes('messages');
$('#filter_submit').on('click', function (event) {
$('#messages').empty();
var params = {'filter': $('filter_filter').value};
p.sendQuery(params);
event.stop();
event.preventDefault();
});
});
EOF;
......
......@@ -98,7 +98,7 @@ $javascript = array_merge($javascript, $blocktype_js['jsfiles']);
if (is_plugin_active('externalvideo', 'blocktype')) {
$javascript = array_merge($javascript, array((is_https() ? 'https:' : 'http:') . '//cdn.embedly.com/widgets/platform.js'));
}
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
$inlinejs = "jQuery( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
// Set up theme
$viewtheme = $view->get('theme');
......
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