1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,60 @@ |
1 |
+/* Add Floating Placeholders to Inputs */ |
|
2 |
+ |
|
3 |
+function addPlaceholders() { |
|
4 |
+ $(".widget:not(.widget-upload):not(.widget-select):not(.widget-radio):not(.widget-checkbox)").each(function (index) { |
|
5 |
+ var placeholder = $(this).find("input, textarea").attr("placeholder"); |
|
6 |
+ var label = $(this).find("input, textarea").prev('label').text(); |
|
7 |
+ var id = $(this).find("input, textarea").attr("id"); |
|
8 |
+ |
|
9 |
+ label = label.replace('Pflichtfeld ', ''); |
|
10 |
+ |
|
11 |
+ if (placeholder) { |
|
12 |
+ $(this).find("label").remove(); |
|
13 |
+ $(this) |
|
14 |
+ .find("input, textarea") |
|
15 |
+ .parent("div:not(.form-floating)") |
|
16 |
+ .addClass("form-floating"); |
|
17 |
+ $(this) |
|
18 |
+ .find("input, textarea") |
|
19 |
+ .parent("div") |
|
20 |
+ .append("<label for='" + id + "'>" + placeholder + "</label>"); |
|
21 |
+ |
|
22 |
+ $(this) |
|
23 |
+ .find("input:not(.form-control), textarea:not(.form-control)").addClass('form-control', ''); |
|
24 |
+ |
|
25 |
+ } else if (label) { |
|
26 |
+ $(this).find("label").remove(); |
|
27 |
+ |
|
28 |
+ $(this) |
|
29 |
+ .find("input, textarea") |
|
30 |
+ .parent("div:not(.form-floating)") |
|
31 |
+ .addClass("form-floating"); |
|
32 |
+ |
|
33 |
+ $(this) |
|
34 |
+ .find("input, textarea") |
|
35 |
+ .parent("div") |
|
36 |
+ .append("<label for='" + id + "'>" + label + "</label>"); |
|
37 |
+ |
|
38 |
+ $(this) |
|
39 |
+ .find("input, textarea").attr('placeholder', label); |
|
40 |
+ |
|
41 |
+ } |
|
42 |
+ }); |
|
43 |
+} |
|
44 |
+ |
|
45 |
+ |
|
46 |
+$(".ce_form form").submit(function (e) { |
|
47 |
+ setTimeout(function () { |
|
48 |
+ addPlaceholders(); |
|
49 |
+ }, 250); |
|
50 |
+}); |
|
51 |
+ |
|
52 |
+ |
|
53 |
+$(function () { |
|
54 |
+ setInterval(function () { |
|
55 |
+ addPlaceholders(); |
|
56 |
+ }, 250, true); |
|
57 |
+}); |
|
58 |
+ |
|
59 |
+ |
|
60 |
+/* END */ |
|
0 | 61 |
\ No newline at end of file |