-
Notifications
You must be signed in to change notification settings - Fork 4
/
script.js
58 lines (50 loc) · 1.65 KB
/
script.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
/* DOKUWIKI:include_once raphael.min.js */
/* DOKUWIKI:include_once flowchart.min.js */
jQuery(function(){
function draw (style){
var sel = 'pre.flowchartjs';
if (style != '') sel = sel + '.' + style;
return function (opt){
jQuery(sel).each(function (index){
var cls = jQuery(this).attr('class').replace(/^\s+|\s+$/, '').replace(/\s+/g, ' ').split(' ');
var obj = flowchart.parse( jQuery(this).text() );
var classes = cls.length == 1? cls[0]: cls[0] + ' ' + cls[1];
var id = classes.replace(/ /g, '_') + '_' + index;
jQuery(this).replaceWith(
jQuery('<div class="' + classes + '" id="' + id + '"></div>')
);
obj.drawSVG(id, opt);
div_size_style = "";
if (cls.length >= 3) div_size_style = div_size_style + "width: " + cls[2] + ";";
if (cls.length >= 4) div_size_style = div_size_style + "height: " + cls[3] + ";";
if (div_size_style != "") jQuery('div#' + id).attr('style', div_size_style);
jQuery('div#' + id + ' svg').attr(
'style',
jQuery('div#' + id + ' svg').attr('style') + ' height: 100%; width: 100%;'
);
});
};
}
/*
* callback should indicate style info
*/
function draw1style (style, callback){
jQuery.ajax(DOKU_BASE + 'lib/plugins/flowchartjs/styles/' + style + '.json', {dataType: 'json'})
.done(function(d){
callback(d);
})
.fail(function(j, s, e){
callback(null);
});
}
var classes = [];
jQuery('pre.flowchartjs').each(function(index){
var cls = jQuery(this).attr('class').replace(/^\s+|\s+$/g, '').replace(/\s+/g, ' ').split(' ');
if (cls.length == 1) classes[''] = 1;
else classes[cls[1]] = 1;
return true;
});
for (var cls in classes){
draw1style(cls, callback=draw(cls));
}
});