Javelin Documentation
Javelin Documentation
Documentation for JavaScript developers using Javelin.
Introduction
Introduction
Concepts
Concepts
Free Radicals
Free Radicals
JX.$()FunctionSelect an element by its "id" attribute, like ##document.getElementById()##.
For example:JX.$A()FunctionConvert an array-like object (usually ##arguments##) into a real Array. An
"array-like object" is something with a ##length## property and numerical
keys. The most common use for this is to let you call Array functions on the
magical ##arguments## object.JX.$AX()FunctionCast a value into an array, by wrapping scalars into singletons. If the
argument is an array, it is returned unmodified. If it is a scalar, an array
with a single element is returned. For example:JX.$E()FunctionThrow an exception and attach the caller data in the exception.JX.$H()FunctionBuild a new HTML object from a trustworthy string. JX.$H is a shortcut for
creating new JX.HTML instances.JX.$N()FunctionCreate a new DOM node with attributes and content.JX.$U()FunctionHandy convenience function that returns a @{class:JX.URI} instance. This
allows you to write things like:JX.$V()FunctionConvenience function that returns a @{class:JX.Vector} instance. This allows
you to concisely write things like:JX.__rawEventQueue()FunctionJX.__simulate()FunctionJX.bag()Function"Bag of holding"; function that does nothing. Primarily, it's used as a
placeholder when you want something to be callable but don't want it to
actually have an effect.JX.BaseClassThis is not a real class, but @{function:JX.install} provides several methods
which exist on all Javelin classes. This class documents those methods.JX.behavior()FunctionDefine a Javelin behavior, which holds glue code in a structured way. See
@{article:Concepts: Behaviors} for a detailed description of Javelin
behaviors.JX.bind()FunctionCreate a function which invokes another function with a bound context and
arguments (i.e., partial function application) when called; king of all
functions.JX.ColorClassJX.CookieClassJX.copy()FunctionCopy properties from one object to another. If properties already exist, they
are overwritten.JX.createClass()FunctionCreates a class from a map of attributes. Requires ##extend## property to
be an actual Class object and not a "String". Supports ##name## property
to give the created Class a readable name.JX.DOMClassQuery and update the DOM. Everything here is static, this is essentially
a collection of common utility functions.JX.DynValClassJX.enableDispatch()FunctionJX.EventClassA generic event, routed by @{class:JX.Stratcom}. All events within Javelin
are represented by a @{class:JX.Event}, regardless of whether they originate
from a native DOM event (like a mouse click) or are custom application
events.JX.flushHoldingQueue()FunctionJX.FXClassJX.HistoryClassJX.History provides a stable interface for managing the browser's history
stack. Whenever the history stack mutates, the "history:change" event is
invoked via JX.Stratcom.JX.HTMLClassUpcast a string into an HTML object so it is treated as markup instead of
plain text. See @{JX.$N} for discussion of Javelin's security model. Every
time you call this function you potentially open up a security hole. Avoid
its use wherever possible.JX.HTMLViewClassJX.id()FunctionIdentity function; returns the argument unmodified. This is primarily useful
as a placeholder for some callback which may transform its argument.JX.initBehaviors()FunctionExecute previously defined Javelin behaviors, running the glue code they
contain to glue stuff together. See @{article:Concepts: Behaviors} for more
information on Javelin behaviors.JX.install()FunctionInstall a class into the Javelin ("JX") namespace. The first argument is the
name of the class you want to install, and the second is a map of these
attributes (all of which are optional):JX.isArray()FunctionChecks whether a value is an array.JX.JSONClassJSON serializer and parser. This class uses the native JSON parser if it is
available; if not, it provides an eval-based parser and a simple serializer.JX.keys()FunctionConvert an object's keys into a list. For example:JX.LeaderClassSynchronize multiple tabs over LocalStorage.JX.log()FunctionPrint a message to the browser debugging console (like Firebug).JX.MaskClassShow a "mask" over the page for lightboxes or dialogs. This is used by
Workflow to draw visual attention to modal dialogs.JX.name()FunctionJX.onload()FunctionJX.onload()FunctionRegister a callback for invocation after DOMContentReady.JX.onload()FunctionJX.QuicksandClassSink into a hopeless, cold mire of limitless depth from which there is
no escape.JX.RDOMClassJX.ReactorClassJX.ReactorNodeClassJX.ReactorNodeCalmerClassJX.RequestClassMake basic AJAX XMLHTTPRequests.JX.require()FunctionJX.ResourceClassJX.RoutableClassJX.RouterClassRoute requests. Primarily, this class provides a quality-of-service
priority queue so large numbers of background loading tasks don't block
interactive requests.JX.ScrollbarClassProvides an aesthetic scrollbar.JX.SoundClassJX.sprintf()FunctionJX.StratcomClassJavelin strategic command, the master event delegation core. This class is
a sort of hybrid between Arbiter and traditional event delegation, and
serves to route event information to handlers in a general way.JX.TokenizerClassA tokenizer is a UI component similar to a text input, except that it
allows the user to input a list of items ("tokens"), generally from a fixed
set of results. A familiar example of this UI is the "To:" field of most
email clients, where the control autocompletes addresses from the user's
address book.JX.TypeaheadClassA typeahead is a UI component similar to a text input, except that it
suggests some set of results (like friends' names, common searches, or
repository paths) as the user types them. Familiar examples of this UI
include Google Suggest, the Facebook search box, and OS X's Spotlight
feature.JX.TypeaheadCompositeSourceClassJX.TypeaheadNormalizerClassJX.TypeaheadOnDemandSourceClassJX.TypeaheadPreloadedSourceClassSimple datasource that loads all possible results from a single call to a
URI. This is appropriate if the total data size is small (up to perhaps a
few thousand items). If you have more items so you can't ship them down to
the client in one repsonse, use @{JX.TypeaheadOnDemandSource}.JX.TypeaheadSourceClassJX.TypeaheadStaticSourceClassTypeahead source that uses static data passed to the constructor. For larger
datasets, use @{class:JX.TypeaheadPreloadedSource} or
@{class:JX.TypeaheadOnDemandSource} to improve performance.JX.URIClassConvert a string URI into a maleable object.JX.VectorClassQuery and update positions and dimensions of nodes (and other things) within
within a document. Each vector has two elements, 'x' and 'y', which usually
represent width/height ('dimension vector') or left/top ('position vector').JX.ViewClassJX.ViewInterpreterClassJX.ViewPlaceholderClassJX.ViewRendererClassJX.ViewVisitorClassJX.WebSocketClassWraps a WebSocket.JX.WorkflowClass