Ticket #8231: 8231.patch
| File 8231.patch, 10.2 KB (added by , 7 years ago) |
|---|
-
src/bp-core/js/cover-image.js
4 4 5 5 ( function( exports, $ ) { 6 6 7 // Bail if not set 7 // Bail if not set. 8 8 if ( typeof BP_Uploader === 'undefined' ) { 9 9 return; 10 10 } … … 16 16 bp.CoverImage = { 17 17 start: function() { 18 18 19 // Init some vars 19 // Init some vars. 20 20 this.views = new Backbone.Collection(); 21 21 this.warning = null; 22 22 … … 23 23 // The Cover Image Attachment object. 24 24 this.Attachment = new Backbone.Model(); 25 25 26 // Set up views 26 // Set up views. 27 27 this.uploaderView(); 28 28 29 // Inform about the needed dimensions 29 // Inform about the needed dimensions. 30 30 this.displayWarning( BP_Uploader.strings.cover_image_warnings.dimensions ); 31 31 32 // Set up the delete view if needed 32 // Set up the delete view if needed. 33 33 if ( true === BP_Uploader.settings.defaults.multipart_params.bp_params.has_cover_image ) { 34 34 this.deleteView(); 35 35 } … … 36 36 }, 37 37 38 38 uploaderView: function() { 39 // Listen to the Queued uploads 39 // Listen to the Queued uploads. 40 40 bp.Uploader.filesQueue.on( 'add', this.uploadProgress, this ); 41 41 42 // Create the BuddyPress Uploader 42 // Create the BuddyPress Uploader. 43 43 var uploader = new bp.Views.Uploader(); 44 44 45 // Add it to views 45 // Add it to views. 46 46 this.views.add( { id: 'upload', view: uploader } ); 47 47 48 // Display it 48 // Display it. 49 49 uploader.inject( '.bp-cover-image' ); 50 50 }, 51 51 52 52 uploadProgress: function() { 53 // Create the Uploader status view 53 // Create the Uploader status view. 54 54 var coverImageUploadProgress = new bp.Views.coverImageUploadProgress( { collection: bp.Uploader.filesQueue } ); 55 55 56 56 if ( ! _.isUndefined( this.views.get( 'status' ) ) ) { … … 59 59 this.views.add( { id: 'status', view: coverImageUploadProgress } ); 60 60 } 61 61 62 // Display it 62 // Display it. 63 63 coverImageUploadProgress.inject( '.bp-cover-image-status' ); 64 64 }, 65 65 66 66 deleteView: function() { 67 // Create the delete model 67 // Create the delete model. 68 68 var delete_model = new Backbone.Model( _.pick( BP_Uploader.settings.defaults.multipart_params.bp_params, 69 69 ['object', 'item_id', 'nonces'] 70 70 ) ); … … 74 74 return; 75 75 } 76 76 77 // Create the delete view 77 // Create the delete view. 78 78 var deleteView = new bp.Views.DeleteCoverImage( { model: delete_model } ); 79 79 80 // Add it to views 80 // Add it to views. 81 81 this.views.add( { id: 'delete', view: deleteView } ); 82 82 83 // Display it 83 // Display it. 84 84 deleteView.inject( '.bp-cover-image-manage' ); 85 85 }, 86 86 … … 88 88 var self = this, 89 89 deleteView; 90 90 91 // Remove the delete view 91 // Remove the delete view. 92 92 if ( ! _.isUndefined( this.views.get( 'delete' ) ) ) { 93 93 deleteView = this.views.get( 'delete' ); 94 94 deleteView.get( 'view' ).remove(); … … 114 114 115 115 coverImageStatus.inject( '.bp-cover-image-status' ); 116 116 117 // Reset the header of the page 117 // Reset the header of the page. 118 118 if ( '' === response.reset_url ) { 119 119 $( '#header-cover-image' ).css( { 120 120 'background-image': 'none' … … 125 125 } ); 126 126 } 127 127 128 // Reset the has_cover_image bp_param 128 // Reset the has_cover_image bp_param. 129 129 BP_Uploader.settings.defaults.multipart_params.bp_params.has_cover_image = false; 130 130 131 131 /** 132 * Reset the Attachment object 132 * Reset the Attachment object. 133 133 * 134 134 * You can run extra actions once the cover image is set using: 135 135 * bp.CoverImage.Attachment.on( 'change:url', function( data ) { your code } ); … … 182 182 } 183 183 }; 184 184 185 // Custom Uploader Files view 185 // Custom Uploader Files view. 186 186 bp.Views.coverImageUploadProgress = bp.Views.uploaderStatus.extend( { 187 187 className: 'files', 188 188 … … 197 197 198 198 if ( ! _.isUndefined( model.get( 'url' ) ) ) { 199 199 200 // Image is too small 200 // Image is too small. 201 201 if ( 0 === model.get( 'feedback_code' ) ) { 202 202 message = BP_Uploader.strings.cover_image_warnings.dimensions; 203 203 type = 'warning'; … … 213 213 type : type 214 214 } ) ); 215 215 216 // Update the header of the page 216 // Update the header of the page. 217 217 $( '#header-cover-image' ).css( { 218 218 'background-image': 'url( ' + model.get( 'url' ) + ' )' 219 219 } ); 220 220 221 // Add the delete view 221 // Add the delete view. 222 222 bp.CoverImage.deleteView(); 223 223 224 224 /** 225 * Set the Attachment object 225 * Set the Attachment object. 226 226 * 227 227 * You can run extra actions once the cover image is set using: 228 228 * bp.CoverImage.Attachment.on( 'change:url', function( data ) { your code } ); … … 238 238 } 239 239 } ); 240 240 241 // BuddyPress Cover Image Feedback view 241 // BuddyPress Cover Image Feedback view. 242 242 bp.Views.CoverImageStatus = bp.View.extend( { 243 243 tagName: 'p', 244 244 className: 'updated', … … 255 255 } 256 256 } ); 257 257 258 // BuddyPress Cover Image Delete view 258 // BuddyPress Cover Image Delete view. 259 259 bp.Views.DeleteCoverImage = bp.View.extend( { 260 260 tagName: 'div', 261 261 id: 'bp-delete-cover-image-container', -
src/bp-core/js/vendor/jquery-cookie.js
8 8 * Released under the MIT license 9 9 */ 10 10 (function(factory) { 11 // AMD 11 // AMD. 12 12 if (typeof define === 'function' && define.amd) { 13 13 define(['jquery'], factory); 14 // CommonJS 14 // CommonJS. 15 15 } else if (typeof exports === 'object') { 16 16 factory(require('jquery')); 17 // Browser globals 17 // Browser globals. 18 18 } else { 19 19 factory(jQuery); 20 20 } … … 57 57 58 58 var config = $.cookie = function(key, value, options) { 59 59 60 // Write 60 // Write. 61 61 62 62 if (value !== undefined && !$.isFunction(value)) { 63 63 options = $.extend({}, config.defaults, options); … … 76 76 ].join('')); 77 77 } 78 78 79 // Read 79 // Read. 80 80 81 81 var result = key ? undefined : {}; 82 82 -
src/bp-core/js/vendor/jquery-scroll-to.js
12 12 */ 13 13 14 14 (function(factory) { 15 // AMD 15 // AMD. 16 16 if (typeof define === 'function' && define.amd) { 17 17 define(['jquery'], factory); 18 // CommonJS 18 // CommonJS. 19 19 } else if (typeof exports === 'object') { 20 20 factory(require('jquery')); 21 // Browser globals 21 // Browser globals. 22 22 } else { 23 23 factory(jQuery); 24 24 } … … 35 35 }; 36 36 37 37 // 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). 39 39 $scrollTo.window = function() { 40 40 return $(window)._scrollable(); 41 41 }; 42 42 43 43 // 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). 45 45 $.fn._scrollable = function() { 46 46 return this.map(function() { 47 47 var elem = this, … … 73 73 } 74 74 75 75 settings = $.extend({}, $scrollTo.defaults, settings); 76 // Speed is still recognized for backwards compatibility 76 // Speed is still recognized for backwards compatibility. 77 77 duration = duration || settings.duration; 78 // Make sure the settings are given right 78 // Make sure the settings are given right. 79 79 settings.queue = settings.queue && settings.axis.length > 1; 80 80 81 // Let's keep the overall duration 81 // Let's keep the overall duration. 82 82 if (settings.queue) { 83 83 duration /= 2; 84 84 } … … 88 88 89 89 return this._scrollable().each(function() { 90 90 91 // Null target yields nothing, just like jQuery does 91 // Null target yields nothing, just like jQuery does. 92 92 if (target === null) { 93 93 return; 94 94 } … … 99 99 win = $elem.is('html,body'); 100 100 101 101 switch (typeof targ) { 102 // A number will pass the regex 102 // A number will pass the regex. 103 103 case 'number': 104 104 case 'string': 105 105 if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) { … … 114 114 } 115 115 /* falls through */ 116 116 case 'object': 117 // DOMElement / jQuery 117 // DOMElement / jQuery. 118 118 if (targ.is || targ.style) { 119 // Get the real position of the target 119 // Get the real position of the target. 120 120 toff = (targ = $(targ)).offset(); 121 121 } 122 122 } … … 130 130 old = elem[key], 131 131 max = $scrollTo.max(elem, axis); 132 132 133 if (toff) { // jQuery / DOMElement133 if (toff) { // jQuery / DOMElement. 134 134 attr[key] = toff[pos] + (win ? 0 : old - $elem.offset()[pos]); 135 135 136 // If it's a dom element, reduce the margin 136 // If it's a dom element, reduce the margin. 137 137 if (settings.margin) { 138 138 attr[key] -= parseInt(targ.css('margin' + Pos)) || 0; 139 139 attr[key] -= parseInt(targ.css('border' + Pos + 'Width')) || 0; … … 141 141 142 142 attr[key] += offset[pos] || 0; 143 143 144 // Scroll to a fraction of its width/height 144 // Scroll to a fraction of its width/height. 145 145 if (settings.over[pos]) { 146 146 attr[key] += targ[axis === 'x' ? 'width' : 'height']() * settings.over[pos]; 147 147 } 148 148 } else { 149 149 var val = targ[pos]; 150 // Handle percentage values 150 // Handle percentage values. 151 151 attr[key] = val.slice && val.slice(-1) === '%' ? 152 152 parseFloat(val) / 100 * max 153 153 : val; 154 154 } 155 155 156 // Number or 'number' 156 // Number or 'number'. 157 157 if (settings.limit && /^\d+$/.test(attr[key])) { 158 158 // Check the limits 159 159 attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max); 160 160 } 161 161 162 // Queueing axes 162 // Queueing axes. 163 163 if (!i && settings.queue) { 164 164 // Don't waste time animating, if there's no need. 165 165 if (old !== attr[key]) { 166 // Intermediate animation 166 // Intermediate animation. 167 167 animate(settings.onAfterFirst); 168 168 } 169 169 // Don't animate this axis again in the next iteration. … … 203 203 return $.isFunction(val) || typeof val === 'object' ? val : {top: val, left: val}; 204 204 } 205 205 206 // AMD requirement 206 // AMD requirement. 207 207 return $scrollTo; 208 208 })); 209 No newline at end of file
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)