-
Notifications
You must be signed in to change notification settings - Fork 1
/
editor.js
65 lines (46 loc) · 1.28 KB
/
editor.js
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
var grid, container, canvas, activeElements = [];
function init() {
"use strict";
/*global Ruler, document, window*/
var canvas = document.getElementById('ruler'),
ruler;
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
ruler = new Ruler("ruler");
ruler.render('#aaa', 'pixels', 100);
window.onresize = function() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
ruler.render('#aaa', 'pixels', 100);
}
grid = new Grid('grid');
grid.render("#ddd", 1, 10, 10);
Selector('container');
PanMe('canvas');
studio.loadControls();
container = document.getElementById('container');
canvas = document.getElementById('canvas');
container.addEventListener('mouseup', function() {
studio.updateEditor("body { padding: 0; margin: 0; }");
});
container.addEventListener('mousedown', function() {
inactivateElements();
});
}
function activateElements(elements, reset) {
if (reset === true) inactivateElements();
var element;
while (element = elements.pop()) {
if (!hasClass(element, 'active')) {
activeElements.push(element);
addClass(element, 'active');
}
}
}
function inactivateElements() {
var element;
while (element = activeElements.pop()) {
removeClass(element, 'active');
}
}
window.onload = init;