forked from STRd6/pixel-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.coffee
43 lines (32 loc) · 1.06 KB
/
main.coffee
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
# Setup
require "./lib/canvas-to-blob"
Editor = require "./editor"
launch = ->
# For debugging
global.editor = Editor()
Template = require "./templates/editor"
editorElement = Template editor
document.body.appendChild editorElement
try
editor.invokeRemote "childLoaded"
updateViewportCentering = ->
{height: mainHeight, width: mainWidth} = editorElement.querySelector(".main").getBoundingClientRect()
editor.mainHeight mainHeight
editor.mainWidth mainWidth
window.addEventListener "resize", updateViewportCentering
updateViewportCentering()
if PACKAGE.name is "ROOT"
# Google Analytics
require("analytics").init("UA-3464282-15")
# For debug purposes
global.PACKAGE = PACKAGE
global.require = require
runtime = require("runtime")(PACKAGE)
runtime.boot()
runtime.applyStyleSheet(require('./style'))
metaTag = document.createElement('meta')
metaTag.name = "viewport"
metaTag.content = "width=device-width, initial-scale=1.0"
document.getElementsByTagName('head')[0].appendChild(metaTag)
launch()
module.exports = Editor