scrivito_sdk 1.4.0.rc1 → 1.4.0.rc2

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
2
  SHA1:
3
- metadata.gz: bed29ff11b6133cbfaaade6b2f4b4803068f4760
4
- data.tar.gz: 7ae4f9b89159e0449c6afd81d1450da6922b8220
3
+ metadata.gz: d1bbfe00ef1710d09ff2d7363a604e3238f14742
4
+ data.tar.gz: 36c6feecc6d525c42552c5bbc92a253fefc5757d
5
5
  SHA512:
6
- metadata.gz: d28ad9f4af8da651d3bc248bb5680e5aa570756250dd9738271a7f836e5af4dbd71dca55541ea7c684809e36395d906cdcb5a9f58d0da71d31a72c19bf0daef8
7
- data.tar.gz: efcc8b24d207de22312753441050cfc5f655933e56fd848804c8d96e9aebdb50c73cd809ca63b7a6e14b1b820266c36edfb981709fb6c6051b170f1cddacd422
6
+ metadata.gz: 68f0092914578fb8e749e2946de66fb9a374a7d6c04006ae67de2c7caa4687fff91a63c688c9337ac9029f3536d4a1c80ca422b8489920f4bdd163788d3ff48e
7
+ data.tar.gz: 912872ea0c2e7e2a526282eacb6ab7723dfceaa11a1463c97f80b0841deb532c7ea73e2f289654ec12d6f46edfaaf651e665f35bda8f988a3f7d5add4f05f763
@@ -18,6 +18,8 @@ module Scrivito
18
18
  other_attributes = {}
19
19
 
20
20
  defaults.each do |name, value|
21
+ next if value.nil?
22
+
21
23
  attribute_type = obj_class.attribute_definitions[name].try(:type)
22
24
  if attribute_type == 'widgetlist'
23
25
  widgets = value.map do |new_widget|
data/config/ca-bundle.crt CHANGED
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## Bundle of CA Root Certificates
3
3
  ##
4
- ## Certificate data from Mozilla as of: Fri Jun 10 08:25:50 2016
4
+ ## Certificate data from Mozilla as of: Thu Jun 16 15:05:45 2016
5
5
  ##
6
6
  ## This is a bundle of X.509 certificates of public Certificate Authorities
7
7
  ## (CA). These were automatically extracted from Mozilla's root certificates
@@ -34278,7 +34278,7 @@ this._namespaceURI=s;var c;if(e.useCreateElement){var p,d=n._ownerDocument;if(s=
34278
34278
  var helper;
34279
34279
 
34280
34280
  return "<li class=\"scrivito_menu_separator scrivito_"
34281
- + container.escapeExpression(((helper = (helper = helpers.headline_color || (depth0 != null ? depth0.headline_color : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"headline_color","hash":{},"data":data}) : helper)))
34281
+ + container.escapeExpression(((helper = (helper = helpers.headlineColor || (depth0 != null ? depth0.headlineColor : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"headlineColor","hash":{},"data":data}) : helper)))
34282
34282
  + "\">\n <span class=\"scrivito_headline\">"
34283
34283
  + container.escapeExpression(((helper = (helper = helpers.headline || (depth0 != null ? depth0.headline : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"headline","hash":{},"data":data}) : helper)))
34284
34284
  + "</span>\n</li>\n<li class=\"scrivito_menu_separator\">\n <span>"
@@ -35964,7 +35964,7 @@ var scrivito = {}; // jshint ignore:line
35964
35964
  scrivito.menu_bar_display_mode_toggle.init();
35965
35965
  scrivito.currentPageMenu.init();
35966
35966
  scrivito.menu_bar_browse_content.init();
35967
- scrivito.menu_bar_conflict_indicator.init();
35967
+ scrivito.menuBarConflictIndicator.init();
35968
35968
  scrivito.current_page_restriction.init();
35969
35969
  scrivito.workspace_select.init();
35970
35970
  scrivito.menu_bar.init();
@@ -36057,10 +36057,15 @@ var scrivito = {}; // jshint ignore:line
36057
36057
  _.extend(scrivito, {
36058
36058
  silent_ajax: function(type, path, options) {
36059
36059
  var is_write_request = type === 'PUT' || type === 'POST' || type === 'DELETE';
36060
+ var skip_write_monitor = options && options.skip_write_monitor;
36061
+
36060
36062
  if (is_write_request) {
36061
36063
  options = options || {};
36062
36064
  options.timeout = 15000; // miliseconds
36063
- scrivito.write_monitor.start_write();
36065
+
36066
+ if (!skip_write_monitor) {
36067
+ scrivito.write_monitor.start_write();
36068
+ }
36064
36069
  }
36065
36070
 
36066
36071
  var ajax_promise = single_ajax(type, path, options).then(function(result) {
@@ -36071,7 +36076,7 @@ var scrivito = {}; // jshint ignore:line
36071
36076
  }
36072
36077
  });
36073
36078
 
36074
- if (is_write_request) {
36079
+ if (is_write_request && !skip_write_monitor) {
36075
36080
  ajax_promise.always(function() {
36076
36081
  scrivito.write_monitor.end_write();
36077
36082
  });
@@ -38194,13 +38199,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
38194
38199
  })();
38195
38200
 
38196
38201
  function renewSession() {
38197
- return scrivito.Promise.resolve(scrivito.silent_ajax('PUT', 'sessions/' + session.id)).then(function (newSession) {
38202
+ return requestSession().then(function (newSession) {
38198
38203
  sessionRenewalPromise = null;
38199
-
38200
38204
  setSession(newSession);
38201
- }, function (error) {
38205
+ })['catch'](function (error) {
38202
38206
  sessionRenewalPromise = null;
38203
-
38204
38207
  throw new scrivito.UnauthorizedError('Failed to renew session.');
38205
38208
  });
38206
38209
  }
@@ -38211,6 +38214,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
38211
38214
  sessionRenewalPromise = renewSession();
38212
38215
  }, (session.maxage - 10) * 1000);
38213
38216
  }
38217
+
38218
+ function requestSession() {
38219
+ return scrivito.Promise.resolve(scrivito.silent_ajax('PUT', 'sessions/' + session.id, { skip_write_monitor: true }));
38220
+ }
38214
38221
  })();
38215
38222
  'use strict';
38216
38223
 
@@ -45415,27 +45422,29 @@ var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr =
45415
45422
  }());
