home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 March / Chip_2011.03_CD.iso / Tools / yabar.msi / fil798FA6A2B65C8B96B39124393AB813B9 < prev    next >
Encoding:
Text File  |  2010-04-16  |  2.9 KB  |  101 lines

  1. var gFinalHeight = 50;
  2. var gSlideIncrement = 1;
  3. var gSlideTime = 10;
  4. var gOpenTime = 3500;
  5.  
  6. var gCloseTimeout = null;
  7.  
  8. var gYaDefence = Components.classes["@yandex.ru/yasearch;1"]
  9.                            .getService(Components.interfaces.nsIYaSearch)
  10.                            .wrappedJSObject
  11.                            .yaDefence;
  12.  
  13. function prefillAlertInfo() {
  14.   var protectedDiff = gYaDefence._getProtectedDiff();
  15.   
  16.   if (protectedDiff.protectedHost)
  17.     document.getElementById("hostProtectedLabel").value = protectedDiff.protectedHost;
  18.   
  19.   if (protectedDiff.currentHost)
  20.     document.getElementById("hostCurrentLabel").value = protectedDiff.currentHost;
  21.   
  22.   if (window.arguments[1] == true)
  23.     document.getElementById("alertBox").setAttribute("class", "changedAgain");
  24. }
  25.  
  26. function onAlertLoad() {
  27.   sizeToContent();
  28.   
  29.   var contentDim = document.getElementById("alertBox").boxObject;
  30.   window.innerWidth = contentDim.width;
  31.   
  32.   gFinalHeight = window.outerHeight- 2;
  33.   
  34.   gSlideIncrement = Math.max(1, parseInt(gFinalHeight / 40, 10));
  35.   
  36.   window.outerHeight = 1;
  37.   
  38.   _moveAlert();
  39.   
  40.   setTimeout(animateAlert, gSlideTime);
  41. }
  42.  
  43. function setHomePageAndExit(aAcceptCurrent) {
  44.   var protectEnabled = document.getElementById("protectEnabledCheckbox").checked;
  45.   gYaDefence.homepageAlertCallback(aAcceptCurrent, protectEnabled);
  46.   
  47.   window.close();
  48. }
  49.  
  50. function onAlertClick(aEvent) {
  51.   switch (aEvent.target.id) {
  52.     case "mailtoSupportLink":
  53.       let target = aEvent.originalTarget;
  54.       let targetHref = target.getAttribute("href");
  55.       
  56.       Components.classes["@yandex.ru/yasearch;1"]
  57.                 .getService(Components.interfaces.nsIYaSearch)
  58.                 .wrappedJSObject
  59.                 .loadURI(targetHref, "new-tab");
  60.       
  61.       window.close();
  62.       break;
  63.     
  64.     case "closeButton":
  65.       window.close();
  66.       break;
  67.     
  68.     case "showMore":
  69.       var currHeight = window.outerHeight;
  70.       document.getElementById("changesHelp").setAttribute("moreHelpShowed", "true");
  71.       
  72.       setTimeout(function() {
  73.         sizeToContent();
  74.         
  75.         var contentDim = document.getElementById("alertBox").boxObject;
  76.         window.innerWidth = contentDim.width;
  77.         
  78.         gFinalHeight = window.outerHeight - 2;
  79.         window.outerHeight = currHeight;
  80.         animateAlert();
  81.       }, 0);
  82.       
  83.       break;
  84.   }
  85. }
  86.  
  87. function _moveAlert() {
  88.   window.moveTo((screen.availLeft + screen.availWidth - window.outerWidth),
  89.                 screen.availTop + screen.availHeight - window.outerHeight);
  90.   
  91.   var opacityValue = Math.min(.99, Math.max(.25, window.outerHeight/gFinalHeight));
  92.   document.getElementById("alertBox").style.opacity = opacityValue;
  93. }
  94.  
  95. function animateAlert() {
  96.   if (window.outerHeight < gFinalHeight) {
  97.     window.outerHeight += Math.min(gSlideIncrement, gFinalHeight - window.outerHeight);
  98.     _moveAlert();
  99.     setTimeout(animateAlert, gSlideTime);
  100.   }
  101. }