Commit 14a66f86 authored by alexeyomelchenko's avatar alexeyomelchenko
Browse files

Bug 1650092: Eliminate MochiKit from Mahara Libs



behatnotneeded: same functionality

Change-Id: I5b15cfdece9a02cd24df9c7cb34898588d08f57e
Signed-off-by: default avataralexeyomelchenko <alexeyomelchenko@catalyst.net.nz>
parent 3745f36e
......@@ -34,13 +34,13 @@ function pieform_element_color(Pieform $form, $element) {
var {$baseid}_oldval = '';
function {$baseid}_toggle(x) {
if ( x.checked ) {
{$baseid}_oldval = $('{$baseid}').value;
$('{$baseid}').value = '';
$('{$baseid}').disabled = true;
{$baseid}_oldval = jQuery('#{$baseid}').val();
jQuery('#{$baseid}').val('');
jQuery('#{$baseid}').prop('disabled', true);
}
else {
$('{$baseid}').value = {$baseid}_oldval;
$('{$baseid}').disabled = false;
jQuery('#{$baseid}').val({$baseid}_oldval);
jQuery('#{$baseid}').prop('disabled', false);
}
}
</script>
......
......@@ -185,7 +185,7 @@ function pieform_element_filebrowser(Pieform $form, $element) {
$_PIEFORM_FILEBROWSERS[$prefix]['views_js'] = $initjs;
$initjs .= "addLoadEvent({$prefix}.init);";
$initjs .= "jQuery({$prefix}.init);";
$initjs .= "upload_max_filesize = '" . get_real_size(ini_get('upload_max_filesize')) . "';";
if ($form->is_submitted() && $form->has_errors()) {
// need to reapply bootstrap file browser stuff
......
......@@ -33,9 +33,9 @@ function pieform_element_passwordnoread(Pieform $form, $element) {
$linktext = isset($element['expandtext']) ? hsc($element['expandtext']) : get_string('changepassword');
$html = '<a href="" '
. "onclick=\""
. "addElementClass('${inputid}_expand', 'hidden'); "
. "jQuery('#${inputid}_expand').addClass('hidden'); "
. "jQuery('#{$inputid}').attr('name', '{$element['name']}');"
. "removeElementClass('{$inputid}', 'hidden'); "
. "jQuery('#{$inputid}').removeClass('hidden'); "
. "return false;"
. "\" id=\"${inputid}_expand\">" . $linktext . '</a>';
$element['class'] .= ' hidden';
......
......@@ -88,7 +88,7 @@ function pieform_element_wysiwyg_get_headdata() {
foreach ($_PIEFORM_WYSIWYGS as $name => $editor) {
$result .= " if (!arguments[0] || arguments[0]=='{$name}') {\n";
$result .= " tinyMCE.execCommand('mceAddEditor', false, '$editor');\n";
$result .= " $('{$editor}').focus = function() {\n";
$result .= " jQuery('#{$editor}').focus = function() {\n";
$result .= " editor_to_focus = '$editor';\n";
$result .= " };\n";
$result .= " };\n";
......
......@@ -127,18 +127,19 @@ function pieform_renderer_maharatable_get_js($id) {
$result = <<<EOF
function {$id}_set_error(message, element) {
element = '{$id}_' + element + '_container';
var container = getFirstElementByTagAndClassName('TD', null, $(element));
addElementClass(container, 'error');
addElementClass(container.firstChild, 'error');
insertSiblingNodesAfter($(element), TR({'id': '{$id}_error_' + element}, TD({'class': 'errmsg'}, message)));
var container = jQuery('#' + element).find('td').first();
container.addClass('error');
container.children().first().addClass('error');
jQuery('<tr>', {'id': '{$id}_error_' + element}).append(jQuery('<td>', {'class': 'errmsg', 'text': message} ))
.insertAfter(jQuery('#' + element));
}
function {$id}_remove_all_errors() {
forEach(getElementsByTagAndClassName('TD', 'errmsg', $('$id')), function(item) {
removeElement(item.parentNode);
jQuery('#$id td.errmsg').each(function() {
jQuery(this).parent().remove();
});
forEach(getElementsByTagAndClassName('TD', 'error', $('$id')), function(item) {
removeElementClass(item, 'error');
removeElementClass(item.firstChild, 'error');
jQuery('#$id td.error').each(function() {
jQuery(this).removeClass('error');
jQuery(this).children().first().removeClass('error');
});
}
EOF;
......
......@@ -929,23 +929,24 @@ function institution_selector_for_page($institution, $page) {
$page = json_encode($page);
$js = <<< EOF
function reloadUsers() {
var urlstr = $page;
var inst = '';
if ($('institutionselect_institution')) {
inst = 'institution='+$('institutionselect_institution').value;
if (urlstr.indexOf('?') > 0) {
urlstr = urlstr + '&' + inst;
}
else {
urlstr = urlstr + '?' + inst;
jQuery(function($) {
function reloadUsers() {
var urlstr = $page;
var inst = '';
if ($('#institutionselect_institution').length) {
inst = 'institution=' + $('#institutionselect_institution').val();
if (urlstr.indexOf('?') > 0) {
urlstr = urlstr + '&' + inst;
}
else {
urlstr = urlstr + '?' + inst;
}
}
window.location.href = urlstr;
}
window.location.href = urlstr;
}
addLoadEvent(function() {
if ($('institutionselect_institution')) {
connect($('institutionselect_institution'), 'onchange', reloadUsers);
if ($('#institutionselect_institution').length) {
$('#institutionselect_institution').on('change', reloadUsers);
}
});
EOF;
......
......@@ -40,7 +40,7 @@ function pieform_element_text(Pieform $form, $element) {/*{{{*/
$inputid = hsc($form->get_name() . '_' . $element['name']);
$linktext = $element['expandtext'] ? hsc($element['expandtext']) : get_string('edit');
$html .= '<a class="btn btn-default" href="" '
. "onclick=\"addElementClass('${inputid}_expand', 'hidden'); removeElementClass('{$inputid}', 'hidden'); return false;\""
. "onclick=\"jQuery('#${inputid}_expand').addClass('hidden'); jQuery('#{$inputid}').removeClass('hidden'); return false;\""
. "id=\"${inputid}_expand\">" . $linktext . '</a>';
$element['class'] .= ' hidden';
}
......
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