--- /dev/null
+Ext.ns("EntSavoie");
+EntSavoie.JQueryUploader = function (config) {
+ Ext.apply(this, config);
+
+ // Ajoute le texte des erreurs
+ Ext.QuickTips.init();
+
+ // turn on validation errors beside the field globally
+ Ext.form.Field.prototype.msgTarget = 'side';
+
+ this.jQUploadBtnId = "jQueryUploader-" + generateUniqueId(); //id du jquery uploader => doit être différent pour chaque instance de l'uploader
+ this.uploadCmd = this.uploadCmd || "addFileEntry"; // cmd à appeler sur l'upload
+ this.isCartable = this.isCartable || false; // permet de savoir si on est sur le cartable
+ this.isGroup = this.isGroup || false; // permet de savoir si on est sur le cartable
+ this.panelColor = this.panelColor || "#DFE8F6"; // couleur de fond du panel contenant le bouton
+ this.filesDropZone = this.filesDropZone || document; // definition de la zone de drop
+ this.supportedExtensions = this.supportedExtensions || []; // tableau des extensions supportees
+ this.singleUpload = this.singleUpload || false; // permet de savoir si on est en upload simple
+ this.advancedView = this.advancedView || false; // permet de savoir si on est sur l'attach file chooser advanced
+ this.btnText = this.btnText || (this.advancedView?this.i18n.addFile2:this.i18n.addFile); // texte affiche sur le bouton
+ this.resizeCmd = "";
+ if (this.resize && this.resize != "") {
+ this.resizeCmd = '&resize='+this.resize;
+ }
+ this.size=100000;
+
+ EntSavoie.JQueryUploader.superclass.constructor.call(this, {
+ border: false,
+ bodyStyle:{"background-color": this.panelColor},
+ layout:'table',
+ layoutConfig: {
+ columns: 1
+ },
+ html: (Ext.isIE7)?'<div id="'+ this.jQUploadBtnId + '">' +
+ '<form id="formFileUpload" action=\''+ this.actionURLAjax +'&cmd=' + this.uploadCmd + this.resizeCmd + '\' method="POST" enctype="multipart/form-data">' +
+ '<div class="fileupload-buttonbar" >' +
+ '<label class="fileinput-button" style="height: 20px !important;">' +
+ '<span class="image-add-file-upload"></span>' +
+ '<div style="padding-left: 20px !important; color: black !important;">' + this.btnText + '</div>' +
+ '<input type="file" name="files[]">' +
+ '</label>' +
+ '</div>' +
+ '</form>' +
+ '</div>' :
+ ((Ext.isGecko3 || Ext.isIE8 || this.singleUpload)?'<div id="'+ this.jQUploadBtnId + '">' +
+ '<form id="formFileUpload" action=\''+ this.actionURLAjax +'&cmd=' + this.uploadCmd + this.resizeCmd + '\' method="POST" enctype="multipart/form-data">' +
+ '<div class="fileupload-buttonbar" >' +
+ '<label class="fileinput-button">' +
+ '<span class="image-add-file-upload"></span>' +
+ '<span class="image-add-file-upload" style="padding-left: 20px !important; color: black !important;">' + this.btnText + '</span>' +
+ '<input type="file" name="files[]">' +
+ '</label>' +
+ '</div>' +
+ '</form>' +
+ '</div>' :
+ '<div id="'+ this.jQUploadBtnId + '">' +
+ '<form id="formFileUpload" action=\''+ this.actionURLAjax +'&cmd=' + this.uploadCmd + this.resizeCmd + '\' method="POST" enctype="multipart/form-data">' +
+ '<div class="fileupload-buttonbar" >' +
+ '<label class="fileinput-button">' +
+ '<span class="image-add-file-upload"></span>' +
+ '<span class="image-add-file-upload" style="padding-left: 20px !important; color: black !important;">' + this.btnText + '</span>' +
+ '<input type="file" name="files[]" multiple>' +
+ '</label>' +
+ '</div>' +
+ '</form>' +
+ '</div>')
+ });
+
+ this.on("afterrender", drawJQUploadFilePanel, this);
+
+};
+
+Ext.extend(EntSavoie.JQueryUploader, Ext.Panel, {
+ initComponent: function () {
+ EntSavoie.JQueryUploader.superclass.initComponent.call(this);
+ if(this.advancedView || this.isGroup){
+ Ext.Ajax.request(
+ {
+ url:this.actionURLAjax,
+ params:{
+ cmd: "getMaxFileUploadSize"
+ },
+ success: this.onSuccessGetMaxFileUploadSize,
+ scope: this
+ }
+ );
+ }
+ },
+
+ onSuccessGetMaxFileUploadSize:function(response, options) {
+ var backObj = Ext.decode(response.responseText);
+ if (backObj.success) {
+ this.size = backObj.uploadMaxSize;
+ warningMessage = new Ext.Panel({
+ border: false,
+ html: this.i18n.limitSizeMessage.replace("$1",this.size)
+ });
+
+ this.add(warningMessage);
+ this.render();
+ this.doLayout();
+ }
+ },
+});
\ No newline at end of file