|
98 | 98 | } |
99 | 99 |
|
100 | 100 | /** |
101 | | - * Parse date into ISO8601 format. |
| 101 | + * Parse date into ISO 8601 format. |
102 | 102 | * |
103 | 103 | * @param {Date} date. |
104 | 104 | */ |
|
306 | 306 | /** |
307 | 307 | * Mixin for all content that is time stamped. |
308 | 308 | * |
309 | | - * This mixin converts between mysql timestamps and JavaScript Dates when syncing a model |
| 309 | + * This mixin converts between MySQL timestamps and JavaScript Dates when syncing a model |
310 | 310 | * to or from the server. For example, a date stored as `2015-12-27T21:22:24` on the server |
311 | 311 | * gets expanded to `Sun Dec 27 2015 14:22:24 GMT-0700 (MST)` when the model is fetched. |
312 | 312 | * |
|
361 | 361 | * Build a helper function to retrieve related model. |
362 | 362 | * |
363 | 363 | * @param {string} parentModel The parent model. |
364 | | - * @param {number} modelId The model ID if the object to request |
| 364 | + * @param {number} modelId The model ID of the object to request. |
365 | 365 | * @param {string} modelName The model name to use when constructing the model. |
366 | 366 | * @param {string} embedSourcePoint Where to check the embedded object for _embed data. |
367 | 367 | * @param {string} embedCheckField Which model field to check to see if the model has data. |
|
423 | 423 | */ |
424 | 424 | buildCollectionGetter = function( parentModel, collectionName, embedSourcePoint, embedIndex ) { |
425 | 425 | /** |
426 | | - * Returns a promise that resolves to the requested collection |
| 426 | + * Returns a promise that resolves to the requested collection. |
427 | 427 | * |
428 | 428 | * Uses the embedded data if available, otherwise fetches the |
429 | 429 | * data from the server. |
|
467 | 467 | // Create the new getObjects collection. |
468 | 468 | getObjects = new wp.api.collections[ collectionName ]( properties, classProperties ); |
469 | 469 |
|
470 | | - // If we didn’t have embedded getObjects, fetch the getObjects data. |
| 470 | + // If we don’t have embedded getObjects, fetch the getObjects data. |
471 | 471 | if ( _.isUndefined( getObjects.models[0] ) ) { |
472 | 472 | getObjects.fetch( { |
473 | 473 | success: function( getObjects ) { |
|
497 | 497 | */ |
498 | 498 | setHelperParentPost = function( collection, postId ) { |
499 | 499 |
|
500 | | - // Attach post_parent id to the collection. |
| 500 | + // Attach parent post ID to the collection. |
501 | 501 | _.each( collection.models, function( model ) { |
502 | 502 | model.set( 'parent_post', postId ); |
503 | 503 | } ); |
|
754 | 754 | return model; |
755 | 755 | } |
756 | 756 |
|
757 | | - // Go thru the parsable date fields, if our model contains any of them it gets the TimeStampedMixin. |
| 757 | + // Go through the parsable date fields. If our model contains any of them, it gets the TimeStampedMixin. |
758 | 758 | _.each( parseableDates, function( theDateKey ) { |
759 | 759 | if ( ! _.isUndefined( model.prototype.args[ theDateKey ] ) ) { |
760 | 760 | hasDate = true; |
|
1168 | 1168 | sessionStorage.getItem( 'wp-api-schema-model' + model.get( 'apiRoot' ) + model.get( 'versionString' ) ) |
1169 | 1169 | ) { |
1170 | 1170 |
|
1171 | | - // Used a cached copy of the schema model if available. |
| 1171 | + // Use a cached copy of the schema model if available. |
1172 | 1172 | model.schemaModel.set( model.schemaModel.parse( JSON.parse( sessionStorage.getItem( 'wp-api-schema-model' + model.get( 'apiRoot' ) + model.get( 'versionString' ) ) ) ) ); |
1173 | 1173 | } else { |
1174 | 1174 | model.schemaModel.fetch( { |
|
1187 | 1187 | sessionStorage.setItem( 'wp-api-schema-model' + model.get( 'apiRoot' ) + model.get( 'versionString' ), JSON.stringify( newSchemaModel ) ); |
1188 | 1188 | } catch ( error ) { |
1189 | 1189 |
|
1190 | | - // Fail silently, fixes errors in safari private mode. |
| 1190 | + // Fail silently, to avoid errors in Safari private mode. |
1191 | 1191 | } |
1192 | 1192 | } |
1193 | 1193 | }, |
|
1207 | 1207 | * Set up the model and collection name mapping options. As the schema is built, the |
1208 | 1208 | * model and collection names will be adjusted if they are found in the mapping object. |
1209 | 1209 | * |
1210 | | - * Localizing a variable wpApiSettings.mapping will over-ride the default mapping options. |
| 1210 | + * Localizing a variable wpApiSettings.mapping will override the default mapping options. |
1211 | 1211 | * |
1212 | 1212 | */ |
1213 | 1213 | mapping = wpApiSettings.mapping || { |
|
1242 | 1242 | modelRegex = new RegExp( '(?:.*[+)]|\/(' + modelEndpoints.join( '|' ) + '))$' ); |
1243 | 1243 |
|
1244 | 1244 | /** |
1245 | | - * Iterate thru the routes, picking up models and collections to build. Builds two arrays, |
| 1245 | + * Iterate through the routes, picking up models and collections to build. Builds two arrays, |
1246 | 1246 | * one for models and one for collections. |
1247 | 1247 | */ |
1248 | 1248 | modelRoutes = []; |
|
1288 | 1288 | parentName = wp.api.utils.extractRoutePart( modelRoute.index, 1, routeModel.get( 'versionString' ), false ), |
1289 | 1289 | routeEnd = wp.api.utils.extractRoutePart( modelRoute.index, 1, routeModel.get( 'versionString' ), true ); |
1290 | 1290 |
|
1291 | | - // Clear the parent part of the route if it's actually the version string. |
| 1291 | + // Clear the parent part of the route if it is actually the version string. |
1292 | 1292 | if ( parentName === routeModel.get( 'versionString' ) ) { |
1293 | 1293 | parentName = ''; |
1294 | 1294 | } |
|
1304 | 1304 | modelClassName = mapping.models[ modelClassName ] || modelClassName; |
1305 | 1305 | loadingObjects.models[ modelClassName ] = wp.api.WPApiBaseModel.extend( { |
1306 | 1306 |
|
1307 | | - // Return a constructed url based on the parent and id. |
| 1307 | + // Return a constructed URL based on the parent and ID. |
1308 | 1308 | url: function() { |
1309 | 1309 | var url = |
1310 | 1310 | routeModel.get( 'apiRoot' ) + |
|
1347 | 1347 | modelClassName = mapping.models[ modelClassName ] || modelClassName; |
1348 | 1348 | loadingObjects.models[ modelClassName ] = wp.api.WPApiBaseModel.extend( { |
1349 | 1349 |
|
1350 | | - // Function that returns a constructed url based on the ID. |
| 1350 | + // Function that returns a constructed URL based on the ID. |
1351 | 1351 | url: function() { |
1352 | 1352 | var url = routeModel.get( 'apiRoot' ) + |
1353 | 1353 | routeModel.get( 'versionString' ) + |
|
1409 | 1409 | collectionClassName = mapping.collections[ collectionClassName ] || collectionClassName; |
1410 | 1410 | loadingObjects.collections[ collectionClassName ] = wp.api.WPApiBaseCollection.extend( { |
1411 | 1411 |
|
1412 | | - // Function that returns a constructed url passed on the parent. |
| 1412 | + // Function that returns a constructed URL passed on the parent. |
1413 | 1413 | url: function() { |
1414 | 1414 | return routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) + |
1415 | 1415 | parentName + '/' + |
|
1448 | 1448 | collectionClassName = mapping.collections[ collectionClassName ] || collectionClassName; |
1449 | 1449 | loadingObjects.collections[ collectionClassName ] = wp.api.WPApiBaseCollection.extend( { |
1450 | 1450 |
|
1451 | | - // For the url of a root level collection, use a string. |
| 1451 | + // For the URL of a root level collection, use a string. |
1452 | 1452 | url: function() { |
1453 | 1453 | return routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) + routeName; |
1454 | 1454 | }, |
|
0 commit comments