Make WordPress Core

Changeset 23110


Ignore:
Timestamp:
12/06/2012 11:12:59 PM (12 years ago)
Author:
ryan
Message:

When inserting from URL in the media modal, retain query params and properly insert the caption code.

Props koopersmith
fixes #22796

Location:
trunk/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/css/media-views.css

    r23095 r23110  
    12501250 * Spinner
    12511251 */
     1252
     1253.media-frame .spinner {
     1254    background: url(../images/wpspin.gif) no-repeat;
     1255    background-size: 16px 16px;
     1256    display: none;
     1257    opacity: 0.7;
     1258    filter: alpha(opacity=70);
     1259    width: 16px;
     1260    height: 16px;
     1261    margin: 0;
     1262}
     1263
    12521264.media-sidebar .settings-save-status {
    12531265    background: #f5f5f5;
     
    12581270
    12591271.media-sidebar .settings-save-status .spinner {
    1260     background: url(../images/wpspin.gif) no-repeat;
    1261     background-size: 16px 16px;
    1262     display: none;
    1263     float: right;
    1264     opacity: 0.7;
    1265     filter: alpha(opacity=70);
    1266     width: 16px;
    1267     height: 16px;
    12681272    margin: 0 5px 0;
    12691273}
     
    13981402    display: block;
    13991403    position: relative;
    1400     height: 40px;
    1401     padding: 0 16px 16px;
     1404    padding: 0 16px 7px;
    14021405    margin: 0;
    14031406    z-index: 250;
     
    14171420}
    14181421
     1422.media-frame .embed-url .spinner {
     1423    position: absolute;
     1424    top: 16px;
     1425    right: 26px;
     1426}
     1427
     1428.media-frame .embed-loading .embed-url .spinner {
     1429    display: block;
     1430}
     1431
    14191432.embed-link-settings,
    14201433.embed-image-settings {
     
    14381451.media-embed .thumbnail img {
    14391452    max-height: 200px;
     1453    display: block;
    14401454}
    14411455
     
    16531667    }
    16541668
    1655     .media-sidebar .settings-save-status .spinner {
     1669    .media-frame .spinner {
    16561670        background-image: url(../images/wpspin-2x.gif);
    16571671    }
  • trunk/wp-includes/js/autosave.js

    r22794 r23110  
    231231    setTimeout(function(){
    232232        jQuery(':button, :submit', '#submitpost').removeAttr('disabled');
    233         jQuery('.spinner').hide();
     233        jQuery('.spinner', '#submitpost').hide();
    234234    }, 500);
    235235}
  • trunk/wp-includes/js/media-views.js

    r23098 r23110  
    779779
    780780        scan: function() {
    781             var attributes = { type: 'link' };
    782 
    783             this.trigger( 'scan', attributes );
     781            var scanners,
     782                embed = this,
     783                attributes = {
     784                    type: 'link',
     785                    scanners: []
     786                };
     787
     788            // Scan is triggered with the list of `attributes` to set on the
     789            // state, useful for the 'type' attribute and 'scanners' attribute,
     790            // an array of promise objects for asynchronous scan operations.
     791            if ( this.props.get('url') )
     792                this.trigger( 'scan', attributes );
     793
     794            if ( attributes.scanners.length ) {
     795                scanners = attributes.scanners = $.when.apply( $, attributes.scanners );
     796                scanners.always( function() {
     797                    if ( embed.get('scanners') === scanners )
     798                        embed.set( 'loading', false );
     799                });
     800            } else {
     801                attributes.scanners = null;
     802            }
     803
     804            attributes.loading = !! attributes.scanners;
    784805            this.set( attributes );
    785806        },
     
    789810                state = this,
    790811                url = this.props.get('url'),
    791                 image = new Image();
     812                image = new Image(),
     813                deferred = $.Deferred();
     814
     815            attributes.scanners.push( deferred.promise() );
    792816
    793817            // Try to load the image and find its width/height.
    794818            image.onload = function() {
     819                deferred.resolve();
     820
    795821                if ( state !== frame.state() || url !== state.props.get('url') )
    796822                    return;
    797823
    798824                state.set({
    799                     type:   'image',
     825                    type: 'image'
     826                });
     827
     828                state.props.set({
    800829                    width:  image.width,
    801830                    height: image.height
     
    803832            };
    804833
     834            image.onerror = deferred.reject;
    805835            image.src = url;
    806 
    807             // Check if the URL looks like an image; skew toward success.
    808             url = url.replace( /([?|#].*)$/, '' );
    809             if ( /\.(png|jpe?g|gif)$/i.test( url ) )
    810                 attributes.type = 'image';
    811836        },
    812837
     
    41484173            this.refresh();
    41494174            this.model.on( 'change:type', this.refresh, this );
     4175            this.model.on( 'change:loading', this.loading, this );
    41504176        },
    41514177
     
    41734199                priority:   40
    41744200            }) );
     4201        },
     4202
     4203        loading: function() {
     4204            this.$el.toggleClass( 'embed-loading', this.model.get('loading') );
    41754205        }
    41764206    });
     
    41954225            });
    41964226
     4227            this.spinner = this.make( 'span', {
     4228                'class': 'spinner'
     4229            });
     4230
    41974231            this.$input = $( this.input );
    4198             this.$el.append( this.input );
     4232            this.$el.append([ this.input, this.spinner ]);
    41994233
    42004234            this.model.on( 'change:url', this.render, this );
Note: See TracChangeset for help on using the changeset viewer.