From: Michael Dale Date: Sat, 7 Nov 2009 11:12:12 +0000 (+0000) Subject: * basic subtitle support (via wikiTitleKey) X-Git-Tag: 1.31.0-rc.0~38924 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=57495d55eee18eeff99e081a47ded507fadb6124;p=lhc%2Fweb%2Fwiklou.git * basic subtitle support (via wikiTitleKey) * some language test updates * drag drop support stubs * language updates for add media wizard search --- diff --git a/js2/editPage.js b/js2/editPage.js index 936dc2d264..8e41461b3d 100644 --- a/js2/editPage.js +++ b/js2/editPage.js @@ -59,4 +59,6 @@ js2AddOnloadHook( function() { $j(".tool [rel='file']").addMediaWiz( amwConf ); } }, 120) + //drag drop for editbar: + //$j('textarea#wpTextbox1').dragFileUpload(); }); diff --git a/js2/mwEmbed/libAddMedia/dragDropFile.js b/js2/mwEmbed/libAddMedia/dragDropFile.js index a033b8c6fa..f4250876ef 100644 --- a/js2/mwEmbed/libAddMedia/dragDropFile.js +++ b/js2/mwEmbed/libAddMedia/dragDropFile.js @@ -1,11 +1,15 @@ /* firefox 3.6 drag-drop uploading */ -var TCNDDU = TCNDDU || {}; - -(function( $ ) { - $.dragDropFile = function ( selector ) { +loadGM({ + "mwe-upload-multi" : "Upload {{PLURAL:$1|file|files}}", + "mwe-review-upload": "Review File {{PLURAL:$1|Upload|Uploads}}" +}); + +(function($){ + $.fn.dragDropFile = function () { + js_log("drag drop: " + this.selector); //setup drag binding and highlight - var dC = $j( selector ).get(0); + var dC = $j( this.selector ).get(0); dC.addEventListener("dragenter", function(event){ $j(dC).css('border', 'solid red'); @@ -26,50 +30,71 @@ var TCNDDU = TCNDDU || {}; }, false); dC.addEventListener("drop", function( event ){ - //for some reason scope does not persist for events so here we go: doDrop( event ); - //handle the drop loader and call event - + //handle the drop loader and call event }, false); - function doDrop(event){ - var dt = event.dataTransfer, - files = dt.files, - imgPreviewFragment = document.createDocumentFragment(), - count = files.length, - domElements; - - event.stopPropagation(); - event.preventDefault(); - // ( error out if they dragged multiple files for now) - if( files.length > 1 ){ - js_log( 'errro multiple files'); + function doDrop(event){ + var dt = event.dataTransfer, + files = dt.files, + fileCount = files.length; + + event.stopPropagation(); + event.preventDefault(); + + $j('#multiple_file_input').remove(); - return false; - } - for (var i = 0; i < count; i++) { - if(files[i].fileSize < 1048576) { - domElements = [ - document.createElement('li'), - document.createElement('a'), - document.createElement('img') - ]; + $j('body').append('
'+ + '
'); + - domElements[2].src = files[i].getAsDataURL(); // base64 encodes local file(s) - domElements[2].width = 300; - domElements[2].height = 200; - domElements[1].appendChild(domElements[2]); - domElements[0].id = "item"+i; - domElements[0].appendChild(domElements[1]); - - imgPreviewFragment.appendChild(domElements[0]); - - dropListing.appendChild(imgPreviewFragment); - - TCNDDU.processXHR(files.item(i), i); - } else { - alert("file is too big, needs to be below 1mb"); - } + var cBtn = {}; + cBtn[ gM('mwe-cancel') ] = function(){ + $j(this).dialog('close'); + } + cBtn[ gM('mwe-upload-multi', fileCount) ] = function(){ + alert('do multiple file upload'); + } + //open up the dialog + $j('#multiple_file_input').dialog({ + bgiframe: true, + autoOpen: true, + modal: true, + draggable:false, + resizable:false, + buttons:cBtn + }); + $j('#multiple_file_input').dialogFitWindow(); + $j(window).resize(function(){ + $j('#multiple_file_input').dialogFitWindow(); + }); + //add the inital table / title: + $j('#multiple_file_input').html('

' + gM('mwe-review-upload') + '

