[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/editor/atto/plugins/managefiles/yui/build/moodle-atto_managefiles-button/ -> moodle-atto_managefiles-button-debug.js (source)

   1  YUI.add('moodle-atto_managefiles-button', 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   * @package    atto_managefiles
  20   * @copyright  2014 Frédéric Massart
  21   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22   */
  23  
  24  /**
  25   * @module moodle-atto-managefiles-button
  26   */
  27  
  28  /**
  29   * Atto text editor managefiles plugin.
  30   *
  31   * @namespace M.atto_link
  32   * @class button
  33   * @extends M.editor_atto.EditorPlugin
  34   */
  35  
  36  var LOGNAME = 'atto_managefiles';
  37  
  38  Y.namespace('M.atto_managefiles').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
  39  
  40      /**
  41       * A reference to the current selection at the time that the dialogue
  42       * was opened.
  43       *
  44       * @property _currentSelection
  45       * @type Range
  46       * @private
  47       */
  48      _currentSelection: null,
  49  
  50      initializer: function() {
  51          if (this.get('disabled')) {
  52              return;
  53          }
  54  
  55          var host = this.get('host'),
  56              area = this.get('area'),
  57              options = host.get('filepickeroptions');
  58  
  59          if (options.image && options.image.itemid) {
  60              area.itemid = options.image.itemid;
  61              this.set('area', area);
  62          } else {
  63              Y.log('Plugin managefiles not available because itemid is missing.',
  64                      'warn', LOGNAME);
  65              return;
  66          }
  67  
  68          this.addButton({
  69              icon: 'e/manage_files',
  70              callback: this._displayDialogue
  71          });
  72      },
  73  
  74      /**
  75       * Display the manage files.
  76       *
  77       * @method _displayDialogue
  78       * @private
  79       */
  80      _displayDialogue: function(e) {
  81          e.preventDefault();
  82  
  83          var dialogue = this.getDialogue({
  84              headerContent: M.util.get_string('managefiles', LOGNAME),
  85              width: '800px',
  86              focusAfterHide: true
  87          });
  88  
  89          var iframe = Y.Node.create('<iframe></iframe>');
  90          // We set the height here because otherwise it is really small. That might not look
  91          // very nice on mobile devices, but we considered that enough for now.
  92          iframe.setStyles({
  93              height: '700px',
  94              border: 'none',
  95              width: '100%'
  96          });
  97          iframe.setAttribute('src', this._getIframeURL());
  98  
  99          dialogue.set('bodyContent', iframe)
 100                  .show();
 101  
 102          this.markUpdated();
 103      },
 104  
 105      /**
 106       * Returns the URL to the file manager.
 107       *
 108       * @param _getIframeURL
 109       * @return {String} URL
 110       * @private
 111       */
 112      _getIframeURL: function() {
 113          var args = Y.mix({
 114                      elementid: this.get('host').get('elementid')
 115                  },
 116                  this.get('area'));
 117          return M.cfg.wwwroot + '/lib/editor/atto/plugins/managefiles/manage.php?' +
 118                  Y.QueryString.stringify(args);
 119      }
 120  }, {
 121      ATTRS: {
 122          disabled: {
 123              value: true
 124          },
 125          area: {
 126              value: {}
 127          }
 128      }
 129  });
 130  
 131  
 132  }, '@VERSION@', {"requires": ["moodle-editor_atto-plugin"]});


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