No Support > Scheduled for cpg1.5.x

Sorting pictures in albums - move to top/bottom button

(1/1)

mironto:
I would really like to have a button to move the picture to top/bottom of the list, instead of clicking x-times move up/down button.
Actually this should be pretty easy, as I implemented it myself already within a few minutes. Here is the code, I am sure you can optimize or make it fool proof if needed.

in picmgr.php I have added these two javascript functions:


--- Code: ---    function Movetop_Option()
    {
        var to = document.picture_menu.to;
        var pos = selectedOptIndex;
        if (pos == 0) {
            return;
        }
        for (i=pos; i>0; i--) {
            swap_option(to, i, i-1);
        }
        selected_option(to, 0);
    }

    function Movebottom_Option()
    {
        var to = document.picture_menu.to;
        var pos = selectedOptIndex;
        if (pos == to.length-1) {
            return;
        }
        for (i=pos; i<to.length-1; i++) {
            swap_option(to, i, i+1);
        }
        selected_option(to, to.length-1);
    }

--- End code ---

Then I added two new buttons.

--- Code: ---<a href="javascript:Movetop_Option();"><img src="images/move_top.gif" width="26" height="21" border="0" alt="" /></a>
<a href="javascript:Movebottom_Option();"><img src="images/move_bottom.gif" width="26" height="21" border="0" alt="" /></a>

--- End code ---

See the attached image, now I can move the pictures to top/bottom by one click.
This can also be applied for sorting albums, just edit albmgr.php the same way.

Joachim Müller:
Nice one, thanks.

Navigation

[0] Message Index

Go to full version