Plugin Directory

Changeset 1058022


Ignore:
Timestamp:
01/01/2015 08:58:20 PM (11 years ago)
Author:
aesqe
Message:

"copy attachments to current post" rethink (moved to the left-side menu, works better on smaller screens)

Location:
file-gallery
Files:
167 added
8 edited

Legend:

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

    r983219 r1058022  
    15731573}
    15741574
     1575.file-gallery-media-menu-item {
     1576    background: #CAE7F2;
     1577}
     1578
    15751579
    15761580/* attachment custom fields */
  • file-gallery/trunk/file-gallery.php

    r1017929 r1058022  
    33Plugin Name: File Gallery
    44Plugin URI: http://skyphe.org/code/wordpress/file-gallery/
    5 Version: 1.7.9.8
     5Version: 1.8
    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.7.9.8');
     34define('FILE_GALLERY_VERSION', '1.8');
    3535define('FILE_GALLERY_DEFAULT_TEMPLATES', serialize( array('default', 'file-gallery', 'list', 'simple') ) );
    3636
     
    15671567    global $post, $wp_version;
    15681568
    1569     $v = (int) $wp_version < 4 ? 39 : 40;
     1569    $v = (string) $wp_version;
     1570    $v = str_replace('.', '', $v);
     1571    $v = substr($v, 0, 2);
    15701572?>
    15711573    <?php require_once('includes/templates-media-wp' . $v . '.php'); ?>
  • file-gallery/trunk/includes/templates-media-wp40.php

    r983219 r1058022  
    22
    33<!-- FILE GALLERY ADDITION -->
    4     <div class="{{ <?php echo $post->ID; ?> == data.uploadedTo? 'isattached' : '' }} attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
     4    <div class="{{ <?php echo $post->ID; ?> == data.uploadedTo ? 'isattached' : '' }} attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
    55<!-- /FILE GALLERY ADDITION -->
    66
  • file-gallery/trunk/js/file-gallery-media.js

    r1017929 r1058022  
    11/*global console _ wp jQuery file_gallery_attach_nonce console file_gallery*/
    22
    3 jQuery(document).ready(function()
     3jQuery(document).ready(function ()
    44{
    5     "use strict";
     5    "use strict";
    66
    7     if( ! wp || ! wp.media ) {
    8         return;
    9     }
     7    if (!wp || !wp.media) {
     8        return;
     9    }
    1010
    11     var responseContainerAdded = false;
    12     var responseContainer = jQuery('<div class="file-gallery-response" style="display: none;"></div>');
     11    var menuTitle = (function()
     12    {
     13        var t = file_gallery.L10n.attach_all_checked_copy.split(" ");
     14        var len = t.length;
     15        var j = 0;
     16        var i = 0;
    1317
    14     var wpMediaFramePost = wp.media.view.MediaFrame.Post;
     18        for( i; i < len; i++ )
     19        {
     20            j += t[i].length;
    1521
    16     wp.media.view.MediaFrame.Post = wpMediaFramePost.extend(
    17     {
    18         mainInsertToolbar: function( view )
    19         {
    20             wpMediaFramePost.prototype.mainInsertToolbar.call(this, view);
     22            if( j >= 18 )
     23            {
     24                t[i] += "<br />";
     25                j = 0;
     26            }
     27        }
    2128
    22             var controller = this;
     29        return t.join(" ");
     30    }());
    2331
    24             view.set( "attach", {
    25                 style: "primary",
    26                 priority: 80,
    27                 text: file_gallery.L10n.attach_all_checked_copy,
    28                 requires: {
    29                     selection: true
    30                 },
     32    var state;
     33    var selection;
     34    var controller;
     35    var ready = false;
     36    var $filters = "select.attachment-filters";
     37    var $responseContainer = jQuery('<div class="file-gallery-response"></div>');
     38    var $menuItem = jQuery('<a href="#" class="media-menu-item">' + menuTitle + '</a>');
     39   
     40    var wpMediaFramePost = wp.media.view.MediaFrame.Post;
     41    wp.media.view.MediaFrame.Post = wpMediaFramePost.extend(
     42    {
     43        mainMenu: function( view )
     44        {
     45            wpMediaFramePost.prototype.mainMenu.call(this, view);
    3146
    32                 click: function()
    33                 {
    34                     var state = controller.state(),
    35                         selection = state.get("selection");
     47            var $menu = view.$el;
     48            controller = this;
     49            var post_id = parseInt(jQuery("#post_ID").val(), 10);
    3650
    37                     if( responseContainerAdded === false )
    38                     {
    39                         controller.content.get().sidebar.$el.append(responseContainer);
    40                         responseContainerAdded = true;
    41                     }
     51            if( file_gallery.tinymce_is_active() )
     52            {
     53                controller.on("ready", function ()
     54                {
     55                    if( ! ready )
     56                    {
     57                        $filters = jQuery($filters);
    4258
    43                     responseContainer.stop().fadeOut(75, function() {
    44                         responseContainer.html("");
    45                     });
     59                        $filters.on("change", function ()
     60                        {
     61                            if( this.value === "uploaded" ) {
     62                                $menuItem.hide();
     63                            } else {
     64                                $menuItem.show();
     65                            }
     66                        });
    4667
    47                     var data = {
    48                         action: "file_gallery_copy_attachments_to_post",
    49                         post_id: jQuery("#post_ID").val(),
    50                         ids: _.uniq( _.pluck(selection._byId, "id") ).join(","),
    51                         _ajax_nonce: file_gallery_attach_nonce
    52                     };
     68                        $responseContainer.hide();
    5369
    54                     jQuery.post(wp.media.model.settings.ajaxurl, data, function ( response )
    55                     {
    56                         state.reset();
     70                        var content = controller.content.get();
    5771
    58                         responseContainer.html( response.split("#").pop() ).fadeIn(500, function() {
    59                             responseContainer.fadeOut(15000);
    60                         });
    61                     }, "html");
    62                 }
    63             });
    64         }
    65     });
     72                        if( content.sidebar ) {
     73                            content.sidebar.$el.append($responseContainer);
     74                        }
    6675
    67     jQuery(document).on("click", ".insert-media, .media-menu-item", function(e)
    68     {
    69         var editor = jQuery(this).data("editor"),
    70             toolbar = wp.media.editor.get(editor).views._views[".media-frame-toolbar"][0];
     76                        ready = true;
     77                    }
     78                });
    7179
    72         toolbar.selection.reset();
    73        
    74         var attachButton = jQuery(".media-frame-toolbar .media-button-attach"),
    75             filters = jQuery("select.attachment-filters");
     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                }
    7688
    77         if( filters.val() === "uploaded" ) {
    78             attachButton.hide();
    79         }
     89                function selectionObserver ()
     90                {
     91                    if( ready && file_gallery.tinymce_is_active() )
     92                    {
     93                        state = controller.state();
     94                        selection = state.get("selection");
    8095
    81         filters.on("change", function()
    82         {
    83             if( this.value === "uploaded" ) {
    84                 attachButton.hide();
    85             }
    86             else {
    87                 attachButton.show();
    88             }
    89         });
    90     });
    91    
    92     wp.media.view.Attachment.Library = wp.media.view.Attachment.extend({
    93         buttons: {
    94             check: true,
    95             attach: true
    96         }
    97     });
     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";
    98101
    99     jQuery("#tmpl-attachment").remove();
    100     jQuery("#tmpl-attachment-filegallery").attr("id", "tmpl-attachment");
     102                        if( len && state && sel && allfiles ) {
     103                            $menuItem.show();
     104                        } else {
     105                            $menuItem.hide();
     106                        }
     107                    }
     108                }
     109
     110                controller.on("activate", selectionObserver);
     111                controller.on("selection:toggle", selectionObserver);
     112
     113                if( file_gallery.options.wp_version < 4 ) {
     114                    jQuery("body").on("click", ".media-frame-content .attachment", selectionObserver);
     115                }
     116
     117                $menuItem.on("click", function ()
     118                {
     119                    state = controller.state();
     120                    selection = state.get("selection");
     121
     122                    var unattached = getUnattached(selection);
     123
     124                    if( unattached.length && $filters.val() !== "uploaded" )
     125                    {
     126                        $responseContainer.stop().fadeOut(75, function() {
     127                            $responseContainer.html("");
     128                        });
     129
     130                        var data = {
     131                            action: "file_gallery_copy_attachments_to_post",
     132                            post_id: wp.media.model.settings.post.id,
     133                            ids: _.uniq( unattached ).join(","),
     134                            _ajax_nonce: file_gallery_attach_nonce
     135                        };
     136
     137                        jQuery.post(wp.media.model.settings.ajaxurl, data, function (response)
     138                        {
     139                            $responseContainer.html( response.split("#").pop() ).fadeIn(500, function () {
     140                                $responseContainer.fadeOut(15000);
     141                            });
     142
     143                            state.reset();
     144                        }, "html");
     145                    }
     146                });
     147
     148                $menuItem.addClass("file-gallery-media-menu-item").hide();
     149                $menu.append($menuItem);
     150            }
     151        }
     152    });
     153
     154    wp.media.view.Attachment.Library = wp.media.view.Attachment.extend(
     155    {
     156        buttons: {
     157            check: true,
     158            attach: true
     159        }
     160    });
     161
     162    jQuery("#tmpl-attachment").remove();
     163    jQuery("#tmpl-attachment-filegallery").attr("id", "tmpl-attachment");
    101164});
  • file-gallery/trunk/js/file-gallery.js

    r1017929 r1058022  
    3232
    3333            return null;
     34        },
     35
     36        tinymce_is_active: function ()
     37        {
     38            var editor = file_gallery.tinymce_get_editor();
     39            return editor && ! editor.isHidden()
    3440        },
    3541
  • file-gallery/trunk/languages/file-gallery-fr_FR.po

    r872364 r1058022  
    33"Project-Id-Version: File Gallery v1.5.9\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2014-03-08 22:18+0100\n"
    6 "PO-Revision-Date: 2014-03-08 22:22+0100\n"
     5"POT-Creation-Date: 2014-11-01 22:41+0100\n"
     6"PO-Revision-Date: 2014-11-01 22:43+0100\n"
    77"Last-Translator: Li-An <lian00@gmail.com>\n"
    88"Language-Team: \n"
     
    1717"X-Poedit-Basepath: ../\n"
    1818"X-Textdomain-Support: yes\n"
    19 "X-Generator: Poedit 1.6.4\n"
     19"X-Generator: Poedit 1.6.10\n"
    2020"X-Poedit-SearchPath-0: .\n"
    2121
     
    115115#: file-gallery.php:282 file-gallery.php:378 includes/main-form.php:109
    116116#: includes/main-form.php:114 includes/main-form.php:292
    117 #: includes/main-form.php:297 includes/media-settings.php:146
     117#: includes/main-form.php:297 includes/media-settings.php:149
    118118msgid "external url"
    119119msgstr "URL externe"
     
    345345# @ file-gallery
    346346#: file-gallery.php:917 file-gallery.php:978 file-gallery.php:979
    347 #: file-gallery.php:1313 file-gallery.php:1558 includes/main-form.php:251
     347#: file-gallery.php:1313 file-gallery.php:1557 includes/main-form.php:251
    348348msgid "Media tags"
    349349msgstr "Mots clef média"
     
    598598
    599599# @ file-gallery
    600 #: file-gallery.php:1479
     600#: file-gallery.php:1478
    601601msgid "No. of attachments"
    602602msgstr "Nombre de fichiers attachés"
    603603
    604604# @ file-gallery
    605 #: file-gallery.php:1518
     605#: file-gallery.php:1517
    606606msgid "No Media Tags"
    607607msgstr "Aucun mot-cler média"
    608 
    609 #: file-gallery.php:1591
    610 msgid "Remove"
    611 msgstr "Retirer"
    612 
    613 #: file-gallery.php:1595
    614 msgid "Deselect"
    615 msgstr "Déselectionner"
    616608
    617609#: includes/attachments-custom-fields.php:46
     
    660652# @ file-gallery
    661653#: includes/attachments-custom-fields.php:116 includes/main.php:182
    662 #: includes/main.php:191
     654#: includes/main.php:191 includes/media-upload.php:91
    663655msgid "Cancel"
    664656msgstr "Annuler"
     
    746738
    747739# @ file-gallery
    748 #: includes/attachments.php:372
     740#: includes/attachments.php:372 includes/templates-media-wp39.php:120
    749741msgid "Title"
    750742msgstr "Titre"
    751743
    752744# @ file-gallery
    753 #: includes/attachments.php:375
     745#: includes/attachments.php:375 includes/templates-media-wp39.php:124
    754746msgid "Caption"
    755747msgstr "Légende"
    756748
    757749# @ file-gallery
    758 #: includes/attachments.php:378
     750#: includes/attachments.php:378 includes/templates-media-wp39.php:134
    759751msgid "Description"
    760752msgstr "Description"
     
    924916# @ file-gallery
    925917#: includes/main-form.php:86 includes/main-form.php:121
    926 #: includes/media-settings.php:176
     918#: includes/media-settings.php:180
    927919msgid "thumbnail"
    928920msgstr "miniature"
     
    930922# @ file-gallery
    931923#: includes/main-form.php:87 includes/main-form.php:122
    932 #: includes/media-settings.php:182
     924#: includes/media-settings.php:187
    933925msgid "medium"
    934926msgstr "medium"
     
    936928# @ file-gallery
    937929#: includes/main-form.php:88 includes/main-form.php:123
    938 #: includes/media-settings.php:188
     930#: includes/media-settings.php:194
    939931msgid "large"
    940932msgstr "grande"
     
    942934# @ file-gallery
    943935#: includes/main-form.php:89 includes/main-form.php:124
    944 #: includes/media-settings.php:194
     936#: includes/media-settings.php:201
    945937msgid "full"
    946938msgstr "entière"
     
    953945# @ file-gallery
    954946#: includes/main-form.php:100 includes/main-form.php:288
    955 #: includes/media-settings.php:142
     947#: includes/media-settings.php:145
    956948msgid "nothing (do not link)"
    957949msgstr "aucun (ne pas lier)"
     
    959951# @ file-gallery
    960952#: includes/main-form.php:101 includes/main-form.php:289
    961 #: includes/media-settings.php:143
     953#: includes/media-settings.php:146
    962954msgid "file"
    963955msgstr "fichier"
     
    965957# @ file-gallery
    966958#: includes/main-form.php:103 includes/main-form.php:105
    967 #: includes/main-form.php:290 includes/media-settings.php:144
     959#: includes/main-form.php:290 includes/media-settings.php:147
    968960msgid "attachment page"
    969961msgstr "page de fichier attaché"
     
    971963# @ file-gallery
    972964#: includes/main-form.php:108 includes/main-form.php:291
    973 #: includes/media-settings.php:145
     965#: includes/media-settings.php:148
    974966msgid "parent post"
    975967msgstr "billet parent"
     
    999991
    1000992# @ file-gallery
    1001 #: includes/main-form.php:154 includes/media-settings.php:149
     993#: includes/main-form.php:154 includes/media-settings.php:152
    1002994msgid "file gallery"
    1003995msgstr "galerie de fichiers"
    1004996
    1005997# @ file-gallery
    1006 #: includes/main-form.php:155 includes/media-settings.php:150
     998#: includes/main-form.php:155 includes/media-settings.php:153
    1007999msgid "random"
    10081000msgstr "au hasard"
     
    10101002# @ file-gallery
    10111003#: includes/main-form.php:156 includes/main-form.php:363
    1012 #: includes/media-settings.php:151
     1004#: includes/media-settings.php:154
    10131005msgid "menu order"
    10141006msgstr "ordre de menu"
     
    10161008# @ file-gallery
    10171009#: includes/main-form.php:157 includes/main-form.php:364
    1018 #: includes/media-settings.php:152
     1010#: includes/media-settings.php:155
    10191011msgid "title"
    10201012msgstr "titre"
    10211013
    10221014# @ file-gallery
    1023 #: includes/main-form.php:158 includes/media-settings.php:153
     1015#: includes/main-form.php:158 includes/media-settings.php:156
    10241016msgid "date / time"
    10251017msgstr "date / heure"
     
    10621054
    10631055# @ file-gallery
    1064 #: includes/main-form.php:314 includes/media-settings.php:136
    1065 #: includes/media-settings.php:160
     1056#: includes/main-form.php:314 includes/media-settings.php:139
     1057#: includes/media-settings.php:163
    10661058msgid "none"
    10671059msgstr "aucun"
    10681060
    10691061# @ file-gallery
    1070 #: includes/main-form.php:315 includes/media-settings.php:137
    1071 #: includes/media-settings.php:161
     1062#: includes/main-form.php:315 includes/media-settings.php:140
     1063#: includes/media-settings.php:164
    10721064msgid "left"
    10731065msgstr "gauche"
    10741066
    10751067# @ file-gallery
    1076 #: includes/main-form.php:316 includes/media-settings.php:138
    1077 #: includes/media-settings.php:162
     1068#: includes/main-form.php:316 includes/media-settings.php:141
     1069#: includes/media-settings.php:165
    10781070msgid "right"
    10791071msgstr "droite"
    10801072
    10811073# @ file-gallery
    1082 #: includes/main-form.php:317 includes/media-settings.php:139
    1083 #: includes/media-settings.php:163
     1074#: includes/main-form.php:317 includes/media-settings.php:142
     1075#: includes/media-settings.php:166
    10841076msgid "center"
    10851077msgstr "centré"
     
    11451137
    11461138# @ file-gallery
    1147 #: includes/main.php:176
     1139#: includes/main.php:176 includes/templates-media-wp39.php:103
    11481140msgid "Detach"
    11491141msgstr "Détacher"
     
    11551147
    11561148# @ file-gallery
    1157 #: includes/main.php:180 includes/main.php:189 includes/media-upload.php:143
     1149#: includes/main.php:180 includes/main.php:189 includes/media-upload.php:138
    11581150msgid "Continue"
    11591151msgstr "Continuer"
     
    12391231
    12401232# @ file-gallery
    1241 #: includes/media-settings.php:156
     1233#: includes/media-settings.php:159
    12421234msgid "ascending"
    12431235msgstr "croissant"
    12441236
    12451237# @ file-gallery
    1246 #: includes/media-settings.php:157
     1238#: includes/media-settings.php:160
    12471239msgid "descending"
    12481240msgstr "décroissant"
    12491241
    12501242# @ file-gallery
    1251 #: includes/media-settings.php:322
     1243#: includes/media-settings.php:348
    12521244msgid "Crop medium size to exact dimensions"
    12531245msgstr "Retailler la taille médium aux dimensions exactes"
    12541246
    12551247# @ file-gallery
    1256 #: includes/media-settings.php:328
     1248#: includes/media-settings.php:353
    12571249msgid "Crop large size to exact dimensions"
    12581250msgstr "Retailler la grande taille aux dimensions exactes"
    12591251
    12601252# @ file-gallery
    1261 #: includes/media-settings.php:342
     1253#: includes/media-settings.php:369
    12621254msgid "Width"
    12631255msgstr "Largeur"
    12641256
    12651257# @ file-gallery
    1266 #: includes/media-settings.php:344
     1258#: includes/media-settings.php:371
    12671259msgid "Height"
    12681260msgstr "Hauteur"
    12691261
    12701262# @ file-gallery
    1271 #: includes/media-settings.php:347
     1263#: includes/media-settings.php:374
    12721264#, php-format
    12731265msgid "Crop %s size to exact dimensions"
     
    13351327
    13361328# @ file-gallery
     1329#: includes/templates-media-wp39.php:31 includes/templates-media-wp40.php:33
     1330msgid "This file is attached to current post"
     1331msgstr "Ce fichier est attaché au billet courant"
     1332
     1333# @ file-gallery
     1334#: includes/templates-media-wp39.php:58
     1335msgid "Attachment Details"
     1336msgstr "Détails de la pièce attachée"
     1337
     1338# @ file-gallery
     1339#: includes/templates-media-wp39.php:85
     1340msgid "Edit Image"
     1341msgstr "Éditer l'image"
     1342
     1343#: includes/templates-media-wp39.php:86
     1344msgid "Refresh"
     1345msgstr "Rafraîchir"
     1346
     1347#: includes/templates-media-wp39.php:91
     1348msgid "Length:"
     1349msgstr "Longueur:"
     1350
     1351#: includes/templates-media-wp39.php:96
     1352msgid "Trash"
     1353msgstr "Poubelle"
     1354
     1355#: includes/templates-media-wp39.php:98
     1356msgid "Delete Permanently"
     1357msgstr "Suppression définitive"
     1358
     1359# @ file-gallery
     1360#: includes/templates-media-wp39.php:105
     1361msgid "Attach"
     1362msgstr "Attacher"
     1363
     1364#: includes/templates-media-wp39.php:129
     1365msgid "Alt Text"
     1366msgstr "Texte Alt"
     1367
     1368# @ file-gallery
    13371369#: includes/templating.php:311
    13381370msgid "file does not exist:"
     
    13451377
    13461378# @ file-gallery
    1347 #: includes/templating.php:1071
     1379#: includes/templating.php:1061
    13481380msgid "Skip to first page"
    13491381msgstr "Aller directement à la première page"
    13501382
    13511383# @ file-gallery
    1352 #: includes/templating.php:1075
     1384#: includes/templating.php:1065
    13531385msgid "Skip to last page"
    13541386msgstr "Aller directement à la dernière page"
    13551387
    1356 #: includes/templating.php:1079
     1388#: includes/templating.php:1069
    13571389msgid "Previous page"
    13581390msgstr "Page précédente"
    13591391
    1360 #: includes/templating.php:1083
     1392#: includes/templating.php:1073
    13611393msgid "Next page"
    13621394msgstr "Page suivante"
     1395
     1396#~ msgid "Remove"
     1397#~ msgstr "Retirer"
     1398
     1399#~ msgid "Deselect"
     1400#~ msgstr "Déselectionner"
  • file-gallery/trunk/readme.txt

    r1017929 r1058022  
    33Donate link: http://skyphe.org/donate/
    44Tags: attachment, attachments, gallery, galleries, template, templates, shortcode, file, files, attach, detach, unattach, copy, media, tags, library, custom, custom fields, custom fields for attachments, attachment custom fields, drag drop upload
    5 Requires at least: 3.5
    6 Tested up to: 4.0
    7 Stable tag: 1.7.9.8
     5Requires at least: 3.9
     6Tested up to: 4.1
     7Stable tag: 1.8
    88
    99File Gallery extends WordPress media (attachments) capabilities
     
    169169
    170170== Changelog ==
     171
     172= 1.8 =
     173* January 1st, 2015
     174* "copy attachments to current post" rethink
     175  (moved to the left-side menu, works better on smaller screens)
    171176
    172177= 1.7.9.8 =
Note: See TracChangeset for help on using the changeset viewer.