Luis Felipe Schenone has submitted this change and it was merged.
Change subject: Minor improvements
......................................................................
Minor improvements
Change-Id: Ieca40af54fba7e4af39033876b53171931b19225
---
M MsUpload.body.php
M MsUpload.js
M MsUpload.php
M README.md
M i18n/de.json
M i18n/en.json
M i18n/es.json
M i18n/qqq.json
8 files changed, 261 insertions(+), 258 deletions(-)
Approvals:
Luis Felipe Schenone: Verified; Looks good to me, approved
diff --git a/MsUpload.body.php b/MsUpload.body.php
index bbd7720..5c0c09a 100644
--- a/MsUpload.body.php
+++ b/MsUpload.body.php
@@ -22,7 +22,7 @@
);
$msuVars = json_encode( $msuVars );
- $wgOut->addScript( "<script type=\"{$wgJsMimeType}\">var
msuVars = $msuVars;</script>\n" );
+ $wgOut->addScript( "<script type=\"$wgJsMimeType\">var msuVars
= $msuVars;</script>\n" );
return true;
}
diff --git a/MsUpload.js b/MsUpload.js
index 9e2d7f2..58bebce 100755
--- a/MsUpload.js
+++ b/MsUpload.js
@@ -6,8 +6,8 @@
file.li.warning.text( errorText );
file.li.addClass( 'yellow' );
file.li.type.addClass( 'error' );
- file.li.click( function() { // Remove li at click
- file.li.fadeOut( 'slow', function() {
+ file.li.click( function () { // Remove li at click
+ file.li.fadeOut( 'slow', function () {
$( this ).remove();
uploader.trigger( 'CheckFiles' );
});
@@ -17,11 +17,20 @@
var galleryArray = [];
function addGallery() {
var galleryText = 'File:' + galleryArray.join( '\nFile:' );
- mw.toolbar.insertTags( '<gallery>\n' + galleryText + '\n</gallery>\n',
'', '', '' ); // Insert gallery
+ mw.toolbar.insertTags( '<gallery>\n' + galleryText + '\n</gallery>\n',
'', '', '' );
}
+var filesArray = [];
function addFiles() {
- mw.toolbar.insertTags( '[[File:' + galleryArray.join( ']]\n[[File:' ) +
']]\n', '', '', '' ); // Insert gallery
+ mw.toolbar.insertTags( '[[File:' + filesArray.join( ']]\n[[File:' ) +
']]\n', '', '', '' );
+}
+
+function addLinks() {
+ if ( msuVars.useMsLinks === true ) {
+ mw.toolbar.insertTags( '*{{#l:' + filesArray.join( '}}\n*{{#l:'
) + '}}\n', '', '', '' );
+ } else {
+ mw.toolbar.insertTags( '*[[:File:' + filesArray.join(
']]\n*[[:File:' ) + ']]\n', '', '', '' );
+ }
}
function warningText( fileItem, warning ) {
@@ -31,7 +40,7 @@
// Error handling
warning = warning.replace( /( <( [^>]+ )> )/ig, '' );
var warningSplit = warning.split( '. ' ); // split error
- $( '<span/>' ).attr( 'class', 'small-warn' ).html(
warningSplit[0] ).click( function() {
+ $( '<span/>' ).attr( 'class', 'small-warn' ).html(
warningSplit[0] ).click( function () {
$( this ).html( warningSplit[0] + '. ' +
warningSplit[1] );
}).appendTo( fileItem.warning );
}
@@ -48,18 +57,18 @@
titles: 'File:' + filename,
prop: 'imageinfo',
iiprop: 'uploadwarning'
- }, success: function( data ) {
+ }, success: function ( data ) {
if ( data && data.query && data.query.pages ) {
var pages = data.query.pages;
// warningText( fileItem, pages[Object.keys(
pages )[0]].imageinfo[0].html ); // .keys possible in ie8
- $.each( pages, function( index, val ) {
+ $.each( pages, function ( index, val ) {
warningText( fileItem,
val.imageinfo[0].html );
return false; // Break out
});
} else {
warningText( fileItem, 'Error: Unknown result
from API.' );
}
- }, error: function() {
+ }, error: function () {
warningText( fileItem, 'Error: Request failed.' );
}});
} else {
@@ -83,17 +92,17 @@
'class': 'check-index',
'type': 'checkbox',
'checked': file.cat
- }).change( function() {
+ }).change( function () {
file.cat = this.checked; // Save
}).appendTo( file.li );
$( '<span/>' ).attr( 'class', 'check-span' ).text(
wgPageName.replace( /_/g, ' ' ) ).appendTo( file.li );
}
- file.li.title.mouseover( function() {
+ file.li.title.mouseover( function () {
$( this ).addClass( 'title_over' );
- }).mouseleave( function() {
+ }).mouseleave( function () {
$( this ).removeClass( 'title_over' );
- }).click( function() {
+ }).click( function () {
$( this ).hide();
var inputChange = $( '<input/>' ).attr({
//'id': 'input-change-' + file.id,
@@ -103,7 +112,7 @@
'value': file.name
}).insertAfter( $( this ) );
- inputChange.change( function() {
+ inputChange.change( function () {
file.name = this.value; // save new name
checkUploadWarning( this.value,file.li );
});
@@ -124,7 +133,7 @@
// file.li.type.addClass( 'picture' );
try { // preview picture
var img = new o.Image();
- img.onload = function() {
+ img.onload = function () {
// embed the current thumbnail
this.embed( file.li.type.get( 0
), {
width: 30,
@@ -148,14 +157,14 @@
}
checkUploadWarning( file.name, file.li );
- file.li.cancel = $( '<span/>' ).attr( 'title', mw.msg(
'msu-cancel-upload' ) ).click( function() {
+ file.li.cancel = $( '<span/>' ).attr( 'title', mw.msg(
'msu-cancel-upload' ) ).click( function () {
uploader.removeFile( file );
if ( file.group === 'pic' ) {
var idx = jQuery.inArray( file.name,
galleryArray ); // Find the index ( indexOf not possible in ie8 )
if ( idx!==-1 ) galleryArray.splice( idx, 1 );
// Remove it if really found!
//uploader.trigger( 'CheckFiles', uploader );
// If Picture is removed
}
- file.li.fadeOut( 'slow', function() {
+ file.li.fadeOut( 'slow', function () {
$( this ).remove();
uploader.trigger( 'CheckFiles' );
});
@@ -164,7 +173,7 @@
build( file ); // alles aufbauen
} else { // wrong datatype
- file.li.loading.hide( 1, function() { // create callback
+ file.li.loading.hide( 1, function () { // create callback
uploader.removeFile( file );
uploader.refresh();
});
@@ -173,233 +182,212 @@
}
function createUpload( wikiEditor ) {
- // Create upload button
- var uploadButton = $( '<div/>' ).attr( 'id', 'upload-select' );
- var uploadContainer = $( '<div/>' ).attr({
- 'id': 'upload-container',
- 'title': mw.msg( 'msu-button-title' ),
- 'class': 'start-loading'
- }).append( uploadButton );
+ // Create upload button
+ var uploadButton = $( '<div/>' ).attr( 'id', 'upload-select' );
+ var uploadContainer = $( '<div/>' ).attr({
+ 'id': 'upload-container',
+ 'title': mw.msg( 'msu-button-title' ),
+ 'class': 'start-loading'
+ }).append( uploadButton );
- var uploadDiv = $( '<div/>' ).attr( 'id', 'upload-div' );
- if ( wikiEditor === true ) {
- // Insert upload button
- var uploadTab = $( '<div/>' ).attr( 'class', 'group'
).appendTo( '#wikiEditor-ui-toolbar .section-main' );
- uploadContainer.appendTo( uploadTab );
- // Create upload div
- uploadDiv.insertAfter( '#wikiEditor-ui-toolbar' );
- $( '#wikiEditor-ui-toolbar .tool .options' ).css(
'z-index', '2' ); // Headline dropdown
- } else { // Only standard editor
- uploadContainer.css( 'display', 'inline-block' ).css(
'vertical-align', 'middle' ).appendTo( '#toolbar' );
- uploadButton.addClass( 'old-button' );
- uploadDiv.insertAfter( '#toolbar' );
- }
+ var uploadDiv = $( '<div/>' ).attr( 'id', 'upload-div' );
+ if ( wikiEditor === true ) {
+ // Insert upload button
+ var uploadTab = $( '<div/>' ).attr( 'class', 'group'
).appendTo( '#wikiEditor-ui-toolbar .section-main' );
+ uploadContainer.appendTo( uploadTab );
+ // Create upload div
+ uploadDiv.insertAfter( '#wikiEditor-ui-toolbar' );
+ $( '#wikiEditor-ui-toolbar .tool .options' ).css( 'z-index',
'2' ); // Headline dropdown
+ } else { // Only standard editor
+ uploadContainer.css( 'display', 'inline-block' ).css(
'vertical-align', 'middle' ).appendTo( '#toolbar' );
+ uploadButton.addClass( 'old-button' );
+ uploadDiv.insertAfter( '#toolbar' );
+ }
- var statusDiv = $( '<div/>' ).attr( 'id', 'upload-status'
).html( 'No runtime found.' ).appendTo( uploadDiv ).hide();
- var uploadList = $( '<ul/>' ).attr( 'id', 'upload-list'
).appendTo( uploadDiv );
- var bottomDiv = $( '<div/>' ).attr( 'id', 'upload-bottom'
).appendTo( uploadDiv ).hide();
- var startButton = $( '<a/>' ).attr( 'id', 'upload-files'
).appendTo( bottomDiv ).hide();
- var spacer1 = $( '<span/>' ).attr( 'class', 'spacer'
).appendTo( bottomDiv ).hide();
- var cleanAll = $( '<a/>' ).attr( 'id', 'cleanAll' ).text(
mw.msg( 'msu-clean-all' ) ).appendTo( bottomDiv ).hide();
- var spacer2 = $( '<span/>' ).attr( 'class', 'spacer'
).appendTo( bottomDiv ).hide();
- var galleryInsert = $( '<a/>' ).attr( 'id', 'gallery-insert'
).appendTo( bottomDiv ).hide();
- var spacer3 = $( '<span/>' ).attr( 'class', 'spacer'
).appendTo( bottomDiv ).hide();
- var filesInsert = $( '<a/>' ).attr( 'id', 'files-insert'
).appendTo( bottomDiv ).hide();
- var uploadDrop = $( '<div/>' ).attr( 'id', 'upload-drop'
).insertAfter( statusDiv ).hide();
+ var statusDiv = $( '<div/>' ).attr( 'id', 'upload-status' ).html( 'No
runtime found.' ).appendTo( uploadDiv ).hide();
+ var uploadList = $( '<ul/>' ).attr( 'id', 'upload-list' ).appendTo(
uploadDiv );
+ var bottomDiv = $( '<div/>' ).attr( 'id', 'upload-bottom' ).appendTo(
uploadDiv ).hide();
+ var startButton = $( '<a/>' ).attr( 'id', 'upload-files' ).appendTo(
bottomDiv ).hide();
+ var spacer1 = $( '<span/>' ).attr( 'class', 'spacer' ).appendTo(
bottomDiv ).hide();
+ var cleanAll = $( '<a/>' ).attr( 'id', 'cleanAll' ).text( mw.msg(
'msu-clean-all' ) ).appendTo( bottomDiv ).hide();
+ var spacer2 = $( '<span/>' ).attr( 'class', 'spacer' ).appendTo(
bottomDiv ).hide();
+ var galleryInsert = $( '<a/>' ).attr( 'id', 'gallery-insert'
).appendTo( bottomDiv ).hide();
+ var spacer3 = $( '<span/>' ).attr( 'class', 'spacer' ).appendTo(
bottomDiv ).hide();
+ var filesInsert = $( '<a/>' ).attr( 'id', 'files-insert' ).appendTo(
bottomDiv ).hide();
+ var spacer4 = $( '<span/>' ).attr( 'class', 'spacer' ).appendTo(
bottomDiv ).hide();
+ var linksInsert = $( '<a/>' ).attr( 'id', 'links-insert' ).appendTo(
bottomDiv ).hide();
+ var uploadDrop = $( '<div/>' ).attr( 'id', 'upload-drop' ).insertAfter(
statusDiv ).hide();
- var uploader = new plupload.Uploader({
- 'runtimes': 'html5,flash,silverlight,html4',
- 'browse_button': 'upload-select',
- 'container': 'upload-container',
- 'max_file_size': '100mb',
- 'drop_element': 'upload-drop',
- //'unique_names': true,
- //'multipart': false, // evtl i
- //'resize': { 'width': 320, 'height': 240, 'quality':
90 }, // Resize pictures
- /* Specify what files to browse for
- 'filters': [
- { 'title': 'Image files', 'extensions':
'jpg,gif,png' },
- { 'title': 'Zip files', 'extensions': 'zip' }
- ], */
- 'url': msuVars.path + '/../../api.php',
- 'flash_swf_url': msuVars.path + '/plupload/Moxie.swf',
- 'silverlight_xap_url': msuVars.path +
'/plupload/Moxie.xap'
- });
+ var uploader = new plupload.Uploader({
+ 'runtimes': 'html5,flash,silverlight,html4',
+ 'browse_button': 'upload-select',
+ 'container': 'upload-container',
+ 'max_file_size': '100mb',
+ 'drop_element': 'upload-drop',
+ //'unique_names': true,
+ //'multipart': false, // evtl i
+ //'resize': { 'width': 320, 'height': 240, 'quality': 90 }, //
Resize pictures
+ /* Specify what files to browse for
+ 'filters': [
+ { 'title': 'Image files', 'extensions': 'jpg,gif,png' },
+ { 'title': 'Zip files', 'extensions': 'zip' }
+ ], */
+ 'url': msuVars.path + '/../../api.php',
+ 'flash_swf_url': msuVars.path + '/plupload/Moxie.swf',
+ 'silverlight_xap_url': msuVars.path + '/plupload/Moxie.xap'
+ });
- uploader.bind( 'PostInit', function( up ) {
- mw.log( 'MsUpload DEBUG: runtime: ' + up.runtime + '
features: ' + JSON.stringify( up.features ) );
- uploadContainer.removeClass( 'start-loading' );
- if ( up.features.dragdrop && msuVars.useDragDrop ) {
- uploadDrop.text( mw.msg( 'msu-dropzone' )
).show();
- uploadDrop.bind( 'dragover',function() {
- $( this ).addClass( 'drop-over' ).css(
'padding', '20px' );
- }).bind( 'dragleave',function() {
- $( this ).removeClass( 'drop-over'
).css( 'padding', 0 );
- }).bind( 'drop',function() {
- $( this ).removeClass( 'drop-over'
).css( 'padding', 0 );
- });
- } else {
- uploadDiv.addClass( 'nodragdrop' );
- }
- });
-
- uploader.bind( 'FilesAdded', function( up, files ) {
- $.each( files, function( i, file ) {
- // iOS6 by SLBoat
- if ( ( navigator.platform === 'iPad' ||
navigator.platform === 'iPhone' ) ) {
- if ( file.name.indexOf( 'image' ) > -1
&& file.name.length < 11 ) {
- var heute = new Date();
- var fileNameApple =
navigator.platform + '_image_' + heute.getFullYear() + '-' + heute.getMonth() +
'-' + heute.getDate() + '-' + heute.getTime(); // Because each image is named
'image.jpg' in iOS6
- file.name = fileNameApple + '_'
+ i + '.' + file.name.split( '.' ).pop(); // image_Y-M-D_0.jpg
- }
- }
- file.li = $( '<li/>' ).attr( 'id',file.id
).attr( 'class', 'file' ).appendTo( uploadList );
- file.li.type = $( '<span/>' ).attr( 'class',
'file-type' ).appendTo( file.li );
- file.li.title = $( '<span/>' ).attr( 'class',
'file-title' ).text( file.name ).appendTo( file.li );
- file.li.size = $( '<span/>' ).attr( 'class',
'file-size' ).text( plupload.formatSize( file.size ) ).appendTo( file.li );
- file.li.loading = $( '<span/>' ).attr( 'class',
'file-loading' ).appendTo( file.li );
- file.li.warning = $( '<span/>' ).attr( 'class',
'file-warning' ).appendTo( file.li );
- checkExtension( file, up );
+ uploader.bind( 'PostInit', function ( up ) {
+ mw.log( 'MsUpload DEBUG: runtime: ' + up.runtime + ' features:
' + JSON.stringify( up.features ) );
+ uploadContainer.removeClass( 'start-loading' );
+ if ( up.features.dragdrop && msuVars.useDragDrop ) {
+ uploadDrop.text( mw.msg( 'msu-dropzone' ) ).show();
+ uploadDrop.bind( 'dragover',function () {
+ $( this ).addClass( 'drop-over' ).css(
'padding', '20px' );
+ }).bind( 'dragleave',function () {
+ $( this ).removeClass( 'drop-over' ).css(
'padding', 0 );
+ }).bind( 'drop',function () {
+ $( this ).removeClass( 'drop-over' ).css(
'padding', 0 );
});
- up.refresh(); // Reposition Flash/Silverlight
- up.trigger( 'CheckFiles' );
- });
+ } else {
+ uploadDiv.addClass( 'nodragdrop' );
+ }
+ });
- uploader.bind( 'QueueChanged', function( up ) {
- up.trigger( 'CheckFiles' );
- });
-
- uploader.bind( 'StateChanged', function( up ) {
- mw.log( up.state );
- if ( up.files.length === ( up.total.uploaded +
up.total.failed ) ) {
- //mw.log( 'State: ' + up.files.length ) // All
files uploaded --> trigger
- }
- });
-
- uploader.bind( 'FilesRemoved', function( up, files ) {
- mw.log( 'Files removed' );
- //uploader.trigger( 'CheckFiles', up );
- });
-
- uploader.bind( 'BeforeUpload', function( up, file ) {
- file.li.title.text( file.name ).show(); // Show title
- $( '#' + file.id + ' input.input-change' ).hide(); //
Hide input
- up.settings.multipart_params = {
- 'filename': file.name,
- 'token': mw.user.tokens.get( 'editToken' ),
- 'action': 'upload',
- 'ignorewarnings': true,
- 'comment': mw.msg( 'msu-comment' ),
- 'format': 'json'
- }; // Set multipart_params
- $( '#' + file.id + ' div.file-progress-bar'
).progressbar({ value: '1' });
- $( '#' + file.id + ' span.file-progress-state' ).html(
'0%' );
- });
-
- uploader.bind( 'UploadProgress', function(up, file) {
- $( '#' + file.id + ' span.file-progress-state' ).html(
file.percent + '%' );
- $( '#' + file.id + ' div.file-progress-bar'
).progressbar({ 'value': file.percent });
- $( '#' + file.id + ' div.file-progress-bar
.ui-progressbar-value' ).removeClass( 'ui-corner-left' );
- });
-
- uploader.bind( 'Error', function( up, err ) {
- $( '#' + err.file.id + ' span.file-warning' ).html(
- 'Error: ' + err.code + ', Message: ' +
err.message + ( err.file ? ', File: ' + err.file.name : '' )
- );
- statusDiv.append( err.message );
- up.refresh(); // Reposition Flash/Silverlight
- });
-
- uploader.bind( 'FileUploaded', function( up, file, success ) {
- mw.log( success );
- file.li.title.unbind( 'click' );
- file.li.title.unbind( 'mouseover' );
- $( '#' + file.id + ' div.file-progress' ).fadeOut(
'slow' );
- $( '#' + file.id + ' div.file-progress-bar' ).fadeOut(
'slow' );
- $( '#' + file.id + ' span.file-progress-state'
).fadeOut( 'slow' );
-
- try {
- var result = jQuery.parseJSON( success.response
);
- if ( result.error ) {
- //{ 'servedby': 'abc-alpha', 'error':
{'code': 'nofilename', 'info': 'The filename parameter must be set' }}
- fileError( up, file, result.error.info
);
- } else {
- //mw.log( result.upload.result );
- /*{'upload': {'result': 'Success',
- 'filename': 'Msupload_v8.4.jpg',
- 'imageinfo': {
- 'timestamp': '2012-02-28T14:52:05Z',
- 'user': 'L\u00fctz',
- 'userid': 4,
- 'size': 35491,
- 'width': 865,
- 'height': 292,
- 'parsedcomment': 'MsUpload',
- 'comment': 'MsUpload',
- 'url': '...',
- 'descriptionurl': '...',
- 'sha1': '...',
- 'metadata': ...,
- 'mime': 'image\/jpeg',
- 'mediatype': 'BITMAP',
- 'bitdepth': 8
- }}}*/
-
- file.li.type.addClass( 'ok' );
- file.li.addClass( 'green' );
- file.li.warning.fadeOut( 'slow' );
-
- if ( file.cat && wgNamespaceNumber ===
14 ) { // should the categroy be set?
- $.get( mw.util.wikiScript(), {
action: 'ajax', rs: 'MsUpload::saveCat', rsargs: [ file.name, wgPageName ] } ,
'json' );
- }
- $( '<a/>' ).text( mw.msg(
'msu-insert-link' ) ).click( function() {
- if ( msuVars.useMsLinks ===
true ) {
- mw.toolbar.insertTags(
'{{#l:' + file.name + '}}', '', '', '' ); // Insert link
- } else {
- mw.toolbar.insertTags(
'[[:File:' + file.name + ']]', '', '', '' ); // Insert link
- }
- }).appendTo( file.li );
- if ( file.group === 'pic' ) {
-
//file.li.type.addClass('picture_load'); // preview -> no need for this any more
- //file.li.type.html('<img
src="'+result.upload.imageinfo.url+'" height="18">');
- galleryArray.push( file.name );
- if ( galleryArray.length === 2
) { // Only at first time add click function
- galleryInsert.click(
function() {
- addGallery();
// To take always the current list
- }).text( mw.msg(
'msu-insert-gallery' ) ).show();
- filesInsert.click(
function() {
- addFiles(); //
To take always the current list
- }).text( mw.msg(
'msu-insert-files' ) ).show();
- } else if ( galleryArray.length
< 2 ) {
- galleryInsert.html( ''
);
- }
- $( '<span/>' ).text( ' | '
).appendTo( file.li );
- $( '<a/>' ).text(
mw.msg('msu-insert-picture' ) ).click( function() {
- mw.toolbar.insertTags(
'[[File:' + file.name + msuVars.imgParams + ']]', '', '', '' );
- }).appendTo( file.li );
- } else if ( file.group === 'mov' ) {
- $( '<span/>' ).text(' |
').appendTo( file.li );
- $( '<a/>' ).text( mw.msg(
'msu-insert-movie' ) ).click( function() {
- mw.toolbar.insertTags(
'[[File:' + file.name + ']]', '', '', '' );
- }).appendTo( file.li );
- }
+ uploader.bind( 'FilesAdded', function ( up, files ) {
+ $.each( files, function ( i, file ) {
+ // iOS6 by SLBoat
+ if ( ( navigator.platform === 'iPad' ||
navigator.platform === 'iPhone' ) ) {
+ if ( file.name.indexOf( 'image' ) > -1 &&
file.name.length < 11 ) {
+ var heute = new Date();
+ var fileNameApple = navigator.platform
+ '_image_' + heute.getFullYear() + '-' + heute.getMonth() + '-' +
heute.getDate() + '-' + heute.getTime(); // Because each image is named
'image.jpg' in iOS6
+ file.name = fileNameApple + '_' + i +
'.' + file.name.split( '.' ).pop(); // image_Y-M-D_0.jpg
}
+ }
+ file.li = $( '<li/>' ).attr( 'id',file.id ).attr(
'class', 'file' ).appendTo( uploadList );
+ file.li.type = $( '<span/>' ).attr( 'class',
'file-type' ).appendTo( file.li );
+ file.li.title = $( '<span/>' ).attr( 'class',
'file-title' ).text( file.name ).appendTo( file.li );
+ file.li.size = $( '<span/>' ).attr( 'class',
'file-size' ).text( plupload.formatSize( file.size ) ).appendTo( file.li );
+ file.li.loading = $( '<span/>' ).attr( 'class',
'file-loading' ).appendTo( file.li );
+ file.li.warning = $( '<span/>' ).attr( 'class',
'file-warning' ).appendTo( file.li );
+ checkExtension( file, up );
+ });
+ up.refresh(); // Reposition Flash/Silverlight
+ up.trigger( 'CheckFiles' );
+ });
+
+ uploader.bind( 'QueueChanged', function ( up ) {
+ up.trigger( 'CheckFiles' );
+ });
+
+ uploader.bind( 'StateChanged', function ( up ) {
+ mw.log( up.state );
+ if ( up.files.length === ( up.total.uploaded + up.total.failed
) ) {
+ //mw.log( 'State: ' + up.files.length ) // All files
uploaded --> trigger
+ }
+ });
+
+ uploader.bind( 'FilesRemoved', function ( up, files ) {
+ mw.log( 'Files removed' );
+ //uploader.trigger( 'CheckFiles', up );
+ });
+
+ uploader.bind( 'BeforeUpload', function ( up, file ) {
+ file.li.title.text( file.name ).show(); // Show title
+ $( '#' + file.id + ' input.input-change' ).hide(); // Hide input
+ up.settings.multipart_params = {
+ 'filename': file.name,
+ 'token': mw.user.tokens.get( 'editToken' ),
+ 'action': 'upload',
+ 'ignorewarnings': true,
+ 'comment': mw.msg( 'msu-comment' ),
+ 'format': 'json'
+ }; // Set multipart_params
+ $( '#' + file.id + ' div.file-progress-bar' ).progressbar({
value: '1' });
+ $( '#' + file.id + ' span.file-progress-state' ).html( '0%' );
+ });
+
+ uploader.bind( 'UploadProgress', function (up, file) {
+ $( '#' + file.id + ' span.file-progress-state' ).html(
file.percent + '%' );
+ $( '#' + file.id + ' div.file-progress-bar' ).progressbar({
'value': file.percent });
+ $( '#' + file.id + ' div.file-progress-bar
.ui-progressbar-value' ).removeClass( 'ui-corner-left' );
+ });
+
+ uploader.bind( 'Error', function ( up, err ) {
+ $( '#' + err.file.id + ' span.file-warning' ).html(
+ 'Error: ' + err.code + ', Message: ' + err.message + (
err.file ? ', File: ' + err.file.name : '' )
+ );
+ statusDiv.append( err.message );
+ up.refresh(); // Reposition Flash/Silverlight
+ });
+
+ uploader.bind( 'FileUploaded', function ( up, file, success ) {
+ mw.log( success );
+ file.li.title.unbind( 'click' );
+ file.li.title.unbind( 'mouseover' );
+ $( '#' + file.id + ' div.file-progress' ).fadeOut( 'slow' );
+ $( '#' + file.id + ' div.file-progress-bar' ).fadeOut( 'slow' );
+ $( '#' + file.id + ' span.file-xprogress-state' ).fadeOut(
'slow' );
+
+ try {
+ var result = jQuery.parseJSON( success.response );
+ if ( result.error ) {
+ fileError( up, file, result.error.info );
+ } else {
+ file.li.type.addClass( 'ok' );
+ file.li.addClass( 'green' );
+ file.li.warning.fadeOut( 'slow' );
+
+ if ( file.cat && wgNamespaceNumber === 14 ) {
// Should the categroy be set?
+ $.get( mw.util.wikiScript(), {
+ action: 'ajax',
+ rs: 'MsUpload::saveCat',
+ rsargs: [ file.name, wgPageName
]
+ }, 'json' );
+ }
+ $( '<a/>' ).text( mw.msg( 'msu-insert-link' )
).click( function () {
+ if ( msuVars.useMsLinks === true ) {
+ mw.toolbar.insertTags( '{{#l:'
+ file.name + '}}', '', '', '' ); // Insert link
+ } else {
+ mw.toolbar.insertTags(
'[[:File:' + file.name + ']]', '', '', '' ); // Insert link
+ }
+ }).appendTo( file.li );
+ if ( file.group === 'pic' ) {
+ galleryArray.push( file.name );
+ if ( galleryArray.length === 2 ) { //
Bind click function only the first time
+ galleryInsert.click( addGallery
).text( mw.msg( 'msu-insert-gallery' ) ).show();
+ }
+ $( '<span/>' ).text( ' | ' ).appendTo(
file.li );
+ $( '<a/>' ).text(
mw.msg('msu-insert-picture' ) ).click( function () {
+ mw.toolbar.insertTags(
'[[File:' + file.name + msuVars.imgParams + ']]', '', '', '' );
+ }).appendTo( file.li );
+ } else if ( file.group === 'mov' ) {
+ $( '<span/>' ).text(' | ').appendTo(
file.li );
+ $( '<a/>' ).text( mw.msg(
'msu-insert-movie' ) ).click( function () {
+ mw.toolbar.insertTags(
'[[File:' + file.name + ']]', '', '', '' );
+ }).appendTo( file.li );
+ }
+ filesArray.push( file.name );
+ if ( filesArray.length === 2 ) { // Bind click
function only the first time
+ filesInsert.click( addFiles ).text(
mw.msg( 'msu-insert-files' ) ).show();
+ linksInsert.click( addLinks ).text(
mw.msg( 'msu-insert-links' ) ).show();
+ }
+ }
} catch( error ) {
fileError( up, file, 'Error: ' +
success.response.replace( /(<([^>]+)>)/ig, '' ) ); // Remove html tags
}
up.removeFile( file ); // For preventing a second upload
afterwards
});
- uploader.bind( 'UploadComplete', function( up, files ) {
+ uploader.bind( 'UploadComplete', function ( up, files ) {
uploader.trigger( 'CheckFiles' ); // trigger --> state changed
//startButton.hide();
});
- uploader.bind( 'CheckFiles', function() {
+ uploader.bind( 'CheckFiles', function () {
var fileLen = uploader.files.length;
- var galleryLen = galleryArray.length;
var listLen = $( '#upload-list li' ).length;
- mw.log( 'files:' + fileLen + ' gallery:' + galleryLen + ' list:
' + listLen );
+ mw.log( 'files:' + fileLen + ' gallery:' + galleryArray.length
+ ' list: ' + listLen );
if ( fileLen > 0 ) {
bottomDiv.show();
@@ -414,11 +402,21 @@
spacer1.hide();
}
- if ( galleryLen >= 2 ) {
+ if ( filesArray.length > 1 ) {
+ filesInsert.show();
+ spacer3.show();
+ linksInsert.show();
+ spacer4.show();
+ } else {
+ filesInsert.hide();
+ spacer3.hide();
+ linksInsert.hide();
+ spacer4.hide();
+ }
+
+ if ( galleryArray.length > 1 ) {
spacer2.show();
galleryInsert.show();
- spacer3.show();
- filesInsert.show();
bottomDiv.show();
} else {
galleryInsert.hide();
@@ -427,16 +425,16 @@
if ( listLen > 0 ) {
bottomDiv.show();
- cleanAll.text( mw.msg( 'msu-clean-all' ) ).click(
function() {
- galleryArray.length = 0; // reset
+ cleanAll.text( mw.msg( 'msu-clean-all' ) ).click(
function () {
+ galleryArray.length = 0; // Reset
uploader.splice( 0, uploader.files.length );
- $( '#upload-list .file' ).hide( 'slow',
function() {
- $(this).remove();
- $(this).hide(); // clear_all button
+ $( '#upload-list .file' ).hide( 'slow',
function () {
+ $( this ).remove();
+ $( this ).hide(); // clear_all button
galleryInsert.unbind( 'click' );
bottomDiv.hide();
});
- //uploader.trigger("CheckFiles", uploader);
+ //uploader.trigger( 'CheckFiles', uploader );
}).show();
} else {
bottomDiv.hide();
@@ -444,12 +442,12 @@
uploader.refresh(); // Reposition Flash/Silverlight
});
- $( '#upload-files' ).click( function( event ) {
+ $( '#upload-files' ).click( function ( event ) {
uploader.start();
event.preventDefault();
});
/*
- $( 'uploadfiles' ).onclick = function() {
+ $( 'uploadfiles' ).onclick = function () {
uploader.start();
return false;
};
diff --git a/MsUpload.php b/MsUpload.php
index e724188..b80872f 100644
--- a/MsUpload.php
+++ b/MsUpload.php
@@ -3,10 +3,10 @@
$wgExtensionCredits['parserhook'][] = array(
'name' => 'MsUpload',
'url' => 'http://www.mediawiki.org/wiki/Extension:MsUpload',
- 'version' => 10,
- 'license-name' => 'GPLv2+',
- 'author' => array( '[mailto:[email protected] Martin Schwindl]',
'[https://www.mediawiki.org/wiki/User:Luis_Felipe_Schenone Luis Felipe
Schenone]' ),
+ 'version' => '10.0',
'descriptionmsg' => 'msu-desc',
+ 'license-name' => 'GPLv2+',
+ 'author' => array( '[mailto:[email protected] Martin Schwindl]',
'[mailto:[email protected] Martin Keyler]',
'[https://www.mediawiki.org/wiki/User:Luis_Felipe_Schenone Luis Felipe
Schenone]' ),
);
$wgResourceModules['ext.MsUpload'] = array(
@@ -17,11 +17,12 @@
'dependencies' => 'jquery.ui.progressbar',
'styles' => 'MsUpload.css',
'messages' => array(
- 'msu-desc',
+ 'msu-description',
'msu-button-title',
'msu-insert-link',
'msu-insert-gallery',
'msu-insert-files',
+ 'msu-insert-links',
'msu-insert-picture',
'msu-insert-movie',
'msu-cancel-upload',
@@ -46,9 +47,9 @@
$wgAjaxExportList[] = 'MsUpload::saveCat';
-//Configuration defaults
+// Default configuration
$wgMSU_useDragDrop = true;
$wgMSU_showAutoCat = true;
$wgMSU_checkAutoCat = true;
-$wgMSU_imgParams = '';
+$wgMSU_imgParams = '400px';
$wgMSU_useMsLinks = false;
\ No newline at end of file
diff --git a/README.md b/README.md
index 3ed9f09..848f302 100755
--- a/README.md
+++ b/README.md
@@ -3,25 +3,25 @@
Installation
------------
-To install, add the following to your LocalSettings.php:
+To install MsUpload, add the following to your LocalSettings.php:
-# Start------------------------MsUpload
# If necessary, adjust the global configuration:
$wgEnableWriteAPI = true; // Enable the API
$wgEnableUploads = true; // Enable uploads
$wgFileExtensions =
array('png','gif','jpg','jpeg','doc','xls','mpp','pdf','ppt','tiff','bmp','docx',
'xlsx','pptx','ps','odt','ods','odp','odg');
+$wgAllowJavaUploads = true; // Solves problem with Office 2007 and newer files
(docx, xlsx, etc.)
# Then include the extension and set its configuration. The values shown below
are the defaults:
require_once "$IP/extensions/MsUpload/MsUpload.php";
$wgMSU_useDragDrop = true;
$wgMSU_showAutoCat = true;
$wgMSU_checkAutoCat = true;
-$wgMSU_imgParams = '';
+$wgMSU_imgParams = '400px'; // Default 400px
$wgMSU_useMsLinks = false;
-# Start------------------------MsUpload
Credits
-------
-* Created by Martin Schwindl, [email protected]
-* Updated, debugged and normalised by Luis Felipe Schenone
([email protected]) in 2014
-* Some icons by Yusuke Kamiyamane. All rights reserved. Licensed under a
Creative Commons Attribution 3.0 License. http://p.yusukekamiyamane.com
\ No newline at end of file
+* Developed and coded by Martin Schwindl ([email protected])
+* Idea, project management and bug fixing by Martin Keyler
([email protected])
+* Updated, debugged and enhanced by Luis Felipe Schenone ([email protected])
+* Some icons by Yusuke Kamiyamane (http://p.yusukekamiyamane.com). All rights
reserved. Licensed under a Creative Commons Attribution 3.0 License.
\ No newline at end of file
diff --git a/i18n/de.json b/i18n/de.json
index ad3fa2e..496afbc 100644
--- a/i18n/de.json
+++ b/i18n/de.json
@@ -7,8 +7,9 @@
"msu-desc": "Ermöglicht einfache Uploads (wenn verfügbar auch per
drag&drop) für eine oder mehrere Dateien gleichzeitig",
"msu-button-title": "Datei(en) auswählen",
"msu-insert-link": "als Link einfügen",
- "msu-insert-gallery": "Bilder als Gallery einfügen",
- "msu-insert-files": "Bilder als Gallerie einfügen",
+ "msu-insert-gallery": "Alle als Gallerie einfügen",
+ "msu-insert-files": "Alle als Bild einfügen",
+ "msu-insert-links": "Alle als Link einfügen",
"msu-insert-picture": "als Bild einfügen",
"msu-insert-movie": "als Film einfügen",
"msu-cancel-upload": "Upload abbrechen",
diff --git a/i18n/en.json b/i18n/en.json
index 882ff89..c89b5af 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -9,8 +9,9 @@
"msu-desc": "Enables easy uploads (when available also via drag&drop)
for one or multiple files simultaneously",
"msu-button-title": "Select files",
"msu-insert-link": "Insert link",
- "msu-insert-gallery": "Insert pictures as gallery",
- "msu-insert-files": "Insert pictures as files",
+ "msu-insert-gallery": "Insert all as gallery",
+ "msu-insert-files": "Insert all as files",
+ "msu-insert-links": "Insert all as links",
"msu-insert-picture": "Insert picture",
"msu-insert-movie": "Insert movie",
"msu-cancel-upload": "Cancel upload",
diff --git a/i18n/es.json b/i18n/es.json
index 5e6af2b..eb00dde 100644
--- a/i18n/es.json
+++ b/i18n/es.json
@@ -7,8 +7,9 @@
"msu-desc": "Permite la transferencia sencilla (si está disponible
también a través de arrastrar y soltar) para uno o varios archivos al mismo
tiempo",
"msu-button-title": "Seleccione los archivos",
"msu-insert-link": "Inserte el link",
- "msu-insert-gallery": "Insertar imagenes como galería",
- "msu-insert-files": "Insertar imagenes como archivos",
+ "msu-insert-gallery": "Insertar todo como galería",
+ "msu-insert-files": "Insertar todo como archivos",
+ "msu-insert-links": "Insertar todo como enlaces",
"msu-insert-picture": "Inserte la imagen",
"msu-insert-movie": "Inserte la película",
"msu-cancel-upload": "Cancelar carga",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 85c6874..c55c7ca 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -7,8 +7,9 @@
"msu-desc":
"{{desc|name=MsUpload|url=https://www.mediawiki.org/wiki/Extension:MsUpload}}",
"msu-button-title": "Button for selecting files from the users
computer.",
"msu-insert-link": "Button for inserting a file link into the
wikitext.",
- "msu-insert-gallery": "Button for inserting a gallery into the
wikitext.",
- "msu-insert-files": "Button for inserting a series of file links into
the wikitext.",
+ "msu-insert-gallery": "Button for inserting a gallery with all the
uploaded files into the wikitext.",
+ "msu-insert-files": "Button for inserting calls to all the uploaded
files into the wikitext.",
+ "msu-insert-links": "Button for inserting links to all the uploaded
files into the wikitext.",
"msu-insert-picture": "Button for inserting a file into the wikitext",
"msu-insert-movie": "Button for inserting a movie",
"msu-cancel-upload": "Button for canceling an upload",
--
To view, visit https://gerrit.wikimedia.org/r/176835
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ieca40af54fba7e4af39033876b53171931b19225
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MsUpload
Gerrit-Branch: master
Gerrit-Owner: Luis Felipe Schenone <[email protected]>
Gerrit-Reviewer: Luis Felipe Schenone <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits