0.2.2 • Published 5 years ago

html-element-js v0.2.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

html-element-js

NOTE: Please do not install this library for prduction because this library is very unstable.

A simple library for creating and manipulating DOM using JavaScript DOM api. See demo

Documentation

Installation

npm install --save html-element-js

or directly import into browser

path/to/html-element-js/dist/html-element.js

Usage

Import in webpack

To import all
import html from 'html-element-js';
To only import tag method
import tag from '/node-modules/dist/tag';
To only import rangeSlider
import rangeSlider from '/node-modules/dist/rangeSlider';
To only import toggler
import toggler from '/node-modules/dist/toggler';
To only import custom select
import comboBox from '/node-modules/dist/comboBox';

Create a new element

To create a span tag
const span = html.tag('span');
Creating element with options
const span = html.tag('span' ,{
  textContent: 'This is span tag',
  className: 'myspan',
  id: 'span1'
});
HTML tags
  • create tag html.tag(tagName:String, options?:Object) anchor tag

Remove event listeners

Remove all EventListeners

const mydiv = html.tag('div');
mydiv.addEventListener('click', function(e){
  console.log(e);
}); //adds a event listener

mydiv.removeEvents(); //remvoes all event listener

Remove specific EventListeners

const mydiv = html.tag('div');
mydiv.addEventListener('click', function(e){
  console.log(e);
}); //adds a event listener

mydiv.removeEvents('click'); //remvoes all click event listener

see demo

Range slider

Creates range slider equivalent to input type range

const slider = html.rangeSlider({
  min: 0,
  max: 100,
  step: 2,
  value: 46
});

Properties - rangeSlider

  • min number:private (minimum value of range)
  • max number:private (maximum value of range)
  • size string:private (size of slider)
  • step string:private (step value)
  • value number:public

Methods - rangeSlider

  • onchange function:public
  • setvalue function:public

Toggler

Creates a toggle button equivalent to input type checkbox or radio

const toggler = html.toggler({
  size: 40,
  valType: 'on/off',
  value: true
});

Properties - toggler

  • size number:private (size of slider)
  • valType string:private (step value, possible value 'bool' or 'on/off')
  • value number:public

Methods - toggler

  • onchange function:public
  • setvalue function:public

ComboBox

Creates a toggle button equivalent to input type checkbox or radio

const toggler = html.select({
  spead: 2, //min 1 max any. Greater value fater opening animation. See in demo
  height: 30, //height of option
  maxheight: 300 //max height of option container.
});

options - comboBox

  • spead number (spead of animation of opening select options)
  • height number (height of option)
  • maxheight number (max height of option container)
  • select Element (Select element from DOM)

Methods - comboBox

  • addOption function:public
  • removeOption function:public
  • setvalue funtion:public
  • value function:public

ToolTip

Creates a toggle button equivalent to input type checkbox or radio

  • JavaScript for single element
const domElement = document.querySelector('some-element');

html.toolTip(domElement, {
  direction: 'left',
  title: 'this is some dummy title'
});
  • JavaScript direction auto
const domElement = document.querySelector('some-element');

html.toolTip(domElement, {
  direction: 'auto',
  defaultDirection: 'left',
  title: 'this is some dummy title',
  showToolTipOn: ['focus']
});
  • HTML without direction attribute
<a href="https://example.com" data-title="click this link">link</a>
  • HTML with direction attribute
<a href="https://example.com" data-title="click this link" data-direction="left">link</a>
  • Initialize all element which has data-title attribute
toolTip.init();

options - toolTip

  • direction string (direction of toolTip i.e. 'left', 'right', 'top' and 'bottom')
  • title string (text in toolTip)
0.2.2

5 years ago

0.2.12

5 years ago

0.2.11

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.236

5 years ago

0.0.235

5 years ago

0.0.234

5 years ago

0.0.233

5 years ago

0.0.232

5 years ago

0.0.231

5 years ago

0.0.230

5 years ago

0.0.229

5 years ago

0.0.228

5 years ago

0.0.227

5 years ago

0.0.226

5 years ago

0.0.225

5 years ago

0.0.224

5 years ago

0.0.223

5 years ago

0.0.222

5 years ago

0.0.221

5 years ago

0.0.220

5 years ago

0.0.219

5 years ago

0.0.218

5 years ago

0.0.217

5 years ago

0.0.216

5 years ago

0.0.215

5 years ago

0.0.214

5 years ago

0.0.213

5 years ago

0.0.212

5 years ago

0.0.211

5 years ago

0.0.21

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago