/** * jqUploader (http://www.pixeline.be/experiments/jqUploader/) * A jQuery plugin to replace html-based file upload input fields with richer flash-based upload progress bar UI. * * Version 1.0.2.2 * September 2007 * * Copyright (c) 2007 Alexandre Plennevaux (http://www.pixeline.be) * Dual licensed under the MIT and GPL licenses. * http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/gpl-license.php * * using plugin "Flash" by Luke Lutman (http://jquery.lukelutman.com/plugins/flash) * * IMPORTANT: * The packed version of jQuery breaks ActiveX control * activation in Internet Explorer. Use JSMin to minifiy * jQuery (see: http://jquery.lukelutman.com/plugins/flash#activex). * **/ jQuery.noConflict(); jQuery.fn.jqUploader = function(options) { return this.each(function(index) { var $this = jQuery(this); // fetch label value if any, otherwise set a default one var $thisForm = $this.parents("form"); var $thisInput = jQuery("input[@type='file']",$this); var $thisLabel = jQuery("label",$this); var page = jQuery("input[@name='page']", $(this.form)).val(); var blockNumber = jQuery("input[@name='blockNumber']", $(this.form)).val(); var containerId = $this.attr("id") || 'jqUploader-'+index; var startMessage = ($thisLabel.text() =='') ? 'Please select a file' : $thisLabel.text(); // get form action attribute value as upload script, appending to it a variable telling the script that this is an upload only functionality var actionURL = $thisForm.attr("action"); // adds a var setting jqUploader to 1, so you can use it for serverside processing var prepender = (actionURL.lastIndexOf("?") != -1) ? "&": "?"; actionURL = actionURL+prepender+'PHPSESSID=3bbb7ts10e8lbdo6gcmj28ajp96a6r5b&jqUploader=1&request=uploadFile&page=' + page + '&blockNumber=' + blockNumber; // alert(actionURL); // check if max file size is set in html form var maxFileSize = jQuery("input[@name='MAX_FILE_SIZE']", $(this.form)).val(); var opts = jQuery.extend({ width:320, height:85, version: 8, // version 8+ of flash player required to run jqUploader background: '333333', // background color of flash file src: 'upload/jqUploader.swf', uploadScript: actionURL, afterScript: null, // if this is empty, jqUploader will replace the upload swf by a hidden input element varName: $thisInput.attr("name"), //this holds the variable name of the file input field in your html form allowedExt: '*.jpg; *.jpeg', // allowed extensions allowedExtDescr: 'Images (*.jpg; *.jpeg)', params: {menu:false}, flashvars: {}, hideSubmit: true, barColor: '0000CC', maxFileSize: maxFileSize, startMessage: startMessage, errorSizeMessage: 'Dieses File ist zu gross!', validFileMessage: 'Klicken Sie jetzt auf Upload!', progressMessage: 'Bitte warten... ', endMessage: 'Upload abgeschlossen...', phpSess: '3bbb7ts10e8lbdo6gcmj28ajp96a6r5b', retrieveTempImageScript: 'upload/retrieveTempImageName.php', page: page, blockNumber: blockNumber }, options || {} ); // disable form submit button if (opts.hideSubmit==true) { jQuery("*[@type='submit']",this.form).hide(); } // THIS WILL BE EXECUTED IN THE USECASE THAT THERE IS NO REDIRECTION TO BE DONE AFTER UPLOAD TerminateJQUploader = function(containerId,filename,varname,uniqueFileName,page,blockNumber){ //alert(uniqueFileName); $this= jQuery('#'+containerId).empty(); // TG //todo div nav_main is used 2 times by tg ;-( jQuery("#newfile").html("

Bitte vergeben Sie einen Namen für Ihr Bild:

Alternatives Querformat-Bild falls Originalbild aufgrund von zuviel Text nicht mehr in den Artikel passt.

"); jQuery("#newfile2").html(""); jQuery("#uploadinfo").html("Schritt 1 abgeschlossen! Schritt 2 von 3: Wählen Sie einen passenden Ausschnitt und klicken Sie auf 'Weiter'!"); new Effect.Highlight('uploadinfo', {startcolor: '#ff3300',endcolor: '#ff0000', duration:3}); initCropper(); var myForm = $this.parents("form"); myForm.submit(function(){return true}); jQuery("*[@type='submit']",myForm).show(); // alert("called"); } var myParams = ''; for (var p in opts.params){ myParams += p+'='+opts.params[p]+','; } myParams = myParams.substring(0, myParams.length-1); // this function interfaces with the jquery flash plugin jQuery(this).flash( { src: opts.src, width: opts.width, height: opts.height, id:'movie_player-'+index, bgcolor:'#666666', //+opts.background, flashvars: { containerId: containerId, uploadScript: opts.uploadScript, afterScript: opts.afterScript, allowedExt: opts.allowedExt, allowedExtDescr: opts.allowedExtDescr, varName : opts.varName, barColor : opts.barColor, maxFileSize :opts.maxFileSize, startMessage : opts.startMessage, errorSizeMessage : opts.errorSizeMessage, validFileMessage : opts.validFileMessage, progressMessage : opts.progressMessage, endMessage: opts.endMessage, phpSess: opts.phpSess, retrieveTempImageScript: opts.retrieveTempImageScript, page:page, blockNumber:blockNumber }, params: myParams }, { version: opts.version, update: false }, function(htmlOptions){ var $el = jQuery('
'+this.innerHTML+'
'); $el.prepend(jQuery.fn.flash.transform(htmlOptions)); jQuery('div.alt',$el).remove(); jQuery(this).after($el).remove(); // alert("htmlOptions called"); } ); }); }