jsanahuja/gModal

Modal without dependencies. Just JavaScript!

Best code Example Alert Confirm Prompt Large one Only text DOM

	
	var mymodal = new gModal({
		title: "This is the best code example Modal",
		body: "This is example defines <strong>all</strong> the available configurations so shows the real power of this library",
		buttons: [
			{
				content: "Cancel",
				classes: "gmodal-button-gray",
				bindKey: 27, /* Esc */
				callback: function(modal){
					console.log("You hace cancelled the modal!");
					modal.hide();
				}
			},{
				content: "Accept",
				classes: "gmodal-button-blue",
				bindKey: 13, /* Enter */
				callback: function(modal){
					console.log("You have accepted the modal!");
					modal.hide();
				}
			}
		],
		close: {
			closable: true,
			location: "in", /* 'in' or 'out' (side) the modal */
			/**
				* Reusing the key 27 here would throw a warning.
				* Button bindings have more priority and would override this.
				*/
			bindKey: false, 
			callback: function(modal){
				console.log("You have closed the modal!");
				modal.hide();
			}
		},

		/**
			* Modal Events.
			* Note that, by default, we destroy modal after hiding it.
		**/
		onShow:     function(modal){},
		onHide:     function(modal){ modal.destroy(); },
		onCreate:   function(modal){},
		onDestroy:  function(modal){}
	});
	mymodal.show();