EXPLAINERS Getting Started

1. Introduction

This document takes you step by step through the process of setting up a Web project to use the UIZE JavaScript Framework. "Hello, world" awaits you.

2. Download UIZE

If you haven't already downloaded the zip archive of the UIZE Web site, DOWNLOAD IT NOW.

Once you've downloaded the zip archive, come back to this page and continue on with the rest of the instructions.

3. Join the Online Users' Group

You may want to consider joining the UIZE JavaScript Framework Group, so you can ask other developers questions as you start using the UIZE JavaScript Framework.

The official UIZE JavaScript Framework Group is the place where developers can discuss ways that they're using UIZE in their own projects. Join up so you can get support, give support, learn tips and tricks, show off your cool projects built on UIZE, and generally get involved in the discussion on all things UIZE. JOIN NOW

4. Unzip the Archive

Locate the uize.zip archive file that you downloaded (probably on your desktop) and unzip it (probably by double-clicking on it).

Extract the contents of the uize.zip archive to your desktop, or any other desired location. You'll end up with a UIZE-JavaScript-Framework folder that contains a local copy of the uize.com Web site.

5. Copy the JavaScript Files

To use UIZE in a Web site project, you should copy the js folder from the UIZE-JavaScript-Framework folder to a desired location in your project's folder.

5.1. What If I Already Have a "js" Folder?

If you already have a folder named "js" and don't wish to interfere with its contents, you can choose to copy the UIZE-JavaScript-Framework folder's "js" folder to your Web site project under a different name, like "uize_js" or whatever makes the most sense for you.

NOTE

This folder doesn't have to be the folder where ALL the JavaScript files for your site live, but it must be the folder where all JavaScript modules built around the UIZE JavaScript Framework live - so the various Uize.* modules, and any UIZE-powered modules that you write specifically for your site.

6. Get the Test Page Running

Now that you've copied over the necessary JavaScript files, you're ready to get the special test page running in your own Web site project.

6.1. Copy the Page

The test page is named HELLO-WORLD.html and is located at the root of the UIZE-JavaScript-Framework folder.

Copy this file over to the root of your own Web site project's main folder.

6.2. Modify the Script Tag, If Necessary

If you didn't copy the UIZE JavaScript modules as the folder "js" in the root folder of your project, but instead named it something else or located it somewhere else in your project's folder structure, then you should edit the script tag that sources in the Uize.js file (in your version of the HELLO-WORLD.html file, of course) so that it points to the correct location.

EDIT THIS LINE, IF NECESSARY

<script type="text/javascript src="js/Uize.js"></script>

NOTE: The script tag is located inside the head of the test page.

6.3. Test the Page

When you're happy that your version of the HELLO-WORLD.html file is pulling in the JavaScript from the correct location, load the page in your Web browser and confirm that it works.

When the page loads in, the text "HELLO,WORLD!" should fade in, and then an effect should animate the color and size of the letters from left to right. If this works, for you, then you've successfully set up the UIZE JavaScript Framework. Congratulations! That wasn't too hard.

NOTES

If your test page doesn't animate as it should, check that your path to the Uize.js file is correct.
To see how the page should behave, you can view the original HELLO-WORLD.html.
If you're using Internet Explorer, you may need to select the option to "Allow Blocked Content..." from the security warning bar that might appear at the top of the browser window.

7. Start Hacking

The many example pages, documentation pages, explainers, and other pages of this Web site all use the UIZE JavaScript Framework to some degree or another - some of them only minimally, and others quite extensively.

By far the most heavily UIZE'd pages are the example pages, while the documentation pages typically just wire up a tree widget for their contents list. The example pages are fair game for hacking, since they show off features that may be compelling for your own projects and provide working examples of the use of various features and widgets.

7.1. Hacking the Examples

To hack the example pages, you can either hack them inside the UIZE-JavaScript-Framework/examples folder, or you can copy the files over to your own Web site project.

7.1.1. Hacking In Situ

Hacking the example pages inside the UIZE-JavaScript-Framework/examples folder is easy and convenient.

If you just want to experiment in order to gain an understanding of how things work, or play around with the settings for some widget, then hacking the example pages inside the UIZE-JavaScript-Framework/examples folder will be easier, since the pages are already set up to utilize assets and CSS from the UIZE Web site project.

7.1.2. Hacking Copies

If you want to use an example page as a starting point for a page in your own Web site project, then you can copy the example over and start hacking.

In this case, you'll need to follow the few steps below...

7.1.2.1. Modify the Script Tag

In your copy of the example page, make sure that the Uize.js file is being sourced in correctly, taking into account both the location of the copied JavaScript files and the location of the example file in your site's folder structure.

EDIT THIS LINE

<script type="text/javascript src="../js/Uize.js"></script>

7.1.2.2. Kill the .library File Reference

The example pages in the UIZE-JavaScript-Framework/examples folder use a JavaScript library file called UizeSite.Page.Example.library.

This is a library file that is specific to the UIZE Web site, and that bundles a bunch of the commonly required JavaScript modules into a single file to reduce HTTP requests and improve page load performance. Eventually, you can make these library files for your own Web site, but for the time being it is not necessary to use the UIZE Web site's version. The example pages will still function correctly without this optimization.

To remove the reference, just do a text search for "UizeSite.Page.Example.library" and then remove the entire entry in the required block, including the quotes and comma, as shown in the example below...

INSTEAD OF...

... ... ...
required:[
  'UizeSite.Page.Example.library',  // <-- DELETE THIS LINE
  'UizeSite.Page.Example',
  ...,
  ...,
  ...
],
... ... ...

