Skip to content

Commit

Permalink
Merge pull request #17 from Tuizi/update
Browse files Browse the repository at this point in the history
Update the library to use Gulp, Markdown and new dependencies version
  • Loading branch information
jeffchan committed Feb 12, 2016
2 parents 261be27 + 330d3ce commit f1c0c5b
Show file tree
Hide file tree
Showing 13 changed files with 599 additions and 9,929 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
71 changes: 71 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,75 @@

pkg
node_modules
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties

### OSX template
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

npm-debug.log
2 changes: 0 additions & 2 deletions jshint.json → .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
"nomen": false,
"onevar": false,
"plusplus": false,
"regexp": false,
"undef": true,
"sub": true,
"strict": false,
"trailing": true,
Expand Down
37 changes: 0 additions & 37 deletions Makefile

This file was deleted.

92 changes: 50 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,63 @@
Truncate.js
====
# Truncate.js

Fast, intelligent Javascript text truncation

Usage
-----------
## Usage

Truncate.js currently depends on jQuery. There are two ways to use Truncate.js:

1) as a jQuery plugin
### As a jQuery plugin

# Initialize and truncate.
// Initialize and truncate.
$('#truncate_me').truncate({
lines: 2,
lineHeight: 20
});

# Update the HTML and truncate.
// Update the HTML and truncate.
$('#truncate_me').truncate('update', 'new html to truncate');

# Undo the truncation.
// Undo the truncation.
$('#truncate_me').truncate('expand');

# Redo the truncation (uses cached HTML).
// Redo the truncation (uses cached HTML).
$('#truncate_me').truncate('collapse');

2) as a vanilla Javascript object
### As a vanilla Javascript object

# Initialize and truncate.
// Initialize and truncate.
var truncated = new Truncate(document.getElementById('#truncate_me'), {
lines: 2,
lineHeight: 20
});

# Update the HTML and truncate.
// Update the HTML and truncate.
truncated.update('new html to truncate');

# Undo the truncation.
// Undo the truncation.
truncated.expand();

# Redo the truncation (uses cached HTML).
// Redo the truncation (uses cached HTML).
truncated.collapse();

# Check if content is truncated. (not supported as a jQuery plugin)
// Check if content is truncated. (not supported as a jQuery plugin)
var isTruncated = truncated.isTruncated;

# Check if content is collapsed. (not supported as a jQuery plugin)
// Check if content is collapsed. (not supported as a jQuery plugin)
var isCollapsed = truncated.isCollapsed

Options
-----------
## Options

- `lineHeight`: **Required**. The text line height.
- `lines`: The number of line maximum. _default: 1_
- `ellipsis`: Text content to add at the truncation point. _default: …_
- `showMore`: HTML to insert at the truncation point. Useful for a "Show More" button. _default: ""_
- `showLess`: HTML to insert when .expand() is called. Useful for a "Show Less" button. _default: ""_

lineHeight - Required. The text line height.
lines - Defaults to 1
ellipsis - Text content to add at the truncation point. Defaults to …
showMore - HTML to insert at the truncation point. Useful for a "Show More" button.
Defaults to empty string.
showLess - HTML to insert when .expand() is called. Useful for a "Show Less" button.
Defaults to empty string.
----

## Caveats

Caveats
-----------
Truncate.js does it's best to intelligently truncate through HTML. However,
there are a few cases where it fails, mostly because the text height cannot
be easily calculated.
Expand All @@ -70,42 +68,52 @@ be easily calculated.

See `demo/demo.html` for examples of what works and what doesn't.

Development
-----------
---

It's very simple, hack on the code, ensure the lint and tests pass and submit
a pull request. Rinse and repeat.
## Build

You need gulp to build the library:

$ npm install
$ npm run build

There is a Makefile containing useful development tools. The available commands
can be listed by running:
The output is in the **dist** folder

$ make
## Development

It's very simple, hack on the code, ensure the lint and tests pass and submit
a pull request. Rinse and repeat.

To install the developer packages you'll need node and npm installed on your
machine. Then run:

$ npm install
$ npm run build

Or you can use Gulp directly:

$ npm install --global gulp-cli
$ npm install
$ gulp build

To run the linter:

$ make lint
$ npm run lint

Testing
-------
## Testing

To run the test suite:

$ make test
$ npm run test


### Libraries
## Libraries

- [Mocha](http://visionmedia.github.com/mocha/) - Test runner, we use the `bdd` style.
- [Chai](http://chaijs.com/api/assert/) - Assertion library, we use `assert` style.
- [Gulp](http://gulpjs.com/) - Builder


License
-------
## License

Available under the MIT license. See LICENSE file for details.

Loading

0 comments on commit f1c0c5b

Please sign in to comment.