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

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')); ...@@ -65,105 +65,105 @@ $strread = json_encode(get_string('read', 'activity'));
$javascript = <<<JAVASCRIPT $javascript = <<<JAVASCRIPT
function markread(form, action) { // function markread(form, action) {
var e = getElementsByTagAndClassName(null,'tocheck'+action,form); // var e = getElementsByTagAndClassName(null,'tocheck'+action,form);
var pd = {}; // var pd = {};
for (cb in e) { // for (cb in e) {
if (e[cb].checked == true) { // if (e[cb].checked == true) {
pd[e[cb].name] = 1; // pd[e[cb].name] = 1;
} // }
} // }
if (action == 'read') { // if (action == 'read') {
pd['markasread'] = 1; // pd['markasread'] = 1;
} else if (action == 'del') { // } else if (action == 'del') {
// If deleting, also pass the ids of unread messages, so we can update // // If deleting, also pass the ids of unread messages, so we can update
// the unread message count as accurately as possible. // // the unread message count as accurately as possible.
forEach(getElementsByTagAndClassName('input', 'tocheckread', form), function(cb) { // forEach(getElementsByTagAndClassName('input', 'tocheckread', form), function(cb) {
pd[cb.name] = 0; // pd[cb.name] = 0;
}); // });
pd['delete'] = 1; // pd['delete'] = 1;
} // }
if (paginatorData) { // if (paginatorData) {
for (p in paginatorData.params) { // for (p in paginatorData.params) {
pd[p] = paginatorData.params[p]; // pd[p] = paginatorData.params[p];
} // }
} // }
sendjsonrequest('index.json.php', pd, 'GET', function (data) { // sendjsonrequest('index.json.php', pd, 'GET', function (data) {
paginator.updateResults(data); // paginator.updateResults(data);
updateUnreadCount(data); // updateUnreadCount(data);
}); // });
} // }
function showHideMessage(id) { // function showHideMessage(id) {
var message = $('message-' + id); // var message = $('message-' + id);
if (!message) { // if (!message) {
return; // return;
} // }
if (hasElementClass(message, 'hidden')) { // if (hasElementClass(message, 'hidden')) {
var unread = getFirstElementByTagAndClassName( // var unread = getFirstElementByTagAndClassName(
'input', 'tocheckread', message.parentNode.parentNode // 'input', 'tocheckread', message.parentNode.parentNode
); // );
var subject = getFirstElementByTagAndClassName( // var subject = getFirstElementByTagAndClassName(
'a', 'inbox-showmessage', message.parentNode // 'a', 'inbox-showmessage', message.parentNode
); // );
var unreadText = getFirstElementByTagAndClassName( // var unreadText = getFirstElementByTagAndClassName(
null, 'accessible-hidden', subject // null, 'accessible-hidden', subject
); // );
if (unread) { // if (unread) {
var pd = {'readone':id}; // var pd = {'readone':id};
sendjsonrequest('index.json.php', pd, 'GET', function(data) { // sendjsonrequest('index.json.php', pd, 'GET', function(data) {
swapDOM(unread, IMG({'src' : {$star}, 'alt' : {$strread}})); // swapDOM(unread, IMG({'src' : {$star}, 'alt' : {$strread}}));
updateUnreadCount(data); // updateUnreadCount(data);
removeElementClass(subject, 'unread'); // removeElementClass(subject, 'unread');
removeElement(unreadText); // removeElement(unreadText);
}); // });
} // }
removeElementClass(message, 'hidden'); // removeElementClass(message, 'hidden');
} // }
else { // else {
addElementClass(message, 'hidden'); // addElementClass(message, 'hidden');
} // }
} // }
function changeactivitytype() { // function changeactivitytype() {
var delallform = document.forms['delete_all_notifications']; // var delallform = document.forms['delete_all_notifications'];
delallform.elements['type'].value = this.options[this.selectedIndex].value; // delallform.elements['type'].value = this.options[this.selectedIndex].value;
var params = {'type': this.options[this.selectedIndex].value}; // var params = {'type': this.options[this.selectedIndex].value};
sendjsonrequest('index.json.php', params, 'GET', function(data) { // sendjsonrequest('index.json.php', params, 'GET', function(data) {
paginator.updateResults(data); // paginator.updateResults(data);
}); // });
} // }
// We want the paginator to tell us when a page gets changed. // // We want the paginator to tell us when a page gets changed.
// @todo: remember checked/unchecked state when changing pages // // @todo: remember checked/unchecked state when changing pages
function PaginatorData() { // function PaginatorData() {
var self = this; // var self = this;
var params = {}; // var params = {};
this.pageChanged = function(data) { // this.pageChanged = function(data) {
self.params = { // self.params = {
'offset': data.offset, // 'offset': data.offset,
'limit': data.limit, // 'limit': data.limit,
'type': data.type // 'type': data.type
} // }
} // }
paginatorProxy.addObserver(self); // paginatorProxy.addObserver(self);
connect(self, 'pagechanged', self.pageChanged); // connect(self, 'pagechanged', self.pageChanged);
} // }
var paginator; // var paginator;
var paginatorData = new PaginatorData(); // var paginatorData = new PaginatorData();
addLoadEvent(function () { // addLoadEvent(function () {
paginator = {$activitylist['pagination_js']} // paginator = {$activitylist['pagination_js']}
connect('notifications_type', 'onchange', changeactivitytype); // connect('notifications_type', 'onchange', changeactivitytype);
}); // });
JAVASCRIPT; JAVASCRIPT;
......
...@@ -77,139 +77,10 @@ $activitylist = activitylistin_html($type); ...@@ -77,139 +77,10 @@ $activitylist = activitylistin_html($type);
$strread = json_encode(get_string('read', 'activity')); $strread = json_encode(get_string('read', 'activity'));
$strnodelete = json_encode(get_string('nodelete', '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( $deleteall = pieform(array(
'name' => 'delete_all_notifications', 'name' => 'delete_all_notifications',
'class' => 'form-deleteall', 'class' => 'form-deleteall sr-only',
'method' => 'post', 'method' => 'post',
'plugintype' => 'core', 'plugintype' => 'core',
'pluginname' => 'account', 'pluginname' => 'account',
...@@ -220,7 +91,7 @@ $deleteall = pieform(array( ...@@ -220,7 +91,7 @@ $deleteall = pieform(array(
), ),
'submit' => array( 'submit' => array(
'type' => 'submit', 'type' => 'submit',
'class' => 'btn btn-danger btn-deleteall', 'class' => 'deleteallnotifications',
'value' => get_string('deleteallnotifications', 'activity'), 'value' => get_string('deleteallnotifications', 'activity'),
'confirm' => get_string('reallydeleteallnotifications', 'activity'), 'confirm' => get_string('reallydeleteallnotifications', 'activity'),
), ),
...@@ -315,7 +186,8 @@ $smarty = smarty(array('paginator'), ...@@ -315,7 +186,8 @@ $smarty = smarty(array('paginator'),
); );
$smarty->assign('options', $options); $smarty->assign('options', $options);
$smarty->assign('type', $type); $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 // Adding the links to out- and inbox
$smarty->assign('PAGEHEADING', TITLE); $smarty->assign('PAGEHEADING', TITLE);
......
...@@ -32,12 +32,12 @@ if ($readone) { ...@@ -32,12 +32,12 @@ if ($readone) {
} }
$unread = $USER->add_unread(-1); $unread = $USER->add_unread(-1);
$data = array( $data = array(
'newunreadcount' => $unread, 'newunreadcount' => $unread
'newimage' => $THEME->get_image_url($unread ? 'newmail' : 'message'),
); );
json_reply(false, array('data' => $data)); json_reply(false, array('data' => $data));
} }
require_once(get_config('libroot') . 'activity.php'); require_once(get_config('libroot') . 'activity.php');
$type = param_variable('type', 'all'); $type = param_variable('type', 'all');
...@@ -50,7 +50,7 @@ if ($markasread) { ...@@ -50,7 +50,7 @@ if ($markasread) {
$ids = array(); $ids = array();
$m = array(); $m = array();
foreach ($_GET as $k => $v) { 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]; $list = $m[1];
$ids[$list][] = $m[2]; $ids[$list][] = $m[2];
} }
...@@ -75,10 +75,10 @@ if ($markasread) { ...@@ -75,10 +75,10 @@ if ($markasread) {
$message = get_string('markedasread', 'activity'); $message = get_string('markedasread', 'activity');
} }
else if ($delete) { else if ($delete) {
$rawids = array(); $ids = array();
$deleteunread = 0; // Remember the number of unread messages being deleted $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) { 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]; $list = $m[1];
$ids[$list][] = $m[2]; $ids[$list][] = $m[2];
if (isset($_GET['unread-' . $list . '-' . $m[2]])) { if (isset($_GET['unread-' . $list . '-' . $m[2]])) {
......
...@@ -130,20 +130,17 @@ class PluginArtefactMultirecipientnotification extends PluginArtefact { ...@@ -130,20 +130,17 @@ class PluginArtefactMultirecipientnotification extends PluginArtefact {
public static function submenu_items() { public static function submenu_items() {
$tabs = array( $tabs = array(
'inbox' => array( 'inbox' => array(
'iconclass' => 'fa fa-inbox',
'url' => 'artefact/multirecipientnotification/inbox.php', 'url' => 'artefact/multirecipientnotification/inbox.php',
'title' => get_string('labelinbox', 'artefact.multirecipientnotification'), 'title' => get_string('labelinbox', 'artefact.multirecipientnotification'),
'tooltip' => get_string('inboxdesc1', 'artefact.multirecipientnotification'), 'tooltip' => get_string('inboxdesc1', 'artefact.multirecipientnotification'),
), ),
'outbox' => array( 'outbox' => array(
'iconclass' => 'fa fa-paper-plane',
'url' => 'artefact/multirecipientnotification/outbox.php', 'url' => 'artefact/multirecipientnotification/outbox.php',
'title' => get_string('labeloutbox1', 'artefact.multirecipientnotification'), 'title' => get_string('labeloutbox1', 'artefact.multirecipientnotification'),
'tooltip' => get_string('outboxdesc', '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])) { if (defined('NOTIFICATION_SUBPAGE') && isset($tabs[NOTIFICATION_SUBPAGE])) {
$tabs[NOTIFICATION_SUBPAGE]['selected'] = true; $tabs[NOTIFICATION_SUBPAGE]['selected'] = true;
......
...@@ -95,7 +95,7 @@ function activitylistin($type='all', $limit=10, $offset=0) { ...@@ -95,7 +95,7 @@ function activitylistin($type='all', $limit=10, $offset=0) {
* 'limit' => 10, * 'limit' => 10,
* 'offset' => 0, * 'offset' => 0,
* 'type' => 'all', * 'type' => 'all',
* 'tablerows' => '//html ... * 'html' => '//html ...
* 'pagination' => '// html * 'pagination' => '// html
* 'pagination_js' => '// javascript * 'pagination_js' => '// javascript
* ) * )
...@@ -130,7 +130,7 @@ function activitylistin_html($type='all', $limit=10, $offset=0) { ...@@ -130,7 +130,7 @@ function activitylistin_html($type='all', $limit=10, $offset=0) {
'limit' => $limit, 'limit' => $limit,
'offset' => $offset, 'offset' => $offset,
'type' => $type, 'type' => $type,
'tablerows' => '', 'html' => '',
'pagination' => $pagination['html'], 'pagination' => $pagination['html'],
'pagination_js' => $pagination['javascript'], 'pagination_js' => $pagination['javascript'],
); );
...@@ -274,7 +274,7 @@ function activitylistin_html($type='all', $limit=10, $offset=0) { ...@@ -274,7 +274,7 @@ function activitylistin_html($type='all', $limit=10, $offset=0) {
$smarty->assign('data', $records); $smarty->assign('data', $records);
$smarty->assign('USER', $USER); $smarty->assign('USER', $USER);
$smarty->assign('maxnamestrlength', PluginArtefactMultirecipientnotification::MAX_USERNAME_IN_LIST_LENGTH); $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; return $result;
} }
...@@ -398,7 +398,7 @@ function activityblocklistin($type='all', $limit=10, $offset=0) { ...@@ -398,7 +398,7 @@ function activityblocklistin($type='all', $limit=10, $offset=0) {
* 'limit' => 10, * 'limit' => 10,
* 'offset' => 0, * 'offset' => 0,
* 'type' => 'all', * 'type' => 'all',
* 'tablerows' => '//html ... * 'html' => '//html ...
* 'pagination' => '// html * 'pagination' => '// html
* 'pagination_js' => '// javascript * 'pagination_js' => '// javascript
* ) * )
...@@ -472,7 +472,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) { ...@@ -472,7 +472,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) {
'limit' => $limit, 'limit' => $limit,
'offset' => $offset, 'offset' => $offset,
'type' => $type, 'type' => $type,
'tablerows' => '', 'html' => '',
'pagination' => $pagination['html'], 'pagination' => $pagination['html'],
'pagination_js' => $pagination['javascript'], 'pagination_js' => $pagination['javascript'],
); );
...@@ -605,7 +605,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) { ...@@ -605,7 +605,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) {
$smarty->assign('data', $records); $smarty->assign('data', $records);
$smarty->assign('USER', $USER); $smarty->assign('USER', $USER);
$smarty->assign('maxnamestrlength', PluginArtefactMultirecipientnotification::MAX_USERNAME_IN_LIST_LENGTH); $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; return $result;
} }
...@@ -72,119 +72,10 @@ $star = json_encode($THEME->get_image_url('star')); ...@@ -72,119 +72,10 @@ $star = json_encode($THEME->get_image_url('star'));
$readicon = json_encode($THEME->get_image_url('readusermessage')); $readicon = json_encode($THEME->get_image_url('readusermessage'));
$strread = json_encode(get_string('read', 'activity')); $strread = json_encode(get_string('read', 'activity'));
$strnodelete = json_encode(get_string('nodelete', '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) {