includes/clientside/static/functions.js
changeset 832 7152ca0a0ce9
parent 823 4596c40aaa94
child 869 58bc29c14a4d
equal deleted inserted replaced
831:45e887f23282 832:7152ca0a0ce9
   102       return false;
   102       return false;
   103     }
   103     }
   104     // The user allowed the editor to be closed. Reset flags and knock out the on-close confirmation.
   104     // The user allowed the editor to be closed. Reset flags and knock out the on-close confirmation.
   105     editor_open = false;
   105     editor_open = false;
   106     enableUnload();
   106     enableUnload();
       
   107     // destroy the MCE instance so it can be recreated later
       
   108     $dynano('ajaxEditArea').destroyMCE(false);
   107   }
   109   }
   108   var ajax = ajaxMakeXHR();
   110   var ajax = ajaxMakeXHR();
   109   if ( !ajax )
   111   if ( !ajax )
   110   {
   112   {
   111     console.error('ajaxMakeXHR() failed');
   113     console.error('ajaxMakeXHR() failed');
   134       return false;
   136       return false;
   135     }
   137     }
   136     // The user allowed the editor to be closed. Reset flags and knock out the on-close confirmation.
   138     // The user allowed the editor to be closed. Reset flags and knock out the on-close confirmation.
   137     editor_open = false;
   139     editor_open = false;
   138     enableUnload();
   140     enableUnload();
       
   141     // destroy the MCE instance so it can be recreated later
       
   142     $dynano('ajaxEditArea').destroyMCE(false);
   139   }
   143   }
   140   var ajax = ajaxMakeXHR();
   144   var ajax = ajaxMakeXHR();
   141   if ( !ajax )
   145   if ( !ajax )
   142   {
   146   {
   143     console.error('ajaxMakeXHR() failed');
   147     console.error('ajaxMakeXHR() failed');
   446     else
   450     else
   447       p = p.parentNode;
   451       p = p.parentNode;
   448   }
   452   }
   449 }
   453 }
   450 
   454 
       
   455 /**
       
   456  * Return a DOMElement that uses a sprite image.
       
   457  * @param string Path to sprite image
       
   458  * @param int Width of resulting image
       
   459  * @param int Height of resulting image
       
   460  * @param int X offset
       
   461  * @param int Y offset
       
   462  * @return object HTMLImageElement
       
   463  */
       
   464 
       
   465 function gen_sprite(path, width, height, xpos, ypos)
       
   466 {
       
   467   var image = document.createElement('img');
       
   468   image.src = scriptPath + '/images/spacer.gif';
       
   469   image.width = String(width);
       
   470   image.height = String(height);
       
   471   image.style.backgroundImage = 'url(' + path + ')';
       
   472   image.style.backgroundRepeat = 'no-repeat';
       
   473   xpos = ( xpos == 0 ) ? '0' : '-' + String(xpos);
       
   474   ypos = ( ypos == 0 ) ? '0' : '-' + String(ypos);
       
   475   image.style.backgroundPosition = ypos + 'px ' + xpos + 'px';
       
   476   
       
   477   return image;
       
   478 }
       
   479 
       
   480 /**
       
   481  * The same as gen_sprite but generates HTML instead of a DOMElement.
       
   482  * @param string Path to sprite image
       
   483  * @param int Width of resulting image
       
   484  * @param int Height of resulting image
       
   485  * @param int X offset
       
   486  * @param int Y offset
       
   487  * @return object HTMLImageElement
       
   488  */
       
   489 
       
   490 function gen_sprite_html(path, width, height, xpos, ypos)
       
   491 {
       
   492   var html = '<img src="' + scriptPath + '/images/spacer.gif" width="' + width + '" height="' + height + '" ';
       
   493   xpos = ( xpos == 0 ) ? '0' : '-' + String(xpos);
       
   494   ypos = ( ypos == 0 ) ? '0' : '-' + String(ypos);
       
   495   html += 'style="background-image: url(' + path + '); background-repeat: no-repeat; background-position: ' + ypos + 'px ' + xpos + 'px;"';
       
   496   html += ' />';
       
   497   
       
   498   return html;
       
   499 }
       
   500 
   451 function findParentForm(o)
   501 function findParentForm(o)
   452 {
   502 {
   453   return get_parent_form(o);
   503   return get_parent_form(o);
   454 }
   504 }
   455 
   505 
   456 function domObjChangeOpac(opacity, id) {
   506 function domObjChangeOpac(opacity, id)
   457     var object = id.style;
   507 {
   458     object.opacity = (opacity / 100);
   508   if ( !id )
   459     object.MozOpacity = (opacity / 100);
   509     return false;
   460     object.KhtmlOpacity = (opacity / 100);
   510   
   461     object.filter = "alpha(opacity=" + opacity + ")";
   511   var object = id.style;
       
   512   object.opacity = (opacity / 100);
       
   513   object.MozOpacity = (opacity / 100);
       
   514   object.KhtmlOpacity = (opacity / 100);
       
   515   object.filter = "alpha(opacity=" + opacity + ")";
   462 }
   516 }
   463 
   517 
   464 function getScrollOffset(el)
   518 function getScrollOffset(el)
   465 {
   519 {
   466   var position;
   520   var position;