Commit a7e4e472 authored by alexeyomelchenko's avatar alexeyomelchenko Committed by Alexey Omelchenko
Browse files

Bug 1649435: Eliminate MochiKit from Theme



behatnotneeded: same functionality

Change-Id: I700c5d291d713b9222d19d2c059c9100275f8cea
Signed-off-by: default avataralexeyomelchenko <alexeyomelchenko@catalyst.net.nz>
parent 08b6177d
......@@ -32,9 +32,9 @@
{/if}
{if $posts.pagination_js}
<script>
addLoadEvent(function() {literal}{{/literal}
jQuery(function($) {literal}{{/literal}
{$posts.pagination_js|safe}
removeElementClass('blogpost_page_container{if $blockid}_{$blockid}{/if}', 'hidden');
$('#blogpost_page_container{if $blockid}_{$blockid}{/if}').removeClass('hidden');
{literal}}{/literal});
</script>
{/if}
......
......@@ -27,9 +27,9 @@
</div>
<div id="blogpost_page_container" class="hidden">{$posts.pagination|safe}</div>
<script>
addLoadEvent(function() {literal}{{/literal}
jQuery(function($) {literal}{{/literal}
{$posts.pagination_js|safe}
removeElementClass('blogpost_page_container', 'hidden');
$('#blogpost_page_container').removeClass('hidden');
{literal}}{/literal});
</script>
{else}
......
......@@ -16,9 +16,9 @@
{$tasks.pagination|safe}
</div>
<script>
addLoadEvent(function() {literal}{{/literal}
jQuery(function($) {literal}{{/literal}
{$tasks.pagination_js|safe}
removeElementClass('plans_page_container_{$blockid}', 'hidden');
$('#plans_page_container_{$blockid}').removeClass('hidden');
{literal}}{/literal});
</script>
{/if}
......
......@@ -13,9 +13,9 @@
{if $groupviews.pagination_js}
<script>
addLoadEvent(function() {literal}{{/literal}
jQuery(function($) {literal}{{/literal}
{$groupviews.pagination_js|safe}
removeElementClass('groupviews_page_container', 'hidden');
$('#groupviews_page_container').removeClass('hidden');
{literal}}{/literal});
</script>
{/if}
......@@ -44,9 +44,9 @@
{if $sharedviews.pagination_js}
<script>
addLoadEvent(function() {literal}{{/literal}
jQuery(function($) {literal}{{/literal}
{$sharedviews.pagination_js|safe}
removeElementClass('sharedviews_page_container', 'hidden');
$('#sharedviews_page_container').removeClass('hidden');
{literal}}{/literal});
</script>
{/if}
......@@ -76,9 +76,9 @@
{if $sharedcollections.pagination_js}
<script>
addLoadEvent(function() {literal}{{/literal}
jQuery(function($) {literal}{{/literal}
{$sharedcollections.pagination_js|safe}
removeElementClass('sharedcollections_page_container', 'hidden');
$('#sharedcollections_page_container').removeClass('hidden');
{literal}}{/literal});
</script>
{/if}
......@@ -105,9 +105,9 @@
{/if}
{if $allsubmitted.pagination_js}
<script>
addLoadEvent(function() {literal}{{/literal}
jQuery(function($) {literal}{{/literal}
{$allsubmitted.pagination_js|safe}
removeElementClass('allsubmitted_page_container', 'hidden');
$('#allsubmitted_page_container').removeClass('hidden');
{literal}}{/literal});
</script>
{/if}
......
......@@ -7,11 +7,11 @@
{$friends.pagination|safe}
</div>
<script>
addLoadEvent(function() {literal}{{/literal}
jQuery(function($) {literal}{{/literal}
{$friends.pagination_js|safe}
removeElementClass('myfriends_page_container', 'hidden');
jQuery(window).on('pageupdated', { }, function() {
jQuery('.js-masonry.user-thumbnails').masonry({ itemSelector: '.user-icon' });
$('#myfriends_page_container').removeClass('hidden');
$(window).on('pageupdated', { }, function() {
$('.js-masonry.user-thumbnails').masonry({ itemSelector: '.user-icon' });
});
{literal}}{/literal});
</script>
......
......@@ -8,9 +8,9 @@
{if $USERGROUPS.pagination_js}
<script>
var cleanurlid = {$userid};
addLoadEvent(function() {literal}{{/literal}
jQuery(function($) {literal}{{/literal}
{$USERGROUPS.pagination_js|safe}
removeElementClass('usergroups_page_container', 'hidden');
$('#usergroups_page_container').removeClass('hidden');
{literal}}{/literal});
</script>
{/if}
......
......@@ -8,9 +8,9 @@
{/if}
{if $myviews.pagination_js}
<script type="application/javascript">
addLoadEvent(function() {literal}{{/literal}
jQuery(function($) {literal}{{/literal}
{$myviews.pagination_js|safe}
removeElementClass('myviews_page_container', 'hidden');
$('#myviews_page_container').removeClass('hidden');
{literal}}{/literal});
</script>
{/if}
......@@ -18,4 +18,3 @@
{else}
<p class="content-text lead text-center">{str tag='noviewstosee' section='group'}</p>
{/if}
......@@ -11,9 +11,9 @@
{/if}
{if $watchlist.pagination_js}
<script type="application/javascript">
jQuery(function() {literal}{{/literal}
jQuery(function($) {literal}{{/literal}
{$watchlist.pagination_js|safe}
removeElementClass('watchlist_page_container', 'hidden');
$('#watchlist_page_container').removeClass('hidden');
{literal}}{/literal});
</script>
{/if}
......
......@@ -8,7 +8,7 @@
<script type="application/javascript">
{{if !$inblockconfig}}
addLoadEvent(function () {
jQuery(window).load(function () {
{{/if}}
jQuery("#{{$id}}").select2({
ajax: {
......
......@@ -20,8 +20,8 @@
var {{$name}}_newref = null;
function {{$name}}_addedemail() {
removeElement({{$name}}_newrefinput);
removeElement({{$name}}_newref);
jQuery("#{{$name}}_newrefinput").remove();
jQuery("#{{$name}}_newref").remove();
var newEmail = {{$name}}_newrefinput.value;
if (typeof(newEmail) == 'string' && newEmail.length > 0) {
if (newEmail.length > 255) {
......@@ -29,16 +29,15 @@
}
else {
var email = {{$name}}_newrefinput.value;
appendChildNodes('{{$name}}_list', DIV({'class': 'unsent'},
INPUT({'type': 'hidden', 'name': '{{$name}}_unsent[]' , 'value': email}),
jQuery('#{{$name}}_list').append(jQuery('<div>', {'class': 'unsent'}).append(
jQuery('<input>', {'type': 'hidden', 'name': '{{$name}}_unsent[]' , 'value': email}),
' ',
SPAN({'class': 'pseudolabel no-radio'}, email),' ',
BUTTON({'class': 'btn btn-default btn-sm', 'onclick': '{{$name}}_remove(this); return false'},
SPAN({'class': 'icon icon-times left icon-lg text-danger', 'role': 'presentation'}),
SPAN('{{str tag=delete}}')
jQuery('<span>', {'class': 'pseudolabel no-radio'}).append(email),' ',
jQuery('<button>', {'class': 'btn btn-default btn-sm', 'onclick': '{{$name}}_remove(this); return false'}).append(
jQuery('<span>', {'class': 'icon icon-times left icon-lg text-danger', 'role': 'presentation'}),
jQuery('<span>', {'text': '{{str tag=delete}}'})
),
DIV({'class': 'clearfix metadata validation-message'}, {{$validationemailstr|safe}})
//' ' + {{$validationemailstr|safe}}
jQuery('<div>', {'class': 'clearfix metadata validation-message'}).append({{$validationemailstr|safe}})
));
if (typeof formchangemanager !== 'undefined') {
var form = jQuery(this).closest('form')[0];
......@@ -56,24 +55,24 @@
return false;
}
{{$name}}_newrefinput = INPUT({'type': 'text', 'id': 'addnew{{$name}}', 'class': 'form-control'});
{{$name}}_newrefsubmit = INPUT({'type': 'submit', 'class': 'btn btn-default', 'value': '{{$addbuttonstr}}'});
{{$name}}_newref = DIV({'class': 'input-group'},{{$name}}_newrefinput,' ',{{$name}}_newrefsubmit);
{{$name}}_newrefinput = jQuery('<input>', {'type': 'text', 'id': 'addnew{{$name}}', 'class': 'form-control'});
{{$name}}_newrefsubmit = jQuery('<input>', {'type': 'submit', 'class': 'btn btn-default', 'value': '{{$addbuttonstr}}'});
{{$name}}_newref = jQuery('<div>', {'class': 'input-group'}).append({{$name}}_newrefinput,' ',{{$name}}_newrefsubmit);
appendChildNodes('{{$name}}_list', {{$name}}_newref);
jQuery('#{{$name}}_list').append({{$name}}_newref);
{{$name}}_newrefinput.focus();
connect({{$name}}_newrefinput, 'onchange', function(k) {
{{$name}}_newrefinput.on('change', function(k) {
if (typeof formchangemanager !== 'undefined') {
var form = jQuery(this).closest('form')[0];
formchangemanager.setFormState(form, FORM_CHANGED);
}
});
connect({{$name}}_newrefsubmit, 'onclick', function(k) {
{{$name}}_newrefsubmit.on('click', function(k) {
{{$name}}_addedemail();
k.stop();
k.preventDefault();
});
}
......@@ -81,8 +80,8 @@
var div = x.parentNode;
var radio = filter(
function(elem) { return getNodeAttribute(elem, 'type') == 'radio'; },
getElementsByTagAndClassName('input', null, div)
function(elem) { return jQuery(elem).prop('type') === 'radio'; },
jQuery(div).find('input')
);
if (radio[0] && radio[0].checked) {
......@@ -95,7 +94,7 @@
formchangemanager.setFormState(form, FORM_CHANGED);
}
removeElement(x.parentNode);
jQuery(x.parentNode).remove();
}
</script>
<div id="{{$name}}_list" class="{{$name}}-list email-list">
......
......@@ -6,12 +6,11 @@
function {{$name}}_new() {
{{$name}}_current++;
var id = '{{$name}}_files_' + {{$name}}_current;
{{$name}}_newlabel = LABEL({'for': id, 'class': 'sr-only'}, $('{{$name}}_files_label').innerHTML);
{{$name}}_newrefinput = INPUT({'type': 'file', 'id': id, 'name': id, 'class': 'file'});
var {{$name}}_newref = DIV({'class': 'file-wrapper'
},{{$name}}_newlabel, {{$name}}_newrefinput);
{{$name}}_newlabel = jQuery('<label>', {'for': id, 'class': 'sr-only'}).append(jQuery('#{{$name}}_files_label').html());
{{$name}}_newrefinput = jQuery('<input>', {'type': 'file', 'id': id, 'name': id, 'class': 'file'});
var {{$name}}_newref = jQuery('<div>', {'class': 'file-wrapper'}).append({{$name}}_newlabel, {{$name}}_newrefinput);
appendChildNodes('{{$name}}_list', {{$name}}_newref);
jQuery('#{{$name}}_list').append({{$name}}_newref);
{{$name}}_newrefinput.focus();
}
......
......@@ -5,10 +5,10 @@
function {{$name}}_new() {
{{$name}}_current++;
{{$name}}_newrefinput = INPUT({'type': 'text', 'name': '{{$name}}[' + {{$name}}_current + ']'});
var {{$name}}_newref = DIV(null, {{$name}}_newrefinput);
{{$name}}_newrefinput = jQuery('<input>', {'type': 'text', 'name': '{{$name}}[' + {{$name}}_current + ']'});
var {{$name}}_newref = jQuery('<div>').append({{$name}}_newrefinput);
appendChildNodes('{{$name}}_list', {{$name}}_newref);
jQuery('#{{$name}}_list').append({{$name}}_newref);
{{$name}}_newrefinput.focus();
}
......@@ -17,7 +17,7 @@
{{foreach from=$value key=k item=v}}
<div>
<input type="text" name="{{$name}}[{{$k}}]" value="{{$v}}">
<a href="" onclick="removeElement(this.parentNode); return false;">[x]</a>
<a href="" onclick="jQuery(this.parentNode).remove(); return false;">[x]</a>
</div>
{{/foreach}}
<div>
......
......@@ -5,7 +5,7 @@
var {{$name}}_searchfunc = function (params) {
replaceChildNodes('{{$name}}_messages');
jQuery("#{{$name}}_messages").empty();
{{if $group}}
{{$name}}_searchparams['group'] = {{$group}};
......@@ -20,7 +20,7 @@
function (users) {
var members = {};
var counter = 0;
forEach($('{{$name}}_members').childNodes, function(node) {
jQuery('#{{$name}}_members').children().each(function(id, node) {
if (node.nodeName == 'OPTION') {
members[node.value] = 1;
counter++;
......@@ -30,95 +30,94 @@
var results = [];
if (users.data) {
forEach(users.data, function(user) {
jQuery.each(users.data, function(id, user) {
if (members[user.id]) {
return;
}
//appendChildNodes('{{$name}}_potential',OPTION({'value':user.id},user.name));
results.push(OPTION({'value':user.id},user.name));
results.push(jQuery('<option>', {'value':user.id, 'text': user.name}));
});
}
replaceChildNodes('{{$name}}_potential', results);
jQuery('#{{$name}}_potential').empty().append(results);
if (typeof params.query != 'undefined') {
$('{{$name}}_potential').focus();
jQuery('#{{$name}}_potential')[0].focus();
}
if(users.count > users.limit) {
replaceChildNodes('{{$name}}_messages',
DIV(null,
{{$onlyshowingfirst|safe}}, ' ',
SPAN({'id': '{{$name}}_userlimit'}, users.limit),
' ', {{$resultsof|safe}}, ' ',
SPAN({'id': '{{$name}}_usercount'}, users.count - counter)
jQuery('#{{$name}}_messages').empty().append(
jQuery('<div>').append(
{{$onlyshowingfirst|safe}}, ' ',
jQuery('<span>', {'id': '{{$name}}_userlimit', 'text': users.limit }),
' ', {{$resultsof|safe}}, ' ',
jQuery('<span>', {'id': '{{$name}}_usercount', 'text': users.count - counter })
)
);
}
});
}
addLoadEvent(function () {
removeElement($('{{$name}}_potential').childNodes[0]);
removeElement($('{{$name}}_members').childNodes[0]);
jQuery(function ($) {
$('#{{$name}}_potential :first').remove();
$('#{{$name}}_members :first').remove();
{{$name}}_searchparams = {{$searchparams|safe}};
{{$name}}_searchfunc({});
jQuery('#{{$name}}_search').keypress(function(k) {
$('#{{$name}}_search').keypress(function(k) {
if (k.keyCode == 13) {
{{$name}}_searchfunc({'query': $('{{$name}}_search').value});
{{$name}}_searchfunc({'query': $('#{{$name}}_search').val()});
k.preventDefault();
}
});
jQuery('#{{$name}}_search_btn').click(function(e) {
{{$name}}_searchfunc({'query': $('{{$name}}_search').value});
$('#{{$name}}_search_btn').click(function(e) {
{{$name}}_searchfunc({'query': $('#{{$name}}_search').val()});
e.preventDefault();
});
});
function {{$name}}_moveopts(from,to) {
var from = $('{{$name}}_' + from);
var to = $('{{$name}}_' + to);
var from = jQuery('#{{$name}}_' + from);
var to = jQuery('#{{$name}}_' + to);
var list = new Array();
forEach(from.childNodes, function(opt) {
if (!opt.selected) {
from.children().each(function() {
if (!this.selected) {
return;
}
list.push(opt);
list.push(this);
});
if (list.length === 0) {
return;
}
forEach(list, function(node) {
to.appendChild(node);
node.selected = false;
jQuery.each(list, function() {
to.append(this);
jQuery(this).prop('selected', false);
});
// Update the counters if they are present
if ($('{{$name}}_userlimit')) {
if (from.id == '{{$name}}_potential') {
replaceChildNodes('{{$name}}_userlimit', parseInt($('{{$name}}_userlimit').innerHTML, 10) - list.length);
replaceChildNodes('{{$name}}_usercount', parseInt($('{{$name}}_usercount').innerHTML, 10) - list.length);
if (jQuery('#{{$name}}_userlimit').length) {
if (from.id === '{{$name}}_potential') {
jQuery('#{{$name}}_userlimit').empty().append(parseInt(jQuery('#{{$name}}_userlimit').html(), 10) - list.length);
jQuery('#{{$name}}_usercount').empty().append(parseInt(jQuery('#{{$name}}_usercount').html(), 10) - list.length);
}
else {
replaceChildNodes('{{$name}}_userlimit', parseInt($('{{$name}}_userlimit').innerHTML, 10) + list.length);
replaceChildNodes('{{$name}}_usercount', parseInt($('{{$name}}_usercount').innerHTML, 10) + list.length);
jQuery('#{{$name}}_userlimit').empty().append(parseInt(jQuery('#{{$name}}_userlimit').html(), 10) + list.length);
jQuery('#{{$name}}_usercount').empty().append(parseInt(jQuery('#{{$name}}_usercount').html(), 10) + list.length);
}
}
var members = new Array();
forEach($('{{$name}}_members').childNodes, function(node) {
jQuery('#{{$name}}_members').children().each(function(i, node) {
if (typeof(node) == 'object' && typeof(node.value) == 'string') {
members.push(node.value);
}
});
$('{{$name}}').value=members.join(',');
jQuery('#{{$name}}').val(members.join(','));
if (typeof formchangemanager !== 'undefined') {
var form = jQuery('select#{{$name}}_members').closest('form')[0];
formchangemanager.setFormState(form, FORM_CHANGED);
......@@ -127,9 +126,9 @@
to.focus();
};
addLoadEvent(function () {
connect('{{$name}}_potential', 'ondblclick', function (event) { {{$name}}_moveopts('potential','members') });
connect('{{$name}}_members', 'ondblclick', function (event) { {{$name}}_moveopts('members','potential') });
jQuery(function ($) {
$('#{{$name}}_potential').on('dblclick', function (event) { {{$name}}_moveopts('potential','members') });
$('#{{$name}}_members', 'ondblclick', function (event) { {{$name}}_moveopts('members','potential') });
});
</script>
<table class="userlisttable fullwidth">
......
......@@ -51,11 +51,11 @@
{if $sbdata.count > 1}
<!-- @todo move this to somewhere better - it shouldn't be rendered in the middle of a page -->
<script language="javascript">
function reloadSideBar() {
window.location.href = window.location.href.split('?')[0]+'?i='+$('progresssidebarselect_institution').value;
}
addLoadEvent(function() {
connect($('progresssidebarselect_institution'), 'onchange', reloadSideBar);
jQuery(function($) {
function reloadSideBar() {
window.location.href = window.location.href.split('?')[0]+'?i='+$('#progresssidebarselect_institution').val();
}
$('#progresssidebarselect_institution').on('change', reloadSideBar);
});
</script>
{/if}
......
......@@ -14,8 +14,8 @@ $j('#blockinstance_{$id} .retractor').click(function (e) {literal}{{/literal}
{literal}}{/literal}
e.preventDefault();
{literal}}{/literal});
addLoadEvent(function() {literal}{{/literal}
var $content = $j('#blockinstance_{$id} > .blockinstance-content');
jQuery(function($) {literal}{{/literal}
var $content = $('#blockinstance_{$id} > .blockinstance-content');
if (!$content.hasClass('js-hidden')) {literal}{{/literal}
return;
{literal}}{/literal}
......
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