includes/clientside/static/editor.js
changeset 473 518bc2b214f1
parent 461 717e71109645
child 474 3d751a6f2b05
equal deleted inserted replaced
472:bc4b58034f4d 473:518bc2b214f1
   120     editor_open = true;
   120     editor_open = true;
   121     disableUnload();
   121     disableUnload();
   122   }
   122   }
   123   
   123   
   124   // Destroy existing contents of page container
   124   // Destroy existing contents of page container
   125   var edcon = document.getElementById('ajaxEditContainer');
   125   if ( editor_use_modal_window )
   126   for ( var i = edcon.childNodes.length - 1; i >= 0; i-- )
   126   {
   127   {
   127     darken(true);
   128     edcon.removeChild(edcon.childNodes[i]);
   128     // Build a div with 80% width, centered, and 10px from the top of the window
       
   129     var edcon = document.createElement('div');
       
   130     edcon.style.position = 'absolute';
       
   131     edcon.style.backgroundColor = '#FFFFFF';
       
   132     edcon.style.padding = '10px';
       
   133     edcon.style.width = '80%';
       
   134     edcon.id = 'ajaxEditContainerModal';
       
   135     
       
   136     // Positioning
       
   137     var top = getScrollOffset() + 10;
       
   138     var left = ( getWidth() / 10 ) - 10; // 10% of window width on either side - 10px for padding = perfect centering effect
       
   139     edcon.style.top = String(top) + 'px';
       
   140     edcon.style.left = String(left) + 'px';
       
   141     var body = document.getElementsByTagName('body')[0];
       
   142     
       
   143     // Set opacity to 0
       
   144     domObjChangeOpac(0, edcon);
       
   145     body.appendChild(edcon);
       
   146   }
       
   147   else
       
   148   {
       
   149     var edcon = document.getElementById('ajaxEditContainer');
       
   150     for ( var i = edcon.childNodes.length - 1; i >= 0; i-- )
       
   151     {
       
   152       edcon.removeChild(edcon.childNodes[i]);
       
   153     }
   129   }
   154   }
   130   
   155   
   131   var content = response.src;
   156   var content = response.src;
   132   
   157   
   133   //
   158   //
   517         return false;
   542         return false;
   518       };
   543       };
   519     }
   544     }
   520   }
   545   }
   521   
   546   
       
   547   // if we're using the modal window, fade it in
       
   548   if ( editor_use_modal_window )
       
   549   {
       
   550     domOpacity(edcon, 0, 100, 500);
       
   551   }
       
   552   
   522   // Autosave every 5 minutes           (m  *  s  *  ms)
   553   // Autosave every 5 minutes           (m  *  s  *  ms)
   523   setInterval('ajaxPerformAutosave();', ( 5 * 60 * 1000 ));
   554   setInterval('ajaxPerformAutosave();', ( 5 * 60 * 1000 ));
       
   555 }
       
   556 
       
   557 function ajaxEditorDestroyModalWindow()
       
   558 {
       
   559   if ( editor_use_modal_window )
       
   560   {
       
   561     var edcon = document.getElementById('ajaxEditContainerModal');
       
   562     var body = document.getElementsByTagName('body')[0];
       
   563     if ( edcon )
       
   564     {
       
   565       body.removeChild(edcon);
       
   566       enlighten(true);
       
   567     }
       
   568   }
   524 }
   569 }
   525 
   570 
   526 function ajaxEditorSave(is_draft)
   571 function ajaxEditorSave(is_draft)
   527 {
   572 {
   528   if ( !is_draft )
   573   if ( !is_draft )
   659                 {
   704                 {
   660                   unsetAjaxLoading();
   705                   unsetAjaxLoading();
   661                   selectButtonMajor('article');
   706                   selectButtonMajor('article');
   662                   unselectAllButtonsMinor();
   707                   unselectAllButtonsMinor();
   663                   
   708                   
       
   709                   ajaxEditorDestroyModalWindow();
   664                   document.getElementById('ajaxEditContainer').innerHTML = '<div class="usermessage">' + $lang.get('editor_msg_saved') + '</div>' + ajax.responseText;
   710                   document.getElementById('ajaxEditContainer').innerHTML = '<div class="usermessage">' + $lang.get('editor_msg_saved') + '</div>' + ajax.responseText;
   665                   opacity('ajaxEditContainer', 0, 100, 1000);
   711                   opacity('ajaxEditContainer', 0, 100, 1000);
   666                 }
   712                 }
   667               });
   713               });
   668           }
   714           }
   764 {
   810 {
   765   var mb = new messagebox(MB_YESNO | MB_ICONQUESTION, $lang.get('editor_msg_cancel_confirm_title'), $lang.get('editor_msg_cancel_confirm_body'));
   811   var mb = new messagebox(MB_YESNO | MB_ICONQUESTION, $lang.get('editor_msg_cancel_confirm_title'), $lang.get('editor_msg_cancel_confirm_body'));
   766   mb.onclick['Yes'] = function()
   812   mb.onclick['Yes'] = function()
   767   {
   813   {
   768     setAjaxLoading();
   814     setAjaxLoading();
       
   815     ajaxEditorDestroyModalWindow();
   769     editor_open = false;
   816     editor_open = false;
   770     enableUnload();
   817     enableUnload();
   771     setTimeout('ajaxReset();', 750);
   818     setTimeout('ajaxReset();', 750);
   772   }
   819   }
   773 }
   820 }