45416
45423
  'use strict';
45417
45424
 
45418
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
45419
-
45420
45425
  (function () {
45421
- var cursor = undefined;
45422
- var draggedWidget = {};
45423
- var lastGesture = undefined;
45426
+ var $cursor = undefined;
45427
+ var state = {}; // State variables: gesture, widgetDrag.
45424
45428
 
45425
45429
  scrivito.dragDrool = Object.defineProperties({
45426
45430
  init: function init() {
45427
- cursor = $('<div class="scrivito_dnd_cursor"></div>');
45428
- cursor.hide();
45429
- $('body').append(cursor);
45431
+ $cursor = $('<div class="scrivito_dnd_cursor"></div>');
45432
+ $cursor.hide();
45433
+ $('body').append($cursor);
45430
45434
 
45431
- scrivito.gui.on('document', function (document) {
45432
- var body = document.dom_element().find('body');
45435
+ scrivito.gui.on('document', function (cmsDocument) {
45436
+ if (scrivito.in_editable_view()) {
45437
+ (function () {
45438
+ var $body = cmsDocument.dom_element().find('body');
45433
45439
 
45434
- body.on('dragover', function (e) {
45435
- if (scrivito.in_editable_view()) {
45436
- scrivito.dragDrool.dragover(e, body.get(0));
45437
- }
45438
- });
45440
+ $body.on('dragover', function (e) {
45441
+ return scrivito.dragDrool.onDragover(e, $body);
45442
+ });
45443
+ $body.on('drop', function (e) {
45444
+ return scrivito.dragDrool.onDrop(e);
45445
+ });
45446
+ })();
45447
+ }
45439
45448
  });
45440
45449
 
45441
45450
  scrivito.on('content', function (content) {
@@ -45443,22 +45452,22 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
45443
45452
  var cmsDocument = scrivito.cms_document.from($(content));
45444
45453
 
45445
45454
  _.each(scrivito.widget_element.all(cmsDocument.dom_element()), function (widgetElement) {
45446
- var markers = widgetElement.dom_element().find('> .scrivito_editing_marker');
45455
+ var $markers = widgetElement.dom_element().find('> .scrivito_editing_marker');
45447
45456
 
45448
- markers.attr('draggable', 'true');
45457
+ $markers.attr('draggable', 'true');
45449
45458
 
45450
- markers.on('dragstart', function (e) {
45451
- return scrivito.dragDrool.dragstart(e);
45459
+ $markers.on('dragstart', function (e) {
45460
+ return scrivito.dragDrool.onDragstart(e);
45452
45461
  });
45453
- markers.on('dragend', function (e) {
45454
- return scrivito.dragDrool.dragend(e);
45462
+ $markers.on('dragend', function (e) {
45463
+ return scrivito.dragDrool.onDragend(e);
45455
45464
  });
45456
45465
  });
45457
45466
  }
45458
45467
  });
45459
45468
  },
45460
45469
 
45461
- dragstart: function dragstart(e) {
45470
+ onDragstart: function onDragstart(e) {
45462
45471
  e.originalEvent.dataTransfer.effectAllowed = 'move';
45463
45472
 
45464
45473
  // Is required in order to dragover event is triggered in FF and Safari.
@@ -45470,12 +45479,13 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
45470
45479
  // Ignore.
45471
45480
  }
45472
45481
 
45473
- draggedWidget.HTMLNode = $(e.originalEvent.target).parent()[0];
45474
- draggedWidget.isHidden = false;
45482
+ var $draggedWidget = $(e.originalEvent.target).parent();
45483
+ var widgetDrag = new scrivito.WidgetDrag($draggedWidget);
45484
+ this.setState({ widgetDrag: widgetDrag });
45475
45485
  },
45476
45486
 
45477
- dragover: scrivito.oncePerFrame(function (e, body) {
45478
- if (!draggedWidget.HTMLNode) {
45487
+ onDragover: function onDragover(e, $body) {
45488
+ if (!scrivito.dragDrool.buildDrag(e)) {
45479
45489
  return;
45480
45490
  }
45481
45491
 
@@ -45484,22 +45494,32 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
45484
45494
  e.preventDefault(); // Necessary: Allows us to drop.
45485
45495
  }
45486
45496
 
45487
- // Replace original with placeholder.
45488
- if (!draggedWidget.isHidden) {
45489
- // jQuery's "css" function does not work correctly in a Chrome + Jasmine environment,
45490
- // so we need to use the low-level accessors in order to test the behavior.
45491
- draggedWidget.HTMLNode.style.opacity = '0.5';
45492
- draggedWidget.isHidden = true;
45493
- }
45494
-
45495
45497
  // Using originalEvent as a workaround.
45496
45498
  // See https://github.com/jquery/jquery/issues/1925.
45497
45499
  var mouse = { x: e.originalEvent.pageX, y: e.originalEvent.pageY };
45498
- var gesture = scrivito.detectGesture(mouse, $(body), draggedWidget.HTMLNode);
45499
- var target = $(gesture.target);
45500
+
45501
+ this._updateCursorDebounced(mouse, $body, e);
45502
+ },
45503
+
45504
+ _updateCursorDebounced: scrivito.oncePerFrame(function () {
45505
+ var _scrivito$dragDrool;
45506
+
45507
+ (_scrivito$dragDrool = scrivito.dragDrool)._updateCursor.apply(_scrivito$dragDrool, arguments);
45508
+ }),
45509
+
45510
+ _updateCursor: function _updateCursor(mouse, $body, e) {
45511
+ var drag = scrivito.dragDrool.buildDrag(e);
45512
+ if (!drag) {
45513
+ return;
45514
+ }
45515
+
45516
+ drag.onDragover();
45517
+
45518
+ var gesture = scrivito.detectGesture(mouse, $body, drag.domElement);
45519
+ var $target = $(gesture.target);
45500
45520
 
45501
45521
  // This should NEVER happen!
45502
- if (!target.length) {
45522
+ if (!$target.length) {
45503
45523
  scrivito.logError('Missing target!');
45504
45524
  return;
45505
45525
  }
@@ -45507,334 +45527,167 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
45507
45527
  var edgeName = gesture.edgeName;
45508
45528
 
45509
45529
  if (edgeName === 'top' || edgeName === 'bottom') {
45510
- scrivito.dragDrool.showRowCursor(edgeName, target);
45530
+ scrivito.dragDrool.showRowCursor(edgeName, $target, drag);
45511
45531
  } else if (edgeName === 'left' || edgeName === 'right') {
45512
- scrivito.dragDrool.showColCursor(edgeName, target, gesture.isWrapFree);
45532
+ scrivito.dragDrool.showColCursor(edgeName, $target, drag, gesture.isWrapFree);
45513
45533
  } else {
45514
45534
  // This should NEVER happen!
45515
45535
  $.error('Unknown gesture: ' + gesture);
45516
45536
  }
45517
45537
 
45518
- lastGesture = gesture;
45519
- }),
45538
+ scrivito.dragDrool.setState({ gesture: gesture });
45539
+ },
45520
45540
 
45521
- dragend: function dragend() {
45522
- var gesture = lastGesture;
45541
+ onDrop: function onDrop(e) {
45542
+ var drag = this.buildDrag(e);
45543
+ var gesture = this.state.gesture;
45523
45544
 
45524
- if (!gesture || !gesture.target || !isValidTarget(gesture.target) || gesture.target.get(0) === draggedWidget.HTMLNode) {
45525
- // Widget class not allowed to drop here: Do nothing.
45526
- // Dragged a widget on itself: Do nothing.
45527
- draggedWidget.HTMLNode.style.opacity = 1;
45545
+ if (!gesture || !gesture.target || !drag.canDropInto(gesture.target)) {
45546
+ drag.onCancel();
45528
45547
  } else if (gesture.target) {
45529
- var target = gesture.target;
45530
- var oldParent = $(draggedWidget.HTMLNode).parent();
45531
- var edgeName = gesture.edgeName;
45532
-
45533
- if (edgeName === 'top' || edgeName === 'bottom') {
45534
- scrivito.dragDrool.insertRow(target, edgeName, oldParent);
45535
- } else {
45536
- scrivito.dragDrool.insertCol(target, edgeName, oldParent);
45537
- }
45548
+ drag.dropInto(gesture.target, gesture.edgeName);
45538
45549
  }
45539
45550
 
45540
- cursor.hide();
45541
- draggedWidget = {};
45551
+ this._cleanup();
45542
45552
  return false;
45543
45553
  },
45544
45554
 
45545
- showRowCursor: function showRowCursor(edgeName, target) {
45546
- cursor.height('0px');
45547
- cursor.width(target.parent().outerWidth());
45555
+ onDragend: function onDragend(e) {
45556
+ var drag = this.buildDrag(e);
45557
+ if (drag) {
45558
+ drag.onCancel();
45559
+ }
45560
+
45561
+ this._cleanup();
45562
+ },
45563
+
45564
+ showRowCursor: function showRowCursor(edgeName, $target, drag) {
45565
+ $cursor.height('0px');
45566
+ $cursor.width($target.parent().outerWidth());
45548
45567
 
45549
45568
  // TODO: Update cursor position on scroll.
45550
- var offset = scrivito.cms_document.offset(target);
45569
+ var offset = scrivito.cms_document.offset($target);
45551
45570
 
45552
45571
  if (edgeName === 'top') {
45553
- var prevRow = target.prev();
45554
- if (prevRow.length) {
45555
- var prevRowOffset = scrivito.cms_document.offset(prevRow);
45556
- offset.top = offsetCenter(prevRow, prevRowOffset, target, offset).top;
45572
+ var $prevRow = $target.prev();
45573
+ if ($prevRow.length) {
45574
+ var prevRowOffset = scrivito.cms_document.offset($prevRow);
45575
+ offset.top = offsetCenter($prevRow, prevRowOffset, offset).top;
45557
45576
  }
45558
45577
  } else {
45559
- var nextRow = target.next();
45560
- if (nextRow.length) {
45561
- var nextRowOffset = scrivito.cms_document.offset(nextRow);
45562
- offset.top = offsetCenter(target, offset, nextRow, nextRowOffset).top;
45578
+ var $nextRow = $target.next();
45579
+ if ($nextRow.length) {
45580
+ var nextRowOffset = scrivito.cms_document.offset($nextRow);
45581
+ offset.top = offsetCenter($target, offset, nextRowOffset).top;
45563
45582
  } else {
45564
- offset.top += target.outerHeight();
45583
+ offset.top += $target.outerHeight();
45565
45584
  }
45566
45585
  }
45567
45586
 
45568
- offset.left = scrivito.cms_document.offset(target.parent()).left;
45569
- cursor.offset(offset);
45570
-
45571
- if (isValidTarget(target)) {
45572
- cursor.removeClass('scrivito_dnd_forbidden');
45573
- } else {
45574
- cursor.addClass('scrivito_dnd_forbidden');
45575
- }
45587
+ offset.left = scrivito.cms_document.offset($target.parent()).left;
45588
+ $cursor.offset(offset);
45576
45589
 
45577
- showCursor(target);
45590
+ showCursor($target, drag);
45578
45591
  },
45579
45592
 
45580
- showColCursor: function showColCursor(edgeName, target, isWrapFree) {
45593
+ showColCursor: function showColCursor(edgeName, $target, drag, isWrapFree) {
45581
45594
  if (!scrivito.enableColDragDrool) {
45582
45595
  return;
45583
45596
  }
45584
45597
 
45585
- cursor.height(target.outerHeight());
45586
- cursor.width('0px');
45598
+ $cursor.height($target.outerHeight());
45599
+ $cursor.width('0px');
45587
45600
 
45588
45601
  // TODO: Update cursor position on scroll.
45589
- var offset = scrivito.cms_document.offset(target);
45602
+ var offset = scrivito.cms_document.offset($target);
45590
45603
 
45591
45604
  if (edgeName === 'left') {
45592
- var prevCol = target.prev();
45593
- if (prevCol.length && isWrapFree) {
45594
- var documentOffset = scrivito.cms_document.offset(prevCol);
45595
- offset.left = offsetCenter(prevCol, documentOffset, target, offset).left;
45596
- cursor.height(target.parent().outerHeight());
45605
+ var $prevCol = $target.prev();
45606
+ if ($prevCol.length && isWrapFree) {
45607
+ var documentOffset = scrivito.cms_document.offset($prevCol);
45608
+ offset.left = offsetCenter($prevCol, documentOffset, offset).left;
45609
+ $cursor.height($target.parent().outerHeight());
45597
45610
  }
45598
45611
  } else {
45599
- var nextCol = target.next();
45600
- if (nextCol.length && isWrapFree) {
45601
- var documentOffset = scrivito.cms_document.offset(nextCol);
45602
- offset.left = offsetCenter(target, offset, nextCol, documentOffset).left;
45603
- cursor.height(target.parent().outerHeight());
45612
+ var $nextCol = $target.next();
45613
+ if ($nextCol.length && isWrapFree) {
45614
+ var documentOffset = scrivito.cms_document.offset($nextCol);
45615
+ offset.left = offsetCenter($target, offset, documentOffset).left;
45616
+ $cursor.height($target.parent().outerHeight());
45604
45617
  } else {
45605
- offset.left += target.outerWidth();
45618
+ offset.left += $target.outerWidth();
45606
45619
  }
45607
45620
  }
45608
45621
 
45609
- cursor.offset(offset);
45610
- showCursor(target);
45622
+ $cursor.offset(offset);
45623
+ showCursor($target, drag);
45611
45624
  },
45612
45625
 
45613
- insertRow: function insertRow(target, edgeName, oldParent) {
45614
- $(draggedWidget.HTMLNode).hide();
45615
-
45616
- if (target.is('[data-scrivito-field-type=widgetlist]')) {
45617
- target.append(draggedWidget.HTMLNode);
45618
- } else {
45619
- target[edgeName === 'top' ? 'before' : 'after'](draggedWidget.HTMLNode);
45620
- }
45621
-
45622
- draggedWidget.HTMLNode.style.opacity = 1;
45623
- $(draggedWidget.HTMLNode).slideDown(100);
45624
-
45625
- if (scrivito.enableColDragDrool) {
45626
- garbageCollect(oldParent);
45627
- }
45628
-
45629
- scrivito.dragDrool.save(oldParent);
45626
+ // Public for test purpose only.
45627
+ buildDrag: function buildDrag(e) {
45628
+ return this.state.widgetDrag;
45630
45629
  },
45631
45630
 
45632
- insertCol: function insertCol(target, edgeName, oldParent) {
45633
- if (!scrivito.enableColDragDrool) {
45634
- draggedWidget.HTMLNode.style.opacity = 1;
45635
- return;
45636
- }
45637
-
45638
- var actualTarget = target;
45639
- var insertAtObjClass = actualTarget.attr('data-scrivito-widget-obj-class');
45640
-
45641
- if (insertAtObjClass !== 'ColumnWidget') {
45642
- actualTarget.wrap('<div class="row" data-scrivito-widget-obj-class=ColumnContainerWidget>' + '<div class="col-md-12" data-scrivito-widget-obj-class=ColumnWidget></div>' + '</div>');
45643
- actualTarget = target.parent();
45644
- }
45645
-
45646
- $(draggedWidget.HTMLNode).detach();
45647
- $(draggedWidget.HTMLNode).wrap('<div class="col-md-12" data-scrivito-widget-obj-class=ColumnWidget></div>');
45648
-
45649
- var insertionMethod = edgeName === 'left' ? 'before' : 'after';
45650
- actualTarget[insertionMethod]($(draggedWidget.HTMLNode).parent());
45651
-
45652
- $(draggedWidget.HTMLNode).css('opacity', '1');
45653
- $(draggedWidget.HTMLNode).show(100);
45654
-
45655
- garbageCollect(oldParent);
45656
-
45657
- resizeRow(actualTarget.closest('.row'));
45631
+ setState: function setState(newState) {
45632
+ state = _.extend(state, newState);
45658
45633
  },
45659
45634
 
45660
- save: function save($sourceField) {
45661
- var $draggedWidget = $(draggedWidget.HTMLNode);
45662
-
45663
- var widgetElement = scrivito.cms_element.from_dom_element($draggedWidget);
45664
- var sourceField = scrivito.cms_element.from_dom_element($sourceField);
45665
- var targetField = scrivito.cms_element.from_dom_element($draggedWidget.parent());
45666
-
45667
- scrivito.widgetlistFieldPlaceholder.update(sourceField);
45668
- scrivito.widgetlistFieldPlaceholder.update(targetField);
45669
-
45670
- updateModelFor(sourceField);
45671
- updateModelFor(targetField);
45672
-
45673
- if (!widgetElement.dom_element().is(targetField.inner_tag())) {
45674
- scrivito.widget_reloading.reload_widget(widgetElement);
45635
+ // For test purpose only.
45636
+ reset: function reset() {
45637
+ if ($cursor) {
45638
+ $cursor.remove();
45675
45639
  }
45640
+
45641
+ state = {};
45676
45642
  },
45677
45643
 
45678
- // For test purpose only.
45679
- cleanup: function cleanup() {
45680
- draggedWidget = {};
45681
- $('.scrivito_dnd_cursor').remove();
45644
+ _cleanup: function _cleanup() {
45645
+ $cursor.hide();
45646
+ this.setState({ widgetDrag: null });
45682
45647
  }
45683
45648
  }, {
45684
- draggedWidget: { // For test purpose only.
45685
-
45686
- get: function get() {
45687
- return draggedWidget;
45688
- },
45689
- configurable: true,
45690
- enumerable: true
45691
- },
45692
- lastGesture: {
45693
-
45694
- // For test purpose only.
45695
-
45649
+ state: {
45696
45650
  get: function get() {
45697
- return lastGesture;
45698
- },
45699
-
45700
- // For test purpose only.
45701
- set: function set(newGesture) {
45702
- lastGesture = newGesture;
45651
+ return state;
45703
45652
  },
45704
45653
  configurable: true,
45705
45654
  enumerable: true
45706
45655
  }
45707
45656
  });
45708
45657
 
45709
- var changeColClass = function changeColClass(elem, newClass) {
45710
- var animation = arguments.length <= 2 || arguments[2] === undefined ? 100 : arguments[2];
45711
-
45712
- var isOldClassFound = undefined;
45713
-
45714
- _.each(_.range(1, 13), function (i) {
45715
- var oldClass = 'col-md-' + i;
45716
- if ($(elem).hasClass(oldClass)) {
45717
- isOldClassFound = true;
45718
- if (oldClass !== newClass) {
45719
- $(elem).switchClass(oldClass, newClass, animation);
45720
- }
45721
- }
45722
- });
45723
-
45724
- if (!isOldClassFound) {
45725
- $(elem).addClass(newClass, animation);
45658
+ function showCursor($target, drag) {
45659
+ if (drag.canDropInto($target)) {
45660
+ $cursor.removeClass('scrivito_dnd_forbidden');
45661
+ } else {
45662
+ $cursor.addClass('scrivito_dnd_forbidden');
45726
45663
  }
45727
- };
45728
45664
 
45729
- var resizeRow = function resizeRow(row) {
45730
- var $row = $(row);
45731
- var cols = $row.children().toArray();
45732
- var space = 12;
45733
-
45734
- while (cols.length > 0) {
45735
- var size = Math.round(space / cols.length);
45736
- space -= size;
45737
- var col = cols.shift();
45738
- changeColClass(col, 'col-md-' + size, 100);
45665
+ if (drag.isStructureWidget()) {
45666
+ $cursor.addClass('scrivito_dnd_structure');
45667
+ } else {
45668
+ $cursor.removeClass('scrivito_dnd_structure');
45739
45669
  }
45740
- };
45741
-
45742
- var garbageCollect = function garbageCollect(elem) {
45743
- if ($(elem).attr('data-scrivito-widget-obj-class') === 'ColumnWidget') {
45744
- if ($(elem).children().length === 0) {
45745
- // remove empty column
45746
- var container = $(elem).parent();
45747
- elem.remove();
45748
45670
 
45749
- var leftoverCols = $(container).children();
45750
- if (leftoverCols.length > 1) {
45751
- resizeRow(container);
45752
- } else {
45753
- // unwrap last column
45754
- var lastCol = leftoverCols[0];
45755
- var widgetsToUnwrap = $(lastCol).children();
45756
-
45757
- if (widgetsToUnwrap.length === 0) {
45758
- // last column is empty.
45759
- // this should never happen, but better safe than sorry...
45760
- $(container).remove();
45761
- } else {
45762
- // remove column widget
45763
- $(widgetsToUnwrap).unwrap();
45764
-
45765
- // remove column container widget
45766
- $(widgetsToUnwrap).unwrap();
45767
- }
45768
- }
45769
- } else {
45770
- var childWidgets = $(elem).children();
45771
- if (childWidgets.length === 1) {
45772
- var lonelyChildWidget = childWidgets.eq(0);
45773
- if (lonelyChildWidget.is('[data-scrivito-widget-obj-class=ColumnContainerWidget]')) {
45774
- var colsToUnwrap = lonelyChildWidget.children();
45775
- if (colsToUnwrap.length) {
45776
- $(elem).replaceWith(colsToUnwrap);
45777
- }
45778
- }
45779
- }
45780
- }
45671
+ if ($target.hasClass('scrivito_empty_widget_field')) {
45672
+ $cursor.height($target.height());
45781
45673
  }
45782
- };
45783
45674
 
45784
- var offsetCenter = function offsetCenter(element, elementOffset, nextElem, nextElemOffset) {
45785
- var leftBoundary = elementOffset.left + element.outerWidth();
45675
+ $cursor.show();
45676
+ }
45677
+
45678
+ function offsetCenter($element, elementOffset, nextElemOffset) {
45679
+ var leftBoundary = elementOffset.left + $element.outerWidth();
45786
45680
  var rightBoundary = nextElemOffset.left;
45787
45681
  var horizOffset = (rightBoundary - leftBoundary) / 2;
45788
45682
  var left = leftBoundary + horizOffset;
45789
45683
 
45790
- var topBoundary = elementOffset.top + element.outerHeight();
45684
+ var topBoundary = elementOffset.top + $element.outerHeight();
45791
45685
  var bottomBoundary = nextElemOffset.top;
45792
45686
  var vertOffset = (bottomBoundary - topBoundary) / 2;
45793
45687
  var top = topBoundary + vertOffset;
45794
45688
 
45795
45689
  return { left: left, top: top };
45796
- };
45797
-
45798
- var updateModelFor = function updateModelFor(fieldElement) {
45799
- var container = fieldElement.container();
45800
- var newWidgets = widgetIdsToWidgets(container, fieldElement.content());
45801
- container.update(_defineProperty({}, fieldElement.field_name(), newWidgets));
45802
- };
45803
-
45804
- var widgetIdsToWidgets = function widgetIdsToWidgets(objOrWidget, ids) {
45805
- return _.map(ids, function (widgetId) {
45806
- return objOrWidget.widget(widgetId);
45807
- });
45808
- };
45809
-
45810
- var isValidTarget = function isValidTarget(target) {
45811
- var targetElement = scrivito.cms_element.from_dom_element(target);
45812
- if (targetElement.widget_field) {
45813
- targetElement = targetElement.widget_field();
45814
- }
45815
-
45816
- var draggedElement = scrivito.cms_element.from_dom_element($(draggedWidget.HTMLNode));
45817
-
45818
- return targetElement.is_valid_child_class(draggedElement.widget().widget_class_name());
45819
- };
45820
-
45821
- var showCursor = function showCursor(target) {
45822
- if ($(draggedWidget.HTMLNode).is('[data-scrivito-private-structure-widget]')) {
45823
- cursor.addClass('scrivito_dnd_structure');
45824
- } else {
45825
- cursor.removeClass('scrivito_dnd_structure');
45826
- }
45827
-
45828
- if (target.hasClass('scrivito_empty_widget_field')) {
45829
- showBoxCursor(target);
45830
- }
45831
-
45832
- cursor.show();
45833
- };
45834
-
45835
- var showBoxCursor = function showBoxCursor(target) {
45836
- cursor.height(target.height());
45837
- };
45690
+ }
45838
45691
  })();
45839
45692
  'use strict';
45840
45693
 
@@ -45903,7 +45756,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
45903
45756
  view.find(".scrivito_input_new_ws_name label, .scrivito_input_new_ws_name input").addClass("scrivito_disabled");
45904
45757
  });
45905
45758
 
45906
- view.on('focus click drop', '.scrivito_input_new_ws_name', function(e) {
45759
+ view.on('focus click', '.scrivito_input_new_ws_name', function(e) {
45907
45760
  create_new_ws = true;
45908
45761
  view.find(".scrivito_confirm").html(scrivito.t('menu_bar.create'));
45909
45762
  view.find(".scrivito_disabled").removeClass("scrivito_disabled");
@@ -46366,74 +46219,81 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
46366
46219
  }
46367
46220
  });
46368
46221
  }());
46369
- (function() {
46370
- var render, current_page;
46222
+ 'use strict';
46371
46223
 
46372
- _.extend(scrivito, {
46373
- menu_bar_conflict_indicator: {
46374
- init: function() {
46375
- scrivito.menu_bar.register_item_renderer(function(menu_bar) {
46376
- render = function(color, commands) {
46377
- var target = $(scrivito.template.render('menu_bar_conflict_indicator'))
46378
- .appendTo(menu_bar.find('#scrivito_menu_bar_conflict_indicator'));
46379
- target.show();
46380
- target.find('.scrivito_icon').addClass('scrivito_'+color);
46381
- target.on('click', function() {
46382
- scrivito.context_menu.toggle(target, commands, {css_class: 'conflict_indicator'});
46383
- });
46384
- };
46224
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
46385
46225
 
46386
- current_page = scrivito.application_document().page();
46387
- if (current_page) {
46388
- check_conflict(function() {
46389
- check_potential_conflicts();
46390
- });
46391
- }
46392
- });
46393
- }
46226
+ (function () {
46227
+ var render = undefined;
46228
+ var currentPage = undefined;
46229
+
46230
+ scrivito.menuBarConflictIndicator = {
46231
+ init: function init() {
46232
+ scrivito.menu_bar.register_item_renderer(function (menuBar) {
46233
+ render = function (color, commands) {
46234
+ var target = $(scrivito.template.render('menu_bar_conflict_indicator'));
46235
+
46236
+ target.appendTo(menuBar.find('#scrivito_menu_bar_conflict_indicator'));
46237
+ target.show();
46238
+ target.find('.scrivito_icon').addClass('scrivito_' + color);
46239
+
46240
+ target.on('click', function () {
46241
+ scrivito.context_menu.toggle(target, commands, { css_class: 'conflict_indicator' });
46242
+ });
46243
+ };
46244
+
46245
+ currentPage = scrivito.application_document().page();
46246
+ if (currentPage && scrivito.editing_context.selected_workspace.is_editable()) {
46247
+ checkConflict(checkPotentialConflicts);
46248
+ }
46249
+ });
46394
46250
  }
46395
- });
46251
+ };
46396
46252
 
46397
- var check_conflict = function(next) {
46398
- if (current_page.has_conflict()) {
46399
- render_conflict();
46253
+ function checkConflict(next) {
46254
+ if (currentPage.has_conflict()) {
46255
+ renderConflict();
46400
46256
  } else {
46401
46257
  next();
46402
46258
  }
46403
- };
46259
+ }
46404
46260
 
46405
- var check_potential_conflicts = function() {
46406
- current_page.conflicting_workspaces().done(function(workspaces) {
46261
+ function checkPotentialConflicts() {
46262
+ currentPage.conflicting_workspaces().done(function (workspaces) {
46407
46263
  if (workspaces.length) {
46408
- render_potential_conflicts(workspaces);
46264
+ renderPotentialConflict(workspaces);
46409
46265
  }
46410
46266
  });
46411
- };
46267
+ }
46412
46268
 
46413
- var render_conflict = function() {
46269
+ function renderConflict() {
46414
46270
  render('red', [{
46415
- id: function() { return 'scrivito.menu_bar_conflict_indicator.header'; },
46416
- render: function() {
46271
+ id: function id() {
46272
+ return 'scrivito.menu_bar_conflict_indicator.header';
46273
+ },
46274
+
46275
+ render: function render() {
46417
46276
  return scrivito.template.render('menu_bar_conflict_indicator/conflict');
46418
46277
  }
46419
46278
  }]);
46420
- };
46279
+ }
46421
46280
 
46422
- var render_potential_conflicts = function(workspaces) {
46281
+ function renderPotentialConflict(workspaces) {
46423
46282
  render('yellow', [{
46424
- id: function() { return 'scrivito.menu_bar_conflict_indicator.header'; },
46425
- render: function() {
46283
+ id: function id() {
46284
+ return 'scrivito.menu_bar_conflict_indicator.header';
46285
+ },
46286
+
46287
+ render: function render() {
46426
46288
  return scrivito.template.render('menu_bar_conflict_indicator/warn', {
46427
- headline_color: 'yellow',
46289
+ headlineColor: 'yellow',
46428
46290
  headline: scrivito.t('menu_bar_conflict_indicator.warn_headline'),
46429
46291
  description: scrivito.t('menu_bar_conflict_indicator.warn_description')
46430
46292
  });
46431
46293
  }
46432
- }].concat(_.map(workspaces, function(ws) {
46433
- return scrivito.select_workspace_command(ws);
46434
- })));
46435
- };
46436
- }());
46294
+ }].concat(_toConsumableArray(_.map(workspaces, scrivito.select_workspace_command))));
46295
+ }
46296
+ })();
46437
46297
  (function() {
46438
46298
  _.extend(scrivito, {
46439
46299
  menu_bar_device_toggle: {
@@ -47269,6 +47129,262 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
47269
47129
  }
47270
47130
  });
47271
47131
  })();
47132
+ 'use strict';
47133
+
47134
+ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
47135
+
47136
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
47137
+
47138
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
47139
+
47140
+ (function () {
47141
+ scrivito.WidgetDrag = (function () {
47142
+ function WidgetDrag(object) {
47143
+ _classCallCheck(this, WidgetDrag);
47144
+
47145
+ if (object instanceof jQuery) {
47146
+ this._domElement = object.get(0);
47147
+ this._$domElement = object;
47148
+ } else {
47149
+ this._domElement = object;
47150
+ this._$domElement = $(object);
47151
+ }
47152
+
47153
+ this._isHidden = false;
47154
+ }
47155
+
47156
+ _createClass(WidgetDrag, [{
47157
+ key: 'isHidden',
47158
+
47159
+ // For test purpose only.
47160
+ value: function isHidden() {
47161
+ return this._isHidden;
47162
+ }
47163
+ }, {
47164
+ key: 'canDropInto',
47165
+ value: function canDropInto($target) {
47166
+ if (scrivito.enableColDragDrool) {
47167
+ return true;
47168
+ }
47169
+
47170
+ var targetElement = scrivito.cms_element.from_dom_element($target);
47171
+ if (targetElement.widget_field) {
47172
+ targetElement = targetElement.widget_field();
47173
+ }
47174
+
47175
+ var draggedElement = scrivito.cms_element.from_dom_element(this._$domElement);
47176
+ return targetElement.is_valid_child_class(draggedElement.widget().widget_class_name());
47177
+ }
47178
+ }, {
47179
+ key: 'isStructureWidget',
47180
+ value: function isStructureWidget() {
47181
+ return this._$domElement.is('[data-scrivito-private-structure-widget]');
47182
+ }
47183
+ }, {
47184
+ key: 'onDragover',
47185
+ value: function onDragover() {
47186
+ if (!this._isHidden) {
47187
+ // jQuery's "css" function does not work correctly in a Chrome + Jasmine environment,
47188
+ // so we need to use the low-level accessors in order to test the behavior.
47189
+ this._domElement.style.opacity = '0.5';
47190
+ this._isHidden = true;
47191
+ }
47192
+ }
47193
+ }, {
47194
+ key: 'dropInto',
47195
+ value: function dropInto($target, edgeName) {
47196
+ // Dropped the widget back.
47197
+ if ($target.is(this._$domElement)) {
47198
+ return this.onCancel();
47199
+ }
47200
+
47201
+ if (edgeName === 'top' || edgeName === 'bottom') {
47202
+ var $sourceList = this._$domElement.parent();
47203
+ this.insertRow($target, edgeName);
47204
+
47205
+ var $targetList = this._$domElement.parent();
47206
+ this.save($sourceList, $targetList);
47207
+ } else {
47208
+ if (scrivito.enableColDragDrool) {
47209
+ this.insertCol($target, edgeName);
47210
+ } else {
47211
+ this.onCancel();
47212
+ }
47213
+ }
47214
+ }
47215
+
47216
+ // Public only for test purpose.
47217
+ }, {
47218
+ key: 'insertRow',
47219
+ value: function insertRow($target, edgeName) {
47220
+ var $sourceList = this._$domElement.parent();
47221
+
47222
+ this._$domElement.hide();
47223
+
47224
+ if ($target.is('[data-scrivito-field-type=widgetlist]')) {
47225
+ $target.append(this._$domElement);
47226
+ } else {
47227
+ $target[edgeName === 'top' ? 'before' : 'after'](this._$domElement);
47228
+ }
47229
+
47230
+ this._domElement.style.opacity = 1;
47231
+ this._$domElement.slideDown(100);
47232
+
47233
+ if (scrivito.enableColDragDrool) {
47234
+ this._garbageCollect($sourceList);
47235
+ }
47236
+ }
47237
+
47238
+ // Public only for test purpose.
47239
+ }, {
47240
+ key: 'insertCol',
47241
+ value: function insertCol($target, edgeName) {
47242
+ var $sourceList = this._$domElement.parent();
47243
+
47244
+ var $actualTarget = $target;
47245
+ var insertAtObjClass = $actualTarget.attr('data-scrivito-widget-obj-class');
47246
+
47247
+ if (insertAtObjClass !== 'ColumnWidget') {
47248
+ $actualTarget.wrap('<div class="row" data-scrivito-widget-obj-class=ColumnContainerWidget>' + '<div class="col-md-12" data-scrivito-widget-obj-class=ColumnWidget></div>' + '</div>');
47249
+ $actualTarget = $target.parent();
47250
+ }
47251
+
47252
+ this._$domElement.detach();
47253
+ this._$domElement.wrap('<div class="col-md-12" data-scrivito-widget-obj-class=ColumnWidget></div>');
47254
+
47255
+ var insertionMethod = edgeName === 'left' ? 'before' : 'after';
47256
+ $actualTarget[insertionMethod](this._$domElement.parent());
47257
+
47258
+ this._$domElement.css('opacity', '1');
47259
+ this._$domElement.show(100);
47260
+
47261
+ this._garbageCollect($sourceList);
47262
+ this._resizeRow($actualTarget.closest('.row'));
47263
+ }
47264
+
47265
+ // Public only for test purpose.
47266
+ }, {
47267
+ key: 'save',
47268
+ value: function save($source, $target) {
47269
+ if (scrivito.enableColDragDrool) {
47270
+ return;
47271
+ }
47272
+
47273
+ var sourceField = scrivito.cms_element.from_dom_element($source);
47274
+ var targetField = scrivito.cms_element.from_dom_element($target);
47275
+
47276
+ scrivito.widgetlistFieldPlaceholder.update(sourceField);
47277
+ scrivito.widgetlistFieldPlaceholder.update(targetField);
47278
+
47279
+ this._updateModelFor(sourceField);
47280
+ this._updateModelFor(targetField);
47281
+
47282
+ var widgetElement = scrivito.cms_element.from_dom_element(this._$domElement);
47283
+ if (!widgetElement.dom_element().is(targetField.inner_tag())) {
47284
+ scrivito.widget_reloading.reload_widget(widgetElement);
47285
+ }
47286
+ }
47287
+ }, {
47288
+ key: 'onCancel',
47289
+ value: function onCancel() {
47290
+ this._domElement.style.opacity = 1;
47291
+ }
47292
+ }, {
47293
+ key: '_resizeRow',
47294
+ value: function _resizeRow($row) {
47295
+ var cols = $row.children().toArray();
47296
+ var space = 12;
47297
+
47298
+ while (cols.length > 0) {
47299
+ var size = Math.round(space / cols.length);
47300
+ space -= size;
47301
+ var col = cols.shift();
47302
+ this._changeColClass($(col), 'col-md-' + size, 100);
47303
+ }
47304
+ }
47305
+ }, {
47306
+ key: '_garbageCollect',
47307
+ value: function _garbageCollect($elem) {
47308
+ if ($elem.attr('data-scrivito-widget-obj-class') === 'ColumnWidget') {
47309
+ if ($elem.children().length === 0) {
47310
+ // remove empty column
47311
+ var $container = $elem.parent();
47312
+ $elem.remove();
47313
+
47314
+ var $leftoverCols = $container.children();
47315
+ if ($leftoverCols.length > 1) {
47316
+ this._resizeRow($container);
47317
+ } else {
47318
+ // unwrap last column
47319
+ var $lastCol = $leftoverCols.eq(0);
47320
+ var $widgetsToUnwrap = $lastCol.children();
47321
+
47322
+ if ($widgetsToUnwrap.length === 0) {
47323
+ // last column is empty.
47324
+ // this should never happen, but better safe than sorry...
47325
+ $container.remove();
47326
+ } else {
47327
+ // remove column widget
47328
+ $widgetsToUnwrap.unwrap();
47329
+
47330
+ // remove column container widget
47331
+ $widgetsToUnwrap.unwrap();
47332
+ }
47333
+ }
47334
+ } else {
47335
+ var $childWidgets = $elem.children();
47336
+ if ($childWidgets.length === 1) {
47337
+ var $lonelyChildWidget = $childWidgets.eq(0);
47338
+ if ($lonelyChildWidget.is('[data-scrivito-widget-obj-class=ColumnContainerWidget]')) {
47339
+ var $colsToUnwrap = $lonelyChildWidget.children();
47340
+ if ($colsToUnwrap.length) {
47341
+ $elem.replaceWith($colsToUnwrap);
47342
+ }
47343
+ }
47344
+ }
47345
+ }
47346
+ }
47347
+ }
47348
+ }, {
47349
+ key: '_changeColClass',
47350
+ value: function _changeColClass($col, newClass) {
47351
+ var animation = arguments.length <= 2 || arguments[2] === undefined ? 100 : arguments[2];
47352
+
47353
+ var isOldClassFound = undefined;
47354
+
47355
+ _.each(_.range(1, 13), function (i) {
47356
+ var oldClass = 'col-md-' + i;
47357
+ if ($col.hasClass(oldClass)) {
47358
+ isOldClassFound = true;
47359
+ if (oldClass !== newClass) {
47360
+ $col.switchClass(oldClass, newClass, animation);
47361
+ }
47362
+ }
47363
+ });
47364
+
47365
+ if (!isOldClassFound) {
47366
+ $col.addClass(newClass, animation);
47367
+ }
47368
+ }
47369
+ }, {
47370
+ key: '_updateModelFor',
47371
+ value: function _updateModelFor(fieldElement) {
47372
+ var container = fieldElement.container();
47373
+ var widgets = _.map(fieldElement.content(), function (id) {
47374
+ return container.widget(id);
47375
+ });
47376
+ container.update(_defineProperty({}, fieldElement.field_name(), widgets));
47377
+ }
47378
+ }, {
47379
+ key: 'domElement',
47380
+ get: function get() {
47381
+ return this._domElement;
47382
+ }
47383
+ }]);
47384
+
47385
+ return WidgetDrag;
47386
+ })();
47387
+ })();
47272
47388
  (function() {
47273
47389
  _.extend(scrivito, {
47274
47390
  widget_marker: {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivito_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0.rc1
4
+ version: 1.4.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Infopark AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-10 00:00:00.000000000 Z
11
+ date: 2016-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable