jenkins-bot has submitted this change and it was merged.
Change subject: Add event binding in initialize for
PhotoUploaderPageActionButton
......................................................................
Add event binding in initialize for PhotoUploaderPageActionButton
This allows us to reuse it elsewhere easily
e.g. in first time uploader tutorial
Rename to more generic LeadPhotoUploaderButton
Change-Id: I93899aeafd13e3d12cfe594374d443d015715d7d
---
M includes/Resources.php
M javascripts/modules/uploads/PhotoUploader.js
M javascripts/modules/uploads/lead-photo-init.js
3 files changed, 34 insertions(+), 34 deletions(-)
Approvals:
JGonera: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Resources.php b/includes/Resources.php
index 836a0d0..cdf8bf0 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -400,8 +400,8 @@
'javascripts/modules/uploads/NagOverlay.js',
'javascripts/modules/uploads/PhotoUploadProgress.js',
'javascripts/modules/uploads/PhotoUploaderPreview.js',
- 'javascripts/modules/uploads/PhotoUploader.js',
'javascripts/modules/uploads/LeadPhoto.js',
+ 'javascripts/modules/uploads/PhotoUploader.js',
// Language specific code
'javascripts/common/languages/LanguageOverlay.js',
),
diff --git a/javascripts/modules/uploads/PhotoUploader.js
b/javascripts/modules/uploads/PhotoUploader.js
index 1c583b4..33cc037 100644
--- a/javascripts/modules/uploads/PhotoUploader.js
+++ b/javascripts/modules/uploads/PhotoUploader.js
@@ -8,7 +8,8 @@
PhotoUploaderPreview = M.require(
'modules/uploads/PhotoUploaderPreview' ),
PhotoUploader,
PhotoUploaderButton,
- PhotoUploaderPageActionButton;
+ LeadPhoto = M.require( 'modules/uploads/LeadPhoto' ),
+ LeadPhotoUploaderButton;
function isSupported() {
// FIXME: create a module for browser detection stuff
@@ -254,15 +255,37 @@
className: 'button photo'
} );
- PhotoUploaderPageActionButton = PhotoUploader.extend( {
+ LeadPhotoUploaderButton = PhotoUploader.extend( {
template: M.template.get( 'photoUploadAction' ),
- className: 'enabled'
+ className: 'enabled',
+ initialize: function( options ) {
+ var self = this;
+ this._super( options );
+ this.on( 'start', function() {
+ self.$el.hide();
+ } ).
+ on( 'success', function( data ) {
+ popup.show( mw.msg(
'mobile-frontend-photo-upload-success-article' ), 'toast' );
+ // FIXME: workaround for
https://bugzilla.wikimedia.org/show_bug.cgi?id=43271
+ if ( !$( '#content_0' ).length ) {
+ $( '<div id="content_0" >'
).insertAfter( $( '#section_0,#page-actions' ).last() );
+ }
+ new LeadPhoto( {
+ url: data.url,
+ pageUrl: data.descriptionUrl,
+ caption: data.description
+ } ).prependTo( '#content_0' );
+ } ).
+ on( 'error cancel', function() {
+ self.$el.show();
+ } );
+ }
} );
- PhotoUploaderButton.isSupported =
PhotoUploaderPageActionButton.isSupported = isSupported();
+ 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/PhotoUploaderPageActionButton',
PhotoUploaderPageActionButton );
+ M.define( 'modules/uploads/LeadPhotoUploaderButton',
LeadPhotoUploaderButton );
}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/uploads/lead-photo-init.js
b/javascripts/modules/uploads/lead-photo-init.js
index 9997858..131546c 100644
--- a/javascripts/modules/uploads/lead-photo-init.js
+++ b/javascripts/modules/uploads/lead-photo-init.js
@@ -4,10 +4,9 @@
funnel = $.cookie( 'mwUploadsFunnel' ) || 'article',
showCta = mw.config.get( 'wgMFEnablePhotoUploadCTA' ) || funnel
=== 'nearby',
popup = M.require( 'notifications' ),
- PhotoUploaderPageActionButton = M.require(
'modules/uploads/PhotoUploaderPageActionButton' ),
+ LeadPhotoUploaderButton = M.require(
'modules/uploads/LeadPhotoUploaderButton' ),
PhotoUploaderButton = M.require(
'modules/uploads/PhotoUploaderButton' ),
- isSupported = PhotoUploaderButton.isSupported,
- LeadPhoto = M.require( 'modules/uploads/LeadPhoto' );
+ isSupported = PhotoUploaderButton.isSupported;
function needsPhoto( $container ) {
var $content_0 = $container.find( '#content_0' );
@@ -37,9 +36,7 @@
// FIXME: not updated on dynamic page loads
isEditable = mw.config.get( 'wgIsPageEditable' ),
validNamespace = ( namespace === namespaceIds[''] ||
namespace === namespaceIds.user ),
- $page = $( '#content' ),
- optionsPhotoUploader,
- photoUploader;
+ $page = $( '#content' );
if ( !M.isLoggedIn() && !showCta ) {
// Note with the CTA this is unnecessary but the new
nav requires showing the upload button at all times
@@ -50,33 +47,13 @@
return makeDisabledButton();
}
- optionsPhotoUploader = {
+ new LeadPhotoUploaderButton( {
buttonCaption: mw.msg( 'mobile-frontend-photo-upload' ),
insertInPage: true,
el: '#ca-upload',
pageTitle: mw.config.get( 'wgTitle' ),
funnel: funnel
- };
-
- photoUploader = new PhotoUploaderPageActionButton(
optionsPhotoUploader );
- photoUploader.on( 'start', function() {
- photoUploader.$el.hide();
- } ).
- on( 'success', function( data ) {
- popup.show( mw.msg(
'mobile-frontend-photo-upload-success-article' ), 'toast' );
- // FIXME: workaround for
https://bugzilla.wikimedia.org/show_bug.cgi?id=43271
- if ( !$( '#content_0' ).length ) {
- $( '<div id="content_0" >'
).insertAfter( $( '#section_0,#page-actions' ).last() );
- }
- new LeadPhoto( {
- url: data.url,
- pageUrl: data.descriptionUrl,
- caption: data.description
- } ).prependTo( '#content_0' ).animate();
- } ).
- on( 'error cancel', function() {
- photoUploader.$el.show();
- } );
+ } );
}
if ( isSupported ) {
--
To view, visit https://gerrit.wikimedia.org/r/74517
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I93899aeafd13e3d12cfe594374d443d015715d7d
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits