trello.js
2.07 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
/**
* Explore plugin.
*/
Draw.loadPlugin(function(editorUi)
{
// Trello plugin only works in embed mode
if (editorUi.actions.get('exit') == null)
{
return;
}
// Overridden to redirect modified check to file
editorUi.actions.get('exit').funct = function()
{
var fn = function()
{
var parent = window.opener || window.parent;
parent.postMessage(JSON.stringify({event: 'exit'}), '*');
}
var file = editorUi.getCurrentFile();
if (file == null || !file.isModified())
{
fn();
}
else
{
editorUi.confirm(mxResources.get('allChangesLost'), null, fn,
mxResources.get('cancel'), mxResources.get('discardChanges'));
}
};
editorUi.showSplash = function()
{
this.actions.get('exit').funct();
};
function main()
{
var name = (urlParams['filename'] != null) ? decodeURIComponent(urlParams['filename']) : null;
var card = (urlParams['card'] != null) ? decodeURIComponent(urlParams['card']) : null;
var template = (urlParams['template'] != null) ? decodeURIComponent(urlParams['template']) : null;
if (name != null && card != null)
{
var doCreateFile = function(templateData)
{
editorUi.createFile(name, templateData ||
editorUi.getFileData(/(\.xml)$/i.test(name) ||
name.indexOf('.') < 0, /(\.svg)$/i.test(name),
/(\.html)$/i.test(name)), null, 'trello',
null, true, card);
};
if (template != null)
{
editorUi.trello.getFile(card + editorUi.trello.SEPARATOR +
template, function(file)
{
doCreateFile(file.getData());
}, function()
{
doCreateFile();
});
}
else
{
doCreateFile();
}
}
else if (window.location.hash.substring(0, 2) == '#T')
{
editorUi.loadFile(editorUi.getDiagramId(), true);
}
editorUi.addEmbedButtons();
};
// Waits for Trello client
if (editorUi.trello == null)
{
var waitForTrello = function()
{
if (editorUi.trello != null)
{
editorUi.removeListener(waitForTrello);
main();
}
};
// Waits for Trello client to load
editorUi.addListener('clientLoaded', waitForTrello);
}
else
{
main();
}
});