scrivito_sdk 1.1.0.rc1 → 1.1.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/ca-bundle.crt +1 -1
- data/lib/assets/javascripts/scrivito_ui.js +257 -258
- data/lib/scrivito/binary.rb +54 -33
- data/lib/scrivito/cms_rest_api.rb +8 -11
- data/lib/scrivito/future_binary.rb +15 -10
- data/lib/scrivito/obj_params_parser.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a74fbb94276191a2a93a9bc371135f056a17dd91
|
4
|
+
data.tar.gz: 92608b0a4cc5523941e4bbd0c25e09635ecbb3c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 625a81d42efb11d2476a03fa71ea7ac995989bdf7e9758c6844008a0635f3f3395c9f6efb5ca589f535f77bfc6c46322ebd3b023693ec8a742c6da23f9967699
|
7
|
+
data.tar.gz: 234c9870ee5c7af5c102d86a0e95764f6cad72595caa62f2907933a8c788f72dcb33e17ac310409f1b338be3401916b5ebdc182aa57855acc62a064f334bf8fe
|
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:
|
4
|
+
## Certificate data from Mozilla as of: Thu Jan 14 17:21:14 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
|
@@ -31946,13 +31946,16 @@ var scrivito = {}; // jshint ignore:line
|
|
31946
31946
|
};
|
31947
31947
|
|
31948
31948
|
var serialize_copied_binary = function(attr_name, attr_value) {
|
31949
|
-
|
31949
|
+
var copy_params = {
|
31950
31950
|
obj_id: attr_value.obj_id,
|
31951
31951
|
widget_id: attr_value.widget_id,
|
31952
|
-
attribute_name: attr_value.attr_name
|
31953
|
-
|
31954
|
-
|
31955
|
-
}
|
31952
|
+
attribute_name: attr_value.attr_name
|
31953
|
+
};
|
31954
|
+
|
31955
|
+
if (attr_value.filename) { copy_params.filename = attr_value.filename; }
|
31956
|
+
if (attr_value.content_type) { copy_params.content_type = attr_value.content_type; }
|
31957
|
+
|
31958
|
+
return [attr_name, {copy: copy_params}];
|
31956
31959
|
};
|
31957
31960
|
|
31958
31961
|
var is_uploaded_binary = function(object) {
|
@@ -32057,6 +32060,8 @@ var scrivito = {}; // jshint ignore:line
|
|
32057
32060
|
},
|
32058
32061
|
|
32059
32062
|
upload_binary: function(params) {
|
32063
|
+
assert_valid_params(params);
|
32064
|
+
|
32060
32065
|
var blob = params.blob || params.file;
|
32061
32066
|
if (!blob) { $.error('need blob or file'); }
|
32062
32067
|
if (!params.content_type) { params.content_type = blob.type; }
|
@@ -32067,6 +32072,17 @@ var scrivito = {}; // jshint ignore:line
|
|
32067
32072
|
params.filename = params.filename.replace(/[^\w\-_\.$]/g, '-');
|
32068
32073
|
|
32069
32074
|
return $.extend(params, {is_uploaded_binary: true});
|
32075
|
+
},
|
32076
|
+
|
32077
|
+
copy_binary: function(obj_id, widget_id, attr_name, params) {
|
32078
|
+
assert_valid_params(params);
|
32079
|
+
|
32080
|
+
return _.extend({
|
32081
|
+
is_copied_binary: true,
|
32082
|
+
obj_id: obj_id,
|
32083
|
+
widget_id: widget_id,
|
32084
|
+
attr_name: attr_name
|
32085
|
+
}, params);
|
32070
32086
|
}
|
32071
32087
|
}
|
32072
32088
|
});
|
@@ -32099,6 +32115,16 @@ var scrivito = {}; // jshint ignore:line
|
|
32099
32115
|
content_type: content_type
|
32100
32116
|
}});
|
32101
32117
|
};
|
32118
|
+
|
32119
|
+
var assert_valid_params = function(params) {
|
32120
|
+
if (_.has(params, 'filename') && !params.filename) {
|
32121
|
+
$.error('filename cannot be blank');
|
32122
|
+
}
|
32123
|
+
|
32124
|
+
if (_.has(params, 'content_type') && !params.content_type) {
|
32125
|
+
$.error('content_type cannot be blank');
|
32126
|
+
}
|
32127
|
+
};
|
32102
32128
|
}());
|
32103
32129
|
(function() {
|
32104
32130
|
_.extend(scrivito, {
|
@@ -32614,12 +32640,12 @@ var scrivito = {}; // jshint ignore:line
|
|
32614
32640
|
},
|
32615
32641
|
|
32616
32642
|
copy: function(params) {
|
32617
|
-
return
|
32618
|
-
|
32619
|
-
|
32620
|
-
|
32621
|
-
|
32622
|
-
|
32643
|
+
return scrivito.blob.copy_binary(
|
32644
|
+
that.obj().id(),
|
32645
|
+
that.widget() && that.widget().id(),
|
32646
|
+
that.field_name(),
|
32647
|
+
params
|
32648
|
+
);
|
32623
32649
|
}
|
32624
32650
|
});
|
32625
32651
|
}
|
@@ -37061,8 +37087,6 @@ var scrivito = {}; // jshint ignore:line
|
|
37061
37087
|
};
|
37062
37088
|
})();
|
37063
37089
|
(function() {
|
37064
|
-
var focus;
|
37065
|
-
var focus_stack = [];
|
37066
37090
|
var dragging;
|
37067
37091
|
|
37068
37092
|
// GEOMETRY UTILS
|
@@ -37070,8 +37094,8 @@ var scrivito = {}; // jshint ignore:line
|
|
37070
37094
|
// distance between point and rectangle
|
37071
37095
|
// returns 0 if point is inside rectangle
|
37072
37096
|
var distance_point_rectangle = function(point, rect) {
|
37073
|
-
var clamped_x = Math.max(Math.min(point.x, rect.
|
37074
|
-
var clamped_y = Math.max(Math.min(point.y, rect.
|
37097
|
+
var clamped_x = Math.max(Math.min(point.x, rect.x2), rect.x1);
|
37098
|
+
var clamped_y = Math.max(Math.min(point.y, rect.y2), rect.y1);
|
37075
37099
|
|
37076
37100
|
var dist_x = point.x - clamped_x;
|
37077
37101
|
var dist_y = point.y - clamped_y;
|
@@ -37079,6 +37103,55 @@ var scrivito = {}; // jshint ignore:line
|
|
37079
37103
|
return Math.sqrt(dist_x * dist_x + dist_y * dist_y);
|
37080
37104
|
};
|
37081
37105
|
|
37106
|
+
// given a rectangle, calculate it's center
|
37107
|
+
var center_of_rectangle = function(rect) {
|
37108
|
+
return { x: (rect.x1 + rect.x2) / 2, y: (rect.y1 + rect.y2) / 2 };
|
37109
|
+
};
|
37110
|
+
|
37111
|
+
// given a rectangle, return it's edges.
|
37112
|
+
// the edges are returned as rectangles with either
|
37113
|
+
// width=0 for left and right, or
|
37114
|
+
// heigth=0 for top and bottom.
|
37115
|
+
var edges_of_rectangle = function(rect) {
|
37116
|
+
return {
|
37117
|
+
left: {
|
37118
|
+
x1: rect.x1,
|
37119
|
+
y1: rect.y1,
|
37120
|
+
x2: rect.x1,
|
37121
|
+
y2: rect.y2
|
37122
|
+
},
|
37123
|
+
right: {
|
37124
|
+
x1: rect.x2,
|
37125
|
+
y1: rect.y1,
|
37126
|
+
x2: rect.x2,
|
37127
|
+
y2: rect.y2
|
37128
|
+
},
|
37129
|
+
top: {
|
37130
|
+
x1: rect.x1,
|
37131
|
+
y1: rect.y1,
|
37132
|
+
x2: rect.x2,
|
37133
|
+
y2: rect.y1
|
37134
|
+
},
|
37135
|
+
bottom: {
|
37136
|
+
x1: rect.x1,
|
37137
|
+
y1: rect.y2,
|
37138
|
+
x2: rect.x2,
|
37139
|
+
y2: rect.y2
|
37140
|
+
}
|
37141
|
+
};
|
37142
|
+
};
|
37143
|
+
|
37144
|
+
// calculate the rectangle that results from cropping the rectangle `rect`
|
37145
|
+
// to be inside the rectangle `crop`.
|
37146
|
+
var crop_rectangle = function(rect, crop) {
|
37147
|
+
return {
|
37148
|
+
x1: Math.min(crop.x2, Math.max(crop.x1, rect.x1)),
|
37149
|
+
y1: Math.min(crop.y2, Math.max(crop.y1, rect.y1)),
|
37150
|
+
x2: Math.min(crop.x2, Math.max(crop.x1, rect.x2)),
|
37151
|
+
y2: Math.min(crop.y2, Math.max(crop.y1, rect.y2))
|
37152
|
+
};
|
37153
|
+
};
|
37154
|
+
|
37082
37155
|
var is_wrap_between = function(column, next_column) {
|
37083
37156
|
var column_offset = column.offset();
|
37084
37157
|
var next_column_offset = next_column.offset();
|
@@ -37115,10 +37188,10 @@ var scrivito = {}; // jshint ignore:line
|
|
37115
37188
|
}
|
37116
37189
|
|
37117
37190
|
return {
|
37118
|
-
|
37119
|
-
|
37120
|
-
|
37121
|
-
|
37191
|
+
x1: offset.left,
|
37192
|
+
y1: offset.top,
|
37193
|
+
x2: offset.left + element.outerWidth(),
|
37194
|
+
y2: offset.top + height
|
37122
37195
|
};
|
37123
37196
|
};
|
37124
37197
|
|
@@ -37215,70 +37288,15 @@ var scrivito = {}; // jshint ignore:line
|
|
37215
37288
|
}
|
37216
37289
|
};
|
37217
37290
|
|
37218
|
-
// FOCUS MARKER
|
37219
|
-
|
37220
|
-
var focus_marker = function() {
|
37221
|
-
var focus_marker;
|
37222
|
-
|
37223
|
-
var rects;
|
37224
|
-
|
37225
|
-
var show_rectangle = function(num, x1, y1, x2, y2) {
|
37226
|
-
var rect = $(rects[num]);
|
37227
|
-
|
37228
|
-
rect.offset({left: x1, top: y1});
|
37229
|
-
rect.width(x2 - x1);
|
37230
|
-
rect.height(y2 - y1);
|
37231
|
-
|
37232
|
-
rect.show();
|
37233
|
-
};
|
37234
|
-
|
37235
|
-
return {
|
37236
|
-
init: function() {
|
37237
|
-
rects = _.map(_.range(4), function() {
|
37238
|
-
var rect = $("<div class='focus_marker'></div>");
|
37239
|
-
rect.css("pointer-events", "none");
|
37240
|
-
rect.css("background", "rgba(255, 159, 0, 0.25)");
|
37241
|
-
rect.css("position", "absolute");
|
37242
|
-
rect.hide();
|
37243
|
-
|
37244
|
-
$("body").append(rect);
|
37245
|
-
|
37246
|
-
return rect;
|
37247
|
-
});
|
37248
|
-
},
|
37249
|
-
|
37250
|
-
show: function(focus) {
|
37251
|
-
var offset = scrivito.cms_document.offset(focus)
|
37252
|
-
var bounds = bounding_rectangle(focus);
|
37253
|
-
var width = bounds.width;
|
37254
|
-
var height = bounds.height;
|
37255
|
-
|
37256
|
-
// FIXME, use actual values
|
37257
|
-
var window_bottom = 2048;
|
37258
|
-
var window_right = 2048;
|
37259
|
-
|
37260
|
-
show_rectangle(0, 0, 0, offset.left, window_bottom);
|
37261
|
-
show_rectangle(1, offset.left + width, 0, window_right, window_bottom);
|
37262
|
-
|
37263
|
-
show_rectangle(2, offset.left, 0, offset.left + width, offset.top);
|
37264
|
-
show_rectangle(3, offset.left, offset.top + height, offset.left + width, window_bottom);
|
37265
|
-
},
|
37266
|
-
|
37267
|
-
hide: function() {
|
37268
|
-
_.each(rects, function(rect) { $(rect).hide(); });
|
37269
|
-
}
|
37270
|
-
};
|
37271
|
-
}();
|
37272
|
-
|
37273
37291
|
var find_selectable_targets = function(root) {
|
37274
37292
|
root = $(root);
|
37275
37293
|
|
37276
|
-
if (root.is('[data-scrivito-widget-obj-class=ColumnWidget]')
|
37294
|
+
if (root.is('[data-scrivito-widget-obj-class=ColumnWidget]') ||
|
37295
|
+
root.is('[data-scrivito-widget-obj-class=ColumnContainerWidget]')) {
|
37277
37296
|
return root.children();
|
37278
37297
|
}
|
37279
37298
|
|
37280
|
-
var widgetlists = root.find('[data-scrivito-field-type=widgetlist]')
|
37281
|
-
.addBack('[data-scrivito-field-type=widgetlist]');
|
37299
|
+
var widgetlists = root.find('[data-scrivito-field-type=widgetlist]');
|
37282
37300
|
widgetlists = _.reject(widgetlists, function(widgetlist) {
|
37283
37301
|
// Reject if not a top-level widgetlist.
|
37284
37302
|
var wrapping_widgetlist = $(widgetlist).parent()
|
@@ -37299,93 +37317,150 @@ var scrivito = {}; // jshint ignore:line
|
|
37299
37317
|
return selectable_targets;
|
37300
37318
|
};
|
37301
37319
|
|
37302
|
-
var find_gesture_targets = function(mouse,
|
37303
|
-
var selectable_targets = find_selectable_targets(
|
37304
|
-
var
|
37305
|
-
var target;
|
37320
|
+
var find_gesture_targets = function(mouse, root) {
|
37321
|
+
var selectable_targets = find_selectable_targets(root);
|
37322
|
+
var target = detect_closest(mouse, selectable_targets);
|
37306
37323
|
|
37307
|
-
if (
|
37308
|
-
|
37309
|
-
} else {
|
37310
|
-
target = target_row;
|
37324
|
+
if (!target) {
|
37325
|
+
return [];
|
37311
37326
|
}
|
37312
37327
|
|
37313
|
-
|
37314
|
-
|
37315
|
-
|
37328
|
+
if (target === dragging) {
|
37329
|
+
return [target];
|
37330
|
+
}
|
37331
|
+
|
37332
|
+
return [target].concat(find_gesture_targets(mouse, target));
|
37333
|
+
};
|
37334
|
+
|
37335
|
+
// given a list of boxes containing each other and the center,
|
37336
|
+
// calculate an adjusted list of boxes so that the edges of successive boxes
|
37337
|
+
// do not touch each other, i.e. there is free space between successive boxes.
|
37338
|
+
// the boxes are adjusted by making successor boxes smaller to create space.
|
37339
|
+
// the first box is never adjusted.
|
37340
|
+
// if the overall space is to tight to create the desired amount of space,
|
37341
|
+
// as much as possible is created, distributed equally between all boxes.
|
37342
|
+
// all adjustments are made with respect to the center,
|
37343
|
+
// i.e. box edges are moved towards the center, but never across the center.
|
37344
|
+
var disperse_boxes = function(center, boxes) {
|
37345
|
+
var box = boxes[0];
|
37346
|
+
var successor_box = boxes[1];
|
37347
|
+
|
37348
|
+
if (!successor_box) { return boxes; }
|
37349
|
+
|
37350
|
+
// the desired amount of space between edges of successive boxes, in pixels.
|
37351
|
+
var desired_space = 20;
|
37352
|
+
|
37353
|
+
// calculate maximum amount of adjustment for each edge
|
37354
|
+
// in order to leave enough space for successive boxes.
|
37355
|
+
var max_x1 = (center.x - box.x1) / boxes.length;
|
37356
|
+
var max_y1 = (center.y - box.y1) / boxes.length;
|
37357
|
+
var max_x2 = (box.x2 - center.x) / boxes.length;
|
37358
|
+
var max_y2 = (box.y2 - center.y) / boxes.length;
|
37359
|
+
|
37360
|
+
// the largest possible box within `box` that leaves enough space
|
37361
|
+
var maximum_box = {
|
37362
|
+
x1: box.x1 + Math.min(desired_space, max_x1),
|
37363
|
+
y1: box.y1 + Math.min(desired_space, max_y1),
|
37364
|
+
x2: box.x2 - Math.min(desired_space, max_x2),
|
37365
|
+
y2: box.y2 - Math.min(desired_space, max_y2)
|
37316
37366
|
};
|
37367
|
+
|
37368
|
+
// crop successor_box to fit inside the largest possible box
|
37369
|
+
var adjusted_box = crop_rectangle(successor_box, maximum_box);
|
37370
|
+
|
37371
|
+
// recurse on remaining boxes
|
37372
|
+
var remaining_boxes = [adjusted_box].concat(boxes.slice(2));
|
37373
|
+
return [box].concat(disperse_boxes(center, remaining_boxes));
|
37317
37374
|
};
|
37318
37375
|
|
37319
|
-
var
|
37320
|
-
|
37321
|
-
|
37322
|
-
|
37323
|
-
|
37324
|
-
|
37376
|
+
var adjust_boxes = function(boxes) {
|
37377
|
+
var innermost_box = boxes[boxes.length - 1];
|
37378
|
+
|
37379
|
+
// crop innermost box to lie inside all outer boxes
|
37380
|
+
_.each(boxes, function(box) {
|
37381
|
+
innermost_box = crop_rectangle(innermost_box, box);
|
37382
|
+
});
|
37325
37383
|
|
37326
|
-
|
37327
|
-
|
37328
|
-
var rowHeight = target_row.height();
|
37384
|
+
return disperse_boxes(center_of_rectangle(innermost_box), boxes);
|
37385
|
+
};
|
37329
37386
|
|
37330
|
-
|
37331
|
-
|
37387
|
+
var build_edges_for = function(target, box) {
|
37388
|
+
target = $(target);
|
37332
37389
|
|
37333
|
-
var
|
37334
|
-
var event_target_y_abs = mouse.y - targetY;
|
37335
|
-
var event_target_y = event_target_y_abs / targetHeight;
|
37390
|
+
var box_edges = edges_of_rectangle(box);
|
37336
37391
|
|
37337
|
-
|
37338
|
-
|
37339
|
-
|
37340
|
-
|
37392
|
+
if (target.is('[data-scrivito-widget-obj-class=ColumnWidget]')) {
|
37393
|
+
// inserting directly above or below does not make sense
|
37394
|
+
// for a Column (user should insert inside the Column instead)
|
37395
|
+
delete box_edges.top;
|
37396
|
+
delete box_edges.bottom;
|
37397
|
+
}
|
37341
37398
|
|
37342
|
-
if (
|
37399
|
+
if (target.is('[data-scrivito-widget-obj-class=ColumnContainerWidget]')) {
|
37400
|
+
// inserting directly left or right does not make sense
|
37401
|
+
// for a ColumnContainer
|
37402
|
+
// (user should insert a new Column inside the Container instead)
|
37403
|
+
delete box_edges.left;
|
37404
|
+
delete box_edges.right;
|
37405
|
+
}
|
37406
|
+
|
37407
|
+
if (
|
37408
|
+
target.parent().is('[data-scrivito-widget-obj-class=ColumnWidget]') &&
|
37409
|
+
target.siblings().length === 0
|
37410
|
+
) {
|
37411
|
+
// inserting directly left or right does not make sense
|
37412
|
+
// for the only item inside a Column
|
37413
|
+
// (user should insert a new Column instead)
|
37414
|
+
delete box_edges.left;
|
37415
|
+
delete box_edges.right;
|
37416
|
+
}
|
37417
|
+
|
37418
|
+
if (target.is('[data-scrivito-field-type=widgetlist]')) {
|
37419
|
+
// inserting left, right or at the bottom does not make sense
|
37420
|
+
// for an empty widgetlist
|
37421
|
+
// (user should insert a first Row before inserting Columns)
|
37422
|
+
delete box_edges.left;
|
37423
|
+
delete box_edges.right;
|
37424
|
+
delete box_edges.bottom;
|
37425
|
+
}
|
37426
|
+
|
37427
|
+
return _.map(box_edges, function(rectangle, name) {
|
37343
37428
|
return {
|
37344
|
-
|
37345
|
-
|
37429
|
+
rectangle: rectangle,
|
37430
|
+
target: target,
|
37431
|
+
name: name
|
37346
37432
|
};
|
37347
|
-
}
|
37348
|
-
var targetX = $(target).offset().left;
|
37349
|
-
var targetWidth = $(target).width();
|
37350
|
-
var event_target_x_abs = mouse.x - targetX;
|
37351
|
-
var eventX = event_target_x_abs / targetWidth;
|
37352
|
-
|
37353
|
-
var widget_obj_class = $(target).attr("data-scrivito-widget-obj-class");
|
37354
|
-
var contains_widgetlist = !!$(target).find('[data-scrivito-field-type=widgetlist]').length;
|
37355
|
-
var is_applicable_for_insert_inside = (contains_widgetlist || widget_obj_class === 'ColumnWidget') &&
|
37356
|
-
dragging !== target;
|
37357
|
-
|
37358
|
-
var is_col_insert_before = eventX < (1 / 4) && event_target_x_abs < 20;
|
37359
|
-
var is_col_insert_after = eventX > (3 / 4) && event_target_x_abs > (targetWidth - 20);
|
37360
|
-
var distance = distance_point_rectangle(mouse, bounding_rectangle(target));
|
37361
|
-
if (is_applicable_for_insert_inside && !is_col_insert_before && !is_col_insert_after && distance < 20) {
|
37362
|
-
return {
|
37363
|
-
name: 'insert_inside',
|
37364
|
-
before: event_target_y < (1 / 2)
|
37365
|
-
};
|
37366
|
-
} else {
|
37367
|
-
return {
|
37368
|
-
name: 'col_insert',
|
37369
|
-
before: eventX < 0.5
|
37370
|
-
};
|
37371
|
-
}
|
37372
|
-
}
|
37433
|
+
});
|
37373
37434
|
};
|
37374
37435
|
|
37375
|
-
var
|
37376
|
-
|
37377
|
-
var distance = distance_point_rectangle(mouse, bounding_rectangle(focus));
|
37378
|
-
if (distance > 20) {
|
37379
|
-
return focus_stack.pop();
|
37380
|
-
} else {
|
37381
|
-
var targets = find_gesture_targets(mouse, _.last(focus_stack) || $(focus).closest('body'));
|
37382
|
-
if (targets.target && targets.target !== focus) {
|
37383
|
-
return focus_stack.pop();
|
37384
|
-
}
|
37385
|
-
}
|
37386
|
-
}
|
37436
|
+
var detect_gesture = function(mouse, root) {
|
37437
|
+
var targets = find_gesture_targets(mouse, root);
|
37387
37438
|
|
37388
|
-
|
37439
|
+
var boxes = adjust_boxes(_.map(targets, bounding_rectangle));
|
37440
|
+
|
37441
|
+
var edges = [];
|
37442
|
+
_.each(targets, function(target, index) {
|
37443
|
+
edges = edges.concat(build_edges_for(target, boxes[index]));
|
37444
|
+
});
|
37445
|
+
|
37446
|
+
var closest_edge = _.min(edges, function(edge) {
|
37447
|
+
return distance_point_rectangle(mouse, edge.rectangle);
|
37448
|
+
});
|
37449
|
+
|
37450
|
+
var edge_name = closest_edge.name;
|
37451
|
+
|
37452
|
+
/*
|
37453
|
+
return {
|
37454
|
+
target: closest_edge.target,
|
37455
|
+
type: edge_name === "left" || edge_name === "right" ? 'column' : 'row',
|
37456
|
+
before: edge_name === "left" || edge_name === "top"
|
37457
|
+
};
|
37458
|
+
*/
|
37459
|
+
|
37460
|
+
return {
|
37461
|
+
target: closest_edge.target,
|
37462
|
+
edge_name: edge_name,
|
37463
|
+
};
|
37389
37464
|
};
|
37390
37465
|
|
37391
37466
|
var offset_center = function(element, element_offset, next_element, next_element_offset) {
|
@@ -37413,11 +37488,7 @@ var scrivito = {}; // jshint ignore:line
|
|
37413
37488
|
cursor.hide();
|
37414
37489
|
$("body").append(cursor);
|
37415
37490
|
|
37416
|
-
|
37417
|
-
|
37418
|
-
var insert_at;
|
37419
|
-
var insert_type;
|
37420
|
-
var insert_before;
|
37491
|
+
var last_gesture;
|
37421
37492
|
|
37422
37493
|
scrivito.gui.on('document', function(document) {
|
37423
37494
|
var body = document.dom_element().find("body");
|
@@ -37429,7 +37500,6 @@ var scrivito = {}; // jshint ignore:line
|
|
37429
37500
|
e.preventDefault(); // Necessary. Allows us to drop.
|
37430
37501
|
}
|
37431
37502
|
|
37432
|
-
|
37433
37503
|
// REPLACE ORIGINAL WITH PLACEHOLDER
|
37434
37504
|
if (!hidden) {
|
37435
37505
|
$(dragging).css("opacity", "0.5");
|
@@ -37440,18 +37510,9 @@ var scrivito = {}; // jshint ignore:line
|
|
37440
37510
|
// see https://github.com/jquery/jquery/issues/1925
|
37441
37511
|
var mouse = {x: e.originalEvent.pageX, y: e.originalEvent.pageY}
|
37442
37512
|
|
37443
|
-
|
37513
|
+
var gesture = detect_gesture(mouse, body);
|
37444
37514
|
|
37445
|
-
|
37446
|
-
focus_marker.show(focus);
|
37447
|
-
}
|
37448
|
-
else {
|
37449
|
-
focus_marker.hide();
|
37450
|
-
}
|
37451
|
-
|
37452
|
-
var targets = find_gesture_targets(mouse, focus || body);
|
37453
|
-
var target_row = $(targets.target_row);
|
37454
|
-
var target = targets.target;
|
37515
|
+
var target = $(gesture.target);
|
37455
37516
|
|
37456
37517
|
// This should NEVER happen!
|
37457
37518
|
if (!target) {
|
@@ -37459,79 +37520,38 @@ var scrivito = {}; // jshint ignore:line
|
|
37459
37520
|
return;
|
37460
37521
|
}
|
37461
37522
|
|
37462
|
-
|
37463
|
-
|
37464
|
-
|
37465
|
-
// only upper 1/3 of widget should count as "row"
|
37466
|
-
if (gesture.name === 'row_insert') {
|
37467
|
-
var before = gesture.before;
|
37523
|
+
if (gesture.target.get(0) === dragging) {
|
37524
|
+
return;
|
37525
|
+
}
|
37468
37526
|
|
37527
|
+
if (gesture.edge_name === 'top' || gesture.edge_name === 'bottom') {
|
37469
37528
|
// CURSOR
|
37470
37529
|
cursor.height("0px");
|
37471
|
-
cursor.width(
|
37530
|
+
cursor.width(target.parent().outerWidth());
|
37472
37531
|
|
37473
37532
|
// TODO update Cursor position on scroll
|
37474
|
-
|
37475
|
-
|
37476
|
-
var offset = scrivito.cms_document.offset(target_row);
|
37533
|
+
var offset = scrivito.cms_document.offset(target);
|
37477
37534
|
|
37478
|
-
if (
|
37479
|
-
var prev_row =
|
37535
|
+
if (gesture.edge_name === 'top') {
|
37536
|
+
var prev_row = target.prev();
|
37480
37537
|
if (prev_row.length) {
|
37481
37538
|
var prev_row_offset = scrivito.cms_document.offset(prev_row);
|
37482
|
-
offset.top = offset_center(prev_row, prev_row_offset,
|
37539
|
+
offset.top = offset_center(prev_row, prev_row_offset, target, offset).top;
|
37483
37540
|
}
|
37484
37541
|
} else {
|
37485
|
-
var next_row =
|
37542
|
+
var next_row = target.next();
|
37486
37543
|
if (next_row.length) {
|
37487
37544
|
var next_row_offset = scrivito.cms_document.offset(next_row);
|
37488
|
-
offset.top = offset_center(
|
37545
|
+
offset.top = offset_center(target, offset, next_row, next_row_offset).top;
|
37489
37546
|
} else {
|
37490
|
-
offset.top +=
|
37547
|
+
offset.top += target.outerHeight();
|
37491
37548
|
}
|
37492
37549
|
}
|
37493
37550
|
|
37494
|
-
offset.left = scrivito.cms_document.offset(
|
37551
|
+
offset.left = scrivito.cms_document.offset(target.parent()).left;
|
37495
37552
|
cursor.offset(offset);
|
37496
37553
|
cursor.show();
|
37497
|
-
|
37498
|
-
// REMEMBER
|
37499
|
-
insert_at = target_row;
|
37500
|
-
insert_type = "row";
|
37501
|
-
insert_before = before;
|
37502
|
-
} else if (gesture.name === 'insert_inside') {
|
37503
|
-
// CURSOR
|
37504
|
-
|
37505
|
-
var bounds = bounding_rectangle(target);
|
37506
|
-
cursor.width(bounds.width);
|
37507
|
-
cursor.height(bounds.height);
|
37508
|
-
|
37509
|
-
// TODO update Cursor position on scroll
|
37510
|
-
var offset = scrivito.cms_document.offset(target);
|
37511
|
-
cursor.offset(offset);
|
37512
|
-
cursor.show();
|
37513
|
-
|
37514
|
-
if (insert_at === target && insert_type === "inside") {
|
37515
|
-
var focus_time = (new Date()) - focus_since;
|
37516
|
-
|
37517
|
-
if (focus_time > 500) {
|
37518
|
-
if (focus) {
|
37519
|
-
focus_stack.push(focus);
|
37520
|
-
}
|
37521
|
-
focus = target;
|
37522
|
-
focus_since = undefined;
|
37523
|
-
}
|
37524
|
-
} else {
|
37525
|
-
focus_since = new Date();
|
37526
|
-
// REMEMBER
|
37527
|
-
insert_at = target;
|
37528
|
-
insert_type = "inside";
|
37529
|
-
}
|
37530
|
-
|
37531
|
-
insert_before = gesture.before;
|
37532
|
-
} else if (gesture.name === 'col_insert') {
|
37533
|
-
var before = gesture.before;
|
37534
|
-
|
37554
|
+
} else if (gesture.edge_name === 'left' || gesture.edge_name === 'right') {
|
37535
37555
|
// CURSOR
|
37536
37556
|
cursor.height($(target).outerHeight());
|
37537
37557
|
cursor.width("0px");
|
@@ -37540,7 +37560,7 @@ var scrivito = {}; // jshint ignore:line
|
|
37540
37560
|
var offset = scrivito.cms_document.offset(target);
|
37541
37561
|
var target_jq = $(target);
|
37542
37562
|
|
37543
|
-
if (
|
37563
|
+
if (gesture.edge_name === 'left') {
|
37544
37564
|
var prev_column = target_jq.prev();
|
37545
37565
|
if (prev_column.length && !is_wrap_between(prev_column, target_jq)) {
|
37546
37566
|
offset.left = offset_center(prev_column, scrivito.cms_document.offset(prev_column),
|
@@ -37560,14 +37580,11 @@ var scrivito = {}; // jshint ignore:line
|
|
37560
37580
|
|
37561
37581
|
cursor.offset(offset);
|
37562
37582
|
cursor.show();
|
37563
|
-
|
37564
|
-
// REMEMBER
|
37565
|
-
insert_at = target;
|
37566
|
-
insert_type = "col";
|
37567
|
-
insert_before = before;
|
37568
37583
|
} else {
|
37569
37584
|
$.error('Unknown gesture: ' + gesture);
|
37570
37585
|
}
|
37586
|
+
|
37587
|
+
last_gesture = gesture;
|
37571
37588
|
});
|
37572
37589
|
|
37573
37590
|
});
|
@@ -37598,15 +37615,6 @@ var scrivito = {}; // jshint ignore:line
|
|
37598
37615
|
//e.originalEvent.dataTransfer.setDragImage(dragIcon, -10, -10);
|
37599
37616
|
|
37600
37617
|
dragging = $(this).parent()[0];
|
37601
|
-
// FIXME: Find also the structure widget.
|
37602
|
-
focus = $(dragging).closest("[data-scrivito-widget-obj-class=ColumnWidget]")[0];
|
37603
|
-
|
37604
|
-
if ($(focus).children().length === 1) { // TODO: Only for ColumnContainerWidget
|
37605
|
-
// if dragging the only widget inside a column
|
37606
|
-
// focussing that column does not make sense
|
37607
|
-
focus = $(focus).parent().
|
37608
|
-
closest("[data-scrivito-widget-obj-class=ColumnWidget]")[0];
|
37609
|
-
}
|
37610
37618
|
|
37611
37619
|
hidden = false;
|
37612
37620
|
});
|
@@ -37615,32 +37623,24 @@ var scrivito = {}; // jshint ignore:line
|
|
37615
37623
|
|
37616
37624
|
if (window.debugdrag) { return }
|
37617
37625
|
|
37618
|
-
|
37626
|
+
var gesture = last_gesture;
|
37627
|
+
|
37628
|
+
if (gesture.target == dragging) {
|
37619
37629
|
// dragged a widget on itself - do nothing
|
37620
37630
|
$(dragging).css("opacity", "1");
|
37621
37631
|
}
|
37622
|
-
else if (
|
37632
|
+
else if (gesture.target) {
|
37633
|
+
var target = gesture.target;
|
37623
37634
|
var old_parent = $(dragging).parent();
|
37624
37635
|
|
37625
|
-
if (
|
37626
|
-
// TODO do noting if not ColumnContainerWidget
|
37627
|
-
// INSIDE EXISTING COLUMN
|
37628
|
-
$(dragging).hide();
|
37629
|
-
$(insert_at)[insert_before ? "prepend" : "append"](dragging);
|
37630
|
-
$(dragging).slideDown(100);
|
37631
|
-
|
37632
|
-
$(dragging).css("opacity", "1");
|
37633
|
-
|
37634
|
-
garbage_collect(old_parent);
|
37635
|
-
}
|
37636
|
-
else if (insert_type == "row") {
|
37636
|
+
if (gesture.edge_name === 'top' || gesture.edge_name === 'bottom') {
|
37637
37637
|
// ROW INSERT
|
37638
37638
|
$(dragging).hide();
|
37639
37639
|
|
37640
|
-
if (
|
37641
|
-
$(
|
37640
|
+
if (target.is('[data-scrivito-field-type=widgetlist]')) {
|
37641
|
+
$(target).append(dragging);
|
37642
37642
|
} else {
|
37643
|
-
$(
|
37643
|
+
$(target)[gesture.edge_name === 'top' ? "before" : "after"](dragging);
|
37644
37644
|
}
|
37645
37645
|
$(dragging).css("opacity", "1");
|
37646
37646
|
|
@@ -37650,21 +37650,21 @@ var scrivito = {}; // jshint ignore:line
|
|
37650
37650
|
}
|
37651
37651
|
else {
|
37652
37652
|
// COL INSERT
|
37653
|
-
var insert_at_obj_class = $(
|
37653
|
+
var insert_at_obj_class = $(target).attr("data-scrivito-widget-obj-class");
|
37654
37654
|
if (insert_at_obj_class !== "ColumnWidget") {
|
37655
|
-
$(
|
37655
|
+
$(target).wrap(
|
37656
37656
|
"<div class='row' data-scrivito-widget-obj-class=ColumnContainerWidget>" +
|
37657
37657
|
"<div class='col-md-12' data-scrivito-widget-obj-class=ColumnWidget></div>" +
|
37658
37658
|
"</div>");
|
37659
37659
|
|
37660
|
-
|
37660
|
+
target = $(target).parent();
|
37661
37661
|
}
|
37662
37662
|
|
37663
37663
|
$(dragging).detach();
|
37664
37664
|
$(dragging).wrap("<div class='col-md-12' data-scrivito-widget-obj-class=ColumnWidget></div>");
|
37665
37665
|
var insert_column = $(dragging).parent();
|
37666
37666
|
|
37667
|
-
$(
|
37667
|
+
$(target)[gesture.edge_name === 'left' ? "before" : "after"](insert_column);
|
37668
37668
|
|
37669
37669
|
$(dragging).css("opacity", "1");
|
37670
37670
|
$(dragging).show(100);
|
@@ -37673,12 +37673,11 @@ var scrivito = {}; // jshint ignore:line
|
|
37673
37673
|
// since it could be inside the same row
|
37674
37674
|
garbage_collect(old_parent);
|
37675
37675
|
|
37676
|
-
resize_row($(
|
37676
|
+
resize_row($(target).closest(".row"));
|
37677
37677
|
}
|
37678
37678
|
}
|
37679
37679
|
|
37680
37680
|
cursor.hide();
|
37681
|
-
focus_marker.hide();
|
37682
37681
|
|
37683
37682
|
return false;
|
37684
37683
|
});
|
data/lib/scrivito/binary.rb
CHANGED
@@ -6,6 +6,12 @@ module Scrivito
|
|
6
6
|
class Binary
|
7
7
|
attr_reader :id, :transformation_definition
|
8
8
|
|
9
|
+
def self.assert_valid_options(options)
|
10
|
+
options.each_pair do |key, value|
|
11
|
+
raise ArgumentError, "#{key} cannot be blank" if value.blank?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
9
15
|
def initialize(id, is_public, transformation_definition: nil, original: nil)
|
10
16
|
@id = id
|
11
17
|
@is_public = !!is_public
|
@@ -13,47 +19,62 @@ class Binary
|
|
13
19
|
@original = original
|
14
20
|
end
|
15
21
|
|
22
|
+
#
|
16
23
|
# @api public
|
24
|
+
#
|
17
25
|
# Uploads a local file to the CMS.
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
# "/Desktop/rick_astley", content_type: "Video/MP4", filename: "ufo_landing.m4v"))
|
26
|
-
# @param file_or_path [File, String] the file to be uploaded or
|
27
|
-
# the path of the file to be uploaded.
|
28
|
-
# @param filename [String, Nil] the desired filename. If +nil+,
|
29
|
-
# the name of the given file is used.
|
30
|
-
# @param content_type [String, Nil] the desired content type. If +nil+,
|
31
|
-
# the content type is calculated based on the extension of the filename.
|
26
|
+
#
|
27
|
+
# @param file_or_path [File, String] the file to be uploaded or the path of the file to be uploaded.
|
28
|
+
# @param options [Hash]
|
29
|
+
# @option options [String] filename the desired filename. Defaults to the name of the given file.
|
30
|
+
# @option options [String] content_type the desired content type. By default, the content type is
|
31
|
+
# calculated based on the extension of the filename.
|
32
|
+
#
|
32
33
|
# @return [Scrivito::FutureBinary] the returned object should be inserted into the binary field
|
33
34
|
# of an {Scrivito::BasicObj Obj} or {Scrivito::BasicWidget Widget}.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
#
|
36
|
+
# @raise ArgumentError if given +filename+ or +content_type+ is blank.
|
37
|
+
#
|
38
|
+
# @example Upload a single file
|
39
|
+
# @obj.update(blob: Scrivito::Binary.upload("./kitten.jpg"))
|
40
|
+
#
|
41
|
+
# # Is equivalent to
|
42
|
+
# @obj.update(blob: File.new("./kitten.jpg"))
|
43
|
+
#
|
44
|
+
# @example Upload a file with a different +filename+ and +content_type+
|
45
|
+
# @obj.update(blob: Scrivito::Binary.upload("./rick_astley",
|
46
|
+
# filename: "ufo_landing.m4v", content_type: "video/mp4"))
|
47
|
+
#
|
48
|
+
def self.upload(file_or_path, options = {})
|
49
|
+
assert_valid_options(options)
|
50
|
+
FutureBinary.new(options.reverse_merge(
|
51
|
+
filename: File.basename(file_or_path),
|
52
|
+
file_to_upload: file_or_path.is_a?(File) ? file_or_path : File.new(file_or_path)
|
53
|
+
))
|
42
54
|
end
|
43
55
|
|
56
|
+
#
|
44
57
|
# @api public
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
# @param
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
58
|
+
#
|
59
|
+
# Create a copy of this {Scrivito::Binary Binary} with a different filename and/or content type.
|
60
|
+
#
|
61
|
+
# @param options [Hash]
|
62
|
+
# @option options [String] filename the desired filename. Defaults to the +filename+ of the
|
63
|
+
# original binary.
|
64
|
+
# @option options [String] content_type the desired content type. By default, the content type is
|
65
|
+
# calculated based on the extension of the filename.
|
66
|
+
#
|
52
67
|
# @return [Scrivito::FutureBinary] the returned object should be inserted into the binary field
|
53
|
-
# of an Obj or Widget.
|
54
|
-
|
55
|
-
|
56
|
-
|
68
|
+
# of an {Scrivito::BasicObj Obj} or {Scrivito::BasicWidget Widget}.
|
69
|
+
#
|
70
|
+
# @raise ArgumentError if given +filename+ or +content_type+ is blank.
|
71
|
+
#
|
72
|
+
# @example Change +filename+ and +content_type+ of an existing binary. Binary content remains the same.
|
73
|
+
# @obj.update(blob: @obj.blob.copy(filename: "cute_kitten.jpg", content_type: "video/mp4"))
|
74
|
+
#
|
75
|
+
def copy(options = {})
|
76
|
+
self.class.assert_valid_options(options)
|
77
|
+
FutureBinary.new(options.reverse_merge(filename: self.filename, id_to_copy: id))
|
57
78
|
end
|
58
79
|
|
59
80
|
# @api public
|
@@ -68,17 +68,14 @@ module Scrivito
|
|
68
68
|
@number_of_requests
|
69
69
|
end
|
70
70
|
|
71
|
-
def self.upload_future_binary(
|
72
|
-
if
|
73
|
-
id = normalize_path_component(
|
74
|
-
put("blobs/#{id}/copy", destination_obj_id: obj_id
|
75
|
-
content_type: binary.content_type)
|
71
|
+
def self.upload_future_binary(future_binary, obj_id)
|
72
|
+
if future_binary.id_to_copy
|
73
|
+
id = normalize_path_component(future_binary.id_to_copy)
|
74
|
+
put("blobs/#{id}/copy", future_binary.to_h.merge(destination_obj_id: obj_id))
|
76
75
|
else
|
77
|
-
|
78
|
-
upload =
|
79
|
-
|
80
|
-
activate_upload(upload: upload, obj_id: obj_id, filename: binary.filename,
|
81
|
-
content_type: binary.content_type)
|
76
|
+
permission = get('blobs/upload_permission')
|
77
|
+
upload = upload_file(future_binary.file_to_upload, future_binary.content_type, permission)
|
78
|
+
activate_upload(future_binary.to_h.merge(upload: upload, obj_id: obj_id))
|
82
79
|
end
|
83
80
|
end
|
84
81
|
|
@@ -185,7 +182,7 @@ module Scrivito
|
|
185
182
|
end
|
186
183
|
end
|
187
184
|
|
188
|
-
def
|
185
|
+
def upload_file(file, content_type, upload_permission)
|
189
186
|
uri = URI.parse(upload_permission['url'])
|
190
187
|
|
191
188
|
File.open(file) do |open_file|
|
@@ -1,22 +1,27 @@
|
|
1
1
|
module Scrivito
|
2
2
|
|
3
|
+
#
|
3
4
|
# @api public
|
5
|
+
#
|
4
6
|
# The FutureBinary class represents the data to be stored in a binary field.
|
5
7
|
# See {Scrivito::Binary.upload} and {Scrivito::Binary#copy} for details.
|
8
|
+
#
|
9
|
+
# @see Scrivito::Binary.upload
|
10
|
+
# @see Scrivito::Binary#copy
|
11
|
+
#
|
6
12
|
class FutureBinary
|
7
|
-
attr_reader :filename, :content_type, :
|
13
|
+
attr_reader :filename, :content_type, :id_to_copy, :file_to_upload
|
8
14
|
|
9
|
-
def initialize(
|
10
|
-
@filename =
|
11
|
-
|
12
|
-
@id_to_be_copied = id_to_be_copied
|
13
|
-
@file_to_be_uploaded = file_to_be_uploaded
|
15
|
+
def initialize(options = {})
|
16
|
+
@filename, @content_type, @id_to_copy, @file_to_upload =
|
17
|
+
options.values_at(:filename, :content_type, :id_to_copy, :file_to_upload)
|
14
18
|
end
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
def to_h
|
21
|
+
{
|
22
|
+
filename: filename,
|
23
|
+
content_type: content_type,
|
24
|
+
}.compact
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
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.1.0.
|
4
|
+
version: 1.1.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-01-
|
11
|
+
date: 2016-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|