Skip to:
Content

BuddyPress.org

Ticket #8231: 8231.patch

File 8231.patch, 10.2 KB (added by passoniate, 7 years ago)

Patch

  • src/bp-core/js/cover-image.js

     
    44
    55( function( exports, $ ) {
    66
    7         // Bail if not set
     7        // Bail if not set.
    88        if ( typeof BP_Uploader === 'undefined' ) {
    99                return;
    1010        }
     
    1616        bp.CoverImage = {
    1717                start: function() {
    1818
    19                         // Init some vars
     19                        // Init some vars.
    2020                        this.views   = new Backbone.Collection();
    2121                        this.warning = null;
    2222
     
    2323                        // The Cover Image Attachment object.
    2424                        this.Attachment = new Backbone.Model();
    2525
    26                         // Set up views
     26                        // Set up views.
    2727                        this.uploaderView();
    2828
    29                         // Inform about the needed dimensions
     29                        // Inform about the needed dimensions.
    3030                        this.displayWarning( BP_Uploader.strings.cover_image_warnings.dimensions );
    3131
    32                         // Set up the delete view if needed
     32                        // Set up the delete view if needed.
    3333                        if ( true === BP_Uploader.settings.defaults.multipart_params.bp_params.has_cover_image ) {
    3434                                this.deleteView();
    3535                        }
     
    3636                },
    3737
    3838                uploaderView: function() {
    39                         // Listen to the Queued uploads
     39                        // Listen to the Queued uploads.
    4040                        bp.Uploader.filesQueue.on( 'add', this.uploadProgress, this );
    4141
    42                         // Create the BuddyPress Uploader
     42                        // Create the BuddyPress Uploader.
    4343                        var uploader = new bp.Views.Uploader();
    4444
    45                         // Add it to views
     45                        // Add it to views.
    4646                        this.views.add( { id: 'upload', view: uploader } );
    4747
    48                         // Display it
     48                        // Display it.
    4949                        uploader.inject( '.bp-cover-image' );
    5050                },
    5151
    5252                uploadProgress: function() {
    53                         // Create the Uploader status view
     53                        // Create the Uploader status view.
    5454                        var coverImageUploadProgress = new bp.Views.coverImageUploadProgress( { collection: bp.Uploader.filesQueue } );
    5555
    5656                        if ( ! _.isUndefined( this.views.get( 'status' ) ) ) {
     
    5959                                this.views.add( { id: 'status', view: coverImageUploadProgress } );
    6060                        }
    6161
    62                         // Display it
     62                        // Display it.
    6363                        coverImageUploadProgress.inject( '.bp-cover-image-status' );
    6464                },
    6565
    6666                deleteView: function() {
    67                         // Create the delete model
     67                        // Create the delete model.
    6868                        var delete_model = new Backbone.Model( _.pick( BP_Uploader.settings.defaults.multipart_params.bp_params,
    6969                                ['object', 'item_id', 'nonces']
    7070                        ) );
     
    7474                                return;
    7575                        }
    7676
    77                         // Create the delete view
     77                        // Create the delete view.
    7878                        var deleteView = new bp.Views.DeleteCoverImage( { model: delete_model } );
    7979
    80                         // Add it to views
     80                        // Add it to views.
    8181                        this.views.add( { id: 'delete', view: deleteView } );
    8282
    83                         // Display it
     83                        // Display it.
    8484                        deleteView.inject( '.bp-cover-image-manage' );
    8585                },
    8686
     
    8888                        var self = this,
    8989                                deleteView;
    9090
    91                         // Remove the delete view
     91                        // Remove the delete view.
    9292                        if ( ! _.isUndefined( this.views.get( 'delete' ) ) ) {
    9393                                deleteView = this.views.get( 'delete' );
    9494                                deleteView.get( 'view' ).remove();
     
    114114
    115115                                coverImageStatus.inject( '.bp-cover-image-status' );
    116116
    117                                 // Reset the header of the page
     117                                // Reset the header of the page.
    118118                                if ( '' === response.reset_url ) {
    119119                                        $( '#header-cover-image' ).css( {
    120120                                                'background-image': 'none'
     
    125125                                        } );
    126126                                }
    127127
    128                                 // Reset the has_cover_image bp_param
     128                                // Reset the has_cover_image bp_param.
    129129                                BP_Uploader.settings.defaults.multipart_params.bp_params.has_cover_image = false;
    130130
    131131                                /**
    132                                  * Reset the Attachment object
     132                                 * Reset the Attachment object.
    133133                                 *
    134134                                 * You can run extra actions once the cover image is set using:
    135135                                 * bp.CoverImage.Attachment.on( 'change:url', function( data ) { your code } );
     
    182182                }
    183183        };
    184184
    185         // Custom Uploader Files view
     185        // Custom Uploader Files view.
    186186        bp.Views.coverImageUploadProgress = bp.Views.uploaderStatus.extend( {
    187187                className: 'files',
    188188
     
    197197
    198198                        if ( ! _.isUndefined( model.get( 'url' ) ) ) {
    199199
    200                                 // Image is too small
     200                                // Image is too small.
    201201                                if ( 0 === model.get( 'feedback_code' ) ) {
    202202                                        message = BP_Uploader.strings.cover_image_warnings.dimensions;
    203203                                        type    = 'warning';
     
    213213                                        type  : type
    214214                                } ) );
    215215
    216                                 // Update the header of the page
     216                                // Update the header of the page.
    217217                                $( '#header-cover-image' ).css( {
    218218                                        'background-image': 'url( ' + model.get( 'url' ) + ' )'
    219219                                } );
    220220
    221                                 // Add the delete view
     221                                // Add the delete view.
    222222                                bp.CoverImage.deleteView();
    223223
    224224                                /**
    225                                  * Set the Attachment object
     225                                 * Set the Attachment object.
    226226                                 *
    227227                                 * You can run extra actions once the cover image is set using:
    228228                                 * bp.CoverImage.Attachment.on( 'change:url', function( data ) { your code } );
     
    238238                }
    239239        } );
    240240
    241         // BuddyPress Cover Image Feedback view
     241        // BuddyPress Cover Image Feedback view.
    242242        bp.Views.CoverImageStatus = bp.View.extend( {
    243243                tagName: 'p',
    244244                className: 'updated',
     
    255255                }
    256256        } );
    257257
    258         // BuddyPress Cover Image Delete view
     258        // BuddyPress Cover Image Delete view.
    259259        bp.Views.DeleteCoverImage = bp.View.extend( {
    260260                tagName: 'div',
    261261                id: 'bp-delete-cover-image-container',
  • src/bp-core/js/vendor/jquery-cookie.js

     
    88 * Released under the MIT license
    99 */
    1010(function(factory) {
    11         // AMD
     11        // AMD.
    1212        if (typeof define === 'function' && define.amd) {
    1313                define(['jquery'], factory);
    14         // CommonJS
     14        // CommonJS.
    1515        } else if (typeof exports === 'object') {
    1616                factory(require('jquery'));
    17         // Browser globals
     17        // Browser globals.
    1818        } else {
    1919                factory(jQuery);
    2020        }
     
    5757
    5858        var config = $.cookie = function(key, value, options) {
    5959
    60                 // Write
     60                // Write.
    6161
    6262                if (value !== undefined && !$.isFunction(value)) {
    6363                        options = $.extend({}, config.defaults, options);
     
    7676                        ].join(''));
    7777                }
    7878
    79                 // Read
     79                // Read.
    8080
    8181                var result = key ? undefined : {};
    8282
  • src/bp-core/js/vendor/jquery-scroll-to.js

     
    1212 */
    1313
    1414(function(factory) {
    15         // AMD
     15        // AMD.
    1616        if (typeof define === 'function' && define.amd) {
    1717                define(['jquery'], factory);
    18         // CommonJS
     18        // CommonJS.
    1919        } else if (typeof exports === 'object') {
    2020                factory(require('jquery'));
    21         // Browser globals
     21        // Browser globals.
    2222        } else {
    2323                factory(jQuery);
    2424        }
     
    3535        };
    3636
    3737        // Returns the element that needs to be animated to scroll the window.
    38         // Kept for backwards compatibility (specially for localScroll & serialScroll)
     38        // Kept for backwards compatibility (specially for localScroll & serialScroll).
    3939        $scrollTo.window = function() {
    4040                return $(window)._scrollable();
    4141        };
    4242
    4343        // Hack, hack, hack :)
    44         // Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
     44        // Returns the real elements to scroll (supports window/iframes, documents and regular nodes).
    4545        $.fn._scrollable = function() {
    4646                return this.map(function() {
    4747                        var elem = this,
     
    7373                }
    7474
    7575                settings = $.extend({}, $scrollTo.defaults, settings);
    76                 // Speed is still recognized for backwards compatibility
     76                // Speed is still recognized for backwards compatibility.
    7777                duration = duration || settings.duration;
    78                 // Make sure the settings are given right
     78                // Make sure the settings are given right.
    7979                settings.queue = settings.queue && settings.axis.length > 1;
    8080
    81                 // Let's keep the overall duration
     81                // Let's keep the overall duration.
    8282                if (settings.queue) {
    8383                        duration /= 2;
    8484                }
     
    8888
    8989                return this._scrollable().each(function() {
    9090
    91                         // Null target yields nothing, just like jQuery does
     91                        // Null target yields nothing, just like jQuery does.
    9292                        if (target === null) {
    9393                                return;
    9494                        }
     
    9999                                        win = $elem.is('html,body');
    100100
    101101                        switch (typeof targ) {
    102                                 // A number will pass the regex
     102                                // A number will pass the regex.
    103103                                case 'number':
    104104                                case 'string':
    105105                                        if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
     
    114114                                        }
    115115                                        /* falls through */
    116116                                case 'object':
    117                                         // DOMElement / jQuery
     117                                        // DOMElement / jQuery.
    118118                                        if (targ.is || targ.style) {
    119                                                 // Get the real position of the target
     119                                                // Get the real position of the target.
    120120                                                toff = (targ = $(targ)).offset();
    121121                                        }
    122122                        }
     
    130130                                                old = elem[key],
    131131                                                max = $scrollTo.max(elem, axis);
    132132
    133                                 if (toff) {// jQuery / DOMElement
     133                                if (toff) { // jQuery / DOMElement.
    134134                                        attr[key] = toff[pos] + (win ? 0 : old - $elem.offset()[pos]);
    135135
    136                                         // If it's a dom element, reduce the margin
     136                                        // If it's a dom element, reduce the margin.
    137137                                        if (settings.margin) {
    138138                                                attr[key] -= parseInt(targ.css('margin' + Pos)) || 0;
    139139                                                attr[key] -= parseInt(targ.css('border' + Pos + 'Width')) || 0;
     
    141141
    142142                                        attr[key] += offset[pos] || 0;
    143143
    144                                         // Scroll to a fraction of its width/height
     144                                        // Scroll to a fraction of its width/height.
    145145                                        if (settings.over[pos]) {
    146146                                                attr[key] += targ[axis === 'x' ? 'width' : 'height']() * settings.over[pos];
    147147                                        }
    148148                                } else {
    149149                                        var val = targ[pos];
    150                                         // Handle percentage values
     150                                        // Handle percentage values.
    151151                                        attr[key] = val.slice && val.slice(-1) === '%' ?
    152152                                                        parseFloat(val) / 100 * max
    153153                                                        : val;
    154154                                }
    155155
    156                                 // Number or 'number'
     156                                // Number or 'number'.
    157157                                if (settings.limit && /^\d+$/.test(attr[key])) {
    158158                                        // Check the limits
    159159                                        attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max);
    160160                                }
    161161
    162                                 // Queueing axes
     162                                // Queueing axes.
    163163                                if (!i && settings.queue) {
    164164                                        // Don't waste time animating, if there's no need.
    165165                                        if (old !== attr[key]) {
    166                                                 // Intermediate animation
     166                                                // Intermediate animation.
    167167                                                animate(settings.onAfterFirst);
    168168                                        }
    169169                                        // Don't animate this axis again in the next iteration.
     
    203203                return $.isFunction(val) || typeof val === 'object' ? val : {top: val, left: val};
    204204        }
    205205
    206         // AMD requirement
     206        // AMD requirement.
    207207        return $scrollTo;
    208208}));
     209 No newline at end of file