MarkTraceur has uploaded a new change for review.
https://gerrit.wikimedia.org/r/189416
Change subject: WIP isolate Flickr UI stuff
......................................................................
WIP isolate Flickr UI stuff
Change-Id: Id5d7444dfe249c6ba599a9a9d6b6678a5ce54e99
---
M resources/mw.UploadWizard.js
A resources/ui/uw.ui.FlickrUpload.js
2 files changed, 73 insertions(+), 23 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard
refs/changes/16/189416/1
diff --git a/resources/mw.UploadWizard.js b/resources/mw.UploadWizard.js
index b35c04b..a185ac7 100644
--- a/resources/mw.UploadWizard.js
+++ b/resources/mw.UploadWizard.js
@@ -148,35 +148,18 @@
flickrInterfaceInit: function () {
var $disclaimer,
wizard = this,
- checker = new mw.FlickrChecker( this,
this.upload ),
- // The input that will hold a flickr URL
entered by the user; will be appended to a form
- $flickrInput = $( '<input
id="mwe-upwiz-flickr-input" class="ui-helper-center-fix" type="text" />' ),
- // A container holding a form
- $flickrContainer = $( '<div
id="mwe-upwiz-upload-add-flickr-container"></div>' ),
- // Form whose submit event will be listened to
and prevented
- $flickrForm = $( '<form
id="mwe-upwiz-flickr-url-form"></form>' )
- .appendTo( $flickrContainer ),
- // Submit button to be clicked after entering
the URL
- $flickrButton = $( '<button
id="mwe-upwiz-upload-add-flickr" class="ui-helper-center-fix"
type="submit"></button>' )
- .appendTo( $flickrForm );
+ checker = new mw.FlickrChecker( this,
this.upload );
// Hide containers for selecting files
$( '#mwe-upwiz-add-file-container,
#mwe-upwiz-upload-ctrl-flickr-container' ).hide();
- // Add placeholder text to the Flickr URL input field
- $flickrInput.placeholder( mw.message(
'mwe-upwiz-flickr-input-placeholder' ).escaped() );
-
- // Insert form into the page
- $( '#mwe-upwiz-files' ).prepend( $flickrContainer );
-
- // Add disclaimer
- $disclaimer = mw.message(
'mwe-upwiz-flickr-disclaimer1' ).parse() +
- '<br/>' + mw.message(
'mwe-upwiz-flickr-disclaimer2' ).parse();
- $disclaimer = $( '<div
id="mwe-upwiz-flickr-disclaimer"></div>' ).html( $disclaimer );
- $( '#mwe-upwiz-upload-add-flickr-container' ).append(
$disclaimer );
+ this.flickrUI = new
mw.uploadWizard.ui.FlickrUploadInterface( $( '#mwe-upwiz-files' ) )
+ .on( 'check', function () {
+ wizard.flickrChecker( checker );
+ } );
// Insert input field into the form and set up submit
action
- $flickrForm.prepend( $flickrInput ).submit( function ()
{
+ $flickrForm.submit( function () {
$flickrButton.prop( 'disabled', true );
wizard.flickrChecker( checker );
// TODO Any particular reason to
stopPropagation ?
diff --git a/resources/ui/uw.ui.FlickrUpload.js
b/resources/ui/uw.ui.FlickrUpload.js
new file mode 100644
index 0000000..8d536ce
--- /dev/null
+++ b/resources/ui/uw.ui.FlickrUpload.js
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the MediaWiki extension UploadWizard.
+ *
+ * UploadWizard is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * UploadWizard is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with UploadWizard. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+( function ( mw, $, ui, oo ) {
+ var FUP;
+
+ /**
+ * Interface for uploading from Flickr.
+ * @class
+ * @mixins OO.EventEmitter
+ * @constructor
+ * @param {jQuery} $parent Where to stick the form.
+ */
+ function FlickrUploadInterface( $parent ) {
+ var fui = this;
+
+ this.$div = $( '<div>' )
+ .attr( 'id', 'mwe-upwiz-upload-add-flickr-container' )
+ .prependTo( $parent );
+
+ this.$form = $( '<form>' )
+ .attr( 'id', 'mwe-upwiz-flickr-url-form' )
+ .appendTo( this.$div )
+ .submit( function () {
+ fui.$button.prop( 'disabled', true );
+ fui.emit( 'check' );
+ } );
+
+ this.$button = $( '<button>' )
+ .attr( 'id', 'mwe-upwiz-upload-add-flickr' )
+ .attr( 'type', 'submit' )
+ .addClass( 'ui-helper-center-fix' )
+ .appendTo( this.$form )
+ .button( {
+ label: mw.message( 'mwe-upwiz-add-flickr'
).text()
+ } );
+
+ this.$input = $( '<input>' )
+ .attr( 'id', 'mwe-upwiz-flickr-input' )
+ .attr( 'type', 'text' )
+ .addClass( 'ui-helper-center-fix' )
+ .placeholder( mw.message(
'mwe-upwiz-flickr-input-placeholder' ).text() )
+ .prependTo( this.$form )
+ .focus()
+ .attr( 'id', 'mwe-upwiz-flickr-disclaimer' )
+ .append(
+ mw.message( 'mwe-upwiz-flickr-disclaimer1'
).parse(),
+ '<br />',
+ mw.message( 'mwe-upwiz-flickr-disclaimer2'
).parse()
+ )
+ .appendTo( this.$div );
+ }
+}( mediaWiki, jQuery, mediaWiki.uploadWizard.ui, OO ) );
--
To view, visit https://gerrit.wikimedia.org/r/189416
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id5d7444dfe249c6ba599a9a9d6b6678a5ce54e99
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits