scrivito_advanced_editors 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/assets/javascripts/scripts/datetime_editor.js +55 -0
- data/app/assets/javascripts/scripts/flatpicker.js +2351 -0
- data/app/assets/stylesheets/scrivito_advanced_editors/flatpicker.scss +850 -0
- data/lib/scrivito_advanced_editors/engine.rb +3 -1
- data/lib/scrivito_advanced_editors/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 35beb2331421a66b36724e2d7f8f70536436b48df02a0d18e602e2c2bf8b0cf7
|
4
|
+
data.tar.gz: 7fab32e15d3198d47be72c04f784deb733fc102791b02750dff16fd55f5fba07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc206ea0dfc3bfbd09573fa39574f652d666f6eb1812096ed9561a04eb117881a813de529c63fa6f55688395755e387f7ece641bf129860a58593d87844e6e34
|
7
|
+
data.tar.gz: f0270ba63019208ba769c9d65b35d008bcd34d2f846a4936867d17d113e67566de43dd9e33d93339c1dc405ae051125da7afe0ead05ade8181ee1342a200850f
|
@@ -0,0 +1,55 @@
|
|
1
|
+
(function($, App) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
var activate, config, save;
|
5
|
+
|
6
|
+
var date_editor = {
|
7
|
+
can_edit: function(element) {
|
8
|
+
return $(element).is('[data-scrivito-field-type=date]');
|
9
|
+
},
|
10
|
+
activate: function(element) {
|
11
|
+
return activate($(element));
|
12
|
+
}
|
13
|
+
};
|
14
|
+
|
15
|
+
scrivito.on('content', function() {
|
16
|
+
if(scrivito.in_editable_view()) {
|
17
|
+
scrivito.define_editor('datetime_editor', date_editor);
|
18
|
+
}
|
19
|
+
});
|
20
|
+
|
21
|
+
activate = function(cmsField) {
|
22
|
+
cmsField.on('click', function(event) {
|
23
|
+
var content = new Date(cmsField.scrivito('content'));
|
24
|
+
var isoOffset = content.getTimezoneOffset() / 60;
|
25
|
+
var date = content.setHours(content.getHours() + isoOffset);
|
26
|
+
var elem = $('<input value="'+ new Date(date) +'">').insertAfter(cmsField);
|
27
|
+
var options = cmsField.data("scrivito-datetimepicker-config");
|
28
|
+
cmsField.hide();
|
29
|
+
cmsField.next().flatpickr($.extend(config, options)).open();
|
30
|
+
})
|
31
|
+
};
|
32
|
+
|
33
|
+
save = function(cmsField, value) {
|
34
|
+
var isoOffset = value.getTimezoneOffset() / 60;
|
35
|
+
var date = value.setHours(value.getHours() - isoOffset);
|
36
|
+
return cmsField.scrivito('save', new Date(date)).done(function() { cmsField.trigger('scrivito_editors:save'); });
|
37
|
+
};
|
38
|
+
|
39
|
+
config = {
|
40
|
+
enableTime: true,
|
41
|
+
enableSeconds: true,
|
42
|
+
time_24hr: true,
|
43
|
+
parseDate: function(date) { return date=="null" ? new Date() : new Date(date); },
|
44
|
+
onChange: function(selectedDates, dateStr, instance) {
|
45
|
+
var cmsField = $(instance.element).prev();
|
46
|
+
save(cmsField, new Date(dateStr));
|
47
|
+
},
|
48
|
+
onClose: function(selectedDates, dateStr, instance) {
|
49
|
+
var cmsField = $(instance.element).prev();
|
50
|
+
save(cmsField, new Date(dateStr));
|
51
|
+
$(instance.element).remove();
|
52
|
+
cmsField.html(dateStr).show();
|
53
|
+
}
|
54
|
+
}
|
55
|
+
})(jQuery, this);
|