Changeset 1009 for branches


Ignore:
Timestamp:
05/23/08 19:42:14 (11 years ago)
Author:
ray
Message:

some fixes for dragging for new dialogs

Location:
branches/new-dialogs-merge
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/new-dialogs-merge/XinhaCore.js

    r1006 r1009  
    17821782        function(ev) 
    17831783        { 
    1784           ev = Xinha.is_ie ? window.event : ev; 
     1784          ev = ev || window.event; 
    17851785          editor.btnClickEvent = {clientX : ev.clientX, clientY : ev.clientY}; 
    17861786          if ( obj.enabled ) 
     
    22052205    'lp_cell': this._panels.left.container,  // left panel 
    22062206    'ed_cell': document.createElement('td'), // editor 
     2207    'iframe_cover' : document.createElement('div'), //the editor iframe has to be covered when draging a dialog over it 
    22072208    'rp_cell': this._panels.right.container, // right panel 
    22082209 
     
    22592260  fw.table.appendChild(fw.tbody); 
    22602261 
    2261   var xinha = this._framework.table; 
     2262  var xinha = fw.table; 
    22622263  this._htmlArea = xinha; 
    22632264  Xinha.freeLater(this, '_htmlArea'); 
     
    22652266 
    22662267    // create the toolbar and put in the area 
    2267   this._framework.tb_cell.appendChild( this._createToolbar() ); 
     2268  fw.tb_cell.appendChild( this._createToolbar() ); 
    22682269 
    22692270    // create the IFRAME & add to container 
     
    22712272  iframe.src = this.popupURL(editor.config.URIs.blank); 
    22722273  iframe.id = "XinhaIFrame_" + this._textArea.id; 
    2273   this._framework.ed_cell.appendChild(iframe); 
     2274  fw.ed_cell.appendChild(iframe); 
    22742275  this._iframe = iframe; 
    22752276  this._iframe.className = 'xinha_iframe'; 
    22762277  Xinha.freeLater(this, '_iframe'); 
    22772278   
     2279  fw.iframe_cover.style.display = 'none'; 
     2280  fw.iframe_cover.style.position = 'absolute'; 
     2281   
     2282  fw.ed_cell.appendChild(fw.iframe_cover); 
     2283   
    22782284    // creates & appends the status bar 
    22792285  var statusbar = this._createStatusBar(); 
    2280   this._framework.sb_cell.appendChild(statusbar); 
     2286  fw.sb_cell.appendChild(statusbar); 
    22812287 
    22822288  // insert Xinha before the textarea. 
     
    22872293  // extract the textarea and insert it into the xinha framework 
    22882294  Xinha.removeFromParent(textarea); 
    2289   this._framework.ed_cell.appendChild(textarea); 
     2295  fw.ed_cell.appendChild(textarea); 
    22902296 
    22912297  // if another editor is activated while this one is in text mode, toolbar is disabled    
     
    24692475  this._risizing = true; 
    24702476   
     2477  var framework = this._framework; 
     2478   
    24712479  this.notifyOf('before_resize', {width:width, height:height}); 
    24722480  this.firePluginEvent('onBeforeResize', width, height); 
     
    25802588//  } 
    25812589 
    2582   this._framework.tb_cell.colSpan = col_span; 
    2583   this._framework.tp_cell.colSpan = col_span; 
    2584   this._framework.bp_cell.colSpan = col_span; 
    2585   this._framework.sb_cell.colSpan = col_span; 
     2590  framework.tb_cell.colSpan = col_span; 
     2591  framework.tp_cell.colSpan = col_span; 
     2592  framework.bp_cell.colSpan = col_span; 
     2593  framework.sb_cell.colSpan = col_span; 
    25862594 
    25872595  // Put in the panel rows, top panel goes above editor row 
    2588   if ( !this._framework.tp_row.childNodes.length ) 
    2589   { 
    2590     Xinha.removeFromParent(this._framework.tp_row); 
     2596  if ( !framework.tp_row.childNodes.length ) 
     2597  { 
     2598    Xinha.removeFromParent(framework.tp_row); 
    25912599  } 
    25922600  else 
    25932601  { 
    2594     if ( !Xinha.hasParentNode(this._framework.tp_row) ) 
    2595     { 
    2596       this._framework.tbody.insertBefore(this._framework.tp_row, this._framework.ler_row); 
     2602    if ( !Xinha.hasParentNode(framework.tp_row) ) 
     2603    { 
     2604      framework.tbody.insertBefore(framework.tp_row, framework.ler_row); 
    25972605    } 
    25982606  } 
    25992607 
    26002608  // bp goes after the editor 
    2601   if ( !this._framework.bp_row.childNodes.length ) 
    2602   { 
    2603     Xinha.removeFromParent(this._framework.bp_row); 
     2609  if ( !framework.bp_row.childNodes.length ) 
     2610  { 
     2611    Xinha.removeFromParent(framework.bp_row); 
    26042612  } 
    26052613  else 
    26062614  { 
    2607     if ( !Xinha.hasParentNode(this._framework.bp_row) ) 
    2608     { 
    2609       this._framework.tbody.insertBefore(this._framework.bp_row, this._framework.ler_row.nextSibling); 
     2615    if ( !Xinha.hasParentNode(framework.bp_row) ) 
     2616    { 
     2617      framework.tbody.insertBefore(framework.bp_row, framework.ler_row.nextSibling); 
    26102618    } 
    26112619  } 
     
    26142622  if ( !this.config.statusBar ) 
    26152623  { 
    2616     Xinha.removeFromParent(this._framework.sb_row); 
     2624    Xinha.removeFromParent(framework.sb_row); 
    26172625  } 
    26182626  else 
    26192627  { 
    2620     if ( !Xinha.hasParentNode(this._framework.sb_row) ) 
    2621     { 
    2622       this._framework.table.appendChild(this._framework.sb_row); 
     2628    if ( !Xinha.hasParentNode(framework.sb_row) ) 
     2629    { 
     2630      framework.table.appendChild(framework.sb_row); 
    26232631    } 
    26242632  } 
    26252633 
    26262634  // Size and set colspans, link up the framework 
    2627   this._framework.lp_cell.style.width  = this.config.panel_dimensions.left; 
    2628   this._framework.rp_cell.style.width  = this.config.panel_dimensions.right; 
    2629   this._framework.tp_cell.style.height = this.config.panel_dimensions.top; 
    2630   this._framework.bp_cell.style.height = this.config.panel_dimensions.bottom; 
    2631   this._framework.tb_cell.style.height = this._toolBar.offsetHeight + 'px'; 
    2632   this._framework.sb_cell.style.height = this._statusBar.offsetHeight + 'px'; 
     2635  framework.lp_cell.style.width  = this.config.panel_dimensions.left; 
     2636  framework.rp_cell.style.width  = this.config.panel_dimensions.right; 
     2637  framework.tp_cell.style.height = this.config.panel_dimensions.top; 
     2638  framework.bp_cell.style.height = this.config.panel_dimensions.bottom; 
     2639  framework.tb_cell.style.height = this._toolBar.offsetHeight + 'px'; 
     2640  framework.sb_cell.style.height = this._statusBar.offsetHeight + 'px'; 
    26332641 
    26342642  var edcellheight = height - this._toolBar.offsetHeight - this._statusBar.offsetHeight; 
     
    26572665  this._textArea.style.height = this._iframe.style.height; 
    26582666  this._textArea.style.width  = this._iframe.style.width; 
    2659       
     2667   
     2668  var iframePos = Xinha.getElementTopLeft(this._iframe); 
     2669  framework.iframe_cover.style.top = iframePos.top; 
     2670  framework.iframe_cover.style.left = iframePos.left; 
     2671  framework.iframe_cover.style.height = this._iframe.style.height; 
     2672  framework.iframe_cover.style.width = this._iframe.style.width; 
     2673   
    26602674  this.notifyOf('resize', {width:this._htmlArea.offsetWidth, height:this._htmlArea.offsetHeight}); 
    26612675  this.firePluginEvent('onResize',this._htmlArea.offsetWidth, this._htmlArea.offsetWidth); 
  • branches/new-dialogs-merge/modules/CreateLink/link.js

    r1008 r1009  
    1 // Paste Plain Text plugin for Xinha 
    2  
    3 // Distributed under the same terms as Xinha itself. 
    4 // This notice MUST stay intact for use (see license.txt). 
     1  /*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- 
     2    --  Xinha (is not htmlArea) - http://xinha.org 
     3    -- 
     4    --  Use of Xinha is granted by the terms of the htmlArea License (based on 
     5    --  BSD license)  please read license.txt in this package for details. 
     6    -- 
     7    --  Copyright (c) 2005-2008 Xinha Developer Team and contributors 
     8    -- 
     9    --  Xinha was originally based on work by Mihai Bazon which is: 
     10    --      Copyright (c) 2003-2004 dynarch.com. 
     11    --      Copyright (c) 2002-2003 interactivetools.com, inc. 
     12    --      This copyright notice MUST stay intact for use. 
     13    -- 
     14    --  This is the standard implementation of the Xinha.prototype._createLink method, 
     15    --  which provides the functionality to insert a hyperlink in the editor. 
     16    -- 
     17    --  The file is loaded as a special plugin by the Xinha Core when no alternative method (plugin) is loaded. 
     18    -- 
     19    -- 
     20    --  $HeadURL:http://svn.xinha.webfactional.com/trunk/modules/CreateLink/link.js $ 
     21    --  $LastChangedDate:2008-04-12 19:10:04 +0200 (Sa, 12 Apr 2008) $ 
     22    --  $LastChangedRevision:990 $ 
     23    --  $LastChangedBy:ray $ 
     24    --------------------------------------------------------------------------*/ 
    525 
    626function CreateLink(editor) { 
  • branches/new-dialogs-merge/modules/Dialogs/XinhaDialog.js

    r1007 r1009  
    122122  var captionBar = main.removeChild( main.getElementsByTagName("h1")[0]); 
    123123  rootElem.insertBefore(captionBar,main); 
    124   captionBar.onmousedown = function(ev) { dialog._dragStart(ev); }; 
     124  Xinha._addEvent(captionBar, 'mousedown',function(ev) { dialog.dragStart(ev); }); 
    125125   
    126126  captionBar.style.MozUserSelect = "none"; 
     
    178178  for (var i=0; i<all.length;i++) 
    179179  { 
    180         var el = all[i];  
     180    var el = all[i];  
    181181    if (el.tagName.toLowerCase() == 'textarea' || el.tagName.toLowerCase() == 'input') 
    182182    { 
     
    198198    right= "0px"; 
    199199  } 
    200   this.resizer.onmousedown = function(ev) { dialog._resizeStart(ev); }; 
     200  Xinha._addEvent(this.resizer, 'mousedown', function(ev) { dialog.resizeStart(ev); }); 
    201201  rootElem.appendChild(this.resizer); 
    202202   
     
    248248  
    249249  // We need to preserve the selection 
    250   this._lastRange = this.editor.saveSelection(); 
    251    
    252   if (Xinha.is_ie && !modal) 
    253   { 
    254     dialog.saveSelection = function() { dialog._lastRange = dialog.editor.saveSelection();}; 
    255     Xinha._addEvent(this.editor._doc,'mouseup', dialog.saveSelection); 
    256   } 
    257  
     250  // if this is called before some editor has been activated, it activates the editor 
     251  if (Xinha._someEditorHasBeenActivated) 
     252  { 
     253     this._lastRange = this.editor.saveSelection(); 
     254      
     255    if (Xinha.is_ie && !modal) 
     256    { 
     257      dialog.saveSelection = function() { dialog._lastRange = dialog.editor.saveSelection();}; 
     258      Xinha._addEvent(this.editor._doc,'mouseup', dialog.saveSelection); 
     259    } 
     260  } 
     261  
    258262  if ( modal ) this.editor.deactivateEditor(); 
    259263 
     
    281285 
    282286    //rootElemStyle.display   = ''; 
    283         Xinha.Dialog.fadeIn(this.rootElem); 
     287    Xinha.Dialog.fadeIn(this.rootElem); 
    284288    var dialogHeight = rootElem.offsetHeight; 
    285289    var dialogWidth = rootElem.offsetWidth; 
     
    369373    //this.rootElem.style.display = 'none'; 
    370374    Xinha.Dialog.fadeOut(this.rootElem); 
    371         this.hideBackground(); 
     375    this.hideBackground(); 
    372376    var dialog = this; 
    373377 
     
    437441}; 
    438442 
    439 Xinha.Dialog.prototype._dragStart = function (ev)  
     443Xinha.Dialog.prototype.dragStart = function (ev)  
    440444{ 
    441445  if ( this.attached || this.dragging)  
     
    443447    return; 
    444448  } 
     449  if (!this.modal) 
     450  { 
     451    Xinha.Dialog.coverIframes(); 
     452  } 
     453  ev = ev || window.event; 
     454   
    445455  this.editor.suspendUpdateToolbar = true; 
    446456  var dialog = this; 
     
    452462  var st = dialog.rootElem.style; 
    453463 
    454   dialog.xOffs = ((Xinha.is_ie) ? window.event.offsetX : ev.layerX); 
    455   dialog.yOffs = ((Xinha.is_ie) ? window.event.offsetY : ev.layerY); 
     464  dialog.xOffs =  ev.offsetX || ev.layerX; //first value for IE/Opera/Safari, second value for Gecko (or should I say "netscape";)) 
     465  dialog.yOffs =  ev.offsetY || ev.layerY; 
    456466 
    457467  dialog.mouseMove = function(ev) { dialog.dragIt(ev); }; 
    458   Xinha._addEvent(document, "mousemove", dialog.mouseMove ); 
     468  Xinha._addEvent(document,"mousemove", dialog.mouseMove ); 
     469 
    459470  dialog.mouseUp = function (ev) { dialog.dragEnd(ev); }; 
    460   Xinha._addEvent(document, "mouseup",  dialog.mouseUp); 
     471  Xinha._addEvent(document,"mouseup",  dialog.mouseUp); 
    461472 
    462473}; 
     
    470481    return false; 
    471482  } 
    472   ev = (Xinha.is_ie) ? window.event : ev; 
    473483 
    474484  if (dialog.rootElem.style.position == 'absolute') 
     
    499509  var dialog = this; 
    500510  this.editor.suspendUpdateToolbar = false; 
     511   
     512  if (!this.modal) 
     513  { 
     514    Xinha.Dialog.unCoverIframes(); 
     515  } 
     516   
    501517  if (!dialog.dragging)  
    502518  { 
     
    506522 
    507523  Xinha._removeEvent(document, "mousemove", dialog.mouseMove ); 
    508   Xinha._removeEvent(document, "mouseup", dialog.mouseUp ); 
     524  Xinha._removeEvent(document, "mousemove", dialog.mouseMove ); 
     525  Xinha._removeEvent(document, "mouseup",  dialog.mouseUp); 
    509526 
    510527  dialog.size.top  = dialog.rootElem.style.top; 
     
    513530 
    514531 
    515 Xinha.Dialog.prototype._resizeStart = function (ev) { 
     532Xinha.Dialog.prototype.resizeStart = function (ev) { 
    516533  var dialog = this; 
    517534  this.editor.suspendUpdateToolbar = true; 
     
    521538  } 
    522539  dialog.resizing = true; 
     540  if (!this.modal) 
     541  { 
     542    Xinha.Dialog.coverIframes(); 
     543  } 
    523544  dialog.scrollPos = dialog.editor.scrollPos(); 
    524545   
     
    530551 
    531552  dialog.mouseMove = function(ev) { dialog.resizeIt(ev); }; 
    532   Xinha._addEvent(document, "mousemove", dialog.mouseMove ); 
     553  Xinha._addEvent(document,"mousemove", dialog.mouseMove ); 
    533554  dialog.mouseUp = function (ev) { dialog.resizeEnd(ev); }; 
    534   Xinha._addEvent(document, "mouseup",  dialog.mouseUp); 
    535      
     555  Xinha._addEvent(document,"mouseup",  dialog.mouseUp);  
    536556}; 
    537557 
     
    554574    var posX = ev.clientX; 
    555575  } 
    556   
     576 
    557577  posX -=  dialog.xOffs; 
    558578  posY -=  dialog.yOffs; 
     
    580600  dialog.resizing = false; 
    581601  this.editor.suspendUpdateToolbar = false; 
    582    
     602  if (!this.modal) 
     603  { 
     604    Xinha.Dialog.unCoverIframes(); 
     605  } 
    583606  Xinha._removeEvent(document, "mousemove", dialog.mouseMove ); 
    584   Xinha._removeEvent(document, "mouseup", dialog.mouseUp ); 
     607  Xinha._removeEvent(document, "mouseup",  dialog.mouseUp); 
    585608   
    586609  dialog.size.width  = dialog.rootElem.offsetWidth; 
     
    628651   
    629652  dialog.attached = false; 
    630    
     653  var pos = Xinha.getElementTopLeft(rootElem); 
    631654  rootElem.style.position = "absolute"; 
     655  rootElem.style.top = pos.top + "px"; 
     656  rootElem.style.left = pos.left + "px"; 
    632657   
    633658  dialog.captionBar.style.paddingLeft = "22px"; 
     
    643668  document.body.appendChild(rootElem); 
    644669   
    645   if (ev) 
    646   { 
    647     var scrollPos = dialog.editor.scrollPos();  
    648     rootElem.style.top = (ev.clientY + scrollPos.y) - ((Xinha.is_ie) ? window.event.offsetY : ev.layerY) + "px"; 
    649     rootElem.style.left =(ev.clientX + scrollPos.x) - ((Xinha.is_ie) ? window.event.offsetX : ev.layerX) + "px"; 
    650   } 
    651670  dialog.captionBar.ondblclick = function() { dialog.attachToPanel(rootElem.side); }; 
    652671   
     
    690709  st.height = size.height; 
    691710  st.width  = size.width; 
    692   this.main.style.height = parseInt(size.height,10) - this.captionBar.offsetHeight + "px"; 
    693   this.main.style.width = size.width; 
    694    
     711  var width = parseInt(size.width, 10); 
     712  var height = parseInt(size.height,10) - this.captionBar.offsetHeight; 
     713  this.main.style.height = (height > 20) ? height : 20 + "px"; 
     714  this.main.style.width = (width > 10) ? width : 10 + 'px'; 
    695715} 
    696716Xinha.Dialog.prototype.setValues = function(values) 
     
    931951} 
    932952 
     953/** When several modeless dialogs are shown, one can be brought to front with this function (as happens on mouseclick)  
     954 *  
     955 * @param {XinhaDialog} dialog The dialog to activate 
     956 */ 
    933957 
    934958Xinha.Dialog.activateModeless = function(dialog) 
    935959{ 
    936   var zIndex; 
    937960  if (Xinha.Dialog.activeModeless == dialog || dialog.attached )  
    938961  { 
     
    948971  Xinha.Dialog.activeModeless.rootElem.style.zIndex = parseInt(Xinha.Dialog.activeModeless.rootElem.style.zIndex) + 10; 
    949972} 
     973/** Set opacity cross browser  
     974 *  
     975 * @param {DomNode} el The element to set the opacity 
     976 * @param {Object} value opacity value (percent) 
     977 */ 
    950978Xinha.Dialog.setOpacity = function(el,value) 
    951979{ 
    952         if (typeof el.style.filter != 'undefined') 
    953         { 
    954                 el.style.filter = (value < 100) ?  'alpha(opacity='+value+')' : ''; 
    955         } 
    956         else 
    957         { 
    958                 el.style.opacity = value/100; 
    959         } 
    960 } 
     980    if (typeof el.style.filter != 'undefined') 
     981    { 
     982        el.style.filter = (value < 100) ?  'alpha(opacity='+value+')' : ''; 
     983    } 
     984    else 
     985    { 
     986        el.style.opacity = value/100; 
     987    } 
     988} 
     989/** Fade in an element 
     990 *  
     991 * @param {DomNode} el The element to fade 
     992 * @param {Number} delay Time for one step in ms 
     993 * @param {Number} endOpacity stop when this value is reached (percent) 
     994 * @param {Number} step Fade this much per step (percent) 
     995 */ 
    961996Xinha.Dialog.fadeIn = function(el,endOpacity,delay,step) 
    962997{ 
    963         delay = delay || 1; 
    964         step = step || 25; 
    965         endOpacity = endOpacity || 100; 
    966         el.op = el.op || 0; 
    967         var op = el.op; 
    968         if (el.style.display == 'none') 
    969         { 
    970                 Xinha.Dialog.setOpacity(el,0); 
    971                 el.style.display = ''; 
    972         } 
    973         if (op < endOpacity) 
    974         { 
    975                 el.op += step; 
    976                 Xinha.Dialog.setOpacity(el,op); 
    977                 el.timeOut = setTimeout(function(){Xinha.Dialog.fadeIn(el,endOpacity,delay,step);},delay); 
    978         } 
    979         else 
    980         { 
    981                 Xinha.Dialog.setOpacity(el,endOpacity); 
    982                 el.op = endOpacity; 
    983                 el.timeOut = null; 
    984         } 
    985 } 
    986  
     998    delay = delay || 1; 
     999    step = step || 25; 
     1000    endOpacity = endOpacity || 100; 
     1001    el.op = el.op || 0; 
     1002    var op = el.op; 
     1003    if (el.style.display == 'none') 
     1004    { 
     1005        Xinha.Dialog.setOpacity(el,0); 
     1006        el.style.display = ''; 
     1007    } 
     1008    if (op < endOpacity) 
     1009    { 
     1010        el.op += step; 
     1011        Xinha.Dialog.setOpacity(el,op); 
     1012        el.timeOut = setTimeout(function(){Xinha.Dialog.fadeIn(el,endOpacity,delay,step);},delay); 
     1013    } 
     1014    else 
     1015    { 
     1016        Xinha.Dialog.setOpacity(el,endOpacity); 
     1017        el.op = endOpacity; 
     1018        el.timeOut = null; 
     1019    } 
     1020} 
     1021/** Fade out an element 
     1022 *  
     1023 * @param {DomNode} el The element to fade 
     1024 * @param {Number} delay Time for one step in ms 
     1025 * @param {Number} step Fade this much per step (percent) 
     1026 */ 
    9871027Xinha.Dialog.fadeOut = function(el,delay,step) 
    9881028{ 
    989         delay = delay || 1; 
    990         step = step || 30; 
    991         if (typeof el.op == 'undefined') el.op = 100; 
    992         var op = el.op; 
    993  
    994         if (op >= 0) 
    995         { 
    996                 el.op -= step; 
    997                 Xinha.Dialog.setOpacity(el,op); 
    998                 el.timeOut = setTimeout(function(){Xinha.Dialog.fadeOut(el,delay,step);},delay); 
    999         } 
    1000         else 
    1001         { 
    1002                 Xinha.Dialog.setOpacity(el,0); 
    1003                 el.style.display = 'none'; 
    1004                 el.op = 0; 
    1005                 el.timeOut = null; 
    1006         } 
    1007 } 
     1029    delay = delay || 1; 
     1030    step = step || 30; 
     1031    if (typeof el.op == 'undefined') el.op = 100; 
     1032    var op = el.op; 
     1033 
     1034    if (op >= 0) 
     1035    { 
     1036        el.op -= step; 
     1037        Xinha.Dialog.setOpacity(el,op); 
     1038        el.timeOut = setTimeout(function(){Xinha.Dialog.fadeOut(el,delay,step);},delay); 
     1039    } 
     1040    else 
     1041    { 
     1042        Xinha.Dialog.setOpacity(el,0); 
     1043        el.style.display = 'none'; 
     1044        el.op = 0; 
     1045        el.timeOut = null; 
     1046    } 
     1047} 
     1048Xinha.Dialog.coverIframes = function() 
     1049{ 
     1050    for (var i=0;i<__xinhas.length;i++) 
     1051    { 
     1052      __xinhas[i]._framework.iframe_cover.style.display = ''; 
     1053    } 
     1054} 
     1055Xinha.Dialog.unCoverIframes = function() 
     1056{ 
     1057    for (var i=0;i<__xinhas.length;i++) 
     1058    { 
     1059      __xinhas[i]._framework.iframe_cover.style.display = 'none'; 
     1060    } 
     1061} 
Note: See TracChangeset for help on using the changeset viewer.