Ticket #301: ticket301.patch

File ticket301.patch, 3.1 KB (added by UdoBorkowski, 5 years ago)

Patch to fix this ticket

  • js/Commands.js

     
    44 
    55config.commands.closeTiddler.handler = function(event,src,title) 
    66{ 
    7         story.closeTiddler(title,true,event.shiftKey || event.altKey); 
     7        story.closeTiddler(title,true,event.shiftKey || event.altKey,true); 
    88        return false; 
    99}; 
    1010 
    1111config.commands.closeOthers.handler = function(event,src,title) 
    1212{ 
    13         story.closeAllTiddlers(title); 
     13        story.closeAllTiddlers(title,true); 
    1414        return false; 
    1515}; 
    1616 
  • js/Macros.js

     
    253253 
    254254config.macros.closeAll.onClick = function(e) 
    255255{ 
    256         story.closeAllTiddlers(); 
     256        story.closeAllTiddlers(null,true); 
    257257        return false; 
    258258}; 
    259259 
  • js/Story.js

     
    398398//# title - name of tiddler to close 
    399399//# animate - whether to perform animations 
    400400//# slowly - whether to perform animations in slomo 
    401 Story.prototype.closeTiddler = function(title,animate,slowly) 
     401//# allowAsync - when true closing the tiddler will occur asynchronously (i.e. possibly after this function returned). (Pass true here as often as possible as it gets rid of the problem described in ticket #301) 
     402Story.prototype.closeTiddler = function(title,animate,slowly,allowAsync) 
    402403{ 
    403404        var tiddlerElem = document.getElementById(this.idPrefix + title); 
    404405        if(tiddlerElem != null) { 
     
    406407                this.scrubTiddler(tiddlerElem); 
    407408                if(config.options.chkAnimate && animate && anim && typeof Slider == "function") 
    408409                        anim.startAnimating(new Slider(tiddlerElem,false,slowly,"all")); 
    409                 else 
    410                         tiddlerElem.parentNode.removeChild(tiddlerElem); 
     410                else { 
     411                        //# bugfox for ticket #301: set overflow=hidden and use asynch redraw (if allowed) 
     412                        tiddlerElem.style.overflow = "hidden"; 
     413                        if (allowAsync) 
     414                                setTimeout(function(){tiddlerElem.parentNode.removeChild(tiddlerElem)},0); 
     415                        else 
     416                                tiddlerElem.parentNode.removeChild(tiddlerElem); 
     417                } 
    411418        } 
    412 }; 
     419} 
    413420 
    414421//# Scrub IDs from a tiddler. This is so that the 'ghost' of a tiddler while it is being closed 
    415422//# does not interfere with things 
     
    450457}; 
    451458 
    452459//# Close all tiddlers in the story 
    453 Story.prototype.closeAllTiddlers = function(exclude) 
     460//# exclude - title of tiddler that should not be closed (i.e. the "close others" case) 
     461//# allowAsync - when true closing the tiddler will occur asynchronously (i.e. possibly after this function returned).  (Pass true here as often as possible as it gets rid of the problem described in ticket #301) 
     462Story.prototype.closeAllTiddlers = function(exclude,allowAsync) 
    454463{ 
    455464        clearMessage(); 
    456465        this.forEachTiddler(function(title,element) { 
    457466                if((title != exclude) && element.getAttribute("dirty") != "true") 
    458                         this.closeTiddler(title); 
    459         }); 
     467                        this.closeTiddler(title,false,false,allowAsync); 
     468                }); 
    460469        window.scrollTo(0,ensureVisible(this.container)); 
    461470}; 
    462471