View Full Version : javascript hide/show information.
harem
02-28-2008, 04:31 PM
hello everybody. :)
i need a javascript or something like it shows the photo comments and information, and with 1 click you can hide and show it again!: ) most like:
http://www.marta.com/index.php/#comscript
i know there are some "scrolling" but the scrolling sucks in firefox, then i only want something like marta's! :)
fredxeric
02-28-2008, 05:22 PM
mootools
harem
02-28-2008, 05:57 PM
do you mean this :
http://mootools.net/download
or what do you mean pleas?
harem
02-28-2008, 06:10 PM
and how do i put it into my files? i have read documantation, but didnt get it! srry!
kevincrafts
02-28-2008, 09:25 PM
I'm a big fan of jquery (http://jquery.com) - but to just simple show/hide without any sort of effect can be done without any library.
document.getElementById('comments').style.display = 'block'; to show
document.getElementById('comments').style.display = 'none'; to hide
fredxeric
02-28-2008, 09:51 PM
do you mean this :
http://mootools.net/download
or what do you mean pleas?
Yes that's right, but like kiven say jquery can do the task.
harem
02-29-2008, 09:11 AM
thank you both of you! :)
but kevin can you tell me what you mean with the code you gav me? :)
i mean where to put it? into my <head> and </head> and whats the code to html? srry, but all what i can is css and html! :)
harem
02-29-2008, 01:04 PM
and pleas, how do i install mootools?
i have downloaded the file with slide.fx and called it mootools.js then put this code:
<script type="text/javascript" src="mootools.js"></script>
into my <head></head>
but dont know what to do more? can you guys help me pleas?
fredxeric
02-29-2008, 01:50 PM
where you have put the script in your template...
<script type="text/javascript" src="mootools.js"></script>
Should be...
<script type="text/javascript" src="templates/templates_name/scripts/mootools.js"></script>
harem
02-29-2008, 02:37 PM
didnt work, i did this:
mootools.js into scripts folder.
put:
#test {
background: #222;
color: #fff;
padding: 10px;
margin: 20px;
border: 10px solid pink;
}
#test2 {
background: #222;
color: #fff;
padding: 10px;
margin: 20px;
border: 10px solid pink;
}
into style.css
put this in <head> </head>:
<script type="text/javascript" src="templates/my_template/scripts/mootools.js"></script>
and this one:
<h3 class="section">Fx.Slide Vertical</h3>
<a id="slideout" href="#">slideout</a> | <a id="slidein" href="#">slidein</a> | <a id="toggle" href="#">toggle</a> | <a id="hide" href="#">hide</a>
<div id="test">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<h3 class="section">Fx.Slide Horizontal</h3>
<a id="slideout2" href="#">slideout</a> | <a id="slidein2" href="#">slidein</a> | <a id="toggle2" href="#">toggle</a> | <a id="hide2" href="#">hide</a>
<div id="test2">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
into my html file, but still doesnt work, any other ideas pleas? :)
Don't forget window.addEvent('domready', function() {
// HERE IS WHAT YOU READ IN JS CODE
});
It's a must, as moo creators explained here: http://demos.mootools.net/
For your example, do like this:
your .html: <html><head>
......
bla-bla-bla-dummy-content
......
<script type="text/javascript" src="templates/my_template/scripts/mootools.js"></script>
window.addEvent('domready', function() {
//-vertical
var mySlide = new Fx.Slide('test');
$('slidein').addEvent('click', function(e){
e = new Event(e);
mySlide.slideIn();
e.stop();
});
$('slideout').addEvent('click', function(e){
e = new Event(e);
mySlide.slideOut();
e.stop();
});
$('toggle').addEvent('click', function(e){
e = new Event(e);
mySlide.toggle();
e.stop();
});
$('hide').addEvent('click', function(e){
e = new Event(e);
mySlide.hide();
e.stop();
});
//--horizontal
var mySlide2 = new Fx.Slide('test2', {mode: 'horizontal'});
$('slidein2').addEvent('click', function(e){
e = new Event(e);
mySlide2.slideIn();
e.stop();
});
$('slideout2').addEvent('click', function(e){
e = new Event(e);
mySlide2.slideOut();
e.stop();
});
$('toggle2').addEvent('click', function(e){
e = new Event(e);
mySlide2.toggle();
e.stop();
});
$('hide2').addEvent('click', function(e){
e = new Event(e);
mySlide2.hide();
e.stop();
});
});
</head>
<body>
......
bla-bla-bla-dummy-content
......
<h3 class="section">Fx.Slide Vertical</h3>
<a id="slideout" href="#">slideout</a> | <a id="slidein" href="#">slidein</a> | <a id="toggle" href="#">toggle</a> | <a id="hide" href="#">hide</a>
<div id="test">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<h3 class="section">Fx.Slide Horizontal</h3>
<a id="slideout2" href="#">slideout</a> | <a id="slidein2" href="#">slidein</a> | <a id="toggle2" href="#">toggle</a> | <a id="hide2" href="#">hide</a>
<div id="test2">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
......
bla-bla-bla-dummy-content
......
</body>
</html>
And .css looks like this:
#test {
background: #222;
color: #fff;
padding: 10px;
margin: 20px;
border: 10px solid pink;
}
#test2 {
background: #222;
color: #fff;
padding: 10px;
margin: 20px;
border: 10px solid pink;
}
Good luck!
harem
02-29-2008, 10:40 PM
thank you everyone and xact, i had forgot this code :
window.addEvent('domready', function() {
// HERE IS WHAT YOU READ IN JS CODE
});
but i have 1 problem now, i made a new button:
<a id="hide" href="#">hide</a> | <a id="show" href="#">show</a>
and it works fine, but how can i do both things with same button? like toggle, but not effect, just show and hide?
i hope someone can help me with that.
and how to hide it from the start whe you are loading the page? then later you can show it? :)
For showing with no effect:
$('show').addEvent('click', function(e){
e = new Event(e);
mySlide.show();
e.stop();
});
To hide an element from the beginning, after declaring it as "var", you only have to hide it, like this:
............
var mySlide = new Fx.Slide('test');
mySlide.hide();
.............
I don't know yet how to do it with the same button. If I have the time I'll dig a little to find out.
harem
03-01-2008, 11:02 AM
thank you very much! :)
i will be waiting until you find out, if not, its okay, i will use toggle, but toggle sucks in firefox, :) but in explorer very nice! :b first time explorer do something cool! :)
hi kevin..
where i have to put that code?
in the head or just where i want to show/hide?
I'm a big fan of jquery (http://jquery.com) - but to just simple show/hide without any sort of effect can be done without any library.
document.getElementById('comments').style.display = 'block'; to show
document.getElementById('comments').style.display = 'none'; to hide
vBulletin® v3.7.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.