USE...

... ... ...
required:[
  'UizeSite.Page.Example',
  ...,
  ...,
  ...
],
... ... ...

7.1.2.3. Use the Plain Vanilla Page Widget

The example pages in the UIZE-JavaScript-Framework/examples folder use the page widget class UizeSite.Page.Example.

This page widget class is a subclass of the plain vanilla page widget class Uize.Widget.Page, and is specific to the UIZE Web site. To change this, just do a text search for "UizeSite.Page.Example" and replace it with "Uize.Widget.Page". To illustrate how the required block will change, consider the following example...

INSTEAD OF...

... ... ...
required:[
  'UizeSite.Page.Example',  // <-- CHANGE THIS LINE
  ...,
  ...,
  ...
],
... ... ...

USE...

... ... ...
required:[
  'Uize.Widget.Page',
  ...,
  ...,
  ...
],
... ... ...

7.1.2.4. Remove Constructor Argument

When switching to using the plain vanilla page widget class, you should remove the constructor argument, if there is one.

Some example pages have the constructor argument {evaluator:function (code) {eval (code)}}. The evaluator property is specific to the UizeSite.Page.Example class and doesn't exist in the Uize.Widget.Page class. You don't need this and you should remove it from the parentheses.

Consider the following example...

INSTEAD OF...

var page = window.page =
  UizeSite.Page.Example ({evaluator:function (code) {eval (code)}})
;

USE...

var page = window.page = Uize.Widget.Page ();

7.1.2.5. CSS, Assets, JavaScript

Realize that the example pages use CSS and assets contained inside the UIZE-JavaScript-Framework folder.

You'll either have to copy those over, or otherwise massage your copies of the example pages so that they use your own CSS and assets. Also, some example pages use JavaScript code that is specific to the UIZE Web site, such as compiled JavaScript templates used for generating HTML for widgets, or JavaScript files that define test data to drive some of the examples.

7.1.3. Switch to Using Source JavaScript

Regardless of whether you hack the example pages inside the UIZE-JavaScript-Framework/examples folder or create your own copies of them in your Web site project, it will be useful to switch the pages over to using the source versions of the JavaScript files.

Fortunately, this is very easy to do. All the source JavaScript files are located in the ~source subfolder inside the JavaScript folder. Simply locate the script tag in the HTML that sources in the Uize.js file and add in the subfolder ~source, right after the name of the folder that contains the JavaScript files.

INSTEAD OF...

<script type="text/javascript src="../js/Uize.js"></script>

USE...

<script type="text/javascript src="../js/~source/Uize.js"></script>

The folder from which you load the Uize.js file will be the folder from which all other dynamically loaded modules will be loaded. You'll want to do most of your development and troubleshooting using the source files, and then switch over to using scrunched JavaScript when your UIZE'd pages are pushed live.

8. Setting Up the Build Scripts

The UIZE JavaScript Framework provides a number of convenient build scripts that will ease tasks like scrunching (aka compressing or minifying) JavaScript files.

These build scripts run using Windows Script Host and must therefore be run on a Windows machine. The good news is that no software needs to be installed for developers with access to a Windows machine on which to run the scripts. The bad news is that Mac and Linux are not currently supported by the build scripts. The build scripts are the only aspect of the framework requiring Windows.

Assuming you can access a Windows machine for running the scripts, even if Windows is not your regular development environment, setting up the build scripts is quite easy.

1. copy all the files with the prefix "_build" from the UIZE-JavaScript-Framework folder to the root folder of your Web site
2. then, crack open your version of the file _build-env.json and edit the value of the moduleFolderPath build environment variable, if necessary, to point to the folder where you copied the JavaScript files
3. you may also want to edit the value of the doNotEnter build environment variable at some point, but it's not essential at first

Most likely you'll be interested in the _build-scrunched.js build script. Double-clicking on this file in Windows should run this build script and a log file should be created. For a more in-depth discussion of the various build scripts and tips on different configuration settings, consult the explainer JavaScript Build Scripts.

9. Removing Unnecessary JavaScript Files

There are some JavaScript files that you can remove from your "js" folder, if you wish to tidy things up a bit.

In an earlier step you copied the UIZE-JavaScript-Framework folder's "js" folder to your Web site project. Now, because this folder is used by the UIZE Web site, it contains a number of JavaScript modules that are specific to UIZE Web site. You don't need these modules for your own Web site project, since they are not part of the framework, per se. These modules are the ones under the UizeSite namespace. You can delete all the JavaScript files prefixed with "UizeSite" (eg. UizeSite.Page.js) from the "js" folder that you copied over, and from the "~source" folder inside the "js" folder. You don't need the source or the scrunched versions of these files.

A PACKAGE DEAL

Beyond the obviously unnecessary UizeSite files, there are likely to be a bunch of framework JavaScript files that you won't end up using, but it might be more bother than it's worth trying to whittle down the contents of the "js" folder any further, and you might remove some files that you end up wanting later on, or you might accidentally remove some files that you don't think you'll need but actually will. If server space is a major concern, you can try to handpick just what you need, but that won't be fun.

10. Getting Support

As mentioned earlier, you can get support by joining the official UIZE JavaScript Framework Group.

And for additional support tips, consult the SUPPORT page.

11. What Next?

Now that you have successfully installed the UIZE JavaScript Framework and set up a Web site project to use it, you will want to learn more about the many feature areas of the framework and how you might use different parts of its large feature set in your own projects.

To get an overview of the functionality of the UIZE JavaScript Framework, consult the explainer Overview of Features.