Permalink
Browse files

MDL-22232 messaging: added some Javascript to the messaging preferenc…

…es screen to make it awesomer
  • Loading branch information...
1 parent 87a4bba commit b15713760e2d5616f22549b70fd509e9344bae12 @andyjdavis andyjdavis committed Aug 29, 2011
Showing with 31 additions and 2 deletions.
  1. +6 −1 message/edit.php
  2. +25 −1 message/module.js
View
@@ -68,6 +68,7 @@
$PAGE->set_context($personalcontext);
$PAGE->set_pagelayout('course');
+$PAGE->requires->js_init_call('M.core_message.init_editsettings');
// check access control
if ($user->id == $USER->id) {
@@ -229,6 +230,10 @@
$providername = get_string('messageprovider:'.$provider->name, $provider->component);
echo '<tr><th align="right">'.$providername.'</th><td colspan="'.$number_procs.'"></td></tr>'."\n";
+ $disabled = '';
+ if ($user->emailstop) {
+ $disabled = 'disabled="disabled"';
+ }
foreach (array('loggedin', 'loggedoff') as $state){
$state_res = get_string($state.'description', 'message');
echo '<tr><td align="right">'.$state_res.'</td>'."\n";
@@ -240,7 +245,7 @@
} else {
$checked = $preferences->{$provider->component.'_'.$provider->name.'_'.$state}[$processor->name]==1?" checked=\"checked\"":"";
}
- echo '<td align="center"><input type="checkbox" name="'.$provider->component.'_'.$provider->name.'_'.$state.'['.$processor->name.']" '.$checked.' /></td>'."\n";
+ echo '<td align="center"><input type="checkbox" '.$disabled.' class="notificationpreference" name="'.$provider->component.'_'.$provider->name.'_'.$state.'['.$processor->name.']" '.$checked.' /></td>'."\n";
}
echo '</tr>'."\n";
}
View
@@ -42,4 +42,28 @@ M.core_message.init_notification = function(Y, title, content, url) {
return false;
}, o);
});
-};
+};
+
+M.core_message.init_editsettings = function(Y) {
+ var editsettings = {
+
+ init : function() {
+ var disableall = Y.one(".disableallcheckbox");
+ disableall.on('change', editsettings.changeState);
+ //disableall.simulate("change"); simulate() not available in this version of YUI
+ },
+
+ changeState : function(e) {
+ Y.all('.notificationpreference').each(function(node) {
+ var disabled = e.target.get('checked');
+
+ node.removeAttribute('disabled');
+ if (disabled) {
+ node.setAttribute('disabled', 1)
+ }
+ }, this);
+ }
+ }
+
+ editsettings.init();
+}

0 comments on commit b157137

Please sign in to comment.