1

Topic: Auto scroll downt to last position.

Hello,

When I am editing a page (or child) and the code is longer than one page, I need to scroll down. But when I cliks on "save and continue" the page is saved and reloaded. This is frustrating behavior cause when I need to edit the same code again, have to scroll down and find a correct place.

Is there any way to solve this problem?
I mean - automatric scroll down to the position where cursor was before saving.

Cheers,

Piotr

--
Piotr

2

Re: Auto scroll downt to last position.

tikky wrote:

Is there any way to solve this problem?
I mean - automatic scroll down to the position where cursor was before saving.

Hi Piotr - glad you asked the question! This often drives me nuts, too -- but I have assumed all along that this is a necessary evil. If there is a "solution", it would be great to know! (For me, this is especially when editing either a Layout, or a CSS file within Wolf.)

(Btw - Edinburgh is heaving at the moment. Not a pretty sight! tongue )

Using Wolf CMS professionally and for profit? Do think about supporting Wolf financially. Thanks!

Re: Auto scroll downt to last position.

Hmm... I must admit this has been bugging me as well. I guess you'd need some sort of line marker? In combination with some clever Javascript or JQuery stuff that auto scrolls down?

I really don't have the time to look into this so if someone else can take a look and perhaps supply a nice, simple, light-weight solution I (or David) would be happy to patch it in. smile

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution or see our financial report first.

Re: Auto scroll downt to last position.

Hypothetically, we could add an anchor name just above the 'Save and Continue Editing' button (being that it will always return the page to the bottom-most position possible) and pass that anchor to the save function and have it take us straight back ... without so much as a single line of javascript!?

I do something similar by passing an anchor to header something like so:
header("location/savedpage#save");

Note: this will not be perfectly usable for everyone, but then again Wolf currently takes the user to the start of the page when you save, which abviously isn't pleasing us.

Last edited by BlueWolf (2010-08-13 13:52)

Thumbs up

Re: Auto scroll downt to last position.

Is this the kind of solution we need?
http://articles.sitepoint.com/article/p … l-position

Re: Auto scroll downt to last position.

Fortron wrote:

Is this the kind of solution we need?
http://articles.sitepoint.com/article/p … l-position

No offense Fortron, but so long as the save buttons are at the bottom of the page isn't that alot more code than is need to get the same result as an anchor!?

If the save buttons moved position as the page was scrolled however, then I think that is really neat.

Thumbs up

Re: Auto scroll downt to last position.

BlueWolf wrote:

Hypothetically, we could add an anchor name just above the 'Save and Continue Editing' button (being that it will always return the page to the bottom-most position possible) and pass that anchor to the save function and have it take us straight back ... without so much as a single line of javascript!?

I do something similar by passing an anchor to header something like so:
header("location/savedpage#save");

Note: this will not be perfectly usable for everyone, but then again Wolf currently takes the user to the start of the page when you save, which abviously isn't pleasing us.

That won't work... we were talking about auto-scrolling the text area field, not the entire page. Though scrolling the entire page is of course also necessary.

Last edited by mvdkleijn (2010-08-13 14:23)

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution or see our financial report first.

Re: Auto scroll downt to last position.

mvdkleijn wrote:

That won't work... we were talking about auto-scrolling the text area field, not the entire page.

Doh, sorry guys.

Thumbs up

9

Re: Auto scroll downt to last position.

Or how about this one? jQuery.ScrollTo article and a demo page. It seems to be able to pick out a DOM element...

Using Wolf CMS professionally and for profit? Do think about supporting Wolf financially. Thanks!

Re: Auto scroll downt to last position.

David wrote:

Or how about this one? jQuery.ScrollTo article and a demo page. It seems to be able to pick out a DOM element...

From the quick look I just took, this could do the trick... scrolling by DOM element isn't very useful (since we won't have DOM elements inside the textarea) but I see we can also into a numeric position. So if we're able to figure out the numerical position you're at inside the textarea upon saving, I think we're set? smile

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution or see our financial report first.

Re: Auto scroll downt to last position.

A little off subject, but there has been alot of jQuery solutions in recent months ... how goes the move from prototype?

Thumbs up

Re: Auto scroll downt to last position.

As a temporary solution you can do this:
Go to your plugins folder and create a new folder call it scrollsaver.
Go to this page and download the scrollsaver.min_.zip. Unzip it and put the .js file inside the scrollsaver folder.

create and index.php and put this:

<?php

Plugin::setInfos(array(
    'id'          => 'scrollsaver',
    'title'       => 'Scroll saver', 
    'description' => 'Mantains scroll position after applying changes.', 
    'version'     => '0.1')
);
// script file by Mahdi Hasheminezhad
// http://en.hasheminezhad.com/scrollsaver

Plugin::addJavascript('scrollsaver', 'scrollsaver.min.js');

Save the index.php
Enable the Scroll saver plugin.

Last edited by andrewmman (2010-08-13 16:11)

Thumbs up

13

Re: Auto scroll downt to last position.

andrewmman wrote:

As a temporary solution you can do this...

Oh yeah cool That works!

Slight downside on this wee netbook screen I'm on at the moment is that you don't see the flash "success" message, as this really does save every scroll position for each element!

But otherwise, I reckon this pretty much nails it. Nice one, Andrew!

Using Wolf CMS professionally and for profit? Do think about supporting Wolf financially. Thanks!

Re: Auto scroll downt to last position.

andrewmman wrote:

As a temporary solution you can do this:

