~canonical-sysadmins/wordpress/4.9.4

« back to all changes in this revision

Viewing changes to wp-includes/js/media-editor.js

  • Committer: Barry Price
  • Date: 2017-11-17 04:49:02 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: barry.price@canonical.com-20171117044902-5frux4ycbq6g9fyf
Merge WP4.9 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
                return attrs[ key ];
31
31
        };
32
32
 
33
 
        /**
34
 
         * wp.media.string
35
 
         * @namespace
36
 
         */
 
33
        /** @namespace wp.media.string */
37
34
        wp.media.string = {
38
35
                /**
39
36
                 * Joins the `props` and `attachment` objects,
40
37
                 * outputting the proper object format based on the
41
38
                 * attachment's type.
42
39
                 *
43
 
                 * @global wp.media.view.settings
44
 
                 * @global getUserSetting()
45
 
                 *
46
40
                 * @param {Object} [props={}] Attachment details (align, link, size, etc).
47
41
                 * @param {Object} attachment The attachment object, media version of Post.
48
42
                 * @returns {Object} Joined props
109
103
                /**
110
104
                 * Create link markup that is suitable for passing to the editor
111
105
                 *
112
 
                 * @global wp.html.string
113
 
                 *
114
106
                 * @param {Object} props Attachment details (align, link, size, etc).
115
107
                 * @param {Object} attachment The attachment object, media version of Post.
116
108
                 * @returns {string} The link markup
159
151
                 *
160
152
                 * @access private
161
153
                 *
162
 
                 * @global wp.shortcode
163
 
                 * @global wp.media.view.settings
164
 
                 *
165
154
                 * @param {string} type The shortcode tag name: 'audio' or 'video'.
166
155
                 * @param {Object} props Attachment details (align, link, size, etc).
167
156
                 * @param {Object} attachment The attachment object, media version of Post.
210
199
                 * Create image markup, optionally with a link and/or wrapped in a caption shortcode,
211
200
                 *  that is suitable for passing to the editor
212
201
                 *
213
 
                 * @global wp.html
214
 
                 * @global wp.shortcode
215
 
                 *
216
202
                 * @param {Object} props Attachment details (align, link, size, etc).
217
203
                 * @param {Object} attachment The attachment object, media version of Post.
218
204
                 * @returns {string}
341
327
                }
342
328
        };
343
329
 
 
330
        /**
 
331
         * @class wp.media.collection
 
332
         *
 
333
         * @param {Object} attributes
 
334
         */
344
335
        wp.media.collection = function(attributes) {
345
336
                var collections = {};
346
337
 
347
 
                return _.extend( {
 
338
                return _.extend(/** @lends wp.media.collection.prototype */{
348
339
                        coerce : wp.media.coerce,
349
340
                        /**
350
341
                         * Retrieve attachments based on the properties of the passed shortcode
351
342
                         *
352
 
                         * @global wp.media.query
353
 
                         *
354
343
                         * @param {wp.shortcode} shortcode An instance of wp.shortcode().
355
344
                         * @returns {wp.media.model.Attachments} A Backbone.Collection containing
356
345
                         *      the media items belonging to a collection.
417
406
                        /**
418
407
                         * Triggered when clicking 'Insert {label}' or 'Update {label}'
419
408
                         *
420
 
                         * @global wp.shortcode
421
 
                         * @global wp.media.model.Attachments
422
 
                         *
423
409
                         * @param {wp.media.model.Attachments} attachments A Backbone.Collection containing
424
410
                         *      the media items belonging to a collection.
425
411
                         *      The query[ this.tag ] property is a Backbone.Model
488
474
                         * Triggered when double-clicking a collection shortcode placeholder
489
475
                         *   in the editor
490
476
                         *
491
 
                         * @global wp.shortcode
492
 
                         * @global wp.media.model.Selection
493
 
                         * @global wp.media.view.l10n
494
 
                         *
495
477
                         * @param {string} content Content that is searched for possible
496
478
                         *    shortcode markup matching the passed tag name,
497
479
                         *
610
592
        });
611
593
 
612
594
        /**
613
 
         * wp.media.featuredImage
614
 
         * @namespace
 
595
         * @namespace wp.media.featuredImage
 
596
         * @memberOf wp.media
615
597
         */
616
598
        wp.media.featuredImage = {
617
599
                /**
618
600
                 * Get the featured image post ID
619
601
                 *
620
 
                 * @global wp.media.view.settings
621
 
                 *
622
602
                 * @returns {wp.media.view.settings.post.featuredImageId|number}
623
603
                 */
624
604
                get: function() {
628
608
                 * Set the featured image id, save the post thumbnail data and
629
609
                 * set the HTML in the post meta box to the new featured image.
630
610
                 *
631
 
                 * @global wp.media.view.settings
632
 
                 * @global wp.media.post
633
 
                 *
634
611
                 * @param {number} id The post ID of the featured image, or -1 to unset it.
635
612
                 */
636
613
                set: function( id ) {
660
637
                /**
661
638
                 * The Featured Image workflow
662
639
                 *
663
 
                 * @global wp.media.controller.FeaturedImage
664
 
                 * @global wp.media.view.l10n
665
 
                 *
666
640
                 * @this wp.media.featuredImage
667
641
                 *
668
642
                 * @returns {wp.media.view.MediaFrame.Select} A media workflow.
705
679
                 * 'select' callback for Featured Image workflow, triggered when
706
680
                 *  the 'Set Featured Image' button is clicked in the media modal.
707
681
                 *
708
 
                 * @global wp.media.view.settings
709
 
                 *
710
682
                 * @this wp.media.controller.FeaturedImage
711
683
                 */
712
684
                select: function() {
723
695
                 * the post thumbnail is clicked.
724
696
                 *
725
697
                 * Update the featured image id when the 'remove' link is clicked.
726
 
                 *
727
 
                 * @global wp.media.view.settings
728
698
                 */
729
699
                init: function() {
730
700
                        $('#postimagediv').on( 'click', '#set-post-thumbnail', function( event ) {
742
712
 
743
713
        $( wp.media.featuredImage.init );
744
714
 
745
 
        /**
746
 
         * wp.media.editor
747
 
         * @namespace
748
 
         */
 
715
        /** @namespace wp.media.editor */
749
716
        wp.media.editor = {
750
717
                /**
751
718
                 * Send content to the editor
752
719
                 *
753
 
                 * @global tinymce
754
 
                 * @global QTags
755
 
                 * @global wpActiveEditor
756
 
                 * @global tb_remove() - Possibly overloaded by legacy plugins
757
 
                 *
758
720
                 * @param {string} html Content to send to the editor
759
721
                 */
760
722
                insert: function( html ) {
805
767
                 * Setup 'workflow' and add to the 'workflows' cache. 'open' can
806
768
                 *  subsequently be called upon it.
807
769
                 *
808
 
                 * @global wp.media.view.l10n
809
 
                 *
810
770
                 * @param {string} id A slug used to identify the workflow.
811
771
                 * @param {Object} [options={}]
812
772
                 *
914
874
                /**
915
875
                 * Determines the proper current workflow id
916
876
                 *
917
 
                 * @global wpActiveEditor
918
 
                 * @global tinymce
919
 
                 *
920
877
                 * @param {string} [id=''] A slug used to identify the workflow.
921
878
                 *
922
879
                 * @returns {wpActiveEditor|string|tinymce.activeEditor.id}
962
919
                        id = this.id( id );
963
920
                        delete workflows[ id ];
964
921
                },
965
 
                /**
966
 
                 * @namespace
967
 
                 */
 
922
                /** @namespace wp.media.editor.send */
968
923
                send: {
969
924
                        /**
970
925
                         * Called when sending an attachment to the editor
971
926
                         *   from the medial modal.
972
927
                         *
973
 
                         * @global wp.media.view.settings
974
 
                         * @global wp.media.post
975
 
                         *
976
928
                         * @param {Object} props Attachment details (align, link, size, etc).
977
929
                         * @param {Object} attachment The attachment object, media version of Post.
978
930
                         * @returns {Promise}
1028
980
                        /**
1029
981
                         * Called when 'Insert From URL' source is not an image. Example: YouTube url.
1030
982
                         *
1031
 
                         * @global wp.media.view.settings
1032
 
                         *
1033
983
                         * @param {Object} embed
1034
984
                         * @returns {Promise}
1035
985
                         */
1075
1025
 
1076
1026
                /**
1077
1027
                 * Bind click event for .insert-media using event delegation
1078
 
                 *
1079
 
                 * @global wp.media.view.l10n
1080
1028
                 */
1081
1029
                init: function() {
1082
1030
                        $(document.body)