-
Notifications
You must be signed in to change notification settings - Fork 1
/
sandbox.js
49 lines (45 loc) · 1.03 KB
/
sandbox.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
(function (Wikidocs) {
'use strict';
var APP_ID = 'barcamp';
var APP_SECRET = 'barcamp';
var channels = [
{
name: 'barcamp/header',
id: 'editable-header'
}
];
function sign(channels, appId, appSecret) {
var allow = {};
var i;
for (i = 0; i < channels.length; i++) {
allow[channels[i].name] = {
sub: true,
pub: true
};
}
var request = signRequest({allow: allow}, appId, appSecret);
Wikidocs.signedRequest(request);
}
function bind(channels) {
var i;
for (i = 0; i < channels.length; i++) {
Aloha.jQuery('#' + channels[i].id).aloha();
var editable = Aloha.getEditableById(channels[i].id);
var channel = Wikidocs.channel(channels[i].name);
channel.bindEditable(editable);
}
}
Aloha.require(['aloha', 'aloha/jquery'], function (Aloha, $) {
Aloha.ready(function () {
if (Wikidocs) {
sign(channels, APP_ID, APP_SECRET);
bind(channels);
} else {
var i;
for (i = 0; i < channels.length; i++) {
$('#' + channels[i].id).aloha();
}
}
});
});
}(window.Wikidocs));