Ticket #1176: XinhaDialogOptions.patch

File XinhaDialogOptions.patch, 3.1 kB (added by guest, 3 months ago)

Patch to allow global overrides of dialog options (resizable, closable, modal, and centered)

  • XinhaDialog.js

     
    2727 * @param html string  
    2828 * @param localizer string the "context" parameter for Xinha._lc(), typically the name of the plugin 
    2929 * @param size object with two possible properties of the size: width & height as int, where height is optional 
     30 * @param options dictionary with optional boolean attributes 'modal', 'closable', 'resizable', and 'centered', as well as integer attribute 'layer' 
    3031 */ 
    3132Xinha.Dialog = function(editor, html, localizer, size, options) 
    3233{ 
     
    3839  this.size = size; 
    3940  this.modal = (options && options.modal === false) ? false : true; 
    4041  this.closable = (options && options.closable === false) ? false : true; 
     42  this.resizable = (options && options.resizable === false) ? false : true; 
    4143  this.layer = (options && options.layer) ? options.layer : 0; 
     44  this.centered = (options && options.centered === true) ? true : false; 
    4245   
    43    
     46  /* Check global config to see if we should override any of the above options 
     47    If a global option is set, it will apply to all dialogs, regardless of their 
     48    individual settings (i.e., it will override them). If the global option is 
     49    undefined, the options passed in above will be used. 
     50  */ 
     51  globalOptions = editor.config.dialogOptions 
     52  if (globalOptions) { 
     53    if (typeof(globalOptions.centered) != 'undefined') { 
     54      this.centered = globalOptions.centered; 
     55    } 
     56    if (typeof(globalOptions.resizable) != 'undefined') { 
     57      this.resizable = globalOptions.resizable; 
     58    } 
     59    if (typeof(globalOptions.closable) != 'undefined') { 
     60      this.closable = globalOptions.closable; 
     61    } 
     62    if (typeof(globalOptions.modal) != 'undefined') { 
     63      this.modal = globalOptions.modal; 
     64    } 
     65  } 
     66 
    4467  if (Xinha.is_ie) 
    4568  { // IE6 needs the iframe to hide select boxes 
    4669    var backG = document.createElement("iframe"); 
     
    204227    } 
    205228  } 
    206229 
    207   this.resizer = document.createElement('div'); 
    208   this.resizer.className = "resizeHandle"; 
    209   with (this.resizer.style) 
     230  this.resizer = null; 
     231  if (this.resizable) 
    210232  { 
    211     position = "absolute"; 
    212     bottom = "0px"; 
    213     right= "0px"; 
     233    this.resizer = document.createElement('div'); 
     234    this.resizer.className = "resizeHandle"; 
     235    with (this.resizer.style) 
     236    { 
     237      position = "absolute"; 
     238      bottom = "0px"; 
     239      right= "0px"; 
     240    } 
     241    Xinha._addEvent(this.resizer, 'mousedown', function(ev) { dialog.resizeStart(ev); }); 
     242    rootElem.appendChild(this.resizer); 
    214243  } 
    215   Xinha._addEvent(this.resizer, 'mousedown', function(ev) { dialog.resizeStart(ev); }); 
    216   rootElem.appendChild(this.resizer); 
    217    
     244 
    218245  this.rootElem = rootElem; 
    219246  this.captionBar = captionBar; 
    220247  this.main = main; 
     
    314341      rootElemStyle.top =  parseInt(this.size.top,10) + 'px'; 
    315342      rootElemStyle.left = parseInt(this.size.left,10) + 'px'; 
    316343    } 
    317     else if (this.editor.btnClickEvent) 
     344    else if (this.editor.btnClickEvent && !this.centered) 
    318345    { 
    319346      var btnClickEvent = this.editor.btnClickEvent; 
    320347      if (rootElemStyle.position == 'absolute')