Typeadmin.js 3.33 KB
/**
 * @package	anc_image
 * @since	20140416 
 * @copyright (c) netz.coop eG
 * @author	netz.coop eG
 */
//$.noConflict();

	var Anc_Image_Typeadmin  = {
		"pastDraggable" : "",
		/**
		 * 
		 * @param element param_dropzone_element - welches die dropzone darstellen soll
		 * @param element param_input_element - optional - set input.value - bekommt die rückgabe id vom hochgeladenen bild
		 * @param string param_url_upload - url die das bild entgegen nimmt
		 * @param element param_note_element - rückgabe notiz (fehler, erfolgreich)
		 * @returns {undefined}
		 */
		"droppableFile" : 	function(param_dropzone_element, param_input_element, param_url_upload, param_note_element, param_url_simpleowngallery,param_secure) {
			/**
			 * fnc teil der die dateien aus dem dateiexplorer entgegen nimmt
			 */
			param_dropzone_element.dropzone({ 
				url: param_url_upload,
				paramName: "file", // The name that will be used to transfer the file
				maxFilesize: 50, // MB
				maxFiles: 10, 
				params: { form_key : param_secure },
	//			maxfilesexceeded: function(file) { },
				processing: function(file) { 
					jQuery(" button.button ").attr("disabled", "disabled");
					param_note_element.append('<div>Bild wird hochgeladen. Bitte warten!</div>');
					jQuery(" > .preview-database-image ", param_dropzone_element).remove();
					jQuery(" > img ", param_dropzone_element).remove();				
					this.removeAllFiles();
				},
				init: function() {
					this.on("complete", function (file) {
						if (this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0) {
//							alert('file.width: '+file.width+' file.height: '+file.height);
						}
					 });					
					this.on("success", function(file,rep) {
						var reponse = jQuery.parseJSON( rep );
						if(param_input_element) {
							param_input_element.attr('value', reponse.id);
						}
						
						
						if(reponse.status === 'OK') {
							var noteclass = 'anc-success';
							jQuery(".anc-image-owngallery-content .anc-image-owngallery-content-view").load(param_url_simpleowngallery, function() {});
						} else {
							var noteclass = 'anc-error';
						}
						jQuery(" button.button ").attr("disabled", false);
						jQuery(" div ", param_note_element).remove();
						param_note_element.append('<div class="'+noteclass+'">'+reponse.message+'</div>');
						
					});
				}
			});		

//			var droppable_opt = {
//				accept:".anc-image-draggable",
//				tolerance: 'touch',
//
//				drop: function(typ, ui) {
//					var currentDraggable = jQuery(ui.draggable).attr('id');
//					jQuery(this).append(jQuery(ui.draggable).clone());
//					if(param_input_element) {
//						param_input_element.attr('value', ui.draggable.attr('id'));
//					}
//					jQuery(" > div ", param_dropzone_element).remove();
//					
//					//If there is an object prior to the current one
//					if (this.pastDraggable != "") {
//						jQuery("#" + this.pastDraggable).remove();	//Place past object into its original coordinate
//					}
//					this.pastDraggable = currentDraggable;
//				},
//				activate: function(typ, ui) {},
//				deactivate: function(typ, ui) {},						
//				over: function(typ, ui) {},					
//				out: function(typ, ui) {
//					jQuery(ui.draggable).remove();		//	jQuery(this).droppable('option', 'accept', '.anc-image-draggable');
//				},											
//			}
//			param_dropzone_element.droppable(droppable_opt);		
		},
		
	}