8000 feat: Mangle props, add new "nobutton" props by tomickigrzegorz · Pull Request #49 · tomickigrzegorz/show-more · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Mangle props, add new "nobutton" props #49

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

Merged
merged 8 commits into from
May 8, 2022
Merged
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
14 changes: 7 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module.exports = {
browser: true,
es2021: true,
},
extends: ['eslint:recommended'],
plugins: ['prettier'],
extends: ["eslint:recommended", "prettier"],
plugins: ["prettier"],
rules: {
'prettier/prettier': 'error',
'comma-dangle': ['error', 'only-multiline'],
'linebreak-style': ['error', 'windows'],
'no-param-reassign': [2, { props: false }],
"prettier/prettier": "error",
"comma-dangle": ["error", "only-multiline"],
"linebreak-style": ["error", "windows"],
"no-param-reassign": [2, { props: false }],
},
parser: '@babel/eslint-parser',
parser: "@babel/eslint-parser",
};
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"semi": true,
"singleQuote": true,
"singleQuote": false,
"tabWidth": 2,
"endOfLine": "auto",
"printWidth": 80
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ npm run prod
<script src="/path/to/showMore.min.js"></script>
```

<img src="https://cdn.jsdelivr.net/www.jsdelivr.com/4a8e863f4c627929f243db3360393a7eed05238c/img/logo-horizontal.svg">
## CDN

HTML
```html
<script src="https://cdn.jsdelivr.net/gh/tomik23/show-more@1.1.2/dist/js/showMore.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/tomik23/show-more@1.1.3/dist/js/showMore.min.js"></script>
```

CSS
```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/tomik23/show-more@1.1.2/dist/css/showMore.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/tomik23/show-more@1.1.3/dist/css/show-more.min.css" />
```

-- OR --
Expand Down Expand Up @@ -156,7 +156,7 @@ CSS
### Only the ellipsis → [live example](https://tomik23.github.io/show-more#ellipsis):

```html
<div class="element" data-config='{ "type": "text", "limit": 100 }'>
<div class="element" data-config='{ "type": "text", "limit": 100, "nobutton": true }'>
It is a long established fact that a reader will be distracted by the readable
content of a page when looking at its layout.
</div>
Expand Down Expand Up @@ -244,9 +244,11 @@ document.addEventListener('DOMContentLoaded', function () {
});
});
```
You can also mix, `global configuration` + `data-config`. In these cases, `data-config` takes precedence over `global configuration`.
You can also mix, `global configuration` + `data-config`. In such cases, the `global configuration` object will merge with` data-config`.
For example, we have 10 texts to shorten, then we add the global configuration, but we also have a table that we want to shorten, in this case we add `data-config` to table - [see table example](#for-table--live-example)

You don't need to add all the variables in the `data-config`. For example, if we have more/less buttons in `global configuration` then in `data-config` we do not have to declare them, but if we add them, they will overwrite their settings in globalen configuration.

## Configuration of the plugin

| element | require | description |
Expand All @@ -260,6 +262,7 @@ For example, we have 10 texts to shorten, then we add the global configuration,
| `more/less` | | is the text and chars that appears after the text, list or table e.g. `> show more` and `< show less` |
| `number` | | number of hidden items to show more/less e.g. `-> show more 3`, only works for list and table |
| `ellipsis` | | By default, adding an ellipsis to shortened text can be turned off by setting 'ellipsis': false |
| `nobutton` | | Diable showing the read more/less button, by default 'nobutton': false |
| `regex` | | adding your own regular expressions. It is an object with two parameters `match` and `replace`, see example below |
| `btnClass` | | Button class name. Default: `show-more-btn` |
| `btnClassAppend` | | Opportunity to add additional classes to the button |
Expand All @@ -280,7 +283,7 @@ Configuration for IE:

### cdn

- https://cdn.jsdelivr.net/gh/tomik23/show-more@1.1.2/dist/js/showMore.min.js
- https://cdn.jsdelivr.net/gh/tomik23/show-more@1.1.3/dist/js/showMore.ie.min.js

### cdn polyfill from npm

Expand Down
Loading
0