JGonera has uploaded a new change for review.
https://gerrit.wikimedia.org/r/92031
Change subject: [WIP] Separate stable and beta upload overlay code
......................................................................
[WIP] Separate stable and beta upload overlay code
And remove the nag overlay from beta.
Change-Id: Iab91e7b061214fff3406c87e09ff2686ed788495
---
M includes/Resources.php
M includes/skins/SkinMinerva.php
A javascripts/modules/uploadsNew/LearnMoreOverlay.js
A javascripts/modules/uploadsNew/PhotoUploadProgress.js
A javascripts/modules/uploadsNew/PhotoUploader.js
A javascripts/modules/uploadsNew/PhotoUploaderButton.js
A javascripts/modules/uploadsNew/PhotoUploaderPreview.js
A javascripts/modules/uploadsNew/leadPhotoInit.js
A templates/uploadsNew/LearnMoreOverlay.html
A templates/uploadsNew/PhotoUploadPreview.html
A templates/uploadsNew/PhotoUploadProgress.html
11 files changed, 588 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/31/92031/1
diff --git a/includes/Resources.php b/includes/Resources.php
index d2a9f91..707e68c 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -268,6 +268,57 @@
),
),
+ 'mobile.uploadsNew' => $wgMFMobileResourceBoilerplate + array(
+ 'dependencies' => array(
+ 'mobile.stable',
+ 'mobile.templates',
+ ),
+ 'scripts' => array(
+ 'javascripts/modules/uploadsNew/LearnMoreOverlay.js',
+ 'javascripts/modules/uploads/PhotoApi.js',
+ 'javascripts/modules/uploadsNew/PhotoUploadProgress.js',
+
'javascripts/modules/uploadsNew/PhotoUploaderPreview.js',
+ 'javascripts/modules/uploads/LeadPhoto.js',
+ 'javascripts/modules/uploadsNew/PhotoUploader.js',
+ ),
+ 'templates' => array(
+ 'uploadsNew/PhotoUploadPreview',
+ 'uploadsNew/PhotoUploadProgress',
+ 'uploadsNew/LearnMoreOverlay',
+ 'uploads/LeadPhoto',
+ ),
+ 'messages' => array(
+ 'mobile-frontend-photo-upload-success-article',
+ 'mobile-frontend-photo-upload-error',
+
+ // LearnMoreOverlay.js
+ 'mobile-frontend-photo-ownership-confirm',
+
+ // PhotoApi.js
+ 'mobile-frontend-photo-article-edit-comment',
+ 'mobile-frontend-photo-article-donate-comment',
+ 'mobile-frontend-photo-upload-error-filename',
+ 'mobile-frontend-photo-upload-comment',
+
+ // PhotoUploaderPreview.js
+ 'mobile-frontend-photo-ownership',
+ 'mobile-frontend-photo-ownership-help',
+ 'mobile-frontend-photo-caption-placeholder',
+ 'mobile-frontend-image-loading',
+ 'mobile-frontend-photo-submit',
+ 'mobile-frontend-photo-cancel',
+ 'mobile-frontend-photo-ownership-bullet-one',
+ 'mobile-frontend-photo-ownership-bullet-two',
+ 'mobile-frontend-photo-ownership-bullet-three',
+ 'mobile-frontend-photo-upload-error-file-type',
+
+ // PhotoUploadProgress.js
+ 'mobile-frontend-image-uploading-wait',
+ 'mobile-frontend-image-uploading-long',
+ 'mobile-frontend-image-uploading-cancel',
+ ),
+ ),
+
'mobile.beta.common' => $wgMFMobileResourceBoilerplate + array(
'dependencies' => array(
'mobile.stable.common',
@@ -331,6 +382,10 @@
'javascripts/modules/mf-toggle-dynamic.js',
'javascripts/modules/talk/talk.js',
'javascripts/modules/notifications/notifications.js',
+ 'javascripts/modules/uploadsNew/PhotoUploaderButton.js',
+ // FIXME: remove when new upload overlays in stable
+ 'javascripts/modules/mainmenutweaks.js',
+ 'javascripts/modules/uploadsNew/leadPhotoInit.js',
'javascripts/modules/search/pageImages.js',
'javascripts/modules/languages/preferred.js',
'javascripts/modules/lastEdited/lastEditedBeta.js',
@@ -500,8 +555,6 @@
'javascripts/widgets/progress-bar.js',
'javascripts/common/notification.js',
'javascripts/common/Page.js',
- // Upload specific code
- 'javascripts/modules/uploads/PhotoUploaderButton.js',
// Language specific code
'javascripts/common/languages/LanguageOverlay.js',
),
@@ -562,8 +615,6 @@
'javascripts/modules/issues/issues.js',
'javascripts/modules/languages/languages.js',
'javascripts/modules/lastEdited/time.js',
- 'javascripts/modules/uploads/lead-photo-init.js',
- 'javascripts/modules/mainmenutweaks.js',
'javascripts/modules/search/search.js',
'javascripts/modules/mf-watchstar.js',
'javascripts/modules/mf-references.js',
@@ -613,6 +664,16 @@
),
),
+ 'mobile.uploads.init.stable' => $wgMFMobileResourceBoilerplate + array(
+ 'dependencies' => array( 'mobile.stable' ),
+ 'scripts' => array(
+ 'javascripts/modules/uploads/PhotoUploaderButton.js',
+ // FIXME: move back to mobile.stable when new uploads
overlay in stable
+ 'javascripts/modules/mainmenutweaks.js',
+ 'javascripts/modules/uploads/lead-photo-init.js',
+ ),
+ ),
+
'mobile.site' => array(
'dependencies' => array( 'mobile.startup' ),
'class' => 'MobileSiteModule',
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 7471c5b..8f50564 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -420,7 +420,10 @@
$modules['watch'] = array();
$modules['search'] = array();
- $modules['stableonly'] = array( 'mobile.lastEdited.stable' );
+ $modules['stableonly'] = array(
+ 'mobile.lastEdited.stable',
+ 'mobile.uploads.init.stable',
+ );
$title = $this->getTitle();
diff --git a/javascripts/modules/uploadsNew/LearnMoreOverlay.js
b/javascripts/modules/uploadsNew/LearnMoreOverlay.js
new file mode 100644
index 0000000..9623aad
--- /dev/null
+++ b/javascripts/modules/uploadsNew/LearnMoreOverlay.js
@@ -0,0 +1,15 @@
+( function( M ) {
+ var Overlay = M.require( 'Overlay' ), LearnMoreOverlay;
+ LearnMoreOverlay = Overlay.extend( {
+ defaults: {
+ confirmMessage: mw.msg(
'mobile-frontend-photo-ownership-confirm' )
+ },
+ templatePartials: {
+ content: M.template.get( 'uploadsNew/LearnMoreOverlay' )
+ }
+ } );
+
+ M.define( 'modules/uploads/LearnMoreOverlay', LearnMoreOverlay );
+
+}( mw.mobileFrontend ) );
+
diff --git a/javascripts/modules/uploadsNew/PhotoUploadProgress.js
b/javascripts/modules/uploadsNew/PhotoUploadProgress.js
new file mode 100644
index 0000000..f41d338
--- /dev/null
+++ b/javascripts/modules/uploadsNew/PhotoUploadProgress.js
@@ -0,0 +1,50 @@
+( function( M ) {
+ var Drawer = M.require( 'Drawer' ),
+ ProgressBar = M.require( 'widgets/progress-bar' ),
+ PhotoUploadProgress;
+
+ PhotoUploadProgress = Drawer.extend( {
+ defaults: {
+ waitMessage: mw.msg(
'mobile-frontend-image-uploading-wait' ),
+ cancelMessage: mw.msg(
'mobile-frontend-image-uploading-cancel' ),
+ messageInterval: 10000
+ },
+
+ template: M.template.get( 'uploadsNew/PhotoUploadProgress' ),
+ className: 'drawer position-fixed text loading',
+ locked: true,
+
+ postRender: function( options ) {
+ var self = this, longMessage = false;
+
+ this._super();
+
+ this.$( 'a' ).on( 'click', function() {
+ self.hide();
+ self.emit( 'cancel' );
+ return false;
+ } );
+
+ setInterval( function() {
+ if ( longMessage ) {
+ self.$( '.wait' ).text( mw.msg(
'mobile-frontend-image-uploading-wait' ) );
+ } else {
+ self.$( '.wait' ).text( mw.msg(
'mobile-frontend-image-uploading-long' ) );
+ }
+ longMessage = !longMessage;
+ }, options.messageInterval );
+ },
+
+ setValue: function( value ) {
+ // only add progress bar if we're getting progress
events
+ if ( !this.progressBar ) {
+ this.progressBar = new ProgressBar();
+ this.progressBar.appendTo( this.$el );
+ }
+ this.progressBar.setValue( value );
+ }
+ } );
+
+ M.define( 'modules/uploads/PhotoUploadProgress', PhotoUploadProgress );
+
+}( mw.mobileFrontend ) );
diff --git a/javascripts/modules/uploadsNew/PhotoUploader.js
b/javascripts/modules/uploadsNew/PhotoUploader.js
new file mode 100644
index 0000000..5368e51
--- /dev/null
+++ b/javascripts/modules/uploadsNew/PhotoUploader.js
@@ -0,0 +1,111 @@
+( function( M, $ ) {
+ var Class = M.require( 'Class' ),
+ popup = M.require( 'notifications' ),
+ PhotoApi = M.require( 'modules/uploads/PhotoApi' ),
+ PhotoUploadProgress = M.require(
'modules/uploads/PhotoUploadProgress' ),
+ PhotoUploaderPreview = M.require(
'modules/uploads/PhotoUploaderPreview' ),
+ PhotoUploader;
+
+ function getLog( funnel ) {
+ return function( data ) {
+ if ( mw.config.get( 'wgArticleId', -1 ) !== -1 ) {
+ data.pageId = mw.config.get( 'wgArticleId' );
+ }
+
+ M.log( 'MobileWebUploads', $.extend( {
+ token: M.getSessionId(),
+ funnel: funnel,
+ username: mw.config.get( 'wgUserName' ),
+ isEditable: mw.config.get( 'wgIsPageEditable' ),
+ mobileMode: mw.config.get( 'wgMFMode' ),
+ userAgent: window.navigator.userAgent
+ }, data ) );
+ };
+ }
+
+ PhotoUploader = Class.extend( {
+
+ initialize: function( options ) {
+ var fileReader = new FileReader(), preview;
+
+ this.log = getLog( options.funnel );
+ preview = this.preview = new PhotoUploaderPreview( {
log: this.log } );
+
+ this.options = options;
+ this.parent = options.parent;
+ this.file = options.file;
+
+ this._showPreview();
+
+ fileReader.readAsDataURL( this.file );
+ fileReader.onload = function() {
+ var dataUrl = fileReader.result;
+ // add mimetype if not present (some browsers
need it, e.g. Android browser)
+ dataUrl = dataUrl.replace( /^data:base64/,
'data:image/jpeg;base64' );
+ preview.setImageUrl( dataUrl );
+ };
+ },
+
+ _showPreview: function() {
+ var self = this;
+
+ self.log( { action: 'preview' } );
+ self.preview.
+ on( 'cancel', function() {
+ self.log( { action: 'previewCancel' } );
+ } ).
+ on( 'submit', function() {
+ self.log( { action: 'previewSubmit' } );
+ self._submit();
+ } );
+
+ self.preview.show();
+ // skip the URL bar if possible
+ window.scrollTo( 0, 1 );
+ },
+
+ _submit: function() {
+ var self = this,
+ description = this.preview.getDescription(),
+ api = new PhotoApi(),
+ progressPopup = new PhotoUploadProgress();
+
+ this.parent.emit( 'start' );
+ this.preview.hide();
+ progressPopup.show();
+ progressPopup.on( 'cancel', function() {
+ api.abort();
+ self.log( { action: 'cancel' } );
+ self.parent.emit( 'cancel' );
+ } );
+
+ api.save( {
+ file: this.file,
+ description: description,
+ insertInPage: this.options.insertInPage,
+ pageTitle: this.options.pageTitle
+ } ).done( function( fileName, descriptionUrl ) {
+ progressPopup.hide();
+ self.log( { action: 'success' } );
+ self.parent.emit( 'success', {
+ fileName: fileName,
+ description: description,
+ descriptionUrl: descriptionUrl,
+ url: self.preview.imageUrl
+ } );
+ } ).fail( function( err, msg ) {
+ progressPopup.hide();
+ popup.show( msg || mw.msg(
'mobile-frontend-photo-upload-error' ), 'toast error' );
+ self.log( { action: 'error', errorText: err } );
+ self.parent.emit( 'error' );
+ } );
+
+ api.on( 'uploadProgress', function( value ) {
+ progressPopup.setValue( value );
+ } );
+ }
+ } );
+
+ M.define( 'modules/uploads/PhotoUploader', PhotoUploader );
+
+}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/uploadsNew/PhotoUploaderButton.js
b/javascripts/modules/uploadsNew/PhotoUploaderButton.js
new file mode 100644
index 0000000..cddafac
--- /dev/null
+++ b/javascripts/modules/uploadsNew/PhotoUploaderButton.js
@@ -0,0 +1,164 @@
+( function( M, $ ) {
+ var View = M.require( 'view' ),
+ popup = M.require( 'notifications' ),
+ CtaDrawer = M.require( 'CtaDrawer' ),
+ LoadingOverlay = M.require( 'LoadingOverlay' ),
+ PhotoUploaderButton,
+ LeadPhotoUploaderButton;
+
+ function isSupported() {
+ // FIXME: create a module for browser detection stuff
+ // deal with known false positives which don't support file
input (bug 47374)
+ if ( navigator.userAgent.match( /Windows Phone (OS 7|8.0)/ ) ) {
+ return false;
+ }
+ var browserSupported = (
+ typeof FileReader !== 'undefined' &&
+ typeof FormData !== 'undefined' &&
+ ($('<input type="file"/>').prop('type') === 'file') //
Firefox OS 1.0 turns <input type="file"> into <input type="text">
+ );
+
+ return browserSupported && !mw.config.get( 'wgImagesDisabled',
false );
+ }
+
+ /**
+ * PhotoUploaderButton is a component for uploading images to the wiki.
+ *
+ * @example
+ * <code>
+ * var photoUploaderButton = new PhotoUploaderButton( {
+ * buttonCaption: 'Add a photo',
+ * } );
+ * photoUploaderButton.
+ * insertAfter( 'h1' ).
+ * on( 'upload', function( fileName, url ) {
+ * $( '.someImage' ).attr( 'src', url );
+ * } );
+ * </code>
+ *
+ * @constructor
+ * @param {Object} options Uploader options.
+ * @param {string} options.buttonCaption Caption for the upload button.
+ * @param {boolean} options.insertInPage If the image should be
prepended
+ * to the wikitext of a page specified by options.pageTitle.
+ * @param {string} options.pageTitle Title of the page to which the
image
+ * belongs (image name will be based on this) and to which it should be
+ * prepended (if options.insertInPage is true).
+ * @param {string} options.funnel Funnel for EventLogging.
+ * @fires PhotoUploader#start
+ * @fires PhotoUploader#success
+ * @fires PhotoUploader#error
+ * @fires PhotoUploader#cancel
+ */
+ /**
+ * Triggered when image upload starts.
+ *
+ * @event PhotoUploader#start
+ */
+ /**
+ * Triggered when image upload is finished successfully.
+ *
+ * @event PhotoUploader#success
+ * @property {Object} data Uploaded image data.
+ * @property {string} data.fileName Name of the uploaded image.
+ * @property {string} data.description Name of the uploaded image.
+ * @property {string} data.url URL to the uploaded image (can be a
+ * local data URL).
+ */
+ /**
+ * Triggered when image upload fails.
+ *
+ * @event PhotoUploader#error
+ */
+ /**
+ * Triggered when image upload is cancelled.
+ *
+ * @event PhotoUploader#cancel
+ */
+ PhotoUploaderButton = View.extend( {
+ template: M.template.get( 'uploads/PhotoUploaderButton' ),
+ className: 'button photo',
+
+ initialize: function( options ) {
+ this._super( options );
+ },
+
+ postRender: function() {
+ var self = this, $input = this.$( 'input' ), ctaDrawer;
+
+ // show CTA instead if not logged in
+ if ( !M.isLoggedIn() ) {
+ ctaDrawer = new CtaDrawer( {
+ content: mw.msg(
'mobile-frontend-photo-upload-cta' ),
+ queryParams: {
+ campaign:
'mobile_uploadPageActionCta',
+ returntoquery:
'article_action=photo-upload'
+ }
+ } );
+ this.$el.click( function( ev ) {
+ ctaDrawer.show();
+ ev.preventDefault();
+ } );
+ return;
+ }
+
+ $input.
+ // accept must be set via attr otherwise cannot
use camera on Android
+ attr( 'accept', 'image/*;' ).
+ on( 'change', function() {
+ var options = $.extend( {},
self.options, {
+ file: $input[0].files[0],
+ parent: self
+ } ),
+ loadingOverlay = new
LoadingOverlay();
+
+ loadingOverlay.show();
+ mw.loader.using( 'mobile.uploadsNew',
function() {
+ var PhotoUploader = M.require(
'modules/uploads/PhotoUploader' );
+ loadingOverlay.hide();
+ new PhotoUploader( options );
+ } );
+
+ // clear so that change event is fired
again when user selects the same file
+ $input.val( '' );
+ } );
+ }
+ } );
+
+ LeadPhotoUploaderButton = PhotoUploaderButton.extend( {
+ template: M.template.get( 'uploads/LeadPhotoUploaderButton' ),
+ className: 'enabled',
+
+ initialize: function( options ) {
+ var self = this;
+ this._super( options );
+ this.on( 'start', function() {
+ self.$el.removeClass( 'enabled' );
+ } ).
+ on( 'success', function( data ) {
+ popup.show( mw.msg(
'mobile-frontend-photo-upload-success-article' ), 'toast' );
+
+ // just in case, LeadPhoto should be
loaded by now anyway
+ mw.loader.using( 'mobile.uploads',
function() {
+ var LeadPhoto = M.require(
'modules/uploads/LeadPhoto' );
+
+ new LeadPhoto( {
+ url: data.url,
+ pageUrl:
data.descriptionUrl,
+ caption:
data.description
+ } ).prependTo(
M.getLeadSection() );
+ } );
+ } ).
+ on( 'error cancel', function() {
+ self.$el.addClass( 'enabled' );
+ } );
+ }
+ } );
+
+ PhotoUploaderButton.isSupported = LeadPhotoUploaderButton.isSupported =
isSupported();
+
+ // FIXME: should we allow more than one define() per file?
+ M.define( 'modules/uploads/PhotoUploaderButton', PhotoUploaderButton );
+ M.define( 'modules/uploads/LeadPhotoUploaderButton',
LeadPhotoUploaderButton );
+
+}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/uploadsNew/PhotoUploaderPreview.js
b/javascripts/modules/uploadsNew/PhotoUploaderPreview.js
new file mode 100644
index 0000000..d1806f4
--- /dev/null
+++ b/javascripts/modules/uploadsNew/PhotoUploaderPreview.js
@@ -0,0 +1,90 @@
+( function( M, $ ) {
+ var popup = M.require( 'notifications' ),
+ Overlay = M.require( 'Overlay' ),
+ LearnMoreOverlay = M.require(
'modules/uploads/LearnMoreOverlay' ),
+ ownershipMessage = mw.msg( 'mobile-frontend-photo-ownership',
mw.config.get( 'wgUserName' ), mw.user ),
+ PhotoUploaderPreview;
+
+ PhotoUploaderPreview = Overlay.extend( {
+ defaults: {
+ loadingMessage: mw.msg( 'mobile-frontend-image-loading'
),
+ license: mw.msg( 'mobile-frontend-photo-license' ),
+ cancelButton: mw.msg( 'mobile-frontend-photo-cancel' ),
+ submitButton: mw.msg( 'mobile-frontend-photo-submit' ),
+ descriptionPlaceholder: mw.msg(
'mobile-frontend-photo-caption-placeholder' ),
+ help: mw.msg( 'mobile-frontend-photo-ownership-help' ),
+ ownerStatement: ownershipMessage
+ },
+
+ className: 'mw-mf-overlay photo-overlay',
+
+ templatePartials: {
+ content: M.template.get(
'uploadsNew/PhotoUploadPreview' )
+ },
+
+ initialize: function( options ) {
+ this.log = options.log;
+ this._super( options );
+ },
+
+ postRender: function() {
+ var self = this, $description, $submitButton;
+
+ this._super();
+
+ this.$description = $description = this.$( 'textarea' );
+ $submitButton = this.$( '.submit' ).on( 'click',
function() {
+ self.emit( 'submit' );
+ } );
+ this.$( '.cancel' ).on( 'click', function() {
+ self.emit( 'cancel' );
+ } );
+
+ // make license links open in separate tabs
+ this.$( '.license a' ).attr( 'target', '_blank' );
+ // use input event too, Firefox doesn't fire keyup on
many devices:
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=737658
+ $description.on( 'keyup input', function() {
+ if ( $description.val() ) {
+ $submitButton.removeAttr( 'disabled' );
+ } else {
+ $submitButton.attr( 'disabled', true );
+ }
+ } );
+ },
+
+ getDescription: function() {
+ return this.$description.val();
+ },
+
+ setImageUrl: function( url ) {
+ var self = this, $img;
+
+ this.imageUrl = url;
+ this.$( '.loading' ).remove();
+ this.$( 'a.help' ).on( 'click', function( ev ) {
+ ev.preventDefault(); // avoid setting #
+ new LearnMoreOverlay( {
+ parent: self,
+ bulletPoints: [
+ mw.msg(
'mobile-frontend-photo-ownership-bullet-one' ),
+ mw.msg(
'mobile-frontend-photo-ownership-bullet-two' ),
+ mw.msg(
'mobile-frontend-photo-ownership-bullet-three' )
+ ],
+ leadText: ownershipMessage
+ } ).show();
+ self.log( { action: 'whatDoesThisMean' } );
+ } );
+ $img = $( '<img>' ).attr( 'src', url ).prependTo(
this.$( '.content' ) );
+
+ // When using a bad filetype close the overlay
+ $img.on( 'error', function() {
+ popup.show( mw.msg(
'mobile-frontend-photo-upload-error-file-type' ), 'toast error' );
+ self.hide();
+ } );
+ }
+ } );
+
+ M.define( 'modules/uploads/PhotoUploaderPreview', PhotoUploaderPreview
);
+
+}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/uploadsNew/leadPhotoInit.js
b/javascripts/modules/uploadsNew/leadPhotoInit.js
new file mode 100644
index 0000000..4850639
--- /dev/null
+++ b/javascripts/modules/uploadsNew/leadPhotoInit.js
@@ -0,0 +1,64 @@
+( function( M, $ ) {
+
+ var
+ funnel = $.cookie( 'mwUploadsFunnel' ) || 'article',
+ showCta = mw.config.get( 'wgMFEnablePhotoUploadCTA' ) || funnel
=== 'nearby',
+ popup = M.require( 'notifications' ),
+ LeadPhotoUploaderButton = M.require(
'modules/uploads/LeadPhotoUploaderButton' ),
+ PhotoUploaderButton = M.require(
'modules/uploads/PhotoUploaderButton' ),
+ isSupported = PhotoUploaderButton.isSupported;
+
+ function needsPhoto( $container ) {
+ return $container.find( mw.config.get(
'wgMFLeadPhotoUploadCssSelector' ) ).length === 0;
+ }
+
+ // reset the funnel cookie as it is no longer valid (this stops upload
cta showing on further page loads)
+ if ( funnel ) {
+ $.cookie( 'mwUploadsFunnel', null );
+ }
+
+ function makeDisabledButton( msg ) {
+ $( '#ca-upload' ).on( 'click', function() {
+ popup.show( mw.msg( msg ||
'mobile-frontend-photo-upload-disabled' ), 'toast' );
+ } );
+ }
+
+ function initialize() {
+ // FIXME: make some general function for that (or a page object
with a method)
+ var
+ // FIXME: not updated on dynamic page loads
+ isEditable = mw.config.get( 'wgIsPageEditable' ),
+ validNamespace = ( M.inNamespace( '' ) ||
M.inNamespace( 'user' ) );
+
+ if ( !M.isLoggedIn() && !showCta ) {
+ // Note with the CTA this is unnecessary but the new
nav requires showing the upload button at all times
+ return makeDisabledButton(
'mobile-frontend-photo-upload-anon' );
+ } else if ( !isEditable ) {
+ return makeDisabledButton(
'mobile-frontend-photo-upload-protected' );
+ } else if ( !validNamespace || mw.util.getParamValue( 'action'
) || !needsPhoto( M.getLeadSection() ) || mw.config.get( 'wgIsMainPage' ) ) {
+ return makeDisabledButton();
+ }
+
+ new LeadPhotoUploaderButton( {
+ buttonCaption: mw.msg( 'mobile-frontend-photo-upload' ),
+ insertInPage: true,
+ el: '#ca-upload',
+ pageTitle: mw.config.get( 'wgPageName' ),
+ funnel: funnel
+ } );
+ }
+
+ if ( isSupported ) {
+ $( initialize );
+ M.on( 'page-loaded', function() {
+ initialize();
+ } );
+ } else {
+ makeDisabledButton( 'mobile-frontend-photo-upload-unavailable'
);
+ }
+
+ M.define( 'modules/uploads/_leadphoto', {
+ needsPhoto: needsPhoto
+ } );
+
+}( mw.mobileFrontend, jQuery ) );
diff --git a/templates/uploadsNew/LearnMoreOverlay.html
b/templates/uploadsNew/LearnMoreOverlay.html
new file mode 100644
index 0000000..08ff5e5
--- /dev/null
+++ b/templates/uploadsNew/LearnMoreOverlay.html
@@ -0,0 +1,12 @@
+<div class="content">
+ {{#leadText}}
+ <p>{{leadText}}</p>
+ {{/leadText}}
+
+ <ul class="informative">
+ {{#bulletPoints}}
+ <li>{{{.}}}</li>
+ {{/bulletPoints}}
+ </ul>
+ <button class="confirm">{{confirmMessage}}</button>
+</div>
diff --git a/templates/uploadsNew/PhotoUploadPreview.html
b/templates/uploadsNew/PhotoUploadPreview.html
new file mode 100644
index 0000000..099467d
--- /dev/null
+++ b/templates/uploadsNew/PhotoUploadPreview.html
@@ -0,0 +1,10 @@
+<div class="content">
+ <p class="loading">{{loadingMessage}}</p>
+ <p>{{ownerStatement}} <a href="#" class="help">{{help}}</a></p>
+ <textarea name="description"
placeholder="{{descriptionPlaceholder}}"></textarea>
+</div>
+<div class="position-fixed buttonBar button-bar-centered">
+ <button class="cancel inline">{{cancelButton}}</button>
+ <button class="submit" disabled>{{submitButton}}</button>
+ <p class="license">{{{license}}}</p>
+</div>
diff --git a/templates/uploadsNew/PhotoUploadProgress.html
b/templates/uploadsNew/PhotoUploadProgress.html
new file mode 100644
index 0000000..53d2fcd
--- /dev/null
+++ b/templates/uploadsNew/PhotoUploadProgress.html
@@ -0,0 +1,3 @@
+<p class="wait">{{waitMessage}}</p>
+<p class="cancel">{{{cancelMessage}}}</p>
+
--
To view, visit https://gerrit.wikimedia.org/r/92031
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iab91e7b061214fff3406c87e09ff2686ed788495
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: JGonera <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits