0.5.4 • Published 7 years ago

flexiejs v0.5.4

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

FlexieJS v0.5.4

Lightweight native javascript modal window framework

Installation

Using npm

npm install flexiejs --save

Using script tag

Download flexie.min.js from this repository and insert it in your HTML:

<!-- import flexie -->
<script type="text/javascript" src="some-path/flexie.min.js"></script>

Usage

import {Dialog, ImageHolder} from "flexiejs";

/*
 * Dialog window
 */
const dialog = new Dialog({
  // options
});

dialog.show();

/*
 * ImageHolder
 */
const imageHolder = ImageHolder({
  src: "./img.jpg"
});

imageHolder.show();

Dialog

Default dialog window

const dialog = new Dialog();
dialog.show();

Options

PropertyTypeValuesDefault
colorstring"blue", "red", "yellow", "green", "black""blue"
titlestring-"title"
contentstring-"some content"

Also, you can cutomize buttons and their actions To add buttons to your dialog box, add buttons array to Flexie options, like this:

new Dialog({
  // some options
  buttons: ["ok", "no", "cancel"]
});

Each element of this array is the text that will be displayed on the corresponding button

buttons0 is confirm button (default), buttons1 - decline, buttons2 - cancel

To handle "click" event on this buttons, add this callbacks to Flexie options:

new Dialog({
  // some options
  buttons: ["ok", "no", "cancel"],
  onConfirm: function(flexie) { alert("onConfirm()") },
  onDecline: function(flexie) { alert("onDecline()") },
  onCancel: function(flexie) { alert("onCancel()") }
});

Each callback function receives a Flexie window object as a parameter. If you need to prevent close action, add this line to your callback function:

new Dialog({
  // some options
  onConfirm: function(flexie) {
    flexie.preventClose();
    // some logic
  }
});

Callback functions

namedescription
onOpencalls when Flexie window opens
onClosecalls when Flexie window close
onConfirmbuttons0 click handler
onDeclinebuttons1 click handler
onCancelbuttons2 click handler

Custom window sample

const dialog = new Dialog({
  color: "green",
  title: "Ask the question",
  content: "Do you want to know the greatest secret?",
  buttons: ["yea!", "nope"],
  onConfirm: function(flexie) {
    console.log("yes");
  },
  onDecline: function(flexie) {
    console.log("no");
  }
});
dialog.show();

ImageHolder

If you need to display some image in dialog window, you should use ImageHolder window:

const image = new ImageHolder({
  src: "https://img2.goodfon.ru/wallpaper/big/0/e9/priroda-derevya-les-doroga-7284.jpg",
  width: 550,
  title: "Road in forest"
});

Options

PropertyTypeValuesDefault
srcstring/url-null
titlestring-""
widthint-500

Animation

You can customize Flexie window open animation. To do this, create animation object

const modal = new Dialog({
  color: "yellow",
  title: "Custom animation demo",
  content: "This animation is not so beautiful as the previous one",
  buttons: ["okay =("],
  onConfirm: function(flexie) {
    console.log("okay =( clicked");
  },
  animation: {
    duration: 1000,
    timingFunction: "easeOutBounce",
    type: "fromTop"
  }
});
modal.show();

Animation options

PropertyTypeValuesDefault
typestring"fade", "scaleIn", "scaleOut", "flipHorizontal", "flipVertical", "fromLeft", "fromTop", "fromRight", "fromLeft", "flipTop", "flipBottom""scaleIn"
timingFunctionstring"linear", "bounce", "easeOutBounce", "elastic", "easeOutElastic""easeOutElastic"
durationintfrom 0 to Infinity =)1000 (ms)
0.5.4

7 years ago

0.5.3

7 years ago

0.5.0

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago