Giter VIP home page Giter VIP logo

cutter.js's Introduction

Cutter.js

Cutter.js is a class to truncate HTML code to limit its length, by words number, without losing the markup.

Description

Cutter solves the problem when its needed to cut some content by a number of words but its mandatory no lose any markup. Cutter cuts the content to the number of requested words and if needed puts a link to open the full content again.

Some benefits:

  • No markup is lost.
  • Framework agnostic.
  • The content can be written without take care about the full content.
  • Not needed to have two different contents.
  • Crossbrowsing
    • Tested on:
      • IE >= 6
      • Firefox >= 3
      • Safari >= 4
      • Google Chrome >= 4
      • Opera >= 9.5
  • Only 1.5kb when Gzipped.

(Links will only work if you clone the repo.)

API documentation

Examples to see for yourself!

Usage

Before using it:

Insert in your code:

<script type="text/javascript" src="/path/to/your/js/libs/Cutter.js"></script>

Simple execution:

Cutter.run(oApplyTo, oTarget, nWords, [oTexts, oClasses]);

####Mandatory

oAplyTo: The element where the cutter will cut the content

oTarget: The element where the content will be attached after cut it.

nWords: Number of words to cut the content.

####Optional

oTexts: The texts config object with the text that will be showed if the link, to open the full content,is needed

oTexts by default: { more: "View more"}.

oClasses: The style config object with the class to style the link if needed.

oClasses by default: { more: "more"}.

Tip: oTarget Could be the same oApplyTo element if we want to replace the full content with the cut content

Tip: If you only need to change the style you must put "undefined" where oTexts must be placed.

Documentation

(Links will only work if you clone the repo.)

API documentation

Examples to see for yourself!

License

Cutter.js is licensed under the MIT license.

cutter.js's People

Contributors

tcorral avatar

Stargazers

jag avatar

Watchers

jag avatar James Cloos 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.