You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
2.6 KiB

11 years ago
# Ply
Amazing layer/modal/dialog system. Wow!
11 years ago
11 years ago
## Features
* Support browsers Chrome 20+, FireFox 20+, Safari 6+, Opera 12+, IE8+ (in progress)
* [ES6 syntax](https://github.com/termi/es6-transpiler)
* No jQuery (but then need polyfill [Promise](https://gist.github.com/RubaXa/8501359) polyfill)
11 years ago
* More than 90% [test code coverage](http://rubaxa.github.io/Ply/tests/)
11 years ago
## Base usage
11 years ago
Include [ply.css](ply.css) in `<head/>` (optional)
11 years ago
```html
<link href='./ply.css' rel='stylesheet' type='text/css'/>
```
Create a dialog:
```js
Ply.dialog("alert", "Wow!").then(function (ui) {
ui.by; // submit, overlay, esc, "x"
ui.state; // true — "OK", false — "cancel"
});
```
11 years ago
---
## Dialogs
```js
Ply.dialog({
"init-state": {
ui: "alert",
data: "Wow!",
next: "other-step"
nextEffect: "3d-flip[180,-180]"
},
"other-step": {
ui: "confirm",
data: {
text: "What's next?",
ok: "Exit", // button text
cancel: "Back"
},
back: "init-state",
backEffect: "3d-flip[-180,180]"
}
}).then(function (ui) {
// ...
})
```
---
11 years ago
## Low-level
```js
var ply = new Ply({
el: "...", // HTML-content
11 years ago
effect: "fade", // or ["open-effect:duration", "close-effect:duration"]
11 years ago
layer: {}, // default css
overlay: { // defaults css
opacity: 0.6,
backgroundColor: "#000"
},
flags: { // defaults
bodyScroll: false, // disable scrollbar at body
closeByEsc: true, // close by press on `Esc` key
closeByOverlay: true // close by click on the overlay
},
// Callback
init: function () {},
open: function (ply) {},
close: function (ply) {},
destory: function (ply) {},
callback: function (ui) {},
});
// And
ply.open().then(function () {
ply.swap({ el: ".." }, "3d-flip").then(function () {
ply.close();
});
});
```
11 years ago
---
11 years ago
11 years ago
## Preset effects
11 years ago
- fade
- scale
- fall
- slide
- 3d-flip
- 3d-sign
11 years ago
### Combined effects
11 years ago
```js
Ply.dialog("alert", { effect: ["fade", "scale"] }, "Fade & scale");
```
11 years ago
### Custom effects
```js
Ply.effects["my-effect"] = {
open: { layer: "fade-in", overlay: "background-in" },
close: { layer: "fade-out", overlay: "background-out" }
};
Ply.effects["background-in"] = {
"from": { opacity: 0, backgroundColor: "red" },
"to": { opacity: 1, backgroundColor: "white" }
};
Ply.effects["background-out"] = {
"from": { opacity: 1, backgroundColor: "white" },
"to": { opacity: 0, backgroundColor: "green" }
};
```
---
11 years ago
## Ply.stack
* last`:Ply|null`
* length`:Number`
11 years ago
---
## Ply.support
* transition`:String|Boolean`
* transform`:String|Boolean`
* perspective`:String|Boolean`
* transformStyle`:String|Boolean`
* transformOrigin`:String|Boolean`
* backfaceVisibility`:String|Boolean`