[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/message/yui/build/moodle-core_message-toolbox/ -> moodle-core_message-toolbox.js (source)

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


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