1.0.26 • Published 6 years ago

ts-on-off-switch v1.0.26

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

JQuery On-Off Switch written in Typescript

JQuery widget which transforms

<input type="checkbox"> 

into a visual On/Off switch.

npm install ts-on-off-switch --save

Example :

Set module resolution to node in tsconfig.json

   "compilerOptions": {
        "moduleResolution" : "node",
        ...
   }

Typescript:

import * as $ from "jquery";

import { OnOffSwitch } from "ts-on-off-switch";

export class TestClass {

    constructor() {
        let el = new OnOffSwitch({
            textOn: "on",
            textOff: "off",
            el: $('#mycheckbox'),
            listener: (name: string, checked: boolean) => {

            }
        });
    }
}

HTML

<html>
<head>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
        crossorigin="anonymous"></script>
    <script type="text/javascript" src="node_modules/ts-on-off-switch/dist/index.js"></script>
</head>

<body>
    <div class="checkbox-container">
        <input type="checkbox" id="on-off-switch" name="switch1" checked>
    </div>
    <div id="listener-text">

    </div>
    <script type="text/javascript">
        new OnOffSwitch({
            el: '#on-off-switch',
            textOn: 'Sync On',
            textOff: 'Off',
            listener: function (name, checked) {
                $("#listener-text").html("Listener called for " + name + ", checked: " + checked);
            }
        });
    </script>
</body>
</html>
1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.4

6 years ago