npm.io
0.9.2 • Published 8 years ago

omitter

Licence
MIT
Version
0.9.2
Deps
0
Size
24 kB
Vulns
0
Weekly
0
Stars
1

omitter.js

Omitter.js is a small javascript plugin, it can omit a text content faster. this plugin thought about reduce reflow count. so probably this plugin is faster than some plugins that using Element.innerText or TextNode.data.

For Example

window.addEventListener("load", function (event){
  // var doms = $(".omitter-target");
  var doms = document.querySelectorAll(".omitter-target");
  var omitter = new Omitter(doms, 3, "..."); // limit to 3 lines.
  omitter.omit();
});

if you want disable omission, you can use omitter.unomit(); method. it show all sentences.

Methods

Method Description
Omitter.omit enable omission mode and update nodes.
Omitter.unomit disable omission mode and update nodes if necessary.
Omitter.update update nodes if omission mode is enabled.
Omitter.toggle toggle omission mode and update nodes.
TODO
  1. I should think whitespace character. the ellipsis ignore whitespace or not?
  2. rename some members and css classes to right words.
License

this plugin released under MIT license.

Keywords