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.
 
 
 
RubaXa dd58d5625b + closeBtn 11 years ago
src + baseHtml 11 years ago
st * upd 11 years ago
tests + baseHtml 11 years ago
.gitignore * init 11 years ago
Gruntfile.js * min file 11 years ago
MIT-LICENSE.md * upd 11 years ago
Ply.min.js * min file 11 years ago
README.md + closeBtn 11 years ago
favicon.ico * init 11 years ago
index.html * html/css 11 years ago
package.json + docs 11 years ago
ply.css * html/css 11 years ago

README.md

Ply

Amazing layer/modal/dialog system. Wow!

Features

  • Support browsers Chrome 20+, FireFox 20+, Safari 6+, Opera 12+, IE8+ (in progress)
  • ES6 syntax
  • No jQuery (but then need polyfill Promise polyfill)
  • More than 90% test code coverage

Base usage

Include ply.css in <head/> (optional)

	<link href='./ply.css' rel='stylesheet' type='text/css'/>

Create a dialog:

Ply.dialog("alert", "Wow!").then(function (ui) {
	ui.by; // submit, overlay, esc, "x"
	ui.state; // true — "OK", false — "cancel"
});

Dialogs

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) {
	// ...
})

Low-level

var ply = new Ply({
	el: "...", // HTML-content

	effect: "fade", // or ["open-effect:duration", "close-effect:duration"]

	layer: {}, // default css

	overlay: { // defaults css
		opacity: 0.6,
		backgroundColor: "#000"
	},

	flags: { // defaults
		closeBtn: true, // presence close button "✖"
		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();
	});
});

Preset effects

  • fade
  • scale
  • fall
  • slide
  • 3d-flip
  • 3d-sign

Combined effects

Ply.dialog("alert", { effect: ["fade", "scale"] }, "Fade & scale");

Custom effects

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.stack

  • last:Ply|null
  • length:Number

Ply.support

  • transition:String|Boolean
  • transform:String|Boolean
  • perspective:String|Boolean
  • transformStyle:String|Boolean
  • transformOrigin:String|Boolean
  • backfaceVisibility:String|Boolean

Ply.lang (localization)

  • ok:String — "OK"
  • cancel:String — "Cancel"
  • cross:String — "✖"

Ply.defaults

  • layer:Object{}
  • overlay:Object{ opacity: 0.6, backgroundColor: 'rgb(0, 0, 0)' }
  • flags:Object{ bodyScroll: false, closeByEsc: true, closeByOverlay: true }

Ply.dom

build(tag:String|Object):HTMLElement

Ply.build(); // <div/>
Ply.build("input"); // <input/>
Ply.build(".foo"); // <div class="foo"/>
Ply.build(".foo.bar"); // <div class="foo bar"/>
Ply.build({  // <input type="password" class="foo" style="padding: 10px" maxlength="32"/>
	tag: "input.foo",
	type: "password",
	css: { padding: "10px" },
	maxlength: 32
});
Ply.build({ text: "<i>?</i>" }); // <div>&lt;i&gt;?&lt;/i&gt;</div>
Ply.build({ html: "<i>!</i>" }); // <div><i>!</i></div>

append(parent:HTMLElement, el:HTMLElement)

remove(el:HTMLElement)

addEvent(el:HTMLElement, name:String, fn:Function)

removeEvent(el:HTMLElement, name:String, fn:Function)