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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1f6221c5c586280c83686ceb389732d7a69e0c39
4
- data.tar.gz: fb0b760a47d4273645d754a178f39109af866459
2
+ SHA256:
3
+ metadata.gz: 35beb2331421a66b36724e2d7f8f70536436b48df02a0d18e602e2c2bf8b0cf7
4
+ data.tar.gz: 7fab32e15d3198d47be72c04f784deb733fc102791b02750dff16fd55f5fba07
5
5
  SHA512:
6
- metadata.gz: 9c515fc453685821796623b24adc5ac26bad8499165feed986d1ef1d6a1cb02425eed5164c792d66b3602a724a0916281531a3769680a17303fbb92ab0aa1fcd
7
- data.tar.gz: 1e1967e26aafa1e49d6361a0f094a06f908a167367cfcb53bc840640772bb03697e448cecc8265f648da9709b248b44f7eaa475297c72362ea305f1fc2d1d37d
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);