Changeset 12548
- Timestamp:
- 01/29/2020 10:04:53 PM (5 years ago)
- Location:
- trunk/src/bp-core/js
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/js/avatar.js
r10496 r12548 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; … … 26 26 this.removeLegacyUI(); 27 27 28 // Init some vars 28 // Init some vars. 29 29 this.views = new Backbone.Collection(); 30 30 this.jcropapi = {}; 31 31 this.warning = null; 32 32 33 // Set up nav 33 // Set up nav. 34 34 this.setupNav(); 35 35 36 // Avatars are uploaded files 36 // Avatars are uploaded files. 37 37 this.avatars = bp.Uploader.filesUploaded; 38 38 … … 40 40 this.Attachment = new Backbone.Model(); 41 41 42 // Wait till the queue is reset 42 // Wait till the queue is reset. 43 43 bp.Uploader.filesQueue.on( 'reset', this.cropView, this ); 44 44 … … 57 57 58 58 removeLegacyUI: function() { 59 // User 59 // User. 60 60 if ( $( '#avatar-upload-form' ).length ) { 61 61 $( '#avatar-upload' ).remove(); 62 62 $( '#avatar-upload-form p' ).remove(); 63 63 64 // Group Manage 64 // Group Manage. 65 65 } else if ( $( '#group-settings-form' ).length ) { 66 66 $( '#group-settings-form p' ).each( function( i ) { … … 74 74 } 75 75 76 // Group Create 76 // Group Create. 77 77 } else if ( $( '#group-create-body' ).length ) { 78 78 $( '.main-column p #file' ).remove(); 79 79 $( '.main-column p #upload' ).remove(); 80 80 81 // Admin Extended Profile 81 // Admin Extended Profile. 82 82 } else if ( $( '#bp_xprofile_user_admin_avatar a.bp-xprofile-avatar-user-admin' ).length ) { 83 83 $( '#bp_xprofile_user_admin_avatar a.bp-xprofile-avatar-user-admin' ).remove(); … … 86 86 87 87 setView: function( view ) { 88 // Clear views 88 // Clear views. 89 89 if ( ! _.isUndefined( this.views.models ) ) { 90 90 _.each( this.views.models, function( model ) { … … 93 93 } 94 94 95 // Reset Views 95 // Reset Views. 96 96 this.views.reset(); 97 97 98 // Reset Avatars (file uploaded) 98 // Reset Avatars (file uploaded). 99 99 if ( ! _.isUndefined( this.avatars ) ) { 100 100 this.avatars.reset(); 101 101 } 102 102 103 // Reset the Jcrop API 103 // Reset the Jcrop API. 104 104 if ( ! _.isEmpty( this.jcropapi ) ) { 105 105 this.jcropapi.destroy(); … … 107 107 } 108 108 109 // Load the required view 109 // Load the required view. 110 110 switch ( view ) { 111 111 case 'upload': … … 120 120 121 121 resetViews: function() { 122 // Reset to the uploader view 122 // Reset to the uploader view. 123 123 this.nav.trigger( 'bp-avatar-view:changed', 'upload' ); 124 124 125 // Reset to the uploader nav 125 // Reset to the uploader nav. 126 126 _.each( this.navItems.models, function( model ) { 127 127 if ( model.id === 'upload' ) { … … 144 144 } 145 145 146 // Reset active View 146 // Reset active View. 147 147 activeView = 0; 148 148 … … 164 164 this.nav.inject( '.bp-avatar-nav' ); 165 165 166 // Activate the initial view (uploader) 166 // Activate the initial view (uploader). 167 167 this.setView( initView ); 168 168 169 // Listen to nav changes (it's like a do_action!) 169 // Listen to nav changes (it's like a do_action!). 170 170 this.nav.on( 'bp-avatar-view:changed', _.bind( this.setView, this ) ); 171 171 }, 172 172 173 173 uploaderView: function() { 174 // Listen to the Queued uploads 174 // Listen to the Queued uploads. 175 175 bp.Uploader.filesQueue.on( 'add', this.uploadProgress, this ); 176 176 177 // Create the BuddyPress Uploader 177 // Create the BuddyPress Uploader. 178 178 var uploader = new bp.Views.Uploader(); 179 179 180 // Add it to views 180 // Add it to views. 181 181 this.views.add( { id: 'upload', view: uploader } ); 182 182 183 // Display it 183 // Display it. 184 184 uploader.inject( '.bp-avatar' ); 185 185 }, 186 186 187 187 uploadProgress: function() { 188 // Create the Uploader status view 188 // Create the Uploader status view. 189 189 var avatarStatus = new bp.Views.uploaderStatus( { collection: bp.Uploader.filesQueue } ); 190 190 … … 195 195 } 196 196 197 // Display it 197 // Display it. 198 198 avatarStatus.inject( '.bp-avatar-status' ); 199 199 }, … … 202 202 var status; 203 203 204 // Bail there was an error during the Upload 204 // Bail there was an error during the Upload. 205 205 if ( _.isEmpty( this.avatars.models ) ) { 206 206 return; 207 207 } 208 208 209 // Make sure to remove the uploads status 209 // Make sure to remove the uploads status. 210 210 if ( ! _.isUndefined( this.views.get( 'status' ) ) ) { 211 211 status = this.views.get( 'status' ); … … 214 214 } 215 215 216 // Create the Avatars view 216 // Create the Avatars view. 217 217 var avatar = new bp.Views.Avatars( { collection: this.avatars } ); 218 218 this.views.add( { id: 'crop', view: avatar } ); … … 225 225 crop; 226 226 227 // Remove the crop view 227 // Remove the crop view. 228 228 if ( ! _.isUndefined( this.views.get( 'crop' ) ) ) { 229 // Remove the JCrop API 229 // Remove the JCrop API. 230 230 if ( ! _.isEmpty( this.jcropapi ) ) { 231 231 this.jcropapi.destroy(); … … 262 262 avatarStatus.inject( '.bp-avatar-status' ); 263 263 264 // Update each avatars of the page 264 // Update each avatars of the page. 265 265 $( '.' + avatar.get( 'object' ) + '-' + response.item_id + '-avatar' ).each( function() { 266 266 $(this).prop( 'src', response.avatar ); 267 267 } ); 268 268 269 // Inject the Delete nav 269 // Inject the Delete nav. 270 270 bp.Avatar.navItems.get( 'delete' ).set( { hide: 0 } ); 271 271 … … 305 305 306 306 deleteView:function() { 307 // Create the delete model 307 // Create the delete model. 308 308 var delete_model = new Backbone.Model( _.pick( BP_Uploader.settings.defaults.multipart_params.bp_params, 309 309 'object', … … 312 312 ) ); 313 313 314 // Create the delete view 314 // Create the delete view. 315 315 var deleteView = new bp.Views.DeleteAvatar( { model: delete_model } ); 316 316 317 // Add it to views 317 // Add it to views. 318 318 this.views.add( { id: 'delete', view: deleteView } ); 319 319 320 // Display it 320 // Display it. 321 321 deleteView.inject( '.bp-avatar' ); 322 322 }, … … 326 326 deleteView; 327 327 328 // Remove the delete view 328 // Remove the delete view. 329 329 if ( ! _.isUndefined( this.views.get( 'delete' ) ) ) { 330 330 deleteView = this.views.get( 'delete' ); … … 352 352 avatarStatus.inject( '.bp-avatar-status' ); 353 353 354 // Update each avatars of the page 354 // Update each avatars of the page. 355 355 $( '.' + model.get( 'object' ) + '-' + response.item_id + '-avatar').each( function() { 356 356 $( this ).prop( 'src', response.avatar ); 357 357 } ); 358 358 359 // Remove the Delete nav 359 // Remove the Delete nav. 360 360 bp.Avatar.navItems.get( 'delete' ).set( { active: 0, hide: 1 } ); 361 361 362 362 /** 363 * Reset the Attachment object 363 * Reset the Attachment object. 364 364 * 365 365 * You can run extra actions once the avatar is set using: … … 411 411 }; 412 412 413 // Main Nav view 413 // Main Nav view. 414 414 bp.Views.Nav = bp.View.extend( { 415 415 tagName: 'ul', … … 423 423 var hasAvatar = _.findWhere( this.collection.models, { id: 'delete' } ); 424 424 425 // Display a message to inform about the delete tab 425 // Display a message to inform about the delete tab. 426 426 if ( 1 !== hasAvatar.get( 'hide' ) ) { 427 427 bp.Avatar.displayWarning( BP_Uploader.strings.has_avatar_warning ); … … 435 435 /** 436 436 * The delete nav is not added if no avatar 437 * is set for the object 437 * is set for the object. 438 438 */ 439 439 if ( 1 === item.get( 'hide' ) ) { … … 456 456 } 457 457 458 // Check to see if the nav is not already rendered 458 // Check to see if the nav is not already rendered. 459 459 if ( item.get( 'id' ) === view.model.get( 'id' ) ) { 460 460 isRendered = true; … … 462 462 } ); 463 463 464 // Add the Delete nav if not rendered 464 // Add the Delete nav if not rendered. 465 465 if ( ! _.isBoolean( isRendered ) ) { 466 466 this.addNavItem( item ); … … 471 471 event.preventDefault(); 472 472 473 // First make sure to remove all warnings 473 // First make sure to remove all warnings. 474 474 bp.Avatar.removeWarning(); 475 475 … … 487 487 } ); 488 488 489 // Nav item view 489 // Nav item view. 490 490 bp.Views.NavItem = bp.View.extend( { 491 491 tagName: 'li', … … 511 511 } ); 512 512 513 // Avatars view 513 // Avatars view. 514 514 bp.Views.Avatars = bp.View.extend( { 515 515 className: 'items', … … 520 520 521 521 addItemView: function( item ) { 522 // Defaults to 150 522 // Defaults to 150. 523 523 var full_d = { full_h: 150, full_w: 150 }; 524 524 525 // Make sure to take in account bp_core_avatar_full_height or bp_core_avatar_full_width php filters 525 // Make sure to take in account bp_core_avatar_full_height or bp_core_avatar_full_width php filters. 526 526 if ( ! _.isUndefined( BP_Uploader.settings.crop.full_h ) && ! _.isUndefined( BP_Uploader.settings.crop.full_w ) ) { 527 527 full_d.full_h = BP_Uploader.settings.crop.full_h; … … 529 529 } 530 530 531 // Set the avatar model 531 // Set the avatar model. 532 532 item.set( _.extend( _.pick( BP_Uploader.settings.defaults.multipart_params.bp_params, 533 533 'object', … … 536 536 ), full_d ) ); 537 537 538 // Add the view 538 // Add the view. 539 539 this.views.add( new bp.Views.Avatar( { model: item } ) ); 540 540 } 541 541 } ); 542 542 543 // Avatar view 543 // Avatar view. 544 544 bp.Views.Avatar = bp.View.extend( { 545 545 className: 'item', … … 557 557 } ); 558 558 559 // Display a warning if the image is smaller than minimum advised 559 // Display a warning if the image is smaller than minimum advised. 560 560 if ( false !== this.model.get( 'feedback' ) ) { 561 561 bp.Avatar.displayWarning( this.model.get( 'feedback' ) ); … … 601 601 } 602 602 603 // Add the cropping interface 603 // Add the cropping interface. 604 604 tocrop.Jcrop( { 605 605 onChange: _.bind( self.showPreview, self ), … … 608 608 setSelect: [ crop_left, crop_top, crop_right, crop_bottom ] 609 609 }, function() { 610 // Get the Jcrop API 610 // Get the Jcrop API. 611 611 bp.Avatar.jcropapi = this; 612 612 } ); … … 630 630 var ry = fh / coords.h; 631 631 632 // Update the model 632 // Update the model. 633 633 this.model.set( { x: coords.x, y: coords.y, w: coords.w, h: coords.h } ); 634 634 … … 644 644 } ); 645 645 646 // BuddyPress Avatar Feedback view 646 // BuddyPress Avatar Feedback view. 647 647 bp.Views.AvatarStatus = bp.View.extend( { 648 648 tagName: 'p', -
trunk/src/bp-core/js/bp-api-request.js
r12454 r12548 9 9 10 10 ( function( wp, bp, $ ) { 11 // Bail if not set 11 // Bail if not set. 12 12 if ( typeof bpApiSettings === 'undefined' ) { 13 13 return; … … 16 16 bp.isRestEnabled = true; 17 17 18 // Polyfill wp.apiRequest if WordPress < 4.9 18 // Polyfill wp.apiRequest if WordPress < 4.9. 19 19 bp.apiRequest = function( options ) { 20 20 var bpRequest; -
trunk/src/bp-core/js/bp-plupload.js
r11727 r12548 6 6 ( function( exports, $ ) { 7 7 8 // Bail if not set 8 // Bail if not set. 9 9 if ( typeof BP_Uploader === 'undefined' ) { 10 10 return; … … 18 18 _.extend( bp, _.pick( wp, 'Backbone', 'ajax', 'template' ) ); 19 19 20 // Init Models, Collections, Views and the BuddyPress Uploader 20 // Init Models, Collections, Views and the BuddyPress Uploader. 21 21 bp.Models = bp.Models || {}; 22 22 bp.Collections = bp.Collections || {}; … … 27 27 * BuddyPress Uploader. 28 28 * 29 * This is an adapted version of wp.Uploader 29 * This is an adapted version of wp.Uploader. 30 30 */ 31 31 bp.Uploader.uploader = function() { … … 48 48 } 49 49 50 // Make sure flash sends cookies (seems in IE it does without switching to urlstream mode) 50 // Make sure flash sends cookies (seems in IE it does without switching to urlstream mode). 51 51 if ( ! isIE && 'flash' === plupload.predictRuntime( this.params.defaults ) && 52 52 ( ! this.params.defaults.required_features || ! this.params.defaults.required_features.hasOwnProperty( 'send_binary_string' ) ) ) { … … 98 98 } ); 99 99 100 // See https://core.trac.wordpress.org/ticket/37039 100 // See https://core.trac.wordpress.org/ticket/37039. 101 101 this.uploader.bind( 'postinit', function( up ) { 102 102 up.refresh(); 103 103 }); 104 104 105 // Init BuddyPress Uploader 105 // Init BuddyPress Uploader. 106 106 this.uploader.init(); 107 107 … … 110 110 * 111 111 * Add a new message to the errors collection, so it's possible 112 * to give some feedback to the user 112 * to give some feedback to the user. 113 113 * 114 114 * @param {string} message … … 141 141 /** 142 142 * In case the multiple selection is false (eg: avatar) stop the process and send 143 * and event containing a warning 143 * and event containing a warning. 144 144 */ 145 145 if ( ! uploader.settings.multi_selection && files.length > 1 ) { … … 182 182 183 183 /** 184 * Update each file item on progress 184 * Update each file item on progress. 185 185 * 186 186 * @event UploadProgress … … 226 226 file.item.set( _.extend( response.data, { uploading: false } ) ); 227 227 228 // Add the file to the Uploaded ones 228 // Add the file to the Uploaded ones. 229 229 bp.Uploader.filesUploaded.add( file.item ); 230 230 … … 232 232 233 233 /** 234 * Trigger an event to inform a new upload is being processed 235 * 236 * Mainly used to remove an eventual warning 234 * Trigger an event to inform a new upload is being processed. 235 * 236 * Mainly used to remove an eventual warning. 237 237 * 238 238 * @event BeforeUpload … … 245 245 246 246 /** 247 * Reset the filesQueue once the upload is complete 247 * Reset the filesQueue once the upload is complete. 248 248 * 249 249 * @event BeforeUpload … … 257 257 258 258 /** 259 * Map Plupload errors & Create a warning when plupload failed 259 * Map Plupload errors & Create a warning when plupload failed. 260 260 * 261 261 * @event Error … … 292 292 }; 293 293 294 // Create a very generic Model for files 294 // Create a very generic Model for files. 295 295 bp.Models.File = Backbone.Model.extend( { 296 296 file: {} 297 297 } ); 298 298 299 // Add Collections to store queue, uploaded files and errors 299 // Add Collections to store queue, uploaded files and errors. 300 300 $.extend( bp.Uploader, { 301 301 filesQueue : new Backbone.Collection(), … … 304 304 } ); 305 305 306 // Extend wp.Backbone.View with .prepare() and .inject() 306 // Extend wp.Backbone.View with .prepare() and .inject(). 307 307 bp.View = bp.Backbone.View.extend( { 308 308 inject: function( selector ) { … … 321 321 } ); 322 322 323 // BuddyPress Uploader main view 323 // BuddyPress Uploader main view. 324 324 bp.Views.Uploader = bp.View.extend( { 325 325 className: 'bp-uploader-window', … … 359 359 } 360 360 361 // Remove all warning views 361 // Remove all warning views. 362 362 _.each( this.warnings, function( view ) { 363 363 view.remove(); 364 364 } ); 365 365 366 // Reset Warnings 366 // Reset Warnings. 367 367 this.warnings = []; 368 368 } 369 369 } ); 370 370 371 // BuddyPress Uploader warning view 371 // BuddyPress Uploader warning view. 372 372 bp.Views.uploaderWarning = bp.View.extend( { 373 373 tagName: 'p', … … 384 384 } ); 385 385 386 // BuddyPress Uploader Files view 386 // BuddyPress Uploader Files view. 387 387 bp.Views.uploaderStatus = bp.View.extend( { 388 388 className: 'files', … … 411 411 } ); 412 412 413 // BuddyPress Uploader File progress view 413 // BuddyPress Uploader File progress view. 414 414 bp.Views.uploaderProgress = bp.View.extend( { 415 415 className: 'bp-uploader-progress', -
trunk/src/bp-core/js/cover-image.js
r10208 r12548 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; … … 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; … … 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(); … … 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 … … 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'] … … 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 }, … … 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' ); … … 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( { … … 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: … … 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', … … 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; … … 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: … … 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', … … 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', -
trunk/src/bp-core/js/vendor/jquery-cookie.js
r11009 r12548 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); … … 58 58 var config = $.cookie = function(key, value, options) { 59 59 60 // Write 60 // Write. 61 61 62 62 if (value !== undefined && !$.isFunction(value)) { … … 77 77 } 78 78 79 // Read 79 // Read. 80 80 81 81 var result = key ? undefined : {}; -
trunk/src/bp-core/js/vendor/jquery-scroll-to.js
r11009 r12548 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); … … 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(); … … 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() { … … 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; … … 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; … … 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': … … 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 } … … 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; … … 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]; … … 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 … … 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 … … 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 } … … 204 204 } 205 205 206 // AMD requirement 206 // AMD requirement. 207 207 return $scrollTo; 208 208 })); -
trunk/src/bp-core/js/vendor/jquery.atwho.js
r11795 r12548 7 7 (function (root, factory) { 8 8 if (typeof define === 'function' && define.amd) { 9 // AMD. Register as an anonymous module unless amdModuleId is set 9 // AMD. Register as an anonymous module unless amdModuleId is set. 10 10 define(["jquery"], function (a0) { 11 11 return (factory(a0)); -
trunk/src/bp-core/js/vendor/jquery.caret.js
r11795 r12548 7 7 } else if (typeof exports === 'object') { 8 8 // Node. Does not work with strict CommonJS, but 9 // only CommonJS-like enviro ments that support module.exports,9 // only CommonJS-like environments that support module.exports, 10 10 // like Node. 11 11 module.exports = factory(require("jquery")); -
trunk/src/bp-core/js/vendor/moment-js/moment.js
r11190 r12548 29 29 function isObject(input) { 30 30 // IE8 will treat undefined and null as object if it wasn't for 31 // input != null 31 // input != null. 32 32 return input != null && Object.prototype.toString.call(input) === '[object Object]'; 33 33 } … … 36 36 var k; 37 37 for (k in obj) { 38 // even if its not own property I'd still call it non-empty38 // Even if its not own property I'd still call it non-empty. 39 39 return false; 40 40 } … … 225 225 var updateInProgress = false; 226 226 227 // Moment prototype object 227 // Moment prototype object. 228 228 function Moment(config) { 229 229 copyConfig(this, config); … … 262 262 } 263 263 264 // compare two arrays, return the number of differences264 // Compare two arrays, return the number of differences. 265 265 function compareArrays(array1, array2, dontConvert) { 266 266 var len = Math.min(array1.length, array2.length), … … 301 301 arg += key + ': ' + arguments[0][key] + ', '; 302 302 } 303 arg = arg.slice(0, -2); // Remove trailing comma and space 303 arg = arg.slice(0, -2); // Remove trailing comma and space. 304 304 } else { 305 305 arg = arguments[i]; … … 368 368 !hasOwnProp(childConfig, prop) && 369 369 isObject(parentConfig[prop])) { 370 // make sure changes to properties don't modify parent config370 // Make sure changes to properties don't modify parent config. 371 371 res[prop] = extend({}, res[prop]); 372 372 } … … 544 544 } 545 545 546 // MOMENTS 546 // MOMENTS. 547 547 548 548 function stringGet (units) { … … 640 640 } 641 641 642 // format date using native date object 642 // format date using native date object. 643 643 function formatMoment(m, format) { 644 644 if (!m.isValid()) { … … 689 689 var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123 690 690 691 // any word (or two) characters or numbers including two/three word month in arabic.692 // includes scottish gaelic two word and hyphenated months 691 // Any word (or two) characters or numbers including two/three word month in arabic. 692 // includes scottish gaelic two word and hyphenated months. 693 693 var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i; 694 694 … … 767 767 } else { 768 768 indexOf = function (o) { 769 // I know 769 // I know. 770 770 var i; 771 771 for (i = 0; i < this.length; ++i) { … … 782 782 } 783 783 784 // FORMATTING 784 // FORMATTING. 785 785 786 786 addFormatToken('M', ['MM', 2], 'Mo', function () { … … 796 796 }); 797 797 798 // ALIASES 798 // ALIASES. 799 799 800 800 addUnitAlias('month', 'M'); 801 801 802 // PRIORITY 802 // PRIORITY. 803 803 804 804 addUnitPriority('month', 8); 805 805 806 // PARSING 806 // PARSING. 807 807 808 808 addRegexToken('M', match1to2); … … 821 821 addParseToken(['MMM', 'MMMM'], function (input, array, config, token) { 822 822 var month = config._locale.monthsParse(input, token, config._strict); 823 // if we didn't find a month name, mark the date as invalid.823 // If we didn't find a month name, mark the date as invalid. 824 824 if (month != null) { 825 825 array[MONTH] = month; … … 829 829 }); 830 830 831 // LOCALES 831 // LOCALES. 832 832 833 833 var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/; … … 904 904 } 905 905 906 // TODO: add sorting 906 // TODO: add sorting. 907 907 // Sorting makes sure if one month (or abbr) is a prefix of another 908 // see sorting in computeMonthsParse 908 // see sorting in computeMonthsParse. 909 909 for (i = 0; i < 12; i++) { 910 // make the regex if we don't have it already910 // Make the regex if we don't have it already. 911 911 mom = create_utc__createUTC([2000, i]); 912 912 if (strict && !this._longMonthsParse[i]) { … … 918 918 this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); 919 919 } 920 // test the regex920 // Test the regex. 921 921 if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) { 922 922 return i; … … 929 929 } 930 930 931 // MOMENTS 931 // MOMENTS. 932 932 933 933 function setMonth (mom, value) { … … 935 935 936 936 if (!mom.isValid()) { 937 // No op 937 // No op. 938 938 return mom; 939 939 } … … 1018 1018 i, mom; 1019 1019 for (i = 0; i < 12; i++) { 1020 // make the regex if we don't have it already1020 // Make the regex if we don't have it already. 1021 1021 mom = create_utc__createUTC([2000, i]); 1022 1022 shortPieces.push(this.monthsShort(mom, '')); … … 1044 1044 } 1045 1045 1046 // FORMATTING 1046 // FORMATTING. 1047 1047 1048 1048 addFormatToken('Y', 0, 0, function () { … … 1059 1059 addFormatToken(0, ['YYYYYY', 6, true], 0, 'year'); 1060 1060 1061 // ALIASES 1061 // ALIASES. 1062 1062 1063 1063 addUnitAlias('year', 'y'); 1064 1064 1065 // PRIORITIES 1065 // PRIORITIES. 1066 1066 1067 1067 addUnitPriority('year', 1); 1068 1068 1069 // PARSING 1069 // PARSING. 1070 1070 1071 1071 addRegexToken('Y', matchSigned); … … 1086 1086 }); 1087 1087 1088 // HELPERS 1088 // HELPERS. 1089 1089 1090 1090 function daysInYear(year) { … … 1096 1096 } 1097 1097 1098 // HOOKS 1098 // HOOKS. 1099 1099 1100 1100 utils_hooks__hooks.parseTwoDigitYear = function (input) { … … 1102 1102 }; 1103 1103 1104 // MOMENTS 1104 // MOMENTS. 1105 1105 1106 1106 var getSetYear = makeGetSet('FullYear', true); … … 1111 1111 1112 1112 function createDate (y, m, d, h, M, s, ms) { 1113 // can't just apply() to create a date:1114 // http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply1113 // can't just apply() to create a date: 1114 // http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply 1115 1115 var date = new Date(y, m, d, h, M, s, ms); 1116 1116 1117 // the date constructor remaps years 0-99 to 1900-19991117 // The date constructor remaps years 0-99 to 1900-1999. 1118 1118 if (y < 100 && y >= 0 && isFinite(date.getFullYear())) { 1119 1119 date.setFullYear(y); … … 1125 1125 var date = new Date(Date.UTC.apply(null, arguments)); 1126 1126 1127 // the Date.UTC function remaps years 0-99 to 1900-19991127 // The Date.UTC function remaps years 0-99 to 1900-1999. 1128 1128 if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) { 1129 1129 date.setUTCFullYear(y); … … 1132 1132 } 1133 1133 1134 // start-of-first-week - start-of-year1134 // Start-of-first-week - start-of-year. 1135 1135 function firstWeekOffset(year, dow, doy) { 1136 var // first-week day -- which january is always in the first week (4 for iso, 1 for other)1136 var // First-week day -- which January is always in the first week (4 for iso, 1 for other). 1137 1137 fwd = 7 + dow - doy, 1138 // first-week day local weekday -- which local weekday is fwd1138 // First-week day local weekday -- which local weekday is fwd. 1139 1139 fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7; 1140 1140 … … 1142 1142 } 1143 1143 1144 // http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday1144 // http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday 1145 1145 function dayOfYearFromWeeks(year, week, weekday, dow, doy) { 1146 1146 var localWeekday = (7 + weekday - dow) % 7, … … 1194 1194 } 1195 1195 1196 // FORMATTING 1196 // FORMATTING. 1197 1197 1198 1198 addFormatToken('w', ['ww', 2], 'wo', 'week'); 1199 1199 addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek'); 1200 1200 1201 // ALIASES 1201 // ALIASES. 1202 1202 1203 1203 addUnitAlias('week', 'w'); 1204 1204 addUnitAlias('isoWeek', 'W'); 1205 1205 1206 // PRIORITIES 1206 // PRIORITIES. 1207 1207 1208 1208 addUnitPriority('week', 5); 1209 1209 addUnitPriority('isoWeek', 5); 1210 1210 1211 // PARSING 1211 // PARSING. 1212 1212 1213 1213 addRegexToken('w', match1to2); … … 1220 1220 }); 1221 1221 1222 // HELPERS 1223 1224 // LOCALES 1222 // HELPERS. 1223 1224 // LOCALES. 1225 1225 1226 1226 function localeWeek (mom) { … … 1241 1241 } 1242 1242 1243 // MOMENTS 1243 // MOMENTS. 1244 1244 1245 1245 function getSetWeek (input) { … … 1253 1253 } 1254 1254 1255 // FORMATTING 1255 // FORMATTING. 1256 1256 1257 1257 addFormatToken('d', 0, 'do', 'day'); … … 1272 1272 addFormatToken('E', 0, 0, 'isoWeekday'); 1273 1273 1274 // ALIASES 1274 // ALIASES. 1275 1275 1276 1276 addUnitAlias('day', 'd'); … … 1278 1278 addUnitAlias('isoWeekday', 'E'); 1279 1279 1280 // PRIORITY 1280 // PRIORITY. 1281 1281 addUnitPriority('day', 11); 1282 1282 addUnitPriority('weekday', 11); 1283 1283 addUnitPriority('isoWeekday', 11); 1284 1284 1285 // PARSING 1285 // PARSING. 1286 1286 1287 1287 addRegexToken('d', match1to2); … … 1300 1300 addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) { 1301 1301 var weekday = config._locale.weekdaysParse(input, token, config._strict); 1302 // if we didn't get a weekday name, mark the date as invalid1302 // If we didn't get a weekday name, mark the date as invalid. 1303 1303 if (weekday != null) { 1304 1304 week.d = weekday; … … 1312 1312 }); 1313 1313 1314 // HELPERS 1314 // HELPERS. 1315 1315 1316 1316 function parseWeekday(input, locale) { … … 1338 1338 } 1339 1339 1340 // LOCALES 1340 // LOCALES. 1341 1341 1342 1342 var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'); … … 1438 1438 1439 1439 for (i = 0; i < 7; i++) { 1440 // make the regex if we don't have it already1440 // Make the regex if we don't have it already. 1441 1441 1442 1442 mom = create_utc__createUTC([2000, 1]).day(i); … … 1450 1450 this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); 1451 1451 } 1452 // test the regex1452 // Test the regex. 1453 1453 if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) { 1454 1454 return i; … … 1463 1463 } 1464 1464 1465 // MOMENTS 1465 // MOMENTS. 1466 1466 1467 1467 function getSetDayOfWeek (input) { … … 1491 1491 } 1492 1492 1493 // behaves the same as moment#day except1493 // Behaves the same as moment#day except 1494 1494 // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) 1495 1495 // as a setter, sunday should belong to the previous week. … … 1605 1605 } 1606 1606 1607 // FORMATTING 1607 // FORMATTING. 1608 1608 1609 1609 function hFormat() { … … 1646 1646 meridiem('A', false); 1647 1647 1648 // ALIASES 1648 // ALIASES. 1649 1649 1650 1650 addUnitAlias('hour', 'h'); 1651 1651 1652 // PRIORITY 1652 // PRIORITY. 1653 1653 addUnitPriority('hour', 13); 1654 1654 1655 // PARSING 1655 // PARSING. 1656 1656 1657 1657 function matchMeridiem (isStrict, locale) { … … 1707 1707 }); 1708 1708 1709 // LOCALES 1709 // LOCALES. 1710 1710 1711 1711 function localeIsPM (input) { … … 1725 1725 1726 1726 1727 // MOMENTS 1727 // MOMENTS. 1728 1728 1729 1729 // Setting the hour should keep the time, because the user explicitly … … 1753 1753 }; 1754 1754 1755 // internal storage for locale config files1755 // Internal storage for locale config files. 1756 1756 var locales = {}; 1757 1757 var globalLocale; … … 1761 1761 } 1762 1762 1763 // pick the locale from the array1763 // Pick the locale from the array 1764 1764 // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each 1765 1765 // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root … … 1778 1778 } 1779 1779 if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { 1780 // the next array item is better than a shallower substring of this one1780 // The next array item is better than a shallower substring of this one. 1781 1781 break; 1782 1782 } … … 1790 1790 function loadLocale(name) { 1791 1791 var oldLocale = null; 1792 // TODO: Find a better way to register and load all the locales in Node 1792 // TODO: Find a better way to register and load all the locales in Node. 1793 1793 if (!locales[name] && (typeof module !== 'undefined') && 1794 1794 module && module.exports) { … … 1796 1796 oldLocale = globalLocale._abbr; 1797 1797 require('./locale/' + name); 1798 // because defineLocale currently also sets the global locale, we1799 // want to undo that for lazy loaded locales 1798 // Because defineLocale currently also sets the global locale, we 1799 // want to undo that for lazy loaded locales. 1800 1800 locale_locales__getSetGlobalLocale(oldLocale); 1801 1801 } catch (e) { } … … 1841 1841 parentConfig = locales[config.parentLocale]._config; 1842 1842 } else { 1843 // treat as if there is no base config1843 // Treat as if there is no base config. 1844 1844 deprecateSimple('parentLocaleUndefined', 1845 1845 'specified parentLocale is not defined yet. See http://momentjs.com/guides/#/warnings/parent-locale/'); … … 1848 1848 locales[name] = new Locale(mergeConfigs(parentConfig, config)); 1849 1849 1850 // backwards compat for now: also set the locale 1850 // backwards compat for now: also set the locale. 1851 1851 locale_locales__getSetGlobalLocale(name); 1852 1852 1853 1853 return locales[name]; 1854 1854 } else { 1855 // useful for testing1855 // Useful for testing. 1856 1856 delete locales[name]; 1857 1857 return null; … … 1862 1862 if (config != null) { 1863 1863 var locale, parentConfig = baseConfig; 1864 // MERGE 1864 // MERGE. 1865 1865 if (locales[name] != null) { 1866 1866 parentConfig = locales[name]._config; … … 1871 1871 locales[name] = locale; 1872 1872 1873 // backwards compat for now: also set the locale1873 // Backwards compat for now: also set the locale. 1874 1874 locale_locales__getSetGlobalLocale(name); 1875 1875 } else { 1876 // pass null for config to unupdate, useful for tests1876 // Pass null for config to unupdate, useful for tests. 1877 1877 if (locales[name] != null) { 1878 1878 if (locales[name].parentLocale != null) { … … 1886 1886 } 1887 1887 1888 // returns locale data1888 // Returns locale data. 1889 1889 function locale_locales__getLocale (key) { 1890 1890 var locale; … … 1899 1899 1900 1900 if (!isArray(key)) { 1901 // short-circuit everything else1901 // Short-circuit everything else. 1902 1902 locale = loadLocale(key); 1903 1903 if (locale) { … … 1960 1960 ['YYYYYYMMDD', /[+-]\d{10}/], 1961 1961 ['YYYYMMDD', /\d{8}/], 1962 // YYYYMM is NOT allowed by the standard 1962 // YYYYMM is NOT allowed by the standard. 1963 1963 ['GGGG[W]WWE', /\d{4}W\d{3}/], 1964 1964 ['GGGG[W]WW', /\d{4}W\d{2}/, false], … … 1966 1966 ]; 1967 1967 1968 // iso time formats and regexes1968 // Iso time formats and regexes. 1969 1969 var isoTimes = [ 1970 1970 ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], … … 1981 1981 var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i; 1982 1982 1983 // date from iso format1983 // Date from iso format. 1984 1984 function configFromISO(config) { 1985 1985 var i, l, … … 2034 2034 } 2035 2035 2036 // date from iso format or fallback2036 // Date from iso format or fallback. 2037 2037 function configFromString(config) { 2038 2038 var matched = aspNetJsonRegex.exec(config._i); … … 2080 2080 } 2081 2081 2082 // convert an array to a date.2082 // Convert an array to a date. 2083 2083 // the array should mirror the parameters below 2084 2084 // note: all values past the year are optional and will default to the lowest possible value. 2085 // [year, month, day , hour, minute, second, millisecond] 2085 // [year, month, day , hour, minute, second, millisecond]. 2086 2086 function configFromArray (config) { 2087 2087 var i, date, input = [], currentDate, yearToUse; … … 2093 2093 currentDate = currentDateArray(config); 2094 2094 2095 // compute day of the year from weeks and weekdays2095 // Compute day of the year from weeks and weekdays. 2096 2096 if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { 2097 2097 dayOfYearFromWeekInfo(config); 2098 2098 } 2099 2099 2100 // if the day of the year is set, figure out what it is2100 // If the day of the year is set, figure out what it is. 2101 2101 if (config._dayOfYear) { 2102 2102 yearToUse = defaults(config._a[YEAR], currentDate[YEAR]); … … 2120 2120 } 2121 2121 2122 // Zero out whatever was not defaulted, including time 2122 // Zero out whatever was not defaulted, including time. 2123 2123 for (; i < 7; i++) { 2124 2124 config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; … … 2172 2172 2173 2173 if (w.d != null) { 2174 // weekday -- low day numbers are considered next week2174 // Weekday -- low day numbers are considered next week. 2175 2175 weekday = w.d; 2176 2176 if (weekday < 0 || weekday > 6) { … … 2178 2178 } 2179 2179 } else if (w.e != null) { 2180 // local weekday -- counting starts from begining of week2180 // Local weekday -- counting starts from beginning of week. 2181 2181 weekday = w.e + dow; 2182 2182 if (w.e < 0 || w.e > 6) { … … 2184 2184 } 2185 2185 } else { 2186 // default to begining of week2186 // Default to beginning of week. 2187 2187 weekday = dow; 2188 2188 } … … 2199 2199 } 2200 2200 2201 // constant that refers to the ISO standard2201 // Constant that refers to the ISO standard. 2202 2202 utils_hooks__hooks.ISO_8601 = function () {}; 2203 2203 2204 // date from string and format string2204 // Date from string and format string. 2205 2205 function configFromStringAndFormat(config) { 2206 // TODO: Move this to another part of the creation flow to prevent circular deps 2206 // TODO: Move this to another part of the creation flow to prevent circular deps. 2207 2207 if (config._f === utils_hooks__hooks.ISO_8601) { 2208 2208 configFromISO(config); … … 2213 2213 getParsingFlags(config).empty = true; 2214 2214 2215 // This array is used to make a Date, either with `new Date` or `Date.UTC` 2215 // This array is used to make a Date, either with `new Date` or `Date.UTC`. 2216 2216 var string = '' + config._i, 2217 2217 i, parsedInput, tokens, token, skipped, … … 2224 2224 token = tokens[i]; 2225 2225 parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0]; 2226 // console.log('token', token, 'parsedInput', parsedInput,2226 // Console.log('token', token, 'parsedInput', parsedInput, 2227 2227 // 'regex', getParseRegexForToken(token, config)); 2228 2228 if (parsedInput) { … … 2234 2234 totalParsedInputLength += parsedInput.length; 2235 2235 } 2236 // don't parse if it's not a known token2236 // Don't parse if it's not a known token. 2237 2237 if (formatTokenFunctions[token]) { 2238 2238 if (parsedInput) { … … 2249 2249 } 2250 2250 2251 // add remaining unparsed input length to the string2251 // Add remaining unparsed input length to the string. 2252 2252 getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength; 2253 2253 if (string.length > 0) { … … 2255 2255 } 2256 2256 2257 // clear _12h flag if hour is <= 122257 // Clear _12h flag if hour is <= 12. 2258 2258 if (config._a[HOUR] <= 12 && 2259 2259 getParsingFlags(config).bigHour === true && … … 2276 2276 2277 2277 if (meridiem == null) { 2278 // nothing to do2278 // Nothing to do. 2279 2279 return hour; 2280 2280 } … … 2282 2282 return locale.meridiemHour(hour, meridiem); 2283 2283 } else if (locale.isPM != null) { 2284 // Fallback 2284 // Fallback. 2285 2285 isPm = locale.isPM(meridiem); 2286 2286 if (isPm && hour < 12) { … … 2292 2292 return hour; 2293 2293 } else { 2294 // this is not supposed to happen2294 // This is not supposed to happen. 2295 2295 return hour; 2296 2296 } 2297 2297 } 2298 2298 2299 // date from string and array of format strings2299 // Date from string and array of format strings. 2300 2300 function configFromStringAndArray(config) { 2301 2301 var tempConfig, … … 2325 2325 } 2326 2326 2327 // if there is any input that was not parsed add a penalty for that format2327 // If there is any input that was not parsed add a penalty for that format. 2328 2328 currentScore += getParsingFlags(tempConfig).charsLeftOver; 2329 2329 2330 // or tokens2330 // Or tokens. 2331 2331 currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10; 2332 2332 … … 2358 2358 var res = new Moment(checkOverflow(prepareConfig(config))); 2359 2359 if (res._nextDay) { 2360 // Adding is smart enough around DST 2360 // Adding is smart enough around DST. 2361 2361 res.add(1, 'd'); 2362 2362 res._nextDay = undefined; … … 2434 2434 input = undefined; 2435 2435 } 2436 // object construction must be done this way.2436 // Object construction must be done this way. 2437 2437 // https://github.com/moment/moment/issues/1423 2438 2438 c._isAMomentObject = true; … … 2525 2525 milliseconds = normalizedInput.millisecond || 0; 2526 2526 2527 // representation for dateAddRemove2527 // Representation for dateAddRemove. 2528 2528 this._milliseconds = +milliseconds + 2529 2529 seconds * 1e3 + // 1000 2530 2530 minutes * 6e4 + // 1000 * 60 2531 hours * 1000 * 60 * 60; // using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/29782531 hours * 1000 * 60 * 60; // Using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978 2532 2532 // Because of dateAddRemove treats 24 hours as different from a 2533 // day when working around DST, we need to store them separately 2533 // day when working around DST, we need to store them separately. 2534 2534 this._days = +days + 2535 2535 weeks * 7; … … 2560 2560 } 2561 2561 2562 // FORMATTING 2562 // FORMATTING. 2563 2563 2564 2564 function offset (token, separator) { … … 2577 2577 offset('ZZ', ''); 2578 2578 2579 // PARSING 2579 // PARSING. 2580 2580 2581 2581 addRegexToken('Z', matchShortOffset); … … 2586 2586 }); 2587 2587 2588 // HELPERS 2589 2590 // timezone chunker2588 // HELPERS. 2589 2590 // Timezone chunker 2591 2591 // '+10:00' > ['10', '00'] 2592 // '-1530' > ['-15', '30'] 2592 // '-1530' > ['-15', '30']. 2593 2593 var chunkOffset = /([\+\-]|\d\d)/gi; 2594 2594 … … 2770 2770 } 2771 2771 2772 // ASP.NET json date format regex 2772 // ASP.NET json date format regex. 2773 2773 var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/; 2774 2774 2775 2775 // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html 2776 2776 // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere 2777 // and further modified to allow for strings containing both week and day 2777 // and further modified to allow for strings containing both week and day. 2778 2778 var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/; 2779 2779 2780 2780 function create__createDuration (input, key) { 2781 2781 var duration = input, 2782 // matching against regexp is expensive, do it on demand2782 // Matching against regexp is expensive, do it on demand. 2783 2783 match = null, 2784 2784 sign, … … 2807 2807 m : toInt(match[MINUTE]) * sign, 2808 2808 s : toInt(match[SECOND]) * sign, 2809 ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match2809 ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // The millisecond decimal point is included in the match. 2810 2810 }; 2811 2811 } else if (!!(match = isoRegex.exec(input))) { … … 2820 2820 s : parseIso(match[8], sign) 2821 2821 }; 2822 } else if (duration == null) { // checks for null or undefined2822 } else if (duration == null) { // Checks for null or undefined. 2823 2823 duration = {}; 2824 2824 } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) { … … 2846 2846 // inp may be undefined, so careful calling replace on it. 2847 2847 var res = inp && parseFloat(inp.replace(',', '.')); 2848 // apply sign while we're at it2848 // Apply sign while we're at it. 2849 2849 return (isNaN(res) ? 0 : res) * sign; 2850 2850 } … … 2882 2882 } 2883 2883 2884 // TODO: remove 'name' arg after deprecation is removed 2884 // TODO: remove 'name' arg after deprecation is removed. 2885 2885 function createAdder(direction, name) { 2886 2886 return function (val, period) { 2887 2887 var dur, tmp; 2888 // invert the arguments, but complain about it2888 // Invert the arguments, but complain about it. 2889 2889 if (period !== null && !isNaN(+period)) { 2890 2890 deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' + … … 2906 2906 2907 2907 if (!mom.isValid()) { 2908 // No op 2908 // No op. 2909 2909 return; 2910 2910 } … … 3049 3049 3050 3050 function monthDiff (a, b) { 3051 // difference in months3051 // Difference in months. 3052 3052 var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()), 3053 // b is in (anchor - 1 month, anchor + 1 month)3053 // B is in (anchor - 1 month, anchor + 1 month). 3054 3054 anchor = a.clone().add(wholeMonthDiff, 'months'), 3055 3055 anchor2, adjust; … … 3057 3057 if (b - anchor < 0) { 3058 3058 anchor2 = a.clone().add(wholeMonthDiff - 1, 'months'); 3059 // linear across the month 3059 // linear across the month. 3060 3060 adjust = (b - anchor) / (anchor - anchor2); 3061 3061 } else { 3062 3062 anchor2 = a.clone().add(wholeMonthDiff + 1, 'months'); 3063 // linear across the month 3063 // linear across the month. 3064 3064 adjust = (b - anchor) / (anchor2 - anchor); 3065 3065 } 3066 3066 3067 // check for negative zero, return zero if negative zero3067 // Check for negative zero, return zero if negative zero. 3068 3068 return -(wholeMonthDiff + adjust) || 0; 3069 3069 } … … 3080 3080 if (0 < m.year() && m.year() <= 9999) { 3081 3081 if (isFunction(Date.prototype.toISOString)) { 3082 // native implementation is ~50x faster, use it when we can3082 // Native implementation is ~50x faster, use it when we can. 3083 3083 return this.toDate().toISOString(); 3084 3084 } else { … … 3160 3160 function startOf (units) { 3161 3161 units = normalizeUnits(units); 3162 // the following switch intentionally omits break keywords3162 // The following switch intentionally omits break keywords 3163 3163 // to utilize falling through the cases. 3164 3164 switch (units) { … … 3186 3186 } 3187 3187 3188 // weeks are a special case3188 // Weeks are a special case. 3189 3189 if (units === 'week') { 3190 3190 this.weekday(0); … … 3194 3194 } 3195 3195 3196 // quarters are also special3196 // Quarters are also special. 3197 3197 if (units === 'quarter') { 3198 3198 this.month(Math.floor(this.month() / 3) * 3); … … 3247 3247 3248 3248 function toJSON () { 3249 // new Date(NaN).toJSON() === null3249 // New Date(NaN).toJSON() === null. 3250 3250 return this.isValid() ? this.toISOString() : null; 3251 3251 } … … 3273 3273 } 3274 3274 3275 // FORMATTING 3275 // FORMATTING. 3276 3276 3277 3277 addFormatToken(0, ['gg', 2], 0, function () { … … 3292 3292 addWeekYearFormatToken('GGGGG', 'isoWeekYear'); 3293 3293 3294 // ALIASES 3294 // ALIASES. 3295 3295 3296 3296 addUnitAlias('weekYear', 'gg'); 3297 3297 addUnitAlias('isoWeekYear', 'GG'); 3298 3298 3299 // PRIORITY 3299 // PRIORITY. 3300 3300 3301 3301 addUnitPriority('weekYear', 1); … … 3303 3303 3304 3304 3305 // PARSING 3305 // PARSING. 3306 3306 3307 3307 addRegexToken('G', matchSigned); … … 3322 3322 }); 3323 3323 3324 // MOMENTS 3324 // MOMENTS. 3325 3325 3326 3326 function getSetWeekYear (input) { … … 3370 3370 } 3371 3371 3372 // FORMATTING 3372 // FORMATTING. 3373 3373 3374 3374 addFormatToken('Q', 0, 'Qo', 'quarter'); 3375 3375 3376 // ALIASES 3376 // ALIASES. 3377 3377 3378 3378 addUnitAlias('quarter', 'Q'); 3379 3379 3380 // PRIORITY 3380 // PRIORITY. 3381 3381 3382 3382 addUnitPriority('quarter', 7); 3383 3383 3384 // PARSING 3384 // PARSING. 3385 3385 3386 3386 addRegexToken('Q', match1); … … 3389 3389 }); 3390 3390 3391 // MOMENTS 3391 // MOMENTS. 3392 3392 3393 3393 function getSetQuarter (input) { … … 3395 3395 } 3396 3396 3397 // FORMATTING 3397 // FORMATTING. 3398 3398 3399 3399 addFormatToken('D', ['DD', 2], 'Do', 'date'); 3400 3400 3401 // ALIASES 3401 // ALIASES. 3402 3402 3403 3403 addUnitAlias('date', 'D'); 3404 3404 3405 // PRIOROITY 3405 // PRIOROITY. 3406 3406 addUnitPriority('date', 9); 3407 3407 3408 // PARSING 3408 // PARSING. 3409 3409 3410 3410 addRegexToken('D', match1to2); … … 3419 3419 }); 3420 3420 3421 // MOMENTS 3421 // MOMENTS. 3422 3422 3423 3423 var getSetDayOfMonth = makeGetSet('Date', true); 3424 3424 3425 // FORMATTING 3425 // FORMATTING. 3426 3426 3427 3427 addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear'); 3428 3428 3429 // ALIASES 3429 // ALIASES. 3430 3430 3431 3431 addUnitAlias('dayOfYear', 'DDD'); 3432 3432 3433 // PRIORITY 3433 // PRIORITY. 3434 3434 addUnitPriority('dayOfYear', 4); 3435 3435 3436 // PARSING 3436 // PARSING. 3437 3437 3438 3438 addRegexToken('DDD', match1to3); … … 3442 3442 }); 3443 3443 3444 // HELPERS 3445 3446 // MOMENTS 3444 // HELPERS. 3445 3446 // MOMENTS. 3447 3447 3448 3448 function getSetDayOfYear (input) { … … 3451 3451 } 3452 3452 3453 // FORMATTING 3453 // FORMATTING. 3454 3454 3455 3455 addFormatToken('m', ['mm', 2], 0, 'minute'); 3456 3456 3457 // ALIASES 3457 // ALIASES. 3458 3458 3459 3459 addUnitAlias('minute', 'm'); 3460 3460 3461 // PRIORITY 3461 // PRIORITY. 3462 3462 3463 3463 addUnitPriority('minute', 14); 3464 3464 3465 // PARSING 3465 // PARSING. 3466 3466 3467 3467 addRegexToken('m', match1to2); … … 3469 3469 addParseToken(['m', 'mm'], MINUTE); 3470 3470 3471 // MOMENTS 3471 // MOMENTS. 3472 3472 3473 3473 var getSetMinute = makeGetSet('Minutes', false); 3474 3474 3475 // FORMATTING 3475 // FORMATTING. 3476 3476 3477 3477 addFormatToken('s', ['ss', 2], 0, 'second'); 3478 3478 3479 // ALIASES 3479 // ALIASES. 3480 3480 3481 3481 addUnitAlias('second', 's'); 3482 3482 3483 // PRIORITY 3483 // PRIORITY. 3484 3484 3485 3485 addUnitPriority('second', 15); 3486 3486 3487 // PARSING 3487 // PARSING. 3488 3488 3489 3489 addRegexToken('s', match1to2); … … 3491 3491 addParseToken(['s', 'ss'], SECOND); 3492 3492 3493 // MOMENTS 3493 // MOMENTS. 3494 3494 3495 3495 var getSetSecond = makeGetSet('Seconds', false); 3496 3496 3497 // FORMATTING 3497 // FORMATTING. 3498 3498 3499 3499 addFormatToken('S', 0, 0, function () { … … 3526 3526 3527 3527 3528 // ALIASES 3528 // ALIASES. 3529 3529 3530 3530 addUnitAlias('millisecond', 'ms'); 3531 3531 3532 // PRIORITY 3532 // PRIORITY. 3533 3533 3534 3534 addUnitPriority('millisecond', 16); 3535 3535 3536 // PARSING 3536 // PARSING. 3537 3537 3538 3538 addRegexToken('S', match1to3, match1); … … 3552 3552 addParseToken(token, parseMs); 3553 3553 } 3554 // MOMENTS 3554 // MOMENTS. 3555 3555 3556 3556 var getSetMillisecond = makeGetSet('Milliseconds', false); 3557 3557 3558 // FORMATTING 3558 // FORMATTING. 3559 3559 3560 3560 addFormatToken('z', 0, 0, 'zoneAbbr'); 3561 3561 addFormatToken('zz', 0, 0, 'zoneName'); 3562 3562 3563 // MOMENTS 3563 // MOMENTS. 3564 3564 3565 3565 function getZoneAbbr () { … … 3611 3611 momentPrototype__proto.creationData = creationData; 3612 3612 3613 // Year 3613 // Year. 3614 3614 momentPrototype__proto.year = getSetYear; 3615 3615 momentPrototype__proto.isLeapYear = getIsLeapYear; 3616 3616 3617 // Week Year 3617 // Week Year. 3618 3618 momentPrototype__proto.weekYear = getSetWeekYear; 3619 3619 momentPrototype__proto.isoWeekYear = getSetISOWeekYear; 3620 3620 3621 // Quarter 3621 // Quarter. 3622 3622 momentPrototype__proto.quarter = momentPrototype__proto.quarters = getSetQuarter; 3623 3623 3624 // Month 3624 // Month. 3625 3625 momentPrototype__proto.month = getSetMonth; 3626 3626 momentPrototype__proto.daysInMonth = getDaysInMonth; 3627 3627 3628 // Week 3628 // Week. 3629 3629 momentPrototype__proto.week = momentPrototype__proto.weeks = getSetWeek; 3630 3630 momentPrototype__proto.isoWeek = momentPrototype__proto.isoWeeks = getSetISOWeek; … … 3632 3632 momentPrototype__proto.isoWeeksInYear = getISOWeeksInYear; 3633 3633 3634 // Day 3634 // Day. 3635 3635 momentPrototype__proto.date = getSetDayOfMonth; 3636 3636 momentPrototype__proto.day = momentPrototype__proto.days = getSetDayOfWeek; … … 3639 3639 momentPrototype__proto.dayOfYear = getSetDayOfYear; 3640 3640 3641 // Hour 3641 // Hour. 3642 3642 momentPrototype__proto.hour = momentPrototype__proto.hours = getSetHour; 3643 3643 3644 // Minute 3644 // Minute. 3645 3645 momentPrototype__proto.minute = momentPrototype__proto.minutes = getSetMinute; 3646 3646 3647 // Second 3647 // Second. 3648 3648 momentPrototype__proto.second = momentPrototype__proto.seconds = getSetSecond; 3649 3649 3650 // Millisecond 3650 // Millisecond. 3651 3651 momentPrototype__proto.millisecond = momentPrototype__proto.milliseconds = getSetMillisecond; 3652 3652 3653 // Offset 3653 // Offset. 3654 3654 momentPrototype__proto.utcOffset = getSetOffset; 3655 3655 momentPrototype__proto.utc = setOffsetToUTC; … … 3663 3663 momentPrototype__proto.isUTC = isUtc; 3664 3664 3665 // Timezone 3665 // Timezone. 3666 3666 momentPrototype__proto.zoneAbbr = getZoneAbbr; 3667 3667 momentPrototype__proto.zoneName = getZoneName; 3668 3668 3669 // Deprecations 3669 // Deprecations. 3670 3670 momentPrototype__proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth); 3671 3671 momentPrototype__proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth); … … 3700 3700 prototype__proto.set = locale_set__set; 3701 3701 3702 // Month 3702 // Month. 3703 3703 prototype__proto.months = localeMonths; 3704 3704 prototype__proto.monthsShort = localeMonthsShort; … … 3707 3707 prototype__proto.monthsShortRegex = monthsShortRegex; 3708 3708 3709 // Week 3709 // Week. 3710 3710 prototype__proto.week = localeWeek; 3711 3711 prototype__proto.firstDayOfYear = localeFirstDayOfYear; 3712 3712 prototype__proto.firstDayOfWeek = localeFirstDayOfWeek; 3713 3713 3714 // Day of Week 3714 // Day of Week. 3715 3715 prototype__proto.weekdays = localeWeekdays; 3716 3716 prototype__proto.weekdaysMin = localeWeekdaysMin; … … 3722 3722 prototype__proto.weekdaysMinRegex = weekdaysMinRegex; 3723 3723 3724 // Hours 3724 // Hours. 3725 3725 prototype__proto.isPM = localeIsPM; 3726 3726 prototype__proto.meridiem = localeMeridiem; … … 3828 3828 }); 3829 3829 3830 // Side effect imports 3830 // Side effect imports. 3831 3831 utils_hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locale_locales__getSetGlobalLocale); 3832 3832 utils_hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locale_locales__getLocale); … … 3861 3861 } 3862 3862 3863 // supports only 2.0-style add(1, 's') or add(duration)3863 // Supports only 2.0-style add(1, 's') or add(duration). 3864 3864 function duration_add_subtract__add (input, value) { 3865 3865 return duration_add_subtract__addSubtract(this, input, value, 1); 3866 3866 } 3867 3867 3868 // supports only 2.0-style subtract(1, 's') or subtract(duration)3868 // Supports only 2.0-style subtract(1, 's') or subtract(duration). 3869 3869 function duration_add_subtract__subtract (input, value) { 3870 3870 return duration_add_subtract__addSubtract(this, input, value, -1); … … 3886 3886 var seconds, minutes, hours, years, monthsFromDays; 3887 3887 3888 // if we have a mix of positive and negative values, bubble down first3889 // check: https://github.com/moment/moment/issues/2166 3888 // If we have a mix of positive and negative values, bubble down first 3889 // check: https://github.com/moment/moment/issues/2166. 3890 3890 if (!((milliseconds >= 0 && days >= 0 && months >= 0) || 3891 3891 (milliseconds <= 0 && days <= 0 && months <= 0))) { … … 3910 3910 days += absFloor(hours / 24); 3911 3911 3912 // convert days to months3912 // Convert days to months. 3913 3913 monthsFromDays = absFloor(daysToMonths(days)); 3914 3914 months += monthsFromDays; 3915 3915 days -= absCeil(monthsToDays(monthsFromDays)); 3916 3916 3917 // 12 months -> 1 year 3917 // 12 months -> 1 year. 3918 3918 years = absFloor(months / 12); 3919 3919 months %= 12; … … 3928 3928 function daysToMonths (days) { 3929 3929 // 400 years have 146097 days (taking into account leap year rules) 3930 // 400 years have 12 months === 4800 3930 // 400 years have 12 months === 4800. 3931 3931 return days * 4800 / 146097; 3932 3932 } 3933 3933 3934 3934 function monthsToDays (months) { 3935 // the reverse of daysToMonths3935 // The reverse of daysToMonths. 3936 3936 return months * 146097 / 4800; 3937 3937 } … … 3949 3949 return units === 'month' ? months : months / 12; 3950 3950 } else { 3951 // handle milliseconds separately because of floating point math errors (issue #1867)3951 // Handle milliseconds separately because of floating point math errors (issue #1867). 3952 3952 days = this._days + Math.round(monthsToDays(this._months)); 3953 3953 switch (units) { … … 3957 3957 case 'minute' : return days * 1440 + milliseconds / 6e4; 3958 3958 case 'second' : return days * 86400 + milliseconds / 1000; 3959 // Math.floor prevents floating point math errors here 3959 // Math.floor prevents floating point math errors here. 3960 3960 case 'millisecond': return Math.floor(days * 864e5) + milliseconds; 3961 3961 default: throw new Error('Unknown unit ' + units); … … 4014 4014 var round = Math.round; 4015 4015 var thresholds = { 4016 s: 45, // seconds to minute4017 m: 45, // minutes to hour4018 h: 22, // hours to day4019 d: 26, // days to month4020 M: 11 // months to year4016 s: 45, // Seconds to minute. 4017 m: 45, // Minutes to hour. 4018 h: 22, // Hours to day. 4019 d: 26, // Days to month. 4020 M: 11 // Months to year. 4021 4021 }; 4022 4022 4023 // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize4023 // Helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize. 4024 4024 function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) { 4025 4025 return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture); … … 4052 4052 } 4053 4053 4054 // This function allows you to set the rounding function for relative time strings 4054 // This function allows you to set the rounding function for relative time strings. 4055 4055 function duration_humanize__getSetRelativeTimeRounding (roundingFunction) { 4056 4056 if (roundingFunction === undefined) { … … 4064 4064 } 4065 4065 4066 // This function allows you to set a threshold for relative time strings 4066 // This function allows you to set a threshold for relative time strings. 4067 4067 function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) { 4068 4068 if (thresholds[threshold] === undefined) { … … 4093 4093 // * milliseconds bubble up until they become hours 4094 4094 // * days do not bubble at all 4095 // * months bubble up until they become years 4095 // * months bubble up until they become years. 4096 4096 // This is because there is no context-free conversion between hours and days 4097 4097 // (think of clock changes) 4098 // and also not between days and months (28-31 days per month) 4098 // and also not between days and months (28-31 days per month). 4099 4099 var seconds = iso_string__abs(this._milliseconds) / 1000; 4100 4100 var days = iso_string__abs(this._days); … … 4102 4102 var minutes, hours, years; 4103 4103 4104 // 3600 seconds -> 60 minutes -> 1 hour 4104 // 3600 seconds -> 60 minutes -> 1 hour. 4105 4105 minutes = absFloor(seconds / 60); 4106 4106 hours = absFloor(minutes / 60); … … 4108 4108 minutes %= 60; 4109 4109 4110 // 12 months -> 1 year 4110 // 12 months -> 1 year. 4111 4111 years = absFloor(months / 12); 4112 4112 months %= 12; 4113 4113 4114 4114 4115 // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js4115 // Inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js 4116 4116 var Y = years; 4117 4117 var M = months; … … 4123 4123 4124 4124 if (!total) { 4125 // this is the same as C#'s (Noda) and python (isodate)...4126 // but not other JS (goog.date) 4125 // This is the same as C#'s (Noda) and python (isodate)... 4126 // but not other JS (goog.date). 4127 4127 return 'P0D'; 4128 4128 } … … 4171 4171 duration_prototype__proto.localeData = localeData; 4172 4172 4173 // Deprecations 4173 // Deprecations. 4174 4174 duration_prototype__proto.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', iso_string__toISOString); 4175 4175 duration_prototype__proto.lang = lang; 4176 4176 4177 // Side effect imports 4178 4179 // FORMATTING 4177 // Side effect imports. 4178 4179 // FORMATTING. 4180 4180 4181 4181 addFormatToken('X', 0, 0, 'unix'); 4182 4182 addFormatToken('x', 0, 0, 'valueOf'); 4183 4183 4184 // PARSING 4184 // PARSING. 4185 4185 4186 4186 addRegexToken('x', matchSigned); … … 4193 4193 }); 4194 4194 4195 // Side effect imports 4195 // Side effect imports. 4196 4196 4197 4197 -
trunk/src/bp-core/js/webcam.js
r11944 r12548 5 5 ( function() { 6 6 7 // Bail if not set 7 // Bail if not set. 8 8 if ( typeof BP_Uploader === 'undefined' ) { 9 9 return; … … 31 31 setView: function( view ) { 32 32 if ( 'camera' !== view ) { 33 // Stop the camera if needed 33 // Stop the camera if needed. 34 34 if ( ! _.isNull( this.params.video ) ) { 35 35 this.stop(); 36 36 37 // Remove all warnings as we're changing the view 37 // Remove all warnings as we're changing the view. 38 38 this.removeWarning(); 39 39 } 40 40 41 // Stop as this is not Camera area 42 return; 43 } 44 45 // Create the WebCam view 41 // Stop as this is not Camera area. 42 return; 43 } 44 45 // Create the WebCam view. 46 46 var cameraView = new bp.Views.WebCamAvatar( { model: new Backbone.Model( { user_media: false } ) } ); 47 47 48 // Make sure the flipped param is reset 48 // Make sure the flipped param is reset. 49 49 this.params.flipped = false; 50 50 51 // Add it to views 51 // Add it to views. 52 52 bp.Avatar.views.add( { id: 'camera', view: cameraView } ); 53 53 54 // Display it 54 // Display it. 55 55 cameraView.inject( '.bp-avatar' ); 56 56 }, … … 70 70 bp.WebCam.params.videoStream = stream; 71 71 72 // User Feedback 72 // User Feedback. 73 73 bp.WebCam.displayWarning( 'loaded' ); 74 74 75 75 video.onerror = function () { 76 // User Feedback 76 // User Feedback. 77 77 bp.WebCam.displayWarning( 'videoerror' ); 78 78 … … 84 84 stream.onended = bp.WebCam.noStream(); 85 85 86 // Older browsers may not have srcObject 86 // Older browsers may not have srcObject. 87 87 if ( 'srcObject' in video ) { 88 88 video.srcObject = stream; … … 122 122 noStream: function() { 123 123 if ( _.isNull( bp.WebCam.params.videoStream ) ) { 124 // User Feedback 124 // User Feedback. 125 125 bp.WebCam.displayWarning( 'noaccess' ); 126 126 … … 134 134 } 135 135 136 // Remove the view 136 // Remove the view. 137 137 bp.WebCam.removeView(); 138 138 … … 157 157 }; 158 158 159 // BuddyPress WebCam view 159 // BuddyPress WebCam view. 160 160 bp.Views.WebCamAvatar = bp.View.extend( { 161 161 tagName: 'div', … … 181 181 182 182 if ( typeof navigator.getUserMedia !== 'undefined' ) { 183 // We need to add some cropping stuff to use bp.Avatar.setAvatar() 183 // We need to add some cropping stuff to use bp.Avatar.setAvatar(). 184 184 params = _.extend( _.pick( BP_Uploader.settings.defaults.multipart_params.bp_params, 185 185 'object', … … 217 217 bp.WebCam.params.canvas = this.options.canvas.el; 218 218 219 // User Feedback 219 // User Feedback. 220 220 bp.WebCam.displayWarning( 'requesting' ); 221 221 … … 235 235 // ES3 compatibility. 236 236 ['catch'](function() { 237 // User Feedback 237 // User Feedback. 238 238 bp.WebCam.displayWarning( 'errormsg' ); 239 239 }); … … 246 246 247 247 if ( ! bp.WebCam.params.capture_enable ) { 248 // User Feedback 248 // User Feedback. 249 249 bp.WebCam.displayWarning( 'loading' ); 250 250 return; … … 256 256 } 257 257 258 // Set the offset 258 // Set the offset. 259 259 sc = this.options.video.el.videoHeight; 260 260 sx = ( this.options.video.el.videoWidth - sc ) / 2; … … 271 271 this.model.set( 'url', bp.WebCam.params.capture ); 272 272 273 // User Feedback 273 // User Feedback. 274 274 bp.WebCam.displayWarning( 'ready' ); 275 275 }, … … 279 279 280 280 if ( ! bp.WebCam.params.capture ) { 281 // User Feedback 281 // User Feedback. 282 282 bp.WebCam.displayWarning( 'nocapture' ); 283 283 return; … … 289 289 } ); 290 290 291 // BuddyPress Video stream view 291 // BuddyPress Video stream view. 292 292 bp.Views.WebCamVideo = bp.View.extend( { 293 293 tagName: 'video', … … 298 298 } ); 299 299 300 // BuddyPress Canvas (capture) view 300 // BuddyPress Canvas (capture) view. 301 301 bp.Views.WebCamCanvas = bp.View.extend( { 302 302 tagName: 'canvas', … … 308 308 309 309 initialize: function() { 310 // Make sure to take in account bp_core_avatar_full_height or bp_core_avatar_full_width php filters 310 // Make sure to take in account bp_core_avatar_full_height or bp_core_avatar_full_width php filters. 311 311 if ( ! _.isUndefined( BP_Uploader.settings.crop.full_h ) && ! _.isUndefined( BP_Uploader.settings.crop.full_w ) ) { 312 312 this.el.attributes.width.value = BP_Uploader.settings.crop.full_w;
Note: See TracChangeset
for help on using the changeset viewer.