forked from moodle/moodle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-29801 core_message: added ability to delete messages
Thanks goes to Jetha for providing the HTML and CSS.
- Loading branch information
Showing
12 changed files
with
600 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
message/yui/build/moodle-core_message-toolbox/moodle-core_message-toolbox-debug.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
YUI.add('moodle-core_message-toolbox', function (Y, NAME) { | ||
|
||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* JS used when deleting messages. | ||
* | ||
* @module moodle-core_message-toolbox | ||
* @package core_message | ||
* @copyright 2015 Mark Nelson <markn@moodle.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
var CSS = { | ||
ACCESSHIDE: 'accesshide', | ||
MESSAGEACTIVE: 'messageactive' | ||
}; | ||
var SELECTORS = { | ||
DELETEICON: '.deleteicon', | ||
MESSAGEACTIVE: '.messageactive', | ||
MESSAGEHISTORY: '.messagehistory', | ||
MESSAGES: '.messagecontent' | ||
}; | ||
|
||
M.core_message = M.core_message || {}; | ||
M.core_message.toolbox = M.core_message.toolbox || {}; | ||
|
||
/** | ||
* This class contains the JS related to deleting messages. | ||
* | ||
* @class M.core_message.toolbox.deletemsg | ||
* @constructor | ||
*/ | ||
M.core_message.toolbox.deletemsg = { | ||
|
||
/** | ||
* The area the messages are contained. | ||
* | ||
* @property messagearea | ||
*/ | ||
messagearea: null, | ||
|
||
/** | ||
* Initializer. | ||
* | ||
* Sets up event listeners which 'activate' and 'deactivate' a message. | ||
* | ||
* @method init | ||
*/ | ||
init: function() { | ||
this.messagearea = Y.one(SELECTORS.MESSAGEHISTORY); | ||
|
||
// Set the events. | ||
this.messagearea.delegate('hover', this.over, this.out, SELECTORS.MESSAGES); | ||
this.messagearea.delegate('click', this.click, SELECTORS.MESSAGES, this); | ||
}, | ||
|
||
/** | ||
* Handles when a mouse hovers over a message. | ||
* | ||
* @private | ||
* @params {EventFacade} e | ||
* @method over | ||
*/ | ||
over: function(e) { | ||
// 'Activate' the message area we hovered on. | ||
e.currentTarget.addClass(CSS.MESSAGEACTIVE); | ||
e.currentTarget.one(SELECTORS.DELETEICON).removeClass(CSS.ACCESSHIDE); | ||
}, | ||
|
||
/** | ||
* Handles when a mouse hovers off a message. | ||
* | ||
* @private | ||
* @params {EventFacade} e | ||
* @method out | ||
*/ | ||
out: function(e) { | ||
// 'Deactivate' the message area we hovered off. | ||
e.currentTarget.removeClass(CSS.MESSAGEACTIVE); | ||
e.currentTarget.one(SELECTORS.DELETEICON).addClass(CSS.ACCESSHIDE); | ||
}, | ||
|
||
/** | ||
* Handles when a mouse clicks on a message. | ||
* | ||
* @private | ||
* @params {EventFacade} e | ||
* @method click | ||
*/ | ||
click: function(e) { | ||
// 'Deactivate' the currently active message (if there is one). | ||
var activemessage = this.messagearea.one(SELECTORS.MESSAGEACTIVE); | ||
if (activemessage) { | ||
activemessage.removeClass(CSS.MESSAGEACTIVE); | ||
activemessage.one(SELECTORS.DELETEICON).addClass(CSS.ACCESSHIDE); | ||
} | ||
// 'Activate' the message area we clicked on. | ||
e.currentTarget.addClass(CSS.MESSAGEACTIVE); | ||
e.currentTarget.one(SELECTORS.DELETEICON).removeClass(CSS.ACCESSHIDE); | ||
} | ||
}; | ||
|
||
|
||
}, '@VERSION@'); |
Oops, something went wrong.