[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yui/build/moodle-core-notification-alert/ -> moodle-core-notification-alert-debug.js (source)

   1  YUI.add('moodle-core-notification-alert', function (Y, NAME) {
   2  
   3  /* eslint-disable no-unused-vars, no-unused-expressions */
   4  var DIALOGUE_PREFIX,
   5      BASE,
   6      CONFIRMYES,
   7      CONFIRMNO,
   8      TITLE,
   9      QUESTION,
  10      CSS;
  11  
  12  DIALOGUE_PREFIX = 'moodle-dialogue',
  13  BASE = 'notificationBase',
  14  CONFIRMYES = 'yesLabel',
  15  CONFIRMNO = 'noLabel',
  16  TITLE = 'title',
  17  QUESTION = 'question',
  18  CSS = {
  19      BASE: 'moodle-dialogue-base',
  20      WRAP: 'moodle-dialogue-wrap',
  21      HEADER: 'moodle-dialogue-hd',
  22      BODY: 'moodle-dialogue-bd',
  23      CONTENT: 'moodle-dialogue-content',
  24      FOOTER: 'moodle-dialogue-ft',
  25      HIDDEN: 'hidden',
  26      LIGHTBOX: 'moodle-dialogue-lightbox'
  27  };
  28  
  29  // Set up the namespace once.
  30  M.core = M.core || {};
  31  /* global BASE, TITLE, CONFIRMYES, DIALOGUE_PREFIX */
  32  
  33  /**
  34   * A dialogue type designed to display an alert to the user.
  35   *
  36   * @module moodle-core-notification
  37   * @submodule moodle-core-notification-alert
  38   */
  39  
  40  var ALERT_NAME = 'Moodle alert',
  41      ALERT;
  42  
  43  /**
  44   * Extends core Dialogue to show the alert dialogue.
  45   *
  46   * @param {Object} config Object literal specifying the dialogue configuration properties.
  47   * @constructor
  48   * @class M.core.alert
  49   * @extends M.core.dialogue
  50   */
  51  ALERT = function(config) {
  52      config.closeButton = false;
  53      ALERT.superclass.constructor.apply(this, [config]);
  54  };
  55  Y.extend(ALERT, M.core.notification.info, {
  56      /**
  57       * The list of events to detach when destroying this dialogue.
  58       *
  59       * @property _closeEvents
  60       * @type EventHandle[]
  61       * @private
  62       */
  63      _closeEvents: null,
  64      initializer: function() {
  65          this._closeEvents = [];
  66          this.publish('complete');
  67          var yes = Y.Node.create('<input type="button" id="id_yuialertconfirm-' + this.get('COUNT') + '"' +
  68                                   'value="' + this.get(CONFIRMYES) + '" />'),
  69              content = Y.Node.create('<div class="confirmation-dialogue"></div>')
  70                      .append(Y.Node.create('<div class="confirmation-message">' + this.get('message') + '</div>'))
  71                      .append(Y.Node.create('<div class="confirmation-buttons"></div>')
  72                              .append(yes));
  73          this.get(BASE).addClass('moodle-dialogue-confirm');
  74          this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
  75          this.setStdModContent(Y.WidgetStdMod.HEADER,
  76                  '<h1 id="moodle-dialogue-' + this.get('COUNT') + '-header-text">' + this.get(TITLE) + '</h1>',
  77                  Y.WidgetStdMod.REPLACE);
  78  
  79          this._closeEvents.push(
  80              Y.on('key', this.submit, window, 'down:13', this),
  81              yes.on('click', this.submit, this)
  82          );
  83  
  84          var closeButton = this.get('boundingBox').one('.closebutton');
  85          if (closeButton) {
  86              // The close button should act exactly like the 'No' button.
  87              this._closeEvents.push(
  88                  closeButton.on('click', this.submit, this)
  89              );
  90          }
  91      },
  92      submit: function() {
  93          new Y.EventHandle(this._closeEvents).detach();
  94          this.fire('complete');
  95          this.hide();
  96          this.destroy();
  97      }
  98  }, {
  99      NAME: ALERT_NAME,
 100      CSS_PREFIX: DIALOGUE_PREFIX,
 101      ATTRS: {
 102  
 103          /**
 104           * The title of the alert.
 105           *
 106           * @attribute title
 107           * @type String
 108           * @default 'Alert'
 109           */
 110          title: {
 111              validator: Y.Lang.isString,
 112              value: 'Alert'
 113          },
 114  
 115          /**
 116           * The message of the alert.
 117           *
 118           * @attribute message
 119           * @type String
 120           * @default 'Confirm'
 121           */
 122          message: {
 123              validator: Y.Lang.isString,
 124              value: 'Confirm'
 125          },
 126  
 127          /**
 128           * The button text to use to accept the alert.
 129           *
 130           * @attribute yesLabel
 131           * @type String
 132           * @default 'Ok'
 133           */
 134          yesLabel: {
 135              validator: Y.Lang.isString,
 136              setter: function(txt) {
 137                  if (!txt) {
 138                      txt = 'Ok';
 139                  }
 140                  return txt;
 141              },
 142              value: 'Ok'
 143          }
 144      }
 145  });
 146  
 147  M.core.alert = ALERT;
 148  
 149  
 150  }, '@VERSION@', {"requires": ["moodle-core-notification-dialogue"]});


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