[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/message/yui/src/toolbox/js/ -> delete.js (source)

   1  // This file is part of Moodle - http://moodle.org/
   2  //
   3  // Moodle is free software: you can redistribute it and/or modify
   4  // it under the terms of the GNU General Public License as published by
   5  // the Free Software Foundation, either version 3 of the License, or
   6  // (at your option) any later version.
   7  //
   8  // Moodle is distributed in the hope that it will be useful,
   9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11  // GNU General Public License for more details.
  12  //
  13  // You should have received a copy of the GNU General Public License
  14  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  15  
  16  /**
  17   * JS used when deleting messages.
  18   *
  19   * @module     moodle-core_message-toolbox
  20   * @package    core_message
  21   * @copyright  2015 Mark Nelson <markn@moodle.com>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  var CSS = {
  26      ACCESSHIDE: 'accesshide',
  27      MESSAGEACTIVE: 'messageactive'
  28  };
  29  var SELECTORS = {
  30      DELETEICON: '.deleteicon',
  31      MESSAGEACTIVE: '.messageactive',
  32      MESSAGEHISTORY: '.messagehistory',
  33      MESSAGES: '.messagecontent'
  34  };
  35  
  36  M.core_message = M.core_message || {};
  37  M.core_message.toolbox = M.core_message.toolbox || {};
  38  
  39  /**
  40   * This class contains the JS related to deleting messages.
  41   *
  42   * @class M.core_message.toolbox.deletemsg
  43   * @constructor
  44   */
  45  M.core_message.toolbox.deletemsg = {
  46  
  47      /**
  48       * The area the messages are contained.
  49       *
  50       * @property messagearea
  51       */
  52      messagearea: null,
  53  
  54      /**
  55       * Initializer.
  56       *
  57       * Sets up event listeners which 'activate' and 'deactivate' a message.
  58       *
  59       * @method init
  60       */
  61      init: function() {
  62          this.messagearea = Y.one(SELECTORS.MESSAGEHISTORY);
  63  
  64          // Set the events.
  65          this.messagearea.delegate('hover', this.over, this.out, SELECTORS.MESSAGES);
  66          this.messagearea.delegate('click', this.click, SELECTORS.MESSAGES, this);
  67      },
  68  
  69      /**
  70       * Handles when a mouse hovers over a message.
  71       *
  72       * @private
  73       * @params {EventFacade} e
  74       * @method over
  75       */
  76      over: function(e) {
  77          // 'Activate' the message area we hovered on.
  78          e.currentTarget.addClass(CSS.MESSAGEACTIVE);
  79          e.currentTarget.one(SELECTORS.DELETEICON).removeClass(CSS.ACCESSHIDE);
  80      },
  81  
  82      /**
  83       * Handles when a mouse hovers off a message.
  84       *
  85       * @private
  86       * @params {EventFacade} e
  87       * @method out
  88       */
  89      out: function(e) {
  90          // 'Deactivate' the message area we hovered off.
  91          e.currentTarget.removeClass(CSS.MESSAGEACTIVE);
  92          e.currentTarget.one(SELECTORS.DELETEICON).addClass(CSS.ACCESSHIDE);
  93      },
  94  
  95      /**
  96       * Handles when a mouse clicks on a message.
  97       *
  98       * @private
  99       * @params {EventFacade} e
 100       * @method click
 101       */
 102      click: function(e) {
 103          // 'Deactivate' the currently active message (if there is one).
 104          var activemessage = this.messagearea.one(SELECTORS.MESSAGEACTIVE);
 105          if (activemessage) {
 106              activemessage.removeClass(CSS.MESSAGEACTIVE);
 107              activemessage.one(SELECTORS.DELETEICON).addClass(CSS.ACCESSHIDE);
 108          }
 109          // 'Activate' the message area we clicked on.
 110          e.currentTarget.addClass(CSS.MESSAGEACTIVE);
 111          e.currentTarget.one(SELECTORS.DELETEICON).removeClass(CSS.ACCESSHIDE);
 112      }
 113  };


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1