require({cache:{
'dijit/registry':function(){
define([
"dojo/_base/array", // array.forEach array.map
"dojo/_base/window", // win.body
"./main" // dijit._scopeName
], function(array, win, dijit){
// module:
// dijit/registry
var _widgetTypeCtr = {}, hash = {};
var registry = {
// summary:
// Registry of existing widget on page, plus some utility methods.
// length: Number
// Number of registered widgets
length: 0,
add: function(widget){
// summary:
// Add a widget to the registry. If a duplicate ID is detected, a error is thrown.
// widget: dijit/_WidgetBase
// Any dijit/_WidgetBase subclass.
if(hash[widget.id]){
throw new Error("Tried to register widget with id==" + widget.id + " but that id is already registered");
}
hash[widget.id] = widget;
this.length++;
},
remove: function(/*String*/ id){
// summary:
// Remove a widget from the registry. Does not destroy the widget; simply
// removes the reference.
if(hash[id]){
delete hash[id];
this.length--;
}
},
byId: function(/*String|Widget*/ id){
// summary:
// Find a widget by it's id.
// If passed a widget then just returns the widget.
return typeof id == "string" ? hash[id] : id; // dijit/_WidgetBase
},
byNode: function(/*DOMNode*/ node){
// summary:
// Returns the widget corresponding to the given DOMNode
return hash[node.getAttribute("widgetId")]; // dijit/_WidgetBase
},
toArray: function(){
// summary:
// Convert registry into a true Array
//
// example:
// Work with the widget .domNodes in a real Array
// | array.map(registry.toArray(), function(w){ return w.domNode; });
var ar = [];
for(var id in hash){
ar.push(hash[id]);
}
return ar; // dijit/_WidgetBase[]
},
getUniqueId: function(/*String*/widgetType){
// summary:
// Generates a unique id for a given widgetType
var id;
do{
id = widgetType + "_" +
(widgetType in _widgetTypeCtr ?
++_widgetTypeCtr[widgetType] : _widgetTypeCtr[widgetType] = 0);
}while(hash[id]);
return dijit._scopeName == "dijit" ? id : dijit._scopeName + "_" + id; // String
},
findWidgets: function(root, skipNode){
// summary:
// Search subtree under root returning widgets found.
// Doesn't search for nested widgets (ie, widgets inside other widgets).
// root: DOMNode
// Node to search under.
// skipNode: DOMNode
// If specified, don't search beneath this node (usually containerNode).
var outAry = [];
function getChildrenHelper(root){
for(var node = root.firstChild; node; node = node.nextSibling){
if(node.nodeType == 1){
var widgetId = node.getAttribute("widgetId");
if(widgetId){
var widget = hash[widgetId];
if(widget){ // may be null on page w/multiple dojo's loaded
outAry.push(widget);
}
}else if(node !== skipNode){
getChildrenHelper(node);
}
}
}
}
getChildrenHelper(root);
return outAry;
},
_destroyAll: function(){
// summary:
// Code to destroy all widgets and do other cleanup on page unload
// Clean up focus manager lingering references to widgets and nodes
dijit._curFocus = null;
dijit._prevFocus = null;
dijit._activeStack = [];
// Destroy all the widgets, top down
array.forEach(registry.findWidgets(win.body()), function(widget){
// Avoid double destroy of widgets like Menu that are attached to
// even though they are logically children of other widgets.
if(!widget._destroyed){
if(widget.destroyRecursive){
widget.destroyRecursive();
}else if(widget.destroy){
widget.destroy();
}
}
});
},
getEnclosingWidget: function(/*DOMNode*/ node){
// summary:
// Returns the widget whose DOM tree contains the specified DOMNode, or null if
// the node is not contained within the DOM tree of any widget
while(node){
var id = node.nodeType == 1 && node.getAttribute("widgetId");
if(id){
return hash[id];
}
node = node.parentNode;
}
return null;
},
// In case someone needs to access hash.
// Actually, this is accessed from WidgetSet back-compatibility code
_hash: hash
};
dijit.registry = registry;
return registry;
});
},
'dijit/main':function(){
define([
"dojo/_base/kernel"
], function(dojo){
// module:
// dijit/main
/*=====
return {
// summary:
// The dijit package main module.
// Deprecated. Users should access individual modules (ex: dijit/registry) directly.
};
=====*/
return dojo.dijit;
});
},
'dojox/mobile/ListItem':function(){
define([
"dojo/_base/array",
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/dom-class",
"dojo/dom-construct",
"dojo/dom-style",
"dojo/dom-attr",
"dijit/registry",
"dijit/_WidgetBase",
"./iconUtils",
"./_ItemBase",
"./ProgressIndicator",
"dojo/has",
"dojo/has!dojo-bidi?dojox/mobile/bidi/ListItem"
], function(array, declare, lang, domClass, domConstruct, domStyle, domAttr, registry, WidgetBase, iconUtils, ItemBase, ProgressIndicator, has, BidiListItem){
// module:
// dojox/mobile/ListItem
var ListItem = declare(has("dojo-bidi") ? "dojox.mobile.NonBidiListItem" : "dojox.mobile.ListItem", ItemBase, {
// summary:
// An item of either RoundRectList or EdgeToEdgeList.
// description:
// ListItem represents an item of either RoundRectList or
// EdgeToEdgeList. There are three ways to move to a different view:
// moveTo, href, and url. You can choose only one of them.
//
// A child DOM node (or widget) can have the layout attribute,
// whose value is "left", "right", or "center". Such nodes will be
// aligned as specified.
// example:
// |
// |
Left Node
// |
Right Node
// |
Center Node
// |
//
// Similarly, a child widget can have the preventTouch
// attribute, whose value is a boolean (or data-mobile-prevent-touch
// for children which are not widgets), such that touching such
// child doesn't trigger the item action.
//
// Note that even if you specify variableHeight="true" for the list
// and place a tall object inside the layout node as in the example
// below, the layout node does not expand as you may expect,
// because layout node is aligned using float:left, float:right, or
// position:absolute.
// example:
// |
// |
// |
// rightText: String
// A right-aligned text to display on the item.
rightText: "",
// rightIcon: String
// An icon to display at the right hand side of the item. The value
// can be either a path for an image file or a class name of a DOM
// button.
rightIcon: "",
// rightIcon2: String
// An icon to display at the left of the rightIcon. The value can
// be either a path for an image file or a class name of a DOM
// button.
rightIcon2: "",
// deleteIcon: String
// A delete icon to display at the left of the item. The value can
// be either a path for an image file or a class name of a DOM
// button.
deleteIcon: "",
// anchorLabel: Boolean
// If true, the label text becomes a clickable anchor text. When
// the user clicks on the text, the onAnchorLabelClicked handler is
// called. You can override or connect to the handler and implement
// any action. The handler has no default action.
anchorLabel: false,
// noArrow: Boolean
// If true, the right hand side arrow is not displayed.
noArrow: false,
// checked: Boolean
// If true, a check mark is displayed at the right of the item.
checked: false,
// arrowClass: String
// An icon to display as an arrow. The value can be either a path
// for an image file or a class name of a DOM button.
arrowClass: "",
// checkClass: String
// An icon to display as a check mark. The value can be either a
// path for an image file or a class name of a DOM button.
checkClass: "",
// uncheckClass: String
// An icon to display as an uncheck mark. The value can be either a
// path for an image file or a class name of a DOM button.
uncheckClass: "",
// variableHeight: Boolean
// If true, the height of the item varies according to its content.
variableHeight: false,
// rightIconTitle: String
// An alt text for the right icon.
rightIconTitle: "",
// rightIcon2Title: String
// An alt text for the right icon2.
rightIcon2Title: "",
// header: Boolean
// If true, this item is rendered as a category header.
header: false,
// tag: String
// A name of html tag to create as domNode.
tag: "li",
// busy: Boolean
// If true, a progress indicator spins.
busy: false,
// progStyle: String
// A css class name to add to the progress indicator.
progStyle: "",
// layoutOnResize: Boolean
// If true, a call to resize() will force computation of variable height items layout. You should not need this as in most
// cases ListItem height doesn't change on container resize. Depending on number and complexity
// of items in a view, setting to true may have a high impact on performance.
layoutOnResize: false,
/* internal properties */
// The following properties are overrides of those in _ItemBase.
paramsToInherit: "variableHeight,transition,deleteIcon,icon,rightIcon,rightIcon2,uncheckIcon,arrowClass,checkClass,uncheckClass,deleteIconTitle,deleteIconRole",
baseClass: "mblListItem",
_selStartMethod: "touch",
_selEndMethod: "timer",
_delayedSelection: true,
_selClass: "mblListItemSelected",
buildRendering: function(){
this._templated = !!this.templateString; // true if this widget is templated
if(!this._templated){
// Create root node if it wasn't created by _TemplatedMixin
this.domNode = this.containerNode = this.srcNodeRef || domConstruct.create(this.tag);
}
this.inherited(arguments);
if(this.selected){
domClass.add(this.domNode, this._selClass);
}
if(this.header){
domClass.replace(this.domNode, "mblEdgeToEdgeCategory", this.baseClass);
}
if(!this._templated){
this.labelNode =
domConstruct.create("div", {className:"mblListItemLabel"});
var ref = this.srcNodeRef;
if(ref && ref.childNodes.length === 1 && ref.firstChild.nodeType === 3){
// if ref has only one text node, regard it as a label
this.labelNode.appendChild(ref.firstChild);
}
this.domNode.appendChild(this.labelNode);
}
this._layoutChildren = [];
},
startup: function(){
if(this._started){ return; }
var parent = this.getParent();
var opts = this.getTransOpts();
// When using a template, labelNode may be created via an attach point.
// The attach points are not yet set when ListItem.buildRendering()
// executes, hence the need to use them in startup().
if((!this._templated || this.labelNode) && this.anchorLabel){
this.labelNode.style.display = "inline"; // to narrow the text region
this.labelNode.style.cursor = "pointer";
this.connect(this.labelNode, "onclick", "_onClick");
this.onTouchStart = function(e){
return (e.target !== this.labelNode);
};
}
this.inherited(arguments);
if(domClass.contains(this.domNode, "mblVariableHeight")){
this.variableHeight = true;
}
if(this.variableHeight){
domClass.add(this.domNode, "mblVariableHeight");
this.defer("layoutVariableHeight");
}
if(!this._isOnLine){
this._isOnLine = true;
this.set({
// retry applying the attributes for which the custom setter delays the actual
// work until _isOnLine is true
icon: this._pending_icon !== undefined ? this._pending_icon : this.icon,
deleteIcon: this._pending_deleteIcon !== undefined ? this._pending_deleteIcon : this.deleteIcon,
rightIcon: this._pending_rightIcon !== undefined ? this._pending_rightIcon : this.rightIcon,
rightIcon2: this._pending_rightIcon2 !== undefined ? this._pending_rightIcon2 : this.rightIcon2,
uncheckIcon: this._pending_uncheckIcon !== undefined ? this._pending_uncheckIcon : this.uncheckIcon
});
// Not needed anymore (this code executes only once per life cycle):
delete this._pending_icon;
delete this._pending_deleteIcon;
delete this._pending_rightIcon;
delete this._pending_rightIcon2;
delete this._pending_uncheckIcon;
}
if(parent && parent.select){
// retry applying the attributes for which the custom setter delays the actual
// work until _isOnLine is true.
this.set("checked", this._pendingChecked !== undefined ? this._pendingChecked : this.checked);
domAttr.set(this.domNode, "role", "option");
if(this._pendingChecked || this.checked){
domAttr.set(this.domNode, "aria-selected", "true");
}
// Not needed anymore (this code executes only once per life cycle):
delete this._pendingChecked;
}
this.setArrow();
this.layoutChildren();
},
_updateHandles: function(){
// tags:
// private
var parent = this.getParent();
var opts = this.getTransOpts();
if(opts.moveTo || opts.href || opts.url || this.clickable || (parent && parent.select)){
if(!this._keydownHandle){
this._keydownHandle = this.connect(this.domNode, "onkeydown", "_onClick"); // for desktop browsers
}
this._handleClick = true;
}else{
if(this._keydownHandle){
this.disconnect(this._keydownHandle);
this._keydownHandle = null;
}
this._handleClick = false;
}
this.inherited(arguments);
},
layoutChildren: function(){
var centerNode;
array.forEach(this.domNode.childNodes, function(n){
if(n.nodeType !== 1){ return; }
var layout = n.getAttribute("layout") || // TODO: Remove the non-HTML5-compliant attribute in 2.0
n.getAttribute("data-mobile-layout") ||
(registry.byNode(n) || {}).layout;
if(layout){
domClass.add(n, "mblListItemLayout" +
layout.charAt(0).toUpperCase() + layout.substring(1));
this._layoutChildren.push(n);
if(layout === "center"){ centerNode = n; }
}
}, this);
if(centerNode){
this.domNode.insertBefore(centerNode, this.domNode.firstChild);
}
},
resize: function(){
if(this.layoutOnResize && this.variableHeight){
this.layoutVariableHeight();
}
// labelNode may not exist only when using a template (if not created by an attach point)
if(!this._templated || this.labelNode){
// If labelNode is empty, shrink it so as not to prevent user clicks.
this.labelNode.style.display = this.labelNode.firstChild ? "block" : "inline";
}
},
_onTouchStart: function(e){
// tags:
// private
if(e.target.getAttribute("preventTouch") || // TODO: Remove the non-HTML5-compliant attribute in 2.0
e.target.getAttribute("data-mobile-prevent-touch") ||
(registry.getEnclosingWidget(e.target) || {}).preventTouch){
return;
}
this.inherited(arguments);
},
_onClick: function(e){
// summary:
// Internal handler for click events.
// tags:
// private
if(this.getParent().isEditing || e && e.type === "keydown" && e.keyCode !== 13){ return; }
if(this.onClick(e) === false){ return; } // user's click action
var n = this.labelNode;
// labelNode may not exist only when using a template
if((this._templated || n) && this.anchorLabel && e.currentTarget === n){
domClass.add(n, "mblListItemLabelSelected");
this.defer(function(){
domClass.remove(n, "mblListItemLabelSelected");
}, this._duration);
this.onAnchorLabelClicked(e);
return;
}
var parent = this.getParent();
if(parent.select){
if(parent.select === "single"){
if(!this.checked){
this.set("checked", true);
}
}else if(parent.select === "multiple"){
this.set("checked", !this.checked);
}
}
this.defaultClickAction(e);
},
onClick: function(/*Event*/ /*===== e =====*/){
// summary:
// User-defined function to handle clicks.
// tags:
// callback
},
onAnchorLabelClicked: function(e){
// summary:
// Stub function to connect to from your application.
},
layoutVariableHeight: function(){
// summary:
// Lays out the current item with variable height.
var h = this.domNode.offsetHeight;
if(h === this.domNodeHeight){ return; }
this.domNodeHeight = h;
array.forEach(this._layoutChildren.concat([
this.rightTextNode,
this.rightIcon2Node,
this.rightIconNode,
this.uncheckIconNode,
this.iconNode,
this.deleteIconNode,
this.knobIconNode
]), function(n){
if(n){
var domNode = this.domNode;
var f = function(){
var t = Math.round((domNode.offsetHeight - n.offsetHeight) / 2) -
domStyle.get(domNode, "paddingTop");
n.style.marginTop = t + "px";
};
if(n.offsetHeight === 0 && n.tagName === "IMG"){
n.onload = f;
}else{
f();
}
}
}, this);
},
setArrow: function(){
// summary:
// Sets the arrow icon if necessary.
if(this.checked){ return; }
var c = "";
var parent = this.getParent();
var opts = this.getTransOpts();
if(opts.moveTo || opts.href || opts.url || this.clickable){
if(!this.noArrow && !(parent && parent.selectOne)){
c = this.arrowClass || "mblDomButtonArrow";
domAttr.set(this.domNode, "role", "button");
}
}
if(c){
this._setRightIconAttr(c);
}
},
_findRef: function(/*String*/type){
// summary:
// Find an appropriate position to insert a new child node.
// tags:
// private
var i, node, list = ["deleteIcon", "icon", "rightIcon", "uncheckIcon", "rightIcon2", "rightText"];
for(i = array.indexOf(list, type) + 1; i < list.length; i++){
node = this[list[i] + "Node"];
if(node){ return node; }
}
for(i = list.length - 1; i >= 0; i--){
node = this[list[i] + "Node"];
if(node){ return node.nextSibling; }
}
return this.domNode.firstChild;
},
_setIcon: function(/*String*/icon, /*String*/type){
// tags:
// private
if(!this._isOnLine){
// record the value to be able to reapply it (see the code in the startup method)
this["_pending_" + type] = icon;
return;
} // icon may be invalid because inheritParams is not called yet
this._set(type, icon);
this[type + "Node"] = iconUtils.setIcon(icon, this[type + "Pos"],
this[type + "Node"], this[type + "Title"] || this.alt, this.domNode, this._findRef(type), "before");
if(this[type + "Node"]){
var cap = type.charAt(0).toUpperCase() + type.substring(1);
domClass.add(this[type + "Node"], "mblListItem" + cap);
}
var role = this[type + "Role"];
if(role){
this[type + "Node"].setAttribute("role", role);
}
},
_setDeleteIconAttr: function(/*String*/icon){
// tags:
// private
this._setIcon(icon, "deleteIcon");
},
_setIconAttr: function(icon){
// tags:
// private
this._setIcon(icon, "icon");
},
_setRightTextAttr: function(/*String*/text){
// tags:
// private
if(!this._templated && !this.rightTextNode){
// When using a template, let the template create the element.
this.rightTextNode = domConstruct.create("div", {className:"mblListItemRightText"}, this.labelNode, "before");
}
this.rightText = text;
this.rightTextNode.innerHTML = this._cv ? this._cv(text) : text;
},
_setRightIconAttr: function(/*String*/icon){
// tags:
// private
this._setIcon(icon, "rightIcon");
},
_setUncheckIconAttr: function(/*String*/icon){
// tags:
// private
this._setIcon(icon, "uncheckIcon");
},
_setRightIcon2Attr: function(/*String*/icon){
// tags:
// private
this._setIcon(icon, "rightIcon2");
},
_setCheckedAttr: function(/*Boolean*/checked){
// tags:
// private
if(!this._isOnLine){
// record the value to be able to reapply it (see the code in the startup method)
this._pendingChecked = checked;
return;
} // icon may be invalid because inheritParams is not called yet
var parent = this.getParent();
if(parent && parent.select === "single" && checked){
array.forEach(parent.getChildren(), function(child){
child !== this && child.checked && child.set("checked", false) && domAttr.set(child.domNode, "aria-selected", "false");
}, this);
}
this._setRightIconAttr(this.checkClass || "mblDomButtonCheck");
this._setUncheckIconAttr(this.uncheckClass);
domClass.toggle(this.domNode, "mblListItemChecked", checked);
domClass.toggle(this.domNode, "mblListItemUnchecked", !checked);
domClass.toggle(this.domNode, "mblListItemHasUncheck", !!this.uncheckIconNode);
this.rightIconNode.style.position = (this.uncheckIconNode && !checked) ? "absolute" : "";
if(parent && this.checked !== checked){
parent.onCheckStateChanged(this, checked);
}
this._set("checked", checked);
domAttr.set(this.domNode, "aria-selected", checked ? "true" : "false");
},
_setBusyAttr: function(/*Boolean*/busy){
// tags:
// private
var prog = this._prog;
if(busy){
if(!this._progNode){
this._progNode = domConstruct.create("div", {className:"mblListItemIcon"});
prog = this._prog = new ProgressIndicator({size:25, center:false, removeOnStop:false});
domClass.add(prog.domNode, this.progStyle);
this._progNode.appendChild(prog.domNode);
}
if(this.iconNode){
this.domNode.replaceChild(this._progNode, this.iconNode);
}else{
domConstruct.place(this._progNode, this._findRef("icon"), "before");
}
prog.start();
}else if(this._progNode){
if(this.iconNode){
this.domNode.replaceChild(this.iconNode, this._progNode);
}else{
this.domNode.removeChild(this._progNode);
}
prog.stop();
}
this._set("busy", busy);
},
_setSelectedAttr: function(/*Boolean*/selected){
// summary:
// Makes this widget in the selected or unselected state.
// tags:
// private
this.inherited(arguments);
domClass.toggle(this.domNode, this._selClass, selected);
},
_setClickableAttr: function(/*Boolean*/clickable){
// tags:
// private
this._set("clickable", clickable);
this._updateHandles();
},
_setMoveToAttr: function(/*String*/moveTo){
// tags:
// private
this._set("moveTo", moveTo);
this._updateHandles();
},
_setHrefAttr: function(/*String*/href){
// tags:
// private
this._set("href", href);
this._updateHandles();
},
_setUrlAttr: function(/*String*/url){
// tags:
// private
this._set("url", url);
this._updateHandles();
}
});
ListItem.ChildWidgetProperties = {
// summary:
// These properties can be specified for the children of a dojox/mobile/ListItem.
// layout: String
// Specifies the position of the ListItem child ("left", "center" or "right").
layout: "",
// preventTouch: Boolean
// Disables touch events on the ListItem child.
preventTouch: false
};
// Since any widget can be specified as a ListItem child, mix ChildWidgetProperties
// into the base widget class. (This is a hack, but it's effective.)
// This is for the benefit of the parser. Remove for 2.0. Also, hide from doc viewer.
lang.extend(WidgetBase, /*===== {} || =====*/ ListItem.ChildWidgetProperties);
return has("dojo-bidi") ? declare("dojox.mobile.ListItem", [ListItem, BidiListItem]) : ListItem;
});
},
'dijit/_WidgetBase':function(){
define([
"require", // require.toUrl
"dojo/_base/array", // array.forEach array.map
"dojo/aspect",
"dojo/_base/config", // config.blankGif
"dojo/_base/connect", // connect.connect
"dojo/_base/declare", // declare
"dojo/dom", // dom.byId
"dojo/dom-attr", // domAttr.set domAttr.remove
"dojo/dom-class", // domClass.add domClass.replace
"dojo/dom-construct", // domConstruct.destroy domConstruct.place
"dojo/dom-geometry", // isBodyLtr
"dojo/dom-style", // domStyle.set, domStyle.get
"dojo/has",
"dojo/_base/kernel",
"dojo/_base/lang", // mixin(), isArray(), etc.
"dojo/on",
"dojo/ready",
"dojo/Stateful", // Stateful
"dojo/topic",
"dojo/_base/window", // win.body()
"./Destroyable",
"dojo/has!dojo-bidi?./_BidiMixin",
"./registry" // registry.getUniqueId(), registry.findWidgets()
], function(require, array, aspect, config, connect, declare,
dom, domAttr, domClass, domConstruct, domGeometry, domStyle, has, kernel,
lang, on, ready, Stateful, topic, win, Destroyable, _BidiMixin, registry){
// module:
// dijit/_WidgetBase
// Flag to make dijit load modules the app didn't explicitly request, for backwards compatibility
has.add("dijit-legacy-requires", !kernel.isAsync);
// Flag to enable support for textdir attribute
has.add("dojo-bidi", false);
// For back-compat, remove in 2.0.
if(has("dijit-legacy-requires")){
ready(0, function(){
var requires = ["dijit/_base/manager"];
require(requires); // use indirection so modules not rolled into a build
});
}
// Nested hash listing attributes for each tag, all strings in lowercase.
// ex: {"div": {"style": true, "tabindex" true}, "form": { ...
var tagAttrs = {};
function getAttrs(obj){
var ret = {};
for(var attr in obj){
ret[attr.toLowerCase()] = true;
}
return ret;
}
function nonEmptyAttrToDom(attr){
// summary:
// Returns a setter function that copies the attribute to this.domNode,
// or removes the attribute from this.domNode, depending on whether the
// value is defined or not.
return function(val){
domAttr[val ? "set" : "remove"](this.domNode, attr, val);
this._set(attr, val);
};
}
function isEqual(a, b){
// summary:
// Function that determines whether two values are identical,
// taking into account that NaN is not normally equal to itself
// in JS.
return a === b || (/* a is NaN */ a !== a && /* b is NaN */ b !== b);
}
var _WidgetBase = declare("dijit._WidgetBase", [Stateful, Destroyable], {
// summary:
// Future base class for all Dijit widgets.
// description:
// Future base class for all Dijit widgets.
// _Widget extends this class adding support for various features needed by desktop.
//
// Provides stubs for widget lifecycle methods for subclasses to extend, like postMixInProperties(), buildRendering(),
// postCreate(), startup(), and destroy(), and also public API methods like set(), get(), and watch().
//
// Widgets can provide custom setters/getters for widget attributes, which are called automatically by set(name, value).
// For an attribute XXX, define methods _setXXXAttr() and/or _getXXXAttr().
//
// _setXXXAttr can also be a string/hash/array mapping from a widget attribute XXX to the widget's DOMNodes:
//
// - DOM node attribute
// | _setFocusAttr: {node: "focusNode", type: "attribute"}
// | _setFocusAttr: "focusNode" (shorthand)
// | _setFocusAttr: "" (shorthand, maps to this.domNode)
// Maps this.focus to this.focusNode.focus, or (last example) this.domNode.focus
//
// - DOM node innerHTML
// | _setTitleAttr: { node: "titleNode", type: "innerHTML" }
// Maps this.title to this.titleNode.innerHTML
//
// - DOM node innerText
// | _setTitleAttr: { node: "titleNode", type: "innerText" }
// Maps this.title to this.titleNode.innerText
//
// - DOM node CSS class
// | _setMyClassAttr: { node: "domNode", type: "class" }
// Maps this.myClass to this.domNode.className
//
// - Toggle DOM node CSS class
// | _setMyClassAttr: { node: "domNode", type: "toggleClass" }
// Toggles myClass on this.domNode by this.myClass
//
// If the value of _setXXXAttr is an array, then each element in the array matches one of the
// formats of the above list.
//
// If the custom setter is null, no action is performed other than saving the new value
// in the widget (in this).
//
// If no custom setter is defined for an attribute, then it will be copied
// to this.focusNode (if the widget defines a focusNode), or this.domNode otherwise.
// That's only done though for attributes that match DOMNode attributes (title,
// alt, aria-labelledby, etc.)
// id: [const] String
// A unique, opaque ID string that can be assigned by users or by the
// system. If the developer passes an ID which is known not to be
// unique, the specified ID is ignored and the system-generated ID is
// used instead.
id: "",
_setIdAttr: "domNode", // to copy to this.domNode even for auto-generated id's
// lang: [const] String
// Rarely used. Overrides the default Dojo locale used to render this widget,
// as defined by the [HTML LANG](http://www.w3.org/TR/html401/struct/dirlang.html#adef-lang) attribute.
// Value must be among the list of locales specified during by the Dojo bootstrap,
// formatted according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt) (like en-us).
lang: "",
// set on domNode even when there's a focus node. but don't set lang="", since that's invalid.
_setLangAttr: nonEmptyAttrToDom("lang"),
// dir: [const] String
// Bi-directional support, as defined by the [HTML DIR](http://www.w3.org/TR/html401/struct/dirlang.html#adef-dir)
// attribute. Either left-to-right "ltr" or right-to-left "rtl". If undefined, widgets renders in page's
// default direction.
dir: "",
// set on domNode even when there's a focus node. but don't set dir="", since that's invalid.
_setDirAttr: nonEmptyAttrToDom("dir"), // to set on domNode even when there's a focus node
// class: String
// HTML class attribute
"class": "",
_setClassAttr: { node: "domNode", type: "class" },
// Override automatic assigning type --> focusNode, it causes exception on IE6-8.
// Instead, type must be specified as ${type} in the template, as part of the original DOM.
_setTypeAttr: null,
// style: String||Object
// HTML style attributes as cssText string or name/value hash
style: "",
// title: String
// HTML title attribute.
//
// For form widgets this specifies a tooltip to display when hovering over
// the widget (just like the native HTML title attribute).
//
// For TitlePane or for when this widget is a child of a TabContainer, AccordionContainer,
// etc., it's used to specify the tab label, accordion pane title, etc. In this case it's
// interpreted as HTML.
title: "",
// tooltip: String
// When this widget's title attribute is used to for a tab label, accordion pane title, etc.,
// this specifies the tooltip to appear when the mouse is hovered over that text.
tooltip: "",
// baseClass: [protected] String
// Root CSS class of the widget (ex: dijitTextBox), used to construct CSS classes to indicate
// widget state.
baseClass: "",
// srcNodeRef: [readonly] DomNode
// pointer to original DOM node
srcNodeRef: null,
// domNode: [readonly] DomNode
// This is our visible representation of the widget! Other DOM
// Nodes may by assigned to other properties, usually through the
// template system's data-dojo-attach-point syntax, but the domNode
// property is the canonical "top level" node in widget UI.
domNode: null,
// containerNode: [readonly] DomNode
// Designates where children of the source DOM node will be placed.
// "Children" in this case refers to both DOM nodes and widgets.
// For example, for myWidget:
//
// |
// | here's a plain DOM node
// | and a widget
// | and another plain DOM node
// |
//
// containerNode would point to:
//
// | here's a plain DOM node
// | and a widget
// | and another plain DOM node
//
// In templated widgets, "containerNode" is set via a
// data-dojo-attach-point assignment.
//
// containerNode must be defined for any widget that accepts innerHTML
// (like ContentPane or BorderContainer or even Button), and conversely
// is null for widgets that don't, like TextBox.
containerNode: null,
// ownerDocument: [const] Document?
// The document this widget belongs to. If not specified to constructor, will default to
// srcNodeRef.ownerDocument, or if no sourceRef specified, then to the document global
ownerDocument: null,
_setOwnerDocumentAttr: function(val){
// this setter is merely to avoid automatically trying to set this.domNode.ownerDocument
this._set("ownerDocument", val);
},
/*=====
// _started: [readonly] Boolean
// startup() has completed.
_started: false,
=====*/
// attributeMap: [protected] Object
// Deprecated. Instead of attributeMap, widget should have a _setXXXAttr attribute
// for each XXX attribute to be mapped to the DOM.
//
// attributeMap sets up a "binding" between attributes (aka properties)
// of the widget and the widget's DOM.
// Changes to widget attributes listed in attributeMap will be
// reflected into the DOM.
//
// For example, calling set('title', 'hello')
// on a TitlePane will automatically cause the TitlePane's DOM to update
// with the new title.
//
// attributeMap is a hash where the key is an attribute of the widget,
// and the value reflects a binding to a:
//
// - DOM node attribute
// | focus: {node: "focusNode", type: "attribute"}
// Maps this.focus to this.focusNode.focus
//
// - DOM node innerHTML
// | title: { node: "titleNode", type: "innerHTML" }
// Maps this.title to this.titleNode.innerHTML
//
// - DOM node innerText
// | title: { node: "titleNode", type: "innerText" }
// Maps this.title to this.titleNode.innerText
//
// - DOM node CSS class
// | myClass: { node: "domNode", type: "class" }
// Maps this.myClass to this.domNode.className
//
// If the value is an array, then each element in the array matches one of the
// formats of the above list.
//
// There are also some shorthands for backwards compatibility:
//
// - string --> { node: string, type: "attribute" }, for example:
//
// | "focusNode" ---> { node: "focusNode", type: "attribute" }
//
// - "" --> { node: "domNode", type: "attribute" }
attributeMap: {},
// _blankGif: [protected] String
// Path to a blank 1x1 image.
// Used by `` nodes in templates that really get their image via CSS background-image.
_blankGif: config.blankGif || require.toUrl("dojo/resources/blank.gif"),
// textDir: String
// Bi-directional support, the main variable which is responsible for the direction of the text.
// The text direction can be different than the GUI direction by using this parameter in creation
// of a widget.
//
// This property is only effective when `has("dojo-bidi")` is defined to be true.
//
// Allowed values:
//
// 1. "" - default value; text is same direction as widget
// 2. "ltr"
// 3. "rtl"
// 4. "auto" - contextual the direction of a text defined by first strong letter.
textDir: "",
//////////// INITIALIZATION METHODS ///////////////////////////////////////
/*=====
constructor: function(params, srcNodeRef){
// summary:
// Create the widget.
// params: Object|null
// Hash of initialization parameters for widget, including scalar values (like title, duration etc.)
// and functions, typically callbacks like onClick.
// The hash can contain any of the widget's properties, excluding read-only properties.
// srcNodeRef: DOMNode|String?
// If a srcNodeRef (DOM node) is specified:
//
// - use srcNodeRef.innerHTML as my contents
// - if this is a behavioral widget then apply behavior to that srcNodeRef
// - otherwise, replace srcNodeRef with my generated DOM tree
},
=====*/
_introspect: function(){
// summary:
// Collect metadata about this widget (only once per class, not once per instance):
//
// - list of attributes with custom setters, storing in this.constructor._setterAttrs
// - generate this.constructor._onMap, mapping names like "mousedown" to functions like onMouseDown
var ctor = this.constructor;
if(!ctor._setterAttrs){
var proto = ctor.prototype,
attrs = ctor._setterAttrs = [], // attributes with custom setters
onMap = (ctor._onMap = {});
// Items in this.attributeMap are like custom setters. For back-compat, remove for 2.0.
for(var name in proto.attributeMap){
attrs.push(name);
}
// Loop over widget properties, collecting properties with custom setters and filling in ctor._onMap.
for(name in proto){
if(/^on/.test(name)){
onMap[name.substring(2).toLowerCase()] = name;
}
if(/^_set[A-Z](.*)Attr$/.test(name)){
name = name.charAt(4).toLowerCase() + name.substr(5, name.length - 9);
if(!proto.attributeMap || !(name in proto.attributeMap)){
attrs.push(name);
}
}
}
// Note: this isn't picking up info on properties like aria-label and role, that don't have custom setters
// but that set() maps to attributes on this.domNode or this.focusNode
}
},
postscript: function(/*Object?*/params, /*DomNode|String*/srcNodeRef){
// summary:
// Kicks off widget instantiation. See create() for details.
// tags:
// private
// Note that we skip calling this.inherited(), i.e. dojo/Stateful::postscript(), because 1.x widgets don't
// expect their custom setters to get called until after buildRendering(). Consider changing for 2.0.
this.create(params, srcNodeRef);
},
create: function(params, srcNodeRef){
// summary:
// Kick off the life-cycle of a widget
// description:
// Create calls a number of widget methods (postMixInProperties, buildRendering, postCreate,
// etc.), some of which of you'll want to override. See http://dojotoolkit.org/reference-guide/dijit/_WidgetBase.html
// for a discussion of the widget creation lifecycle.
//
// Of course, adventurous developers could override create entirely, but this should
// only be done as a last resort.
// params: Object|null
// Hash of initialization parameters for widget, including scalar values (like title, duration etc.)
// and functions, typically callbacks like onClick.
// The hash can contain any of the widget's properties, excluding read-only properties.
// srcNodeRef: DOMNode|String?
// If a srcNodeRef (DOM node) is specified:
//
// - use srcNodeRef.innerHTML as my contents
// - if this is a behavioral widget then apply behavior to that srcNodeRef
// - otherwise, replace srcNodeRef with my generated DOM tree
// tags:
// private
// First time widget is instantiated, scan prototype to figure out info about custom setters etc.
this._introspect();
// store pointer to original DOM tree
this.srcNodeRef = dom.byId(srcNodeRef);
// No longer used, remove for 2.0.
this._connects = [];
this._supportingWidgets = [];
// this is here for back-compat, remove in 2.0 (but check NodeList-instantiate.html test)
if(this.srcNodeRef && this.srcNodeRef.id && (typeof this.srcNodeRef.id == "string")){
this.id = this.srcNodeRef.id;
}
// mix in our passed parameters
if(params){
this.params = params;
lang.mixin(this, params);
}
this.postMixInProperties();
// Generate an id for the widget if one wasn't specified, or it was specified as id: undefined.
// Do this before buildRendering() because it might expect the id to be there.
if(!this.id){
this.id = registry.getUniqueId(this.declaredClass.replace(/\./g, "_"));
if(this.params){
// if params contains {id: undefined}, prevent _applyAttributes() from processing it
delete this.params.id;
}
}
// The document and node this widget is associated with
this.ownerDocument = this.ownerDocument || (this.srcNodeRef ? this.srcNodeRef.ownerDocument : document);
this.ownerDocumentBody = win.body(this.ownerDocument);
registry.add(this);
this.buildRendering();
var deleteSrcNodeRef;
if(this.domNode){
// Copy attributes listed in attributeMap into the [newly created] DOM for the widget.
// Also calls custom setters for all attributes with custom setters.
this._applyAttributes();
// If srcNodeRef was specified, then swap out original srcNode for this widget's DOM tree.
// For 2.0, move this after postCreate(). postCreate() shouldn't depend on the
// widget being attached to the DOM since it isn't when a widget is created programmatically like
// new MyWidget({}). See #11635.
var source = this.srcNodeRef;
if(source && source.parentNode && this.domNode !== source){
source.parentNode.replaceChild(this.domNode, source);
deleteSrcNodeRef = true;
}
// Note: for 2.0 may want to rename widgetId to dojo._scopeName + "_widgetId",
// assuming that dojo._scopeName even exists in 2.0
this.domNode.setAttribute("widgetId", this.id);
}
this.postCreate();
// If srcNodeRef has been processed and removed from the DOM (e.g. TemplatedWidget) then delete it to allow GC.
// I think for back-compatibility it isn't deleting srcNodeRef until after postCreate() has run.
if(deleteSrcNodeRef){
delete this.srcNodeRef;
}
this._created = true;
},
_applyAttributes: function(){
// summary:
// Step during widget creation to copy widget attributes to the
// DOM according to attributeMap and _setXXXAttr objects, and also to call
// custom _setXXXAttr() methods.
//
// Skips over blank/false attribute values, unless they were explicitly specified
// as parameters to the widget, since those are the default anyway,
// and setting tabIndex="" is different than not setting tabIndex at all.
//
// For backwards-compatibility reasons attributeMap overrides _setXXXAttr when
// _setXXXAttr is a hash/string/array, but _setXXXAttr as a functions override attributeMap.
// tags:
// private
// Call this.set() for each property that was either specified as parameter to constructor,
// or is in the list found above. For correlated properties like value and displayedValue, the one
// specified as a parameter should take precedence.
// Particularly important for new DateTextBox({displayedValue: ...}) since DateTextBox's default value is
// NaN and thus is not ignored like a default value of "".
// Step 1: Save the current values of the widget properties that were specified as parameters to the constructor.
// Generally this.foo == this.params.foo, except if postMixInProperties() changed the value of this.foo.
var params = {};
for(var key in this.params || {}){
params[key] = this._get(key);
}
// Step 2: Call set() for each property with a non-falsy value that wasn't passed as a parameter to the constructor
array.forEach(this.constructor._setterAttrs, function(key){
if(!(key in params)){
var val = this._get(key);
if(val){
this.set(key, val);
}
}
}, this);
// Step 3: Call set() for each property that was specified as parameter to constructor.
// Use params hash created above to ignore side effects from step #2 above.
for(key in params){
this.set(key, params[key]);
}
},
postMixInProperties: function(){
// summary:
// Called after the parameters to the widget have been read-in,
// but before the widget template is instantiated. Especially
// useful to set properties that are referenced in the widget
// template.
// tags:
// protected
},
buildRendering: function(){
// summary:
// Construct the UI for this widget, setting this.domNode.
// Most widgets will mixin `dijit._TemplatedMixin`, which implements this method.
// tags:
// protected
if(!this.domNode){
// Create root node if it wasn't created by _TemplatedMixin
this.domNode = this.srcNodeRef || this.ownerDocument.createElement("div");
}
// baseClass is a single class name or occasionally a space-separated list of names.
// Add those classes to the DOMNode. If RTL mode then also add with Rtl suffix.
// TODO: make baseClass custom setter
if(this.baseClass){
var classes = this.baseClass.split(" ");
if(!this.isLeftToRight()){
classes = classes.concat(array.map(classes, function(name){
return name + "Rtl";
}));
}
domClass.add(this.domNode, classes);
}
},
postCreate: function(){
// summary:
// Processing after the DOM fragment is created
// description:
// Called after the DOM fragment has been created, but not necessarily
// added to the document. Do not include any operations which rely on
// node dimensions or placement.
// tags:
// protected
},
startup: function(){
// summary:
// Processing after the DOM fragment is added to the document
// description:
// Called after a widget and its children have been created and added to the page,
// and all related widgets have finished their create() cycle, up through postCreate().
//
// Note that startup() may be called while the widget is still hidden, for example if the widget is
// inside a hidden dijit/Dialog or an unselected tab of a dijit/layout/TabContainer.
// For widgets that need to do layout, it's best to put that layout code inside resize(), and then
// extend dijit/layout/_LayoutWidget so that resize() is called when the widget is visible.
if(this._started){
return;
}
this._started = true;
array.forEach(this.getChildren(), function(obj){
if(!obj._started && !obj._destroyed && lang.isFunction(obj.startup)){
obj.startup();
obj._started = true;
}
});
},
//////////// DESTROY FUNCTIONS ////////////////////////////////
destroyRecursive: function(/*Boolean?*/ preserveDom){
// summary:
// Destroy this widget and its descendants
// description:
// This is the generic "destructor" function that all widget users
// should call to cleanly discard with a widget. Once a widget is
// destroyed, it is removed from the manager object.
// preserveDom:
// If true, this method will leave the original DOM structure
// alone of descendant Widgets. Note: This will NOT work with
// dijit._TemplatedMixin widgets.
this._beingDestroyed = true;
this.destroyDescendants(preserveDom);
this.destroy(preserveDom);
},
destroy: function(/*Boolean*/ preserveDom){
// summary:
// Destroy this widget, but not its descendants. Descendants means widgets inside of
// this.containerNode. Will also destroy any resources (including widgets) registered via this.own().
//
// This method will also destroy internal widgets such as those created from a template,
// assuming those widgets exist inside of this.domNode but outside of this.containerNode.
//
// For 2.0 it's planned that this method will also destroy descendant widgets, so apps should not
// depend on the current ability to destroy a widget without destroying its descendants. Generally
// they should use destroyRecursive() for widgets with children.
// preserveDom: Boolean
// If true, this method will leave the original DOM structure alone.
// Note: This will not yet work with _TemplatedMixin widgets
this._beingDestroyed = true;
this.uninitialize();
function destroy(w){
if(w.destroyRecursive){
w.destroyRecursive(preserveDom);
}else if(w.destroy){
w.destroy(preserveDom);
}
}
// Back-compat, remove for 2.0
array.forEach(this._connects, lang.hitch(this, "disconnect"));
array.forEach(this._supportingWidgets, destroy);
// Destroy supporting widgets, but not child widgets under this.containerNode (for 2.0, destroy child widgets
// here too). if() statement is to guard against exception if destroy() called multiple times (see #15815).
if(this.domNode){
array.forEach(registry.findWidgets(this.domNode, this.containerNode), destroy);
}
this.destroyRendering(preserveDom);
registry.remove(this.id);
this._destroyed = true;
},
destroyRendering: function(/*Boolean?*/ preserveDom){
// summary:
// Destroys the DOM nodes associated with this widget.
// preserveDom:
// If true, this method will leave the original DOM structure alone
// during tear-down. Note: this will not work with _Templated
// widgets yet.
// tags:
// protected
if(this.bgIframe){
this.bgIframe.destroy(preserveDom);
delete this.bgIframe;
}
if(this.domNode){
if(preserveDom){
domAttr.remove(this.domNode, "widgetId");
}else{
domConstruct.destroy(this.domNode);
}
delete this.domNode;
}
if(this.srcNodeRef){
if(!preserveDom){
domConstruct.destroy(this.srcNodeRef);
}
delete this.srcNodeRef;
}
},
destroyDescendants: function(/*Boolean?*/ preserveDom){
// summary:
// Recursively destroy the children of this widget and their
// descendants.
// preserveDom:
// If true, the preserveDom attribute is passed to all descendant
// widget's .destroy() method. Not for use with _Templated
// widgets.
// get all direct descendants and destroy them recursively
array.forEach(this.getChildren(), function(widget){
if(widget.destroyRecursive){
widget.destroyRecursive(preserveDom);
}
});
},
uninitialize: function(){
// summary:
// Deprecated. Override destroy() instead to implement custom widget tear-down
// behavior.
// tags:
// protected
return false;
},
////////////////// GET/SET, CUSTOM SETTERS, ETC. ///////////////////
_setStyleAttr: function(/*String||Object*/ value){
// summary:
// Sets the style attribute of the widget according to value,
// which is either a hash like {height: "5px", width: "3px"}
// or a plain string
// description:
// Determines which node to set the style on based on style setting
// in attributeMap.
// tags:
// protected
var mapNode = this.domNode;
// Note: technically we should revert any style setting made in a previous call
// to his method, but that's difficult to keep track of.
if(lang.isObject(value)){
domStyle.set(mapNode, value);
}else{
if(mapNode.style.cssText){
mapNode.style.cssText += "; " + value;
}else{
mapNode.style.cssText = value;
}
}
this._set("style", value);
},
_attrToDom: function(/*String*/ attr, /*String*/ value, /*Object?*/ commands){
// summary:
// Reflect a widget attribute (title, tabIndex, duration etc.) to
// the widget DOM, as specified by commands parameter.
// If commands isn't specified then it's looked up from attributeMap.
// Note some attributes like "type"
// cannot be processed this way as they are not mutable.
// attr:
// Name of member variable (ex: "focusNode" maps to this.focusNode) pointing
// to DOMNode inside the widget, or alternately pointing to a subwidget
// tags:
// private
commands = arguments.length >= 3 ? commands : this.attributeMap[attr];
array.forEach(lang.isArray(commands) ? commands : [commands], function(command){
// Get target node and what we are doing to that node
var mapNode = this[command.node || command || "domNode"]; // DOM node
var type = command.type || "attribute"; // class, innerHTML, innerText, or attribute
switch(type){
case "attribute":
if(lang.isFunction(value)){ // functions execute in the context of the widget
value = lang.hitch(this, value);
}
// Get the name of the DOM node attribute; usually it's the same
// as the name of the attribute in the widget (attr), but can be overridden.
// Also maps handler names to lowercase, like onSubmit --> onsubmit
var attrName = command.attribute ? command.attribute :
(/^on[A-Z][a-zA-Z]*$/.test(attr) ? attr.toLowerCase() : attr);
if(mapNode.tagName){
// Normal case, mapping to a DOMNode. Note that modern browsers will have a mapNode.set()
// method, but for consistency we still call domAttr
domAttr.set(mapNode, attrName, value);
}else{
// mapping to a sub-widget
mapNode.set(attrName, value);
}
break;
case "innerText":
// Deprecated, use "textContent" instead.
mapNode.innerHTML = "";
mapNode.appendChild(this.ownerDocument.createTextNode(value));
break;
case "textContent":
mapNode.textContent = value;
break;
case "innerHTML":
mapNode.innerHTML = value;
break;
case "class":
domClass.replace(mapNode, value, this[attr]);
break;
case "toggleClass":
domClass.toggle(mapNode, command.className || attr, value);
break;
}
}, this);
},
get: function(name){
// summary:
// Get a property from a widget.
// name:
// The property to get.
// description:
// Get a named property from a widget. The property may
// potentially be retrieved via a getter method. If no getter is defined, this
// just retrieves the object's property.
//
// For example, if the widget has properties `foo` and `bar`
// and a method named `_getFooAttr()`, calling:
// `myWidget.get("foo")` would be equivalent to calling
// `widget._getFooAttr()` and `myWidget.get("bar")`
// would be equivalent to the expression
// `widget.bar2`
var names = this._getAttrNames(name);
return this[names.g] ? this[names.g]() : this._get(name);
},
set: function(name, value){
// summary:
// Set a property on a widget
// name:
// The property to set.
// value:
// The value to set in the property.
// description:
// Sets named properties on a widget which may potentially be handled by a
// setter in the widget.
//
// For example, if the widget has properties `foo` and `bar`
// and a method named `_setFooAttr()`, calling
// `myWidget.set("foo", "Howdy!")` would be equivalent to calling
// `widget._setFooAttr("Howdy!")` and `myWidget.set("bar", 3)`
// would be equivalent to the statement `widget.bar = 3;`
//
// set() may also be called with a hash of name/value pairs, ex:
//
// | myWidget.set({
// | foo: "Howdy",
// | bar: 3
// | });
//
// This is equivalent to calling `set(foo, "Howdy")` and `set(bar, 3)`
if(typeof name === "object"){
for(var x in name){
this.set(x, name[x]);
}
return this;
}
var names = this._getAttrNames(name),
setter = this[names.s];
if(lang.isFunction(setter)){
// use the explicit setter
var result = setter.apply(this, Array.prototype.slice.call(arguments, 1));
}else{
// Mapping from widget attribute to DOMNode/subwidget attribute/value/etc.
// Map according to:
// 1. attributeMap setting, if one exists (TODO: attributeMap deprecated, remove in 2.0)
// 2. _setFooAttr: {...} type attribute in the widget (if one exists)
// 3. apply to focusNode or domNode if standard attribute name, excluding funcs like onClick.
// Checks if an attribute is a "standard attribute" by whether the DOMNode JS object has a similar
// attribute name (ex: accept-charset attribute matches jsObject.acceptCharset).
// Note also that Tree.focusNode() is a function not a DOMNode, so test for that.
var defaultNode = this.focusNode && !lang.isFunction(this.focusNode) ? "focusNode" : "domNode",
tag = this[defaultNode] && this[defaultNode].tagName,
attrsForTag = tag && (tagAttrs[tag] || (tagAttrs[tag] = getAttrs(this[defaultNode]))),
map = name in this.attributeMap ? this.attributeMap[name] :
names.s in this ? this[names.s] :
((attrsForTag && names.l in attrsForTag && typeof value != "function") ||
/^aria-|^data-|^role$/.test(name)) ? defaultNode : null;
if(map != null){
this._attrToDom(name, value, map);
}
this._set(name, value);
}
return result || this;
},
_attrPairNames: {}, // shared between all widgets
_getAttrNames: function(name){
// summary:
// Helper function for get() and set().
// Caches attribute name values so we don't do the string ops every time.
// tags:
// private
var apn = this._attrPairNames;
if(apn[name]){
return apn[name];
}
var uc = name.replace(/^[a-z]|-[a-zA-Z]/g, function(c){
return c.charAt(c.length - 1).toUpperCase();
});
return (apn[name] = {
n: name + "Node",
s: "_set" + uc + "Attr", // converts dashes to camel case, ex: accept-charset --> _setAcceptCharsetAttr
g: "_get" + uc + "Attr",
l: uc.toLowerCase() // lowercase name w/out dashes, ex: acceptcharset
});
},
_set: function(/*String*/ name, /*anything*/ value){
// summary:
// Helper function to set new value for specified property, and call handlers
// registered with watch() if the value has changed.
var oldValue = this[name];
this[name] = value;
if(this._created && !isEqual(oldValue, value)){
if(this._watchCallbacks){
this._watchCallbacks(name, oldValue, value);
}
this.emit("attrmodified-" + name, {
detail: {
prevValue: oldValue,
newValue: value
}
});
}
},
_get: function(/*String*/ name){
// summary:
// Helper function to get value for specified property stored by this._set(),
// i.e. for properties with custom setters. Used mainly by custom getters.
//
// For example, CheckBox._getValueAttr() calls this._get("value").
// future: return name in this.props ? this.props[name] : this[name];
return this[name];
},
emit: function(/*String*/ type, /*Object?*/ eventObj, /*Array?*/ callbackArgs){
// summary:
// Used by widgets to signal that a synthetic event occurred, ex:
// | myWidget.emit("attrmodified-selectedChildWidget", {}).
//
// Emits an event on this.domNode named type.toLowerCase(), based on eventObj.
// Also calls onType() method, if present, and returns value from that method.
// By default passes eventObj to callback, but will pass callbackArgs instead, if specified.
// Modifies eventObj by adding missing parameters (bubbles, cancelable, widget).
// tags:
// protected
// Specify fallback values for bubbles, cancelable in case they are not set in eventObj.
// Also set pointer to widget, although since we can't add a pointer to the widget for native events
// (see #14729), maybe we shouldn't do it here?
eventObj = eventObj || {};
if(eventObj.bubbles === undefined){
eventObj.bubbles = true;
}
if(eventObj.cancelable === undefined){
eventObj.cancelable = true;
}
if(!eventObj.detail){
eventObj.detail = {};
}
eventObj.detail.widget = this;
var ret, callback = this["on" + type];
if(callback){
ret = callback.apply(this, callbackArgs ? callbackArgs : [eventObj]);
}
// Emit event, but avoid spurious emit()'s as parent sets properties on child during startup/destroy
if(this._started && !this._beingDestroyed){
on.emit(this.domNode, type.toLowerCase(), eventObj);
}
return ret;
},
on: function(/*String|Function*/ type, /*Function*/ func){
// summary:
// Call specified function when event occurs, ex: myWidget.on("click", function(){ ... }).
// type:
// Name of event (ex: "click") or extension event like touch.press.
// description:
// Call specified function when event `type` occurs, ex: `myWidget.on("click", function(){ ... })`.
// Note that the function is not run in any particular scope, so if (for example) you want it to run in the
// widget's scope you must do `myWidget.on("click", lang.hitch(myWidget, func))`.
// For backwards compatibility, if there's an onType() method in the widget then connect to that.
// Remove in 2.0.
var widgetMethod = this._onMap(type);
if(widgetMethod){
return aspect.after(this, widgetMethod, func, true);
}
// Otherwise, just listen for the event on this.domNode.
return this.own(on(this.domNode, type, func))[0];
},
_onMap: function(/*String|Function*/ type){
// summary:
// Maps on() type parameter (ex: "mousemove") to method name (ex: "onMouseMove").
// If type is a synthetic event like touch.press then returns undefined.
var ctor = this.constructor, map = ctor._onMap;
if(!map){
map = (ctor._onMap = {});
for(var attr in ctor.prototype){
if(/^on/.test(attr)){
map[attr.replace(/^on/, "").toLowerCase()] = attr;
}
}
}
return map[typeof type == "string" && type.toLowerCase()]; // String
},
toString: function(){
// summary:
// Returns a string that represents the widget.
// description:
// When a widget is cast to a string, this method will be used to generate the
// output. Currently, it does not implement any sort of reversible
// serialization.
return '[Widget ' + this.declaredClass + ', ' + (this.id || 'NO ID') + ']'; // String
},
getChildren: function(){
// summary:
// Returns all direct children of this widget, i.e. all widgets underneath this.containerNode whose parent
// is this widget. Note that it does not return all descendants, but rather just direct children.
// Analogous to [Node.childNodes](https://developer.mozilla.org/en-US/docs/DOM/Node.childNodes),
// except containing widgets rather than DOMNodes.
//
// The result intentionally excludes internally created widgets (a.k.a. supporting widgets)
// outside of this.containerNode.
//
// Note that the array returned is a simple array. Application code should not assume
// existence of methods like forEach().
return this.containerNode ? registry.findWidgets(this.containerNode) : []; // dijit/_WidgetBase[]
},
getParent: function(){
// summary:
// Returns the parent widget of this widget.
return registry.getEnclosingWidget(this.domNode.parentNode);
},
connect: function(/*Object|null*/ obj, /*String|Function*/ event, /*String|Function*/ method){
// summary:
// Deprecated, will be removed in 2.0, use this.own(on(...)) or this.own(aspect.after(...)) instead.
//
// Connects specified obj/event to specified method of this object
// and registers for disconnect() on widget destroy.
//
// Provide widget-specific analog to dojo.connect, except with the
// implicit use of this widget as the target object.
// Events connected with `this.connect` are disconnected upon
// destruction.
// returns:
// A handle that can be passed to `disconnect` in order to disconnect before
// the widget is destroyed.
// example:
// | var btn = new Button();
// | // when foo.bar() is called, call the listener we're going to
// | // provide in the scope of btn
// | btn.connect(foo, "bar", function(){
// | console.debug(this.toString());
// | });
// tags:
// protected
return this.own(connect.connect(obj, event, this, method))[0]; // handle
},
disconnect: function(handle){
// summary:
// Deprecated, will be removed in 2.0, use handle.remove() instead.
//
// Disconnects handle created by `connect`.
// tags:
// protected
handle.remove();
},
subscribe: function(t, method){
// summary:
// Deprecated, will be removed in 2.0, use this.own(topic.subscribe()) instead.
//
// Subscribes to the specified topic and calls the specified method
// of this object and registers for unsubscribe() on widget destroy.
//
// Provide widget-specific analog to dojo.subscribe, except with the
// implicit use of this widget as the target object.
// t: String
// The topic
// method: Function
// The callback
// example:
// | var btn = new Button();
// | // when /my/topic is published, this button changes its label to
// | // be the parameter of the topic.
// | btn.subscribe("/my/topic", function(v){
// | this.set("label", v);
// | });
// tags:
// protected
return this.own(topic.subscribe(t, lang.hitch(this, method)))[0]; // handle
},
unsubscribe: function(/*Object*/ handle){
// summary:
// Deprecated, will be removed in 2.0, use handle.remove() instead.
//
// Unsubscribes handle created by this.subscribe.
// Also removes handle from this widget's list of subscriptions
// tags:
// protected
handle.remove();
},
isLeftToRight: function(){
// summary:
// Return this widget's explicit or implicit orientation (true for LTR, false for RTL)
// tags:
// protected
return this.dir ? (this.dir.toLowerCase() == "ltr") : domGeometry.isBodyLtr(this.ownerDocument); //Boolean
},
isFocusable: function(){
// summary:
// Return true if this widget can currently be focused
// and false if not
return this.focus && (domStyle.get(this.domNode, "display") != "none");
},
placeAt: function(/*String|DomNode|DocumentFragment|dijit/_WidgetBase*/ reference, /*String|Int?*/ position){
// summary:
// Place this widget somewhere in the DOM based
// on standard domConstruct.place() conventions.
// description:
// A convenience function provided in all _Widgets, providing a simple
// shorthand mechanism to put an existing (or newly created) Widget
// somewhere in the dom, and allow chaining.
// reference:
// Widget, DOMNode, DocumentFragment, or id of widget or DOMNode
// position:
// If reference is a widget (or id of widget), and that widget has an ".addChild" method,
// it will be called passing this widget instance into that method, supplying the optional
// position index passed. In this case position (if specified) should be an integer.
//
// If reference is a DOMNode (or id matching a DOMNode but not a widget),
// the position argument can be a numeric index or a string
// "first", "last", "before", or "after", same as dojo/dom-construct::place().
// returns: dijit/_WidgetBase
// Provides a useful return of the newly created dijit._Widget instance so you
// can "chain" this function by instantiating, placing, then saving the return value
// to a variable.
// example:
// | // create a Button with no srcNodeRef, and place it in the body:
// | var button = new Button({ label:"click" }).placeAt(win.body());
// | // now, 'button' is still the widget reference to the newly created button
// | button.on("click", function(e){ console.log('click'); }));
// example:
// | // create a button out of a node with id="src" and append it to id="wrapper":
// | var button = new Button({},"src").placeAt("wrapper");
// example:
// | // place a new button as the first element of some div
// | var button = new Button({ label:"click" }).placeAt("wrapper","first");
// example:
// | // create a contentpane and add it to a TabContainer
// | var tc = dijit.byId("myTabs");
// | new ContentPane({ href:"foo.html", title:"Wow!" }).placeAt(tc)
var refWidget = !reference.tagName && registry.byId(reference);
if(refWidget && refWidget.addChild && (!position || typeof position === "number")){
// Adding this to refWidget and can use refWidget.addChild() to handle everything.
refWidget.addChild(this, position);
}else{
// "reference" is a plain DOMNode, or we can't use refWidget.addChild(). Use domConstruct.place() and
// target refWidget.containerNode for nested placement (position==number, "first", "last", "only"), and
// refWidget.domNode otherwise ("after"/"before"/"replace"). (But not supported officially, see #14946.)
var ref = refWidget && ("domNode" in refWidget) ?
(refWidget.containerNode && !/after|before|replace/.test(position || "") ?
refWidget.containerNode : refWidget.domNode) : dom.byId(reference, this.ownerDocument);
domConstruct.place(this.domNode, ref, position);
// Start this iff it has a parent widget that's already started.
// TODO: for 2.0 maybe it should also start the widget when this.getParent() returns null??
if(!this._started && (this.getParent() || {})._started){
this.startup();
}
}
return this;
},
defer: function(fcn, delay){
// summary:
// Wrapper to setTimeout to avoid deferred functions executing
// after the originating widget has been destroyed.
// Returns an object handle with a remove method (that returns null) (replaces clearTimeout).
// fcn: Function
// Function reference.
// delay: Number?
// Delay, defaults to 0.
// tags:
// protected
var timer = setTimeout(lang.hitch(this,
function(){
if(!timer){
return;
}
timer = null;
if(!this._destroyed){
lang.hitch(this, fcn)();
}
}),
delay || 0
);
return {
remove: function(){
if(timer){
clearTimeout(timer);
timer = null;
}
return null; // so this works well: handle = handle.remove();
}
};
}
});
if(has("dojo-bidi")){
_WidgetBase.extend(_BidiMixin);
}
return _WidgetBase;
});
},
'dojo/Stateful':function(){
define(["./_base/declare", "./_base/lang", "./_base/array", "./when"], function(declare, lang, array, when){
// module:
// dojo/Stateful
return declare("dojo.Stateful", null, {
// summary:
// Base class for objects that provide named properties with optional getter/setter
// control and the ability to watch for property changes
//
// The class also provides the functionality to auto-magically manage getters
// and setters for object attributes/properties.
//
// Getters and Setters should follow the format of _xxxGetter or _xxxSetter where
// the xxx is a name of the attribute to handle. So an attribute of "foo"
// would have a custom getter of _fooGetter and a custom setter of _fooSetter.
//
// example:
// | require(["dojo/Stateful", function(Stateful) {
// | var obj = new Stateful();
// | obj.watch("foo", function(){
// | console.log("foo changed to " + this.get("foo"));
// | });
// | obj.set("foo","bar");
// | });
// _attrPairNames: Hash
// Used across all instances a hash to cache attribute names and their getter
// and setter names.
_attrPairNames: {},
_getAttrNames: function(name){
// summary:
// Helper function for get() and set().
// Caches attribute name values so we don't do the string ops every time.
// tags:
// private
var apn = this._attrPairNames;
if(apn[name]){ return apn[name]; }
return (apn[name] = {
s: "_" + name + "Setter",
g: "_" + name + "Getter"
});
},
postscript: function(/*Object?*/ params){
// Automatic setting of params during construction
if (params){ this.set(params); }
},
_get: function(name, names){
// summary:
// Private function that does a get based off a hash of names
// names:
// Hash of names of custom attributes
return typeof this[names.g] === "function" ? this[names.g]() : this[name];
},
get: function(/*String*/name){
// summary:
// Get a property on a Stateful instance.
// name:
// The property to get.
// returns:
// The property value on this Stateful instance.
// description:
// Get a named property on a Stateful object. The property may
// potentially be retrieved via a getter method in subclasses. In the base class
// this just retrieves the object's property.
// example:
// | require(["dojo/Stateful", function(Stateful) {
// | var stateful = new Stateful({foo: 3});
// | stateful.get("foo") // returns 3
// | stateful.foo // returns 3
// | });
return this._get(name, this._getAttrNames(name)); //Any
},
set: function(/*String*/name, /*Object*/value){
// summary:
// Set a property on a Stateful instance
// name:
// The property to set.
// value:
// The value to set in the property.
// returns:
// The function returns this dojo.Stateful instance.
// description:
// Sets named properties on a stateful object and notifies any watchers of
// the property. A programmatic setter may be defined in subclasses.
// example:
// | require(["dojo/Stateful", function(Stateful) {
// | var stateful = new Stateful();
// | stateful.watch(function(name, oldValue, value){
// | // this will be called on the set below
// | }
// | stateful.set(foo, 5);
// set() may also be called with a hash of name/value pairs, ex:
// | stateful.set({
// | foo: "Howdy",
// | bar: 3
// | });
// | });
// This is equivalent to calling set(foo, "Howdy") and set(bar, 3)
// If an object is used, iterate through object
if(typeof name === "object"){
for(var x in name){
if(name.hasOwnProperty(x) && x !="_watchCallbacks"){
this.set(x, name[x]);
}
}
return this;
}
var names = this._getAttrNames(name),
oldValue = this._get(name, names),
setter = this[names.s],
result;
if(typeof setter === "function"){
// use the explicit setter
result = setter.apply(this, Array.prototype.slice.call(arguments, 1));
}else{
// no setter so set attribute directly
this[name] = value;
}
if(this._watchCallbacks){
var self = this;
// If setter returned a promise, wait for it to complete, otherwise call watches immediately
when(result, function(){
self._watchCallbacks(name, oldValue, value);
});
}
return this; // dojo/Stateful
},
_changeAttrValue: function(name, value){
// summary:
// Internal helper for directly changing an attribute value.
//
// name: String
// The property to set.
// value: Mixed
// The value to set in the property.
//
// description:
// Directly change the value of an attribute on an object, bypassing any
// accessor setter. Also handles the calling of watch and emitting events.
// It is designed to be used by descendant class when there are two values
// of attributes that are linked, but calling .set() is not appropriate.
var oldValue = this.get(name);
this[name] = value;
if(this._watchCallbacks){
this._watchCallbacks(name, oldValue, value);
}
return this; // dojo/Stateful
},
watch: function(/*String?*/name, /*Function*/callback){
// summary:
// Watches a property for changes
// name:
// Indicates the property to watch. This is optional (the callback may be the
// only parameter), and if omitted, all the properties will be watched
// returns:
// An object handle for the watch. The unwatch method of this object
// can be used to discontinue watching this property:
// | var watchHandle = obj.watch("foo", callback);
// | watchHandle.unwatch(); // callback won't be called now
// callback:
// The function to execute when the property changes. This will be called after
// the property has been changed. The callback will be called with the |this|
// set to the instance, the first argument as the name of the property, the
// second argument as the old value and the third argument as the new value.
var callbacks = this._watchCallbacks;
if(!callbacks){
var self = this;
callbacks = this._watchCallbacks = function(name, oldValue, value, ignoreCatchall){
var notify = function(propertyCallbacks){
if(propertyCallbacks){
propertyCallbacks = propertyCallbacks.slice();
for(var i = 0, l = propertyCallbacks.length; i < l; i++){
propertyCallbacks[i].call(self, name, oldValue, value);
}
}
};
notify(callbacks['_' + name]);
if(!ignoreCatchall){
notify(callbacks["*"]); // the catch-all
}
}; // we use a function instead of an object so it will be ignored by JSON conversion
}
if(!callback && typeof name === "function"){
callback = name;
name = "*";
}else{
// prepend with dash to prevent name conflicts with function (like "name" property)
name = '_' + name;
}
var propertyCallbacks = callbacks[name];
if(typeof propertyCallbacks !== "object"){
propertyCallbacks = callbacks[name] = [];
}
propertyCallbacks.push(callback);
// TODO: Remove unwatch in 2.0
var handle = {};
handle.unwatch = handle.remove = function(){
var index = array.indexOf(propertyCallbacks, callback);
if(index > -1){
propertyCallbacks.splice(index, 1);
}
};
return handle; //Object
}
});
});
},
'dijit/Destroyable':function(){
define([
"dojo/_base/array", // array.forEach array.map
"dojo/aspect",
"dojo/_base/declare"
], function(array, aspect, declare){
// module:
// dijit/Destroyable
return declare("dijit.Destroyable", null, {
// summary:
// Mixin to track handles and release them when instance is destroyed.
// description:
// Call this.own(...) on list of handles (returned from dojo/aspect, dojo/on,
// dojo/Stateful::watch, or any class (including widgets) with a destroyRecursive() or destroy() method.
// Then call destroy() later to destroy this instance and release the resources.
destroy: function(/*Boolean*/ preserveDom){
// summary:
// Destroy this class, releasing any resources registered via own().
this._destroyed = true;
},
own: function(){
// summary:
// Track specified handles and remove/destroy them when this instance is destroyed, unless they were
// already removed/destroyed manually.
// tags:
// protected
// returns:
// The array of specified handles, so you can do for example:
// | var handle = this.own(on(...))[0];
var cleanupMethods = [
"destroyRecursive",
"destroy",
"remove"
];
array.forEach(arguments, function(handle){
// When this.destroy() is called, destroy handle. Since I'm using aspect.before(),
// the handle will be destroyed before a subclass's destroy() method starts running, before it calls
// this.inherited() or even if it doesn't call this.inherited() at all. If that's an issue, make an
// onDestroy() method and connect to that instead.
var destroyMethodName;
var odh = aspect.before(this, "destroy", function (preserveDom){
handle[destroyMethodName](preserveDom);
});
// Callback for when handle is manually destroyed.
var hdhs = [];
function onManualDestroy(){
odh.remove();
array.forEach(hdhs, function(hdh){
hdh.remove();
});
}
// Setup listeners for manual destroy of handle.
// Also computes destroyMethodName, used in listener above.
if(handle.then){
// Special path for Promises. Detect when Promise is resolved, rejected, or
// canceled (nb: cancelling a Promise causes it to be rejected).
destroyMethodName = "cancel";
handle.then(onManualDestroy, onManualDestroy);
}else{
// Path for other handles. Just use AOP to detect when handle is manually destroyed.
array.forEach(cleanupMethods, function(cleanupMethod){
if(typeof handle[cleanupMethod] === "function"){
if(!destroyMethodName){
// Use first matching method name in above listener (prefer destroyRecursive() to destroy())
destroyMethodName = cleanupMethod;
}
hdhs.push(aspect.after(handle, cleanupMethod, onManualDestroy, true));
}
});
}
}, this);
return arguments; // handle
}
});
});
},
'dojox/mobile/iconUtils':function(){
define([
"dojo/_base/array",
"dojo/_base/config",
"dojo/_base/connect",
"dojo/_base/event",
"dojo/_base/lang",
"dojo/_base/window",
"dojo/dom-class",
"dojo/dom-construct",
"dojo/dom-style",
"./sniff"
], function(array, config, connect, event, lang, win, domClass, domConstruct, domStyle, has){
var dm = lang.getObject("dojox.mobile", true);
// module:
// dojox/mobile/iconUtils
var IconUtils = function(){
// summary:
// Utilities to create an icon (image, CSS sprite image, or DOM Button).
this.setupSpriteIcon = function(/*DomNode*/iconNode, /*String*/iconPos){
// summary:
// Sets up CSS sprite for a foreground image.
if(iconNode && iconPos){
var arr = array.map(iconPos.split(/[ ,]/),function(item){return item-0});
var t = arr[0]; // top
var r = arr[1] + arr[2]; // right
var b = arr[0] + arr[3]; // bottom
var l = arr[1]; // left
domStyle.set(iconNode, {
position: "absolute",
clip: "rect("+t+"px "+r+"px "+b+"px "+l+"px)",
top: (iconNode.parentNode ? domStyle.get(iconNode, "top") : 0) - t + "px",
left: -l + "px"
});
domClass.add(iconNode, "mblSpriteIcon");
}
};
this.createDomButton = function(/*DomNode*/refNode, /*Object?*/style, /*DomNode?*/toNode){
// summary:
// Creates a DOM button.
// description:
// DOM button is a simple graphical object that consists of one or
// more nested DIV elements with some CSS styling. It can be used
// in place of an icon image on ListItem, IconItem, and so on.
// The kind of DOM button to create is given as a class name of
// refNode. The number of DIVs to create is searched from the style
// sheets in the page. However, if the class name has a suffix that
// starts with an underscore, like mblDomButtonGoldStar_5, then the
// suffixed number is used instead. A class name for DOM button
// must starts with 'mblDomButton'.
// refNode:
// A node that has a DOM button class name.
// style:
// A hash object to set styles to the node.
// toNode:
// A root node to create a DOM button. If omitted, refNode is used.
if(!this._domButtons){
if(has("webkit")){
var findDomButtons = function(sheet, dic){
// summary:
// Searches the style sheets for DOM buttons.
// description:
// Returns a key-value pair object whose keys are DOM
// button class names and values are the number of DOM
// elements they need.
var i, j;
if(!sheet){
var _dic = {};
var ss = win.doc.styleSheets;
for (i = 0; i < ss.length; i++){
ss[i] && findDomButtons(ss[i], _dic);
}
return _dic;
}
var rules = sheet.cssRules || [];
for (i = 0; i < rules.length; i++){
var rule = rules[i];
if(rule.href && rule.styleSheet){
findDomButtons(rule.styleSheet, dic);
}else if(rule.selectorText){
var sels = rule.selectorText.split(/,/);
for (j = 0; j < sels.length; j++){
var sel = sels[j];
var n = sel.split(/>/).length - 1;
if(sel.match(/(mblDomButton\w+)/)){
var cls = RegExp.$1;
if(!dic[cls] || n > dic[cls]){
dic[cls] = n;
}
}
}
}
}
return dic;
};
this._domButtons = findDomButtons();
}else{
this._domButtons = {};
}
}
var s = refNode.className;
var node = toNode || refNode;
if(s.match(/(mblDomButton\w+)/) && s.indexOf("/") === -1){
var btnClass = RegExp.$1;
var nDiv = 4;
if(s.match(/(mblDomButton\w+_(\d+))/)){
nDiv = RegExp.$2 - 0;
}else if(this._domButtons[btnClass] !== undefined){
nDiv = this._domButtons[btnClass];
}
var props = null;
if(has("bb") && config.mblBBBoxShadowWorkaround !== false){
// Removes box-shadow because BlackBerry incorrectly renders it.
props = {style:"-webkit-box-shadow:none"};
}
for(var i = 0, p = node; i < nDiv; i++){
p = p.firstChild || domConstruct.create("div", props, p);
}
if(toNode){
setTimeout(function(){
domClass.remove(refNode, btnClass);
}, 0);
domClass.add(toNode, btnClass);
}
}else if(s.indexOf(".") !== -1){ // file name
domConstruct.create("img", {src:s}, node);
}else{
return null;
}
domClass.add(node, "mblDomButton");
!!style && domStyle.set(node, style);
return node;
};
this.createIcon = function(/*String*/icon, /*String?*/iconPos, /*DomNode?*/node, /*String?*/title, /*DomNode?*/parent, /*DomNode?*/refNode, /*String?*/pos){
// summary:
// Creates or updates an icon node
// description:
// If node exists, updates the existing node. Otherwise, creates a new one.
// icon:
// Path for an image, or DOM button class name.
title = title || "";
if(icon && icon.indexOf("mblDomButton") === 0){
// DOM button
if(!node){
node = domConstruct.create("div", null, refNode || parent, pos);
}else{
if(node.className.match(/(mblDomButton\w+)/)){
domClass.remove(node, RegExp.$1);
}
}
node.title = title;
domClass.add(node, icon);
this.createDomButton(node);
}else if(icon && icon !== "none"){
// Image
if(!node || node.nodeName !== "IMG"){
node = domConstruct.create("img", {
alt: title
}, refNode || parent, pos);
}
node.src = (icon || "").replace("${theme}", dm.currentTheme);
this.setupSpriteIcon(node, iconPos);
if(iconPos && parent){
var arr = iconPos.split(/[ ,]/);
domStyle.set(parent, {
position: "relative",
width: arr[2] + "px",
height: arr[3] + "px"
});
domClass.add(parent, "mblSpriteIconParent");
}
connect.connect(node, "ondragstart", event, "stop");
}
return node;
};
this.iconWrapper = false;
this.setIcon = function(/*String*/icon, /*String*/iconPos, /*DomNode*/iconNode, /*String?*/alt, /*DomNode*/parent, /*DomNode?*/refNode, /*String?*/pos){
// summary:
// A setter function to set an icon.
// description:
// This function is intended to be used by icon setters (e.g. _setIconAttr)
// icon:
// An icon path or a DOM button class name.
// iconPos:
// The position of an aggregated icon. IconPos is comma separated
// values like top,left,width,height (ex. "0,0,29,29").
// iconNode:
// An icon node.
// alt:
// An alt text for the icon image.
// parent:
// Parent node of the icon.
// refNode:
// A node reference to place the icon.
// pos:
// The position of the icon relative to refNode.
if(!parent || !icon && !iconNode){ return null; }
if(icon && icon !== "none"){ // create or update an icon
if(!this.iconWrapper && icon.indexOf("mblDomButton") !== 0 && !iconPos){ // image
if(iconNode && iconNode.tagName === "DIV"){
domConstruct.destroy(iconNode);
iconNode = null;
}
iconNode = this.createIcon(icon, null, iconNode, alt, parent, refNode, pos);
domClass.add(iconNode, "mblImageIcon");
}else{ // sprite or DOM button
if(iconNode && iconNode.tagName === "IMG"){
domConstruct.destroy(iconNode);
iconNode = null;
}
iconNode && domConstruct.empty(iconNode);
if(!iconNode){
iconNode = domConstruct.create("div", null, refNode || parent, pos);
}
this.createIcon(icon, iconPos, null, null, iconNode);
if(alt){
iconNode.title = alt;
}
}
domClass.remove(parent, "mblNoIcon");
return iconNode;
}else{ // clear the icon
domConstruct.destroy(iconNode);
domClass.add(parent, "mblNoIcon");
return null;
}
};
};
// Return singleton. (TODO: can we replace IconUtils class and singleton w/a simple hash of functions?)
return new IconUtils();
});
},
'dojox/mobile/sniff':function(){
define([
"dojo/_base/kernel",
"dojo/sniff"
], function(kernel, has){
kernel.deprecated("dojox/mobile/sniff", "Use dojo/sniff instead", "2.0");
// TODO: remove this in 2.0
has.add("iphone", has("ios"));
/*=====
return {
// summary:
// Deprecated: use dojo/sniff instead.
// On iOS, dojox/mobile/sniff sets "iphone" to the same value as "ios"
// for compatibility with earlier versions, but this should be considered deprecated.
// In future versions, "iphone" will be set only when running on an iPhone (not iPad on iPod).
};
=====*/
return has;
});
},
'dojox/mobile/_ItemBase':function(){
define([
"dojo/_base/array",
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/_base/window",
"dojo/dom-class",
"dojo/touch",
"dijit/registry",
"dijit/_Contained",
"dijit/_Container",
"dijit/_WidgetBase",
"./TransitionEvent",
"./iconUtils",
"./sniff",
"./viewRegistry",
"dojo/has!dojo-bidi?dojox/mobile/bidi/_ItemBase"
], function(array, declare, lang, win, domClass, touch, registry, Contained, Container,
WidgetBase, TransitionEvent, iconUtils, has, viewRegistry, BidiItemBase){
// module:
// dojox/mobile/_ItemBase
var _ItemBase = declare(has("dojo-bidi") ? "dojox.mobile._NonBidiItemBase" : "dojox.mobile._ItemBase", [WidgetBase, Container, Contained], {
// summary:
// A base class for item classes (e.g. ListItem, IconItem, etc.).
// description:
// _ItemBase is a base class for widgets that have capability to
// make a view transition when clicked.
// icon: String
// An icon image to display. The value can be either a path for an
// image file or a class name of a DOM button. If icon is not
// specified, the iconBase parameter of the parent widget is used.
icon: "",
// iconPos: String
// The position of an aggregated icon. IconPos is comma separated
// values like top,left,width,height (ex. "0,0,29,29"). If iconPos
// is not specified, the iconPos parameter of the parent widget is
// used.
iconPos: "", // top,left,width,height (ex. "0,0,29,29")
// alt: String
// An alternate text for the icon image.
alt: "",
// href: String
// A URL of another web page to go to.
href: "",
// hrefTarget: String
// A target that specifies where to open a page specified by
// href. The value will be passed to the 2nd argument of
// window.open().
hrefTarget: "",
// moveTo: String
// The id of the transition destination view which resides in the
// current page.
//
// If the value has a hash sign ('#') before the id (e.g. #view1)
// and the dojo/hash module is loaded by the user application, the
// view transition updates the hash in the browser URL so that the
// user can bookmark the destination view. In this case, the user
// can also use the browser's back/forward button to navigate
// through the views in the browser history.
//
// If null, transitions to a blank view.
// If '#', returns immediately without transition.
moveTo: "",
// scene: String
// The name of a scene. Used from dojox/mobile/app.
scene: "",
// clickable: Boolean
// If true, this item becomes clickable even if a transition
// destination (moveTo, etc.) is not specified.
clickable: false,
// url: String
// A URL of an html fragment page or JSON data that represents a
// new view content. The view content is loaded with XHR and
// inserted in the current page. Then a view transition occurs to
// the newly created view. The view is cached so that subsequent
// requests would not load the content again.
url: "",
// urlTarget: String
// Node id under which a new view will be created according to the
// url parameter. If not specified, The new view will be created as
// a sibling of the current view.
urlTarget: "",
// back: Boolean
// If true, history.back() is called when clicked.
back: false,
// transition: String
// A type of animated transition effect. You can choose from the
// standard transition types, "slide", "fade", "flip", or from the
// extended transition types, "cover", "coverv", "dissolve",
// "reveal", "revealv", "scaleIn", "scaleOut", "slidev",
// "swirl", "zoomIn", "zoomOut", "cube", and "swap". If "none" is
// specified, transition occurs immediately without animation.
transition: "",
// transitionDir: Number
// The transition direction. If 1, transition forward. If -1,
// transition backward. For example, the slide transition slides
// the view from right to left when dir == 1, and from left to
// right when dir == -1.
transitionDir: 1,
// transitionOptions: Object
// A hash object that holds transition options.
transitionOptions: null,
// callback: Function|String
// A callback function that is called when the transition has been
// finished. A function reference, or name of a function in
// context.
callback: null,
// label: String
// A label of the item. If the label is not specified, innerHTML is
// used as a label.
label: "",
// toggle: Boolean
// If true, the item acts like a toggle button.
toggle: false,
// selected: Boolean
// If true, the item is highlighted to indicate it is selected.
selected: false,
// tabIndex: String
// Tabindex setting for the item so users can hit the tab key to
// focus on it.
tabIndex: "0",
// _setTabIndexAttr: [private] String
// Sets tabIndex to domNode.
_setTabIndexAttr: "",
/* internal properties */
// paramsToInherit: String
// Comma separated parameters to inherit from the parent.
paramsToInherit: "transition,icon",
// _selStartMethod: String
// Specifies how the item enters the selected state.
//
// - "touch": Use touch events to enter the selected state.
// - "none": Do not change the selected state.
_selStartMethod: "none", // touch or none
// _selEndMethod: String
// Specifies how the item leaves the selected state.
//
// - "touch": Use touch events to leave the selected state.
// - "timer": Use setTimeout to leave the selected state.
// - "none": Do not change the selected state.
_selEndMethod: "none", // touch, timer, or none
// _delayedSelection: Boolean
// If true, selection is delayed 100ms and canceled if dragged in
// order to avoid selection when flick operation is performed.
_delayedSelection: false,
// _duration: Number
// Duration of selection, milliseconds.
_duration: 800,
// _handleClick: Boolean
// If true, this widget listens to touch events.
_handleClick: true,
buildRendering: function(){
this.inherited(arguments);
this._isOnLine = this.inheritParams();
},
startup: function(){
if(this._started){ return; }
if(!this._isOnLine){
this.inheritParams();
}
this._updateHandles();
this.inherited(arguments);
},
inheritParams: function(){
// summary:
// Copies from the parent the values of parameters specified
// by the property paramsToInherit.
var parent = this.getParent();
if(parent){
array.forEach(this.paramsToInherit.split(/,/), function(p){
if(p.match(/icon/i)){
var base = p + "Base", pos = p + "Pos";
if(this[p] && parent[base] &&
parent[base].charAt(parent[base].length - 1) === '/'){
this[p] = parent[base] + this[p];
}
if(!this[p]){ this[p] = parent[base]; }
if(!this[pos]){ this[pos] = parent[pos]; }
}
if(!this[p]){ this[p] = parent[p]; }
}, this);
}
return !!parent;
},
_updateHandles: function(){
// tags:
// private
if(this._handleClick && this._selStartMethod === "touch"){
if(!this._onTouchStartHandle){
this._onTouchStartHandle = this.connect(this.domNode, touch.press, "_onTouchStart");
}
}else{
if(this._onTouchStartHandle){
this.disconnect(this._onTouchStartHandle);
this._onTouchStartHandle = null;
}
}
},
getTransOpts: function(){
// summary:
// Copies from the parent and returns the values of parameters
// specified by the property paramsToInherit.
var opts = this.transitionOptions || {};
array.forEach(["moveTo", "href", "hrefTarget", "url", "target",
"urlTarget", "scene", "transition", "transitionDir"], function(p){
opts[p] = opts[p] || this[p];
}, this);
return opts; // Object
},
userClickAction: function(/*Event*/ /*===== e =====*/){
// summary:
// User-defined click action.
},
defaultClickAction: function(/*Event*/e){
// summary:
// The default action of this item.
this.handleSelection(e);
if(this.userClickAction(e) === false){ return; } // user's click action
this.makeTransition(e);
},
handleSelection: function(/*Event*/e){
// summary:
// Handles this items selection state.
// Before transitioning, we want the visual effect of selecting the item.
// To ensure this effect happens even if _delayedSelection is true:
if(this._delayedSelection){
this.set("selected", true);
} // the item will be deselected after transition.
if(this._onTouchEndHandle){
this.disconnect(this._onTouchEndHandle);
this._onTouchEndHandle = null;
}
var p = this.getParent();
if(this.toggle){
this.set("selected", !this._currentSel);
}else if(p && p.selectOne){
this.set("selected", true);
}else{
if(this._selEndMethod === "touch"){
this.set("selected", false);
}else if(this._selEndMethod === "timer"){
this.defer(function(){
this.set("selected", false);
}, this._duration);
}
}
},
makeTransition: function(/*Event*/e){
// summary:
// Makes a transition.
if(this.back && history){
history.back();
return;
}
if (this.href && this.hrefTarget && this.hrefTarget != "_self") {
win.global.open(this.href, this.hrefTarget || "_blank");
this._onNewWindowOpened(e);
return;
}
var opts = this.getTransOpts();
var doTransition =
!!(opts.moveTo || opts.href || opts.url || opts.target || opts.scene);
if(this._prepareForTransition(e, doTransition ? opts : null) === false){ return; }
if(doTransition){
this.setTransitionPos(e);
new TransitionEvent(this.domNode, opts, e).dispatch();
}
},
_onNewWindowOpened: function(/*Event*/ /*===== e =====*/){
// summary:
// Subclasses may want to implement it.
},
_prepareForTransition: function(/*Event*/e, /*Object*/transOpts){
// summary:
// Subclasses may want to implement it.
},
_onTouchStart: function(e){
// tags:
// private
if(this.getParent().isEditing || this.onTouchStart(e) === false){ return; } // user's touchStart action
var enclosingScrollable = viewRegistry.getEnclosingScrollable(this.domNode);
if(enclosingScrollable &&
domClass.contains(enclosingScrollable.containerNode, "mblScrollableScrollTo2")){
// #17165: do not select the item during scroll animation
return;
}
if(!this._onTouchEndHandle && this._selStartMethod === "touch"){
// Connect to the entire window. Otherwise, fail to receive
// events if operation is performed outside this widget.
// Expose both connect handlers in case the user has interest.
this._onTouchMoveHandle = this.connect(win.body(), touch.move, "_onTouchMove");
this._onTouchEndHandle = this.connect(win.body(), touch.release, "_onTouchEnd");
}
this.touchStartX = e.touches ? e.touches[0].pageX : e.clientX;
this.touchStartY = e.touches ? e.touches[0].pageY : e.clientY;
this._currentSel = this.selected;
if(this._delayedSelection){
// so as not to make selection when the user flicks on ScrollableView
this._selTimer = this.defer(function(){
this.set("selected", true);
}, 100);
}else{
this.set("selected", true);
}
},
onTouchStart: function(/*Event*/ /*===== e =====*/){
// summary:
// User-defined function to handle touchStart events.
// tags:
// callback
},
_onTouchMove: function(e){
// tags:
// private
var x = e.touches ? e.touches[0].pageX : e.clientX;
var y = e.touches ? e.touches[0].pageY : e.clientY;
if(Math.abs(x - this.touchStartX) >= 4 ||
Math.abs(y - this.touchStartY) >= 4){ // dojox/mobile/scrollable.threshold
this.cancel();
var p = this.getParent();
if(p && p.selectOne){
this._prevSel && this._prevSel.set("selected", true);
}else{
this.set("selected", false);
}
}
},
_disconnect: function(){
// tags:
// private
this.disconnect(this._onTouchMoveHandle);
this.disconnect(this._onTouchEndHandle);
this._onTouchMoveHandle = this._onTouchEndHandle = null;
},
cancel: function(){
// summary:
// Cancels an ongoing selection (if any).
if(this._selTimer){
this._selTimer.remove();
this._selTimer = null;
}
this._disconnect();
},
_onTouchEnd: function(e){
// tags:
// private
if(!this._selTimer && this._delayedSelection){ return; }
this.cancel();
this._onClick(e);
},
setTransitionPos: function(e){
// summary:
// Stores the clicked position for later use.
// description:
// Some of the transition animations (e.g. ScaleIn) need the
// clicked position.
var w = this;
while(true){
w = w.getParent();
if(!w || domClass.contains(w.domNode, "mblView")){ break; }
}
if(w){
w.clickedPosX = e.clientX;
w.clickedPosY = e.clientY;
}
},
transitionTo: function(/*String|Object*/moveTo, /*String*/href, /*String*/url, /*String*/scene){
// summary:
// Performs a view transition.
// description:
// Given a transition destination, this method performs a view
// transition. This method is typically called when this item
// is clicked.
var opts = (moveTo && typeof(moveTo) === "object") ? moveTo :
{moveTo: moveTo, href: href, url: url, scene: scene,
transition: this.transition, transitionDir: this.transitionDir};
new TransitionEvent(this.domNode, opts).dispatch();
},
_setIconAttr: function(icon){
// tags:
// private
if(!this._isOnLine){
// record the value to be able to reapply it (see the code in the startup method)
this._pendingIcon = icon;
return;
} // icon may be invalid because inheritParams is not called yet
this._set("icon", icon);
this.iconNode = iconUtils.setIcon(icon, this.iconPos, this.iconNode, this.alt, this.iconParentNode, this.refNode, this.position);
},
_setLabelAttr: function(/*String*/text){
// tags:
// private
this._set("label", text);
this.labelNode.innerHTML = this._cv ? this._cv(text) : text;
},
_setSelectedAttr: function(/*Boolean*/selected){
// summary:
// Makes this widget in the selected or unselected state.
// description:
// Subclass should override.
// tags:
// private
if(selected){
var p = this.getParent();
if(p && p.selectOne){
// deselect the currently selected item
var arr = array.filter(p.getChildren(), function(w){
return w.selected;
});
array.forEach(arr, function(c){
this._prevSel = c;
c.set("selected", false);
}, this);
}
}
this._set("selected", selected);
}
});
return has("dojo-bidi") ? declare("dojox.mobile._ItemBase", [_ItemBase, BidiItemBase]) : _ItemBase;
});
},
'dojo/touch':function(){
define(["./_base/kernel", "./aspect", "./dom", "./dom-class", "./_base/lang", "./on", "./has", "./mouse", "./domReady", "./_base/window"],
function(dojo, aspect, dom, domClass, lang, on, has, mouse, domReady, win){
// module:
// dojo/touch
var ios4 = has("ios") < 5;
// Detect if platform supports Pointer Events, and if so, the names of the events (pointerdown vs. MSPointerDown).
var hasPointer = has("pointer-events") || has("MSPointer"),
pointer = (function () {
var pointer = {};
for (var type in { down: 1, move: 1, up: 1, cancel: 1, over: 1, out: 1 }) {
pointer[type] = has("MSPointer") ?
"MSPointer" + type.charAt(0).toUpperCase() + type.slice(1) :
"pointer" + type;
}
return pointer;
})();
// Detect if platform supports the webkit touchstart/touchend/... events
var hasTouch = has("touch-events");
// Click generation variables
var clicksInited, clickTracker, useTarget = false, clickTarget, clickX, clickY, clickDx, clickDy, clickTime;
// Time of most recent touchstart, touchmove, or touchend event
var lastTouch;
function dualEvent(mouseType, touchType, pointerType){
// Returns synthetic event that listens for both the specified mouse event and specified touch event.
// But ignore fake mouse events that were generated due to the user touching the screen.
if(hasPointer && pointerType){
// IE10+: MSPointer* events are designed to handle both mouse and touch in a uniform way,
// so just use that regardless of hasTouch.
return function(node, listener){
return on(node, pointerType, listener);
};
}else if(hasTouch){
return function(node, listener){
var handle1 = on(node, touchType, function(evt){
listener.call(this, evt);
// On slow mobile browsers (see https://bugs.dojotoolkit.org/ticket/17634),
// a handler for a touch event may take >1s to run. That time shouldn't
// be included in the calculation for lastTouch.
lastTouch = (new Date()).getTime();
}),
handle2 = on(node, mouseType, function(evt){
if(!lastTouch || (new Date()).getTime() > lastTouch + 1000){
listener.call(this, evt);
}
});
return {
remove: function(){
handle1.remove();
handle2.remove();
}
};
};
}else{
// Avoid creating listeners for touch events on performance sensitive older browsers like IE6
return function(node, listener){
return on(node, mouseType, listener);
};
}
}
function marked(/*DOMNode*/ node){
// Search for node ancestor has been marked with the dojoClick property to indicate special processing.
// Returns marked ancestor.
do{
if(node.dojoClick !== undefined){ return node; }
}while(node = node.parentNode);
}
function doClicks(e, moveType, endType){
// summary:
// Setup touch listeners to generate synthetic clicks immediately (rather than waiting for the browser
// to generate clicks after the double-tap delay) and consistently (regardless of whether event.preventDefault()
// was called in an event listener. Synthetic clicks are generated only if a node or one of its ancestors has
// its dojoClick property set to truthy. If a node receives synthetic clicks because one of its ancestors has its
// dojoClick property set to truthy, you can disable synthetic clicks on this node by setting its own dojoClick property
// to falsy.
if(mouse.isRight(e)){
return; // avoid spurious dojoclick event on IE10+; right click is just for context menu
}
var markedNode = marked(e.target);
clickTracker = !e.target.disabled && markedNode && markedNode.dojoClick; // click threshold = true, number, x/y object, or "useTarget"
if(clickTracker){
useTarget = (clickTracker == "useTarget");
clickTarget = (useTarget?markedNode:e.target);
if(useTarget){
// We expect a click, so prevent any other
// default action on "touchpress"
e.preventDefault();
}
clickX = e.changedTouches ? e.changedTouches[0].pageX - win.global.pageXOffset : e.clientX;
clickY = e.changedTouches ? e.changedTouches[0].pageY - win.global.pageYOffset : e.clientY;
clickDx = (typeof clickTracker == "object" ? clickTracker.x : (typeof clickTracker == "number" ? clickTracker : 0)) || 4;
clickDy = (typeof clickTracker == "object" ? clickTracker.y : (typeof clickTracker == "number" ? clickTracker : 0)) || 4;
// add move/end handlers only the first time a node with dojoClick is seen,
// so we don't add too much overhead when dojoClick is never set.
if(!clicksInited){
clicksInited = true;
var updateClickTracker = function updateClickTracker(e){
if(useTarget){
clickTracker = dom.isDescendant(
win.doc.elementFromPoint(
(e.changedTouches ? e.changedTouches[0].pageX - win.global.pageXOffset : e.clientX),
(e.changedTouches ? e.changedTouches[0].pageY - win.global.pageYOffset : e.clientY)),
clickTarget);
}else{
clickTracker = clickTracker &&
(e.changedTouches ? e.changedTouches[0].target : e.target) == clickTarget &&
Math.abs((e.changedTouches ? e.changedTouches[0].pageX - win.global.pageXOffset : e.clientX) - clickX) <= clickDx &&
Math.abs((e.changedTouches ? e.changedTouches[0].pageY - win.global.pageYOffset : e.clientY) - clickY) <= clickDy;
}
};
win.doc.addEventListener(moveType, function(e){
if(mouse.isRight(e)){
return; // avoid spurious dojoclick event on IE10+; right click is just for context menu
}
updateClickTracker(e);
if(useTarget){
// prevent native scroll event and ensure touchend is
// fire after touch moves between press and release.
e.preventDefault();
}
}, true);
win.doc.addEventListener(endType, function(e){
if(mouse.isRight(e)){
return; // avoid spurious dojoclick event on IE10+; right click is just for context menu
}
updateClickTracker(e);
if(clickTracker){
clickTime = (new Date()).getTime();
var target = (useTarget?clickTarget:e.target);
if(target.tagName === "LABEL"){
// when clicking on a label, forward click to its associated input if any
target = dom.byId(target.getAttribute("for")) || target;
}
//some attributes can be on the Touch object, not on the Event:
//http://www.w3.org/TR/touch-events/#touch-interface
var src = (e.changedTouches) ? e.changedTouches[0] : e;
var createMouseEvent = function createMouseEvent(type){
//create the synthetic event.
//http://www.w3.org/TR/DOM-Level-3-Events/#widl-MouseEvent-initMouseEvent
var evt = document.createEvent("MouseEvents");
evt._dojo_click = true;
evt.initMouseEvent(type,
true, //bubbles
true, //cancelable
e.view,
e.detail,
src.screenX,
src.screenY,
src.clientX,
src.clientY,
e.ctrlKey,
e.altKey,
e.shiftKey,
e.metaKey,
0, //button
null //related target
);
return evt;
};
var mouseDownEvt = createMouseEvent("mousedown");
var mouseUpEvt = createMouseEvent("mouseup");
var clickEvt = createMouseEvent("click");
setTimeout(function(){
on.emit(target, "mousedown", mouseDownEvt);
on.emit(target, "mouseup", mouseUpEvt);
on.emit(target, "click", clickEvt);
// refresh clickTime in case app-defined click handler took a long time to run
clickTime = (new Date()).getTime();
}, 0);
}
}, true);
var stopNativeEvents = function stopNativeEvents(type){
win.doc.addEventListener(type, function(e){
// Stop native events when we emitted our own click event. Note that the native click may occur
// on a different node than the synthetic click event was generated on. For example,
// click on a menu item, causing the menu to disappear, and then (~300ms later) the browser
// sends a click event to the node that was *underneath* the menu. So stop all native events
// sent shortly after ours, similar to what is done in dualEvent.
// The INPUT.dijitOffScreen test is for offscreen inputs used in dijit/form/Button, on which
// we call click() explicitly, we don't want to stop this event.
var target = e.target;
if(clickTracker && !e._dojo_click &&
(new Date()).getTime() <= clickTime + 1000 &&
!(target.tagName == "INPUT" && domClass.contains(target, "dijitOffScreen"))){
e.stopPropagation();
e.stopImmediatePropagation && e.stopImmediatePropagation();
if(type == "click" &&
(target.tagName != "INPUT" ||
(target.type == "radio" &&
// #18352 Do not preventDefault for radios that are not dijit or
// dojox/mobile widgets.
// (The CSS class dijitCheckBoxInput holds for both checkboxes and radio buttons.)
(domClass.contains(target, "dijitCheckBoxInput") ||
domClass.contains(target, "mblRadioButton"))) ||
(target.type == "checkbox" &&
// #18352 Do not preventDefault for checkboxes that are not dijit or
// dojox/mobile widgets.
(domClass.contains(target, "dijitCheckBoxInput") ||
domClass.contains(target, "mblCheckBox")))) &&
target.tagName != "TEXTAREA" && target.tagName != "AUDIO" && target.tagName != "VIDEO"){
// preventDefault() breaks textual s on android, keyboard doesn't popup,
// but it is still needed for checkboxes and radio buttons, otherwise in some cases
// the checked state becomes inconsistent with the widget's state
e.preventDefault();
}
}
}, true);
};
stopNativeEvents("click");
// We also stop mousedown/up since these would be sent well after with our "fast" click (300ms),
// which can confuse some dijit widgets.
stopNativeEvents("mousedown");
stopNativeEvents("mouseup");
}
}
}
var hoveredNode;
if(has("touch")){
if(hasPointer){
// MSPointer (IE10+) already has support for over and out, so we just need to init click support
domReady(function(){
win.doc.addEventListener(pointer.down, function(evt){
doClicks(evt, pointer.move, pointer.up);
}, true);
});
}else{
domReady(function(){
// Keep track of currently hovered node
hoveredNode = win.body(); // currently hovered node
win.doc.addEventListener("touchstart", function(evt){
lastTouch = (new Date()).getTime();
// Precede touchstart event with touch.over event. DnD depends on this.
// Use addEventListener(cb, true) to run cb before any touchstart handlers on node run,
// and to ensure this code runs even if the listener on the node does event.stop().
var oldNode = hoveredNode;
hoveredNode = evt.target;
on.emit(oldNode, "dojotouchout", {
relatedTarget: hoveredNode,
bubbles: true
});
on.emit(hoveredNode, "dojotouchover", {
relatedTarget: oldNode,
bubbles: true
});
doClicks(evt, "touchmove", "touchend"); // init click generation
}, true);
function copyEventProps(evt){
// Make copy of event object and also set bubbles:true. Used when calling on.emit().
var props = lang.delegate(evt, {
bubbles: true
});
if(has("ios") >= 6){
// On iOS6 "touches" became a non-enumerable property, which
// is not hit by for...in. Ditto for the other properties below.
props.touches = evt.touches;
props.altKey = evt.altKey;
props.changedTouches = evt.changedTouches;
props.ctrlKey = evt.ctrlKey;
props.metaKey = evt.metaKey;
props.shiftKey = evt.shiftKey;
props.targetTouches = evt.targetTouches;
}
return props;
}
on(win.doc, "touchmove", function(evt){
lastTouch = (new Date()).getTime();
var newNode = win.doc.elementFromPoint(
evt.pageX - (ios4 ? 0 : win.global.pageXOffset), // iOS 4 expects page coords
evt.pageY - (ios4 ? 0 : win.global.pageYOffset)
);
if(newNode){
// Fire synthetic touchover and touchout events on nodes since the browser won't do it natively.
if(hoveredNode !== newNode){
// touch out on the old node
on.emit(hoveredNode, "dojotouchout", {
relatedTarget: newNode,
bubbles: true
});
// touchover on the new node
on.emit(newNode, "dojotouchover", {
relatedTarget: hoveredNode,
bubbles: true
});
hoveredNode = newNode;
}
// Unlike a listener on "touchmove", on(node, "dojotouchmove", listener) fires when the finger
// drags over the specified node, regardless of which node the touch started on.
if(!on.emit(newNode, "dojotouchmove", copyEventProps(evt))){
// emit returns false when synthetic event "dojotouchmove" is cancelled, so we prevent the
// default behavior of the underlying native event "touchmove".
evt.preventDefault();
}
}
});
// Fire a dojotouchend event on the node where the finger was before it was removed from the screen.
// This is different than the native touchend, which fires on the node where the drag started.
on(win.doc, "touchend", function(evt){
lastTouch = (new Date()).getTime();
var node = win.doc.elementFromPoint(
evt.pageX - (ios4 ? 0 : win.global.pageXOffset), // iOS 4 expects page coords
evt.pageY - (ios4 ? 0 : win.global.pageYOffset)
) || win.body(); // if out of the screen
on.emit(node, "dojotouchend", copyEventProps(evt));
});
});
}
}
//device neutral events - touch.press|move|release|cancel/over/out
var touch = {
press: dualEvent("mousedown", "touchstart", pointer.down),
move: dualEvent("mousemove", "dojotouchmove", pointer.move),
release: dualEvent("mouseup", "dojotouchend", pointer.up),
cancel: dualEvent(mouse.leave, "touchcancel", hasPointer ? pointer.cancel : null),
over: dualEvent("mouseover", "dojotouchover", pointer.over),
out: dualEvent("mouseout", "dojotouchout", pointer.out),
enter: mouse._eventHandler(dualEvent("mouseover","dojotouchover", pointer.over)),
leave: mouse._eventHandler(dualEvent("mouseout", "dojotouchout", pointer.out))
};
/*=====
touch = {
// summary:
// This module provides unified touch event handlers by exporting
// press, move, release and cancel which can also run well on desktop.
// Based on http://dvcs.w3.org/hg/webevents/raw-file/tip/touchevents.html
// Also, if the dojoClick property is set to truthy on a DOM node, dojo/touch generates
// click events immediately for this node and its descendants (except for descendants that
// have a dojoClick property set to falsy), to avoid the delay before native browser click events,
// and regardless of whether evt.preventDefault() was called in a touch.press event listener.
//
// example:
// Used with dojo/on
// | define(["dojo/on", "dojo/touch"], function(on, touch){
// | on(node, touch.press, function(e){});
// | on(node, touch.move, function(e){});
// | on(node, touch.release, function(e){});
// | on(node, touch.cancel, function(e){});
// example:
// Used with touch.* directly
// | touch.press(node, function(e){});
// | touch.move(node, function(e){});
// | touch.release(node, function(e){});
// | touch.cancel(node, function(e){});
// example:
// Have dojo/touch generate clicks without delay, with a default move threshold of 4 pixels
// | node.dojoClick = true;
// example:
// Have dojo/touch generate clicks without delay, with a move threshold of 10 pixels horizontally and vertically
// | node.dojoClick = 10;
// example:
// Have dojo/touch generate clicks without delay, with a move threshold of 50 pixels horizontally and 10 pixels vertically
// | node.dojoClick = {x:50, y:5};
// example:
// Disable clicks without delay generated by dojo/touch on a node that has an ancestor with property dojoClick set to truthy
// | node.dojoClick = false;
press: function(node, listener){
// summary:
// Register a listener to 'touchstart'|'mousedown' for the given node
// node: Dom
// Target node to listen to
// listener: Function
// Callback function
// returns:
// A handle which will be used to remove the listener by handle.remove()
},
move: function(node, listener){
// summary:
// Register a listener that fires when the mouse cursor or a finger is dragged over the given node.
// node: Dom
// Target node to listen to
// listener: Function
// Callback function
// returns:
// A handle which will be used to remove the listener by handle.remove()
},
release: function(node, listener){
// summary:
// Register a listener to releasing the mouse button while the cursor is over the given node
// (i.e. "mouseup") or for removing the finger from the screen while touching the given node.
// node: Dom
// Target node to listen to
// listener: Function
// Callback function
// returns:
// A handle which will be used to remove the listener by handle.remove()
},
cancel: function(node, listener){
// summary:
// Register a listener to 'touchcancel'|'mouseleave' for the given node
// node: Dom
// Target node to listen to
// listener: Function
// Callback function
// returns:
// A handle which will be used to remove the listener by handle.remove()
},
over: function(node, listener){
// summary:
// Register a listener to 'mouseover' or touch equivalent for the given node
// node: Dom
// Target node to listen to
// listener: Function
// Callback function
// returns:
// A handle which will be used to remove the listener by handle.remove()
},
out: function(node, listener){
// summary:
// Register a listener to 'mouseout' or touch equivalent for the given node
// node: Dom
// Target node to listen to
// listener: Function
// Callback function
// returns:
// A handle which will be used to remove the listener by handle.remove()
},
enter: function(node, listener){
// summary:
// Register a listener to mouse.enter or touch equivalent for the given node
// node: Dom
// Target node to listen to
// listener: Function
// Callback function
// returns:
// A handle which will be used to remove the listener by handle.remove()
},
leave: function(node, listener){
// summary:
// Register a listener to mouse.leave or touch equivalent for the given node
// node: Dom
// Target node to listen to
// listener: Function
// Callback function
// returns:
// A handle which will be used to remove the listener by handle.remove()
}
};
=====*/
1 && (dojo.touch = touch);
return touch;
});
},
'dijit/_Contained':function(){
define([
"dojo/_base/declare", // declare
"./registry" // registry.getEnclosingWidget(), registry.byNode()
], function(declare, registry){
// module:
// dijit/_Contained
return declare("dijit._Contained", null, {
// summary:
// Mixin for widgets that are children of a container widget
// example:
// | // make a basic custom widget that knows about its parents
// | declare("my.customClass",[dijit._WidgetBase, dijit._Contained],{});
_getSibling: function(/*String*/ which){
// summary:
// Returns next or previous sibling
// which:
// Either "next" or "previous"
// tags:
// private
var p = this.getParent();
return (p && p._getSiblingOfChild && p._getSiblingOfChild(this, which == "previous" ? -1 : 1)) || null; // dijit/_WidgetBase
},
getPreviousSibling: function(){
// summary:
// Returns null if this is the first child of the parent,
// otherwise returns the next element sibling to the "left".
return this._getSibling("previous"); // dijit/_WidgetBase
},
getNextSibling: function(){
// summary:
// Returns null if this is the last child of the parent,
// otherwise returns the next element sibling to the "right".
return this._getSibling("next"); // dijit/_WidgetBase
},
getIndexInParent: function(){
// summary:
// Returns the index of this widget within its container parent.
// It returns -1 if the parent does not exist, or if the parent
// is not a dijit/_Container
var p = this.getParent();
if(!p || !p.getIndexOfChild){
return -1; // int
}
return p.getIndexOfChild(this); // int
}
});
});
},
'dijit/_Container':function(){
define([
"dojo/_base/array", // array.forEach array.indexOf
"dojo/_base/declare", // declare
"dojo/dom-construct", // domConstruct.place
"dojo/_base/kernel" // kernel.deprecated
], function(array, declare, domConstruct, kernel){
// module:
// dijit/_Container
return declare("dijit._Container", null, {
// summary:
// Mixin for widgets that contain HTML and/or a set of widget children.
buildRendering: function(){
this.inherited(arguments);
if(!this.containerNode){
// All widgets with descendants must set containerNode.
// NB: this code doesn't quite work right because for TabContainer it runs before
// _TemplatedMixin::buildRendering(), and thus
// sets this.containerNode to this.domNode, later to be overridden by the assignment in the template.
this.containerNode = this.domNode;
}
},
addChild: function(/*dijit/_WidgetBase*/ widget, /*int?*/ insertIndex){
// summary:
// Makes the given widget a child of this widget.
// description:
// Inserts specified child widget's dom node as a child of this widget's
// container node, and possibly does other processing (such as layout).
// I want to just call domConstruct.place(widget.domNode, this.containerNode, insertIndex), but the counting
// is thrown off by text nodes and comment nodes that show up when constructed by markup.
// In the future consider stripping those nodes on construction, either in the parser or this widget code.
var refNode = this.containerNode;
if(insertIndex > 0){
// Old-school way to get nth child; dojo.query would be easier but _Container was weened from dojo.query
// in #10087 to minimize download size. Not sure if that's still and issue with new smaller dojo/query.
refNode = refNode.firstChild;
while(insertIndex > 0){
if(refNode.nodeType == 1){ insertIndex--; }
refNode = refNode.nextSibling;
}
if(refNode){
insertIndex = "before";
}else{
// to support addChild(child, n-1) where there are n children (should add child at end)
refNode = this.containerNode;
insertIndex = "last";
}
}
domConstruct.place(widget.domNode, refNode, insertIndex);
// If I've been started but the child widget hasn't been started,
// start it now. Make sure to do this after widget has been
// inserted into the DOM tree, so it can see that it's being controlled by me,
// so it doesn't try to size itself.
if(this._started && !widget._started){
widget.startup();
}
},
removeChild: function(/*Widget|int*/ widget){
// summary:
// Removes the passed widget instance from this widget but does
// not destroy it. You can also pass in an integer indicating
// the index within the container to remove (ie, removeChild(5) removes the sixth widget).
if(typeof widget == "number"){
widget = this.getChildren()[widget];
}
if(widget){
var node = widget.domNode;
if(node && node.parentNode){
node.parentNode.removeChild(node); // detach but don't destroy
}
}
},
hasChildren: function(){
// summary:
// Returns true if widget has child widgets, i.e. if this.containerNode contains widgets.
return this.getChildren().length > 0; // Boolean
},
_getSiblingOfChild: function(/*dijit/_WidgetBase*/ child, /*int*/ dir){
// summary:
// Get the next or previous widget sibling of child
// dir:
// if 1, get the next sibling
// if -1, get the previous sibling
// tags:
// private
var children = this.getChildren(),
idx = array.indexOf(children, child); // int
return children[idx + dir];
},
getIndexOfChild: function(/*dijit/_WidgetBase*/ child){
// summary:
// Gets the index of the child in this container or -1 if not found
return array.indexOf(this.getChildren(), child); // int
}
});
});
},
'dojox/mobile/TransitionEvent':function(){
define(["dojo/_base/declare", "dojo/on"], function(declare, on){
return declare("dojox.mobile.TransitionEvent", null, {
// summary:
// A class used to trigger view transitions.
constructor: function(/*DomNode*/target, /*Object*/transitionOptions, /*Event?*/triggerEvent){
// summary:
// Creates a transition event.
// target:
// The DOM node that initiates the transition (for example a ListItem).
// transitionOptions:
// Contains the transition options.
// triggerEvent:
// The event that triggered the transition (for example a touch event on a ListItem).
this.transitionOptions = transitionOptions;
this.target = target;
this.triggerEvent = triggerEvent||null;
},
dispatch: function(){
// summary:
// Dispatches this transition event. Emits a "startTransition" event on the target.
var opts = {bubbles:true, cancelable:true, detail: this.transitionOptions, triggerEvent: this.triggerEvent};
var evt = on.emit(this.target,"startTransition", opts);
}
});
});
},
'dojox/mobile/viewRegistry':function(){
define([
"dojo/_base/array",
"dojo/dom-class",
"dijit/registry"
], function(array, domClass, registry){
// module:
// dojox/mobile/viewRegistry
var viewRegistry = {
// summary:
// A registry of existing views.
// length: Number
// The number of registered views.
length: 0,
// hash: [private] Object
// The object used to register views.
hash: {},
// initialView: [private] dojox/mobile/View
// The initial view.
initialView: null,
add: function(/*dojox/mobile/View*/ view){
// summary:
// Adds a view to the registry.
this.hash[view.id] = view;
this.length++;
},
remove: function(/*String*/ id){
// summary:
// Removes a view from the registry.
if(this.hash[id]){
delete this.hash[id];
this.length--;
}
},
getViews: function(){
// summary:
// Gets all registered views.
// returns: Array
var arr = [];
for(var i in this.hash){
arr.push(this.hash[i]);
}
return arr;
},
getParentView: function(/*dojox/mobile/View*/ view){
// summary:
// Gets the parent view of the specified view.
// returns: dojox/mobile/View
for(var v = view.getParent(); v; v = v.getParent()){
if(domClass.contains(v.domNode, "mblView")){ return v; }
}
return null;
},
getChildViews: function(/*dojox/mobile/View*/ parent){
// summary:
// Gets the children views of the specified view.
// returns: Array
return array.filter(this.getViews(), function(v){ return this.getParentView(v) === parent; }, this);
},
getEnclosingView: function(/*DomNode*/ node){
// summary:
// Gets the view containing the specified DOM node.
// returns: dojox/mobile/View
for(var n = node; n && n.tagName !== "BODY"; n = n.parentNode){
if(n.nodeType === 1 && domClass.contains(n, "mblView")){
return registry.byNode(n);
}
}
return null;
},
getEnclosingScrollable: function(/*DomNode*/ node){
// summary:
// Gets the dojox/mobile/scrollable object containing the specified DOM node.
// returns: dojox/mobile/scrollable
for(var w = registry.getEnclosingWidget(node); w; w = w.getParent()){
if(w.scrollableParams && w._v){ return w; }
}
return null;
}
};
return viewRegistry;
});
},
'dojox/mobile/ProgressIndicator':function(){
define([
"dojo/_base/config",
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/dom-class",
"dojo/dom-construct",
"dojo/dom-geometry",
"dojo/dom-style",
"dojo/has",
"dijit/_Contained",
"dijit/_WidgetBase",
"./_css3",
"dojo/has!dojo-bidi?dojox/mobile/bidi/ProgressIndicator"
], function(config, declare, lang, domClass, domConstruct, domGeometry, domStyle, has, Contained, WidgetBase, css3, BidiProgressIndicator){
// module:
// dojox/mobile/ProgressIndicator
var cls = declare("dojox.mobile.ProgressIndicator", [WidgetBase, Contained], {
// summary:
// A progress indication widget.
// description:
// ProgressIndicator is a round spinning graphical representation
// that indicates the current task is ongoing.
// interval: Number
// The time interval in milliseconds for updating the spinning
// indicator.
interval: 100,
// size: [const] Number
// The size of the indicator in pixels.
// Note that changing the value of the property after the widget
// creation has no effect.
size: 40,
// removeOnStop: Boolean
// If true, this widget is removed from the parent node
// when stop() is called.
removeOnStop: true,
// startSpinning: Boolean
// If true, calls start() to run the indicator at startup.
startSpinning: false,
// center: Boolean
// If true, the indicator is displayed as center aligned.
center: true,
// colors: String[]
// An array of indicator colors. 12 colors have to be given.
// If colors are not specified, CSS styles
// (mblProg0Color - mblProg11Color) are used.
colors: null,
/* internal properties */
// baseClass: String
// The name of the CSS class of this widget.
baseClass: "mblProgressIndicator",
constructor: function(){
// summary:
// Creates a new instance of the class.
this.colors = [];
this._bars = [];
},
buildRendering: function(){
this.inherited(arguments);
if(this.center){
domClass.add(this.domNode, "mblProgressIndicatorCenter");
}
this.containerNode = domConstruct.create("div", {className:"mblProgContainer"}, this.domNode);
this.spinnerNode = domConstruct.create("div", null, this.containerNode);
for(var i = 0; i < 12; i++){
var div = domConstruct.create("div", {className:"mblProg mblProg"+i}, this.spinnerNode);
this._bars.push(div);
}
this.scale(this.size);
if(this.startSpinning){
this.start();
}
},
scale: function(/*Number*/size){
// summary:
// Changes the size of the indicator.
// size:
// The size of the indicator in pixels.
var scale = size / 40;
domStyle.set(this.containerNode, css3.add({}, {
transform: "scale(" + scale + ")",
transformOrigin: "0 0"
}));
domGeometry.setMarginBox(this.domNode, {w:size, h:size});
domGeometry.setMarginBox(this.containerNode, {w:size / scale, h:size / scale});
},
start: function(){
// summary:
// Starts the spinning of the ProgressIndicator.
if(this.imageNode){
var img = this.imageNode;
var l = Math.round((this.containerNode.offsetWidth - img.offsetWidth) / 2);
var t = Math.round((this.containerNode.offsetHeight - img.offsetHeight) / 2);
img.style.margin = t+"px "+l+"px";
return;
}
var cntr = 0;
var _this = this;
var n = 12;
this.timer = setInterval(function(){
cntr--;
cntr = cntr < 0 ? n - 1 : cntr;
var c = _this.colors;
for(var i = 0; i < n; i++){
var idx = (cntr + i) % n;
if(c[idx]){
_this._bars[i].style.backgroundColor = c[idx];
}else{
domClass.replace(_this._bars[i],
"mblProg" + idx + "Color",
"mblProg" + (idx === n - 1 ? 0 : idx + 1) + "Color");
}
}
}, this.interval);
},
stop: function(){
// summary:
// Stops the spinning of the ProgressIndicator.
if(this.timer){
clearInterval(this.timer);
}
this.timer = null;
if(this.removeOnStop && this.domNode && this.domNode.parentNode){
this.domNode.parentNode.removeChild(this.domNode);
}
},
setImage: function(/*String*/file){
// summary:
// Sets an indicator icon image file (typically animated GIF).
// If null is specified, restores the default spinner.
if(file){
this.imageNode = domConstruct.create("img", {src:file}, this.containerNode);
this.spinnerNode.style.display = "none";
}else{
if(this.imageNode){
this.containerNode.removeChild(this.imageNode);
this.imageNode = null;
}
this.spinnerNode.style.display = "";
}
},
destroy: function(){
this.inherited(arguments);
if(this === cls._instance){
cls._instance = null;
}
}
});
cls = has("dojo-bidi") ? declare("dojox.mobile.ProgressIndicator", [cls, BidiProgressIndicator]) : cls;
cls._instance = null;
cls.getInstance = function(props){
if(!cls._instance){
cls._instance = new cls(props);
}
return cls._instance;
};
return cls;
});
},
'dojox/mobile/_css3':function(){
define([
"dojo/_base/window",
"dojo/_base/array",
"dojo/has"
], function(win, arr, has){
// caches for capitalized names and hypen names
var cnames = [], hnames = [];
// element style used for feature testing
var style = win.doc.createElement("div").style;
// We just test webkit prefix for now since our themes only have standard and webkit
// (see dojox/mobile/themes/common/css3.less)
// More prefixes can be added if/when we add them to css3.less.
var prefixes = ["webkit"];
// Does the browser support CSS3 animations?
has.add("css3-animations", function(global, document, element){
var style = element.style;
return (style["animation"] !== undefined && style["transition"] !== undefined) ||
arr.some(prefixes, function(p){
return style[p+"Animation"] !== undefined && style[p+"Transition"] !== undefined;
});
});
// Indicates whether style 'transition' returns empty string instead of
// undefined, although TransitionEvent is not supported.
// Reported on Android 4.1.x on some devices: https://bugs.dojotoolkit.org/ticket/17164
has.add("t17164", function(global, document, element){
return (element.style["transition"] !== undefined) && !('TransitionEvent' in window);
});
var css3 = {
// summary:
// This module provide some cross-browser support for CSS3 properties.
name: function(/*String*/p, /*Boolean?*/hyphen){
// summary:
// Returns the name of a CSS3 property with the correct prefix depending on the browser.
// p:
// The (non-prefixed) property name. The property name is assumed to be consistent with
// the hyphen argument, for example "transition-property" if hyphen is true, or "transitionProperty"
// if hyphen is false. If the browser supports the non-prefixed property, the property name will be
// returned unchanged.
// hyphen:
// Optional, true if hyphen notation should be used (for example "transition-property" or "-webkit-transition-property"),
// false for camel-case notation (for example "transitionProperty" or "webkitTransitionProperty").
var n = (hyphen?hnames:cnames)[p];
if(!n){
if(/End|Start/.test(p)){
// event names: no good way to feature-detect, so we
// assume they have the same prefix as the corresponding style property
var idx = p.length - (p.match(/End/) ? 3 : 5);
var s = p.substr(0, idx);
var pp = this.name(s);
if(pp == s){
// no prefix, standard event names are all lowercase
n = p.toLowerCase();
}else{
// prefix, e.g. webkitTransitionEnd (camel case)
n = pp + p.substr(idx);
}
}else if(p == "keyframes"){
// special case for keyframes, we also rely on consistency between 'animation' and 'keyframes'
var pk = this.name("animation", hyphen);
if(pk == "animation"){
n = p;
}else if(hyphen){
n = pk.replace(/animation/, "keyframes");
}else{
n = pk.replace(/Animation/, "Keyframes");
}
}else{
// convert name to camel-case for feature test
var cn = hyphen ? p.replace(/-(.)/g, function(match, p1){
return p1.toUpperCase();
}) : p;
if(style[cn] !== undefined && !has('t17164')){
// standard non-prefixed property is supported
n = p;
}else{
// try prefixed versions
cn = cn.charAt(0).toUpperCase() + cn.slice(1);
arr.some(prefixes, function(prefix){
if(style[prefix+cn] !== undefined){
if(hyphen){
n = "-" + prefix + "-" + p;
}else{
n = prefix + cn;
}
}
});
}
}
if(!n){
// The property is not supported, just return it unchanged, it will be ignored.
n = p;
}
(hyphen?hnames:cnames)[p] = n;
}
return n;
},
add: function(/*Object*/styles, /*Object*/css3Styles){
// summary:
// Prefixes all property names in "css3Styles" and adds the prefixed properties in "styles".
// Used as a convenience when an object is passed to domStyle.set to set multiple styles.
// example:
// domStyle.set(bar, css3.add({
// opacity: 0.6,
// position: "absolute",
// backgroundColor: "#606060"
// }, {
// borderRadius: "2px",
// transformOrigin: "0 0"
// }));
// returns:
// The "styles" argument where the CSS3 styles have been added.
for(var p in css3Styles){
if(css3Styles.hasOwnProperty(p)){
styles[css3.name(p)] = css3Styles[p];
}
}
return styles;
}
};
return css3;
});
},
'dojox/mobile/parser':function(){
define([
"dojo/_base/kernel",
"dojo/_base/array",
"dojo/_base/config",
"dojo/_base/lang",
"dojo/_base/window",
"dojo/ready"
], function(dojo, array, config, lang, win, ready){
// module:
// dojox/mobile/parser
var dm = lang.getObject("dojox.mobile", true);
var Parser = function(){
// summary:
// A lightweight parser.
// description:
// dojox/mobile/parser is an extremely small subset of dojo/parser.
// It has no additional features over dojo/parser, so there is no
// benefit in terms of features by using dojox/mobile/parser instead
// of dojo/parser. However, if dojox/mobile/parser's capabilities are
// enough for your application, using it could reduce the total code size.
var _ctorMap = {};
var getCtor = function(type, mixins){
if(typeof(mixins) === "string"){
var t = type + ":" + mixins.replace(/ /g, "");
return _ctorMap[t] ||
(_ctorMap[t] = getCtor(type).createSubclass(array.map(mixins.split(/, */), getCtor)));
}
return _ctorMap[type] || (_ctorMap[type] = lang.getObject(type) || require(type));
};
var _eval = function(js){ return eval(js); };
this.instantiate = function(/* DomNode[] */nodes, /* Object? */mixin, /* Object? */options){
// summary:
// Function for instantiating a list of widget nodes.
// nodes:
// The list of DomNodes to walk and instantiate widgets on.
mixin = mixin || {};
options = options || {};
var i, ws = [];
if(nodes){
for(i = 0; i < nodes.length; i++){
var n = nodes[i],
type = n._type,
ctor = getCtor(type, n.getAttribute("data-dojo-mixins")),
proto = ctor.prototype,
params = {}, prop, v, t;
lang.mixin(params, _eval.call(options.propsThis, '({'+(n.getAttribute("data-dojo-props")||"")+'})'));
lang.mixin(params, options.defaults);
lang.mixin(params, mixin);
for(prop in proto){
v = n.getAttributeNode(prop);
v = v && v.nodeValue;
t = typeof proto[prop];
if(!v && (t !== "boolean" || v !== "")){ continue; }
if(lang.isArray(proto[prop])){
params[prop] = v.split(/\s*,\s*/);
}else if(t === "string"){
params[prop] = v;
}else if(t === "number"){
params[prop] = v - 0;
}else if(t === "boolean"){
params[prop] = (v !== "false");
}else if(t === "object"){
params[prop] = eval("(" + v + ")");
}else if(t === "function"){
params[prop] = lang.getObject(v, false) || new Function(v);
n.removeAttribute(prop);
}
}
params["class"] = n.className;
if(!params.style){ params.style = n.style.cssText; }
v = n.getAttribute("data-dojo-attach-point");
if(v){ params.dojoAttachPoint = v; }
v = n.getAttribute("data-dojo-attach-event");
if(v){ params.dojoAttachEvent = v; }
var instance = new ctor(params, n);
ws.push(instance);
var jsId = n.getAttribute("jsId") || n.getAttribute("data-dojo-id");
if(jsId){
lang.setObject(jsId, instance);
}
}
for(i = 0; i < ws.length; i++){
var w = ws[i];
!options.noStart && w.startup && !w._started && w.startup();
}
}
return ws;
};
this.parse = function(/* DomNode */ rootNode, /* Object? */ options){
// summary:
// Function to handle parsing for widgets in the current document.
// It is not as powerful as the full parser, but it will handle basic
// use cases fine.
// rootNode:
// The root node in the document to parse from
if(!rootNode){
rootNode = win.body();
}else if(!options && rootNode.rootNode){
// Case where 'rootNode' is really a params object.
options = rootNode;
rootNode = rootNode.rootNode;
}
var nodes = rootNode.getElementsByTagName("*");
var i, j, list = [];
for(i = 0; i < nodes.length; i++){
var n = nodes[i],
type = (n._type = n.getAttribute("dojoType") || n.getAttribute("data-dojo-type"));
if(type){
if(n._skip){
n._skip = "";
continue;
}
if(getCtor(type).prototype.stopParser && !(options && options.template)){
var arr = n.getElementsByTagName("*");
for(j = 0; j < arr.length; j++){
arr[j]._skip = "1";
}
}
list.push(n);
}
}
var mixin = options && options.template ? {template: true} : null;
return this.instantiate(list, mixin, options);
};
};
// Singleton. (TODO: replace parser class and singleton w/a simple hash of functions)
var parser = new Parser();
if(config.parseOnLoad){
ready(100, function(){
// Now that all the modules are loaded, check if the app loaded dojo/parser too.
// If it did, let dojo/parser handle the parseOnLoad flag instead of me.
try{
if(!require("dojo/parser")){
// IE6 takes this path when dojo/parser unavailable, rather than catch() block below,
// due to http://support.microsoft.com/kb/944397
parser.parse();
}
}catch(e){
// Other browsers (and later versions of IE) take this path when dojo/parser unavailable
parser.parse();
}
});
}
dm.parser = parser; // for backward compatibility
dojo.parser = dojo.parser || parser; // in case user application calls dojo.parser
return parser;
});
},
'dojox/mobile':function(){
define([
".",
"dojo/_base/lang",
"dojox/mobile/_base"
], function(dojox, lang, base){
lang.getObject("mobile", true, dojox);
/*=====
return {
// summary:
// Deprecated. Should require dojox/mobile classes directly rather than trying to access them through
// this module.
};
=====*/
return dojox.mobile;
});
},
'dojox/main':function(){
define(["dojo/_base/kernel"], function(dojo) {
// module:
// dojox/main
/*=====
return {
// summary:
// The dojox package main module; dojox package is somewhat unusual in that the main module currently just provides an empty object.
// Apps should require modules from the dojox packages directly, rather than loading this module.
};
=====*/
return dojo.dojox;
});
},
'dojox/mobile/_base':function(){
define([
"./common",
"./View",
"./Heading",
"./RoundRect",
"./RoundRectCategory",
"./EdgeToEdgeCategory",
"./RoundRectList",
"./EdgeToEdgeList",
"./ListItem",
"./Container",
"./Pane",
"./Switch",
"./ToolBarButton",
"./ProgressIndicator"
], function(common, View, Heading, RoundRect, RoundRectCategory, EdgeToEdgeCategory, RoundRectList, EdgeToEdgeList, ListItem, Switch, ToolBarButton, ProgressIndicator){
// module:
// dojox/mobile/_base
/*=====
return {
// summary:
// Includes the basic dojox/mobile modules: common, View, Heading,
// RoundRect, RoundRectCategory, EdgeToEdgeCategory, RoundRectList,
// EdgeToEdgeList, ListItem, Container, Pane, Switch, ToolBarButton,
// and ProgressIndicator.
};
=====*/
return common;
});
},
'dojox/mobile/common':function(){
define([
"dojo/_base/array",
"dojo/_base/config",
"dojo/_base/connect",
"dojo/_base/lang",
"dojo/_base/window",
"dojo/_base/kernel",
"dojo/dom",
"dojo/dom-class",
"dojo/dom-construct",
"dojo/domReady",
"dojo/ready",
"dojo/touch",
"dijit/registry",
"./sniff",
"./uacss" // (no direct references)
], function(array, config, connect, lang, win, kernel, dom, domClass, domConstruct, domReady, ready, touch, registry, has){
// module:
// dojox/mobile/common
var dm = lang.getObject("dojox.mobile", true);
// tell dojo/touch to generate synthetic clicks immediately
// and regardless of preventDefault() calls on touch events
win.doc.dojoClick = true;
/// ... but let user disable this by removing dojoClick from the document
if(has("touch")){
// Do we need to send synthetic clicks when preventDefault() is called on touch events?
// This is normally true on anything except Android 4.1+ and IE10+, but users reported
// exceptions like Galaxy Note 2. So let's use a has("clicks-prevented") flag, and let
// applications override it through data-dojo-config="has:{'clicks-prevented':true}" if needed.
has.add("clicks-prevented", !(has("android") >= 4.1 || (has("ie") === 10) || (!has("ie") && has("trident") > 6)));
if(has("clicks-prevented")){
dm._sendClick = function(target, e){
// dojo/touch will send a click if dojoClick is set, so don't do it again.
for(var node = target; node; node = node.parentNode){
if(node.dojoClick){
return;
}
}
var ev = win.doc.createEvent("MouseEvents");
ev.initMouseEvent("click", true, true, win.global, 1, e.screenX, e.screenY, e.clientX, e.clientY);
target.dispatchEvent(ev);
};
}
}
dm.getScreenSize = function(){
// summary:
// Returns the dimensions of the browser window.
return {
h: win.global.innerHeight || win.doc.documentElement.clientHeight,
w: win.global.innerWidth || win.doc.documentElement.clientWidth
};
};
dm.updateOrient = function(){
// summary:
// Updates the orientation specific CSS classes, 'dj_portrait' and
// 'dj_landscape'.
var dim = dm.getScreenSize();
domClass.replace(win.doc.documentElement,
dim.h > dim.w ? "dj_portrait" : "dj_landscape",
dim.h > dim.w ? "dj_landscape" : "dj_portrait");
};
dm.updateOrient();
dm.tabletSize = 500;
dm.detectScreenSize = function(/*Boolean?*/force){
// summary:
// Detects the screen size and determines if the screen is like
// phone or like tablet. If the result is changed,
// it sets either of the following css class to ``:
//
// - 'dj_phone'
// - 'dj_tablet'
//
// and it publishes either of the following events:
//
// - '/dojox/mobile/screenSize/phone'
// - '/dojox/mobile/screenSize/tablet'
var dim = dm.getScreenSize();
var sz = Math.min(dim.w, dim.h);
var from, to;
if(sz >= dm.tabletSize && (force || (!this._sz || this._sz < dm.tabletSize))){
from = "phone";
to = "tablet";
}else if(sz < dm.tabletSize && (force || (!this._sz || this._sz >= dm.tabletSize))){
from = "tablet";
to = "phone";
}
if(to){
domClass.replace(win.doc.documentElement, "dj_"+to, "dj_"+from);
connect.publish("/dojox/mobile/screenSize/"+to, [dim]);
}
this._sz = sz;
};
dm.detectScreenSize();
// dojox/mobile.hideAddressBarWait: Number
// The time in milliseconds to wait before the fail-safe hiding address
// bar runs. The value must be larger than 800.
dm.hideAddressBarWait = typeof(config.mblHideAddressBarWait) === "number" ?
config.mblHideAddressBarWait : 1500;
dm.hide_1 = function(){
// summary:
// Internal function to hide the address bar.
// tags:
// private
scrollTo(0, 1);
dm._hidingTimer = (dm._hidingTimer == 0) ? 200 : dm._hidingTimer * 2;
setTimeout(function(){ // wait for a while for "scrollTo" to finish
if(dm.isAddressBarHidden() || dm._hidingTimer > dm.hideAddressBarWait){
// Succeeded to hide address bar, or failed but timed out
dm.resizeAll();
dm._hiding = false;
}else{
// Failed to hide address bar, so retry after a while
setTimeout(dm.hide_1, dm._hidingTimer);
}
}, 50); //50ms is an experiential value
};
dm.hideAddressBar = function(/*Event?*/evt){
// summary:
// Hides the address bar.
// description:
// Tries to hide the address bar a couple of times. The purpose is to do
// it as quick as possible while ensuring the resize is done after the hiding
// finishes.
if(dm.disableHideAddressBar || dm._hiding){ return; }
dm._hiding = true;
dm._hidingTimer = has("ios") ? 200 : 0; // Need to wait longer in case of iPhone
var minH = screen.availHeight;
if(has('android')){
minH = outerHeight / devicePixelRatio;
// On some Android devices such as Galaxy SII, minH might be 0 at this time.
// In that case, retry again after a while. (200ms is an experiential value)
if(minH == 0){
dm._hiding = false;
setTimeout(function(){ dm.hideAddressBar(); }, 200);
}
// On some Android devices such as HTC EVO, "outerHeight/devicePixelRatio"
// is too short to hide address bar, so make it high enough
if(minH <= innerHeight){ minH = outerHeight; }
// On Android 2.2/2.3, hiding address bar fails when "overflow:hidden" style is
// applied to html/body element, so force "overflow:visible" style
if(has('android') < 3){
win.doc.documentElement.style.overflow = win.body().style.overflow = "visible";
}
}
if(win.body().offsetHeight < minH){ // to ensure enough height for scrollTo to work
win.body().style.minHeight = minH + "px";
dm._resetMinHeight = true;
}
setTimeout(dm.hide_1, dm._hidingTimer);
};
dm.isAddressBarHidden = function(){
return pageYOffset === 1;
};
dm.resizeAll = function(/*Event?*/evt, /*Widget?*/root){
// summary:
// Calls the resize() method of all the top level resizable widgets.
// description:
// Finds all widgets that do not have a parent or the parent does not
// have the resize() method, and calls resize() for them.
// If a widget has a parent that has resize(), calling widget's
// resize() is its parent's responsibility.
// evt:
// Native event object
// root:
// If specified, searches the specified widget recursively for top-level
// resizable widgets.
// root.resize() is always called regardless of whether root is a
// top level widget or not.
// If omitted, searches the entire page.
if(dm.disableResizeAll){ return; }
connect.publish("/dojox/mobile/resizeAll", [evt, root]); // back compat
connect.publish("/dojox/mobile/beforeResizeAll", [evt, root]);
if(dm._resetMinHeight){
win.body().style.minHeight = dm.getScreenSize().h + "px";
}
dm.updateOrient();
dm.detectScreenSize();
var isTopLevel = function(w){
var parent = w.getParent && w.getParent();
return !!((!parent || !parent.resize) && w.resize);
};
var resizeRecursively = function(w){
array.forEach(w.getChildren(), function(child){
if(isTopLevel(child)){ child.resize(); }
resizeRecursively(child);
});
};
if(root){
if(root.resize){ root.resize(); }
resizeRecursively(root);
}else{
array.forEach(array.filter(registry.toArray(), isTopLevel),
function(w){ w.resize(); });
}
connect.publish("/dojox/mobile/afterResizeAll", [evt, root]);
};
dm.openWindow = function(url, target){
// summary:
// Opens a new browser window with the given URL.
win.global.open(url, target || "_blank");
};
dm._detectWindowsTheme = function(){
// summary:
// Detects if the "windows" theme is used,
// if it is used, set has("windows-theme") and
// add the .windows_theme class on the document.
// Avoid unwanted (un)zoom on some WP8 devices (at least Nokia Lumia 920)
if(navigator.userAgent.match(/IEMobile\/10\.0/)){
domConstruct.create("style",
{innerHTML: "@-ms-viewport {width: auto !important}"}, win.doc.head);
}
var setWindowsTheme = function(){
domClass.add(win.doc.documentElement, "windows_theme");
kernel.experimental("Dojo Mobile Windows theme", "Behavior and appearance of the Windows theme are experimental.");
};
// First see if the "windows-theme" feature has already been set explicitly
// in that case skip aut-detect
var windows = has("windows-theme");
if(windows !== undefined){
if(windows){
setWindowsTheme();
}
return;
}
// check css
var i, j;
var check = function(href){
// TODO: find a better regexp to match?
if(href && href.indexOf("/windows/") !== -1){
has.add("windows-theme", true);
setWindowsTheme();
return true;
}
return false;
};
// collect @import
var s = win.doc.styleSheets;
for(i = 0; i < s.length; i++){
if(s[i].href){ continue; }
var r = s[i].cssRules || s[i].imports;
if(!r){ continue; }
for(j = 0; j < r.length; j++){
if(check(r[j].href)){
return;
}
}
}
// collect
var elems = win.doc.getElementsByTagName("link");
for(i = 0; i < elems.length; i++){
if(check(elems[i].href)){
return;
}
}
};
if(config.mblApplyPageStyles !== false){
domClass.add(win.doc.documentElement, "mobile");
}
if(has('chrome')){
// dojox/mobile does not load uacss (only _compat does), but we need dj_chrome.
domClass.add(win.doc.documentElement, "dj_chrome");
}
if(win.global._no_dojo_dm){
// deviceTheme seems to be loaded from a script tag (= non-dojo usage)
var _dm = win.global._no_dojo_dm;
for(var i in _dm){
dm[i] = _dm[i];
}
dm.deviceTheme.setDm(dm);
}
// flag for Android transition animation flicker workaround
has.add('mblAndroidWorkaround',
config.mblAndroidWorkaround !== false && has('android') < 3, undefined, true);
has.add('mblAndroid3Workaround',
config.mblAndroid3Workaround !== false && has('android') >= 3, undefined, true);
dm._detectWindowsTheme();
dm.setSelectable = function(/*Node*/node, /*Boolean*/selectable){
var nodes, i;
node = dom.byId(node);
if (has("ie") <= 9){
// (IE < 10) Fall back to setting/removing the
// unselectable attribute on the element and all its children
// except the input element (see https://bugs.dojotoolkit.org/ticket/13846)
nodes = node.getElementsByTagName("*");
i = nodes.length;
if(selectable){
node.removeAttribute("unselectable");
while(i--){
nodes[i].removeAttribute("unselectable");
}
}else{
node.setAttribute("unselectable", "on");
while(i--){
if (nodes[i].tagName !== "INPUT"){
nodes[i].setAttribute("unselectable", "on");
}
}
}
}else{
domClass.toggle(node, "unselectable", !selectable);
}
};
var touchActionProp = has("pointer-events") ? "touchAction" : has("MSPointer") ? "msTouchAction" : null;
dm._setTouchAction = touchActionProp ? function(/*Node*/node, /*Boolean*/value){
node.style[touchActionProp] = value;
} : function(){};
// Set the background style using dojo/domReady, not dojo/ready, to ensure it is already
// set at widget initialization time. (#17418)
domReady(function(){
if(config.mblApplyPageStyles !== false){
domClass.add(win.body(), "mblBackground");
}
});
ready(function(){
dm.detectScreenSize(true);
if(config.mblAndroidWorkaroundButtonStyle !== false && has('android')){
// workaround for the form button disappearing issue on Android 2.2-4.0
domConstruct.create("style", {innerHTML:"BUTTON,INPUT[type='button'],INPUT[type='submit'],INPUT[type='reset'],INPUT[type='file']::-webkit-file-upload-button{-webkit-appearance:none;} audio::-webkit-media-controls-play-button,video::-webkit-media-controls-play-button{-webkit-appearance:media-play-button;} video::-webkit-media-controls-fullscreen-button{-webkit-appearance:media-fullscreen-button;}"}, win.doc.head, "first");
}
if(has('mblAndroidWorkaround')){
// add a css class to show view offscreen for android flicker workaround
domConstruct.create("style", {innerHTML:".mblView.mblAndroidWorkaround{position:absolute;top:-9999px !important;left:-9999px !important;}"}, win.doc.head, "last");
}
var f = dm.resizeAll;
// Address bar hiding
var isHidingPossible =
navigator.appVersion.indexOf("Mobile") != -1 && // only mobile browsers
// #17455: hiding Safari's address bar works in iOS < 7 but this is
// no longer possible since iOS 7. Hence, exclude iOS 7 and later:
!(has("ios") >= 7);
// You can disable the hiding of the address bar with the following dojoConfig:
// var dojoConfig = { mblHideAddressBar: false };
// If unspecified, the flag defaults to true.
if((config.mblHideAddressBar !== false && isHidingPossible) ||
config.mblForceHideAddressBar === true){
dm.hideAddressBar();
if(config.mblAlwaysHideAddressBar === true){
f = dm.hideAddressBar;
}
}
var ios6 = has("ios") >= 6; // Full-screen support for iOS6 or later
if((has('android') || ios6) && win.global.onorientationchange !== undefined){
var _f = f;
var curSize, curClientWidth, curClientHeight;
if(ios6){
curClientWidth = win.doc.documentElement.clientWidth;
curClientHeight = win.doc.documentElement.clientHeight;
}else{ // Android
// Call resize for the first resize event after orientationchange
// because the size information may not yet be up to date when the
// event orientationchange occurs.
f = function(evt){
var _conn = connect.connect(null, "onresize", null, function(e){
connect.disconnect(_conn);
_f(e);
});
};
curSize = dm.getScreenSize();
};
// Android: Watch for resize events when the virtual keyboard is shown/hidden.
// The heuristic to detect this is that the screen width does not change
// and the height changes by more than 100 pixels.
//
// iOS >= 6: Watch for resize events when entering or existing the new iOS6
// full-screen mode. The heuristic to detect this is that clientWidth does not
// change while the clientHeight does change.
connect.connect(null, "onresize", null, function(e){
if(ios6){
var newClientWidth = win.doc.documentElement.clientWidth,
newClientHeight = win.doc.documentElement.clientHeight;
if(newClientWidth == curClientWidth && newClientHeight != curClientHeight){
// full-screen mode has been entered/exited (iOS6)
_f(e);
}
curClientWidth = newClientWidth;
curClientHeight = newClientHeight;
}else{ // Android
var newSize = dm.getScreenSize();
if(newSize.w == curSize.w && Math.abs(newSize.h - curSize.h) >= 100){
// keyboard has been shown/hidden (Android)
_f(e);
}
curSize = newSize;
}
});
}
connect.connect(null, win.global.onorientationchange !== undefined
? "onorientationchange" : "onresize", null, f);
win.body().style.visibility = "visible";
});
// TODO: return functions declared above in this hash, rather than
// dojox.mobile.
/*=====
return {
// summary:
// A common module for dojox/mobile.
// description:
// This module includes common utility functions that are used by
// dojox/mobile widgets. Also, it provides functions that are commonly
// necessary for mobile web applications, such as the hide address bar
// function.
};
=====*/
return dm;
});
},
'dojox/mobile/uacss':function(){
define([
"dojo/_base/kernel",
"dojo/_base/lang",
"dojo/_base/window",
"./sniff"
], function(dojo, lang, win, has){
var html = win.doc.documentElement;
html.className = lang.trim(html.className + " " + [
has('bb') ? "dj_bb" : "",
has('android') ? "dj_android" : "",
has("ios") ? "dj_ios" : "",
has("ios") >= 6 ? "dj_ios6" : "",
has("ios") ? "dj_iphone" : "", // TODO: remove for 2.0
has('ipod') ? "dj_ipod" : "",
has('ipad') ? "dj_ipad" : "",
has('ie') ? "dj_ie": ""
].join(" ").replace(/ +/g," "));
/*=====
return {
// summary:
// Requiring this module adds CSS classes to your document's ` tag:
//
// - "dj_android" when running on Android;
// - "dj_bb" when running on BlackBerry;
// - "dj_ios" when running on iOS (iPhone, iPad or iPod);
// - "dj_ios6" when running on iOS6+; this class is intended for the iphone theme to detect if it must use the iOS 6 variant of the theme. Currently applies on iOS 6 or later.
// - "dj_iphone" when running on iPhone, iPad or iPod (Note: will be changed in future versions to be set only on iPhone);
// - "dj_ipod" when running on iPod;
// - "dj_ipad" when running on iPad.
};
=====*/
return dojo;
});
},
'dojox/mobile/View':function(){
define([
"dojo/_base/array",
"dojo/_base/config",
"dojo/_base/connect",
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/sniff",
"dojo/_base/window",
"dojo/_base/Deferred",
"dojo/dom",
"dojo/dom-class",
"dojo/dom-construct",
"dojo/dom-geometry",
"dojo/dom-style",
"dijit/registry",
"dijit/_Contained",
"dijit/_Container",
"dijit/_WidgetBase",
"./ViewController", // to load ViewController for you (no direct references)
"./common",
"./transition",
"./viewRegistry",
"./_css3"
], function(array, config, connect, declare, lang, has, win, Deferred, dom, domClass, domConstruct, domGeometry, domStyle, registry, Contained, Container, WidgetBase, ViewController, common, transitDeferred, viewRegistry, css3){
// module:
// dojox/mobile/View
var dm = lang.getObject("dojox.mobile", true);
return declare("dojox.mobile.View", [WidgetBase, Container, Contained], {
// summary:
// A container widget for any HTML element and/or Dojo widgets
// description:
// View is a container widget for any HTML element and/or Dojo widgets.
// As a Dojo widget container it can itself contain View widgets
// forming a set of nested views. A Dojo Mobile application is usually
// made of multiple View widgets and the user can navigate through
// the views back and forth with animated transition effects.
//
// When using several sibling views (direct children of the same
// element), you can use the 'selected' attribute to define whether
// the view should be displayed when the application is launched.
// If no view has selected=true, the first sibling view is displayed
// at startup time.
// selected: Boolean
// If true, the view is displayed at startup time.
selected: false,
// keepScrollPos: Boolean
// If true, the scroll position is kept when transition occurs between views.
keepScrollPos: true,
// tag: String
// The name of the HTML tag to create as domNode. The default value is "div".
tag: "div",
/* internal properties */
baseClass: "mblView",
constructor: function(/*Object*/params, /*DomNode?*/node){
// summary:
// Creates a new instance of the class.
// params:
// Contains the parameters.
// node:
// The DOM node. If none is specified, it is automatically created.
if(node){
dom.byId(node).style.visibility = "hidden";
}
},
destroy: function(){
viewRegistry.remove(this.id);
this.inherited(arguments);
},
buildRendering: function(){
if(!this.templateString){
// Create root node if it wasn't created by _TemplatedMixin
this.domNode = this.containerNode = this.srcNodeRef || domConstruct.create(this.tag);
}
this._animEndHandle = this.connect(this.domNode, css3.name("animationEnd"), "onAnimationEnd");
this._animStartHandle = this.connect(this.domNode, css3.name("animationStart"), "onAnimationStart");
if(!config.mblCSS3Transition){
this._transEndHandle = this.connect(this.domNode, css3.name("transitionEnd"), "onAnimationEnd");
}
if(has('mblAndroid3Workaround')){
// workaround for the screen flicker issue on Android 3.x/4.0
// applying "-webkit-transform-style:preserve-3d" to domNode can avoid
// transition animation flicker
domStyle.set(this.domNode, css3.name("transformStyle"), "preserve-3d");
}
viewRegistry.add(this);
this.inherited(arguments);
},
startup: function(){
if(this._started){ return; }
// Determine which view among the siblings should be visible.
// Priority:
// 1. fragment id in the url (ex. #view1,view2)
// 2. this.selected
// 3. the first view
if(this._visible === undefined){
var views = this.getSiblingViews();
var ids = location.hash && location.hash.substring(1).split(/,/);
var fragView, selectedView, firstView;
array.forEach(views, function(v, i){
if(array.indexOf(ids, v.id) !== -1){ fragView = v; }
if(i == 0){ firstView = v; }
if(v.selected){ selectedView = v; }
v._visible = false;
}, this);
(fragView || selectedView || firstView)._visible = true;
}
if(this._visible){
// The 2nd arg is not to hide its sibling views so that they can be
// correctly initialized.
this.show(true, true);
// Defer firing events to let user connect to events just after creation
// TODO: revisit this for 2.0
this.defer(function(){
this.onStartView();
connect.publish("/dojox/mobile/startView", [this]);
});
}
if(this.domNode.style.visibility === "hidden"){ // this check is to avoid screen flickers
this.domNode.style.visibility = "inherit";
}
// Need to call inherited first - so that child widgets get started
// up correctly
this.inherited(arguments);
var parent = this.getParent();
if(!parent || !parent.resize){ // top level widget
this.resize();
}
if(!this._visible){
// hide() should be called last so that child widgets can be
// initialized while they are visible.
this.hide();
}
},
resize: function(){
// summary:
// Calls resize() of each child widget.
array.forEach(this.getChildren(), function(child){
if(child.resize){ child.resize(); }
});
},
onStartView: function(){
// summary:
// Stub function to connect to from your application.
// description:
// Called only when this view is shown at startup time.
},
onBeforeTransitionIn: function(moveTo, dir, transition, context, method){
// summary:
// Stub function to connect to from your application.
// description:
// Called before the arriving transition occurs.
},
onAfterTransitionIn: function(moveTo, dir, transition, context, method){
// summary:
// Stub function to connect to from your application.
// description:
// Called after the arriving transition occurs.
},
onBeforeTransitionOut: function(moveTo, dir, transition, context, method){
// summary:
// Stub function to connect to from your application.
// description:
// Called before the leaving transition occurs.
},
onAfterTransitionOut: function(moveTo, dir, transition, context, method){
// summary:
// Stub function to connect to from your application.
// description:
// Called after the leaving transition occurs.
},
_clearClasses: function(/*DomNode*/node){
// summary:
// Clean up the domNode classes that were added while making a transition.
// description:
// Remove all the "mbl" prefixed classes except mbl*View.
if(!node){ return; }
var classes = [];
array.forEach(lang.trim(node.className||"").split(/\s+/), function(c){
if(c.match(/^mbl\w*View$/) || c.indexOf("mbl") === -1){
classes.push(c);
}
}, this);
node.className = classes.join(' ');
},
_fixViewState: function(/*DomNode*/toNode){
// summary:
// Sanity check for view transition states.
// description:
// Sometimes uninitialization of Views fails after making view transition,
// and that results in failure of subsequent view transitions.
// This function does the uninitialization for all the sibling views.
var nodes = this.domNode.parentNode.childNodes;
for(var i = 0; i < nodes.length; i++){
var n = nodes[i];
if(n.nodeType === 1 && domClass.contains(n, "mblView")){
this._clearClasses(n);
}
}
this._clearClasses(toNode); // just in case toNode is a sibling of an ancestor.
// #16337
// Uninitialization may fail to clear _inProgress when multiple
// performTransition calls occur in a short duration of time.
var toWidget = registry.byNode(toNode);
if(toWidget){
toWidget._inProgress = false;
}
},
convertToId: function(moveTo){
if(typeof(moveTo) == "string"){
// removes a leading hash mark (#) and params if exists
// ex. "#bar&myParam=0003" -> "bar"
return moveTo.replace(/^#?([^&?]+).*/, "$1");
}
return moveTo;
},
_isBookmarkable: function(detail){
return detail.moveTo && (config.mblForceBookmarkable || detail.moveTo.charAt(0) === '#') && !detail.hashchange;
},
performTransition: function(/*String*/moveTo, /*Number*/transitionDir, /*String*/transition,
/*Object|null*/context, /*String|Function*/method /*...*/){
// summary:
// Function to perform the various types of view transitions, such as fade, slide, and flip.
// moveTo: String
// The id of the transition destination view which resides in
// the current page.
// If the value has a hash sign ('#') before the id
// (e.g. #view1) and the dojo/hash module is loaded by the user
// application, the view transition updates the hash in the
// browser URL so that the user can bookmark the destination
// view. In this case, the user can also use the browser's
// back/forward button to navigate through the views in the
// browser history.
// If null, transitions to a blank view.
// If '#', returns immediately without transition.
// transitionDir: Number
// The transition direction. If 1, transition forward. If -1, transition backward.
// For example, the slide transition slides the view from right to left when transitionDir == 1,
// and from left to right when transitionDir == -1.
// transition: String
// A type of animated transition effect. You can choose from
// the standard transition types, "slide", "fade", "flip", or
// from the extended transition types, "cover", "coverv",
// "dissolve", "reveal", "revealv", "scaleIn", "scaleOut",
// "slidev", "swirl", "zoomIn", "zoomOut", "cube", and
// "swap". If "none" is specified, transition occurs
// immediately without animation.
// context: Object
// The object that the callback function will receive as "this".
// method: String|Function
// A callback function that is called when the transition has finished.
// A function reference, or name of a function in context.
// tags:
// public
//
// example:
// Transition backward to a view whose id is "foo" with the slide animation.
// | performTransition("foo", -1, "slide");
//
// example:
// Transition forward to a blank view, and then open another page.
// | performTransition(null, 1, "slide", null, function(){location.href = href;});
if(this._inProgress){ return; } // transition is in progress
this._inProgress = true;
// normalize the arg
var detail, optArgs;
if(moveTo && typeof(moveTo) === "object"){
detail = moveTo;
optArgs = transitionDir; // array
}else{
detail = {
moveTo: moveTo,
transitionDir: transitionDir,
transition: transition,
context: context,
method: method
};
optArgs = [];
for(var i = 5; i < arguments.length; i++){
optArgs.push(arguments[i]);
}
}
// save the parameters
this._detail = detail;
this._optArgs = optArgs;
this._arguments = [
detail.moveTo,
detail.transitionDir,
detail.transition,
detail.context,
detail.method
];
if(detail.moveTo === "#"){ return; }
var toNode;
if(detail.moveTo){
toNode = this.convertToId(detail.moveTo);
}else{
if(!this._dummyNode){
this._dummyNode = win.doc.createElement("div");
win.body().appendChild(this._dummyNode);
}
toNode = this._dummyNode;
}
if(this.addTransitionInfo && typeof(detail.moveTo) == "string" && this._isBookmarkable(detail)){
this.addTransitionInfo(this.id, detail.moveTo, {transitionDir:detail.transitionDir, transition:detail.transition});
}
var fromNode = this.domNode;
var fromTop = fromNode.offsetTop;
toNode = this.toNode = dom.byId(toNode);
if(!toNode){ console.log("dojox/mobile/View.performTransition: destination view not found: "+detail.moveTo); return; }
toNode.style.visibility = "hidden";
toNode.style.display = "";
this._fixViewState(toNode);
var toWidget = registry.byNode(toNode);
if(toWidget){
// Now that the target view became visible, it's time to run resize()
if(config.mblAlwaysResizeOnTransition || !toWidget._resized){
common.resizeAll(null, toWidget);
toWidget._resized = true;
}
if(detail.transition && detail.transition != "none"){
// Temporarily add padding to align with the fromNode while transition
toWidget._addTransitionPaddingTop(fromTop);
}
toWidget.load && toWidget.load(); // for ContentView
toWidget.movedFrom = fromNode.id;
}
if(has('mblAndroidWorkaround') && !config.mblCSS3Transition
&& detail.transition && detail.transition != "none"){
// workaround for the screen flicker issue on Android 2.2/2.3
// apply "-webkit-transform-style:preserve-3d" to both toNode and fromNode
// to make them 3d-transition-ready state just before transition animation
domStyle.set(toNode, css3.name("transformStyle"), "preserve-3d");
domStyle.set(fromNode, css3.name("transformStyle"), "preserve-3d");
// show toNode offscreen to avoid flicker when switching "display" and "visibility" styles
domClass.add(toNode, "mblAndroidWorkaround");
}
this.onBeforeTransitionOut.apply(this, this._arguments);
connect.publish("/dojox/mobile/beforeTransitionOut", [this].concat(lang._toArray(this._arguments)));
if(toWidget){
// perform view transition keeping the scroll position
if(this.keepScrollPos && !this.getParent()){
var scrollTop = win.body().scrollTop || win.doc.documentElement.scrollTop || win.global.pageYOffset || 0;
fromNode._scrollTop = scrollTop;
var toTop = (detail.transitionDir == 1) ? 0 : (toNode._scrollTop || 0);
toNode.style.top = "0px";
if(scrollTop > 1 || toTop !== 0){
fromNode.style.top = toTop - scrollTop + "px";
// address bar hiding does not work on iOS 7+.
if(!(has("ios") >= 7) && config.mblHideAddressBar !== false){
this.defer(function(){ // iPhone needs setTimeout (via defer)
win.global.scrollTo(0, (toTop || 1));
});
}
}
}else{
toNode.style.top = "0px";
}
toWidget.onBeforeTransitionIn.apply(toWidget, this._arguments);
connect.publish("/dojox/mobile/beforeTransitionIn", [toWidget].concat(lang._toArray(this._arguments)));
}
toNode.style.display = "none";
toNode.style.visibility = "inherit";
common.fromView = this;
common.toView = toWidget;
this._doTransition(fromNode, toNode, detail.transition, detail.transitionDir);
},
_addTransitionPaddingTop: function(/*String|Integer*/ value){
// add padding top to the view in order to get alignment during the transition
this.containerNode.style.paddingTop = value + "px";
},
_removeTransitionPaddingTop: function(){
// remove padding top from the view after the transition
this.containerNode.style.paddingTop = "";
},
_toCls: function(s){
// convert from transition name to corresponding class name
// ex. "slide" -> "mblSlide"
return "mbl"+s.charAt(0).toUpperCase() + s.substring(1);
},
_doTransition: function(fromNode, toNode, transition, transitionDir){
var rev = (transitionDir == -1) ? " mblReverse" : "";
toNode.style.display = "";
if(!transition || transition == "none"){
this.domNode.style.display = "none";
this.invokeCallback();
}else if(config.mblCSS3Transition){
//get dojox/css3/transit first
Deferred.when(transitDeferred, lang.hitch(this, function(transit){
//follow the style of .mblView.mblIn in View.css
//need to set the toNode to absolute position
var toPosition = domStyle.get(toNode, "position");
domStyle.set(toNode, "position", "absolute");
Deferred.when(transit(fromNode, toNode, {transition: transition, reverse: (transitionDir===-1)?true:false}),lang.hitch(this,function(){
domStyle.set(toNode, "position", toPosition);
// Reset the temporary padding on toNode
toNode.style.paddingTop = "";
this.invokeCallback();
}));
}));
}else{
if(transition.indexOf("cube") != -1){
if(has('ipad')){
domStyle.set(toNode.parentNode, {webkitPerspective:1600});
}else if(has("ios")){
domStyle.set(toNode.parentNode, {webkitPerspective:800});
}
}
var s = this._toCls(transition);
if(has('mblAndroidWorkaround')){
// workaround for the screen flicker issue on Android 2.2
// applying transition css classes just after setting toNode.style.display = ""
// causes flicker, so wait for a while using setTimeout (via defer)
var _this = this;
_this.defer(function(){
domClass.add(fromNode, s + " mblOut" + rev);
domClass.add(toNode, s + " mblIn" + rev);
domClass.remove(toNode, "mblAndroidWorkaround"); // remove offscreen style
_this.defer(function(){
domClass.add(fromNode, "mblTransition");
domClass.add(toNode, "mblTransition");
}, 30); // 30 = 100 - 70, to make total delay equal to 100ms
}, 70); // 70ms is experiential value
}else{
domClass.add(fromNode, s + " mblOut" + rev);
domClass.add(toNode, s + " mblIn" + rev);
this.defer(function(){
domClass.add(fromNode, "mblTransition");
domClass.add(toNode, "mblTransition");
}, 100);
}
// set transform origin
var fromOrigin = "50% 50%";
var toOrigin = "50% 50%";
var scrollTop, posX, posY;
if(transition.indexOf("swirl") != -1 || transition.indexOf("zoom") != -1){
if(this.keepScrollPos && !this.getParent()){
scrollTop = win.body().scrollTop || win.doc.documentElement.scrollTop || win.global.pageYOffset || 0;
}else{
scrollTop = -domGeometry.position(fromNode, true).y;
}
posY = win.global.innerHeight / 2 + scrollTop;
fromOrigin = "50% " + posY + "px";
toOrigin = "50% " + posY + "px";
}else if(transition.indexOf("scale") != -1){
var viewPos = domGeometry.position(fromNode, true);
posX = ((this.clickedPosX !== undefined) ? this.clickedPosX : win.global.innerWidth / 2) - viewPos.x;
if(this.keepScrollPos && !this.getParent()){
scrollTop = win.body().scrollTop || win.doc.documentElement.scrollTop || win.global.pageYOffset || 0;
}else{
scrollTop = -viewPos.y;
}
posY = ((this.clickedPosY !== undefined) ? this.clickedPosY : win.global.innerHeight / 2) + scrollTop;
fromOrigin = posX + "px " + posY + "px";
toOrigin = posX + "px " + posY + "px";
}
domStyle.set(fromNode, css3.add({}, {transformOrigin:fromOrigin}));
domStyle.set(toNode, css3.add({}, {transformOrigin:toOrigin}));
}
},
onAnimationStart: function(e){
// summary:
// A handler that is called when transition animation starts.
},
onAnimationEnd: function(e){
// summary:
// A handler that is called after transition animation ends.
var name = e.animationName || e.target.className;
if(name.indexOf("Out") === -1 &&
name.indexOf("In") === -1 &&
name.indexOf("Shrink") === -1){ return; }
var isOut = false;
if(domClass.contains(this.domNode, "mblOut")){
isOut = true;
this.domNode.style.display = "none";
domClass.remove(this.domNode, [this._toCls(this._detail.transition), "mblIn", "mblOut", "mblReverse"]);
}else{
// Reset the temporary padding
this._removeTransitionPaddingTop();
}
domStyle.set(this.domNode, css3.add({}, {transformOrigin:""}));
if(name.indexOf("Shrink") !== -1){
var li = e.target;
li.style.display = "none";
domClass.remove(li, "mblCloseContent");
// If target is placed inside scrollable, need to call onTouchEnd
// to adjust scroll position
var p = viewRegistry.getEnclosingScrollable(this.domNode);
p && p.onTouchEnd();
}
if(isOut){
this.invokeCallback();
}
this._clearClasses(this.domNode);
// clear the clicked position
this.clickedPosX = this.clickedPosY = undefined;
if(name.indexOf("Cube") !== -1 &&
name.indexOf("In") !== -1 && has("ios")){
this.domNode.parentNode.style[css3.name("perspective")] = "";
}
},
invokeCallback: function(){
// summary:
// A function to be called after performing a transition to
// call a specified callback.
this.onAfterTransitionOut.apply(this, this._arguments);
connect.publish("/dojox/mobile/afterTransitionOut", [this].concat(this._arguments));
var toWidget = registry.byNode(this.toNode);
if(toWidget){
toWidget.onAfterTransitionIn.apply(toWidget, this._arguments);
connect.publish("/dojox/mobile/afterTransitionIn", [toWidget].concat(this._arguments));
toWidget.movedFrom = undefined;
if(this.setFragIds && this._isBookmarkable(this._detail)){
this.setFragIds(toWidget); // setFragIds is defined in bookmarkable.js
}
}
if(has('mblAndroidWorkaround')){
// workaround for the screen flicker issue on Android 2.2/2.3
// remove "-webkit-transform-style" style after transition finished
// to avoid side effects such as input field auto-scrolling issue
// use setTimeout (via defer) to avoid flicker in case of ScrollableView
this.defer(function(){
if(toWidget){ domStyle.set(this.toNode, css3.name("transformStyle"), ""); }
domStyle.set(this.domNode, css3.name("transformStyle"), "");
});
}
var c = this._detail.context, m = this._detail.method;
if(c || m){
if(!m){
m = c;
c = null;
}
c = c || win.global;
if(typeof(m) == "string"){
c[m].apply(c, this._optArgs);
}else if(typeof(m) == "function"){
m.apply(c, this._optArgs);
}
}
this._detail = this._optArgs = this._arguments = undefined;
this._inProgress = false;
},
isVisible: function(/*Boolean?*/checkAncestors){
// summary:
// Return true if this view is visible
// checkAncestors:
// If true, in addition to its own visibility, also checks the
// ancestors visibility to see if the view is actually being
// shown or not.
var visible = function(node){
return domStyle.get(node, "display") !== "none";
};
if(checkAncestors){
for(var n = this.domNode; n.tagName !== "BODY"; n = n.parentNode){
if(!visible(n)){ return false; }
}
return true;
}else{
return visible(this.domNode);
}
},
getShowingView: function(){
// summary:
// Find the currently showing view from my sibling views.
// description:
// Note that depending on the ancestor views' visibility,
// the found view may not be actually shown.
var nodes = this.domNode.parentNode.childNodes;
for(var i = 0; i < nodes.length; i++){
var n = nodes[i];
if(n.nodeType === 1 && domClass.contains(n, "mblView") && n.style.display !== "none"){
return registry.byNode(n);
}
}
return null;
},
getSiblingViews: function(){
// summary:
// Returns an array of the sibling views.
if(!this.domNode.parentNode){ return [this]; }
return array.map(array.filter(this.domNode.parentNode.childNodes,
function(n){ return n.nodeType === 1 && domClass.contains(n, "mblView"); }),
function(n){ return registry.byNode(n); });
},
show: function(/*Boolean?*/noEvent, /*Boolean?*/doNotHideOthers){
// summary:
// Shows this view without a transition animation.
var out = this.getShowingView();
if(!noEvent){
if(out){
out.onBeforeTransitionOut(out.id);
connect.publish("/dojox/mobile/beforeTransitionOut", [out, out.id]);
}
this.onBeforeTransitionIn(this.id);
connect.publish("/dojox/mobile/beforeTransitionIn", [this, this.id]);
}
if(doNotHideOthers){
this.domNode.style.display = "";
}else{
array.forEach(this.getSiblingViews(), function(v){
v.domNode.style.display = (v === this) ? "" : "none";
}, this);
}
this.load && this.load(); // for ContentView
if(!noEvent){
if(out){
out.onAfterTransitionOut(out.id);
connect.publish("/dojox/mobile/afterTransitionOut", [out, out.id]);
}
this.onAfterTransitionIn(this.id);
connect.publish("/dojox/mobile/afterTransitionIn", [this, this.id]);
}
},
hide: function(){
// summary:
// Hides this view without a transition animation.
this.domNode.style.display = "none";
}
});
});
},
'dojox/mobile/ViewController':function(){
define([
"dojo/_base/kernel",
"dojo/_base/array",
"dojo/_base/connect",
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/_base/window",
"dojo/_base/Deferred",
"dojo/dom",
"dojo/dom-class",
"dojo/dom-construct",
"dojo/on",
"dojo/ready",
"dijit/registry",
"./ProgressIndicator",
"./TransitionEvent",
"./viewRegistry"
], function(dojo, array, connect, declare, lang, win, Deferred, dom, domClass, domConstruct, on, ready, registry, ProgressIndicator, TransitionEvent, viewRegistry){
// module:
// dojox/mobile/ViewController
var Controller = declare("dojox.mobile.ViewController", null, {
// summary:
// A singleton class that controls view transition.
// description:
// This class listens to the "startTransition" events and performs
// view transitions. If the transition destination is an external
// view specified with the url parameter, the view content is
// retrieved and parsed to create a new target view.
// dataHandlerClass: Object
// The data handler class used to load external views,
// by default "dojox/mobile/dh/DataHandler"
// (see the Data Handlers page in the reference documentation).
dataHandlerClass: "dojox/mobile/dh/DataHandler",
// dataSourceClass: Object
// The data source class used to load external views,
// by default "dojox/mobile/dh/UrlDataSource"
// (see the Data Handlers page in the reference documentation).
dataSourceClass: "dojox/mobile/dh/UrlDataSource",
// fileTypeMapClass: Object
// The file type map class used to load external views,
// by default "dojox/mobile/dh/SuffixFileTypeMap"
// (see the Data Handlers page in the reference documentation).
fileTypeMapClass: "dojox/mobile/dh/SuffixFileTypeMap",
constructor: function(){
// summary:
// Creates a new instance of the class.
// tags:
// private
this.viewMap = {};
ready(lang.hitch(this, function(){
on(win.body(), "startTransition", lang.hitch(this, "onStartTransition"));
}));
},
findTransitionViews: function(/*String*/moveTo){
// summary:
// Parses the moveTo argument and determines a starting view and a destination view.
// returns: Array
// An array containing the currently showing view, the destination view
// and the transition parameters, or an empty array if the moveTo argument
// could not be parsed.
if(!moveTo){ return []; }
// removes a leading hash mark (#) and params if exists
// ex. "#bar&myParam=0003" -> "bar"
moveTo.match(/^#?([^&?]+)(.*)/);
var params = RegExp.$2;
var view = registry.byId(RegExp.$1);
if(!view){ return []; }
for(var v = view.getParent(); v; v = v.getParent()){ // search for the topmost invisible parent node
if(v.isVisible && !v.isVisible()){
var sv = view.getShowingView();
if(sv && sv.id !== view.id){
view.show();
}
view = v;
}
}
return [view.getShowingView(), view, params]; // fromView, toView, params
},
openExternalView: function(/*Object*/ transOpts, /*DomNode*/ target){
// summary:
// Loads an external view and performs a transition to it.
// returns: dojo/_base/Deferred
// Deferred object that resolves when the external view is
// ready and a transition starts. Note that it resolves before
// the transition is complete.
// description:
// This method loads external view content through the
// dojox/mobile data handlers, creates a new View instance with
// the loaded content, and performs a view transition to the
// new view. The external view content can be specified with
// the url property of transOpts. The new view is created under
// a DOM node specified by target.
//
// example:
// This example loads view1.html, creates a new view under
// ``, and performs a transition to the new view with the
// slide animation.
//
// | var vc = ViewController.getInstance();
// | vc.openExternalView({
// | url: "view1.html",
// | transition: "slide"
// | }, win.body());
//
//
// example:
// If you want to perform a view transition without animation,
// you can give transition:"none" to transOpts.
//
// | var vc = ViewController.getInstance();
// | vc.openExternalView({
// | url: "view1.html",
// | transition: "none"
// | }, win.body());
//
// example:
// If you want to dynamically create an external view, but do
// not want to perform a view transition to it, you can give noTransition:true to transOpts.
// This may be useful when you want to preload external views before the user starts using them.
//
// | var vc = ViewController.getInstance();
// | vc.openExternalView({
// | url: "view1.html",
// | noTransition: true
// | }, win.body());
//
// example:
// To do something when the external view is ready:
//
// | var vc = ViewController.getInstance();
// | Deferred.when(vc.openExternalView({...}, win.body()), function(){
// | doSomething();
// | });
var d = new Deferred();
var id = this.viewMap[transOpts.url];
if(id){
transOpts.moveTo = id;
if(transOpts.noTransition){
registry.byId(id).hide();
}else{
new TransitionEvent(win.body(), transOpts).dispatch();
}
d.resolve(true);
return d;
}
// if a fixed bottom bar exists, a new view should be placed before it.
var refNode = null;
for(var i = target.childNodes.length - 1; i >= 0; i--){
var c = target.childNodes[i];
if(c.nodeType === 1){
var fixed = c.getAttribute("fixed") // TODO: Remove the non-HTML5-compliant attribute in 2.0
|| c.getAttribute("data-mobile-fixed")
|| (registry.byNode(c) && registry.byNode(c).fixed);
if(fixed === "bottom"){
refNode = c;
break;
}
}
}
var dh = transOpts.dataHandlerClass || this.dataHandlerClass;
var ds = transOpts.dataSourceClass || this.dataSourceClass;
var ft = transOpts.fileTypeMapClass || this.fileTypeMapClass;
require([dh, ds, ft], lang.hitch(this, function(DataHandler, DataSource, FileTypeMap){
var handler = new DataHandler(new DataSource(transOpts.data || transOpts.url), target, refNode);
var contentType = transOpts.contentType || FileTypeMap.getContentType(transOpts.url) || "html";
handler.processData(contentType, lang.hitch(this, function(id){
if(id){
this.viewMap[transOpts.url] = transOpts.moveTo = id;
if(transOpts.noTransition){
registry.byId(id).hide();
}else{
new TransitionEvent(win.body(), transOpts).dispatch();
}
d.resolve(true);
}else{
d.reject("Failed to load "+transOpts.url);
}
}));
}));
return d;
},
onStartTransition: function(evt){
// summary:
// A handler that performs view transition.
evt.preventDefault();
if(!evt.detail){ return; }
var detail = evt.detail;
if(!detail.moveTo && !detail.href && !detail.url && !detail.scene){ return; }
if(detail.url && !detail.moveTo){
var urlTarget = detail.urlTarget;
var w = registry.byId(urlTarget);
var target = w && w.containerNode || dom.byId(urlTarget);
if(!target){
w = viewRegistry.getEnclosingView(evt.target);
target = w && w.domNode.parentNode || win.body();
}
var src = registry.getEnclosingWidget(evt.target);
if(src && src.callback){
detail.context = src;
detail.method = src.callback;
}
this.openExternalView(detail, target);
return;
}else if(detail.href){
if(detail.hrefTarget && detail.hrefTarget != "_self"){
win.global.open(detail.href, detail.hrefTarget);
}else{
var view; // find top level visible view
for(var v = viewRegistry.getEnclosingView(evt.target); v; v = viewRegistry.getParentView(v)){
view = v;
}
if(view){
view.performTransition(null, detail.transitionDir, detail.transition, evt.target, function(){location.href = detail.href;});
}
}
return;
}else if(detail.scene){
connect.publish("/dojox/mobile/app/pushScene", [detail.scene]);
return;
}
var arr = this.findTransitionViews(detail.moveTo),
fromView = arr[0],
toView = arr[1],
params = arr[2];
if(!location.hash && !detail.hashchange){
viewRegistry.initialView = fromView;
}
if(detail.moveTo && toView){
detail.moveTo = (detail.moveTo.charAt(0) === '#' ? '#' + toView.id : toView.id) + params;
}
if(!fromView || (detail.moveTo && fromView === registry.byId(detail.moveTo.replace(/^#?([^&?]+).*/, "$1")))){ return; }
src = registry.getEnclosingWidget(evt.target);
if(src && src.callback){
detail.context = src;
detail.method = src.callback;
}
fromView.performTransition(detail);
}
});
Controller._instance = new Controller(); // singleton
Controller.getInstance = function(){
return Controller._instance;
};
return Controller;
});
},
'dojox/mobile/transition':function(){
define([
"dojo/_base/Deferred",
"dojo/_base/config"
], function(Deferred, config){
/*=====
return {
// summary:
// This is the wrapper module which loads
// dojox/css3/transit conditionally. If mblCSS3Transition
// is set to 'dojox/css3/transit', it will be loaded as
// the module to conduct view transitions, otherwise this module returns null.
};
=====*/
if(config.mblCSS3Transition){
//require dojox/css3/transit and resolve it as the result of transitDeferred.
var transitDeferred = new Deferred();
require([config.mblCSS3Transition], function(transit){
transitDeferred.resolve(transit);
});
return transitDeferred;
}
return null;
});
},
'dojox/mobile/Heading':function(){
define([
"dojo/_base/array",
"dojo/_base/connect",
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/_base/window",
"dojo/dom-class",
"dojo/dom-construct",
"dojo/dom-style",
"dojo/dom-attr",
"dijit/registry",
"./common",
"dijit/_Contained",
"dijit/_Container",
"dijit/_WidgetBase",
"./ProgressIndicator",
"./ToolBarButton",
"./View",
"dojo/has",
"dojo/has!dojo-bidi?dojox/mobile/bidi/Heading"
], function(array, connect, declare, lang, win, domClass, domConstruct, domStyle, domAttr, registry, common, Contained, Container, WidgetBase, ProgressIndicator, ToolBarButton, View, has, BidiHeading){
// module:
// dojox/mobile/Heading
var dm = lang.getObject("dojox.mobile", true);
var Heading = declare(has("dojo-bidi") ? "dojox.mobile.NonBidiHeading" : "dojox.mobile.Heading", [WidgetBase, Container, Contained],{
// summary:
// A widget that represents a navigation bar.
// description:
// Heading is a widget that represents a navigation bar, which
// usually appears at the top of an application. It usually
// displays the title of the current view and can contain a
// navigational control. If you use it with
// dojox/mobile/ScrollableView, it can also be used as a fixed
// header bar or a fixed footer bar. In such cases, specify the
// fixed="top" attribute to be a fixed header bar or the
// fixed="bottom" attribute to be a fixed footer bar. Heading can
// have one or more ToolBarButton widgets as its children.
// back: String
// A label for the navigational control to return to the previous View.
back: "",
// href: String
// A URL to open when the navigational control is pressed.
href: "",
// moveTo: String
// The id of the transition destination of the navigation control.
// If the value has a hash sign ('#') before the id (e.g. #view1)
// and the dojox/mobile/bookmarkable module is loaded by the user application,
// the view transition updates the hash in the browser URL so that the
// user can bookmark the destination view. In this case, the user
// can also use the browser's back/forward button to navigate
// through the views in the browser history.
//
// If null, transitions to a blank view.
// If '#', returns immediately without transition.
moveTo: "",
// transition: String
// A type of animated transition effect. You can choose from the
// standard transition types, "slide", "fade", "flip", or from the
// extended transition types, "cover", "coverv", "dissolve",
// "reveal", "revealv", "scaleIn", "scaleOut", "slidev",
// "swirl", "zoomIn", "zoomOut", "cube", and "swap". If "none" is
// specified, transition occurs immediately without animation.
transition: "slide",
// label: String
// A title text of the heading. If the label is not specified, the
// innerHTML of the node is used as a label.
label: "",
// iconBase: String
// The default icon path for child items.
iconBase: "",
// tag: String
// A name of HTML tag to create as domNode.
tag: "h1",
// busy: Boolean
// If true, a progress indicator spins on this widget.
busy: false,
// progStyle: String
// A css class name to add to the progress indicator.
progStyle: "mblProgWhite",
/* internal properties */
// baseClass: String
// The name of the CSS class of this widget.
baseClass: "mblHeading",
buildRendering: function(){
if(!this.templateString){ // true if this widget is not templated
// Create root node if it wasn't created by _TemplatedMixin
this.domNode = this.containerNode = this.srcNodeRef || win.doc.createElement(this.tag);
}
this.inherited(arguments);
if(!this.templateString){ // true if this widget is not templated
if(!this.label){
array.forEach(this.domNode.childNodes, function(n){
if(n.nodeType == 3){
var v = lang.trim(n.nodeValue);
if(v){
this.label = v;
this.labelNode = domConstruct.create("span", {innerHTML:v}, n, "replace");
}
}
}, this);
}
if(!this.labelNode){
this.labelNode = domConstruct.create("span", null, this.domNode);
}
this.labelNode.className = "mblHeadingSpanTitle";
this.labelDivNode = domConstruct.create("div", {
className: "mblHeadingDivTitle",
innerHTML: this.labelNode.innerHTML
}, this.domNode);
}
if(this.labelDivNode){
domAttr.set(this.labelDivNode, "role", "heading"); //a11y
domAttr.set(this.labelDivNode, "aria-level", "1");
}
common.setSelectable(this.domNode, false);
},
startup: function(){
if(this._started){ return; }
var parent = this.getParent && this.getParent();
if(!parent || !parent.resize){ // top level widget
var _this = this;
_this.defer(function(){ // necessary to render correctly
_this.resize();
});
}
this.inherited(arguments);
},
resize: function(){
if(this.labelNode){
// find the rightmost left button (B), and leftmost right button (C)
// +-----------------------------+
// | |A| |B| |C| |D| |
// +-----------------------------+
var leftBtn, rightBtn;
var children = this.containerNode.childNodes;
for(var i = children.length - 1; i >= 0; i--){
var c = children[i];
if(c.nodeType === 1 && domStyle.get(c, "display") !== "none"){
if(!rightBtn && domStyle.get(c, "float") === "right"){
rightBtn = c;
}
if(!leftBtn && domStyle.get(c, "float") === "left"){
leftBtn = c;
}
}
}
if(!this.labelNodeLen && this.label){
this.labelNode.style.display = "inline";
this.labelNodeLen = this.labelNode.offsetWidth;
this.labelNode.style.display = "";
}
var bw = this.domNode.offsetWidth; // bar width
var rw = rightBtn ? bw - rightBtn.offsetLeft + 5 : 0; // rightBtn width
var lw = leftBtn ? leftBtn.offsetLeft + leftBtn.offsetWidth + 5 : 0; // leftBtn width
var tw = this.labelNodeLen || 0; // title width
domClass[bw - Math.max(rw,lw)*2 > tw ? "add" : "remove"](this.domNode, "mblHeadingCenterTitle");
}
array.forEach(this.getChildren(), function(child){
if(child.resize){ child.resize(); }
});
},
_setBackAttr: function(/*String*/back){
// tags:
// private
this._set("back", back);
if(!this.backButton){
this.backButton = new ToolBarButton({
arrow: "left",
label: back,
moveTo: this.moveTo,
back: !this.moveTo && !this.href, // use browser history unless moveTo or href
href: this.href,
transition: this.transition,
transitionDir: -1,
dir: this.isLeftToRight() ? "ltr" : "rtl"
});
this.backButton.placeAt(this.domNode, "first");
}else{
this.backButton.set("label", back);
}
this.resize();
},
_setMoveToAttr: function(/*String*/moveTo){
// tags:
// private
this._set("moveTo", moveTo);
if(this.backButton){
this.backButton.set("moveTo", moveTo);
this.backButton.set("back", !moveTo && !this.href);
}
},
_setHrefAttr: function(/*String*/href){
// tags:
// private
this._set("href", href);
if(this.backButton){
this.backButton.set("href", href);
this.backButton.set("back", !this.moveTo && !href);
}
},
_setTransitionAttr: function(/*String*/transition){
// tags:
// private
this._set("transition", transition);
if(this.backButton){
this.backButton.set("transition", transition);
}
},
_setLabelAttr: function(/*String*/label){
// tags:
// private
this._set("label", label);
this.labelNode.innerHTML = this.labelDivNode.innerHTML = this._cv ? this._cv(label) : label;
delete this.labelNodeLen;
},
_setBusyAttr: function(/*Boolean*/busy){
// tags:
// private
var prog = this._prog;
if(busy){
if(!prog){
prog = this._prog = new ProgressIndicator({size:30, center:false});
domClass.add(prog.domNode, this.progStyle);
}
domConstruct.place(prog.domNode, this.domNode, "first");
prog.start();
}else if(prog){
prog.stop();
}
this._set("busy", busy);
}
});
return has("dojo-bidi") ? declare("dojox.mobile.Heading", [Heading, BidiHeading]) : Heading;
});
},
'dojox/mobile/ToolBarButton':function(){
define([
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/_base/window",
"dojo/dom-class",
"dojo/dom-construct",
"dojo/dom-style",
"dojo/dom-attr",
"./sniff",
"./_ItemBase",
"dojo/has!dojo-bidi?dojox/mobile/bidi/ToolBarButton"
], function(declare, lang, win, domClass, domConstruct, domStyle, domAttr, has, ItemBase, BidiToolBarButton){
// module:
// dojox/mobile/ToolBarButton
var ToolBarButton = declare(has("dojo-bidi") ? "dojox.mobile.NonBidiToolBarButton" : "dojox.mobile.ToolBarButton", ItemBase, {
// summary:
// A button widget which is placed in the Heading widget.
// description:
// ToolBarButton is a button which is typically placed in the
// Heading widget. It is a subclass of dojox/mobile/_ItemBase just
// like ListItem or IconItem. So, unlike Button, it has basically
// the same capability as ListItem or IconItem, such as icon
// support, transition, etc.
// selected: Boolean
// If true, the button is in the selected state.
selected: false,
// arrow: [const] String
// Specifies "right" or "left" to be an arrow button.
// Note that changing the value of the property after the widget
// creation has no effect.
arrow: "",
// light: [const] Boolean
// If true, this widget produces only a single `` node when it
// has only an icon or only a label, and has no arrow. In that
// case, you cannot have both icon and label, or arrow even if you
// try to set them.
// Note that changing the value of the property after the widget
// creation has no effect.
light: true,
// defaultColor: String
// CSS class for the default color.
// Note: If this button has an arrow (typically back buttons on iOS),
// the class selector used for it is the value of defaultColor + "45".
// For example, by default the arrow selector is "mblColorDefault45".
defaultColor: "mblColorDefault",
// selColor: String
// CSS class for the selected color.
// Note: If this button has an arrow (typically back buttons on iOS),
// the class selector used for it is the value of selColor + "45".
// For example, by default the selected arrow selector is "mblColorDefaultSel45".
selColor: "mblColorDefaultSel",
/* internal properties */
baseClass: "mblToolBarButton",
_selStartMethod: "touch",
_selEndMethod: "touch",
buildRendering: function(){
if(!this.label && this.srcNodeRef){
this.label = this.srcNodeRef.innerHTML;
}
this.label = lang.trim(this.label);
this.domNode = (this.srcNodeRef && this.srcNodeRef.tagName === "SPAN") ?
this.srcNodeRef : domConstruct.create("span");
domAttr.set(this.domNode, "role", "button");
this.inherited(arguments);
if(this.light && !this.arrow && (!this.icon || !this.label)){
this.labelNode = this.tableNode = this.bodyNode = this.iconParentNode = this.domNode;
domClass.add(this.domNode, this.defaultColor + " mblToolBarButtonBody" +
(this.icon ? " mblToolBarButtonLightIcon" : " mblToolBarButtonLightText"));
return;
}
this.domNode.innerHTML = "";
if(this.arrow === "left" || this.arrow === "right"){
this.arrowNode = domConstruct.create("span", {
className: "mblToolBarButtonArrow mblToolBarButton" +
(this.arrow === "left" ? "Left" : "Right") + "Arrow " +
(has("ie") < 10 ? "" : (this.defaultColor + " " + this.defaultColor + "45"))
}, this.domNode);
domClass.add(this.domNode, "mblToolBarButtonHas" +
(this.arrow === "left" ? "Left" : "Right") + "Arrow");
}
this.bodyNode = domConstruct.create("span", {className:"mblToolBarButtonBody"}, this.domNode);
this.tableNode = domConstruct.create("table", {cellPadding:"0",cellSpacing:"0",border:"0",role:"presentation"}, this.bodyNode);
if(!this.label && this.arrow){
// The class mblToolBarButtonText is needed for arrow shape too.
// If the button has a label, the class is set by _setLabelAttr. If no label, do it here.
this.tableNode.className = "mblToolBarButtonText";
}
var row = this.tableNode.insertRow(-1);
this.iconParentNode = row.insertCell(-1);
this.labelNode = row.insertCell(-1);
this.iconParentNode.className = "mblToolBarButtonIcon";
this.labelNode.className = "mblToolBarButtonLabel";
if(this.icon && this.icon !== "none" && this.label){
domClass.add(this.domNode, "mblToolBarButtonHasIcon");
domClass.add(this.bodyNode, "mblToolBarButtonLabeledIcon");
}
domClass.add(this.bodyNode, this.defaultColor);
},
startup: function(){
if(this._started){ return; }
this.connect(this.domNode, "onkeydown", "_onClick"); // for desktop browsers
this.inherited(arguments);
if(!this._isOnLine){
this._isOnLine = true;
// retry applying the attribute for which the custom setter delays the actual
// work until _isOnLine is true.
this.set("icon", this._pendingIcon !== undefined ? this._pendingIcon : this.icon);
// Not needed anymore (this code executes only once per life cycle):
delete this._pendingIcon;
}
},
_onClick: function(e){
// summary:
// Internal handler for click events.
// tags:
// private
if(e && e.type === "keydown" && e.keyCode !== 13){ return; }
if(this.onClick(e) === false){ return; } // user's click action
this.defaultClickAction(e);
},
onClick: function(/*Event*/ /*===== e =====*/){
// summary:
// User defined function to handle clicks
// tags:
// callback
},
_setLabelAttr: function(/*String*/text){
// summary:
// Sets the button label text.
this.inherited(arguments);
domClass.toggle(this.tableNode, "mblToolBarButtonText", text || this.arrow); // also needed if only arrow
},
_setSelectedAttr: function(/*Boolean*/selected){
// summary:
// Makes this widget in the selected or unselected state.
var replace = function(node, a, b){
domClass.replace(node, a + " " + a + "45", b + " " + b + "45");
};
this.inherited(arguments);
if(selected){
domClass.replace(this.bodyNode, this.selColor, this.defaultColor);
if(!(has("ie") < 10) && this.arrowNode){
replace(this.arrowNode, this.selColor, this.defaultColor);
}
}else{
domClass.replace(this.bodyNode, this.defaultColor, this.selColor);
if(!(has("ie") < 10) && this.arrowNode){
replace(this.arrowNode, this.defaultColor, this.selColor);
}
}
domClass.toggle(this.domNode, "mblToolBarButtonSelected", selected);
domClass.toggle(this.bodyNode, "mblToolBarButtonBodySelected", selected);
}
});
return has("dojo-bidi") ? declare("dojox.mobile.ToolBarButton", [ToolBarButton, BidiToolBarButton]) : ToolBarButton;
});
},
'dojox/mobile/RoundRect':function(){
define([
"dojo/_base/declare",
"dojo/dom-class",
"./Container"
], function(declare, domClass, Container){
// module:
// dojox/mobile/RoundRect
return declare("dojox.mobile.RoundRect", Container, {
// summary:
// A simple round rectangle container.
// description:
// RoundRect is a simple round rectangle container for any HTML
// and/or widgets. You can achieve the same appearance by just
// applying the -webkit-border-radius style to a div tag. However,
// if you use RoundRect, you can get a round rectangle even on
// non-CSS3 browsers such as (older) IE.
// shadow: [const] Boolean
// If true, adds a shadow effect to the container element by adding
// the CSS class "mblShadow" to widget's domNode. The default value
// is false. Note that changing the value of the property after
// the widget creation has no effect.
shadow: false,
/* internal properties */
// baseClass: String
// The name of the CSS class of this widget.
baseClass: "mblRoundRect",
buildRendering: function(){
this.inherited(arguments);
if(this.shadow){
domClass.add(this.domNode, "mblShadow");
}
}
});
});
},
'dojox/mobile/Container':function(){
define([
"dojo/_base/declare",
"dijit/_Container",
"./Pane"
], function(declare, Container, Pane){
// module:
// dojox/mobile/Container
return declare("dojox.mobile.Container", [Pane, Container], {
// summary:
// A simple container-type widget.
// description:
// Container is a simple general-purpose container widget.
// It is a widget, but can be regarded as a simple `
` element.
// baseClass: String
// The name of the CSS class of this widget.
baseClass: "mblContainer"
});
});
},
'dojox/mobile/Pane':function(){
define([
"dojo/_base/array",
"dojo/_base/declare",
"dijit/_Contained",
"dijit/_WidgetBase"
], function(array, declare, Contained, WidgetBase){
// module:
// dojox/mobile/Pane
return declare("dojox.mobile.Pane", [WidgetBase, Contained], {
// summary:
// A simple pane widget.
// description:
// Pane is a simple general-purpose pane widget.
// It is a widget, but can be regarded as a simple `
` element.
// baseClass: String
// The name of the CSS class of this widget.
baseClass: "mblPane",
buildRendering: function(){
this.inherited(arguments);
if(!this.containerNode){
// set containerNode so that getChildren() works
this.containerNode = this.domNode;
}
},
resize: function(){
// summary:
// Calls resize() of each child widget.
array.forEach(this.getChildren(), function(child){
if(child.resize){ child.resize(); }
});
}
});
});
},
'dojox/mobile/RoundRectCategory':function(){
define([
"dojo/_base/declare",
"dojo/_base/window",
"dojo/dom-construct",
"dijit/_Contained",
"dijit/_WidgetBase",
"dojo/has",
"dojo/has!dojo-bidi?dojox/mobile/bidi/RoundRectCategory"
], function(declare, win, domConstruct, Contained, WidgetBase, has, BidiRoundRectCategory){
// module:
// dojox/mobile/RoundRectCategory
var RoundRectCategory = declare(has("dojo-bidi") ? "dojox.mobile.NonBidiRoundRectCategory" : "dojox.mobile.RoundRectCategory", [WidgetBase, Contained], {
// summary:
// A category header for a rounded rectangle list.
// label: String
// A label of the category. If the label is not specified,
// innerHTML is used as a label.
label: "",
// tag: String
// A name of html tag to create as domNode.
tag: "h2",
/* internal properties */
// baseClass: String
// The name of the CSS class of this widget.
baseClass: "mblRoundRectCategory",
buildRendering: function(){
var domNode = this.domNode = this.containerNode = this.srcNodeRef || domConstruct.create(this.tag);
this.inherited(arguments);
if(!this.label && domNode.childNodes.length === 1 && domNode.firstChild.nodeType === 3){
// if it has only one text node, regard it as a label
this.label = domNode.firstChild.nodeValue;
}
},
_setLabelAttr: function(/*String*/label){
// summary:
// Sets the category header text.
// tags:
// private
this.label = label;
this.domNode.innerHTML = this._cv ? this._cv(label) : label;
}
});
return has("dojo-bidi") ? declare("dojox.mobile.RoundRectCategory", [RoundRectCategory, BidiRoundRectCategory]) : RoundRectCategory;
});
},
'dojox/mobile/EdgeToEdgeCategory':function(){
define([
"dojo/_base/declare",
"./RoundRectCategory"
], function(declare, RoundRectCategory){
// module:
// dojox/mobile/EdgeToEdgeCategory
return declare("dojox.mobile.EdgeToEdgeCategory", RoundRectCategory, {
// summary:
// A category header for an edge-to-edge list.
buildRendering: function(){
this.inherited(arguments);
this.domNode.className = "mblEdgeToEdgeCategory";
if(this.type && this.type == "long"){
this.domNode.className += " mblEdgeToEdgeCategoryLong";
}
}
});
});
},
'dojox/mobile/RoundRectList':function(){
define([
"dojo/_base/array",
"dojo/_base/declare",
"dojo/_base/event",
"dojo/_base/lang",
"dojo/_base/window",
"dojo/dom-construct",
"dojo/dom-attr",
"dijit/_Contained",
"dijit/_Container",
"dijit/_WidgetBase"
], function(array, declare, event, lang, win, domConstruct, domAttr, Contained, Container, WidgetBase){
// module:
// dojox/mobile/RoundRectList
return declare("dojox.mobile.RoundRectList", [WidgetBase, Container, Contained], {
// summary:
// A rounded rectangle list.
// description:
// RoundRectList is a rounded rectangle list, which can be used to
// display a group of items. Each item must be a dojox/mobile/ListItem.
// transition: String
// The default animated transition effect for child items.
transition: "slide",
// iconBase: String
// The default icon path for child items.
iconBase: "",
// iconPos: String
// The default icon position for child items.
iconPos: "",
// select: String
// Selection mode of the list. The check mark is shown for the
// selected list item(s). The value can be "single", "multiple", or "".
// If "single", there can be only one selected item at a time.
// If "multiple", there can be multiple selected items at a time.
// If "", the check mark is not shown.
select: "",
// stateful: Boolean
// If true, the last selected item remains highlighted.
stateful: false,
// syncWithViews: [const] Boolean
// If true, this widget listens to view transition events to be
// synchronized with view's visibility.
// Note that changing the value of the property after the widget
// creation has no effect.
syncWithViews: false,
// editable: [const] Boolean
// If true, the list can be reordered.
// Note that changing the value of the property after the widget
// creation has no effect.
editable: false,
// tag: String
// A name of html tag to create as domNode.
tag: "ul",
/* internal properties */
// editableMixinClass: String
// The name of the mixin class.
editableMixinClass: "dojox/mobile/_EditableListMixin",
// baseClass: String
// The name of the CSS class of this widget.
baseClass: "mblRoundRectList",
// filterBoxClass: String
// The name of the CSS class added to the DOM node inside which is placed the
// dojox/mobile/SearchBox created when mixing dojox/mobile/FilteredListMixin.
// The default value is "mblFilteredRoundRectListSearchBox".
filterBoxClass: "mblFilteredRoundRectListSearchBox",
buildRendering: function(){
this.domNode = this.srcNodeRef || domConstruct.create(this.tag);
if(this.select){
domAttr.set(this.domNode, "role", "listbox");
if(this.select === "multiple"){
domAttr.set(this.domNode, "aria-multiselectable", "true");
}
}
this.inherited(arguments);
},
postCreate: function(){
if(this.editable){
require([this.editableMixinClass], lang.hitch(this, function(module){
declare.safeMixin(this, new module());
}));
}
this.connect(this.domNode, "onselectstart", event.stop);
if(this.syncWithViews){ // see also TabBar#postCreate
var f = function(view, moveTo, dir, transition, context, method){
var child = array.filter(this.getChildren(), function(w){
return w.moveTo === "#" + view.id || w.moveTo === view.id; })[0];
if(child){ child.set("selected", true); }
};
this.subscribe("/dojox/mobile/afterTransitionIn", f);
this.subscribe("/dojox/mobile/startView", f);
}
},
resize: function(){
// summary:
// Calls resize() of each child widget.
array.forEach(this.getChildren(), function(child){
if(child.resize){ child.resize(); }
});
},
onCheckStateChanged: function(/*Widget*//*===== listItem, =====*/ /*String*//*===== newState =====*/){
// summary:
// Stub function to connect to from your application.
// description:
// Called when the check state has been changed.
},
_setStatefulAttr: function(stateful){
// tags:
// private
this._set("stateful", stateful);
this.selectOne = stateful;
array.forEach(this.getChildren(), function(child){
child.setArrow && child.setArrow();
});
},
deselectItem: function(/*dojox/mobile/ListItem*/item){
// summary:
// Deselects the given item.
item.set("selected", false);
},
deselectAll: function(){
// summary:
// Deselects all the items.
array.forEach(this.getChildren(), function(child){
child.set("selected", false);
});
},
selectItem: function(/*ListItem*/item){
// summary:
// Selects the given item.
item.set("selected", true);
}
});
});
},
'dojox/mobile/EdgeToEdgeList':function(){
define([
"dojo/_base/declare",
"./RoundRectList"
], function(declare, RoundRectList){
// module:
// dojox/mobile/EdgeToEdgeCategory
return declare("dojox.mobile.EdgeToEdgeList", RoundRectList, {
// summary:
// An edge-to-edge layout list.
// description:
// EdgeToEdgeList is an edge-to-edge layout list, which displays
// all items in equally-sized rows. Each item must be a
// dojox/mobile/ListItem.
// filterBoxClass: String
// The name of the CSS class added to the DOM node inside which is placed the
// dojox/mobile/SearchBox created when mixing dojox/mobile/FilteredListMixin.
// The default value is "mblFilteredEdgeToEdgeListSearchBox".
filterBoxClass: "mblFilteredEdgeToEdgeListSearchBox",
buildRendering: function(){
this.inherited(arguments);
this.domNode.className = "mblEdgeToEdgeList";
}
});
});
},
'dojox/mobile/Switch':function(){
define([
"dojo/_base/array",
"dojo/_base/connect",
"dojo/_base/declare",
"dojo/_base/event",
"dojo/_base/window",
"dojo/dom-class",
"dojo/dom-construct",
"dojo/dom-style",
"dojo/dom-attr",
"dojo/touch",
"dijit/_Contained",
"dijit/_WidgetBase",
"./sniff",
"./_maskUtils",
"./common",
"dojo/has!dojo-bidi?dojox/mobile/bidi/Switch"
], function(array, connect, declare, event, win, domClass, domConstruct, domStyle, domAttr, touch, Contained, WidgetBase, has, maskUtils, dm, BidiSwitch){
// module:
// dojox/mobile/Switch
var Switch = declare(has("dojo-bidi") ? "dojox.mobile.NonBidiSwitch" : "dojox.mobile.Switch", [WidgetBase, Contained],{
// summary:
// A toggle switch with a sliding knob.
// description:
// Switch is a toggle switch with a sliding knob. You can either
// tap or slide the knob to toggle the switch. The onStateChanged
// handler is called when the switch is manipulated.
// value: String
// The initial state of the switch: "on" or "off". The default
// value is "on".
value: "on",
// name: String
// A name for a hidden input field, which holds the current value.
name: "",
// leftLabel: String
// The left-side label of the switch.
leftLabel: "ON",
// rightLabel: String
// The right-side label of the switch.
rightLabel: "OFF",
// shape: String
// The shape of the switch.
// "mblSwDefaultShape", "mblSwSquareShape", "mblSwRoundShape1",
// "mblSwRoundShape2", "mblSwArcShape1" or "mblSwArcShape2".
// The default value is "mblSwDefaultShape".
shape: "mblSwDefaultShape",
// tabIndex: String
// Tabindex setting for this widget so users can hit the tab key to
// focus on it.
tabIndex: "0",
_setTabIndexAttr: "", // sets tabIndex to domNode
/* internal properties */
baseClass: "mblSwitch",
// role: [private] String
// The accessibility role.
role: "", // a11y
buildRendering: function(){
if(!this.templateString){ // true if this widget is not templated
this.domNode = (this.srcNodeRef && this.srcNodeRef.tagName === "SPAN") ?
this.srcNodeRef : domConstruct.create("span");
}
// prevent browser scrolling on IE10 (evt.preventDefault() is not enough)
dm._setTouchAction(this.domNode, "none");
this.inherited(arguments);
if(!this.templateString){ // true if this widget is not templated
var c = (this.srcNodeRef && this.srcNodeRef.className) || this.className || this["class"];
if((c = c.match(/mblSw.*Shape\d*/))){ this.shape = c; }
domClass.add(this.domNode, this.shape);
var nameAttr = this.name ? " name=\"" + this.name + "\"" : "";
this.domNode.innerHTML =
'
'
+ '
'
+ ''
+ '
'
+ '
'
+ ''
+ '
'
+ ''
+ '
'
+ '
';
var n = this.inner = this.domNode.firstChild;
this.left = n.childNodes[0];
this.right = n.childNodes[1];
this.knob = n.childNodes[2];
this.input = n.childNodes[3];
}
domAttr.set(this.domNode, "role", "checkbox"); //a11y
domAttr.set(this.domNode, "aria-checked", (this.value === "on") ? "true" : "false"); //a11y
this.switchNode = this.domNode;
if(has("windows-theme")) {
var rootNode = domConstruct.create("div", {className: "mblSwitchContainer"});
this.labelNode = domConstruct.create("label", {"class": "mblSwitchLabel", "for": this.id}, rootNode);
rootNode.appendChild(this.domNode.cloneNode(true));
this.domNode = rootNode;
this.focusNode = rootNode.childNodes[1];
this.labelNode.innerHTML = (this.value=="off") ? this.rightLabel : this.leftLabel;
this.switchNode = this.domNode.childNodes[1];
var inner = this.inner = this.domNode.childNodes[1].firstChild;
this.left = inner.childNodes[0];
this.right = inner.childNodes[1];
this.knob = inner.childNodes[2];
this.input = inner.childNodes[3];
}
},
postCreate: function(){
this.connect(this.switchNode, "onclick", "_onClick");
this.connect(this.switchNode, "onkeydown", "_onClick"); // for desktop browsers
this._startHandle = this.connect(this.switchNode, touch.press, "onTouchStart");
this._initialValue = this.value; // for reset()
},
startup: function(){
var started = this._started;
this.inherited(arguments);
if(!started){
this.resize();
}
},
resize: function(){
if(has("windows-theme")){
// Override the custom CSS width (if any) to avoid misplacement.
// Per design, the windows theme does not allow resizing the controls.
// The label of the switch is placed next to the switch, and a custom
// width would only have the effect to increase the distance between the
// label and the switch, which is undesired. Hence, on windows theme,
// ensure the width of root DOM node is 100%.
domStyle.set(this.domNode, "width", "100%");
}else{
var value = domStyle.get(this.domNode,"width");
var outWidth = value + "px";
var innWidth = (value - domStyle.get(this.knob,"width")) + "px";
domStyle.set(this.left, "width", outWidth);
domStyle.set(this.right,this.isLeftToRight()?{width: outWidth, left: innWidth}:{width: outWidth});
domStyle.set(this.left.firstChild, "width", innWidth);
domStyle.set(this.right.firstChild, "width", innWidth);
domStyle.set(this.knob, "left", innWidth);
if(this.value == "off"){
domStyle.set(this.inner, "left", this.isLeftToRight()?("-" + innWidth):0);
}
this._hasMaskImage = false;
this._createMaskImage();
}
},
_changeState: function(/*String*/state, /*Boolean*/anim){
var on = (state === "on");
this.left.style.display = "";
this.right.style.display = "";
this.inner.style.left = "";
if(anim){
domClass.add(this.switchNode, "mblSwitchAnimation");
}
domClass.remove(this.switchNode, on ? "mblSwitchOff" : "mblSwitchOn");
domClass.add(this.switchNode, on ? "mblSwitchOn" : "mblSwitchOff");
domAttr.set(this.switchNode, "aria-checked", on ? "true" : "false"); //a11y
if(!on && !has("windows-theme")){
this.inner.style.left = (this.isLeftToRight()?(-(domStyle.get(this.domNode,"width") - domStyle.get(this.knob,"width"))):0) + "px";
}
var _this = this;
_this.defer(function(){
_this.left.style.display = on ? "" : "none";
_this.right.style.display = !on ? "" : "none";
domClass.remove(_this.switchNode, "mblSwitchAnimation");
}, anim ? 300 : 0);
},
_createMaskImage: function(){
if(this._timer){
this._timer.remove();
delete this._timer;
}
if(this._hasMaskImage){ return; }
var w = domStyle.get(this.domNode,"width"), h = domStyle.get(this.domNode,"height");
this._width = (w - domStyle.get(this.knob,"width"));
this._hasMaskImage = true;
if(!(has("mask-image"))){ return; }
var rDef = domStyle.get(this.left, "borderTopLeftRadius");
if(!rDef || rDef == "0px"){ return; }
var rDefs = rDef.split(" ");
var rx = parseFloat(rDefs[0]), ry = (rDefs.length == 1) ? rx : parseFloat(rDefs[1]);
if(rx && ry){
maskUtils.createRoundMask(this.switchNode, 0, 0, 0, 0, w, h, rx, ry, 1);
}
},
_onClick: function(e){
// summary:
// Internal handler for click events.
// tags:
// private
if(e && e.type === "keydown" && e.keyCode !== 13){ return; }
if(this.onClick(e) === false){ return; } // user's click action
if(this._moved){ return; }
this._set("value", this.input.value = (this.value == "on") ? "off" : "on");
this._changeState(this.value, true);
this.onStateChanged(this.value);
},
onClick: function(/*Event*/ /*===== e =====*/){
// summary:
// User defined function to handle clicks
// tags:
// callback
},
onTouchStart: function(/*Event*/e){
// summary:
// Internal function to handle touchStart events.
this._moved = false;
this.innerStartX = this.inner.offsetLeft;
if(!this._conn){
this._conn = [
this.connect(this.inner, touch.move, "onTouchMove"),
this.connect(win.doc, touch.release, "onTouchEnd")
];
/* While moving the slider knob sometimes IE fires MSPointerCancel event. That prevents firing
MSPointerUp event (http://msdn.microsoft.com/ru-ru/library/ie/hh846776%28v=vs.85%29.aspx) so the
knob can be stuck in the middle of the switch. As a fix we handle MSPointerCancel event with the
same lintener as for MSPointerUp event.
*/
if(has("windows-theme")){
this._conn.push(this.connect(win.doc, "MSPointerCancel", "onTouchEnd"));
}
}
this.touchStartX = e.touches ? e.touches[0].pageX : e.clientX;
this.left.style.display = "";
this.right.style.display = "";
event.stop(e);
this._createMaskImage();
},
onTouchMove: function(/*Event*/e){
// summary:
// Internal function to handle touchMove events.
e.preventDefault();
var dx;
if(e.targetTouches){
if(e.targetTouches.length != 1){ return; }
dx = e.targetTouches[0].clientX - this.touchStartX;
}else{
dx = e.clientX - this.touchStartX;
}
var pos = this.innerStartX + dx;
var d = 10;
if(pos <= -(this._width-d)){ pos = -this._width; }
if(pos >= -d){ pos = 0; }
this.inner.style.left = pos + "px";
if(Math.abs(dx) > d){
this._moved = true;
}
},
onTouchEnd: function(/*Event*/e){
// summary:
// Internal function to handle touchEnd events.
array.forEach(this._conn, connect.disconnect);
this._conn = null;
if(this.innerStartX == this.inner.offsetLeft){
// need to send a synthetic click?
if(has("touch") && has("clicks-prevented")){
dm._sendClick(this.inner, e);
}
return;
}
var newState = (this.inner.offsetLeft < -(this._width/2)) ? "off" : "on";
newState = this._newState(newState);
this._changeState(newState, true);
if(newState != this.value){
this._set("value", this.input.value = newState);
this.onStateChanged(newState);
}
},
_newState: function(newState){
return newState;
},
onStateChanged: function(/*String*/newState){
// summary:
// Stub function to connect to from your application.
// description:
// Called when the state has been changed.
if (this.labelNode) {
this.labelNode.innerHTML = newState=='off' ? this.rightLabel : this.leftLabel;
}
},
_setValueAttr: function(/*String*/value){
this._changeState(value, false);
if(this.value != value){
this._set("value", this.input.value = value);
this.onStateChanged(value);
}
},
_setLeftLabelAttr: function(/*String*/label){
this.leftLabel = label;
this.left.firstChild.innerHTML = this._cv ? this._cv(label) : label;
},
_setRightLabelAttr: function(/*String*/label){
this.rightLabel = label;
this.right.firstChild.innerHTML = this._cv ? this._cv(label) : label;
},
reset: function(){
// summary:
// Reset the widget's value to what it was at initialization time
this.set("value", this._initialValue);
}
});
return has("dojo-bidi") ? declare("dojox.mobile.Switch", [Switch, BidiSwitch]) : Switch;
});
},
'dojox/mobile/_maskUtils':function(){
define([
"dojo/_base/window",
"dojo/dom-style",
"./sniff"
], function(win, domStyle, has){
has.add("mask-image-css", function(global, doc, elt){
return typeof doc.getCSSCanvasContext === "function" && typeof elt.style.webkitMaskImage !== "undefined";
});
// Indicates whether image mask is available (either via css mask image or svg)
has.add("mask-image", function(){
return has("mask-image-css") || has("svg");
});
var cache = {};
return {
// summary:
// Utility methods to clip rounded corners of various elements (Switch, ScrollablePane, scrollbars in scrollable widgets).
// Uses -webkit-mask-image on webkit, or SVG on other browsers.
createRoundMask: function(/*DomNode*/node, x, y, r, b, w, h, rx, ry, e){
// summary:
// Creates and sets a mask for the specified node.
var tw = x + w + r;
var th = y + h + b;
if(has("mask-image-css")){ // use -webkit-mask-image
var id = ("DojoMobileMask" + x + y + w + h + rx + ry).replace(/\./g, "_");
if (!cache[id]) {
cache[id] = 1;
var ctx = win.doc.getCSSCanvasContext("2d", id, tw, th);
ctx.beginPath();
if (rx == ry) {
// round arc
if(rx == 2 && w == 5){
// optimized case for vertical scrollbar
ctx.fillStyle = "rgba(0,0,0,0.5)";
ctx.fillRect(1, 0, 3, 2);
ctx.fillRect(0, 1, 5, 1);
ctx.fillRect(0, h - 2, 5, 1);
ctx.fillRect(1, h - 1, 3, 2);
ctx.fillStyle = "rgb(0,0,0)";
ctx.fillRect(0, 2, 5, h - 4);
}else if(rx == 2 && h == 5){
// optimized case for horizontal scrollbar
ctx.fillStyle = "rgba(0,0,0,0.5)";
ctx.fillRect(0, 1, 2, 3);
ctx.fillRect(1, 0, 1, 5);
ctx.fillRect(w - 2, 0, 1, 5);
ctx.fillRect(w - 1, 1, 2, 3);
ctx.fillStyle = "rgb(0,0,0)";
ctx.fillRect(2, 0, w - 4, 5);
}else{
// general case
ctx.fillStyle = "#000000";
ctx.moveTo(x+rx, y);
ctx.arcTo(x, y, x, y+rx, rx);
ctx.lineTo(x, y+h - rx);
ctx.arcTo(x, y+h, x+rx, y+h, rx);
ctx.lineTo(x+w - rx, y+h);
ctx.arcTo(x+w, y+h, x+w, y+rx, rx);
ctx.lineTo(x+w, y+rx);
ctx.arcTo(x+w, y, x+w - rx, y, rx);
}
} else {
// elliptical arc
var pi = Math.PI;
ctx.scale(1, ry / rx);
ctx.moveTo(x+rx, y);
ctx.arc(x+rx, y+rx, rx, 1.5 * pi, 0.5 * pi, true);
ctx.lineTo(x+w - rx, y+2 * rx);
ctx.arc(x+w - rx, y+rx, rx, 0.5 * pi, 1.5 * pi, true);
}
ctx.closePath();
ctx.fill();
}
node.style.webkitMaskImage = "-webkit-canvas(" + id + ")";
}else if(has("svg")){ // add an SVG image to clip the corners.
if(node._svgMask){
node.removeChild(node._svgMask);
}
var bg = null;
for(var p = node.parentNode; p; p = p.parentNode){
bg = domStyle.getComputedStyle(p).backgroundColor;
if(bg && bg != "transparent" && !bg.match(/rgba\(.*,\s*0\s*\)/)){
break;
}
}
var svgNS = "http://www.w3.org/2000/svg";
var svg = win.doc.createElementNS(svgNS, "svg");
svg.setAttribute("width", tw);
svg.setAttribute("height", th);
svg.style.position = "absolute";
svg.style.pointerEvents = "none";
svg.style.opacity = "1";
svg.style.zIndex = "2147483647"; // max int
var path = win.doc.createElementNS(svgNS, "path");
e = e || 0;
rx += e;
ry += e;
// TODO: optimized cases for scrollbars as in webkit case?
var d = " M" + (x + rx - e) + "," + (y - e) + " a" + rx + "," + ry + " 0 0,0 " + (-rx) + "," + ry + " v" + (-ry) + " h" + rx + " Z" +
" M" + (x - e) + "," + (y + h - ry + e) + " a" + rx + "," + ry + " 0 0,0 " + rx + "," + ry + " h" + (-rx) + " v" + (-ry) + " z" +
" M" + (x + w - rx + e) + "," + (y + h + e) + " a" + rx + "," + ry + " 0 0,0 " + rx + "," + (-ry) + " v" + ry + " h" + (-rx) + " z" +
" M" + (x + w + e) + "," + (y + ry - e) + " a" + rx + "," + ry + " 0 0,0 " + (-rx) + "," + (-ry) + " h" + rx + " v" + ry + " z";
if(y > 0){
d += " M0,0 h" + tw + " v" + y + " h" + (-tw) + " z";
}
if(b > 0){
d += " M0," + (y + h) + " h" + tw + " v" + b + " h" + (-tw) + " z";
}
path.setAttribute("d", d);
path.setAttribute("fill", bg);
path.setAttribute("stroke", bg);
path.style.opacity = "1";
svg.appendChild(path);
node._svgMask = svg;
node.appendChild(svg);
}
}
};
});
},
'dojox/mobile/compat':function(){
define([
"dojo/_base/lang",
"dojo/sniff"
], function(lang, has){
// module:
// dojox/mobile/compat
var dm = lang.getObject("dojox.mobile", true);
// TODO: Use feature detection instead, but this would require a major rewrite of _compat
// to detect each feature and plug the corresponding compat code if needed.
// Currently the compat code is a workaround for too many different things to be able to
// decide based on feature detection. So for now we just disable _compat on the mobile browsers
// that are known to support enough CSS3: all webkit-based browsers, IE10 (Windows [Phone] 8) and IE11+.
if(!(has("webkit") || has("ie") === 10) || (!has("ie") && has("trident") > 6)){
var s = "dojox/mobile/_compat"; // assign to a variable so as not to be picked up by the build tool
require([s]);
}
/*=====
return {
// summary:
// CSS3 compatibility module.
// description:
// This module provides to dojox/mobile support for some of the CSS3 features
// in non-CSS3 browsers, such as IE or Firefox.
// If you require this module, when running in a non-CSS3 browser it directly
// replaces some of the methods of dojox/mobile classes, without any subclassing.
// This way, HTML pages remain the same regardless of whether this compatibility
// module is used or not.
//
// Example of usage:
// | require([
// | "dojox/mobile",
// | "dojox/mobile/compat",
// | ...
// | ], function(...){
// | ...
// | });
//
// This module also loads compatibility CSS files, which have a -compat.css
// suffix. You can use either the `` tag or `@import` to load theme
// CSS files. Then, this module searches for the loaded CSS files and loads
// compatibility CSS files. For example, if you load dojox/mobile/themes/iphone/iphone.css
// in a page, this module automatically loads dojox/mobile/themes/iphone/iphone-compat.css.
// If you explicitly load iphone-compat.css with `` or `@import`,
// this module will not load again the already loaded file.
//
// Note that, by default, compatibility CSS files are only loaded for CSS files located
// in a directory containing a "mobile/themes" path. For that, a matching is done using
// the default pattern "/\/mobile\/themes\/.*\.css$/". If a custom theme is not located
// in a directory containing this path, the data-dojo-config needs to specify a custom
// pattern using the "mblLoadCompatPattern" configuration parameter, for instance:
// | data-dojo-config="mblLoadCompatPattern: /\/mycustomtheme\/.*\.css$/"
};
=====*/
return dm;
});
},
'dojox/mobile/FixedSplitter':function(){
define([
"dojo/_base/array",
"dojo/_base/declare",
"dojo/_base/window",
"dojo/dom-class",
"dojo/dom-geometry",
"dijit/_Contained",
"dijit/_Container",
"dijit/_WidgetBase",
"dojo/has",
"./common" // to ensure proper relayout when resizing/switching orientation (#18684)
], function(array, declare, win, domClass, domGeometry, Contained, Container, WidgetBase, has){
// module:
// dojox/mobile/FixedSplitter
return declare("dojox.mobile.FixedSplitter", [WidgetBase, Container, Contained], {
// summary:
// A layout container that splits the window horizontally or
// vertically.
// description:
// FixedSplitter is a very simple container widget that layouts its
// child DOM nodes side by side either horizontally or
// vertically. An example usage of this widget would be to realize
// the split view on iPad. There is no visual splitter between the
// children, and there is no function to resize the child panes
// with drag-and-drop. If you need a visual splitter, you can
// specify a border of a child DOM node with CSS.
//
// FixedSplitter has no knowledge of its child widgets.
// dojox/mobile/Container, dojox/mobile/Pane, or dojox/mobile/ContentPane
// can be used as a child widget of FixedSplitter.
//
// - Use dojox/mobile/Container if your content consists of ONLY
// Dojo widgets.
// - Use dojox/mobile/Pane if your content is an inline HTML
// fragment (may or may not include Dojo widgets).
// - Use dojox/mobile/ContentPane if your content is an external
// HTML fragment (may or may not include Dojo widgets).
//
// example:
// |
// |
// | pane #1 (width=200px)
// |
// |
// | pane #2
// |
// |
// orientation: String
// The direction of split. If "H" is specified, panes are split
// horizontally. If "V" is specified, panes are split vertically.
orientation: "H",
// variablePane: Number
// The index of a pane that fills the remainig space.
// If -1, the last child pane fills the remaining space.
variablePane: -1,
// screenSizeAware: Boolean
// If true, dynamically load a screen-size-aware module.
screenSizeAware: false,
// screenSizeAwareClass: String
// A screen-size-aware module to load.
screenSizeAwareClass: "dojox/mobile/ScreenSizeAware",
/* internal properties */
// baseClass: String
// The name of the CSS class of this widget.
baseClass: "mblFixedSplitter",
startup: function(){
if(this._started){ return; }
domClass.add(this.domNode, this.baseClass + this.orientation);
var parent = this.getParent(), f;
if(!parent || !parent.resize){ // top level widget
var _this = this;
f = function(){
_this.defer(function(){
_this.resize();
});
};
}
if(this.screenSizeAware){
require([this.screenSizeAwareClass], function(module){
module.getInstance();
f && f();
});
}else{
f && f();
}
this.inherited(arguments);
},
resize: function(){
var paddingTop = domGeometry.getPadExtents(this.domNode).t;
var wh = this.orientation === "H" ? "w" : "h", // width/height
tl = this.orientation === "H" ? "l" : "t", // top/left
props1 = {}, props2 = {},
i, c, h,
a = [], offset = 0, total = 0,
children = array.filter(this.domNode.childNodes, function(node){ return node.nodeType == 1; }),
idx = this.variablePane == -1 ? children.length - 1 : this.variablePane;
for(i = 0; i < children.length; i++){
if(i != idx){
a[i] = domGeometry.getMarginBox(children[i])[wh];
total += a[i];
}
}
if(this.orientation == "V"){
if(this.domNode.parentNode.tagName == "BODY"){
if(array.filter(win.body().childNodes, function(node){ return node.nodeType == 1; }).length == 1){
h = (win.global.innerHeight||win.doc.documentElement.clientHeight);
}
}
}
var l = (h || domGeometry.getMarginBox(this.domNode)[wh]) - total;
if(this.orientation === "V"){
l -= paddingTop;
}
props2[wh] = a[idx] = l;
c = children[idx];
domGeometry.setMarginBox(c, props2);
c.style[this.orientation === "H" ? "height" : "width"] = "";
// dojox.mobile mirroring support
if(has("dojo-bidi") && (this.orientation=="H" && !this.isLeftToRight())){
offset = l;
for(i = children.length - 1; i >= 0; i--){
c = children[i];
props1[tl] = l - offset;
domGeometry.setMarginBox(c, props1);
if(this.orientation === "H"){
c.style.top = paddingTop +"px";
}else{
c.style.left = "";
}
offset -= a[i];
}
}else{
if(this.orientation === "V"){
offset = offset ? offset + paddingTop : paddingTop;
}
for(i = 0; i < children.length; i++){
c = children[i];
props1[tl] = offset;
domGeometry.setMarginBox(c, props1);
if(this.orientation === "H"){
c.style.top = paddingTop +"px";
}else{
c.style.left = "";
}
offset += a[i];
}
}
array.forEach(this.getChildren(), function(child){
if(child.resize){ child.resize(); }
});
},
_setOrientationAttr: function(/*String*/orientation){
// summary:
// Sets the direction of split.
// description:
// The value must be either "H" or "V".
// If "H" is specified, panes are split horizontally.
// If "V" is specified, panes are split vertically.
// tags:
// private
var s = this.baseClass;
domClass.replace(this.domNode, s + orientation, s + this.orientation);
this.orientation = orientation;
if(this._started){
this.resize();
}
}
});
});
},
'dojox/mobile/ScrollableView':function(){
define([
"dojo/_base/array",
"dojo/_base/declare",
"dojo/dom-class",
"dojo/dom-construct",
"dijit/registry", // registry.byNode
"./View",
"./_ScrollableMixin"
], function(array, declare, domClass, domConstruct, registry, View, ScrollableMixin){
// module:
// dojox/mobile/ScrollableView
return declare("dojox.mobile.ScrollableView", [View, ScrollableMixin], {
// summary:
// A container that has a touch scrolling capability.
// description:
// ScrollableView is a subclass of View (dojox/mobile/View).
// Unlike the base View class, ScrollableView's domNode always stays
// at the top of the screen and its height is "100%" of the screen.
// Inside this fixed domNode, the containerNode scrolls. The browser's
// default scrolling behavior is disabled, and the scrolling mechanism is
// reimplemented in JavaScript. Thus the user does not need to use the
// two-finger operation to scroll the inner DIV (containerNode).
// The main purpose of this widget is to realize fixed-positioned header
// and/or footer bars.
// scrollableParams: Object
// Parameters for dojox/mobile/scrollable.init().
scrollableParams: null,
// keepScrollPos: Boolean
// Overrides dojox/mobile/View/keepScrollPos.
keepScrollPos: false,
constructor: function(){
// summary:
// Creates a new instance of the class.
this.scrollableParams = {noResize: true};
},
buildRendering: function(){
this.inherited(arguments);
domClass.add(this.domNode, "mblScrollableView");
this.domNode.style.overflow = "hidden";
this.domNode.style.top = "0px";
this.containerNode = domConstruct.create("div",
{className:"mblScrollableViewContainer"}, this.domNode);
this.containerNode.style.position = "absolute";
this.containerNode.style.top = "0px"; // view bar is relative
if(this.scrollDir === "v"){
this.containerNode.style.width = "100%";
}
},
startup: function(){
if(this._started){ return; }
// user can initialize the app footers using a value for fixedFooter (we keep this value for non regression of existing apps)
if(this.fixedFooter && !this.isLocalFooter){
this._fixedAppFooter = this.fixedFooter;
this.fixedFooter = "";
}
this.reparent();
this.inherited(arguments);
},
resize: function(){
// summary:
// Calls resize() of each child widget.
this.inherited(arguments); // scrollable#resize() will be called
array.forEach(this.getChildren(), function(child){
if(child.resize){ child.resize(); }
});
this._dim = this.getDim(); // update dimension cache
if(this._conn){
// if a resize happens during a scroll, update the scrollbar
this.resetScrollBar();
}
},
isTopLevel: function(/*Event*/e){
// summary:
// Returns true if this is a top-level widget.
// Overrides dojox/mobile/scrollable.isTopLevel.
var parent = this.getParent && this.getParent();
return (!parent || !parent.resize); // top level widget
},
addFixedBar: function(/*Widget*/widget){
// summary:
// Adds a view local fixed bar to this widget.
// description:
// This method can be used to programmatically add a view local
// fixed bar to ScrollableView. The bar is appended to this
// widget's domNode. The addChild API cannot be used for this
// purpose, because it adds the given widget to containerNode.
var c = widget.domNode;
var fixed = this.checkFixedBar(c, true);
if(!fixed){ return; }
// Fixed bar has to be added to domNode, not containerNode.
this.domNode.appendChild(c);
if(fixed === "top"){
this.fixedHeaderHeight = c.offsetHeight;
this.isLocalHeader = true;
}else if(fixed === "bottom"){
this.fixedFooterHeight = c.offsetHeight;
this.isLocalFooter = true;
c.style.bottom = "0px";
}
this.resize();
},
reparent: function(){
// summary:
// Moves all the children, except header and footer, to
// containerNode.
var i, idx, len, c;
for(i = 0, idx = 0, len = this.domNode.childNodes.length; i < len; i++){
c = this.domNode.childNodes[idx];
// search for view-specific header or footer
if(c === this.containerNode || this.checkFixedBar(c, true)){
idx++;
continue;
}
this.containerNode.appendChild(this.domNode.removeChild(c));
}
},
onAfterTransitionIn: function(moveTo, dir, transition, context, method){
// summary:
// Overrides View.onAfterTransitionIn to flash the scroll bar
// after performing a view transition.
this.flashScrollBar();
},
getChildren: function(){
// summary:
// Overrides _WidgetBase.getChildren to add local fixed bars,
// which are not under containerNode, to the children array.
var children = this.inherited(arguments);
var fixedWidget;
if(this.fixedHeader && this.fixedHeader.parentNode === this.domNode){
fixedWidget = registry.byNode(this.fixedHeader);
if(fixedWidget){
children.push(fixedWidget);
}
}
if(this.fixedFooter && this.fixedFooter.parentNode === this.domNode){
fixedWidget = registry.byNode(this.fixedFooter);
if(fixedWidget){
children.push(fixedWidget);
}
}
return children;
},
_addTransitionPaddingTop: function(/*String|Integer*/ value){
// add padding top to the view in order to get alignment during the transition
this.domNode.style.paddingTop = value + "px";
this.containerNode.style.paddingTop = value + "px";
},
_removeTransitionPaddingTop: function(){
// remove padding top from the view after the transition
this.domNode.style.paddingTop = "";
this.containerNode.style.paddingTop = "";
}
});
});
},
'dojox/mobile/_ScrollableMixin':function(){
define([
"dojo/_base/kernel",
"dojo/_base/config",
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/_base/window",
"dojo/dom",
"dojo/dom-class",
"dijit/registry", // registry.byNode
"./scrollable"
], function(dojo, config, declare, lang, win, dom, domClass, registry, Scrollable){
// module:
// dojox/mobile/_ScrollableMixin
var cls = declare("dojox.mobile._ScrollableMixin", Scrollable, {
// summary:
// Mixin for widgets to have a touch scrolling capability.
// fixedHeader: String
// Id of the fixed header.
fixedHeader: "",
// fixedFooter: String
// Id of the fixed footer.
fixedFooter: "",
_fixedAppFooter: "",
// scrollableParams: Object
// Parameters for dojox/mobile/scrollable.init().
scrollableParams: null,
// allowNestedScrolls: Boolean
// Flag to allow scrolling in nested containers, e.g. to allow ScrollableView in a SwapView.
allowNestedScrolls: true,
// appBars: Boolean
// Enables the search for application-specific bars (header or footer).
appBars: true,
constructor: function(){
// summary:
// Creates a new instance of the class.
// tags:
// private
this.scrollableParams = {};
},
destroy: function(){
this.cleanup();
this.inherited(arguments);
},
startup: function(){
if(this._started){ return; }
if(this._fixedAppFooter){
this._fixedAppFooter = dom.byId(this._fixedAppFooter);
}
this.findAppBars();
var node, params = this.scrollableParams;
if(this.fixedHeader){
node = dom.byId(this.fixedHeader);
if(node.parentNode == this.domNode){ // local footer
this.isLocalHeader = true;
}
params.fixedHeaderHeight = node.offsetHeight;
}
if(this.fixedFooter){
node = dom.byId(this.fixedFooter);
if(node.parentNode == this.domNode){ // local footer
this.isLocalFooter = true;
node.style.bottom = "0px";
}
params.fixedFooterHeight = node.offsetHeight;
}
this.scrollType = this.scrollType || config.mblScrollableScrollType || 0;
this.init(params);
if(this.allowNestedScrolls){
for(var p = this.getParent(); p; p = p.getParent()){
if(p && p.scrollableParams){
this.dirLock = true;
p.dirLock = true;
break;
}
}
}
// subscribe to afterResizeAll to scroll the focused input field into view
// so as not to break layout on orientation changes while keyboard is shown (#14991)
this._resizeHandle = this.subscribe("/dojox/mobile/afterResizeAll", function(){
if(this.domNode.style.display === 'none'){ return; }
var elem = win.doc.activeElement;
if(this.isFormElement(elem) && dom.isDescendant(elem, this.containerNode)){
this.scrollIntoView(elem);
}
});
this.inherited(arguments);
},
findAppBars: function(){
// summary:
// Search for application-specific header or footer.
if(!this.appBars){ return; }
var i, len, c;
for(i = 0, len = win.body().childNodes.length; i < len; i++){
c = win.body().childNodes[i];
this.checkFixedBar(c, false);
}
if(this.domNode.parentNode){
for(i = 0, len = this.domNode.parentNode.childNodes.length; i < len; i++){
c = this.domNode.parentNode.childNodes[i];
this.checkFixedBar(c, false);
}
}
this.fixedFooterHeight = this.fixedFooter ? this.fixedFooter.offsetHeight : 0;
},
checkFixedBar: function(/*DomNode*/node, /*Boolean*/local){
// summary:
// Checks if the given node is a fixed bar or not.
if(node.nodeType === 1){
var fixed = node.getAttribute("fixed") // TODO: Remove the non-HTML5-compliant attribute in 2.0
|| node.getAttribute("data-mobile-fixed")
|| (registry.byNode(node) && registry.byNode(node).fixed);
if(fixed === "top"){
domClass.add(node, "mblFixedHeaderBar");
if(local){
node.style.top = "0px";
this.fixedHeader = node;
}
return fixed;
}else if(fixed === "bottom"){
domClass.add(node, "mblFixedBottomBar");
if(local){
this.fixedFooter = node;
}else{
this._fixedAppFooter = node;
}
return fixed;
}
}
return null;
}
});
return cls;
});
},
'dojox/mobile/scrollable':function(){
define([
"dojo/_base/kernel",
"dojo/_base/connect",
"dojo/_base/event",
"dojo/_base/lang",
"dojo/_base/window",
"dojo/dom-class",
"dojo/dom-construct",
"dojo/dom-style",
"dojo/dom-geometry",
"dojo/touch",
"dijit/registry",
"dijit/form/_TextBoxMixin",
"./sniff",
"./_css3",
"./_maskUtils",
"./common",
"dojo/_base/declare",
"dojo/has!dojo-bidi?dojox/mobile/bidi/Scrollable"
], function(dojo, connect, event, lang, win, domClass, domConstruct, domStyle,
domGeom, touch, registry, TextBoxMixin, has, css3, maskUtils, common, declare, BidiScrollable){
// module:
// dojox/mobile/scrollable
// TODO: rename to Scrollable.js (capital S) for 2.0
// TODO: shouldn't be referencing this dojox/mobile variable, would be better to require the mobile.js module
var dm = lang.getObject("dojox.mobile", true);
// feature detection
has.add("translate3d", function(){
if(has("css3-animations")){
var elem = win.doc.createElement("div");
elem.style[css3.name("transform")] = "translate3d(0px,1px,0px)";
win.doc.documentElement.appendChild(elem);
var v = win.doc.defaultView.getComputedStyle(elem, '')[css3.name("transform", true)];
var hasTranslate3d = v && v.indexOf("matrix") === 0;
win.doc.documentElement.removeChild(elem);
return hasTranslate3d;
}
});
var Scrollable = function(){
// summary:
// Mixin for enabling touch scrolling capability.
// description:
// Mixin for enabling touch scrolling capability.
// Mobile WebKit browsers do not allow scrolling inner DIVs. (For instance,
// on iOS you need the two-finger operation to scroll them.)
// That means you cannot have fixed-positioned header/footer bars.
// To solve this issue, this module disables the browsers default scrolling
// behavior, and rebuilds its own scrolling machinery by handling touch
// events. In this module, this.domNode has height "100%" and is fixed to
// the window, and this.containerNode scrolls. If you place a bar outside
// of this.containerNode, then it will be fixed-positioned while
// this.containerNode is scrollable.
//
// This module has the following features:
//
// - Scrolls inner DIVs vertically, horizontally, or both.
// - Vertical and horizontal scroll bars.
// - Flashes the scroll bars when a view is shown.
// - Simulates the flick operation using animation.
// - Respects header/footer bars if any.
};
lang.extend(Scrollable, {
// fixedHeaderHeight: Number
// height of a fixed header
fixedHeaderHeight: 0,
// fixedFooterHeight: Number
// height of a fixed footer
fixedFooterHeight: 0,
// isLocalFooter: Boolean
// footer is view-local (as opposed to application-wide)
isLocalFooter: false,
// scrollBar: Boolean
// show scroll bar or not
scrollBar: true,
// scrollDir: String
// v: vertical, h: horizontal, vh: both, f: flip
scrollDir: "v",
// weight: Number
// frictional drag
weight: 0.6,
// fadeScrollBar: Boolean
fadeScrollBar: true,
// disableFlashScrollBar: Boolean
disableFlashScrollBar: false,
// threshold: Number
// drag threshold value in pixels
threshold: 4,
// constraint: Boolean
// bounce back to the content area
constraint: true,
// touchNode: DOMNode
// a node that will have touch event handlers
touchNode: null,
// propagatable: Boolean
// let touchstart event propagate up
propagatable: true,
// dirLock: Boolean
// disable the move handler if scroll starts in the unexpected direction
dirLock: false,
// height: String
// explicitly specified height of this widget (ex. "300px")
height: "",
// scrollType: Number
// - 1: use (-webkit-)transform:translate3d(x,y,z) style, use (-webkit-)animation for slide animation
// - 2: use top/left style,
// - 3: use (-webkit-)transform:translate3d(x,y,z) style, use (-webkit-)transition for slide animation
// - 0: use default value (3 for Android, iOS6+, and BlackBerry; otherwise 1)
scrollType: 0,
// _parentPadBorderExtentsBottom: [private] Number
// For Tooltip.js.
_parentPadBorderExtentsBottom: 0,
// _moved: [private] Boolean
// Flag that signals if the user have moved in (one of) the scroll
// direction(s) since touch start (a move under the threshold is ignored).
_moved: false,
init: function(/*Object?*/params){
// summary:
// Initialize according to the given params.
// description:
// Mixes in the given params into this instance. At least domNode
// and containerNode have to be given.
// Starts listening to the touchstart events.
// Calls resize(), if this widget is a top level widget.
if(params){
for(var p in params){
if(params.hasOwnProperty(p)){
this[p] = ((p == "domNode" || p == "containerNode") && typeof params[p] == "string") ?
win.doc.getElementById(params[p]) : params[p]; // mix-in params
}
}
}
// prevent browser scrolling on IE10 (evt.preventDefault() is not enough)
common._setTouchAction(this.domNode, "none");
this.touchNode = this.touchNode || this.containerNode;
this._v = (this.scrollDir.indexOf("v") != -1); // vertical scrolling
this._h = (this.scrollDir.indexOf("h") != -1); // horizontal scrolling
this._f = (this.scrollDir == "f"); // flipping views
this._ch = []; // connect handlers
this._ch.push(connect.connect(this.touchNode, touch.press, this, "onTouchStart"));
if(has("css3-animations")){
// flag for whether to use -webkit-transform:translate3d(x,y,z) or top/left style.
// top/left style works fine as a workaround for input fields auto-scrolling issue,
// so use top/left in case of Android by default.
this._useTopLeft = this.scrollType ? this.scrollType === 2 : false;
// Flag for using webkit transition on transform, instead of animation + keyframes.
// (keyframes create a slight delay before the slide animation...)
if(!this._useTopLeft){
this._useTransformTransition =
this.scrollType ? this.scrollType === 3 : has("ios") >= 6 || has("android") || has("bb");
}
if(!this._useTopLeft){
if(this._useTransformTransition){
this._ch.push(connect.connect(this.containerNode, css3.name("transitionEnd"), this, "onFlickAnimationEnd"));
// Note that there is no transitionstart event (#17822).
}else{
this._ch.push(connect.connect(this.containerNode, css3.name("animationEnd"), this, "onFlickAnimationEnd"));
this._ch.push(connect.connect(this.containerNode, css3.name("animationStart"), this, "onFlickAnimationStart"));
// Creation of keyframes takes a little time. If they are created
// in a lazy manner, a slight delay is noticeable when you start
// scrolling for the first time. This is to create keyframes up front.
for(var i = 0; i < 3; i++){
this.setKeyframes(null, null, i);
}
}
if(has("translate3d")){ // workaround for flicker issue on iPhone and Android 3.x/4.0
domStyle.set(this.containerNode, css3.name("transform"), "translate3d(0,0,0)");
}
}else{
this._ch.push(connect.connect(this.containerNode, css3.name("transitionEnd"), this, "onFlickAnimationEnd"));
// Note that there is no transitionstart event (#17822).
}
}
this._speed = {x:0, y:0};
this._appFooterHeight = 0;
if(this.isTopLevel() && !this.noResize){
this.resize();
}
var _this = this;
setTimeout(function(){
// Why not using widget.defer() instead of setTimeout()? Because this module
// is not always mixed into a widget (ex. dojox/mobile/_ComboBoxMenu), and adding
// a check to call either defer or setTimeout has been considered overkill.
_this.flashScrollBar();
}, 600);
// #16363: while navigating among input field using TAB (desktop keyboard) or
// NEXT (mobile soft keyboard), domNode.scrollTop gets modified (this holds even
// if the text widget has selectOnFocus at false, that is even if dijit's _FormWidgetMixin._onFocus
// does not trigger a global scrollIntoView). This messes up ScrollableView's own
// scrolling machinery. To avoid this misbehavior:
if(win.global.addEventListener){ // all supported browsers but IE8
// (for IE8, using attachEvent is not a solution, because it only works in bubbling phase)
this._onScroll = function(e){
if(!_this.domNode || _this.domNode.style.display === 'none'){ return; }
var scrollTop = _this.domNode.scrollTop;
var scrollLeft = _this.domNode.scrollLeft;
var pos;
if(scrollTop > 0 || scrollLeft > 0){
pos = _this.getPos();
// Reset to zero while compensating using our own scroll:
_this.domNode.scrollLeft = 0;
_this.domNode.scrollTop = 0;
_this.scrollTo({x: pos.x - scrollLeft, y: pos.y - scrollTop}); // no animation
}
};
win.global.addEventListener("scroll", this._onScroll, true);
}
// #17062: Ensure auto-scroll when navigating focusable fields
if(!this.disableTouchScroll && this.domNode.addEventListener){
this._onFocusScroll = function(e){
if(!_this.domNode || _this.domNode.style.display === 'none'){ return; }
var node = win.doc.activeElement;
var nodeRect, scrollableRect;
if(node){
nodeRect = node.getBoundingClientRect();
scrollableRect = _this.domNode.getBoundingClientRect();
if(nodeRect.height < _this.getDim().d.h){
// do not call scrollIntoView for elements with a height
// larger than the height of scrollable's content display
// area (it would be ergonomically harmful).
if(nodeRect.top < (scrollableRect.top + _this.fixedHeaderHeight)){
// scrolling towards top (to bring into the visible area an element
// located above it).
_this.scrollIntoView(node, true);
}else if((nodeRect.top + nodeRect.height) >
(scrollableRect.top + scrollableRect.height - _this.fixedFooterHeight)){
// scrolling towards bottom (to bring into the visible area an element
// located below it).
_this.scrollIntoView(node, false);
} // else do nothing (the focused node is already visible)
}
}
};
this.domNode.addEventListener("focus", this._onFocusScroll, true);
}
},
isTopLevel: function(){
// summary:
// Returns true if this is a top-level widget.
// description:
// Subclass may want to override.
return true;
},
cleanup: function(){
// summary:
// Uninitialize the module.
if(this._ch){
for(var i = 0; i < this._ch.length; i++){
connect.disconnect(this._ch[i]);
}
this._ch = null;
}
if(this._onScroll && win.global.removeEventListener){ // all supported browsers but IE8
win.global.removeEventListener("scroll", this._onScroll, true);
this._onScroll = null;
}
if(this._onFocusScroll && this.domNode.removeEventListener){
this.domNode.removeEventListener("focus", this._onFocusScroll, true);
this._onFocusScroll = null;
}
},
findDisp: function(/*DomNode*/node){
// summary:
// Finds the currently displayed view node from my sibling nodes.
if(!node.parentNode){ return null; }
// the given node is the first candidate
if(node.nodeType === 1 && domClass.contains(node, "mblSwapView") && node.style.display !== "none"){
return node;
}
var nodes = node.parentNode.childNodes;
for(var i = 0; i < nodes.length; i++){
var n = nodes[i];
if(n.nodeType === 1 && domClass.contains(n, "mblView") && n.style.display !== "none"){
return n;
}
}
return node;
},
getScreenSize: function(){
// summary:
// Returns the dimensions of the browser window.
return {
h: win.global.innerHeight||win.doc.documentElement.clientHeight||win.doc.documentElement.offsetHeight,
w: win.global.innerWidth||win.doc.documentElement.clientWidth||win.doc.documentElement.offsetWidth
};
},
resize: function(e){
// summary:
// Adjusts the height of the widget.
// description:
// If the height property is 'inherit', the height is inherited
// from its offset parent. If 'auto', the content height, which
// could be smaller than the entire screen height, is used. If an
// explicit height value (ex. "300px"), it is used as the new
// height. If nothing is specified as the height property, from the
// current top position of the widget to the bottom of the screen
// will be the new height.
// moved from init() to support dynamically added fixed bars
this._appFooterHeight = (this._fixedAppFooter) ? this._fixedAppFooter.offsetHeight : 0;
if(this.isLocalHeader){
this.containerNode.style.marginTop = this.fixedHeaderHeight + "px";
}
// Get the top position. Same as dojo.position(node, true).y
var top = 0;
for(var n = this.domNode; n && n.tagName != "BODY"; n = n.offsetParent){
n = this.findDisp(n); // find the first displayed view node
if(!n){ break; }
top += n.offsetTop + domGeom.getBorderExtents(n).h;
}
// adjust the height of this view
var h,
screenHeight = this.getScreenSize().h,
dh = screenHeight - top - this._appFooterHeight; // default height
if(this.height === "inherit"){
if(this.domNode.offsetParent){
h = domGeom.getContentBox(this.domNode.offsetParent).h - domGeom.getBorderExtents(this.domNode).h + "px";
}
}else if(this.height === "auto"){
var parent = this.domNode.offsetParent;
if(parent){
this.domNode.style.height = "0px";
var parentRect = parent.getBoundingClientRect(),
scrollableRect = this.domNode.getBoundingClientRect(),
contentBottom = parentRect.bottom - this._appFooterHeight - this._parentPadBorderExtentsBottom;
if(scrollableRect.bottom >= contentBottom){ // use entire screen
dh = screenHeight - (scrollableRect.top - parentRect.top) - this._appFooterHeight - this._parentPadBorderExtentsBottom;
}else{ // stretch to fill predefined area
dh = contentBottom - scrollableRect.bottom;
}
}
// content could be smaller than entire screen height
var contentHeight = Math.max(this.domNode.scrollHeight, this.containerNode.scrollHeight);
h = (contentHeight ? Math.min(contentHeight, dh) : dh) + "px";
}else if(this.height){
h = this.height;
}
if(!h){
h = dh + "px";
}
if(h.charAt(0) !== "-" && // to ensure that h is not negative (e.g. "-10px")
h !== "default"){
this.domNode.style.height = h;
}
if(!this._conn){
// to ensure that the view is within a scrolling area when resized.
this.onTouchEnd();
}
},
onFlickAnimationStart: function(e){
if(e){
event.stop(e);
}
},
onFlickAnimationEnd: function(e){
if(has("ios")){
this._keepInputCaretInActiveElement();
}
if(e){
var an = e.animationName;
if(an && an.indexOf("scrollableViewScroll2") === -1){
if(an.indexOf("scrollableViewScroll0") !== -1){ // scrollBarV
if(this._scrollBarNodeV){ domClass.remove(this._scrollBarNodeV, "mblScrollableScrollTo0"); }
}else if(an.indexOf("scrollableViewScroll1") !== -1){ // scrollBarH
if(this._scrollBarNodeH){ domClass.remove(this._scrollBarNodeH, "mblScrollableScrollTo1"); }
}else{ // fade or others
if(this._scrollBarNodeV){ this._scrollBarNodeV.className = ""; }
if(this._scrollBarNodeH){ this._scrollBarNodeH.className = ""; }
}
return;
}
if(this._useTransformTransition || this._useTopLeft){
var n = e.target;
if(n === this._scrollBarV || n === this._scrollBarH){
var cls = "mblScrollableScrollTo" + (n === this._scrollBarV ? "0" : "1");
if(domClass.contains(n, cls)){
domClass.remove(n, cls);
}else{
n.className = "";
}
return;
}
}
if(e.srcElement){
event.stop(e);
}
}
this.stopAnimation();
if(this._bounce){
var _this = this;
var bounce = _this._bounce;
setTimeout(function(){
_this.slideTo(bounce, 0.3, "ease-out");
}, 0);
_this._bounce = undefined;
}else{
this.hideScrollBar();
this.removeCover();
}
},
isFormElement: function(/*DOMNode*/node){
// summary:
// Returns true if the given node is a form control.
if(node && node.nodeType !== 1){ node = node.parentNode; }
if(!node || node.nodeType !== 1){ return false; }
var t = node.tagName;
return (t === "SELECT" || t === "INPUT" || t === "TEXTAREA" || t === "BUTTON");
},
onTouchStart: function(e){
// summary:
// User-defined function to handle touchStart events.
if(this.disableTouchScroll){ return; }
if(this._conn && (new Date()).getTime() - this.startTime < 500){
return; // ignore successive onTouchStart calls
}
if(!this._conn){
this._conn = [];
this._conn.push(connect.connect(win.doc, touch.move, this, "onTouchMove"));
this._conn.push(connect.connect(win.doc, touch.release, this, "onTouchEnd"));
}
this._aborted = false;
if(domClass.contains(this.containerNode, "mblScrollableScrollTo2")){
this.abort();
}else{ // reset scrollbar class especially for reseting fade-out animation
if(this._scrollBarNodeV){ this._scrollBarNodeV.className = ""; }
if(this._scrollBarNodeH){ this._scrollBarNodeH.className = ""; }
}
this.touchStartX = e.touches ? e.touches[0].pageX : e.clientX;
this.touchStartY = e.touches ? e.touches[0].pageY : e.clientY;
this.startTime = (new Date()).getTime();
this.startPos = this.getPos();
this._dim = this.getDim();
this._time = [0];
this._posX = [this.touchStartX];
this._posY = [this.touchStartY];
this._locked = false;
this._moved = false;
this._preventDefaultInNextTouchMove = true; // #17502
if(!this.isFormElement(e.target)){
// Call preventDefault to avoid browser scroll, except for form elements
// for which doing it in touch.press would forbid the virtual keyboard
// from showing up (for form elements which are text widgets, preventDefault
// is called in touch.move).
this.propagatable ? e.preventDefault() : event.stop(e);
this._preventDefaultInNextTouchMove = false;
}
},
onTouchMove: function(e){
// summary:
// User-defined function to handle touchMove events.
if(this._locked){ return; }
if(this._preventDefaultInNextTouchMove){ // #17502
this._preventDefaultInNextTouchMove = false; // only in the first touch.move
var enclosingWidget = registry.getEnclosingWidget(
// On touch-enabled devices, e.target can be different in touch.move than in
// touch.start. Hence:
((e.targetTouches && e.targetTouches.length === 1) ? e.targetTouches[0] : e).target);
if(enclosingWidget && enclosingWidget.isInstanceOf(TextBoxMixin)){
// For touches on text widgets for which e.preventDefault() has not been
// called in onTouchStart, call it in onTouchMove() to avoid browser scroll.
// Not done on other elements such that for instance a native slider
// can still handle touchmove events.
this.propagatable ? e.preventDefault() : event.stop(e);
}
}
var x = e.touches ? e.touches[0].pageX : e.clientX;
var y = e.touches ? e.touches[0].pageY : e.clientY;
var dx = x - this.touchStartX;
var dy = y - this.touchStartY;
var to = {x:this.startPos.x + dx, y:this.startPos.y + dy};
var dim = this._dim;
dx = Math.abs(dx);
dy = Math.abs(dy);
if(this._time.length == 1){ // the first TouchMove after TouchStart
if(this.dirLock){
if(this._v && !this._h && dx >= this.threshold && dx >= dy ||
(this._h || this._f) && !this._v && dy >= this.threshold && dy >= dx){
this._locked = true;
return;
}
}
if(this._v && this._h){ // scrollDir="hv"
if(dy < this.threshold &&
dx < this.threshold){
return;
}
}else{
if(this._v && dy < this.threshold ||
(this._h || this._f) && dx < this.threshold){
return;
}
}
this._moved = true;
this.addCover();
this.showScrollBar();
}
var weight = this.weight;
if(this._v && this.constraint){
if(to.y > 0){ // content is below the screen area
to.y = Math.round(to.y * weight);
}else if(to.y < -dim.o.h){ // content is above the screen area
if(dim.c.h < dim.d.h){ // content is shorter than display
to.y = Math.round(to.y * weight);
}else{
to.y = -dim.o.h - Math.round((-dim.o.h - to.y) * weight);
}
}
}
if((this._h || this._f) && this.constraint){
if(to.x > 0){
to.x = Math.round(to.x * weight);
}else if(to.x < -dim.o.w){
if(dim.c.w < dim.d.w){
to.x = Math.round(to.x * weight);
}else{
to.x = -dim.o.w - Math.round((-dim.o.w - to.x) * weight);
}
}
}
this.scrollTo(to);
var max = 10;
var n = this._time.length; // # of samples
if(n >= 2){
this._moved = true;
// Check the direction of the finger move.
// If the direction has been changed, discard the old data.
var d0, d1;
if(this._v && !this._h){
d0 = this._posY[n - 1] - this._posY[n - 2];
d1 = y - this._posY[n - 1];
}else if(!this._v && this._h){
d0 = this._posX[n - 1] - this._posX[n - 2];
d1 = x - this._posX[n - 1];
}
if(d0 * d1 < 0){ // direction changed
// leave only the latest data
this._time = [this._time[n - 1]];
this._posX = [this._posX[n - 1]];
this._posY = [this._posY[n - 1]];
n = 1;
}
}
if(n == max){
this._time.shift();
this._posX.shift();
this._posY.shift();
}
this._time.push((new Date()).getTime() - this.startTime);
this._posX.push(x);
this._posY.push(y);
},
_keepInputCaretInActiveElement: function(){
var activeElement = win.doc.activeElement;
var initialValue;
if(activeElement && (activeElement.tagName == "INPUT" || activeElement.tagName == "TEXTAREA")){
initialValue = activeElement.value;
if(activeElement.type == "number" || activeElement.type == "week"){
if(initialValue){
activeElement.value = activeElement.value + 1;
}else{
activeElement.value = (activeElement.type == "week") ? "2013-W10" : 1;
}
activeElement.value = initialValue;
}else{
activeElement.value = activeElement.value + " ";
activeElement.value = initialValue;
}
}
},
onTouchEnd: function(/*Event*/e){
// summary:
// User-defined function to handle touchEnd events.
if(this._locked){ return; }
var speed = this._speed = {x:0, y:0};
var dim = this._dim;
var pos = this.getPos();
var to = {}; // destination
if(e){
if(!this._conn){ return; } // if we get onTouchEnd without onTouchStart, ignore it.
for(var i = 0; i < this._conn.length; i++){
connect.disconnect(this._conn[i]);
}
this._conn = null;
var clicked = false;
if(!this._aborted && !this._moved){
clicked = true;
}
if(clicked){ // clicked, not dragged or flicked
this.hideScrollBar();
this.removeCover();
// need to send a synthetic click?
if(has("touch") && has("clicks-prevented") && !this.isFormElement(e.target)){
var elem = e.target;
if(elem.nodeType != 1){
elem = elem.parentNode;
}
setTimeout(function(){
dm._sendClick(elem, e);
});
}
return;
}
speed = this._speed = this.getSpeed();
}else{
if(pos.x == 0 && pos.y == 0){ return; } // initializing
dim = this.getDim();
}
if(this._v){
to.y = pos.y + speed.y;
}
if(this._h || this._f){
to.x = pos.x + speed.x;
}
if(this.adjustDestination(to, pos, dim) === false){ return; }
if(this.constraint){
if(this.scrollDir == "v" && dim.c.h < dim.d.h){ // content is shorter than display
this.slideTo({y:0}, 0.3, "ease-out"); // go back to the top
return;
}else if(this.scrollDir == "h" && dim.c.w < dim.d.w){ // content is narrower than display
this.slideTo({x:0}, 0.3, "ease-out"); // go back to the left
return;
}else if(this._v && this._h && dim.c.h < dim.d.h && dim.c.w < dim.d.w){
this.slideTo({x:0, y:0}, 0.3, "ease-out"); // go back to the top-left
return;
}
}
var duration, easing = "ease-out";
var bounce = {};
if(this._v && this.constraint){
if(to.y > 0){ // going down. bounce back to the top.
if(pos.y > 0){ // started from below the screen area. return quickly.
duration = 0.3;
to.y = 0;
}else{
to.y = Math.min(to.y, 20);
easing = "linear";
bounce.y = 0;
}
}else if(-speed.y > dim.o.h - (-pos.y)){ // going up. bounce back to the bottom.
if(pos.y < -dim.o.h){ // started from above the screen top. return quickly.
duration = 0.3;
to.y = dim.c.h <= dim.d.h ? 0 : -dim.o.h; // if shorter, move to 0
}else{
to.y = Math.max(to.y, -dim.o.h - 20);
easing = "linear";
bounce.y = -dim.o.h;
}
}
}
if((this._h || this._f) && this.constraint){
if(to.x > 0){ // going right. bounce back to the left.
if(pos.x > 0){ // started from right of the screen area. return quickly.
duration = 0.3;
to.x = 0;
}else{
to.x = Math.min(to.x, 20);
easing = "linear";
bounce.x = 0;
}
}else if(-speed.x > dim.o.w - (-pos.x)){ // going left. bounce back to the right.
if(pos.x < -dim.o.w){ // started from left of the screen top. return quickly.
duration = 0.3;
to.x = dim.c.w <= dim.d.w ? 0 : -dim.o.w; // if narrower, move to 0
}else{
to.x = Math.max(to.x, -dim.o.w - 20);
easing = "linear";
bounce.x = -dim.o.w;
}
}
}
this._bounce = (bounce.x !== undefined || bounce.y !== undefined) ? bounce : undefined;
if(duration === undefined){
var distance, velocity;
if(this._v && this._h){
velocity = Math.sqrt(speed.x*speed.x + speed.y*speed.y);
distance = Math.sqrt(Math.pow(to.y - pos.y, 2) + Math.pow(to.x - pos.x, 2));
}else if(this._v){
velocity = speed.y;
distance = to.y - pos.y;
}else if(this._h){
velocity = speed.x;
distance = to.x - pos.x;
}
if(distance === 0 && !e){ return; } // #13154
duration = velocity !== 0 ? Math.abs(distance / velocity) : 0.01; // time = distance / velocity
}
this.slideTo(to, duration, easing);
},
adjustDestination: function(/*Object*/to, /*Object*/pos, /*Object*/dim){
// summary:
// A stub function to be overridden by subclasses.
// description:
// This function is called from onTouchEnd(). The purpose is to give its
// subclasses a chance to adjust the destination position. If this
// function returns false, onTouchEnd() returns immediately without
// performing scroll.
// to:
// The destination position. An object with x and y.
// pos:
// The current position. An object with x and y.
// dim:
// Dimension information returned by getDim().
// subclass may want to implement
return true; // Boolean
},
abort: function(){
// summary:
// Aborts scrolling.
// description:
// This function stops the scrolling animation that is currently
// running. It is called when the user touches the screen while
// scrolling.
this._aborted = true;
this.scrollTo(this.getPos());
this.stopAnimation();
},
stopAnimation: function(){
// summary:
// Stops the currently running animation.
domClass.remove(this.containerNode, "mblScrollableScrollTo2");
this.containerNode.className = this.containerNode.className
.replace(/mblScrollableScrollTo2-[^ ]+/, ""); // TODO: remove supports regexp?
// TODO: there must be a better way than hardcoding this class name in
// 20 different places and 2 files
if(this._scrollBarV){
this._scrollBarV.className = "";
}
if(this._scrollBarH){
this._scrollBarH.className = "";
}
if(this._useTransformTransition || this._useTopLeft){
this.containerNode.style[css3.name("transition")] = "";
if(this._scrollBarV) { this._scrollBarV.style[css3.name("transition")] = ""; }
if(this._scrollBarH) { this._scrollBarH.style[css3.name("transition")] = ""; }
}
},
scrollIntoView: function(/*DOMNode*/node, /*Boolean?*/alignWithTop, /*Number?*/duration){
// summary:
// Scrolls the pane until the searching node is in the view.
// node:
// A DOM node to be searched for view.
// alignWithTop:
// If true, aligns the node at the top of the pane.
// If false, aligns the node at the bottom of the pane.
// duration:
// Duration of scrolling in seconds. (ex. 0.3)
// If not specified, scrolls without animation.
// description:
// Just like the scrollIntoView method of DOM elements, this
// function causes the given node to scroll into view, aligning it
// either at the top or bottom of the pane.
if(!this._v){ return; } // cannot scroll vertically
var c = this.containerNode,
h = this.getDim().d.h, // the height of ScrollableView's content display area
top = 0;
// Get the top position of node relative to containerNode
for(var n = node; n !== c; n = n.offsetParent){
if(!n || n.tagName === "BODY"){ return; } // exit if node is not a child of scrollableView
top += n.offsetTop;
}
// Calculate scroll destination position
var y = alignWithTop ? Math.max(h - c.offsetHeight, -top) : Math.min(0, h - top - node.offsetHeight);
// Scroll to destination position
(duration && typeof duration === "number") ?
this.slideTo({y: y}, duration, "ease-out") : this.scrollTo({y: y});
},
getSpeed: function(){
// summary:
// Returns an object that indicates the scrolling speed.
// description:
// From the position and elapsed time information, calculates the
// scrolling speed, and returns an object with x and y.
var x = 0, y = 0, n = this._time.length;
// if the user holds the mouse or finger more than 0.5 sec, do not move.
if(n >= 2 && (new Date()).getTime() - this.startTime - this._time[n - 1] < 500){
var dy = this._posY[n - (n > 3 ? 2 : 1)] - this._posY[(n - 6) >= 0 ? n - 6 : 0];
var dx = this._posX[n - (n > 3 ? 2 : 1)] - this._posX[(n - 6) >= 0 ? n - 6 : 0];
var dt = this._time[n - (n > 3 ? 2 : 1)] - this._time[(n - 6) >= 0 ? n - 6 : 0];
y = this.calcSpeed(dy, dt);
x = this.calcSpeed(dx, dt);
}
return {x:x, y:y};
},
calcSpeed: function(/*Number*/distance, /*Number*/time){
// summary:
// Calculate the speed given the distance and time.
return Math.round(distance / time * 100) * 4;
},
scrollTo: function(/*Object*/to, /*Boolean?*/doNotMoveScrollBar, /*DomNode?*/node){
// summary:
// Scrolls to the given position immediately without animation.
// to:
// The destination position. An object with x and y.
// ex. {x:0, y:-5}
// doNotMoveScrollBar:
// If true, the scroll bar will not be updated. If not specified,
// it will be updated.
// node:
// A DOM node to scroll. If not specified, defaults to
// this.containerNode.
// scroll events
var scrollEvent, beforeTopHeight, afterBottomHeight;
var doScroll = true;
if(!this._aborted && this._conn){ // No scroll event if the call to scrollTo comes from abort or onTouchEnd
if(!this._dim){
this._dim = this.getDim();
}
beforeTopHeight = (to.y > 0)?to.y:0;
afterBottomHeight = (this._dim.o.h + to.y < 0)?-1 * (this._dim.o.h + to.y):0;
scrollEvent = {bubbles: false,
cancelable: false,
x: to.x,
y: to.y,
beforeTop: beforeTopHeight > 0,
beforeTopHeight: beforeTopHeight,
afterBottom: afterBottomHeight > 0,
afterBottomHeight: afterBottomHeight};
// before scroll event
doScroll = this.onBeforeScroll(scrollEvent);
}
if(doScroll){
var s = (node || this.containerNode).style;
if(has("css3-animations")){
if(!this._useTopLeft){
if(this._useTransformTransition){
s[css3.name("transition")] = "";
}
s[css3.name("transform")] = this.makeTranslateStr(to);
}else{
s[css3.name("transition")] = "";
if(this._v){
s.top = to.y + "px";
}
if(this._h || this._f){
s.left = to.x + "px";
}
}
}else{
if(this._v){
s.top = to.y + "px";
}
if(this._h || this._f){
s.left = to.x + "px";
}
}
if(has("ios")){
this._keepInputCaretInActiveElement();
}
if(!doNotMoveScrollBar){
this.scrollScrollBarTo(this.calcScrollBarPos(to));
}
if(scrollEvent){
// After scroll event
this.onAfterScroll(scrollEvent);
}
}
},
onBeforeScroll: function(/*Event*/e){
// e: Event
// the scroll event, that contains the following attributes:
// x (x coordinate of the scroll destination),
// y (y coordinate of the scroll destination),
// beforeTop (a boolean that is true if the scroll detination is before the top of the scrollable),
// beforeTopHeight (the number of pixels before the top of the scrollable for the scroll destination),
// afterBottom (a boolean that is true if the scroll destination is after the bottom of the scrollable),
// afterBottomHeight (the number of pixels after the bottom of the scrollable for the scroll destination)
// summary:
// called before a scroll is initiated. If this method returns false,
// the scroll is canceled.
// tags:
// callback
return true;
},
onAfterScroll: function(/*Event*/e){
// e: Event
// the scroll event, that contains the following attributes:
// x (x coordinate of the scroll destination),
// y (y coordinate of the scroll destination),
// beforeTop (a boolean that is true if the scroll detination is before the top of the scrollable),
// beforeTopHeight (the number of pixels before the top of the scrollable for the scroll destination),
// afterBottom (a boolean that is true if the scroll destination is after the bottom of the scrollable),
// afterBottomHeight (the number of pixels after the bottom of the scrollable for the scroll destination)
// summary:
// called after a scroll has been performed.
// tags:
// callback
},
slideTo: function(/*Object*/to, /*Number*/duration, /*String*/easing){
// summary:
// Scrolls to the given position with the slide animation.
// to:
// The scroll destination position. An object with x and/or y.
// ex. {x:0, y:-5}, {y:-29}, etc.
// duration:
// Duration of scrolling in seconds. (ex. 0.3)
// easing:
// The name of easing effect which webkit supports.
// "ease", "linear", "ease-in", "ease-out", etc.
this._runSlideAnimation(this.getPos(), to, duration, easing, this.containerNode, 2);
this.slideScrollBarTo(to, duration, easing);
},
makeTranslateStr: function(/*Object*/to){
// summary:
// Constructs a string value that is passed to the -webkit-transform property.
// to:
// The destination position. An object with x and/or y.
// description:
// Return value example: "translate3d(0px,-8px,0px)"
var y = this._v && typeof to.y == "number" ? to.y+"px" : "0px";
var x = (this._h||this._f) && typeof to.x == "number" ? to.x+"px" : "0px";
return has("translate3d") ?
"translate3d("+x+","+y+",0px)" : "translate("+x+","+y+")";
},
getPos: function(){
// summary:
// Gets the top position in the midst of animation.
if(has("css3-animations")){
var s = win.doc.defaultView.getComputedStyle(this.containerNode, '');
if(!this._useTopLeft){
var m = s[css3.name("transform")];
if(m && m.indexOf("matrix") === 0){
var arr = m.split(/[,\s\)]+/);
// IE10 returns a matrix3d
var i = m.indexOf("matrix3d") === 0 ? 12 : 4;
return {y:arr[i+1] - 0, x:arr[i] - 0};
}
return {x:0, y:0};
}else{
return {x:parseInt(s.left) || 0, y:parseInt(s.top) || 0};
}
}else{
// this.containerNode.offsetTop does not work here,
// because it adds the height of the top margin.
var y = parseInt(this.containerNode.style.top) || 0;
return {y:y, x:this.containerNode.offsetLeft};
}
},
getDim: function(){
// summary:
// Returns various internal dimensional information needed for calculation.
var d = {};
// content width/height
d.c = {h:this.containerNode.offsetHeight, w:this.containerNode.offsetWidth};
// view width/height
d.v = {h:this.domNode.offsetHeight + this._appFooterHeight, w:this.domNode.offsetWidth};
// display width/height
d.d = {h:d.v.h - this.fixedHeaderHeight - this.fixedFooterHeight - this._appFooterHeight, w:d.v.w};
// overflowed width/height
d.o = {h:d.c.h - d.v.h + this.fixedHeaderHeight + this.fixedFooterHeight + this._appFooterHeight, w:d.c.w - d.v.w};
return d;
},
showScrollBar: function(){
// summary:
// Shows the scroll bar.
// description:
// This function creates the scroll bar instance if it does not
// exist yet, and calls resetScrollBar() to reset its length and
// position.
if(!this.scrollBar){ return; }
var dim = this._dim;
if(this.scrollDir == "v" && dim.c.h <= dim.d.h){ return; }
if(this.scrollDir == "h" && dim.c.w <= dim.d.w){ return; }
if(this._v && this._h && dim.c.h <= dim.d.h && dim.c.w <= dim.d.w){ return; }
var createBar = function(self, dir){
var bar = self["_scrollBarNode" + dir];
if(!bar){
var wrapper = domConstruct.create("div", null, self.domNode);
var props = { position: "absolute", overflow: "hidden" };
if(dir == "V"){
props.right = "2px";
props.width = "5px";
}else{
props.bottom = (self.isLocalFooter ? self.fixedFooterHeight : 0) + 2 + "px";
props.height = "5px";
}
domStyle.set(wrapper, props);
wrapper.className = "mblScrollBarWrapper";
self["_scrollBarWrapper"+dir] = wrapper;
bar = domConstruct.create("div", null, wrapper);
domStyle.set(bar, css3.add({
opacity: 0.6,
position: "absolute",
backgroundColor: "#606060",
fontSize: "1px",
MozBorderRadius: "2px",
zIndex: 2147483647 // max of signed 32-bit integer
}, {
borderRadius: "2px",
transformOrigin: "0 0"
}));
domStyle.set(bar, dir == "V" ? {width: "5px"} : {height: "5px"});
self["_scrollBarNode" + dir] = bar;
}
return bar;
};
if(this._v && !this._scrollBarV){
this._scrollBarV = createBar(this, "V");
}
if(this._h && !this._scrollBarH){
this._scrollBarH = createBar(this, "H");
}
this.resetScrollBar();
},
hideScrollBar: function(){
// summary:
// Hides the scroll bar.
// description:
// If the fadeScrollBar property is true, hides the scroll bar with
// the fade animation.
if(this.fadeScrollBar && has("css3-animations")){
if(!dm._fadeRule){
var node = domConstruct.create("style", null, win.doc.getElementsByTagName("head")[0]);
node.textContent =
".mblScrollableFadeScrollBar{"+
" " + css3.name("animation-duration", true) + ": 1s;"+
" " + css3.name("animation-name", true) + ": scrollableViewFadeScrollBar;}"+
"@" + css3.name("keyframes", true) + " scrollableViewFadeScrollBar{"+
" from { opacity: 0.6; }"+
" to { opacity: 0; }}";
dm._fadeRule = node.sheet.cssRules[1];
}
}
if(!this.scrollBar){ return; }
var f = function(bar, self){
domStyle.set(bar, css3.add({
opacity: 0
}, {
animationDuration: ""
}));
// do not use fade animation in case of using top/left on Android
// since it causes screen flicker during adress bar's fading out
if(!(self._useTopLeft && has('android'))){
bar.className = "mblScrollableFadeScrollBar";
}
};
if(this._scrollBarV){
f(this._scrollBarV, this);
this._scrollBarV = null;
}
if(this._scrollBarH){
f(this._scrollBarH, this);
this._scrollBarH = null;
}
},
calcScrollBarPos: function(/*Object*/to){
// summary:
// Calculates the scroll bar position.
// description:
// Given the scroll destination position, calculates the top and/or
// the left of the scroll bar(s). Returns an object with x and y.
// to:
// The scroll destination position. An object with x and y.
// ex. {x:0, y:-5}
var pos = {};
var dim = this._dim;
var f = function(wrapperH, barH, t, d, c){
var y = Math.round((d - barH - 8) / (d - c) * t);
if(y < -barH + 5){
y = -barH + 5;
}
if(y > wrapperH - 5){
y = wrapperH - 5;
}
return y;
};
if(typeof to.y == "number" && this._scrollBarV){
pos.y = f(this._scrollBarWrapperV.offsetHeight, this._scrollBarV.offsetHeight, to.y, dim.d.h, dim.c.h);
}
if(typeof to.x == "number" && this._scrollBarH){
pos.x = f(this._scrollBarWrapperH.offsetWidth, this._scrollBarH.offsetWidth, to.x, dim.d.w, dim.c.w);
}
return pos;
},
scrollScrollBarTo: function(/*Object*/to){
// summary:
// Moves the scroll bar(s) to the given position without animation.
// to:
// The destination position. An object with x and/or y.
// ex. {x:2, y:5}, {y:20}, etc.
if(!this.scrollBar){ return; }
if(this._v && this._scrollBarV && typeof to.y == "number"){
if(has("css3-animations")){
if(!this._useTopLeft){
if(this._useTransformTransition){
this._scrollBarV.style[css3.name("transition")] = "";
}
this._scrollBarV.style[css3.name("transform")] = this.makeTranslateStr({y:to.y});
}else{
domStyle.set(this._scrollBarV, css3.add({
top: to.y + "px"
}, {
transition: ""
}));
}
}else{
this._scrollBarV.style.top = to.y + "px";
}
}
if(this._h && this._scrollBarH && typeof to.x == "number"){
if(has("css3-animations")){
if(!this._useTopLeft){
if(this._useTransformTransition){
this._scrollBarH.style[css3.name("transition")] = "";
}
this._scrollBarH.style[css3.name("transform")] = this.makeTranslateStr({x:to.x});
}else{
domStyle.set(this._scrollBarH, css3.add({
left: to.x + "px"
}, {
transition: ""
}));
}
}else{
this._scrollBarH.style.left = to.x + "px";
}
}
},
slideScrollBarTo: function(/*Object*/to, /*Number*/duration, /*String*/easing){
// summary:
// Moves the scroll bar(s) to the given position with the slide animation.
// to:
// The destination position. An object with x and y.
// ex. {x:0, y:-5}
// duration:
// Duration of the animation in seconds. (ex. 0.3)
// easing:
// The name of easing effect which webkit supports.
// "ease", "linear", "ease-in", "ease-out", etc.
if(!this.scrollBar){ return; }
var fromPos = this.calcScrollBarPos(this.getPos());
var toPos = this.calcScrollBarPos(to);
if(this._v && this._scrollBarV){
this._runSlideAnimation({y:fromPos.y}, {y:toPos.y}, duration, easing, this._scrollBarV, 0);
}
if(this._h && this._scrollBarH){
this._runSlideAnimation({x:fromPos.x}, {x:toPos.x}, duration, easing, this._scrollBarH, 1);
}
},
_runSlideAnimation: function(/*Object*/from, /*Object*/to, /*Number*/duration, /*String*/easing, /*DomNode*/node, /*Number*/idx){
// tags:
// private
// idx: 0:scrollbarV, 1:scrollbarH, 2:content
if(has("css3-animations")){
if(!this._useTopLeft){
if(this._useTransformTransition){
// for iOS6 (maybe others?): use -webkit-transform + -webkit-transition
if(to.x === undefined){ to.x = from.x; }
if(to.y === undefined){ to.y = from.y; }
// make sure we actually change the transform, otherwise no webkitTransitionEnd is fired.
if(to.x !== from.x || to.y !== from.y){
this.onFlickAnimationStart(); // needed because there is no transitionstart event.
domStyle.set(node, css3.add({}, {
transitionProperty: css3.name("transform"),
transitionDuration: duration + "s",
transitionTimingFunction: easing
}));
var t = this.makeTranslateStr(to);
setTimeout(function(){ // setTimeout is needed to prevent webkitTransitionEnd not fired
domStyle.set(node, css3.add({}, {
transform: t
}));
}, 0);
domClass.add(node, "mblScrollableScrollTo"+idx);
} else {
// transform not changed, just hide the scrollbar
this.hideScrollBar();
this.removeCover();
}
}else{
// use -webkit-transform + -webkit-animation
var entering = this.findDisp(this.domNode) === this.domNode;
var className = this.setKeyframes(from, to, idx, entering);
domStyle.set(node, css3.add({}, {
animationDuration: duration + "s",
animationTimingFunction: easing
}));
domClass.add(node, className);
domClass.add(node, "mblScrollableScrollTo"+idx);
if(idx == 2){
this.scrollTo(to, true, node);
}else{
this.scrollScrollBarTo(to);
}
}
}else if(to.x !== undefined || to.y !== undefined){
this.onFlickAnimationStart(); // #17822: needed because there is no transitionstart event.
domStyle.set(node, css3.add({}, {
// #17822 when scrolling on one direction, avoid unnecessarily animating
// both top and left, because this leads to two transitionend events fired
// instead of one in some browsers (Safari/iOS7 at least).
transitionProperty: (to.x !== undefined && to.y !== undefined) ?
"top, left" :
to.y !== undefined ? "top" : "left",
transitionDuration: duration + "s",
transitionTimingFunction: easing
}));
setTimeout(function(){ // setTimeout is needed to prevent webkitTransitionEnd not fired
var style = {};
if(to.x !== undefined){
style.left = to.x + "px";
}
if(to.y !== undefined){
style.top = to.y + "px";
}
domStyle.set(node, style);
}, 0);
domClass.add(node, "mblScrollableScrollTo"+idx);
}
}else if(dojo.fx && dojo.fx.easing && duration){
// If you want to support non-webkit browsers,
// your application needs to load necessary modules as follows:
//
// | dojo.require("dojo.fx");
// | dojo.require("dojo.fx.easing");
//
// This module itself does not make dependency on them.
// TODO: for 2.0 the dojo global is going away. Use require("dojo/fx") and require("dojo/fx/easing") instead.
var self = this;
var s = dojo.fx.slideTo({
node: node,
duration: duration*1000,
left: to.x,
top: to.y,
easing: (easing == "ease-out") ? dojo.fx.easing.quadOut : dojo.fx.easing.linear,
onBegin: function(){ // #17822
if(idx == 2){
self.onFlickAnimationStart();
}
},
onEnd: function(){
if(idx == 2){
self.onFlickAnimationEnd();
}
}
}).play();
}else{
// directly jump to the destination without animation
if(idx == 2){
this.onFlickAnimationStart(); // #17822
this.scrollTo(to, false, node);
this.onFlickAnimationEnd();
}else{
this.scrollScrollBarTo(to);
}
}
},
resetScrollBar: function(){
// summary:
// Resets the scroll bar length, position, etc.
var f = function(wrapper, bar, d, c, hd, v){
if(!bar){ return; }
var props = {};
props[v ? "top" : "left"] = hd + 4 + "px"; // +4 is for top or left margin
var t = (d - 8) <= 0 ? 1 : d - 8;
props[v ? "height" : "width"] = t + "px";
domStyle.set(wrapper, props);
var l = Math.round(d * d / c); // scroll bar length
l = Math.min(Math.max(l - 8, 5), t); // -8 is for margin for both ends
bar.style[v ? "height" : "width"] = l + "px";
domStyle.set(bar, {"opacity": 0.6});
};
var dim = this.getDim();
f(this._scrollBarWrapperV, this._scrollBarV, dim.d.h, dim.c.h, this.fixedHeaderHeight, true);
f(this._scrollBarWrapperH, this._scrollBarH, dim.d.w, dim.c.w, 0);
this.createMask();
},
createMask: function(){
// summary:
// Creates a mask for a scroll bar edge.
// description:
// This function creates a mask that hides corners of one scroll
// bar edge to make it round edge. The other side of the edge is
// always visible and round shaped with the border-radius style.
if(!(has("mask-image"))){ return; }
if(this._scrollBarWrapperV){
var h = this._scrollBarWrapperV.offsetHeight;
maskUtils.createRoundMask(this._scrollBarWrapperV, 0, 0, 0, 0, 5, h, 2, 2, 0.5);
}
if(this._scrollBarWrapperH){
var w = this._scrollBarWrapperH.offsetWidth;
maskUtils.createRoundMask(this._scrollBarWrapperH, 0, 0, 0, 0, w, 5, 2, 2, 0.5);
}
},
flashScrollBar: function(){
// summary:
// Shows the scroll bar instantly.
// description:
// This function shows the scroll bar, and then hides it 300ms
// later. This is used to show the scroll bar to the user for a
// short period of time when a hidden view is revealed.
if(this.disableFlashScrollBar || !this.domNode){ return; }
this._dim = this.getDim();
if(this._dim.d.h <= 0){ return; } // dom is not ready
this.showScrollBar();
var _this = this;
setTimeout(function(){
_this.hideScrollBar();
}, 300);
},
addCover: function(){
// summary:
// Adds the transparent DIV cover.
// description:
// The cover is to prevent DOM events from affecting the child
// widgets such as a list widget. Without the cover, for example,
// child widgets may receive a click event and respond to it
// unexpectedly when the user flicks the screen to scroll.
// Note that only the desktop browsers need the cover.
if(!has("touch") && !(has("pointer-events") || has("MSPointer")) && !this.noCover){
if(!dm._cover){
dm._cover = domConstruct.create("div", null, win.doc.body);
dm._cover.className = "mblScrollableCover";
domStyle.set(dm._cover, {
backgroundColor: "#ffff00",
opacity: 0,
position: "absolute",
top: "0px",
left: "0px",
width: "100%",
height: "100%",
zIndex: 2147483647 // max of signed 32-bit integer
});
this._ch.push(connect.connect(dm._cover, touch.press, this, "onTouchEnd"));
}else{
dm._cover.style.display = "";
}
this.setSelectable(dm._cover, false);
this.setSelectable(this.domNode, false);
}
},
removeCover: function(){
// summary:
// Removes the transparent DIV cover.
if(!has("touch") && dm._cover){
dm._cover.style.display = "none";
this.setSelectable(dm._cover, true);
this.setSelectable(this.domNode, true);
}
},
setKeyframes: function(/*Object*/from, /*Object*/to, /*Number*/idx, entering){
// summary:
// Programmatically sets key frames for the scroll animation.
if(!dm._rule){
dm._rule = [];
}
var keyframeId = idx + (entering ? "-in" : "-out");
// idx: 0:scrollbarV, 1:scrollbarH, 2:content
if(!(dm._rule[keyframeId])){
var node = domConstruct.create("style", null, win.doc.getElementsByTagName("head")[0]);
node.textContent =
".mblScrollableScrollTo"+keyframeId+"{" + css3.name("animation-name", true) + ": scrollableViewScroll"+keyframeId+";}"+
"@" + css3.name("keyframes", true) + " scrollableViewScroll"+keyframeId+"{}";
dm._rule[keyframeId] = node.sheet.cssRules[1];
}
var rule = dm._rule[keyframeId];
if(rule){
if(from){
rule.deleteRule(has("webkit")?"from":0);
(rule.insertRule||rule.appendRule).call(rule, "from { " + css3.name("transform", true) + ": "+this.makeTranslateStr(from)+"; }");
}
if(to){
if(to.x === undefined){ to.x = from.x; }
if(to.y === undefined){ to.y = from.y; }
rule.deleteRule(has("webkit")?"to":1);
(rule.insertRule||rule.appendRule).call(rule, "to { " + css3.name("transform", true) + ": "+this.makeTranslateStr(to)+"; }");
}
}
return "mblScrollableScrollTo"+keyframeId;
},
setSelectable: function(/*DomNode*/node, /*Boolean*/selectable){
// summary:
// Sets the given node as selectable or unselectable.
// dojo.setSelectable has dependency on dojo.query. Redefine our own.
node.style.KhtmlUserSelect = selectable ? "auto" : "none";
node.style.MozUserSelect = selectable ? "" : "none";
node.onselectstart = selectable ? null : function(){return false;};
if(has("ie")){
node.unselectable = selectable ? "" : "on";
var nodes = node.getElementsByTagName("*");
for(var i = 0; i < nodes.length; i++){
nodes[i].unselectable = selectable ? "" : "on";
}
}
}
});
Scrollable = has("dojo-bidi") ? declare("dojox.mobile.Scrollable", [Scrollable, BidiScrollable]) : Scrollable;
lang.setObject("dojox.mobile.scrollable", Scrollable);
return Scrollable;
});
},
'dijit/form/_TextBoxMixin':function(){
define([
"dojo/_base/array", // array.forEach
"dojo/_base/declare", // declare
"dojo/dom", // dom.byId
"dojo/sniff", // has("ie"), has("dojo-bidi")
"dojo/keys", // keys.ALT keys.CAPS_LOCK keys.CTRL keys.META keys.SHIFT
"dojo/_base/lang", // lang.mixin
"dojo/on", // on
"../main" // for exporting dijit._setSelectionRange, dijit.selectInputText
], function(array, declare, dom, has, keys, lang, on, dijit){
// module:
// dijit/form/_TextBoxMixin
var _TextBoxMixin = declare("dijit.form._TextBoxMixin" + (has("dojo-bidi") ? "_NoBidi" : ""), null, {
// summary:
// A mixin for textbox form input widgets
// trim: Boolean
// Removes leading and trailing whitespace if true. Default is false.
trim: false,
// uppercase: Boolean
// Converts all characters to uppercase if true. Default is false.
uppercase: false,
// lowercase: Boolean
// Converts all characters to lowercase if true. Default is false.
lowercase: false,
// propercase: Boolean
// Converts the first character of each word to uppercase if true.
propercase: false,
// maxLength: String
// HTML INPUT tag maxLength declaration.
maxLength: "",
// selectOnClick: [const] Boolean
// If true, all text will be selected when focused with mouse
selectOnClick: false,
// placeHolder: String
// Defines a hint to help users fill out the input field (as defined in HTML 5).
// This should only contain plain text (no html markup).
placeHolder: "",
_getValueAttr: function(){
// summary:
// Hook so get('value') works as we like.
// description:
// For `dijit/form/TextBox` this basically returns the value of the ``.
//
// For `dijit/form/MappedTextBox` subclasses, which have both
// a "displayed value" and a separate "submit value",
// This treats the "displayed value" as the master value, computing the
// submit value from it via this.parse().
return this.parse(this.get('displayedValue'), this.constraints);
},
_setValueAttr: function(value, /*Boolean?*/ priorityChange, /*String?*/ formattedValue){
// summary:
// Hook so set('value', ...) works.
//
// description:
// Sets the value of the widget to "value" which can be of
// any type as determined by the widget.
//
// value:
// The visual element value is also set to a corresponding,
// but not necessarily the same, value.
//
// formattedValue:
// If specified, used to set the visual element value,
// otherwise a computed visual value is used.
//
// priorityChange:
// If true, an onChange event is fired immediately instead of
// waiting for the next blur event.
var filteredValue;
if(value !== undefined){
// TODO: this is calling filter() on both the display value and the actual value.
// I added a comment to the filter() definition about this, but it should be changed.
filteredValue = this.filter(value);
if(typeof formattedValue != "string"){
if(filteredValue !== null && ((typeof filteredValue != "number") || !isNaN(filteredValue))){
formattedValue = this.filter(this.format(filteredValue, this.constraints));
}else{
formattedValue = '';
}
// Ensure the filtered value does not change after being formatted. See track #17955.
//
// This check is only applied when the formatted value is not specified by the caller in order to allow the
// behavior to be overriden. This is needed whenever value synonyms cannot be determined using parse/compare. For
// example, dijit/form/FilteringSelect determines the formatted value asynchronously and applies it using a
// callback to this method.
//
// TODO: Should developers be warned that they broke the round trip on format?
if (this.compare(filteredValue, this.filter(this.parse(formattedValue, this.constraints))) != 0){
formattedValue = null;
}
}
}
if(formattedValue != null /* and !undefined */ && ((typeof formattedValue) != "number" || !isNaN(formattedValue)) && this.textbox.value != formattedValue){
this.textbox.value = formattedValue;
this._set("displayedValue", this.get("displayedValue"));
}
this.inherited(arguments, [filteredValue, priorityChange]);
},
// displayedValue: String
// For subclasses like ComboBox where the displayed value
// (ex: Kentucky) and the serialized value (ex: KY) are different,
// this represents the displayed value.
//
// Setting 'displayedValue' through set('displayedValue', ...)
// updates 'value', and vice-versa. Otherwise 'value' is updated
// from 'displayedValue' periodically, like onBlur etc.
//
// TODO: move declaration to MappedTextBox?
// Problem is that ComboBox references displayedValue,
// for benefit of FilteringSelect.
displayedValue: "",
_getDisplayedValueAttr: function(){
// summary:
// Hook so get('displayedValue') works.
// description:
// Returns the displayed value (what the user sees on the screen),
// after filtering (ie, trimming spaces etc.).
//
// For some subclasses of TextBox (like ComboBox), the displayed value
// is different from the serialized value that's actually
// sent to the server (see `dijit/form/ValidationTextBox.serialize()`)
// TODO: maybe we should update this.displayedValue on every keystroke so that we don't need
// this method
// TODO: this isn't really the displayed value when the user is typing
return this.filter(this.textbox.value);
},
_setDisplayedValueAttr: function(/*String*/ value){
// summary:
// Hook so set('displayedValue', ...) works.
// description:
// Sets the value of the visual element to the string "value".
// The widget value is also set to a corresponding,
// but not necessarily the same, value.
if(value == null /* or undefined */){
value = ''
}
else if(typeof value != "string"){
value = String(value)
}
this.textbox.value = value;
// sets the serialized value to something corresponding to specified displayedValue
// (if possible), and also updates the textbox.value, for example converting "123"
// to "123.00"
this._setValueAttr(this.get('value'), undefined);
this._set("displayedValue", this.get('displayedValue'));
},
format: function(value /*=====, constraints =====*/){
// summary:
// Replaceable function to convert a value to a properly formatted string.
// value: String
// constraints: Object
// tags:
// protected extension
return value == null /* or undefined */ ? "" : (value.toString ? value.toString() : value);
},
parse: function(value /*=====, constraints =====*/){
// summary:
// Replaceable function to convert a formatted string to a value
// value: String
// constraints: Object
// tags:
// protected extension
return value; // String
},
_refreshState: function(){
// summary:
// After the user types some characters, etc., this method is
// called to check the field for validity etc. The base method
// in `dijit/form/TextBox` does nothing, but subclasses override.
// tags:
// protected
},
onInput: function(/*Event*/ /*===== evt =====*/){
// summary:
// Connect to this function to receive notifications of various user data-input events.
// Return false to cancel the event and prevent it from being processed.
// Note that although for historical reasons this method is called `onInput()`, it doesn't
// correspond to the standard DOM "input" event, because it occurs before the input has been processed.
// event:
// keydown | keypress | cut | paste | compositionend
// tags:
// callback
},
_onInput: function(/*Event*/ evt){
// summary:
// Called AFTER the input event has happened and this.textbox.value has new value.
this._lastInputEventValue = this.textbox.value;
// For Combobox, this needs to be called w/the keydown/keypress event that was passed to onInput().
// As a backup, use the "input" event itself.
this._processInput(this._lastInputProducingEvent || evt);
delete this._lastInputProducingEvent;
if(this.intermediateChanges){
this._handleOnChange(this.get('value'), false);
}
},
_processInput: function(/*Event*/ /*===== evt =====*/){
// summary:
// Default action handler for user input events.
// Called after the "input" event (i.e. after this.textbox.value has been updated),
// but `evt` is the keydown/keypress/etc. event that triggered the "input" event.
// tags:
// protected
this._refreshState();
// In case someone is watch()'ing for changes to displayedValue
this._set("displayedValue", this.get("displayedValue"));
},
postCreate: function(){
// setting the value here is needed since value="" in the template causes "undefined"
// and setting in the DOM (instead of the JS object) helps with form reset actions
this.textbox.setAttribute("value", this.textbox.value); // DOM and JS values should be the same
this.inherited(arguments);
// normalize input events to reduce spurious event processing
// keydown: do not forward modifier keys
// set charOrCode to numeric keycode
// keypress: do not forward numeric charOrCode keys (already sent through onkeydown)
// paste, cut, compositionend: set charOrCode to 229 (IME)
function handleEvent(e){
var charOrCode;
// Filter out keydown events that will be followed by keypress events. Note that chrome/android
// w/word suggestion has keydown/229 events on typing with no corresponding keypress events.
if(e.type == "keydown" && e.keyCode != 229){
charOrCode = e.keyCode;
switch(charOrCode){ // ignore state keys
case keys.SHIFT:
case keys.ALT:
case keys.CTRL:
case keys.META:
case keys.CAPS_LOCK:
case keys.NUM_LOCK:
case keys.SCROLL_LOCK:
return;
}
if(!e.ctrlKey && !e.metaKey && !e.altKey){ // no modifiers
switch(charOrCode){ // ignore location keys
case keys.NUMPAD_0:
case keys.NUMPAD_1:
case keys.NUMPAD_2:
case keys.NUMPAD_3:
case keys.NUMPAD_4:
case keys.NUMPAD_5:
case keys.NUMPAD_6:
case keys.NUMPAD_7:
case keys.NUMPAD_8:
case keys.NUMPAD_9:
case keys.NUMPAD_MULTIPLY:
case keys.NUMPAD_PLUS:
case keys.NUMPAD_ENTER:
case keys.NUMPAD_MINUS:
case keys.NUMPAD_PERIOD:
case keys.NUMPAD_DIVIDE:
return;
}
if((charOrCode >= 65 && charOrCode <= 90) || (charOrCode >= 48 && charOrCode <= 57) || charOrCode == keys.SPACE){
return; // keypress will handle simple non-modified printable keys
}
var named = false;
for(var i in keys){
if(keys[i] === e.keyCode){
named = true;
break;
}
}
if(!named){
return;
} // only allow named ones through
}
}
charOrCode = e.charCode >= 32 ? String.fromCharCode(e.charCode) : e.charCode;
if(!charOrCode){
charOrCode = (e.keyCode >= 65 && e.keyCode <= 90) || (e.keyCode >= 48 && e.keyCode <= 57) || e.keyCode == keys.SPACE ? String.fromCharCode(e.keyCode) : e.keyCode;
}
if(!charOrCode){
charOrCode = 229; // IME
}
if(e.type == "keypress"){
if(typeof charOrCode != "string"){
return;
}
if((charOrCode >= 'a' && charOrCode <= 'z') || (charOrCode >= 'A' && charOrCode <= 'Z') || (charOrCode >= '0' && charOrCode <= '9') || (charOrCode === ' ')){
if(e.ctrlKey || e.metaKey || e.altKey){
return;
} // can only be stopped reliably in keydown
}
}
// create fake event to set charOrCode and to know if preventDefault() was called
var faux = { faux: true }, attr;
for(attr in e){
if(!/^(layer[XY]|returnValue|keyLocation)$/.test(attr)){ // prevent WebKit warnings
var v = e[attr];
if(typeof v != "function" && typeof v != "undefined"){
faux[attr] = v;
}
}
}
lang.mixin(faux, {
charOrCode: charOrCode,
_wasConsumed: false,
preventDefault: function(){
faux._wasConsumed = true;
e.preventDefault();
},
stopPropagation: function(){
e.stopPropagation();
}
});
this._lastInputProducingEvent = faux;
// Give web page author a chance to consume the event. Note that onInput() may be called multiple times
// for same keystroke: once for keypress event and once for input event.
//console.log(faux.type + ', charOrCode = (' + (typeof charOrCode) + ') ' + charOrCode + ', ctrl ' + !!faux.ctrlKey + ', alt ' + !!faux.altKey + ', meta ' + !!faux.metaKey + ', shift ' + !!faux.shiftKey);
if(this.onInput(faux) === false){ // return false means stop
faux.preventDefault();
faux.stopPropagation();
}
if(faux._wasConsumed){
return;
} // if preventDefault was called
// IE8 doesn't emit the "input" event at all, and IE9 doesn't emit it for backspace, delete, cut, etc.
// Since the code below (and perhaps user code) depends on that event, emit it synthetically.
// See http://benalpert.com/2013/06/18/a-near-perfect-oninput-shim-for-ie-8-and-9.html.
if(has("ie") <= 9){
switch(e.keyCode){
case keys.TAB:
case keys.ESCAPE:
case keys.DOWN_ARROW:
case keys.UP_ARROW:
case keys.LEFT_ARROW:
case keys.RIGHT_ARROW:
// These keys may alter the 's value indirectly, but we don't want to emit an "input"
// event. For example, the up/down arrows in TimeTextBox or ComboBox will cause the next
// dropdown item's value to be copied to the .
break;
default:
if(e.keyCode == keys.ENTER && this.textbox.tagName.toLowerCase() != "textarea"){
break;
}
this.defer(function(){
if(this.textbox.value !== this._lastInputEventValue){
on.emit(this.textbox, "input", {bubbles: true});
}
});
}
}
}
this.own(
on(this.textbox, "keydown, keypress, paste, cut, compositionend", lang.hitch(this, handleEvent)),
on(this.textbox, "input", lang.hitch(this, "_onInput")),
// Allow keypress to bubble to this.domNode, so that TextBox.on("keypress", ...) works,
// but prevent it from further propagating, so that typing into a TextBox inside a Toolbar doesn't
// trigger the Toolbar's letter key navigation.
on(this.domNode, "keypress", function(e){ e.stopPropagation(); })
);
},
_blankValue: '', // if the textbox is blank, what value should be reported
filter: function(val){
// summary:
// Auto-corrections (such as trimming) that are applied to textbox
// value on blur or form submit.
// description:
// For MappedTextBox subclasses, this is called twice
//
// - once with the display value
// - once the value as set/returned by set('value', ...)
//
// and get('value'), ex: a Number for NumberTextBox.
//
// In the latter case it does corrections like converting null to NaN. In
// the former case the NumberTextBox.filter() method calls this.inherited()
// to execute standard trimming code in TextBox.filter().
//
// TODO: break this into two methods in 2.0
//
// tags:
// protected extension
if(val === null){
return this._blankValue;
}
if(typeof val != "string"){
return val;
}
if(this.trim){
val = lang.trim(val);
}
if(this.uppercase){
val = val.toUpperCase();
}
if(this.lowercase){
val = val.toLowerCase();
}
if(this.propercase){
val = val.replace(/[^\s]+/g, function(word){
return word.substring(0, 1).toUpperCase() + word.substring(1);
});
}
return val;
},
_setBlurValue: function(){
// Format the displayed value, for example (for NumberTextBox) convert 1.4 to 1.400,
// or (for CurrencyTextBox) 2.50 to $2.50
this._setValueAttr(this.get('value'), true);
},
_onBlur: function(e){
if(this.disabled){
return;
}
this._setBlurValue();
this.inherited(arguments);
},
_isTextSelected: function(){
return this.textbox.selectionStart != this.textbox.selectionEnd;
},
_onFocus: function(/*String*/ by){
if(this.disabled || this.readOnly){
return;
}
// Select all text on focus via click if nothing already selected.
// Since mouse-up will clear the selection, need to defer selection until after mouse-up.
// Don't do anything on focus by tabbing into the widget since there's no associated mouse-up event.
if(this.selectOnClick && by == "mouse"){
// Use on.once() to only select all text on first click only; otherwise users would have no way to clear
// the selection.
this._selectOnClickHandle = on.once(this.domNode, "mouseup, touchend", lang.hitch(this, function(evt){
// Check if the user selected some text manually (mouse-down, mouse-move, mouse-up)
// and if not, then select all the text
if(!this._isTextSelected()){
_TextBoxMixin.selectInputText(this.textbox);
}
}));
this.own(this._selectOnClickHandle);
// in case the mouseup never comes
this.defer(function(){
if(this._selectOnClickHandle){
this._selectOnClickHandle.remove();
this._selectOnClickHandle = null;
}
}, 500); // if mouseup not received soon, then treat it as some gesture
}
// call this.inherited() before refreshState(), since this.inherited() will possibly scroll the viewport
// (to scroll the TextBox into view), which will affect how _refreshState() positions the tooltip
this.inherited(arguments);
this._refreshState();
},
reset: function(){
// Overrides `dijit/_FormWidget/reset()`.
// Additionally resets the displayed textbox value to ''
this.textbox.value = '';
this.inherited(arguments);
}
});
if(has("dojo-bidi")){
_TextBoxMixin = declare("dijit.form._TextBoxMixin", _TextBoxMixin, {
_setValueAttr: function(){
this.inherited(arguments);
this.applyTextDir(this.focusNode);
},
_setDisplayedValueAttr: function(){
this.inherited(arguments);
this.applyTextDir(this.focusNode);
},
_onInput: function(){
this.applyTextDir(this.focusNode);
this.inherited(arguments);
}
});
}
_TextBoxMixin._setSelectionRange = dijit._setSelectionRange = function(/*DomNode*/ element, /*Number?*/ start, /*Number?*/ stop){
if(element.setSelectionRange){
element.setSelectionRange(start, stop);
}
};
_TextBoxMixin.selectInputText = dijit.selectInputText = function(/*DomNode*/ element, /*Number?*/ start, /*Number?*/ stop){
// summary:
// Select text in the input element argument, from start (default 0), to stop (default end).
// TODO: use functions in _editor/selection.js?
element = dom.byId(element);
if(isNaN(start)){
start = 0;
}
if(isNaN(stop)){
stop = element.value ? element.value.length : 0;
}
try{
element.focus();
_TextBoxMixin._setSelectionRange(element, start, stop);
}catch(e){ /* squelch random errors (esp. on IE) from unexpected focus changes or DOM nodes being hidden */
}
};
return _TextBoxMixin;
});
},
'dojox/mobile/SwapView':function(){
define([
"dojo/_base/array",
"dojo/_base/connect",
"dojo/_base/declare",
"dojo/dom",
"dojo/dom-class",
"dijit/registry",
"./View",
"./_ScrollableMixin",
"./sniff",
"./_css3",
"dojo/has!dojo-bidi?dojox/mobile/bidi/SwapView"
], function(array, connect, declare, dom, domClass, registry, View, ScrollableMixin, has, css3, BidiSwapView){
// module:
// dojox/mobile/SwapView
var SwapView = declare(has("dojo-bidi") ? "dojox.mobile.NonBidiSwapView" : "dojox.mobile.SwapView", [View, ScrollableMixin], {
// summary:
// A container that can be swiped horizontally.
// description:
// SwapView is a container widget which can be swiped horizontally.
// SwapView is a subclass of dojox/mobile/View. It allows the user to
// swipe the screen left or right to move between the views. When
// SwapView is swiped, it finds an adjacent SwapView to open. When
// the transition is done, a topic "/dojox/mobile/viewChanged" is
// published. Note that, to behave properly, the SwapView needs to
// occupy the entire width of the screen.
/* internal properties */
// scrollDir: [private] String
// Scroll direction, used by dojox/mobile/scrollable (always "f" for this class).
scrollDir: "f",
// weight: [private] Number
// Frictional weight used to compute scrolling speed.
weight: 1.2,
// _endOfTransitionTimeoutHandle: [private] Object
// The handle (returned by _WidgetBase.defer) for the timeout set on touchEnd in case
// the end of transition event is not fired by the browser.
_endOfTransitionTimeoutHandle: null,
buildRendering: function(){
this.inherited(arguments);
domClass.add(this.domNode, "mblSwapView");
this.setSelectable(this.domNode, false);
this.containerNode = this.domNode;
this.subscribe("/dojox/mobile/nextPage", "handleNextPage");
this.subscribe("/dojox/mobile/prevPage", "handlePrevPage");
this.noResize = true; // not to call resize() from scrollable#init
},
startup: function(){
if(this._started){ return; }
this.inherited(arguments);
},
resize: function(){
// summary:
// Calls resize() of each child widget.
this.inherited(arguments); // scrollable#resize() will be called
array.forEach(this.getChildren(), function(child){
if(child.resize){ child.resize(); }
});
},
onTouchStart: function(/*Event*/e){
// summary:
// Internal function to handle touchStart events.
if(this._siblingViewsInMotion()){ // Ignore touchstart if the views are already in motion
this.propagatable ? e.preventDefault() : event.stop(e);
return;
}
var fromTop = this.domNode.offsetTop;
var nextView = this.nextView(this.domNode);
if(nextView){
nextView.stopAnimation();
domClass.add(nextView.domNode, "mblIn");
// Temporarily add padding to align with the fromNode while transition
nextView.containerNode.style.paddingTop = fromTop + "px";
}
var prevView = this.previousView(this.domNode);
if(prevView){
prevView.stopAnimation();
domClass.add(prevView.domNode, "mblIn");
// Temporarily add padding to align with the fromNode while transition
prevView.containerNode.style.paddingTop = fromTop + "px";
}
this._setSiblingViewsInMotion(true);
this.inherited(arguments);
},
onTouchEnd: function(/*Event*/e){
if(e){
if(!this._moved){ // No transition / animation following touchend in this case
this._setSiblingViewsInMotion(false);
}else{ // There might be a transition / animation following touchend
// As the webkitTransitionEndEvent is not always fired, make sure we call this._setSiblingViewsInMotion(false) even
// if the event is not fired (and onFlickAnimationEnd is not called as a result)
this._endOfTransitionTimeoutHandle = this.defer(function(){
this._setSiblingViewsInMotion(false);
}, 1000);
}
}
this.inherited(arguments);
},
handleNextPage: function(/*Widget*/w){
// summary:
// Called when the "/dojox/mobile/nextPage" topic is published.
var refNode = w.refId && dom.byId(w.refId) || w.domNode;
if(this.domNode.parentNode !== refNode.parentNode){ return; }
if(this.getShowingView() !== this){ return; }
this.goTo(1);
},
handlePrevPage: function(/*Widget*/w){
// summary:
// Called when the "/dojox/mobile/prevPage" topic is published.
var refNode = w.refId && dom.byId(w.refId) || w.domNode;
if(this.domNode.parentNode !== refNode.parentNode){ return; }
if(this.getShowingView() !== this){ return; }
this.goTo(-1);
},
goTo: function(/*Number*/dir, /*String?*/moveTo){
// summary:
// Moves to the next or previous view.
var view = moveTo ? registry.byId(moveTo) :
((dir == 1) ? this.nextView(this.domNode) : this.previousView(this.domNode));
if(view && view !== this){
this.stopAnimation(); // clean-up animation states
view.stopAnimation();
this.domNode._isShowing = false; // update isShowing flag
view.domNode._isShowing = true;
this.performTransition(view.id, dir, "slide", null, function(){
connect.publish("/dojox/mobile/viewChanged", [view]);
});
}
},
isSwapView: function(/*DomNode*/node){
// summary:
// Returns true if the given node is a SwapView widget.
return (node && node.nodeType === 1 && domClass.contains(node, "mblSwapView"));
},
nextView: function(/*DomNode*/node){
// summary:
// Returns the next view.
for(var n = node.nextSibling; n; n = n.nextSibling){
if(this.isSwapView(n)){ return registry.byNode(n); }
}
return null;
},
previousView: function(/*DomNode*/node){
// summary:
// Returns the previous view.
for(var n = node.previousSibling; n; n = n.previousSibling){
if(this.isSwapView(n)){ return registry.byNode(n); }
}
return null;
},
scrollTo: function(/*Object*/to){
// summary:
// Overrides dojox/mobile/scrollable.scrollTo().
if(!this._beingFlipped){
var newView, x;
if(to.x){
if(to.x < 0){
newView = this.nextView(this.domNode);
x = to.x + this.domNode.offsetWidth;
}else{
newView = this.previousView(this.domNode);
x = to.x - this.domNode.offsetWidth;
}
}
if(newView){
if(newView.domNode.style.display === "none"){
newView.domNode.style.display = "";
newView.resize();
}
newView._beingFlipped = true;
newView.scrollTo({x:x});
newView._beingFlipped = false;
}
}
this.inherited(arguments);
},
findDisp: function(/*DomNode*/node){
// summary:
// Overrides dojox/mobile/scrollable.findDisp().
// description:
// When this function is called from scrollable.js, there are
// two visible views, one is the current view, the other is the
// next view. This function returns the current view, not the
// next view, which has the mblIn class.
if(!domClass.contains(node, "mblSwapView")){
return this.inherited(arguments);
}
if(!node.parentNode){ return null; }
var nodes = node.parentNode.childNodes;
for(var i = 0; i < nodes.length; i++){
var n = nodes[i];
if(n.nodeType === 1 && domClass.contains(n, "mblSwapView")
&& !domClass.contains(n, "mblIn") && n.style.display !== "none"){
return n;
}
}
return node;
},
slideTo: function(/*Object*/to, /*Number*/duration, /*String*/easing, /*Object?*/fake_pos){
// summary:
// Overrides dojox/mobile/scrollable.slideTo().
if(!this._beingFlipped){
var w = this.domNode.offsetWidth;
var pos = fake_pos || this.getPos();
var newView, newX;
if(pos.x < 0){ // moving to left
newView = this.nextView(this.domNode);
if(pos.x < -w/4){ // slide to next
if(newView){
to.x = -w;
newX = 0;
}
}else{ // go back
if(newView){
newX = w;
}
}
}else{ // moving to right
newView = this.previousView(this.domNode);
if(pos.x > w/4){ // slide to previous
if(newView){
to.x = w;
newX = 0;
}
}else{ // go back
if(newView){
newX = -w;
}
}
}
if(newView){
newView._beingFlipped = true;
newView.slideTo({x:newX}, duration, easing);
newView._beingFlipped = false;
newView.domNode._isShowing = (newView && newX === 0);
}
this.domNode._isShowing = !(newView && newX === 0);
}
this.inherited(arguments);
},
onAnimationEnd: function(/*Event*/e){
// summary:
// Overrides dojox/mobile/View.onAnimationEnd().
if(e && e.target && domClass.contains(e.target, "mblScrollableScrollTo2")){ return; }
this.inherited(arguments);
},
onFlickAnimationEnd: function(/*Event*/e){
if(this._endOfTransitionTimeoutHandle){
this._endOfTransitionTimeoutHandle = this._endOfTransitionTimeoutHandle.remove();
}
// summary:
// Overrides dojox/mobile/scrollable.onFlickAnimationEnd().
if(e && e.target && !domClass.contains(e.target, "mblScrollableScrollTo2")){ return; }
this.inherited(arguments);
if(this.domNode._isShowing){
// Hide all the views other than the currently showing one.
// Otherwise, when the orientation is changed, other views
// may appear unexpectedly.
array.forEach(this.domNode.parentNode.childNodes, function(c){
if(this.isSwapView(c)){
domClass.remove(c, "mblIn");
if(!c._isShowing){
c.style.display = "none";
c.style[css3.name("transform")] = "";
c.style.left = "0px"; // top/left mode needs this
// reset the temporaty padding on the container node
c.style.paddingTop = "";
}
}
}, this);
connect.publish("/dojox/mobile/viewChanged", [this]);
// Reset the temporary padding
this.containerNode.style.paddingTop = "";
}else if(!has("css3-animations")){
this.containerNode.style.left = "0px"; // compat mode needs this
}
this._setSiblingViewsInMotion(false);
},
_setSiblingViewsInMotion: function(/*Boolean*/inMotion){
var inMotionAttributeValue = inMotion ? "true" : false;
var parent = this.domNode.parentNode;
if(parent){
parent.setAttribute("data-dojox-mobile-swapview-inmotion", inMotionAttributeValue);
}
},
_siblingViewsInMotion: function(){
var parent = this.domNode.parentNode;
if(parent){
return parent.getAttribute("data-dojox-mobile-swapview-inmotion") == "true";
}else{
return false;
}
}
});
return has("dojo-bidi") ? declare("dojox.mobile.SwapView", [SwapView, BidiSwapView]) : SwapView;
});
},
'dojox/mobile/PageIndicator':function(){
define([
"dojo/_base/connect",
"dojo/_base/declare",
"dojo/dom",
"dojo/dom-class",
"dojo/dom-construct",
"dijit/registry",
"dijit/_Contained",
"dijit/_WidgetBase",
"dojo/i18n!dojox/mobile/nls/messages"
], function(connect, declare, dom, domClass, domConstruct, registry, Contained, WidgetBase, messages){
// module:
// dojox/mobile/PageIndicator
return declare("dojox.mobile.PageIndicator", [WidgetBase, Contained],{
// summary:
// A current page indicator.
// description:
// PageIndicator displays a series of gray and white dots to
// indicate which page is currently being viewed. It can typically
// be used with dojox/mobile/SwapView. It is also internally used
// in dojox/mobile/Carousel.
// refId: String
// An ID of a DOM node to be searched. Siblings of the reference
// node will be searched for views. If not specified, this.domNode
// will be the reference node.
refId: "",
// baseClass: String
// The name of the CSS class of this widget.
baseClass: "mblPageIndicator",
buildRendering: function(){
this.inherited(arguments);
this.domNode.setAttribute("role", "img");
this._tblNode = domConstruct.create("table", {className:"mblPageIndicatorContainer"}, this.domNode);
this._tblNode.insertRow(-1);
this.connect(this.domNode, "onclick", "_onClick");
this.subscribe("/dojox/mobile/viewChanged", function(view){
this.reset();
});
},
startup: function(){
var _this = this;
_this.defer(function(){ // to wait until views' visibility is determined
_this.reset();
});
},
reset: function(){
// summary:
// Updates the indicator.
var r = this._tblNode.rows[0];
var i, c, a = [], dot, value = 0;
var refNode = (this.refId && dom.byId(this.refId)) || this.domNode;
var children = refNode.parentNode.childNodes;
for(i = 0; i < children.length; i++){
c = children[i];
if(this.isView(c)){
a.push(c);
}
}
if(r.cells.length !== a.length){
domConstruct.empty(r);
for(i = 0; i < a.length; i++){
c = a[i];
dot = domConstruct.create("div", {className:"mblPageIndicatorDot"});
r.insertCell(-1).appendChild(dot);
}
}
if(a.length === 0){ return; }
var currentView = registry.byNode(a[0]).getShowingView();
for(i = 0; i < r.cells.length; i++){
dot = r.cells[i].firstChild;
if(a[i] === currentView.domNode){
value = i + 1;
domClass.add(dot, "mblPageIndicatorDotSelected");
}else{
domClass.remove(dot, "mblPageIndicatorDotSelected");
}
}
if (r.cells.length) {
this.domNode.setAttribute("alt", messages["PageIndicatorLabel"].replace("$0", value).replace("$1", r.cells.length));
} else {
this.domNode.removeAttribute("alt");
}
},
isView: function(node){
// summary:
// Returns true if the given node is a view.
return (node && node.nodeType === 1 && domClass.contains(node, "mblView")); // Boolean
},
_onClick: function(e){
// summary:
// Internal handler for click events.
// tags:
// private
if(this.onClick(e) === false){ return; } // user's click action
if(e.target !== this.domNode){ return; }
if(e.layerX < this._tblNode.offsetLeft){
connect.publish("/dojox/mobile/prevPage", [this]);
}else if(e.layerX > this._tblNode.offsetLeft + this._tblNode.offsetWidth){
connect.publish("/dojox/mobile/nextPage", [this]);
}
},
onClick: function(/*Event*/ /*===== e =====*/){
// summary:
// User-defined function to handle clicks.
// tags:
// callback
}
});
});
},
'dojo/i18n':function(){
define(["./_base/kernel", "require", "./has", "./_base/array", "./_base/config", "./_base/lang", "./_base/xhr", "./json", "module"],
function(dojo, require, has, array, config, lang, xhr, json, module){
// module:
// dojo/i18n
has.add("dojo-preload-i18n-Api",
// if true, define the preload localizations machinery
1
);
1 || has.add("dojo-v1x-i18n-Api",
// if true, define the v1.x i18n functions
1
);
var
thisModule = dojo.i18n =
{
// summary:
// This module implements the dojo/i18n! plugin and the v1.6- i18n API
// description:
// We choose to include our own plugin to leverage functionality already contained in dojo
// and thereby reduce the size of the plugin compared to various loader implementations. Also, this
// allows foreign AMD loaders to be used without their plugins.
},
nlsRe =
// regexp for reconstructing the master bundle name from parts of the regexp match
// nlsRe.exec("foo/bar/baz/nls/en-ca/foo") gives:
// ["foo/bar/baz/nls/en-ca/foo", "foo/bar/baz/nls/", "/", "/", "en-ca", "foo"]
// nlsRe.exec("foo/bar/baz/nls/foo") gives:
// ["foo/bar/baz/nls/foo", "foo/bar/baz/nls/", "/", "/", "foo", ""]
// so, if match[5] is blank, it means this is the top bundle definition.
// courtesy of http://requirejs.org
/(^.*(^|\/)nls)(\/|$)([^\/]*)\/?([^\/]*)/,
getAvailableLocales = function(
root,
locale,
bundlePath,
bundleName
){
// summary:
// return a vector of module ids containing all available locales with respect to the target locale
// For example, assuming:
//
// - the root bundle indicates specific bundles for "fr" and "fr-ca",
// - bundlePath is "myPackage/nls"
// - bundleName is "myBundle"
//
// Then a locale argument of "fr-ca" would return
//
// ["myPackage/nls/myBundle", "myPackage/nls/fr/myBundle", "myPackage/nls/fr-ca/myBundle"]
//
// Notice that bundles are returned least-specific to most-specific, starting with the root.
//
// If root===false indicates we're working with a pre-AMD i18n bundle that doesn't tell about the available locales;
// therefore, assume everything is available and get 404 errors that indicate a particular localization is not available
for(var result = [bundlePath + bundleName], localeParts = locale.split("-"), current = "", i = 0; i/nls/*` and
// therefore never looks like a relative
return /^\./.test(id) ? toAbsMid(id) : id;
},
getLocalesToLoad = function(targetLocale){
var list = config.extraLocale || [];
list = lang.isArray(list) ? list : [list];
list.push(targetLocale);
return list;
},
load = function(id, require, load){
// summary:
// id is in one of the following formats
//
// 1. /nls/
// => load the bundle, localized to config.locale; load all bundles localized to
// config.extraLocale (if any); return the loaded bundle localized to config.locale.
//
// 2. /nls//
// => load then return the bundle localized to
//
// 3. *preload*/nls/*
// => for config.locale and all config.extraLocale, load all bundles found
// in the best-matching bundle rollup. A value of 1 is returned, which
// is meaningless other than to say the plugin is executing the requested
// preloads
//
// In cases 1 and 2, is always normalized to an absolute module id upon entry; see
// normalize. In case 3, it is assumed to be absolute; this is arranged by the builder.
//
// To load a bundle means to insert the bundle into the plugin's cache and publish the bundle
// value to the loader. Given , , and a particular , the cache key
//
// /nls//
//
// will hold the value. Similarly, then plugin will publish this value to the loader by
//
// define("/nls//", );
//
// Given this algorithm, other machinery can provide fast load paths be preplacing
// values in the plugin's cache, which is public. When a load is demanded the
// cache is inspected before starting any loading. Explicitly placing values in the plugin
// cache is an advanced/experimental feature that should not be needed; use at your own risk.
//
// For the normal AMD algorithm, the root bundle is loaded first, which instructs the
// plugin what additional localized bundles are required for a particular locale. These
// additional locales are loaded and a mix of the root and each progressively-specific
// locale is returned. For example:
//
// 1. The client demands "dojo/i18n!some/path/nls/someBundle
//
// 2. The loader demands load(some/path/nls/someBundle)
//
// 3. This plugin require's "some/path/nls/someBundle", which is the root bundle.
//
// 4. Assuming config.locale is "ab-cd-ef" and the root bundle indicates that localizations
// are available for "ab" and "ab-cd-ef" (note the missing "ab-cd", then the plugin
// requires "some/path/nls/ab/someBundle" and "some/path/nls/ab-cd-ef/someBundle"
//
// 5. Upon receiving all required bundles, the plugin constructs the value of the bundle
// ab-cd-ef as...
//
// mixin(mixin(mixin({}, require("some/path/nls/someBundle"),
// require("some/path/nls/ab/someBundle")),
// require("some/path/nls/ab-cd-ef/someBundle"));
//
// This value is inserted into the cache and published to the loader at the
// key/module-id some/path/nls/someBundle/ab-cd-ef.
//
// The special preload signature (case 3) instructs the plugin to stop servicing all normal requests
// (further preload requests will be serviced) until all ongoing preloading has completed.
//
// The preload signature instructs the plugin that a special rollup module is available that contains
// one or more flattened, localized bundles. The JSON array of available locales indicates which locales
// are available. Here is an example:
//
// *preload*some/path/nls/someModule*["root", "ab", "ab-cd-ef"]
//
// This indicates the following rollup modules are available:
//
// some/path/nls/someModule_ROOT
// some/path/nls/someModule_ab
// some/path/nls/someModule_ab-cd-ef
//
// Each of these modules is a normal AMD module that contains one or more flattened bundles in a hash.
// For example, assume someModule contained the bundles some/bundle/path/someBundle and
// some/bundle/path/someOtherBundle, then some/path/nls/someModule_ab would be expressed as follows:
//
// define({
// some/bundle/path/someBundle:,
// some/bundle/path/someOtherBundle:,
// });
//
// E.g., given this design, preloading for locale=="ab" can execute the following algorithm:
//
// require(["some/path/nls/someModule_ab"], function(rollup){
// for(var p in rollup){
// var id = p + "/ab",
// cache[id] = rollup[p];
// define(id, rollup[p]);
// }
// });
//
// Similarly, if "ab-cd" is requested, the algorithm can determine that "ab" is the best available and
// load accordingly.
//
// The builder will write such rollups for every layer if a non-empty localeList profile property is
// provided. Further, the builder will include the following cache entry in the cache associated with
// any layer.
//
// "*now":function(r){r(['dojo/i18n!*preload*/nls/*']);}
//
// The *now special cache module instructs the loader to apply the provided function to context-require
// with respect to the particular layer being defined. This causes the plugin to hold all normal service
// requests until all preloading is complete.
//
// Notice that this algorithm is rarely better than the standard AMD load algorithm. Consider the normal case
// where the target locale has a single segment and a layer depends on a single bundle:
//
// Without Preloads:
//
// 1. Layer loads root bundle.
// 2. bundle is demanded; plugin loads single localized bundle.
//
// With Preloads:
//
// 1. Layer causes preloading of target bundle.
// 2. bundle is demanded; service is delayed until preloading complete; bundle is returned.
//
// In each case a single transaction is required to load the target bundle. In cases where multiple bundles
// are required and/or the locale has multiple segments, preloads still requires a single transaction whereas
// the normal path requires an additional transaction for each additional bundle/locale-segment. However all
// of these additional transactions can be done concurrently. Owing to this analysis, the entire preloading
// algorithm can be discard during a build by setting the has feature dojo-preload-i18n-Api to false.
var match = nlsRe.exec(id),
bundlePath = match[1] + "/",
bundleName = match[5] || match[4],
bundlePathAndName = bundlePath + bundleName,
localeSpecified = (match[5] && match[4]),
targetLocale = localeSpecified || dojo.locale || "",
loadTarget = bundlePathAndName + "/" + targetLocale,
loadList = localeSpecified ? [targetLocale] : getLocalesToLoad(targetLocale),
remaining = loadList.length,
finish = function(){
if(!--remaining){
load(lang.delegate(cache[loadTarget]));
}
},
split = id.split("*"),
preloadDemand = split[1] == "preload";
if(has("dojo-preload-i18n-Api")){
if(preloadDemand){
if(!cache[id]){
// use cache[id] to prevent multiple preloads of the same preload; this shouldn't happen, but
// who knows what over-aggressive human optimizers may attempt
cache[id] = 1;
preloadL10n(split[2], json.parse(split[3]), 1, require);
}
// don't stall the loader!
load(1);
}
if(preloadDemand || (waitForPreloads(id, require, load) && !cache[loadTarget])){
return;
}
}
else if (preloadDemand) {
// If a build is created with nls resources and 'dojo-preload-i18n-Api' has not been set to false,
// the built file will include a preload in the cache (which looks about like so:)
// '*now':function(r){r(['dojo/i18n!*preload*dojo/nls/dojo*["ar","ca","cs","da","de","el","en-gb","en-us","es-es","fi-fi","fr-fr","he-il","hu","it-it","ja-jp","ko-kr","nl-nl","nb","pl","pt-br","pt-pt","ru","sk","sl","sv","th","tr","zh-tw","zh-cn","ROOT"]']);}
// If the consumer of the build sets 'dojo-preload-i18n-Api' to false in the Dojo config, the cached
// preload will not be parsed and will result in an attempt to call 'require' passing it the unparsed
// preload, which is not a valid module id.
// In this case we should skip this request.
load(1);
return;
}
array.forEach(loadList, function(locale){
var target = bundlePathAndName + "/" + locale;
if(has("dojo-preload-i18n-Api")){
checkForLegacyModules(target);
}
if(!cache[target]){
doLoad(require, bundlePathAndName, bundlePath, bundleName, locale, finish);
}else{
finish();
}
});
};
if(has("dojo-preload-i18n-Api") || 1 ){
var normalizeLocale = thisModule.normalizeLocale = function(locale){
var result = locale ? locale.toLowerCase() : dojo.locale;
return result == "root" ? "ROOT" : result;
},
isXd = function(mid, contextRequire){
return ( 1 && 1 ) ?
contextRequire.isXdUrl(require.toUrl(mid + ".js")) :
true;
},
preloading = 0,
preloadWaitQueue = [],
preloadL10n = thisModule._preloadLocalizations = function(/*String*/bundlePrefix, /*Array*/localesGenerated, /*boolean?*/ guaranteedAmdFormat, /*function?*/ contextRequire){
// summary:
// Load available flattened resource bundles associated with a particular module for dojo/locale and all dojo/config.extraLocale (if any)
// description:
// Only called by built layer files. The entire locale hierarchy is loaded. For example,
// if locale=="ab-cd", then ROOT, "ab", and "ab-cd" are loaded. This is different than v1.6-
// in that the v1.6- would only load ab-cd...which was *always* flattened.
//
// If guaranteedAmdFormat is true, then the module can be loaded with require thereby circumventing the detection algorithm
// and the extra possible extra transaction.
// If this function is called from legacy code, then guaranteedAmdFormat and contextRequire will be undefined. Since the function
// needs a require in order to resolve module ids, fall back to the context-require associated with this dojo/i18n module, which
// itself may have been mapped.
contextRequire = contextRequire || require;
function doRequire(mid, callback){
if(isXd(mid, contextRequire) || guaranteedAmdFormat){
contextRequire([mid], callback);
}else{
syncRequire([mid], callback, contextRequire);
}
}
function forEachLocale(locale, func){
// given locale= "ab-cd-ef", calls func on "ab-cd-ef", "ab-cd", "ab", "ROOT"; stops calling the first time func returns truthy
var parts = locale.split("-");
while(parts.length){
if(func(parts.join("-"))){
return;
}
parts.pop();
}
func("ROOT");
}
function preloadingAddLock(){
preloading++;
}
function preloadingRelLock(){
--preloading;
while(!preloading && preloadWaitQueue.length){
load.apply(null, preloadWaitQueue.shift());
}
}
function cacheId(path, name, loc, require){
// path is assumed to have a trailing "/"
return require.toAbsMid(path + name + "/" + loc)
}
function preload(locale){
locale = normalizeLocale(locale);
forEachLocale(locale, function(loc){
if(array.indexOf(localesGenerated, loc) >= 0){
var mid = bundlePrefix.replace(/\./g, "/") + "_" + loc;
preloadingAddLock();
doRequire(mid, function(rollup){
for(var p in rollup){
var bundle = rollup[p],
match = p.match(/(.+)\/([^\/]+)$/),
bundleName, bundlePath;
// If there is no match, the bundle is not a regular bundle from an AMD layer.
if (!match){continue;}
bundleName = match[2];
bundlePath = match[1] + "/";
// backcompat
if(!bundle._localized){continue;}
var localized;
if(loc === "ROOT"){
var root = localized = bundle._localized;
delete bundle._localized;
root.root = bundle;
cache[require.toAbsMid(p)] = root;
}else{
localized = bundle._localized;
cache[cacheId(bundlePath, bundleName, loc, require)] = bundle;
}
if(loc !== locale){
// capture some locale variables
var improveBundle = function improveBundle(bundlePath, bundleName, bundle, localized){
// locale was not flattened and we've fallen back to a less-specific locale that was flattened
// for example, we had a flattened 'fr', a 'fr-ca' is available for at least this bundle, and
// locale==='fr-ca'; therefore, we must improve the bundle as retrieved from the rollup by
// manually loading the fr-ca version of the bundle and mixing this into the already-retrieved 'fr'
// version of the bundle.
//
// Remember, different bundles may have different sets of locales available.
//
// we are really falling back on the regular algorithm here, but--hopefully--starting with most
// of the required bundles already on board as given by the rollup and we need to "manually" load
// only one locale from a few bundles...or even better...we won't find anything better to load.
// This algorithm ensures there is nothing better to load even when we can only load a less-specific rollup.
//
// note: this feature is only available in async mode
// inspect the loaded bundle that came from the rollup to see if something better is available
// for any bundle in a rollup, more-specific available locales are given at localized.
var requiredBundles = [],
cacheIds = [];
forEachLocale(locale, function(loc){
if(localized[loc]){
requiredBundles.push(require.toAbsMid(bundlePath + loc + "/" + bundleName));
cacheIds.push(cacheId(bundlePath, bundleName, loc, require));
}
});
if(requiredBundles.length){
preloadingAddLock();
contextRequire(requiredBundles, function(){
// requiredBundles was constructed by forEachLocale so it contains locales from
// less specific to most specific.
// the loop starts with the most specific locale, the last one.
for(var i = requiredBundles.length - 1; i >= 0 ; i--){
bundle = lang.mixin(lang.clone(bundle), arguments[i]);
cache[cacheIds[i]] = bundle;
}
// this is the best possible (maybe a perfect match, maybe not), accept it
cache[cacheId(bundlePath, bundleName, locale, require)] = lang.clone(bundle);
preloadingRelLock();
});
}else{
// this is the best possible (definitely not a perfect match), accept it
cache[cacheId(bundlePath, bundleName, locale, require)] = bundle;
}
};
improveBundle(bundlePath, bundleName, bundle, localized);
}
}
preloadingRelLock();
});
return true;
}
return false;
});
}
preload();
array.forEach(dojo.config.extraLocale, preload);
},
waitForPreloads = function(id, require, load){
if(preloading){
preloadWaitQueue.push([id, require, load]);
}
return preloading;
},
checkForLegacyModules = function()
{};
}
if( 1 ){
// this code path assumes the dojo loader and won't work with a standard AMD loader
var amdValue = {},
l10nCache = {},
evalBundle,
syncRequire = function(deps, callback, require){
var results = [];
array.forEach(deps, function(mid){
var url = require.toUrl(mid + ".js");
function load(text){
if (!evalBundle) {
// use the function ctor to keep the minifiers away (also come close to global scope, but this is secondary)
evalBundle = new Function(
"__bundle", // the bundle to evalutate
"__checkForLegacyModules", // a function that checks if __bundle defined __mid in the global space
"__mid", // the mid that __bundle is intended to define
"__amdValue",
// returns one of:
// 1 => the bundle was an AMD bundle
// a legacy bundle object that is the value of __mid
// instance of Error => could not figure out how to evaluate bundle
// used to detect when __bundle calls define
"var define = function(mid, factory){define.called = 1; __amdValue.result = factory || mid;},"
+ " require = function(){define.called = 1;};"
+ "try{"
+ "define.called = 0;"
+ "eval(__bundle);"
+ "if(define.called==1)"
// bundle called define; therefore signal it's an AMD bundle
+ "return __amdValue;"
+ "if((__checkForLegacyModules = __checkForLegacyModules(__mid)))"
// bundle was probably a v1.6- built NLS flattened NLS bundle that defined __mid in the global space
+ "return __checkForLegacyModules;"
+ "}catch(e){}"
// evaulating the bundle was *neither* an AMD *nor* a legacy flattened bundle
// either way, re-eval *after* surrounding with parentheses
+ "try{"
+ "return eval('('+__bundle+')');"
+ "}catch(e){"
+ "return e;"
+ "}"
);
}
var result = evalBundle(text, checkForLegacyModules, mid, amdValue);
if(result===amdValue){
// the bundle was an AMD module; re-inject it through the normal AMD path
// we gotta do this since it could be an anonymous module and simply evaluating
// the text here won't provide the loader with the context to know what
// module is being defined()'d. With browser caching, this should be free; further
// this entire code path can be circumvented by using the AMD format to begin with
results.push(cache[url] = amdValue.result);
}else{
if(result instanceof Error){
console.error("failed to evaluate i18n bundle; url=" + url, result);
result = {};
}
// nls// indicates not the root.
results.push(cache[url] = (/nls\/[^\/]+\/[^\/]+$/.test(url) ? result : {root:result, _v1x:1}));
}
}
if(cache[url]){
results.push(cache[url]);
}else{
var bundle = require.syncLoadNls(mid);
// need to check for legacy module here because there might be a legacy module for a
// less specific locale (which was not looked up during the first checkForLegacyModules
// call in load()).
// Also need to reverse the locale and the module name in the mid because syncRequire
// deps parameters uses the AMD style package/nls/locale/module while legacy code uses
// package/nls/module/locale.
if(!bundle){
bundle = checkForLegacyModules(mid.replace(/nls\/([^\/]*)\/([^\/]*)$/, "nls/$2/$1"));
}
if(bundle){
results.push(bundle);
}else{
if(!xhr){
try{
require.getText(url, true, load);
}catch(e){
results.push(cache[url] = {});
}
}else{
xhr.get({
url:url,
sync:true,
load:load,
error:function(){
results.push(cache[url] = {});
}
});
}
}
}
});
callback && callback.apply(null, results);
};
checkForLegacyModules = function(target){
// legacy code may have already loaded [e.g] the raw bundle x/y/z at x.y.z; when true, push into the cache
for(var result, names = target.split("/"), object = dojo.global[names[0]], i = 1; object && i .axis", n).map(collectAxisParams).filter(notNull),
plots = query("> .plot", n).map(collectPlotParams).filter(notNull),
actions = query("> .action", n).map(collectActionParams).filter(notNull),
series = query("> .series", n).map(collectDataParams).filter(notNull);
// build the chart
n.innerHTML = "";
var c = this.chart = new ChartBase(n, {
margins: this.margins,
stroke: this.stroke,
fill: this.fill,
textDir: this.textDir
});
// add collected parameters
if(this.theme){
c.setTheme(this.theme);
}
axes.forEach(function(axis){
c.addAxis(axis.name, axis.kwArgs);
});
plots.forEach(function(plot){
c.addPlot(plot.name, plot.kwArgs);
});
this.actions = actions.map(function(action){
return new action.action(c, action.plot, action.kwArgs);
});
var render = df.foldl(series, function(render, series){
if(series.type == "data"){
c.addSeries(series.name, series.data, series.kwArgs);
render = true;
}else{
c.addSeries(series.name, [0], series.kwArgs);
var kw = {};
du.updateWithPattern(
kw,
series.kwArgs,
{
"query": "",
"queryOptions": null,
"start": 0,
"count": 1 //,
// "sort": []
},
true
);
if(series.kwArgs.sort){
// sort is a complex object type and doesn't survive coercian
kw.sort = lang.clone(series.kwArgs.sort);
}
lang.mixin(kw, {
onComplete: function(data){
var values;
if("valueFn" in series.kwArgs){
var fn = series.kwArgs.valueFn;
values = arr.map(data, function(x){
return fn(series.data.getValue(x, series.field, 0));
});
}else{
values = arr.map(data, function(x){
return series.data.getValue(x, series.field, 0);
});
}
c.addSeries(series.name, values, series.kwArgs).render();
}
});
series.data.fetch(kw);
}
return render;
}, false);
if(render){ c.render(); }
},
destroy: function(){
// summary:
// properly destroy the widget
this.chart.destroy();
this.inherited(arguments);
},
resize: function(box){
// summary:
// Resize the widget.
// description:
// Resize the domNode and the widget surface to the dimensions of a box of the following form:
// `{ l: 50, t: 200, w: 300: h: 150 }`
// If no box is provided, resize the surface to the marginBox of the domNode.
// box:
// If passed, denotes the new size of the widget.
this.chart.resize.apply(this.chart, arguments);
}
});
return has("dojo-bidi")? declare("dojox.charting.widget.Chart", [Chart, BidiChart]) : Chart;
});
},
'dojox/charting/Chart':function(){
define(["../main", "dojo/_base/lang", "dojo/_base/array","dojo/_base/declare", "dojo/dom-style",
"dojo/dom", "dojo/dom-geometry", "dojo/dom-construct","dojo/_base/Color", "dojo/sniff",
"./Element", "./SimpleTheme", "./Series", "./axis2d/common", "./plot2d/common", "dojox/gfx/shape",
"dojox/gfx", "dojo/has!dojo-bidi?./bidi/Chart", "dojox/lang/functional", "dojox/lang/functional/fold", "dojox/lang/functional/reversed"],
function(dojox, lang, arr, declare, domStyle,
dom, domGeom, domConstruct, Color, has,
Element, SimpleTheme, Series, common, plot2dCommon, shape,
g, BidiChart, func){
/*=====
var __ChartCtorArgs = {
// summary:
// The keyword arguments that can be passed in a Chart constructor.
// margins: Object?
// Optional margins for the chart, in the form of { l, t, r, b}.
// stroke: dojox.gfx.Stroke?
// An optional outline/stroke for the chart.
// fill: dojox.gfx.Fill?
// An optional fill for the chart.
// delayInMs: Number
// Delay in ms for delayedRender(). Default: 200.
};
=====*/
/*=====
var __SeriesCtorArgs = {
// summary:
// An optional arguments object that can be used in the Series constructor.
// plot: String?
// The plot (by name) that this series belongs to.
};
=====*/
/*=====
var __BaseAxisCtorArgs = {
// summary:
// Optional arguments used in the definition of an invisible axis.
// vertical: Boolean?
// A flag that says whether an axis is vertical (i.e. y axis) or horizontal. Default is false (horizontal).
// min: Number?
// The smallest value on an axis. Default is 0.
// max: Number?
// The largest value on an axis. Default is 1.
};
=====*/
var dc = lang.getObject("charting", true, dojox),
defaultMargins = {l: 10, t: 10, r: 10, b: 10};
function clear (item) {
return item.clear();
}
function destroy (item) {
return item.destroy();
}
function makeClean (item) {
item.dirty = false;
return false;
}
function makeDirty (item) {
item.dirty = true;
return true;
}
function getName (item) {
return item.name;
}
var Chart = declare(has("dojo-bidi")? "dojox.charting.NonBidiChart" : "dojox.charting.Chart", null, {
// summary:
// The main chart object in dojox.charting. This will create a two dimensional
// chart based on dojox.gfx.
//
// description:
// dojox.charting.Chart is the primary object used for any kind of charts. It
// is simple to create--just pass it a node reference, which is used as the
// container for the chart--and a set of optional keyword arguments and go.
//
// Note that like most of dojox.gfx, most of dojox.charting.Chart's methods are
// designed to return a reference to the chart itself, to allow for functional
// chaining. This makes defining everything on a Chart very easy to do.
//
// example:
// Create an area chart, with smoothing.
// | require(["dojox/charting/Chart", "dojox/charting/themes/Shrooms", "dojox/charting/plot2d/Areas", ...],
// | function(Chart, Shrooms, Areas, ...){
// | new Chart(node)
// | .addPlot("default", { type: Areas, tension: "X" })
// | .setTheme(Shrooms)
// | .addSeries("Series A", [1, 2, 0.5, 1.5, 1, 2.8, 0.4])
// | .addSeries("Series B", [2.6, 1.8, 2, 1, 1.4, 0.7, 2])
// | .addSeries("Series C", [6.3, 1.8, 3, 0.5, 4.4, 2.7, 2])
// | .render();
// | });
//
// example:
// The form of data in a data series can take a number of forms: a simple array,
// an array of objects {x,y}, or something custom (as determined by the plot).
// Here's an example of a Candlestick chart, which expects an object of
// { open, high, low, close }.
// | require(["dojox/charting/Chart", "dojox/charting/plot2d/Candlesticks", ...],
// | function(Chart, Candlesticks, ...){
// | new Chart(node)
// | .addPlot("default", {type: Candlesticks, gap: 1})
// | .addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true})
// | .addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true})
// | .addSeries("Series A", [
// | { open: 20, close: 16, high: 22, low: 8 },
// | { open: 16, close: 22, high: 26, low: 6, mid: 18 },
// | { open: 22, close: 18, high: 22, low: 11, mid: 21 },
// | { open: 18, close: 29, high: 32, low: 14, mid: 27 },
// | { open: 29, close: 24, high: 29, low: 13, mid: 27 },
// | { open: 24, close: 8, high: 24, low: 5 },
// | { open: 8, close: 16, high: 22, low: 2 },
// | { open: 16, close: 12, high: 19, low: 7 },
// | { open: 12, close: 20, high: 22, low: 8 },
// | { open: 20, close: 16, high: 22, low: 8 },
// | { open: 16, close: 22, high: 26, low: 6, mid: 18 },
// | { open: 22, close: 18, high: 22, low: 11, mid: 21 },
// | { open: 18, close: 29, high: 32, low: 14, mid: 27 },
// | { open: 29, close: 24, high: 29, low: 13, mid: 27 },
// | { open: 24, close: 8, high: 24, low: 5 },
// | { open: 8, close: 16, high: 22, low: 2 },
// | { open: 16, close: 12, high: 19, low: 7 },
// | { open: 12, close: 20, high: 22, low: 8 },
// | { open: 20, close: 16, high: 22, low: 8 },
// | { open: 16, close: 22, high: 26, low: 6 },
// | { open: 22, close: 18, high: 22, low: 11 },
// | { open: 18, close: 29, high: 32, low: 14 },
// | { open: 29, close: 24, high: 29, low: 13 },
// | { open: 24, close: 8, high: 24, low: 5 },
// | { open: 8, close: 16, high: 22, low: 2 },
// | { open: 16, close: 12, high: 19, low: 7 },
// | { open: 12, close: 20, high: 22, low: 8 },
// | { open: 20, close: 16, high: 22, low: 8 }
// | ],
// | { stroke: { color: "green" }, fill: "lightgreen" }
// | )
// | .render();
// | });
// theme: dojox/charting/SimpleTheme?
// An optional theme to use for styling the chart.
// axes: dojox/charting/axis2d/Base{}?
// A map of axes for use in plotting a chart.
// stack: dojox/charting/plot2d/Base[]
// A stack of plotters.
// plots: dojox/charting/plot2d/Base{}
// A map of plotter indices
// series: dojox/charting/Series[]
// The stack of data runs used to create plots.
// runs: dojox/charting/Series{}
// A map of series indices
// margins: Object?
// The margins around the chart. Default is { l:10, t:10, r:10, b:10 }.
// stroke: dojox.gfx.Stroke?
// The outline of the chart (stroke in vector graphics terms).
// fill: dojox.gfx.Fill?
// The color for the chart.
// node: DOMNode
// The container node passed to the constructor.
// surface: dojox/gfx/shape.Surface
// The main graphics surface upon which a chart is drawn.
// dirty: Boolean
// A boolean flag indicating whether or not the chart needs to be updated/re-rendered.
// htmlLabels: Boolean
// A boolean flag indicating whether or not it should try to use HTML-based labels for the title or not.
// The default is true. The only caveat is IE and Opera browsers will always use GFX-based labels.
constructor: function(/* DOMNode */node, /* __ChartCtorArgs? */kwArgs){
// summary:
// The constructor for a new Chart. Initializes all parameters used for a chart.
// returns: dojox/charting/Chart
// The newly created chart.
// initialize parameters
if(!kwArgs){ kwArgs = {}; }
this.margins = kwArgs.margins || defaultMargins;
this._customMargins = !!kwArgs.margins;
this.stroke = kwArgs.stroke;
this.fill = kwArgs.fill;
this.delayInMs = kwArgs.delayInMs || 200;
this.title = kwArgs.title;
this.titleGap = kwArgs.titleGap;
this.titlePos = kwArgs.titlePos;
this.titleFont = kwArgs.titleFont;
this.titleFontColor = kwArgs.titleFontColor;
this.titleAlign = kwArgs.titleAlign; // This can be middle, left, right, or edge
// edge is left or right aligned with chart plot edge depending on bidi.
this.chartTitle = null;
this.htmlLabels = true;
if("htmlLabels" in kwArgs){
this.htmlLabels = kwArgs.htmlLabels;
}
// default initialization
this.theme = null;
this.axes = {}; // map of axes
this.stack = []; // stack of plotters
this.plots = {}; // map of plotter indices
this.series = []; // stack of data runs
this.runs = {}; // map of data run indices
this.dirty = true;
// create a surface
this.node = dom.byId(node);
var box = domGeom.getMarginBox(node);
this.surface = g.createSurface(this.node, box.w || 400, box.h || 300);
if(this.surface.declaredClass.indexOf("vml") == -1){
// except if vml use native clipping
this._nativeClip = true;
}
},
destroy: function(){
// summary:
// Cleanup when a chart is to be destroyed.
// returns: void
arr.forEach(this.series, destroy);
arr.forEach(this.stack, destroy);
func.forIn(this.axes, destroy);
this.surface.destroy();
if(this.chartTitle && this.chartTitle.tagName){
// destroy title if it is a DOM node
domConstruct.destroy(this.chartTitle);
}
},
getCoords: function(){
// summary:
// Get the coordinates and dimensions of the containing DOMNode, as
// returned by dojo.coords.
// returns: Object
// The resulting coordinates of the chart. See dojo.coords for details.
var node = this.node;
var s = domStyle.getComputedStyle(node), coords = domGeom.getMarginBox(node, s);
var abs = domGeom.position(node, true);
coords.x = abs.x;
coords.y = abs.y;
return coords; // Object
},
setTheme: function(theme){
// summary:
// Set a theme of the chart.
// theme: dojox/charting/SimpleTheme
// The theme to be used for visual rendering.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
this.theme = theme.clone();
if(!this._customMargins){
this.margins = this.theme.chart.margins || defaultMargins;
}
this.dirty = true;
return this; // dojox/charting/Chart
},
addAxis: function(name, kwArgs){
// summary:
// Add an axis to the chart, for rendering.
// name: String
// The name of the axis.
// kwArgs: __BaseAxisCtorArgs?
// An optional keyword arguments object for use in defining details of an axis.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
var axis, axisType = kwArgs && kwArgs.type || "Default";
if(typeof axisType == "string"){
if(!dc.axis2d || !dc.axis2d[axisType]){
throw Error("Can't find axis: " + axisType + " - Check " + "require() dependencies.");
}
axis = new dc.axis2d[axisType](this, kwArgs);
}else{
axis = new axisType(this, kwArgs);
}
axis.name = name;
axis.dirty = true;
if(name in this.axes){
this.axes[name].destroy();
}
this.axes[name] = axis;
this.dirty = true;
return this; // dojox/charting/Chart
},
getAxis: function(name){
// summary:
// Get the given axis, by name.
// name: String
// The name the axis was defined by.
// returns: dojox/charting/axis2d/Default
// The axis as stored in the chart's axis map.
return this.axes[name]; // dojox/charting/axis2d/Default
},
removeAxis: function(name){
// summary:
// Remove the axis that was defined using name.
// name: String
// The axis name, as defined in addAxis.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
if(name in this.axes){
// destroy the axis
this.axes[name].destroy();
delete this.axes[name];
// mark the chart as dirty
this.dirty = true;
}
return this; // dojox/charting/Chart
},
addPlot: function(name, kwArgs){
// summary:
// Add a new plot to the chart, defined by name and using the optional keyword arguments object.
// Note that dojox.charting assumes the main plot to be called "default"; if you do not have
// a plot called "default" and attempt to add data series to the chart without specifying the
// plot to be rendered on, you WILL get errors.
// name: String
// The name of the plot to be added to the chart. If you only plan on using one plot, call it "default".
// kwArgs: dojox.charting.plot2d.__PlotCtorArgs
// An object with optional parameters for the plot in question.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
var plot, plotType = kwArgs && kwArgs.type || "Default";
if(typeof plotType == "string"){
if(!dc.plot2d || !dc.plot2d[plotType]){
throw Error("Can't find plot: " + plotType + " - didn't you forget to dojo" + ".require() it?");
}
plot = new dc.plot2d[plotType](this, kwArgs);
}else{
plot = new plotType(this, kwArgs);
}
plot.name = name;
plot.dirty = true;
if(name in this.plots){
this.stack[this.plots[name]].destroy();
this.stack[this.plots[name]] = plot;
}else{
this.plots[name] = this.stack.length;
this.stack.push(plot);
}
this.dirty = true;
return this; // dojox/charting/Chart
},
getPlot: function(name){
// summary:
// Get the given plot, by name.
// name: String
// The name the plot was defined by.
// returns: dojox/charting/plot2d/Base
// The plot.
return this.stack[this.plots[name]];
},
removePlot: function(name){
// summary:
// Remove the plot defined using name from the chart's plot stack.
// name: String
// The name of the plot as defined using addPlot.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
if(name in this.plots){
// get the index and remove the name
var index = this.plots[name];
delete this.plots[name];
// destroy the plot
this.stack[index].destroy();
// remove the plot from the stack
this.stack.splice(index, 1);
// update indices to reflect the shift
func.forIn(this.plots, function(idx, name, plots){
if(idx > index){
plots[name] = idx - 1;
}
});
// remove all related series
var ns = arr.filter(this.series, function(run){ return run.plot != name; });
if(ns.length < this.series.length){
// kill all removed series
arr.forEach(this.series, function(run){
if(run.plot == name){
run.destroy();
}
});
// rebuild all necessary data structures
this.runs = {};
arr.forEach(ns, function(run, index){
this.runs[run.plot] = index;
}, this);
this.series = ns;
}
// mark the chart as dirty
this.dirty = true;
}
return this; // dojox/charting/Chart
},
getPlotOrder: function(){
// summary:
// Returns an array of plot names in the current order
// (the top-most plot is the first).
// returns: Array
return func.map(this.stack, getName); // Array
},
setPlotOrder: function(newOrder){
// summary:
// Sets new order of plots. newOrder cannot add or remove
// plots. Wrong names, or dups are ignored.
// newOrder: Array
// Array of plot names compatible with getPlotOrder().
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
var names = {},
order = func.filter(newOrder, function(name){
if(!(name in this.plots) || (name in names)){
return false;
}
names[name] = 1;
return true;
}, this);
if(order.length < this.stack.length){
func.forEach(this.stack, function(plot){
var name = plot.name;
if(!(name in names)){
order.push(name);
}
});
}
var newStack = func.map(order, function(name){
return this.stack[this.plots[name]];
}, this);
func.forEach(newStack, function(plot, i){
this.plots[plot.name] = i;
}, this);
this.stack = newStack;
this.dirty = true;
return this; // dojox/charting/Chart
},
movePlotToFront: function(name){
// summary:
// Moves a given plot to front.
// name: String
// Plot's name to move.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
if(name in this.plots){
var index = this.plots[name];
if(index){
var newOrder = this.getPlotOrder();
newOrder.splice(index, 1);
newOrder.unshift(name);
return this.setPlotOrder(newOrder); // dojox/charting/Chart
}
}
return this; // dojox/charting/Chart
},
movePlotToBack: function(name){
// summary:
// Moves a given plot to back.
// name: String
// Plot's name to move.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
if(name in this.plots){
var index = this.plots[name];
if(index < this.stack.length - 1){
var newOrder = this.getPlotOrder();
newOrder.splice(index, 1);
newOrder.push(name);
return this.setPlotOrder(newOrder); // dojox/charting/Chart
}
}
return this; // dojox/charting/Chart
},
addSeries: function(name, data, kwArgs){
// summary:
// Add a data series to the chart for rendering.
// name: String
// The name of the data series to be plotted.
// data: Array|Object
// The array of data points (either numbers or objects) that
// represents the data to be drawn. Or it can be an object. In
// the latter case, it should have a property "data" (an array),
// destroy(), and setSeriesObject().
// kwArgs: __SeriesCtorArgs?
// An optional keyword arguments object that will be mixed into
// the resultant series object.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
var run = new Series(this, data, kwArgs);
run.name = name;
if(name in this.runs){
this.series[this.runs[name]].destroy();
this.series[this.runs[name]] = run;
}else{
this.runs[name] = this.series.length;
this.series.push(run);
}
this.dirty = true;
// fix min/max
if(!("ymin" in run) && "min" in run){ run.ymin = run.min; }
if(!("ymax" in run) && "max" in run){ run.ymax = run.max; }
return this; // dojox/charting/Chart
},
getSeries: function(name){
// summary:
// Get the given series, by name.
// name: String
// The name the series was defined by.
// returns: dojox/charting/Series
// The series.
return this.series[this.runs[name]];
},
removeSeries: function(name){
// summary:
// Remove the series defined by name from the chart.
// name: String
// The name of the series as defined by addSeries.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
if(name in this.runs){
// get the index and remove the name
var index = this.runs[name];
delete this.runs[name];
// destroy the run
this.series[index].destroy();
// remove the run from the stack of series
this.series.splice(index, 1);
// update indices to reflect the shift
func.forIn(this.runs, function(idx, name, runs){
if(idx > index){
runs[name] = idx - 1;
}
});
this.dirty = true;
}
return this; // dojox/charting/Chart
},
updateSeries: function(name, data, offsets){
// summary:
// Update the given series with a new set of data points.
// name: String
// The name of the series as defined in addSeries.
// data: Array|Object
// The array of data points (either numbers or objects) that
// represents the data to be drawn. Or it can be an object. In
// the latter case, it should have a property "data" (an array),
// destroy(), and setSeriesObject().
// offsets: Boolean?
// If true recomputes the offsets of the chart based on the new
// data. This is useful if the range of data is drastically changing
// and offsets need to be recomputed.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
if(name in this.runs){
var run = this.series[this.runs[name]];
run.update(data);
if(offsets){
this.dirty = true;
}else{
this._invalidateDependentPlots(run.plot, false);
this._invalidateDependentPlots(run.plot, true);
}
}
return this; // dojox/charting/Chart
},
getSeriesOrder: function(plotName){
// summary:
// Returns an array of series names in the current order
// (the top-most series is the first) within a plot.
// plotName: String
// Plot's name.
// returns: Array
return func.map(func.filter(this.series, function(run){
return run.plot == plotName;
}), getName);
},
setSeriesOrder: function(newOrder){
// summary:
// Sets new order of series within a plot. newOrder cannot add
// or remove series. Wrong names, or dups are ignored.
// newOrder: Array
// Array of series names compatible with getPlotOrder(). All
// series should belong to the same plot.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
var plotName, names = {},
order = func.filter(newOrder, function(name){
if(!(name in this.runs) || (name in names)){
return false;
}
var run = this.series[this.runs[name]];
if(plotName){
if(run.plot != plotName){
return false;
}
}else{
plotName = run.plot;
}
names[name] = 1;
return true;
}, this);
func.forEach(this.series, function(run){
var name = run.name;
if(!(name in names) && run.plot == plotName){
order.push(name);
}
});
var newSeries = func.map(order, function(name){
return this.series[this.runs[name]];
}, this);
this.series = newSeries.concat(func.filter(this.series, function(run){
return run.plot != plotName;
}));
func.forEach(this.series, function(run, i){
this.runs[run.name] = i;
}, this);
this.dirty = true;
return this; // dojox/charting/Chart
},
moveSeriesToFront: function(name){
// summary:
// Moves a given series to front of a plot.
// name: String
// Series' name to move.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
if(name in this.runs){
var index = this.runs[name],
newOrder = this.getSeriesOrder(this.series[index].plot);
if(name != newOrder[0]){
newOrder.splice(index, 1);
newOrder.unshift(name);
return this.setSeriesOrder(newOrder); // dojox/charting/Chart
}
}
return this; // dojox/charting/Chart
},
moveSeriesToBack: function(name){
// summary:
// Moves a given series to back of a plot.
// name: String
// Series' name to move.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
if(name in this.runs){
var index = this.runs[name],
newOrder = this.getSeriesOrder(this.series[index].plot);
if(name != newOrder[newOrder.length - 1]){
newOrder.splice(index, 1);
newOrder.push(name);
return this.setSeriesOrder(newOrder); // dojox/charting/Chart
}
}
return this; // dojox/charting/Chart
},
resize: function(width, height){
// summary:
// Resize the chart to the dimensions of width and height.
// description:
// Resize the chart and its surface to the width and height dimensions.
// If a single argument of the form {w: value1, h: value2} is provided take that argument as the dimensions to use.
// Finally if no argument is provided, resize the surface to the marginBox of the chart.
// width: Number|Object?
// The new width of the chart or the box definition.
// height: Number?
// The new height of the chart.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
switch(arguments.length){
// case 0, do not resize the div, just the surface
case 1:
// argument, override node box
domGeom.setMarginBox(this.node, width);
break;
case 2:
// argument, override node box
domGeom.setMarginBox(this.node, {w: width, h: height});
break;
}
// in all cases take back the computed box
var box = domGeom.getMarginBox(this.node);
var d = this.surface.getDimensions();
if(d.width != box.w || d.height != box.h){
// and set it on the surface
this.surface.setDimensions(box.w, box.h);
this.dirty = true;
return this.render(); // dojox/charting/Chart
}else{
return this;
}
},
getGeometry: function(){
// summary:
// Returns a map of information about all axes in a chart and what they represent
// in terms of scaling (see dojox.charting.axis2d.Default.getScaler).
// returns: Object
// An map of geometry objects, a one-to-one mapping of axes.
var ret = {};
func.forIn(this.axes, function(axis){
if(axis.initialized()){
ret[axis.name] = {
name: axis.name,
vertical: axis.vertical,
scaler: axis.scaler,
ticks: axis.ticks
};
}
});
return ret; // Object
},
setAxisWindow: function(name, scale, offset, zoom){
// summary:
// Zooms an axis and all dependent plots. Can be used to zoom in 1D.
// name: String
// The name of the axis as defined by addAxis.
// scale: Number
// The scale on the target axis.
// offset: Number
// Any offest, as measured by axis tick
// zoom: Boolean|Object?
// The chart zooming animation trigger. This is null by default,
// e.g. {duration: 1200}, or just set true.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
var axis = this.axes[name];
if(axis){
axis.setWindow(scale, offset);
arr.forEach(this.stack,function(plot){
if(plot.hAxis == name || plot.vAxis == name){
plot.zoom = zoom;
}
});
}
return this; // dojox/charting/Chart
},
setWindow: function(sx, sy, dx, dy, zoom){
// summary:
// Zooms in or out any plots in two dimensions.
// sx: Number
// The scale for the x axis.
// sy: Number
// The scale for the y axis.
// dx: Number
// The pixel offset on the x axis.
// dy: Number
// The pixel offset on the y axis.
// zoom: Boolean|Object?
// The chart zooming animation trigger. This is null by default,
// e.g. {duration: 1200}, or just set true.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
if(!("plotArea" in this)){
this.calculateGeometry();
}
func.forIn(this.axes, function(axis){
var scale, offset, bounds = axis.getScaler().bounds,
s = bounds.span / (bounds.upper - bounds.lower);
if(axis.vertical){
scale = sy;
offset = dy / s / scale;
}else{
scale = sx;
offset = dx / s / scale;
}
axis.setWindow(scale, offset);
});
arr.forEach(this.stack, function(plot){ plot.zoom = zoom; });
return this; // dojox/charting/Chart
},
zoomIn: function(name, range, delayed){
// summary:
// Zoom the chart to a specific range on one axis. This calls render()
// directly as a convenience method.
// name: String
// The name of the axis as defined by addAxis.
// range: Array
// The end points of the zoom range, measured in axis ticks.
var axis = this.axes[name];
if(axis){
var scale, offset, bounds = axis.getScaler().bounds;
var lower = Math.min(range[0],range[1]);
var upper = Math.max(range[0],range[1]);
lower = range[0] < bounds.lower ? bounds.lower : lower;
upper = range[1] > bounds.upper ? bounds.upper : upper;
scale = (bounds.upper - bounds.lower) / (upper - lower);
offset = lower - bounds.lower;
this.setAxisWindow(name, scale, offset);
if(delayed){
this.delayedRender();
}else{
this.render();
}
}
},
calculateGeometry: function(){
// summary:
// Calculate the geometry of the chart based on the defined axes of
// a chart.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
if(this.dirty){
return this.fullGeometry();
}
// calculate geometry
var dirty = arr.filter(this.stack, function(plot){
return plot.dirty ||
(plot.hAxis && this.axes[plot.hAxis].dirty) ||
(plot.vAxis && this.axes[plot.vAxis].dirty);
}, this);
calculateAxes(dirty, this.plotArea);
return this; // dojox/charting/Chart
},
fullGeometry: function(){
// summary:
// Calculate the full geometry of the chart. This includes passing
// over all major elements of a chart (plots, axes, series, container)
// in order to ensure proper rendering.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
this._makeDirty();
// clear old values
arr.forEach(this.stack, clear);
// rebuild new connections, and add defaults
// set up a theme
if(!this.theme){
this.setTheme(new SimpleTheme());
}
// assign series
arr.forEach(this.series, function(run){
if(!(run.plot in this.plots)){
// TODO remove auto-assignment
if(!dc.plot2d || !dc.plot2d.Default){
throw Error("Can't find plot: Default - didn't you forget to dojo" + ".require() it?");
}
var plot = new dc.plot2d.Default(this, {});
plot.name = run.plot;
this.plots[run.plot] = this.stack.length;
this.stack.push(plot);
}
this.stack[this.plots[run.plot]].addSeries(run);
}, this);
// assign axes
arr.forEach(this.stack, function(plot){
if(plot.assignAxes){
plot.assignAxes(this.axes);
}
}, this);
// calculate geometry
// 1st pass
var dim = this.dim = this.surface.getDimensions();
dim.width = g.normalizedLength(dim.width);
dim.height = g.normalizedLength(dim.height);
func.forIn(this.axes, clear);
calculateAxes(this.stack, dim);
// assumption: we don't have stacked axes yet
var offsets = this.offsets = {l: 0, r: 0, t: 0, b: 0};
// chart mirroring starts
var self = this;
func.forIn(this.axes, function(axis){
if(has("dojo-bidi")){
self._resetLeftBottom(axis);
}
func.forIn(axis.getOffsets(), function(o, i){ offsets[i] = Math.max(o, offsets[i]); });
});
// chart mirroring ends
// add title area
if(this.title){
this.titleGap = (this.titleGap==0) ? 0 : this.titleGap || this.theme.chart.titleGap || 20;
this.titlePos = this.titlePos || this.theme.chart.titlePos || "top";
this.titleFont = this.titleFont || this.theme.chart.titleFont;
this.titleFontColor = this.titleFontColor || this.theme.chart.titleFontColor || "black";
this.titleAlign = this.titleAlign || this.theme && this.theme.chart && this.theme.chart.titleAlign || "middle";
var tsize = g.normalizedLength(g.splitFontString(this.titleFont).size);
offsets[this.titlePos == "top" ? "t" : "b"] += (tsize + this.titleGap);
}
// add margins
func.forIn(this.margins, function(o, i){ offsets[i] += o; });
// 2nd pass with realistic dimensions
this.plotArea = {
width: dim.width - offsets.l - offsets.r,
height: dim.height - offsets.t - offsets.b
};
func.forIn(this.axes, clear);
calculateAxes(this.stack, this.plotArea);
return this; // dojox/charting/Chart
},
render: function(){
// summary:
// Render the chart according to the current information defined. This should
// be the last call made when defining/creating a chart, or if data within the
// chart has been changed.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
// do we have a delayed renderer pending? If yes we need to clear it
if(this._delayedRenderHandle){
clearTimeout(this._delayedRenderHandle);
this._delayedRenderHandle = null;
}
if(this.theme){
this.theme.clear();
}
if(this.dirty){
return this.fullRender();
}
this.calculateGeometry();
// go over the stack backwards
func.forEachRev(this.stack, function(plot){ plot.render(this.dim, this.offsets); }, this);
// go over axes
func.forIn(this.axes, function(axis){ axis.render(this.dim, this.offsets); }, this);
this._makeClean();
return this; // dojox/charting/Chart
},
fullRender: function(){
// summary:
// Force a full rendering of the chart, including full resets on the chart itself.
// You should not call this method directly unless absolutely necessary.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
// calculate geometry
this.fullGeometry();
var offsets = this.offsets, dim = this.dim;
var w = Math.max(0, dim.width - offsets.l - offsets.r),
h = Math.max(0, dim.height - offsets.t - offsets.b);
// get required colors
//var requiredColors = func.foldl(this.stack, "z + plot.getRequiredColors()", 0);
//this.theme.defineColors({num: requiredColors, cache: false});
// clear old shapes
arr.forEach(this.series, plot2dCommon.purgeGroup);
func.forIn(this.axes, plot2dCommon.purgeGroup);
arr.forEach(this.stack, plot2dCommon.purgeGroup);
var children = this.surface.children;
// starting with 1.9 the registry is optional and thus dispose is
if(shape.dispose){
for(var i = 0; i < children.length;++i){
shape.dispose(children[i]);
}
}
if(this.chartTitle && this.chartTitle.tagName){
// destroy title if it is a DOM node
domConstruct.destroy(this.chartTitle);
}
this.surface.clear();
this.chartTitle = null;
this._renderChartBackground(dim, offsets);
if(this._nativeClip){
this._renderPlotBackground(dim, offsets, w, h);
}else{
// VML
this._renderPlotBackground(dim, offsets, w, h);
}
// go over the stack backwards
func.foldr(this.stack, function(z, plot){ return plot.render(dim, offsets), 0; }, 0);
if(!this._nativeClip){
// VML, matting-clipping
this._renderChartBackground(dim, offsets);
}
//create title: Whether to make chart title as a widget which extends dojox.charting.Element?
if(this.title){
this._renderTitle(dim, offsets);
}
// go over axes
func.forIn(this.axes, function(axis){ axis.render(dim, offsets); });
this._makeClean();
return this; // dojox/charting/Chart
},
_renderTitle: function(dim, offsets){
// summary:
// Internal function to render the chart title.
// dim:
// The dimension object of the chart
// tags:
// private
var forceHtmlLabels = (g.renderer == "canvas") && this.htmlLabels,
labelType = forceHtmlLabels || !has("ie") && !has("opera") && this.htmlLabels ? "html" : "gfx",
tsize = g.normalizedLength(g.splitFontString(this.titleFont).size),
tBox = g._base._getTextBox(this.title,{ font: this.titleFont });
var titleAlign = this.titleAlign;
var isRtl = has("dojo-bidi") && this.isRightToLeft();
var posX = dim.width/2; // Default is middle.
if(titleAlign === "edge"){
titleAlign = "left";
if(isRtl){
posX = dim.width - (offsets.r + tBox.w);
}else {
posX = offsets.l;
}
}else if(titleAlign != "middle"){
if(isRtl){
// We're in BIDI mode, reverse the alignment.
titleAlign = titleAlign === "left" ? "right" : "left";
}
if(titleAlign === "left"){
posX = this.margins.l;
}else if(titleAlign === "right"){
titleAlign = "left";
posX = dim.width - (this.margins.l + tBox.w);
}
}
this.chartTitle = common.createText[labelType](
this,
this.surface,
posX,
this.titlePos=="top" ? tsize + this.margins.t : dim.height - this.margins.b,
titleAlign,
this.title,
this.titleFont,
this.titleFontColor
);
},
_renderChartBackground: function(dim, offsets){
var t = this.theme, rect;
// chart background
var fill = this.fill !== undefined ? this.fill : (t.chart && t.chart.fill);
var stroke = this.stroke !== undefined ? this.stroke : (t.chart && t.chart.stroke);
// TRT: support for "inherit" as a named value in a theme.
if(fill == "inherit"){
// find the background color of the nearest ancestor node, and use that explicitly.
var node = this.node;
fill = new Color(domStyle.get(node, "backgroundColor"));
while(fill.a==0 && node!=document.documentElement){
fill = new Color(domStyle.get(node, "backgroundColor"));
node = node.parentNode;
}
}
if(fill){
if(this._nativeClip){
fill = Element.prototype._shapeFill(Element.prototype._plotFill(fill, dim),
{ x:0, y: 0, width: dim.width + 1, height: dim.height + 1 });
this.surface.createRect({ width: dim.width + 1, height: dim.height + 1 }).setFill(fill);
}else{
// VML
fill = Element.prototype._plotFill(fill, dim, offsets);
if(offsets.l){ // left
rect = {
x: 0,
y: 0,
width: offsets.l,
height: dim.height + 1
};
this.surface.createRect(rect).setFill(Element.prototype._shapeFill(fill, rect));
}
if(offsets.r){ // right
rect = {
x: dim.width - offsets.r,
y: 0,
width: offsets.r + 1,
height: dim.height + 2
};
this.surface.createRect(rect).setFill(Element.prototype._shapeFill(fill, rect));
}
if(offsets.t){ // top
rect = {
x: 0,
y: 0,
width: dim.width + 1,
height: offsets.t
};
this.surface.createRect(rect).setFill(Element.prototype._shapeFill(fill, rect));
}
if(offsets.b){ // bottom
rect = {
x: 0,
y: dim.height - offsets.b,
width: dim.width + 1,
height: offsets.b + 2
};
this.surface.createRect(rect).setFill(Element.prototype._shapeFill(fill, rect));
}
}
}
if(stroke){
this.surface.createRect({
width: dim.width - 1,
height: dim.height - 1
}).setStroke(stroke);
}
},
_renderPlotBackground: function(dim, offsets, w, h){
var t = this.theme;
// draw a plot background
var fill = t.plotarea && t.plotarea.fill;
var stroke = t.plotarea && t.plotarea.stroke;
// size might be neg if offsets are bigger that chart size this happens quite often at
// initialization time if the chart widget is used in a BorderContainer
// this will fail on IE/VML
var rect = {
x: offsets.l - 1, y: offsets.t - 1,
width: w + 2,
height: h + 2
};
if(fill){
fill = Element.prototype._shapeFill(Element.prototype._plotFill(fill, dim, offsets), rect);
this.surface.createRect(rect).setFill(fill);
}
if(stroke){
this.surface.createRect({
x: offsets.l, y: offsets.t,
width: w + 1,
height: h + 1
}).setStroke(stroke);
}
},
delayedRender: function(){
// summary:
// Delayed render, which is used to collect multiple updates
// within a delayInMs time window.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
if(!this._delayedRenderHandle){
this._delayedRenderHandle = setTimeout(
lang.hitch(this, function(){
this.render();
}),
this.delayInMs
);
}
return this; // dojox/charting/Chart
},
connectToPlot: function(name, object, method){
// summary:
// A convenience method to connect a function to a plot.
// name: String
// The name of the plot as defined by addPlot.
// object: Object
// The object to be connected.
// method: Function
// The function to be executed.
// returns: Array
// A handle to the connection, as defined by dojo.connect (see dojo.connect).
return name in this.plots ? this.stack[this.plots[name]].connect(object, method) : null; // Array
},
fireEvent: function(seriesName, eventName, index){
// summary:
// Fires a synthetic event for a series item.
// seriesName: String
// Series name.
// eventName: String
// Event name to simulate: onmouseover, onmouseout, onclick.
// index: Number
// Valid data value index for the event.
// returns: dojox/charting/Chart
// A reference to the current chart for functional chaining.
if(seriesName in this.runs){
var plotName = this.series[this.runs[seriesName]].plot;
if(plotName in this.plots){
var plot = this.stack[this.plots[plotName]];
if(plot){
plot.fireEvent(seriesName, eventName, index);
}
}
}
return this; // dojox/charting/Chart
},
_makeClean: function(){
// reset dirty flags
arr.forEach(this.axes, makeClean);
arr.forEach(this.stack, makeClean);
arr.forEach(this.series, makeClean);
this.dirty = false;
},
_makeDirty: function(){
// reset dirty flags
arr.forEach(this.axes, makeDirty);
arr.forEach(this.stack, makeDirty);
arr.forEach(this.series, makeDirty);
this.dirty = true;
},
_invalidateDependentPlots: function(plotName, /* Boolean */ verticalAxis){
if(plotName in this.plots){
var plot = this.stack[this.plots[plotName]], axis,
axisName = verticalAxis ? "vAxis" : "hAxis";
if(plot[axisName]){
axis = this.axes[plot[axisName]];
if(axis && axis.dependOnData()){
axis.dirty = true;
// find all plots and mark them dirty
arr.forEach(this.stack, function(p){
if(p[axisName] && p[axisName] == plot[axisName]){
p.dirty = true;
}
});
}
}else{
plot.dirty = true;
}
}
},
setDir : function(dir){
return this;
},
_resetLeftBottom: function(axis){
},
formatTruncatedLabel: function(element, label, labelType){
}
});
function hSection(stats){
return {min: stats.hmin, max: stats.hmax};
}
function vSection(stats){
return {min: stats.vmin, max: stats.vmax};
}
function hReplace(stats, h){
stats.hmin = h.min;
stats.hmax = h.max;
}
function vReplace(stats, v){
stats.vmin = v.min;
stats.vmax = v.max;
}
function combineStats(target, source){
if(target && source){
target.min = Math.min(target.min, source.min);
target.max = Math.max(target.max, source.max);
}
return target || source;
}
function calculateAxes(stack, plotArea){
var plots = {}, axes = {};
arr.forEach(stack, function(plot){
var stats = plots[plot.name] = plot.getSeriesStats();
if(plot.hAxis){
axes[plot.hAxis] = combineStats(axes[plot.hAxis], hSection(stats));
}
if(plot.vAxis){
axes[plot.vAxis] = combineStats(axes[plot.vAxis], vSection(stats));
}
});
arr.forEach(stack, function(plot){
var stats = plots[plot.name];
if(plot.hAxis){
hReplace(stats, axes[plot.hAxis]);
}
if(plot.vAxis){
vReplace(stats, axes[plot.vAxis]);
}
plot.initializeScalers(plotArea, stats);
});
}
return has("dojo-bidi")? declare("dojox.charting.Chart", [Chart, BidiChart]) : Chart;
});
},
'dojox/charting/Element':function(){
define(["dojo/_base/array", "dojo/dom-construct","dojo/_base/declare", "dojox/gfx", "dojox/gfx/shape"],
function(arr, domConstruct, declare, gfx, shape){
return declare("dojox.charting.Element", null, {
// summary:
// A base class that is used to build other elements of a chart, such as
// a series.
// chart: dojox/charting/Chart
// The parent chart for this element.
// group: dojox/gfx/shape.Group
// The visual GFX group representing this element.
// htmlElement: Array
// Any DOMNodes used as a part of this element (such as HTML-based labels).
// dirty: Boolean
// A flag indicating whether or not this element needs to be rendered.
chart: null,
group: null,
htmlElements: null,
dirty: true,
renderingOptions: null,
constructor: function(chart, kwArgs){
// summary:
// Creates a new charting element.
// chart: dojox/charting/Chart
// The chart that this element belongs to.
this.chart = chart;
this.group = null;
this.htmlElements = [];
this.dirty = true;
this.trailingSymbol = "...";
this._events = [];
if (kwArgs && kwArgs.renderingOptions) {
this.renderingOptions = kwArgs.renderingOptions;
}
},
purgeGroup: function(){
// summary:
// Clear any elements out of our group, and destroy the group.
// returns: dojox/charting/Element
// A reference to this object for functional chaining.
this.destroyHtmlElements();
if(this.group){
// since 1.7.x we need dispose shape otherwise there is a memoryleak
this.getGroup().removeShape();
var children = this.getGroup().children;
// starting with 1.9 the registry is optional and thus dispose is
if(shape.dispose){
for(var i = 0; i < children.length;++i){
shape.dispose(children[i], true);
}
}
if(this.getGroup().rawNode){
domConstruct.empty(this.getGroup().rawNode);
}
this.getGroup().clear();
// starting with 1.9 the registry is optional and thus dispose is
if(shape.dispose){
shape.dispose(this.getGroup(), true);
}
if(this.getGroup() != this.group){
// we do have an intermediary clipping group (see CartesianBase)
if(this.group.rawNode){
domConstruct.empty(this.group.rawNode);
}
this.group.clear();
// starting with 1.9 the registry is optional and thus dispose is
if(shape.dispose){
shape.dispose(this.group, true);
}
}
this.group = null;
}
this.dirty = true;
if(this._events.length){
arr.forEach(this._events, function(item){
item.shape.disconnect(item.handle);
});
this._events = [];
}
return this; // dojox.charting.Element
},
cleanGroup: function(creator){
// summary:
// Clean any elements (HTML or GFX-based) out of our group, and create a new one.
// creator: dojox/gfx/shape.Surface?
// An optional surface to work with.
// returns: dojox/charting/Element
// A reference to this object for functional chaining.
this.destroyHtmlElements();
if(!creator){ creator = this.chart.surface; }
if(this.group){
var bgnode;
var children = this.getGroup().children;
// starting with 1.9 the registry is optional and thus dispose is
if(shape.dispose){
for(var i = 0; i < children.length;++i){
shape.dispose(children[i], true);
}
}
if(this.getGroup().rawNode){
bgnode = this.getGroup().bgNode;
domConstruct.empty(this.getGroup().rawNode);
}
this.getGroup().clear();
if(bgnode){
this.getGroup().rawNode.appendChild(bgnode);
}
}else{
this.group = creator.createGroup();
// in some cases we have a rawNode but this is not an actual DOM element (CanvasWithEvents) so check
// the actual rawNode type.
if (this.renderingOptions && this.group.rawNode &&
this.group.rawNode.namespaceURI == "http://www.w3.org/2000/svg") {
for (var key in this.renderingOptions) {
this.group.rawNode.setAttribute(key, this.renderingOptions[key]);
}
}
}
this.dirty = true;
return this; // dojox.charting.Element
},
getGroup: function(){
return this.group;
},
destroyHtmlElements: function(){
// summary:
// Destroy any DOMNodes that may have been created as a part of this element.
if(this.htmlElements.length){
arr.forEach(this.htmlElements, domConstruct.destroy);
this.htmlElements = [];
}
},
destroy: function(){
// summary:
// API addition to conform to the rest of the Dojo Toolkit's standard.
this.purgeGroup();
},
overrideShape: function(shape, params){
// summary:
// Extension point for overriding the charting shape
},
//text utilities
getTextWidth: function(s, font){
return gfx._base._getTextBox(s, {font: font}).w || 0;
},
getTextWithLimitLength: function(s, font, limitWidth, truncated){
// summary:
// Get the truncated string based on the limited width in px(dichotomy algorithm)
// s: String?
// candidate text.
// font: String?
// text's font style.
// limitWidth: Number?
// text limited width in px.
// truncated: Boolean?
// whether the input text(s) has already been truncated.
// returns: Object
// | {
// | text: processed text, maybe truncated or not,
// | truncated: whether text has been truncated
// | }
if(!s || s.length <= 0){
return {
text: "",
truncated: truncated || false
};
}
if(!limitWidth || limitWidth <= 0){
return {
text: s,
truncated: truncated || false
};
}
var delta = 2,
//golden section for dichotomy algorithm
trucPercentage = 0.618,
minStr = s.substring(0,1) + this.trailingSymbol,
minWidth = this.getTextWidth(minStr, font);
if(limitWidth <= minWidth){
return {
text: minStr,
truncated: true
};
}
var width = this.getTextWidth(s, font);
if(width <= limitWidth){
return {
text: s,
truncated: truncated || false
};
}else{
var begin = 0,
end = s.length;
while(begin < end){
if(end - begin <= delta ){
while (this.getTextWidth(s.substring(0, begin) + this.trailingSymbol, font) > limitWidth) {
begin -= 1;
}
return {
text: (s.substring(0,begin) + this.trailingSymbol),
truncated: true
};
}
var index = begin + Math.round((end - begin) * trucPercentage),
widthIntercepted = this.getTextWidth(s.substring(0, index), font);
if(widthIntercepted < limitWidth){
begin = index;
end = end;
}else{
begin = begin;
end = index;
}
}
}
},
getTextWithLimitCharCount: function(s, font, wcLimit, truncated){
// summary:
// Get the truncated string based on the limited character count(dichotomy algorithm)
// s: String?
// candidate text.
// font: String?
// text's font style.
// wcLimit: Number?
// text limited character count.
// truncated: Boolean?
// whether the input text(s) has already been truncated.
// returns: Object
// | {
// | text: processed text, maybe truncated or not,
// | truncated: whether text has been truncated
// | }
if (!s || s.length <= 0) {
return {
text: "",
truncated: truncated || false
};
}
if(!wcLimit || wcLimit <= 0 || s.length <= wcLimit){
return {
text: s,
truncated: truncated || false
};
}
return {
text: s.substring(0, wcLimit) + this.trailingSymbol,
truncated: true
};
},
// fill utilities
_plotFill: function(fill, dim, offsets){
// process a plot-wide fill
if(!fill || !fill.type || !fill.space){
return fill;
}
var space = fill.space, span;
switch(fill.type){
case "linear":
if(space === "plot" || space === "shapeX" || space === "shapeY"){
// clone a fill so we can modify properly directly
fill = gfx.makeParameters(gfx.defaultLinearGradient, fill);
fill.space = space;
// process dimensions
if(space === "plot" || space === "shapeX"){
// process Y
span = dim.height - offsets.t - offsets.b;
fill.y1 = offsets.t + span * fill.y1 / 100;
fill.y2 = offsets.t + span * fill.y2 / 100;
}
if(space === "plot" || space === "shapeY"){
// process X
span = dim.width - offsets.l - offsets.r;
fill.x1 = offsets.l + span * fill.x1 / 100;
fill.x2 = offsets.l + span * fill.x2 / 100;
}
}
break;
case "radial":
if(space === "plot"){
// this one is used exclusively for scatter charts
// clone a fill so we can modify properly directly
fill = gfx.makeParameters(gfx.defaultRadialGradient, fill);
fill.space = space;
// process both dimensions
var spanX = dim.width - offsets.l - offsets.r,
spanY = dim.height - offsets.t - offsets.b;
fill.cx = offsets.l + spanX * fill.cx / 100;
fill.cy = offsets.t + spanY * fill.cy / 100;
fill.r = fill.r * Math.sqrt(spanX * spanX + spanY * spanY) / 200;
}
break;
case "pattern":
if(space === "plot" || space === "shapeX" || space === "shapeY"){
// clone a fill so we can modify properly directly
fill = gfx.makeParameters(gfx.defaultPattern, fill);
fill.space = space;
// process dimensions
if(space === "plot" || space === "shapeX"){
// process Y
span = dim.height - offsets.t - offsets.b;
fill.y = offsets.t + span * fill.y / 100;
fill.height = span * fill.height / 100;
}
if(space === "plot" || space === "shapeY"){
// process X
span = dim.width - offsets.l - offsets.r;
fill.x = offsets.l + span * fill.x / 100;
fill.width = span * fill.width / 100;
}
}
break;
}
return fill;
},
_shapeFill: function(fill, bbox){
// process shape-specific fill
if(!fill || !fill.space){
return fill;
}
var space = fill.space, span;
switch(fill.type){
case "linear":
if(space === "shape" || space === "shapeX" || space === "shapeY"){
// clone a fill so we can modify properly directly
fill = gfx.makeParameters(gfx.defaultLinearGradient, fill);
fill.space = space;
// process dimensions
if(space === "shape" || space === "shapeX"){
// process X
span = bbox.width;
fill.x1 = bbox.x + span * fill.x1 / 100;
fill.x2 = bbox.x + span * fill.x2 / 100;
}
if(space === "shape" || space === "shapeY"){
// process Y
span = bbox.height;
fill.y1 = bbox.y + span * fill.y1 / 100;
fill.y2 = bbox.y + span * fill.y2 / 100;
}
}
break;
case "radial":
if(space === "shape"){
// this one is used exclusively for bubble charts and pie charts
// clone a fill so we can modify properly directly
fill = gfx.makeParameters(gfx.defaultRadialGradient, fill);
fill.space = space;
// process both dimensions
fill.cx = bbox.x + bbox.width / 2;
fill.cy = bbox.y + bbox.height / 2;
fill.r = fill.r * bbox.width / 200;
}
break;
case "pattern":
if(space === "shape" || space === "shapeX" || space === "shapeY"){
// clone a fill so we can modify properly directly
fill = gfx.makeParameters(gfx.defaultPattern, fill);
fill.space = space;
// process dimensions
if(space === "shape" || space === "shapeX"){
// process X
span = bbox.width;
fill.x = bbox.x + span * fill.x / 100;
fill.width = span * fill.width / 100;
}
if(space === "shape" || space === "shapeY"){
// process Y
span = bbox.height;
fill.y = bbox.y + span * fill.y / 100;
fill.height = span * fill.height / 100;
}
}
break;
}
return fill;
},
_pseudoRadialFill: function(fill, center, radius, start, end){
// process pseudo-radial fills
if(!fill || fill.type !== "radial" || fill.space !== "shape"){
return fill;
}
// clone and normalize fill
var space = fill.space;
fill = gfx.makeParameters(gfx.defaultRadialGradient, fill);
fill.space = space;
if(arguments.length < 4){
// process both dimensions
fill.cx = center.x;
fill.cy = center.y;
fill.r = fill.r * radius / 100;
return fill;
}
// convert to a linear gradient
var angle = arguments.length < 5 ? start : (end + start) / 2;
return {
type: "linear",
x1: center.x,
y1: center.y,
x2: center.x + fill.r * radius * Math.cos(angle) / 100,
y2: center.y + fill.r * radius * Math.sin(angle) / 100,
colors: fill.colors
};
}
});
});
},
'dojox/gfx':function(){
define(["dojo/_base/lang", "./gfx/_base", "./gfx/renderer!"],
function(lang, gfxBase, renderer){
// module:
// dojox/gfx
// summary:
// This the root of the Dojo Graphics package
gfxBase.switchTo(renderer);
return gfxBase;
});
},
'dojox/gfx/_base':function(){
define(["dojo/_base/kernel", "dojo/_base/lang", "dojo/_base/Color", "dojo/_base/sniff", "dojo/_base/window",
"dojo/_base/array","dojo/dom", "dojo/dom-construct","dojo/dom-geometry"],
function(kernel, lang, Color, has, win, arr, dom, domConstruct, domGeom){
// module:
// dojox/gfx
// summary:
// This module contains common core Graphics API used by different graphics renderers.
var g = lang.getObject("dojox.gfx", true),
b = g._base = {};
// candidates for dojox.style (work on VML and SVG nodes)
g._hasClass = function(/*DomNode*/node, /*String*/classStr){
// summary:
// Returns whether or not the specified classes are a portion of the
// class list currently applied to the node.
// return (new RegExp('(^|\\s+)'+classStr+'(\\s+|$)')).test(node.className) // Boolean
var cls = node.getAttribute("className");
return cls && (" " + cls + " ").indexOf(" " + classStr + " ") >= 0; // Boolean
};
g._addClass = function(/*DomNode*/node, /*String*/classStr){
// summary:
// Adds the specified classes to the end of the class list on the
// passed node.
var cls = node.getAttribute("className") || "";
if(!cls || (" " + cls + " ").indexOf(" " + classStr + " ") < 0){
node.setAttribute("className", cls + (cls ? " " : "") + classStr);
}
};
g._removeClass = function(/*DomNode*/node, /*String*/classStr){
// summary:
// Removes classes from node.
var cls = node.getAttribute("className");
if(cls){
node.setAttribute(
"className",
cls.replace(new RegExp('(^|\\s+)' + classStr + '(\\s+|$)'), "$1$2")
);
}
};
// candidate for dojox.html.metrics (dynamic font resize handler is not implemented here)
// derived from Morris John's emResized measurer
b._getFontMeasurements = function(){
// summary:
// Returns an object that has pixel equivilents of standard font
// size values.
var heights = {
'1em': 0, '1ex': 0, '100%': 0, '12pt': 0, '16px': 0, 'xx-small': 0,
'x-small': 0, 'small': 0, 'medium': 0, 'large': 0, 'x-large': 0,
'xx-large': 0
};
var p, oldStyle;
if(has("ie")){
// We do a font-size fix if and only if one isn't applied already.
// NOTE: If someone set the fontSize on the HTML Element, this will kill it.
oldStyle = win.doc.documentElement.style.fontSize || "";
if(!oldStyle){
win.doc.documentElement.style.fontSize="100%";
}
}
// set up the measuring node.
var div = domConstruct.create("div", {style: {
position: "absolute",
left: "0",
top: "-100px",
width: "30px",
height: "1000em",
borderWidth: "0",
margin: "0",
padding: "0",
outline: "none",
lineHeight: "1",
overflow: "hidden"
}}, win.body());
// do the measurements.
for(p in heights){
div.style.fontSize = p;
heights[p] = Math.round(div.offsetHeight * 12/16) * 16/12 / 1000;
}
if(has("ie")){
// Restore the font to its old style.
win.doc.documentElement.style.fontSize = oldStyle;
}
win.body().removeChild(div);
return heights; //object
};
var fontMeasurements = null;
b._getCachedFontMeasurements = function(recalculate){
if(recalculate || !fontMeasurements){
fontMeasurements = b._getFontMeasurements();
}
return fontMeasurements;
};
// candidate for dojox.html.metrics
var measuringNode = null, empty = {};
b._getTextBox = function( /*String*/ text,
/*Object*/ style,
/*String?*/ className){
var m, s, al = arguments.length;
var i, box;
if(!measuringNode){
measuringNode = domConstruct.create("div", {style: {
position: "absolute",
top: "-10000px",
left: "0",
visibility: "hidden"
}}, win.body());
}
m = measuringNode;
// reset styles
m.className = "";
s = m.style;
s.borderWidth = "0";
s.margin = "0";
s.padding = "0";
s.outline = "0";
// set new style
if(al > 1 && style){
for(i in style){
if(i in empty){ continue; }
s[i] = style[i];
}
}
// set classes
if(al > 2 && className){
m.className = className;
}
// take a measure
m.innerHTML = text;
if(m.getBoundingClientRect){
var bcr = m.getBoundingClientRect();
box = {l: bcr.left, t: bcr.top, w: bcr.width || (bcr.right - bcr.left), h: bcr.height || (bcr.bottom - bcr.top)};
}else{
box = domGeom.getMarginBox(m);
}
m.innerHTML = "";
return box;
};
b._computeTextLocation = function(/*g.defaultTextShape*/textShape, /*Number*/width, /*Number*/height, /*Boolean*/fixHeight) {
var loc = {}, align = textShape.align;
switch (align) {
case 'end':
loc.x = textShape.x - width;
break;
case 'middle':
loc.x = textShape.x - width / 2;
break;
default:
loc.x = textShape.x;
break;
}
var c = fixHeight ? 0.75 : 1;
loc.y = textShape.y - height*c; // **rough** approximation of the ascent...
return loc;
};
b._computeTextBoundingBox = function(/*shape.Text*/s){
// summary:
// Compute the bbox of the given shape.Text instance. Note that this method returns an
// approximation of the bbox, and should be used when the underlying renderer cannot provide precise metrics.
if(!g._base._isRendered(s)){
return {x:0, y:0, width:0, height:0};
}
var loc, textShape = s.getShape(),
font = s.getFont() || g.defaultFont,
w = s.getTextWidth(),
h = g.normalizedLength(font.size);
loc = b._computeTextLocation(textShape, w, h, true);
return {
x: loc.x,
y: loc.y,
width: w,
height: h
};
};
b._isRendered = function(/*Shape*/s){
var p = s.parent;
while(p && p.getParent){
p = p.parent;
}
return p !== null;
};
// candidate for dojo.dom
var uniqueId = 0;
b._getUniqueId = function(){
// summary:
// returns a unique string for use with any DOM element
var id;
do{
id = kernel._scopeName + "xUnique" + (++uniqueId);
}while(dom.byId(id));
return id;
};
// IE10
var touchActionProp = has("pointer-events") ? "touchAction" : has("MSPointer") ? "msTouchAction" : null;
b._fixMsTouchAction = touchActionProp ? function(/*dojox/gfx/shape.Surface*/surface){
surface.rawNode.style[touchActionProp] = "none";
} : function() {};
/*=====
g.Stroke = {
// summary:
// A stroke defines stylistic properties that are used when drawing a path.
// color: String
// The color of the stroke, default value 'black'.
color: "black",
// style: String
// The style of the stroke, one of 'solid', ... . Default value 'solid'.
style: "solid",
// width: Number
// The width of a stroke, default value 1.
width: 1,
// cap: String
// The endcap style of the path. One of 'butt', 'round', ... . Default value 'butt'.
cap: "butt",
// join: Number
// The join style to use when combining path segments. Default value 4.
join: 4
};
g.Fill = {
// summary:
// Defines how to fill a shape. Four types of fills can be used: solid, linear gradient, radial gradient and pattern.
// See dojox/gfx.LinearGradient, dojox/gfx.RadialGradient and dojox/gfx.Pattern respectively for more information about the properties supported by each type.
// type: String?
// The type of fill. One of 'linear', 'radial', 'pattern' or undefined. If not specified, a solid fill is assumed.
type:"",
// color: String|dojo/Color?
// The color of a solid fill type.
color:null,
};
g.LinearGradient = {
// summary:
// An object defining the default stylistic properties used for Linear Gradient fills.
// Linear gradients are drawn along a virtual line, which results in appearance of a rotated pattern in a given direction/orientation.
// type: String
// Specifies this object is a Linear Gradient, value 'linear'
type: "linear",
// x1: Number
// The X coordinate of the start of the virtual line along which the gradient is drawn, default value 0.
x1: 0,
// y1: Number
// The Y coordinate of the start of the virtual line along which the gradient is drawn, default value 0.
y1: 0,
// x2: Number
// The X coordinate of the end of the virtual line along which the gradient is drawn, default value 100.
x2: 100,
// y2: Number
// The Y coordinate of the end of the virtual line along which the gradient is drawn, default value 100.
y2: 100,
// colors: Array
// An array of colors at given offsets (from the start of the line). The start of the line is
// defined at offest 0 with the end of the line at offset 1.
// Default value, [{ offset: 0, color: 'black'},{offset: 1, color: 'white'}], is a gradient from black to white.
colors: []
};
g.RadialGradient = {
// summary:
// Specifies the properties for RadialGradients using in fills patterns.
// type: String
// Specifies this is a RadialGradient, value 'radial'
type: "radial",
// cx: Number
// The X coordinate of the center of the radial gradient, default value 0.
cx: 0,
// cy: Number
// The Y coordinate of the center of the radial gradient, default value 0.
cy: 0,
// r: Number
// The radius to the end of the radial gradient, default value 100.
r: 100,
// colors: Array
// An array of colors at given offsets (from the center of the radial gradient).
// The center is defined at offest 0 with the outer edge of the gradient at offset 1.
// Default value, [{ offset: 0, color: 'black'},{offset: 1, color: 'white'}], is a gradient from black to white.
colors: []
};
g.Pattern = {
// summary:
// An object specifying the default properties for a Pattern using in fill operations.
// type: String
// Specifies this object is a Pattern, value 'pattern'.
type: "pattern",
// x: Number
// The X coordinate of the position of the pattern, default value is 0.
x: 0,
// y: Number
// The Y coordinate of the position of the pattern, default value is 0.
y: 0,
// width: Number
// The width of the pattern image, default value is 0.
width: 0,
// height: Number
// The height of the pattern image, default value is 0.
height: 0,
// src: String
// A url specifying the image to use for the pattern.
src: ""
};
g.Text = {
// summary:
// A keyword argument object defining both the text to be rendered in a VectorText shape,
// and specifying position, alignment, and fitting.
// text: String
// The text to be rendered.
// x: Number?
// The left coordinate for the text's bounding box.
// y: Number?
// The top coordinate for the text's bounding box.
// width: Number?
// The width of the text's bounding box.
// height: Number?
// The height of the text's bounding box.
// align: String?
// The alignment of the text, as defined in SVG. Can be "start", "end" or "middle".
// fitting: Number?
// How the text is to be fitted to the bounding box. Can be 0 (no fitting), 1 (fitting based on
// passed width of the bounding box and the size of the font), or 2 (fit text to the bounding box,
// and ignore any size parameters).
// leading: Number?
// The leading to be used between lines in the text.
// decoration: String?
// Any text decoration to be used.
};
g.Font = {
// summary:
// An object specifying the properties for a Font used in text operations.
// type: String
// Specifies this object is a Font, value 'font'.
type: "font",
// style: String
// The font style, one of 'normal', 'bold', default value 'normal'.
style: "normal",
// variant: String
// The font variant, one of 'normal', ... , default value 'normal'.
variant: "normal",
// weight: String
// The font weight, one of 'normal', ..., default value 'normal'.
weight: "normal",
// size: String
// The font size (including units), default value '10pt'.
size: "10pt",
// family: String
// The font family, one of 'serif', 'sanserif', ..., default value 'serif'.
family: "serif"
};
=====*/
lang.mixin(g, {
// summary:
// defines constants, prototypes, and utility functions for the core Graphics API
// default shapes, which are used to fill in missing parameters
defaultPath: {
// summary:
// Defines the default Path prototype object.
// type: String
// Specifies this object is a Path, default value 'path'.
type: "path",
// path: String
// The path commands. See W32C SVG 1.0 specification.
// Defaults to empty string value.
path: ""
},
defaultPolyline: {
// summary:
// Defines the default PolyLine prototype.
// type: String
// Specifies this object is a PolyLine, default value 'polyline'.
type: "polyline",
// points: Array
// An array of point objects [{x:0,y:0},...] defining the default polyline's line segments. Value is an empty array [].
points: []
},
defaultRect: {
// summary:
// Defines the default Rect prototype.
// type: String
// Specifies this default object is a type of Rect. Value is 'rect'
type: "rect",
// x: Number
// The X coordinate of the default rectangles position, value 0.
x: 0,
// y: Number
// The Y coordinate of the default rectangle's position, value 0.
y: 0,
// width: Number
// The width of the default rectangle, value 100.
width: 100,
// height: Number
// The height of the default rectangle, value 100.
height: 100,
// r: Number
// The corner radius for the default rectangle, value 0.
r: 0
},
defaultEllipse: {
// summary:
// Defines the default Ellipse prototype.
// type: String
// Specifies that this object is a type of Ellipse, value is 'ellipse'
type: "ellipse",
// cx: Number
// The X coordinate of the center of the ellipse, default value 0.
cx: 0,
// cy: Number
// The Y coordinate of the center of the ellipse, default value 0.
cy: 0,
// rx: Number
// The radius of the ellipse in the X direction, default value 200.
rx: 200,
// ry: Number
// The radius of the ellipse in the Y direction, default value 200.
ry: 100
},
defaultCircle: {
// summary:
// An object defining the default Circle prototype.
// type: String
// Specifies this object is a circle, value 'circle'
type: "circle",
// cx: Number
// The X coordinate of the center of the circle, default value 0.
cx: 0,
// cy: Number
// The Y coordinate of the center of the circle, default value 0.
cy: 0,
// r: Number
// The radius, default value 100.
r: 100
},
defaultLine: {
// summary:
// An object defining the default Line prototype.
// type: String
// Specifies this is a Line, value 'line'
type: "line",
// x1: Number
// The X coordinate of the start of the line, default value 0.
x1: 0,
// y1: Number
// The Y coordinate of the start of the line, default value 0.
y1: 0,
// x2: Number
// The X coordinate of the end of the line, default value 100.
x2: 100,
// y2: Number
// The Y coordinate of the end of the line, default value 100.
y2: 100
},
defaultImage: {
// summary:
// Defines the default Image prototype.
// type: String
// Specifies this object is an image, value 'image'.
type: "image",
// x: Number
// The X coordinate of the image's position, default value 0.
x: 0,
// y: Number
// The Y coordinate of the image's position, default value 0.
y: 0,
// width: Number
// The width of the image, default value 0.
width: 0,
// height: Number
// The height of the image, default value 0.
height: 0,
// src: String
// The src url of the image, defaults to empty string.
src: ""
},
defaultText: {
// summary:
// Defines the default Text prototype.
// type: String
// Specifies this is a Text shape, value 'text'.
type: "text",
// x: Number
// The X coordinate of the text position, default value 0.
x: 0,
// y: Number
// The Y coordinate of the text position, default value 0.
y: 0,
// text: String
// The text to be displayed, default value empty string.
text: "",
// align: String
// The horizontal text alignment, one of 'start', 'end', 'center'. Default value 'start'.
align: "start",
// decoration: String
// The text decoration , one of 'none', ... . Default value 'none'.
decoration: "none",
// rotated: Boolean
// Whether the text is rotated, boolean default value false.
rotated: false,
// kerning: Boolean
// Whether kerning is used on the text, boolean default value true.
kerning: true
},
defaultTextPath: {
// summary:
// Defines the default TextPath prototype.
// type: String
// Specifies this is a TextPath, value 'textpath'.
type: "textpath",
// text: String
// The text to be displayed, default value empty string.
text: "",
// align: String
// The horizontal text alignment, one of 'start', 'end', 'center'. Default value 'start'.
align: "start",
// decoration: String
// The text decoration , one of 'none', ... . Default value 'none'.
decoration: "none",
// rotated: Boolean
// Whether the text is rotated, boolean default value false.
rotated: false,
// kerning: Boolean
// Whether kerning is used on the text, boolean default value true.
kerning: true
},
// default stylistic attributes
defaultStroke: {
// summary:
// A stroke defines stylistic properties that are used when drawing a path.
// This object defines the default Stroke prototype.
// type: String
// Specifies this object is a type of Stroke, value 'stroke'.
type: "stroke",
// color: String
// The color of the stroke, default value 'black'.
color: "black",
// style: String
// The style of the stroke, one of 'solid', ... . Default value 'solid'.
style: "solid",
// width: Number
// The width of a stroke, default value 1.
width: 1,
// cap: String
// The endcap style of the path. One of 'butt', 'round', ... . Default value 'butt'.
cap: "butt",
// join: Number
// The join style to use when combining path segments. Default value 4.
join: 4
},
defaultLinearGradient: {
// summary:
// An object defining the default stylistic properties used for Linear Gradient fills.
// Linear gradients are drawn along a virtual line, which results in appearance of a rotated pattern in a given direction/orientation.
// type: String
// Specifies this object is a Linear Gradient, value 'linear'
type: "linear",
// x1: Number
// The X coordinate of the start of the virtual line along which the gradient is drawn, default value 0.
x1: 0,
// y1: Number
// The Y coordinate of the start of the virtual line along which the gradient is drawn, default value 0.
y1: 0,
// x2: Number
// The X coordinate of the end of the virtual line along which the gradient is drawn, default value 100.
x2: 100,
// y2: Number
// The Y coordinate of the end of the virtual line along which the gradient is drawn, default value 100.
y2: 100,
// colors: Array
// An array of colors at given offsets (from the start of the line). The start of the line is
// defined at offest 0 with the end of the line at offset 1.
// Default value, [{ offset: 0, color: 'black'},{offset: 1, color: 'white'}], is a gradient from black to white.
colors: [
{ offset: 0, color: "black" }, { offset: 1, color: "white" }
]
},
defaultRadialGradient: {
// summary:
// An object specifying the default properties for RadialGradients using in fills patterns.
// type: String
// Specifies this is a RadialGradient, value 'radial'
type: "radial",
// cx: Number
// The X coordinate of the center of the radial gradient, default value 0.
cx: 0,
// cy: Number
// The Y coordinate of the center of the radial gradient, default value 0.
cy: 0,
// r: Number
// The radius to the end of the radial gradient, default value 100.
r: 100,
// colors: Array
// An array of colors at given offsets (from the center of the radial gradient).
// The center is defined at offest 0 with the outer edge of the gradient at offset 1.
// Default value, [{ offset: 0, color: 'black'},{offset: 1, color: 'white'}], is a gradient from black to white.
colors: [
{ offset: 0, color: "black" }, { offset: 1, color: "white" }
]
},
defaultPattern: {
// summary:
// An object specifying the default properties for a Pattern using in fill operations.
// type: String
// Specifies this object is a Pattern, value 'pattern'.
type: "pattern",
// x: Number
// The X coordinate of the position of the pattern, default value is 0.
x: 0,
// y: Number
// The Y coordinate of the position of the pattern, default value is 0.
y: 0,
// width: Number
// The width of the pattern image, default value is 0.
width: 0,
// height: Number
// The height of the pattern image, default value is 0.
height: 0,
// src: String
// A url specifying the image to use for the pattern.
src: ""
},
defaultFont: {
// summary:
// An object specifying the default properties for a Font used in text operations.
// type: String
// Specifies this object is a Font, value 'font'.
type: "font",
// style: String
// The font style, one of 'normal', 'bold', default value 'normal'.
style: "normal",
// variant: String
// The font variant, one of 'normal', ... , default value 'normal'.
variant: "normal",
// weight: String
// The font weight, one of 'normal', ..., default value 'normal'.
weight: "normal",
// size: String
// The font size (including units), default value '10pt'.
size: "10pt",
// family: String
// The font family, one of 'serif', 'sanserif', ..., default value 'serif'.
family: "serif"
},
getDefault: (function(){
// summary:
// Returns a function used to access default memoized prototype objects (see them defined above).
var typeCtorCache = {};
// a memoized delegate()
return function(/*String*/ type){
var t = typeCtorCache[type];
if(t){
return new t();
}
t = typeCtorCache[type] = function () {};
t.prototype = g[ "default" + type ];
return new t();
}
})(),
normalizeColor: function(/*dojo/Color|Array|string|Object*/ color){
// summary:
// converts any legal color representation to normalized
// dojo/Color object
// color:
// A color representation.
return (color instanceof Color) ? color : new Color(color); // dojo/Color
},
normalizeParameters: function(existed, update){
// summary:
// updates an existing object with properties from an 'update'
// object
// existed: Object
// the target object to be updated
// update: Object
// the 'update' object, whose properties will be used to update
// the existed object
var x;
if(update){
var empty = {};
for(x in existed){
if(x in update && !(x in empty)){
existed[x] = update[x];
}
}
}
return existed; // Object
},
makeParameters: function(defaults, update){
// summary:
// copies the original object, and all copied properties from the
// 'update' object
// defaults: Object
// the object to be cloned before updating
// update: Object
// the object, which properties are to be cloned during updating
// returns: Object
// new object with new and default properties
var i = null;
if(!update){
// return dojo.clone(defaults);
return lang.delegate(defaults);
}
var result = {};
for(i in defaults){
if(!(i in result)){
result[i] = lang.clone((i in update) ? update[i] : defaults[i]);
}
}
return result; // Object
},
formatNumber: function(x, addSpace){
// summary:
// converts a number to a string using a fixed notation
// x: Number
// number to be converted
// addSpace: Boolean
// whether to add a space before a positive number
// returns: String
// the formatted value
var val = x.toString();
if(val.indexOf("e") >= 0){
val = x.toFixed(4);
}else{
var point = val.indexOf(".");
if(point >= 0 && val.length - point > 5){
val = x.toFixed(4);
}
}
if(x < 0){
return val; // String
}
return addSpace ? " " + val : val; // String
},
// font operations
makeFontString: function(font){
// summary:
// converts a font object to a CSS font string
// font: Object
// font object (see dojox/gfx.defaultFont)
return font.style + " " + font.variant + " " + font.weight + " " + font.size + " " + font.family; // Object
},
splitFontString: function(str){
// summary:
// converts a CSS font string to a font object
// description:
// Converts a CSS font string to a gfx font object. The CSS font
// string components should follow the W3C specified order
// (see http://www.w3.org/TR/CSS2/fonts.html#font-shorthand):
// style, variant, weight, size, optional line height (will be
// ignored), and family. Note that the Font.size attribute is limited to numeric CSS length.
// str: String
// a CSS font string.
// returns: Object
// object in dojox/gfx.defaultFont format
var font = g.getDefault("Font");
var t = str.split(/\s+/);
do{
if(t.length < 5){ break; }
font.style = t[0];
font.variant = t[1];
font.weight = t[2];
var i = t[3].indexOf("/");
font.size = i < 0 ? t[3] : t[3].substring(0, i);
var j = 4;
if(i < 0){
if(t[4] == "/"){
j = 6;
}else if(t[4].charAt(0) == "/"){
j = 5;
}
}
if(j < t.length){
font.family = t.slice(j).join(" ");
}
}while(false);
return font; // Object
},
// length operations
// cm_in_pt: Number
// points per centimeter (constant)
cm_in_pt: 72 / 2.54,
// mm_in_pt: Number
// points per millimeter (constant)
mm_in_pt: 7.2 / 2.54,
px_in_pt: function(){
// summary:
// returns the current number of pixels per point.
return g._base._getCachedFontMeasurements()["12pt"] / 12; // Number
},
pt2px: function(len){
// summary:
// converts points to pixels
// len: Number
// a value in points
return len * g.px_in_pt(); // Number
},
px2pt: function(len){
// summary:
// converts pixels to points
// len: Number
// a value in pixels
return len / g.px_in_pt(); // Number
},
normalizedLength: function(len) {
// summary:
// converts any length value to pixels
// len: String
// a length, e.g., '12pc'
// returns: Number
// pixels
if(len.length === 0){ return 0; }
if(len.length > 2){
var px_in_pt = g.px_in_pt();
var val = parseFloat(len);
switch(len.slice(-2)){
case "px": return val;
case "pt": return val * px_in_pt;
case "in": return val * 72 * px_in_pt;
case "pc": return val * 12 * px_in_pt;
case "mm": return val * g.mm_in_pt * px_in_pt;
case "cm": return val * g.cm_in_pt * px_in_pt;
}
}
return parseFloat(len); // Number
},
// pathVmlRegExp: RegExp
// a constant regular expression used to split a SVG/VML path into primitive components
// tags:
// private
pathVmlRegExp: /([A-Za-z]+)|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g,
// pathVmlRegExp: RegExp
// a constant regular expression used to split a SVG/VML path into primitive components
// tags:
// private
pathSvgRegExp: /([A-DF-Za-df-z])|([-+]?\d*[.]?\d+(?:[eE][-+]?\d+)?)/g,
equalSources: function(a, b){
// summary:
// compares event sources, returns true if they are equal
// a: Object
// first event source
// b: Object
// event source to compare against a
// returns: Boolean
// true, if objects are truthy and the same
return a && b && a === b;
},
switchTo: function(/*String|Object*/ renderer){
// summary:
// switch the graphics implementation to the specified renderer.
// renderer:
// Either the string name of a renderer (eg. 'canvas', 'svg, ...) or the renderer
// object to switch to.
var ns = typeof renderer == "string" ? g[renderer] : renderer;
if(ns){
// If more options are added, update the docblock at the end of shape.js!
arr.forEach(["Group", "Rect", "Ellipse", "Circle", "Line",
"Polyline", "Image", "Text", "Path", "TextPath",
"Surface", "createSurface", "fixTarget"], function(name){
g[name] = ns[name];
});
if(typeof renderer == "string"){
g.renderer = renderer;
}else{
arr.some(["svg","vml","canvas","canvasWithEvents","silverlight"], function(r){
return (g.renderer = g[r] && g[r].Surface === g.Surface ? r : null);
});
}
}
}
});
/*=====
g.createSurface = function(parentNode, width, height){
// summary:
// creates a surface
// parentNode: Node
// a parent node
// width: String|Number
// width of surface, e.g., "100px" or 100
// height: String|Number
// height of surface, e.g., "100px" or 100
// returns: dojox/gfx.Surface
// newly created surface
};
g.fixTarget = function(){
// tags:
// private
};
=====*/
return g; // defaults object api
});
},
'dojox/gfx/renderer':function(){
define(["./_base","dojo/_base/lang", "dojo/_base/sniff", "dojo/_base/window", "dojo/_base/config"],
function(g, lang, has, win, config){
//>> noBuildResolver
var currentRenderer = null;
has.add("vml", function(global, document, element){
element.innerHTML = "";
var supported = ("adj" in element.firstChild);
element.innerHTML = "";
return supported;
});
return {
// summary:
// This module is an AMD loader plugin that loads the appropriate graphics renderer
// implementation based on detected environment and current configuration settings.
load: function(id, require, load){
// tags:
// private
if(currentRenderer && id != "force"){
load(currentRenderer);
return;
}
var renderer = config.forceGfxRenderer,
renderers = !renderer && (lang.isString(config.gfxRenderer) ?
config.gfxRenderer : "svg,vml,canvas,silverlight").split(","),
silverlightObject, silverlightFlag;
while(!renderer && renderers.length){
switch(renderers.shift()){
case "svg":
// the next test is from https://github.com/phiggins42/has.js
if("SVGAngle" in win.global){
renderer = "svg";
}
break;
case "vml":
if(has("vml")){
renderer = "vml";
}
break;
case "silverlight":
try{
if(has("ie")){
silverlightObject = new ActiveXObject("AgControl.AgControl");
if(silverlightObject && silverlightObject.IsVersionSupported("1.0")){
silverlightFlag = true;
}
}else{
if(navigator.plugins["Silverlight Plug-In"]){
silverlightFlag = true;
}
}
}catch(e){
silverlightFlag = false;
}finally{
silverlightObject = null;
}
if(silverlightFlag){
renderer = "silverlight";
}
break;
case "canvas":
if(win.global.CanvasRenderingContext2D){
renderer = "canvas";
}
break;
}
}
if (renderer === 'canvas' && config.canvasEvents !== false) {
renderer = "canvasWithEvents";
}
if(config.isDebug){
console.log("gfx renderer = " + renderer);
}
function loadRenderer(){
require(["dojox/gfx/" + renderer], function(module){
g.renderer = renderer;
// memorize the renderer module
currentRenderer = module;
// now load it
load(module);
});
}
if(renderer == "svg" && typeof window.svgweb != "undefined"){
window.svgweb.addOnLoad(loadRenderer);
}else{
loadRenderer();
}
}
};
});
},
'dojox/gfx/shape':function(){
define(["./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/kernel", "dojo/_base/sniff",
"dojo/on", "dojo/_base/array", "dojo/dom-construct", "dojo/_base/Color", "./matrix" ],
function(g, lang, declare, kernel, has, on, arr, domConstruct, Color, matrixLib){
function removeItemAt(a, index) {
var len = (a.length - 1);
while (index < len) {
a[index] = a[++index];
}
a.length = len;
}
var shape = g.shape = {
// summary:
// This module contains the core graphics Shape API.
// Different graphics renderer implementation modules (svg, canvas, vml, silverlight, etc.) extend this
// basic api to provide renderer-specific implementations for each shape.
};
shape.Shape = declare("dojox.gfx.shape.Shape", null, {
// summary:
// a Shape object, which knows how to apply
// graphical attributes and transformations
constructor: function(){
// rawNode: Node
// underlying graphics-renderer-specific implementation object (if applicable)
this.rawNode = null;
// shape: Object
// an abstract shape object
// (see dojox/gfx.defaultPath,
// dojox/gfx.defaultPolyline,
// dojox/gfx.defaultRect,
// dojox/gfx.defaultEllipse,
// dojox/gfx.defaultCircle,
// dojox/gfx.defaultLine,
// or dojox/gfx.defaultImage)
this.shape = null;
// matrix: dojox/gfx/matrix.Matrix2D
// a transformation matrix
this.matrix = null;
// fillStyle: dojox/gfx.Fill
// a fill object
// (see dojox/gfx.defaultLinearGradient,
// dojox/gfx.defaultRadialGradient,
// dojox/gfx.defaultPattern,
// or dojo/Color)
this.fillStyle = null;
// strokeStyle: dojox/gfx.Stroke
// a stroke object
// (see dojox/gfx.defaultStroke)
this.strokeStyle = null;
// bbox: dojox/gfx.Rectangle
// a bounding box of this shape
// (see dojox/gfx.defaultRect)
this.bbox = null;
// virtual group structure
// parent: Object
// a parent or null
// (see dojox/gfx/shape.Surface,
// or dojox/gfx.Group)
this.parent = null;
// parentMatrix: dojox/gfx/matrix.Matrix2D
// a transformation matrix inherited from the parent
this.parentMatrix = null;
if(has("gfxRegistry")){
var uid = shape.register(this);
this.getUID = function(){
return uid;
}
}
},
destroy: function(){
// summary:
// Releases all internal resources owned by this shape. Once this method has been called,
// the instance is considered destroyed and should not be used anymore.
if(has("gfxRegistry")){
shape.dispose(this);
}
if(this.rawNode && "__gfxObject__" in this.rawNode){
this.rawNode.__gfxObject__ = null;
}
this.rawNode = null;
},
// trivial getters
getNode: function(){
// summary:
// Different graphics rendering subsystems implement shapes in different ways. This
// method provides access to the underlying graphics subsystem object. Clients calling this
// method and using the return value must be careful not to try sharing or using the underlying node
// in a general way across renderer implementation.
// Returns the underlying graphics Node, or null if no underlying graphics node is used by this shape.
return this.rawNode; // Node
},
getShape: function(){
// summary:
// returns the current Shape object or null
// (see dojox/gfx.defaultPath,
// dojox/gfx.defaultPolyline,
// dojox/gfx.defaultRect,
// dojox/gfx.defaultEllipse,
// dojox/gfx.defaultCircle,
// dojox/gfx.defaultLine,
// or dojox/gfx.defaultImage)
return this.shape; // Object
},
getTransform: function(){
// summary:
// Returns the current transformation matrix applied to this Shape or null
return this.matrix; // dojox/gfx/matrix.Matrix2D
},
getFill: function(){
// summary:
// Returns the current fill object or null
// (see dojox/gfx.defaultLinearGradient,
// dojox/gfx.defaultRadialGradient,
// dojox/gfx.defaultPattern,
// or dojo/Color)
return this.fillStyle; // Object
},
getStroke: function(){
// summary:
// Returns the current stroke object or null
// (see dojox/gfx.defaultStroke)
return this.strokeStyle; // Object
},
getParent: function(){
// summary:
// Returns the parent Shape, Group or null if this Shape is unparented.
// (see dojox/gfx/shape.Surface,
// or dojox/gfx.Group)
return this.parent; // Object
},
getBoundingBox: function(){
// summary:
// Returns the bounding box Rectangle for this shape or null if a BoundingBox cannot be
// calculated for the shape on the current renderer or for shapes with no geometric area (points).
// A bounding box is a rectangular geometric region
// defining the X and Y extent of the shape.
// (see dojox/gfx.defaultRect)
// Note that this method returns a direct reference to the attribute of this instance. Therefore you should
// not modify its value directly but clone it instead.
return this.bbox; // dojox/gfx.Rectangle
},
getTransformedBoundingBox: function(){
// summary:
// returns an array of four points or null
// four points represent four corners of the untransformed bounding box
var b = this.getBoundingBox();
if(!b){
return null; // null
}
var m = this._getRealMatrix(),
gm = matrixLib;
return [ // Array
gm.multiplyPoint(m, b.x, b.y),
gm.multiplyPoint(m, b.x + b.width, b.y),
gm.multiplyPoint(m, b.x + b.width, b.y + b.height),
gm.multiplyPoint(m, b.x, b.y + b.height)
];
},
getEventSource: function(){
// summary:
// returns a Node, which is used as
// a source of events for this shape
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
return this.rawNode; // Node
},
// empty settings
setClip: function(clip){
// summary:
// sets the clipping area of this shape.
// description:
// The clipping area defines the shape area that will be effectively visible. Everything that
// would be drawn outside of the clipping area will not be rendered.
// The possible clipping area types are rectangle, ellipse, polyline and path, but all are not
// supported by all the renderers. vml only supports rectangle clipping, while the gfx silverlight renderer does not
// support path clipping.
// The clip parameter defines the clipping area geometry, and should be an object with the following properties:
//
// - {x:Number, y:Number, width:Number, height:Number} for rectangular clip
// - {cx:Number, cy:Number, rx:Number, ry:Number} for ellipse clip
// - {points:Array} for polyline clip
// - {d:String} for a path clip.
//
// The clip geometry coordinates are expressed in the coordinate system used to draw the shape. In other
// words, the clipping area is defined in the shape parent coordinate system and the shape transform is automatically applied.
// example:
// The following example shows how to clip a gfx image with all the possible clip geometry: a rectangle,
// an ellipse, a circle (using the ellipse geometry), a polyline and a path:
//
// | surface.createImage({src:img, width:200,height:200}).setClip({x:10,y:10,width:50,height:50});
// | surface.createImage({src:img, x:100,y:50,width:200,height:200}).setClip({cx:200,cy:100,rx:20,ry:30});
// | surface.createImage({src:img, x:0,y:350,width:200,height:200}).setClip({cx:100,cy:425,rx:60,ry:60});
// | surface.createImage({src:img, x:300,y:0,width:200,height:200}).setClip({points:[350,0,450,50,380,130,300,110]});
// | surface.createImage({src:img, x:300,y:350,width:200,height:200}).setClip({d:"M 350,350 C314,414 317,557 373,450.0000 z"});
// clip: Object
// an object that defines the clipping geometry, or null to remove clip.
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
this.clip = clip;
},
getClip: function(){
return this.clip;
},
setShape: function(shape){
// summary:
// sets a shape object
// (the default implementation simply ignores it)
// shape: Object
// a shape object
// (see dojox/gfx.defaultPath,
// dojox/gfx.defaultPolyline,
// dojox/gfx.defaultRect,
// dojox/gfx.defaultEllipse,
// dojox/gfx.defaultCircle,
// dojox/gfx.defaultLine,
// or dojox/gfx.defaultImage)
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
this.shape = g.makeParameters(this.shape, shape);
this.bbox = null;
return this; // self
},
setFill: function(fill){
// summary:
// sets a fill object
// (the default implementation simply ignores it)
// fill: Object
// a fill object
// (see dojox/gfx.defaultLinearGradient,
// dojox/gfx.defaultRadialGradient,
// dojox/gfx.defaultPattern,
// or dojo/_base/Color)
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
if(!fill){
// don't fill
this.fillStyle = null;
return this; // self
}
var f = null;
if(typeof(fill) == "object" && "type" in fill){
// gradient or pattern
switch(fill.type){
case "linear":
f = g.makeParameters(g.defaultLinearGradient, fill);
break;
case "radial":
f = g.makeParameters(g.defaultRadialGradient, fill);
break;
case "pattern":
f = g.makeParameters(g.defaultPattern, fill);
break;
}
}else{
// color object
f = g.normalizeColor(fill);
}
this.fillStyle = f;
return this; // self
},
setStroke: function(stroke){
// summary:
// sets a stroke object
// (the default implementation simply ignores it)
// stroke: Object
// a stroke object
// (see dojox/gfx.defaultStroke)
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
if(!stroke){
// don't stroke
this.strokeStyle = null;
return this; // self
}
// normalize the stroke
if(typeof stroke == "string" || lang.isArray(stroke) || stroke instanceof Color){
stroke = {color: stroke};
}
var s = this.strokeStyle = g.makeParameters(g.defaultStroke, stroke);
s.color = g.normalizeColor(s.color);
return this; // self
},
setTransform: function(matrix){
// summary:
// sets a transformation matrix
// matrix: dojox/gfx/matrix.Matrix2D
// a matrix or a matrix-like object
// (see an argument of dojox/gfx/matrix.Matrix2D
// constructor for a list of acceptable arguments)
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
this.matrix = matrixLib.clone(matrix ? matrixLib.normalize(matrix) : matrixLib.identity);
return this._applyTransform(); // self
},
_applyTransform: function(){
// summary:
// physically sets a matrix
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
return this; // self
},
// z-index
moveToFront: function(){
// summary:
// moves a shape to front of its parent's list of shapes
var p = this.getParent();
if(p){
p._moveChildToFront(this);
this._moveToFront(); // execute renderer-specific action
}
return this; // self
},
moveToBack: function(){
// summary:
// moves a shape to back of its parent's list of shapes
var p = this.getParent();
if(p){
p._moveChildToBack(this);
this._moveToBack(); // execute renderer-specific action
}
return this;
},
_moveToFront: function(){
// summary:
// renderer-specific hook, see dojox/gfx/shape.Shape.moveToFront()
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
},
_moveToBack: function(){
// summary:
// renderer-specific hook, see dojox/gfx/shape.Shape.moveToFront()
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
},
// apply left & right transformation
applyRightTransform: function(matrix){
// summary:
// multiplies the existing matrix with an argument on right side
// (this.matrix * matrix)
// matrix: dojox/gfx/matrix.Matrix2D
// a matrix or a matrix-like object
// (see an argument of dojox/gfx/matrix.Matrix2D
// constructor for a list of acceptable arguments)
return matrix ? this.setTransform([this.matrix, matrix]) : this; // self
},
applyLeftTransform: function(matrix){
// summary:
// multiplies the existing matrix with an argument on left side
// (matrix * this.matrix)
// matrix: dojox/gfx/matrix.Matrix2D
// a matrix or a matrix-like object
// (see an argument of dojox/gfx/matrix.Matrix2D
// constructor for a list of acceptable arguments)
return matrix ? this.setTransform([matrix, this.matrix]) : this; // self
},
applyTransform: function(matrix){
// summary:
// a shortcut for dojox/gfx/shape.Shape.applyRightTransform
// matrix: dojox/gfx/matrix.Matrix2D
// a matrix or a matrix-like object
// (see an argument of dojox/gfx/matrix.Matrix2D
// constructor for a list of acceptable arguments)
return matrix ? this.setTransform([this.matrix, matrix]) : this; // self
},
// virtual group methods
removeShape: function(silently){
// summary:
// removes the shape from its parent's list of shapes
// silently: Boolean
// if true, do not redraw a picture yet
if(this.parent){
this.parent.remove(this, silently);
}
return this; // self
},
_setParent: function(parent, matrix){
// summary:
// sets a parent
// parent: Object
// a parent or null
// (see dojox/gfx/shape.Surface,
// or dojox/gfx.Group)
// matrix: dojox/gfx/matrix.Matrix2D
// a 2D matrix or a matrix-like object
this.parent = parent;
return this._updateParentMatrix(matrix); // self
},
_updateParentMatrix: function(matrix){
// summary:
// updates the parent matrix with new matrix
// matrix: dojox/gfx/Matrix2D
// a 2D matrix or a matrix-like object
this.parentMatrix = matrix ? matrixLib.clone(matrix) : null;
return this._applyTransform(); // self
},
_getRealMatrix: function(){
// summary:
// returns the cumulative ('real') transformation matrix
// by combining the shape's matrix with its parent's matrix
var m = this.matrix;
var p = this.parent;
while(p){
if(p.matrix){
m = matrixLib.multiply(p.matrix, m);
}
p = p.parent;
}
return m; // dojox/gfx/matrix.Matrix2D
}
});
shape._eventsProcessing = {
on: function(type, listener){
// summary:
// Connects an event to this shape.
return on(this.getEventSource(), type, shape.fixCallback(this, g.fixTarget, listener));
},
connect: function(name, object, method){
// summary:
// connects a handler to an event on this shape
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
// redirect to fixCallback to normalize events and add the gfxTarget to the event. The latter
// is done by dojox/gfx.fixTarget which is defined by each renderer
if(name.substring(0, 2) == "on"){
name = name.substring(2);
}
return this.on(name, method ? lang.hitch(object, method) : object);
},
disconnect: function(token){
// summary:
// connects a handler by token from an event on this shape
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
return token.remove();
}
};
shape.fixCallback = function(gfxElement, fixFunction, scope, method){
// summary:
// Wraps the callback to allow for tests and event normalization
// before it gets invoked. This is where 'fixTarget' is invoked.
// tags:
// private
// gfxElement: Object
// The GFX object that triggers the action (ex.:
// dojox/gfx.Surface and dojox/gfx/shape.Shape). A new event property
// 'gfxTarget' is added to the event to reference this object.
// for easy manipulation of GFX objects by the event handlers.
// fixFunction: Function
// The function that implements the logic to set the 'gfxTarget'
// property to the event. It should be 'dojox/gfx.fixTarget' for
// most of the cases
// scope: Object
// Optional. The scope to be used when invoking 'method'. If
// omitted, a global scope is used.
// method: Function|String
// The original callback to be invoked.
if(!method){
method = scope;
scope = null;
}
if(lang.isString(method)){
scope = scope || kernel.global;
if(!scope[method]){ throw(['dojox.gfx.shape.fixCallback: scope["', method, '"] is null (scope="', scope, '")'].join('')); }
return function(e){
return fixFunction(e,gfxElement) ? scope[method].apply(scope, arguments || []) : undefined; }; // Function
}
return !scope
? function(e){
return fixFunction(e,gfxElement) ? method.apply(scope, arguments) : undefined; }
: function(e){
return fixFunction(e,gfxElement) ? method.apply(scope, arguments || []) : undefined; }; // Function
};
lang.extend(shape.Shape, shape._eventsProcessing);
shape.Container = {
// summary:
// a container of shapes, which can be used
// as a foundation for renderer-specific groups, or as a way
// to logically group shapes (e.g, to propagate matricies)
_init: function() {
// children: Array
// a list of children
this.children = [];
this._batch = 0;
},
// group management
openBatch: function() {
// summary:
// starts a new batch, subsequent new child shapes will be held in
// the batch instead of appending to the container directly.
// description:
// Because the canvas renderer has no DOM hierarchy, the canvas implementation differs
// such that it suspends the repaint requests for this container until the current batch is closed by a call to closeBatch().
return this;
},
closeBatch: function() {
// summary:
// submits the current batch, append all pending child shapes to DOM
// description:
// On canvas, this method flushes the pending redraws queue.
return this;
},
add: function(shape){
// summary:
// adds a shape to the list
// shape: dojox/gfx/shape.Shape
// the shape to add to the list
var oldParent = shape.getParent();
if(oldParent){
oldParent.remove(shape, true);
}
this.children.push(shape);
return shape._setParent(this, this._getRealMatrix()); // self
},
remove: function(shape, silently){
// summary:
// removes a shape from the list
// shape: dojox/gfx/shape.Shape
// the shape to remove
// silently: Boolean
// if true, do not redraw a picture yet
for(var i = 0; i < this.children.length; ++i){
if(this.children[i] == shape){
if(silently){
// skip for now
}else{
shape.parent = null;
shape.parentMatrix = null;
}
removeItemAt(this.children, i);
break;
}
}
return this; // self
},
clear: function(/*Boolean?*/ destroy){
// summary:
// removes all shapes from a group/surface.
// destroy: Boolean
// Indicates whether the children should be destroyed. Optional.
var shape;
for(var i = 0; i < this.children.length;++i){
shape = this.children[i];
shape.parent = null;
shape.parentMatrix = null;
if(destroy){
shape.destroy();
}
}
this.children = [];
return this; // self
},
getBoundingBox: function(){
// summary:
// Returns the bounding box Rectangle for this shape.
if(this.children){
// if this is a composite shape, then sum up all the children
var result = null;
arr.forEach(this.children, function(shape){
var bb = shape.getBoundingBox();
if(bb){
var ct = shape.getTransform();
if(ct){
bb = matrixLib.multiplyRectangle(ct, bb);
}
if(result){
// merge two bbox
result.x = Math.min(result.x, bb.x);
result.y = Math.min(result.y, bb.y);
result.endX = Math.max(result.endX, bb.x + bb.width);
result.endY = Math.max(result.endY, bb.y + bb.height);
}else{
// first bbox
result = {
x: bb.x,
y: bb.y,
endX: bb.x + bb.width,
endY: bb.y + bb.height
};
}
}
});
if(result){
result.width = result.endX - result.x;
result.height = result.endY - result.y;
}
return result; // dojox/gfx.Rectangle
}
// unknown/empty bounding box, subclass shall override this impl
return null;
},
// moving child nodes
_moveChildToFront: function(shape){
// summary:
// moves a shape to front of the list of shapes
// shape: dojox/gfx/shape.Shape
// one of the child shapes to move to the front
for(var i = 0; i < this.children.length; ++i){
if(this.children[i] == shape){
removeItemAt(this.children, i);
this.children.push(shape);
break;
}
}
return this; // self
},
_moveChildToBack: function(shape){
// summary:
// moves a shape to back of the list of shapes
// shape: dojox/gfx/shape.Shape
// one of the child shapes to move to the front
for(var i = 0; i < this.children.length; ++i){
if(this.children[i] == shape){
removeItemAt(this.children, i);
this.children.unshift(shape);
break;
}
}
return this; // self
}
};
shape.Surface = declare("dojox.gfx.shape.Surface", null, {
// summary:
// a surface object to be used for drawings
constructor: function(){
// underlying node
this.rawNode = null;
// the parent node
this._parent = null;
// the list of DOM nodes to be deleted in the case of destruction
this._nodes = [];
// the list of events to be detached in the case of destruction
this._events = [];
},
destroy: function(){
// summary:
// destroy all relevant external resources and release all
// external references to make this object garbage-collectible
arr.forEach(this._nodes, domConstruct.destroy);
this._nodes = [];
arr.forEach(this._events, function(h){ if(h){ h.remove(); } });
this._events = [];
this.rawNode = null; // recycle it in _nodes, if it needs to be recycled
if(has("ie")){
while(this._parent.lastChild){
domConstruct.destroy(this._parent.lastChild);
}
}else{
this._parent.innerHTML = "";
}
this._parent = null;
},
getEventSource: function(){
// summary:
// returns a node, which can be used to attach event listeners
return this.rawNode; // Node
},
_getRealMatrix: function(){
// summary:
// always returns the identity matrix
return null; // dojox/gfx/Matrix2D
},
/*=====
setDimensions: function(width, height){
// summary:
// sets the width and height of the rawNode
// width: String
// width of surface, e.g., "100px"
// height: String
// height of surface, e.g., "100px"
return this; // self
},
getDimensions: function(){
// summary:
// gets current width and height in pixels
// returns: Object
// object with properties "width" and "height"
},
=====*/
isLoaded: true,
onLoad: function(/*dojox/gfx/shape.Surface*/ surface){
// summary:
// local event, fired once when the surface is created
// asynchronously, used only when isLoaded is false, required
// only for Silverlight.
},
whenLoaded: function(/*Object|Null*/ context, /*Function|String*/ method){
var f = lang.hitch(context, method);
if(this.isLoaded){
f(this);
}else{
on.once(this, "load", function(surface){
f(surface);
});
}
}
});
lang.extend(shape.Surface, shape._eventsProcessing);
/*=====
g.Point = declare("dojox/gfx.Point", null, {
// summary:
// 2D point for drawings - {x, y}
// description:
// Do not use this object directly!
// Use the naked object instead: {x: 1, y: 2}.
});
g.Rectangle = declare("dojox.gfx.Rectangle", null, {
// summary:
// rectangle - {x, y, width, height}
// description:
// Do not use this object directly!
// Use the naked object instead: {x: 1, y: 2, width: 100, height: 200}.
});
=====*/
shape.Rect = declare("dojox.gfx.shape.Rect", shape.Shape, {
// summary:
// a generic rectangle
constructor: function(rawNode){
// rawNode: Node
// The underlying graphics system object (typically a DOM Node)
this.shape = g.getDefault("Rect");
this.rawNode = rawNode;
},
getBoundingBox: function(){
// summary:
// returns the bounding box (its shape in this case)
return this.shape; // dojox/gfx.Rectangle
}
});
shape.Ellipse = declare("dojox.gfx.shape.Ellipse", shape.Shape, {
// summary:
// a generic ellipse
constructor: function(rawNode){
// rawNode: Node
// a DOM Node
this.shape = g.getDefault("Ellipse");
this.rawNode = rawNode;
},
getBoundingBox: function(){
// summary:
// returns the bounding box
if(!this.bbox){
var shape = this.shape;
this.bbox = {x: shape.cx - shape.rx, y: shape.cy - shape.ry,
width: 2 * shape.rx, height: 2 * shape.ry};
}
return this.bbox; // dojox/gfx.Rectangle
}
});
shape.Circle = declare("dojox.gfx.shape.Circle", shape.Shape, {
// summary:
// a generic circle
constructor: function(rawNode){
// rawNode: Node
// a DOM Node
this.shape = g.getDefault("Circle");
this.rawNode = rawNode;
},
getBoundingBox: function(){
// summary:
// returns the bounding box
if(!this.bbox){
var shape = this.shape;
this.bbox = {x: shape.cx - shape.r, y: shape.cy - shape.r,
width: 2 * shape.r, height: 2 * shape.r};
}
return this.bbox; // dojox/gfx.Rectangle
}
});
shape.Line = declare("dojox.gfx.shape.Line", shape.Shape, {
// summary:
// a generic line (do not instantiate it directly)
constructor: function(rawNode){
// rawNode: Node
// a DOM Node
this.shape = g.getDefault("Line");
this.rawNode = rawNode;
},
getBoundingBox: function(){
// summary:
// returns the bounding box
if(!this.bbox){
var shape = this.shape;
this.bbox = {
x: Math.min(shape.x1, shape.x2),
y: Math.min(shape.y1, shape.y2),
width: Math.abs(shape.x2 - shape.x1),
height: Math.abs(shape.y2 - shape.y1)
};
}
return this.bbox; // dojox/gfx.Rectangle
}
});
shape.Polyline = declare("dojox.gfx.shape.Polyline", shape.Shape, {
// summary:
// a generic polyline/polygon (do not instantiate it directly)
constructor: function(rawNode){
// rawNode: Node
// a DOM Node
this.shape = g.getDefault("Polyline");
this.rawNode = rawNode;
},
setShape: function(points, closed){
// summary:
// sets a polyline/polygon shape object
// points: Object|Array
// a polyline/polygon shape object, or an array of points
// closed: Boolean
// close the polyline to make a polygon
if(points && points instanceof Array){
this.inherited(arguments, [{points: points}]);
if(closed && this.shape.points.length){
this.shape.points.push(this.shape.points[0]);
}
}else{
this.inherited(arguments, [points]);
}
return this; // self
},
_normalizePoints: function(){
// summary:
// normalize points to array of {x:number, y:number}
var p = this.shape.points, l = p && p.length;
if(l && typeof p[0] == "number"){
var points = [];
for(var i = 0; i < l; i += 2){
points.push({x: p[i], y: p[i + 1]});
}
this.shape.points = points;
}
},
getBoundingBox: function(){
// summary:
// returns the bounding box
if(!this.bbox && this.shape.points.length){
var p = this.shape.points;
var l = p.length;
var t = p[0];
var bbox = {l: t.x, t: t.y, r: t.x, b: t.y};
for(var i = 1; i < l; ++i){
t = p[i];
if(bbox.l > t.x) bbox.l = t.x;
if(bbox.r < t.x) bbox.r = t.x;
if(bbox.t > t.y) bbox.t = t.y;
if(bbox.b < t.y) bbox.b = t.y;
}
this.bbox = {
x: bbox.l,
y: bbox.t,
width: bbox.r - bbox.l,
height: bbox.b - bbox.t
};
}
return this.bbox; // dojox/gfx.Rectangle
}
});
shape.Image = declare("dojox.gfx.shape.Image", shape.Shape, {
// summary:
// a generic image (do not instantiate it directly)
constructor: function(rawNode){
// rawNode: Node
// a DOM Node
this.shape = g.getDefault("Image");
this.rawNode = rawNode;
},
getBoundingBox: function(){
// summary:
// returns the bounding box (its shape in this case)
return this.shape; // dojox/gfx.Rectangle
},
setStroke: function(){
// summary:
// ignore setting a stroke style
return this; // self
},
setFill: function(){
// summary:
// ignore setting a fill style
return this; // self
}
});
shape.Text = declare(shape.Shape, {
// summary:
// a generic text (do not instantiate it directly)
constructor: function(rawNode){
// rawNode: Node
// a DOM Node
this.fontStyle = null;
this.shape = g.getDefault("Text");
this.rawNode = rawNode;
},
getFont: function(){
// summary:
// returns the current font object or null
return this.fontStyle; // Object
},
setFont: function(newFont){
// summary:
// sets a font for text
// newFont: Object
// a font object (see dojox/gfx.defaultFont) or a font string
this.fontStyle = typeof newFont == "string" ? g.splitFontString(newFont) :
g.makeParameters(g.defaultFont, newFont);
this._setFont();
return this; // self
},
getBoundingBox: function(){
var bbox = null, s = this.getShape();
if(s.text){
bbox = g._base._computeTextBoundingBox(this);
}
return bbox;
}
});
shape.Creator = {
// summary:
// shape creators
createShape: function(shape){
// summary:
// creates a shape object based on its type; it is meant to be used
// by group-like objects
// shape: Object
// a shape descriptor object
// returns: dojox/gfx/shape.Shape | Null
// a fully instantiated surface-specific Shape object
switch(shape.type){
case g.defaultPath.type: return this.createPath(shape);
case g.defaultRect.type: return this.createRect(shape);
case g.defaultCircle.type: return this.createCircle(shape);
case g.defaultEllipse.type: return this.createEllipse(shape);
case g.defaultLine.type: return this.createLine(shape);
case g.defaultPolyline.type: return this.createPolyline(shape);
case g.defaultImage.type: return this.createImage(shape);
case g.defaultText.type: return this.createText(shape);
case g.defaultTextPath.type: return this.createTextPath(shape);
}
return null;
},
createGroup: function(){
// summary:
// creates a group shape
return this.createObject(g.Group); // dojox/gfx/Group
},
createRect: function(rect){
// summary:
// creates a rectangle shape
// rect: Object
// a path object (see dojox/gfx.defaultRect)
return this.createObject(g.Rect, rect); // dojox/gfx/shape.Rect
},
createEllipse: function(ellipse){
// summary:
// creates an ellipse shape
// ellipse: Object
// an ellipse object (see dojox/gfx.defaultEllipse)
return this.createObject(g.Ellipse, ellipse); // dojox/gfx/shape.Ellipse
},
createCircle: function(circle){
// summary:
// creates a circle shape
// circle: Object
// a circle object (see dojox/gfx.defaultCircle)
return this.createObject(g.Circle, circle); // dojox/gfx/shape.Circle
},
createLine: function(line){
// summary:
// creates a line shape
// line: Object
// a line object (see dojox/gfx.defaultLine)
return this.createObject(g.Line, line); // dojox/gfx/shape.Line
},
createPolyline: function(points){
// summary:
// creates a polyline/polygon shape
// points: Object
// a points object (see dojox/gfx.defaultPolyline)
// or an Array of points
return this.createObject(g.Polyline, points); // dojox/gfx/shape.Polyline
},
createImage: function(image){
// summary:
// creates a image shape
// image: Object
// an image object (see dojox/gfx.defaultImage)
return this.createObject(g.Image, image); // dojox/gfx/shape.Image
},
createText: function(text){
// summary:
// creates a text shape
// text: Object
// a text object (see dojox/gfx.defaultText)
return this.createObject(g.Text, text); // dojox/gfx/shape.Text
},
createPath: function(path){
// summary:
// creates a path shape
// path: Object
// a path object (see dojox/gfx.defaultPath)
return this.createObject(g.Path, path); // dojox/gfx/shape.Path
},
createTextPath: function(text){
// summary:
// creates a text shape
// text: Object
// a textpath object (see dojox/gfx.defaultTextPath)
return this.createObject(g.TextPath, {}).setText(text); // dojox/gfx/shape.TextPath
},
createObject: function(shapeType, rawShape){
// summary:
// creates an instance of the passed shapeType class
// shapeType: Function
// a class constructor to create an instance of
// rawShape: Object
// properties to be passed in to the classes 'setShape' method
// SHOULD BE RE-IMPLEMENTED BY THE RENDERER!
return null; // dojox/gfx/shape.Shape
}
};
/*=====
lang.extend(shape.Surface, shape.Container);
lang.extend(shape.Surface, shape.Creator);
g.Group = declare(shape.Shape, {
// summary:
// a group shape, which can be used
// to logically group shapes (e.g, to propagate matricies)
});
lang.extend(g.Group, shape.Container);
lang.extend(g.Group, shape.Creator);
g.Rect = shape.Rect;
g.Circle = shape.Circle;
g.Ellipse = shape.Ellipse;
g.Line = shape.Line;
g.Polyline = shape.Polyline;
g.Text = shape.Text;
g.Surface = shape.Surface;
=====*/
return shape;
});
},
'dojox/gfx/matrix':function(){
define(["./_base","dojo/_base/lang"],
function(g, lang){
var m = g.matrix = {};
// candidates for dojox.math:
var _degToRadCache = {};
m._degToRad = function(degree){
return _degToRadCache[degree] || (_degToRadCache[degree] = (Math.PI * degree / 180));
};
m._radToDeg = function(radian){ return radian / Math.PI * 180; };
m.Matrix2D = function(arg){
// summary:
// a 2D matrix object
// description:
// Normalizes a 2D matrix-like object. If arrays is passed,
// all objects of the array are normalized and multiplied sequentially.
// arg: Object
// a 2D matrix-like object, a number, or an array of such objects
if(arg){
if(typeof arg == "number"){
this.xx = this.yy = arg;
}else if(arg instanceof Array){
if(arg.length > 0){
var matrix = m.normalize(arg[0]);
// combine matrices
for(var i = 1; i < arg.length; ++i){
var l = matrix, r = m.normalize(arg[i]);
matrix = new m.Matrix2D();
matrix.xx = l.xx * r.xx + l.xy * r.yx;
matrix.xy = l.xx * r.xy + l.xy * r.yy;
matrix.yx = l.yx * r.xx + l.yy * r.yx;
matrix.yy = l.yx * r.xy + l.yy * r.yy;
matrix.dx = l.xx * r.dx + l.xy * r.dy + l.dx;
matrix.dy = l.yx * r.dx + l.yy * r.dy + l.dy;
}
lang.mixin(this, matrix);
}
}else{
lang.mixin(this, arg);
}
}
};
// the default (identity) matrix, which is used to fill in missing values
lang.extend(m.Matrix2D, {xx: 1, xy: 0, yx: 0, yy: 1, dx: 0, dy: 0});
lang.mixin(m, {
// summary:
// class constants, and methods of dojox/gfx/matrix
// matrix constants
// identity: dojox/gfx/matrix.Matrix2D
// an identity matrix constant: identity * (x, y) == (x, y)
identity: new m.Matrix2D(),
// flipX: dojox/gfx/matrix.Matrix2D
// a matrix, which reflects points at x = 0 line: flipX * (x, y) == (-x, y)
flipX: new m.Matrix2D({xx: -1}),
// flipY: dojox/gfx/matrix.Matrix2D
// a matrix, which reflects points at y = 0 line: flipY * (x, y) == (x, -y)
flipY: new m.Matrix2D({yy: -1}),
// flipXY: dojox/gfx/matrix.Matrix2D
// a matrix, which reflects points at the origin of coordinates: flipXY * (x, y) == (-x, -y)
flipXY: new m.Matrix2D({xx: -1, yy: -1}),
// matrix creators
translate: function(a, b){
// summary:
// forms a translation matrix
// description:
// The resulting matrix is used to translate (move) points by specified offsets.
// a: Number|dojox/gfx.Point
// an x coordinate value, or a point-like object, which specifies offsets for both dimensions
// b: Number?
// a y coordinate value
// returns: dojox/gfx/matrix.Matrix2D
if(arguments.length > 1){
return new m.Matrix2D({dx: a, dy: b}); // dojox/gfx/matrix.Matrix2D
}
// branch
return new m.Matrix2D({dx: a.x, dy: a.y}); // dojox/gfx/matrix.Matrix2D
},
scale: function(a, b){
// summary:
// forms a scaling matrix
// description:
// The resulting matrix is used to scale (magnify) points by specified offsets.
// a: Number|dojox/gfx.Point
// a scaling factor used for the x coordinate, or
// a uniform scaling factor used for the both coordinates, or
// a point-like object, which specifies scale factors for both dimensions
// b: Number?
// a scaling factor used for the y coordinate
// returns: dojox/gfx/matrix.Matrix2D
if(arguments.length > 1){
return new m.Matrix2D({xx: a, yy: b}); // dojox/gfx/matrix.Matrix2D
}
if(typeof a == "number"){
return new m.Matrix2D({xx: a, yy: a}); // dojox/gfx/matrix.Matrix2D
}
return new m.Matrix2D({xx: a.x, yy: a.y}); // dojox/gfx/matrix.Matrix2D
},
rotate: function(angle){
// summary:
// forms a rotating matrix
// description:
// The resulting matrix is used to rotate points
// around the origin of coordinates (0, 0) by specified angle.
// angle: Number
// an angle of rotation in radians (>0 for CW)
// returns: dojox/gfx/matrix.Matrix2D
var c = Math.cos(angle);
var s = Math.sin(angle);
return new m.Matrix2D({xx: c, xy: -s, yx: s, yy: c}); // dojox/gfx/matrix.Matrix2D
},
rotateg: function(degree){
// summary:
// forms a rotating matrix
// description:
// The resulting matrix is used to rotate points
// around the origin of coordinates (0, 0) by specified degree.
// See dojox/gfx/matrix.rotate() for comparison.
// degree: Number
// an angle of rotation in degrees (>0 for CW)
// returns: dojox/gfx/matrix.Matrix2D
return m.rotate(m._degToRad(degree)); // dojox/gfx/matrix.Matrix2D
},
skewX: function(angle) {
// summary:
// forms an x skewing matrix
// description:
// The resulting matrix is used to skew points in the x dimension
// around the origin of coordinates (0, 0) by specified angle.
// angle: Number
// a skewing angle in radians
// returns: dojox/gfx/matrix.Matrix2D
return new m.Matrix2D({xy: Math.tan(angle)}); // dojox/gfx/matrix.Matrix2D
},
skewXg: function(degree){
// summary:
// forms an x skewing matrix
// description:
// The resulting matrix is used to skew points in the x dimension
// around the origin of coordinates (0, 0) by specified degree.
// See dojox/gfx/matrix.skewX() for comparison.
// degree: Number
// a skewing angle in degrees
// returns: dojox/gfx/matrix.Matrix2D
return m.skewX(m._degToRad(degree)); // dojox/gfx/matrix.Matrix2D
},
skewY: function(angle){
// summary:
// forms a y skewing matrix
// description:
// The resulting matrix is used to skew points in the y dimension
// around the origin of coordinates (0, 0) by specified angle.
// angle: Number
// a skewing angle in radians
// returns: dojox/gfx/matrix.Matrix2D
return new m.Matrix2D({yx: Math.tan(angle)}); // dojox/gfx/matrix.Matrix2D
},
skewYg: function(degree){
// summary:
// forms a y skewing matrix
// description:
// The resulting matrix is used to skew points in the y dimension
// around the origin of coordinates (0, 0) by specified degree.
// See dojox/gfx/matrix.skewY() for comparison.
// degree: Number
// a skewing angle in degrees
// returns: dojox/gfx/matrix.Matrix2D
return m.skewY(m._degToRad(degree)); // dojox/gfx/matrix.Matrix2D
},
reflect: function(a, b){
// summary:
// forms a reflection matrix
// description:
// The resulting matrix is used to reflect points around a vector,
// which goes through the origin.
// a: dojox/gfx.Point|Number
// a point-like object, which specifies a vector of reflection, or an X value
// b: Number?
// a Y value
// returns: dojox/gfx/matrix.Matrix2D
if(arguments.length == 1){
b = a.y;
a = a.x;
}
// make a unit vector
var a2 = a * a, b2 = b * b, n2 = a2 + b2, xy = 2 * a * b / n2;
return new m.Matrix2D({xx: 2 * a2 / n2 - 1, xy: xy, yx: xy, yy: 2 * b2 / n2 - 1}); // dojox/gfx/matrix.Matrix2D
},
project: function(a, b){
// summary:
// forms an orthogonal projection matrix
// description:
// The resulting matrix is used to project points orthogonally on a vector,
// which goes through the origin.
// a: dojox/gfx.Point|Number
// a point-like object, which specifies a vector of projection, or
// an x coordinate value
// b: Number?
// a y coordinate value
// returns: dojox/gfx/matrix.Matrix2D
if(arguments.length == 1){
b = a.y;
a = a.x;
}
// make a unit vector
var a2 = a * a, b2 = b * b, n2 = a2 + b2, xy = a * b / n2;
return new m.Matrix2D({xx: a2 / n2, xy: xy, yx: xy, yy: b2 / n2}); // dojox/gfx/matrix.Matrix2D
},
// ensure matrix 2D conformance
normalize: function(matrix){
// summary:
// converts an object to a matrix, if necessary
// description:
// Converts any 2D matrix-like object or an array of
// such objects to a valid dojox/gfx/matrix.Matrix2D object.
// matrix: Object
// an object, which is converted to a matrix, if necessary
// returns: dojox/gfx/matrix.Matrix2D
return (matrix instanceof m.Matrix2D) ? matrix : new m.Matrix2D(matrix); // dojox/gfx/matrix.Matrix2D
},
// common operations
isIdentity: function(matrix){
// summary:
// returns whether the specified matrix is the identity.
// matrix: dojox/gfx/matrix.Matrix2D
// a 2D matrix object to be tested
// returns: Boolean
return matrix.xx == 1 && matrix.xy == 0 && matrix.yx == 0 && matrix.yy == 1 && matrix.dx == 0 && matrix.dy == 0; // Boolean
},
clone: function(matrix){
// summary:
// creates a copy of a 2D matrix
// matrix: dojox/gfx/matrix.Matrix2D
// a 2D matrix-like object to be cloned
// returns: dojox/gfx/matrix.Matrix2D
var obj = new m.Matrix2D();
for(var i in matrix){
if(typeof(matrix[i]) == "number" && typeof(obj[i]) == "number" && obj[i] != matrix[i]) obj[i] = matrix[i];
}
return obj; // dojox/gfx/matrix.Matrix2D
},
invert: function(matrix){
// summary:
// inverts a 2D matrix
// matrix: dojox/gfx/matrix.Matrix2D
// a 2D matrix-like object to be inverted
// returns: dojox/gfx/matrix.Matrix2D
var M = m.normalize(matrix),
D = M.xx * M.yy - M.xy * M.yx;
M = new m.Matrix2D({
xx: M.yy/D, xy: -M.xy/D,
yx: -M.yx/D, yy: M.xx/D,
dx: (M.xy * M.dy - M.yy * M.dx) / D,
dy: (M.yx * M.dx - M.xx * M.dy) / D
});
return M; // dojox/gfx/matrix.Matrix2D
},
_multiplyPoint: function(matrix, x, y){
// summary:
// applies a matrix to a point
// matrix: dojox/gfx/matrix.Matrix2D
// a 2D matrix object to be applied
// x: Number
// an x coordinate of a point
// y: Number
// a y coordinate of a point
// returns: dojox/gfx.Point
return {x: matrix.xx * x + matrix.xy * y + matrix.dx, y: matrix.yx * x + matrix.yy * y + matrix.dy}; // dojox/gfx.Point
},
multiplyPoint: function(matrix, /* Number||Point */ a, /* Number? */ b){
// summary:
// applies a matrix to a point
// matrix: dojox/gfx/matrix.Matrix2D
// a 2D matrix object to be applied
// a: Number|dojox/gfx.Point
// an x coordinate of a point, or a point
// b: Number?
// a y coordinate of a point
// returns: dojox/gfx.Point
var M = m.normalize(matrix);
if(typeof a == "number" && typeof b == "number"){
return m._multiplyPoint(M, a, b); // dojox/gfx.Point
}
return m._multiplyPoint(M, a.x, a.y); // dojox/gfx.Point
},
multiplyRectangle: function(matrix, /*Rectangle*/ rect){
// summary:
// Applies a matrix to a rectangle.
// description:
// The method applies the transformation on all corners of the
// rectangle and returns the smallest rectangle enclosing the 4 transformed
// points.
// matrix: dojox/gfx/matrix.Matrix2D
// a 2D matrix object to be applied.
// rect: Rectangle
// the rectangle to transform.
// returns: dojox/gfx.Rectangle
var M = m.normalize(matrix);
rect = rect || {x:0, y:0, width:0, height:0};
if(m.isIdentity(M))
return {x: rect.x, y: rect.y, width: rect.width, height: rect.height}; // dojo/gfx.Rectangle
var p0 = m.multiplyPoint(M, rect.x, rect.y),
p1 = m.multiplyPoint(M, rect.x, rect.y + rect.height),
p2 = m.multiplyPoint(M, rect.x + rect.width, rect.y),
p3 = m.multiplyPoint(M, rect.x + rect.width, rect.y + rect.height),
minx = Math.min(p0.x, p1.x, p2.x, p3.x),
miny = Math.min(p0.y, p1.y, p2.y, p3.y),
maxx = Math.max(p0.x, p1.x, p2.x, p3.x),
maxy = Math.max(p0.y, p1.y, p2.y, p3.y);
return{ // dojo/gfx.Rectangle
x: minx,
y: miny,
width: maxx - minx,
height: maxy - miny
};
},
multiply: function(matrix){
// summary:
// combines matrices by multiplying them sequentially in the given order
// matrix: dojox/gfx/matrix.Matrix2D
// a 2D matrix-like object,
// all subsequent arguments are matrix-like objects too
var M = m.normalize(matrix);
// combine matrices
for(var i = 1; i < arguments.length; ++i){
var l = M, r = m.normalize(arguments[i]);
M = new m.Matrix2D();
M.xx = l.xx * r.xx + l.xy * r.yx;
M.xy = l.xx * r.xy + l.xy * r.yy;
M.yx = l.yx * r.xx + l.yy * r.yx;
M.yy = l.yx * r.xy + l.yy * r.yy;
M.dx = l.xx * r.dx + l.xy * r.dy + l.dx;
M.dy = l.yx * r.dx + l.yy * r.dy + l.dy;
}
return M; // dojox/gfx/matrix.Matrix2D
},
// high level operations
_sandwich: function(matrix, x, y){
// summary:
// applies a matrix at a central point
// matrix: dojox/gfx/matrix.Matrix2D
// a 2D matrix-like object, which is applied at a central point
// x: Number
// an x component of the central point
// y: Number
// a y component of the central point
return m.multiply(m.translate(x, y), matrix, m.translate(-x, -y)); // dojox/gfx/matrix.Matrix2D
},
scaleAt: function(a, b, c, d){
// summary:
// scales a picture using a specified point as a center of scaling
// description:
// Compare with dojox/gfx/matrix.scale().
// a: Number
// a scaling factor used for the x coordinate, or a uniform scaling factor used for both coordinates
// b: Number?
// a scaling factor used for the y coordinate
// c: Number|Point
// an x component of a central point, or a central point
// d: Number
// a y component of a central point
// returns: dojox/gfx/matrix.Matrix2D
switch(arguments.length){
case 4:
// a and b are scale factor components, c and d are components of a point
return m._sandwich(m.scale(a, b), c, d); // dojox/gfx/matrix.Matrix2D
case 3:
if(typeof c == "number"){
return m._sandwich(m.scale(a), b, c); // dojox/gfx/matrix.Matrix2D
}
return m._sandwich(m.scale(a, b), c.x, c.y); // dojox/gfx/matrix.Matrix2D
}
return m._sandwich(m.scale(a), b.x, b.y); // dojox/gfx/matrix.Matrix2D
},
rotateAt: function(angle, a, b){
// summary:
// rotates a picture using a specified point as a center of rotation
// description:
// Compare with dojox/gfx/matrix.rotate().
// angle: Number
// an angle of rotation in radians (>0 for CW)
// a: Number|dojox/gfx.Point
// an x component of a central point, or a central point
// b: Number?
// a y component of a central point
// returns: dojox/gfx/matrix.Matrix2D
if(arguments.length > 2){
return m._sandwich(m.rotate(angle), a, b); // dojox/gfx/matrix.Matrix2D
}
return m._sandwich(m.rotate(angle), a.x, a.y); // dojox/gfx/matrix.Matrix2D
},
rotategAt: function(degree, a, b){
// summary:
// rotates a picture using a specified point as a center of rotation
// description:
// Compare with dojox/gfx/matrix.rotateg().
// degree: Number
// an angle of rotation in degrees (>0 for CW)
// a: Number|dojox/gfx.Point
// an x component of a central point, or a central point
// b: Number?
// a y component of a central point
// returns: dojox/gfx/matrix.Matrix2D
if(arguments.length > 2){
return m._sandwich(m.rotateg(degree), a, b); // dojox/gfx/matrix.Matrix2D
}
return m._sandwich(m.rotateg(degree), a.x, a.y); // dojox/gfx/matrix.Matrix2D
},
skewXAt: function(angle, a, b){
// summary:
// skews a picture along the x axis using a specified point as a center of skewing
// description:
// Compare with dojox/gfx/matrix.skewX().
// angle: Number
// a skewing angle in radians
// a: Number|dojox/gfx.Point
// an x component of a central point, or a central point
// b: Number?
// a y component of a central point
// returns: dojox/gfx/matrix.Matrix2D
if(arguments.length > 2){
return m._sandwich(m.skewX(angle), a, b); // dojox/gfx/matrix.Matrix2D
}
return m._sandwich(m.skewX(angle), a.x, a.y); // dojox/gfx/matrix.Matrix2D
},
skewXgAt: function(degree, a, b){
// summary:
// skews a picture along the x axis using a specified point as a center of skewing
// description:
// Compare with dojox/gfx/matrix.skewXg().
// degree: Number
// a skewing angle in degrees
// a: Number|dojox/gfx.Point
// an x component of a central point, or a central point
// b: Number?
// a y component of a central point
// returns: dojox/gfx/matrix.Matrix2D
if(arguments.length > 2){
return m._sandwich(m.skewXg(degree), a, b); // dojox/gfx/matrix.Matrix2D
}
return m._sandwich(m.skewXg(degree), a.x, a.y); // dojox/gfx/matrix.Matrix2D
},
skewYAt: function(angle, a, b){
// summary:
// skews a picture along the y axis using a specified point as a center of skewing
// description:
// Compare with dojox/gfx/matrix.skewY().
// angle: Number
// a skewing angle in radians
// a: Number|dojox/gfx.Point
// an x component of a central point, or a central point
// b: Number?
// a y component of a central point
// returns: dojox/gfx/matrix.Matrix2D
if(arguments.length > 2){
return m._sandwich(m.skewY(angle), a, b); // dojox/gfx/matrix.Matrix2D
}
return m._sandwich(m.skewY(angle), a.x, a.y); // dojox/gfx/matrix.Matrix2D
},
skewYgAt: function(/* Number */ degree, /* Number||Point */ a, /* Number? */ b){
// summary:
// skews a picture along the y axis using a specified point as a center of skewing
// description:
// Compare with dojox/gfx/matrix.skewYg().
// degree: Number
// a skewing angle in degrees
// a: Number|dojox/gfx.Point
// an x component of a central point, or a central point
// b: Number?
// a y component of a central point
// returns: dojox/gfx/matrix.Matrix2D
if(arguments.length > 2){
return m._sandwich(m.skewYg(degree), a, b); // dojox/gfx/matrix.Matrix2D
}
return m._sandwich(m.skewYg(degree), a.x, a.y); // dojox/gfx/matrix.Matrix2D
}
//TODO: rect-to-rect mapping, scale-to-fit (isotropic and anisotropic versions)
});
// propagate Matrix2D up
g.Matrix2D = m.Matrix2D;
return m;
});
},
'dojox/charting/SimpleTheme':function(){
define(["dojo/_base/lang", "dojo/_base/array","dojo/_base/declare","dojo/_base/Color", "dojox/lang/utils", "dojox/gfx/gradutils"],
function(lang, arr, declare, Color, dlu, dgg){
var SimpleTheme = declare("dojox.charting.SimpleTheme", null, {
// summary:
// A SimpleTheme or Theme is a pre-defined object, primarily JSON-based, that makes up the definitions to
// style a chart.
//
// description:
// While you can set up style definitions on a chart directly (usually through the various add methods
// on a dojox.charting.Chart object), a Theme simplifies this manual setup by allowing you to
// pre-define all of the various visual parameters of each element in a chart.
//
// Most of the properties of a Theme are straight-forward; if something is line-based (such as
// an axis or the ticks on an axis), they will be defined using basic stroke parameters. Likewise,
// if an element is primarily block-based (such as the background of a chart), it will be primarily
// fill-based.
//
// In addition (for convenience), a Theme definition does not have to contain the entire JSON-based
// structure. Each theme is built on top of a default theme (which serves as the basis for the theme
// "GreySkies"), and is mixed into the default theme object. This allows you to create a theme based,
// say, solely on colors for data series.
//
// Defining a new theme is relatively easy; see any of the themes in dojox.charting.themes for examples
// on how to define your own.
//
// When you set a theme on a chart, the theme itself is deep-cloned. This means that you cannot alter
// the theme itself after setting the theme value on a chart, and expect it to change your chart. If you
// are looking to make alterations to a theme for a chart, the suggestion would be to create your own
// theme, based on the one you want to use, that makes those alterations before it is applied to a chart.
//
// Finally, a Theme contains a number of functions to facilitate rendering operations on a chart--the main
// helper of which is the ~next~ method, in which a chart asks for the information for the next data series
// to be rendered.
//
// A note on colors:
// A theme palette is usually comprised of 5 different color definitions, and
// no more. If you have a need to render a chart with more than 5 data elements, you can simply "push"
// new color definitions into the theme's .color array. Make sure that you do that with the actual
// theme object from a Chart, and not in the theme itself (i.e. either do that before using .setTheme
// on a chart).
//
// example:
// The default theme (and structure) looks like so:
// | // all objects are structs used directly in dojox.gfx
// | chart:{
// | margins: {l: 10, t: 10, r: 10, b: 10},
// | stroke: null,
// | fill: "white",
// | pageStyle: null // suggested page style as an object suitable for dojo.style()
// | },
// | plotarea:{
// | stroke: null,
// | fill: "white"
// | },
// | axis:{
// | stroke: { // the axis itself
// | color: "#333",
// | width: 1
// | },
// | tick: { // used as a foundation for all ticks
// | color: "#666",
// | position: "center",
// | font: "normal normal normal 7pt Tahoma", // labels on axis
// | fontColor: "#333" // color of labels
// | },
// | majorTick: { // major ticks on axis, and used for major gridlines
// | width: 1,
// | length: 6
// | },
// | minorTick: { // minor ticks on axis, and used for minor gridlines
// | width: 0.8,
// | length: 3
// | },
// | microTick: { // minor ticks on axis, and used for minor gridlines
// | width: 0.5,
// | length: 1
// | },
// | title: {
// | gap: 15,
// | font: "normal normal normal 11pt Tahoma", // title font
// | fontColor: "#333", // title font color
// | orientation: "axis" // "axis": facing the axis, "away": facing away
// | }
// | },
// | series: {
// | stroke: {width: 1.5, color: "#333"}, // line
// | outline: {width: 0.1, color: "#ccc"}, // outline
// | //shadow: {dx: 1, dy: 1, width: 2, color: [0, 0, 0, 0.3]},
// | shadow: null, // no shadow
// | //filter: dojox/gfx/filters.createFilter(),
// | filter: null, // no filter, to use a filter you must use gfx SVG render and require dojox/gfx/svgext
// | fill: "#ccc", // fill, if appropriate
// | font: "normal normal normal 8pt Tahoma", // if there's a label
// | fontColor: "#000" // color of labels
// | labelWiring: {width: 1, color: "#ccc"}, // connect marker and target data item(slice, column, bar...)
// | },
// | marker: { // any markers on a series
// | symbol: "m-3,3 l3,-6 3,6 z", // symbol
// | stroke: {width: 1.5, color: "#333"}, // stroke
// | outline: {width: 0.1, color: "#ccc"}, // outline
// | shadow: null, // no shadow
// | fill: "#ccc", // fill if needed
// | font: "normal normal normal 8pt Tahoma", // label
// | fontColor: "#000"
// | },
// | grid: { // grid, when not present axis tick strokes are used instead
// | majorLine: { // major grid line
// | color: "#666",
// | width: 1,
// | length: 6
// | },
// | minorLine: { // minor grid line
// | color: "#666",
// | width: 0.8,
// | length: 3
// | },
// | fill: "grey", // every other stripe
// | alternateFill: "grey" // alternate stripe
// | },
// | indicator: {
// | lineStroke: {width: 1.5, color: "#333"}, // line
// | lineOutline: {width: 0.1, color: "#ccc"}, // line outline
// | lineShadow: null, // no line shadow
// | lineFill: null, // fill between lines for dual indicators
// | stroke: {width: 1.5, color: "#333"}, // label background stroke
// | outline: {width: 0.1, color: "#ccc"}, // label background outline
// | shadow: null, // no label background shadow
// | fill: "#ccc", // label background fill
// | radius: 3, // radius of the label background
// | font: "normal normal normal 10pt Tahoma", // label font
// | fontColor: "#000" // label color
// | markerFill: "#ccc", // marker fill
// | markerSymbol: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0", // marker symbol
// | markerStroke: {width: 1.5, color: "#333"}, // marker stroke
// | markerOutline: {width: 0.1, color: "#ccc"}, // marker outline
// | markerShadow: null // no marker shadow
// | },
// | pieInnerRadius: 33
//
// example:
// Defining a new theme is pretty simple:
// | var Grasslands = new SimpleTheme({
// | colors: [ "#70803a", "#dde574", "#788062", "#b1cc5d", "#eff2c2" ],
// | pieInnerRadius: 15
// | });
// |
// | myChart.setTheme(Grasslands);
shapeSpaces: {shape: 1, shapeX: 1, shapeY: 1},
constructor: function(kwArgs){
// summary:
// Initialize a theme using the keyword arguments. Note that the arguments
// look like the example (above), and may include a few more parameters.
kwArgs = kwArgs || {};
// populate theme with defaults updating them if needed
var def = SimpleTheme.defaultTheme;
arr.forEach(["chart", "plotarea", "axis", "grid", "series", "marker", "indicator"], function(name){
this[name] = lang.delegate(def[name], kwArgs[name]);
}, this);
// personalize theme
if(kwArgs.seriesThemes && kwArgs.seriesThemes.length){
this.colors = null;
this.seriesThemes = kwArgs.seriesThemes.slice(0);
}else{
this.seriesThemes = null;
this.colors = (kwArgs.colors || SimpleTheme.defaultColors).slice(0);
}
this.markerThemes = null;
if(kwArgs.markerThemes && kwArgs.markerThemes.length){
this.markerThemes = kwArgs.markerThemes.slice(0);
}
this.markers = kwArgs.markers ? lang.clone(kwArgs.markers) : lang.delegate(SimpleTheme.defaultMarkers);
// set flags
this.noGradConv = kwArgs.noGradConv;
this.noRadialConv = kwArgs.noRadialConv;
if(kwArgs.reverseFills){
this.reverseFills();
}
// private housekeeping
this._current = 0;
this._buildMarkerArray();
},
clone: function(){
// summary:
// Clone the current theme.
// returns: dojox.charting.SimpleTheme
// The cloned theme; any alterations made will not affect the original.
var theme = new this.constructor({
// theme components
chart: this.chart,
plotarea: this.plotarea,
axis: this.axis,
grid: this.grid,
series: this.series,
marker: this.marker,
// individual arrays
colors: this.colors,
markers: this.markers,
indicator: this.indicator,
seriesThemes: this.seriesThemes,
markerThemes: this.markerThemes,
// flags
noGradConv: this.noGradConv,
noRadialConv: this.noRadialConv,
pieInnerRadius: this.pieInnerRadius
});
// copy custom methods
arr.forEach(
["clone", "clear", "next", "skip", "addMixin", "post", "getTick"],
function(name){
if(this.hasOwnProperty(name)){
theme[name] = this[name];
}
},
this
);
return theme; // dojox.charting.SimpleTheme
},
clear: function(){
// summary:
// Clear and reset the internal pointer to start fresh.
this._current = 0;
},
next: function(elementType, mixin, doPost){
// summary:
// Get the next color or series theme.
// elementType: String?
// An optional element type (for use with series themes)
// mixin: Object?
// An optional object to mix into the theme.
// doPost: Boolean?
// A flag to post-process the results.
// returns: Object
// An object of the structure { series, marker, symbol }
var merge = dlu.merge, series, marker;
if(this.colors){
series = lang.delegate(this.series);
marker = lang.delegate(this.marker);
var color = new Color(this.colors[this._current % this.colors.length]), old;
// modify the stroke
if(series.stroke && series.stroke.color){
series.stroke = lang.delegate(series.stroke);
old = new Color(series.stroke.color);
series.stroke.color = new Color(color);
series.stroke.color.a = old.a;
}else{
series.stroke = {color: color};
}
if(marker.stroke && marker.stroke.color){
marker.stroke = lang.delegate(marker.stroke);
old = new Color(marker.stroke.color);
marker.stroke.color = new Color(color);
marker.stroke.color.a = old.a;
}else{
marker.stroke = {color: color};
}
// modify the fill
if(!series.fill || series.fill.type){
series.fill = color;
}else{
old = new Color(series.fill);
series.fill = new Color(color);
series.fill.a = old.a;
}
if(!marker.fill || marker.fill.type){
marker.fill = color;
}else{
old = new Color(marker.fill);
marker.fill = new Color(color);
marker.fill.a = old.a;
}
}else{
series = this.seriesThemes ?
merge(this.series, this.seriesThemes[this._current % this.seriesThemes.length]) :
this.series;
marker = this.markerThemes ?
merge(this.marker, this.markerThemes[this._current % this.markerThemes.length]) :
series;
}
var symbol = marker && marker.symbol || this._markers[this._current % this._markers.length];
var theme = {series: series, marker: marker, symbol: symbol};
// advance the counter
++this._current;
if(mixin){
theme = this.addMixin(theme, elementType, mixin);
}
if(doPost){
theme = this.post(theme, elementType);
}
return theme; // Object
},
skip: function(){
// summary:
// Skip the next internal color.
++this._current;
},
addMixin: function(theme, elementType, mixin, doPost){
// summary:
// Add a mixin object to the passed theme and process.
// theme: dojox/charting/SimpleTheme
// The theme to mixin to.
// elementType: String
// The type of element in question. Can be "line", "bar" or "circle"
// mixin: Object|Array
// The object or objects to mix into the theme.
// doPost: Boolean
// If true, run the new theme through the post-processor.
// returns: dojox/charting/SimpleTheme
// The new theme.
if(lang.isArray(mixin)){
arr.forEach(mixin, function(m){
theme = this.addMixin(theme, elementType, m);
}, this);
}else{
var t = {};
if("color" in mixin){
if(elementType == "line" || elementType == "area"){
lang.setObject("series.stroke.color", mixin.color, t);
lang.setObject("marker.stroke.color", mixin.color, t);
}else{
lang.setObject("series.fill", mixin.color, t);
}
}
arr.forEach(["stroke", "outline", "shadow", "fill", "filter", "font", "fontColor", "labelWiring"], function(name){
var markerName = "marker" + name.charAt(0).toUpperCase() + name.substr(1),
b = markerName in mixin;
if(name in mixin){
lang.setObject("series." + name, mixin[name], t);
if(!b){
lang.setObject("marker." + name, mixin[name], t);
}
}
if(b){
lang.setObject("marker." + name, mixin[markerName], t);
}
});
if("marker" in mixin){
t.symbol = mixin.marker;
t.symbol = mixin.marker;
}
theme = dlu.merge(theme, t);
}
if(doPost){
theme = this.post(theme, elementType);
}
return theme; // dojox/charting/SimpleTheme
},
post: function(theme, elementType){
// summary:
// Process any post-shape fills.
// theme: dojox/charting/SimpleTheme
// The theme to post process with.
// elementType: String
// The type of element being filled. Can be "bar" or "circle".
// returns: dojox/charting/SimpleTheme
// The post-processed theme.
var fill = theme.series.fill, t;
if(!this.noGradConv && this.shapeSpaces[fill.space] && fill.type == "linear"){
if(elementType == "bar"){
// transpose start and end points
t = {
x1: fill.y1,
y1: fill.x1,
x2: fill.y2,
y2: fill.x2
};
}else if(!this.noRadialConv && fill.space == "shape" && (elementType == "slice" || elementType == "circle")){
// switch to radial
t = {
type: "radial",
cx: 0,
cy: 0,
r: 100
};
}
if(t){
return dlu.merge(theme, {series: {fill: t}});
}
}
return theme; // dojox/charting/SimpleTheme
},
getTick: function(name, mixin){
// summary:
// Calculates and merges tick parameters.
// name: String
// Tick name, can be "major", "minor", or "micro".
// mixin: Object?
// Optional object to mix in to the tick.
var tick = this.axis.tick, tickName = name + "Tick",
merge = dlu.merge;
if(tick){
if(this.axis[tickName]){
tick = merge(tick, this.axis[tickName]);
}
}else{
tick = this.axis[tickName];
}
if(mixin){
if(tick){
if(mixin[tickName]){
tick = merge(tick, mixin[tickName]);
}
}else{
tick = mixin[tickName];
}
}
return tick; // Object
},
inspectObjects: function(f){
arr.forEach(["chart", "plotarea", "axis", "grid", "series", "marker", "indicator"], function(name){
f(this[name]);
}, this);
if(this.seriesThemes){
arr.forEach(this.seriesThemes, f);
}
if(this.markerThemes){
arr.forEach(this.markerThemes, f);
}
},
reverseFills: function(){
this.inspectObjects(function(o){
if(o && o.fill){
o.fill = dgg.reverse(o.fill);
}
});
},
addMarker:function(/*String*/ name, /*String*/ segment){
// summary:
// Add a custom marker to this theme.
// example:
// | myTheme.addMarker("Ellipse", foo);
this.markers[name] = segment;
this._buildMarkerArray();
},
setMarkers:function(/*Object*/ obj){
// summary:
// Set all the markers of this theme at once. obj should be a
// dictionary of keys and path segments.
//
// example:
// | myTheme.setMarkers({ "CIRCLE": foo });
this.markers = obj;
this._buildMarkerArray();
},
_buildMarkerArray: function(){
this._markers = [];
for(var p in this.markers){
this._markers.push(this.markers[p]);
}
}
});
lang.mixin(SimpleTheme, {
defaultMarkers: {
CIRCLE: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0",
SQUARE: "m-3,-3 l0,6 6,0 0,-6 z",
DIAMOND: "m0,-3 l3,3 -3,3 -3,-3 z",
CROSS: "m0,-3 l0,6 m-3,-3 l6,0",
X: "m-3,-3 l6,6 m0,-6 l-6,6",
TRIANGLE: "m-3,3 l3,-6 3,6 z",
TRIANGLE_INVERTED: "m-3,-3 l3,6 3,-6 z"
},
defaultColors:[
// gray skies
"#54544c", "#858e94", "#6e767a", "#948585", "#474747"
],
defaultTheme: {
// all objects are structs used directly in dojox.gfx
chart:{
stroke: null,
fill: "white",
pageStyle: null,
titleGap: 20,
titlePos: "top",
titleFont: "normal normal bold 14pt Tahoma", // chart title
titleFontColor: "#333",
titleAlign: "middle"
},
plotarea:{
stroke: null,
fill: "white"
},
// TODO: label rotation on axis
axis:{
stroke: { // the axis itself
color: "#333",
width: 1
},
tick: { // used as a foundation for all ticks
color: "#666",
position: "center",
font: "normal normal normal 7pt Tahoma", // labels on axis
fontColor: "#333", // color of labels
labelGap: 4 // gap between a tick and its label in pixels
},
majorTick: { // major ticks on axis, and used for major gridlines
width: 1,
length: 6
},
minorTick: { // minor ticks on axis, and used for minor gridlines
width: 0.8,
length: 3
},
microTick: { // minor ticks on axis, and used for minor gridlines
width: 0.5,
length: 1
},
title: {
gap: 15,
font: "normal normal normal 11pt Tahoma", // title font
fontColor: "#333", // title font color
orientation: "axis" // "axis": facing the axis, "away": facing away
}
},
series: {
// used as a "main" theme for series, sThemes augment it
stroke: {width: 1.5, color: "#333"}, // line
outline: {width: 0.1, color: "#ccc"}, // outline
//shadow: {dx: 1, dy: 1, width: 2, color: [0, 0, 0, 0.3]},
shadow: null, // no shadow
fill: "#ccc", // fill, if appropriate
font: "normal normal normal 8pt Tahoma", // if there's a label
fontColor: "#000", // color of labels
labelWiring: {width: 1, color: "#ccc"} // connect marker and target data item(slice, column, bar...)
},
marker: { // any markers on a series
stroke: {width: 1.5, color: "#333"}, // stroke
outline: {width: 0.1, color: "#ccc"}, // outline
//shadow: {dx: 1, dy: 1, width: 2, color: [0, 0, 0, 0.3]},
shadow: null, // no shadow
fill: "#ccc", // fill if needed
font: "normal normal normal 8pt Tahoma", // label
fontColor: "#000"
},
indicator: {
lineStroke: {width: 1.5, color: "#333"},
lineOutline: {width: 0.1, color: "#ccc"},
lineShadow: null,
lineFill: null,
stroke: {width: 1.5, color: "#333"},
outline: {width: 0.1, color: "#ccc"},
shadow: null,
fill : "#ccc",
radius: 3,
font: "normal normal normal 10pt Tahoma",
fontColor: "#000",
markerFill: "#ccc",
markerSymbol: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0",
markerStroke: {width: 1.5, color: "#333"},
markerOutline: {width: 0.1, color: "#ccc"},
markerShadow: null
}
}
});
return SimpleTheme;
});
},
'dojox/lang/utils':function(){
define(["..", "dojo/_base/lang"],
function(dojox, lang){
var du = lang.getObject("lang.utils", true, dojox);
var empty = {}, opts = Object.prototype.toString;
var clone = function(o){
if(o){
switch(opts.call(o)){
case "[object Array]":
return o.slice(0);
case "[object Object]":
return lang.delegate(o);
}
}
return o;
}
lang.mixin(du, {
coerceType: function(target, source){
// summary:
// Coerces one object to the type of another.
// target: Object
// object, which typeof result is used to coerce "source" object.
// source: Object
// object, which will be forced to change type.
switch(typeof target){
case "number": return Number(eval("(" + source + ")"));
case "string": return String(source);
case "boolean": return Boolean(eval("(" + source + ")"));
}
return eval("(" + source + ")");
},
updateWithObject: function(target, source, conv){
// summary:
// Updates an existing object in place with properties from an "source" object.
// target: Object
// the "target" object to be updated
// source: Object
// the "source" object, whose properties will be used to source the existed object.
// conv: Boolean?
// force conversion to the original type
if(!source){ return target; }
for(var x in target){
if(x in source && !(x in empty)){
var t = target[x];
if(t && typeof t == "object"){
du.updateWithObject(t, source[x], conv);
}else{
target[x] = conv ? du.coerceType(t, source[x]) : clone(source[x]);
}
}
}
return target; // Object
},
updateWithPattern: function(target, source, pattern, conv){
// summary:
// Updates an existing object in place with properties from an "source" object.
// target: Object
// the "target" object to be updated
// source: Object
// the "source" object, whose properties will be used to source the existed object.
// pattern: Object
// object, whose properties will be used to pull values from the "source"
// conv: Boolean?
// force conversion to the original type
if(!source || !pattern){ return target; }
for(var x in pattern){
if(x in source && !(x in empty)){
target[x] = conv ? du.coerceType(pattern[x], source[x]) : clone(source[x]);
}
}
return target; // Object
},
merge: function(object, mixin){
// summary:
// Merge two objects structurally, mixin properties will override object's properties.
// object: Object
// original object.
// mixin: Object
// additional object, which properties will override object's properties.
if(mixin){
var otype = opts.call(object), mtype = opts.call(mixin), t, i, l, m;
switch(mtype){
case "[object Array]":
if(mtype == otype){
t = new Array(Math.max(object.length, mixin.length));
for(i = 0, l = t.length; i < l; ++i){
t[i] = du.merge(object[i], mixin[i]);
}
return t;
}
return mixin.slice(0);
case "[object Object]":
if(mtype == otype && object){
t = lang.delegate(object);
for(i in mixin){
if(i in object){
l = object[i];
m = mixin[i];
if(m !== l){
t[i] = du.merge(l, m);
}
}else{
t[i] = lang.clone(mixin[i]);
}
}
return t;
}
return lang.clone(mixin);
}
}
return mixin;
}
});
return du;
});
},
'dojox/gfx/gradutils':function(){
// Various generic utilities to deal with a linear gradient
define(["./_base", "dojo/_base/lang", "./matrix", "dojo/_base/Color"],
function(g, lang, m, Color){
var gradutils = g.gradutils = {};
function findColor(o, c){
if(o <= 0){
return c[0].color;
}
var len = c.length;
if(o >= 1){
return c[len - 1].color;
}
//TODO: use binary search
for(var i = 0; i < len; ++i){
var stop = c[i];
if(stop.offset >= o){
if(i){
var prev = c[i - 1];
return Color.blendColors(new Color(prev.color), new Color(stop.color),
(o - prev.offset) / (stop.offset - prev.offset));
}
return stop.color;
}
}
return c[len - 1].color;
}
gradutils.getColor = function(fill, pt){
// summary:
// sample a color from a gradient using a point
// fill: Object
// fill object
// pt: dojox/gfx.Point
// point where to sample a color
var o;
if(fill){
switch(fill.type){
case "linear":
var angle = Math.atan2(fill.y2 - fill.y1, fill.x2 - fill.x1),
rotation = m.rotate(-angle),
projection = m.project(fill.x2 - fill.x1, fill.y2 - fill.y1),
p = m.multiplyPoint(projection, pt),
pf1 = m.multiplyPoint(projection, fill.x1, fill.y1),
pf2 = m.multiplyPoint(projection, fill.x2, fill.y2),
scale = m.multiplyPoint(rotation, pf2.x - pf1.x, pf2.y - pf1.y).x;
o = m.multiplyPoint(rotation, p.x - pf1.x, p.y - pf1.y).x / scale;
break;
case "radial":
var dx = pt.x - fill.cx, dy = pt.y - fill.cy;
o = Math.sqrt(dx * dx + dy * dy) / fill.r;
break;
}
return findColor(o, fill.colors); // dojo/_base/Color
}
// simple color
return new Color(fill || [0, 0, 0, 0]); // dojo/_base/Color
};
gradutils.reverse = function(fill){
// summary:
// reverses a gradient
// fill: Object
// fill object
if(fill){
switch(fill.type){
case "linear":
case "radial":
fill = lang.delegate(fill);
if(fill.colors){
var c = fill.colors, l = c.length, i = 0, stop,
n = fill.colors = new Array(c.length);
for(; i < l; ++i){
stop = c[i];
n[i] = {
offset: 1 - stop.offset,
color: stop.color
};
}
n.sort(function(a, b){ return a.offset - b.offset; });
}
break;
}
}
return fill; // Object
};
return gradutils;
});
},
'dojox/charting/Series':function(){
define(["dojo/_base/lang", "dojo/_base/declare", "./Element"],
function(lang, declare, Element){
/*=====
var __SeriesCtorArgs = {
// summary:
// An optional arguments object that can be used in the Series constructor.
// plot: String?
// The plot (by name) that this series belongs to.
};
=====*/
return declare("dojox.charting.Series", Element, {
// summary:
// An object representing a series of data for plotting on a chart.
constructor: function(chart, data, kwArgs){
// summary:
// Create a new data series object for use within charting.
// chart: dojox/charting/Chart
// The chart that this series belongs to.
// data: Array|Object
// The array of data points (either numbers or objects) that
// represents the data to be drawn. Or it can be an object. In
// the latter case, it should have a property "data" (an array),
// destroy(), and setSeriesObject().
// kwArgs: __SeriesCtorArgs?
// An optional keyword arguments object to set details for this series.
lang.mixin(this, kwArgs);
if(typeof this.plot != "string"){ this.plot = "default"; }
this.update(data);
},
clear: function(){
// summary:
// Clear the calculated additional parameters set on this series.
this.dyn = {};
},
update: function(data){
// summary:
// Set data and make this object dirty, so it can be redrawn.
// data: Array|Object
// The array of data points (either numbers or objects) that
// represents the data to be drawn. Or it can be an object. In
// the latter case, it should have a property "data" (an array),
// destroy(), and setSeriesObject().
if(lang.isArray(data)){
this.data = data;
}else{
this.source = data;
this.data = this.source.data;
if(this.source.setSeriesObject){
this.source.setSeriesObject(this);
}
}
this.dirty = true;
this.clear();
}
});
});
},
'dojox/charting/axis2d/common':function(){
define(["dojo/_base/lang", "dojo/_base/window", "dojo/dom-geometry", "dojox/gfx", "dojo/has"],
function(lang, win, domGeom, g, has){
var common = lang.getObject("dojox.charting.axis2d.common", true);
var clearNode = function(s){
s.marginLeft = "0px";
s.marginTop = "0px";
s.marginRight = "0px";
s.marginBottom = "0px";
s.paddingLeft = "0px";
s.paddingTop = "0px";
s.paddingRight = "0px";
s.paddingBottom = "0px";
s.borderLeftWidth = "0px";
s.borderTopWidth = "0px";
s.borderRightWidth = "0px";
s.borderBottomWidth = "0px";
};
var getBoxWidth = function(n){
// marginBox is incredibly slow, so avoid it if we can
if(n["getBoundingClientRect"]){
var bcr = n.getBoundingClientRect();
return bcr.width || (bcr.right - bcr.left);
}else{
return domGeom.getMarginBox(n).w;
}
};
return lang.mixin(common, {
// summary:
// Common methods to be used by any axis. This is considered "static".
createText: {
gfx: function(chart, creator, x, y, align, text, font, fontColor){
// summary:
// Use dojox.gfx to create any text.
// chart: dojox.charting.Chart
// The chart to create the text into.
// creator: dojox.gfx.Surface
// The graphics surface to use for creating the text.
// x: Number
// Where to create the text along the x axis (CSS left).
// y: Number
// Where to create the text along the y axis (CSS top).
// align: String
// How to align the text. Can be "left", "right", "center".
// text: String
// The text to render.
// font: String
// The font definition, a la CSS "font".
// fontColor: String|dojo.Color
// The color of the resultant text.
// returns: dojox.gfx.Text
// The resultant GFX object.
return creator.createText({
x: x, y: y, text: text, align: align
}).setFont(font).setFill(fontColor); // dojox.gfx.Text
},
html: function(chart, creator, x, y, align, text, font, fontColor, labelWidth){
// summary:
// Use the HTML DOM to create any text.
// chart: dojox.charting.Chart
// The chart to create the text into.
// creator: dojox.gfx.Surface
// The graphics surface to use for creating the text.
// x: Number
// Where to create the text along the x axis (CSS left).
// y: Number
// Where to create the text along the y axis (CSS top).
// align: String
// How to align the text. Can be "left", "right", "center".
// text: String
// The text to render.
// font: String
// The font definition, a la CSS "font".
// fontColor: String|dojo.Color
// The color of the resultant text.
// labelWidth: Number?
// The maximum width of the resultant DOM node.
// returns: DOMNode
// The resultant DOMNode (a "div" element).
// setup the text node
var p = win.doc.createElement("div"), s = p.style, boxWidth;
// bidi support, if this function exists the module was loaded
if(chart.getTextDir){
p.dir = chart.getTextDir(text);
}
clearNode(s);
s.font = font;
p.innerHTML = String(text).replace(/\s/g, " ");
s.color = fontColor;
// measure the size
s.position = "absolute";
s.left = "-10000px";
win.body().appendChild(p);
var size = g.normalizedLength(g.splitFontString(font).size);
// do we need to calculate the label width?
if(!labelWidth){
boxWidth = getBoxWidth(p);
}
// when the textDir is rtl, but the UI ltr needs
// to recalculate the starting point
if(p.dir == "rtl"){
x += labelWidth ? labelWidth : boxWidth;
}
// new settings for the text node
win.body().removeChild(p);
s.position = "relative";
if(labelWidth){
s.width = labelWidth + "px";
// s.border = "1px dotted grey";
switch(align){
case "middle":
s.textAlign = "center";
s.left = (x - labelWidth / 2) + "px";
break;
case "end":
s.textAlign = "right";
s.left = (x - labelWidth) + "px";
break;
default:
s.left = x + "px";
s.textAlign = "left";
break;
}
}else{
switch(align){
case "middle":
s.left = Math.floor(x - boxWidth / 2) + "px";
// s.left = Math.floor(x - p.offsetWidth / 2) + "px";
break;
case "end":
s.left = Math.floor(x - boxWidth) + "px";
// s.left = Math.floor(x - p.offsetWidth) + "px";
break;
//case "start":
default:
s.left = Math.floor(x) + "px";
break;
}
}
s.top = Math.floor(y - size) + "px";
s.whiteSpace = "nowrap"; // hack for WebKit
// setup the wrapper node
var wrap = win.doc.createElement("div"), w = wrap.style;
clearNode(w);
w.width = "0px";
w.height = "0px";
// insert nodes
wrap.appendChild(p);
chart.node.insertBefore(wrap, chart.node.firstChild);
if(has("dojo-bidi")){
chart.htmlElementsRegistry.push([wrap, x, y, align, text, font, fontColor]);
}
return wrap; // DOMNode
}
}
});
});
},
'dojox/charting/plot2d/common':function(){
define(["dojo/_base/lang", "dojo/_base/array", "dojo/_base/Color",
"dojox/gfx", "dojox/lang/functional", "../scaler/common"],
function(lang, arr, Color, g, df, sc){
var common = lang.getObject("dojox.charting.plot2d.common", true);
return lang.mixin(common, {
doIfLoaded: sc.doIfLoaded,
makeStroke: function(stroke){
if(!stroke){ return stroke; }
if(typeof stroke == "string" || stroke instanceof Color){
stroke = {color: stroke};
}
return g.makeParameters(g.defaultStroke, stroke);
},
augmentColor: function(target, color){
var t = new Color(target),
c = new Color(color);
c.a = t.a;
return c;
},
augmentStroke: function(stroke, color){
var s = common.makeStroke(stroke);
if(s){
s.color = common.augmentColor(s.color, color);
}
return s;
},
augmentFill: function(fill, color){
var fc, c = new Color(color);
if(typeof fill == "string" || fill instanceof Color){
return common.augmentColor(fill, color);
}
return fill;
},
defaultStats: {
vmin: Number.POSITIVE_INFINITY, vmax: Number.NEGATIVE_INFINITY,
hmin: Number.POSITIVE_INFINITY, hmax: Number.NEGATIVE_INFINITY
},
collectSimpleStats: function(series, isNullValue){
var stats = lang.delegate(common.defaultStats);
for(var i = 0; i < series.length; ++i){
var run = series[i];
for(var j = 0; j < run.data.length; j++){
if(!isNullValue(run.data[j])){
if(typeof run.data[j] == "number"){
// 1D case
var old_vmin = stats.vmin, old_vmax = stats.vmax;
arr.forEach(run.data, function(val, i){
if(!isNullValue(val)){
var x = i + 1, y = val;
if(isNaN(y)){ y = 0; }
stats.hmin = Math.min(stats.hmin, x);
stats.hmax = Math.max(stats.hmax, x);
stats.vmin = Math.min(stats.vmin, y);
stats.vmax = Math.max(stats.vmax, y);
}
});
if("ymin" in run){ stats.vmin = Math.min(old_vmin, run.ymin); }
if("ymax" in run){ stats.vmax = Math.max(old_vmax, run.ymax); }
}else{
// 2D case
var old_hmin = stats.hmin, old_hmax = stats.hmax,
old_vmin = stats.vmin, old_vmax = stats.vmax;
if(!("xmin" in run) || !("xmax" in run) || !("ymin" in run) || !("ymax" in run)){
arr.forEach(run.data, function(val, i){
if(!isNullValue(val)){
var x = "x" in val ? val.x : i + 1, y = val.y;
if(isNaN(x)){ x = 0; }
if(isNaN(y)){ y = 0; }
stats.hmin = Math.min(stats.hmin, x);
stats.hmax = Math.max(stats.hmax, x);
stats.vmin = Math.min(stats.vmin, y);
stats.vmax = Math.max(stats.vmax, y);
}
});
}
if("xmin" in run){ stats.hmin = Math.min(old_hmin, run.xmin); }
if("xmax" in run){ stats.hmax = Math.max(old_hmax, run.xmax); }
if("ymin" in run){ stats.vmin = Math.min(old_vmin, run.ymin); }
if("ymax" in run){ stats.vmax = Math.max(old_vmax, run.ymax); }
}
break;
}
}
}
return stats;
},
calculateBarSize: function(/* Number */ availableSize, /* Object */ opt, /* Number? */ clusterSize){
if(!clusterSize){
clusterSize = 1;
}
var gap = opt.gap, size = (availableSize - 2 * gap) / clusterSize;
if("minBarSize" in opt){
size = Math.max(size, opt.minBarSize);
}
if("maxBarSize" in opt){
size = Math.min(size, opt.maxBarSize);
}
size = Math.max(size, 1);
gap = (availableSize - size * clusterSize) / 2;
return {size: size, gap: gap}; // Object
},
collectStackedStats: function(series){
// collect statistics
var stats = lang.clone(common.defaultStats);
if(series.length){
// 1st pass: find the maximal length of runs
stats.hmin = Math.min(stats.hmin, 1);
stats.hmax = df.foldl(series, "seed, run -> Math.max(seed, run.data.length)", stats.hmax);
// 2nd pass: stack values
for(var i = 0; i < stats.hmax; ++i){
var v = series[0].data[i];
v = v && (typeof v == "number" ? v : v.y);
if(isNaN(v)){ v = 0; }
stats.vmin = Math.min(stats.vmin, v);
for(var j = 1; j < series.length; ++j){
var t = series[j].data[i];
t = t && (typeof t == "number" ? t : t.y);
if(isNaN(t)){ t = 0; }
v += t;
}
stats.vmax = Math.max(stats.vmax, v);
}
}
return stats;
},
curve: function(/* Number[] */a, /* Number|String */tension){
// FIX for #7235, submitted by Enzo Michelangeli.
// Emulates the smoothing algorithms used in a famous, unnamed spreadsheet
// program ;)
var array = a.slice(0);
if(tension == "x") {
array[array.length] = array[0]; // add a last element equal to the first, closing the loop
}
var p=arr.map(array, function(item, i){
if(i==0){ return "M" + item.x + "," + item.y; }
if(!isNaN(tension)) { // use standard Dojo smoothing in tension is numeric
var dx=item.x-array[i-1].x, dy=array[i-1].y;
return "C"+(item.x-(tension-1)*(dx/tension))+","+dy+" "+(item.x-(dx/tension))+","+item.y+" "+item.x+","+item.y;
} else if(tension == "X" || tension == "x" || tension == "S") {
// use Excel "line smoothing" algorithm (http://xlrotor.com/resources/files.shtml)
var p0, p1 = array[i-1], p2 = array[i], p3;
var bz1x, bz1y, bz2x, bz2y;
var f = 1/6;
if(i==1) {
if(tension == "x") {
p0 = array[array.length-2];
} else { // "tension == X || tension == "S"
p0 = p1;
}
f = 1/3;
} else {
p0 = array[i-2];
}
if(i==(array.length-1)) {
if(tension == "x") {
p3 = array[1];
} else { // "tension == X || tension == "S"
p3 = p2;
}
f = 1/3;
} else {
p3 = array[i+1];
}
var p1p2 = Math.sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y));
var p0p2 = Math.sqrt((p2.x-p0.x)*(p2.x-p0.x)+(p2.y-p0.y)*(p2.y-p0.y));
var p1p3 = Math.sqrt((p3.x-p1.x)*(p3.x-p1.x)+(p3.y-p1.y)*(p3.y-p1.y));
var p0p2f = p0p2 * f;
var p1p3f = p1p3 * f;
if(p0p2f > p1p2/2 && p1p3f > p1p2/2) {
p0p2f = p1p2/2;
p1p3f = p1p2/2;
} else if(p0p2f > p1p2/2) {
p0p2f = p1p2/2;
p1p3f = p1p2/2 * p1p3/p0p2;
} else if(p1p3f > p1p2/2) {
p1p3f = p1p2/2;
p0p2f = p1p2/2 * p0p2/p1p3;
}
if(tension == "S") {
if(p0 == p1) { p0p2f = 0; }
if(p2 == p3) { p1p3f = 0; }
}
bz1x = p1.x + p0p2f*(p2.x - p0.x)/p0p2;
bz1y = p1.y + p0p2f*(p2.y - p0.y)/p0p2;
bz2x = p2.x - p1p3f*(p3.x - p1.x)/p1p3;
bz2y = p2.y - p1p3f*(p3.y - p1.y)/p1p3;
}
return "C"+(bz1x+","+bz1y+" "+bz2x+","+bz2y+" "+p2.x+","+p2.y);
});
return p.join(" ");
},
getLabel: function(/*Number*/number, /*Boolean*/fixed, /*Number*/precision){
return sc.doIfLoaded("dojo/number", function(numberLib){
return (fixed ? numberLib.format(number, {places : precision}) :
numberLib.format(number)) || "";
}, function(){
return fixed ? number.toFixed(precision) : number.toString();
});
},
purgeGroup: function (item) {
return item.purgeGroup();
}
});
});
},
'dojox/lang/functional':function(){
define(["./functional/lambda", "./functional/array", "./functional/object"], function(df){
return df;
});
},
'dojox/lang/functional/lambda':function(){
define(["../..", "dojo/_base/lang", "dojo/_base/array"], function(dojox, lang, arr){
var df = lang.getObject("lang.functional", true, dojox);
// This module adds high-level functions and related constructs:
// - anonymous functions built from the string
// Acknowledgements:
// - lambda() is based on work by Oliver Steele
// (http://osteele.com/sources/javascript/functional/functional.js)
// which was published under MIT License
// Notes:
// - lambda() produces functions, which after the compilation step are
// as fast as regular JS functions (at least theoretically).
// Lambda input values:
// - returns functions unchanged
// - converts strings to functions
// - converts arrays to a functional composition
var lcache = {};
// split() is augmented on IE6 to ensure the uniform behavior
var split = "ab".split(/a*/).length > 1 ? String.prototype.split :
function(sep){
var r = this.split.call(this, sep),
m = sep.exec(this);
if(m && m.index == 0){ r.unshift(""); }
return r;
};
var lambda = function(/*String*/ s){
var args = [], sects = split.call(s, /\s*->\s*/m);
if(sects.length > 1){
while(sects.length){
s = sects.pop();
args = sects.pop().split(/\s*,\s*|\s+/m);
if(sects.length){ sects.push("(function(" + args.join(", ") + "){ return (" + s + "); })"); }
}
}else if(s.match(/\b_\b/)){
args = ["_"];
}else{
var l = s.match(/^\s*(?:[+*\/%&|\^\.=<>]|!=)/m),
r = s.match(/[+\-*\/%&|\^\.=<>!]\s*$/m);
if(l || r){
if(l){
args.push("$1");
s = "$1" + s;
}
if(r){
args.push("$2");
s = s + "$2";
}
}else{
// the point of the long regex below is to exclude all well-known
// lower-case words from the list of potential arguments
var vars = s.
replace(/(?:\b[A-Z]|\.[a-zA-Z_$])[a-zA-Z_$\d]*|[a-zA-Z_$][a-zA-Z_$\d]*:|this|true|false|null|undefined|typeof|instanceof|in|delete|new|void|arguments|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval|isFinite|isNaN|parseFloat|parseInt|unescape|dojo|dijit|dojox|window|document|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, "").
match(/([a-z_$][a-z_$\d]*)/gi) || [], t = {};
arr.forEach(vars, function(v){
if(!t.hasOwnProperty(v)){
args.push(v);
t[v] = 1;
}
});
}
}
return {args: args, body: s}; // Object
};
var compose = function(/*Array*/ a){
return a.length ?
function(){
var i = a.length - 1, x = df.lambda(a[i]).apply(this, arguments);
for(--i; i >= 0; --i){ x = df.lambda(a[i]).call(this, x); }
return x;
}
:
// identity
function(x){ return x; };
};
lang.mixin(df, {
// lambda
rawLambda: function(/*String*/ s){
// summary:
// builds a function from a snippet, or array (composing),
// returns an object describing the function; functions are
// passed through unmodified.
// description:
// This method is to normalize a functional representation (a
// text snippet) to an object that contains an array of
// arguments, and a body , which is used to calculate the
// returning value.
return lambda(s); // Object
},
buildLambda: function(/*String*/ s){
// summary:
// builds a function from a snippet, returns a string, which
// represents the function.
// description:
// This method returns a textual representation of a function
// built from the snippet. It is meant to be evaled in the
// proper context, so local variables can be pulled from the
// environment.
var l = lambda(s);
return "function(" + l.args.join(",") + "){return (" + l.body + ");}"; // String
},
lambda: function(/*Function|String|Array*/ s){
// summary:
// builds a function from a snippet, or array (composing),
// returns a function object; functions are passed through
// unmodified.
// description:
// This method is used to normalize a functional
// representation (a text snippet, an array, or a function) to
// a function object.
if(typeof s == "function"){ return s; }
if(s instanceof Array){ return compose(s); }
if(lcache.hasOwnProperty(s)){ return lcache[s]; }
var l = lambda(s);
return lcache[s] = new Function(l.args, "return (" + l.body + ");"); // Function
},
clearLambdaCache: function(){
// summary:
// clears internal cache of lambdas
lcache = {};
}
});
return df;
});
},
'dojox/lang/functional/array':function(){
define(["dojo/_base/kernel", "dojo/_base/lang", "dojo/_base/array", "./lambda"],
function(kernel, lang, arr, df){
// This module adds high-level functions and related constructs:
// - array-processing functions similar to standard JS functions
// Notes:
// - this module provides JS standard methods similar to high-level functions in dojo/_base/array.js:
// forEach, map, filter, every, some
// Defined methods:
// - take any valid lambda argument as the functional argument
// - operate on dense arrays
// - take a string as the array argument
// - take an iterator objects as the array argument
var empty = {};
lang.mixin(df, {
// JS 1.6 standard array functions, which can take a lambda as a parameter.
// Consider using dojo._base.array functions, if you don't need the lambda support.
filter: function(/*Array|String|Object*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// creates a new array with all elements that pass the test
// implemented by the provided function.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
var t = [], v, i, n;
if(lang.isArray(a)){
// array
for(i = 0, n = a.length; i < n; ++i){
v = a[i];
if(f.call(o, v, i, a)){ t.push(v); }
}
}else if(typeof a.hasNext == "function" && typeof a.next == "function"){
// iterator
for(i = 0; a.hasNext();){
v = a.next();
if(f.call(o, v, i++, a)){ t.push(v); }
}
}else{
// object/dictionary
for(i in a){
if(!(i in empty)){
v = a[i];
if(f.call(o, v, i, a)){ t.push(v); }
}
}
}
return t; // Array
},
forEach: function(/*Array|String|Object*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// executes a provided function once per array element.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
var i, n;
if(lang.isArray(a)){
// array
for(i = 0, n = a.length; i < n; f.call(o, a[i], i, a), ++i);
}else if(typeof a.hasNext == "function" && typeof a.next == "function"){
// iterator
for(i = 0; a.hasNext(); f.call(o, a.next(), i++, a));
}else{
// object/dictionary
for(i in a){
if(!(i in empty)){
f.call(o, a[i], i, a);
}
}
}
return o; // Object
},
map: function(/*Array|String|Object*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// creates a new array with the results of calling
// a provided function on every element in this array.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
var t, n, i;
if(lang.isArray(a)){
// array
t = new Array(n = a.length);
for(i = 0; i < n; t[i] = f.call(o, a[i], i, a), ++i);
}else if(typeof a.hasNext == "function" && typeof a.next == "function"){
// iterator
t = [];
for(i = 0; a.hasNext(); t.push(f.call(o, a.next(), i++, a)));
}else{
// object/dictionary
t = [];
for(i in a){
if(!(i in empty)){
t.push(f.call(o, a[i], i, a));
}
}
}
return t; // Array
},
every: function(/*Array|String|Object*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// tests whether all elements in the array pass the test
// implemented by the provided function.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
var i, n;
if(lang.isArray(a)){
// array
for(i = 0, n = a.length; i < n; ++i){
if(!f.call(o, a[i], i, a)){
return false; // Boolean
}
}
}else if(typeof a.hasNext == "function" && typeof a.next == "function"){
// iterator
for(i = 0; a.hasNext();){
if(!f.call(o, a.next(), i++, a)){
return false; // Boolean
}
}
}else{
// object/dictionary
for(i in a){
if(!(i in empty)){
if(!f.call(o, a[i], i, a)){
return false; // Boolean
}
}
}
}
return true; // Boolean
},
some: function(/*Array|String|Object*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// tests whether some element in the array passes the test
// implemented by the provided function.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
var i, n;
if(lang.isArray(a)){
// array
for(i = 0, n = a.length; i < n; ++i){
if(f.call(o, a[i], i, a)){
return true; // Boolean
}
}
}else if(typeof a.hasNext == "function" && typeof a.next == "function"){
// iterator
for(i = 0; a.hasNext();){
if(f.call(o, a.next(), i++, a)){
return true; // Boolean
}
}
}else{
// object/dictionary
for(i in a){
if(!(i in empty)){
if(f.call(o, a[i], i, a)){
return true; // Boolean
}
}
}
}
return false; // Boolean
}
});
return df;
});
},
'dojox/lang/functional/object':function(){
define(["dojo/_base/kernel", "dojo/_base/lang", "./lambda"], function(kernel, lang, df){
// This module adds high-level functions and related constructs:
// - object/dictionary helpers
// Defined methods:
// - take any valid lambda argument as the functional argument
// - skip all attributes that are present in the empty object
// (IE and/or 3rd-party libraries).
var empty = {};
lang.mixin(df, {
// object helpers
keys: function(/*Object*/ obj){
// summary:
// returns an array of all keys in the object
var t = [];
for(var i in obj){
if(!(i in empty)){
t.push(i);
}
}
return t; // Array
},
values: function(/*Object*/ obj){
// summary:
// returns an array of all values in the object
var t = [];
for(var i in obj){
if(!(i in empty)){
t.push(obj[i]);
}
}
return t; // Array
},
filterIn: function(/*Object*/ obj, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// creates new object with all attributes that pass the test
// implemented by the provided function.
o = o || kernel.global; f = df.lambda(f);
var t = {}, v, i;
for(i in obj){
if(!(i in empty)){
v = obj[i];
if(f.call(o, v, i, obj)){ t[i] = v; }
}
}
return t; // Object
},
forIn: function(/*Object*/ obj, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// iterates over all object attributes.
o = o || kernel.global; f = df.lambda(f);
for(var i in obj){
if(!(i in empty)){
f.call(o, obj[i], i, obj);
}
}
return o; // Object
},
mapIn: function(/*Object*/ obj, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// creates new object with the results of calling
// a provided function on every attribute in this object.
o = o || kernel.global; f = df.lambda(f);
var t = {}, i;
for(i in obj){
if(!(i in empty)){
t[i] = f.call(o, obj[i], i, obj);
}
}
return t; // Object
}
});
return df;
});
},
'dojox/charting/scaler/common':function(){
define(["dojo/_base/lang"], function(lang){
var eq = function(/*Number*/ a, /*Number*/ b){
// summary:
// compare two FP numbers for equality
return Math.abs(a - b) <= 1e-6 * (Math.abs(a) + Math.abs(b)); // Boolean
};
var common = lang.getObject("dojox.charting.scaler.common", true);
var testedModules = {};
return lang.mixin(common, {
doIfLoaded: function(moduleName, ifloaded, ifnotloaded){
if(testedModules[moduleName] === undefined){
try{
testedModules[moduleName] = require(moduleName);
}catch(e){
testedModules[moduleName] = null;
}
}
if(testedModules[moduleName]){
return ifloaded(testedModules[moduleName]);
}else{
return ifnotloaded();
}
},
getNumericLabel: function(/*Number*/ number, /*Number*/ precision, /*Object*/ kwArgs){
var def = "";
common.doIfLoaded("dojo/number", function(numberLib){
def = (kwArgs.fixed ? numberLib.format(number, {places : precision < 0 ? -precision : 0}) :
numberLib.format(number)) || "";
}, function(){
def = kwArgs.fixed ? number.toFixed(precision < 0 ? -precision : 0) : number.toString();
});
if(kwArgs.labelFunc){
var r = kwArgs.labelFunc(def, number, precision);
if(r){ return r; }
// else fall through to the regular labels search
}
if(kwArgs.labels){
// classic binary search
// TODO: working only if the array is sorted per value should be better documented or sorted automatically
var l = kwArgs.labels, lo = 0, hi = l.length;
while(lo < hi){
var mid = Math.floor((lo + hi) / 2), val = l[mid].value;
if(val < number){
lo = mid + 1;
}else{
hi = mid;
}
}
// lets take into account FP errors
if(lo < l.length && eq(l[lo].value, number)){
return l[lo].text;
}
--lo;
if(lo >= 0 && lo < l.length && eq(l[lo].value, number)){
return l[lo].text;
}
lo += 2;
if(lo < l.length && eq(l[lo].value, number)){
return l[lo].text;
}
// otherwise we will produce a number
}
return def;
}
});
});
},
'dojox/lang/functional/fold':function(){
define(["dojo/_base/lang", "dojo/_base/array", "dojo/_base/kernel", "./lambda"],
function(lang, arr, kernel, df){
// This module adds high-level functions and related constructs:
// - "fold" family of functions
// Notes:
// - missing high-level functions are provided with the compatible API:
// foldl, foldl1, foldr, foldr1
// - missing JS standard functions are provided with the compatible API:
// reduce, reduceRight
// - the fold's counterpart: unfold
// Defined methods:
// - take any valid lambda argument as the functional argument
// - operate on dense arrays
// - take a string as the array argument
// - take an iterator objects as the array argument (only foldl, foldl1, and reduce)
var empty = {};
lang.mixin(df, {
// classic reduce-class functions
foldl: function(/*Array|String|Object*/ a, /*Function*/ f, /*Object*/ z, /*Object?*/ o){
// summary:
// repeatedly applies a binary function to an array from left
// to right using a seed value as a starting point; returns the final
// value.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
var i, n;
if(lang.isArray(a)){
// array
for(i = 0, n = a.length; i < n; z = f.call(o, z, a[i], i, a), ++i);
}else if(typeof a.hasNext == "function" && typeof a.next == "function"){
// iterator
for(i = 0; a.hasNext(); z = f.call(o, z, a.next(), i++, a));
}else{
// object/dictionary
for(i in a){
if(!(i in empty)){
z = f.call(o, z, a[i], i, a);
}
}
}
return z; // Object
},
foldl1: function(/*Array|String|Object*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// repeatedly applies a binary function to an array from left
// to right; returns the final value.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
var z, i, n;
if(lang.isArray(a)){
// array
z = a[0];
for(i = 1, n = a.length; i < n; z = f.call(o, z, a[i], i, a), ++i);
}else if(typeof a.hasNext == "function" && typeof a.next == "function"){
// iterator
if(a.hasNext()){
z = a.next();
for(i = 1; a.hasNext(); z = f.call(o, z, a.next(), i++, a));
}
}else{
// object/dictionary
var first = true;
for(i in a){
if(!(i in empty)){
if(first){
z = a[i];
first = false;
}else{
z = f.call(o, z, a[i], i, a);
}
}
}
}
return z; // Object
},
foldr: function(/*Array|String*/ a, /*Function|String|Array*/ f, /*Object*/ z, /*Object?*/ o){
// summary:
// repeatedly applies a binary function to an array from right
// to left using a seed value as a starting point; returns the final
// value.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
for(var i = a.length; i > 0; --i, z = f.call(o, z, a[i], i, a));
return z; // Object
},
foldr1: function(/*Array|String*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// repeatedly applies a binary function to an array from right
// to left; returns the final value.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
var n = a.length, z = a[n - 1], i = n - 1;
for(; i > 0; --i, z = f.call(o, z, a[i], i, a));
return z; // Object
},
// JS 1.8 standard array functions, which can take a lambda as a parameter.
reduce: function(/*Array|String|Object*/ a, /*Function|String|Array*/ f, /*Object?*/ z){
// summary:
// apply a function simultaneously against two values of the array
// (from left-to-right) as to reduce it to a single value.
return arguments.length < 3 ? df.foldl1(a, f) : df.foldl(a, f, z); // Object
},
reduceRight: function(/*Array|String*/ a, /*Function|String|Array*/ f, /*Object?*/ z){
// summary:
// apply a function simultaneously against two values of the array
// (from right-to-left) as to reduce it to a single value.
return arguments.length < 3 ? df.foldr1(a, f) : df.foldr(a, f, z); // Object
},
// the fold's counterpart: unfold
unfold: function(/*Function|String|Array*/ pr, /*Function|String|Array*/ f,
/*Function|String|Array*/ g, /*Object*/ z, /*Object?*/ o){
// summary:
// builds an array by unfolding a value
o = o || kernel.global; f = df.lambda(f); g = df.lambda(g); pr = df.lambda(pr);
var t = [];
for(; !pr.call(o, z); t.push(f.call(o, z)), z = g.call(o, z));
return t; // Array
}
});
});
},
'dojox/lang/functional/reversed':function(){
define(["dojo/_base/lang", "dojo/_base/kernel" ,"./lambda"],
function(lang, kernel, df){
// This module adds high-level functions and related constructs:
// - reversed versions of array-processing functions similar to standard JS functions
// Notes:
// - this module provides reversed versions of standard array-processing functions:
// forEachRev, mapRev, filterRev
// Defined methods:
// - take any valid lambda argument as the functional argument
// - operate on dense arrays
// - take a string as the array argument
lang.mixin(df, {
// JS 1.6 standard array functions, which can take a lambda as a parameter.
// Consider using dojo._base.array functions, if you don't need the lambda support.
filterRev: function(/*Array|String*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// creates a new array with all elements that pass the test
// implemented by the provided function.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
var t = [], v, i = a.length - 1;
for(; i >= 0; --i){
v = a[i];
if(f.call(o, v, i, a)){ t.push(v); }
}
return t; // Array
},
forEachRev: function(/*Array|String*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// executes a provided function once per array element.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
for(var i = a.length - 1; i >= 0; f.call(o, a[i], i, a), --i);
},
mapRev: function(/*Array|String*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// creates a new array with the results of calling
// a provided function on every element in this array.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
var n = a.length, t = new Array(n), i = n - 1, j = 0;
for(; i >= 0; t[j++] = f.call(o, a[i], i, a), --i);
return t; // Array
},
everyRev: function(/*Array|String*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// tests whether all elements in the array pass the test
// implemented by the provided function.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
for(var i = a.length - 1; i >= 0; --i){
if(!f.call(o, a[i], i, a)){
return false; // Boolean
}
}
return true; // Boolean
},
someRev: function(/*Array|String*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary:
// tests whether some element in the array passes the test
// implemented by the provided function.
if(typeof a == "string"){ a = a.split(""); }
o = o || kernel.global; f = df.lambda(f);
for(var i = a.length - 1; i >= 0; --i){
if(f.call(o, a[i], i, a)){
return true; // Boolean
}
}
return false; // Boolean
}
});
return df;
});
},
'dojox/charting/axis2d/Default':function(){
define(["dojo/_base/lang", "dojo/_base/array", "dojo/sniff", "dojo/_base/declare",
"dojo/_base/connect", "dojo/dom-geometry", "./Invisible",
"../scaler/linear", "./common", "dojox/gfx", "dojox/lang/utils", "dojox/lang/functional",
"dojo/has!dojo-bidi?../bidi/axis2d/Default"],
function(lang, arr, has, declare, connect, domGeom, Invisible,
lin, acommon, g, du, df, BidiDefault){
/*=====
var __AxisCtorArgs = {
// summary:
// Optional arguments used in the definition of an axis.
// vertical: Boolean?
// A flag that says whether an axis is vertical (i.e. y axis) or horizontal. Default is false (horizontal).
// fixUpper: String?
// Align the greatest value on the axis with the specified tick level. Options are "major", "minor", "micro", or "none". Defaults to "none".
// fixLower: String?
// Align the smallest value on the axis with the specified tick level. Options are "major", "minor", "micro", or "none". Defaults to "none".
// natural: Boolean?
// Ensure tick marks are made on "natural" numbers. Defaults to false.
// leftBottom: Boolean?
// Deprecated: use position instead. The position of a vertical axis; if true, will be placed against the left-bottom corner of the chart. Defaults to true.
// includeZero: Boolean?
// Include 0 on the axis rendering. Default is false.
// fixed: Boolean?
// Force all axis labels to be fixed numbers. Default is true.
// majorLabels: Boolean?
// Flag to draw labels at major ticks. Default is true.
// minorTicks: Boolean?
// Flag to draw minor ticks on an axis. Default is true.
// minorLabels: Boolean?
// Flag to labels on minor ticks when there is enough space. Default is true.
// microTicks: Boolean?
// Flag to draw micro ticks on an axis. Default is false.
// htmlLabels: Boolean?
// Flag to use HTML (as opposed to the native vector graphics engine) to draw labels. Default is true.
// min: Number?
// The smallest value on an axis. Default is 0.
// max: Number?
// The largest value on an axis. Default is 1.
// from: Number?
// Force the chart to render data visible from this value. Default is 0.
// to: Number?
// Force the chart to render data visible to this value. Default is 1.
// majorTickStep: Number?
// The amount to skip before a major tick is drawn. When not set the major ticks step is computed from
// the data range.
// minorTickStep: Number?
// The amount to skip before a minor tick is drawn. When not set the minor ticks step is computed from
// the data range.
// microTickStep: Number?
// The amount to skip before a micro tick is drawn. When not set the micro ticks step is computed from
// labels: Object[]?
// An array of labels for major ticks, with corresponding numeric values, ordered by value.
// labelFunc: Function?
// An optional function to use to compute label text. It takes precedence over
// the default text when available. The function must be of the following form:
// | function labelFunc(text, value, precision) {}
// `text` is the already pre-formatted text. Pre-formatting is done using `dojo/number` is available, `Date.toFixed` otherwise.
// `value` is the raw axis value.
// `precision` is the requested precision to be applied.
// maxLabelSize: Number?
// The maximum size, in pixels, for a label. To be used with the optional label function.
// stroke: dojox.gfx.Stroke?
// An optional stroke to be used for drawing an axis.
// majorTick: Object?
// An object containing a dojox.gfx.Stroke, and a length (number) for a major tick.
// minorTick: Object?
// An object containing a dojox.gfx.Stroke, and a length (number) for a minor tick.
// microTick: Object?
// An object containing a dojox.gfx.Stroke, and a length (number) for a micro tick.
// tick: Object?
// An object containing a dojox.gfx.Stroke, and a length (number) for a tick.
// font: String?
// An optional font definition (as used in the CSS font property) for labels.
// fontColor: String|dojo.Color?
// An optional color to be used in drawing labels.
// titleGap: Number?
// An optional grap between axis title and axis label
// titleFont: String?
// An optional font definition for axis title
// titleFontColor: String?
// An optional axis title color
// titleOrientation: String?
// An optional orientation for axis title. "axis" means the title facing the axis, "away" means facing away.
// If no value is set "axis" is used.
// enableCache: Boolean?
// Whether the ticks and labels are cached from one rendering to another. This improves the rendering performance of
// successive rendering but penalize the first rendering. For labels it is only working with gfx labels
// not html ones. Default false.
// dropLabels: Boolean?
// Whether the axis automatically drops labels at regular interval or not to avoid labels overlapping.
// This gives better results but require more computations. You can disable it to save computation
// time when you know your labels won't overlap. Default is true.
// labelSizeChange: Boolean?
// Indicates to the axis whether the axis labels are changing their size on zoom. If false this allows to
// optimize the axis by avoiding recomputing labels maximum size on zoom actions. Default is false.
// position: String?
// The position of the axis. Values: "leftOrBottom", "center" or "rightOrTop". Default is "leftOrBottom".
};
=====*/
var centerAnchorLimit = 45; // in degrees
var Default = declare(has("dojo-bidi")? "dojox.charting.axis2d.NonBidiDefault" : "dojox.charting.axis2d.Default", Invisible, {
// summary:
// The default axis object used in dojox.charting. See dojox.charting.Chart.addAxis for details.
// defaultParams: Object
// The default parameters used to define any axis.
// optionalParams: Object
// Any optional parameters needed to define an axis.
/*=====
// TODO: the documentation tools need these to be pre-defined in order to pick them up
// correctly, but the code here is partially predicated on whether or not the properties
// actually exist. For now, we will leave these undocumented but in the code for later. -- TRT
// opt: Object
// The actual options used to define this axis, created at initialization.
// scaler: Object
// The calculated helper object to tell charts how to draw an axis and any data.
// ticks: Object
// The calculated tick object that helps a chart draw the scaling on an axis.
// dirty: Boolean
// The state of the axis (whether it needs to be redrawn or not)
// scale: Number
// The current scale of the axis.
// offset: Number
// The current offset of the axis.
opt: null,
scaler: null,
ticks: null,
dirty: true,
scale: 1,
offset: 0,
=====*/
defaultParams: {
vertical: false, // true for vertical axis
fixUpper: "none", // align the upper on ticks: "major", "minor", "micro", "none"
fixLower: "none", // align the lower on ticks: "major", "minor", "micro", "none"
natural: false, // all tick marks should be made on natural numbers
leftBottom: true, // position of the axis, used with "vertical" - deprecated: use position instead
includeZero: false, // 0 should be included
fixed: true, // all labels are fixed numbers
majorLabels: true, // draw major labels
minorTicks: true, // draw minor ticks
minorLabels: true, // draw minor labels
microTicks: false, // draw micro ticks
rotation: 0, // label rotation angle in degrees
htmlLabels: true, // use HTML to draw labels
enableCache: false, // whether we cache or not
dropLabels: true, // whether we automatically drop overlapping labels or not
labelSizeChange: false, // whether the labels size change on zoom
position: "leftOrBottom" // position of the axis: "leftOrBottom" (default), "center" or "rightOrTop"
},
optionalParams: {
min: 0, // minimal value on this axis
max: 1, // maximal value on this axis
from: 0, // visible from this value
to: 1, // visible to this value
majorTickStep: 4, // major tick step
minorTickStep: 2, // minor tick step
microTickStep: 1, // micro tick step
labels: [], // array of labels for major ticks
// with corresponding numeric values
// ordered by values
labelFunc: null, // function to compute label values
maxLabelSize: 0, // size in px. For use with labelFunc
maxLabelCharCount: 0, // size in word count.
trailingSymbol: null,
// TODO: add support for minRange!
// minRange: 1, // smallest distance from min allowed on the axis
// theme components
stroke: {}, // stroke for an axis
majorTick: {}, // stroke + length for a tick
minorTick: {}, // stroke + length for a tick
microTick: {}, // stroke + length for a tick
tick: {}, // stroke + length for a tick
font: "", // font for labels
fontColor: "", // color for labels as a string
title: "", // axis title
titleGap: 0, // gap between axis title and axis label
titleFont: "", // axis title font
titleFontColor: "", // axis title font color
titleOrientation: "" // "axis" means the title facing the axis, "away" means facing away
},
constructor: function(chart, kwArgs){
// summary:
// The constructor for an axis.
// chart: dojox/charting/Chart
// The chart the axis belongs to.
// kwArgs: __AxisCtorArgs?
// Any optional keyword arguments to be used to define this axis.
this.opt = lang.clone(this.defaultParams);
du.updateWithObject(this.opt, kwArgs);
du.updateWithPattern(this.opt, kwArgs, this.optionalParams);
if(this.opt.enableCache){
this._textFreePool = [];
this._lineFreePool = [];
this._textUsePool = [];
this._lineUsePool = [];
}
this._invalidMaxLabelSize = true;
// replace deprecated leftBotton to position
if(!(kwArgs && ('position' in kwArgs))){
this.opt.position = this.opt.leftBottom ? "leftOrBottom" : "rightOrTop";
}
this.renderingOptions = { "shape-rendering": "crispEdges" };
},
setWindow: function(scale, offset){
// summary:
// Set the drawing "window" for the axis.
// scale: Number
// The new scale for the axis.
// offset: Number
// The new offset for the axis.
// returns: dojox/charting/axis2d/Default
// The reference to the axis for functional chaining.
if(scale != this.scale){
// if scale changed we need to recompute new max label size
this._invalidMaxLabelSize = true;
}
return this.inherited(arguments);
},
_groupLabelWidth: function(labels, font, wcLimit){
if(!labels.length){
return 0;
}
if(labels.length > 50){
// let's avoid degenerated cases
labels.length = 50;
}
if(lang.isObject(labels[0])){
labels = df.map(labels, function(label){ return label.text; });
}
if(wcLimit){
labels = df.map(labels, function(label){
return lang.trim(label).length == 0 ? "" : label.substring(0, wcLimit) + this.trailingSymbol;
}, this);
}
var s = labels.join(" ");
return g._base._getTextBox(s, {font: font}).w || 0;
},
_getMaxLabelSize: function(min, max, span, rotation, font, size){
if(this._maxLabelSize == null && arguments.length == 6){
var o = this.opt;
// everything might have changed, reset the minMinorStep value
this.scaler.minMinorStep = this._prevMinMinorStep = 0;
var ob = lang.clone(o);
delete ob.to;
delete ob.from;
// build all the ticks from min, to max not from to to _but_ using the step
// that would be used if we where just displaying from to to from.
var sb = lin.buildScaler(min, max, span, ob, o.to - o.from);
sb.minMinorStep = 0;
this._majorStart = sb.major.start;
// we build all the ticks not only the ones we need to draw in order to get
// a correct drop rate computation that works for any offset of this scale
var tb = lin.buildTicks(sb, o);
// if there is not tick at all tb is null
if(size && tb){
var majLabelW = 0, minLabelW = 0; // non rotated versions
// we first collect all labels when needed
var tickLabelFunc = function(tick){
if(tick.label){
this.push(tick.label);
}
};
var labels = [];
if(this.opt.majorLabels){
arr.forEach(tb.major, tickLabelFunc, labels);
majLabelW = this._groupLabelWidth(labels, font, ob.maxLabelCharCount);
if(ob.maxLabelSize){
majLabelW = Math.min(ob.maxLabelSize, majLabelW);
}
}
// do the minor labels computation only if dropLabels is set
labels = [];
if(this.opt.dropLabels && this.opt.minorLabels){
arr.forEach(tb.minor, tickLabelFunc, labels);
minLabelW = this._groupLabelWidth(labels, font, ob.maxLabelCharCount);
if(ob.maxLabelSize){
minLabelW = Math.min(ob.maxLabelSize, minLabelW);
}
}
this._maxLabelSize = {
majLabelW: majLabelW, minLabelW: minLabelW,
majLabelH: size, minLabelH: size
};
}else{
this._maxLabelSize = null;
}
}
return this._maxLabelSize;
},
calculate: function(min, max, span){
this.inherited(arguments);
// when the scale has not changed there is no reason for minMinorStep to change
this.scaler.minMinorStep = this._prevMinMinorStep;
// we want to recompute the dropping mechanism only when the scale or the size of the axis is changing
// not when for example when we scroll (otherwise effect would be weird)
if((this._invalidMaxLabelSize || span != this._oldSpan) && (min != Infinity && max != -Infinity)){
this._invalidMaxLabelSize = false;
if(this.opt.labelSizeChange){
this._maxLabelSize = null;
}
this._oldSpan = span;
var o = this.opt;
var ta = this.chart.theme.axis, rotation = o.rotation % 360,
labelGap = this.chart.theme.axis.tick.labelGap,
// TODO: we use one font --- of major tick, we need to use major and minor fonts
font = o.font || (ta.majorTick && ta.majorTick.font) || (ta.tick && ta.tick.font),
size = font ? g.normalizedLength(g.splitFontString(font).size) : 0,
// even if we don't drop label we need to compute max size for offsets
labelW = this._getMaxLabelSize(min, max, span, rotation, font, size);
if(typeof labelGap != "number"){
labelGap = 4; // in pixels
}
if(labelW && o.dropLabels){
var cosr = Math.abs(Math.cos(rotation * Math.PI / 180)),
sinr = Math.abs(Math.sin(rotation * Math.PI / 180));
var majLabelW, minLabelW;
if(rotation < 0){
rotation += 360;
}
switch(rotation){
case 0:
case 180:
// trivial cases: horizontal labels
if(this.vertical){
majLabelW = minLabelW = size;
}else{
majLabelW = labelW.majLabelW;
minLabelW = labelW.minLabelW;
}
break;
case 90:
case 270:
// trivial cases: vertical
if(this.vertical){
majLabelW = labelW.majLabelW;
minLabelW = labelW.minLabelW;
}else{
majLabelW = minLabelW = size;
}
break;
default:
// all major labels are parallel they can't collapse except if the two ticks are
// closer than the height of the text * cos(90-rotation)
majLabelW = this.vertical ? Math.min(labelW.majLabelW, size / cosr) : Math.min(labelW.majLabelW, size / sinr);
// for minor labels we need to rotated them
var gap1 = Math.sqrt(labelW.minLabelW * labelW.minLabelW + size * size),
gap2 = this.vertical ? size * cosr + labelW.minLabelW * sinr : labelW.minLabelW * cosr + size * sinr;
minLabelW = Math.min(gap1, gap2);
break;
}
// we need to check both minor and major labels fit a minor step
this.scaler.minMinorStep = this._prevMinMinorStep = Math.max(majLabelW, minLabelW) + labelGap;
var canMinorLabel = this.scaler.minMinorStep <= this.scaler.minor.tick * this.scaler.bounds.scale;
if(!canMinorLabel){
// we can't place minor labels, let's see if we can place major ones
// in a major step and if not which skip interval we must follow
this._skipInterval = Math.floor((majLabelW + labelGap) / (this.scaler.major.tick * this.scaler.bounds.scale));
}else{
// everything fit well
this._skipInterval = 0;
}
}else{
// drop label disabled
this._skipInterval = 0;
}
}
// computes the tick subset we need for that scale/offset
this.ticks = lin.buildTicks(this.scaler, this.opt);
return this;
},
getOffsets: function(){
// summary:
// Get the physical offset values for this axis (used in drawing data series). This method is not
// supposed to be called by the users but internally.
// returns: Object
// The calculated offsets in the form of { l, r, t, b } (left, right, top, bottom).
var s = this.scaler, offsets = { l: 0, r: 0, t: 0, b: 0 };
if(!s){
return offsets;
}
var o = this.opt,
ta = this.chart.theme.axis,
labelGap = this.chart.theme.axis.tick.labelGap,
// TODO: we use one font --- of major tick, we need to use major and minor fonts
taTitleFont = o.titleFont || (ta.title && ta.title.font),
taTitleGap = (o.titleGap==0) ? 0 : o.titleGap || (ta.title && ta.title.gap),
taMajorTick = this.chart.theme.getTick("major", o),
taMinorTick = this.chart.theme.getTick("minor", o),
tsize = taTitleFont ? g.normalizedLength(g.splitFontString(taTitleFont).size) : 0,
rotation = o.rotation % 360, position = o.position,
leftBottom = position !== "rightOrTop",
cosr = Math.abs(Math.cos(rotation * Math.PI / 180)),
sinr = Math.abs(Math.sin(rotation * Math.PI / 180));
this.trailingSymbol = (o.trailingSymbol === undefined || o.trailingSymbol === null) ?
this.trailingSymbol : o.trailingSymbol;
if(typeof labelGap != "number"){
labelGap = 4; // in pixels
}
if(rotation < 0){
rotation += 360;
}
var maxLabelSize = this._getMaxLabelSize(); // don't need parameters, calculate has been called before => we use cached value
if(maxLabelSize){
var side;
var labelWidth = Math.ceil(Math.max(maxLabelSize.majLabelW, maxLabelSize.minLabelW)) + 1,
size = Math.ceil(Math.max(maxLabelSize.majLabelH, maxLabelSize.minLabelH)) + 1;
if(this.vertical){
side = leftBottom ? "l" : "r";
switch(rotation){
case 0:
case 180:
offsets[side] = position === "center" ? 0 : labelWidth;
offsets.t = offsets.b = size / 2;
break;
case 90:
case 270:
offsets[side] = size;
offsets.t = offsets.b = labelWidth / 2;
break;
default:
if(rotation <= centerAnchorLimit || (180 < rotation && rotation <= (180 + centerAnchorLimit))){
offsets[side] = size * sinr / 2 + labelWidth * cosr;
offsets[leftBottom ? "t" : "b"] = size * cosr / 2 + labelWidth * sinr;
offsets[leftBottom ? "b" : "t"] = size * cosr / 2;
}else if(rotation > (360 - centerAnchorLimit) || (180 > rotation && rotation > (180 - centerAnchorLimit))){
offsets[side] = size * sinr / 2 + labelWidth * cosr;
offsets[leftBottom ? "b" : "t"] = size * cosr / 2 + labelWidth * sinr;
offsets[leftBottom ? "t" : "b"] = size * cosr / 2;
}else if(rotation < 90 || (180 < rotation && rotation < 270)){
offsets[side] = size * sinr + labelWidth * cosr;
offsets[leftBottom ? "t" : "b"] = size * cosr + labelWidth * sinr;
}else{
offsets[side] = size * sinr + labelWidth * cosr;
offsets[leftBottom ? "b" : "t"] = size * cosr + labelWidth * sinr;
}
break;
}
if(position === "center"){
offsets[side] = 0;
}
else{
offsets[side] += labelGap + Math.max(taMajorTick.length > 0?taMajorTick.length:0,
taMinorTick.length > 0?taMinorTick.length:0) + (o.title ? (tsize + taTitleGap) : 0);
}
}else{
side = leftBottom ? "b" : "t";
switch(rotation){
case 0:
case 180:
offsets[side] = position === "center" ? 0 : size;
offsets.l = offsets.r = labelWidth / 2;
break;
case 90:
case 270:
offsets[side] = labelWidth;
offsets.l = offsets.r = size / 2;
break;
default:
if((90 - centerAnchorLimit) <= rotation && rotation <= 90 || (270 - centerAnchorLimit) <= rotation && rotation <= 270){
offsets[side] = size * cosr / 2 + labelWidth * sinr;
offsets[leftBottom ? "r" : "l"] = size * sinr / 2 + labelWidth * cosr;
offsets[leftBottom ? "l" : "r"] = size * sinr / 2;
}else if(90 <= rotation && rotation <= (90 + centerAnchorLimit) || 270 <= rotation && rotation <= (270 + centerAnchorLimit)){
offsets[side] = size * cosr / 2 + labelWidth * sinr;
offsets[leftBottom ? "l" : "r"] = size * sinr / 2 + labelWidth * cosr;
offsets[leftBottom ? "r" : "l"] = size * sinr / 2;
}else if(rotation < centerAnchorLimit || (180 < rotation && rotation < (180 + centerAnchorLimit))){
offsets[side] = size * cosr + labelWidth * sinr;
offsets[leftBottom ? "r" : "l"] = size * sinr + labelWidth * cosr;
}else{
offsets[side] = size * cosr + labelWidth * sinr;
offsets[leftBottom ? "l" : "r"] = size * sinr + labelWidth * cosr;
}
break;
}
if(position === "center"){
offsets[side] = 0;
}
else{
offsets[side] += labelGap + Math.max(taMajorTick.length > 0?taMajorTick.length:0,
taMinorTick.length > 0?taMinorTick.length:0) + (o.title ? (tsize + taTitleGap) : 0);
}
}
}
return offsets; // Object
},
cleanGroup: function(creator){
if(this.opt.enableCache && this.group){
this._lineFreePool = this._lineFreePool.concat(this._lineUsePool);
this._lineUsePool = [];
this._textFreePool = this._textFreePool.concat(this._textUsePool);
this._textUsePool = [];
}
this.inherited(arguments);
},
createText: function(labelType, creator, x, y, align, textContent, font, fontColor, labelWidth){
if(!this.opt.enableCache || labelType=="html"){
return acommon.createText[labelType](
this.chart,
creator,
x,
y,
align,
textContent,
font,
fontColor,
labelWidth
);
}
var text;
if(this._textFreePool.length > 0){
text = this._textFreePool.pop();
text.setShape({x: x, y: y, text: textContent, align: align});
// For now all items share the same font, no need to re-set it
//.setFont(font).setFill(fontColor);
// was cleared, add it back
creator.add(text);
}else{
text = acommon.createText[labelType](
this.chart,
creator,
x,
y,
align,
textContent,
font,
fontColor
);
}
this._textUsePool.push(text);
return text;
},
createLine: function(creator, params){
var line;
if(this.opt.enableCache && this._lineFreePool.length > 0){
line = this._lineFreePool.pop();
line.setShape(params);
// was cleared, add it back
creator.add(line);
}else{
line = creator.createLine(params);
}
if(this.opt.enableCache){
this._lineUsePool.push(line);
}
return line;
},
render: function(dim, offsets){
// summary:
// Render/draw the axis.
// dim: Object
// An object of the form { width, height}.
// offsets: Object
// An object of the form { l, r, t, b }.
// returns: dojox/charting/axis2d/Default
// The reference to the axis for functional chaining.
var isRtl = this._isRtl(); // chart mirroring
if(!this.dirty || !this.scaler){
return this; // dojox/charting/axis2d/Default
}
// prepare variable
var o = this.opt, ta = this.chart.theme.axis, position = o.position,
leftBottom = position !== "rightOrTop", rotation = o.rotation % 360,
start, stop, titlePos, titleRotation=0, titleOffset, axisVector, tickVector, anchorOffset, labelOffset, labelAlign,
labelGap = this.chart.theme.axis.tick.labelGap,
// TODO: we use one font --- of major tick, we need to use major and minor fonts
taFont = o.font || (ta.majorTick && ta.majorTick.font) || (ta.tick && ta.tick.font),
taTitleFont = o.titleFont || (ta.title && ta.title.font),
// TODO: we use one font color --- we need to use different colors
taFontColor = o.fontColor || (ta.majorTick && ta.majorTick.fontColor) || (ta.tick && ta.tick.fontColor) || "black",
taTitleFontColor = o.titleFontColor || (ta.title && ta.title.fontColor) || "black",
taTitleGap = (o.titleGap==0) ? 0 : o.titleGap || (ta.title && ta.title.gap) || 15,
taTitleOrientation = o.titleOrientation || (ta.title && ta.title.orientation) || "axis",
taMajorTick = this.chart.theme.getTick("major", o),
taMinorTick = this.chart.theme.getTick("minor", o),
taMicroTick = this.chart.theme.getTick("micro", o),
taStroke = "stroke" in o ? o.stroke : ta.stroke,
size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0,
cosr = Math.abs(Math.cos(rotation * Math.PI / 180)),
sinr = Math.abs(Math.sin(rotation * Math.PI / 180)),
tsize = taTitleFont ? g.normalizedLength(g.splitFontString(taTitleFont).size) : 0;
if(typeof labelGap != "number"){
labelGap = 4; // in pixels
}
if(rotation < 0){
rotation += 360;
}
var cachedLabelW = this._getMaxLabelSize();
cachedLabelW = cachedLabelW && cachedLabelW.majLabelW;
if(this.vertical){
start = {y: dim.height - offsets.b};
stop = {y: offsets.t};
titlePos = {y: (dim.height - offsets.b + offsets.t)/2};
titleOffset = size * sinr + (cachedLabelW || 0) * cosr + labelGap + Math.max(taMajorTick.length > 0?taMajorTick.length:0,
taMinorTick.length > 0?taMinorTick.length:0) +
tsize + taTitleGap;
axisVector = {x: 0, y: -1};
labelOffset = {x: 0, y: 0};
tickVector = {x: 1, y: 0};
anchorOffset = {x: labelGap, y: 0};
switch(rotation){
case 0:
labelAlign = "end";
labelOffset.y = size * 0.4;
break;
case 90:
labelAlign = "middle";
labelOffset.x = -size;
break;
case 180:
labelAlign = "start";
labelOffset.y = -size * 0.4;
break;
case 270:
labelAlign = "middle";
break;
default:
if(rotation < centerAnchorLimit){
labelAlign = "end";
labelOffset.y = size * 0.4;
}else if(rotation < 90){
labelAlign = "end";
labelOffset.y = size * 0.4;
}else if(rotation < (180 - centerAnchorLimit)){
labelAlign = "start";
}else if(rotation < (180 + centerAnchorLimit)){
labelAlign = "start";
labelOffset.y = -size * 0.4;
}else if(rotation < 270){
labelAlign = "start";
labelOffset.x = leftBottom ? 0 : size * 0.4;
}else if(rotation < (360 - centerAnchorLimit)){
labelAlign = "end";
labelOffset.x = leftBottom ? 0 : size * 0.4;
}else{
labelAlign = "end";
labelOffset.y = size * 0.4;
}
}
if(leftBottom){
start.x = stop.x = position === "center" ? dim.width/2 : offsets.l;
titleRotation = (taTitleOrientation && taTitleOrientation == "away") ? 90 : 270;
titlePos.x = offsets.l - titleOffset + (titleRotation == 270 ? tsize : 0);
tickVector.x = -1;
anchorOffset.x = -anchorOffset.x;
}else{
start.x = stop.x = dim.width - offsets.r;
titleRotation = (taTitleOrientation && taTitleOrientation == "axis") ? 90 : 270;
titlePos.x = dim.width - offsets.r + titleOffset - (titleRotation == 270 ? 0 : tsize);
switch(labelAlign){
case "start":
labelAlign = "end";
break;
case "end":
labelAlign = "start";
break;
case "middle":
labelOffset.x += size;
break;
}
}
}else{
start = {x: offsets.l};
stop = {x: dim.width - offsets.r};
titlePos = {x: (dim.width - offsets.r + offsets.l)/2};
titleOffset = size * cosr + (cachedLabelW || 0) * sinr + labelGap + Math.max(taMajorTick.length > 0?taMajorTick.length:0,
taMinorTick.length > 0?taMinorTick.length:0) +
tsize + taTitleGap;
axisVector = {x: isRtl ? -1 : 1, y: 0}; // chart mirroring
labelOffset = {x: 0, y: 0};
tickVector = {x: 0, y: 1};
anchorOffset = {x: 0, y: labelGap};
switch(rotation){
case 0:
labelAlign = "middle";
labelOffset.y = size;
break;
case 90:
labelAlign = "start";
labelOffset.x = -size * 0.4;
break;
case 180:
labelAlign = "middle";
break;
case 270:
labelAlign = "end";
labelOffset.x = size * 0.4;
break;
default:
if(rotation < (90 - centerAnchorLimit)){
labelAlign = "start";
labelOffset.y = leftBottom ? size : 0;
}else if(rotation < (90 + centerAnchorLimit)){
labelAlign = "start";
labelOffset.x = -size * 0.4;
}else if(rotation < 180){
labelAlign = "start";
labelOffset.y = leftBottom ? 0 : -size;
}else if(rotation < (270 - centerAnchorLimit)){
labelAlign = "end";
labelOffset.y = leftBottom ? 0 : -size;
}else if(rotation < (270 + centerAnchorLimit)){
labelAlign = "end";
labelOffset.y = leftBottom ? size * 0.4 : 0;
}else{
labelAlign = "end";
labelOffset.y = leftBottom ? size : 0;
}
}
if(leftBottom){
start.y = stop.y = position === "center" ? dim.height/2 : dim.height - offsets.b;
titleRotation = (taTitleOrientation && taTitleOrientation == "axis") ? 180 : 0;
titlePos.y = dim.height - offsets.b + titleOffset - (titleRotation ? tsize : 0);
}else{
start.y = stop.y = offsets.t;
titleRotation = (taTitleOrientation && taTitleOrientation == "away") ? 180 : 0;
titlePos.y = offsets.t - titleOffset + (titleRotation ? 0 : tsize);
tickVector.y = -1;
anchorOffset.y = -anchorOffset.y;
switch(labelAlign){
case "start":
labelAlign = "end";
break;
case "end":
labelAlign = "start";
break;
case "middle":
labelOffset.y -= size;
break;
}
}
}
// render shapes
this.cleanGroup();
var s = this.group,
c = this.scaler,
t = this.ticks,
f = lin.getTransformerFromModel(this.scaler),
// GFX Canvas now supports labels, so let's _not_ fallback to HTML anymore on canvas, just use
// HTML labels if explicitly asked + no rotation + no IE + no Opera
labelType = (!o.title || !titleRotation) && !rotation && this.opt.htmlLabels && !has("ie") && !has("opera") ? "html" : "gfx",
dx = tickVector.x * taMajorTick.length,
dy = tickVector.y * taMajorTick.length,
skip = this._skipInterval;
s.createLine({
x1: start.x,
y1: start.y,
x2: stop.x,
y2: stop.y
}).setStroke(taStroke);
//create axis title
if(o.title){
var axisTitle = acommon.createText[labelType](
this.chart,
s,
titlePos.x,
titlePos.y,
"middle",
o.title,
taTitleFont,
taTitleFontColor
);
if(labelType == "html"){
this.htmlElements.push(axisTitle);
}else{
//as soon as rotation is provided, labelType won't be "html"
//rotate gfx labels
axisTitle.setTransform(g.matrix.rotategAt(titleRotation, titlePos.x, titlePos.y));
}
}
// go out nicely instead of try/catch
if(t == null){
this.dirty = false;
return this;
}
var rel = (t.major.length > 0)?(t.major[0].value - this._majorStart) / c.major.tick:0;
var canLabel = this.opt.majorLabels;
arr.forEach(t.major, function(tick, i){
var offset = f(tick.value), elem,
x = (isRtl ? stop.x : start.x) + axisVector.x * offset, // chart mirroring
y = start.y + axisVector.y * offset;
i += rel;
this.createLine(s, {
x1: x, y1: y,
x2: x + dx,
y2: y + dy
}).setStroke(taMajorTick);
if(tick.label && (!skip || (i - (1 + skip)) % (1 + skip) == 0)){
var label = o.maxLabelCharCount ? this.getTextWithLimitCharCount(tick.label, taFont, o.maxLabelCharCount) : {
text: tick.label,
truncated: false
};
label = o.maxLabelSize ? this.getTextWithLimitLength(label.text, taFont, o.maxLabelSize, label.truncated) : label;
elem = this.createText(labelType,
s,
x + (taMajorTick.length > 0 ? dx : 0) + anchorOffset.x + (rotation ? 0 : labelOffset.x),
y + (taMajorTick.length > 0 ? dy : 0) + anchorOffset.y + (rotation ? 0 : labelOffset.y),
labelAlign,
label.text,
taFont,
taFontColor
//cachedLabelW
);
// if bidi support was required, the textDir is "auto" and truncation
// took place, we need to update the dir of the element for cases as:
// Fool label: 111111W (W for bidi character)
// truncated label: 11...
// in this case for auto textDir the dir will be "ltr" which is wrong.
if(label.truncated){
this.chart.formatTruncatedLabel(elem, tick.label, labelType);
}
label.truncated && this.labelTooltip(elem, this.chart, tick.label, label.text, taFont, labelType);
if(labelType == "html"){
this.htmlElements.push(elem);
}else if(rotation){
elem.setTransform([
{dx: labelOffset.x, dy: labelOffset.y},
g.matrix.rotategAt(
rotation,
x + (taMajorTick.length > 0 ? dx : 0) + anchorOffset.x,
y + (taMajorTick.length > 0 ? dy : 0) + anchorOffset.y
)
]);
}
}
}, this);
dx = tickVector.x * taMinorTick.length;
dy = tickVector.y * taMinorTick.length;
canLabel = this.opt.minorLabels && c.minMinorStep <= c.minor.tick * c.bounds.scale;
arr.forEach(t.minor, function(tick){
var offset = f(tick.value), elem,
x = (isRtl ? stop.x : start.x) + axisVector.x * offset,
y = start.y + axisVector.y * offset; // chart mirroring
this.createLine(s, {
x1: x, y1: y,
x2: x + dx,
y2: y + dy
}).setStroke(taMinorTick);
if(canLabel && tick.label){
var label = o.maxLabelCharCount ? this.getTextWithLimitCharCount(tick.label, taFont, o.maxLabelCharCount) : {
text: tick.label,
truncated: false
};
label = o.maxLabelSize ? this.getTextWithLimitLength(label.text, taFont, o.maxLabelSize, label.truncated) : label;
elem = this.createText(labelType,
s,
x + (taMinorTick.length > 0 ? dx : 0) + anchorOffset.x + (rotation ? 0 : labelOffset.x),
y + (taMinorTick.length > 0 ? dy : 0) + anchorOffset.y + (rotation ? 0 : labelOffset.y),
labelAlign,
label.text,
taFont,
taFontColor
//cachedLabelW
);
// if bidi support was required, the textDir is "auto" and truncation
// took place, we need to update the dir of the element for cases as:
// Fool label: 111111W (W for bidi character)
// truncated label: 11...
// in this case for auto textDir the dir will be "ltr" which is wrong.
if(label.truncated){
this.chart.formatTruncatedLabel(elem, tick.label, labelType);
}
label.truncated && this.labelTooltip(elem, this.chart, tick.label, label.text, taFont, labelType);
if(labelType == "html"){
this.htmlElements.push(elem);
}else if(rotation){
elem.setTransform([
{dx: labelOffset.x, dy: labelOffset.y},
g.matrix.rotategAt(
rotation,
x + (taMinorTick.length > 0 ? dx : 0) + anchorOffset.x,
y + (taMinorTick.length > 0 ? dy : 0) + anchorOffset.y
)
]);
}
}
}, this);
dx = tickVector.x * taMicroTick.length;
dy = tickVector.y * taMicroTick.length;
arr.forEach(t.micro, function(tick){
var offset = f(tick.value),
x = start.x + axisVector.x * offset,
y = start.y + axisVector.y * offset;
this.createLine(s, {
x1: x, y1: y,
x2: x + dx,
y2: y + dy
}).setStroke(taMicroTick);
}, this);
this.dirty = false;
return this; // dojox/charting/axis2d/Default
},
labelTooltip: function(elem, chart, label, truncatedLabel, font, elemType){
var modules = ["dijit/Tooltip"];
var aroundRect = {type: "rect"}, position = ["above", "below"],
fontWidth = g._base._getTextBox(truncatedLabel, {font: font}).w || 0,
fontHeight = font ? g.normalizedLength(g.splitFontString(font).size) : 0;
if(elemType == "html"){
lang.mixin(aroundRect, domGeom.position(elem.firstChild, true));
aroundRect.width = Math.ceil(fontWidth);
aroundRect.height = Math.ceil(fontHeight);
this._events.push({
shape: dojo,
handle: connect.connect(elem.firstChild, "onmouseover", this, function(e){
require(modules, function(Tooltip){
Tooltip.show(label, aroundRect, position);
});
})
});
this._events.push({
shape: dojo,
handle: connect.connect(elem.firstChild, "onmouseout", this, function(e){
require(modules, function(Tooltip){
Tooltip.hide(aroundRect);
});
})
});
}else{
var shp = elem.getShape(),
lt = chart.getCoords();
aroundRect = lang.mixin(aroundRect, {
x: shp.x - fontWidth / 2,
y: shp.y
});
aroundRect.x += lt.x;
aroundRect.y += lt.y;
aroundRect.x = Math.round(aroundRect.x);
aroundRect.y = Math.round(aroundRect.y);
aroundRect.width = Math.ceil(fontWidth);
aroundRect.height = Math.ceil(fontHeight);
this._events.push({
shape: elem,
handle: elem.connect("onmouseenter", this, function(e){
require(modules, function(Tooltip){
Tooltip.show(label, aroundRect, position);
});
})
});
this._events.push({
shape: elem,
handle: elem.connect("onmouseleave", this, function(e){
require(modules, function(Tooltip){
Tooltip.hide(aroundRect);
});
})
});
}
},
_isRtl: function(){
return false;
}
});
return has("dojo-bidi")? declare("dojox.charting.axis2d.Default", [Default, BidiDefault]) : Default;
});
},
'dojox/charting/axis2d/Invisible':function(){
define(["dojo/_base/lang", "dojo/_base/declare", "./Base", "../scaler/linear",
"dojox/lang/utils"],
function(lang, declare, Base, lin, du){
/*=====
var __InvisibleAxisCtorArgs = {
// summary:
// Optional arguments used in the definition of an invisible axis.
// vertical: Boolean?
// A flag that says whether an axis is vertical (i.e. y axis) or horizontal. Default is false (horizontal).
// fixUpper: String?
// Align the greatest value on the axis with the specified tick level. Options are "major", "minor", "micro", or "none". Defaults to "none".
// fixLower: String?
// Align the smallest value on the axis with the specified tick level. Options are "major", "minor", "micro", or "none". Defaults to "none".
// natural: Boolean?
// Ensure tick marks are made on "natural" numbers. Defaults to false.
// leftBottom: Boolean?
// The position of a vertical axis; if true, will be placed against the left-bottom corner of the chart. Defaults to true.
// includeZero: Boolean?
// Include 0 on the axis rendering. Default is false.
// fixed: Boolean?
// Force all axis labels to be fixed numbers. Default is true.
// min: Number?
// The smallest value on an axis. Default is 0.
// max: Number?
// The largest value on an axis. Default is 1.
// from: Number?
// Force the chart to render data visible from this value. Default is 0.
// to: Number?
// Force the chart to render data visible to this value. Default is 1.
// majorTickStep: Number?
// The amount to skip before a major tick is drawn. When not set the major ticks step is computed from
// the data range.
// minorTickStep: Number?
// The amount to skip before a minor tick is drawn. When not set the minor ticks step is computed from
// the data range.
// microTickStep: Number?
// The amount to skip before a micro tick is drawn. When not set the micro ticks step is computed from
};
=====*/
return declare("dojox.charting.axis2d.Invisible", Base, {
// summary:
// A axis object used in dojox.charting. You can use that axis if you want the axis to be invisible.
// See dojox.charting.Chart.addAxis for details.
//
// defaultParams: Object
// The default parameters used to define any axis.
// optionalParams: Object
// Any optional parameters needed to define an axis.
/*
// TODO: the documentation tools need these to be pre-defined in order to pick them up
// correctly, but the code here is partially predicated on whether or not the properties
// actually exist. For now, we will leave these undocumented but in the code for later. -- TRT
// opt: Object
// The actual options used to define this axis, created at initialization.
// scaler: Object
// The calculated helper object to tell charts how to draw an axis and any data.
// ticks: Object
// The calculated tick object that helps a chart draw the scaling on an axis.
// dirty: Boolean
// The state of the axis (whether it needs to be redrawn or not)
// scale: Number
// The current scale of the axis.
// offset: Number
// The current offset of the axis.
opt: null,
scaler: null,
ticks: null,
dirty: true,
scale: 1,
offset: 0,
*/
defaultParams: {
vertical: false, // true for vertical axis
fixUpper: "none", // align the upper on ticks: "major", "minor", "micro", "none"
fixLower: "none", // align the lower on ticks: "major", "minor", "micro", "none"
natural: false, // all tick marks should be made on natural numbers
leftBottom: true, // position of the axis, used with "vertical"
includeZero: false, // 0 should be included
fixed: true // all labels are fixed numbers
},
optionalParams: {
min: 0, // minimal value on this axis
max: 1, // maximal value on this axis
from: 0, // visible from this value
to: 1, // visible to this value
majorTickStep: 4, // major tick step
minorTickStep: 2, // minor tick step
microTickStep: 1 // micro tick step
},
constructor: function(chart, kwArgs){
// summary:
// The constructor for an invisible axis.
// chart: dojox/charting/Chart
// The chart the axis belongs to.
// kwArgs: __InvisibleAxisCtorArgs?
// Any optional keyword arguments to be used to define this axis.
this.opt = lang.clone(this.defaultParams);
du.updateWithObject(this.opt, kwArgs);
du.updateWithPattern(this.opt, kwArgs, this.optionalParams);
},
dependOnData: function(){
// summary:
// Find out whether or not the axis options depend on the data in the axis.
return !("min" in this.opt) || !("max" in this.opt); // Boolean
},
clear: function(){
// summary:
// Clear out all calculated properties on this axis;
// returns: dojox/charting/axis2d/Invisible
// The reference to the axis for functional chaining.
delete this.scaler;
delete this.ticks;
this.dirty = true;
return this; // dojox/charting/axis2d/Invisible
},
initialized: function(){
// summary:
// Finds out if this axis has been initialized or not.
// returns: Boolean
// Whether a scaler has been calculated and if the axis is not dirty.
return "scaler" in this && !(this.dirty && this.dependOnData());
},
setWindow: function(scale, offset){
// summary:
// Set the drawing "window" for the axis.
// scale: Number
// The new scale for the axis.
// offset: Number
// The new offset for the axis.
// returns: dojox/charting/axis2d/Invisible
// The reference to the axis for functional chaining.
this.scale = scale;
this.offset = offset;
return this.clear(); // dojox/charting/axis2d/Invisible
},
getWindowScale: function(){
// summary:
// Get the current windowing scale of the axis.
return "scale" in this ? this.scale : 1; // Number
},
getWindowOffset: function(){
// summary:
// Get the current windowing offset for the axis.
return "offset" in this ? this.offset : 0; // Number
},
calculate: function(min, max, span, scalerType){
// summary:
// Perform all calculations needed to render this axis.
// min: Number
// The smallest value represented on this axis.
// max: Number
// The largest value represented on this axis.
// span: Number
// The span in pixels over which axis calculations are made.
// scalerType: Object
// An optional scaler type object.
// returns: dojox/charting/axis2d/Invisible
// The reference to the axis for functional chaining.
if(this.initialized()){
return this;
}
var o = this.opt;
// we used to have a 4th function parameter to reach labels but
// nobody was calling it with 4 parameters.
this.labels = o.labels;
this.scaler = (scalerType || lin).buildScaler(min, max, span, o);
// store the absolute major tick start, this will be useful when dropping a label every n labels
// TODO: if o.lower then it does not work
var tsb = this.scaler.bounds;
if("scale" in this){
// calculate new range
o.from = tsb.lower + this.offset;
o.to = (tsb.upper - tsb.lower) / this.scale + o.from;
// make sure that bounds are correct
if( !isFinite(o.from) ||
isNaN(o.from) ||
!isFinite(o.to) ||
isNaN(o.to) ||
o.to - o.from >= tsb.upper - tsb.lower
){
// any error --- remove from/to bounds
delete o.from;
delete o.to;
delete this.scale;
delete this.offset;
}else{
// shift the window, if we are out of bounds
if(o.from < tsb.lower){
o.to += tsb.lower - o.from;
o.from = tsb.lower;
}else if(o.to > tsb.upper){
o.from += tsb.upper - o.to;
o.to = tsb.upper;
}
// update the offset
this.offset = o.from - tsb.lower;
}
// re-calculate the scaler
this.scaler = (scalerType || lin).buildScaler(min, max, span, o);
tsb = this.scaler.bounds;
// cleanup
if(this.scale == 1 && this.offset == 0){
delete this.scale;
delete this.offset;
}
}
return this; // dojox/charting/axis2d/Invisible
},
getScaler: function(){
// summary:
// Get the pre-calculated scaler object.
return this.scaler; // Object
},
getTicks: function(){
// summary:
// Get the pre-calculated ticks object.
return this.ticks; // Object
}
});
});
},
'dojox/charting/axis2d/Base':function(){
define(["dojo/_base/declare", "../Element"],
function(declare, Element){
/*=====
var __BaseAxisCtorArgs = {
// summary:
// Optional arguments used in the definition of an invisible axis.
// vertical: Boolean?
// A flag that says whether an axis is vertical (i.e. y axis) or horizontal. Default is false (horizontal).
// min: Number?
// The smallest value on an axis. Default is 0.
// max: Number?
// The largest value on an axis. Default is 1.
};
=====*/
return declare("dojox.charting.axis2d.Base", Element, {
// summary:
// The base class for any axis. This is more of an interface/API
// definition than anything else; see dojox.charting.axis2d.Default
// for more details.
constructor: function(chart, kwArgs){
// summary:
// Return a new base axis.
// chart: dojox/charting/Chart
// The chart this axis belongs to.
// kwArgs: __BaseAxisCtorArgs?
// An optional arguments object to define the axis parameters.
this.vertical = kwArgs && kwArgs.vertical;
this.opt = {};
this.opt.min = kwArgs && kwArgs.min;
this.opt.max = kwArgs && kwArgs.max;
},
clear: function(){
// summary:
// Stub function for clearing the axis.
// returns: dojox/charting/axis2d/Base
// A reference to the axis for functional chaining.
return this; // dojox/charting/axis2d/Base
},
initialized: function(){
// summary:
// Return a flag as to whether or not this axis has been initialized.
// returns: Boolean
// If the axis is initialized or not.
return false; // Boolean
},
calculate: function(min, max, span){
// summary:
// Stub function to run the calculations needed for drawing this axis.
// returns: dojox/charting/axis2d/Base
// A reference to the axis for functional chaining.
return this; // dojox/charting/axis2d/Base
},
getScaler: function(){
// summary:
// A stub function to return the scaler object created during calculate.
// returns: Object
// The scaler object (see dojox.charting.scaler.linear for more information)
return null; // Object
},
getTicks: function(){
// summary:
// A stub function to return the object that helps define how ticks are rendered.
// returns: Object
// The ticks object.
return null; // Object
},
getOffsets: function(){
// summary:
// A stub function to return any offsets needed for axis and series rendering.
// returns: Object
// An object of the form { l, r, t, b }.
return {l: 0, r: 0, t: 0, b: 0}; // Object
},
render: function(dim, offsets){
// summary:
// Stub function to render this axis.
// returns: dojox/charting/axis2d/Base
// A reference to the axis for functional chaining.
this.dirty = false;
return this; // dojox/charting/axis2d/Base
},
isNullValue: function(value){
// summary:
// A stub function to determine a data value
// that should be ignored.
// value: Number|Null|Object
// A data value to be inspected.
// returns: Boolean
// If the value makes sense for this axis or not.
return false;
},
naturalBaseline: 0
});
});
},
'dojox/charting/scaler/linear':function(){
define(["dojo/_base/lang", "./common"],
function(lang, common){
var linear = lang.getObject("dojox.charting.scaler.linear", true);
var deltaLimit = 3, // pixels
getLabel = common.getNumericLabel;
function findString(/*String*/ val, /*Array*/ text){
val = val.toLowerCase();
for(var i = text.length - 1; i >= 0; --i){
if(val === text[i]){
return true;
}
}
return false;
}
var calcTicks = function(min, max, kwArgs, majorTick, minorTick, microTick, span){
kwArgs = lang.delegate(kwArgs);
if(!majorTick){
if(kwArgs.fixUpper == "major"){ kwArgs.fixUpper = "minor"; }
if(kwArgs.fixLower == "major"){ kwArgs.fixLower = "minor"; }
}
if(!minorTick){
if(kwArgs.fixUpper == "minor"){ kwArgs.fixUpper = "micro"; }
if(kwArgs.fixLower == "minor"){ kwArgs.fixLower = "micro"; }
}
if(!microTick){
if(kwArgs.fixUpper == "micro"){ kwArgs.fixUpper = "none"; }
if(kwArgs.fixLower == "micro"){ kwArgs.fixLower = "none"; }
}
var lowerBound = findString(kwArgs.fixLower, ["major"]) ?
Math.floor(kwArgs.min / majorTick) * majorTick :
findString(kwArgs.fixLower, ["minor"]) ?
Math.floor(kwArgs.min / minorTick) * minorTick :
findString(kwArgs.fixLower, ["micro"]) ?
Math.floor(kwArgs.min / microTick) * microTick : kwArgs.min,
upperBound = findString(kwArgs.fixUpper, ["major"]) ?
Math.ceil(kwArgs.max / majorTick) * majorTick :
findString(kwArgs.fixUpper, ["minor"]) ?
Math.ceil(kwArgs.max / minorTick) * minorTick :
findString(kwArgs.fixUpper, ["micro"]) ?
Math.ceil(kwArgs.max / microTick) * microTick : kwArgs.max;
if(kwArgs.useMin){ min = lowerBound; }
if(kwArgs.useMax){ max = upperBound; }
var majorStart = (!majorTick || kwArgs.useMin && findString(kwArgs.fixLower, ["major"])) ?
min : Math.ceil(min / majorTick) * majorTick,
minorStart = (!minorTick || kwArgs.useMin && findString(kwArgs.fixLower, ["major", "minor"])) ?
min : Math.ceil(min / minorTick) * minorTick,
microStart = (! microTick || kwArgs.useMin && findString(kwArgs.fixLower, ["major", "minor", "micro"])) ?
min : Math.ceil(min / microTick) * microTick,
majorCount = !majorTick ? 0 : (kwArgs.useMax && findString(kwArgs.fixUpper, ["major"]) ?
Math.round((max - majorStart) / majorTick) :
Math.floor((max - majorStart) / majorTick)) + 1,
minorCount = !minorTick ? 0 : (kwArgs.useMax && findString(kwArgs.fixUpper, ["major", "minor"]) ?
Math.round((max - minorStart) / minorTick) :
Math.floor((max - minorStart) / minorTick)) + 1,
microCount = !microTick ? 0 : (kwArgs.useMax && findString(kwArgs.fixUpper, ["major", "minor", "micro"]) ?
Math.round((max - microStart) / microTick) :
Math.floor((max - microStart) / microTick)) + 1,
minorPerMajor = minorTick ? Math.round(majorTick / minorTick) : 0,
microPerMinor = microTick ? Math.round(minorTick / microTick) : 0,
majorPrecision = majorTick ? Math.floor(Math.log(majorTick) / Math.LN10) : 0,
minorPrecision = minorTick ? Math.floor(Math.log(minorTick) / Math.LN10) : 0,
scale = span / (max - min);
if(!isFinite(scale)){ scale = 1; }
return {
bounds: {
lower: lowerBound,
upper: upperBound,
from: min,
to: max,
scale: scale,
span: span
},
major: {
tick: majorTick,
start: majorStart,
count: majorCount,
prec: majorPrecision
},
minor: {
tick: minorTick,
start: minorStart,
count: minorCount,
prec: minorPrecision
},
micro: {
tick: microTick,
start: microStart,
count: microCount,
prec: 0
},
minorPerMajor: minorPerMajor,
microPerMinor: microPerMinor,
scaler: linear
};
};
return lang.mixin(linear, {
buildScaler: function(/*Number*/ min, /*Number*/ max, /*Number*/ span, /*Object*/ kwArgs, /*Number?*/ delta, /*Number?*/ minorDelta){
var h = {fixUpper: "none", fixLower: "none", natural: false};
if(kwArgs){
if("fixUpper" in kwArgs){ h.fixUpper = String(kwArgs.fixUpper); }
if("fixLower" in kwArgs){ h.fixLower = String(kwArgs.fixLower); }
if("natural" in kwArgs){ h.natural = Boolean(kwArgs.natural); }
}
minorDelta = !minorDelta || minorDelta < deltaLimit ? deltaLimit : minorDelta;
// update bounds
if("min" in kwArgs){ min = kwArgs.min; }
if("max" in kwArgs){ max = kwArgs.max; }
if(kwArgs.includeZero){
if(min > 0){ min = 0; }
if(max < 0){ max = 0; }
}
h.min = min;
h.useMin = true;
h.max = max;
h.useMax = true;
if("from" in kwArgs){
min = kwArgs.from;
h.useMin = false;
}
if("to" in kwArgs){
max = kwArgs.to;
h.useMax = false;
}
// check for erroneous condition
if(max <= min){
return calcTicks(min, max, h, 0, 0, 0, span); // Object
}
if(!delta){
delta = max - min;
}
var mag = Math.floor(Math.log(delta) / Math.LN10),
major = kwArgs && ("majorTickStep" in kwArgs) ? kwArgs.majorTickStep : Math.pow(10, mag),
minor = 0, micro = 0, ticks;
// calculate minor ticks
if(kwArgs && ("minorTickStep" in kwArgs)){
minor = kwArgs.minorTickStep;
}else{
do{
minor = major / 10;
if(!h.natural || minor > 0.9){
ticks = calcTicks(min, max, h, major, minor, 0, span);
if(ticks.bounds.scale * ticks.minor.tick > minorDelta){ break; }
}
minor = major / 5;
if(!h.natural || minor > 0.9){
ticks = calcTicks(min, max, h, major, minor, 0, span);
if(ticks.bounds.scale * ticks.minor.tick > minorDelta){ break; }
}
minor = major / 2;
if(!h.natural || minor > 0.9){
ticks = calcTicks(min, max, h, major, minor, 0, span);
if(ticks.bounds.scale * ticks.minor.tick > minorDelta){ break; }
}
return calcTicks(min, max, h, major, 0, 0, span); // Object
}while(false);
}
// calculate micro ticks
if(kwArgs && ("microTickStep" in kwArgs)){
micro = kwArgs.microTickStep;
ticks = calcTicks(min, max, h, major, minor, micro, span);
}else{
do{
micro = minor / 10;
if(!h.natural || micro > 0.9){
ticks = calcTicks(min, max, h, major, minor, micro, span);
if(ticks.bounds.scale * ticks.micro.tick > deltaLimit){ break; }
}
micro = minor / 5;
if(!h.natural || micro > 0.9){
ticks = calcTicks(min, max, h, major, minor, micro, span);
if(ticks.bounds.scale * ticks.micro.tick > deltaLimit){ break; }
}
micro = minor / 2;
if(!h.natural || micro > 0.9){
ticks = calcTicks(min, max, h, major, minor, micro, span);
if(ticks.bounds.scale * ticks.micro.tick > deltaLimit){ break; }
}
micro = 0;
}while(false);
}
return micro ? ticks : calcTicks(min, max, h, major, minor, 0, span); // Object
},
buildTicks: function(/*Object*/ scaler, /*Object*/ kwArgs){
var step, next, tick,
nextMajor = scaler.major.start,
nextMinor = scaler.minor.start,
nextMicro = scaler.micro.start;
if(kwArgs.microTicks && scaler.micro.tick){
step = scaler.micro.tick, next = nextMicro;
}else if(kwArgs.minorTicks && scaler.minor.tick){
step = scaler.minor.tick, next = nextMinor;
}else if(scaler.major.tick){
step = scaler.major.tick, next = nextMajor;
}else{
// no ticks
return null;
}
// make sure that we have finite bounds
var revScale = 1 / scaler.bounds.scale;
if(scaler.bounds.to <= scaler.bounds.from || isNaN(revScale) || !isFinite(revScale) ||
step <= 0 || isNaN(step) || !isFinite(step)){
// no ticks
return null;
}
// loop over all ticks
var majorTicks = [], minorTicks = [], microTicks = [];
while(next <= scaler.bounds.to + revScale){
if(Math.abs(nextMajor - next) < step / 2){
// major tick
tick = {value: nextMajor};
if(kwArgs.majorLabels){
tick.label = getLabel(nextMajor, scaler.major.prec, kwArgs);
}
majorTicks.push(tick);
nextMajor += scaler.major.tick;
nextMinor += scaler.minor.tick;
nextMicro += scaler.micro.tick;
}else if(Math.abs(nextMinor - next) < step / 2){
// minor tick
if(kwArgs.minorTicks){
tick = {value: nextMinor};
if(kwArgs.minorLabels && (scaler.minMinorStep <= scaler.minor.tick * scaler.bounds.scale)){
tick.label = getLabel(nextMinor, scaler.minor.prec, kwArgs);
}
minorTicks.push(tick);
}
nextMinor += scaler.minor.tick;
nextMicro += scaler.micro.tick;
}else{
// micro tick
if(kwArgs.microTicks){
microTicks.push({value: nextMicro});
}
nextMicro += scaler.micro.tick;
}
next += step;
}
return {major: majorTicks, minor: minorTicks, micro: microTicks}; // Object
},
getTransformerFromModel: function(/*Object*/ scaler){
var offset = scaler.bounds.from, scale = scaler.bounds.scale;
return function(x){ return (x - offset) * scale; }; // Function
},
getTransformerFromPlot: function(/*Object*/ scaler){
var offset = scaler.bounds.from, scale = scaler.bounds.scale;
return function(x){ return x / scale + offset; }; // Function
}
});
});
},
'dojox/charting/plot2d/Lines':function(){
define(["dojo/_base/declare", "./Default"], function(declare, Default){
return declare("dojox.charting.plot2d.Lines", Default, {
// summary:
// A convenience constructor to create a typical line chart.
constructor: function(){
// summary:
// Preset our default plot to be line-based.
this.opt.lines = true;
}
});
});
},
'dojox/charting/plot2d/Default':function(){
define(["dojo/_base/lang", "dojo/_base/declare", "dojo/_base/array", "dojo/has",
"./CartesianBase", "./_PlotEvents", "./common", "dojox/lang/functional", "dojox/lang/utils", "dojox/gfx/fx"],
function(lang, declare, arr, has, CartesianBase, _PlotEvents, dc, df, du, fx){
/*=====
declare("dojox.charting.plot2d.__DefaultCtorArgs", dojox.charting.plot2d.__CartesianCtorArgs, {
// summary:
// The arguments used for any/most plots.
// lines: Boolean?
// Whether or not to draw lines on this plot. Defaults to true.
lines: true,
// areas: Boolean?
// Whether or not to draw areas on this plot. Defaults to false.
areas: false,
// markers: Boolean?
// Whether or not to draw markers at data points on this plot. Default is false.
markers: false,
// tension: Number|String?
// Whether or not to apply 'tensioning' to the lines on this chart.
// Options include a number, "X", "x", or "S"; if a number is used, the
// simpler bezier curve calculations are used to draw the lines. If X, x or S
// is used, the more accurate smoothing algorithm is used.
tension: "",
// animate: Boolean?|Number?
// Whether or not to animate the chart to place. When a Number it specifies the duration of the animation.
// Default is false.
animate: false,
// stroke: dojox.gfx.Stroke?
// An optional stroke to use for any series on the plot.
stroke: {},
// outline: dojox.gfx.Stroke?
// An optional stroke used to outline any series on the plot.
outline: {},
// shadow: dojox.gfx.Stroke?
// An optional stroke to use to draw any shadows for a series on a plot.
shadow: {},
// fill: dojox.gfx.Fill?
// Any fill to be used for elements on the plot (such as areas).
fill: {},
// filter: dojox.gfx.Filter?
// An SVG filter to be used for elements on the plot. gfx SVG renderer must be used and dojox/gfx/svgext must
// be required for this to work.
filter: {},
// styleFunc: Function?
// A function that returns a styling object for the a given data item.
styleFunc: null,
// font: String?
// A font definition to be used for labels and other text-based elements on the plot.
font: "",
// fontColor: String|dojo.Color?
// The color to be used for any text-based elements on the plot.
fontColor: "",
// markerStroke: dojo.gfx.Stroke?
// An optional stroke to use for any markers on the plot.
markerStroke: {},
// markerOutline: dojo.gfx.Stroke?
// An optional outline to use for any markers on the plot.
markerOutline: {},
// markerShadow: dojo.gfx.Stroke?
// An optional shadow to use for any markers on the plot.
markerShadow: {},
// markerFill: dojo.gfx.Fill?
// An optional fill to use for any markers on the plot.
markerFill: {},
// markerFont: String?
// An optional font definition to use for any markers on the plot.
markerFont: "",
// markerFontColor: String|dojo.Color?
// An optional color to use for any marker text on the plot.
markerFontColor: "",
// enableCache: Boolean?
// Whether the markers are cached from one rendering to another. This improves the rendering performance of
// successive rendering but penalize the first rendering. Default false.
enableCache: false,
// interpolate: Boolean?
// Whether when there is a null data point in the data the plot interpolates it or if the lines is split at that
// point. Default false.
interpolate: false,
// zeroLine: Number?
// Zero line for an area fill. Should be a numeric value in user coordinates.
// Default: the lowest value on a vertical axis.
zeroLine: 0
});
=====*/
var DEFAULT_ANIMATION_LENGTH = 1200; // in ms
return declare("dojox.charting.plot2d.Default", [CartesianBase, _PlotEvents], {
// defaultParams:
// The default parameters of this plot.
defaultParams: {
lines: true, // draw lines
areas: false, // draw areas
markers: false, // draw markers
tension: "", // draw curved lines (tension is "X", "x", or "S")
animate: false, // animate chart to place
enableCache: false,
interpolate: false
},
// optionalParams:
// The optional parameters of this plot.
optionalParams: {
// theme component
stroke: {},
outline: {},
shadow: {},
fill: {},
filter: {},
styleFunc: null,
font: "",
fontColor: "",
marker: "",
markerStroke: {},
markerOutline: {},
markerShadow: {},
markerFill: {},
markerFont: "",
markerFontColor: "",
zeroLine: 0
},
constructor: function(chart, kwArgs){
// summary:
// Return a new plot.
// chart: dojox/charting/Chart
// The chart this plot belongs to.
// kwArgs: dojox.charting.plot2d.__DefaultCtorArgs?
// An optional arguments object to help define this plot.
this.opt = lang.clone(lang.mixin(this.opt, this.defaultParams));
du.updateWithObject(this.opt, kwArgs);
du.updateWithPattern(this.opt, kwArgs, this.optionalParams);
// animation properties
this.animate = this.opt.animate;
},
createPath: function(run, creator, params){
var path;
if(this.opt.enableCache && run._pathFreePool.length > 0){
path = run._pathFreePool.pop();
path.setShape(params);
// was cleared, add it back
creator.add(path);
}else{
path = creator.createPath(params);
}
if(this.opt.enableCache){
run._pathUsePool.push(path);
}
return path;
},
buildSegments: function(i, indexed){
var run = this.series[i],
min = indexed?Math.max(0, Math.floor(this._hScaler.bounds.from - 1)):0,
max = indexed?Math.min(run.data.length, Math.ceil(this._hScaler.bounds.to)):run.data.length,
rseg = null, segments = [];
// split the run data into dense segments (each containing no nulls)
// except if interpolates is false in which case ignore null between valid data
for(var j = min; j < max; j++){
if(!this.isNullValue(run.data[j])){
if(!rseg){
rseg = [];
segments.push({index: j, rseg: rseg});
}
rseg.push((indexed && run.data[j].hasOwnProperty("y"))?run.data[j].y:run.data[j]);
}else{
if(!this.opt.interpolate || indexed){
// we break the line only if not interpolating or if we have indexed data
rseg = null;
}
}
}
return segments;
},
render: function(dim, offsets){
// summary:
// Render/draw everything on this plot.
// dim: Object
// An object of the form { width, height }
// offsets: Object
// An object of the form { l, r, t, b }
// returns: dojox/charting/plot2d/Default
// A reference to this plot for functional chaining.
// make sure all the series is not modified
if(this.zoom && !this.isDataDirty()){
return this.performZoom(dim, offsets);
}
this.resetEvents();
this.dirty = this.isDirty();
var s;
if(this.dirty){
arr.forEach(this.series, dc.purgeGroup);
this._eventSeries = {};
this.cleanGroup();
this.getGroup().setTransform(null);
s = this.getGroup();
df.forEachRev(this.series, function(item){ item.cleanGroup(s); });
}
var t = this.chart.theme, stroke, outline, events = this.events();
for(var i = 0; i < this.series.length; i++){
var run = this.series[i];
if(!this.dirty && !run.dirty){
t.skip();
this._reconnectEvents(run.name);
continue;
}
run.cleanGroup();
if(this.opt.enableCache){
run._pathFreePool = (run._pathFreePool?run._pathFreePool:[]).concat(run._pathUsePool?run._pathUsePool:[]);
run._pathUsePool = [];
}
if(!run.data.length){
run.dirty = false;
t.skip();
continue;
}
var theme = t.next(this.opt.areas ? "area" : "line", [this.opt, run], true),
lpoly,
ht = this._hScaler.scaler.getTransformerFromModel(this._hScaler),
vt = this._vScaler.scaler.getTransformerFromModel(this._vScaler),
eventSeries = this._eventSeries[run.name] = new Array(run.data.length);
s = run.group;
if(run.hidden){
if(this.opt.lines){
run.dyn.stroke = theme.series.stroke;
}
if (run.markers || (run.markers === undefined && this.opt.markers)) {
run.dyn.markerFill = theme.marker.fill;
run.dyn.markerStroke = theme.marker.stroke;
run.dyn.marker = theme.symbol;
}
if(this.opt.areas){
run.dyn.fill = theme.series.fill;
}
continue;
}
// optim works only for index based case
var indexed = arr.some(run.data, function(item){
return typeof item == "number" || (item && !item.hasOwnProperty("x"));
});
var rsegments = this.buildSegments(i, indexed);
for(var seg = 0; seg < rsegments.length; seg++){
var rsegment = rsegments[seg];
if(indexed){
lpoly = arr.map(rsegment.rseg, function(v, i){
return {
x: ht(i + rsegment.index + 1) + offsets.l,
y: dim.height - offsets.b - vt(v),
data: v
};
}, this);
}else{
lpoly = arr.map(rsegment.rseg, function(v){
return {
x: ht(v.x) + offsets.l,
y: dim.height - offsets.b - vt(v.y),
data: v
};
}, this);
}
// if we are indexed & we interpolate we need to put all the segments as a single one now
if(indexed && this.opt.interpolate){
while(seg < rsegments.length) {
seg++;
rsegment = rsegments[seg];
if(rsegment){
lpoly = lpoly.concat(arr.map(rsegment.rseg, function(v, i){
return {
x: ht(i + rsegment.index + 1) + offsets.l,
y: dim.height - offsets.b - vt(v),
data: v
};
}, this));
}
}
}
var lpath = this.opt.tension ? dc.curve(lpoly, this.opt.tension) : "";
if(this.opt.areas && lpoly.length > 1){
var fill = this._plotFill(theme.series.fill, dim, offsets), apoly = lang.clone(lpoly),
zeroLine = dim.height - offsets.b;
if(!isNaN(this.opt.zeroLine)){
zeroLine = Math.max(offsets.t, Math.min(dim.height - offsets.b - vt(this.opt.zeroLine), zeroLine));
}
if(this.opt.tension){
var apath = "L" + apoly[apoly.length-1].x + "," + zeroLine +
" L" + apoly[0].x + "," + zeroLine +
" L" + apoly[0].x + "," + apoly[0].y;
run.dyn.fill = s.createPath(lpath + " " + apath).setFill(fill).getFill();
} else {
apoly.push({x: lpoly[lpoly.length - 1].x, y: zeroLine});
apoly.push({x: lpoly[0].x, y: zeroLine});
apoly.push(lpoly[0]);
run.dyn.fill = s.createPolyline(apoly).setFill(fill).getFill();
}
}
if(this.opt.lines || this.opt.markers){
// need a stroke
stroke = theme.series.stroke;
if(theme.series.outline){
outline = run.dyn.outline = dc.makeStroke(theme.series.outline);
outline.width = 2 * outline.width + (stroke && stroke.width || 0);
}
}
if(this.opt.markers){
run.dyn.marker = theme.symbol;
}
var frontMarkers = null, outlineMarkers = null, shadowMarkers = null;
if(stroke && theme.series.shadow && lpoly.length > 1){
var shadow = theme.series.shadow,
spoly = arr.map(lpoly, function(c){
return {x: c.x + shadow.dx, y: c.y + shadow.dy};
});
if(this.opt.lines){
if(this.opt.tension){
run.dyn.shadow = s.createPath(dc.curve(spoly, this.opt.tension)).setStroke(shadow).getStroke();
} else {
run.dyn.shadow = s.createPolyline(spoly).setStroke(shadow).getStroke();
}
}
if(this.opt.markers && theme.marker.shadow){
shadow = theme.marker.shadow;
shadowMarkers = arr.map(spoly, function(c){
return this.createPath(run, s, "M" + c.x + " " + c.y + " " + theme.symbol).
setStroke(shadow).setFill(shadow.color);
}, this);
}
}
if(this.opt.lines && lpoly.length > 1){
var shape;
if(outline){
if(this.opt.tension){
run.dyn.outline = s.createPath(lpath).setStroke(outline).getStroke();
} else {
run.dyn.outline = s.createPolyline(lpoly).setStroke(outline).getStroke();
}
}
if(this.opt.tension){
run.dyn.stroke = (shape = s.createPath(lpath)).setStroke(stroke).getStroke();
} else {
run.dyn.stroke = (shape = s.createPolyline(lpoly)).setStroke(stroke).getStroke();
}
if(shape.setFilter && theme.series.filter){
shape.setFilter(theme.series.filter);
}
}
var markerBox = null;
if(this.opt.markers){
var markerTheme = theme;
frontMarkers = new Array(lpoly.length);
outlineMarkers = new Array(lpoly.length);
outline = null;
if(markerTheme.marker.outline){
outline = dc.makeStroke(markerTheme.marker.outline);
outline.width = 2 * outline.width + (markerTheme.marker.stroke ? markerTheme.marker.stroke.width : 0);
}
arr.forEach(lpoly, function(c, i){
if(this.opt.styleFunc || typeof c.data != "number"){
var tMixin = typeof c.data != "number" ? [c.data] : [];
if(this.opt.styleFunc){
tMixin.push(this.opt.styleFunc(c.data));
}
markerTheme = t.addMixin(theme, "marker", tMixin, true);
}else{
markerTheme = t.post(theme, "marker");
}
var path = "M" + c.x + " " + c.y + " " + markerTheme.symbol;
if(outline){
outlineMarkers[i] = this.createPath(run, s, path).setStroke(outline);
}
frontMarkers[i] = this.createPath(run, s, path).setStroke(markerTheme.marker.stroke).setFill(markerTheme.marker.fill);
}, this);
run.dyn.markerFill = markerTheme.marker.fill;
run.dyn.markerStroke = markerTheme.marker.stroke;
if(!markerBox && this.opt.labels){
markerBox = frontMarkers[0].getBoundingBox();
}
if(events){
arr.forEach(frontMarkers, function(s, i){
var o = {
element: "marker",
index: i + rsegment.index,
run: run,
shape: s,
outline: outlineMarkers[i] || null,
shadow: shadowMarkers && shadowMarkers[i] || null,
cx: lpoly[i].x,
cy: lpoly[i].y
};
if(indexed){
o.x = i + rsegment.index + 1;
o.y = run.data[i + rsegment.index];
}else{
o.x = rsegment.rseg[i].x;
o.y = run.data[i + rsegment.index].y;
}
this._connectEvents(o);
eventSeries[i + rsegment.index] = o;
}, this);
}else{
delete this._eventSeries[run.name];
}
}
if(this.opt.labels){
var labelBoxW = markerBox?markerBox.width:2;
var labelBoxH = markerBox?markerBox.height:2;
arr.forEach(lpoly, function(c, i){
if(this.opt.styleFunc || typeof c.data != "number"){
var tMixin = typeof c.data != "number" ? [c.data] : [];
if(this.opt.styleFunc){
tMixin.push(this.opt.styleFunc(c.data));
}
markerTheme = t.addMixin(theme, "marker", tMixin, true);
}else{
markerTheme = t.post(theme, "marker");
}
this.createLabel(s, rsegment.rseg[i], { x: c.x - labelBoxW / 2, y: c.y - labelBoxH / 2,
width: labelBoxW , height: labelBoxH }, markerTheme);
}, this);
}
}
run.dirty = false;
}
// chart mirroring starts
if(has("dojo-bidi")){
this._checkOrientation(this.group, dim, offsets);
}
// chart mirroring ends
if(this.animate){
// grow from the bottom
var plotGroup = this.getGroup();
fx.animateTransform(lang.delegate({
shape: plotGroup,
duration: DEFAULT_ANIMATION_LENGTH,
transform:[
{name:"translate", start: [0, dim.height - offsets.b], end: [0, 0]},
{name:"scale", start: [1, 0], end:[1, 1]},
{name:"original"}
]
}, this.animate)).play();
}
this.dirty = false;
return this; // dojox/charting/plot2d/Default
}
});
});
},
'dojox/charting/plot2d/CartesianBase':function(){
define(["dojo/_base/lang", "dojo/_base/declare", "dojo/_base/connect", "dojo/has",
"./Base", "../scaler/primitive", "dojox/gfx", "dojox/gfx/fx", "dojox/lang/utils"],
function(lang, declare, hub, has, Base, primitive, gfx, fx, du){
/*=====
declare("dojox.charting.plot2d.__CartesianCtorArgs", dojox.charting.plot2d.__PlotCtorArgs, {
// hAxis: String?
// The horizontal axis name.
hAxis: "x",
// vAxis: String?
// The vertical axis name
vAxis: "y",
// labels: Boolean?
// For plots that support labels, whether or not to draw labels for each data item. Default is false.
labels: false,
// fixed: Boolean?
// Whether a fixed precision must be applied to data values for display. Default is true.
fixed: true,
// precision: Number?
// The precision at which to round data values for display. Default is 0.
precision: 1,
// labelOffset: Number?
// The amount in pixels by which to offset labels when using "outside" labelStyle. Default is 10.
labelOffset: 10,
// labelStyle: String?
// Options as to where to draw labels. This must be either "inside" or "outside". By default
// the labels are drawn "inside" the shape representing the data point (a column rectangle for a Columns plot
// or a marker for a Line plot for instance). When "outside" is used the labels are drawn above the data point shape.
labelStyle: "inside",
// htmlLabels: Boolean?
// Whether or not to use HTML to render slice labels. Default is true.
htmlLabels: true,
// omitLabels: Boolean?
// Whether labels that do not fit in an item render are omitted or not. This applies only when labelStyle
// is "inside". Default is false.
omitLabels: true,
// labelFunc: Function?
// An optional function to use to compute label text. It takes precedence over
// the default text when available.
// | function labelFunc(value, fixed, precision) {}
// `value` is the data value to display
// `fixed` is true if fixed precision must be applied.
// `precision` is the requested precision to be applied.
labelFunc: null
});
=====*/
var alwaysFalse = function(){ return false; }
return declare("dojox.charting.plot2d.CartesianBase", Base, {
baseParams: {
hAxis: "x",
vAxis: "y",
labels: false,
labelOffset: 10,
fixed: true,
precision: 1,
labelStyle: "inside",
htmlLabels: true, // use HTML to draw labels
omitLabels: true,
labelFunc: null
},
// summary:
// Base class for cartesian plot types.
constructor: function(chart, kwArgs){
// summary:
// Create a cartesian base plot for cartesian charts.
// chart: dojox/chart/Chart
// The chart this plot belongs to.
// kwArgs: dojox.charting.plot2d.__CartesianCtorArgs?
// An optional arguments object to help define the plot.
this.axes = ["hAxis", "vAxis"];
this.zoom = null;
this.zoomQueue = []; // zooming action task queue
this.lastWindow = {vscale: 1, hscale: 1, xoffset: 0, yoffset: 0};
this.hAxis = (kwArgs && kwArgs.hAxis) || "x";
this.vAxis = (kwArgs && kwArgs.vAxis) || "y";
this.series = [];
this.opt = lang.clone(this.baseParams);
du.updateWithObject(this.opt, kwArgs);
},
clear: function(){
// summary:
// Clear out all of the information tied to this plot.
// returns: dojox/charting/plot2d/CartesianBase
// A reference to this plot for functional chaining.
this.inherited(arguments);
this._hAxis = null;
this._vAxis = null;
return this; // dojox/charting/plot2d/CartesianBase
},
cleanGroup: function(creator, noClip){
this.inherited(arguments);
if(!noClip && this.chart._nativeClip){
var offsets = this.chart.offsets, dim = this.chart.dim;
var w = Math.max(0, dim.width - offsets.l - offsets.r),
h = Math.max(0, dim.height - offsets.t - offsets.b);
this.group.setClip({ x: offsets.l, y: offsets.t, width: w, height: h });
if(!this._clippedGroup){
this._clippedGroup = this.group.createGroup();
}
}
},
purgeGroup: function(){
this.inherited(arguments);
this._clippedGroup = null;
},
getGroup: function(){
return this._clippedGroup || this.group;
},
setAxis: function(axis){
// summary:
// Set an axis for this plot.
// axis: dojox/charting/axis2d/Base
// The axis to set.
// returns: dojox/charting/plot2d/CartesianBase
// A reference to this plot for functional chaining.
if(axis){
this[axis.vertical ? "_vAxis" : "_hAxis"] = axis;
}
return this; // dojox/charting/plot2d/CartesianBase
},
toPage: function(coord){
// summary:
// Compute page coordinates from plot axis data coordinates.
// coord: Object?
// The coordinates in plot axis data coordinate space. For cartesian charts that is of the following form:
// `{ hAxisName: 50, vAxisName: 200 }`
// If not provided return the transform method instead of the result of the transformation.
// returns: Object
// The resulting page pixel coordinates. That is of the following form:
// `{ x: 50, y: 200 }`
var ah = this._hAxis, av = this._vAxis,
sh = ah.getScaler(), sv = av.getScaler(),
th = sh.scaler.getTransformerFromModel(sh),
tv = sv.scaler.getTransformerFromModel(sv),
c = this.chart.getCoords(),
o = this.chart.offsets, dim = this.chart.dim;
var t = function(coord){
var r = {};
r.x = th(coord[ah.name]) + c.x + o.l;
r.y = c.y + dim.height - o.b - tv(coord[av.name]);
return r;
};
// if no coord return the function so that we can capture the current transforms
// and reuse them later on
return coord?t(coord):t; // Object
},
toData: function(coord){
// summary:
// Compute plot axis data coordinates from page coordinates.
// coord: Object
// The pixel coordinate in page coordinate space. That is of the following form:
// `{ x: 50, y: 200 }`
// If not provided return the tranform method instead of the result of the transformation.
// returns: Object
// The resulting plot axis data coordinates. For cartesian charts that is of the following form:
// `{ hAxisName: 50, vAxisName: 200 }`
var ah = this._hAxis, av = this._vAxis,
sh = ah.getScaler(), sv = av.getScaler(),
th = sh.scaler.getTransformerFromPlot(sh),
tv = sv.scaler.getTransformerFromPlot(sv),
c = this.chart.getCoords(),
o = this.chart.offsets, dim = this.chart.dim;
var t = function(coord){
var r = {};
r[ah.name] = th(coord.x - c.x - o.l);
r[av.name] = tv(c.y + dim.height - coord.y - o.b);
return r;
};
// if no coord return the function so that we can capture the current transforms
// and reuse them later on
return coord?t(coord):t; // Object
},
isDirty: function(){
// summary:
// Returns whether or not this plot needs to be rendered.
// returns: Boolean
// The state of the plot.
return this.dirty || this._hAxis && this._hAxis.dirty || this._vAxis && this._vAxis.dirty; // Boolean
},
createLabel: function(group, value, bbox, theme){
if(this.opt.labels){
var x, y, label = this.opt.labelFunc?this.opt.labelFunc.apply(this, [value, this.opt.fixed, this.opt.precision]):
this._getLabel(isNaN(value.y)?value:value.y);
if(this.opt.labelStyle == "inside"){
var lbox = gfx._base._getTextBox(label, { font: theme.series.font } );
x = bbox.x + bbox.width / 2;
y = bbox.y + bbox.height / 2 + lbox.h / 4;
if(lbox.w > bbox.width || lbox.h > bbox.height){
return;
}
}else{
x = bbox.x + bbox.width / 2;
y = bbox.y - this.opt.labelOffset;
}
this.renderLabel(group, x, y, label, theme, this.opt.labelStyle == "inside");
}
},
performZoom: function(dim, offsets){
// summary:
// Create/alter any zooming windows on this plot.
// dim: Object
// An object of the form { width, height }.
// offsets: Object
// An object of the form { l, r, t, b }.
// returns: dojox/charting/plot2d/CartesianBase
// A reference to this plot for functional chaining.
// get current zooming various
var vs = this._vAxis.scale || 1,
hs = this._hAxis.scale || 1,
vOffset = dim.height - offsets.b,
hBounds = this._hScaler.bounds,
xOffset = (hBounds.from - hBounds.lower) * hBounds.scale,
vBounds = this._vScaler.bounds,
yOffset = (vBounds.from - vBounds.lower) * vBounds.scale,
// get incremental zooming various
rVScale = vs / this.lastWindow.vscale,
rHScale = hs / this.lastWindow.hscale,
rXOffset = (this.lastWindow.xoffset - xOffset)/
((this.lastWindow.hscale == 1)? hs : this.lastWindow.hscale),
rYOffset = (yOffset - this.lastWindow.yoffset)/
((this.lastWindow.vscale == 1)? vs : this.lastWindow.vscale),
shape = this.getGroup(),
anim = fx.animateTransform(lang.delegate({
shape: shape,
duration: 1200,
transform:[
{name:"translate", start:[0, 0], end: [offsets.l * (1 - rHScale), vOffset * (1 - rVScale)]},
{name:"scale", start:[1, 1], end: [rHScale, rVScale]},
{name:"original"},
{name:"translate", start: [0, 0], end: [rXOffset, rYOffset]}
]}, this.zoom));
lang.mixin(this.lastWindow, {vscale: vs, hscale: hs, xoffset: xOffset, yoffset: yOffset});
//add anim to zooming action queue,
//in order to avoid several zooming action happened at the same time
this.zoomQueue.push(anim);
//perform each anim one by one in zoomQueue
hub.connect(anim, "onEnd", this, function(){
this.zoom = null;
this.zoomQueue.shift();
if(this.zoomQueue.length > 0){
this.zoomQueue[0].play();
}
});
if(this.zoomQueue.length == 1){
this.zoomQueue[0].play();
}
return this; // dojox/charting/plot2d/CartesianBase
},
initializeScalers: function(dim, stats){
// summary:
// Initializes scalers using attached axes.
// dim: Object
// Size of a plot area in pixels as {width, height}.
// stats: Object
// Min/max of data in both directions as {hmin, hmax, vmin, vmax}.
// returns: dojox/charting/plot2d/CartesianBase
// A reference to this plot for functional chaining.
if(this._hAxis){
if(!this._hAxis.initialized()){
this._hAxis.calculate(stats.hmin, stats.hmax, dim.width);
}
this._hScaler = this._hAxis.getScaler();
}else{
this._hScaler = primitive.buildScaler(stats.hmin, stats.hmax, dim.width);
}
if(this._vAxis){
if(!this._vAxis.initialized()){
this._vAxis.calculate(stats.vmin, stats.vmax, dim.height);
}
this._vScaler = this._vAxis.getScaler();
}else{
this._vScaler = primitive.buildScaler(stats.vmin, stats.vmax, dim.height);
}
return this; // dojox/charting/plot2d/CartesianBase
},
isNullValue: function(value){
if(value === null || typeof value == "undefined"){
return true;
}
var h = this._hAxis ? this._hAxis.isNullValue : alwaysFalse,
v = this._vAxis ? this._vAxis.isNullValue : alwaysFalse;
if(typeof value == "number"){
return h(1) || v(value);
}
return h(isNaN(value.x) ? 1 : value.x) || value.y === null || v(value.y);
}
});
});
},
'dojox/charting/plot2d/Base':function(){
define(["dojo/_base/declare", "dojo/_base/array", "dojo/_base/lang", "dojox/gfx",
"../Element", "./common", "../axis2d/common", "dojo/has"],
function(declare, arr, lang, gfx, Element, common, ac, has){
/*=====
dojox.charting.plot2d.__PlotCtorArgs = {
// summary:
// The base keyword arguments object for plot constructors.
// Note that the parameters for this may change based on the
// specific plot type (see the corresponding plot type for
// details).
// tooltipFunc: Function?
// An optional function used to compute tooltip text for this plot. It takes precedence over
// the default function when available.
// | function tooltipFunc(o) { return "text"; }
// `o`is the event object that triggered the tooltip.
tooltipFunc: null
};
=====*/
var Base = declare("dojox.charting.plot2d.Base", Element, {
// summary:
// Base class for all plot types.
constructor: function(chart, kwArgs){
// summary:
// Create a base plot for charting.
// chart: dojox/chart/Chart
// The chart this plot belongs to.
// kwArgs: dojox.charting.plot2d.__PlotCtorArgs?
// An optional arguments object to help define the plot.
// TODO does not work in markup
if(kwArgs && kwArgs.tooltipFunc){
this.tooltipFunc = kwArgs.tooltipFunc;
}
},
clear: function(){
// summary:
// Clear out all of the information tied to this plot.
// returns: dojox.charting.plot2d.Base
// A reference to this plot for functional chaining.
this.series = [];
this.dirty = true;
return this; // dojox/charting/plot2d/Base
},
setAxis: function(axis){
// summary:
// Set an axis for this plot.
// axis: dojox.charting.axis2d.Base
// The axis to set.
// returns: dojox/charting/plot2d/Base
// A reference to this plot for functional chaining.
return this; // dojox/charting/plot2d/Base
},
assignAxes: function(axes){
// summary:
// From an array of axes pick the ones that correspond to this plot and
// assign them to the plot using setAxis method.
// axes: Array
// An array of dojox/charting/axis2d/Base
// tags:
// protected
arr.forEach(this.axes, function(axis){
if(this[axis]){
this.setAxis(axes[this[axis]]);
}
}, this);
},
addSeries: function(run){
// summary:
// Add a data series to this plot.
// run: dojox.charting.Series
// The series to be added.
// returns: dojox/charting/plot2d/Base
// A reference to this plot for functional chaining.
this.series.push(run);
return this; // dojox/charting/plot2d/Base
},
getSeriesStats: function(){
// summary:
// Calculate the min/max on all attached series in both directions.
// returns: Object
// {hmin, hmax, vmin, vmax} min/max in both directions.
return common.collectSimpleStats(this.series, lang.hitch(this, "isNullValue"));
},
calculateAxes: function(dim){
// summary:
// Stub function for running the axis calculations (deprecated).
// dim: Object
// An object of the form { width, height }
// returns: dojox/charting/plot2d/Base
// A reference to this plot for functional chaining.
this.initializeScalers(dim, this.getSeriesStats());
return this; // dojox/charting/plot2d/Base
},
initializeScalers: function(){
// summary:
// Does nothing.
return this;
},
isDataDirty: function(){
// summary:
// Returns whether or not any of this plot's data series need to be rendered.
// returns: Boolean
// Flag indicating if any of this plot's series are invalid and need rendering.
return arr.some(this.series, function(item){ return item.dirty; }); // Boolean
},
render: function(dim, offsets){
// summary:
// Render the plot on the chart.
// dim: Object
// An object of the form { width, height }.
// offsets: Object
// An object of the form { l, r, t, b }.
// returns: dojox/charting/plot2d/Base
// A reference to this plot for functional chaining.
return this; // dojox/charting/plot2d/Base
},
renderLabel: function(group, x, y, label, theme, block, align){
var elem = ac.createText[this.opt.htmlLabels && gfx.renderer != "vml" ? "html" : "gfx"]
(this.chart, group, x, y, align?align:"middle", label, theme.series.font, theme.series.fontColor);
// if the label is inside we need to avoid catching events on it this would prevent action on
// chart elements
if(block){
// TODO this won't work in IE neither in VML nor in HTML
// a solution would be to catch the event on the label and refire it to the element
// possibly using elementFromPoint or having it already available
if(this.opt.htmlLabels && gfx.renderer != "vml"){
// we have HTML labels, let's use pointEvents on the HTML node
elem.style.pointerEvents = "none";
}else if(elem.rawNode){
// we have SVG labels, let's use pointerEvents on the SVG or VML node
elem.rawNode.style.pointerEvents = "none";
}
// else we have Canvas, we need do nothing, as Canvas text won't catch events
}
if(this.opt.htmlLabels && gfx.renderer != "vml"){
this.htmlElements.push(elem);
}
return elem;
},
getRequiredColors: function(){
// summary:
// Get how many data series we have, so we know how many colors to use.
// returns: Number
// The number of colors needed.
return this.series.length; // Number
},
_getLabel: function(number){
return common.getLabel(number, this.opt.fixed, this.opt.precision);
}
});
if(has("dojo-bidi")){
Base.extend({
_checkOrientation: function(group, dim, offsets){
this.chart.applyMirroring(this.group, dim, offsets);
}
});
}
return Base;
});
},
'dojox/charting/scaler/primitive':function(){
define(["dojo/_base/lang"],
function(lang){
var primitive = lang.getObject("dojox.charting.scaler.primitive", true);
return lang.mixin(primitive, {
buildScaler: function(/*Number*/ min, /*Number*/ max, /*Number*/ span, /*Object*/ kwArgs){
if(min == max){
// artificially extend bounds
min -= 0.5;
max += 0.5;
// now the line will be centered
}
return {
bounds: {
lower: min,
upper: max,
from: min,
to: max,
scale: span / (max - min),
span: span
},
scaler: primitive
};
},
buildTicks: function(/*Object*/ scaler, /*Object*/ kwArgs){
return {major: [], minor: [], micro: []}; // Object
},
getTransformerFromModel: function(/*Object*/ scaler){
var offset = scaler.bounds.from, scale = scaler.bounds.scale;
return function(x){ return (x - offset) * scale; }; // Function
},
getTransformerFromPlot: function(/*Object*/ scaler){
var offset = scaler.bounds.from, scale = scaler.bounds.scale;
return function(x){ return x / scale + offset; }; // Function
}
});
});
},
'dojox/gfx/fx':function(){
define(["dojo/_base/lang", "./_base", "./matrix", "dojo/_base/Color", "dojo/_base/array", "dojo/_base/fx", "dojo/_base/connect", "dojo/sniff"],
function(lang, g, m, Color, arr, fx, Hub, has){
var fxg = g.fx = {};
// Generic interpolators. Should they be moved to dojox.fx?
function InterpolNumber(start, end){
this.start = start, this.end = end;
}
InterpolNumber.prototype.getValue = function(r){
return (this.end - this.start) * r + this.start;
};
function InterpolUnit(start, end, units){
this.start = start, this.end = end;
this.units = units;
}
InterpolUnit.prototype.getValue = function(r){
return (this.end - this.start) * r + this.start + this.units;
};
function InterpolColor(start, end){
this.start = start, this.end = end;
this.temp = new Color();
}
InterpolColor.prototype.getValue = function(r){
return Color.blendColors(this.start, this.end, r, this.temp);
};
function InterpolValues(values){
this.values = values;
this.length = values.length;
}
InterpolValues.prototype.getValue = function(r){
return this.values[Math.min(Math.floor(r * this.length), this.length - 1)];
};
function InterpolObject(values, def){
this.values = values;
this.def = def ? def : {};
}
InterpolObject.prototype.getValue = function(r){
var ret = lang.clone(this.def);
for(var i in this.values){
ret[i] = this.values[i].getValue(r);
}
return ret;
};
function InterpolTransform(stack, original){
this.stack = stack;
this.original = original;
}
InterpolTransform.prototype.getValue = function(r){
var ret = [];
arr.forEach(this.stack, function(t){
if(t instanceof m.Matrix2D){
ret.push(t);
return;
}
if(t.name == "original" && this.original){
ret.push(this.original);
return;
}
// Adding support for custom matrices
if(t.name == "matrix"){
if((t.start instanceof m.Matrix2D) && (t.end instanceof m.Matrix2D)){
var transfMatrix = new m.Matrix2D();
for(var p in t.start) {
transfMatrix[p] = (t.end[p] - t.start[p])*r + t.start[p];
}
ret.push(transfMatrix);
}
return;
}
if(!(t.name in m)){ return; }
var f = m[t.name];
if(typeof f != "function"){
// constant
ret.push(f);
return;
}
var val = arr.map(t.start, function(v, i){
return (t.end[i] - v) * r + v;
}),
matrix = f.apply(m, val);
if(matrix instanceof m.Matrix2D){
ret.push(matrix);
}
}, this);
return ret;
};
var transparent = new Color(0, 0, 0, 0);
function getColorInterpol(prop, obj, name, def){
if(prop.values){
return new InterpolValues(prop.values);
}
var value, start, end;
if(prop.start){
start = g.normalizeColor(prop.start);
}else{
start = value = obj ? (name ? obj[name] : obj) : def;
}
if(prop.end){
end = g.normalizeColor(prop.end);
}else{
if(!value){
value = obj ? (name ? obj[name] : obj) : def;
}
end = value;
}
return new InterpolColor(start, end);
}
function getNumberInterpol(prop, obj, name, def){
if(prop.values){
return new InterpolValues(prop.values);
}
var value, start, end;
if(prop.start){
start = prop.start;
}else{
start = value = obj ? obj[name] : def;
}
if(prop.end){
end = prop.end;
}else{
if(typeof value != "number"){
value = obj ? obj[name] : def;
}
end = value;
}
return new InterpolNumber(start, end);
}
fxg.animateStroke = function(/*Object*/ args){
// summary:
// Returns an animation which will change stroke properties over time.
// args:
// an object defining the animation setting.
// example:
// | fxg.animateStroke{{
// | shape: shape,
// | duration: 500,
// | color: {start: "red", end: "green"},
// | width: {end: 15},
// | join: {values: ["miter", "bevel", "round"]}
// | }).play();
if(!args.easing){ args.easing = fx._defaultEasing; }
var anim = new fx.Animation(args), shape = args.shape, stroke;
Hub.connect(anim, "beforeBegin", anim, function(){
stroke = shape.getStroke();
var prop = args.color, values = {}, value, start, end;
if(prop){
values.color = getColorInterpol(prop, stroke, "color", transparent);
}
prop = args.style;
if(prop && prop.values){
values.style = new InterpolValues(prop.values);
}
prop = args.width;
if(prop){
values.width = getNumberInterpol(prop, stroke, "width", 1);
}
prop = args.cap;
if(prop && prop.values){
values.cap = new InterpolValues(prop.values);
}
prop = args.join;
if(prop){
if(prop.values){
values.join = new InterpolValues(prop.values);
}else{
start = prop.start ? prop.start : (stroke && stroke.join || 0);
end = prop.end ? prop.end : (stroke && stroke.join || 0);
if(typeof start == "number" && typeof end == "number"){
values.join = new InterpolNumber(start, end);
}
}
}
this.curve = new InterpolObject(values, stroke);
});
Hub.connect(anim, "onAnimate", shape, "setStroke");
return anim; // dojo.Animation
};
fxg.animateFill = function(/*Object*/ args){
// summary:
// Returns an animation which will change fill color over time.
// Only solid fill color is supported at the moment
// args:
// an object defining the animation setting.
// example:
// | gfx.animateFill{{
// | shape: shape,
// | duration: 500,
// | color: {start: "red", end: "green"}
// | }).play();
if(!args.easing){ args.easing = fx._defaultEasing; }
var anim = new fx.Animation(args), shape = args.shape, fill;
Hub.connect(anim, "beforeBegin", anim, function(){
fill = shape.getFill();
var prop = args.color, values = {};
if(prop){
this.curve = getColorInterpol(prop, fill, "", transparent);
}
});
Hub.connect(anim, "onAnimate", shape, "setFill");
return anim; // dojo.Animation
};
fxg.animateFont = function(/*Object*/ args){
// summary:
// Returns an animation which will change font properties over time.
// args:
// an object defining the animation setting.
// example:
// | gfx.animateFont{{
// | shape: shape,
// | duration: 500,
// | variant: {values: ["normal", "small-caps"]},
// | size: {end: 10, units: "pt"}
// | }).play();
if(!args.easing){ args.easing = fx._defaultEasing; }
var anim = new fx.Animation(args), shape = args.shape, font;
Hub.connect(anim, "beforeBegin", anim, function(){
font = shape.getFont();
var prop = args.style, values = {}, value, start, end;
if(prop && prop.values){
values.style = new InterpolValues(prop.values);
}
prop = args.variant;
if(prop && prop.values){
values.variant = new InterpolValues(prop.values);
}
prop = args.weight;
if(prop && prop.values){
values.weight = new InterpolValues(prop.values);
}
prop = args.family;
if(prop && prop.values){
values.family = new InterpolValues(prop.values);
}
prop = args.size;
if(prop && prop.units){
start = parseFloat(prop.start ? prop.start : (shape.font && shape.font.size || "0"));
end = parseFloat(prop.end ? prop.end : (shape.font && shape.font.size || "0"));
values.size = new InterpolUnit(start, end, prop.units);
}
this.curve = new InterpolObject(values, font);
});
Hub.connect(anim, "onAnimate", shape, "setFont");
return anim; // dojo.Animation
};
fxg.animateTransform = function(/*Object*/ args){
// summary:
// Returns an animation which will change transformation over time.
// args:
// an object defining the animation setting.
// example:
// | gfx.animateTransform{{
// | shape: shape,
// | duration: 500,
// | transform: [
// | {name: "translate", start: [0, 0], end: [200, 200]},
// | {name: "original"}
// | ]
// | }).play();
if(!args.easing){ args.easing = fx._defaultEasing; }
var anim = new fx.Animation(args), shape = args.shape, original;
Hub.connect(anim, "beforeBegin", anim, function(){
original = shape.getTransform();
this.curve = new InterpolTransform(args.transform, original);
});
Hub.connect(anim, "onAnimate", shape, "setTransform");
if(g.renderer === "svg" && (has("ie") >= 9 || has("ff"))){
// fix http://bugs.dojotoolkit.org/ticket/16879
var handlers = [
Hub.connect(anim, "onBegin", anim, function(){
var parent = shape.getParent();
while(parent && parent.getParent){
parent = parent.getParent();
}
if(parent){
shape.__svgContainer = parent.rawNode.parentNode;
shape.__svgRoot = parent.rawNode;
if(shape.__svgRoot && shape.__svgRoot.getAttribute){
shape.__svgWidth = parseInt(shape.__svgRoot.getAttribute("width"), 10);
if(isNaN(shape.__svgWidth)){
delete shape.__svgWidth;
}
}
}
}),
Hub.connect(anim, "onAnimate", anim, function(){
try{
if(shape.__svgContainer){
var ov = shape.__svgContainer.style.visibility;
shape.__svgContainer.style.visibility = "visible";
var pokeNode = shape.__svgContainer.offsetHeight;
shape.__svgContainer.style.visibility = ov;
var width = shape.__svgWidth;
if(!isNaN(width)){
try{
shape.__svgRoot.setAttribute("width", width - 0.000005);
shape.__svgRoot.setAttribute("width", width);
}catch(ignore){}
}
}
}catch(e){}
}),
Hub.connect(anim, "onEnd", anim, function(){
arr.forEach(handlers, Hub.disconnect);
if(shape.__svgContainer){
var sn = shape.__svgContainer;
if(sn.getAttribute("__gotVis") == null){
sn.setAttribute("__gotVis", true);
var ov = shape.__svgContainer.style.visibility;
var root = shape.__svgRoot;
var width = shape.__svgWidth;
sn.style.visibility = "visible";
setTimeout(function(){
try{
sn.style.visibility = ov;
sn.removeAttribute("__gotVis");
sn = null;
try{
if(!isNaN(width)){
root.setAttribute("width", width - 0.000005);
root.setAttribute("width", width);
}
}catch(ignore){}
}catch(e){}
},100);
}
}
delete shape.__svgContainer;
delete shape.__svgRoot;
delete shape.__svgWidth;
})
];
}
return anim; // dojo.Animation
};
return fxg;
});
},
'dojox/charting/plot2d/_PlotEvents':function(){
define(["dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "dojo/_base/connect"],
function(lang, arr, declare, hub){
return declare("dojox.charting.plot2d._PlotEvents", null, {
constructor: function(){
this._shapeEvents = [];
this._eventSeries = {};
},
destroy: function(){
// summary:
// Destroy any internal elements and event handlers.
this.resetEvents();
this.inherited(arguments);
},
plotEvent: function(o){
// summary:
// Stub function for use by specific plots.
// o: Object
// An object intended to represent event parameters.
},
raiseEvent: function(o){
// summary:
// Raises events in predefined order
// o: Object
// An object intended to represent event parameters.
this.plotEvent(o);
var t = lang.delegate(o);
t.originalEvent = o.type;
t.originalPlot = o.plot;
t.type = "onindirect";
arr.forEach(this.chart.stack, function(plot){
if(plot !== this && plot.plotEvent){
t.plot = plot;
plot.plotEvent(t);
}
}, this);
},
connect: function(object, method){
// summary:
// Helper function to connect any object's method to our plotEvent.
// object: Object
// The object to connect to.
// method: String|Function
// The method to fire when our plotEvent is fired.
// returns: Array
// The handle as returned from dojo.connect (see dojo.connect).
this.dirty = true;
return hub.connect(this, "plotEvent", object, method); // Array
},
events: function(){
// summary:
// Find out if any event handlers have been connected to our plotEvent.
// returns: Boolean
// A flag indicating that there are handlers attached.
return !!this.plotEvent.after;
},
resetEvents: function(){
// summary:
// Reset all events attached to our plotEvent (i.e. disconnect).
if(this._shapeEvents.length){
arr.forEach(this._shapeEvents, function(item){
item.shape.disconnect(item.handle);
});
this._shapeEvents = [];
}
this.raiseEvent({type: "onplotreset", plot: this});
},
_connectSingleEvent: function(o, eventName){
this._shapeEvents.push({
shape: o.eventMask,
handle: o.eventMask.connect(eventName, this, function(e){
o.type = eventName;
o.event = e;
this.raiseEvent(o);
o.event = null;
})
});
},
_connectEvents: function(o){
if(o){
o.chart = this.chart;
o.plot = this;
o.hAxis = this.hAxis || null;
o.vAxis = this.vAxis || null;
o.eventMask = o.eventMask || o.shape;
this._connectSingleEvent(o, "onmouseover");
this._connectSingleEvent(o, "onmouseout");
this._connectSingleEvent(o, "onclick");
}
},
_reconnectEvents: function(seriesName){
var a = this._eventSeries[seriesName];
if(a){
arr.forEach(a, this._connectEvents, this);
}
},
fireEvent: function(seriesName, eventName, index, eventObject){
// summary:
// Emulates firing an event for a given data value (specified by
// an index) of a given series.
// seriesName: String
// Series name.
// eventName: String
// Event name to emulate.
// index: Number
// Valid data value index used to raise an event.
// eventObject: Object?
// Optional event object. Especially useful for synthetic events.
// Default: null.
var s = this._eventSeries[seriesName];
if(s && s.length && index < s.length){
var o = s[index];
o.type = eventName;
o.event = eventObject || null;
this.raiseEvent(o);
o.event = null;
}
}
});
});
},
'dojox/charting/plot2d/Grid':function(){
define(["dojo/_base/lang", "dojo/_base/declare", "dojo/_base/array", "dojo/sniff",
"./CartesianBase", "./common", "dojox/lang/utils", "dojox/gfx/fx"],
function(lang, declare, arr, has, CartesianBase, dc, du, fx){
var sortTicks = function(a,b){return a.value - b.value};
/*=====
declare("dojox.charting.plot2d.__GridCtorArgs", dojox.charting.plot2d.__CartesianCtorArgs, {
// summary:
// A special keyword arguments object that is specific to a grid "plot".
// majorHLine: dojox.gfx.Stroke?
// An optional dojox.gfx.Stroke for a major horizontal line. By default major lines use major tick stroke.
majorHLine:undefined,
// minorHLine: dojox.gfx.Stroke?
// An optional dojox.gfx.Stroke for a minor horizontal line. By default minor lines use minor tick stroke.
minorHLine:undefined,
// majorVLine: dojox.gfx.Stroke?
// An optional dojox.gfx.Stroke for a major vertical line. By default major lines use major tick stroke.
majorVLine:undefined,
// minorVLine: dojox.gfx.Stroke?
// An optional dojox.gfx.Stroke for a minor vertical line. By default major lines use major tick stroke.
minorVLine:undefined,
// hFill: dojox.gfx.Fill?
// An optional dojox.gfx.Fill used to fill every other horizontal stripe created by grid lines.
hFill: undefined,
// hAlternateFill: dojox.gfx.Fill?
// An optional dojox.gfx.Fill used to fill alternating horizontal stripe created by grid lines not filled by `hFill`.
hAlternateFill: undefined,
// vFill: dojox.gfx.Fill?
// An optional dojox.gfx.Fill used to fill every other vertical stripe created by grid lines.
vFill: undefined,
// vAlternateFill: dojox.gfx.Fill?
// An optional dojox.gfx.Fill used to fill alternating vertical stripe created by grid lines not filled by `vFill`.
vAlternateFill: undefined,
// hMajorLines: Boolean?
// Whether to show lines at the major ticks along the horizontal axis. Default is true.
hMajorLines: true,
// hMinorLines: Boolean?
// Whether to show lines at the minor ticks along the horizontal axis. Default is false.
hMinorLines: false,
// vMajorLines: Boolean?
// Whether to show lines at the major ticks along the vertical axis. Default is true.
vMajorLines: true,
// vMinorLines: Boolean?
// Whether to show lines at the major ticks along the vertical axis. Default is false.
vMinorLines: false,
// hStripes: Boolean?
// Whether to show horizontal stripes. Default is false.
hStripes: false,
// vStripes: Boolean?
// Whether to show vertical stripes. Default is false.
vStripes: false,
// enableCache: Boolean?
// Whether the grid lines are cached from one rendering to another. This improves the rendering performance of
// successive rendering but penalize the first rendering. Default false.
enableCache: false,
// renderOnAxis: Boolean?
// Whether or not the grid is rendered when drawn at horizontal or vertical axis position. Default is true.
renderOnAxis: true
});
=====*/
return declare("dojox.charting.plot2d.Grid", CartesianBase, {
// summary:
// A "faux" plot that can be placed behind other plots to represent
// a grid against which other plots can be easily measured.
defaultParams: {
hMajorLines: true, // draw horizontal major lines
hMinorLines: false, // draw horizontal minor lines
vMajorLines: true, // draw vertical major lines
vMinorLines: false, // draw vertical minor lines
hStripes: false, // draw vertical stripes
vStripes: false, // draw vertical stripes
animate: null, // animate bars into place
enableCache: false,
renderOnAxis: true
},
optionalParams: {
majorHLine: {},
minorHLine: {},
majorVLine: {},
minorVLine: {},
hFill: {},
vFill: {},
hAlternateFill: {},
vAlternateFill: {}
},
constructor: function(chart, kwArgs){
// summary:
// Create the faux Grid plot.
// chart: dojox/charting/Chart
// The chart this plot belongs to.
// kwArgs: dojox.charting.plot2d.__GridCtorArgs?
// An optional keyword arguments object to help define the parameters of the underlying grid.
this.opt = lang.clone(this.defaultParams);
du.updateWithObject(this.opt, kwArgs);
du.updateWithPattern(this.opt, kwArgs, this.optionalParams);
this.animate = this.opt.animate;
if(this.opt.enableCache){
this._lineFreePool = [];
this._lineUsePool = [];
this._rectFreePool = [];
this._rectUsePool = [];
}
},
addSeries: function(run){
// summary:
// Ignored but included as a dummy method.
// returns: dojox/charting/plot2d/Grid
// The reference to this plot for functional chaining.
return this; // dojox/charting/plot2d/Grid
},
getSeriesStats: function(){
// summary:
// Returns default stats (irrelevant for this type of plot).
// returns: Object
// {hmin, hmax, vmin, vmax} min/max in both directions.
return lang.delegate(dc.defaultStats); // Object
},
cleanGroup: function(){
this.inherited(arguments);
if(this.opt.enableCache){
this._lineFreePool = this._lineFreePool.concat(this._lineUsePool);
this._lineUsePool = [];
this._rectFreePool = this._rectFreePool.concat(this._rectUsePool);
this._rectUsePool = [];
}
},
createLine: function(creator, params){
var line;
if(this.opt.enableCache && this._lineFreePool.length > 0){
line = this._lineFreePool.pop();
line.setShape(params);
// was cleared, add it back
creator.add(line);
}else{
line = creator.createLine(params);
}
if(this.opt.enableCache){
this._lineUsePool.push(line);
}
return line;
},
createRect: function(creator, params){
var rect;
if(this.opt.enableCache && this._rectFreePool.length > 0){
rect = this._rectFreePool.pop();
rect.setShape(params);
// was cleared, add it back
creator.add(rect);
}else{
rect = creator.createRect(params);
}
if(this.opt.enableCache){
this._rectUsePool.push(rect);
}
return rect;
},
render: function(dim, offsets){
// summary:
// Render the plot on the chart.
// dim: Object
// An object of the form { width, height }.
// offsets: Object
// An object of the form { l, r, t, b }.
// returns: dojox/charting/plot2d/Grid
// A reference to this plot for functional chaining.
if(this.zoom){
return this.performZoom(dim, offsets);
}
this.dirty = this.isDirty();
if(!this.dirty){ return this; }
this.cleanGroup();
var s = this.getGroup(), ta = this.chart.theme, lineStroke, ticks;
if((has("ios") && has("ios") < 6) || has("android") || (has("safari") && !has("ios"))){
// clipping seems buggy in some mobile Webkit browser and Safari desktop
// it does not clip correctly if only lines are present => create a invisible rectangle...
var w = Math.max(0, dim.width - offsets.l - offsets.r),
h = Math.max(0, dim.height - offsets.t - offsets.b);
s.createRect({ x: offsets.l, y: offsets.t, width: w, height: h});
}
if(this._vAxis){
// draw horizontal stripes and lines
ticks = this._vAxis.getTicks();
var vScaler = this._vAxis.getScaler();
if(ticks != null && vScaler != null){
var vt = vScaler.scaler.getTransformerFromModel(vScaler);
if(this.opt.hStripes){
this._renderHRect(ticks, ta.grid, dim, offsets, vScaler, vt);
}
if(this.opt.hMinorLines){
lineStroke = this.opt.minorHLine || (ta.grid && ta.grid.minorLine) || ta.axis.minorTick;
this._renderHLines(ticks.minor, lineStroke, dim, offsets, vScaler, vt);
}
if(this.opt.hMajorLines){
lineStroke = this.opt.majorHLine || (ta.grid && ta.grid.majorLine) || ta.axis.majorTick;
this._renderHLines(ticks.major, lineStroke, dim, offsets, vScaler, vt);
}
}
}
if(this._hAxis){
// draw vertical stripes and lines
ticks = this._hAxis.getTicks();
var hScaler = this._hAxis.getScaler();
if(ticks != null && hScaler != null){
var ht = hScaler.scaler.getTransformerFromModel(hScaler);
if(this.opt.vStripes){
this._renderVRect(ticks, ta.grid, dim, offsets, hScaler, ht);
}
if(ticks && this.opt.vMinorLines){
lineStroke = this.opt.minorVLine || (ta.grid && ta.grid.minorLine) || ta.axis.minorTick;
this._renderVLines(ticks.minor, lineStroke, dim, offsets, hScaler, ht);
}
if(ticks && this.opt.vMajorLines){
lineStroke = this.opt.majorVLine || (ta.grid && ta.grid.majorLine) || ta.axis.majorTick;
this._renderVLines(ticks.major, lineStroke, dim, offsets, hScaler, ht);
}
}
}
this.dirty = false;
return this; // dojox/charting/plot2d/Grid
},
_renderHLines: function(ticks, lineStroke, dim, offsets, vScaler, vt){
var s = this.getGroup();
arr.forEach(ticks, function(tick){
if(!this.opt.renderOnAxis && tick.value == (this._vAxis.opt.leftBottom?vScaler.bounds.from:vScaler.bounds.to)){
return;
}
var y = dim.height - offsets.b - vt(tick.value);
var hLine = this.createLine(s, {
x1: offsets.l,
y1: y,
x2: dim.width - offsets.r,
y2: y
}).setStroke(lineStroke);
if(this.animate){
this._animateGrid(hLine, "h", offsets.l, offsets.r + offsets.l - dim.width);
}
}, this);
},
_renderVLines: function(ticks, lineStroke, dim, offsets, hScaler, ht){
var s = this.getGroup();
arr.forEach(ticks, function(tick){
if(!this.opt.renderOnAxis && tick.value == (this._hAxis.opt.leftBottom?hScaler.bounds.from:hScaler.bounds.to)){
return;
}
var x = offsets.l + ht(tick.value);
var vLine = this.createLine(s, {
x1: x,
y1: offsets.t,
x2: x,
y2: dim.height - offsets.b
}).setStroke(lineStroke);
if(this.animate){
this._animateGrid(vLine, "v", dim.height - offsets.b, dim.height - offsets.b - offsets.t);
}
}, this);
},
_renderHRect: function(ticks, theme, dim, offsets, vScaler, vt){
var fill, tick, y, y2, hStripe;
var allTicks = ticks.major.concat(ticks.minor);
allTicks.sort(sortTicks);
if(allTicks[0].value > vScaler.bounds.from){
allTicks.splice(0, 0, {value: vScaler.bounds.from});
}
if(allTicks[allTicks.length - 1].value < vScaler.bounds.to){
allTicks.push({value: vScaler.bounds.to});
}
var s = this.getGroup();
for(var j = 0; j < allTicks.length - 1; j++){
tick = allTicks[j];
y = dim.height - offsets.b - vt(tick.value);
y2 = dim.height - offsets.b - vt(allTicks[j+1].value);
fill = (j%2 == 0)?(this.opt.hAlternateFill ||(theme && theme.alternateFill)):
(this.opt.hFill || (theme && theme.fill));
if(fill){
hStripe = this.createRect(s, {
x: offsets.l,
y: y,
width: dim.width - offsets.r,
height: y - y2
}).setFill(fill);
if(this.animate){
this._animateGrid(hStripe, "h", offsets.l, offsets.r + offsets.l - dim.width);
}
}
}
},
_renderVRect: function(ticks, theme, dim, offsets, hScaler, ht){
var fill, tick, x, x2, vStripe;
var allTicks = ticks.major.concat(ticks.minor);
allTicks.sort(sortTicks);
if(allTicks[0].value > hScaler.bounds.from){
allTicks.splice(0, 0, {value: hScaler.bounds.from});
}
if(allTicks[allTicks.length - 1].value < hScaler.bounds.to){
allTicks.push({value: hScaler.bounds.to});
}
var s = this.getGroup();
for(var j = 0; j < allTicks.length - 1; j++){
tick = allTicks[j];
x = offsets.l + ht(tick.value);
x2 = offsets.l + ht(allTicks[j+1].value);
fill = (j%2 == 0)?(this.opt.vAlternateFill ||(theme && theme.alternateFill)):
(this.opt.vFill || (theme && theme.fill));
if(fill){
vStripe = this.createRect(s, {
x: x,
y: offsets.t,
width: x2 - x,
height: dim.width - offsets.r
}).setFill(fill);
if(this.animate){
this._animateGrid(vStripe, "v", dim.height - offsets.b, dim.height - offsets.b - offsets.t);
}
}
}
},
_animateGrid: function(shape, type, offset, size){
var transStart = type == "h" ? [offset, 0] : [0, offset];
var scaleStart = type == "h" ? [1/size, 1] : [1, 1/size];
fx.animateTransform(lang.delegate({
shape: shape,
duration: 1200,
transform: [
{name: "translate", start: transStart, end: [0, 0]},
{name: "scale", start: scaleStart, end: [1, 1]},
{name: "original"}
]
}, this.animate)).play();
}
});
});
},
'*now':function(r){r(['dojo/i18n!*preload*demos/mobileStockPortfolio/nls/src*["ar","ca","cs","da","de","el","en-gb","en-us","es-es","fi-fi","fr-fr","he-il","hu","it-it","ja-jp","ko-kr","nl-nl","nb","pl","pt-br","pt-pt","ru","sk","sl","sv","th","tr","zh-tw","zh-cn","ROOT"]']);}
}});
require([
"dojo/dom",
"dojo/_base/array",
"dojo/ready",
"dijit/registry",
"dojox/mobile/ListItem",
"dojox/mobile/parser",
"dojox/mobile",
// include it only if you intend this to be runnable on IE & FF as well
"dojox/mobile/compat",
"dojox/mobile/FixedSplitter",
"dojox/mobile/ScrollableView",
"dojox/mobile/Pane",
"dojox/mobile/Container",
"dojox/mobile/SwapView",
"dojox/mobile/PageIndicator",
"dojox/charting/widget/Chart",
"dojox/charting/axis2d/Default",
"dojox/charting/plot2d/Lines",
"dojox/charting/plot2d/Grid"
], function(dom, arr, ready, registry, ListItem){
function details(event){
var id = this.id;
// get the details (news, figures & chart) for that given id
// xhr.get(...) to get back data from the server, here we are faking it
var data = {
news: [
{
url: "http://www.dojotoolkit.org",
title: id+ " is making headlines",
subtitle: "Newspaper Corp"
},
{
url: "http://www.dojotoolkit.org",
title: "this year "+id+" will sell more",
subtitle: "News Daily"
},
{
url: "http://www.dojotoolkit.org",
title: id+" latest news",
subtitle: "The World"
},
{
url: "http://www.dojotoolkit.org",
title: "The "+id+" revolution",
subtitle: "Freedom paper"
}
],
day: {
open: 10.1 + Math.random(), cap: 15343412 + Math.random() * 100, max: 10.5 + Math.random(), min: 9.9 - Math.random(),
max52: 93 + Math.random(), min52: 3.5 - Math.random(), vol: 3242 + Math.random() * 10,
meanvol: 3403 + Math.random() * 10, per: 5 + Math.random(), rdt: 3 + Math.random()
},
history: [ 5, 6, 7, 8, 10, 13, 18, 24, 32, 37, 45, 51 ]
};
var news = registry.byId("news");
// remove anything from previous selected stock
arr.forEach(news.getChildren(), function(child){
news.removeChild(child);
});
// go over the news for my stock and add them
arr.forEach(data.news, function(item){
var li = new ListItem({
href: item.url,
hrefTarget: "_blank",
arrowClass: "mblDomButtonBlueCircleArrow"
});
li.labelNode.innerHTML = item.title+"
"+item.subtitle+"
";
news.addChild(li);
});
// go over the daily data and update them
for(var key in data.day){
dom.byId(key).innerHTML = data.day[key] > 100?Math.round(data.day[key]) : data.day[key].toFixed(2);
}
// go over the historical data and update the chart
// randomize it a bit...
data.history = arr.map(data.history, function(item){
return Math.round(item + 2*Math.random());
});
registry.byId("chart").chart.updateSeries("data", data.history).render();
}
ready(function(){
// fill the main view with live data
// here we are just pretenting we get if from server
var live = [
{
id: "stock1",
title: "Stock 1",
price: 10.1,
change: 10.5
},
{
id: "stock2",
title: "Stock 2",
price: 15.8,
change: -0.3
},
{
id: "stock3",
title: "Stock 3",
price: 56,
change: 13.4
},
{
id: "stock4",
title: "Stock 4",
price: 8.5,
change: -1.3
},
{
id: "stock5",
title: "Stock 5",
price: 10.9,
change: 0.5
},
{
id: "stock6",
title: "Stock 6",
price: 35,
change: -5.3
},
{
id: "stock7",
title: "Stock 7",
price: 3.5,
change: -4.4
},
{
id: "stock8",
title: "Stock 8",
price: 5.8,
change: -0.9
}
];
var stocks = registry.byId("stocks");
arr.forEach(live, function(item, i){
var li = new ListItem({
onClick: details,
moveTo: "#",
selected: i == 0,
id: item.id
});
var pos = item.change > 0;
li.labelNode.innerHTML =
"
"+item.title+"
"+
"
"+item.price+"
"+
"
"+(pos?"+":"")+item.change+"%
";
stocks.addChild(li);
});
// at init time first stock is always selected
details({ id: "stock1"});
});
});