Skip to content

Commit

Permalink
Updated readme (#223)
Browse files Browse the repository at this point in the history
* Updated readme

* Release 1.1.1
  • Loading branch information
armino-dev authored Feb 3, 2024
1 parent c5f1cfd commit b9002af
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 140 deletions.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,84 @@ A jquery plugin for creating a timed modal dialog

* Under development

## Getting started

Install the jQuery and the jQuery timed dialog.

### Using npm

```bash
npm i jquery
npm i @armino-dev/jquery-timed-dialog
```

Import the components into your script.

```js
import $ from 'jquery';
import timedDialog from '@armino-dev/jquery-timed-dialog';
```

Import the css into your stylesheet.

```css
import '@armino-dev/jquery-timed-dialog/dist/timed-dialog.min.css';
```

### Directly into your html from node_modules

```html
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/@armino-dev/jquery-timed-dialog/dist/timed-dialog.min.js"></script>
<link rel="stylesheet" href="node_modules/@armino-dev/jquery-timed-dialog/dist/timed-dialog.min.css" />
```

### Directly into your html from cdn
```html
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="[node_modules/@armino-dev/jquery-timed-dialog/dist/timed-dialog.min.js](https://esm.sh/@armino-dev/jquery-timed-dialog)"></script>
<link rel="stylesheet" href="https://esm.sh/@armino-dev/jquery-timed-dialog/dist/timed-dialog.min.css" />
```

## Use it

```js

const myCallback = () => {
console.log('The callback was executed!');
}

const options = {
type: 'confirmation',
title: 'Confirm callback execution',
body: '<p>Are you sure you want to execute myCallback?<br/><span style="font-size: 12px; padding:10px 0;">Check the console</span></p>',
width: 400,
height: 280,
timeout: 10,
closeOnTimer: true,
btnConfirm: {
text: 'Execute my callback',
action: () => myCallback(),
}
};

document.addEventListener("DOMContentLoaded", () => {
// add a button to dom
const button = document.createElement('button');
button.textContent = 'Show dialog';

// add a click event listener to the button
button.addEventListener("click", () => {
$().timedDialog(options);
});

// add the button to page
document.body.appendChild(button);
});
```

### **Please take a look at [this working example on CodePen](https://codepen.io/armino-dev/pen/zYbjdJw).**

## Demo

Demo can be viewed on [here](https://armino-dev.github.io/jquery-timed-dialog/demo/)
Expand Down
125 changes: 0 additions & 125 deletions css/timed-dialog.css

This file was deleted.

2 changes: 1 addition & 1 deletion demo/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import url('https://fonts.googleapis.com/css?family=Noto+Serif:400,700&display=swap');
@import "../css/timed-dialog.css";
@import "../dist/css/timed-dialog.min.css";

body {
font-family: 'Noto Serif', serif;
Expand Down
8 changes: 4 additions & 4 deletions dist/timed-dialog.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ module.exports = function (config) {
// list of files / patterns to load in the browser
files: [
'https://code.jquery.com/jquery-3.4.1.min.js',
'demo/index.html',
'demo/index.css',
'css/timed-dialog.css',
'dist/css/timed-dialog.min.css',
'src/**/*.js',
'specs/**/*.js'
],
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@armino-dev/jquery-timed-dialog",
"title": "jQuery Timed Dialog",
"version": "1.1.0",
"version": "1.1.1",
"description": "A jQuery timed dialog UI",
"homepage": "https://github.com/armino-dev/jquery-timed-dialog#readme",
"main": "dist/timed-dialog.min.js",
Expand Down
7 changes: 3 additions & 4 deletions specs/timed-dialogSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ describe("jQuery Timed Dialog Plugin", () => {
it("Should close on dialog btnDismiss click", (done) => {
let dialog = $().timedDialog(options);
const random = dialog.random;

let btnDismiss = $(document.querySelector(`#btn-dismiss-${random}`));
btnDismiss.trigger('click');


let btnDismiss = document.querySelector(`#btn-dismiss-${random}`);
btnDismiss.click();
setTimeout(() => {
expect($(`#timed-dialog-${random}`).length).toBeLessThan(1);
done();
Expand Down
3 changes: 3 additions & 0 deletions src/timed-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@
}

this.random = random;
this.overlay = overlay;
this.dialog = dialog;
this.dismissDialog = dismissDialog;

this.initialize = () => {
const isAlreadyOpen = $('.timed-dialog-overlay').length;
Expand Down

0 comments on commit b9002af

Please sign in to comment.