Skip to main content
Topic: Idea for ya: compact page index that saves a pile of code. (Read 2787 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Idea for ya: compact page index that saves a pile of code.

Was just playing around with this today. Not on the Elk codebase, but should be a piece of cake to adapt. I don't really have the time and motivation to do it myself at the moment (would have to learn Elk back end n stuff all over again) but if you think the idea is worth nicking, go for it.

So the plan is to ditch most of the markup, CSS and js for the old page index, and substitute a select. This is nice and clean on desktop, and nice and compact on phones. Phones like selects, going from what the nutters who browse with them tell me.

Keep the previous/next page buttons for convenience, since 99% of the time that's what people will probably use. Select is just for backup if they want some particular page in a hurry, and to give them a clear indication of where they are up to. If there is only one page, no need for the select or the previous/next buttons. It just gives you the page without added crud.

Even with the two remaining buttons, the code is still much simpler overall.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Idea for ya: compact page index that saves a pile of code.

Reply #1

OMG, the avatar!  :o  :D

Re: Idea for ya: compact page index that saves a pile of code.

Reply #2

Concentrate on the page index. Breathe deeply. You can get through this. :D
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Idea for ya: compact page index that saves a pile of code.

Reply #3

I can see that helping on the small screens vs the current buttons. 

Re: Idea for ya: compact page index that saves a pile of code.

Reply #4

Yeah that's what I was thinking. That and a general reduction in bloat. The code I was playing with was based on Arantor's old Page Dropdown mod.

At a WIP stage I have it mutated to this:

Code: [Select]
	if($max_value > $num_per_page) {
$dropdown_url = ($flexible_start ? $base_url : strtr($base_url, array('%' => '%%')) . ';start=');
if(strpos($dropdown_url, '%1$d') === false) {
if(strpos($dropdown_url, 'start=') === false) {
$dropdown_url .= ';start=%1$d';
} else {
$dropdown_url = str_replace('start=', 'start=%1$d', $dropdown_url);
}
}
$base_dropdown = '<div class="hey_try_this"><select onchange="javascript:window.location=(\'' . $dropdown_url . '\').replace(/%1\$d/, this.value);">';
$display_page = 0;
$myPage = ($start / $num_per_page);
for ($counter = 0; $counter < $max_value; $counter += $num_per_page) {
$base_dropdown .= '<option value="' . ($num_per_page * $display_page) . '"';
if($display_page == $myPage) $base_dropdown .= ' selected="selected"';
$base_dropdown .= '>Page ' . ++$display_page;
if($display_page == $myPage + 1) $base_dropdown .= ' of '. sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);
$base_dropdown .= '</option>';
}
$base_dropdown .= '</select></div>  ';
} else {
$base_dropdown = "";
}

return $base_dropdown . $pageindex;
}

The extra div is just to allow cleaner styling of the select, so you can hide the default pointer via hidden overflow.

Bloc has already decided it's a good enough idea to be worth nicking. :D
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Idea for ya: compact page index that saves a pile of code.

Reply #5

Hey I've been playing with this some more and have thought of some improvements (PHP, CSS, a11y, etc). Will have it packaged for SMF 2.0.x soon. Most of the XML work will be dealing with moving default crud out of cruddy 2.0.x default templates, so I can put the nifty stuff in without it getting screwed around. ::)

Anywayz, since Elk doesn't have the same template crud to worry about, and IIRC uses basically the same page index function, it should be easy to adapt. As soon as the package is tested for clean installation I'll let you know. Then, if you want to, you can just throw it on a vanilla 2.0.x test site and see what makes it tick.

I'll be licensing the mod as WTFPL, so no dramas with licenses. :)

 Antechinus really likes WTFPL. :D
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P


 

Re: Idea for ya: compact page index that saves a pile of code.

Reply #7

ROFL. Well yes, but the other reasons I like it are that anyone can read it before their first coffee of the day, in only a minute, and still manage to comprehend it perfectly.

There's none of this "Herewith be teh license of much awesomeness, and herein will be described, in great detail, what thou shalt and shall not do if thou wanteth thy gonads to stay in their current location."

For items which suit a do-wotcha-like license, I like having one that just says "do wotcha like". No muss. No fuss. :)
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P