Plugin Directory

Changeset 1059038


Ignore:
Timestamp:
01/03/2015 02:47:57 PM (11 years ago)
Author:
aesqe
Message:

"copy attachments to current post" bugfix

Location:
file-gallery
Files:
166 added
3 edited

Legend:

Unmodified
Added
Removed
  • file-gallery/trunk/file-gallery.php

    r1058022 r1059038  
    33Plugin Name: File Gallery
    44Plugin URI: http://skyphe.org/code/wordpress/file-gallery/
    5 Version: 1.8
     5Version: 1.8.2
    66Description: "File Gallery" extends WordPress' media (attachments) capabilities by adding a new gallery shortcode handler with templating support, a new interface for attachment handling when editing posts, and much more.
    77Author: Bruno "Aesqe" Babic
     
    3232 */
    3333
    34 define('FILE_GALLERY_VERSION', '1.8');
     34define('FILE_GALLERY_VERSION', '1.8.2');
    3535define('FILE_GALLERY_DEFAULT_TEMPLATES', serialize( array('default', 'file-gallery', 'list', 'simple') ) );
    3636
  • file-gallery/trunk/js/file-gallery-media.js

    r1058022 r1059038  
    3434    var controller;
    3535    var ready = false;
     36    var responseContainerAdded = false;
    3637    var $filters = "select.attachment-filters";
    3738    var $responseContainer = jQuery('<div class="file-gallery-response"></div>');
     
    4546            wpMediaFramePost.prototype.mainMenu.call(this, view);
    4647
     48            controller = this;
     49
     50            var content;
    4751            var $menu = view.$el;
    48             controller = this;
    4952            var post_id = parseInt(jQuery("#post_ID").val(), 10);
     53
     54            var getUnattached = function ( selection )
     55            {
     56                if( ! selection ) {
     57                    return [];
     58                }
     59
     60                return selection.filter(function(attachment) {
     61                    return attachment.get("uploadedTo") !== post_id;
     62                }).map(function(attachment) {
     63                    return attachment.get("id");
     64                });
     65            };
     66
     67            var selectionObserver = function ()
     68            {
     69                if( ready && file_gallery.tinymce_is_active() )
     70                {
     71                    state = controller.state();
     72                    selection = state.get("selection");
     73
     74                    var sel = selection && selection.length;
     75                    var unattached = getUnattached(selection);
     76                    var len = unattached.length > 0;
     77                    var state = controller._state === "insert";
     78                    var allfiles = $filters.val() !== "uploaded";
     79
     80                    if( len && state && sel && allfiles ) {
     81                        $menuItem.show();
     82                    } else {
     83                        $menuItem.hide();
     84                    }
     85                }
     86            };
    5087
    5188            if( file_gallery.tinymce_is_active() )
     
    67104
    68105                        $responseContainer.hide();
     106                        content = controller.content.get();
    69107
    70                         var content = controller.content.get();
    71 
    72                         if( content.sidebar ) {
     108                        if( content.sidebar )
     109                        {
    73110                            content.sidebar.$el.append($responseContainer);
     111                            responseContainerAdded = true;
    74112                        }
    75113
     
    77115                    }
    78116                });
    79 
    80                 function getUnattached ( selection )
    81                 {
    82                     return selection.filter(function(attachment) {
    83                         return attachment.get("uploadedTo") !== post_id;
    84                     }).map(function(attachment) {
    85                         return attachment.get("id");
    86                     });
    87                 }
    88 
    89                 function selectionObserver ()
    90                 {
    91                     if( ready && file_gallery.tinymce_is_active() )
    92                     {
    93                         state = controller.state();
    94                         selection = state.get("selection");
    95 
    96                         var sel = selection && selection.length ? true : false;
    97                         var unattached = getUnattached(selection);
    98                         var len = unattached.length > 0;
    99                         var state = controller._state === "insert";
    100                         var allfiles = $filters.val() !== "uploaded";
    101 
    102                         if( len && state && sel && allfiles ) {
    103                             $menuItem.show();
    104                         } else {
    105                             $menuItem.hide();
    106                         }
    107                     }
    108                 }
    109117
    110118                controller.on("activate", selectionObserver);
     
    115123                }
    116124
    117                 $menuItem.on("click", function ()
     125                $menuItem.on("click", function ( event )
    118126                {
    119127                    state = controller.state();
    120128                    selection = state.get("selection");
    121129
     130                    if( ! responseContainerAdded )
     131                    {
     132                        content = controller.content.get();
     133
     134                        if( content.sidebar )
     135                        {
     136                            content.sidebar.$el.append($responseContainer);
     137                            responseContainerAdded = true;
     138                        }
     139                    }
     140
    122141                    var unattached = getUnattached(selection);
     142                    var data;
    123143
    124                     if( unattached.length && $filters.val() !== "uploaded" )
     144                    if( unattached.length > 0 )
    125145                    {
    126146                        $responseContainer.stop().fadeOut(75, function() {
     
    128148                        });
    129149
    130                         var data = {
     150                        data = {
    131151                            action: "file_gallery_copy_attachments_to_post",
    132152                            post_id: wp.media.model.settings.post.id,
     
    144164                        }, "html");
    145165                    }
     166
     167                    event.preventDefault();
     168                    return false;
    146169                });
    147170
  • file-gallery/trunk/readme.txt

    r1058022 r1059038  
    55Requires at least: 3.9
    66Tested up to: 4.1
    7 Stable tag: 1.8
     7Stable tag: 1.8.2
    88
    99File Gallery extends WordPress media (attachments) capabilities
     
    169169
    170170== Changelog ==
     171
     172= 1.8.2 =
     173* January 3rd, 2015
     174* "copy attachments to current post" bugfix
    171175
    172176= 1.8 =
Note: See TracChangeset for help on using the changeset viewer.