php, coldfusion and general web development waffle

for all net-related stuff
Post Reply
User avatar
Brown Sauce
admin
Posts: 1485
Joined: Sun Jan 07, 2007 3:40 pm

Post by Brown Sauce »

:lol:
User avatar
luke
admin
Posts: 5653
Joined: Sun Feb 11, 2007 5:32 pm
Location: by the sea

Post by luke »

i don't think theres a solution to this, but i'll ask just in case ...

i'm redoing a site at the moment, the original is in asp with an access database

the current site, and mine at the moment, displays document titles alphabetically, for example;

Guideline 01 - Appendix 01 - Principal UK Fishing Organisations
Guideline 01 - Appendix 02 - Principal Operational Regulations, Issue 4, May 2012
Guideline 01 - Appendix 03 - Fishing Claims forms & Guidance Notes
Guideline 01 - Appendix 04 - Guidance Fishing Reps, Issue 4, May 2012
Guideline 01 - Appendix 05 - Guidance Notes for Guard Vessels
Guideline 01 - Appendix 06 - Telecom Cable Works Notice, Issue 4, May 2012
Guideline 01 - Fishing Liaison, Issue 5, May 2012

so it just sorts by the field

but, they'd actually like the last item in that list to be the first ... because the appendixes should come after the main document

the only solution i can think of is they'd need to rename all the document titles so they are actually alphabetically correct, so 'Guideline 01 - Appendix 01 - Principal UK Fishing Organisations' would become 'Guideline 01 - Fishing Liaison, Issue 5, May 2012 - Appendix 01 - Principal UK Fishing Organisations' - but theres so many that it would take forever. theres no other solution though is there ... ?
User avatar
faceless
Posts: 27009
Joined: Tue Apr 25, 2006 6:16 pm

Post by faceless »

Could you add an extra (hidden) field that could be used for setting the display sequence?
User avatar
luke
admin
Posts: 5653
Joined: Sun Feb 11, 2007 5:32 pm
Location: by the sea

Post by luke »

not really, i could do it - but as soon as new documents are added it would all go wrong, unless they had to add the sequence in for new documents, but i don't think i'd trust the users to maintain the correct sequence. theres hundreds of documents, they can be viewed all together or in document types, it would be a nightmare

i'm just going to tell them they'll have to type them alphabetically. i mean, they couldn't get excel, access or windows explorer to display their list like they want them ordered so why expect it of a web site?

the only thing i could think of is to have two document title fields, a main and secondary, so 'Guideline 01 - Fishing Liaison, Issue 5, May 2012 ' would be the main title, and this one wouldn't have a secondary title, the others would have the main title 'Guideline 01' with secondary titles 'Appendix 01 - Principal UK Fishing Organisations' etc, but that seems like a bit too much hassle!
User avatar
luke
admin
Posts: 5653
Joined: Sun Feb 11, 2007 5:32 pm
Location: by the sea

Post by luke »

i wonder if anyone can come up with a solution to this little problem ...

so i've got a long page, lets say different chapters going down. at the top i've got a jump to section 1, 2, 3 etc, and you click that to jump to that section

its just a basic <a>section 1</a> / <a>section 2</a> etc

with section 1 having a <a></a>

so clicking the section 1 link would move the page down so section 1 was positioned at the top of the browser window.

but instead of it being positioned at the top, i'd like it to be positioned where the mouse currently is ...any ideas?!

i had a google about but couldn't see anything. i did see something that made me think, you could put a padding-top on the <a> links styling, but the padding-top you'd want for this would be the pixels down the mouse currently is from the top of the browser window, so you'd have to use javascript/jquery i guess. when you click a section to jump to, you'd work out the mouse position, set the padding-top on the section you're going to that mouse position value, and then jump to the link - so you'd end up with the section being where your mouse currently is.

i think :lol:

anyone ever done anything like that? is it even possible? or have i got it completely wrong
User avatar
faceless
Posts: 27009
Joined: Tue Apr 25, 2006 6:16 pm

Post by faceless »

yeah, I've been starting to add such tags into the galloway archive so that one day it will be easily searched

here's a page about it - it's really one of the oldest techniques about though!

