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

  1. var gFinalHeight = 50;
  2. var gSlideIncrement = 1;
  3. var gSlideTime = 10;
  4. var gOpenTime = 3500;
  5.  
  6. var gAlertCookie = "";
  7. var gAlertListener = null;
  8.  
  9. var gMouseOver = false;
  10. var gCloseTimeout = null;
  11.  
  12. function prefillAlertInfo() {
  13.   document.getElementById('alertTitleLabel').textContent = window.arguments[1];
  14.   document.getElementById('alertTextLabel').textContent = window.arguments[2].shift();
  15.   
  16.   var mailMsg = window.arguments[2].shift();
  17.   if (mailMsg) {
  18.     document.getElementById('alertTextMailFrom').setAttribute("value", mailMsg[0]);
  19.     document.getElementById('alertTextMailSubject').setAttribute("value", mailMsg[1]);
  20.     document.getElementById('alertGrid').setAttribute("hidden", "false");
  21.   }
  22.   
  23.   gAlertCookie = window.arguments[3];
  24.   gAlertListener = window.arguments[4];
  25. }
  26.  
  27. function onAlertLoad() {
  28.   sizeToContent();
  29.   
  30.   var contentDim = document.getElementById("alertBox").boxObject;
  31.   window.innerWidth = contentDim.width;
  32.   
  33.   gFinalHeight = window.outerHeight - 2;
  34.   
  35.   gSlideIncrement = Math.max(1, parseInt(gFinalHeight / 40, 10));
  36.   
  37.   window.outerHeight = 1;
  38.   
  39.   _moveAlert();
  40.   
  41.   setTimeout(animateAlert, gSlideTime);
  42. }
  43.  
  44. function _moveAlert() {
  45.   window.moveTo((screen.availLeft + screen.availWidth - window.outerWidth),
  46.                 screen.availTop + screen.availHeight - window.outerHeight);
  47.   
  48.   var opacityValue = Math.min(.99, Math.max(.25, window.outerHeight/gFinalHeight));
  49.   document.getElementById("alertBox").style.opacity = opacityValue;
  50. }
  51.  
  52. function animateAlert() {
  53.   if (window.outerHeight < gFinalHeight) {
  54.     window.outerHeight += Math.min(gSlideIncrement, gFinalHeight - window.outerHeight);
  55.     _moveAlert();
  56.     setTimeout(animateAlert, gSlideTime);
  57.   }
  58.   else if (!gMouseOver)
  59.     gCloseTimeout = setTimeout(closeAlert, gOpenTime);
  60. }
  61.  
  62. function closeAlert() {
  63.   if (gMouseOver)
  64.     return;
  65.   
  66.   if (window.outerHeight > gSlideIncrement) {
  67.     window.outerHeight -= gSlideIncrement;
  68.     _moveAlert();
  69.     setTimeout(closeAlert, gSlideTime);
  70.   } else {
  71.     closeWindow();
  72.   }
  73. }
  74.  
  75. function onAlertClick(aEvent) {
  76.   if (aEvent.button == 2 || aEvent.target.id == "closeButton") {
  77.     closeWindow();
  78.   } else if (gAlertCookie == "mail" || gAlertCookie == "feeds") {
  79.     var action = gAlertCookie == "mail" ? 1040 : 1120;
  80.     
  81.     Components.classes["@yandex.ru/yasearch;1"]
  82.               .getService(Components.interfaces.nsIYaSearch)
  83.               .wrappedJSObject
  84.               .loadConditionalURI(gAlertCookie, "tab", {action:action});
  85.     
  86.     closeWindow();
  87.   }
  88.   return true;
  89. }
  90.  
  91. function closeWindow() {
  92.   if (gAlertListener)
  93.     gAlertListener.observe(null, "alertfinished", gAlertCookie);
  94.   
  95.   window.close();
  96. }
  97.  
  98. function onMouseOver(aEvent) {
  99.   gMouseOver = true;
  100.   if (gCloseTimeout)
  101.     clearTimeout(gCloseTimeout);
  102. }
  103.  
  104. function onMouseOut(aEvent) {
  105.   gMouseOver = false;
  106.   gOpenTime = 1000;
  107.   animateAlert();
  108. }