Code Monkey home page Code Monkey logo

show-more's Introduction

Show More

Author: Jason Alvis
Author Email: [email protected]
Version: 1.0.4
License: Free General Public License (GPL)

Brief

A neat little plugin that allows you to show / hide content (toggle) on clicking a trigger. Useful for areas of a website with restricted space but you still want to show a lot of content. Typically used on text blocks where you reveal a small portion of the text and show more on clicking a trigger.

Very easy to implement please follow the instructions below. You can check it out over on js fiddle http://jsfiddle.net/pnfh3/2/ there is also a demo included in the zip.

HTML

<div class="showmore">
     <h2>Show more block</h2>
     <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In et felis rutrum neque aliquam hendrerit eu et massa. Phasellus fermentum, elit nec vulputate vehicula, massa lorem ultrices purus, id pulvinar elit massa et ligula. Suspendisse vulputate quam non sem iaculis auctor. Maecenas ut nisi ut urna bibendum aliquet non vestibulum mi. Fusce euismod condimentum sem, vitae elementum dui mattis eget. Duis imperdiet congue justo, eget commodo risus imperdiet sit amet. Aenean sem augue, pulvinar nec sagittis eu, hendrerit vitae sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse laoreet, diam sed faucibus ultricies, velit tortor fringilla ligula, sed malesuada magna justo nec ligula. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Etiam metus leo, tincidunt eu fringilla at, tincidunt et leo. Aliquam nec eros eu nisl consectetur mattis. Nullam eleifend velit at est varius non sagittis ligula tincidunt. Aenean elementum rhoncus mattis.</p>	
     <p>Maecenas ullamcorper erat ut leo imperdiet sed aliquet nunc congue. Maecenas consectetur purus ac lorem pellentesque dignissim. Nunc aliquet sapien sit amet odio tincidunt a commodo ante dignissim. Praesent vel ligula odio, sit amet fringilla tortor. Ut nec erat sit amet nisl varius euismod a ut lorem. Morbi dapibus dui luctus lorem fermentum at gravida sapien auctor. Aliquam erat volutpat. Aenean turpis metus, laoreet sit amet venenatis quis, ornare vitae erat. Integer gravida aliquam fringilla. Curabitur eros eros, placerat non pharetra id, fringilla vitae justo. Aenean sagittis facilisis sapien, eu varius augue adipiscing ut.</p>	
</div>

jQuery

Add the following code to your JavaScript file typically on a document.ready:

$(document).ready(function() {
          
     $('.showmore').showMore({
          speedDown: 300,
          speedUp: 300,
          height: '165px',
          showText: 'Show more',
          hideText: 'Show less'
     });
          
});

Minimum CSS styles

To ensure consistency across multiple browsers please ensure the showmore block has a line-height specified. This will then provide an accurate height and display correctly.

.showmore { line-height:18px; }
.showmore_content { position:relative; overflow:hidden; }			
.showmore_trigger { width:100%; height:45px; line-height:45px; cursor:pointer; }
.showmore_trigger span { display:block; }

show-more's People

Contributors

jasonujmaalvis avatar baig avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.