Commit d678d1eb authored by Naomi Guyer's avatar Naomi Guyer Committed by Aaron Wells

Notifications (bootstrap)

Bug 1465107: Use Bootstrap CSS Framework
Fix merge regression
Fix padding on expanded inbox
FIX: sidebar panels

Change-Id: Ie7cbcb185c075c3c80ce9270fef6df482dd7f763
parent c2b85abf
......@@ -65,105 +65,105 @@ $strread = json_encode(get_string('read', 'activity'));
$javascript = <<<JAVASCRIPT
function markread(form, action) {
var e = getElementsByTagAndClassName(null,'tocheck'+action,form);
var pd = {};
for (cb in e) {
if (e[cb].checked == true) {
pd[e[cb].name] = 1;
}
}
if (action == 'read') {
pd['markasread'] = 1;
} else if (action == 'del') {
// If deleting, also pass the ids of unread messages, so we can update
// the unread message count as accurately as possible.
forEach(getElementsByTagAndClassName('input', 'tocheckread', form), function(cb) {
pd[cb.name] = 0;
});
pd['delete'] = 1;
}
if (paginatorData) {
for (p in paginatorData.params) {
pd[p] = paginatorData.params[p];
}
}
sendjsonrequest('index.json.php', pd, 'GET', function (data) {
paginator.updateResults(data);
updateUnreadCount(data);
});
}
function showHideMessage(id) {
var message = $('message-' + id);
if (!message) {
return;
}
if (hasElementClass(message, 'hidden')) {
var unread = getFirstElementByTagAndClassName(
'input', 'tocheckread', message.parentNode.parentNode
);
var subject = getFirstElementByTagAndClassName(
'a', 'inbox-showmessage', message.parentNode
);
var unreadText = getFirstElementByTagAndClassName(
null, 'accessible-hidden', subject
);
if (unread) {
var pd = {'readone':id};
sendjsonrequest('index.json.php', pd, 'GET', function(data) {
swapDOM(unread, IMG({'src' : {$star}, 'alt' : {$strread}}));
updateUnreadCount(data);
removeElementClass(subject, 'unread');
removeElement(unreadText);
});
}
removeElementClass(message, 'hidden');
}
else {
addElementClass(message, 'hidden');
}
}
function changeactivitytype() {
var delallform = document.forms['delete_all_notifications'];
delallform.elements['type'].value = this.options[this.selectedIndex].value;
var params = {'type': this.options[this.selectedIndex].value};
sendjsonrequest('index.json.php', params, 'GET', function(data) {
paginator.updateResults(data);
});
}
// We want the paginator to tell us when a page gets changed.
// @todo: remember checked/unchecked state when changing pages
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);
}
var paginator;
var paginatorData = new PaginatorData();
addLoadEvent(function () {
paginator = {$activitylist['pagination_js']}
connect('notifications_type', 'onchange', changeactivitytype);
});
// function markread(form, action) {
// var e = getElementsByTagAndClassName(null,'tocheck'+action,form);
// var pd = {};
// for (cb in e) {
// if (e[cb].checked == true) {
// pd[e[cb].name] = 1;
// }
// }
// if (action == 'read') {
// pd['markasread'] = 1;
// } else if (action == 'del') {
// // If deleting, also pass the ids of unread messages, so we can update
// // the unread message count as accurately as possible.
// forEach(getElementsByTagAndClassName('input', 'tocheckread', form), function(cb) {
// pd[cb.name] = 0;
// });
// pd['delete'] = 1;
// }
// if (paginatorData) {
// for (p in paginatorData.params) {
// pd[p] = paginatorData.params[p];
// }
// }
// sendjsonrequest('index.json.php', pd, 'GET', function (data) {
// paginator.updateResults(data);
// updateUnreadCount(data);
// });
// }
// function showHideMessage(id) {
// var message = $('message-' + id);
// if (!message) {
// return;
// }
// if (hasElementClass(message, 'hidden')) {
// var unread = getFirstElementByTagAndClassName(
// 'input', 'tocheckread', message.parentNode.parentNode
// );
// var subject = getFirstElementByTagAndClassName(
// 'a', 'inbox-showmessage', message.parentNode
// );
// var unreadText = getFirstElementByTagAndClassName(
// null, 'accessible-hidden', subject
// );
// if (unread) {
// var pd = {'readone':id};
// sendjsonrequest('index.json.php', pd, 'GET', function(data) {
// swapDOM(unread, IMG({'src' : {$star}, 'alt' : {$strread}}));
// updateUnreadCount(data);
// removeElementClass(subject, 'unread');
// removeElement(unreadText);
// });
// }
// removeElementClass(message, 'hidden');
// }
// else {
// addElementClass(message, 'hidden');
// }
// }
// function changeactivitytype() {
// var delallform = document.forms['delete_all_notifications'];
// delallform.elements['type'].value = this.options[this.selectedIndex].value;
// var params = {'type': this.options[this.selectedIndex].value};
// sendjsonrequest('index.json.php', params, 'GET', function(data) {
// paginator.updateResults(data);
// });
// }
// // We want the paginator to tell us when a page gets changed.
// // @todo: remember checked/unchecked state when changing pages
// 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);
// }
// var paginator;
// var paginatorData = new PaginatorData();
// addLoadEvent(function () {
// paginator = {$activitylist['pagination_js']}
// connect('notifications_type', 'onchange', changeactivitytype);
// });
JAVASCRIPT;
......
......@@ -77,139 +77,10 @@ $activitylist = activitylistin_html($type);
$strread = json_encode(get_string('read', 'activity'));
$strnodelete = json_encode(get_string('nodelete', 'activity'));
$javascript = <<<JAVASCRIPT
function markread(form, action) {
var e = getElementsByTagAndClassName(null,'tocheck'+action,form);
var pd = {};
var havedelete = false;
for (cb in e) {
if (e[cb].checked == true) {
pd[e[cb].name] = 1;
havedelete = true;
}
}
// if nothing has been seleced for deletion bail out now with error message
if (!havedelete && action == 'del') {
alert($strnodelete);
return;
}
if (action == 'read') {
pd['markasread'] = 1;
}
else if (action == 'del') {
// If deleting, also pass the ids of unread messages, so we can update
// the unread message count as accurately as possible.
forEach(getElementsByTagAndClassName('input', 'tocheckread', form), function(cb) {
pd[cb.name] = 0;
});
pd['delete'] = 1;
}
if (paginatorData) {
for (p in paginatorData.params) {
pd[p] = paginatorData.params[p];
}
}
sendjsonrequest('indexin.json.php', pd, 'GET', function (data) {
paginator.updateResults(data);
updateUnreadCount(data);
});
}
function toggleMessageDisplay(table, id) {
var messages = jQuery('#message-' + table + '-' + id);
if (messages.length <= 0) {
return;
}
message = messages[0];
messages.parents("tr.unread").removeClass("unread");
if (hasElementClass(message, 'hidden')) {
var unread = getFirstElementByTagAndClassName(
'input', 'tocheckread', message.parentNode.parentNode
);
var unreadicon = getFirstElementByTagAndClassName(
'img', 'unreadmessage', message.parentNode.parentNode
);
if (unread) {
var pd = {'readone':id, 'table':table};
sendjsonrequest('indexin.json.php', pd, 'GET', function(data) {
swapDOM(unread, IMG({'src' : {$star}, 'alt' : {$strread}}));
if (unreadicon) {
swapDOM(unreadicon, IMG({'src' : {$readicon}, 'alt' : getNodeAttribute(unreadicon, 'alt') + ' - ' + {$strread}}));
};
updateUnreadCount(data);
});
}
}
var rows = messages.parents("tr");
if (rows.length > 0) {
if (jQuery(rows[0]).find(".messagedisplaylong.hidden").length > 0) {
jQuery(rows[0]).find(".messagedisplaylong").removeClass("hidden");
jQuery(rows[0]).find(".messagedisplayshort").addClass("hidden");
}
else {
jQuery(rows[0]).find(".messagedisplaylong").addClass("hidden");
jQuery(rows[0]).find(".messagedisplayshort").removeClass("hidden");
}
}
}
function changeactivitytype() {
var delallform = document.forms['delete_all_notifications'];
delallform.elements['type'].value = this.options[this.selectedIndex].value;
var params = {'type': this.options[this.selectedIndex].value};
sendjsonrequest('indexin.json.php', params, 'GET', function(data) {
paginator.updateResults(data);
});
}
// We want the paginator to tell us when a page gets changed.
// @todo: remember checked/unchecked state when changing pages
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);
}
var paginator;
var paginatorData = new PaginatorData();
addLoadEvent(function () {
paginator = {$activitylist['pagination_js']}
connect('notifications_type', 'onchange', changeactivitytype);
});
jQuery(function() {
jQuery('#activitylist tr').hover(
function() {
jQuery(this).addClass('highlight');
},
function() {
jQuery(this).removeClass('highlight');
}
);
});
JAVASCRIPT;
$deleteall = pieform(array(
'name' => 'delete_all_notifications',
'class' => 'form-deleteall',
'class' => 'form-deleteall sr-only',
'method' => 'post',
'plugintype' => 'core',
'pluginname' => 'account',
......@@ -220,7 +91,7 @@ $deleteall = pieform(array(
),
'submit' => array(
'type' => 'submit',
'class' => 'btn btn-danger btn-deleteall',
'class' => 'deleteallnotifications',
'value' => get_string('deleteallnotifications', 'activity'),
'confirm' => get_string('reallydeleteallnotifications', 'activity'),
),
......@@ -315,7 +186,8 @@ $smarty = smarty(array('paginator'),
);
$smarty->assign('options', $options);
$smarty->assign('type', $type);
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->assign('INLINEJAVASCRIPT',null);
$smarty->assign('paginatorData', $activitylist['pagination_js']);
// Adding the links to out- and inbox
$smarty->assign('PAGEHEADING', TITLE);
......
......@@ -32,12 +32,12 @@ if ($readone) {
}
$unread = $USER->add_unread(-1);
$data = array(
'newunreadcount' => $unread,
'newimage' => $THEME->get_image_url($unread ? 'newmail' : 'message'),
'newunreadcount' => $unread
);
json_reply(false, array('data' => $data));
}
require_once(get_config('libroot') . 'activity.php');
$type = param_variable('type', 'all');
......@@ -50,7 +50,7 @@ if ($markasread) {
$ids = array();
$m = array();
foreach ($_GET as $k => $v) {
if (preg_match('/^unread\-([a-zA-Z_]+)\-(\d+)$/',$k,$m)) {
if (preg_match('/^select\-([a-zA-Z_]+)\-(\d+)$/',$k,$m)) {
$list = $m[1];
$ids[$list][] = $m[2];
}
......@@ -75,10 +75,10 @@ if ($markasread) {
$message = get_string('markedasread', 'activity');
}
else if ($delete) {
$rawids = array();
$deleteunread = 0; // Remember the number of unread messages being deleted
$ids = array();
$deleteunread = 0; // Remember the number of unread messages being deleted (this doesn't do that though... it counts the number of message that have mark as read selected)
foreach ($_GET as $k => $v) {
if (preg_match('/^delete\-([a-zA-Z_]+)\-(\d+)$/',$k,$m)) {
if (preg_match('/^select\-([a-zA-Z_]+)\-(\d+)$/',$k,$m)) {
$list = $m[1];
$ids[$list][] = $m[2];
if (isset($_GET['unread-' . $list . '-' . $m[2]])) {
......
......@@ -130,20 +130,17 @@ class PluginArtefactMultirecipientnotification extends PluginArtefact {
public static function submenu_items() {
$tabs = array(
'inbox' => array(
'iconclass' => 'fa fa-inbox',
'url' => 'artefact/multirecipientnotification/inbox.php',
'title' => get_string('labelinbox', 'artefact.multirecipientnotification'),
'tooltip' => get_string('inboxdesc1', 'artefact.multirecipientnotification'),
),
'outbox' => array(
'iconclass' => 'fa fa-paper-plane',
'url' => 'artefact/multirecipientnotification/outbox.php',
'title' => get_string('labeloutbox1', 'artefact.multirecipientnotification'),
'tooltip' => get_string('outboxdesc', 'artefact.multirecipientnotification'),
),
'compose' => array(
'url' => 'artefact/multirecipientnotification/sendmessage.php',
'title' => get_string('composemessage', 'artefact.multirecipientnotification'),
'tooltip' => get_string('composemessagedesc', 'artefact.multirecipientnotification'),
),
)
);
if (defined('NOTIFICATION_SUBPAGE') && isset($tabs[NOTIFICATION_SUBPAGE])) {
$tabs[NOTIFICATION_SUBPAGE]['selected'] = true;
......
......@@ -95,7 +95,7 @@ function activitylistin($type='all', $limit=10, $offset=0) {
* 'limit' => 10,
* 'offset' => 0,
* 'type' => 'all',
* 'tablerows' => '//html ...
* 'html' => '//html ...
* 'pagination' => '// html
* 'pagination_js' => '// javascript
* )
......@@ -130,7 +130,7 @@ function activitylistin_html($type='all', $limit=10, $offset=0) {
'limit' => $limit,
'offset' => $offset,
'type' => $type,
'tablerows' => '',
'html' => '',
'pagination' => $pagination['html'],
'pagination_js' => $pagination['javascript'],
);
......@@ -274,7 +274,7 @@ function activitylistin_html($type='all', $limit=10, $offset=0) {
$smarty->assign('data', $records);
$smarty->assign('USER', $USER);
$smarty->assign('maxnamestrlength', PluginArtefactMultirecipientnotification::MAX_USERNAME_IN_LIST_LENGTH);
$result['tablerows'] = $smarty->fetch('artefact:multirecipientnotification:activitylistin.tpl');
$result['html'] = $smarty->fetch('artefact:multirecipientnotification:activitylistin.tpl');
return $result;
}
......@@ -398,7 +398,7 @@ function activityblocklistin($type='all', $limit=10, $offset=0) {
* 'limit' => 10,
* 'offset' => 0,
* 'type' => 'all',
* 'tablerows' => '//html ...
* 'html' => '//html ...
* 'pagination' => '// html
* 'pagination_js' => '// javascript
* )
......@@ -472,7 +472,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) {
'limit' => $limit,
'offset' => $offset,
'type' => $type,
'tablerows' => '',
'html' => '',
'pagination' => $pagination['html'],
'pagination_js' => $pagination['javascript'],
);
......@@ -605,7 +605,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) {
$smarty->assign('data', $records);
$smarty->assign('USER', $USER);
$smarty->assign('maxnamestrlength', PluginArtefactMultirecipientnotification::MAX_USERNAME_IN_LIST_LENGTH);
$result['tablerows'] = $smarty->fetch('artefact:multirecipientnotification:activitylistout.tpl');
$result['html'] = $smarty->fetch('artefact:multirecipientnotification:activitylistout.tpl');
return $result;
}
......@@ -72,119 +72,10 @@ $star = json_encode($THEME->get_image_url('star'));
$readicon = json_encode($THEME->get_image_url('readusermessage'));
$strread = json_encode(get_string('read', 'activity'));
$strnodelete = json_encode(get_string('nodelete', 'activity'));
$javascript = <<<JAVASCRIPT
function markread(form, action) {
var e = getElementsByTagAndClassName(null,'tocheck'+action,form);
var pd = {};
var havedelete = false;
for (cb in e) {
if (e[cb].checked == true) {
pd[e[cb].name] = 1;
havedelete = true;
}
}
// if nothing has been seleced for deletion bail out now with error message
if (!havedelete && action == 'del') {
alert($strnodelete);
return;
}
if (action == 'read') {
pd['markasread'] = 1;
}
else if (action == 'del') {
// If deleting, also pass the ids of unread messages, so we can update
// the unread message count as accurately as possible.
forEach(getElementsByTagAndClassName('input', 'tocheckread', form), function(cb) {
pd[cb.name] = 0;
});
pd['delete'] = 1;
}
if (paginatorData) {
for (p in paginatorData.params) {
pd[p] = paginatorData.params[p];
}
}
sendjsonrequest('indexout.json.php', pd, 'GET', function (data) {
paginator.updateResults(data);
updateUnreadCount(data);
});
}
function toggleMessageDisplay(table, id) {
var messages = jQuery('#message-' + table + '-' + id);
if (messages.length <= 0) {
return;
}
var rows = messages.parents("tr");
if (rows.length > 0) {
if (jQuery(rows[0]).find(".messagedisplaylong.hidden").length > 0) {
jQuery(rows[0]).find(".messagedisplaylong").removeClass("hidden");
jQuery(rows[0]).find(".messagedisplayshort").addClass("hidden");
}
else {
jQuery(rows[0]).find(".messagedisplaylong").addClass("hidden");
jQuery(rows[0]).find(".messagedisplayshort").removeClass("hidden");
}
}
}
function changeactivitytype() {
var delallform = document.forms['delete_all_notifications'];
delallform.elements['type'].value = this.options[this.selectedIndex].value;
var params = {'type': this.options[this.selectedIndex].value};
sendjsonrequest('indexout.json.php', params, 'GET', function(data) {
paginator.updateResults(data);
});
}
// We want the paginator to tell us when a page gets changed.
// @todo: remember checked/unchecked state when changing pages
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);
}
var paginator;
var paginatorData = new PaginatorData();
addLoadEvent(function () {
paginator = {$activitylist['pagination_js']}
connect('notifications_type', 'onchange', changeactivitytype);
});
jQuery(function() {
jQuery('#activitylist tr').hover(
function() {
jQuery(this).addClass('highlight');
},
function() {
jQuery(this).removeClass('highlight');
}
);
});
JAVASCRIPT;
$deleteall = pieform(array(
'name' => 'delete_all_notifications',
'class' => 'form-deleteall',
'class' => 'form-deleteall sr-only',
'method' => 'post',
'plugintype' => 'core',
'pluginname' => 'account',
......@@ -195,7 +86,7 @@ $deleteall = pieform(array(
),
'submit' => array(
'type' => 'submit',
'class' => 'btn btn-danger btn-deleteall',
'class' => 'deleteallnotifications',
'value' => get_string('deleteallnotifications', 'activity'),
'confirm' => get_string('reallydeleteallnotifications', 'activity'),
),
......@@ -247,7 +138,7 @@ $smarty = smarty(array('paginator'),
);
$smarty->assign('options', $options);
$smarty->assign('type', $type);
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->assign('INLINEJAVASCRIPT', null);
// Adding the links to out- and inbox
$smarty->assign('PAGEHEADING', TITLE);
......
......@@ -1243,7 +1243,7 @@ function auth_get_login_form() {
function auth_get_login_form_elements() {
// See if user can register
if (count_records('institution', 'registerallowed', 1, 'suspended', 0)) {
$registerlink = '<a href="' . get_config('wwwroot') . 'register.php">' . get_string('register') . '</a><br>';
$registerlink = '<a class="btn btn-primary btn-xs" href="' . get_config('wwwroot') . 'register.php">' .