Mydows Javascript Window Library


Mydows is a small library of javascript functions that sit above the Prototype Javascript library and aid in the creation and management of free floating windows contained within the webpage. Mydows will also work with the Scriptaculous library for added features.

Mydows is free to use and is released under the MIT license.
mydows.js v.0.2
Default img directory

Setting it up

First, download prototype.js, then download mydows.js. Include them as you would any Javascript file, making sure to call mydows_init(); before attempting to open any new mydows. You'll also need to download a copy of the default img directory, unzip it and place it in the directory with your webpage.

<script src="prototype.js"></script>
<script src="mydows.js"></script>>
...
window.load=function() {
	mydows_init();
	}

Your first window

function first_window() {
	show_close_button=1;
	show_maximize_button=1;
	var w= new_mydow("My Window");
	$(w.statbar).update("Some helpful information");
	$(w.body).update (
		"<h3>The following hash was returned</h3>" +
		"<ul>"+
		"<li>handle: '"+w.handle+"'</li>"+
		"<li>frame: '"+w.frame+"'</li>"+
		"<li>body: '"+w.body+"'</li>"+
		"<li>title: '"+w.title+"'</li>"+
		"<li>title_msg: '"+w.title_msg+"'</li>"+
		"<li>statbar: '"+w.statbar+"'</li>"+
		"</ul>"
		);
	}

new_mydow() generates and inserts all of the critical parts of a window, and returns a hash of values that represent each elements id. In addition to this the mydows global hash is updated to contain the handle as a key and a hash of runtime information as its value. Click for an Example.

More control over your windows

function more_control() {
	show_close_button=0;
	show_maximize_button=0;
	new_mydow("More Control");
	}
...
mydow_set_position('More Control',200,500,300,200);
...
kill_mydow('More Control');

Try opening, resizing, or closing the window.

Brutally easy Ajax

function easy_ajax() {
	show_close_button=1;
	show_maximize_button=0;
	mydow_default_w=427;
	mydow_default_h=386;
	var w=new_mydow("Tux in an orb");
	mydow_load(w.handle, "ajax_example.php");
	}

Try it out: Example.

Advanced effects

<script src="scriptaculous.js"></script>
...
Effect.SlideUp(mydow.frame);
...
kill_mydow(mydow.handle);

Mydows is a minimalist library, it tries to provide the minimum amount of functionality needed to manage windows within a webpage. Because of this it mixes well with using the prototype and scriptaculous APIs.

Copyright 2008 Patrick Avella