Index: trunk/phase3/js2/editPage.js |
— | — | @@ -24,6 +24,11 @@ |
25 | 25 | var amwConf = $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig ); |
26 | 26 | // kind of tricky, it would be nice to use run on ready "loader" call here |
27 | 27 | var didWikiEditorBind = false; |
| 28 | + |
| 29 | + //setup the drag drop binding (will only work for html5 upload browsers) |
| 30 | + //$j( 'textarea#wpTextbox1' ).dragFileUpload(); |
| 31 | + |
| 32 | + //set up the add-media-wizard binding: |
28 | 33 | if( typeof $j.wikiEditor != 'undefined' ) { |
29 | 34 | $j( 'textarea#wpTextbox1' ).bind( 'wikiEditor-toolbar-buildSection-main', |
30 | 35 | function( e, section ) { |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/dragDropFile.js |
— | — | @@ -0,0 +1,75 @@ |
| 2 | +/* firefox 3.6 drag-drop uploading |
| 3 | +*/ |
| 4 | +var TCNDDU = TCNDDU || {}; |
| 5 | + |
| 6 | +(function( $ ) { |
| 7 | + $.dragDropFile = function ( selector ) { |
| 8 | + //setup drag binding and highlight |
| 9 | + var dC = $j( selector ).get(0); |
| 10 | + dC.addEventListener("dragenter", |
| 11 | + function(event){ |
| 12 | + $j(dC).css('border', 'solid red'); |
| 13 | + event.stopPropagation(); |
| 14 | + event.preventDefault(); |
| 15 | + }, false); |
| 16 | + dC.addEventListener("dragleave", |
| 17 | + function(event){ |
| 18 | + //default textbox css (should be an easy way to do this) |
| 19 | + $j(dC).css('border', ''); |
| 20 | + event.stopPropagation(); |
| 21 | + event.preventDefault(); |
| 22 | + }, false); |
| 23 | + dC.addEventListener("dragover", |
| 24 | + function(event){ |
| 25 | + event.stopPropagation(); |
| 26 | + event.preventDefault(); |
| 27 | + }, false); |
| 28 | + dC.addEventListener("drop", |
| 29 | + function( event ){ |
| 30 | + //for some reason scope does not persist for events so here we go: |
| 31 | + doDrop( event ); |
| 32 | + //handle the drop loader and call event |
| 33 | + |
| 34 | + }, false); |
| 35 | + function doDrop(event){ |
| 36 | + var dt = event.dataTransfer, |
| 37 | + files = dt.files, |
| 38 | + imgPreviewFragment = document.createDocumentFragment(), |
| 39 | + count = files.length, |
| 40 | + domElements; |
| 41 | + |
| 42 | + event.stopPropagation(); |
| 43 | + event.preventDefault(); |
| 44 | + // ( error out if they dragged multiple files for now) |
| 45 | + if( files.length > 1 ){ |
| 46 | + js_log( 'errro multiple files'); |
| 47 | + |
| 48 | + return false; |
| 49 | + } |
| 50 | + for (var i = 0; i < count; i++) { |
| 51 | + if(files[i].fileSize < 1048576) { |
| 52 | + domElements = [ |
| 53 | + document.createElement('li'), |
| 54 | + document.createElement('a'), |
| 55 | + document.createElement('img') |
| 56 | + ]; |
| 57 | + |
| 58 | + domElements[2].src = files[i].getAsDataURL(); // base64 encodes local file(s) |
| 59 | + domElements[2].width = 300; |
| 60 | + domElements[2].height = 200; |
| 61 | + domElements[1].appendChild(domElements[2]); |
| 62 | + domElements[0].id = "item"+i; |
| 63 | + domElements[0].appendChild(domElements[1]); |
| 64 | + |
| 65 | + imgPreviewFragment.appendChild(domElements[0]); |
| 66 | + |
| 67 | + dropListing.appendChild(imgPreviewFragment); |
| 68 | + |
| 69 | + TCNDDU.processXHR(files.item(i), i); |
| 70 | + } else { |
| 71 | + alert("file is too big, needs to be below 1mb"); |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | +})(window.$mw); |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js |
— | — | @@ -508,23 +508,20 @@ |
509 | 509 | //grab the extension: |
510 | 510 | var sf = _this.fogg.sourceFilename; |
511 | 511 | var ext = ''; |
512 | | - if( sf.lastIndexOf('.') != -1){ |
513 | | - ext = sf.substring( sf.lastIndexOf('.')+1 ).toLowerCase(); |
514 | | - } |
| 512 | + if( sf.lastIndexOf('.') != -1) |
| 513 | + ext = sf.substring( sf.lastIndexOf('.')+1 ).toLowerCase(); |
515 | 514 | |
516 | 515 | //set to passthrough to true by default (images, arbitrary files that we want to send with http chunks) |
517 | 516 | this.encoder_settings['passthrough'] = true; |
518 | 517 | |
519 | 518 | //see if we have video or audio: |
520 | | - if( _this.isSourceAudio() || _this.isSourceVideo() ){ |
521 | | - _this.encoder_settings['passthrough'] = false; |
522 | | - } |
| 519 | + if( _this.isSourceAudio() || _this.isSourceVideo() ) |
| 520 | + _this.encoder_settings['passthrough'] = false; |
523 | 521 | |
524 | 522 | //special case see if we already have ogg video: |
525 | | - if( _this.isOggFormat() ){ |
| 523 | + if( _this.isOggFormat() ) |
526 | 524 | _this.encoder_settings['passthrough'] = true; |
527 | | - } |
528 | | - |
| 525 | + |
529 | 526 | js_log('base autoEncoderSettings::' + _this.sourceFileInfo.contentType + ' passthrough:' + _this.encoder_settings['passthrough']); |
530 | 527 | }, |
531 | 528 | isUnknown:function(){ |
Index: trunk/phase3/js2/mwEmbed/mv_embed.js |
— | — | @@ -451,7 +451,7 @@ |
452 | 452 | }, |
453 | 453 | updateText : function( wikiText ){ |
454 | 454 | this.wikiText = wikiText; |
455 | | - //invalidate the output (will force a reparse) |
| 455 | + //invalidate the output (will force a re-parse ) |
456 | 456 | this.pOut = ''; |
457 | 457 | }, |
458 | 458 | parse : function(){ |
— | — | @@ -530,7 +530,7 @@ |
531 | 531 | } |
532 | 532 | function getMagicTxtFromTempNode( node ){ |
533 | 533 | node.tObj = parseTmplTxt ( node.t ); |
534 | | - //do magic swap if templet key found in pMagicSet |
| 534 | + //do magic swap if template key found in pMagicSet |
535 | 535 | if( node.tObj.name in pMagicSet){ |
536 | 536 | var nt = pMagicSet[ node.tObj.name ]( node.tObj ); |
537 | 537 | return nt; |
— | — | @@ -575,7 +575,7 @@ |
576 | 576 | //strip out the parent from the root |
577 | 577 | this.pNode['p'] = null; |
578 | 578 | |
579 | | - //do the recusrive magic swap text: |
| 579 | + //do the recursive magic swap text: |
580 | 580 | this.pOut = recurse_magic_swap( this.pNode ); |
581 | 581 | |
582 | 582 | }, |
— | — | @@ -613,10 +613,10 @@ |
614 | 614 | /** |
615 | 615 | * Returns the transformed wikitext |
616 | 616 | * |
617 | | - * Build output from swapable index |
618 | | - * (all transforms must be expanded in parse stage and linerarly rebuilt) |
619 | | - * Alternativly we could build output using a placeholder & replace system |
620 | | - * (this lets us be slightly more slopty with ordering and indexes, but probably slower) |
| 617 | + * Build output from swappable index |
| 618 | + * (all transforms must be expanded in parse stage and linearly rebuilt) |
| 619 | + * Alternatively we could build output using a place-holder & replace system |
| 620 | + * (this lets us be slightly more slopy with ordering and indexes, but probably slower) |
621 | 621 | * |
622 | 622 | * Ideal: we build a 'wiki DOM' |
623 | 623 | * When editing you update the data structure directly |
— | — | @@ -641,11 +641,6 @@ |
642 | 642 | var loadRS = $mw.lang.loadRS; |
643 | 643 | var gM = $mw.lang.gM; |
644 | 644 | |
645 | | -//if some no-js2 script defined and loaded gMsg in global space: |
646 | | -if( _global['gMsg'] ){ |
647 | | - loadGM( _global['gMsg'] ); |
648 | | -} |
649 | | - |
650 | 645 | // All default messages in [English] should be overwritten by the CMS language message system. |
651 | 646 | $mw.lang.loadGM({ |
652 | 647 | "mwe-loading_txt" : "loading ...", |
— | — | @@ -656,11 +651,11 @@ |
657 | 652 | "mwe-size-bytes" : "$1 B", |
658 | 653 | "mwe-error_load_lib" : "Error: JavaScript $1 was not retrievable or does not define $2", |
659 | 654 | "mwe-loading-add-media-wiz": "Loading add media wizard", |
660 | | - "mwe-apiproxy-setup" : " Setting up API proxy" |
| 655 | + "mwe-apiproxy-setup" : "Setting up API proxy", |
| 656 | + "mwe-load-drag-item" : "Loading draged item", |
| 657 | + "mwe-ok" : "Ok" |
661 | 658 | }); |
662 | 659 | |
663 | | - |
664 | | - |
665 | 660 | /** |
666 | 661 | * AutoLoader paths (this should mirror the file: jsAutoloadLocalClasses.php ) |
667 | 662 | * Any file _not_ listed here won't be auto-loadable |
— | — | @@ -757,6 +752,7 @@ |
758 | 753 | "$j.ui.draggable" : "jquery/jquery.ui/ui/ui.draggable.js", |
759 | 754 | "$j.ui.selectable" : "jquery/jquery.ui/ui/ui.selectable.js", |
760 | 755 | |
| 756 | + "$mw.dragDropFile" : "libAddMedia/dragDropFile.js", |
761 | 757 | "mvFirefogg" : "libAddMedia/mvFirefogg.js", |
762 | 758 | "mvAdvFirefogg" : "libAddMedia/mvAdvFirefogg.js", |
763 | 759 | "mvBaseUploadInterface" : "libAddMedia/mvBaseUploadInterface.js", |
— | — | @@ -1133,8 +1129,6 @@ |
1134 | 1130 | document.getElementsByTagName( "playlist" ) |
1135 | 1131 | ]; |
1136 | 1132 | if( e[0].length != 0 || e[1].length != 0 || e[2].length != 0 ) { |
1137 | | - js_log( 'we have items to rewrite' ); |
1138 | | - setSwappableToLoading( e ); |
1139 | 1133 | // Load libs and process them |
1140 | 1134 | mvJsLoader.embedVideoCheck( function() { |
1141 | 1135 | // Run any queued global events: |
— | — | @@ -1148,16 +1142,9 @@ |
1149 | 1143 | mvJsLoader.runQueuedFunctions(); |
1150 | 1144 | } |
1151 | 1145 | } |
1152 | | -// A quick function that sets the initial text of swappable elements to "loading". |
1153 | | -// jQuery might not be ready. Does not destroy inner elements. |
1154 | | -function setSwappableToLoading( e ) { |
1155 | | - //for(var i =0) |
1156 | | - //for(var j = 0; i < j.length; j++){ |
1157 | | - //} |
1158 | | -} |
| 1146 | + |
1159 | 1147 | //js2AddOnloadHook: ensure jQuery and the DOM are ready |
1160 | | -function js2AddOnloadHook( func ) { |
1161 | | - js_log("js2AddOnloadHook::" + mvJsLoader.doneReadyEvents); |
| 1148 | +function js2AddOnloadHook( func ) { |
1162 | 1149 | // If we have already run the DOM-ready function, just run the function directly: |
1163 | 1150 | if( mvJsLoader.doneReadyEvents ) { |
1164 | 1151 | // Make sure jQuery is there: |
— | — | @@ -1204,8 +1191,8 @@ |
1205 | 1192 | * Store all the mwEmbed jQuery-specific bindings |
1206 | 1193 | * (set up after jQuery is available). |
1207 | 1194 | * |
1208 | | - * These functions are genneraly are loaders that do the dynamic mapping of |
1209 | | - * dependencies for a given compoent |
| 1195 | + * These functions are generaly are loaders that do the dynamic mapping of |
| 1196 | + * dependencies for a given componet |
1210 | 1197 | * |
1211 | 1198 | * |
1212 | 1199 | */ |
— | — | @@ -1213,6 +1200,18 @@ |
1214 | 1201 | js_log( 'mv_jqueryBindings' ); |
1215 | 1202 | (function( $ ) { |
1216 | 1203 | /* |
| 1204 | + * dragDrop file loader |
| 1205 | + */ |
| 1206 | + $.fn.dragFileUpload = function ( conf ){ |
| 1207 | + if( this.selector ){ |
| 1208 | + var _this = this; |
| 1209 | + //load the dragger and "setup" |
| 1210 | + $mw.load( ['$mw.dragDropFile'], function(){ |
| 1211 | + $mw.dragDropFile( _this.selector ); |
| 1212 | + }); |
| 1213 | + } |
| 1214 | + } |
| 1215 | + /* |
1217 | 1216 | * apiProxy Loader loader: |
1218 | 1217 | * |
1219 | 1218 | * @param mode is either 'server' or 'client' |
— | — | @@ -1491,7 +1490,13 @@ |
1492 | 1491 | //append the style free loader ontop: |
1493 | 1492 | $('body').append('<div id="mwe_tmp_loader" style="display:none" title="' + title + '" >' + |
1494 | 1493 | msg_txt + |
1495 | | - '</div>'); |
| 1494 | + '</div>'); |
| 1495 | + //special btn == ok gives empty give a single "oky" -> "close" |
| 1496 | + if( btn == 'ok' ){ |
| 1497 | + btn[ gM('mwe-ok') ] = function(){ |
| 1498 | + $j('#mwe_tmp_loader').close(); |
| 1499 | + } |
| 1500 | + } |
1496 | 1501 | //turn the loader into a real dialog loader: |
1497 | 1502 | mvJsLoader.doLoadDepMode([ |
1498 | 1503 | [ |