Make WordPress Core

Ticket #22796: 22796.2.diff

File 22796.2.diff, 4.9 KB (added by koopersmith, 12 years ago)
  • wp-includes/css/media-views.css

     
    12491249/**
    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;
    12541266        float: right;
     
    12571269}
    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}
    12701274
     
    13971401.embed-url {
    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;
    14041407        background: #fff;
     
    14161419        box-shadow: inset 2px 2px 4px -2px rgba( 0, 0, 0, 0.1 );
    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 {
    14211434        position: absolute;
     
    14371450
    14381451.media-embed .thumbnail img {
    14391452        max-height: 200px;
     1453        display: block;
    14401454}
    14411455
    14421456.media-embed .thumbnail:after {
     
    16521666                background-size: 134px 15px;
    16531667        }
    16541668
    1655         .media-sidebar .settings-save-status .spinner {
     1669        .media-frame .spinner {
    16561670                background-image: url(../images/wpspin-2x.gif);
    16571671        }
    16581672}
     1673 No newline at end of file
  • wp-includes/js/autosave.js

     
    230230        // delay that a bit to avoid some rare collisions while the DOM is being updated.
    231231        setTimeout(function(){
    232232                jQuery(':button, :submit', '#submitpost').removeAttr('disabled');
    233                 jQuery('.spinner').hide();
     233                jQuery('.spinner', '#submitpost').hide();
    234234        }, 500);
    235235}
    236236
  • wp-includes/js/media-views.js

     
    778778                },
    779779
    780780                scan: function() {
    781                         var attributes = { type: 'link' };
     781                        var scanners,
     782                                embed = this,
     783                                attributes = {
     784                                        type: 'link',
     785                                        scanners: []
     786                                };
    782787
    783                         this.trigger( 'scan', attributes );
     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                },
    786807
     
    788809                        var frame = this.frame,
    789810                                state = this,
    790811                                url = this.props.get('url'),
    791                                 image = new Image();
     812                                image = new Image(),
     813                                deferred = $.Deferred();
    792814
     815                        attributes.scanners.push( deferred.promise() );
     816
    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
    802831                                });
    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
    813838                refresh: function() {
     
    41474172                        this.views.set([ this.url ]);
    41484173                        this.refresh();
    41494174                        this.model.on( 'change:type', this.refresh, this );
     4175                        this.model.on( 'change:loading', this.loading, this );
    41504176                },
    41514177
    41524178                settings: function( view ) {
     
    41724198                                model:      this.model.props,
    41734199                                priority:   40
    41744200                        }) );
     4201                },
     4202
     4203                loading: function() {
     4204                        this.$el.toggleClass( 'embed-loading', this.model.get('loading') );
    41754205                }
    41764206        });
    41774207
     
    41944224                                value: this.model.get('url') || ''
    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 );
    42014235                },