includes/clientside/static/editor.js
changeset 672 08a7875258b4
parent 651 ce9d78d7251d
child 673 99c617146a34
equal deleted inserted replaced
671:267c9f93b51f 672:08a7875258b4
   625         }
   625         }
   626         if ( response.mode == 'success' )
   626         if ( response.mode == 'success' )
   627         {
   627         {
   628           if ( response.is_draft )
   628           if ( response.is_draft )
   629           {
   629           {
   630             document.getElementById('ajaxEditArea').used_draft = true;
   630             try
   631             document.getElementById('ajaxEditArea').needReset = true;
       
   632             var img = $dynano('ajax_edit_savedraft_btn').object.getElementsByTagName('img')[0];
       
   633             var lbl = $dynano('ajax_edit_savedraft_btn').object.getElementsByTagName('span')[0];
       
   634             if ( response.is_draft == 'delete' )
       
   635             {
   631             {
   636               img.src = scriptPath + '/images/editor/savedraft.gif';
   632               document.getElementById('ajaxEditArea').used_draft = true;
   637               lbl.innerHTML = $lang.get('editor_btn_savedraft');
   633               document.getElementById('ajaxEditArea').needReset = true;
   638               
   634               var img = $dynano('ajax_edit_savedraft_btn').object.getElementsByTagName('img')[0];
   639               var dn = $dynano('ajax_edit_draft_notice').object;
   635               var lbl = $dynano('ajax_edit_savedraft_btn').object.getElementsByTagName('span')[0];
   640               if ( dn )
   636               if ( response.is_draft == 'delete' )
   641               {
   637               {
   642                 dn.parentNode.removeChild(dn);
   638                 img.src = scriptPath + '/images/editor/savedraft.gif';
       
   639                 lbl.innerHTML = $lang.get('editor_btn_savedraft');
       
   640                 
       
   641                 var dn = $dynano('ajax_edit_draft_notice').object;
       
   642                 if ( dn )
       
   643                 {
       
   644                   dn.parentNode.removeChild(dn);
       
   645                 }
       
   646               }
       
   647               else
       
   648               {
       
   649                 img.src = scriptPath + '/images/mini-info.png';
       
   650                 var d = new Date();
       
   651                 var m = String(d.getMinutes());
       
   652                 if ( m.length < 2 )
       
   653                   m = '0' + m;
       
   654                 var time = d.getHours() + ':' + m;
       
   655                 lbl.innerHTML = $lang.get('editor_msg_draft_saved', { time: time });
   643               }
   656               }
   644             }
   657             }
   645             else
   658             catch(e)
   646             {
   659             {
   647               img.src = scriptPath + '/images/mini-info.png';
   660               console.warn('Exception thrown during save, error dump follows');
   648               var d = new Date();
   661               console.debug(e);
   649               var m = String(d.getMinutes());
       
   650               if ( m.length < 2 )
       
   651                 m = '0' + m;
       
   652               var time = d.getHours() + ':' + m;
       
   653               lbl.innerHTML = $lang.get('editor_msg_draft_saved', { time: time });
       
   654             }
   662             }
   655           }
   663           }
   656           else
   664           else
   657           {
   665           {
   658             // The save was successful; reset flags and make another request for the new page content
   666             // The save was successful; reset flags and make another request for the new page content
   668                   selectButtonMajor('article');
   676                   selectButtonMajor('article');
   669                   unselectAllButtonsMinor();
   677                   unselectAllButtonsMinor();
   670                   
   678                   
   671                   ajaxEditorDestroyModalWindow();
   679                   ajaxEditorDestroyModalWindow();
   672                   document.getElementById('ajaxEditContainer').innerHTML = '<div class="usermessage">' + $lang.get('editor_msg_saved') + '</div>' + ajax.responseText;
   680                   document.getElementById('ajaxEditContainer').innerHTML = '<div class="usermessage">' + $lang.get('editor_msg_saved') + '</div>' + ajax.responseText;
       
   681                   // if we're on a userpage, call the onload function to rebuild the tabs
       
   682                   if ( typeof(userpage_onload) == 'function' )
       
   683                   {
       
   684                     window.userpage_blocks = [];
       
   685                     userpage_onload();
       
   686                   }
   673                   opacity('ajaxEditContainer', 0, 100, 1000);
   687                   opacity('ajaxEditContainer', 0, 100, 1000);
   674                 }
   688                 }
   675               });
   689               });
   676           }
   690           }
   677         }
   691         }