[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/backup/util/ui/yui/build/moodle-backup-confirmcancel/ -> moodle-backup-confirmcancel-debug.js (source)

   1  YUI.add('moodle-backup-confirmcancel', function (Y, NAME) {
   2  
   3  /**
   4   * Add a confirmation dialogue when cancelling a backup.
   5   *
   6   * @module moodle-backup-confirmcancel
   7   */
   8  
   9  /**
  10   * Add a confirmation dialogue when cancelling a backup.
  11   *
  12   * @class M.core_backup.confirmcancel
  13   */
  14  
  15  
  16  // Namespace for the backup.
  17  M.core_backup = M.core_backup || {};
  18  
  19  M.core_backup.confirmcancel = {
  20      /**
  21       * An array of EventHandlers which call the confirm_cancel dialogue.
  22       *
  23       * @property listeners
  24       * @protected
  25       * @type Array
  26       */
  27      listeners: [],
  28  
  29      /**
  30       * The configuration supplied to this instance.
  31       *
  32       * @property config
  33       * @protected
  34       * @type Object
  35       */
  36      config: {},
  37  
  38      /**
  39       * Initializer to watch all cancel buttons.
  40       *
  41       * @method watch_cancel_buttons
  42       * @param {Object} config The configuration for the confirmation dialogue.
  43       */
  44      watch_cancel_buttons: function(config) {
  45          this.config = config;
  46  
  47          this.listeners.push(
  48              Y.one(Y.config.doc.body).delegate('click', this.confirm_cancel, '.confirmcancel', this)
  49          );
  50      },
  51  
  52      /**
  53       * Display the confirmation dialogue.
  54       *
  55       * @method confirm_cancel
  56       * @protected
  57       * @param {EventFacade} e
  58       */
  59      confirm_cancel: function(e) {
  60          // Prevent the default event (submit) from firing.
  61          e.preventDefault();
  62  
  63          // Create the confirmation dialogue.
  64          var confirm = new M.core.confirm(this.config);
  65  
  66          // If the user clicks yes.
  67          confirm.on('complete-yes', function() {
  68              // Detach the listeners for the confirm box so they don't fire again.
  69              new Y.EventHandle(M.core_backup.confirmcancel.listeners).detach();
  70  
  71              // Simulate the original cancel button click.
  72              e.currentTarget.simulate('click');
  73          }, this);
  74  
  75  
  76          // Show the confirm box.
  77          confirm.show();
  78      }
  79  };
  80  
  81  
  82  }, '@VERSION@', {"requires": ["node", "node-event-simulate", "moodle-core-notification-confirm"]});


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