www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Rate Thread Display Modes
      #1  
    Old 08-24-2007, 05:31 PM
    qwik3r qwik3r is offline
    Registered User
     
    Join Date: Oct 2006
    Posts: 208
    mootools fx slide anyone good?

    Having a bit of trouble with mootools fx.slide - I posted in the mootools forum to no avail so I thought maybe some gurus could help me out here. I am brand spakin new to javascript, I understand the logic for the most part but yeah I know its like playing with fire and your not a fireman, don't bother until your properly trained. I still need some help though.

    Ok so a bit of a preface.
    FX.slide http://demos.mootools.net/Fx.Slide is what I am using.

    I am trying to achieve the following.
    User clicks more info and a div slides down with more info, it is initially hidden etc. I want them to be able to toggle it on and off.

    The code for ONE of these with a div ID is:

    Code:
    window.addEvent('domready', function(){
    	var mySlide = new Fx.Slide('moreinfo'
    			$('toggle').addEvent('click', function(e){
    				e = new Event(e);
    				mySlide.toggle();
    				e.stop();
    			});
    			
    			mySlide.hide();	
    		
    	
    		});
    Toggle is the link and moreinfo is the div. Now this only works with ONE div right now and it only works with IDs.

    So I was wondering if someone with experience in javascript or mootools could help me in doing multiple divs.

    So say I have 10 divs all with the class "moreinfo" and the toggle is always "toggle" - I have tried and googled and searched mootools forum and didn't come across any relevant info, assistance would be great, thanks.
    Reply With Quote
      #2  
    Old 08-26-2007, 04:48 PM
    qwik3r qwik3r is offline
    Registered User
     
    Join Date: Oct 2006
    Posts: 208
    anyone?
    Reply With Quote
      #3  
    Old 08-28-2007, 05:34 AM
    campbellm campbellm is offline
    Registered User
     
    Join Date: Aug 2007
    Posts: 3
    mootools multiple sliders

    Quote:
    Originally Posted by qwik3r
    Having a bit of trouble with mootools fx.slide
    This is a bit rough and ready, but it should do what you want.

    You can see a demo of it here - but with only four sliding elements. To add more, just copy each the HTML for each div.

    Rather than trying to ID all the elements (which is a headache and doesn't scale) better to wrap each slider in a div with it's own class. This makes associating the toggle element and the sliding element simple since they both children of the wrapper div.

    We then need to just loop through each wrapper div - making each child slider element into a slider and adding the click event to each toggle.

    BTW - the code given assumes there is one and only one element of each class (ie divToggle and moreInfo) within the wrapper div. You should probably use $chk( ... ) to ensure you don't get errors if either of the elements are missing.

    I tested this only with FF and Safari on Mac.

    javascript:
    Code:
    window.addEvent( 'domready', function(){
    	$$( '.moreInfoWrapper' ).each(function(item){
    		var thisSlider = new Fx.Slide( item.getElement( '.moreInfo' ), { duration: 500 } );
    		thisSlider.hide();
    		item.getElement( '.divToggle' ).addEvent( 'click', function(){ thisSlider.toggle(); } );
    	} );
    } );
    CSS
    Code:
    body
    {
    	font-size: 0.7em;
    	background-color:#dddddd;
    	font-family:Verdana, Arial, Helvetica, sans-serif;
    }
    h3
    {
    	font-size: 0.9em;
    	font-weight: bold;
    }
    .divToggle
    {
    	color: #ffffff;
    	background-color:#0033cc;
    	padding: 8px;
    }
    .moreInfoWrapper
    {
    	float: left;
    	width: 128px;
    	border: 2px solid #dddddd;
    	background-color: #ffffff;
    	padding: 0px;
    }
    .moreInfo
    {
    	padding: 2px;
    }
    HTML
    Code:
    	<div class='moreInfoWrapper'>
    		<div class='divToggle'>
    			<h3>Click to Show/Hide</h3>
    		</div>
    		<div class='moreInfo'>
    			<h3>More Info About Item 1</h3>
    			<p>Here is some content.</p>
    			<p>More Content</p>
    			<p>End of Content</p>
    		</div>
    	</div>
    	<div class='moreInfoWrapper'>
    		<div class='divToggle'>
    			<h3>Click to Show/Hide</h3>
    		</div>
    		<div class='moreInfo'>
    			<h3>More Info About Item 2</h3>
    			<p>Here is some content.</p>
    			<p>More Content</p>
    			<p>End of Content</p>
    		</div>
    	</div>
    etc etc

    HTH.
    Reply With Quote
      #4  
    Old 08-28-2007, 09:41 AM
    qwik3r qwik3r is offline
    Registered User
     
    Join Date: Oct 2006
    Posts: 208
    Great! thanks for coming to the rescue man!
    Reply With Quote
      #5  
    Old 06-06-2008, 07:18 AM
    Mini0n Mini0n is offline
    Registered User
     
    Join Date: Jun 2008
    Posts: 1
    Sorry to dig this up, but I was trying to do the same thing as qwik3r, and tried to use campbellm's tip but it won't work.

    FireBug tells me

    Quote:
    this.element has no properties
    this.offset = this.element.offsetHeight;
    Does anyone know what this means?
    I'm doing everything as the example campbellm uses...

    TIA
    Reply With Quote
      #6  
    Old 09-08-2008, 03:41 PM
    campbellm campbellm is offline
    Registered User
     
    Join Date: Aug 2007
    Posts: 3
    sorry - seems a bunch of people still want the example to look at. I had taken it down but it's now back - unfortunately have to change the url.
    multipleSliders.html

    Campbell
    Reply With Quote
      #7  
    Old 09-02-2009, 01:28 AM
    bigonroad bigonroad is offline
    Registered User
     
    Join Date: Sep 2009
    Posts: 4
    Sorry to bring this up so long after...

    Just came accross this, and it works well. However, I want to use it to hide the elipse as well - in other words, for divToggle to toggle two divs, one that is currently hidden to become visible, and one that was visible to hide. Here's my code -

    Code:
    <script type="text/javascript">
    window.addEvent( 'domready', function(){
    	$$( '.moreInfoWrapper' ).each(function(item){
    		var thisSlider = new Fx.Slide( item.getElement( '.moreInfo' ), { duration: 500 } );
    		thisSlider.hide();
    		var otherSlider = new Fx.Slide( item.getElement( '.otherInfo' ), { duration: 500 } );
    		otherSlider.show();
    		
    		item.getElement( '.divToggle' ).addEvent( 'click', function(){ thisSlider.toggle(); 
    		item.getElement( '.divToggle' ).addEvent( 'click', function(){ otherSlider.toggle(); } );
    	} );
    } );
    </script>
    Code:
    <div class="moreInfoWrapper">
    	<h3><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h3>
    	<p><?php 
    	$description=$item->get_description();
    	$intro = cutText($description, 175);   
    	echo $intro.'<div class="otherInfo">...</div>';
    	?>
    	<div class="moreInfo">paragraph to appear here</p>
            <p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p></div>
    	<p><div class='divToggle'> <a href="#">read more/less... </a></div>
    any ideas?
    Reply With Quote
      #8  
    Old 09-02-2009, 05:46 AM
    bigonroad bigonroad is offline
    Registered User
     
    Join Date: Sep 2009
    Posts: 4
    anyone?

    Would really appreciate some help on this one!
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 04:53 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.