It doesn't work for me, tried it on Firefox and IE.
I've also disabled the Textarea Resizer plugin  (by sartas) but it doesn't make a change.
I see that scrollsaver.min.js gets loaded fine in the backend.

Re: Auto scroll downt to last position.

I looked for some scripts that could work, the one I posted did, but didn't really tested it much, then instead of editing the backend layout I thought loading it as "plugin" would be cleaner. It doesn't work for me either if I have Codepress filter enabled (code highlighter). I wish I knew how to help so I could contribute something.

By the way, tested on Firefox 3.6.8, nothing else.

Thumbs up

16

Re: Auto scroll downt to last position.

Works for me just fine in Seamonkey 2.0.6 and Chrome 5.0 using Wolf 0.6.0a -- haven't tried it with a nightly install yet. Nice simple solution for me!

@Fortron - Wonder what else might be happening for you?? hmm

Using Wolf CMS professionally and for profit? Do think about supporting Wolf financially. Thanks!

17

Re: Auto scroll downt to last position.

Update - that testing was done under Windows (XP/SP3, I'm afraid). I've just tried this with Ubuntu (9.04, I'm afraid) using Seamonkey, Chrome 5.0 and Opera 10.6 -- all fine. Also with Mac OSX (10.5, or "Leopard", I'm afraid) (there's a bit of a theme with slightly out-of-date OS's, isn't there! big_smile ) using FF 3.6.8 and Safari 5.0 -- works fine in all of them.

The Mozilla based browsers gave me the most seamless experience, but in each case my editing point was preserved after a save.

Sweet, indeed! Thanks again, Andy.

Using Wolf CMS professionally and for profit? Do think about supporting Wolf financially. Thanks!

Re: Auto scroll downt to last position.

David wrote:

@Fortron - Wonder what else might be happening for you?? hmm

It works fine with Google Chrome and Opera.
I have no luck with IE8, Firefox 3.6.8 and Seamonkey 2.0.6,
not even with all add-ons disabled (Safe modus).

Windows XP here too.

Last edited by Fortron (2010-08-15 15:42)

19

Re: Auto scroll downt to last position.

Hello,

I've just back to my office and I am surprised - 17 replies. Nice to hear that you are also have similar feelings.

So, we have solution which doesn't work on Firefox? Am I right? I will try to do some tests also and let you know.

--
Piotr

20

Re: Auto scroll downt to last position.

...after tests:

Works correctly on Opera, Google Chrome but not on Firefox.

I found also interesting information about bug in Firefox here:
http://connect.microsoft.com/VisualStud … in-firefox

Microsoft says: "We have fixed this issue and the fix will be available in the next release of Visual Studio 2010 and .NET Framework 4."

Last edited by tikky (2010-08-16 11:13)

--
Piotr

21

Re: Auto scroll downt to last position.

A little further testing -- my earlier results were based on editing Layouts which tended to give me the longest file to work with.

It looks like Pages are resistant to this solution! But Snippets, Layouts, and CSS (under Files) work beautifully. This pattern was consistent between Seamonkey 2.0.6, and FF 3.0.10 (latest FF on this machine).

FWIW!

Using Wolf CMS professionally and for profit? Do think about supporting Wolf financially. Thanks!

Re: Auto scroll downt to last position.

I've been doing some tests trying to make something thaat could help with this mostly to learn javascript and maybe help a little, but I got to the point were I'm stuck. The main problem comes with the textareas in page editing and getting the current one and it's scroll value.
Each textarea in page editing have an id like page_0_content, page_1_content, etc... To store the current one I've done the following:

jQuery.setpgtx = function() {
    var tab = $j('#tab-control a.tab'),
    cpgtx = tab.index($j('#tab-control a.here')),
    cpgid= '#page_'+cpgtx+'_content';
        $j('body').data('tx',cpgid);
};

Function that when document loads stores the current textarea ( that in most cases would be 0 by default). I also binded this function to the page_parts title tabs click event. So to get the current page textarea id I just have to retrieve the body data called "tx" and get the correct one. That's working fine, but the problem comes when I want to use that string as the value inside a jquery selector, that would be the equivalent of doing something like this:

$('#page_1_content')

so I could store both the page id and scrollTop() value, but to do the later I need to get the selector working.
I hope I explained it correctly and would like to know if there's any solution for this or maybe I'm just taking the wrong approach.

P.D: In the case of snippet, layout and file editing it's fine cause it's just one textarea per page and by using  $('textarea').attr('id') and $('textarea').scrollTop() you can store both values.

Thumbs up

Re: Auto scroll downt to last position.

andrewmman wrote:

... jquery selector, that would be the equivalent of doing something like this:

$('#page_1_content')

Currently, JQuery is running in compatibility mode within Wolf.

$j('#page_1_content')
Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution or see our financial report first.

Re: Auto scroll downt to last position.

Yes, I put that only as an example. What I need is to get the string stored in body.data, which would be the current textarea id and pass it as the "text inside" the selector.
The thing is that something like this won't work:

var curid = $j('body').data('tx');
$j(curid) // do something

Thumbs up

Re: Auto scroll downt to last position.

mvdkleijn wrote:

Hmm... I must admit this has been bugging me as well. I guess you'd need some sort of line marker? In combination with some clever Javascript or JQuery stuff that auto scrolls down?

Why do a page reload at all? Maybe just submit the form via Ajax. Unless there is something tricky in the admin HTML jQuery Form plugin might be a drop in solution.

http://jquery.malsup.com/form/

Thumbs up