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

Bug 1649741: Eliminate MochiKit from views



behatnotneeded: same functionality

Change-Id: Id97f0ba57dc7154e67407f67b47e547a0f211d24
Signed-off-by: default avataralexeyomelchenko <alexeyomelchenko@catalyst.net.nz>
parent 3745f36e
......@@ -246,19 +246,20 @@ if ($institution) {
'defaultvalue' => $view->get('template') && $view->get('retainview'),
);
$js .= <<< EOF
function update_retainview() {
if ($('editaccess_template').checked) {
removeElementClass($('editaccess_retainview_container'), 'hidden');
}
else {
addElementClass($('editaccess_retainview_container'), 'hidden');
$('editaccess_retainview').checked = false;
update_loggedin_access();
}
};
addLoadEvent(function() {
jQuery(function($) {
function update_retainview() {
if ($('#editaccess_template').prop('checked')) {
$('#editaccess_retainview_container').removeClass('hidden');
}
else {
$('#editaccess_retainview_container').addClass('hidden');
$('#editaccess_retainview').prop('checked',false);
update_loggedin_access();
}
};
update_retainview();
connect('editaccess_template', 'onclick', update_retainview);
$('#editaccess_template').on('click', update_retainview);
});
EOF;
$js .= "function update_loggedin_access() {}\n";
......@@ -270,25 +271,26 @@ if (!$allowcomments) {
$allowcomments = json_encode((int) $allowcomments);
$js .= <<<EOF
var allowcomments = {$allowcomments};
function update_comment_options() {
allowcomments = $('editaccess_allowcomments').checked;
if (allowcomments) {
removeElementClass($('editaccess_approvecomments'), 'hidden');
removeElementClass($('editaccess_approvecomments_container'), 'hidden');
forEach(getElementsByTagAndClassName(null, 'commentcolumn', 'accesslisttable'), function (elem) {
addElementClass(elem, 'hidden');
});
}
else {
addElementClass($('editaccess_approvecomments_container'), 'hidden');
forEach(getElementsByTagAndClassName(null, 'commentcolumn', 'accesslisttable'), function (elem) {
removeElementClass(elem, 'hidden');
});
jQuery(function($) {
var allowcomments = {$allowcomments};
function update_comment_options() {
allowcomments = $('#editaccess_allowcomments').prop('checked');
if (allowcomments) {
$('#editaccess_approvecomments').removeClass('hidden');
$('#editaccess_approvecomments_container').removeClass('hidden');
$('#accesslisttable .commentcolumn').each(function () {
$(this).addClass('hidden');
});
}
else {
$('#editaccess_approvecomments_container').addClass('hidden');
$('#accesslisttable .commentcolumn').each(function () {
$(this).removeClass('hidden');
});
}
}
}
addLoadEvent(function() {
connect('editaccess_allowcomments', 'onclick', update_comment_options);
$('#editaccess_allowcomments').on('click', update_comment_options);
update_comment_options();
});
EOF;
......
......@@ -87,43 +87,51 @@ $js = <<<EOF
templatelist = new SearchTable('templatesearch');
addLoadEvent(function() {
jQuery(function($) {
templatelist.rewriteOther = function () {
forEach(getElementsByTagAndClassName('a', 'grouplink', 'templatesearch'), function(i) {
connect(i, 'onclick', function (e) {
e.stop();
var href = getNodeAttribute(this, 'href');
var params = parseQueryString(href.substring(href.indexOf('?')+1, href.length));
sendjsonrequest(config.wwwroot + 'group/groupinfo.json.php', params, 'POST', partial(showPreview, 'small'));
$('#templatesearch a.grouplink').each(function() {
$(this).on('click', function (e) {
e.preventDefault();
var href = $(this).prop('href');
var params = {
'id': getUrlParameter('id', href)
}
sendjsonrequest(config.wwwroot + 'group/groupinfo.json.php', params, 'POST', showPreview.bind(null, 'small'));
});
});
forEach(getElementsByTagAndClassName('a', 'userlink', 'templatesearch'), function(i) {
connect(i, 'onclick', function (e) {
e.stop();
var href = getNodeAttribute(this, 'href');
var params = parseQueryString(href.substring(href.indexOf('?')+1, href.length));
sendjsonrequest(config.wwwroot + 'user/userdetail.json.php', params, 'POST', partial(showPreview, 'small'));
});
$('#templatesearch a.userlink').each(function() {
jQuery(this).on('click', function (e) {
e.preventDefault();
var href = jQuery(this).prop('href');
var params = {
'id': getUrlParameter('id', href)
}
sendjsonrequest(config.wwwroot + 'user/userdetail.json.php', params, 'POST', showPreview.bind(null, 'small'));
});
});
forEach(getElementsByTagAndClassName('a', 'viewlink', 'templatesearch'), function(i) {
disconnectAll(i);
setNodeAttribute(i, 'title', {$strpreview});
connect(i, 'onclick', function (e) {
e.stop();
var href = getNodeAttribute(this, 'href');
var params = parseQueryString(href.substring(href.indexOf('?')+1, href.length));
sendjsonrequest('viewcontent.json.php', params, 'POST', partial(showPreview, 'big'));
$('#templatesearch a.viewlink').each(function() {
$(this).off();
$(this).prop('title', {$strpreview});
$(this).on('click', function (e) {
e.preventDefault();
var href = $(this).prop('href');
var params = {
'id': getUrlParameter('id', href)
}
sendjsonrequest('viewcontent.json.php', params, 'POST', showPreview.bind(null, 'big'));
});
});
forEach(getElementsByTagAndClassName('a', 'collectionlink', 'templatesearch'), function(i) {
disconnectAll(i);
setNodeAttribute(i, 'title', {$strpreview});
connect(i, 'onclick', function (e) {
e.stop();
var href = getNodeAttribute(this, 'href');
var params = parseQueryString(href.substring(href.indexOf('?')+1, href.length));
sendjsonrequest('../collection/viewcontent.json.php', params, 'POST', partial(showPreview, 'big'));
$('#templatesearch a.collectionlink').each(function() {
$(this).off();
$(this).prop('title', {$strpreview});
$(this).on('click', function (e) {
e.preventDefault();
var href = $(this).prop('href');
var params = {
'id': getUrlParameter('id', href)
}
sendjsonrequest('../collection/viewcontent.json.php', params, 'POST', showPreview.bind(null, 'big'));
});
});
};
......
......@@ -71,25 +71,25 @@ else {
$createviewform = pieform(create_view_form($group->id));
}
$js = <<< EOF
addLoadEvent(function () {
jQuery(function ($) {
p = {$pagination['javascript']}
EOF;
if ($offset > 0) {
$js .= <<< EOF
if ($('groupviews')) {
getFirstElementByTagAndClassName('a', null, 'groupviews').focus();
if ($('#groupviews').length) {
$('#groupviews a:first').focus();
}
if ($('myviews')) {
getFirstElementByTagAndClassName('a', null, 'myviews').focus();
if ($('#myviews').length) {
$('#myviews a:first').focus();
}
EOF;
}
else {
$js .= <<< EOF
if ($('searchresultsheading')) {
addElementClass('searchresultsheading', 'hidefocus');
setNodeAttribute('searchresultsheading', 'tabIndex', -1);
$('searchresultsheading').focus();
if ($('#searchresultsheading').length) {
$('#searchresultsheading').addClass('hidefocus')
.prop('tabIndex', -1)
.focus();
}
EOF;
}
......
......@@ -25,22 +25,22 @@ $offset = param_integer('offset', 0);
list($searchform, $data, $pagination) = View::views_by_owner();
$js = <<< EOF
addLoadEvent(function () {
jQuery(function ($) {
p = {$pagination['javascript']}
EOF;
if ($offset > 0) {
$js .= <<< EOF
if ($('myviews')) {
getFirstElementByTagAndClassName('a', null, 'myviews').focus();
if ($('#myviews').length) {
$('#myviews a').focus();
}
EOF;
}
else {
$js .= <<< EOF
if ($('searchresultsheading')) {
addElementClass('searchresultsheading', 'hidefocus');
setNodeAttribute('searchresultsheading', 'tabIndex', -1);
$('searchresultsheading').focus();
if ($('#searchresultsheading').length) {
$('#searchresultsheading').addClass('hidefocus')
.prop('tabIndex', -1)
.focus();
}
EOF;
}
......
......@@ -43,22 +43,22 @@ if ($institution === false) {
list($searchform, $data, $pagination) = View::views_by_owner(null, $institution);
$js = <<< EOF
addLoadEvent(function () {
jQuery(function ($) {
p = {$pagination['javascript']}
EOF;
if ($offset > 0) {
$js .= <<< EOF
if ($('myviews')) {
getFirstElementByTagAndClassName('a', null, 'myviews').focus();
if ($('#myviews').length) {
$('#myviews a').focus();
}
EOF;
}
else {
$js .= <<< EOF
if ($('searchresultsheading')) {
addElementClass('searchresultsheading', 'hidefocus');
setNodeAttribute('searchresultsheading', 'tabIndex', -1);
$('searchresultsheading').focus();
if ($('#searchresultsheading').length) {
$('#searchresultsheading').addClass('hidefocus')
.prop('tabIndex', -1)
.focus();
}
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