[tw] Re: [TWC] TiddlersBarPlugin remembering scroll position

2014-03-11 Thread Leo Staley
I can't help, but could you explain the difference between Tobias' fork and 
the original? I read it, but i don't understand. 

On Tuesday, March 11, 2014 10:42:16 AM UTC-7, Albert Riedinger wrote:
>
> Hi all,
>
> I use Tobias Beers' fork of TiddlersBarPlugin[1] in my custom theme with 
> TiddlersBar fixed in left sidebar. What I would like to achieve is that 
> TiddlersBarPlugin remembers the scroll position of tiddlers while switching 
> between them[2]. I tried to modify the code of TiddlersBarPlugin, but had 
> to give up realizing that I am only a JS beginner ;) My approach would be 
> to save the horizontal and vertical scroll positions in particular tiddler 
> fields with code like this:
>
> // save scroll position
> var scrX = findScrollX();
> var scrY = findScrollY();
> store.setValue(tiddler, "scrollPosX", scrX);
> store.setValue(tiddler, "scrollPosY", scrY);
>
> [...]
>
> // load and set scroll position
> var scrX = store.getValue(title, "scrollPosX");
> var scrY = store.getValue(title, "scrollPosY");
> window.scrollTo(scrX, scrY);
>
> The problem is, that I don't know where to put this or similar code in the 
> TiddlersBarPlugin. Maybe somewhere in the hijacked displayTiddler function? 
> I appriciate any help.
>
> Thanks in advance,
> Albert
>
>
> [1] already requested by another user here: 
> https://raw.github.com/tobibeer/TiddlyWikiPlugins/master/forked/TiddlersBarPlugin.js
> [2] https://groups.google.com/d/topic/tiddlywiki/uH1N8FB8_uY/discussion
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TWC] TiddlersBarPlugin remembering scroll position

2014-03-26 Thread Albert Riedinger
Hi Leo,

sorry, I forgot to answer you.
As far as I know Tobias' fork includes Marios Popup-Bug-Workaround and an 
implementation for his PaintrPlugin.



Am Mittwoch, 12. März 2014 04:03:53 UTC+1 schrieb Leo Staley:
>
> I can't help, but could you explain the difference between Tobias' fork 
> and the original? I read it, but i don't understand. 
>
> On Tuesday, March 11, 2014 10:42:16 AM UTC-7, Albert Riedinger wrote:
>>
>> Hi all,
>>
>> I use Tobias Beers' fork of TiddlersBarPlugin[1] in my custom theme with 
>> TiddlersBar fixed in left sidebar. What I would like to achieve is that 
>> TiddlersBarPlugin remembers the scroll position of tiddlers while switching 
>> between them[2]. I tried to modify the code of TiddlersBarPlugin, but had 
>> to give up realizing that I am only a JS beginner ;) My approach would be 
>> to save the horizontal and vertical scroll positions in particular tiddler 
>> fields with code like this:
>>
>> // save scroll position
>> var scrX = findScrollX();
>> var scrY = findScrollY();
>> store.setValue(tiddler, "scrollPosX", scrX);
>> store.setValue(tiddler, "scrollPosY", scrY);
>>
>> [...]
>>
>> // load and set scroll position
>> var scrX = store.getValue(title, "scrollPosX");
>> var scrY = store.getValue(title, "scrollPosY");
>> window.scrollTo(scrX, scrY);
>>
>> The problem is, that I don't know where to put this or similar code in 
>> the TiddlersBarPlugin. Maybe somewhere in the hijacked displayTiddler 
>> function? I appriciate any help.
>>
>> Thanks in advance,
>> Albert
>>
>>
>> [1] already requested by another user here: 
>> https://raw.github.com/tobibeer/TiddlyWikiPlugins/master/forked/TiddlersBarPlugin.js
>> [2] https://groups.google.com/d/topic/tiddlywiki/uH1N8FB8_uY/discussion
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TWC] TiddlersBarPlugin remembering scroll position

2014-03-26 Thread PMario
On Tuesday, March 11, 2014 6:42:16 PM UTC+1, Albert Riedinger wrote:
>
> I use Tobias Beers' fork of TiddlersBarPlugin[1] in my custom theme with 
> TiddlersBar fixed in left sidebar.
>

So your left sidebar is fixed too and it is always visible, when you sroll 
down?

 

> What I would like to achieve is that TiddlersBarPlugin remembers the 
> scroll position of tiddlers while switching between them[2]. I tried to 
> modify the code of TiddlersBarPlugin, but had to give up realizing that I 
> am only a JS beginner ;) My approach would be to save the horizontal and 
> vertical scroll positions in particular tiddler 
>
fields with code like this:
>

I wouldn't store those values with the tiddler, because you would get a new 
modified timestamp. If you want that, then it's ok. 
Do you really need the x position? In normal cases it is alway 0.

If only "y" is needed, you could create a "tbScrollPositions" tiddler with 
a lot of slices with the "tiddlername:y-value" in it. ... 
store.calcAllSlices("tbScrollPositions") should return all the tiddlers and 
there values. But you'd need to create a search function. so your approach 
is easier for the beginning.

