https://github.com/dimimikadze/vanilla-helpers
Vanilla Javascript Helper Functions, Ajax, Effects, DOM manipulation, Styles, Utilities
https://github.com/dimimikadze/vanilla-helpers
javascript
Last synced: about 1 year ago
JSON representation
Vanilla Javascript Helper Functions, Ajax, Effects, DOM manipulation, Styles, Utilities
- Host: GitHub
- URL: https://github.com/dimimikadze/vanilla-helpers
- Owner: DimiMikadze
- License: mit
- Created: 2015-07-22T19:47:17.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-08-06T13:37:45.000Z (almost 11 years ago)
- Last Synced: 2025-03-23T12:41:27.416Z (over 1 year ago)
- Topics: javascript
- Language: JavaScript
- Homepage:
- Size: 166 KB
- Stars: 34
- Watchers: 6
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# Vanilla Javascript Helper Functions, Ajax, Effects, DOM manipulation, Styles, Utilities, Without jQuery.
Easy to use Vanilla Javascript Helper Functions Collection, Ajax, Effects, DOM manipulation, Styles, Utilities ...
## Features
- Lightweight, No libraries required
- Ajax
- Effects
- DOM manipulation
- Styles
- Utilities
## Bower
````
bower install vanilla-helpers
````
## Getting Started
include js/vanillaHelpers.js OR js/vanillaHelpers.min.js
## Example Ajax GET
````
vanillaHelpers.ajaxGet('http://example.com/fa=foo&foo=faa', function(data) {
console.log(data);
});
````
If server returns json, parse it in callback function
````
vanillaHelpers.ajaxGet('http://example.com/fa=foo&foo=faa', function(data) {
console.log(JSON.parse(data));
});
````
## Example Ajax Post
````
vanillaHelpers.ajaxPost('http://example.com/', 'a=b&b=c', function(data) {
console.log(data);
});
````
You can also pass object as data
````
vanillaHelpers.ajaxPost('http://example.com/', { a: 'b', b: 'c' }, function(data) {
console.log(data);
});
````
## Fade In
````
vanillaHelpers.fadeIn(document.getElementById('test'), 3000);
````
With Callback
````
vanillaHelpers.fadeIn(document.getElementById('test'), 3000, function() {
console.log('animation stopped');
});
````
## Fade Out
````
vanillaHelpers.fadeOut(document.getElementById('test'), 3000);
````
With Callback
````
vanillaHelpers.fadeOut(document.getElementById('test'), 3000, function() {
console.log('animation stopped');
});
````
## Next Element
````
vanillaHelpers.nextElement(document.getElementById('test'));
````
## Previous Element
````
vanillaHelpers.previousElement(document.getElementById('test'));
````
## Browser Vendor Properties
````
vanillaHelpers.setVendor(document.getElementById('test'), 'Transition', '1s');
````
Will add next styles
````
-webkit-transition: 1s;
-moz-transition: 1s;
-ms-transition: 1s;
-o-transition: 1s;
transition: 1s;
````
## Generate random integer
````
vanillaHelpers.randomInt(1, 10);
````
## Get Current url segment
if url is: http://example.com/faa/foo/boo
````
vanillaHelpers.urlSegment(2);
````
Will return foo
## Check if element has specific class
````
vanillaHelpers.hasCls(document.getElementById('test'), 'foo');
````
## Add Class
````
vanillaHelpers.addCls(document.getElementById('test'), 'foo');
````
## Remove Class
````
vanillaHelpers.removeCls(document.getElementById('test'), 'foo');
````
## Toggle Class
````
vanillaHelpers.toggleCls(document.getElementById('test'), 'foo');
````
## Matches
````
vanillaHelpers.matches(document.getElementById('selector'), '#selector');
````
## String Starts With
````
vanillaHelpers.startsWith('SomeRandomText', 'Some');
````
## String Ends With
````
vanillaHelpers.endsWith('SomeRandomText', 'Some');
````
## String Between two characters
````
vanillaHelpers.stringBetween('SomeRandomText', 'R', 'T');
````
## In Array
````
vanillaHelpers.inArray(['a', 'b', 'c', 'd'], 'c');
````
## Contributing
contributions are more than welcome!
## License
See license.txt