aboutsummaryrefslogtreecommitdiff
path: root/mod/dokuwiki/vendors/dokuwiki/lib/plugins/indexmenu/edit-full.js
blob: 9ab87c8a82742a1043e1edf62ad3fbabdba3e0cb (plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
function indexmenu_toolbar_additions() {
    var edbtn,cmenu,indx_btn,toolbar = DOKUid('tool__bar');
    if(!toolbar) return;
    edbtn = DOKUid('edbtn__save');
    if(!edbtn) return;
    var indx_list = indexmenu_createPicker('picker_plugin_indexmenu');
    indx_btn = indexmenu_createToolbar();
    toolbar.appendChild(indx_btn);
    indx_btn.onclick = function(){indexmenu_ajaxmenu('req=local',indx_list,this,false,indexmenu_createThemes);return false;};
    cmenu=window.indexmenu_contextmenu;
    if(cmenu[1]) {
	window.indexmenu_contextmenu[0]=cmenu[1].concat(cmenu[0]);
    }
}

function indexmenu_createThemes(data,indx_list) {
    if (data.substring(0,9) != 'indexmenu') {
	indx_list.innerHTML="Retrieving error";
	return;
    }
    var checkboxes=[['<p><strong><em>Navigation</em></strong></p>',0],
		    ['navbar','The tree opens at the current namespace'],
		    ['context','Display the tree of the current wiki namespace context'],
		    ['nocookie','Don\t remember open/closed nodes during user navigation'],
		    ['noscroll','Prevent to scrolling the tree when it does not fit its container width'],
		    ['notoc','Disable the toc preview feature'],
		    ['<p><strong><em>Sort</em></strong></p>',0],
		    ['nsort','Sort also namespaces'],
		    ['tsort','By title'],
		    ['dsort','By date'],
		    ['msort','By meta tag'],
		    ['<p><strong><em>Performance</em></strong></p>',0],
		    ['max#2','How many levels to render with ajax when a node is opened'],
		    ['maxjs#2','How many levels to render in the client browser when a node is opened'],
		    ['<p><strong><em>Filters</em></strong></p>',0],
		    ['nons','Show only pages'],
		    ['nopg','Show only namespaces']];

    var btn,key,theme_url,adata,f,f2,l,fo;
    adata=data.split(',');
    theme_url = DOKU_MEDIA + 'lib/plugins/indexmenu/images/';
    f=indexmenu_toolFrame(indx_list,'Indexmenu');
    l = document.createElement('div');
    l.className = 'no indexmenu_nojstoolbar';
    f.appendChild(l);
    btn = createToolButton(DOKU_MEDIA + 'lib/tpl/default/images/open.gif','nojs index');
    btn.innerHTML += 'Nojs';
    btn.className = 'pickerbutton';
    eval('btn.onclick = function(){indexmenu_opts("");}');
    l.appendChild(btn);

    l = document.createElement('div');
    l.className = 'no indexmenu_jstoolbar';
    f.appendChild(l);
    if (adata[0] != 'indexmenu') {
	l.innerHTML += 'No themes';
	adata=[];
    } else {
	adata.splice(0,3);
    }
    for (key in adata) {
	btn = createToolButton(theme_url + adata[key]+'/base.'+indexmenu_findExt(adata[key]),adata[key]);
	btn.className = 'pickerbutton';
	eval('btn.onclick = function(){indexmenu_opts("js#'+adata[key]+'");}');
	l.appendChild(btn);
    }
    f2=indexmenu_toolFrame(indx_list,'Options');
    fo=document.createElement('form');
    fo.id='indexmenu_optfrm';
    fo.className='indexmenu_opts';
    f2.appendChild(fo);
    for (key in checkboxes) {
	lc = document.createElement('label');
	lc.innerHTML=checkboxes[key][0]+' ';
	if (checkboxes[key][1]) {
	    lc.title= checkboxes[key][1];
	    btn=document.createElement('input');
	    btn.type = 'checkbox';
	    btn.name = 'check';
	    btn.title = checkboxes[key][1];
	    btn.value = checkboxes[key][0];
	    fo.appendChild(btn);
	}
	fo.appendChild(lc);
    }

    l = document.createElement('div');
    l.className = 'indexmenu_extratoolbar';
    l.innerHTML='<p><strong><em>Extra</em></strong></p>';
    f.appendChild(l);
    btn = createToolButton(theme_url+'/msort.gif','Insert the sort meta-number');
    btn.className = 'pickerbutton';
    btn.onclick = function(){insertTags(
	'wiki__text',
	'{{indexmenu_n>',
	'}}',
	'1'
	);
	DOKUid('picker_plugin_indexmenu').style.display='none';
	return false;
    };
    l.appendChild(btn);
}

function indexmenu_createToolbar (){
    var indx_ico = document.createElement('img');
    indx_ico.src = DOKU_MEDIA + 'lib/plugins/indexmenu/images/indexmenu_toolbar.png';
    var indx_btn = document.createElement('button');
    indx_btn.id = 'syntax_plugin_indexmenu';
    indx_btn.className = 'toolbutton';
    indx_btn.title = 'Insert the Indexmenu tree';
    indx_btn.appendChild(indx_ico);
    return indx_btn;
}

function indexmenu_opts(m) {
    var i,v = '';
    var f=DOKUid('indexmenu_optfrm');
    for (i=0; i < f.length; i++) {
	if (f[i].checked) {
	    v = v + ' ' + f[i].value;
	}
    }
    insertTags(
	       'wiki__text',
	       '{{indexmenu>',
	       ((m||v)?'|':'')+m.replace(/#default$/,'')+v+'}}',
	       '#1'
	       );
    DOKUid('picker_plugin_indexmenu').style.display='none';
    return false;
}

function indexmenu_insertTags(lnk,sep) {
    var r,l=lnk;
    if (sep) {
	r=new RegExp (sep,"g");
	l=lnk.replace(r,':');
    }
    insertTags('wiki__text','[[',']]',l);
}

function indexmenu_toolFrame(parent,txt) {
    f=document.createElement('fieldset');
    l=document.createElement('legend');
    l.innerHTML='<strong>'+txt+'</strong>';
    f.appendChild(l);
    parent.appendChild(f);
    return f;
}

indexmenu_toolbar_additions();