story.displayTiddler = 
function(srcElement,tiddler,template,animate,unused,customFields,toggle){

story.coreDisplayTiddler(config.macros.tiddlersBar.tabsAnimationSource,tiddler,template,animate,unused,customFields,toggle);
var title = (tiddler instanceof Tiddler)? tiddler.title : tiddler;  
if (config.macros.tiddlersBar.isShown()) {
story.forEachTiddler(function(t,e){
if (t!=title) e.style.display="none";
else { // <- a fast test
e.style.display="";// <- this will scroll 200 px down. 
So it should be the right place
window.scrollTo(0, 200)// <- when you display the tiddler. 
}
})
config.macros.tiddlersBar.currentTiddler=title;
}
var e=document.getElementById("tiddlersBar");
if (e) config.macros.tiddlersBar.refresh(e,null);
}

Finding the place to save the value will be trickier. I'll post again :)

have fun!
mario

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TWC] TiddlersBarPlugin remembering scroll position

2014-03-26 Thread PMario
@Albert, 

The modification that I made here are dangerous with TiddlyWeb, 
TiddlySpace. I did a "tiddlyweb" check so the code is deactivated for 
TiddlyWeb, TiddlySpace.

... and just to be sure ...

I did comment to 2 lines that write the scroll position to the active 
tiddler.
So everyone that does a copy paste, but doesn't read the docs, can't say 
I'm the one who caused problems.
Everyone who wants to use the code needs to remove the "store.setValue()" 
comments below.


IMPORTANT: If you use it that way, make sure, that you rename your plugin, 
and make it clear, that it won't work with TiddlySpace and TiddlyWeb.



story.displayTiddler = 
function(srcElement,tiddler,template,animate,unused,customFields,toggle){
   
 
story.coreDisplayTiddler(config.macros.tiddlersBar.tabsAnimationSource,tiddler,template,animate,unused,customFields,toggle);
var title = (tiddler instanceof Tiddler)? tiddler.title : tiddler;  
if (config.macros.tiddlersBar.isShown()) {
story.forEachTiddler(function(t,e){
if (t!=title) e.style.display="none";
else {
// DON'T allow modification on TiddlyWeb, TiddlySpace ... 
because it may clone tiddlers if you view them. 
if (tiddlyweb) {
// WARNING don't remove this security check !!
// do nothing
}
else {
// save scroll position
//
store.setValue(config.macros.tiddlersBar.currentTiddler, "scrollPosX", 
findScrollX());
//
store.setValue(config.macros.tiddlersBar.currentTiddler, "scrollPosY", 
findScrollY());

// load and set scroll position
var scrX = store.getValue(title, "scrollPosX");
var scrY = store.getValue(title, "scrollPosY");

// if undefined .. don't scroll to 0
if (scrX && scrY) window.scrollTo(scrX, scrY);
}
e.style.display="";
}
})
config.macros.tiddlersBar.currentTiddler=title;
}
var e=document.getElementById("tiddlersBar");
if (e) config.macros.tiddlersBar.refresh(e,null);
}

have fun!
mario

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TWC] TiddlersBarPlugin remembering scroll position

2014-04-07 Thread PMario
On Monday, April 7, 2014 10:13:07 AM UTC+2, Albert Riedinger wrote:
>
> sorry for the delay, I was very busy the last few days (baby is coming 
> soon ;).
> Thank you for your effort. I just tried your mod, but it doesn't work 
> properly. I tested it also in a vanilla TW (see attachment), but with the 
> same result. Maybe I did something wrong? I can't figure out why your code 
> is not working, since your modifications looks correct for me.
>

uups,
I did test the modification, but not with a vanilla file TW. ... It seems 
scrolling to pos 0/0 already happened, when our new code is executed. so it 
always records 0/0.
I'll need to investigate a bit. There is a second problem with the 
tiddlyweb variable and a vanilla tw. (fixing that one is easy :)
-m 

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TWC] TiddlersBarPlugin remembering scroll position

2014-04-07 Thread PMario
Somehow it seems the first version just worked under special conditions :) 
 
So this one should be better now.

Be aware:  ... it doesn't work with TiddlyWeb / TiddlySpace.


story.displayTiddler = 
function(srcElement,tiddler,template,animate,unused,customFields,toggle){

story.coreDisplayTiddler(config.macros.tiddlersBar.tabsAnimationSource,tiddler,template,animate,unused,customFields,toggle);
var title = (tiddler instanceof Tiddler)? tiddler.title : tiddler;  
if (config.macros.tiddlersBar.isShown()) {

// save scroll position ... only allowed if TiddlyWeb is _not_ 
active
if (typeof tiddlyweb == "undefined") {
store.setValue(config.macros.tiddlersBar.currentTiddler, 
"scrollPosX", findScrollX());
store.setValue(config.macros.tiddlersBar.currentTiddler, 
"scrollPosY", findScrollY());
// console.log("set: ", 
config.macros.tiddlersBar.currentTiddler , findScrollY() )
}

story.forEachTiddler(function(t,e){
var scrX, scrY;
if (t!=title) e.style.display="none"
else {
// DON'T allow modification on TiddlyWeb, TiddlySpace ... 
because it may clone tiddlers if you view them.
if (typeof tiddlyweb == "undefined") {
// load and set scroll position
scrX = store.getValue(title, "scrollPosX");
scrY = store.getValue(title, "scrollPosY");
// console.log("scroll: ", title , scrY )
}
e.style.display="";
window.scrollTo(scrX, scrY);
}
})
config.macros.tiddlersBar.currentTiddler=title;
}
var e=document.getElementById("tiddlersBar");
if (e) config.macros.tiddlersBar.refresh(e,null);
}


have fun!
mario

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.