Git Product home page Git Product logo

jquery.spacesaver's Introduction

jQuery.spaceSaver

A simple show more/show less plugin. For when less is more.

This plugin has been designed to work with my own system, but feel free to hack it to death if required.

Current version: 0.1.0

Requirements

Getting up and running

Download the files

Reference the files

<link rel="stylesheet" href="path/to/file/jquery.spaceSaver.css" type="text/css">

This script requires jQuery so make sure you add the space saver script after it or define jQuery as a dependency.

<script src="path/to/file/jquery.spaceSaver.js"></script>

Optional

If you wish space saver to react to window resizes, you will need to include jquery.debouncedresize.js before the space saver script or define it as a dependency.

This feature is set to false by default, but can be enabled by passing resizable: true during initialisation.

Usage:

HTML

This plugin required a container for the content you wish to show more/show less. You will need to add the 'space-saver' class to the container, so it has the required styling.

<div id="container" class="space-saver">
	<p>Some content here</p>
</div>

JS

$('#container').spaceSaver({
	// This height will be where the contents of the target div is cut-off and replaced by the 'show more'. 
	// You can adjust this to suit your content
	heightLimit: 100,
	// The background colour (Hex) of the 'show more/show less'
  	backgroundColor: '#fff',
  	// You can supply the html for including an 'open' icon
  	iconOpen: '<i class="icon-up-open"></i>',
  	// You can supply the html for including an 'closed' icon
  	iconClosed: '<i class="icon-down-open"></i>',
  	// You can set whether you want the plugin to refresh if the window is resized.
	// This requires jquery.debouncedresize.js to be available
  	resizable: false
});

NOTE: The DOM must be rendered before you initialise the plugin so that it can access the element's height.

jquery.spacesaver's People

Watchers

 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.