This repository was archived by the owner on Jul 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 511
/
Copy pathmain.js
88 lines (74 loc) · 2.75 KB
/
main.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// NOTE: if you change this, update Gruntfile's requirejs:dist task too
require.config({
waitSeconds: 120,
baseUrl: "/{{ locale }}/editor/scripts/editor/js",
paths: {
// Folders
"project": "../../project",
// Files
"bowser": "/scripts/vendor/bowser",
"sso-override": "../../sso-override",
"logger": "../../logger",
"jquery": "/node_modules/jquery/dist/jquery.min",
"localized": "/node_modules/webmaker-i18n/localized",
"uuid": "/node_modules/node-uuid/uuid",
"cookies": "/node_modules/cookies-js/dist/cookies",
"PathCache": "../../path-cache",
"constants": "../../constants",
"EventEmitter": "/node_modules/wolfy87-eventemitter/EventEmitter.min",
"analytics": "../../analytics"
},
shim: {
"jquery": {
exports: "$"
}
}
});
require(["jquery", "bowser", "fc/offline"], function($, bowser, Offline) {
// Warn users of unsupported browsers that they can try something newer,
// specifically anything before IE 11 or Safari 8.
if((bowser.msie && bowser.version < 11) || (bowser.safari && bowser.version < 8)) {
$("#browser-support-warning").removeClass("hide");
$(".let-me-in").on("click", function() {
$("#browser-support-warning").fadeOut();
return false;
});
}
function onError(err) {
console.error("[Bramble Error]", err);
$("#spinner-container").addClass("loading-error");
}
// If Bramble fails to load (some browser loading issues cause it to fail),
// error out now, since we won't get to Bramble.on('error', ...)
if(!window.Bramble) {
onError(new Error("Unable to load Bramble editor in this browser"));
return;
}
Bramble.once("error", onError);
// Initialize offline/online handling
Offline.init(Bramble);
function init(BrambleEditor, Project, SSOOverride, ProjectRenameUtility) {
var thimbleScript = document.getElementById("thimble-script");
var appUrl = thimbleScript.getAttribute("data-app-url");
var projectDetails = thimbleScript.getAttribute("data-project-details");
var editorUrl = thimbleScript.getAttribute("data-editor-url");
// Unpack projectDetails details
projectDetails = JSON.parse(decodeURIComponent(projectDetails));
Project.init(projectDetails, appUrl, function(err) {
if (err) {
console.error("[Bramble] Failed to load Project state, with", err);
}
// Initialize the name UI for an anonymous project
if(!projectDetails.userID){
ProjectRenameUtility.init(appUrl, BrambleEditor.csrfToken);
}
// Initialize the login links
SSOOverride.init();
BrambleEditor.create({
editorUrl: editorUrl,
appUrl: appUrl
});
});
}
require(["bramble-editor", "project/project", "sso-override", "fc/project-rename"], init);
});