Typeadmin.js
3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* @package anc_text
* @since 20140416
* @copyright (c) netz.coop eG
* @author netz.coop eG
*/
//$.noConflict();
var Anc_Text_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-text ", 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-text-owngallery-content .anc-text-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-text-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-text-draggable');
},
}
param_dropzone_element.droppable(droppable_opt);
},
"draggableFile" : function() {
var draggable_opt = {
revert: "invalid", // im zweifel gehts wieder zurück zum ursprung
cursor: "move", // mauszeiger ....
containment: "#ancsubbundleproduct", // element darf nur innerhalb von containment bewegt werden
opacity: .5,
snap:true, // einrasten
snapMode:"inner",
grid: [10,10],
stack: '.anc-text-draggable', // letzter drop liegt vorne
helper: 'clone', // nicht moven sondern kopieren
// snapTolerance:50,
}
jQuery(' .anc-text-draggable').draggable(draggable_opt);
}
}