1var element = document.getElementById('wiki__text');
2
3
4// add a new toolbar button, but first check if there is a toolbar
5if (typeof window.toolbar !== 'undefined') {
6    window.toolbar[window.toolbar.length] = {
7        type: "imgpreview", // we have a new type that links to the function
8        title: "Image Preview",
9        icon: "../../plugins/imagepreview/imgpreview.png",
10        key:"q"
11    };
12}
13
14
15
16
17function addBtnActionImgpreview($btn, props, edid) {
18    // initialize stuff if required
19    // ...
20
21    $btn.click(function() {
22      handler1();
23
24        return false;
25    });
26
27    return 'click';
28}
29
30
31
32
33
34function handler1(){
35 if(document.getElementById('yourpreviewId')==null){
36         jQuery(document.createElement('div'))
37               .dialog({
38                    autoOpen: false,
39                    draggable: true,
40                    resizable: false
41               })
42               .html(
43                    '<img id="previewimg" width=100%  onclick="divhide()">'
44                    )
45               .parent()
46               .attr('id','yourpreviewId')
47               .attr('onclick','divhide()')
48               .css({
49                    'position':    'absolute',
50                    'top':         '0px',
51                    'left':        '70px',
52
53                    'height':'100%'
54                   })
55               .hide()
56               .appendTo('.summary');
57
58 }
59
60            var seltext = window.getSelection().toString();
61            var pattern = /(\{\{)(.*?)\.(gif|jpg|jpeg|tiff|png)(.*?)(\}\})(.*?)/;
62            var containimg = pattern.test(seltext);
63            if (containimg==true){
64                match= seltext.match(pattern);
65                seltext = DOKU_BASE+"lib/exe/fetch.php?media="+match[2]+"."+match[3] ;
66                document.getElementById("previewimg").src = seltext;
67                jQuery("#yourpreviewId").toggle();
68
69            }
70
71
72}
73
74function divhide(){
75    jQuery("#yourpreviewId").toggle();
76
77}