home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / komunikace / kmeleon / K-Meleon1.1.3en-US.exe / macros / zoom.kmm < prev   
Text File  |  2007-05-04  |  6KB  |  133 lines

  1. # K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
  2.  
  3. # ---------- Zoom Functionality ------------------------------------------------------------------------------------
  4. #
  5. # Dependencies    : main.kmm ($macroPrefBranch, JS)
  6. # Resources    : -
  7. # Preferences    : kmeleon.plugins.macros.zoom
  8. #
  9. # ------------------------------------------------------------------------------------------------------------------
  10.  
  11. Zoom_In{
  12. $__data=getpref(STRING,$_Zoom_Pref);
  13. $__data=="text"?id(ID_FONT_INCREASE):($__data=="page"?&Zoom_Page_In:($__data=="images"?&Zoom_Images_In:0));
  14. }
  15. Zoom_Out{
  16. $__data=getpref(STRING,$_Zoom_Pref);
  17. $__data=="text"?id(ID_FONT_DECREASE):($__data=="page"?&Zoom_Page_Out:($__data=="images"?&Zoom_Images_Out:0));
  18. }
  19.  
  20. Zoom_Page_In{
  21. $_Zoom_By="1"; &_Zoom_Images;
  22. # EITHER:
  23. id(ID_FONT_INCREASE);
  24. # OR:
  25. #&_Zoom_Text;
  26. }
  27. Zoom_Page_Out{
  28. $_Zoom_By="-1"; &_Zoom_Images;
  29. # EITHER:
  30. id(ID_FONT_DECREASE);
  31. # OR:
  32. #&_Zoom_Text;
  33. }
  34.  
  35. Zoom_Images_In{
  36. $_Zoom_By="1"; &_Zoom_Images;
  37. }
  38. Zoom_Images_Out{
  39. $_Zoom_By="-1"; &_Zoom_Images;
  40. }
  41.  
  42. Zoom_Image_In{
  43. $_Zoom_By="2"; &_Zoom_Image;
  44. }
  45. Zoom_Image_Out{
  46. $_Zoom_By="1/2"; &_Zoom_Image;
  47. }
  48.  
  49. Zoom_Page{
  50. menuchecked=(getpref(STRING,$_Zoom_Pref)=="page");
  51. $_default="page"; $_tip=_("Zoom buttons effect text and images."); &_Zoom_Set;
  52. }
  53. Zoom_Text{
  54. menuchecked=(getpref(STRING,$_Zoom_Pref)=="text");
  55. $_default="text"; $_tip=_("Zoom buttons effect text only."); &_Zoom_Set;
  56. }
  57. Zoom_Images{
  58. menuchecked=(getpref(STRING,$_Zoom_Pref)=="images");
  59. $_default="images"; $_tip=_("Zoom buttons effect images only."); &_Zoom_Set;
  60. }
  61.  
  62. # ----- PRIVATE
  63.  
  64. $_Zoom_Pref=$macroPrefBranch."zoom";
  65.  
  66. _Zoom_Image{
  67. $_Zoom_doitImg="if(getAttribute('zoom')==null){setAttribute('initW',width);setAttribute('initH',height);setAttribute('zoom',1)}var iz=".$_Zoom_By.";setAttribute('zoom',getAttribute('zoom')*iz);iz=getAttribute('zoom');width=bz*iz*getAttribute('initW');height=bz*iz*getAttribute('initH')"; &_Zoom_hndlImage;
  68. }
  69. _Zoom_Images{
  70. $_Zoom_doitImg="var iz=(getAttribute('zoom')==null)?1:getAttribute('zoom');if(getAttribute('initW')==null){setAttribute('initW',width);setAttribute('initH',height)}width=bz*iz*getAttribute('initW');height=bz*iz*getAttribute('initH')"; &_Zoom_hndlImages;
  71. }
  72. _Zoom_Text{
  73. $JS_doit="var b=getElementsByTagName('body')[0];if(b)zoomNode(b,(10+".$_Zoom_By.")/10);"; $JS_func="function zoomNode(n,z){for(var j=0;j<n.childNodes.length;j++)if(n.childNodes[j].nodeType==1)zoomNode(n.childNodes[j],z);var lh=getComputedStyle(n,'').getPropertyValue('line-height');if(lh!='normal')n.style.lineHeight=Math.round(parseFloat(lh.replace(/px/,''))*z)+'px';n.style.fontSize=Math.round(parseFloat(getComputedStyle(n,'').getPropertyValue('font-size').replace(/px/,''))*z)+'px'}"; &JS_hndlDocs;
  74. }
  75. _Zoom_hndlImage{
  76. $JS_doit="var b=getElementsByTagName('body')[0];if(b){var bz=(b.getAttribute('zoom')==null)?1:(b.getAttribute('zoom')/10);for(var j=0,i=images;j<i.length;j++)with(i[j])if(urlencode(src)=='".urlencode($ImageURL)."'){".$_Zoom_doitImg."}}"; &JS_hndlDoc;
  77. }
  78. _Zoom_hndlImages{
  79. $JS_doit="var b=getElementsByTagName('body')[0];if(b){if(b.getAttribute('zoom')==null)b.setAttribute('zoom',10);var bz=".$_Zoom_By.",o=parseFloat(b.getAttribute('zoom'));if(Math.round(bz+o)){b.setAttribute('zoom',Math.round(bz+o));bz=b.getAttribute('zoom')/10;for(var j=0,i=images;j<i.length;j++)with(i[j]){".$_Zoom_doitImg."}}}"; &JS_hndlDocs;
  80. }
  81.  
  82. _Zoom_Set{
  83. setpref(STRING,$_Zoom_Pref,$_default); statusbar($_tip);
  84. }
  85. _Zoom_SetDefaults{
  86. getpref(STRING,$_Zoom_Pref)==""?setpref(STRING,$_Zoom_Pref,"text"):0;
  87. }
  88. $OnStartup=$OnStartup."_Zoom_SetDefaults;";
  89.  
  90. _Zoom_BuildMenu{
  91. # view menu
  92. setmenu(PageDisplay,popup,"&Zoom",ID_FONT_INCREASE);
  93. setmenu(PageDisplay,command,"",ID_FONT_INCREASE);
  94. setmenu(PageDisplay,command,"",ID_FONT_DECREASE);
  95. setmenu("&Zoom",inline,__Zoom_In);
  96. setmenu(__Zoom_In,macro,"Zoom In &Page",Zoom_Page_In);
  97. setmenu(__Zoom_In,command,"Zoom In &Text",ID_FONT_INCREASE);
  98. setmenu(__Zoom_In,macro,"Zoom In &Images",Zoom_Images_In);
  99. setmenu("&Zoom",inline,__Zoom_Out);
  100. setmenu(__Zoom_Out,macro,"Zoom Out P&age",Zoom_Page_Out);
  101. setmenu(__Zoom_Out,command,"Zoom Out T&ext",ID_FONT_DECREASE);
  102. setmenu(__Zoom_Out,macro,"Zoom Out I&mages",Zoom_Images_Out);
  103. $kToolbars==true?&_Zoom_BuildButtonMenu:0;
  104. # context menus
  105. setmenu(ImageView,macro,"Zoom I&n",Zoom_Image_In);
  106. setmenu(ImageView,macro,"Zoom Ou&t",Zoom_Image_Out);
  107. }
  108. _Zoom_BuildButtonMenu{
  109. # zoom buttons
  110. setmenu("&Zoom",inline,__Zoom_Btn);
  111. setmenu(__Zoom_Btn,popup,"Zoom &Buttons");
  112. setmenu("Zoom &Buttons",macro,"Zoom Full &Page",Zoom_Page);
  113. setmenu("Zoom &Buttons",macro,"Zoom &Text Only",Zoom_Text);
  114. setmenu("Zoom &Buttons",macro,"Zoom &Images Only",Zoom_Images);
  115. setmenu(_Zoom_In,inline,__Zoom_In);
  116. setmenu(_Zoom_In,inline,__Zoom_Btn);
  117. setmenu(_Zoom_Out,inline,__Zoom_Out);
  118. setmenu(_Zoom_Out,inline,__Zoom_Btn);
  119. }
  120. _Zoom_SetAccels{
  121. setaccel("ALT VK_PLUS","macros(Zoom_Images_In)");
  122. setaccel("ALT VK_ADD","macros(Zoom_Images_In)");
  123. setaccel("ALT VK_MINUS","macros(Zoom_Images_Out)");
  124. setaccel("ALT VK_SUBTRACT","macros(Zoom_Images_Out)");
  125. setaccel("CTRL ALT VK_PLUS","macros(Zoom_Page_In)");
  126. setaccel("CTRL ALT VK_ADD","macros(Zoom_Page_In)");
  127. setaccel("CTRL ALT VK_MINUS","macros(Zoom_Page_Out)");
  128. setaccel("CTRL ALT VK_SUBTRACT","macros(Zoom_Page_Out)");
  129. }
  130. $OnInit=$OnInit."_Zoom_SetAccels;_Zoom_BuildMenu;";
  131.  
  132. # ------------------------------------------------------------------------------------------------------------------
  133. $macroModules=$macroModules."Zoom;";