Who?
• Samuel Lebeau, http://i.gotfresh.info/
French student, JS/Rails developer, prototype contributor.
Change Class.extend to allow for superclass method resolution and remove Class.inherit. Closes
#9274. [Samuel Lebeau]
• Juriy Zaytsev (kangax), http://thinkweb2.com/
New York based JS developer, UI expert.
• Sébastien Gruhier, http://www.xilinus.com
PWC creator, creator of many prototype-based open-source projects.
• Vincent Le Moign, http://www.webalys.com
Designer.
Why?
• Prototype Window Class (PWC)
• Prototype Carousel
• Prototype Portal
• ...
• ‣And classcourse Prototype 1.6:
of
New architecture (true inheritance)
‣ New event model
‣ ...
How?
• Same license as Prototype (MIT).
• ‣Same approach as Prototype:
Subversion repository
‣ Functionals and unit tests
‣ Trac
‣ Core Team + contributions from community
How?
• Documentation (automatic with NaturalDocs)
that can be installed locally
• Full distrib file or per component (will be
available with first stable version)
• PackR integration (25Kb only)
• Active forum
Features
• Independent components
• Easy and fun to use
• Highly configurable
• Fully skinnable
• Coherent API and documentation
• Most of the methods are chainable
Components
• Core (Adds methods to String, Array, etc.)
• Window
• Carousel
• Shadow
• Dock (experimental)
• Context Menu (experimental)
Core
• Adds core level methods (DOM, String,
Array, etc. )
• UI.Option class to handle options of all
components easily.
Window
• Skinnable Design and Shadow
• Modal mode
• HTML and Ajax content
• All PWC options and more
Carousel
• Horizontal and Vertical
• Always 100% skinnable
Context Menu
• One more time: skinnable
• Uses Shadow class
Example
Let’s create a desktop behavior
Example
Some includes
<!-- Javascripts -->
<script src=\"../lib/prototype.js\" type=\"text/javascript\"></script>
<script src=\"../lib/effects.js\" type=\"text/javascript\"></script>
<script src=\"../dist/window.js\" type=\"text/javascript\"></script>
<!-- CSS -->
<link href=\"../themes/window/window.css\" rel=\"stylesheet\" type=\"text/css\">
<link href=\"../themes/window/mac_os_x.css\" rel=\"stylesheet\" type=\"text/css\">
<link href=\"../themes/shadow/mac_shadow.css\" rel=\"stylesheet\" type=\"text/css\">
1
And 3 line of Javascript code!
<body>
URL: <input type=\"text\" id=\"url\"/>
<input type=\"button\" value=\"open\" onclick=\"openWindow()\"/>
<script type=\"text/javascript\">
function openWindow() {
new UI.URLWindow({url: $F('url'), theme: \"mac_os_x\", shadow:true}).setHeader(url).show().focus();
}
</script>
</body>
Example
Simplify creation code by using Option class
function openWindow() {
new UI.URLWindow({url: $F('url'), theme: \"mac_os_x\", shadow: true}).setHeader(url).show().focus();
}
UI.Window.setOptions({theme: \"mac_os_x\",
shadow: true,
top: 40,
left: 100,
width: 700,
height: 400 });
function openWindow() {
new UI.URLWindow({url: $F('url')}).setHeader(url).show().focus();
}
Example
Let’s create an desktop icon when closing a window
Example
Add action on hide
• Let's change default closing behavior from destroy to hide
UI.Window.setOptions({theme: \"mac_os_x\",
shadow: true,
top: 40,
left: 100,
width: 700,
height: 400,
close: \"hide\"
});
• And add an event when a window is hidden
function openWindow() {
var win = new UI.URLWindow({url: $F('url')}).setHeader(url).show().focus();
win.observe(\"hidden\", hideWindow);
}
Example
Now the hideWindow function
function hideWindow(data) {
var win = data.memo.window;
// Create a icon on desktop
var icon = new Element(\"div\", {className: \"icon\"}).update(win.header.innerHTML);
icon.observe(\"dblclick\", function(){
win.show();
icon.remove();
});
document.body.appendChild(icon);
}
And some CSS for icon
.icon {
position: absolute;
top: 40px;
left: 20px;
background: url(\"safari.png\") no-repeat top center;
width: 128px;
height: 64px;
text-align:center;
padding-top: 64px;
font-size: 12px;
}
Full sample with icon dragging
UI.Window.setOptions({theme: \"mac_os_x\", shadow: true, width: 700, height: 400, close: \"hide\"});
var windowPosition = {top: 40, left: 100};
function hideWindow(data) {
var win = data.memo.window;
if (win.icon)
win.icon.show();
else {
var pos = win.getPosition();
// Create a icon on desktop at window position
var style = 'top: #{top}px; left:#{left}px'.interpolate(pos);
var icon = new Element(\"div\", {className: \"icon\", style: style})
icon.update(win.header.innerHTML);
// Observe double click to hide icon and show window
icon.observe(\"dblclick\", function(){
win.show();
icon.hide();
});
new Draggable(icon);
document.body.appendChild(icon);
win.icon = icon;
}
}
function openWindow() {
var win = new UI.URLWindow(Object.extend({url: $F('url')}, windowPosition)).setHeader(url).show().focus();
win.observe(\"hidden\", hideWindow);
windowPosition.top += 40;
windowPosition.left += 40;
}
Next
• Stable version
• More tests, more documentation and more
demos
• Custom builds
• Dialog class
• New components (portal, layout manager,
tooltips ...)
• Questions?
• And see you soon on http://prototype-ui.com
0 comments
Post a comment