コード例 #1
0
ファイル: camdram.js プロジェクト: CHTJonas/camdram
    		  init: function() {
    			  var msgDiv = Dropzone.createElement('<div/>');
    			  msgDiv.className = 'hidden'
    			  this.element.append(msgDiv);
    			  
    			  this.on('error', function(file, errorMessage, blah) {
			    	this.removeAllFiles();
			    	
			    	var errorText = 'Error uploading "' + file.name + '"';
			    	
			    	if (typeof errorMessage == 'string')
		    		{
			    		errorText += ':<br />' + errorMessage;
		    		}
			    	else if (typeof errorMessage.error == 'string')
		    		{
			    		errorText += ':<br />' + errorMessage.error;
		    		}
			    	msgDiv.innerHTML = errorText;
			    	msgDiv.className = 'alert-box alert round';
			      })
			      .on('addedfile', function() {
			    	  msgDiv.className = 'hidden';
			    	  msgDiv.innerHTML = '';
			      })
			      .on('success', function(file) {
			    	  this.destroy();
			    	  
			    	  msgDiv.innerHTML = '"' + file.name + '" uploaded'
			    	  		+ '<br />Reloading page...'
			    	  msgDiv.className = 'alert-box success round'
			    	  
		              location.reload();
    		      })
    		      .on("maxfilesexceeded", function(file) { 
    		    	  this.removeFile(file); 
    		      });
    		   }
コード例 #2
0
ファイル: upload.js プロジェクト: BryceHQ/form-designer
    var {url, eventHandlers, config} = this.props;
    config = _.assign(config || {}, _config);
    if(url){
      componentConfig.postUrl = url;
    }

		return (
      <DropzoneComponent config={componentConfig} eventHandlers={eventHandlers} djsConfig={config} />
    );
	},

  _handleSuccess(file, data) {
    //add a custom button

    // Create the remove button
    var removeButton = Dropzone.createElement(`<button class="button link-button">${lang.message.background}</button>`);


    // Listen to the click event
    removeButton.addEventListener("click", function(e) {
      // Make sure the button click doesn't submit the form:
      e.preventDefault();
      e.stopPropagation();

      if(this.props.onDefaultBtn){
        this.props.onDefaultBtn(data);
      }
    });

    // Add the button to the file preview element.
    file.previewElement.appendChild(removeButton);