Amazing layer/modal/dialog system. Wow!
Amazing layer/modal/dialog system. Wow!
Include ply.css in `` (optional)
Create a dialog:
Ply.dialog("alert", "Wow!").always(function (ui) {
ui.state; // true — "OK", false — "cancel"
ui.by; // submit, overlay, esc, "x"
ui.widget; // Ply instance
});
//or
Ply.dialog("confirm", "Do you like it?")
.done(function (ui) {
// OK
})
.fail(function (ui) {
// Cancel
})
.always(function (ui) {
if (ui.state) {
// Clicked "OK"
}
else {
// Clicked "Cancel"
// details: `ui.by` — "cancel", "overlay", "esc", "x"
}
});
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]"
}
}).always(function (ui) {
if (ui.state) {
// OK
} else {
// Cancel
// ui.by — 'overlay', 'x', 'esc'
}
})
String|HTMLElement — content of layerObject — layer optionsObject — layer options…
PromisePromisePromiseSwapping one layer to another
PromiseSwapping the content of one layer to another
Destroy layer
Ply.dialog("alert", { effect: ["fade", "scale"] }, "Fade & scale");
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" }
};
Ply|nullNumberString|BooleanString|BooleanString|BooleanString|BooleanString|BooleanString|BooleanString — "OK"String — "Cancel"String — "✖"Object — cssObject — style overlay0.6rgb(0, 0, 0)'ObjectBoolean — presence close button "✖"falseBoolean — closing the layer by pressing the esc key, default trueBoolean — closing the layer by clicking on the overlay, default trueBoolean — hide the layer if it is not the first in the stackBoolean — visibility overlay, if the layer is not the first in the stackString|Object):HTMLElementPly.build(); //
Ply.build({ html: "!" }); //
HTMLElement, el:HTMLElement)HTMLElement)HTMLElement, name:String, fn:Function)HTMLElement, name:String, fn:Function)HTMLElementString — ui-element namevar el = Ply.ui("btn", {
title: "click me",
value: "Wow!"
})
String — ui-element nameFunction — callbackPly.ui.factory("btn", function (data, children) {
// data:`Object`
// children:`HTMLElement`
return {
"tag": ".btn",
"text": data.value
};
});
// or button with icon (optional)
Ply.ui.factory("btn", function (data, children) {
return {
"tag": ".btn",
"title": data.title
"children": [
data.icon && { "tag": "span.glyphicon.glyphicon-" + data.icon },
{ "tag": "span", "text": data.value }
]
};
});
String — template nameFunction — callback…
grunt watch — dev modegrunt build — assembly projectply-loadingui.layer -> ui.widgeton prefix to all callbacksNo open issues yet, or sync has not completed.