Build windows.
Copyright © 2007-2008 Greg Houston, http://greghoustondesign.com/.
MIT-style license.
Core.js
| Window.js | Build windows. |
| Classes | |
| Window | Creates a single MochaUI window. |
| Functions | |
| hideSpinner | Hides the spinner. |
| showSpinner | Shows the spinner. |
Creates a single MochaUI window.
new MochaUI.Window(options);
options
| id | The ID of the window. If not defined, it will be set to ‘win’ + windowIDCount. |
| title | The title of the window. |
| icon | Place an icon in the window’s titlebar. This is either set to false or to the url of the icon. It is set up for icons that are 16 x 16px. |
| type | (‘window’, ‘modal’, ‘modal2’, or ‘notification’) Defaults to ‘window’. |
| loadMethod | (‘html’, ‘xhr’, or ‘iframe’) Defaults to ‘html’. |
| contentURL | Used if loadMethod is set to ‘xhr’ or ‘iframe’. |
| closeAfter | Either false or time in milliseconds. Closes the window after a certain period of time in milliseconds. This is particularly useful for notifications. |
| evalScripts | (boolean) An xhr loadMethod option. Defaults to true. |
| evalResponse | (boolean) An xhr loadMethod option. Defaults to false. |
| content | (string or element) An html loadMethod option. |
| toolbar | (boolean) Create window toolbar. Defaults to false. This can be used for tabs, media controls, and so forth. |
| toolbarPosition | (‘top’ or ‘bottom’) Defaults to top. |
| toolbarHeight | (number) |
| toolbarURL | (url) Defaults to ‘pages/lipsum.html’. |
| toolbarContent | (string) |
| container | (element ID) Element the window is injected in. The container defaults to ‘desktop’. If no desktop then to document.body. Use ‘pageWrapper’ if you don’t want the windows to overlap the toolbars. |
| restrict | (boolean) Restrict window to container when dragging. |
| shape | (‘box’ or ‘gauge’) Shape of window. Defaults to ‘box’. |
| collapsible | (boolean) Defaults to true. |
| minimizable | (boolean) Requires MochaUI.Desktop and MochaUI.Dock. Defaults to true if dependenices are met. |
| maximizable | (boolean) Requires MochaUI.Desktop. Defaults to true if dependenices are met. |
| closable | (boolean) Defaults to true. |
| draggable | (boolean) Defaults to false for modals; otherwise true. |
| draggableGrid | (false or number) Distance in pixels for snap-to-grid dragging. Defaults to false. |
| draggableLimit | (false or number) An object with x and y properties used to limit the movement of the Window. Defaults to false. |
| draggableSnap | (boolean) The distance to drag before the Window starts to respond to the drag. Defaults to false. |
| resizable | (boolean) Defaults to false for modals, notifications and gauges; otherwise true. |
| resizeLimit | (object) Minimum and maximum width and height of window when resized. |
| addClass | (string) Add a class to the window for more control over styling. |
| width | (number) Width of content area. |
| height | (number) Height of content area. |
| x | (number) If x and y are left undefined the window is centered on the page. |
| y | (number) |
| scrollbars | (boolean) |
| padding | (object) |
| shadowBlur | (number) Width of shadows. |
| shadowOffset | Should be positive and not be greater than the ShadowBlur. |
| controlsOffset | Change this if you want to reposition the window controls. |
| useCanvas | (boolean) Set this to false if you don’t want a canvas body. |
| useCanvasControls | (boolean) Set this to false if you wish to use images for the buttons. |
| headerHeight | (number) Height of window titlebar. |
| footerHeight | (number) Height of window footer. |
| cornerRadius | (number) |
| contentBgColor | (hex) Body background color |
| headerStartColor | ([r,g,b,]) Titlebar gradient’s top color |
| headerStopColor | ([r,g,b,]) Titlebar gradient’s bottom color |
| bodyBgColor | ([r,g,b,]) Background color of the main canvas shape |
| minimizeBgColor | ([r,g,b,]) Minimize button background color |
| minimizeColor | ([r,g,b,]) Minimize button color |
| maximizeBgColor | ([r,g,b,]) Maximize button background color |
| maximizeColor | ([r,g,b,]) Maximize button color |
| closeBgColor | ([r,g,b,]) Close button background color |
| closeColor | ([r,g,b,]) Close button color |
| resizableColor | ([r,g,b,]) Resizable icon color |
| onBeforeBuild | (function) Fired just before the window is built. |
| onContentLoaded | (function) Fired when content is successfully loaded via XHR or Iframe. |
| onFocus | (function) Fired when the window is focused. |
| onBlur | (function) Fired when window loses focus. |
| onResize | (function) Fired when the window is resized. |
| onMinimize | (function) Fired when the window is minimized. |
| onMaximize | (function) Fired when the window is maximized. |
| onRestore | (function) Fired when a window is restored from minimized or maximized. |
| onClose | (function) Fired just before the window is closed. |
| onCloseComplete | (function) Fired after the window is closed. |
Window object.
Define a window. It is suggested you name the function the same as your window ID + “Window”.
var mywindowWindow = function(){
new MochaUI.Window({
id: 'mywindow',
title: 'My Window',
loadMethod: 'xhr',
contentURL: 'pages/lipsum.html',
width: 340,
height: 150
});
}Create window onDomReady.
window.addEvent('domready', function(){
mywindow();
});Add link events to build future windows. It is suggested you give your anchor the same ID as your window + “WindowLink” or + “WindowLinkCheck”. Use the latter if it is a link in the menu toolbar.
If you wish to add links in windows that open other windows remember to add events to those links when the windows are created.
// Javascript:
if ($('mywindowLink')){
$('mywindowLink').addEvent('click', function(e) {
new Event(e).stop();
mywindow();
});
}
// HTML:
<a id="mywindowLink" href="pages/lipsum.html">My Window</a>For content to load via xhr all the files must be online and in the same domain. If you need to load content from another domain or wish to have it work offline, load the content in an iframe instead of using the xhr option.
If you use the iframe loadMethod your iframe will automatically be resized when the window it is in is resized. If you want this same functionality when using one of the other load options simply add class=”mochaIframe” to those iframes and they will be resized for you as well.
Hides the spinner.
hideSpinner: function( spinner )
Shows the spinner.
showSpinner: function( spinner )