Git Product home page Git Product logo

vanilla-helpers's Introduction

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 hass specific class

vanillaHelpers.hasClass(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

vanilla-helpers's People

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.