'+ + '
'); + $j.each(files, function(i, file){ + if(file.fileSize < 64048576) { + $j('#multiple_file_input .table_list').append( + '' + + '' +''+ + '' + + 'File Name:
'+ + 'File Desc:
'+ + ''+ + '' + ); + /*$j.addDialog( "upload this image", '' + + '
name: ' + files[i].name + '
' + + '
size: ' + files[i].fileSize + '
' + + '
mime: ' + files[i].mediaType + '
'); + */ + //do the add-media-wizard with the upload tab + } else { + alert("file is too big, needs to be below 64mb"); + } + }); } } - -})(window.$mw); +})(jQuery); + + diff --git a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js index 4bab6f628a..4a6a10d684 100644 --- a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js @@ -525,7 +525,7 @@ remoteSearchDriver.prototype = { js_log('got caret_pos:' + this.caret_pos.s); //restore text value: (creating textRanges sometimes screws with the text content) - $j(this.target_textbox).val(this.caret_pos.text); + $j(this.target_textbox).val( this.caret_pos.text ); }, init_modal:function(){ js_log("init_modal"); @@ -541,13 +541,7 @@ remoteSearchDriver.prototype = { var cBtn = {}; cBtn[ gM('mwe-cancel') ] = function(){ _this.cancelClipEditCB(); - } - function doResize(){ - js_log('do resize:: ' + _this.target_container); - $j( '#rsd_modal_target').dialog('option', 'width', $j(window).width()-50 ); - $j( '#rsd_modal_target').dialog('option', 'height', $j(window).height()-50 ); - $j( '#rsd_modal_target').dialog('option', 'position','center'); - } + } $j(_this.target_container).dialog({ bgiframe: true, @@ -563,22 +557,13 @@ remoteSearchDriver.prototype = { $j(this).parents('.ui-dialog').fadeOut('slow'); } }); - doResize(); + $j(_this.target_container).dialogFitWindow(); $j(window).resize(function(){ - doResize(); - }); - + $j(_this.target_container).dialogFitWindow(); + }); //add cancel callback and updated button with icon - _this.cancelClipEditCB(); - - //update the child position: (some of this should be pushed up-stream via dialog config options - $j(_this.target_container +'~ .ui-dialog-buttonpane').css({ - 'position':'absolute', - 'left':'0px', - 'right':'0px', - 'bottom':'0px' - }); + _this.cancelClipEditCB(); } }, //sets up the initial html interface @@ -708,7 +693,7 @@ remoteSearchDriver.prototype = { _this.addResourceEditLoader(); //@@note: we have most of what we need in resultData imageinfo cp.sObj.addByTitle( wTitle, function( rObj ){ - //redraw (with added result if new) + //redraw ( with added result if new ) _this.drawOutputResults(); //pull up resource editor: _this.resourceEdit( rObj, $j('#res_upload__' + rObj.id).get(0) ); diff --git a/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js index 9367ce11ae..9ba12330c0 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js @@ -15,9 +15,16 @@ mediaWikiSearch.prototype = { //inherit the cp settings for }, //returns a rObj by title - addByTitle:function( title , callback){ + addByTitle:function( title , callback, redirect_count){ js_log("AddByTitle::" + title); - var _this = this; + var _this = this; + if(!redirect_count) + redirect_count=0; + if(redirect_count > 5){ + js_log('Error: addByTitle too many redirects'); + callback( false ); + return false; + } var reqObj = { 'action':'query', 'titles':'File:'+title, @@ -29,7 +36,24 @@ mediaWikiSearch.prototype = { do_api_req( { 'data':reqObj, 'url':this.cp.api_url - }, function(data){ + }, function(data){ + //check for redirect + for(var i in data.query.pages){ + var page = data.query.pages[i]; + if(page.revisions[0]['*'] && page.revisions[0]['*'].indexOf('#REDIRECT') === 0){ + var re = new RegExp(/[^\[]*\[\[([^\]]*)/); + var pt = page.revisions[0]['*'].match( re ); + if( pt[1] ){ + _this.addByTitle( pt[1], callback, redirect_count++); + return ; + }else{ + js_log('Error: addByTitle could not proccess redirect'); + callback( false ); + return false; + } + } + } + //if not a redirect do the callback directly: callback( _this.addSingleResult(data) ); } ); diff --git a/js2/mwEmbed/libClipEdit/mvClipEdit.js b/js2/mwEmbed/libClipEdit/mvClipEdit.js index 8a08d0c4fe..87ce2255f4 100644 --- a/js2/mwEmbed/libClipEdit/mvClipEdit.js +++ b/js2/mwEmbed/libClipEdit/mvClipEdit.js @@ -29,7 +29,7 @@ loadGM({ "mwe-end_time" : "End time", "mwe-preview_inout" : "Preview in-out points", "mwe-edit-tools" : "Edit tools", - "mwe-inline-description" : "Inline description", + "mwe-inline-description" : "Caption", "mwe-edit-video-tools" : "Edit video tools:", "mwe-duration" : "Duration:" }); diff --git a/js2/mwEmbed/libEmbedVideo/embedVideo.js b/js2/mwEmbed/libEmbedVideo/embedVideo.js index 5a1b7b1f78..74ae795686 100644 --- a/js2/mwEmbed/libEmbedVideo/embedVideo.js +++ b/js2/mwEmbed/libEmbedVideo/embedVideo.js @@ -519,7 +519,7 @@ mediaElement.prototype = this.thumbnail = $j(video_element).attr('poster'); if($j(video_element).attr('wikiTitleKey')) - this.wikiTitleKey=$j(video_element).attr('wikiTitleKey'); + this.wikiTitleKey = $j(video_element).attr('wikiTitleKey'); // Process all inner elements //js_log("inner source count: " + video_element.getElementsByTagName('source').length ); @@ -679,13 +679,13 @@ mediaElement.prototype = }, /** Adds a single mediaSource using the provided element if the element has a 'src' attribute. - @param element {element}