Make WordPress Core

Changeset 27901


Ignore:
Timestamp:
04/02/2014 02:41:24 AM (11 years ago)
Author:
azaozz
Message:

Drag and drop files on the editor to upload: add new argument to wp_editor() to enable, fixes #27465

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-advanced.php

    r27864 r27901  
    480480<?php wp_editor( $post->post_content, 'content', array(
    481481    'dfw' => true,
     482    'drag_drop_upload' => true,
    482483    'tabfocus_elements' => 'insert-media-button,save-post',
    483484    'editor_height' => 360,
  • trunk/src/wp-includes/class-wp-editor.php

    r27897 r27901  
    2525    private static $has_medialib = false;
    2626    private static $editor_buttons_css = true;
     27    private static $drag_drop_upload = false;
    2728
    2829    private function __construct() {}
     
    3940     *     @type string     $default_editor    When both TinyMCE and Quicktags are used, set which
    4041     *                                         editor is shown on page load. Default empty.
     42     *     @type bool       $drag_drop_upload  Whether to enable drag & drop on the editor uploading. Default false.
     43     *                                         Requires the media modal.
    4144     *     @type string     $textarea_name     Give the textarea a unique name here. Square brackets
    4245     *                                         can be used here. Default $editor_id.
     
    6467            'media_buttons'     => true,
    6568            'default_editor'    => '',
     69            'drag_drop_upload'  => false,
    6670            'textarea_name'     => $editor_id,
    6771            'textarea_rows'     => 20,
     
    124128        $switch_class = 'html-active';
    125129        $toolbar = $buttons = $autocomplete = '';
     130
     131        if ( $set['drag_drop_upload'] ) {
     132            self::$drag_drop_upload = true;
     133        }
    126134
    127135        if ( ! empty( $set['editor_height'] ) )
     
    981989            baseURL: "<?php echo self::$baseurl; ?>",
    982990            suffix: "<?php echo $suffix; ?>",
     991            <?php
     992
     993            if ( self::$drag_drop_upload ) {
     994                echo 'dragDropUpload: true,';
     995            }
     996
     997            ?>
    983998            mceInit: <?php echo $mceInit; ?>,
    984999            qtInit: <?php echo $qtInit; ?>,
  • trunk/src/wp-includes/js/media-views.js

    r27898 r27901  
    31323132            this.initialized = false;
    31333133
    3134             // Bail if UA does not support drag'n'drop or File API.
    3135             if ( ! this.browserSupport() ) {
     3134            // Bail if not enabled or UA does not support drag'n'drop or File API.
     3135            if ( ! window.tinyMCEPreInit || ! window.tinyMCEPreInit.dragDropUpload || ! this.browserSupport() ) {
    31363136                return this;
    31373137            }
  • trunk/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

    r27857 r27901  
    312312        }
    313313
    314         dom.bind( doc, 'dragstart dragend dragover drop', function( event ) {
    315             if ( typeof window.jQuery !== 'undefined' ) {
    316                 // Trigger the jQuery handlers.
    317                 window.jQuery( document ).triggerHandler( event.type );
    318             }
    319         });
     314        if ( window.tinyMCEPreInit && window.tinyMCEPreInit.dragDropUpload ) {
     315            dom.bind( doc, 'dragstart dragend dragover drop', function( event ) {
     316                if ( typeof window.jQuery !== 'undefined' ) {
     317                    // Trigger the jQuery handlers.
     318                    window.jQuery( document ).triggerHandler( event.type );
     319                }
     320            });
     321        }
    320322    });
    321323
Note: See TracChangeset for help on using the changeset viewer.