https://www.davesite.com/webstation/html/chap09.shtml
User avatar
luke
admin
Posts: 5653
Joined: Sun Feb 11, 2007 5:32 pm
Location: by the sea

Post by luke »

sorry my code hasn't displayed quite right - the forum has removed bits!

but yeah, what you linked is what i'm doing at the moment, but what i want is when i click section 2 on that site - instead of section 2 moving to the top of the page, i want section 2 to move to where the mouse currently is ...
User avatar
Brown Sauce
admin
Posts: 1485
Joined: Sun Jan 07, 2007 3:40 pm

Post by Brown Sauce »

you may need to find the co ordinates of the mouse position, and then move the section to that position, maybe you only need the y position?

here's a script to find the coordinates

https://dev-notes.com/code.php?q=33

maybe this

https://stackoverflow.com/questions/6088 ... ith-jquery

and

https://jsfiddle.net/mattball/haFMn/

works
User avatar
luke
admin
Posts: 5653
Joined: Sun Feb 11, 2007 5:32 pm
Location: by the sea

Post by luke »

thanks sauce, i think the javascript code will be more helpful than the jquery one - as i don't want to move a single div/element, i want the whole page to move to a certain position.

although looking at the javascript, its tracking the position within the whole page - i need to the mouse position not within the whole page, but within the current browser view area. so you could scroll to the bottom, move your mouse to the top of the viewing area ( without scrolling up ), and it would be 0 - where as that code calculates from the top of the page ...

if i could work out the position within the viewing area, and then change the padding-top of the a name based on the mouse x position ... i shall google
User avatar
luke
admin
Posts: 5653
Joined: Sun Feb 11, 2007 5:32 pm
Location: by the sea

Post by luke »

ignore everything i said about the padding, stupid idea - i just did a mock up and of course it puts a gap the size of the mouse position in the page layout ... i didn't think that through

back to the drawing board ...
User avatar
faceless
Posts: 27009
Joined: Tue Apr 25, 2006 6:16 pm

Post by faceless »

when code doesn't display correctly, either wrap it in

Code: Select all

 tags, or click the 'disable HTML' option in the post reply page.
User avatar
luke
admin
Posts: 5653
Joined: Sun Feb 11, 2007 5:32 pm
Location: by the sea

Post by luke »

i did it :) ( thanks to sauce's link to that js )

its all in this;

Code: Select all

document.getElementById(e).style.top="-"+(event.clientY-10)+"px";
clientY is the pixel position within the browser - not the page

set the a names as position:relative, and when clicking the links, run the above js to set its top position ( e in the code above is the a name id ) and you're done. the extra 10 pixels was just to get the spacing of where i wanted to land spot on.

i'm not sure what would happen on a tablet or touch phone, i don't know if the tap of your finger would register as a mouse position ...
User avatar
faceless
Posts: 27009
Joined: Tue Apr 25, 2006 6:16 pm

Post by faceless »

It sounds like a neat idea from what I can gather, but I'm not entirely sure how it will work - can you post an example page that uses it?

is it similar to the navigation bar on the page here? I quite like that because the movement of it attracts the eye, so people know it's there
User avatar
luke
admin
Posts: 5653
Joined: Sun Feb 11, 2007 5:32 pm
Location: by the sea

Post by luke »

sorry, i don't think i explained it very well, its nothing as fancy as that!

its stupid really, and i'd not even noticed it in 16 years - and its not something i'll probably use again, its just this one client wasn't keen and it got me thinking if it could be done

this is what he didn't like - the standard 'a name' and 'a href=#'

click say section 2, and section 2 will move to the top of the screen - but your mouse is over section 3

this is with the solution with the javascript;

click section 2, and section 2 moves to where your mouse is

theres a slight change in the code from what i posted, what i posted didn't work in firefox or ie - but worked in chrome, safari and opera. the new code works in all of them.
Last edited by luke on Wed Jan 29, 2014 7:57 am, edited 1 time in total.
User avatar
Brown Sauce
admin
Posts: 1485
Joined: Sun Jan 07, 2007 3:40 pm

Post by Brown Sauce »

Looks good though, maybe it's the sort of thing that's used in photo galleries, but horizontally and with some delay ..
Post Reply