From 15166f696845b88012e32d3b7d70b2ddaf1b7920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Alcaraz=20Mart=C3=ADnez?= Date: Mon, 26 Dec 2022 08:00:54 +0100 Subject: [PATCH 1/2] Prepare v5 branch --- README.md | 11 ++++++----- package.json | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 00dc245..c986359 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ [![GitHub license](https://img.shields.io/github/license/palcarazm/bootstrap5-toggle.svg?color=informational)](https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE) -[![Latest release](https://img.shields.io/github/package-json/v/palcarazm/bootstrap5-toggle/v4?logo=github)](https://github.com/palcarazm/bootstrap5-toggle/releases) -[![Bootstrap 4](https://img.shields.io/static/v1?label=bootstrap&message=%5E5.0.0&color=informational&logo=bootstrap&logoColor=white)](https://getbootstrap.com/docs/5.0) +[![Latest release](https://img.shields.io/github/package-json/v/palcarazm/bootstrap5-toggle/v5?logo=github)](https://github.com/palcarazm/bootstrap5-toggle/releases) +[![Bootstrap 5](https://img.shields.io/static/v1?label=bootstrap&message=%5E5.0.0&color=informational&logo=bootstrap&logoColor=white)](https://getbootstrap.com/docs/5.0) [![JSDelivr Badge](https://img.shields.io/jsdelivr/npm/hm/bootstrap5-toggle?label=hits&logo=jsdelivr&logoColor=white)](https://www.jsdelivr.com/package/npm/bootstrap5-toggle) [![NPM Badge](https://img.shields.io/npm/dm/bootstrap5-toggle?logo=npm)](https://www.npmjs.com/package/bootstrap5-toggle) -[![Build](https://img.shields.io/github/actions/workflow/status/palcarazm/bootstrap5-toggle/build.yml?branch=v4&logo=npm)](https://github.com/palcarazm/bootstrap5-toggle/actions?query=workflow%3A%22Build+Check%22) -[![Test](https://img.shields.io/github/actions/workflow/status/palcarazm/bootstrap5-toggle/cypress.yml?branch=v4&label=tests&logo=cypress)](https://github.com/palcarazm/bootstrap5-toggle/actions?query=workflow%3A%22Cypress+Tests%22) +[![Build](https://img.shields.io/github/actions/workflow/status/palcarazm/bootstrap5-toggle/build.yml?branch=v5&logo=npm)](https://github.com/palcarazm/bootstrap5-toggle/actions?query=workflow%3A%22Build+Check%22) +[![Test](https://img.shields.io/github/actions/workflow/status/palcarazm/bootstrap5-toggle/cypress.yml?branch=v5&label=tests&logo=cypress)](https://github.com/palcarazm/bootstrap5-toggle/actions?query=workflow%3A%22Cypress+Tests%22) [![Security](https://img.shields.io/snyk/vulnerabilities/npm/bootstrap5-toggle@4.3.6?logo=snyk)](https://snyk.io/advisor/npm-package/bootstrap5-toggle) [![EOL](https://img.shields.io/static/v1?label=EOL&message=active%20support&color=success)](https://github.com/palcarazm/bootstrap5-toggle/security/policy) [![Funding](https://img.shields.io/badge/sponsor-30363D?style=flat&logo=GitHub-Sponsors&logoColor=#white)](https://github.com/sponsors/palcarazm) @@ -20,6 +20,7 @@ | Branch | Bootstrap Support | Last Release | | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [bootstrap5-toggle v5](https://github.com/palcarazm/bootstrap5-toggle/tree/v5) | [![Bootstrap 5](https://img.shields.io/static/v1?label=bootstrap&message=%5E5.0.0&color=informational&logo=bootstrap&logoColor=white)](https://getbootstrap.com/docs/5.0) | [![Latest release](https://img.shields.io/github/package-json/v/palcarazm/bootstrap5-toggle/v5?logo=github)](https://github.com/palcarazm/bootstrap5-toggle/releases) | | [bootstrap5-toggle v4](https://github.com/palcarazm/bootstrap5-toggle/tree/v4) | [![Bootstrap 5](https://img.shields.io/static/v1?label=bootstrap&message=%5E5.0.0&color=informational&logo=bootstrap&logoColor=white)](https://getbootstrap.com/docs/5.0) | [![Latest release](https://img.shields.io/github/package-json/v/palcarazm/bootstrap5-toggle/v4?logo=github)](https://github.com/palcarazm/bootstrap5-toggle/releases) | | [bootstrap5-toggle v3](https://github.com/palcarazm/bootstrap5-toggle/tree/v3) | [![Bootstrap 4](https://img.shields.io/static/v1?label=bootstrap&message=%5E4.0.0&color=informational&logo=bootstrap&logoColor=white)](https://getbootstrap.com/docs/4.0) | [![Latest release](https://img.shields.io/github/package-json/v/palcarazm/bootstrap5-toggle/v3?logo=github)](https://github.com/palcarazm/bootstrap5-toggle/releases) | @@ -98,7 +99,7 @@ ## Download -[![Latest release](https://img.shields.io/github/package-json/v/palcarazm/bootstrap5-toggle/v4?logo=github)](https://github.com/palcarazm/bootstrap5-toggle/releases) +[![Latest release](https://img.shields.io/github/package-json/v/palcarazm/bootstrap5-toggle/v5?logo=github)](https://github.com/palcarazm/bootstrap5-toggle/releases) ## NPM diff --git a/package.json b/package.json index 97697a3..88d0705 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "name": "Pablo Alcaraz Martínez", "url": "https://github.com/palcarazm/" }, - "description": "Bootstrap 5 Toggle is a bootstrap 5 plugin that converts checkboxes into toggles.", + "description": "Bootstrap Toggle is a bootstrap 5 plugin that converts checkboxes into toggles.", "homepage": "https://palcarazm.github.io/bootstrap5-toggle/", "license": "MIT", "funding": { @@ -27,9 +27,9 @@ "bootstrap5", "bootstrap-5", "bootstrap 5", - "bootstrap 5 checkbox", - "bootstrap 5 switch", - "bootstrap 5 toggle", + "bootstrap checkbox", + "bootstrap switch", + "bootstrap toggle", "bootstrap-checkbox", "bootstrap-switch", "bootstrap-switch-button", From bc3f8de0f6a6e24e278c9dc66773b5d3915e75c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Alcaraz=20Mart=C3=ADnez?= Date: Mon, 26 Dec 2022 08:09:08 +0100 Subject: [PATCH 2/2] feat!: Set ecmas interface as main interface - Add syfix to jQuery interface - Change readme docs to use ecmas interface - Set jQuery as optional dependencie BREAKING CHANGE: the jQuery interface script file had been rename. --- Gruntfile.js | 10 +-- README.md | 77 +++++++++---------- ...-toggle.js => bootstrap5-toggle.jquery.js} | 0 ...min.js => bootstrap5-toggle.jquery.min.js} | 2 +- js/bootstrap5-toggle.jquery.min.js.map | 1 + js/bootstrap5-toggle.min.js.map | 1 - package-lock.json | 20 +++-- package.json | 8 +- test/test-app.jquery.html | 2 +- 9 files changed, 62 insertions(+), 59 deletions(-) rename js/{bootstrap5-toggle.js => bootstrap5-toggle.jquery.js} (100%) rename js/{bootstrap5-toggle.min.js => bootstrap5-toggle.jquery.min.js} (99%) create mode 100644 js/bootstrap5-toggle.jquery.min.js.map delete mode 100644 js/bootstrap5-toggle.min.js.map diff --git a/Gruntfile.js b/Gruntfile.js index 54086c8..51277c6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -22,13 +22,13 @@ module.exports = function (grunt) { sourceMap: true, }, build: { - files:[ + files: [ { expand: true, cwd: "js", - src: "bootstrap5-toggle.js", + src: "bootstrap5-toggle.jquery.js", dest: "js", - ext: ".min.js", + ext: ".jquery.min.js", }, { expand: true, @@ -36,8 +36,8 @@ module.exports = function (grunt) { src: "bootstrap5-toggle.ecmas.js", dest: "js", ext: ".ecmas.min.js", - } - ] + }, + ], }, }, cssmin: { diff --git a/README.md b/README.md index c986359..15046f8 100644 --- a/README.md +++ b/README.md @@ -45,15 +45,11 @@ -**Table of Contents** _generated with [DocToc](https://github.com/thlorenz/doctoc)_ -- [Bootstrap 5 Toggle](#bootstrap-5-toggle) - [Library Distributions](#library-distributions) -- [Demos](#demos) -- [Related Bootstrap Plugins](#related-bootstrap-plugins) - [Installation](#installation) - [CDN](#cdn) - - [jQuery Interface](#jquery-interface) - [ECMAS Interface](#ecmas-interface) + - [jQuery Interface](#jquery-interface) - [Download](#download) - [NPM](#npm) - [Yarn](#yarn) @@ -79,22 +75,22 @@ [![JSDelivr Badge](https://img.shields.io/jsdelivr/npm/hm/bootstrap5-toggle?label=hits&logo=jsdelivr&logoColor=white)](https://www.jsdelivr.com/package/npm/bootstrap5-toggle) -### jQuery Interface +### ECMAS Interface ```html - + ``` -### ECMAS Interface +### jQuery Interface ```html - + ``` ## Download @@ -134,9 +130,7 @@ EX: Initialize id `chkToggle` with a single line of JavaScript. ```html ``` @@ -155,11 +149,9 @@ EX: Initialize id `chkToggle` with a single line of JavaScript. data-off="Disabled" /> ``` @@ -185,20 +177,23 @@ Methods can be used to control toggles directly. ```html + ``` -| Method | Example | Description | -| ------------- | ---------------------------------------------------- | ------------------------------------------------- | -| initialize | `$('#toggle-demo').bootstrapToggle()` | Initializes the toggle plugin with options | -| destroy | `$('#toggle-demo').bootstrapToggle('destroy')` | Destroys the toggle | -| on | `$('#toggle-demo').bootstrapToggle('on')` | Sets the toggle to 'On' state | -| off | `$('#toggle-demo').bootstrapToggle('off')` | Sets the toggle to 'Off' state | -| toggle | `$('#toggle-demo').bootstrapToggle('toggle')` | Toggles the state of the toggle on/off | -| enable | `$('#toggle-demo').bootstrapToggle('enable')` | Enables the toggle | -| disable | `$('#toggle-demo').bootstrapToggle('disable')` | Disables the toggle | -| readonly | `$('#toggle-demo').bootstrapToggle('readonly')` | Disables the toggle but preserve checkbox enabled | -| indeterminate | `$('#toggle-demo').bootstrapToggle('indeterminate')` | Sets the toggle to 'indeterminate' state | -| determinate | `$('#toggle-demo').bootstrapToggle('determinate')` | Sets the toggle to 'determinate' state | +| Method | Example | Description | +| ------------- | --------------------------------------------- | ------------------------------------------------- | +| initialize | `toggleDemo.bootstrapToggle()` | Initializes the toggle plugin with options | +| destroy | `toggleDemo.bootstrapToggle('destroy')` | Destroys the toggle | +| on | `toggleDemo.bootstrapToggle('on')` | Sets the toggle to 'On' state | +| off | `toggleDemo.bootstrapToggle('off')` | Sets the toggle to 'Off' state | +| toggle | `toggleDemo.bootstrapToggle('toggle')` | Toggles the state of the toggle on/off | +| enable | `toggleDemo.bootstrapToggle('enable')` | Enables the toggle | +| disable | `toggleDemo.bootstrapToggle('disable')` | Disables the toggle | +| readonly | `toggleDemo.bootstrapToggle('readonly')` | Disables the toggle but preserve checkbox enabled | +| indeterminate | `toggleDemo.bootstrapToggle('indeterminate')` | Sets the toggle to 'indeterminate' state | +| determinate | `toggleDemo.bootstrapToggle('determinate')` | Sets the toggle to 'determinate' state | # Events @@ -212,10 +207,10 @@ You should listen to events from the `` directly rather t
``` @@ -240,16 +235,16 @@ Passing `true` to the on, off, toggle, determinate and indeterminate methods wil ``` @@ -266,16 +261,16 @@ This also means that using the API or Input to trigger events will work both way ``` diff --git a/js/bootstrap5-toggle.js b/js/bootstrap5-toggle.jquery.js similarity index 100% rename from js/bootstrap5-toggle.js rename to js/bootstrap5-toggle.jquery.js diff --git a/js/bootstrap5-toggle.min.js b/js/bootstrap5-toggle.jquery.min.js similarity index 99% rename from js/bootstrap5-toggle.min.js rename to js/bootstrap5-toggle.jquery.min.js index 47799ff..1ad22ef 100644 --- a/js/bootstrap5-toggle.min.js +++ b/js/bootstrap5-toggle.jquery.min.js @@ -11,4 +11,4 @@ */ !function(a){"use strict";function o(t,e){this.$element=a(t),this.options=a.extend({},this.defaults(),e),this.render()}function h(t,e){e.options.tristate?e.$toggle.hasClass("indeterminate")?(e.determinate(!0),e.toggle()):e.indeterminate():e.toggle(),t.preventDefault()}o.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"secondary",onvalue:null,offvalue:null,size:"normal",style:"",width:null,height:null,tabindex:0,tristate:!1,name:null},o.prototype.defaults=function(){return{on:this.$element.attr("data-on")||o.DEFAULTS.on,off:this.$element.attr("data-off")||o.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||o.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||o.DEFAULTS.offstyle,onvalue:this.$element.attr("value")||this.$element.attr("data-onvalue")||o.DEFAULTS.onvalue,offvalue:this.$element.attr("data-offvalue")||o.DEFAULTS.offvalue,size:this.$element.attr("data-size")||o.DEFAULTS.size,style:this.$element.attr("data-style")||o.DEFAULTS.style,width:this.$element.attr("data-width")||o.DEFAULTS.width,height:this.$element.attr("data-height")||o.DEFAULTS.height,tabindex:this.$element.attr("tabindex")||o.DEFAULTS.tabindex,tristate:this.$element.is("[tristate]")||o.DEFAULTS.tristate,name:this.$element.attr("name")||o.DEFAULTS.name}},o.prototype.render=function(){let t;switch(this.options.size){case"large":case"lg":t="btn-lg";break;case"small":case"sm":t="btn-sm";break;case"mini":case"xs":t="btn-xs";break;default:t=""}var e=a('