*/
// jscs:enable checkParamNames
-( function ( $ ) {
+( function ( $, mw ) {
var hasOwn = Object.hasOwnProperty;
context.data.prevText = val;
// Try cache first
if ( context.config.cache && hasOwn.call( cache, val ) ) {
- if ( +new Date() - cache[ val ].timestamp < context.config.cacheMaxAge ) {
+ if ( mw.now() - cache[ val ].timestamp < context.config.cacheMaxAge ) {
context.data.$textbox.suggestions( 'suggestions', cache[ val ].suggestions );
if ( typeof context.config.update.after === 'function' ) {
context.config.update.after.call( context.data.$textbox, cache[ val ].metadata );
cache[ val ] = {
suggestions: suggestions,
metadata: metadata,
- timestamp: +new Date()
+ timestamp: mw.now()
};
}
},
* @mixins jQuery.plugin.suggestions
*/
-}( jQuery ) );
+}( jQuery, mediaWiki ) );
*/
mw.Upload.BookletLayout.prototype.uploadFile = function () {
var deferred = $.Deferred(),
- startTime = new Date(),
+ startTime = mw.now(),
layout = this,
file = this.getFile();
deferred.reject( errorMessage );
} );
}, function ( progress ) {
- var elapsedTime = new Date() - startTime,
+ var elapsedTime = mw.now() - startTime,
estimatedTotalTime = ( 1 / progress ) * elapsedTime,
estimatedRemainingTime = moment.duration( estimatedTotalTime - elapsedTime );
layout.emit( 'fileUploadProgress', progress, estimatedRemainingTime );