home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / komunikace / maxthon / mx_2.0.5.7845.exe / template / Options / maxOptions.js < prev   
Text File  |  2007-11-01  |  4KB  |  148 lines

  1. var maxOptions={};
  2. $langDefaultSection="Options";
  3. maxOptions.init=function(_1){
  4. maxConfig.setActiveFile("$main");
  5. document.title=$lang("maxthon_options");
  6. maxOptions.adjustHeight();
  7. window.onresize=maxOptions.adjustHeight;
  8. if(!_1){
  9. var _2=$cookies("activePage");
  10. var _3=$parseQueryString();
  11. if(_3["page"]){
  12. if(maxOptions.pages[_3["page"]]){
  13. _2=_3["page"];
  14. }
  15. }
  16. if(maxOptions.pages[_2]){
  17. maxOptions.activePage=_2;
  18. }
  19. maxOptions.ui.buildPageLinks();
  20. }
  21. maxOptions.action.activatePage(maxOptions.activePage);
  22. };
  23. maxOptions.destroy=function(){
  24. };
  25. maxOptions.adjustHeight=function(){
  26. var _4=$id("sidebar");
  27. var _5=document.documentElement.clientHeight-_4.offsetTop;
  28. _4.style.height=_5;
  29. var _4=$id("contentBlock");
  30. _5=document.documentElement.clientHeight-_4.offsetTop-22;
  31. $id("pageContent").style.height=_5;
  32. };
  33. maxOptions.action={};
  34. maxOptions.action.activatePage=function(_6){
  35. var _7=$id("pageLink_"+maxOptions.activePage);
  36. if(_7){
  37. _7.className="";
  38. }
  39. _7=$id("pageLink_"+_6);
  40. if(_7){
  41. _7.className="active";
  42. }
  43. maxOptions.ui.setPageHeader(_6);
  44. maxOptions.ui.buildPage(_6);
  45. try{
  46. eval("maxOptions.pages."+maxOptions.activePage+".destroy()");
  47. }
  48. catch(e){
  49. if(!((e.number&65535)==438)){
  50. alert("maxOptions.pages."+_6+".destroy()\n"+(e.number&65535)+" : "+e.message);
  51. throw (e);
  52. }
  53. }
  54. try{
  55. maxOptions.pages[_6].init();
  56. }
  57. catch(e){
  58. if(!((e.number&65535)==438)){
  59. alert("maxOptions.pages["+_6+"].init()\n"+(e.number&65535)+" : "+e.message);
  60. throw (e);
  61. }
  62. }
  63. maxOptions.activePage=_6;
  64. $cookies("activePage",_6);
  65. };
  66. maxOptions.action.applyChanges=function(){
  67. maxConfig.save();
  68. external.max_Invoke("ReloadConfig");
  69. maxOptions.ui.showMessage($lang("config_saved"),3000);
  70. };
  71. maxOptions.action.resetChanges=function(){
  72. if(maxConfig.modified&&confirm("["+$lang("maxthon_options")+"]\n\n"+$lang("config_reset_confirm"))){
  73. maxConfig.load();
  74. maxOptions.action.activatePage(maxOptions.activePage);
  75. maxOptions.ui.showMessage($lang("config_reset"),3000);
  76. }
  77. };
  78. maxOptions.action.restoreDefault=function(){
  79. if(confirm("["+$lang("maxthon_options")+"]\n\n"+$lang("confirm_restore_default"))){
  80. external.max_Invoke("DefaultConfig","All");
  81. maxOptions.init(true);
  82. maxOptions.ui.showMessage($lang("config_reset"),3000);
  83. }
  84. };
  85. maxOptions.action.close=function(_8){
  86. if(maxConfig.files["$main"].modified&&confirm("["+$lang("maxthon_options")+"]\n\n"+$lang("config_not_saved_confirm"))){
  87. maxOptions.action.applyChanges();
  88. }else{
  89. maxConfig.files["$main"].modified=false;
  90. }
  91. maxOptions.destroy();
  92. if(!_8){
  93. window.close();
  94. }
  95. };
  96. maxOptions.ui={};
  97. maxOptions.ui.showMessage=function(_9,_a){
  98. var _b=$id("msgBox");
  99. if(_b){
  100. _b.innerHTML=_9;
  101. _b.style.display="block";
  102. window.setTimeout(maxOptions.ui.clearMessage,_a);
  103. }
  104. };
  105. maxOptions.ui.clearMessage=function(){
  106. var _c=$id("msgBox");
  107. if(_c){
  108. _c.innerHTML="";
  109. _c.style.display="none";
  110. }
  111. };
  112. maxOptions.ui.toggleSidebar=function(){
  113. var _d=$id("sidebarWrapper");
  114. var _e=$id("btnSidebar");
  115. if($toggleElement("sidebar")){
  116. _d.style.width="";
  117. _e.src="../_shared/images/btn_hide_sidebar.png";
  118. }else{
  119. _d.style.width="8";
  120. _e.src="../_shared/images/btn_show_sidebar.png";
  121. }
  122. };
  123. maxOptions.ui.setPageHeader=function(_f){
  124. var _10=$lang("page_"+_f);
  125. $write(_10,"pageHeader",false);
  126. };
  127. maxOptions.ui.buildPageLinks=function(){
  128. var _11="";
  129. for(label in maxOptions.pages){
  130. if(maxOptions.pages[label].type=="separator"){
  131. _11+="<hr/>";
  132. }else{
  133. _11+="<a id=\"pageLink_"+label+"\" class=\"pageLink\" href=\"javascript:;\" "+"onclick=\"this.blur();maxOptions.action.activatePage('"+label+"');\">"+"<img src=\"images/page_"+label+".png\"/> "+$lang("page_"+label)+"</a>\n";
  134. }
  135. }
  136. $write(_11,"pageLinks",false);
  137. };
  138. maxOptions.ui.buildPage=function(_12){
  139. var obj=$id("pageContent");
  140. if(!obj){
  141. alert("maxOptions.ui.buildPage :: missing 'pageContent' object");
  142. }
  143. var _14=maxConfig.ui.buildItems(maxOptions.pages[_12].items);
  144. _14+="<br/><br/><br/><br/><br/><br/>";
  145. obj.innerHTML=_14;
  146. };
  147.  
  148.