-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestsetup.js
More file actions
148 lines (132 loc) · 3.59 KB
/
testsetup.js
File metadata and controls
148 lines (132 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
(function(win, undefined) {
// "global" variables within this closure scope
var $ = jQuery,
doc = document,
root = win.ds || {},
dsCanvas = root.canvas || {};
var tmp = $(".ds-canvas-container").detach();
var scaffold = Lao.create("Scaffold", {
"vertical": false,
"children": {
"topbar": {
"height": 70
},
"toolbar": {
"height": 30
},
"middlebar": {
"children": {
"left": {
"className": "toollist",
"width": 150
},
"center": {
"className": "canvasWrapper"
}
}
},
"bottombar": {
"height": 25
}
}
});
scaffold.appendTo(doc.body);
scaffold.getBooth("toolbar").append(ds.ToolbarManager.activate().el);
scaffold.getBooth("center").append(tmp);
ds.document.getCurrentPage().set({
width: 300,
height: 300
})
ds.guideList.add({axis: "x", position: 300});
ds.guideList.add({axis: "y", position: 200});
ds.guideList.add({axis: "x", position: 100});
ds.guideList.add({axis: "y", position: 300});
ds.ItemController.create("Text", {
x: 0,
y: 0,
width: 100,
height: 200,
content: "<p>Hallo Welt!</p>"
})
ds.ItemController.create("Image", {
x: 100,
y: 200,
width: 200,
height: 100,
url: "test.jpg"
})
var layer = Lao.extend("ListItem", {
template: "<li><div class=\"ListItem-Cell listitem-visibility listitem-is-<%= !visible ? \"in\":\"\" %>visible\"></div><div class=\"ListItem-Cell listitem-name\">Ebene <%= nr %></div></li>",
className: "Layer",
initialize: function () {
if (this.model) {
this.model.on("change:visible", this.changeVisible, this);
}
},
changeVisible: function (m) {
this.$(".listitem-visibility")
.toggleClass("listitem-is-visible", m.get("visible"))
.toggleClass("listitem-is-invisible", !m.get("visible"))
},
toggleVisibility: function (e) {
e.stopPropagation();
this.model.set("visible", !this.model.get("visible"));
},
events: {
"click .listitem-visibility": "toggleVisibility"
}
}),
Layers = Lao.extend("SelectableList", {
className: "Layers",
listItem: layer,
initialize: function () {
// We have two selectmanagers triggering each others select and unselect-methods
// To prevent potential recursions we use a flag that indicates a current select-cycle
var busy = false;
ds.SelectManager.on("select unselect", function (e) {
busy = true;
var index = ds.document.getCurrentPage().get("itemList").indexOf(e.dsObject);
this.selectManager[e.type](index);
busy = false;
}, this)
this
.on("add remove reset", function (m) {
if (!busy) {
var ids = _.pluck(this.selectManager.models, "id"),
items = _.map(ids, function (id) {
return ds.document.getCurrentPage().get("itemList").at(id);
}, this);
ds.SelectManager.selectOnly(items);
}
}, this)
}
});
Lao.define({
"fooLayer": layer,
"fooLayers": Layers
})
var layers = Lao.create("fooLayers", {
collection: ds.document.getCurrentPage().get("itemList")
});
scaffold.getBooth("left").append(layers);
ds.UndoManager.register(ds.guideList, ds.document.get("pageList"), ds.document.getCurrentPage().get("itemList"));
ds.UndoManager.startTracking();
var zoomSteps = _.map([0.2, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 7, 8], function (val) {
return [(100 * val) + "%", val];
}), zoomIndicator = new ds.ZoomIndicator({
model: ds.ScaleManager,
steps: zoomSteps
})
scaffold.getBooth("bottombar").append(zoomIndicator.el);
$.Shortcut.on({
"meta+H": function () {
ds.ScaleManager.zoomIn()
},
"meta+V": function () {
ds.ScaleManager.zoomOut()
},
"meta+0": function () {
ds.ScaleManager.setScale(1)
}
});
})(ds, this);