Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove animations #37

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Logs
logs
*.log
npm-debug.log*

# Dependency directories
node_modules

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ You can change the behaviour by changing following js variables.
| `onMore` | Callback function to trigger when "more" is clicked |
| `onLess` | Callback function to trigger when "less" is clicked |

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

Minifying of the source file with uglify-js is registered as npm script.
To start developing install dependencies:

$ npm install

After changes of the source file `jquery.shorten.js` the minified version
`jquery.shorten.min.js` can be generated with the following command.

$ npm run minify

Licence
-------
Expand Down
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "jquery.shorten",
"version": "1.0.0",
"description": "A simple jquery plugin that automatically shortens text within an element and add more link.",
"main": "src/jquery.shorten.js",
"dependencies": {
"jquery": "^3.1.0"
},
"devDependencies": {
"uglify-js": "latest"
},
"scripts": {
"minify": "uglifyjs src/jquery.shorten.js > src/jquery.shorten.min.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/viralpatel/jquery.shorten.git"
},
"keywords": [],
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/viralpatel/jquery.shorten/issues"
},
"homepage": "https://github.com/viralpatel/jquery.shorten#readme"
}
12 changes: 4 additions & 8 deletions src/jquery.shorten.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
ellipsesText: "...",
moreText: "more",
lessText: "less",
onLess: function() {},
onMore: function() {},
errMsg: null,
force: false
};
Expand All @@ -50,16 +48,14 @@
if ($this.hasClass('less')) {
$this.removeClass('less');
$this.html(config.moreText);
$this.parent().prev().animate({'height':'0'+'%'}, function () { $this.parent().prev().prev().show(); }).hide('fast', function() {
config.onLess();
});
$this.parent().prev().prev().show(); // shortcontent
$this.parent().prev().hide(); // allcontent

} else {
$this.addClass('less');
$this.html(config.lessText);
$this.parent().prev().animate({'height':'100'+'%'}, function () { $this.parent().prev().prev().hide(); }).show('fast', function() {
config.onMore();
});
$this.parent().prev().prev().hide(); // shortcontent
$this.parent().prev().show(); // allcontent
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/jquery.shorten.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.