Hi,
I''m a new to prototype and js in general and this is my first attempt
at writing js code. The code below adds a container for a couple
links, the links themselves and some additional text on load. Then on
rollover/out the additional text is shown/hidden; on click it hides
itself and shows the other link and changes the stylesheet via the ALA
stylesheet switcher method. The stylesheet controls which link is
shown on page load.
As this is my first attempt at coding, could someone please give me
feedback so I can improve and learn.
Thanks
------
// functions to add container, links and additional link text on load
Event.observe(window, ''load'', function() {
var StyleLinks = {
addLinkContainer: function() {
$(''search'').insert(''<div
id="style_switcher"></div>'', content);
},
addLinks: function() {
$(''style_switcher'').insert(''<p
id="normal_vision_p"><a href="#"
id="normal_vision">normal view ></a> </p>'',
content);
$(''style_switcher'').insert(''<p
id="low_vision_p"><a href="#"
id="low_vision">low vision users ></a>
</p>'', content);
},
addStyleLinkOptions: function() {
$(''low_vision_p'').insert(''<span
id="low_vision_option"> click
here</span>'', content);
$(''normal_vision_p'').insert(''<span
id="normal_vision_option">
this way</span>'', content);
},
hideStyleLinkOptions: function() {
$(''low_vision_option'').hide();
$(''normal_vision_option'').hide();
},
showStyleLinkOptions: function() {
$(''low_vision_option'').show();
$(''normal_vision_option'').show();
},
hideStyleLinks: function() {
$(''low_vision_p'').hide();
$(''normal_vision_p'').hide();
},
showStyleLinks: function() {
$(''low_vision_p'').show();
$(''normal_vision_p'').show();
}
};
StyleLinks.addLinkContainer();
StyleLinks.addLinks();
StyleLinks.addStyleLinkOptions();
StyleLinks.hideStyleLinkOptions();
$(''low_vision'').observe(''mouseover'',
function(event){
Effect.Appear(''low_vision_option'', {duration: .125,
queue: ''end''});
});
$(''low_vision'').observe(''mouseout'',function(event){
Effect.Fade(''low_vision_option'', {duration: .125, queue:
''end''});
});
$(''low_vision'').observe(''click'',function(event){
$(''low_vision_p'').hide();
$(''normal_vision_p'').show();
setActiveStyleSheet(''low_vision''); return false;
});
$(''normal_vision'').observe(''mouseover'',
function(event){
Effect.Appear(''normal_vision_option'', {duration: .125,
queue:
''end''});
});
$(''normal_vision'').observe(''mouseout'',function(event){
Effect.Fade(''normal_vision_option'', {duration: .125,
queue: ''end''});
});
$(''normal_vision'').observe(''click'',function(event){
$(''normal_vision_p'').hide();
$(''low_vision_p'').show();
setActiveStyleSheet(''default''); return false;
});
});
-----
Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---