source: documentation/trunk/packages/dokuwiki-2011-05-25a/lib/plugins/imagereference/script.js@ 25027

Last change on this file since 25027 was 25027, checked in by jmt12, 12 years ago

Adding the packages directory, and within it a configured version of dokuwiki all ready to run

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1 function checkImages() {
2
3 var divs=document.getElementsByTagName("DIV");
4
5 for (var i=0;i<divs.length;i++) {
6 // adding in more checks to ensure elements exist [jmt12]
7 if (divs[i] && divs[i].childNodes[0] && divs[i].childNodes[0].childNodes[0] && (divs[i].className == "imgcaption" || divs[i].className == "imgcaptionleft" || divs[i].className == "imgcaptionright")) {
8
9 var children = divs[i].getElementsByTagName("IMG");
10 // check if there is a link encapsulating the image
11 var tmpImg = divs[i].childNodes[0].childNodes[0];
12 if (tmpImg == null)
13 tmpImg = divs[i].childNodes[0];
14 else {
15 // we have link and we can build the link image
16 var innerElements = divs[i];
17 // adding in more checks to ensure elements exist [jmt12]
18 if (innerElements && innerElements.childNodes[0] && innerElements.childNodes[1])
19 {
20 var iLink = innerElements.childNodes[1].childNodes[2];
21 var iSpan = iLink.childNodes[0];
22 // set the href of the link to the image link
23 iLink.href= innerElements.childNodes[0].href;
24 // show the link image
25 iSpan.style.display="inline";
26 }
27 }
28 //var tmpLink = divs[i].childNodes[0];
29 divs[i].style.width=(tmpImg.width + 8)+"px";
30 }
31 }
32 }
33
34
35 if(window.toolbar!=undefined){
36 toolbar[toolbar.length] = {"type":"format",
37 "title":"Adds an ImageCaption tag",
38 "icon":"../../plugins/imagereference/button.png",
39 "key":"",
40 "open":"<imgcaption image1|>",
41 "close":"</imgcaption>"};
42 toolbar[toolbar.length] = {"type":"format",
43 "title":"Adds an ImageReference tag",
44 "icon":"../../plugins/imagereference/refbutton.png",
45 "key":"",
46 "open":"<imgref ",
47 "sample":"image1",
48 "close":">"};
49}
50
51
52 addInitEvent(function(){checkImages();});
Note: See TracBrowser for help on using the repository browser.