Subversion Repositories Applications.papyrus

Compare Revisions

No changes between revisions

Regard whitespace Rev 2149 → Rev 2150

/trunk/api/js/dojo1.0/dojox/collections.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.collections"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections"] = true;
dojo.provide("dojox.collections");
dojo.require("dojox.collections._base");
 
}
/trunk/api/js/dojo1.0/dojox/crypto.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.crypto"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.crypto"] = true;
dojo.provide("dojox.crypto");
dojo.require("dojox.crypto._base");
 
}
/trunk/api/js/dojo1.0/dojox/_sql/demos/customers/customers.html
New file
0,0 → 1,292
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
<html>
<head>
<script type="text/javascript"
src="../../../../dojo/dojo.js" djConfig="isDebug: false"></script>
<script type="text/javascript" src="../../../../dojox/off/offline.js"></script>
<style type="text/css">
body{
padding: 2em;
}
#dataTable{
margin-top: 2em;
}
button{
margin-left: 1em;
}
th, tr, td{
text-align: left;
}
table{
text-align: center;
clear: both;
}
#cryptoContainer{
float: left;
width: 60%;
}
#numRowsContainer{
float: right;
width: 40%;
}
#numRowsContainer input{
margin-left: 1.5em;
width: 5em;
}
.table-columns{
font-weight: bold;
}
</style>
<script>
dojo.require("dojox.sql");
dojo.connect(window, "onload", function(){
// draw our customer table on the screen
createTable();
// create our customer table in the database
dojox.sql("DROP TABLE IF EXISTS CUSTOMERS");
dojox.sql("CREATE TABLE CUSTOMERS ("
+ "last_name TEXT, "
+ "first_name TEXT, "
+ "social_security TEXT"
+ ")"
);
});
function createTable(){
// get number of rows to create
var NUM_ROWS = document.getElementById("numRows").value;
if(!NUM_ROWS){
alert("Please enter the number of "
+ "customer rows the table should have");
return;
}
var table = document.getElementById("dataTable");
if(table){
table.parentNode.removeChild(table);
}
table = document.createElement("table");
table.setAttribute("id", "dataTable");
table.setAttribute("border", 1);
// if we don't use IE's craptacular proprietary table methods
// we get strange display glitches
var tr = (dojo.isIE) ? table.insertRow() : document.createElement("tr");
tr.className = "table-columns";
var th = (dojo.isIE) ? tr.insertCell() : document.createElement("th");
th.appendChild(document.createTextNode("Last Name"));
if(!dojo.isIE){
tr.appendChild(th);
}
th = (dojo.isIE) ? tr.insertCell() : document.createElement("th");
th.appendChild(document.createTextNode("First Name"));
if(!dojo.isIE){
tr.appendChild(th);
}
th = (dojo.isIE) ? tr.insertCell() : document.createElement("th");
th.appendChild(document.createTextNode("Social Security"));
if(!dojo.isIE){
tr.appendChild(th);
table.appendChild(tr);
}
for(var i = 1; i <= NUM_ROWS; i++){
tr = (dojo.isIE) ? table.insertRow() : document.createElement("tr");
tr.className = "data-item";
var elem = (dojo.isIE) ? tr.insertCell() : document.createElement("td");
elem.className = "last-name";
var lastName = "Doe" + i;
elem.appendChild(document.createTextNode(lastName));
if(!dojo.isIE){
tr.appendChild(elem);
}
elem = (dojo.isIE) ? tr.insertCell() : document.createElement("td");
elem.className = "first-name";
var firstName = "John" + i;
elem.appendChild(document.createTextNode(firstName));
if(!dojo.isIE){
tr.appendChild(elem);
}
elem = elem = (dojo.isIE) ? tr.insertCell() : document.createElement("td");
elem.className = "social-security";
var ss = 513121500 + i;
ss = new String(ss);
ss = ss.slice(0, 3) + "-" + ss.slice(3, 5) + "-" + ss.slice(5);
elem.appendChild(document.createTextNode(ss));
if(!dojo.isIE){
tr.appendChild(elem);
table.appendChild(tr);
}
}
document.body.appendChild(table);
// reset button state
dojo.byId("encrypt").disabled = false;
dojo.byId("decrypt").disabled = true;
}
function readTable(){
var data = [];
var rows = dojo.query(".data-item");
dojo.forEach(rows, function(row){
var td = row.getElementsByTagName("td");
var lastName = td[0].childNodes[0].nodeValue;
var firstName = td[1].childNodes[0].nodeValue;
var ssNumber = td[2].childNodes[0].nodeValue;
 
data.push({lastName: lastName, firstName: firstName, ssNumber: ssNumber,
toString: function(){
return "{lastName: " + lastName
+ ", firstName: " + firstName
+ ", ssNumber: " + ssNumber
+ "}";
}});
});
return data;
}
function setData(data){
var rows = document.getElementsByTagName("tr");
for(var i = 1; i < rows.length; i++){
var customer = data[i - 1];
var td = rows[i].getElementsByTagName("td");
td[2].childNodes[0].nodeValue = customer.social_security;
}
}
function encrypt(){
// disable our buttons
dojo.byId("encrypt").disabled = true;
dojo.byId("decrypt").disabled = true;
var data = readTable();
var password = document.getElementById("password").value;
// delete any old data
dojox.sql("DELETE FROM CUSTOMERS");
// insert new data
insertCustomers(data, 0, password);
}
function insertCustomers(data, i, password){
var nextIndex = i + 1;
if(i >= data.length){
var savedRows = dojox.sql("SELECT * FROM CUSTOMERS");
setData(savedRows);
return;
}
dojox.sql("INSERT INTO CUSTOMERS VALUES (?, ?, ENCRYPT(?))",
data[i].lastName, data[i].firstName,
data[i].ssNumber,
password,
function(results, error, errorMsg){
// enable our buttons
dojo.byId("encrypt").disabled = true;
dojo.byId("decrypt").disabled = false;
if(error == true){
alert(errorMsg);
return;
}
insertCustomers(data, nextIndex, password);
}
);
}
function decrypt(){
// disable our buttons
dojo.byId("encrypt").disabled = true;
dojo.byId("decrypt").disabled = true;
var password = document.getElementById("password").value;
dojox.sql("SELECT last_name, first_name, DECRYPT(social_security) FROM CUSTOMERS",
password,
function(results, error, errorMsg){
// enable our buttons
dojo.byId("encrypt").disabled = false;
dojo.byId("decrypt").disabled = true;
if(error == true){
alert(errorMsg);
return;
}
setData(results);
}
);
}
</script>
</head>
<body>
<h1>Dojo SQL Cryptography</h1>
<h2>Instructions</h2>
<p>This demo shows Dojo Offline's SQL encryption technologies. In the table below, we have a
sample SQL table that has three columns of data: a last name, a first name, and
a social security number. We don't want to store the social security numbers
in the clear, just in case they are downloaded for offline use to a laptop and the
laptop is stolen.</p>
<p>To use this demo, enter a password and press the ENCRYPT button to see the Social Security column encrypt. Enter
the same password and press DECRYPT to see it decrypt. If you enter an incorrect password and
press DECRYPT, the Social Security column will remain encrypted and only show gibberish.</p>
<p>Under the covers we use 256-bit AES encryption and your password to derive the crypto key; we use
a facility in Google Gears to do the cryptography in such a way that the browser does not lock up
during processing. Dojo Offline ties this cryptography into Dojo SQL, providing convenient ENCRYPT()
and DECRYPT() SQL keywords you can use to easily have this functionality in your
own offline applications. To learn how you can use this feature
<a href="http://docs.google.com/View?docid=dhkhksk4_8gdp9gr#crypto" target="_blank">see here</a>.</p>
<div id="cryptoContainer">
<label for="password">
Password:
</label>
<input type="input" name="password" id="password" value="sample_password">
<button id="encrypt" onclick="window.setTimeout(encrypt, 1)">Encrypt</button>
<button id="decrypt" onclick="window.setTimeout(decrypt, 1)" disabled="true">Decrypt</button>
</div>
<div id="numRowsContainer">
<label for="numRows">
Number of Customer Rows in Table:
</label>
<input id="numRows" type="input" value="30">
<button onclick="createTable()">Update</button>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/_sql/_crypto.js
New file
0,0 → 1,443
if(!dojo._hasResource["dojox._sql._crypto"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox._sql._crypto"] = true;
// Taken from http://www.movable-type.co.uk/scripts/aes.html by
// Chris Veness (CLA signed); adapted for Dojo and Google Gears Worker Pool
// by Brad Neuberg, bkn3@columbia.edu
 
dojo.provide("dojox._sql._crypto");
 
dojo.mixin(dojox._sql._crypto,{
// _POOL_SIZE:
// Size of worker pool to create to help with crypto
_POOL_SIZE: 100,
encrypt: function(plaintext, password, callback){
// summary:
// Use Corrected Block TEA to encrypt plaintext using password
// (note plaintext & password must be strings not string objects).
// Results will be returned to the 'callback' asychronously.
this._initWorkerPool();
var msg ={plaintext: plaintext, password: password};
msg = dojo.toJson(msg);
msg = "encr:" + String(msg);
this._assignWork(msg, callback);
},
 
decrypt: function(ciphertext, password, callback){
// summary:
// Use Corrected Block TEA to decrypt ciphertext using password
// (note ciphertext & password must be strings not string objects).
// Results will be returned to the 'callback' asychronously.
this._initWorkerPool();
var msg ={ciphertext: ciphertext, password: password};
msg = dojo.toJson(msg);
msg = "decr:" + String(msg);
this._assignWork(msg, callback);
},
_initWorkerPool: function(){
// bugs in Google Gears prevents us from dynamically creating
// and destroying workers as we need them -- the worker
// pool functionality stops working after a number of crypto
// cycles (probably related to a memory leak in Google Gears).
// this is too bad, since it results in much simpler code.
// instead, we have to create a pool of workers and reuse them. we
// keep a stack of 'unemployed' Worker IDs that are currently not working.
// if a work request comes in, we pop off the 'unemployed' stack
// and put them to work, storing them in an 'employed' hashtable,
// keyed by their Worker ID with the value being the callback function
// that wants the result. when an employed worker is done, we get
// a message in our 'manager' which adds this worker back to the
// unemployed stack and routes the result to the callback that
// wanted it. if all the workers were employed in the past but
// more work needed to be done (i.e. it's a tight labor pool ;)
// then the work messages are pushed onto
// a 'handleMessage' queue as an object tuple{msg: msg, callback: callback}
if(!this._manager){
try{
this._manager = google.gears.factory.create("beta.workerpool", "1.0");
this._unemployed = [];
this._employed ={};
this._handleMessage = [];
var self = this;
this._manager.onmessage = function(msg, sender){
// get the callback necessary to serve this result
var callback = self._employed["_" + sender];
// make this worker unemployed
self._employed["_" + sender] = undefined;
self._unemployed.push("_" + sender);
// see if we need to assign new work
// that was queued up needing to be done
if(self._handleMessage.length){
var handleMe = self._handleMessage.shift();
self._assignWork(handleMe.msg, handleMe.callback);
}
// return results
callback(msg);
}
var workerInit = "function _workerInit(){"
+ "gearsWorkerPool.onmessage = "
+ String(this._workerHandler)
+ ";"
+ "}";
var code = workerInit + " _workerInit();";
// create our worker pool
for(var i = 0; i < this._POOL_SIZE; i++){
this._unemployed.push("_" + this._manager.createWorker(code));
}
}catch(exp){
throw exp.message||exp;
}
}
},
 
_assignWork: function(msg, callback){
// can we immediately assign this work?
if(!this._handleMessage.length && this._unemployed.length){
// get an unemployed worker
var workerID = this._unemployed.shift().substring(1); // remove _
// list this worker as employed
this._employed["_" + workerID] = callback;
// do the worke
this._manager.sendMessage(msg, workerID);
}else{
// we have to queue it up
this._handleMessage ={msg: msg, callback: callback};
}
},
 
_workerHandler: function(msg, sender){
/* Begin AES Implementation */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
// Sbox is pre-computed multiplicative inverse in GF(2^8) used in SubBytes and KeyExpansion [§5.1.1]
var Sbox = [0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16];
 
// Rcon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [§5.2]
var Rcon = [ [0x00, 0x00, 0x00, 0x00],
[0x01, 0x00, 0x00, 0x00],
[0x02, 0x00, 0x00, 0x00],
[0x04, 0x00, 0x00, 0x00],
[0x08, 0x00, 0x00, 0x00],
[0x10, 0x00, 0x00, 0x00],
[0x20, 0x00, 0x00, 0x00],
[0x40, 0x00, 0x00, 0x00],
[0x80, 0x00, 0x00, 0x00],
[0x1b, 0x00, 0x00, 0x00],
[0x36, 0x00, 0x00, 0x00] ];
 
/*
* AES Cipher function: encrypt 'input' with Rijndael algorithm
*
* takes byte-array 'input' (16 bytes)
* 2D byte-array key schedule 'w' (Nr+1 x Nb bytes)
*
* applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage
*
* returns byte-array encrypted value (16 bytes)
*/
function Cipher(input, w) { // main Cipher function [§5.1]
var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
 
var state = [[],[],[],[]]; // initialise 4xNb byte-array 'state' with input [§3.4]
for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i];
 
state = AddRoundKey(state, w, 0, Nb);
 
for (var round=1; round<Nr; round++) {
state = SubBytes(state, Nb);
state = ShiftRows(state, Nb);
state = MixColumns(state, Nb);
state = AddRoundKey(state, w, round, Nb);
}
 
state = SubBytes(state, Nb);
state = ShiftRows(state, Nb);
state = AddRoundKey(state, w, Nr, Nb);
 
var output = new Array(4*Nb); // convert state to 1-d array before returning [§3.4]
for (var i=0; i<4*Nb; i++) output[i] = state[i%4][Math.floor(i/4)];
return output;
}
 
 
function SubBytes(s, Nb) { // apply SBox to state S [§5.1.1]
for (var r=0; r<4; r++) {
for (var c=0; c<Nb; c++) s[r][c] = Sbox[s[r][c]];
}
return s;
}
 
 
function ShiftRows(s, Nb) { // shift row r of state S left by r bytes [§5.1.2]
var t = new Array(4);
for (var r=1; r<4; r++) {
for (var c=0; c<4; c++) t[c] = s[r][(c+r)%Nb]; // shift into temp copy
for (var c=0; c<4; c++) s[r][c] = t[c]; // and copy back
} // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
return s; // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf
}
 
 
function MixColumns(s, Nb) { // combine bytes of each col of state S [§5.1.3]
for (var c=0; c<4; c++) {
var a = new Array(4); // 'a' is a copy of the current column from 's'
var b = new Array(4); // 'b' is a•{02} in GF(2^8)
for (var i=0; i<4; i++) {
a[i] = s[i][c];
b[i] = s[i][c]&0x80 ? s[i][c]<<1 ^ 0x011b : s[i][c]<<1;
}
// a[n] ^ b[n] is a•{03} in GF(2^8)
s[0][c] = b[0] ^ a[1] ^ b[1] ^ a[2] ^ a[3]; // 2*a0 + 3*a1 + a2 + a3
s[1][c] = a[0] ^ b[1] ^ a[2] ^ b[2] ^ a[3]; // a0 * 2*a1 + 3*a2 + a3
s[2][c] = a[0] ^ a[1] ^ b[2] ^ a[3] ^ b[3]; // a0 + a1 + 2*a2 + 3*a3
s[3][c] = a[0] ^ b[0] ^ a[1] ^ a[2] ^ b[3]; // 3*a0 + a1 + a2 + 2*a3
}
return s;
}
 
 
function AddRoundKey(state, w, rnd, Nb) { // xor Round Key into state S [§5.1.4]
for (var r=0; r<4; r++) {
for (var c=0; c<Nb; c++) state[r][c] ^= w[rnd*4+c][r];
}
return state;
}
 
 
function KeyExpansion(key) { // generate Key Schedule (byte-array Nr+1 x Nb) from Key [§5.2]
var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
var Nk = key.length/4 // key length (in words): 4/6/8 for 128/192/256-bit keys
var Nr = Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys
 
var w = new Array(Nb*(Nr+1));
var temp = new Array(4);
 
for (var i=0; i<Nk; i++) {
var r = [key[4*i], key[4*i+1], key[4*i+2], key[4*i+3]];
w[i] = r;
}
 
for (var i=Nk; i<(Nb*(Nr+1)); i++) {
w[i] = new Array(4);
for (var t=0; t<4; t++) temp[t] = w[i-1][t];
if (i % Nk == 0) {
temp = SubWord(RotWord(temp));
for (var t=0; t<4; t++) temp[t] ^= Rcon[i/Nk][t];
} else if (Nk > 6 && i%Nk == 4) {
temp = SubWord(temp);
}
for (var t=0; t<4; t++) w[i][t] = w[i-Nk][t] ^ temp[t];
}
 
return w;
}
 
function SubWord(w) { // apply SBox to 4-byte word w
for (var i=0; i<4; i++) w[i] = Sbox[w[i]];
return w;
}
 
function RotWord(w) { // rotate 4-byte word w left by one byte
w[4] = w[0];
for (var i=0; i<4; i++) w[i] = w[i+1];
return w;
}
 
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
/*
* Use AES to encrypt 'plaintext' with 'password' using 'nBits' key, in 'Counter' mode of operation
* - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
* for each block
* - outputblock = cipher(counter, key)
* - cipherblock = plaintext xor outputblock
*/
function AESEncryptCtr(plaintext, password, nBits) {
if (!(nBits==128 || nBits==192 || nBits==256)) return ''; // standard allows 128/192/256 bit keys
// for this example script, generate the key by applying Cipher to 1st 16/24/32 chars of password;
// for real-world applications, a more secure approach would be to hash the password e.g. with SHA-1
var nBytes = nBits/8; // no bytes in key
var pwBytes = new Array(nBytes);
for (var i=0; i<nBytes; i++) pwBytes[i] = password.charCodeAt(i) & 0xff;
 
var key = Cipher(pwBytes, KeyExpansion(pwBytes));
 
key = key.concat(key.slice(0, nBytes-16)); // key is now 16/24/32 bytes long
 
// initialise counter block (NIST SP800-38A §B.2): millisecond time-stamp for nonce in 1st 8 bytes,
// block counter in 2nd 8 bytes
var blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
var counterBlock = new Array(blockSize); // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
var nonce = (new Date()).getTime(); // milliseconds since 1-Jan-1970
 
// encode nonce in two stages to cater for JavaScript 32-bit limit on bitwise ops
for (var i=0; i<4; i++) counterBlock[i] = (nonce >>> i*8) & 0xff;
for (var i=0; i<4; i++) counterBlock[i+4] = (nonce/0x100000000 >>> i*8) & 0xff;
 
// generate key schedule - an expansion of the key into distinct Key Rounds for each round
var keySchedule = KeyExpansion(key);
 
var blockCount = Math.ceil(plaintext.length/blockSize);
var ciphertext = new Array(blockCount); // ciphertext as array of strings
for (var b=0; b<blockCount; b++) {
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
// again done in two stages for 32-bit ops
for (var c=0; c<4; c++) counterBlock[15-c] = (b >>> c*8) & 0xff;
for (var c=0; c<4; c++) counterBlock[15-c-4] = (b/0x100000000 >>> c*8)
 
var cipherCntr = Cipher(counterBlock, keySchedule); // -- encrypt counter block --
// calculate length of final block:
var blockLength = b<blockCount-1 ? blockSize : (plaintext.length-1)%blockSize+1;
 
var ct = '';
for (var i=0; i<blockLength; i++) { // -- xor plaintext with ciphered counter byte-by-byte --
var plaintextByte = plaintext.charCodeAt(b*blockSize+i);
var cipherByte = plaintextByte ^ cipherCntr[i];
ct += String.fromCharCode(cipherByte);
}
// ct is now ciphertext for this block
 
ciphertext[b] = escCtrlChars(ct); // escape troublesome characters in ciphertext
}
 
// convert the nonce to a string to go on the front of the ciphertext
var ctrTxt = '';
for (var i=0; i<8; i++) ctrTxt += String.fromCharCode(counterBlock[i]);
ctrTxt = escCtrlChars(ctrTxt);
 
// use '-' to separate blocks, use Array.join to concatenate arrays of strings for efficiency
return ctrTxt + '-' + ciphertext.join('-');
}
 
 
/*
* Use AES to decrypt 'ciphertext' with 'password' using 'nBits' key, in Counter mode of operation
*
* for each block
* - outputblock = cipher(counter, key)
* - cipherblock = plaintext xor outputblock
*/
function AESDecryptCtr(ciphertext, password, nBits) {
if (!(nBits==128 || nBits==192 || nBits==256)) return ''; // standard allows 128/192/256 bit keys
 
var nBytes = nBits/8; // no bytes in key
var pwBytes = new Array(nBytes);
for (var i=0; i<nBytes; i++) pwBytes[i] = password.charCodeAt(i) & 0xff;
var pwKeySchedule = KeyExpansion(pwBytes);
var key = Cipher(pwBytes, pwKeySchedule);
key = key.concat(key.slice(0, nBytes-16)); // key is now 16/24/32 bytes long
 
var keySchedule = KeyExpansion(key);
 
ciphertext = ciphertext.split('-'); // split ciphertext into array of block-length strings
 
// recover nonce from 1st element of ciphertext
var blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
var counterBlock = new Array(blockSize);
var ctrTxt = unescCtrlChars(ciphertext[0]);
for (var i=0; i<8; i++) counterBlock[i] = ctrTxt.charCodeAt(i);
 
var plaintext = new Array(ciphertext.length-1);
 
for (var b=1; b<ciphertext.length; b++) {
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
for (var c=0; c<4; c++) counterBlock[15-c] = ((b-1) >>> c*8) & 0xff;
for (var c=0; c<4; c++) counterBlock[15-c-4] = ((b/0x100000000-1) >>> c*8) & 0xff;
 
var cipherCntr = Cipher(counterBlock, keySchedule); // encrypt counter block
 
ciphertext[b] = unescCtrlChars(ciphertext[b]);
 
var pt = '';
for (var i=0; i<ciphertext[b].length; i++) {
// -- xor plaintext with ciphered counter byte-by-byte --
var ciphertextByte = ciphertext[b].charCodeAt(i);
var plaintextByte = ciphertextByte ^ cipherCntr[i];
pt += String.fromCharCode(plaintextByte);
}
// pt is now plaintext for this block
 
plaintext[b-1] = pt; // b-1 'cos no initial nonce block in plaintext
}
 
return plaintext.join('');
}
 
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
function escCtrlChars(str) { // escape control chars which might cause problems handling ciphertext
return str.replace(/[\0\t\n\v\f\r\xa0!-]/g, function(c) { return '!' + c.charCodeAt(0) + '!'; });
} // \xa0 to cater for bug in Firefox; include '-' to leave it free for use as a block marker
 
function unescCtrlChars(str) { // unescape potentially problematic control characters
return str.replace(/!\d\d?\d?!/g, function(c) { return String.fromCharCode(c.slice(1,-1)); });
}
 
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function encrypt(plaintext, password){
return AESEncryptCtr(plaintext, password, 256);
}
 
function decrypt(ciphertext, password){
return AESDecryptCtr(ciphertext, password, 256);
}
/* End AES Implementation */
var cmd = msg.substr(0,4);
var arg = msg.substr(5);
if(cmd == "encr"){
arg = eval("(" + arg + ")");
var plaintext = arg.plaintext;
var password = arg.password;
var results = encrypt(plaintext, password);
gearsWorkerPool.sendMessage(String(results), sender);
}else if(cmd == "decr"){
arg = eval("(" + arg + ")");
var ciphertext = arg.ciphertext;
var password = arg.password;
var results = decrypt(ciphertext, password);
gearsWorkerPool.sendMessage(String(results), sender);
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/_sql/LICENSE
New file
0,0 → 1,9
License Disclaimer:
 
All contents of this directory are Copyright (c) the Dojo Foundation, with the
following exceptions:
-------------------------------------------------------------------------------
 
_crypto.js - internally uses AES algorithm
* AES algorithm copyright Chris Veness (CLA signed and permission given to use code under BSD license)
Taken from http://www.movable-type.co.uk/scripts/aes.html
/trunk/api/js/dojo1.0/dojox/_sql/common.js
New file
0,0 → 1,535
if(!dojo._hasResource["dojox._sql.common"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox._sql.common"] = true;
dojo.provide("dojox._sql.common");
 
dojo.require("dojox._sql._crypto");
 
// summary:
// Executes a SQL expression.
// description:
// There are four ways to call this:
// 1) Straight SQL: dojox.sql("SELECT * FROM FOOBAR");
// 2) SQL with parameters: dojox.sql("INSERT INTO FOOBAR VALUES (?)", someParam)
// 3) Encrypting particular values:
// dojox.sql("INSERT INTO FOOBAR VALUES (ENCRYPT(?))", someParam, "somePassword", callback)
// 4) Decrypting particular values:
// dojox.sql("SELECT DECRYPT(SOMECOL1), DECRYPT(SOMECOL2) FROM
// FOOBAR WHERE SOMECOL3 = ?", someParam,
// "somePassword", callback)
//
// For encryption and decryption the last two values should be the the password for
// encryption/decryption, and the callback function that gets the result set.
//
// Note: We only support ENCRYPT(?) statements, and
// and DECRYPT(*) statements for now -- you can not have a literal string
// inside of these, such as ENCRYPT('foobar')
//
// Note: If you have multiple columns to encrypt and decrypt, you can use the following
// convenience form to not have to type ENCRYPT(?)/DECRYPT(*) many times:
//
// dojox.sql("INSERT INTO FOOBAR VALUES (ENCRYPT(?, ?, ?))",
// someParam1, someParam2, someParam3,
// "somePassword", callback)
//
// dojox.sql("SELECT DECRYPT(SOMECOL1, SOMECOL2) FROM
// FOOBAR WHERE SOMECOL3 = ?", someParam,
// "somePassword", callback)
dojox.sql = new Function("return dojox.sql._exec(arguments);");
 
dojo.mixin(dojox.sql, {
dbName: null,
// summary:
// If true, then we print out any SQL that is executed
// to the debug window
debug: (dojo.exists("dojox.sql.debug")?dojox.sql.debug:false),
 
open: function(dbName){
if(this._dbOpen && (!dbName || dbName == this.dbName)){
return;
}
if(!this.dbName){
this.dbName = "dot_store_"
+ window.location.href.replace(/[^0-9A-Za-z_]/g, "_");
//console.debug("Using Google Gears database " + this.dbName);
}
if(!dbName){
dbName = this.dbName;
}
try{
this._initDb();
this.db.open(dbName);
this._dbOpen = true;
}catch(exp){
throw exp.message||exp;
}
},
 
close: function(dbName){
// on Internet Explorer, Google Gears throws an exception
// "Object not a collection", when we try to close the
// database -- just don't close it on this platform
// since we are running into a Gears bug; the Gears team
// said it's ok to not close a database connection
if(dojo.isIE){ return; }
if(!this._dbOpen && (!dbName || dbName == this.dbName)){
return;
}
if(!dbName){
dbName = this.dbName;
}
try{
this.db.close(dbName);
this._dbOpen = false;
}catch(exp){
throw exp.message||exp;
}
},
_exec: function(params){
try{
// get the Gears Database object
this._initDb();
// see if we need to open the db; if programmer
// manually called dojox.sql.open() let them handle
// it; otherwise we open and close automatically on
// each SQL execution
if(!this._dbOpen){
this.open();
this._autoClose = true;
}
// determine our parameters
var sql = null;
var callback = null;
var password = null;
 
var args = dojo._toArray(params);
 
sql = args.splice(0, 1)[0];
 
// does this SQL statement use the ENCRYPT or DECRYPT
// keywords? if so, extract our callback and crypto
// password
if(this._needsEncrypt(sql) || this._needsDecrypt(sql)){
callback = args.splice(args.length - 1, 1)[0];
password = args.splice(args.length - 1, 1)[0];
}
 
// 'args' now just has the SQL parameters
 
// print out debug SQL output if the developer wants that
if(this.debug){
this._printDebugSQL(sql, args);
}
 
// handle SQL that needs encryption/decryption differently
// do we have an ENCRYPT SQL statement? if so, handle that first
if(this._needsEncrypt(sql)){
var crypto = new dojox.sql._SQLCrypto("encrypt", sql,
password, args,
callback);
return; // encrypted results will arrive asynchronously
}else if(this._needsDecrypt(sql)){ // otherwise we have a DECRYPT statement
var crypto = new dojox.sql._SQLCrypto("decrypt", sql,
password, args,
callback);
return; // decrypted results will arrive asynchronously
}
 
// execute the SQL and get the results
var rs = this.db.execute(sql, args);
// Gears ResultSet object's are ugly -- normalize
// these into something JavaScript programmers know
// how to work with, basically an array of
// JavaScript objects where each property name is
// simply the field name for a column of data
rs = this._normalizeResults(rs);
if(this._autoClose){
this.close();
}
return rs;
}catch(exp){
exp = exp.message||exp;
console.debug("SQL Exception: " + exp);
if(this._autoClose){
try{
this.close();
}catch(e){
console.debug("Error closing database: "
+ e.message||e);
}
}
throw exp;
}
},
 
_initDb: function(){
if(!this.db){
try{
this.db = google.gears.factory.create('beta.database', '1.0');
}catch(exp){
dojo.setObject("google.gears.denied", true);
dojox.off.onFrameworkEvent("coreOperationFailed");
throw "Google Gears must be allowed to run";
}
}
},
 
_printDebugSQL: function(sql, args){
var msg = "dojox.sql(\"" + sql + "\"";
for(var i = 0; i < args.length; i++){
if(typeof args[i] == "string"){
msg += ", \"" + args[i] + "\"";
}else{
msg += ", " + args[i];
}
}
msg += ")";
console.debug(msg);
},
 
_normalizeResults: function(rs){
var results = [];
if(!rs){ return []; }
while(rs.isValidRow()){
var row = {};
for(var i = 0; i < rs.fieldCount(); i++){
var fieldName = rs.fieldName(i);
var fieldValue = rs.field(i);
row[fieldName] = fieldValue;
}
results.push(row);
rs.next();
}
rs.close();
return results;
},
 
_needsEncrypt: function(sql){
return /encrypt\([^\)]*\)/i.test(sql);
},
 
_needsDecrypt: function(sql){
return /decrypt\([^\)]*\)/i.test(sql);
}
});
 
// summary:
// A private class encapsulating any cryptography that must be done
// on a SQL statement. We instantiate this class and have it hold
// it's state so that we can potentially have several encryption
// operations happening at the same time by different SQL statements.
dojo.declare("dojox.sql._SQLCrypto", null, {
constructor: function(action, sql, password, args, callback){
if(action == "encrypt"){
this._execEncryptSQL(sql, password, args, callback);
}else{
this._execDecryptSQL(sql, password, args, callback);
}
},
_execEncryptSQL: function(sql, password, args, callback){
// strip the ENCRYPT/DECRYPT keywords from the SQL
var strippedSQL = this._stripCryptoSQL(sql);
// determine what arguments need encryption
var encryptColumns = this._flagEncryptedArgs(sql, args);
// asynchronously encrypt each argument that needs it
var self = this;
this._encrypt(strippedSQL, password, args, encryptColumns, function(finalArgs){
// execute the SQL
var error = false;
var resultSet = [];
var exp = null;
try{
resultSet = dojox.sql.db.execute(strippedSQL, finalArgs);
}catch(execError){
error = true;
exp = execError.message||execError;
}
// was there an error during SQL execution?
if(exp != null){
if(dojox.sql._autoClose){
try{ dojox.sql.close(); }catch(e){}
}
callback(null, true, exp.toString());
return;
}
// normalize SQL results into a JavaScript object
// we can work with
resultSet = dojox.sql._normalizeResults(resultSet);
if(dojox.sql._autoClose){
dojox.sql.close();
}
// are any decryptions necessary on the result set?
if(dojox.sql._needsDecrypt(sql)){
// determine which of the result set columns needs decryption
var needsDecrypt = self._determineDecryptedColumns(sql);
 
// now decrypt columns asynchronously
// decrypt columns that need it
self._decrypt(resultSet, needsDecrypt, password, function(finalResultSet){
callback(finalResultSet, false, null);
});
}else{
callback(resultSet, false, null);
}
});
},
 
_execDecryptSQL: function(sql, password, args, callback){
// strip the ENCRYPT/DECRYPT keywords from the SQL
var strippedSQL = this._stripCryptoSQL(sql);
// determine which columns needs decryption; this either
// returns the value *, which means all result set columns will
// be decrypted, or it will return the column names that need
// decryption set on a hashtable so we can quickly test a given
// column name; the key is the column name that needs
// decryption and the value is 'true' (i.e. needsDecrypt["someColumn"]
// would return 'true' if it needs decryption, and would be 'undefined'
// or false otherwise)
var needsDecrypt = this._determineDecryptedColumns(sql);
// execute the SQL
var error = false;
var resultSet = [];
var exp = null;
try{
resultSet = dojox.sql.db.execute(strippedSQL, args);
}catch(execError){
error = true;
exp = execError.message||execError;
}
// was there an error during SQL execution?
if(exp != null){
if(dojox.sql._autoClose){
try{ dojox.sql.close(); }catch(e){}
}
callback(resultSet, true, exp.toString());
return;
}
// normalize SQL results into a JavaScript object
// we can work with
resultSet = dojox.sql._normalizeResults(resultSet);
if(dojox.sql._autoClose){
dojox.sql.close();
}
// decrypt columns that need it
this._decrypt(resultSet, needsDecrypt, password, function(finalResultSet){
callback(finalResultSet, false, null);
});
},
 
_encrypt: function(sql, password, args, encryptColumns, callback){
//console.debug("_encrypt, sql="+sql+", password="+password+", encryptColumns="+encryptColumns+", args="+args);
this._totalCrypto = 0;
this._finishedCrypto = 0;
this._finishedSpawningCrypto = false;
this._finalArgs = args;
for(var i = 0; i < args.length; i++){
if(encryptColumns[i]){
// we have an encrypt() keyword -- get just the value inside
// the encrypt() parantheses -- for now this must be a ?
var sqlParam = args[i];
var paramIndex = i;
// update the total number of encryptions we know must be done asynchronously
this._totalCrypto++;
// FIXME: This currently uses DES as a proof-of-concept since the
// DES code used is quite fast and was easy to work with. Modify dojox.sql
// to be able to specify a different encryption provider through a
// a SQL-like syntax, such as dojox.sql("SET ENCRYPTION BLOWFISH"),
// and modify the dojox.crypto.Blowfish code to be able to work using
// a Google Gears Worker Pool
// do the actual encryption now, asychronously on a Gears worker thread
dojox._sql._crypto.encrypt(sqlParam, password, dojo.hitch(this, function(results){
// set the new encrypted value
this._finalArgs[paramIndex] = results;
this._finishedCrypto++;
// are we done with all encryption?
if(this._finishedCrypto >= this._totalCrypto
&& this._finishedSpawningCrypto){
callback(this._finalArgs);
}
}));
}
}
this._finishedSpawningCrypto = true;
},
 
_decrypt: function(resultSet, needsDecrypt, password, callback){
//console.debug("decrypt, resultSet="+resultSet+", needsDecrypt="+needsDecrypt+", password="+password);
this._totalCrypto = 0;
this._finishedCrypto = 0;
this._finishedSpawningCrypto = false;
this._finalResultSet = resultSet;
for(var i = 0; i < resultSet.length; i++){
var row = resultSet[i];
// go through each of the column names in row,
// seeing if they need decryption
for(var columnName in row){
if(needsDecrypt == "*" || needsDecrypt[columnName]){
this._totalCrypto++;
var columnValue = row[columnName];
// forming a closure here can cause issues, with values not cleanly
// saved on Firefox/Mac OS X for some of the values above that
// are needed in the callback below; call a subroutine that will form
// a closure inside of itself instead
this._decryptSingleColumn(columnName, columnValue, password, i,
function(finalResultSet){
callback(finalResultSet);
});
}
}
}
this._finishedSpawningCrypto = true;
},
 
_stripCryptoSQL: function(sql){
// replace all DECRYPT(*) occurrences with a *
sql = sql.replace(/DECRYPT\(\*\)/ig, "*");
// match any ENCRYPT(?, ?, ?, etc) occurrences,
// then replace with just the question marks in the
// middle
var matches = sql.match(/ENCRYPT\([^\)]*\)/ig);
if(matches != null){
for(var i = 0; i < matches.length; i++){
var encryptStatement = matches[i];
var encryptValue = encryptStatement.match(/ENCRYPT\(([^\)]*)\)/i)[1];
sql = sql.replace(encryptStatement, encryptValue);
}
}
// match any DECRYPT(COL1, COL2, etc) occurrences,
// then replace with just the column names
// in the middle
matches = sql.match(/DECRYPT\([^\)]*\)/ig);
if(matches != null){
for(var i = 0; i < matches.length; i++){
var decryptStatement = matches[i];
var decryptValue = decryptStatement.match(/DECRYPT\(([^\)]*)\)/i)[1];
sql = sql.replace(decryptStatement, decryptValue);
}
}
return sql;
},
 
_flagEncryptedArgs: function(sql, args){
// capture literal strings that have question marks in them,
// and also capture question marks that stand alone
var tester = new RegExp(/([\"][^\"]*\?[^\"]*[\"])|([\'][^\']*\?[^\']*[\'])|(\?)/ig);
var matches;
var currentParam = 0;
var results = [];
while((matches = tester.exec(sql)) != null){
var currentMatch = RegExp.lastMatch+"";
 
// are we a literal string? then ignore it
if(/^[\"\']/.test(currentMatch)){
continue;
}
 
// do we have an encrypt keyword to our left?
var needsEncrypt = false;
if(/ENCRYPT\([^\)]*$/i.test(RegExp.leftContext)){
needsEncrypt = true;
}
 
// set the encrypted flag
results[currentParam] = needsEncrypt;
 
currentParam++;
}
return results;
},
 
_determineDecryptedColumns: function(sql){
var results = {};
 
if(/DECRYPT\(\*\)/i.test(sql)){
results = "*";
}else{
var tester = /DECRYPT\((?:\s*\w*\s*\,?)*\)/ig;
var matches;
while(matches = tester.exec(sql)){
var lastMatch = new String(RegExp.lastMatch);
var columnNames = lastMatch.replace(/DECRYPT\(/i, "");
columnNames = columnNames.replace(/\)/, "");
columnNames = columnNames.split(/\s*,\s*/);
dojo.forEach(columnNames, function(column){
if(/\s*\w* AS (\w*)/i.test(column)){
column = column.match(/\s*\w* AS (\w*)/i)[1];
}
results[column] = true;
});
}
}
 
return results;
},
 
_decryptSingleColumn: function(columnName, columnValue, password, currentRowIndex,
callback){
//console.debug("decryptSingleColumn, columnName="+columnName+", columnValue="+columnValue+", currentRowIndex="+currentRowIndex)
dojox._sql._crypto.decrypt(columnValue, password, dojo.hitch(this, function(results){
// set the new decrypted value
this._finalResultSet[currentRowIndex][columnName] = results;
this._finishedCrypto++;
// are we done with all encryption?
if(this._finishedCrypto >= this._totalCrypto
&& this._finishedSpawningCrypto){
//console.debug("done with all decrypts");
callback(this._finalResultSet);
}
}));
}
});
 
}
/trunk/api/js/dojo1.0/dojox/gfx.js
New file
0,0 → 1,39
if(!dojo._hasResource["dojox.gfx"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx"] = true;
dojo.provide("dojox.gfx");
 
dojo.require("dojox.gfx.matrix");
dojo.require("dojox.gfx._base");
 
(function(){
var renderers = (typeof djConfig["gfxRenderer"] == "string" ?
djConfig["gfxRenderer"] : "svg,vml,silverlight,canvas").split(",");
for(var i = 0; i < renderers.length; ++i){
switch(renderers[i]){
case "svg":
//TODO: need more comprehensive test for SVG
if(!dojo.isIE && (navigator.userAgent.indexOf("iPhone") < 0) && (navigator.userAgent.indexOf("iPod") < 0)){ dojox.gfx.renderer = "svg"; }
break;
case "vml":
if(dojo.isIE != 0){ dojox.gfx.renderer = "vml"; }
break;
case "silverlight":
//TODO: need more comprehensive test for Silverlight
if(window.Silverlight){ dojox.gfx.renderer = "silverlight"; }
break;
case "canvas":
//TODO: need more comprehensive test for Canvas
if(dojo.isIE == 0){ dojox.gfx.renderer = "canvas"; }
break;
}
if(dojox.gfx.renderer){ break; }
}
})();
 
// include a renderer conditionally
dojo.requireIf(dojox.gfx.renderer == "svg", "dojox.gfx.svg");
dojo.requireIf(dojox.gfx.renderer == "vml", "dojox.gfx.vml");
dojo.requireIf(dojox.gfx.renderer == "silverlight", "dojox.gfx.silverlight");
dojo.requireIf(dojox.gfx.renderer == "canvas", "dojox.gfx.canvas");
 
}
/trunk/api/js/dojo1.0/dojox/validate.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.validate"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.validate"] = true;
dojo.provide("dojox.validate");
dojo.require("dojox.validate._base");
 
}
/trunk/api/js/dojo1.0/dojox/storage/Storage_version8.swf
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/storage/Storage_version8.swf
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/storage/_common.js
New file
0,0 → 1,18
if(!dojo._hasResource["dojox.storage._common"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.storage._common"] = true;
dojo.provide("dojox.storage._common");
dojo.require("dojox.storage.Provider");
dojo.require("dojox.storage.manager");
 
dojo.require("dojox.storage.GearsStorageProvider");
 
// FIXME: Find way to set isGears from offline.profile.js file; it didn't
// work for me
//dojo.requireIf(!dojo.isGears, "dojox.storage.FlashStorageProvider");
//dojo.requireIf(!dojo.isGears, "dojox.storage.WhatWGStorageProvider");
 
// now that we are loaded and registered tell the storage manager to
// initialize itself
dojox.storage.manager.initialize();
 
}
/trunk/api/js/dojo1.0/dojox/storage/tests/test_storage.html
New file
0,0 → 1,159
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
 
<html>
 
<head>
<title>Dojo Storage Test</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
</style>
 
<script type="text/javascript"
src="../../../dojo/dojo.js" djConfig="isDebug: false"></script>
 
<!--
// 'forceStorageProvider' is a flag to
// force a particular storage type. Example:
//var djConfig = {
// isDebug: false,
// forceStorageProvider: "dojox.storage.FlashStorageProvider"
// };
-->
<script type="text/javascript" src="test_storage.js"></script>
<style type="text/css">
h1 { margin: 0px auto 0px auto; padding-top: 0px auto 0px auto; clear: none; float: left; }
body { padding: 0.2em 1em 1em 1em; }
div { margin-bottom: 1.5em; }
label { margin-right: 0.6em; }
button { margin-right: 0.6em; }
form { float: right; width: 80%; }
#top { width: 70%; }
#directoryContainer { float: left; clear: left; width: 20%; }
#templates { text-align: center; }
#templates a { display: block; margin-top: 1em; }
#directory { width: 100%; }
#namespaceDirectory { width: 100%; }
#storageValue { vertical-align: top; width: 100%; height: 10em; }
#buttonContainer { text-align: center; }
#currentStorageProvider { font-weight: bold; }
#providerMetadataContainer { float: right; font-size: 9pt; }
#storageForm { width: 70%; }
.status { float: right; padding-left: 5px; padding-right: 5px; background: red; color: white; }
.providerMetadata { font-weight: bold; margin-bottom: 0.5em; }
.providerMetadataValue { font-weight: normal; }
</style>
</head>
 
<body>
<div id="top">
<h1>Dojo.Storage Test</h1>
</div>
<div id="directoryContainer">
<h2>All Namespaces:</h2>
<select id="namespaceDirectory" size="3"></select>
<h2>All Keys:</h2>
<select id="directory" size="10">
</select>
<div id="templates">
<a href="#" onclick="return TestStorage.saveBook()">Save Test Book (238K - Faust by Goethe)</a>
<a href="#" onclick="return TestStorage.saveXML()">Save Test XML</a>
</div>
</div>
<form id="storageForm">
<h2>Save/Load Values:</h2>
<div>
<div id="providerMetadataContainer">
<div class="providerMetadata">
Supported:
<span id="isSupported" class="providerMetadataValue">
</span>
</div>
<div class="providerMetadata">
Supports Persistence:
<span id="isPersistent" class="providerMetadataValue">
</span>
</div>
<div class="providerMetadata">
Supports UI Configuration:
<span id="hasUIConfig" class="providerMetadataValue">
</span>
</div>
<div class="providerMetadata">
Maximum Size:
<span id="maximumSize" class="providerMetadataValue">
</span>
</div>
<div class="providerMetadata">
Value size:
<span id="valueSize" class="providerMetadataValue">
</span>
</div>
<div class="providerMetadata">
More info:
<span id="moreInfo" class="providerMetadataValue">
</span>
</div>
</div>
<div>
Storage Provider:
<span id="currentStorageProvider">None</span>
</div>
</div>
<div id="storageNamespaceContainer">
<label for="storageNamespace">
Namespace:
</label>
<input type="text" id="storageNamespace" name="storageNamespace" size="40" disabled="true">
</div>
<div id="storageKeyContainer">
<label for="storageKey">
Key:
</label>
<input type="text" id="storageKey" name="storageKey" size="40" disabled="true">
</div>
<div id="storageValueContainer">
<label for="storageValue">
Value:
</label>
<textarea id="storageValue" name="storageValue" disabled="true"></textarea>
</div>
<div id="buttonContainer">
<button id="loadButton" disabled="true">Load</button>
<button id="saveButton" disabled="true">Save</button>
<button id="removeButton" disabled="true">Remove</button>
<button id="clearNamespaceButton" disabled="true">Clear Namespace</button>
<button id="configureButton" disabled="true">Configure</button>
</div>
</form>
</body>
 
</html>
/trunk/api/js/dojo1.0/dojox/storage/tests/resources/testXML.xml
New file
0,0 → 1,203
<?xml version="1.0" encoding="windows-1252" standalone="yes"?>
<feed xmlns="http://purl.org/atom/ns#" version="0.3" xml:lang="en-US">
<link href="https://www.blogger.com/atom/3191291" rel="service.post" title="Coding In Paradise" type="application/atom+xml"/>
<link href="https://www.blogger.com/atom/3191291" rel="service.feed" title="Coding In Paradise" type="application/atom+xml"/>
<title mode="escaped" type="text/html">Coding In Paradise</title>
<tagline mode="escaped" type="text/html">Brad Neuberg's thoughts, feelings, and experiences.</tagline>
<link href="http://codinginparadise.org/weblog/" rel="alternate" title="Coding In Paradise" type="text/html"/>
<id>tag:blogger.com,1999:blog-3191291</id>
<modified>2006-01-26T01:37:22Z</modified>
<generator url="http://www.blogger.com/" version="5.15">Blogger</generator>
<info mode="xml" type="text/html">
<div xmlns="http://www.w3.org/1999/xhtml">This is an Atom formatted XML site feed. It is intended to be viewed in a Newsreader or syndicated to another site. Please visit the <a href="http://help.blogger.com/bin/answer.py?answer=697">Blogger Help</a> for more info.</div>
</info>
<convertLineBreaks xmlns="http://www.blogger.com/atom/ns#">true</convertLineBreaks>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/3191291/113823944195262179" rel="service.edit" title="Resume" type="application/atom+xml"/>
<author>
<name>Brad GNUberg</name>
</author>
<issued>2006-01-25T17:36:00-08:00</issued>
<modified>2006-01-26T01:37:21Z</modified>
<created>2006-01-26T01:37:21Z</created>
<link href="http://codinginparadise.org/weblog/2006/01/resume.html" rel="alternate" title="Resume" type="text/html"/>
<id>tag:blogger.com,1999:blog-3191291.post-113823944195262179</id>
<title mode="escaped" type="text/html">Resume</title>
<summary type="application/xhtml+xml" xml:base="http://codinginparadise.org/weblog/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">I just finished and put up my resume. Resumes are hard :)</div>
</summary>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/3191291/113761645059106145" rel="service.edit" title="AJAXian Site Comparison with Alexa" type="application/atom+xml"/>
<author>
<name>Brad GNUberg</name>
</author>
<issued>2006-01-18T12:33:00-08:00</issued>
<modified>2006-01-18T20:34:10Z</modified>
<created>2006-01-18T20:34:10Z</created>
<link href="http://codinginparadise.org/weblog/2006/01/ajaxian-site-comparison-with-alexa.html" rel="alternate" title="AJAXian Site Comparison with Alexa" type="text/html"/>
<id>tag:blogger.com,1999:blog-3191291.post-113761645059106145</id>
<title mode="escaped" type="text/html">AJAXian Site Comparison with Alexa</title>
<summary type="application/xhtml+xml" xml:base="http://codinginparadise.org/weblog/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Joe Walker has created an interesting AJAX mashup using Alexa data, making Alexa a bit more useful.</div>
</summary>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/3191291/113761599631873348" rel="service.edit" title="Civil Engines Released" type="application/atom+xml"/>
<author>
<name>Brad GNUberg</name>
</author>
<issued>2006-01-18T12:16:00-08:00</issued>
<modified>2006-01-18T21:43:11Z</modified>
<created>2006-01-18T20:26:36Z</created>
<link href="http://codinginparadise.org/weblog/2006/01/civil-engines-released.html" rel="alternate" title="Civil Engines Released" type="text/html"/>
<id>tag:blogger.com,1999:blog-3191291.post-113761599631873348</id>
<title mode="escaped" type="text/html">Civil Engines Released</title>
<summary type="application/xhtml+xml" xml:base="http://codinginparadise.org/weblog/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">My old cohorts with BaseSystem and OpenPortal, Christoper Tse, Paolo de Dios, and Ken Rossi of Liquid Orb Media have just shipped their software and announced their company. The company is named Civil Engines, and the software is called Civil Netizen:
 
Civil Netizen provides a useful, secure way to easily transfer large files and groups of files between people on the Internet, getting past FTP</div>
</summary>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/3191291/113756800036562086" rel="service.edit" title="Photos of Mash Pit" type="application/atom+xml"/>
<author>
<name>Brad GNUberg</name>
</author>
<issued>2006-01-17T23:06:00-08:00</issued>
<modified>2006-01-18T07:13:56Z</modified>
<created>2006-01-18T07:06:40Z</created>
<link href="http://codinginparadise.org/weblog/2006/01/photos-of-mash-pit.html" rel="alternate" title="Photos of Mash Pit" type="text/html"/>
<id>tag:blogger.com,1999:blog-3191291.post-113756800036562086</id>
<title mode="escaped" type="text/html">Photos of Mash Pit</title>
<summary type="application/xhtml+xml" xml:base="http://codinginparadise.org/weblog/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Photos of Flash Pit are up on Flickr now:
 
 
 
 
 
 
 
 
 
</div>
</summary>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/3191291/113756743174780868" rel="service.edit" title="Offline Access in AJAX Applications" type="application/atom+xml"/>
<author>
<name>Brad GNUberg</name>
</author>
<issued>2006-01-17T22:56:00-08:00</issued>
<modified>2006-01-18T19:45:28Z</modified>
<created>2006-01-18T06:57:11Z</created>
<link href="http://codinginparadise.org/weblog/2006/01/offline-access-in-ajax-applications.html" rel="alternate" title="Offline Access in AJAX Applications" type="text/html"/>
<id>tag:blogger.com,1999:blog-3191291.post-113756743174780868</id>
<title mode="escaped" type="text/html">Offline Access in AJAX Applications</title>
<summary type="application/xhtml+xml" xml:base="http://codinginparadise.org/weblog/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Update: Julien reports that he's not actually using AMASS in his offline work, but was inspired by it. He rolled his own access to Flash's storage capabilities using ExternalInterface, but he should be aware of the reliability and performance issues with ExternalInterface (I tried to paste 250K of text into the Wiki and the browser locked up for a long period of time as it tried to pass the data</div>
</summary>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/3191291/113756574524170757" rel="service.edit" title="Mash Pit Synopses" type="application/atom+xml"/>
<author>
<name>Brad GNUberg</name>
</author>
<issued>2006-01-17T22:15:00-08:00</issued>
<modified>2006-01-18T06:29:05Z</modified>
<created>2006-01-18T06:29:05Z</created>
<link href="http://codinginparadise.org/weblog/2006/01/mash-pit-synopses.html" rel="alternate" title="Mash Pit Synopses" type="text/html"/>
<id>tag:blogger.com,1999:blog-3191291.post-113756574524170757</id>
<title mode="escaped" type="text/html">Mash Pit Synopses</title>
<summary type="application/xhtml+xml" xml:base="http://codinginparadise.org/weblog/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Man, what an amazing event! We had a post-Mash Pit dinner and party at Lonely Palm.
 
Here's some more info about the three projects that were produced at the end of the day.
 
The first one was called Whuffie Tracker; the idea there was to produce a single site that could take your list of blogs and online sites, query other remote sites like Technorati and Flickr, and tell you who is talking about</div>
</summary>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/3191291/113754717012597001" rel="service.edit" title="Mash Pit 4" type="application/atom+xml"/>
<author>
<name>Brad GNUberg</name>
</author>
<issued>2006-01-17T17:19:00-08:00</issued>
<modified>2006-01-18T01:19:30Z</modified>
<created>2006-01-18T01:19:30Z</created>
<link href="http://codinginparadise.org/weblog/2006/01/mash-pit-4.html" rel="alternate" title="Mash Pit 4" type="text/html"/>
<id>tag:blogger.com,1999:blog-3191291.post-113754717012597001</id>
<title mode="escaped" type="text/html">Mash Pit 4</title>
<summary type="application/xhtml+xml" xml:base="http://codinginparadise.org/weblog/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">It's demo time at Mash Pit. Everyone is furiously coding, but the clock is almost over. We'll have three demos. I'll try to blog them as people give them.</div>
</summary>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/3191291/113754482097808410" rel="service.edit" title="Mash Pit 3" type="application/atom+xml"/>
<author>
<name>Brad GNUberg</name>
</author>
<issued>2006-01-17T16:39:00-08:00</issued>
<modified>2006-01-18T00:40:20Z</modified>
<created>2006-01-18T00:40:20Z</created>
<link href="http://codinginparadise.org/weblog/2006/01/mash-pit-3.html" rel="alternate" title="Mash Pit 3" type="text/html"/>
<id>tag:blogger.com,1999:blog-3191291.post-113754482097808410</id>
<title mode="escaped" type="text/html">Mash Pit 3</title>
<summary type="application/xhtml+xml" xml:base="http://codinginparadise.org/weblog/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">We're hacking away, very intensely! No time to post! Just 30 more minutes till we have to be done, at 5:15 PM. Nothing like a hard deadline to force you to make hard decisions.</div>
</summary>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/3191291/113753268191434316" rel="service.edit" title="Mash Pit 2" type="application/atom+xml"/>
<author>
<name>Brad GNUberg</name>
</author>
<issued>2006-01-17T10:43:00-08:00</issued>
<modified>2006-01-17T21:18:01Z</modified>
<created>2006-01-17T21:18:01Z</created>
<link href="http://codinginparadise.org/weblog/2006/01/mash-pit-2.html" rel="alternate" title="Mash Pit 2" type="text/html"/>
<id>tag:blogger.com,1999:blog-3191291.post-113753268191434316</id>
<title mode="escaped" type="text/html">Mash Pit 2</title>
<summary type="application/xhtml+xml" xml:base="http://codinginparadise.org/weblog/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">People are doing intros, saying what their skills are and what they are interested in.
 
We had a big brainstorming session in the morning. The goal was to focus on ideas independent of technology, to force us to focus on whether something is relevant rather than just technologically interesting.
 
We broke for lunch, sponsored by Ning.
 
We've formed three groups that are working independently now.</div>
</summary>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/3191291/113752336910726653" rel="service.edit" title="Mash Pit Starts" type="application/atom+xml"/>
<author>
<name>Brad GNUberg</name>
</author>
<issued>2006-01-17T10:36:00-08:00</issued>
<modified>2006-01-17T18:42:49Z</modified>
<created>2006-01-17T18:42:49Z</created>
<link href="http://codinginparadise.org/weblog/2006/01/mash-pit-starts.html" rel="alternate" title="Mash Pit Starts" type="text/html"/>
<id>tag:blogger.com,1999:blog-3191291.post-113752336910726653</id>
<title mode="escaped" type="text/html">Mash Pit Starts</title>
<summary type="application/xhtml+xml" xml:base="http://codinginparadise.org/weblog/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Mash Pit is starting now, Chris is talking. We've got a full house of hackers, programmers, thinkers, and open source folks.
 
The goal today is to somehow make the work people have been doing with Web 2.0 relevant for normal folks.
 
We're doing introductions and introducing people to the coworking space. Thanks to Chris for setting up Mash Pit.
 
We should be lazy today, try to reuse as much</div>
</summary>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
</feed>
/trunk/api/js/dojo1.0/dojox/storage/tests/resources/testBook.txt
New file
0,0 → 1,7104
The Project Gutenberg EBook of Faust, by Goethe
 
This eBook is for the use of anyone anywhere at no cost and with
almost no restrictions whatsoever. You may copy it, give it away or
re-use it under the terms of the Project Gutenberg License included
with this eBook or online at www.gutenberg.net
 
 
Title: Faust
 
Author: Goethe
 
Release Date: December 25, 2004 [EBook #14460]
 
Language: English
 
Character set encoding: ISO-8859-1
 
*** START OF THIS PROJECT GUTENBERG EBOOK FAUST ***
 
 
 
 
Produced by Juliet Sutherland, Charles Bidwell and the PG Online
Distributed Proofreading Team
 
 
 
 
 
 
FAUST
 
 
A TRAGEDY
 
TRANSLATED FROM THE GERMAN
 
OF
 
GOETHE
 
 
WITH NOTES
 
BY
 
CHARLES T BROOKS
 
 
SEVENTH EDITION.
 
BOSTON
TICKNOR AND FIELDS
 
MDCCCLXVIII.
 
 
 
Entered according to Act of Congress, in the year 1856,
by CHARLES T. BROOKS,
In the Clerk's Office of the District Court
of the District of Rhode Island.
 
UNIVERSITY PRESS:
WELCH, BIGELOW, AND COMPANY,
CAMBRIDGE.
 
 
 
 
TRANSLATOR'S PREFACE.
 
 
Perhaps some apology ought to be given to English scholars, that is, those
who do not know German, (to those, at least, who do not know what sort of
a thing Faust is in the original,) for offering another translation to the
public, of a poem which has been already translated, not only in a literal
prose form, but also, twenty or thirty times, in metre, and sometimes with
great spirit, beauty, and power.
 
The author of the present version, then, has no knowledge that a rendering
of this wonderful poem into the exact and ever-changing metre of the
original has, until now, been so much as attempted. To name only one
defect, the very best versions which he has seen neglect to follow the
exquisite artist in the evidently planned and orderly intermixing of
_male_ and _female_ rhymes, _i.e._ rhymes which fall on the last syllable
and those which fall on the last but one. Now, every careful student of
the versification of Faust must feel and see that Goethe did not
intersperse the one kind of rhyme with the other, at random, as those
translators do; who, also, give the female rhyme (on which the vivacity of
dialogue and description often so much depends,) in so small a proportion.
 
A similar criticism might be made of their liberty in neglecting Goethe's
method of alternating different measures with each other.
 
It seems as if, in respect to metre, at least, they had asked themselves,
how would Goethe have written or shaped this in English, had that been his
native language, instead of seeking _con amore_ (and _con fidelità_) as
they should have done, to reproduce, both in spirit and in form, the
movement, so free and yet orderly, of the singularly endowed and
accomplished poet whom they undertook to represent.
 
As to the objections which Hayward and some of his reviewers have
instituted in advance against the possibility of a good and faithful
metrical translation of a poem like Faust, they seem to the present
translator full of paradox and sophistry. For instance, take this
assertion of one of the reviewers: "The sacred and mysterious union of
thought with verse, twin-born and immortally wedded from the moment of
their common birth, can never be understood by those who desire verse
translations of good poetry." If the last part of this statement had read
"by those who can be contented with _prose_ translations of good poetry,"
the position would have been nearer the truth. This much we might well
admit, that, if the alternative were either to have a poem like Faust in a
metre different and glaringly different from the original, or to have it
in simple and strong prose, then the latter alternative would be the one
every tasteful and feeling scholar would prefer; but surely to every one
who can read the original or wants to know how this great song _sung
itself_ (as Carlyle says) out of Goethe's soul, a mere prose rendering
must be, comparatively, a _corpus mortuum._
 
The translator most heartily dissents from Hayward's assertion that a
translator of Faust "must sacrifice either metre or meaning." At least he
flatters himself that he has made, in the main, (not a compromise between
meaning and melody, though in certain instances he may have fallen into
that, but) a combination of the meaning with the melody, which latter is
so important, so vital a part of the lyric poem's meaning, in any worthy
sense. "No poetic translation," says Hayward's reviewer, already quoted,
"can give the rhythm and rhyme of the original; it can only substitute the
rhythm and rhyme of the translator." One might just as well say "no
_prose_ translation can give the _sense and spirit_ of the original; it
can only substitute the _sense and spirit of the words and phrases of the
translator's language_;" and then, these two assertions balancing each
other, there will remain in the metrical translator's favor, that he may
come as near to giving both the letter and the spirit, as the effects of
the Babel dispersion will allow.
 
As to the original creation, which he has attempted here to reproduce, the
translator might say something, but prefers leaving his readers to the
poet himself, as revealed in the poem, and to the various commentaries of
which we have some accounts, at least, in English. A French translator of
the poem speaks in his introduction as follows: "This Faust, conceived by
him in his youth, completed in ripe age, the idea of which he carried with
him through all the commotions of his life, as Camoens bore his poem with
him through the waves, this Faust contains him entire. The thirst for
knowledge and the martyrdom of doubt, had they not tormented his early
years? Whence came to him the thought of taking refuge in a supernatural
realm, of appealing to invisible powers, which plunged him, for a
considerable time, into the dreams of Illuminati and made him even invent
a religion? This irony of Mephistopheles, who carries on so audacious a
game with the weakness and the desires of man, is it not the mocking,
scornful side of the poet's spirit, a leaning to sullenness, which can be
traced even into the earliest years of his life, a bitter leaven thrown
into a strong soul forever by early satiety? The character of Faust
especially, the man whose burning, untiring heart can neither enjoy
fortune nor do without it, who gives himself unconditionally and watches
himself with mistrust, who unites the enthusiasm of passion and the
dejectedness of despair, is not this an eloquent opening up of the most
secret and tumultuous part of the poet's soul? And now, to complete the
image of his inner life, he has added the transcendingly sweet person of
Margaret, an exalted reminiscence of a young girl, by whom, at the age of
fourteen, he thought himself beloved, whose image ever floated round him,
and has contributed some traits to each of his heroines. This heavenly
surrender of a simple, good, and tender heart contrasts wonderfully with
the sensual and gloomy passion of the lover, who, in the midst of his
love-dreams, is persecuted by the phantoms of his imagination and by the
nightmares of thought, with those sorrows of a soul, which is crushed, but
not extinguished, which is tormented by the invincible want of happiness
and the bitter feeling, how hard a thing it is to receive or to bestow."
 
 
 
 
DEDICATION.[1]
 
Once more ye waver dreamily before me,
Forms that so early cheered my troubled eyes!
To hold you fast doth still my heart implore me?
Still bid me clutch the charm that lures and flies?
Ye crowd around! come, then, hold empire o'er me,
As from the mist and haze of thought ye rise;
The magic atmosphere, your train enwreathing,
Through my thrilled bosom youthful bliss is breathing.
 
Ye bring with you the forms of hours Elysian,
And shades of dear ones rise to meet my gaze;
First Love and Friendship steal upon my vision
Like an old tale of legendary days;
Sorrow renewed, in mournful repetition,
Runs through life's devious, labyrinthine ways;
And, sighing, names the good (by Fortune cheated
Of blissful hours!) who have before me fleeted.
 
These later songs of mine, alas! will never
Sound in their ears to whom the first were sung!
Scattered like dust, the friendly throng forever!
Mute the first echo that so grateful rung!
To the strange crowd I sing, whose very favor
Like chilling sadness on my heart is flung;
And all that kindled at those earlier numbers
Roams the wide earth or in its bosom slumbers.
 
And now I feel a long-unwonted yearning
For that calm, pensive spirit-realm, to-day;
Like an Aeolian lyre, (the breeze returning,)
Floats in uncertain tones my lisping lay;
Strange awe comes o'er me, tear on tear falls burning,
The rigid heart to milder mood gives way!
What I possess I see afar off lying,
And what I lost is real and undying.
 
 
 
 
PRELUDE
 
IN THE THEATRE.
 
 
_Manager. Dramatic Poet. Merry Person._
 
_Manager_. You who in trouble and distress
Have both held fast your old allegiance,
What think ye? here in German regions
Our enterprise may hope success?
To please the crowd my purpose has been steady,
Because they live and let one live at least.
The posts are set, the boards are laid already,
And every one is looking for a feast.
They sit, with lifted brows, composed looks wearing,
Expecting something that shall set them staring.
I know the public palate, that's confest;
Yet never pined so for a sound suggestion;
True, they are not accustomed to the best,
But they have read a dreadful deal, past question.
How shall we work to make all fresh and new,
Acceptable and profitable, too?
For sure I love to see the torrent boiling,
When towards our booth they crowd to find a place,
Now rolling on a space and then recoiling,
Then squeezing through the narrow door of grace:
Long before dark each one his hard-fought station
In sight of the box-office window takes,
And as, round bakers' doors men crowd to escape starvation,
For tickets here they almost break their necks.
This wonder, on so mixed a mass, the Poet
Alone can work; to-day, my friend, O, show it!
 
_Poet_. Oh speak not to me of that motley ocean,
Whose roar and greed the shuddering spirit chill!
Hide from my sight that billowy commotion
That draws us down the whirlpool 'gainst our will.
No, lead me to that nook of calm devotion,
Where blooms pure joy upon the Muses' hill;
Where love and friendship aye create and cherish,
With hand divine, heart-joys that never perish.
Ah! what, from feeling's deepest fountain springing,
Scarce from the stammering lips had faintly passed,
Now, hopeful, venturing forth, now shyly clinging,
To the wild moment's cry a prey is cast.
Oft when for years the brain had heard it ringing
It comes in full and rounded shape at last.
What shines, is born but for the moment's pleasure;
The genuine leaves posterity a treasure.
 
_Merry Person_. Posterity! I'm sick of hearing of it;
Supposing I the future age would profit,
Who then would furnish ours with fun?
For it must have it, ripe and mellow;
The presence of a fine young fellow,
Is cheering, too, methinks, to any one.
Whoso can pleasantly communicate,
Will not make war with popular caprices,
For, as the circle waxes great,
The power his word shall wield increases.
Come, then, and let us now a model see,
Let Phantasy with all her various choir,
Sense, reason, passion, sensibility,
But, mark me, folly too! the scene inspire.
 
_Manager_. But the great point is action! Every one
Comes as spectator, and the show's the fun.
Let but the plot be spun off fast and thickly,
So that the crowd shall gape in broad surprise,
Then have you made a wide impression quickly,
You are the man they'll idolize.
The mass can only be impressed by masses;
Then each at last picks out his proper part.
Give much, and then to each one something passes,
And each one leaves the house with happy heart.
Have you a piece, give it at once in pieces!
Such a ragout your fame increases;
It costs as little pains to play as to invent.
But what is gained, if you a whole present?
Your public picks it presently to pieces.
 
_Poet_. You do not feel how mean a trade like that must be!
In the true Artist's eyes how false and hollow!
Our genteel botchers, well I see,
Have given the maxims that you follow.
 
_Manager_. Such charges pass me like the idle wind;
A man who has right work in mind
Must choose the instruments most fitting.
Consider what soft wood you have for splitting,
And keep in view for whom you write!
If this one from _ennui_ seeks flight,
That other comes full from the groaning table,
Or, the worst case of all to cite,
From reading journals is for thought unable.
Vacant and giddy, all agog for wonder,
As to a masquerade they wing their way;
The ladies give themselves and all their precious plunder
And without wages help us play.
On your poetic heights what dream comes o'er you?
What glads a crowded house? Behold
Your patrons in array before you!
One half are raw, the other cold.
One, after this play, hopes to play at cards,
One a wild night to spend beside his doxy chooses,
Poor fools, why court ye the regards,
For such a set, of the chaste muses?
I tell you, give them more and ever more and more,
And then your mark you'll hardly stray from ever;
To mystify be your endeavor,
To satisfy is labor sore....
What ails you? Are you pleased or pained? What notion----
 
_Poet_. Go to, and find thyself another slave!
What! and the lofty birthright Nature gave,
The noblest talent Heaven to man has lent,
Thou bid'st the Poet fling to folly's ocean!
How does he stir each deep emotion?
How does he conquer every element?
But by the tide of song that from his bosom springs,
And draws into his heart all living things?
When Nature's hand, in endless iteration,
The thread across the whizzing spindle flings,
When the complex, monotonous creation
Jangles with all its million strings:
Who, then, the long, dull series animating,
Breaks into rhythmic march the soulless round?
And, to the law of All each member consecrating,
Bids one majestic harmony resound?
Who bids the tempest rage with passion's power?
The earnest soul with evening-redness glow?
Who scatters vernal bud and summer flower
Along the path where loved ones go?
Who weaves each green leaf in the wind that trembles
To form the wreath that merit's brow shall crown?
Who makes Olympus fast? the gods assembles?
The power of manhood in the Poet shown.
 
_Merry Person_. Come, then, put forth these noble powers,
And, Poet, let thy path of flowers
Follow a love-adventure's winding ways.
One comes and sees by chance, one burns, one stays,
And feels the gradual, sweet entangling!
The pleasure grows, then comes a sudden jangling,
Then rapture, then distress an arrow plants,
And ere one dreams of it, lo! _there_ is a romance.
Give us a drama in this fashion!
Plunge into human life's full sea of passion!
Each lives it, few its meaning ever guessed,
Touch where you will, 'tis full of interest.
Bright shadows fleeting o'er a mirror,
A spark of truth and clouds of error,
By means like these a drink is brewed
To cheer and edify the multitude.
The fairest flower of the youth sit listening
Before your play, and wait the revelation;
Each melancholy heart, with soft eyes glistening,
Draws sad, sweet nourishment from your creation;
This passion now, now that is stirred, by turns,
And each one sees what in his bosom burns.
Open alike, as yet, to weeping and to laughter,
They still admire the flights, they still enjoy the show;
Him who is formed, can nothing suit thereafter;
The yet unformed with thanks will ever glow.
 
_Poet_. Ay, give me back the joyous hours,
When I myself was ripening, too,
When song, the fount, flung up its showers
Of beauty ever fresh and new.
When a soft haze the world was veiling,
Each bud a miracle bespoke,
And from their stems a thousand flowers I broke,
Their fragrance through the vales exhaling.
I nothing and yet all possessed,
Yearning for truth and in illusion blest.
Give me the freedom of that hour,
The tear of joy, the pleasing pain,
Of hate and love the thrilling power,
Oh, give me back my youth again!
 
_Merry Person_. Youth, my good friend, thou needest certainly
When ambushed foes are on thee springing,
When loveliest maidens witchingly
Their white arms round thy neck are flinging,
When the far garland meets thy glance,
High on the race-ground's goal suspended,
When after many a mazy dance
In drink and song the night is ended.
But with a free and graceful soul
To strike the old familiar lyre,
And to a self-appointed goal
Sweep lightly o'er the trembling wire,
There lies, old gentlemen, to-day
Your task; fear not, no vulgar error blinds us.
Age does not make us childish, as they say,
But we are still true children when it finds us.
 
_Manager_. Come, words enough you two have bandied,
Now let us see some deeds at last;
While you toss compliments full-handed,
The time for useful work flies fast.
Why talk of being in the humor?
Who hesitates will never be.
If you are poets (so says rumor)
Now then command your poetry.
You know full well our need and pleasure,
We want strong drink in brimming measure;
Brew at it now without delay!
To-morrow will not do what is not done to-day.
Let not a day be lost in dallying,
But seize the possibility
Right by the forelock, courage rallying,
And forth with fearless spirit sallying,--
Once in the yoke and you are free.
Upon our German boards, you know it,
What any one would try, he may;
Then stint me not, I beg, to-day,
In scenery or machinery, Poet.
With great and lesser heavenly lights make free,
Spend starlight just as you desire;
No want of water, rocks or fire
Or birds or beasts to you shall be.
So, in this narrow wooden house's bound,
Stride through the whole creation's round,
And with considerate swiftness wander
From heaven, through this world, to the world down yonder.
 
 
 
 
PROLOGUE
 
 
IN HEAVEN.
 
 
[THE LORD. THE HEAVENLY HOSTS _afterward_ MEPHISTOPHELES.
_The three archangels_, RAPHAEL, GABRIEL, _and_ MICHAEL, _come forward_.]
 
_Raphael_. The sun, in ancient wise, is sounding,
With brother-spheres, in rival song;
And, his appointed journey rounding,
With thunderous movement rolls along.
His look, new strength to angels lending,
No creature fathom can for aye;
The lofty works, past comprehending,
Stand lordly, as on time's first day.
 
_Gabriel_. And swift, with wondrous swiftness fleeting,
The pomp of earth turns round and round,
The glow of Eden alternating
With shuddering midnight's gloom profound;
Up o'er the rocks the foaming ocean
Heaves from its old, primeval bed,
And rocks and seas, with endless motion,
On in the spheral sweep are sped.
 
_Michael_. And tempests roar, glad warfare waging,
From sea to land, from land to sea,
And bind round all, amidst their raging,
A chain of giant energy.
There, lurid desolation, blazing,
Foreruns the volleyed thunder's way:
Yet, Lord, thy messengers[2] are praising
The mild procession of thy day.
 
_All Three_. The sight new strength to angels lendeth,
For none thy being fathom may,
The works, no angel comprehendeth,
Stand lordly as on time's first day.
 
_Mephistopheles_. Since, Lord, thou drawest near us once again,
And how we do, dost graciously inquire,
And to be pleased to see me once didst deign,
I too among thy household venture nigher.
Pardon, high words I cannot labor after,
Though the whole court should look on me with scorn;
My pathos certainly would stir thy laughter,
Hadst thou not laughter long since quite forsworn.
Of sun and worlds I've nought to tell worth mention,
How men torment themselves takes my attention.
The little God o' the world jogs on the same old way
And is as singular as on the world's first day.
A pity 'tis thou shouldst have given
The fool, to make him worse, a gleam of light from heaven;
He calls it reason, using it
To be more beast than ever beast was yet.
He seems to me, (your grace the word will pardon,)
Like a long-legg'd grasshopper in the garden,
Forever on the wing, and hops and sings
The same old song, as in the grass he springs;
Would he but stay there! no; he needs must muddle
His prying nose in every puddle.
 
_The Lord_. Hast nothing for our edification?
Still thy old work of accusation?
Will things on earth be never right for thee?
 
_Mephistopheles_. No, Lord! I find them still as bad as bad can be.
Poor souls! their miseries seem so much to please 'em,
I scarce can find it in my heart to tease 'em.
 
_The Lord_. Knowest thou Faust?
 
_Mephistopheles_. The Doctor?
 
_The Lord_. Ay, my servant!
 
_Mephistopheles_. He!
Forsooth! he serves you in a famous fashion;
No earthly meat or drink can feed his passion;
Its grasping greed no space can measure;
Half-conscious and half-crazed, he finds no rest;
The fairest stars of heaven must swell his treasure.
Each highest joy of earth must yield its zest,
Not all the world--the boundless azure--
Can fill the void within his craving breast.
 
_The Lord_. He serves me somewhat darkly, now, I grant,
Yet will he soon attain the light of reason.
Sees not the gardener, in the green young plant,
That bloom and fruit shall deck its coming season?
 
_Mephistopheles_. What will you bet? You'll surely lose your wager!
If you will give me leave henceforth,
To lead him softly on, like an old stager.
 
_The Lord_. So long as he shall live on earth,
Do with him all that you desire.
Man errs and staggers from his birth.
 
_Mephistopheles_. Thank you; I never did aspire
To have with dead folk much transaction.
In full fresh cheeks I take the greatest satisfaction.
A corpse will never find me in the house;
I love to play as puss does with the mouse.
 
_The Lord_. All right, I give thee full permission!
Draw down this spirit from its source,
And, canst thou catch him, to perdition
Carry him with thee in thy course,
But stand abashed, if thou must needs confess,
That a good man, though passion blur his vision,
Has of the right way still a consciousness.
 
_Mephistopheles_. Good! but I'll make it a short story.
About my wager I'm by no means sorry.
And if I gain my end with glory
Allow me to exult from a full breast.
Dust shall he eat and that with zest,
Like my old aunt, the snake, whose fame is hoary.
 
_The Lord_. Well, go and come, and make thy trial;
The like of thee I never yet did hate.
Of all the spirits of denial
The scamp is he I best can tolerate.
Man is too prone, at best, to seek the way that's easy,
He soon grows fond of unconditioned rest;
And therefore such a comrade suits him best,
Who spurs and works, true devil, always busy.
But you, true sons of God, in growing measure,
Enjoy rich beauty's living stores of pleasure!
The Word[3] divine that lives and works for aye,
Fold you in boundless love's embrace alluring,
And what in floating vision glides away,
That seize ye and make fast with thoughts enduring.
 
[_Heaven closes, the archangels disperse._]
 
_Mephistopheles. [Alone.]_ I like at times to exchange with him a word,
And take care not to break with him. 'Tis civil
In the old fellow[4] and so great a Lord
To talk so kindly with the very devil.
 
 
 
 
FAUST.
 
 
_Night. In a narrow high-arched Gothic room_,
FAUST _sitting uneasy at his desk_.
 
_Faust_. Have now, alas! quite studied through
Philosophy and Medicine,
And Law, and ah! Theology, too,
With hot desire the truth to win!
And here, at last, I stand, poor fool!
As wise as when I entered school;
Am called Magister, Doctor, indeed,--
Ten livelong years cease not to lead
Backward and forward, to and fro,
My scholars by the nose--and lo!
Just nothing, I see, is the sum of our learning,
To the very core of my heart 'tis burning.
'Tis true I'm more clever than all the foplings,
Doctors, Magisters, Authors, and Popelings;
Am plagued by no scruple, nor doubt, nor cavil,
Nor lingering fear of hell or devil--
What then? all pleasure is fled forever;
To know one thing I vainly endeavor,
There's nothing wherein one fellow-creature
Could be mended or bettered with me for a teacher.
And then, too, nor goods nor gold have I,
Nor fame nor worldly dignity,--
A condition no dog could longer live in!
And so to magic my soul I've given,
If, haply, by spirits' mouth and might,
Some mysteries may not be brought to light;
That to teach, no longer may be my lot,
With bitter sweat, what I need to be taught;
That I may know what the world contains
In its innermost heart and finer veins,
See all its energies and seeds
And deal no more in words but in deeds.
O full, round Moon, didst thou but thine
For the last time on this woe of mine!
Thou whom so many a midnight I
Have watched, at this desk, come up the sky:
O'er books and papers, a dreary pile,
Then, mournful friend! uprose thy smile!
Oh that I might on the mountain-height,
Walk in the noon of thy blessed light,
Round mountain-caverns with spirits hover,
Float in thy gleamings the meadows over,
And freed from the fumes of a lore-crammed brain,
Bathe in thy dew and be well again!
Woe! and these walls still prison me?
Dull, dismal hole! my curse on thee!
Where heaven's own light, with its blessed beams,
Through painted panes all sickly gleams!
Hemmed in by these old book-piles tall,
Which, gnawed by worms and deep in must,
Rise to the roof against a wall
Of smoke-stained paper, thick with dust;
'Mid glasses, boxes, where eye can see,
Filled with old, obsolete instruments,
Stuffed with old heirlooms of implements--
That is thy world! There's a world for thee!
And still dost ask what stifles so
The fluttering heart within thy breast?
By what inexplicable woe
The springs of life are all oppressed?
Instead of living nature, where
God made and planted men, his sons,
Through smoke and mould, around thee stare
Grim skeletons and dead men's bones.
Up! Fly! Far out into the land!
And this mysterious volume, see!
By Nostradamus's[5] own hand,
Is it not guide enough for thee?
Then shalt thou thread the starry skies,
And, taught by nature in her walks,
The spirit's might shall o'er thee rise,
As ghost to ghost familiar talks.
Vain hope that mere dry sense should here
Explain the holy signs to thee.
I feel you, spirits, hovering near;
Oh, if you hear me, answer me!
[_He opens the book and beholds the sign of the Macrocosm.[_6]]
Ha! as I gaze, what ecstasy is this,
In one full tide through all my senses flowing!
I feel a new-born life, a holy bliss
Through nerves and veins mysteriously glowing.
Was it a God who wrote each sign?
Which, all my inner tumult stilling,
And this poor heart with rapture filling,
Reveals to me, by force divine,
Great Nature's energies around and through me thrilling?
Am I a God? It grows so bright to me!
Each character on which my eye reposes
Nature in act before my soul discloses.
The sage's word was truth, at last I see:
"The spirit-world, unbarred, is waiting;
Thy sense is locked, thy heart is dead!
Up, scholar, bathe, unhesitating,
The earthly breast in morning-red!"
[_He contemplates the sign._]
How all one whole harmonious weaves,
Each in the other works and lives!
See heavenly powers ascending and descending,
The golden buckets, one long line, extending!
See them with bliss-exhaling pinions winging
Their way from heaven through earth--their singing
Harmonious through the universe is ringing!
Majestic show! but ah! a show alone!
Nature! where find I thee, immense, unknown?
Where you, ye breasts? Ye founts all life sustaining,
On which hang heaven and earth, and where
Men's withered hearts their waste repair--
Ye gush, ye nurse, and I must sit complaining?
[_He opens reluctantly the book and sees the sign of the earth-spirit._]
How differently works on me this sign!
Thou, spirit of the earth, art to me nearer;
I feel my powers already higher, clearer,
I glow already as with new-pressed wine,
I feel the mood to brave life's ceaseless clashing,
To bear its frowning woes, its raptures flashing,
To mingle in the tempest's dashing,
And not to tremble in the shipwreck's crashing;
Clouds gather o'er my head--
Them moon conceals her light--
The lamp goes out!
It smokes!--Red rays are darting, quivering
Around my head--comes down
A horror from the vaulted roof
And seizes me!
Spirit that I invoked, thou near me art,
Unveil thyself!
Ha! what a tearing in my heart!
Upheaved like an ocean
My senses toss with strange emotion!
I feel my heart to thee entirely given!
Thou must! and though the price were life--were heaven!
[_He seizes the book and pronounces mysteriously the sign of the spirit.
A ruddy flame darts out, the spirit appears in the flame._]
 
_Spirit_. Who calls upon me?
 
_Faust. [Turning away.]_ Horrid sight!
 
_Spirit_. Long have I felt the mighty action,
Upon my sphere, of thy attraction,
And now--
 
_Faust_. Away, intolerable sprite!
 
_Spirit_. Thou breath'st a panting supplication
To hear my voice, my face to see;
Thy mighty prayer prevails on me,
I come!--what miserable agitation
Seizes this demigod! Where is the cry of thought?
Where is the breast? that in itself a world begot,
And bore and cherished, that with joy did tremble
And fondly dream us spirits to resemble.
Where art thou, Faust? whose voice rang through my ear,
Whose mighty yearning drew me from my sphere?
Is this thing thou? that, blasted by my breath,
Through all life's windings shuddereth,
A shrinking, cringing, writhing worm!
 
_Faust_. Thee, flame-born creature, shall I fear?
'Tis I, 'tis Faust, behold thy peer!
 
_Spirit_. In life's tide currents, in action's storm,
Up and down, like a wave,
Like the wind I sweep!
Cradle and grave--
A limitless deep---
An endless weaving
To and fro,
A restless heaving
Of life and glow,--
So shape I, on Destiny's thundering loom,
The Godhead's live garment, eternal in bloom.
 
_Faust_. Spirit that sweep'st the world from end to end,
How near, this hour, I feel myself to thee!
 
_Spirit_. Thou'rt like the spirit thou canst comprehend,
Not me! [_Vanishes._]
 
_Faust_. [_Collapsing_.] Not thee?
Whom then?
I, image of the Godhead,
And no peer for thee!
[_A knocking_.]
O Death! I know it!--'tis my Famulus--
Good-bye, ye dreams of bliss Elysian!
Shame! that so many a glowing vision
This dried-up sneak must scatter thus!
 
[WAGNER, _in sleeping-gown and night-cap, a lamp in his hand._
FAUST _turns round with an annoyed look_.]
 
_Wagner_. Excuse me! you're engaged in declamation;
'Twas a Greek tragedy no doubt you read?
I in this art should like initiation,
For nowadays it stands one well instead.
I've often heard them boast, a preacher
Might profit with a player for his teacher.
 
_Faust_. Yes, when the preacher is a player, granted:
As often happens in our modern ways.
 
_Wagner_. Ah! when one with such love of study's haunted,
And scarcely sees the world on holidays,
And takes a spy-glass, as it were, to read it,
How can one by persuasion hope to lead it?
 
_Faust_. What you don't feel, you'll never catch by hunting,
It must gush out spontaneous from the soul,
And with a fresh delight enchanting
The hearts of all that hear control.
Sit there forever! Thaw your glue-pot,--
Blow up your ash-heap to a flame, and brew,
With a dull fire, in your stew-pot,
Of other men's leavings a ragout!
Children and apes will gaze delighted,
If their critiques can pleasure impart;
But never a heart will be ignited,
Comes not the spark from the speaker's heart.
 
_Wagner_. Delivery makes the orator's success;
There I'm still far behindhand, I confess.
 
_Faust_. Seek honest gains, without pretence!
Be not a cymbal-tinkling fool!
Sound understanding and good sense
Speak out with little art or rule;
And when you've something earnest to utter,
Why hunt for words in such a flutter?
Yes, your discourses, that are so refined'
In which humanity's poor shreds you frizzle,
Are unrefreshing as the mist and wind
That through the withered leaves of autumn whistle!
 
_Wagner_. Ah God! well, art is long!
And life is short and fleeting.
What headaches have I felt and what heart-beating,
When critical desire was strong.
How hard it is the ways and means to master
By which one gains each fountain-head!
 
And ere one yet has half the journey sped,
The poor fool dies--O sad disaster!
 
_Faust_. Is parchment, then, the holy well-spring, thinkest,
A draught from which thy thirst forever slakes?
No quickening element thou drinkest,
Till up from thine own soul the fountain breaks.
 
_Wagner_. Excuse me! in these olden pages
We catch the spirit of the by-gone ages,
We see what wisest men before our day have thought,
And to what glorious heights we their bequests have brought.
 
_Faust_. O yes, we've reached the stars at last!
My friend, it is to us,--the buried past,--
A book with seven seals protected;
Your spirit of the times is, then,
At bottom, your own spirit, gentlemen,
In which the times are seen reflected.
And often such a mess that none can bear it;
At the first sight of it they run away.
A dust-bin and a lumber-garret,
At most a mock-heroic play[8]
With fine, pragmatic maxims teeming,
The mouths of puppets well-beseeming!
 
_Wagner_. But then the world! the heart and mind of man!
To know of these who would not pay attention?
 
_Faust_. To know them, yes, as weaklings can!
Who dares the child's true name outright to mention?
The few who any thing thereof have learned,
Who out of their heart's fulness needs must gabble,
And show their thoughts and feelings to the rabble,
Have evermore been crucified and burned.
I pray you, friend, 'tis wearing into night,
Let us adjourn here, for the present.
 
_Wagner_. I had been glad to stay till morning light,
This learned talk with you has been so pleasant,
But the first day of Easter comes to-morrow.
And then an hour or two I'll borrow.
With zeal have I applied myself to learning,
True, I know much, yet to know all am burning.
[_Exit_.]
 
_Faust_. [_Alone_.] See how in _his_ head only, hope still lingers,
Who evermore to empty rubbish clings,
With greedy hand grubs after precious things,
And leaps for joy when some poor worm he fingers!
That such a human voice should dare intrude,
Where all was full of ghostly tones and features!
Yet ah! this once, my gratitude
Is due to thee, most wretched of earth's creatures.
Thou snatchedst me from the despairing state
In which my senses, well nigh crazed, were sunken.
The apparition was so giant-great,
That to a very dwarf my soul had shrunken.
I, godlike, who in fancy saw but now
Eternal truth's fair glass in wondrous nearness,
Rejoiced in heavenly radiance and clearness,
Leaving the earthly man below;
I, more than cherub, whose free force
Dreamed, through the veins of nature penetrating,
To taste the life of Gods, like them creating,
Behold me this presumption expiating!
A word of thunder sweeps me from my course.
Myself with thee no longer dare I measure;
Had I the power to draw thee down at pleasure;
To hold thee here I still had not the force.
Oh, in that blest, ecstatic hour,
I felt myself so small, so great;
Thou drovest me with cruel power
Back upon man's uncertain fate
What shall I do? what slum, thus lonely?
That impulse must I, then, obey?
Alas! our very deeds, and not our sufferings only,
How do they hem and choke life's way!
To all the mind conceives of great and glorious
A strange and baser mixture still adheres;
Striving for earthly good are we victorious?
A dream and cheat the better part appears.
The feelings that could once such noble life inspire
Are quenched and trampled out in passion's mire.
Where Fantasy, erewhile, with daring flight
Out to the infinite her wings expanded,
A little space can now suffice her quite,
When hope on hope time's gulf has wrecked and stranded.
Care builds her nest far down the heart's recesses,
There broods o'er dark, untold distresses,
Restless she sits, and scares thy joy and peace away;
She puts on some new mask with each new day,
Herself as house and home, as wife and child presenting,
As fire and water, bane and blade;
What never hits makes thee afraid,
And what is never lost she keeps thee still lamenting.
Not like the Gods am I! Too deep that truth is thrust!
But like the worm, that wriggles through the dust;
Who, as along the dust for food he feels,
Is crushed and buried by the traveller's heels.
Is it not dust that makes this lofty wall
Groan with its hundred shelves and cases;
The rubbish and the thousand trifles all
That crowd these dark, moth-peopled places?
Here shall my craving heart find rest?
Must I perchance a thousand books turn over,
To find that men are everywhere distrest,
And here and there one happy one discover?
Why grin'st thou down upon me, hollow skull?
But that thy brain, like mine, once trembling, hoping,
Sought the light day, yet ever sorrowful,
Burned for the truth in vain, in twilight groping?
Ye, instruments, of course, are mocking me;
Its wheels, cogs, bands, and barrels each one praises.
I waited at the door; you were the key;
Your ward is nicely turned, and yet no bolt it raises.
Unlifted in the broadest day,
Doth Nature's veil from prying eyes defend her,
And what (he chooses not before thee to display,
Not all thy screws and levers can force her to surrender.
Old trumpery! not that I e'er used thee, but
Because my father used thee, hang'st thou o'er me,
Old scroll! thou hast been stained with smoke and smut
Since, on this desk, the lamp first dimly gleamed before me.
Better have squandered, far, I now can clearly see,
My little all, than melt beneath it, in this Tophet!
That which thy fathers have bequeathed to thee,
Earn and become possessor of it!
What profits not a weary load will be;
What it brings forth alone can yield the moment profit.
Why do I gaze as if a spell had bound me
Up yonder? Is that flask a magnet to the eyes?
What lovely light, so sudden, blooms around me?
As when in nightly woods we hail the full-moon-rise.
I greet thee, rarest phial, precious potion!
As now I take thee down with deep devotion,
In thee I venerate man's wit and art.
Quintessence of all soporific flowers,
Extract of all the finest deadly powers,
Thy favor to thy master now impart!
I look on thee, the sight my pain appeases,
I handle thee, the strife of longing ceases,
The flood-tide of the spirit ebbs away.
Far out to sea I'm drawn, sweet voices listening,
The glassy waters at my feet are glistening,
To new shores beckons me a new-born day.
A fiery chariot floats, on airy pinions,
To where I sit! Willing, it beareth me,
On a new path, through ether's blue dominions,
To untried spheres of pure activity.
This lofty life, this bliss elysian,
Worm that thou waft erewhile, deservest thou?
Ay, on this earthly sun, this charming vision,
Turn thy back resolutely now!
Boldly draw near and rend the gates asunder,
By which each cowering mortal gladly steals.
Now is the time to show by deeds of wonder
That manly greatness not to godlike glory yields;
Before that gloomy pit to stand, unfearing,
Where Fantasy self-damned in its own torment lies,
Still onward to that pass-way steering,
Around whose narrow mouth hell-flames forever rise;
Calmly to dare the step, serene, unshrinking,
Though into nothingness the hour should see thee sinking.
Now, then, come down from thy old case, I bid thee,
Where thou, forgotten, many a year hast hid thee,
Into thy master's hand, pure, crystal glass!
The joy-feasts of the fathers thou hast brightened,
The hearts of gravest guests were lightened,
When, pledged, from hand to hand they saw thee pass.
Thy sides, with many a curious type bedight,
Which each, as with one draught he quaffed the liquor
Must read in rhyme from off the wondrous beaker,
Remind me, ah! of many a youthful night.
I shall not hand thee now to any neighbor,
Not now to show my wit upon thy carvings labor;
Here is a juice of quick-intoxicating might.
The rich brown flood adown thy sides is streaming,
With my own choice ingredients teeming;
Be this last draught, as morning now is gleaming,
Drained as a lofty pledge to greet the festal light!
[_He puts the goblet to his lips_.
 
_Ringing of bells and choral song_.
 
_Chorus of Angels_. Christ hath arisen!
Joy to humanity!
No more shall vanity,
Death and inanity
Hold thee in prison!
 
_Faust_. What hum of music, what a radiant tone,
Thrills through me, from my lips the goblet stealing!
Ye murmuring bells, already make ye known
The Easter morn's first hour, with solemn pealing?
Sing you, ye choirs, e'en now, the glad, consoling song,
That once, from angel-lips, through gloom sepulchral rung,
A new immortal covenant sealing?
 
_Chorus of Women_. Spices we carried,
Laid them upon his breast;
Tenderly buried
Him whom we loved the best;
 
Cleanly to bind him
Took we the fondest care,
Ah! and we find him
Now no more there.
 
_Chorus of Angels_. Christ hath ascended!
Reign in benignity!
Pain and indignity,
Scorn and malignity,
_Their_ work have ended.
 
_Faust_. Why seek ye me in dust, forlorn,
Ye heavenly tones, with soft enchanting?
Go, greet pure-hearted men this holy morn!
Your message well I hear, but faith to me is wanting;
Wonder, its dearest child, of Faith is born.
To yonder spheres I dare no more aspire,
Whence the sweet tidings downward float;
And yet, from childhood heard, the old, familiar note
Calls back e'en now to life my warm desire.
Ah! once how sweetly fell on me the kiss
Of heavenly love in the still Sabbath stealing!
Prophetically rang the bells with solemn pealing;
A prayer was then the ecstasy of bliss;
A blessed and mysterious yearning
Drew me to roam through meadows, woods, and skies;
And, midst a thousand tear-drops burning,
I felt a world within me rise
That strain, oh, how it speaks youth's gleesome plays and feelings,
Joys of spring-festivals long past;
Remembrance holds me now, with childhood's fond appealings,
Back from the fatal step, the last.
Sound on, ye heavenly strains, that bliss restore me!
Tears gush, once more the spell of earth is o'er me
 
_Chorus of Disciples_. Has the grave's lowly one
Risen victorious?
Sits he, God's Holy One,
High-throned and glorious?
He, in this blest new birth,
Rapture creative knows;[9]
Ah! on the breast of earth
Taste we still nature's woes.
Left here to languish
Lone in a world like this,
Fills us with anguish
Master, thy bliss!
 
_Chorus of Angels_. Christ has arisen
Out of corruption's gloom.
Break from your prison,
Burst every tomb!
Livingly owning him,
Lovingly throning him,
Feasting fraternally,
Praying diurnally,
Bearing his messages,
Sharing his promises,
Find ye your master near,
Find ye him here![10]
 
 
 
 
BEFORE THE GATE.
 
_Pedestrians of all descriptions stroll forth_.
 
_Mechanics' Apprentices_. Where are you going to carouse?
 
_Others_. We're all going out to the Hunter's House.
 
_The First_. We're going, ourselves, out to the Mill-House, brothers.
 
_An Apprentice_. The Fountain-House I rather recommend.
 
_Second_. 'Tis not a pleasant road, my friend.
 
_The second group_. What will you do, then?
 
_A Third_. I go with the others.
 
_Fourth_. Come up to Burgdorf, there you're sure to find good cheer,
The handsomest of girls and best of beer,
And rows, too, of the very first water.
 
_Fifth_. You monstrous madcap, does your skin
Itch for the third time to try that inn?
I've had enough for _my_ taste in that quarter.
 
_Servant-girl_. No! I'm going back again to town for one.
 
_Others_. Under those poplars we are sure to meet him.
 
_First Girl_. But that for me is no great fun;
For you are always sure to get him,
He never dances with any but you.
Great good to me your luck will do!
 
_Others_. He's not alone, I heard him say,
The curly-head would be with him to-day.
 
_Scholar_. Stars! how the buxom wenches stride there!
Quick, brother! we must fasten alongside there.
Strong beer, good smart tobacco, and the waist
Of a right handsome gall, well rigg'd, now that's my taste.
 
_Citizen's Daughter_. Do see those fine, young fellows yonder!
'Tis, I declare, a great disgrace;
When they might have the very best, I wonder,
After these galls they needs must race!
 
_Second scholar_ [_to the first_].
Stop! not so fast! there come two more behind,
My eyes! but ain't they dressed up neatly?
One is my neighbor, or I'm blind;
I love the girl, she looks so sweetly.
Alone all quietly they go,
You'll find they'll take us, by and bye, in tow.
 
_First_. No, brother! I don't like these starched up ways.
Make haste! before the game slips through our fingers.
The hand that swings the broom o' Saturdays
On Sundays round thy neck most sweetly lingers.
 
_Citizen_. No, I don't like at all this new-made burgomaster!
His insolence grows daily ever faster.
No good from him the town will get!
Will things grow better with him? Never!
We're under more constraint than ever,
And pay more tax than ever yet.
 
_Beggar_. [_Sings_.] Good gentlemen, and you, fair ladies,
With such red cheeks and handsome dress,
Think what my melancholy trade is,
And see and pity my distress!
Help the poor harper, sisters, brothers!
Who loves to give, alone is gay.
This day, a holiday to others,
Make it for me a harvest day.
 
_Another citizen_.
Sundays and holidays, I like, of all things, a good prattle
Of war and fighting, and the whole array,
When back in Turkey, far away,
The peoples give each other battle.
One stands before the window, drinks his glass,
And sees the ships with flags glide slowly down the river;
Comes home at night, when out of sight they pass,
And sings with joy, "Oh, peace forever!"
 
_Third citizen_. So I say, neighbor! let them have their way,
Crack skulls and in their crazy riot
Turn all things upside down they may,
But leave us here in peace and quiet.
 
_Old Woman_ [_to the citizen's daughter_].
Heyday, brave prinking this! the fine young blood!
Who is not smitten that has met you?--
But not so proud! All very good!
And what you want I'll promise soon to get you.
 
_Citizen's Daughter_. Come, Agatha! I dread in public sight
To prattle with such hags; don't stay, O, Luddy!
'Tis true she showed me, on St. Andrew's night,
My future sweetheart in the body.
 
_The other_. She showed me mine, too, in a glass,
Right soldierlike, with daring comrades round him.
I look all round, I study all that pass,
But to this hour I have not found him.
 
_Soldiers_. Castles with lowering
Bulwarks and towers,
Maidens with towering
Passions and powers,
Both shall be ours!
Daring the venture,
Glorious the pay!
 
When the brass trumpet
Summons us loudly,
Joy-ward or death-ward,
On we march proudly.
That is a storming!
 
Life in its splendor!
Castles and maidens
Both must surrender.
Daring the venture,
Glorious the pay.
There go the soldiers
Marching away!
 
 
FAUST _and_ WAGNER.
 
_Faust_. Spring's warm look has unfettered the fountains,
Brooks go tinkling with silvery feet;
Hope's bright blossoms the valley greet;
Weakly and sickly up the rough mountains
Pale old Winter has made his retreat.
Thence he launches, in sheer despite,
Sleet and hail in impotent showers,
O'er the green lawn as he takes his flight;
But the sun will suffer no white,
Everywhere waking the formative powers,
Living colors he yearns to spread;
Yet, as he finds it too early for flowers,
Gayly dressed people he takes instead.
Look from this height whereon we find us
Back to the town we have left behind us,
Where from the dark and narrow door
Forth a motley multitude pour.
They sun themselves gladly and all are gay,
They celebrate Christ's resurrection to-day.
For have not they themselves arisen?
From smoky huts and hovels and stables,
From labor's bonds and traffic's prison,
From the confinement of roofs and gables,
From many a cramping street and alley,
From churches full of the old world's night,
All have come out to the day's broad light.
See, only see! how the masses sally
Streaming and swarming through gardens and fields
How the broad stream that bathes the valley
Is everywhere cut with pleasure boats' keels,
And that last skiff, so heavily laden,
Almost to sinking, puts off in the stream;
Ribbons and jewels of youngster and maiden
From the far paths of the mountain gleam.
How it hums o'er the fields and clangs from the steeple!
This is the real heaven of the people,
Both great and little are merry and gay,
I am a man, too, I can be, to-day.
 
_Wagner_. With you, Sir Doctor, to go out walking
Is at all times honor and gain enough;
But to trust myself here alone would be shocking,
For I am a foe to all that is rough.
Fiddling and bowling and screams and laughter
To me are the hatefullest noises on earth;
They yell as if Satan himself were after,
And call it music and call it mirth.
 
[_Peasants (under the linden). Dance and song._]
 
The shepherd prinked him for the dance,
With jacket gay and spangle's glance,
And all his finest quiddle.
And round the linden lass and lad
They wheeled and whirled and danced like mad.
Huzza! huzza!
Huzza! Ha, ha, ha!
And tweedle-dee went the fiddle.
 
And in he bounded through the whirl,
And with his elbow punched a girl,
Heigh diddle, diddle!
The buxom wench she turned round quick,
"Now that I call a scurvy trick!"
Huzza! huzza!
Huzza! ha, ha, ha!
Tweedle-dee, tweedle-dee went the fiddle.
 
And petticoats and coat-tails flew
As up and down they went, and through,
Across and down the middle.
They all grew red, they all grew warm,
And rested, panting, arm in arm,
Huzza! huzza!
Ta-ra-la!
Tweedle-dee went the fiddle!
 
"And don't be so familiar there!
How many a one, with speeches fair,
His trusting maid will diddle!"
But still he flattered her aside--
And from the linden sounded wide:
Huzza! huzza!
Huzza! huzza! ha! ha! ha!
And tweedle-dee the fiddle.
 
_Old Peasant._ Sir Doctor, this is kind of you,
That with us here you deign to talk,
And through the crowd of folk to-day
A man so highly larned, walk.
So take the fairest pitcher here,
Which we with freshest drink have filled,
I pledge it to you, praying aloud
That, while your thirst thereby is stilled,
So many days as the drops it contains
May fill out the life that to you remains.
 
_Faust._ I take the quickening draught and call
For heaven's best blessing on one and all.
 
[_The people form a circle round him._]
 
_Old Peasant._ Your presence with us, this glad day,
We take it very kind, indeed!
In truth we've found you long ere this
In evil days a friend in need!
Full many a one stands living here,
Whom, at death's door already laid,
Your father snatched from fever's rage,
When, by his skill, the plague he stayed.
You, a young man, we daily saw
Go with him to the pest-house then,
And many a corpse was carried forth,
But you came out alive again.
With a charmed life you passed before us,
Helped by the Helper watching o'er us.
 
_All._ The well-tried man, and may he live,
Long years a helping hand to give!
 
_Faust._ Bow down to Him on high who sends
His heavenly help and helping friends!
[_He goes on with_ WAGNER.]
 
_Wagner._ What feelings, O great man, thy heart must swell
Thus to receive a people's veneration!
O worthy all congratulation,
Whose gifts to such advantage tell.
The father to his son shows thee with exultation,
All run and crowd and ask, the circle closer draws,
The fiddle stops, the dancers pause,
Thou goest--the lines fall back for thee.
They fling their gay-decked caps on high;
A little more and they would bow the knee
As if the blessed Host came by.
 
_Faust._ A few steps further on, until we reach that stone;
There will we rest us from our wandering.
How oft in prayer and penance there alone,
Fasting, I sate, on holy mysteries pondering.
There, rich in hope, in faith still firm,
I've wept, sighed, wrung my hands and striven
This plague's removal to extort (poor worm!)
From the almighty Lord of Heaven.
The crowd's applause has now a scornful tone;
O couldst thou hear my conscience tell its story,
How little either sire or son
Has done to merit such a glory!
My father was a worthy man, confused
And darkened with his narrow lucubrations,
Who with a whimsical, though well-meant patience,
On Nature's holy circles mused.
Shut up in his black laboratory,
Experimenting without end,
'Midst his adepts, till he grew hoary,
He sought the opposing powers to blend.
Thus, a red lion,[11] a bold suitor, married
The silver lily, in the lukewarm bath,
And, from one bride-bed to another harried,
The two were seen to fly before the flaming wrath.
If then, with colors gay and splendid,
The glass the youthful queen revealed,
Here was the physic, death the patients' sufferings ended,
And no one asked, who then was healed?
Thus, with electuaries so satanic,
Worse than the plague with all its panic,
We rioted through hill and vale;
Myself, with my own hands, the drug to thousands giving,
They passed away, and I am living
To hear men's thanks the murderers hail!
 
_Wagner._ Forbear! far other name that service merits!
Can a brave man do more or less
Than with nice conscientiousness
To exercise the calling he inherits?
If thou, as youth, thy father honorest,
To learn from him thou wilt desire;
If thou, as man, men with new light hast blest,
Then may thy son to loftier heights aspire.
 
_Faust._ O blest! who hopes to find repose,
Up from this mighty sea of error diving!
Man cannot use what he already knows,
To use the unknown ever striving.
But let not such dark thoughts a shadow throw
O'er the bright joy this hour inspires!
See how the setting sun, with ruddy glow,
The green-embosomed hamlet fires!
He sinks and fades, the day is lived and gone,
He hastens forth new scenes of life to waken.
O for a wing to lift and bear me on,
And on, to where his last rays beckon!
Then should I see the world's calm breast
In everlasting sunset glowing,
The summits all on fire, each valley steeped in rest,
The silver brook to golden rivers flowing.
No savage mountain climbing to the skies
Should stay the godlike course with wild abysses;
And now the sea, with sheltering, warm recesses
Spreads out before the astonished eyes.
At last it seems as if the God were sinking;
But a new impulse fires the mind,
Onward I speed, his endless glory drinking,
The day before me and the night behind,
The heavens above my head and under me the ocean.
A lovely dream,--meanwhile he's gone from sight.
Ah! sure, no earthly wing, in swiftest flight,
May with the spirit's wings hold equal motion.
Yet has each soul an inborn feeling
Impelling it to mount and soar away,
When, lost in heaven's blue depths, the lark is pealing
High overhead her airy lay;
When o'er the mountain pine's black shadow,
With outspread wing the eagle sweeps,
And, steering on o'er lake and meadow,
The crane his homeward journey keeps.
 
_Wagner._ I've had myself full many a wayward hour,
But never yet felt such a passion's power.
One soon grows tired of field and wood and brook,
I envy not the fowl of heaven his pinions.
Far nobler joy to soar through thought's dominions
From page to page, from book to book!
Ah! winter nights, so dear to mind and soul!
Warm, blissful life through all the limbs is thrilling,
And when thy hands unfold a genuine ancient scroll,
It seems as if all heaven the room were filling.
 
_Faust_. One passion only has thy heart possessed;
The other, friend, O, learn it never!
Two souls, alas! are lodged in my wild breast,
Which evermore opposing ways endeavor,
The one lives only on the joys of time,
Still to the world with clamp-like organs clinging;
The other leaves this earthly dust and slime,
To fields of sainted sires up-springing.
O, are there spirits in the air,
That empire hold 'twixt earth's and heaven's dominions,
Down from your realm of golden haze repair,
Waft me to new, rich life, upon your rosy pinions!
Ay! were a magic mantle only mine,
To soar o'er earth's wide wildernesses,
I would not sell it for the costliest dresses,
Not for a royal robe the gift resign.
 
_Wagner_. O, call them not, the well known powers of air,
That swarm through all the middle kingdom, weaving
Their fairy webs, with many a fatal snare
The feeble race of men deceiving.
First, the sharp spirit-tooth, from out the North,
And arrowy tongues and fangs come thickly flying;
Then from the East they greedily dart forth,
Sucking thy lungs, thy life-juice drying;
If from the South they come with fever thirst,
Upon thy head noon's fiery splendors heaping;
The Westwind brings a swarm, refreshing first,
Then all thy world with thee in stupor steeping.
They listen gladly, aye on mischief bent,
Gladly draw near, each weak point to espy,
They make believe that they from heaven are sent,
Whispering like angels, while they lie.
But let us go! The earth looks gray, my friend,
The air grows cool, the mists ascend!
At night we learn our homes to prize.--
Why dost thou stop and stare with all thy eyes?
What can so chain thy sight there, in the gloaming?
 
_Faust_. Seest thou that black dog through stalks and stubble roaming?
 
_Wagner_. I saw him some time since, he seemed not strange to me.
 
_Faust_. Look sharply! What dost take the beast to be?
 
_Wagner_. For some poor poodle who has lost his master,
And, dog-like, scents him o'er the ground.
 
_Faust_. Markst thou how, ever nearer, ever faster,
Towards us his spiral track wheels round and round?
And if my senses suffer no confusion,
Behind him trails a fiery glare.
 
_Wagner_. 'Tis probably an optical illusion;
I still see only a black poodle there.
 
_Faust_. He seems to me as he were tracing slyly
His magic rings our feet at last to snare.
 
_Wagner_. To me he seems to dart around our steps so shyly,
As if he said: is one of them my master there?
 
_Faust_. The circle narrows, he is near!
 
_Wagner_. Thou seest! a dog we have, no spectre, here!
He growls and stops, crawls on his belly, too,
And wags his tail,--as all dogs do.
 
_Faust_. Come here, sir! come, our comrade be!
 
_Wagner_. He has a poodle's drollery.
Stand still, and he, too, waits to see;
Speak to him, and he jumps on thee;
Lose something, drop thy cane or sling it
Into the stream, he'll run and bring it.
 
_Faust_. I think you're right; I trace no spirit here,
'Tis all the fruit of training, that is clear.
 
_Wagner_. A well-trained dog is a great treasure,
Wise men in such will oft take pleasure.
And he deserves your favor and a collar,
He, of the students the accomplished scholar.
 
[_They go in through the town gate._]
 
 
 
 
STUDY-CHAMBER.
 
_Enter_ FAUST _with the_ POODLE.
 
 
I leave behind me field and meadow
Veiled in the dusk of holy night,
Whose ominous and awful shadow
Awakes the better soul to light.
To sleep are lulled the wild desires,
The hand of passion lies at rest;
The love of man the bosom fires,
The love of God stirs up the breast.
 
Be quiet, poodle! what worrisome fiend hath possest thee,
Nosing and snuffling so round the door?
Go behind the stove there and rest thee,
There's my best pillow--what wouldst thou more?
As, out on the mountain-paths, frisking and leaping,
Thou, to amuse us, hast done thy best,
So now in return lie still in my keeping,
A quiet, contented, and welcome guest.
 
When, in our narrow chamber, nightly,
The friendly lamp begins to burn,
Then in the bosom thought beams brightly,
Homeward the heart will then return.
Reason once more bids passion ponder,
Hope blooms again and smiles on man;
Back to life's rills he yearns to wander,
Ah! to the source where life began.
 
Stop growling, poodle! In the music Elysian
That laps my soul at this holy hour,
These bestial noises have jarring power.
We know that men will treat with derision
Whatever they cannot understand,
At goodness and truth and beauty's vision
Will shut their eyes and murmur and howl at it;
And must the dog, too, snarl and growl at it?
 
But ah, with the best will, I feel already,
No peace will well up in me, clear and steady.
But why must hope so soon deceive us,
And the dried-up stream in fever leave us?
For in this I have had a full probation.
And yet for this want a supply is provided,
To a higher than earth the soul is guided,
We are ready and yearn for revelation:
And where are its light and warmth so blent
As here in the New Testament?
I feel, this moment, a mighty yearning
To expound for once the ground text of all,
The venerable original
Into my own loved German honestly turning.
[_He opens the volume, and applies himself to the task_.]
"In the beginning was the _Word_." I read.
But here I stick! Who helps me to proceed?
The _Word_--so high I cannot--dare not, rate it,
I must, then, otherwise translate it,
If by the spirit I am rightly taught.
It reads: "In the beginning was the _thought_."
But study well this first line's lesson,
Nor let thy pen to error overhasten!
Is it the _thought_ does all from time's first hour?
"In the beginning," read then, "was the _power_."
Yet even while I write it down, my finger
Is checked, a voice forbids me there to linger.
The spirit helps! At once I dare to read
And write: "In the beginning was the _deed_."
 
If I with thee must share my chamber,
Poodle, now, remember,
No more howling,
No more growling!
I had as lief a bull should bellow,
As have for a chum such a noisy fellow.
Stop that yell, now,
One of us must quit this cell now!
'Tis hard to retract hospitality,
But the door is open, thy way is free.
But what ails the creature?
Is this in the course of nature?
Is it real? or one of Fancy's shows?
 
How long and broad my poodle grows!
He rises from the ground;
That is no longer the form of a hound!
Heaven avert the curse from us!
He looks like a hippopotamus,
With his fiery eyes and the terrible white
Of his grinning teeth! oh what a fright
Have I brought with me into the house! Ah now,
No mystery art thou!
Methinks for such half hellish brood
The key of Solomon were good.
 
_Spirits_ [_in the passage_]. Softly! a fellow is caught there!
Keep back, all of you, follow him not there!
Like the fox in the trap,
Mourns the old hell-lynx his mishap.
But give ye good heed!
This way hover, that way hover,
Over and over,
And he shall right soon be freed.
Help can you give him,
O do not leave him!
Many good turns he's done us,
Many a fortune won us.
 
_Faust_. First, to encounter the creature
By the spell of the Four, says the teacher:
Salamander shall glisten,[12]
Undina lapse lightly,
Sylph vanish brightly,
Kobold quick listen.
 
He to whom Nature
Shows not, as teacher,
Every force
And secret source,
Over the spirits
No power inherits.
 
Vanish in glowing
Flame, Salamander!
Inward, spirally flowing,
Gurgle, Undine!
Gleam in meteoric splendor,
Airy Queen!
Thy homely help render,
Incubus! Incubus!
Forth and end the charm for us!
 
No kingdom of Nature
Resides in the creature.
He lies there grinning--'tis clear, my charm
Has done the monster no mite of harm.
I'll try, for thy curing,
Stronger adjuring.
 
Art thou a jail-bird,
A runaway hell-bird?
This sign,[13] then--adore it!
They tremble before it
All through the dark dwelling.
 
His hair is bristling--his body swelling.
 
Reprobate creature!
Canst read his nature?
The Uncreated,
Ineffably Holy,
With Deity mated,
Sin's victim lowly?
 
Driven behind the stove by my spells,
Like an elephant he swells;
He fills the whole room, so huge he's grown,
He waxes shadowy faster and faster.
Rise not up to the ceiling--down!
Lay thyself at the feet of thy master!
Thou seest, there's reason to dread my ire.
I'll scorch thee with the holy fire!
Wait not for the sight
Of the thrice-glowing light!
Wait not to feel the might
Of the potentest spell in all my treasure!
 
 
MEPHISTOPHELES.
[_As the mist sinks, steps forth from behind the stove,
dressed as a travelling scholasticus_.]
Why all this noise? What is your worship's pleasure?
 
_Faust_. This was the poodle's essence then!
A travelling clark? Ha! ha! The casus is too funny.
 
_Mephistopheles_. I bow to the most learned among men!
'Faith you did sweat me without ceremony.
 
_Faust_. What is thy name?
 
_Mephistopheles_. The question seems too small
For one who holds the _word_ so very cheaply,
Who, far removed from shadows all,
For substances alone seeks deeply.
 
_Faust_. With gentlemen like him in my presence,
The name is apt to express the essence,
Especially if, when you inquire,
You find it God of flies,[14] Destroyer, Slanderer, Liar.
Well now, who art thou then?
 
_Mephistopheles_. A portion of that power,
Which wills the bad and works the good at every hour.
 
_Faust_. Beneath thy riddle-word what meaning lies?
 
_Mephistopheles_. I am the spirit that denies!
And justly so; for all that time creates,
He does well who annihilates!
Better, it ne'er had had beginning;
And so, then, all that you call sinning,
Destruction,--all you pronounce ill-meant,--
Is my original element.
 
_Faust_. Thou call'st thyself a part, yet lookst complete to me.
 
_Mephistopheles_. I speak the modest truth to thee.
A world of folly in one little soul,
_Man_ loves to think himself a whole;
Part of the part am I, which once was all, the Gloom
That brought forth Light itself from out her mighty womb,
The upstart proud, that now with mother Night
Disputes her ancient rank and space and right,
Yet never shall prevail, since, do whate'er he will,
He cleaves, a slave, to bodies still;
From bodies flows, makes bodies fair to sight;
A body in his course can check him,
His doom, I therefore hope, will soon o'ertake him,
With bodies merged in nothingness and night.
 
_Faust_. Ah, now I see thy high vocation!
In gross thou canst not harm creation,
And so in small hast now begun.
 
_Mephistopheles_. And, truth to tell, e'en here, not much have done.
That which at nothing the gauntlet has hurled,
This, what's its name? this clumsy world,
So far as I have undertaken,
I have to own, remains unshaken
By wave, storm, earthquake, fiery brand.
Calm, after all, remain both sea and land.
And the damn'd living fluff, of man and beast the brood,
It laughs to scorn my utmost power.
I've buried myriads by the hour,
And still there circulates each hour a new, fresh blood.
It were enough to drive one to distraction!
Earth, water, air, in constant action,
Through moist and dry, through warm and cold,
Going forth in endless germination!
Had I not claimed of fire a reservation,
Not one thing I alone should hold.
 
_Faust_. Thus, with the ever-working power
Of good dost thou in strife persist,
And in vain malice, to this hour,
Clenchest thy cold and devilish fist!
Go try some other occupation,
Singular son of Chaos, thou!
 
_Mephistopheles_. We'll give the thing consideration,
When next we meet again! But now
Might I for once, with leave retire?
 
_Faust_. Why thou shouldst ask I do not see.
Now that I know thee, when desire
Shall prompt thee, freely visit me.
Window and door give free admission.
At least there's left the chimney flue.
 
_Mephistopheles_. Let me confess there's one small prohibition
 
Lies on thy threshold, 'gainst my walking through,
The wizard-foot--[15]
 
_Faust_. Does that delay thee?
The Pentagram disturbs thee? Now,
Come tell me, son of hell, I pray thee,
If that spell-binds thee, then how enteredst thou?
_Thou_ shouldst proceed more circumspectly!
 
_Mephistopheles_. Mark well! the figure is not drawn correctly;
One of the angles, 'tis the outer one,
Is somewhat open, dost perceive it?
 
_Faust_. That was a lucky hit, believe it!
And I have caught thee then? Well done!
'Twas wholly chance--I'm quite astounded!
 
_Mephistopheles_. The _poodle_ took no heed,
as through the door he bounded;
The case looks differently now;
The _devil_ can leave the house no-how.
 
_Faust_. The window offers free emission.
 
_Mephistopheles_. Devils and ghosts are bound by this condition:
 
The way they entered in, they must come out. Allow
In the first clause we're free, yet not so in the second.
 
_Faust_. In hell itself, then, laws are reckoned?
Now that I like; so then, one may, in fact,
Conclude a binding compact with you gentry?
 
_Mephistopheles_. Whatever promise on our books finds entry,
We strictly carry into act.
But hereby hangs a grave condition,
Of this we'll talk when next we meet;
But for the present I entreat
Most urgently your kind dismission.
 
_Faust_. Do stay but just one moment longer, then,
Tell me good news and I'll release thee.
 
_Mephistopheles_. Let me go now! I'll soon come back again,
Then may'st thou ask whate'er shall please thee.
 
_Faust_. I laid no snare for thee, old chap!
Thou shouldst have watched and saved thy bacon.
Who has the devil in his trap
Must hold him fast, next time he'll not so soon be taken.
 
_Mephistopheles_. Well, if it please thee, I'm content to stay
For company, on one condition,
That I, for thy amusement, may
To exercise my arts have free permission.
 
_Faust_. I gladly grant it, if they be
Not disagreeable to me.
 
_Mephistopheles_. Thy senses, friend, in this one hour
Shall grasp the world with clearer power
Than in a year's monotony.
The songs the tender spirits sing thee,
The lovely images they bring thee
Are not an idle magic play.
Thou shalt enjoy the daintiest savor,
Then feast thy taste on richest flavor,
Then thy charmed heart shall melt away.
Come, all are here, and all have been
Well trained and practised, now begin!
 
_Spirits_. Vanish, ye gloomy
Vaulted abysses!
Tenderer, clearer,
Friendlier, nearer,
Ether, look through!
O that the darkling
Cloud-piles were riven!
Starlight is sparkling,
Purer is heaven,
Holier sunshine
Softens the blue.
Graces, adorning
Sons of the morning--
Shadowy wavings--
Float along over;
Yearnings and cravings
After them hover.
Garments ethereal,
Tresses aerial,
Float o'er the flowers,
Float o'er the bowers,
Where, with deep feeling,
Thoughtful and tender,
Lovers, embracing,
Life-vows are sealing.
Bowers on bowers!
Graceful and slender
Vines interlacing!
Purple and blushing,
Under the crushing
Wine-presses gushing,
Grape-blood, o'erflowing,
Down over gleaming
Precious stones streaming,
Leaves the bright glowing
Tops of the mountains,
Leaves the red fountains,
Widening and rushing,
Till it encloses
Green hills all flushing,
Laden with roses.
Happy ones, swarming,
Ply their swift pinions,
Glide through the charming
Airy dominions,
Sunward still fleering,
Onward, where peering
Far o'er the ocean,
Islets are dancing
With an entrancing,
Magical motion;
Hear them, in chorus,
Singing high o'er us;
Over the meadows
Flit the bright shadows;
Glad eyes are glancing,
Tiny feet dancing.
Up the high ridges
Some of them clamber,
Others are skimming
Sky-lakes of amber,
Others are swimming
Over the ocean;--
All are in motion,
Life-ward all yearning,
Longingly turning
To the far-burning
Star-light of bliss.
 
_Mephistopheles_. He sleeps! Ye airy, tender youths, your numbers
Have sung him into sweetest slumbers!
You put me greatly in your debt by this.
Thou art not yet the man that shall hold fast the devil!
Still cheat his senses with your magic revel,
Drown him in dreams of endless youth;
But this charm-mountain on the sill to level,
I need, O rat, thy pointed tooth!
Nor need I conjure long, they're near me,
E'en now comes scampering one, who presently will hear me.
 
The sovereign lord of rats and mice,
Of flies and frogs and bugs and lice,
Commands thee to come forth this hour,
And gnaw this threshold with great power,
As he with oil the same shall smear--
Ha! with a skip e'en now thou'rt here!
But brisk to work! The point by which I'm cowered,
Is on the ledge, the farthest forward.
Yet one more bite, the deed is done.--
Now, Faust, until we meet again, dream on!
 
_Faust_. [_Waking_.] Again has witchcraft triumphed o'er me?
Was it a ghostly show, so soon withdrawn?
I dream, the devil stands himself before me--wake, to find a poodle gone!
 
 
 
 
STUDY-CHAMBER.
 
FAUST. MEPHISTOPHELES.
 
 
_Faust_. A knock? Walk in! Who comes again to tease me?
 
_Mephistopheles_. 'Tis I.
 
_Faust_. Come in!
 
_Mephistopheles_. Must say it thrice, to please me.
 
_Faust_. Come in then!
 
_Mephistopheles_. That I like to hear.
We shall, I hope, bear with each other;
For to dispel thy crotchets, brother,
As a young lord, I now appear,
In scarlet dress, trimmed with gold lacing,
A stiff silk cloak with stylish facing,
A tall cock's feather in my hat,
A long, sharp rapier to defend me,
And I advise thee, short and flat,
In the same costume to attend me;
If thou wouldst, unembarrassed, see
What sort of thing this life may be.
 
_Faust_. In every dress I well may feel the sore
Of this low earth-life's melancholy.
I am too old to live for folly,
Too young, to wish for nothing more.
Am I content with all creation?
Renounce! renounce! Renunciation--
Such is the everlasting song
That in the ears of all men rings,
Which every hour, our whole life long,
With brazen accents hoarsely sings.
With terror I behold each morning's light,
With bitter tears my eyes are filling,
To see the day that shall not in its flight
Fulfil for me one wish, not one, but killing
Every presentiment of zest
With wayward skepticism, chases
The fair creations from my breast
With all life's thousand cold grimaces.
And when at night I stretch me on my bed
And darkness spreads its shadow o'er me;
No rest comes then anigh my weary head,
Wild dreams and spectres dance before me.
The God who dwells within my soul
Can heave its depths at any hour;
Who holds o'er all my faculties control
Has o'er the outer world no power;
Existence lies a load upon my breast,
Life is a curse and death a long'd-for rest.
 
_Mephistopheles_. And yet death never proves a wholly welcome guest.
 
_Faust_. O blest! for whom, when victory's joy fire blazes,
Death round his brow the bloody laurel windeth,
Whom, weary with the dance's mazes,
He on a maiden's bosom findeth.
O that, beneath the exalted spirit's power,
I had expired, in rapture sinking!
 
_Mephistopheles_. And yet I knew one, in a midnight hour,
Who a brown liquid shrank from drinking.
 
_Faust_. Eaves-dropping seems a favorite game with thee.
 
_Mephistopheles_. Omniscient am I not; yet much is known to me.
 
_Faust_. Since that sweet tone, with fond appealing,
Drew me from witchcraft's horrid maze,
And woke the lingering childlike feeling
With harmonies of happier days;
My curse on all the mock-creations
That weave their spell around the soul,
And bind it with their incantations
And orgies to this wretched hole!
Accursed be the high opinion
Hugged by the self-exalting mind!
Accursed all the dream-dominion
That makes the dazzled senses blind!
Curs'd be each vision that befools us,
Of fame, outlasting earthly life!
Curs'd all that, as possession, rules us,
As house and barn, as child and wife!
Accurs'd be mammon, when with treasure
He fires our hearts for deeds of might,
When, for a dream of idle pleasure,
He makes our pillow smooth and light!
Curs'd be the grape-vine's balsam-juices!
On love's high grace my curses fall!
On faith! On hope that man seduces,
On patience last, not least, of all!
 
_Choir of spirits_. [_Invisible_.] Woe! Woe!
Thou hast ground it to dust,
The beautiful world,
With mighty fist;
To ruins 'tis hurled;
A demi-god's blow hath done it!
A moment we look upon it,
Then carry (sad duty!)
The fragments over into nothingness,
With tears unavailing
Bewailing
All the departed beauty.
Lordlier
Than all sons of men,
Proudlier
Build it again,
Build it up in thy breast anew!
A fresh career pursue,
Before thee
A clearer view,
And, from the Empyréan,
A new-born Paean
Shall greet thee, too!
 
_Mephistopheles_. Be pleased to admire
My juvenile choir!
Hear how they counsel in manly measure
Action and pleasure!
Out into life,
Its joy and strife,
Away from this lonely hole,
Where senses and soul
Rot in stagnation,
Calls thee their high invitation.
 
Give over toying with thy sorrow
Which like a vulture feeds upon thy heart;
Thou shalt, in the worst company, to-morrow
Feel that with men a man thou art.
Yet I do not exactly intend
Among the canaille to plant thee.
I'm none of your magnates, I grant thee;
Yet if thou art willing, my friend,
Through life to jog on beside me,
Thy pleasure in all things shall guide me,
To thee will I bind me,
A friend thou shalt find me,
And, e'en to the grave,
Shalt make me thy servant, make me thy slave!
 
_Faust_. And in return what service shall I render?
 
_Mephistopheles_. There's ample grace--no hurry, not the least.
 
_Faust_. No, no, the devil is an egotist,
And does not easily "for God's sake" tender
That which a neighbor may assist.
Speak plainly the conditions, come!
'Tis dangerous taking such a servant home.
 
_Mephistopheles_. I to thy service _here_ agree to bind me,
To run and never rest at call of thee;
When _over yonder_ thou shalt find me,
Then thou shalt do as much for me.
 
_Faust_. I care not much what's over yonder:
When thou hast knocked this world asunder,
Come if it will the other may!
Up from this earth my pleasures all are streaming,
Down on my woes this earthly sun is beaming;
Let me but end this fit of dreaming,
Then come what will, I've nought to say.
I'll hear no more of barren wonder
If in that world they hate and love,
And whether in that future yonder
There's a Below and an Above.
 
_Mephistopheles._ In such a mood thou well mayst venture.
Bind thyself to me, and by this indenture
Thou shalt enjoy with relish keen
Fruits of my arts that man had never seen.
 
_Faust_. And what hast thou to give, poor devil?
Was e'er a human mind, upon its lofty level,
Conceived of by the like of thee?
Yet hast thou food that brings satiety,
Not satisfaction; gold that reftlessly,
Like quicksilver, melts down within
The hands; a game in which men never win;
A maid that, hanging on my breast,
Ogles a neighbor with her wanton glances;
Of fame the glorious godlike zest,
That like a short-lived meteor dances--
Show me the fruit that, ere it's plucked, will rot,
And trees from which new green is daily peeping!
 
_Mephistopheles_. Such a requirement scares me not;
Such treasures have I in my keeping.
Yet shall there also come a time, good friend,
When we may feast on good things at our leisure.
 
_Faust_. If e'er I lie content upon a lounge of pleasure--
Then let there be of me an end!
When thou with flattery canst cajole me,
Till I self-satisfied shall be,
When thou with pleasure canst befool me,
Be that the last of days for me!
I lay the wager!
 
_Mephistopheles_. Done!
 
_Faust_. And heartily!
Whenever to the passing hour
I cry: O stay! thou art so fair!
To chain me down I give thee power
To the black bottom of despair!
Then let my knell no longer linger,
Then from my service thou art free,
Fall from the clock the index-finger,
Be time all over, then, for me!
 
_Mephistopheles_. Think well, for we shall hold you to the letter.
 
_Faust_. Full right to that just now I gave;
I spoke not as an idle braggart better.
Henceforward I remain a slave,
What care I who puts on the setter?
 
_Mephistopheles_. I shall this very day, at Doctor's-feast,[16]
My bounden service duly pay thee.
But one thing!--For insurance' sake, I pray thee,
Grant me a line or two, at least.
 
_Faust_. Pedant! will writing gain thy faith, alone?
In all thy life, no man, nor man's word hast thou known?
Is't not enough that I the fatal word
That passes on my future days have spoken?
The world-stream raves and rushes (hast not heard?)
And shall a promise hold, unbroken?
Yet this delusion haunts the human breast,
Who from his soul its roots would sever?
Thrice happy in whose heart pure truth finds rest.
No sacrifice shall he repent of ever!
But from a formal, written, sealed attest,
As from a spectre, all men shrink forever.
The word and spirit die together,
Killed by the sight of wax and leather.
What wilt thou, evil sprite, from me?
Brass, marble, parchment, paper, shall it be?
Shall I subscribe with pencil, pen or graver?
Among them all thy choice is free.
 
_Mephistopheles_. This rhetoric of thine to me
Hath a somewhat bombastic savor.
Any small scrap of paper's good.
Thy signature will need a single drop of blood.[17]
 
_Faust_. If this will satisfy thy mood,
I will consent thy whim to favor.
 
_Mephistopheles._ Quite a peculiar juice is blood.
 
_Faust_. Fear not that I shall break this bond; O, never!
My promise, rightly understood,
Fulfils my nature's whole endeavor.
I've puffed myself too high, I see;
To _thy_ rank only I belong.
The Lord of Spirits scorneth me,
Nature, shut up, resents the wrong.
The thread of thought is snapt asunder,
All science to me is a stupid blunder.
Let us in sensuality's deep
Quench the passions within us blazing!
And, the veil of sorcery raising,
Wake each miracle from its long sleep!
Plunge we into the billowy dance,
The rush and roll of time and chance!
Then may pleasure and distress,
Disappointment and success,
Follow each other as fast as they will;
Man's restless activity flourishes still.
 
_Mephistopheles_. No bound or goal is set to you;
Where'er you like to wander sipping,
And catch a tit-bit in your skipping,
Eschew all coyness, just fall to,
And may you find a good digestion!
 
_Faust_. Now, once for all, pleasure is not the question.
I'm sworn to passion's whirl, the agony of bliss,
The lover's hate, the sweets of bitterness.
My heart, no more by pride of science driven,
Shall open wide to let each sorrow enter,
And all the good that to man's race is given,
I will enjoy it to my being's centre,
Through life's whole range, upward and downward sweeping,
Their weal and woe upon my bosom heaping,
Thus in my single self their selves all comprehending
And with them in a common shipwreck ending.
 
_Mephistopheles_. O trust me, who since first I fell from heaven,
Have chewed this tough meat many a thousand year,
No man digests the ancient leaven,
No mortal, from the cradle to the bier.
Trust one of _us_--the _whole_ creation
To God alone belongs by right;
_He_ has in endless day his habitation,
_Us_ He hath made for utter night,
_You_ for alternate dark and light.
 
_Faust_. But then I _will!_
 
_Mephistopheles_. Now that's worth hearing!
But one thing haunts me, the old song,
That time is short and art is long.
You need some slight advice, I'm fearing.
Take to you one of the poet-feather,
Let the gentleman's thought, far-sweeping,
Bring all the noblest traits together,
On your one crown their honors heaping,
The lion's mood
The stag's rapidity,
The fiery blood of Italy,
The Northman's hardihood.
Bid him teach thee the art of combining
Greatness of soul with fly designing,
And how, with warm and youthful passion,
To fall in love by plan and fashion.
Should like, myself, to come across 'm,
Would name him Mr. Microcosm.
 
_Faust_. What am I then? if that for which my heart
Yearns with invincible endeavor,
The crown of man, must hang unreached forever?
 
_Mephistopheles_. Thou art at last--just what thou art.
Pile perukes on thy head whose curls cannot be counted,
On yard-high buskins let thy feet be mounted,
Still thou art only what thou art.
 
_Faust_. Yes, I have vainly, let me not deny it,
Of human learning ransacked all the stores,
And when, at last, I set me down in quiet,
There gushes up within no new-born force;
I am not by a hair's-breadth higher,
Am to the Infinite no nigher.
 
_Mephistopheles_. My worthy sir, you see the matter
As people generally see;
But we must learn to take things better,
Before life pleasures wholly flee.
The deuce! thy head and all that's in it,
Hands, feet and ------ are thine;
What I enjoy with zest each minute,
Is surely not the less mine?
If I've six horses in my span,
Is it not mine, their every power?
I fly along as an undoubted man,
On four and twenty legs the road I scour.
Cheer up, then! let all thinking be,
And out into the world with me!
I tell thee, friend, a speculating churl
Is like a beast, some evil spirit chases
Along a barren heath in one perpetual whirl,
While round about lie fair, green pasturing places.
 
_Faust_. But how shall we begin?
 
_Mephistopheles_. We sally forth e'en now.
What martyrdom endurest thou!
What kind of life is this to be living,
Ennui to thyself and youngsters giving?
Let Neighbor Belly that way go!
To stay here threshing straw why car'st thou?
The best that thou canst think and know
To tell the boys not for the whole world dar'st thou.
E'en now I hear one in the entry.
 
_Faust_. I have no heart the youth to see.
 
_Mephistopheles_. The poor boy waits there like a sentry,
He shall not want a word from me.
Come, give me, now, thy robe and bonnet;
This mask will suit me charmingly.
[_He puts them on_.]
Now for my wit--rely upon it!
'Twill take but fifteen minutes, I am sure.
Meanwhile prepare thyself to make the pleasant tour!
 
[_Exit_ FAUST.]
 
_Mephistopheles [in_ FAUST'S _long gown_].
Only despise all human wit and lore,
The highest flights that thought can soar--
Let but the lying spirit blind thee,
And with his spells of witchcraft bind thee,
Into my snare the victim creeps.--
To him has destiny a spirit given,
That unrestrainedly still onward sweeps,
To scale the skies long since hath striven,
And all earth's pleasures overleaps.
He shall through life's wild scenes be driven,
And through its flat unmeaningness,
I'll make him writhe and stare and stiffen,
And midst all sensual excess,
His fevered lips, with thirst all parched and riven,
Insatiably shall haunt refreshment's brink;
And had he not, himself, his soul to Satan given,
Still must he to perdition sink!
 
[_Enter_ A SCHOLAR.]
 
_Scholar_. I have but lately left my home,
And with profound submission come,
To hold with one some conversation
Whom all men name with veneration.
 
_Mephistopheles._ Your courtesy greatly flatters me
A man like many another you see.
Have you made any applications elsewhere?
 
_Scholar_. Let me, I pray, your teachings share!
With all good dispositions I come,
A fresh young blood and money some;
My mother would hardly hear of my going;
But I long to learn here something worth knowing.
 
_Mephistopheles_. You've come to the very place for it, then.
 
_Scholar_. Sincerely, could wish I were off again:
My soul already has grown quite weary
Of walls and halls, so dark and dreary,
The narrowness oppresses me.
One sees no green thing, not a tree.
On the lecture-seats, I know not what ails me,
Sight, hearing, thinking, every thing fails me.
 
_Mephistopheles_. 'Tis all in use, we daily see.
The child takes not the mother's breast
In the first instance willingly,
But soon it feeds itself with zest.
So you at wisdom's breast your pleasure
Will daily find in growing measure.
 
_Scholar_. I'll hang upon her neck, a raptured wooer,
But only tell me, who shall lead me to her?
 
_Mephistopheles_. Ere you go further, give your views
As to which faculty you choose?
 
_Scholar_. To be right learn'd I've long desired,
And of the natural world aspired
To have a perfect comprehension
In this and in the heavenly sphere.
 
_Mephistopheles_. I see you're on the right track here;
But you'll have to give undivided attention.
 
_Scholar_. My heart and soul in the work'll be found;
Only, of course, it would give me pleasure,
When summer holidays come round,
To have for amusement a little leisure.
 
_Mephistopheles_. Use well the precious time, it flips away so,
Yet method gains you time, if I may say so.
I counsel you therefore, my worthy friend,
The logical leisures first to attend.
Then is your mind well trained and cased
In Spanish boots,[18] all snugly laced,
So that henceforth it can creep ahead
On the road of thought with a cautious tread.
And not at random shoot and strike,
Zig-zagging Jack-o'-lanthorn-like.
Then will you many a day be taught
That what you once to do had thought
Like eating and drinking, extempore,
Requires the rule of one, two, three.
It is, to be sure, with the fabric of thought,
As with the _chef d'œuvre_ by weavers wrought,
Where a thousand threads one treadle plies,
Backward and forward the shuttles keep going,
Invisibly the threads keep flowing,
One stroke a thousand fastenings ties:
Comes the philosopher and cries:
I'll show you, it could not be otherwise:
The first being so, the second so,
The third and fourth must of course be so;
And were not the first and second, you see,
The third and fourth could never be.
The scholars everywhere call this clever,
But none have yet become weavers ever.
Whoever will know a live thing and expound it,
First kills out the spirit it had when he found it,
And then the parts are all in his hand,
Minus only the spiritual band!
Encheiresin naturæ's[19] the chemical name,
By which dunces themselves unwittingly shame.
 
_Scholar_. Cannot entirely comprehend you.
 
_Mephistopheles_. Better success will shortly attend you,
When you learn to analyze all creation
And give it a proper classification.
 
_Scholar_. I feel as confused by all you've said,
As if 'twere a mill-wheel going round in my head!
 
_Mephistopheles_. The next thing most important to mention,
Metaphysics will claim your attention!
There see that you can clearly explain
What fits not into the human brain:
For that which will not go into the head,
A pompous word will stand you in stead.
But, this half-year, at least, observe
From regularity never to swerve.
You'll have five lectures every day;
Be in at the stroke of the bell I pray!
And well prepared in every part;
Study each paragraph by heart,
So that you scarce may need to look
To see that he says no more than's in the book;
And when he dictates, be at your post,
As if you wrote for the Holy Ghost!
 
_Scholar_. That caution is unnecessary!
I know it profits one to write,
For what one has in black and white,
He to his home can safely carry.
 
_Mephistopheles_. But choose some faculty, I pray!
 
_Scholar_. I feel a strong dislike to try the legal college.
 
_Mephistopheles_. I cannot blame you much, I must acknowledge.
I know how this profession stands to-day.
Statutes and laws through all the ages
Like a transmitted malady you trace;
In every generation still it rages
And softly creeps from place to place.
Reason is nonsense, right an impudent suggestion;
Alas for thee, that thou a grandson art!
Of inborn law in which each man has part,
Of that, unfortunately, there's no question.
 
_Scholar_. My loathing grows beneath your speech.
O happy he whom you shall teach!
To try theology I'm almost minded.
 
_Mephistopheles_. I must not let you by zeal be blinded.
This is a science through whose field
Nine out of ten in the wrong road will blunder,
And in it so much poison lies concealed,
That mould you this mistake for physic, no great wonder.
Here also it were best, if only one you heard
And swore to that one master's word.
Upon the whole--words only heed you!
These through the temple door will lead you
Safe to the shrine of certainty.
 
_Scholar_. Yet in the word a thought must surely be.
 
_Mephistopheles_. All right! But one must not perplex himself about it;
For just where one must go without it,
The word comes in, a friend in need, to thee.
With words can one dispute most featly,
With words build up a system neatly,
In words thy faith may stand unshaken,
From words there can be no iota taken.
 
_Scholar_. Forgive my keeping you with many questions,
Yet must I trouble you once more,
Will you not give me, on the score
Of medicine, some brief suggestions?
Three years are a short time, O God!
And then the field is quite too broad.
If one had only before his nose
Something else as a hint to follow!--
 
_Mephistopheles_ [_aside_]. I'm heartily tired of this dry prose,
Must play the devil again out hollow.
[_Aloud_.]
The healing art is quickly comprehended;
Through great and little world you look abroad,
And let it wag, when all is ended,
As pleases God.
Vain is it that your science sweeps the skies,
Each, after all, learns only what he can;
Who grasps the moment as it flies
He is the real man.
Your person somewhat takes the eye,
Boldness you'll find an easy science,
And if you on yourself rely,
Others on you will place reliance.
In the women's good graces seek first to be seated;
Their oh's and ah's, well known of old,
So thousand-fold,
Are all from a single point to be treated;
Be decently modest and then with ease
You may get the blind side of them when you please.
A title, first, their confidence must waken,
That _your_ art many another art transcends,
Then may you, lucky man, on all those trifles reckon
For which another years of groping spends:
Know how to press the little pulse that dances,
And fearlessly, with sly and fiery glances,
Clasp the dear creatures round the waist
To see how tightly they are laced.
 
_Scholar_. This promises! One loves the How and Where to see!
 
_Mephistopheles_. Gray, worthy friend, is all your theory
And green the golden tree of life.
 
_Scholar_. I seem,
I swear to you, like one who walks in dream.
Might I another time, without encroaching,
Hear you the deepest things of wisdom broaching?
 
_Mephistopheles_. So far as I have power, you may.
 
_Scholar_. I cannot tear myself away,
Till I to you my album have presented.
Grant me one line and I'm contented!
 
_Mephistopheles_. With pleasure.
[_Writes and returns it_.]
 
_Scholar [reads]._ Eritis sicut Deus, scientes bonum et malum.
[_Shuts it reverently, and bows himself out_.]
 
_Mephistopheles_.
Let but the brave old saw and my aunt, the serpent, guide thee,
And, with thy likeness to God, shall woe one day betide thee!
 
_Faust [enters_]. Which way now shall we go?
 
_Mephistopheles_. Which way it pleases thee.
The little world and then the great we see.
O with what gain, as well as pleasure,
Wilt thou the rollicking cursus measure!
 
_Faust_. I fear the easy life and free
With my long beard will scarce agree.
'Tis vain for me to think of succeeding,
I never could learn what is called good-breeding.
In the presence of others I feel so small;
I never can be at my ease at all.
 
_Mephistopheles_. Dear friend, vain trouble to yourself you're giving;
Whence once you trust yourself, you know the art of living.
 
_Faust_. But how are we to start, I pray?
Where are thy servants, coach and horses?
 
_Mephistopheles_. We spread the mantle, and away
It bears us on our airy courses.
But, on this bold excursion, thou
Must take no great portmanteau now.
A little oxygen, which I will soon make ready,
From earth uplifts us, quick and steady.
And if we're light, we'll soon surmount the sphere;
I give thee hearty joy in this thy new career.
 
 
 
 
AUERBACH'S CELLAR IN LEIPSIC.[20]
 
_Carousal of Jolly Companions_.
 
 
_Frosch_.[21] Will nobody drink? Stop those grimaces!
I'll teach you how to be cutting your faces!
Laugh out! You're like wet straw to-day,
And blaze, at other times, like dry hay.
 
_Brander_. 'Tis all your fault; no food for fun you bring,
Not a nonsensical nor nasty thing.
 
_Frosch [dashes a glass of wine over his bead_]. There you have both!
 
_Brander_. You hog twice o'er!
 
_Frosch_. You wanted it, what would you more?
 
_Siebel_ Out of the door with them that brawl!
Strike up a round; swill, shout there, one and all!
Wake up! Hurra!
 
_Altmayer_. Woe's me, I'm lost! Bring cotton!
The rascal splits my ear-drum.
 
_Siebel_. Only shout on!
When all the arches ring and yell,
Then does the base make felt its true ground-swell.
 
_Frosch_. That's right, just throw him out, who undertakes to fret!
A! tara! lara da!
 
_Altmayer_. A! tara! lara da!
 
_Frosch_. Our whistles all are wet.
[_Sings_.]
The dear old holy Romish realm,
What holds it still together?
 
_Brander_. A sorry song! Fie! a political song!
A tiresome song! Thank God each morning therefor,
That you have not the Romish realm to care for!
At least I count it a great gain that He
Kaiser nor chancellor has made of me.
E'en we can't do without a head, however;
To choose a pope let us endeavour.
You know what qualification throws
The casting vote and the true man shows.
 
_Frosch [sings_].
Lady Nightingale, upward soar,
Greet me my darling ten thousand times o'er.
 
_Siebel_. No greetings to that girl! Who does so, I resent it!
 
_Frosch_. A greeting and a kiss! And you will not prevent it!
[_Sings.]_
Draw the bolts! the night is clear.
Draw the bolts! Love watches near.
Close the bolts! the dawn is here.
 
_Siebel_. Ay, sing away and praise and glorify your dear!
Soon I shall have my time for laughter.
The jade has jilted me, and will you too hereafter;
May Kobold, for a lover, be her luck!
At night may he upon the cross-way meet her;
Or, coming from the Blocksberg, some old buck
May, as he gallops by, a good-night bleat her!
A fellow fine of real flesh and blood
Is for the wench a deal too good.
She'll get from me but one love-token,
That is to have her window broken!
 
_Brander [striking on the table_]. Attend! attend! To me give ear!
I know what's life, ye gents, confess it:
We've lovesick people sitting near,
And it is proper they should hear
A good-night strain as well as I can dress it.
Give heed! And hear a bran-new song!
Join in the chorus loud and strong!
[_He sings_.]
A rat in the cellar had built his nest,
He daily grew sleeker and smoother,
He lined his paunch from larder and chest,
And was portly as Doctor Luther.
The cook had set him poison one day;
From that time forward he pined away
As if he had love in his body.
 
_Chorus [flouting_]. As if he had love in his body.
 
_Brander_. He raced about with a terrible touse,
From all the puddles went swilling,
He gnawed and he scratched all over the house,
His pain there was no stilling;
He made full many a jump of distress,
And soon the poor beast got enough, I guess,
As if he had love in his body.
 
_Chorus_. As if he had love in his body.
 
_Brander_. With pain he ran, in open day,
Right up into the kitchen;
He fell on the hearth and there he lay
Gasping and moaning and twitchin'.
Then laughed the poisoner: "He! he! he!
He's piping on the last hole," said she,
"As if he had love in his body."
 
_Chorus_. As if he had love in his body.
 
_Siebel_. Just hear now how the ninnies giggle!
That's what I call a genuine art,
To make poor rats with poison wriggle!
 
_Brander_. You take their case so much to heart?
 
_Altmayer_. The bald pate and the butter-belly!
The sad tale makes him mild and tame;
He sees in the swollen rat, poor fellow!
His own true likeness set in a frame.
 
 
FAUST _and_ MEPHISTOPHELES.
 
_Mephistopheles_. Now, first of all, 'tis necessary
To show you people making merry,
That you may see how lightly life can run.
Each day to this small folk's a feast of fun;
Not over-witty, self-contented,
Still round and round in circle-dance they whirl,
As with their tails young kittens twirl.
If with no headache they're tormented,
Nor dunned by landlord for his pay,
They're careless, unconcerned, and gay.
 
_Brander_. They're fresh from travel, one might know it,
Their air and manner plainly show it;
They came here not an hour ago.
 
_Frosch_. Thou verily art right! My Leipsic well I know!
Paris in small it is, and cultivates its people.
 
_Siebel_. What do the strangers seem to thee?
 
_Frosch_. Just let me go! When wine our friendship mellows,
Easy as drawing a child's tooth 'twill be
To worm their secrets out of these two fellows.
They're of a noble house, I dare to swear,
They have a proud and discontented air.
 
_Brander_. They're mountebanks, I'll bet a dollar!
 
_Altmayer_. Perhaps.
 
_Frosch_. I'll smoke them, mark you that!
 
_Mephistopheles_ [_to Faust_]. These people never smell the old rat,
E'en when he has them by the collar.
 
_Faust_. Fair greeting to you, sirs!
 
_Siebel_. The same, and thanks to boot.
[_In a low tone, faking a side look at MEPHISTOPHELES_.]
Why has the churl one halting foot?
 
_Mephistopheles_. With your permission, shall we make one party?
Instead of a good drink, which get here no one can,
Good company must make us hearty.
 
_Altmayer_. You seem a very fastidious man.
 
_Frosch_. I think you spent some time at Rippach[22] lately?
You supped with Mister Hans not long since, I dare say?
 
_Mephistopheles_. We passed him on the road today!
Fine man! it grieved us parting with him, greatly.
He'd much to say to us about his cousins,
And sent to each, through us, his compliments by dozens.
[_He bows to_ FROSCH.]
 
_Altmayer_ [_softly_]. You've got it there! he takes!
 
_Siebel_. The chap don't want for wit!
 
_Frosch_. I'll have him next time, wait a bit!
 
_Mephistopheles_. If I mistook not, didn't we hear
Some well-trained voices chorus singing?
'Faith, music must sound finely here.
From all these echoing arches ringing!
 
_Frosch_. You are perhaps a connoisseur?
 
_Mephistopheles_. O no! my powers are small, I'm but an amateur.
 
_Altmayer_. Give us a song!
 
_Mephistopheles_. As many's you desire.
 
_Siebel_. But let it be a bran-new strain!
 
_Mephistopheles_. No fear of that! We've just come back from Spain,
The lovely land of wine and song and lyre.
[_Sings_.]
There was a king, right stately,
Who had a great, big flea,--
 
_Frosch_. Hear him! A flea! D'ye take there, boys? A flea!
I call that genteel company.
 
_Mephistopheles_ [_resumes_]. There was a king, right stately,
Who had a great, big flea,
And loved him very greatly,
As if his own son were he.
He called the knight of stitches;
The tailor came straightway:
Ho! measure the youngster for breeches,
And make him a coat to-day!
 
_Brander_. But don't forget to charge the knight of stitches,
The measure carefully to take,
And, as he loves his precious neck,
To leave no wrinkles in the breeches.
 
_Mephistopheles_. In silk and velvet splendid
The creature now was drest,
To his coat were ribbons appended,
A cross was on his breast.
He had a great star on his collar,
Was a minister, in short;
And his relatives, greater and smaller,
Became great people at court.
 
The lords and ladies of honor
Fared worse than if they were hung,
The queen, she got them upon her,
And all were bitten and stung,
And did not dare to attack them,
Nor scratch, but let them stick.
We choke them and we crack them
The moment we feel one prick.
 
_Chorus_ [_loud_]. We choke 'em and we crack 'em
The moment we feel one prick.
 
_Frosch_. Bravo! Bravo! That was fine!
 
_Siebel_. So shall each flea his life resign!
 
_Brander_. Point your fingers and nip them fine!
 
_Altmayer_. Hurra for Liberty! Hurra for Wine!
 
_Mephistopheles_. I'd pledge the goddess, too, to show how high I set her,
Right gladly, if your wines were just a trifle better.
 
_Siebel_. Don't say that thing again, you fretter!
 
_Mephistopheles_. Did I not fear the landlord to affront;
I'd show these worthy guests this minute
What kind of stuff our stock has in it.
 
_Siebel_. Just bring it on! I'll bear the brunt.
 
_Frosch_. Give us a brimming glass, our praise shall then be ample,
But don't dole out too small a sample;
For if I'm to judge and criticize,
I need a good mouthful to make me wise.
 
_Altmayer_ [_softly_]. They're from the Rhine, as near as I can make it.
 
_Mephistopheles_. Bring us a gimlet here!
 
_Brander_. What shall be done with that?
You've not the casks before the door, I take it?
 
_Altmayer_. The landlord's tool-chest there is easily got at.
 
_Mephistopheles_ [_takes the gimlet_] (_to Frosch_).
What will you have? It costs but speaking.
 
_Frosch_. How do you mean? Have you so many kinds?
 
_Mephistopheles_. Enough to suit all sorts of minds.
 
_Altmayer_. Aha! old sot, your lips already licking!
 
_Frosch_. Well, then! if I must choose, let Rhine-wine fill my beaker,
Our fatherland supplies the noblest liquor.
 
MEPHISTOPHELES
[_boring a hole in the rim of the table near the place
where_ FROSCH _sits_].
Get us a little wax right off to make the stoppers!
 
_Altmayer_. Ah, these are jugglers' tricks, and whappers!
 
_Mephistopheles_ [_to Brander_]. And you?
 
_Brander_. Champaigne's the wine for me,
But then right sparkling it must be!
 
[MEPHISTOPHELES _bores; meanwhile one of them has made
the wax-stoppers and stopped the holes_.]
 
_Brander_. Hankerings for foreign things will sometimes haunt you,
The good so far one often finds;
Your real German man can't bear the French, I grant you,
And yet will gladly drink their wines.
 
_Siebel_ [_while Mephistopheles approaches his seat_].
I don't like sour, it sets my mouth awry,
Let mine have real sweetness in it!
 
_Mephistopheles_ [_bores_]. Well, you shall have Tokay this minute.
 
_Altmayer_. No, sirs, just look me in the eye!
I see through this, 'tis what the chaps call smoking.
 
_Mephistopheles_. Come now! That would be serious joking,
To make so free with worthy men.
But quickly now! Speak out again!
With what description can I serve you?
 
_Altmayer_. Wait not to ask; with any, then.
 
[_After all the holes are bored and stopped_.]
 
_Mephistopheles_ [_with singular gestures_].
From the vine-stock grapes we pluck;
Horns grow on the buck;
Wine is juicy, the wooden table,
Like wooden vines, to give wine is able.
An eye for nature's depths receive!
Here is a miracle, only believe!
Now draw the plugs and drink your fill!
 
ALL
[_drawing the stoppers, and catching each in his glass
the wine he had desired_].
Sweet spring, that yields us what we will!
 
_Mephistopheles_. Only be careful not a drop to spill!
[_They drink repeatedly_.]
 
_All_ [_sing_]. We're happy all as cannibals,
Five hundred hogs together.
 
_Mephistopheles_. Look at them now, they're happy as can be!
 
_Faust_. To go would suit my inclination.
 
_Mephistopheles_. But first give heed, their bestiality
Will make a glorious demonstration.
 
SIEBEL
[_drinks carelessly; the wine is spilt upon the ground
and turns to flame_].
Help! fire! Ho! Help! The flames of hell!
 
_Mephistopheles [_conjuring the flame_].
Peace, friendly element, be still!
[_To the Toper_.]
This time 'twas but a drop of fire from purgatory.
 
_Siebel_. What does this mean? Wait there, or you'll be sorry!
It seems you do not know us well.
 
_Frosch_. Not twice, in this way, will it do to joke us!
 
_Altmayer_. I vote, we give him leave himself here _scarce_ to make.
 
_Siebel_. What, sir! How dare you undertake
To carry on here your old hocus-pocus?
 
_Mephistopheles_. Be still, old wine-cask!
 
_Siebel_. Broomstick, you!
Insult to injury add? Confound you!
 
_Brander_. Stop there! Or blows shall rain down round you!
 
ALTMAYER
[_draws a stopper out of the table; fire flies at him_].
I burn! I burn!
 
_Siebel_. Foul sorcery! Shame!
Lay on! the rascal is fair game!
 
[_They draw their knives and rush at_ MEPHISTOPHELES.]
 
_Mephistopheles_ [_with a serious mien_].
Word and shape of air!
Change place, new meaning wear!
Be here--and there!
 
[_They stand astounded and look at each other_.]
 
_Altmayer_. Where am I? What a charming land!
 
_Frosch_. Vine hills! My eyes! Is't true?
 
_Siebel_. And grapes, too, close at hand!
 
_Brander_. Beneath this green see what a stem is growing!
See what a bunch of grapes is glowing!
[_He seizes_ SIEBEL _by the nose. The rest do the same to each
other and raise their knives._]
 
_Mephistopheles_ [_as above_]. Loose, Error, from their eyes the band!
How Satan plays his tricks, you need not now be told of.
[_He vanishes with_ FAUST, _the companions start back from each
other_.]
 
_Siebel_. What ails me?
 
_Altmayer_. How?
 
_Frosch_. Was that thy nose, friend, I had hold of?
 
_Brander_ [_to Siebel_]. And I have thine, too, in my hand!
 
_Altmayer_. O what a shock! through all my limbs 'tis crawling!
Get me a chair, be quick, I'm falling!
 
_Frosch_. No, say what was the real case?
 
_Siebel_. O show me where the churl is hiding!
Alive he shall not leave the place!
 
_Altmayer_. Out through the cellar-door I saw him riding--
Upon a cask--he went full chase.--
Heavy as lead my feet are growing.
 
[_Turning towards the table_.]
 
My! If the wine should yet be flowing.
 
_Siebel_. 'Twas all deception and moonshine.
 
_Frosch_. Yet I was sure I did drink wine.
 
_Brander_. But how about the bunches, brother?
 
_Altmayer_. After such miracles, I'll doubt no other!
 
 
 
 
WITCHES' KITCHEN.
 
[_On a low hearth stands a great kettle over the fire. In the smoke,
which rises from it, are seen various forms. A female monkey[28] sits by
the kettle and skims it, and takes care that it does not run over. The
male monkey with the young ones sits close by, warming himself. Walls and
ceiling are adorned 'with the most singular witch-household stuff_.]
 
 
FAUST. MEPHISTOPHELES.
 
_Faust_. Would that this vile witch-business were well over!
Dost promise me I shall recover
In this hodge-podge of craziness?
From an old hag do I advice require?
And will this filthy cooked-up mess
My youth by thirty years bring nigher?
Woe's me, if that's the best you know!
Already hope is from my bosom banished.
Has not a noble mind found long ago
Some balsam to restore a youth that's vanished?
 
_Mephistopheles_. My friend, again thou speakest a wise thought!
I know a natural way to make thee young,--none apter!
But in another book it must be sought,
And is a quite peculiar chapter.
 
_Faust_. I beg to know it.
 
_Mephistopheles_. Well! here's one that needs no pay,
No help of physic, nor enchanting.
Out to the fields without delay,
And take to hacking, digging, planting;
Run the same round from day to day,
A treadmill-life, contented, leading,
With simple fare both mind and body feeding,
Live with the beast as beast, nor count it robbery
Shouldst thou manure, thyself, the field thou reapest;
Follow this course and, trust to me,
For eighty years thy youth thou keepest!
 
_Faust_. I am not used to that, I ne'er could bring me to it,
To wield the spade, I could not do it.
The narrow life befits me not at all.
 
_Mephistopheles_. So must we on the witch, then, call.
 
_Faust_. But why just that old hag? Canst thou
Not brew thyself the needful liquor?
 
_Mephistopheles_. That were a pretty pastime now
I'd build about a thousand bridges quicker.
Science and art alone won't do,
The work will call for patience, too;
Costs a still spirit years of occupation:
Time, only, strengthens the fine fermentation.
To tell each thing that forms a part
Would sound to thee like wildest fable!
The devil indeed has taught the art;
To make it not the devil is able.
[_Espying the animals_.]
See, what a genteel breed we here parade!
This is the house-boy! that's the maid!
[_To the animals_.]
Where's the old lady gone a mousing?
 
_The animals_. Carousing;
Out she went
By the chimney-vent!
 
_Mephistopheles_. How long does she spend in gadding and storming?
 
_The animals_. While we are giving our paws a warming.
 
_Mephistopheles_ [_to Faust_]. How do you find the dainty creatures?
 
_Faust_. Disgusting as I ever chanced to see!
 
_Mephistopheles_. No! a discourse like this to me,
I own, is one of life's most pleasant features;
[_To the animals_.]
Say, cursed dolls, that sweat, there, toiling!
What are you twirling with the spoon?
 
_Animals_. A common beggar-soup we're boiling.
 
_Mephistopheles_. You'll have a run of custom soon.
 
THE HE-MONKEY
[_Comes along and fawns on_ MEPHISTOPHELES].
O fling up the dice,
Make me rich in a trice,
Turn fortune's wheel over!
My lot is right bad,
If money I had,
My wits would recover.
 
_Mephistopheles_. The monkey'd be as merry as a cricket,
Would somebody give him a lottery-ticket!
 
[_Meanwhile the young monkeys have been playing with a great
ball, which they roll backward and forward_.]
 
_The monkey_. 'The world's the ball;
See't rise and fall,
Its roll you follow;
Like glass it rings:
Both, brittle things!
Within 'tis hollow.
There it shines clear,
And brighter here,--
I live--by 'Pollo!--
Dear son, I pray,
Keep hands away!
_Thou_ shalt fall so!
'Tis made of clay,
Pots are, also.
 
_Mephistopheles_. What means the sieve?
 
_The monkey [takes it down_]. Wert thou a thief,
'Twould show the thief and shame him.
[_Runs to his mate and makes her look through_.]
Look through the sieve!
Discern'st thou the thief,
And darest not name him?
 
_Mephistopheles [approaching the fire_]. And what's this pot?
 
_The monkeys_. The dunce! I'll be shot!
He knows not the pot,
He knows not the kettle!
 
_Mephistopheles_. Impertinence! Hush!
 
_The monkey_. Here, take you the brush,
And sit on the settle!
[_He forces_ MEPHISTOPHELES _to sit down_.]
 
FAUST
[_who all this time has been standing before a looking-glass,
now approaching and now receding from it_].
 
What do I see? What heavenly face
Doth, in this magic glass, enchant me!
O love, in mercy, now, thy swiftest pinions grant me!
And bear me to her field of space!
Ah, if I seek to approach what doth so haunt me,
If from this spot I dare to stir,
Dimly as through a mist I gaze on her!--
The loveliest vision of a woman!
Such lovely woman can there be?
Must I in these reposing limbs naught human.
But of all heavens the finest essence see?
Was such a thing on earth seen ever?
 
_Mephistopheles_. Why, when you see a God six days in hard work spend,
And then cry bravo at the end,
Of course you look for something clever.
Look now thy fill; I have for thee
Just such a jewel, and will lead thee to her;
And happy, whose good fortune it shall be,
To bear her home, a prospered wooer!
 
[FAUST _keeps on looking into the mirror_. MEPHISTOPHELES
_stretching himself out on the settle and playing with the brush,
continues speaking_.]
Here sit I like a king upon his throne,
The sceptre in my hand,--I want the crown alone.
 
THE ANIMALS
[_who up to this time have been going through all sorts of queer antics
with each other, bring_ MEPHISTOPHELES _a crown with a loud cry_].
O do be so good,--
With sweat and with blood,
To take it and lime it;
[_They go about clumsily with the crown and break it into two pieces,
with which they jump round_.]
'Tis done now! We're free!
We speak and we see,
We hear and we rhyme it;
 
_Faust [facing the mirror_]. Woe's me! I've almost lost my wits.
 
_Mephistopheles [pointing to the animals_].
My head, too, I confess, is very near to spinning.
 
_The animals_. And then if it hits
And every thing fits,
We've thoughts for our winning.
 
_Faust [as before_]. Up to my heart the flame is flying!
Let us begone--there's danger near!
 
_Mephistopheles [in the former position_].
Well, this, at least, there's no denying,
That we have undissembled poets here.
 
[The kettle, which the she-monkey has hitherto left unmatched, begins to
run over; a great flame breaks out, which roars up the chimney. The_ WITCH
_comes riding down through the flame with a terrible outcry_.]
 
_Witch_. Ow! Ow! Ow! Ow!
The damned beast! The cursed sow!
Neglected the kettle, scorched the Frau!
The cursed crew!
[_Seeing_ FAUST _and_ MEPHISTOPHELES.]
And who are you?
And what d'ye do?
And what d'ye want?
And who sneaked in?
The fire-plague grim
Shall light on him
In every limb!
 
[_She makes a dive at the kettle with the skimmer and spatters flames
at _FAUST, MEPHISTOPHELES_, and the creatures. These last whimper_.]
 
MEPHISTOPHELES
[_inverting the brush which he holds in his hand, and striking
among the glasses and pots_].
 
In two! In two!
There lies the brew!
There lies the glass!
This joke must pass;
For time-beat, ass!
To thy melody, 'twill do.
[_While the_ WITCH _starts back full of wrath and horror.]
Skeleton! Scarcecrow! Spectre! Know'st thou me,
Thy lord and master? What prevents my dashing
Right in among thy cursed company,
Thyself and all thy monkey spirits smashing?
Has the red waistcoat thy respect no more?
Has the cock's-feather, too, escaped attention?
Hast never seen this face before?
My name, perchance, wouldst have me mention?
 
_The witch_. Pardon the rudeness, sir, in me!
But sure no cloven foot I see.
Nor find I your two ravens either.
 
_Mephistopheles_. I'll let thee off for this once so;
For a long while has passed, full well I know,
Since the last time we met together.
The culture, too, which licks the world to shape,
The devil himself cannot escape;
The phantom of the North men's thoughts have left behind them,
Horns, tail, and claws, where now d'ye find them?
And for the foot, with which dispense I nowise can,
'Twould with good circles hurt my standing;
And so I've worn, some years, like many a fine young man,
False calves to make me more commanding.
 
_The witch [dancing_]. O I shall lose my wits, I fear,
Do I, again, see Squire Satan here!
 
_Mephistopheles_. Woman, the name offends my ear!
 
_The witch_. Why so? What has it done to you?
 
_Mephistopheles_. It has long since to fable-books been banished;
But men are none the better for it; true,
The wicked _one_, but not the wicked _ones_, has vanished.
Herr Baron callst thou me, then all is right and good;
I am a cavalier, like others. Doubt me?
Doubt for a moment of my noble blood?
See here the family arms I bear about me!
[_He makes an indecent gesture.]
 
The witch [laughs immoderately_]. Ha! ha! full well I know you, sir!
You are the same old rogue you always were!
 
_Mephistopheles [to Faust_]. I pray you, carefully attend,
This is the way to deal with witches, friend.
 
_The witch_. Now, gentles, what shall I produce?
 
_Mephistopheles_. A right good glassful of the well-known juice!
And pray you, let it be the oldest;
Age makes it doubly strong for use.
 
_The witch_. Right gladly! Here I have a bottle,
From which, at times, I wet my throttle;
Which now, not in the slightest, stinks;
A glass to you I don't mind giving;
[_Softly_.]
But if this man, without preparing, drinks,
He has not, well you know, another hour for living.
 
_Mephistopheles_.
'Tis a good friend of mine, whom it shall straight cheer up;
Thy kitchen's best to give him don't delay thee.
Thy ring--thy spell, now, quick, I pray thee,
And give him then a good full cup.
 
[_The_ WITCH, _with strange gestures, draws a circle, and places singular
things in it; mean-while the glasses begin to ring, the kettle to sound
and make music. Finally, she brings a great book and places the monkeys in
the circle, whom she uses as a reading-desk and to hold the torches. She
beckons_ FAUST _to come to her_.]
 
_Faust [to Mephistopheles_].
Hold! what will come of this? These creatures,
These frantic gestures and distorted features,
And all the crazy, juggling fluff,
I've known and loathed it long enough!
 
_Mephistopheles_. Pugh! that is only done to smoke us;
Don't be so serious, my man!
She must, as Doctor, play her hocus-pocus
To make the dose work better, that's the plan.
[_He constrains_ FAUST _to step into the circle_.]
 
THE WITCH
[_beginning with great emphasis to declaim out of the book_]
 
Remember then!
Of One make Ten,
The Two let be,
Make even Three,
There's wealth for thee.
The Four pass o'er!
Of Five and Six,
(The witch so speaks,)
Make Seven and Eight,
The thing is straight:
And Nine is One
And Ten is none--
This is the witch's one-time-one![24]
 
_Faust_. The old hag talks like one delirious.
 
_Mephistopheles_. There's much more still, no less mysterious,
I know it well, the whole book sounds just so!
I've lost full many a year in poring o'er it,
For perfect contradiction, you must know,
A mystery stands, and fools and wise men bow before it,
The art is old and new, my son.
Men, in all times, by craft and terror,
With One and Three, and Three and One,
For truth have propagated error.
They've gone on gabbling so a thousand years;
Who on the fools would waste a minute?
Man generally thinks, if words he only hears,
Articulated noise must have some meaning in it.
 
_The witch [goes on_]. Deep wisdom's power
Has, to this hour,
From all the world been hidden!
Whoso thinks not,
To him 'tis brought,
To him it comes unbidden.
 
_Faust_. What nonsense is she talking here?
My heart is on the point of cracking.
In one great choir I seem to hear
A hundred thousand ninnies clacking.
 
_Mephistopheles_. Enough, enough, rare Sibyl, sing us
These runes no more, thy beverage bring us,
And quickly fill the goblet to the brim;
This drink may by my friend be safely taken:
Full many grades the man can reckon,
Many good swigs have entered him.
 
[_The_ WITCH, _with many ceremonies, pours the drink into a cup;
as she puts it to_ FAUST'S _lips, there rises a light flame_.]
 
_Mephistopheles_. Down with it! Gulp it down! 'Twill prove
All that thy heart's wild wants desire.
Thou, with the devil, hand and glove,[25]
And yet wilt be afraid of fire?
 
[_The_ WITCH _breaks the circle_; FAUST _steps out_.]
 
_Mephistopheles_. Now briskly forth! No rest for thee!
 
_The witch_. Much comfort may the drink afford you!
 
_Mephistopheles [to the witch_]. And any favor you may ask of me,
I'll gladly on Walpurgis' night accord you.
 
_The witch_. Here is a song, which if you sometimes sing,
'Twill stir up in your heart a special fire.
 
_Mephistopheles [to Faust_]. Only make haste; and even shouldst thou tire,
Still follow me; one must perspire,
That it may set his nerves all quivering.
I'll teach thee by and bye to prize a noble leisure,
And soon, too, shalt thou feel with hearty pleasure,
How busy Cupid stirs, and shakes his nimble wing.
 
_Faust_. But first one look in yonder glass, I pray thee!
Such beauty I no more may find!
 
_Mephistopheles_. Nay! in the flesh thine eyes shall soon display thee
The model of all woman-kind.
[_Softly_.]
Soon will, when once this drink shall heat thee,
In every girl a Helen meet thee!
 
 
 
 
A STREET.
 
FAUST. MARGARET [_passing over_].
 
_Faust_. My fair young lady, will it offend her
If I offer my arm and escort to lend her?
 
_Margaret_. Am neither lady, nor yet am fair!
Can find my way home without any one's care.
[_Disengages herself and exit_.]
 
_Faust_. By heavens, but then the child _is_ fair!
I've never seen the like, I swear.
So modest is she and so pure,
And somewhat saucy, too, to be sure.
The light of the cheek, the lip's red bloom,
I shall never forget to the day of doom!
How me cast down her lovely eyes,
Deep in my soul imprinted lies;
How she spoke up, so curt and tart,
Ah, that went right to my ravished heart!
[_Enter_ MEPHISTOPHELES.]
 
_Faust_. Hark, thou shalt find me a way to address her!
 
_Mephistopheles_. Which one?
 
_Faust_. She just went by.
 
_Mephistopheles_. What! She?
She came just now from her father confessor,
Who from all sins pronounced her free;
I stole behind her noiselessly,
'Tis an innocent thing, who, for nothing at all,
Must go to the confessional;
O'er such as she no power I hold!
 
_Faust_. But then she's over fourteen years old.
 
_Mephistopheles_. Thou speak'st exactly like Jack Rake,
Who every fair flower his own would make.
And thinks there can be no favor nor fame,
But one may straightway pluck the same.
But 'twill not always do, we see.
 
_Faust_. My worthy Master Gravity,
Let not a word of the Law be spoken!
One thing be clearly understood,--
Unless I clasp the sweet, young blood
This night in my arms--then, well and good:
When midnight strikes, our bond is broken.
 
_Mephistopheles_. Reflect on all that lies in the way!
I need a fortnight, at least, to a day,
For finding so much as a way to reach her.
 
_Faust_. Had I seven hours, to call my own,
Without the devil's aid, alone
I'd snare with ease so young a creature.
 
_Mephistopheles_. You talk quite Frenchman-like to-day;
But don't be vexed beyond all measure.
What boots it thus to snatch at pleasure?
'Tis not so great, by a long way,
As if you first, with tender twaddle,
And every sort of fiddle-faddle,
Your little doll should mould and knead,
As one in French romances may read.
 
_Faust_. My appetite needs no such spur.
 
_Mephistopheles_. Now, then, without a jest or slur,
I tell you, once for all, such speed
With the fair creature won't succeed.
Nothing will here by storm be taken;
We must perforce on intrigue reckon.
 
_Faust_. Get me some trinket the angel has blest!
Lead me to her chamber of rest!
Get me a 'kerchief from her neck,
A garter get me for love's sweet sake!
 
_Mephistopheles_. To prove to you my willingness
To aid and serve you in this distress;
You shall visit her chamber, by me attended,
Before the passing day is ended.
 
_Faust_. And see her, too? and have her?
 
_Mephistopheles_. Nay!
She will to a neighbor's have gone away.
Meanwhile alone by yourself you may,
There in her atmosphere, feast at leisure
And revel in dreams of future pleasure.
 
_Faust_. Shall we start at once?
 
_Mephistopheles_. 'Tis too early yet.
 
_Faust_. Some present to take her for me you must get.
 
[_Exit_.]
 
_Mephistopheles_. Presents already! Brave! He's on the right foundation!
Full many a noble place I know,
And treasure buried long ago;
Must make a bit of exploration.
 
[_Exit_.]
 
 
 
 
EVENING.
 
_A little cleanly Chamber_.
 
MARGARET [_braiding and tying up her hair_.]
I'd give a penny just to say
What gentleman that was to-day!
How very gallant he seemed to be,
He's of a noble family;
That I could read from his brow and bearing--
And he would not have otherwise been so daring.
[_Exit_.]
 
FAUST. MEPHISTOPHELES.
 
_Mephistopheles_. Come in, step softly, do not fear!
 
_Faust [after a pause_]. Leave me alone, I prithee, here!
 
_Mephistopheles [peering round_]. Not every maiden keeps so neat.
[_Exit_.]
 
_Faust [gazing round_]. Welcome this hallowed still retreat!
Where twilight weaves its magic glow.
Seize on my heart, love-longing, sad and sweet,
That on the dew of hope dost feed thy woe!
How breathes around the sense of stillness,
Of quiet, order, and content!
In all this poverty what fulness!
What blessedness within this prison pent!
[_He throws himself into a leathern chair by the bed_.]
Take me, too! as thou hast, in years long flown,
In joy and grief, so many a generation!
Ah me! how oft, on this ancestral throne,
Have troops of children climbed with exultation!
Perhaps, when Christmas brought the Holy Guest,
My love has here, in grateful veneration
The grandsire's withered hand with child-lips prest.
I feel, O maiden, circling me,
Thy spirit of grace and fulness hover,
Which daily like a mother teaches thee
The table-cloth to spread in snowy purity,
And even, with crinkled sand the floor to cover.
Dear, godlike hand! a touch of thine
Makes this low house a heavenly kingdom slime!
And here!
[_He lifts a bed-curtain_.]
What blissful awe my heart thrills through!
Here for long hours could I linger.
Here, Nature! in light dreams, thy airy finger
The inborn angel's features drew!
Here lay the child, when life's fresh heavings
Its tender bosom first made warm,
And here with pure, mysterious weavings
The spirit wrought its godlike form!
And thou! What brought thee here? what power
Stirs in my deepest soul this hour?
What wouldst thou here? What makes thy heart so sore?
Unhappy Faust! I know thee thus no more.
Breathe I a magic atmosphere?
The will to enjoy how strong I felt it,--
And in a dream of love am now all melted!
Are we the sport of every puff of air?
And if she suddenly should enter now,
How would she thy presumptuous folly humble!
Big John-o'dreams! ah, how wouldst thou
Sink at her feet, collapse and crumble!
 
_Mephistopheles_. Quick, now! She comes! I'm looking at her.
 
_Faust_. Away! Away! O cruel fate!
 
_Mephistopheles_. Here is a box of moderate weight;
I got it somewhere else--no matter!
Just shut it up, here, in the press,
I swear to you, 'twill turn her senses;
I meant the trifles, I confess,
To scale another fair one's fences.
True, child is child and play is play.
 
_Faust_. Shall I? I know not.
 
_Mephistopheles_. Why delay?
You mean perhaps to keep the bauble?
If so, I counsel you to spare
From idle passion hours so fair,
And me, henceforth, all further trouble.
I hope you are not avaricious!
I rub my hands, I scratch my head--
[_He places the casket in the press and locks it up again_.]
(Quick! Time we sped!)--
That the dear creature may be led
And moulded by your will and wishes;
And you stand here as glum,
As one at the door of the auditorium,
As if before your eyes you saw
In bodily shape, with breathless awe,
Metaphysics and physics, grim and gray!
Away!
[_Exit_.]
 
_Margaret [with a lamp_]. It seems so close, so sultry here.
[_She opens the window_.]
Yet it isn't so very warm out there,
I feel--I know not how--oh dear!
I wish my mother 'ld come home, I declare!
I feel a shudder all over me crawl--
I'm a silly, timid thing, that's all!
[_She begins to sing, while undressing_.]
There was a king in Thulè,
To whom, when near her grave,
The mistress he loved so truly
A golden goblet gave.
 
He cherished it as a lover,
He drained it, every bout;
His eyes with tears ran over,
As oft as he drank thereout.
 
And when he found himself dying,
His towns and cities he told;
Naught else to his heir denying
Save only the goblet of gold.
 
His knights he straightway gathers
And in the midst sate he,
In the banquet hall of the fathers
In the castle over the sea.
 
There stood th' old knight of liquor,
And drank the last life-glow,
Then flung the holy beaker
Into the flood below.
 
He saw it plunging, drinking
And sinking in the roar,
His eyes in death were sinking,
He never drank one drop more.
[_She opens the press, to put away her clothes,
and discovers the casket_.]
 
How in the world came this fine casket here?
I locked the press, I'm very clear.
I wonder what's inside! Dear me! it's very queer!
Perhaps 'twas brought here as a pawn,
In place of something mother lent.
Here is a little key hung on,
A single peep I shan't repent!
What's here? Good gracious! only see!
I never saw the like in my born days!
On some chief festival such finery
Might on some noble lady blaze.
How would this chain become my neck!
Whose may this splendor be, so lonely?
[_She arrays herself in it, and steps before the glass_.]
Could I but claim the ear-rings only!
A different figure one would make.
What's beauty worth to thee, young blood!
May all be very well and good;
What then? 'Tis half for pity's sake
They praise your pretty features.
Each burns for gold,
All turns on gold,--
Alas for us! poor creatures!
 
 
 
 
PROMENADE.
 
 
FAUST [_going up and down in thought_.] MEPHISTOPHELES _to him_.
 
_Mephistopheles_. By all that ever was jilted! By all the infernal fires!
I wish I knew something worse, to curse as my heart desires!
 
_Faust_. What griping pain has hold of thee?
Such grins ne'er saw I in the worst stage-ranter!
 
_Mephistopheles_. Oh, to the devil I'd give myself instanter,
If I were not already he!
 
_Faust_. Some pin's loose in your head, old fellow!
That fits you, like a madman thus to bellow!
 
_Mephistopheles_. Just think, the pretty toy we got for Peg,
A priest has hooked, the cursed plague I--
The thing came under the eye of the mother,
And caused her a dreadful internal pother:
The woman's scent is fine and strong;
Snuffles over her prayer-book all day long,
And knows, by the smell of an article, plain,
Whether the thing is holy or profane;
And as to the box she was soon aware
There could not be much blessing there.
"My child," she cried, "unrighteous gains
Ensnare the soul, dry up the veins.
We'll consecrate it to God's mother,
She'll give us some heavenly manna or other!"
Little Margaret made a wry face; "I see
'Tis, after all, a gift horse," said she;
"And sure, no godless one is he
Who brought it here so handsomely."
The mother sent for a priest (they're cunning);
Who scarce had found what game was running,
When he rolled his greedy eyes like a lizard,
And, "all is rightly disposed," said he,
"Who conquers wins, for a certainty.
The church has of old a famous gizzard,
She calls it little whole lands to devour,
Yet never a surfeit got to this hour;
The church alone, dear ladies; _sans_ question,
Can give unrighteous gains digestion."
 
_Faust_. That is a general pratice, too,
Common alike with king and Jew.
 
_Mephistopheles_. Then pocketed bracelets and chains and rings
As if they were mushrooms or some such things,
With no more thanks, (the greedy-guts!)
Than if it had been a basket of nuts,
Promised them all sorts of heavenly pay--
And greatly edified were they.
 
_Faust_. And Margery?
 
_Mephistopheles_. Sits there in distress,
And what to do she cannot guess,
The jewels her daily and nightly thought,
And he still more by whom they were brought.
 
_Faust._ My heart is troubled for my pet.
Get her at once another set!
The first were no great things in their way.
 
_Mephistopheles._ O yes, my gentleman finds all child's play!
 
_Faust._ And what I wish, that mind and do!
Stick closely to her neighbor, too.
Don't be a devil soft as pap,
And fetch me some new jewels, old chap!
 
_Mephistopheles._ Yes, gracious Sir, I will with pleasure.
[_Exit_ FAUST.]
Such love-sick fools will puff away
Sun, moon, and stars, and all in the azure,
To please a maiden's whimsies, any day.
[_Exit._]
 
 
 
 
THE NEIGHBOR'S HOUSE.
 
 
MARTHA [_alone]._
My dear good man--whom God forgive!
He has not treated me well, as I live!
Right off into the world he's gone
And left me on the straw alone.
I never did vex him, I say it sincerely,
I always loved him, God knows how dearly.
[_She weeps_.]
Perhaps he's dead!--O cruel fate!--
If I only had a certificate!
 
_Enter_ MARGARET.
Dame Martha!
 
_Martha_. What now, Margery?
 
_Margaret_. I scarce can keep my knees from sinking!
Within my press, again, not thinking,
I find a box of ebony,
With things--can't tell how grand they are,--
More splendid than the first by far.
 
_Martha_. You must not tell it to your mother,
She'd serve it as she did the other.
 
_Margaret_. Ah, only look! Behold and see!
 
_Martha [puts them on her_]. Fortunate thing! I envy thee!
 
_Margaret._ Alas, in the street or at church I never
Could be seen on any account whatever.
 
_Martha._ Come here as often as you've leisure,
And prink yourself quite privately;
Before the looking-glass walk up and down at pleasure,
Fine times for both us 'twill be;
Then, on occasions, say at some great feast,
Can show them to the world, one at a time, at least.
A chain, and then an ear-pearl comes to view;
Your mother may not see, we'll make some pretext, too.
 
_Margaret._ Who could have brought both caskets in succession?
There's something here for just suspicion!
[_A knock._ ]
Ah, God! If that's my mother--then!
 
_Martha_ [_peeping through the blind_].
'Tis a strange gentleman--come in!
 
[_Enter_ MEPHISTOPHELES.]
Must, ladies, on your kindness reckon
To excuse the freedom I have taken;
[_Steps back with profound respect at seeing_ MARGARET.]
I would for Dame Martha Schwerdtlein inquire!
 
_Martha._ I'm she, what, sir, is your desire?
 
_Mephistopheles_ [_aside to her_]. I know your face, for now 'twill do;
A distinguished lady is visiting you.
For a call so abrupt be pardon meted,
This afternoon it shall be repeated.
 
_Martha [aloud]._ For all the world, think, child! my sakes!
The gentleman you for a lady takes.
 
_Margaret_. Ah, God! I am a poor young blood;
The gentleman is quite too good;
The jewels and trinkets are none of my own.
 
_Mephistopheles_. Ah, 'tis not the jewels and trinkets alone;
Her look is so piercing, so _distinguè_!
How glad I am to be suffered to stay.
 
_Martha_. What bring you, sir? I long to hear--
 
_Mephistopheles_. Would I'd a happier tale for your ear!
I hope you'll forgive me this one for repeating:
Your husband is dead and sends you a greeting.
 
_Martha_. Is dead? the faithful heart! Woe! Woe!
My husband dead! I, too, shall go!
 
_Margaret_. Ah, dearest Dame, despair not thou!
 
_Mephistopheles_ Then, hear the mournful story now!
 
_Margaret_. Ah, keep me free from love forever,
I should never survive such a loss, no, never!
 
_Mephistopheles_. Joy and woe, woe and joy, must have each other.
 
_Martha_. Describe his closing hours to me!
 
_Mephistopheles_. In Padua lies our departed brother,
In the churchyard of St. Anthony,
In a cool and quiet bed lies sleeping,
In a sacred spot's eternal keeping.
 
_Martha_. And this was all you had to bring me?
 
_Mephistopheles_. All but one weighty, grave request!
"Bid her, when I am dead, three hundred masses sing me!"
With this I have made a clean pocket and breast.
 
_Martha_. What! not a medal, pin nor stone?
Such as, for memory's sake, no journeyman will lack,
Saved in the bottom of his sack,
And sooner would hunger, be a pauper--
 
_Mephistopheles_. Madam, your case is hard, I own!
But blame him not, he squandered ne'er a copper.
He too bewailed his faults with penance sore,
Ay, and his wretched luck bemoaned a great deal more.
 
_Margaret_. Alas! that mortals so unhappy prove!
I surely will for him pray many a requiem duly.
 
_Mephistopheles_. You're worthy of a spouse this moment; truly
You are a child a man might love.
 
_Margaret_. It's not yet time for that, ah no!
 
_Mephistopheles_. If not a husband, say, meanwhile a beau.
It is a choice and heavenly blessing,
Such a dear thing to one's bosom pressing.
 
_Margaret_. With us the custom is not so.
 
_Mephistopheles_. Custom or not! It happens, though.
 
_Martha_. Tell on!
 
_Mephistopheles_. I slood beside his bed, as he lay dying,
Better than dung it was somewhat,--
Half-rotten straw; but then, he died as Christian ought,
And found an unpaid score, on Heaven's account-book lying.
"How must I hate myself," he cried, "inhuman!
So to forsake my business and my woman!
Oh! the remembrance murders me!
Would she might still forgive me this side heaven!"
 
_Martha_ [_weeping_]. The dear good man! he has been long forgiven.
 
_Mephistopheles_. "But God knows, I was less to blame than she."
 
_Martha_. A lie! And at death's door! abominable!
 
_Mephistopheles_. If I to judge of men half-way am able,
He surely fibbed while passing hence.
"Ways to kill time, (he said)--be sure, I did not need them;
First to get children--and then bread to feed them,
And bread, too, in the widest sense,
And even to eat my bit in peace could not be thought on."
 
_Martha_. Has he all faithfulness, all love, so far forgotten,
The drudgery by day and night!
 
_Mephistopheles_. Not so, he thought of you with all his might.
He said: "When I from Malta went away,
For wife and children my warm prayers ascended;
And Heaven so far our cause befriended,
Our ship a Turkish cruiser took one day,
Which for the mighty Sultan bore a treasure.
Then valor got its well-earned pay,
And I too, who received but my just measure,
A goodly portion bore away."
 
_Martha_. How? Where? And he has left it somewhere buried?
 
_Mephistopheles_. Who knows which way by the four winds 'twas carried?
He chanced to take a pretty damsel's eye,
As, a strange sailor, he through Naples jaunted;
All that she did for him so tenderly,
E'en to his blessed end the poor man haunted.
 
_Martha_. The scamp! his children thus to plunder!
And could not all his troubles sore
Arrest his vile career, I wonder?
 
_Mephistopheles_. But mark! his death wipes off the score.
Were I in your place now, good lady;
One year I'd mourn him piously
And look about, meanwhiles, for a new flame already.
 
_Martha_. Ah, God! another such as he
I may not find with ease on this side heaven!
Few such kind fools as this dear spouse of mine.
Only to roving he was too much given,
And foreign women and foreign wine,
And that accursed game of dice.
 
_Mephistopheles_. Mere trifles these; you need not heed 'em,
If he, on his part, not o'er-nice,
Winked at, in you, an occasional freedom.
I swear, on that condition, too,
I would, myself, 'change rings with you!
 
_Martha_. The gentleman is pleased to jest now!
 
_Mephistopheles [aside_]. I see it's now high time I stirred!
She'd take the very devil at his word.
[_To_ MARGERY.]
How is it with your heart, my best, now?
 
_Margaret_. What means the gentleman?
 
_Mephistopheles. [aside_]. Thou innocent young heart!
[_Aloud_.]
Ladies, farewell!
 
_Margaret_. Farewell!
 
_Martha_. But quick, before we part!--
I'd like some witness, vouching truly
Where, how and when my love died and was buried duly.
I've always paid to order great attention,
Would of his death read some newspaper mention.
 
_Mephistopheles_. Ay, my dear lady, in the mouths of two
Good witnesses each word is true;
I've a friend, a fine fellow, who, when you desire,
Will render on oath what you require.
I'll bring him here.
 
_Martha_. O pray, sir, do!
 
_Mephistopheles_. And this young lady 'll be there too?
Fine boy! has travelled everywhere,
And all politeness to the fair.
 
_Margaret_. Before him shame my face must cover.
 
_Mephistopheles_. Before no king the wide world over!
 
_Martha_. Behind the house, in my garden, at leisure,
We'll wait this eve the gentlemen's pleasure.
 
 
 
 
STREET.
 
FAUST. MEPHISTOPHELES.
 
_Faust_. How now? What progress? Will 't come right?
 
_Mephistopheles_. Ha, bravo? So you're all on fire?
Full soon you'll see whom you desire.
In neighbor Martha's grounds we are to meet tonight.
That woman's one of nature's picking
For pandering and gipsy-tricking!
 
_Faust_. So far, so good!
 
_Mephistopheles_. But one thing we must do.
 
_Faust_. Well, one good turn deserves another, true.
 
_Mephistopheles_. We simply make a solemn deposition
That her lord's bones are laid in good condition
In holy ground at Padua, hid from view.
 
_Faust_. That's wise! But then we first must make the journey thither?
 
_Mephistopheles. Sancta simplicitas_! no need of such to-do;
Just swear, and ask not why or whether.
 
_Faust_. If that's the best you have, the plan's not worth a feather.
 
_Mephistopheles_. O holy man! now that's just you!
In all thy life hast never, to this hour,
To give false witness taken pains?
Have you of God, the world, and all that it contains,
Of man, and all that stirs within his heart and brains,
Not given definitions with great power,
Unscrupulous breast, unblushing brow?
And if you search the matter clearly,
Knew you as much thereof, to speak sincerely,
As of Herr Schwerdtlein's death? Confess it now!
 
_Faust_. Thou always wast a sophist and a liar.
 
_Mephistopheles_. Ay, if one did not look a little nigher.
For will you not, in honor, to-morrow
Befool poor Margery to her sorrow,
And all the oaths of true love borrow?
 
_Faust_. And from the heart, too.
 
_Mephistopheles_. Well and fair!
Then there'll be talk of truth unending,
Of love o'ermastering, all transcending--
Will every word be heart-born there?
 
_Faust_. Enough! It will!--If, for the passion
That fills and thrills my being's frame,
I find no name, no fit expression,
Then, through the world, with all my senses, ranging,
Seek what most strongly speaks the unchanging.
And call this glow, within me burning,
Infinite--endless--endless yearning,
Is that a devilish lying game?
 
_Mephistopheles_. I'm right, nathless!
 
_Faust_. Now, hark to me--
This once, I pray, and spare my lungs, old fellow--
Whoever _will_ be right, and has a tongue to bellow,
Is sure to be.
But come, enough of swaggering, let's be quit,
For thou art right, because I must submit.
 
 
 
 
GARDEN.
 
MARGARET _on_ FAUST'S _arm_. MARTHA _with_ MEPHISTOPHELES.
[_Promenading up and down_.]
 
_Margaret_. The gentleman but makes me more confused
 
With all his condescending goodness.
Men who have travelled wide are used
To bear with much from dread of rudeness;
I know too well, a man of so much mind
In my poor talk can little pleasure find.
 
_Faust_. One look from thee, one word, delights me more
Than this world's wisdom o'er and o'er.
[_Kisses her hand_.]
 
_Margaret_. Don't take that trouble, sir! How could you bear to kiss it?
A hand so ugly, coarse, and rough!
How much I've had to do! must I confess it--
Mother is more than close enough.
[_They pass on_.]
 
_Martha_. And you, sir, are you always travelling so?
 
_Mephistopheles_. Alas, that business forces us to do it!
With what regret from many a place we go,
Though tenderest bonds may bind us to it!
 
_Martha_. 'Twill do in youth's tumultuous maze
To wander round the world, a careless rover;
But soon will come the evil days,
And then, a lone dry stick, on the grave's brink to hover,
For that nobody ever prays.
 
_Mephistopheles_. The distant prospect shakes my reason.
 
_Martha_. Then, worthy sir, bethink yourself in season.
[_They pass on_.]
 
_Margaret_. Yes, out of sight and out of mind!
Politeness you find no hard matter;
But you have friends in plenty, better
Than I, more sensible, more refined.
 
_Faust_. Dear girl, what one calls sensible on earth,
Is often vanity and nonsense.
 
_Margaret_. How?
 
_Faust_. Ah, that the pure and simple never know
Aught of themselves and all their holy worth!
That meekness, lowliness, the highest measure
Of gifts by nature lavished, full and free--
 
_Margaret_. One little moment, only, think of me,
I shall to think of you have ample time and leisure.
 
_Faust_. You're, may be, much alone?
 
_Margaret_. Our household is but small, I own,
And yet needs care, if truth were known.
We have no maid; so I attend to cooking, sweeping,
Knit, sew, do every thing, in fact;
And mother, in all branches of housekeeping,
Is so exact!
Not that she need be tied so very closely down;
We might stand higher than some others, rather;
A nice estate was left us by my father,
A house and garden not far out of town.
Yet, after all, my life runs pretty quiet;
My brother is a soldier,
My little sister's dead;
With the dear child indeed a wearing life I led;
And yet with all its plagues again would gladly try it,
The child was such a pet.
 
_Faust_. An angel, if like thee!
 
_Margaret_. I reared her and she heartily loved me.
She and my father never saw each other,
He died before her birth, and mother
Was given up, so low she lay,
But me, by slow degrees, recovered, day by day.
Of course she now, long time so feeble,
To nurse the poor little worm was unable,
And so I reared it all alone,
With milk and water; 'twas my own.
Upon my bosom all day long
It smiled and sprawled and so grew strong.
 
_Faust_. Ah! thou hast truly known joy's fairest flower.
 
_Margaret_. But no less truly many a heavy hour.
The wee thing's cradle stood at night
Close to my bed; did the least thing awake her,
My sleep took flight;
'Twas now to nurse her, now in bed to take her,
Then, if she was not still, to rise,
Walk up and down the room, and dance away her cries,
And at the wash-tub stand, when morning streaked the skies;
Then came the marketing and kitchen-tending,
Day in, day out, work never-ending.
One cannot always, sir, good temper keep;
But then it sweetens food and sweetens sleep.
[_They pass on_.]
 
_Martha_. But the poor women suffer, you must own:
A bachelor is hard of reformation.
 
_Mephistopheles_. Madam, it rests with such as you, alone,
To help me mend my situation.
 
_Martha_. Speak plainly, sir, has none your fancy taken?
Has none made out a tender flame to waken?
 
_Mephistopheles_. The proverb says: A man's own hearth,
And a brave wife, all gold and pearls are worth.
 
_Martha_. I mean, has ne'er your heart been smitten slightly?
 
_Mephistopheles_. I have, on every hand, been entertained politely.
 
_Martha_. Have you not felt, I mean, a serious intention?
 
_Mephistopheles_.
Jesting with women, that's a thing one ne'er should mention.
 
_Martha_. Ah, you misunderstand!
 
_Mephistopheles_. It grieves me that I should!
But this I understand--that you are good.
[_They pass on_.]
 
_Faust_. So then, my little angel recognized me,
As I came through the garden gate?
 
_Margaret_. Did not my downcast eyes show you surprised me?
 
_Faust_. And thou forgav'st that liberty, of late?
That impudence of mine, so daring,
As thou wast home from church repairing?
 
_Margaret_. I was confused, the like was new to me;
No one could say a word to my dishonor.
Ah, thought I, has he, haply, in thy manner
Seen any boldness--impropriety?
It seemed as if the feeling seized him,
That he might treat this girl just as it pleased him.
Let me confess! I knew not from what cause,
Some flight relentings here began to threaten danger;
I know, right angry with myself I was,
That I could not be angrier with the stranger.
 
_Faust_. Sweet darling!
 
_Margaret_. Let me once!
 
[_She plucks a china-aster and picks off the leaves one after another_.]
 
_Faust_. What's that for? A bouquet?
 
_Margaret_. No, just for sport.
 
_Faust_. How?
 
_Margaret_. Go! you'll laugh at me; away!
[_She picks and murmurs to herself_.]
 
_Faust_. What murmurest thou?
 
_Margaret [half aloud_]. He loves me--loves me not.
 
_Faust_. Sweet face! from heaven that look was caught!
 
_Margaret [goes on_]. Loves me--not--loves me--not--
[_picking off the last leaf with tender joy_]
He loves me!
 
_Faust_. Yes, my child! And be this floral word
An oracle to thee. He loves thee!
Knowest thou all it mean? He loves thee!
[_Clasping both her hands_.]
 
_Margaret_. What thrill is this!
 
_Faust_. O, shudder not! This look of mine.
This pressure of the hand shall tell thee
What cannot be expressed:
Give thyself up at once and feel a rapture,
An ecstasy never to end!
Never!--It's end were nothing but blank despair.
No, unending! unending!
 
[MARGARET _presses his hands, extricates herself, and runs away.
He stands a moment in thought, then follows her_].
 
_Martha [coming_]. The night falls fast.
 
_Mephistopheles_. Ay, and we must away.
 
_Martha_. If it were not for one vexation,
I would insist upon your longer stay.
Nobody seems to have no occupation,
No care nor labor,
Except to play the spy upon his neighbor;
And one becomes town-talk, do whatsoe'er they may.
But where's our pair of doves?
 
_Mephistopheles_. Flown up the alley yonder.
Light summer-birds!
 
_Martha_. He seems attached to her.
 
_Mephistopheles_. No wonder.
And she to him. So goes the world, they say.
 
 
 
 
A SUMMER-HOUSE.
 
MARGARET [_darts in, hides behind the door, presses the tip of
her finger to her lips, and peeps through the crack_].
 
_Margaret_. He comes!
 
_Enter_ FAUST.
 
_Faust_. Ah rogue, how sly thou art!
I've caught thee!
[_Kisses her_.]
 
_Margaret [embracing him and returning the kiss_].
Dear good man! I love thee from my heart!
 
[MEPHISTOPHELES _knocks_.]
 
_Faust [stamping_]. Who's there?
 
_Mephistopheles_. A friend!
 
_Faust_. A beast!
 
_Mephistopheles_. Time flies, I don't offend you?
 
_Martha [entering_]. Yes, sir, 'tis growing late.
 
_Faust_. May I not now attend you?
 
_Margaret_. Mother would--Fare thee well!
 
_Faust_. And must I leave thee then? Farewell!
 
_Martha_. Adé!
 
_Margaret_. Till, soon, we meet again!
 
[_Exeunt_ FAUST _and_ MEPHISTOPHELES.]
 
_Margaret_. Good heavens! what such a man's one brain
Can in itself alone contain!
I blush my rudeness to confess,
And answer all he says with yes.
Am a poor, ignorant child, don't see
What he can possibly find in me.
 
[_Exit_.]
 
 
 
 
WOODS AND CAVERN.
 
_Faust_ [_alone_]. Spirit sublime, thou gav'st me, gav'st me all
For which I prayed. Thou didst not lift in vain
Thy face upon me in a flame of fire.
Gav'st me majestic nature for a realm,
The power to feel, enjoy her. Not alone
A freezing, formal visit didst thou grant;
Deep down into her breast invitedst me
To look, as if she were a bosom-friend.
The series of animated things
Thou bidst pass by me, teaching me to know
My brothers in the waters, woods, and air.
And when the storm-swept forest creaks and groans,
The giant pine-tree crashes, rending off
The neighboring boughs and limbs, and with deep roar
The thundering mountain echoes to its fall,
To a safe cavern then thou leadest me,
Showst me myself; and my own bosom's deep
Mysterious wonders open on my view.
And when before my sight the moon comes up
With soft effulgence; from the walls of rock,
From the damp thicket, slowly float around
The silvery shadows of a world gone by,
And temper meditation's sterner joy.
O! nothing perfect is vouchsafed to man:
I feel it now! Attendant on this bliss,
Which brings me ever nearer to the Gods,
Thou gav'st me the companion, whom I now
No more can spare, though cold and insolent;
He makes me hate, despise myself, and turns
Thy gifts to nothing with a word--a breath.
He kindles up a wild-fire in my breast,
Of restless longing for that lovely form.
Thus from desire I hurry to enjoyment,
And in enjoyment languish for desire.
 
_Enter_ MEPHISTOPHELES.
 
_Mephistopheles_. Will not this life have tired you by and bye?
I wonder it so long delights you?
'Tis well enough for once the thing to try;
Then off to where a new invites you!
 
_Faust_. Would thou hadst something else to do,
That thus to spoil my joy thou burnest.
 
_Mephistopheles_. Well! well! I'll leave thee, gladly too!--
Thou dar'st not tell me that in earnest!
'Twere no great loss, a fellow such as you,
So crazy, snappish, and uncivil.
One has, all day, his hands full, and more too;
To worm out from him what he'd have one do,
Or not do, puzzles e'en the very devil.
 
_Faust_. Now, that I like! That's just the tone!
Wants thanks for boring me till I'm half dead!
 
_Mephistopheles_. Poor son of earth, if left alone,
What sort of life wouldst thou have led?
How oft, by methods all my own,
I've chased the cobweb fancies from thy head!
And but for me, to parts unknown
Thou from this earth hadst long since fled.
What dost thou here through cave and crevice groping?
Why like a hornèd owl sit moping?
And why from dripping stone, damp moss, and rotten wood
Here, like a toad, suck in thy food?
Delicious pastime! Ah, I see,
Somewhat of Doctor sticks to thee.
 
_Faust_. What new life-power it gives me, canst thou guess--
This conversation with the wilderness?
Ay, couldst thou dream how sweet the employment,
Thou wouldst be devil enough to grudge me my enjoyment.
 
_Mephistopheles_. Ay, joy from super-earthly fountains!
By night and day to lie upon the mountains,
To clasp in ecstasy both earth and heaven,
Swelled to a deity by fancy's leaven,
Pierce, like a nervous thrill, earth's very marrow,
Feel the whole six days' work for thee too narrow,
To enjoy, I know not what, in blest elation,
Then with thy lavish love o'erflow the whole creation.
Below thy sight the mortal cast,
And to the glorious vision give at last--
[_with a gesture_]
I must not say what termination!
 
_Faust_. Shame on thee!
 
_Mephistopheles_. This displeases thee; well, surely,
Thou hast a right to say "for shame" demurely.
One must not mention that to chaste ears--never,
Which chaste hearts cannot do without, however.
And, in one word, I grudge you not the pleasure
Of lying to yourself in moderate measure;
But 'twill not hold out long, I know;
Already thou art fast recoiling,
And soon, at this rate, wilt be boiling
With madness or despair and woe.
Enough of this! Thy sweetheart sits there lonely,
And all to her is close and drear.
Her thoughts are on thy image only,
She holds thee, past all utterance, dear.
At first thy passion came bounding and rushing
Like a brooklet o'erflowing with melted snow and rain;
Into her heart thou hast poured it gushing:
And now thy brooklet's dry again.
Methinks, thy woodland throne resigning,
'Twould better suit so great a lord
The poor young monkey to reward
For all the love with which she's pining.
She finds the time dismally long;
Stands at the window, sees the clouds on high
Over the old town-wall go by.
"Were I a little bird!"[26] so runneth her song
All the day, half the night long.
At times she'll be laughing, seldom smile,
At times wept-out she'll seem,
Then again tranquil, you'd deem,--
Lovesick all the while.
 
_Faust_. Viper! Viper!
 
_Mephistopheles_ [_aside_]. Ay! and the prey grows riper!
 
_Faust_. Reprobate! take thee far behind me!
No more that lovely woman name!
Bid not desire for her sweet person flame
Through each half-maddened sense, again to blind me!
 
_Mephistopheles_. What then's to do? She fancies thou hast flown,
And more than half she's right, I own.
 
_Faust_. I'm near her, and, though far away, my word,
I'd not forget her, lose her; never fear it!
I envy e'en the body of the Lord,
Oft as those precious lips of hers draw near it.
 
_Mephistopheles_. No doubt; and oft my envious thought reposes
On the twin-pair that feed among the roses.
 
_Faust_. Out, pimp!
 
_Mephistopheles_. Well done! Your jeers I find fair game for laughter.
The God, who made both lad and lass,
Unwilling for a bungling hand to pass,
Made opportunity right after.
But come! fine cause for lamentation!
Her chamber is your destination,
And not the grave, I guess.
 
_Faust_. What are the joys of heaven while her fond arms enfold me?
O let her kindling bosom hold me!
Feel I not always her distress?
The houseless am I not? the unbefriended?
The monster without aim or rest?
That, like a cataract, from rock to rock descended
To the abyss, with maddening greed possest:
She, on its brink, with childlike thoughts and lowly,--
Perched on the little Alpine field her cot,--
This narrow world, so still and holy
Ensphering, like a heaven, her lot.
And I, God's hatred daring,
Could not be content
The rocks all headlong bearing,
By me to ruins rent,--
Her, yea her peace, must I o'erwhelm and bury!
This victim, hell, to thee was necessary!
Help me, thou fiend, the pang soon ending!
What must be, let it quickly be!
And let her fate upon my head descending,
Crush, at one blow, both her and me.
 
_Mephistopheles_. Ha! how it seethes again and glows!
Go in and comfort her, thou dunce!
Where such a dolt no outlet sees or knows,
He thinks he's reached the end at once.
None but the brave deserve the fair!
Thou _hast_ had devil enough to make a decent show of.
For all the world a devil in despair
Is just the insipidest thing I know of.
 
 
 
 
MARGERY'S ROOM.
 
MARGERY [_at the spinning-wheel alone_].
My heart is heavy,
My peace is o'er;
I never--ah! never--
Shall find it more.
While him I crave,
Each place is the grave,
The world is all
Turned into gall.
My wretched brain
Has lost its wits,
My wretched sense
Is all in bits.
My heart is heavy,
My peace is o'er;
I never--ah! never--
Shall find it more.
Him only to greet, I
The street look down,
Him only to meet, I
Roam through town.
His lofty step,
His noble height,
His smile of sweetness,
His eye of might,
His words of magic,
Breathing bliss,
His hand's warm pressure
And ah! his kiss.
My heart is heavy,
My peace is o'er,
I never--ah! never--
Shall find it more.
My bosom yearns
To behold him again.
Ah, could I find him
That best of men!
I'd tell him then
How I did miss him,
And kiss him
As much as I could,
Die on his kisses
I surely should!
 
 
 
 
MARTHA'S GARDEN.
 
MARGARET. FAUST.
 
_Margaret_. Promise me, Henry.
 
_Faust_. What I can.
 
_Margaret_. How is it now with thy religion, say?
I know thou art a dear good man,
But fear thy thoughts do not run much that way.
 
_Faust_. Leave that, my child! Enough, thou hast my heart;
For those I love with life I'd freely part;
I would not harm a soul, nor of its faith bereave it.
 
_Margaret_. That's wrong, there's one true faith--one must believe it?
 
_Faust_. Must one?
 
_Margaret_. Ah, could I influence thee, dearest!
The holy sacraments thou scarce reverest.
 
_Faust_. I honor them.
 
_Margaret_. But yet without desire.
Of mass and confession both thou'st long begun to tire.
Believest thou in God?
 
_Faust_. My. darling, who engages
To say, I do believe in God?
The question put to priests or sages:
Their answer seems as if it sought
To mock the asker.
 
_Margaret_. Then believ'st thou not?
 
_Faust_. Sweet face, do not misunderstand my thought!
Who dares express him?
And who confess him,
Saying, I do believe?
A man's heart bearing,
What man has the daring
To say: I acknowledge him not?
The All-enfolder,
The All-upholder,
Enfolds, upholds He not
Thee, me, Himself?
Upsprings not Heaven's blue arch high o'er thee?
Underneath thee does not earth stand fast?
See'st thou not, nightly climbing,
Tenderly glancing eternal stars?
Am I not gazing eye to eye on thee?
Through brain and bosom
Throngs not all life to thee,
Weaving in everlasting mystery
Obscurely, clearly, on all sides of thee?
Fill with it, to its utmost stretch, thy breast,
And in the consciousness when thou art wholly blest,
Then call it what thou wilt,
Joy! Heart! Love! God!
I have no name to give it!
All comes at last to feeling;
Name is but sound and smoke,
Beclouding Heaven's warm glow.
 
_Margaret_. That is all fine and good, I know;
And just as the priest has often spoke,
Only with somewhat different phrases.
 
_Faust_. All hearts, too, in all places,
Wherever Heaven pours down the day's broad blessing,
Each in its way the truth is confessing;
And why not I in mine, too?
 
_Margaret_. Well, all have a way that they incline to,
But still there is something wrong with thee;
Thou hast no Christianity.
 
_Faust_. Dear child!
 
_Margaret_. It long has troubled me
That thou shouldst keep such company.
 
_Faust_. How so?
 
_Margaret_. The man whom thou for crony hast,
Is one whom I with all my soul detest.
Nothing in all my life has ever
Stirred up in my heart such a deep disfavor
As the ugly face that man has got.
 
_Faust_. Sweet plaything; fear him not!
 
_Margaret_. His presence stirs my blood, I own.
I can love almost all men I've ever known;
But much as thy presence with pleasure thrills me,
That man with a secret horror fills me.
And then for a knave I've suspected him long!
God pardon me, if I do him wrong!
 
_Faust_. To make up a world such odd sticks are needed.
 
_Margaret_. Shouldn't like to live in the house where he did!
Whenever I see him coming in,
He always wears such a mocking grin.
Half cold, half grim;
One sees, that naught has interest for him;
'Tis writ on his brow and can't be mistaken,
No soul in him can love awaken.
I feel in thy arms so happy, so free,
I yield myself up so blissfully,
He comes, and all in me is closed and frozen now.
 
_Faust_. Ah, thou mistrustful angel, thou!
 
_Margaret_. This weighs on me so sore,
That when we meet, and he is by me,
I feel, as if I loved thee now no more.
Nor could I ever pray, if he were nigh me,
That eats the very heart in me;
Henry, it must be so with thee.
 
_Faust_. 'Tis an antipathy of thine!
 
_Margaret_. Farewell!
 
_Faust_. Ah, can I ne'er recline
One little hour upon thy bosom, pressing
My heart to thine and all my soul confessing?
 
_Margaret_. Ah, if my chamber were alone,
This night the bolt should give thee free admission;
But mother wakes at every tone,
And if she had the least suspicion,
Heavens! I should die upon the spot!
 
_Faust_. Thou angel, need of that there's not.
Here is a flask! Three drops alone
Mix with her drink, and nature
Into a deep and pleasant sleep is thrown.
 
_Margaret_. Refuse thee, what can I, poor creature?
I hope, of course, it will not harm her!
 
_Faust_. Would I advise it then, my charmer?
 
_Margaret_. Best man, when thou dost look at me,
I know not what, moves me to do thy will;
I have already done so much for thee,
Scarce any thing seems left me to fulfil.
[_Exit_.]
 
Enter_ MEPHISTOPHELES.
 
_Mephtftopheles_. The monkey! is she gone?
 
_Faust_. Hast played the spy again?
 
_Mephistopheles_. I overheard it all quite fully.
The Doctor has been well catechized then?
Hope it will sit well on him truly.
The maidens won't rest till they know if the men
Believe as good old custom bids them do.
They think: if there he yields, he'll follow our will too.
 
_Faust_. Monster, thou wilt not, canst not see,
How this true soul that loves so dearly,
Yet hugs, at every cost,
The faith which she
Counts Heaven itself, is horror-struck sincerely
To think of giving up her dearest man for lost.
 
_Mephistopheles_. Thou supersensual, sensual wooer,
A girl by the nose is leading thee.
 
_Faust_. Abortion vile of fire and sewer!
 
_Mephistopheles_. In physiognomy, too, her skill is masterly.
When I am near she feels she knows not how,
My little mask some secret meaning shows;
She thinks, I'm certainly a genius, now,
Perhaps the very devil--who knows?
To-night then?--
 
_Faust_. Well, what's that to you?
 
_Mephistopheles_. I find my pleasure in it, too!
 
 
 
 
AT THE WELL.
 
MARGERY _and_ LIZZY _with Pitchers._
 
_Lizzy_. Hast heard no news of Barbara to-day?
 
_Margery_. No, not a word. I've not been out much lately.
 
_Lizzy_. It came to me through Sybill very straightly.
She's made a fool of herself at last, they say.
That comes of taking airs!
 
_Margery_. What meanst thou?
 
_Lizzy_. Pah!
She daily eats and drinks for two now.
 
_Margery_. Ah!
 
_Lizzy_. It serves the jade right for being so callow.
How long she's been hanging upon the fellow!
Such a promenading!
To fair and dance parading!
Everywhere as first she must shine,
He was treating her always with tarts and wine;
She began to think herself something fine,
And let her vanity so degrade her
That she even accepted the presents he made her.
There was hugging and smacking, and so it went on--
And lo! and behold! the flower is gone!
 
_Margery_. Poor thing!
 
_Lizzy_. Canst any pity for her feel!
When such as we spun at the wheel,
Our mothers kept us in-doors after dark;
While she stood cozy with her spark,
Or sate on the door-bench, or sauntered round,
And never an hour too long they found.
But now her pride may let itself down,
To do penance at church in the sinner's gown!
 
_Margery_. He'll certainly take her for his wife.
 
_Lizzy_. He'd be a fool! A spruce young blade
Has room enough to ply his trade.
Besides, he's gone.
 
_Margery_. Now, that's not fair!
 
_Lizzy_. If she gets him, her lot'll be hard to bear.
The boys will tear up her wreath, and what's more,
We'll strew chopped straw before her door.
 
[_Exit._]
 
_Margery [going home]_. Time was when I, too, instead of bewailing,
Could boldly jeer at a poor girl's failing!
When my scorn could scarcely find expression
At hearing of another's transgression!
How black it seemed! though black as could be,
It never was black enough for me.
I blessed my soul, and felt so high,
And now, myself, in sin I lie!
Yet--all that led me to it, sure,
O God! it was so dear, so pure!
 
 
 
 
DONJON.[27]
 
[_In a niche a devotional image of the Mater Dolorosa,
before it pots of flowers._]
 
MARGERY [_puts fresh flowers into the pots_].
Ah, hear me,
Draw kindly near me,
Mother of sorrows, heal my woe!
 
Sword-pierced, and stricken
With pangs that sicken,
Thou seest thy son's last life-blood flow!
 
Thy look--thy sighing---
To God are crying,
Charged with a son's and mother's woe!
 
Sad mother!
What other
Knows the pangs that eat me to the bone?
What within my poor heart burneth,
How it trembleth, how it yearneth,
Thou canst feel and thou alone!
 
Go where I will, I never
Find peace or hope--forever
Woe, woe and misery!
 
Alone, when all are sleeping,
I'm weeping, weeping, weeping,
My heart is crushed in me.
 
The pots before my window,
In the early morning-hours,
Alas, my tears bedewed them,
As I plucked for thee these flowers,
 
When the bright sun good morrow
In at my window said,
Already, in my anguish,
I sate there in my bed.
 
From shame and death redeem me, oh!
Draw near me,
And, pitying, hear me,
Mother of sorrows, heal my woe!
 
 
 
 
NIGHT.
 
_Street before_ MARGERY'S _Door._
 
 
VALENTINE [_soldier,_ MARGERY'S _brother_].
 
When at the mess I used to sit,
Where many a one will show his wit,
And heard my comrades one and all
The flower of the sex extol,
Drowning their praise with bumpers high,
Leaning upon my elbows, I
Would hear the braggadocios through,
And then, when it came my turn, too,
Would stroke my beard and, smiling, say,
A brimming bumper in my hand:
All very decent in their way!
But is there one, in all the land,
With my sweet Margy to compare,
A candle to hold to my sister fair?
Bravo! Kling! Klang! it echoed round!
One party cried: 'tis truth he speaks,
She is the jewel of the sex!
And the braggarts all in silence were bound.
And now!--one could pull out his hair with vexation,
And run up the walls for mortification!--
Every two-legged creature that goes in breeches
Can mock me with sneers and stinging speeches!
And I like a guilty debtor sitting,
For fear of each casual word am sweating!
And though I could smash them in my ire,
I dare not call a soul of them liar.
 
What's that comes yonder, sneaking along?
There are two of them there, if I see not wrong.
Is't he, I'll give him a dose that'll cure him,
He'll not leave the spot alive, I assure him!
 
 
FAUST. MEPHISTOPHELES.
 
_Faust_. How from yon window of the sacristy
The ever-burning lamp sends up its glimmer,
And round the edge grows ever dimmer,
Till in the gloom its flickerings die!
So in my bosom all is nightlike.
 
_Mephistopheles_. A starving tom-cat I feel quite like,
That o'er the fire ladders crawls
Then softly creeps, ground the walls.
My aim's quite virtuous ne'ertheless,
A bit of thievish lust, a bit of wantonness.
I feel it all my members haunting--
The glorious Walpurgis night.
One day--then comes the feast enchanting
That shall all pinings well requite.
 
_Faust_. Meanwhile can that the casket be, I wonder,
I see behind rise glittering yonder.[28]
 
_Mephistopheles_. Yes, and thou soon shalt have the pleasure
Of lifting out the precious treasure.
I lately 'neath the lid did squint,
Has piles of lion-dollars[29] in't.
 
_Faust_. But not a jewel? Not a ring?
To deck my mistress not a trinket?
 
_Mephistopheles_. I caught a glimpse of some such thing,
Sort of pearl bracelet I should think it.
 
_Faust_. That's well! I always like to bear
Some present when I visit my fair.
 
_Mephistopheles_. You should not murmur if your fate is,
To have a bit of pleasure gratis.
Now, as the stars fill heaven with their bright throng,
List a fine piece, artistic purely:
I sing her here a moral song,
To make a fool of her more surely.
[_Sings to the guitar_.][30]
What dost thou here,
Katrina dear,
At daybreak drear,
Before thy lover's chamber?
Give o'er, give o'er!
The maid his door
Lets in, no more
Goes out a maid--remember!
 
Take heed! take heed!
Once done, the deed
Ye'll rue with speed--
And then--good night--poor thing--a!
Though ne'er so fair
His speech, beware,
Until you bear
His ring upon your finger.
 
_Valentine_ [_comes forward_].
Whom lur'ft thou here? what prey dost scent?
Rat-catching[81] offspring of perdition!
To hell goes first the instrument!
To hell then follows the musician!
 
_Mephistopheles_. He 's broken the guitar! to music, then, good-bye, now.
 
_Valentine_. A game of cracking skulls we'll try now!
 
_Mephistopbeles_ [_to Faust_]. Never you flinch, Sir Doctor! Brisk!
Mind every word I say---be wary!
Stand close by me, out with your whisk!
Thrust home upon the churl! I'll parry.
 
_Valentine_. Then parry that!
 
_Mephistopheles_. Be sure. Why not?
 
_Valentine_. And that!
 
_Mephistopheles_. With ease!
 
_Valentine_. The devil's aid he's got!
But what is this? My hand's already lame.
 
_Mephistopheles_ [_to Faust_]. Thrust home!
 
_Valentine_ [_falls_]. O woe!
 
_Mephistopheles_. Now is the lubber tame!
But come! We must be off. I hear a clatter;
And cries of murder, too, that fast increase.
I'm an old hand to manage the police,
But then the penal court's another matter.
 
_Martha_. Come out! Come out!
 
_Margery_ [_at the window_]. Bring on a light!
 
_Martha_ [_as above_]. They swear and scuffle, scream and fight.
 
_People_. There's one, has got's death-blow!
 
_Martha_ [_coming out_]. Where are the murderers, have they flown?
 
_Margery_ [_coming out_]. Who's lying here?
 
_People_. Thy mother's son.
 
_Margery_. Almighty God! What woe!
 
_Valentine_. I'm dying! that is quickly said,
And even quicklier done.
Women! Why howl, as if half-dead?
Come, hear me, every one!
[_All gather round him_.]
My Margery, look! Young art thou still,
But managest thy matters ill,
Hast not learned out yet quite.
I say in confidence--think it o'er:
Thou art just once for all a whore;
Why, be one, then, outright.
 
_Margery_. My brother! God! What words to me!
 
_Valentine_. In this game let our Lord God be!
That which is done, alas! is done.
And every thing its course will run.
With one you secretly begin,
Presently more of them come in,
And when a dozen share in thee,
Thou art the whole town's property.
 
When shame is born to this world of sorrow,
The birth is carefully hid from sight,
And the mysterious veil of night
To cover her head they borrow;
Yes, they would gladly stifle the wearer;
But as she grows and holds herself high,
She walks uncovered in day's broad eye,
Though she has not become a whit fairer.
The uglier her face to sight,
The more she courts the noonday light.
 
Already I the time can see
When all good souls shall shrink from thee,
Thou prostitute, when thou go'st by them,
As if a tainted corpse were nigh them.
Thy heart within thy breast shall quake then,
When they look thee in the face.
Shalt wear no gold chain more on thy neck then!
Shalt stand no more in the holy place!
No pleasure in point-lace collars take then,
Nor for the dance thy person deck then!
But into some dark corner gliding,
'Mong beggars and cripples wilt be hiding;
And even should God thy sin forgive,
Wilt be curs'd on earth while thou shalt live!
 
_Martha_. Your soul to the mercy of God surrender!
Will you add to your load the sin of slander?
 
_Valentine_. Could I get at thy dried-up frame,
Vile bawd, so lost to all sense of shame!
Then might I hope, e'en this side Heaven,
Richly to find my sins forgiven.
 
_Margery_. My brother! This is hell to me!
 
_Valentine_. I tell thee, let these weak tears be!
When thy last hold of honor broke,
Thou gav'st my heart the heaviest stroke.
I'm going home now through the grave
To God, a soldier and a brave.
[_Dies_.]
 
 
 
 
CATHEDRAL.
 
_Service, Organ, and Singing._
 
 
[MARGERY _amidst a crowd of people._ EVIL SPIRIT _behind_ MARGERY.]
 
_Evil Spirit_. How different was it with thee, Margy,
When, innocent and artless,
Thou cam'st here to the altar,
From the well-thumbed little prayer-book,
Petitions lisping,
Half full of child's play,
Half full of Heaven!
Margy!
Where are thy thoughts?
What crime is buried
Deep within thy heart?
Prayest thou haply for thy mother, who
Slept over into long, long pain, on thy account?
Whose blood upon thy threshold lies?
--And stirs there not, already
Beneath thy heart a life
Tormenting itself and thee
With bodings of its coming hour?
 
_Margery_. Woe! Woe!
Could I rid me of the thoughts,
Still through my brain backward and forward flitting,
Against my will!
 
_Chorus_. Dies irae, dies illa
Solvet saeclum in favillâ.
 
[_Organ plays_.]
 
_Evil Spirit_. Wrath smites thee!
Hark! the trumpet sounds!
The graves are trembling!
And thy heart,
Made o'er again
For fiery torments,
Waking from its ashes
Starts up!
 
_Margery_. Would I were hence!
I feel as if the organ's peal
My breath were stifling,
The choral chant
My heart were melting.
 
_Chorus_. Judex ergo cum sedebit,
Quidquid latet apparebit.
Nil inultum remanebit.
 
_Margery_. How cramped it feels!
The walls and pillars
Imprison me!
And the arches
Crush me!--Air!
 
_Evil Spirit_. What! hide thee! sin and shame
Will not be hidden!
Air? Light?
Woe's thee!
 
_Chorus_. Quid sum miser tunc dicturus?
Quem patronum rogaturus?
Cum vix justus sit securus.
 
_Evil Spirit_. They turn their faces,
The glorified, from thee.
To take thy hand, the pure ones
Shudder with horror.
Woe!
 
_Chorus_. Quid sum miser tunc dicturus?
 
_Margery_. Neighbor! your phial!--
[_She swoons._]
 
 
 
 
WALPURGIS NIGHT.[32]
 
_Harz Mountains._
 
_District of Schirke and Elend._
 
 
FAUST. MEPHISTOPHELES.
 
_Mephistopheles_. Wouldst thou not like a broomstick, now, to ride on?
At this rate we are, still, a long way off;
I'd rather have a good tough goat, by half,
Than the best legs a man e'er set his pride on.
 
_Faust_. So long as I've a pair of good fresh legs to stride on,
Enough for me this knotty staff.
What use of shortening the way!
Following the valley's labyrinthine winding,
Then up this rock a pathway finding,
From which the spring leaps down in bubbling play,
That is what spices such a walk, I say!
Spring through the birch-tree's veins is flowing,
The very pine is feeling it;
Should not its influence set our limbs a-glowing?
 
_Mephistopheles_. I do not feel it, not a bit!
My wintry blood runs very slowly;
I wish my path were filled with frost and snow.
The moon's imperfect disk, how melancholy
It rises there with red, belated glow,
And shines so badly, turn where'er one can turn,
At every step he hits a rock or tree!
With leave I'll beg a Jack-o'lantern!
I see one yonder burning merrily.
Heigh, there! my friend! May I thy aid desire?
Why waste at such a rate thy fire?
Come, light us up yon path, good fellow, pray!
 
_Jack-o'lantern_. Out of respect, I hope I shall be able
To rein a nature quite unstable;
We usually take a zigzag way.
 
_Mephistopheles_. Heigh! heigh! He thinks man's crooked course to travel.
Go straight ahead, or, by the devil,
I'll blow your flickering life out with a puff.
 
_Jack-o'lantern_. You're master of the house, that's plain enough,
So I'll comply with your desire.
But see! The mountain's magic-mad to-night,
And if your guide's to be a Jack-o'lantern's light,
Strict rectitude you'll scarce require.
 
FAUST, MEPHISTOPHELES, JACK-O'LANTERN, _in alternate song_.
 
Spheres of magic, dream, and vision,
Now, it seems, are opening o'er us.
For thy credit, use precision!
Let the way be plain before us
Through the lengthening desert regions.
 
See how trees on trees, in legions,
Hurrying by us, change their places,
And the bowing crags make faces,
And the rocks, long noses showing,
Hear them snoring, hear them blowing![33]
 
Down through stones, through mosses flowing,
See the brook and brooklet springing.
Hear I rustling? hear I singing?
Love-plaints, sweet and melancholy,
Voices of those days so holy?
All our loving, longing, yearning?
Echo, like a strain returning
From the olden times, is ringing.
 
Uhu! Schuhu! Tu-whit! Tu-whit!
Are the jay, and owl, and pewit
All awake and loudly calling?
What goes through the bushes yonder?
Can it be the Salamander--
Belly thick and legs a-sprawling?
Roots and fibres, snake-like, crawling,
Out from rocky, sandy places,
Wheresoe'er we turn our faces,
Stretch enormous fingers round us,
Here to catch us, there confound us;
Thick, black knars to life are starting,
Polypusses'-feelers darting
At the traveller. Field-mice, swarming,
Thousand-colored armies forming,
Scamper on through moss and heather!
And the glow-worms, in the darkling,
With their crowded escort sparkling,
Would confound us altogether.
 
But to guess I'm vainly trying--
Are we stopping? are we hieing?
Round and round us all seems flying,
Rocks and trees, that make grimaces,
And the mist-lights of the places
Ever swelling, multiplying.
 
_Mephistopheles_. Here's my coat-tail--tightly thumb it!
We have reached a middle summit,
Whence one stares to see how shines
Mammon in the mountain-mines.
 
_Faust_. How strangely through the dim recesses
A dreary dawning seems to glow!
And even down the deep abysses
Its melancholy quiverings throw!
Here smoke is boiling, mist exhaling;
Here from a vapory veil it gleams,
Then, a fine thread of light, goes trailing,
Then gushes up in fiery streams.
The valley, here, you see it follow,
One mighty flood, with hundred rills,
And here, pent up in some deep hollow,
It breaks on all sides down the hills.
Here, spark-showers, darting up before us,
Like golden sand-clouds rise and fall.
But yonder see how blazes o'er us,
All up and down, the rocky wall!
 
_Mephistopheles_. Has not Sir Mammon gloriously lighted
His palace for this festive night?
Count thyself lucky for the sight:
I catch e'en now a glimpse of noisy guests invited.
 
_Faust_. How the mad tempest[34] sweeps the air!
On cheek and neck the wind-gusts how they flout me.
 
_Mephistopheles_. Must seize the rock's old ribs and hold on stoutly!
Else will they hurl thee down the dark abysses there.
A mist-rain thickens the gloom.
Hark, how the forests crash and boom!
Out fly the owls in dread and wonder;
Splitting their columns asunder,
Hear it, the evergreen palaces shaking!
Boughs are twisting and breaking!
Of stems what a grinding and moaning!
Of roots what a creaking and groaning!
In frightful confusion, headlong tumbling,
They fall, with a sound of thunder rumbling,
And, through the wreck-piled ravines and abysses,
The tempest howls and hisses.
Hearst thou voices high up o'er us?
Close around us--far before us?
Through the mountain, all along,
Swells a torrent of magic song.
 
_Witches_ [_in chorus_]. The witches go to the Brocken's top,
The stubble is yellow, and green the crop.
They gather there at the well-known call,
Sir Urian[85] sits at the head of all.
Then on we go o'er stone and stock:
The witch, she--and--the buck.
 
_Voice_. Old Baubo comes along, I vow!
She rides upon a farrow-sow.
 
_Chorus_. Then honor to whom honor's due!
Ma'am Baubo ahead! and lead the crew!
A good fat sow, and ma'am on her back,
Then follow the witches all in a pack.
 
_Voice_. Which way didst thou come?
 
_Voice_. By the Ilsenstein!
Peeped into an owl's nest, mother of mine!
What a pair of eyes!
 
_Voice_. To hell with your flurry!
Why ride in such hurry!
 
_Voice_. The hag be confounded!
My skin flie has wounded!
 
_Witches_ [_chorus]._ The way is broad, the way is long,
What means this noisy, crazy throng?
The broom it scratches, the fork it flicks,
The child is stifled, the mother breaks.
 
_Wizards_ [_semi-chorus_]. Like housed-up snails we're creeping on,
The women all ahead are gone.
When to the Bad One's house we go,
She gains a thousand steps, you know.
 
_The other half_. We take it not precisely so;
What she in thousand steps can go,
Make all the haste she ever can,
'Tis done in just one leap by man.
 
_Voice_ [_above_]. Come on, come on, from Felsensee!
 
_Voices_ [_from below_]. We'd gladly join your airy way.
For wash and clean us as much as we will,
We always prove unfruitful still.
 
_Both chorusses_. The wind is hushed, the star shoots by,
The moon she hides her sickly eye.
The whirling, whizzing magic-choir
Darts forth ten thousand sparks of fire.
 
_Voice_ [_from below_]. Ho, there! whoa, there!
 
_Voice_ [_from above_]. Who calls from the rocky cleft below there?
 
_Voice_ [_below_]. Take me too! take me too!
Three hundred years I've climbed to you,
Seeking in vain my mates to come at,
For I can never reach the summit.
 
_Both chorusses_. Can ride the besom, the stick can ride,
Can stride the pitchfork, the goat can stride;
Who neither will ride to-night, nor can,
Must be forever a ruined man.
 
_Half-witch_ [_below_]. I hobble on--I'm out of wind--
And still they leave me far behind!
To find peace here in vain I come,
I get no more than I left at home.
 
_Chorus of witches_. The witch's salve can never fail,
A rag will answer for a sail,
Any trough will do for a ship, that's tight;
He'll never fly who flies not to-night.
 
_Both chorusses_. And when the highest peak we round,
Then lightly graze along the ground,
And cover the heath, where eye can see,
With the flower of witch-errantry.
[_They alight_.]
 
_Mephistopheles._ What squeezing and pushing, what rustling and hustling!
What hissing and twirling, what chattering and bustling!
How it shines and sparkles and burns and stinks!
A true witch-element, methinks!
Keep close! or we are parted in two winks.
Where art thou?
 
_Faust_ [_in the distance_]. Here!
 
_Mephistopheles_. What! carried off already?
Then I must use my house-right.--Steady!
Room! Squire Voland[36] comes. Sweet people, Clear the ground!
Here, Doctor, grasp my arm! and, at a single bound;
Let us escape, while yet 'tis easy;
E'en for the like of me they're far too crazy.
See! yonder, something shines with quite peculiar glare,
And draws me to those bushes mazy.
Come! come! and let us slip in there.
 
_Faust_. All-contradicting sprite! To follow thee I'm fated.
But I must say, thy plan was very bright!
We seek the Brocken here, on the Walpurgis night,
Then hold ourselves, when here, completely isolated!
 
_Mephistopheles_. What motley flames light up the heather!
A merry club is met together,
In a small group one's not alone.
 
_Faust_. I'd rather be up there, I own!
See! curling smoke and flames right blue!
To see the Evil One they travel;
There many a riddle to unravel.
 
_Mephistopheles_. And tie up many another, too.
Let the great world there rave and riot,
We here will house ourselves in quiet.
The saying has been long well known:
In the great world one makes a small one of his own.
I see young witches there quite naked all,
And old ones who, more prudent, cover.
For my sake some flight things look over;
The fun is great, the trouble small.
I hear them tuning instruments! Curs'd jangle!
Well! one must learn with such things not to wrangle.
Come on! Come on! For so it needs must be,
Thou shalt at once be introduced by me.
And I new thanks from thee be earning.
That is no scanty space; what sayst thou, friend?
Just take a look! thou scarce canst see the end.
There, in a row, a hundred fires are burning;
They dance, chat, cook, drink, love; where can be found
Any thing better, now, the wide world round?
 
_Faust_. Wilt thou, as things are now in this condition,
Present thyself for devil, or magician?
 
_Mephistopheles_. I've been much used, indeed, to going incognito;
 
But then, on gala-day, one will his order show.
No garter makes my rank appear,
But then the cloven foot stands high in honor here.
Seest thou the snail? Look there! where she comes creeping yonder!
Had she already smelt the rat,
I should not very greatly wonder.
Disguise is useless now, depend on that.
Come, then! we will from fire to fire wander,
Thou shalt the wooer be and I the pander.
[_To a party who sit round expiring embers_.]
Old gentlemen, you scarce can hear the fiddle!
You'd gain more praise from me, ensconced there in the middle,
'Mongst that young rousing, tousing set.
One can, at home, enough retirement get.
 
_General_. Trust not the people's fickle favor!
However much thou mayst for them have done.
Nations, as well as women, ever,
Worship the rising, not the setting sun.
 
_Minister_. From the right path we've drifted far away,
The good old past my heart engages;
Those were the real golden ages,
When such as we held all the sway.
 
_Parvenu_. We were no simpletons, I trow,
And often did the thing we should not;
But all is turning topsy-turvy now,
And if we tried to stem the wave, we could not.
 
_Author_. Who on the whole will read a work today,
Of moderate sense, with any pleasure?
And as regards the dear young people, they
Pert and precocious are beyond all measure.
 
_Mephistopheles_ [_who all at once appears very old_].
The race is ripened for the judgment day:
So I, for the last time, climb the witch-mountain, thinking,
And, as my cask runs thick, I say,
The world, too, on its lees is sinking.
 
_Witch-broker_. Good gentlemen, don't hurry by!
The opportunity's a rare one!
My stock is an uncommon fair one,
Please give it an attentive eye.
There's nothing in my shop, whatever,
But on the earth its mate is found;
That has not proved itself right clever
To deal mankind some fatal wound.
No dagger here, but blood has some time stained it;
No cup, that has not held some hot and poisonous juice,
And stung to death the throat that drained it;
No trinket, but did once a maid seduce;
No sword, but hath some tie of sacred honor riven,
Or haply from behind through foeman's neck been driven.
 
_Mephistopheles_. You're quite behind the times, I tell you, Aunty!
By-gones be by-gones! done is done!
Get us up something new and jaunty!
For new things now the people run.
 
_Faust_. To keep my wits I must endeavor!
Call this a fair! I swear, I never--!
 
_Mephistopheles_. Upward the billowy mass is moving;
You're shoved along and think, meanwhile, you're shoving.
 
_Faust_. What woman's that?
 
_Mephistopheles_. Mark her attentively.
That's Lilith.[37]
 
_Faust_. Who?
 
_Mephistopbeles_. Adam's first wife is she.
Beware of her one charm, those lovely tresses,
In which she shines preeminently fair.
When those soft meshes once a young man snare,
How hard 'twill be to escape he little guesses.
 
_Faust_. There sit an old one and a young together;
They've skipped it well along the heather!
 
_Mephistopheles_. No rest from that till night is through.
Another dance is up; come on! let us fall to.
 
_Faust_ [_dancing with the young one_]. A lovely dream once came to me;
In it I saw an apple-tree;
Two beauteous apples beckoned there,
I climbed to pluck the fruit so fair.
 
_The Fair one_. Apples you greatly seem to prize,
And did so even in Paradise.
I feel myself delighted much
That in my garden I have such.
 
_Mephistopheles_ [_with the old hag_]. A dismal dream once came to me;
In it I saw a cloven tree,
It had a ------ but still,
I looked on it with right good-will.
 
_The Hog_. With best respect I here salute
The noble knight of the cloven foot!
Let him hold a ------ near,
If a ------ he does not fear.
 
_Proctophantasmist_.[38] What's this ye undertake? Confounded crew!
Have we not giv'n you demonstration?
No spirit stands on legs in all creation,
And here you dance just as we mortals do!
 
_The Fair one_ [_dancing_]. What does that fellow at our ball?
 
_Faust_ [_dancing_]. Eh! he must have a hand in all.
What others dance that he appraises.
Unless each step he criticizes,
The step as good as no step he will call.
But when we move ahead, that plagues him more than all.
If in a circle you would still keep turning,
As he himself in his old mill goes round,
He would be sure to call that sound!
And most so, if you went by his superior learning.
 
_Proctophantasmist_. What, and you still are here! Unheard off obstinates!
Begone! We've cleared it up! You shallow pates!
The devilish pack from rules deliverance boasts.
We've grown so wise, and Tegel[39] still sees ghosts.
How long I've toiled to sweep these cobwebs from the brain,
And yet--unheard of folly! all in vain.
 
_The Fair one_. And yet on us the stupid bore still tries it!
 
_Proctophantasmist_. I tell you spirits, to the face,
I give to spirit-tyranny no place,
My spirit cannot exercise it.
[_They dance on_.]
I can't succeed to-day, I know it;
Still, there's the journey, which I like to make,
And hope, before the final step I take,
To rid the world of devil and of poet.
 
_Mephistopheles_. You'll see him shortly sit into a puddle,
In that way his heart is reassured;
When on his rump the leeches well shall fuddle,
Of spirits and of spirit he'll be cured.
[_To_ FAUST, _who has left the dance_.]
Why let the lovely girl slip through thy fingers,
Who to thy dance so sweetly sang?
 
_Faust_. Ah, right amidst her singing, sprang
A wee red mouse from her mouth and made me cower.
 
_Mephistopheles_. That's nothing wrong! You're in a dainty way;
Enough, the mouse at least wan't gray.
Who minds such thing in happy amorous hour?
 
_Faust_. Then saw I--
 
_Mephistopheles_. What?
 
_Faust_. Mephisto, seest thou not
Yon pale, fair child afar, who stands so sad and lonely,
And moves so slowly from the spot,
Her feet seem locked, and she drags them only.
I must confess, she seems to me
To look like my own good Margery.
 
_Mephistopheles_. Leave that alone! The sight no health can bring.
it is a magic shape, an idol, no live thing.
To meet it never can be good!
Its haggard look congeals a mortal's blood,
And almost turns him into stone;
The story of Medusa thou hast known.
 
_Faust_. Yes, 'tis a dead one's eyes that stare upon me,
Eyes that no loving hand e'er closed;
That is the angel form of her who won me,
Tis the dear breast on which I once reposed.
 
_Mephistopheles_. 'Tis sorcery all, thou fool, misled by passion's dreams!
For she to every one his own love seems.
 
_Faust_. What bliss! what woe! Methinks I never
My sight from that sweet form can sever.
Seeft thou, not thicker than a knife-blade's back,
A small red ribbon, fitting sweetly
The lovely neck it clasps so neatly?
 
_Mephistopheles_. I see the streak around her neck.
Her head beneath her arm, you'll next behold her;
Perseus has lopped it from her shoulder,--
But let thy crazy passion rest!
Come, climb with me yon hillock's breast,
Was e'er the Prater[40] merrier then?
And if no sorcerer's charm is o'er me,
That is a theatre before me.
What's doing there?
 
_Servibilis_. They'll straight begin again.
A bran-new piece, the very last of seven;
To have so much, the fashion here thinks fit.
By Dilettantes it is given;
'Twas by a Dilettante writ.
Excuse me, sirs, I go to greet you;
I am the curtain-raising Dilettant.
 
_Mephistopheles_. When I upon the Blocksberg meet you,
That I approve; for there's your place, I grant.
 
 
 
 
WALPURGIS-NIGHT'S DREAM, OR OBERON AND TITANIA'S GOLDEN NUPTIALS.
 
_Intermezzo_.
 
 
_Theatre manager_. Here, for once, we rest, to-day,
Heirs of Mieding's[41] glory.
All the scenery we display--
Damp vale and mountain hoary!
 
_Herald_. To make the wedding a golden one,
Must fifty years expire;
But when once the strife is done,
I prize the _gold_ the higher.
 
_Oberon_. Spirits, if my good ye mean,
Now let all wrongs be righted;
For to-day your king and queen
Are once again united.
 
_Puck_. Once let Puck coming whirling round,
And set his foot to whisking,
Hundreds with him throng the ground,
Frolicking and frisking.
 
_Ariel_. Ariel awakes the song
With many a heavenly measure;
Fools not few he draws along,
But fair ones hear with pleasure.
 
_Oberon_. Spouses who your feuds would smother,
Take from us a moral!
Two who wish to love each other,
Need only first to quarrel.
 
_Titania_. If she pouts and he looks grim,
Take them both together,
To the north pole carry him,
And off with her to t'other.
 
_Orchestra Tutti_.
 
_Fortissimo_. Fly-snouts and gnats'-noses, these,
And kin in all conditions,
Grass-hid crickets, frogs in trees,
We take for our musicians!
 
_Solo_. See, the Bagpipe comes! fall back!
Soap-bubble's name he owneth.
How the _Schnecke-schnicke-schnack_
Through his snub-nose droneth!
_Spirit that is just shaping itself_. Spider-foot, toad's-belly, too,
Give the child, and winglet!
'Tis no animalcule, true,
But a poetic thinglet.
 
_A pair of lovers_. Little step and lofty bound
Through honey-dew and flowers;
Well thou trippest o'er the ground,
But soarst not o'er the bowers.
 
_Curious traveller_. This must be masquerade!
How odd!
My very eyes believe I?
Oberon, the beauteous God
Here, to-night perceive I!
 
_Orthodox_. Neither claws, nor tail I see!
And yet, without a cavil,
Just as "the Gods of Greece"[42] were, he
Must also be a devil.
 
_Northern artist_. What here I catch is, to be sure,
But sketchy recreation;
And yet for my Italian tour
'Tis timely preparation.
 
_Purist_. Bad luck has brought me here, I see!
The rioting grows louder.
And of the whole witch company,
There are but two, wear powder.
 
_Young witch_. Powder becomes, like petticoat,
Your little, gray old woman:
Naked I sit upon my goat,
And show the untrimmed human.
 
_Matron_. To stand here jawing[43] with you, we
Too much good-breeding cherish;
But young and tender though you be,
I hope you'll rot and perish.
 
_Leader of the music_. Fly-snouts and gnat-noses, please,
Swarm not so round the naked!
Grass-hid crickets, frogs in trees,
Keep time and don't forsake it!
 
_Weathercock_ [_towards one side_]. Find better company, who can!
Here, brides attended duly!
There, bachelors, ranged man by man,
Most hopeful people truly!
 
_Weathercock [towards the other side_].
And if the ground don't open straight,
The crazy crew to swallow,
You'll see me, at a furious rate,
Jump down to hell's black hollow.
 
_Xenia[_44] We are here as insects, ah!
Small, sharp nippers wielding,
Satan, as our _cher papa_,
Worthy honor yielding.
 
_Hennings_. See how naïvely, there, the throng
Among themselves are jesting,
You'll hear them, I've no doubt, ere long,
Their good kind hearts protesting.
 
_Musagetes_. Apollo in this witches' group
Himself right gladly loses;
For truly I could lead this troop
Much easier than the muses.
 
_Ci-devant genius of the age_. Right company will raise man up.
Come, grasp my skirt, Lord bless us!
The Blocksberg has a good broad top,
Like Germany's Parnassus.
 
_Curious traveller_. Tell me who is that stiff man?
With what stiff step he travels!
He noses out whate'er he can.
"He scents the Jesuit devils."
 
_Crane_. In clear, and muddy water, too,
The long-billed gentleman fishes;
Our pious gentlemen we view
Fingering in devils' dishes.
 
_Child of this world_. Yes, with the pious ones, 'tis clear,
"All's grist that comes to their mill;"
They build their tabernacles here,
On Blocksberg, as on Carmel.
 
_Dancer_. Hark! a new choir salutes my ear!
I hear a distant drumming.
"Be not disturbed! 'mong reeds you hear
The one-toned bitterns bumming."
 
_Dancing-master._ How each his legs kicks up and flings,
Pulls foot as best he's able!
The clumsy hops, the crooked springs,
'Tis quite disreputable!
 
_Fiddler_. The scurvy pack, they hate, 'tis clear,
Like cats and dogs, each other.
Like Orpheus' lute, the bagpipe here
Binds beast to beast as brother.
 
_Dogmatist_. You'll not scream down my reason, though,
By criticism's cavils.
The devil's something, that I know,
Else how could there be devils?
 
_Idealist_. Ah, phantasy, for once thy sway
Is guilty of high treason.
If all I see is I, to-day,
'Tis plain I've lost my reason.
 
_Realist_. To me, of all life's woes and plagues,
Substance is most provoking,
For the first time I feel my legs
Beneath me almost rocking.
 
_Supernaturalist_. I'm overjoyed at being here,
And even among these rude ones;
For if bad spirits are, 'tis clear,
There also must be good ones.
 
_Skeptic_. Where'er they spy the flame they roam,
And think rich stores to rifle,
Here such as I are quite at home,
For _Zweifel_ rhymes with _Teufel_.[45]
 
_Leader of the music_. Grass-hid cricket, frogs in trees,
You cursed dilettanti!
Fly-snouts and gnats'-noses, peace!
Musicians you, right jaunty!
 
_The Clever ones_. Sans-souci we call this band
Of merry ones that skip it;
Unable on our feet to stand,
Upon our heads we trip it.
 
_The Bunglers_. Time was, we caught our tit-bits, too,
God help us now! that's done with!
We've danced our leathers entirely through,
And have only bare soles to run with.
 
_Jack-o'lanterns_. From the dirty bog we come,
Whence we've just arisen:
Soon in the dance here, quite at home,
As gay young _sparks_ we'll glisten.
 
_Shooting star_. Trailing from the sky I shot,
Not a star there missed me:
Crooked up in this grassy spot,
Who to my legs will assist me?
 
_The solid men_. Room there! room there! clear the ground!
Grass-blades well may fall so;
Spirits are we, but 'tis found
They have plump limbs also.
 
_Puck_. Heavy men! do not, I say,
Like elephants' calves go stumping:
Let the plumpest one to-day
Be Puck, the ever-jumping.
 
_Ariel_. If the spirit gave, indeed,
If nature gave you, pinions,
Follow up my airy lead
To the rose-dominions!
 
_Orchestra_ [_pianissimo_]. Gauzy mist and fleecy cloud
Sun and wind have banished.
Foliage rustles, reeds pipe loud,
All the show has vanished.
 
 
 
 
DREARY DAY.[46]
 
_Field_.
 
 
FAUST. MEPHISTOPHELES.
 
_Faust_. In wretchedness! In despair! Long hunted up and down the earth, a
miserable fugitive, and caught at last! Locked up as a malefactor in
prison, to converse with horrible torments--the sweet, unhappy creature!
Even to this pass! even to this!--Treacherous, worthless spirit, and this
thou hast hidden from me!--Stand up here--stand up! Roll thy devilish eyes
round grimly in thy head! Stand and defy me with thy intolerable presence!
Imprisoned! In irretrievable misery! Given over to evil spirits and to the
judgment of unfeeling humanity, and me meanwhile thou lullest in insipid
dissipations, concealest from me her growing anguish, and leavest her
without help to perish!
 
_Mephistopheles_. She is not the first!
 
_Faust_. Dog! abominable monster! Change him, thou Infinite Spirit! change
the worm back into his canine form, as he was often pleased in the night
to trot before me, to roll before the feet of the harmless wanderer, and,
when he fell, to hang on his shoulders. Change him again into his favorite
shape, that he may crawl before me on his belly in the sand, and that I
may tread him under foot, the reprobate!--Not the first! Misery! Misery!
inconceivable by any human soul! that more than one creature ever sank
into the depth of this wretchedness, that the first in its writhing
death-agony did not atone for the guilt of all the rest before the eyes of
the eternally Forgiving! My very marrow and life are consumed by the
misery of this single one; thou grinnest away composedly at the fate of
thousands!
 
_Mephistopheles_. Here we are again at our wits' ends already, where the
thread of sense, with you mortals, snaps short. Why make a partnership
with us, if thou canst not carry it through? Wilt fly, and art not proof
against dizziness? Did we thrust ourselves on thee, or thou on us?
 
_Faust_. Gnash not so thy greedy teeth against me! It disgusts me!--Great
and glorious spirit, thou that deignedst to appear to me, who knowest my
heart and soul, why yoke me to this shame-fellow, who feeds on mischief
and feasts on ruin?
 
_Mephistopheles_. Hast thou done?
 
_Faust_. Rescue her! O woe be unto thee! The most horrible curse on thee
for thousands of years!
 
_Mephistopheles_. I cannot loose the bonds of the avenger, nor open his
bolts.--Rescue her!--Who was it that plunged her into ruin? I or thou?
[FAUST _looks wildly round_.]
Grasp'st thou after the thunder? Well that it was not given to you
miserable mortals! To crush an innocent respondent, that is a sort of
tyrant's-way of getting room to breathe in embarrassment.
 
_Faust_. Lead me to her! She shall be free!
 
_Mephistopheles_. And the danger which thou incurrest? Know that the guilt
of blood at thy hand still lies upon the town. Over the place of the
slain, avenging spirits hover and lurk for the returning murderer.
 
_Faust_. That, too, from thee? Murder and death of a world upon thee,
monster! Lead me thither, I say, and free her!
 
_Mephistopheles_. I will lead thee, and hear what I can do! Have I all
power in heaven and on earth? I will becloud the turnkey's senses; possess
thyself of the keys, and bear her out with human hand. I will watch! The
magic horses shall be ready, and I will bear you away. So much I can do.
 
_Faust_. Up and away!
 
 
 
 
NIGHT. OPEN FIELD.
 
FAUST. MEPHISTOPHELES.
_Scudding along on black horses_.
 
_Faust_. What's doing, off there, round the gallows-tree?[47]
 
_Mephistopheles_. Know not what they are doing and brewing.
 
_Faust_. Up they go--down they go--wheel about, reel about.
 
_Mephistopheles_. A witches'-crew.
 
_Faust_. They're strewing and vowing.
 
_Mephistopheles_. Pass on! Pass on!
 
 
 
 
PRISON.
 
FAUST [_with a bunch of keys and a lamp, before an iron door_]
A long unwonted chill comes o'er me,
I feel the whole great load of human woe.
Within this clammy wall that frowns before me
Lies one whom blinded love, not guilt, brought low!
Thou lingerest, in hope to grow bolder!
Thou fearest again to behold her!
On! Thy shrinking slowly hastens the blow!
[_He grasps the key. Singing from within_.]
My mother, the harlot,
That strung me up!
My father, the varlet,
That ate me up!
My sister small,
She gathered up all
The bones that day,
And in a cool place did lay;
Then I woke, a sweet bird, at a magic call;
Fly away, fly away!
 
_Faust [unlocking_]. She little dreams, her lover is so near,
The clanking chains, the rustling straw can hear;
[_He enters_.]
 
_Margaret [burying herself in the bed_]. Woe! woe!
They come. O death of bitterness!
 
_Faust_ [_softly_]. Hush! hush! I come to free thee; thou art dreaming.
 
_Margaret_ [_prostrating herself before him_].
Art thou a man, then feel for my distress.
 
_Faust_. Thou'lt wake the guards with thy loud screaming!
[_He seizes the chains to tin lock them._]
 
_Margaret_ [_on her knees_]. Headsman, who's given thee this right
O'er me, this power!
Thou com'st for me at dead of night;
In pity spare me, one short hour!
Wilt't not be time when Matin bell has rung?
[_She stands up._]
Ah, I am yet so young, so young!
And death pursuing!
Fair was I too, and that was my undoing.
My love was near, far is he now!
Tom is the wreath, the scattered flowers lie low.
Take not such violent hold of me!
Spare me! what harm have I done to thee?
Let me not in vain implore thee.
Thou ne'er till now sawft her who lies before thee!
 
_Faust_. O sorrow worse than death is o'er me!
 
_Margaret_. Now I am wholly in thy power.
But first I'd nurse my child--do not prevent me.
I hugged it through the black night hour;
They took it from me to torment me,
And now they say I killed the pretty flower.
I shall never be happy again, I know.
They sing vile songs at me! 'Tis bad in them to do it!
There's an old tale that ends just so,
Who gave that meaning to it?
 
_Faust [prostrates himself_]. A lover at thy feet is bending,
Thy bonds of misery would be rending.
 
_Margaret [flings herself beside him_].
O let us kneel, the saints for aid invoking!
See! 'neath the threshold smoking,
Fire-breathing,
Hell is seething!
There prowling,
And grim under cover,
Satan is howling!
 
_Faust [aloud_]. Margery! Margery!
 
_Margaret [listening_]. That was the voice of my lover!
[_She springs up. The chains fall off_.]
 
Where is he? Where? He calls. I hear him.
I'm free! Who hinders? I will be near him.
I'll fly to his neck! I'll hold him!
To my bosom I'll enfold him!
He stood on the threshold--called Margery plainly!
Hell's howling and clattering to drown it sought vainly,--
Through the devilish, grim scoffs, that might turn one to stone,
I caught the sweet, loving, enrapturing tone.
 
_Faust_. 'Tis I!
 
_Margaret_. 'Tis thou! O say it once again.
[_Clasping again._]
'Tis he! 'tis he! Where now is all my pain?
And where the dungeon's anguish? Joy-giver!
'Tis thou! And come to deliver!
I am delivered!
Again before me lies the street,
Where for the first time thou and I did meet.
And the garden-bower,
Where we spent that evening hour.
 
_Faust_ [_trying to draw her away_]. Come! Come with me!
 
_Margaret_. O tarry!
I tarry so gladly where thou tarriest.
[_Caressing him._]
 
_Faust_. Hurry!
Unless thou hurriest,
Bitterly we both must rue it.
 
_Margaret_. Kiss me! Canst no more do it?
So short an absence, love, as this,
And forgot how to kiss?
What saddens me so as I hang about thy neck?
When once, in thy words, thy looks, such a heaven of blisses
Came o'er me, I thought my heart would break,
And it seemed as if thou wouldst smother me with kisses.
Kiss thou me!
Else I kiss thee!
[_She embraces him._]
Woe! woe! thy lips are cold,
Stone-dumb.
Where's thy love left?
Oh! I'm bereft!
Who robbed me?
[_She turns from him_]
 
_Faust_. O come!
Take courage, my darling! Let us go;
I clasp-thee with unutterable glow;
But follow me! For this alone I plead!
 
_Margaret [turning to him_]. Is it, then, thou?
And is it thou indeed?
 
_Faust_. 'Tis I! Come, follow me!
 
_Margaret_. Thou break'st my chain,
And tak'st me to thy breast again!
How comes it, then, that thou art not afraid of me?
And dost thou know, my friend, who 'tis thou settest free?
 
_Faust_. Come! come! The night is on the wane.
 
_Margaret_. Woe! woe! My mother I've slain!
Have drowned the babe of mine!
Was it not sent to be mine and thine?
Thine, too--'tis thou! Scarce true doth it seem.
Give me thy hand! 'Tis not a dream!
Thy blessed hand!--But ah! there's dampness here!
Go, wipe it off! I fear
There's blood thereon.
Ah God! what hast thou done!
Put up thy sword again;
I pray thee, do!
 
_Faust_. The past is past--there leave it then,
Thou kill'st me too!
 
_Margaret_. No, thou must longer tarry!
I'll tell thee how each thou shalt bury;
The places of sorrow
Make ready to-morrow;
Must give the best place to my mother,
The very next to my brother,
Me a little aside,
But make not the space too wide!
And on my right breast let the little one lie.
No one else will be sleeping by me.
Once, to feel _thy_ heart beat nigh me,
Oh, 'twas a precious, a tender joy!
But I shall have it no more--no, never;
I seem to be forcing myself on thee ever,
And thou repelling me freezingly;
And 'tis thou, the same good soul, I see.
 
_Faust_. If thou feelest 'tis I, then come with me
 
_Margaret_. Out yonder?
 
_Faust_. Into the open air.
 
_Margaret_. If the grave is there,
If death is lurking; then come!
From here to the endless resting-place,
And not another pace--Thou
go'st e'en now? O, Henry, might I too.
 
_Faust_. Thou canst! 'Tis but to will! The door stands open.
 
_Margaret_. I dare not go; for me there's no more hoping.
What use to fly? They lie in wait for me.
So wretched the lot to go round begging,
With an evil conscience thy spirit plaguing!
So wretched the lot, an exile roaming--And
then on my heels they are ever coming!
 
_Faust_. I shall be with thee.
 
_Margaret_. Make haste! make haste!
No time to waste!
Save thy poor child!
Quick! follow the edge
Of the rushing rill,
Over the bridge
And by the mill,
Then into the woods beyond
On the left where lies the plank
Over the pond.
Seize hold of it quick!
To rise 'tis trying,
It struggles still!
Rescue! rescue!
 
_Faust_. Bethink thyself, pray!
A single step and thou art free!
 
_Margaret_. Would we were by the mountain. See!
There sits my mother on a stone,
The sight on my brain is preying!
There sits my mother on a stone,
And her head is constantly swaying;
She beckons not, nods not, her head falls o'er,
So long she's been sleeping, she'll wake no more.
She slept that we might take pleasure.
O that was bliss without measure!
 
_Faust_. Since neither reason nor prayer thou hearest;
I must venture by force to take thee, dearest.
 
_Margaret_. Let go! No violence will I bear!
Take not such a murderous hold of me!
I once did all I could to gratify thee.
 
_Faust_. The day is breaking! Dearest! dearest!
 
_Margaret_. Day! Ay, it is day! the last great day breaks in!
My wedding-day it should have been!
Tell no one thou hast been with Margery!
Alas for my garland! The hour's advancing!
Retreat is in vain!
We meet again,
But not at the dancing.
The multitude presses, no word is spoke.
Square, streets, all places--
sea of faces--
The bell is tolling, the staff is broke.
How they seize me and bind me!
They hurry me off to the bloody block.[48]
The blade that quivers behind me,
Quivers at every neck with convulsive shock;
Dumb lies the world as the grave!
 
_Faust_. O had I ne'er been born!
 
_Mephistopheles [appears without_]. Up! or thou'rt lost! The morn
Flushes the sky.
Idle delaying! Praying and playing!
My horses are neighing,
They shudder and snort for the bound.
 
_Margaret_. What's that, comes up from the ground?
He! He! Avaunt! that face!
What will he in the sacred place?
He seeks me!
 
_Faust_. Thou shalt live!
 
_Margaret_. Great God in heaven!
Unto thy judgment my soul have I given!
 
_Mephistopheles [to Faust_].
Come! come! or in the lurch I leave both her and thee!
 
_Margaret_. Thine am I, Father! Rescue me!
Ye angels, holy bands, attend me!
And camp around me to defend me I
Henry! I dread to look on thee.
 
_Mephistopheles_. She's judged!
 
_Voice [from above_]. She's saved!
 
_Mephistopheles [to Faust_]. Come thou to me!
[_Vanishes with_ FAUST.]
 
_Voice [from within, dying away_]. Henry! Henry!
 
 
 
 
NOTES.
 
 
[Footnote 1: Dedication. The idea of Faust had early entered into Goethe's
mind. He probably began the work when he was about twenty years old. It
was first published, as a fragment, in 1790, and did not appear in its
present form till 1808, when its author's age was nearly sixty. By the
"forms" are meant, of course, the shadowy personages and scenes of the
drama.]
 
[Footnote 2: --"Thy messengers"--
"He maketh the winds his-messengers,
The flaming lightnings his ministers."
_Noyes's Psalms_, c. iv. 4.]
 
[Footnote 3: "The Word Divine." In translating the German "Werdende"
(literally, the _becoming, developing_, or _growing_) by the term _word_,
I mean the _word_ in the largest sense: "In the beginning was the Word,
&c." Perhaps "nature" would be a pretty good rendering, but "word," being
derived from "werden," and expressing philosophically and scripturally the
going forth or manifestation of mind, seemed to me as appropriate a
translation as any.]
 
[Footnote 4: "The old fellow." The commentators do not seem quite agreed
whether "den Alten" (the old one) is an entirely reverential phrase here,
like the "ancient of days," or savors a little of profane pleasantry, like
the title "old man" given by boys to their schoolmaster or of "the old
gentleman" to their fathers. Considering who the speaker is, I have
naturally inclined to the latter alternative.]
 
[Footnote 5: "Nostradamus" (properly named Michel Notre Dame) lived
through the first half of the sixteenth century. He was born in the south
of France and was of Jewish extraction. As physician and astrologer, he
was held in high honor by the French nobility and kings.]
 
[Footnote 6: The "Macrocosm" is the great world of outward things, in
contrast with its epitome, the little world in man, called the microcosm
(or world in miniature).]
 
[Footnote 7: "Famulus" seems to mean a cross between a servant and a
scholar. The Dominie Sampson called Wagner, is appended to Faust for the
time somewhat as Sancho is to Don Quixote. The Doctor Faust of the legend
has a servant by that name, who seems to have been more of a _Sancho_, in
the sense given to the word by the old New England mothers when upbraiding
bad boys (you Sanch'!). Curiously enough, Goethe had in early life a
(treacherous) friend named Wagner, who plagiarized part of Faust and made
a tragedy of it.]
 
[Footnote 8: "Mock-heroic play." We have Schlegel's authority for thus
rendering the phrase "Haupt- und Staats-Action," (literally, "head and
State-action,") who says that this title was given to dramas designed for
puppets, when they treated of heroic and historical subjects.]
 
[Footnote 9: The literal sense of this couplet in the original is:--
"Is he, in the bliss of becoming,
To creative joy near--"
"Werde-lust" presents the same difficulty that we found in note 3. This
same word, "Werden," is also used by the poet in the introductory theatre
scene (page 7), where he longs for the time when he himself was
_ripening_, growing, becoming, or _forming_, (as Hayward renders it.) I
agree with Hayward, "the meaning probably is, that our Saviour enjoys, in
coming to life again," (I should say, in being born into the upper life,)
"a happiness nearly equal to that of the Creator in creating."]
 
[Footnote 10: The Angel-chorusses in this scene present the only instances
in which the translator, for the sake of retaining the ring and swing of
the melody, has felt himself obliged to give a transfusion of the spirit
of the thought, instead of its exact form.
 
The literal meaning of the first chorus is:--
 
Christ is arisen!
Joy to the Mortal,
Whom the ruinous,
Creeping, hereditary
Infirmities wound round.
 
Dr. Hedge has come nearer than any one to reconciling meaning and melody
thus:--
 
"Christ has arisen!
Joy to our buried Head!
Whom the unmerited,
Trailing, inherited
Woes did imprison."
 
The present translator, without losing sight of the fact that "the Mortal"
means Christ, has taken the liberty (constrained by rhyme,--which is
sometimes more than the _rudder_ of verse,) of making the congratulation
include Humanity, as incarnated in Christ, "the second Adam."
 
In the closing Chorus of Angels, the translator found that he could best
preserve the spirit of the five-fold rhyme:--
 
"Thätig ihn preisenden,
Liebe beweisenden,
Brüderlich speisenden,
Predigend reisenden,
Wonne verheissenden,"
 
by running it into three couplets.]
 
[Footnote 11: The prose account of the alchymical process is as follows:--
 
"There was red mercury, a powerfully acting body, united with the tincture
of antimony, at a gentle heat of the water-bath. Then, being exposed to
the heat of open fire in an aludel, (or alembic,) a sublimate filled its
heads in succession, which, if it appeared with various hues, was the
desired medicine."]
 
[Footnote 12: "Salamander, &c." The four represent the spirits of the
four elements, fire, water, air, and earth, which Faust successively
conjures, so that, if the monster belongs in any respect to this mundane
sphere, he may be exorcized. But it turns out that he is beyond and
beneath all.]
 
[Footnote 13: Here, of course, Faust makes the sign of the cross, or holds
out a crucifix.]
 
[Footnote 14: "Fly-God," _i.e._ Beelzebub.]
 
[Footnote 15: The "Drudenfuss," or pentagram, was a pentagonal figure
composed of three triangles, thus:
[Illustration]
 
[Footnote 16: Doctor's Feast. The inaugural feast given at taking a
degree.]
 
[Footnote 17: "Blood." When at the first invention of printing, the art
was ascribed to the devil, the illuminated red ink parts were said by the
people to be done in blood.]
 
[Footnote 18: "The Spanish boot" was an instrument of torture, like the
Scottish boot mentioned in Old Mortality.]
 
[Footnote 19: "Encheiresin Naturæ." Literally, a handling of nature.]
 
[Footnote 20: Still a famous place of public resort and entertainment. On
the wall are two old paintings of Faust's carousal and his ride out of the
door on a cask. One is accompanied by the following inscription, being two
lines (Hexameter and Pentameter) broken into halves:--
 
"Vive, bibe, obgregare, memor
Fausti hujus et hujus
Pœnæ. Aderat clauda haec,
Ast erat ampla gradû. 1525."
 
"Live, drink, be merry, remembering
This Faust and his
Punishment. It came slowly
But was in ample measure."]
 
[Footnote 21:_Frosch, Brander_, &c. These names seem to be chosen with an
eye to adaptation, Frosch meaning frog, and Brander fireship. "Frog"
happens also to be the nickname the students give to a pupil of the
gymnasium, or school preparatory to the university.]
 
[Footnote 22: Rippach is a village near Leipsic, and Mr. Hans was a
fictitious personage about whom the students used to quiz greenhorns.]
 
[Footnote 23: The original means literally _sea-cat_. Retzsch says, it is
the little ring-tailed monkey.]
 
[Footnote 24: One-time-one, _i.e._ multiplication-table.]
 
[Footnote 25: "Hand and glove." The translator's coincidence with Miss
Swanwick here was entirely accidental. The German is "thou and thou,"
alluding to the fact that intimate friends among the Germans, like the
sect of Friends, call each other _thou_.]
 
[Footnote 26: The following is a literal translation of the song referred
to:--
 
Were I a little bird,
Had I two wings of mine,
I'd fly to my dear;
But that can never be,
So I stay here.
 
Though I am far from thee,
Sleeping I'm near to thee,
Talk with my dear;
When I awake again,
I am alone.
 
Scarce is there an hour in the night,
When sleep does not take its flight,
And I think of thee,
How many thousand times
Thou gav'st thy heart to me.]
 
[Footnote 27: Donjon. The original is _Zwinger_, which Hayward says is
untranslatable. It probably means an old tower, such as is often found in
the free cities, where, in a dark passage-way, a lamp is sometimes placed,
and a devotional image near it.]
 
[Footnote 28: It was a superstitious belief that the presence of buried
treasure was indicated by a blue flame.]
 
[Footnote 29: Lion-dollars--a Bohemian coin, first minted three centuries
ago, by Count Schlick, from the mines of Joachim's-Thal. The one side
bears a lion, the other a full length image of St. John.]
 
[Footnote 30: An imitation of Ophelia's song: _Hamlet_, act 14, scene 5.]
 
[Footnote 31: The Rat-catcher was supposed to have the art of drawing rats
after him by his whistle, like a sort of Orpheus.]
 
[Footnote 32: Walpurgis Night. May-night. Walpurgis is the female saint
who converted the Saxons to Christianity.--The Brocken or Blocksberg is
the highest peak of the Harz mountains, which comprise about 1350 square
miles.--Schirke and Elend are two villages in the neighborhood.]
 
[Footnote 33: Shelley's translation of this couplet is very fine:
("_O si sic omnia!_")
 
"The giant-snouted crags, ho! ho!
How they snort and how they blow!"]
 
[Footnote 34: The original is _Windsbraut_, (wind's-bride,) the word used
in Luther's Bible to translate Paul's _Euroclydon_.]
 
[Footnote 35: One of the names of the devil in Germany.]
 
[Footnote 36: One of the names of Beelzebub.]
 
[Footnote 37: "The Talmudists say that Adam had a wife called Lilis before
he married Eve, and of her he begat nothing but devils."
_Burton's Anatomy of Melancholy_.
 
A learned writer says that _Lullaby_ is derived from "Lilla, abi!" "Begone
Lilleth!" she having been supposed to lie in wait for children to kill
them.]
 
[Footnote 38: This name, derived from two Greek words meaning _rump_ and
_fancy_, was meant for Nicolai of Berlin, a great hater of Goethe's
writings, and is explained by the fact that the man had for a long time a
violent affection of the nerves, and by the application he made of leeches
as a remedy, (alluded to by Mephistopheles.)]
 
[Footnote 39: Tegel (mistranslated _pond_ by Shelley) is a small place a
few miles from Berlin, whose inhabitants were, in 1799, hoaxed by a ghost
story, of which the scene was laid in the former place.]
 
[Footnote 40: The park in Vienna.]
 
[Footnote 41: He was scene-painter to the Weimar theatre.]
 
[Footnote 42: A poem of Schiller's, which gave great offence to the
religious people of his day.]
 
[Footnote 43: A literal translation of _Maulen_, but a slang-term in
Yankee land.]
 
[Footnote 44: Epigrams, published from time to time by Goethe and Schiller
jointly. Hennings (whose name heads the next quatrain) was editor of the
_Musaget_, (a title of Apollo, "leader of the muses,") and also of the
_Genius of the Age_. The other satirical allusions to classes of
notabilities will, without difficulty, be guessed out by the readers.]
 
[Footnote 45: "_Doubt_ is the only rhyme for devil," in German.]
 
[Footnote 46: The French translator, Stapfer, assigns as the probable
reason why this scene alone, of the whole drama, should have been left in
prose, "that it might not be said that Faust wanted any one of the
possible forms of style."]
 
[Footnote 47: Literally the _raven-stone_.]
 
[Footnote 48: The _blood-seat_, in allusion to the old German custom of
tying a woman, who was to be beheaded, into a wooden chair.]
 
* * * * *
 
P. S. There is a passage on page 84, the speech of Faust, ending with the
lines:--
 
Show me the fruit that, ere it's plucked, will rot,
And trees from which new green is daily peeping,
 
which seems to have puzzled or misled so much, not only English
translators, but even German critics, that the present translator has
concluded, for once, to depart from his usual course, and play the
commentator, by giving his idea of Goethe's meaning, which is this: Faust
admits that the devil has all the different kinds of Sodom-apples which he
has just enumerated, gold that melts away in the hand, glory that vanishes
like a meteor, and pleasure that perishes in the possession. But all these
torments are too insipid for Faust's morbid and mad hankering after the
luxury of spiritual pain. Show me, he says, the fruit that rots _before_
one can pluck it, and [a still stronger expression of his diseased craving
for agony] trees that fade so quickly as to be every day just putting
forth new green, only to tantalize one with perpetual promise and
perpetual disappointment.
 
 
 
 
 
End of the Project Gutenberg EBook of Faust, by Goethe
 
*** END OF THIS PROJECT GUTENBERG EBOOK FAUST ***
 
***** This file should be named 14460-8.txt or 14460-8.zip *****
This and all associated files of various formats will be found in:
http://www.gutenberg.net/1/4/4/6/14460/
 
Produced by Juliet Sutherland, Charles Bidwell and the PG Online
Distributed Proofreading Team
 
 
Updated editions will replace the previous one--the old editions
will be renamed.
 
Creating the works from public domain print editions means that no
one owns a United States copyright in these works, so the Foundation
(and you!) can copy and distribute it in the United States without
permission and without paying copyright royalties. Special rules,
set forth in the General Terms of Use part of this license, apply to
copying and distributing Project Gutenberg-tm electronic works to
protect the PROJECT GUTENBERG-tm concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if you
charge for the eBooks, unless you receive specific permission. If you
do not charge anything for copies of this eBook, complying with the
rules is very easy. You may use this eBook for nearly any purpose
such as creation of derivative works, reports, performances and
research. They may be modified and printed and given away--you may do
practically ANYTHING with public domain eBooks. Redistribution is
subject to the trademark license, especially commercial
redistribution.
 
 
 
*** START: FULL LICENSE ***
 
THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK
 
To protect the Project Gutenberg-tm mission of promoting the free
distribution of electronic works, by using or distributing this work
(or any other work associated in any way with the phrase "Project
Gutenberg"), you agree to comply with all the terms of the Full Project
Gutenberg-tm License (available with this file or online at
http://gutenberg.net/license).
 
 
Section 1. General Terms of Use and Redistributing Project Gutenberg-tm
electronic works
 
1.A. By reading or using any part of this Project Gutenberg-tm
electronic work, you indicate that you have read, understand, agree to
and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or destroy
all copies of Project Gutenberg-tm electronic works in your possession.
If you paid a fee for obtaining a copy of or access to a Project
Gutenberg-tm electronic work and you do not agree to be bound by the
terms of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.
 
1.B. "Project Gutenberg" is a registered trademark. It may only be
used on or associated in any way with an electronic work by people who
agree to be bound by the terms of this agreement. There are a few
things that you can do with most Project Gutenberg-tm electronic works
even without complying with the full terms of this agreement. See
paragraph 1.C below. There are a lot of things you can do with Project
Gutenberg-tm electronic works if you follow the terms of this agreement
and help preserve free future access to Project Gutenberg-tm electronic
works. See paragraph 1.E below.
 
1.C. The Project Gutenberg Literary Archive Foundation ("the Foundation"
or PGLAF), owns a compilation copyright in the collection of Project
Gutenberg-tm electronic works. Nearly all the individual works in the
collection are in the public domain in the United States. If an
individual work is in the public domain in the United States and you are
located in the United States, we do not claim a right to prevent you from
copying, distributing, performing, displaying or creating derivative
works based on the work as long as all references to Project Gutenberg
are removed. Of course, we hope that you will support the Project
Gutenberg-tm mission of promoting free access to electronic works by
freely sharing Project Gutenberg-tm works in compliance with the terms of
this agreement for keeping the Project Gutenberg-tm name associated with
the work. You can easily comply with the terms of this agreement by
keeping this work in the same format with its attached full Project
Gutenberg-tm License when you share it without charge with others.
 
1.D. The copyright laws of the place where you are located also govern
what you can do with this work. Copyright laws in most countries are in
a constant state of change. If you are outside the United States, check
the laws of your country in addition to the terms of this agreement
before downloading, copying, displaying, performing, distributing or
creating derivative works based on this work or any other Project
Gutenberg-tm work. The Foundation makes no representations concerning
the copyright status of any work in any country outside the United
States.
 
1.E. Unless you have removed all references to Project Gutenberg:
 
1.E.1. The following sentence, with active links to, or other immediate
access to, the full Project Gutenberg-tm License must appear prominently
whenever any copy of a Project Gutenberg-tm work (any work on which the
phrase "Project Gutenberg" appears, or with which the phrase "Project
Gutenberg" is associated) is accessed, displayed, performed, viewed,
copied or distributed:
 
This eBook is for the use of anyone anywhere at no cost and with
almost no restrictions whatsoever. You may copy it, give it away or
re-use it under the terms of the Project Gutenberg License included
with this eBook or online at www.gutenberg.net
 
1.E.2. If an individual Project Gutenberg-tm electronic work is derived
from the public domain (does not contain a notice indicating that it is
posted with permission of the copyright holder), the work can be copied
and distributed to anyone in the United States without paying any fees
or charges. If you are redistributing or providing access to a work
with the phrase "Project Gutenberg" associated with or appearing on the
work, you must comply either with the requirements of paragraphs 1.E.1
through 1.E.7 or obtain permission for the use of the work and the
Project Gutenberg-tm trademark as set forth in paragraphs 1.E.8 or
1.E.9.
 
1.E.3. If an individual Project Gutenberg-tm electronic work is posted
with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any additional
terms imposed by the copyright holder. Additional terms will be linked
to the Project Gutenberg-tm License for all works posted with the
permission of the copyright holder found at the beginning of this work.
 
1.E.4. Do not unlink or detach or remove the full Project Gutenberg-tm
License terms from this work, or any files containing a part of this
work or any other work associated with Project Gutenberg-tm.
 
1.E.5. Do not copy, display, perform, distribute or redistribute this
electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1 with
active links or immediate access to the full terms of the Project
Gutenberg-tm License.
 
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form, including any
word processing or hypertext form. However, if you provide access to or
distribute copies of a Project Gutenberg-tm work in a format other than
"Plain Vanilla ASCII" or other format used in the official version
posted on the official Project Gutenberg-tm web site (www.gutenberg.net),
you must, at no additional cost, fee or expense to the user, provide a
copy, a means of exporting a copy, or a means of obtaining a copy upon
request, of the work in its original "Plain Vanilla ASCII" or other
form. Any alternate format must include the full Project Gutenberg-tm
License as specified in paragraph 1.E.1.
 
1.E.7. Do not charge a fee for access to, viewing, displaying,
performing, copying or distributing any Project Gutenberg-tm works
unless you comply with paragraph 1.E.8 or 1.E.9.
 
1.E.8. You may charge a reasonable fee for copies of or providing
access to or distributing Project Gutenberg-tm electronic works provided
that
 
- You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg-tm works calculated using the method
you already use to calculate your applicable taxes. The fee is
owed to the owner of the Project Gutenberg-tm trademark, but he
has agreed to donate royalties under this paragraph to the
Project Gutenberg Literary Archive Foundation. Royalty payments
must be paid within 60 days following each date on which you
prepare (or are legally required to prepare) your periodic tax
returns. Royalty payments should be clearly marked as such and
sent to the Project Gutenberg Literary Archive Foundation at the
address specified in Section 4, "Information about donations to
the Project Gutenberg Literary Archive Foundation."
 
- You provide a full refund of any money paid by a user who notifies
you in writing (or by e-mail) within 30 days of receipt that s/he
does not agree to the terms of the full Project Gutenberg-tm
License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg-tm works.
 
- You provide, in accordance with paragraph 1.F.3, a full refund of any
money paid for a work or a replacement copy, if a defect in the
electronic work is discovered and reported to you within 90 days
of receipt of the work.
 
- You comply with all other terms of this agreement for free
distribution of Project Gutenberg-tm works.
 
1.E.9. If you wish to charge a fee or distribute a Project Gutenberg-tm
electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
both the Project Gutenberg Literary Archive Foundation and Michael
Hart, the owner of the Project Gutenberg-tm trademark. Contact the
Foundation as set forth in Section 3 below.
 
1.F.
 
1.F.1. Project Gutenberg volunteers and employees expend considerable
effort to identify, do copyright research on, transcribe and proofread
public domain works in creating the Project Gutenberg-tm
collection. Despite these efforts, Project Gutenberg-tm electronic
works, and the medium on which they may be stored, may contain
"Defects," such as, but not limited to, incomplete, inaccurate or
corrupt data, transcription errors, a copyright or other intellectual
property infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be read by
your equipment.
 
1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for the "Right
of Replacement or Refund" described in paragraph 1.F.3, the Project
Gutenberg Literary Archive Foundation, the owner of the Project
Gutenberg-tm trademark, and any other party distributing a Project
Gutenberg-tm electronic work under this agreement, disclaim all
liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE
PROVIDED IN PARAGRAPH F3. YOU AGREE THAT THE FOUNDATION, THE
TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE
LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE OR
INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH
DAMAGE.
 
1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you discover a
defect in this electronic work within 90 days of receiving it, you can
receive a refund of the money (if any) you paid for it by sending a
written explanation to the person you received the work from. If you
received the work on a physical medium, you must return the medium with
your written explanation. The person or entity that provided you with
the defective work may elect to provide a replacement copy in lieu of a
refund. If you received the work electronically, the person or entity
providing it to you may choose to give you a second opportunity to
receive the work electronically in lieu of a refund. If the second copy
is also defective, you may demand a refund in writing without further
opportunities to fix the problem.
 
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you 'AS-IS' WITH NO OTHER
WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
WARRANTIES OF MERCHANTIBILITY OR FITNESS FOR ANY PURPOSE.
 
1.F.5. Some states do not allow disclaimers of certain implied
warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted by
the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.
 
1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation, the
trademark owner, any agent or employee of the Foundation, anyone
providing copies of Project Gutenberg-tm electronic works in accordance
with this agreement, and any volunteers associated with the production,
promotion and distribution of Project Gutenberg-tm electronic works,
harmless from all liability, costs and expenses, including legal fees,
that arise directly or indirectly from any of the following which you do
or cause to occur: (a) distribution of this or any Project Gutenberg-tm
work, (b) alteration, modification, or additions or deletions to any
Project Gutenberg-tm work, and (c) any Defect you cause.
 
 
Section 2. Information about the Mission of Project Gutenberg-tm
 
Project Gutenberg-tm is synonymous with the free distribution of
electronic works in formats readable by the widest variety of computers
including obsolete, old, middle-aged and new computers. It exists
because of the efforts of hundreds of volunteers and donations from
people in all walks of life.
 
Volunteers and financial support to provide volunteers with the
assistance they need, is critical to reaching Project Gutenberg-tm's
goals and ensuring that the Project Gutenberg-tm collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a secure
and permanent future for Project Gutenberg-tm and future generations.
To learn more about the Project Gutenberg Literary Archive Foundation
and how your efforts and donations can help, see Sections 3 and 4
and the Foundation web page at http://www.pglaf.org.
 
 
Section 3. Information about the Project Gutenberg Literary Archive
Foundation
 
The Project Gutenberg Literary Archive Foundation is a non profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation's EIN or federal tax identification
number is 64-6221541. Its 501(c)(3) letter is posted at
http://pglaf.org/fundraising. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state's laws.
 
The Foundation's principal office is located at 4557 Melan Dr. S.
Fairbanks, AK, 99712., but its volunteers and employees are scattered
throughout numerous locations. Its business office is located at
809 North 1500 West, Salt Lake City, UT 84116, (801) 596-1887, email
business@pglaf.org. Email contact links and up to date contact
information can be found at the Foundation's web site and official
page at http://pglaf.org
 
For additional contact information:
Dr. Gregory B. Newby
Chief Executive and Director
gbnewby@pglaf.org
 
 
Section 4. Information about Donations to the Project Gutenberg
Literary Archive Foundation
 
Project Gutenberg-tm depends upon and cannot survive without wide
spread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can be
freely distributed in machine readable form accessible by the widest
array of equipment including outdated equipment. Many small donations
($1 to $5,000) are particularly important to maintaining tax exempt
status with the IRS.
 
The Foundation is committed to complying with the laws regulating
charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and keep up
with these requirements. We do not solicit donations in locations
where we have not received written confirmation of compliance. To
SEND DONATIONS or determine the status of compliance for any
particular state visit http://pglaf.org
 
While we cannot and do not solicit contributions from states where we
have not met the solicitation requirements, we know of no prohibition
against accepting unsolicited donations from donors in such states who
approach us with offers to donate.
 
International donations are gratefully accepted, but we cannot make
any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.
 
Please check the Project Gutenberg Web pages for current donation
methods and addresses. Donations are accepted in a number of other
ways including including checks, online payments and credit card
donations. To donate, please visit: http://pglaf.org/donate
 
 
Section 5. General Information About Project Gutenberg-tm electronic
works.
 
Professor Michael S. Hart is the originator of the Project Gutenberg-tm
concept of a library of electronic works that could be freely shared
with anyone. For thirty years, he produced and distributed Project
Gutenberg-tm eBooks with only a loose network of volunteer support.
 
 
Project Gutenberg-tm eBooks are often created from several printed
editions, all of which are confirmed as Public Domain in the U.S.
unless a copyright notice is included. Thus, we do not necessarily
keep eBooks in compliance with any particular paper edition.
 
 
Most people start at our Web site which has the main PG search facility:
 
http://www.gutenberg.net
 
This Web site includes information about Project Gutenberg-tm,
including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how to
subscribe to our email newsletter to hear about new eBooks.
 
/trunk/api/js/dojo1.0/dojox/storage/tests/test_storage.js
New file
0,0 → 1,428
dojo.require("dojox.storage");
 
 
var TestStorage = {
currentProvider: "default",
currentNamespace: dojox.storage.DEFAULT_NAMESPACE,
initialize: function(){
//console.debug("test_storage.initialize()");
// do we even have a storage provider?
if(dojox.storage.manager.available == false){
alert("No storage provider is available on this browser");
return;
}
// clear out old values and enable input forms
dojo.byId("storageNamespace").value = this.currentNamespace;
dojo.byId("storageNamespace").disabled = false;
dojo.byId("storageKey").value = "";
dojo.byId("storageKey").disabled = false;
dojo.byId("storageValue").value = "";
dojo.byId("storageValue").disabled = false;
// write out our available namespaces
this._printAvailableNamespaces();
// write out our available keys
this._printAvailableKeys();
// initialize our event handlers
var namespaceDirectory = dojo.byId("namespaceDirectory");
dojo.connect(namespaceDirectory, "onchange", this, this.namespaceChange);
var directory = dojo.byId("directory");
dojo.connect(directory, "onchange", this, this.directoryChange);
var storageValueElem = dojo.byId("storageValue");
dojo.connect(storageValueElem, "onkeyup", this, this.printValueSize);
// make the directory be unselected if the key name field gets focus
var keyNameField = dojo.byId("storageKey");
dojo.connect(keyNameField, "onfocus", function(evt){
directory.selectedIndex = -1;
});
// add onclick listeners to all of our buttons
var buttonContainer = dojo.byId("buttonContainer");
var currentChild = buttonContainer.firstChild;
while(currentChild.nextSibling != null){
if(currentChild.nodeType == 1){
var buttonName = currentChild.id;
var functionName = buttonName.match(/^(.*)Button$/)[1];
dojo.connect(currentChild, "onclick", this, this[functionName]);
currentChild.disabled = false;
}
currentChild = currentChild.nextSibling;
}
// print out metadata
this._printProviderMetadata();
// disable the configuration button if none is supported for this provider
if(dojox.storage.hasSettingsUI() == false){
dojo.byId("configureButton").disabled = true;
}
},
namespaceChange: function(evt){
var ns = evt.target.value;
this.currentNamespace = ns;
// update our available keys
this._printAvailableKeys();
// clear out our key and values
dojo.byId("storageNamespace").value = this.currentNamespace;
dojo.byId("storageKey").value = "";
dojo.byId("storageValue").value = "";
},
directoryChange: function(evt){
var key = evt.target.value;
// add this value into the form
var keyNameField = dojo.byId("storageKey");
keyNameField.value = key;
this._handleLoad(key);
},
load: function(evt){
// cancel the button's default behavior
evt.preventDefault();
evt.stopPropagation();
// get the key to load
var key = dojo.byId("storageKey").value;
if(key == null || typeof key == "undefined" || key == ""){
alert("Please enter a key name");
return;
}
this._handleLoad(key);
},
save: function(evt){
// cancel the button's default behavior
evt.preventDefault();
evt.stopPropagation();
// get the new values
var key = dojo.byId("storageKey").value;
var value = dojo.byId("storageValue").value;
var namespace = dojo.byId("storageNamespace").value;
if(key == null || typeof key == "undefined" || key == ""){
alert("Please enter a key name");
return;
}
if(value == null || typeof value == "undefined" || value == ""){
alert("Please enter a key value");
return;
}
// print out the size of the value
this.printValueSize();
// do the save
this._save(key, value, namespace);
},
clearNamespace: function(evt){
// cancel the button's default behavior
evt.preventDefault();
evt.stopPropagation();
dojox.storage.clear(this.currentNamespace);
this._printAvailableNamespaces();
this._printAvailableKeys();
},
configure: function(evt){
// cancel the button's default behavior
evt.preventDefault();
evt.stopPropagation();
if(dojox.storage.hasSettingsUI()){
// redraw our keys after the dialog is closed, in
// case they have all been erased
var self = this;
dojox.storage.onHideSettingsUI = function(){
self._printAvailableKeys();
}
// show the dialog
dojox.storage.showSettingsUI();
}
},
remove: function(evt){
// cancel the button's default behavior
evt.preventDefault();
evt.stopPropagation();
// determine what key to delete; if the directory has a selected value,
// use that; otherwise, use the key name field
var directory = dojo.byId("directory");
var keyNameField = dojo.byId("storageKey");
var keyValueField = dojo.byId("storageValue");
var key;
if(directory.selectedIndex != -1){
key = directory.value;
// delete this option
var options = directory.childNodes;
for(var i = 0; i < options.length; i++){
if(options[i].nodeType == 1 &&
options[i].value == key){
directory.removeChild(options[i]);
break;
}
}
}else{
key = keyNameField.value;
}
keyNameField.value = "";
keyValueField.value = "";
// now delete the value
this._printStatus("Removing '" + key + "'...");
if(this.currentNamespace == dojox.storage.DEFAULT_NAMESPACE){
dojox.storage.remove(key);
}else{
dojox.storage.remove(key, this.currentNamespace);
}
// update our UI
this._printAvailableNamespaces();
this._printStatus("Removed '" + key);
},
printValueSize: function(){
var storageValue = dojo.byId("storageValue").value;
var size = 0;
if(storageValue != null && typeof storageValue != "undefined"){
size = storageValue.length;
}
// determine the units we are dealing with
var units;
if(size < 1024)
units = " bytes";
else{
units = " K";
size = size / 1024;
size = Math.round(size);
}
size = size + units;
var valueSize = dojo.byId("valueSize");
valueSize.innerHTML = size;
},
saveBook: function(evt){
this._printStatus("Loading book...");
var d = dojo.xhrGet({
url: "resources/testBook.txt",
handleAs: "text"
});
d.addCallback(dojo.hitch(this, function(results){
this._printStatus("Book loaded");
this._save("testBook", results);
}));
d.addErrback(dojo.hitch(this, function(error){
alert("Unable to load testBook.txt: " + error);
}));
if(!typeof evt != "undefined" && evt != null){
evt.preventDefault();
evt.stopPropagation();
}
return false;
},
saveXML: function(evt){
this._printStatus("Loading XML...");
var d = dojo.xhrGet({
url: "resources/testXML.xml",
handleAs: "text"
});
d.addCallback(dojo.hitch(this, function(results){
this._printStatus("XML loaded");
this._save("testXML", results);
}));
d.addErrback(dojo.hitch(this, function(error){
alert("Unable to load testXML.xml: " + error);
}));
if(!typeof evt != "undefined" && evt != null){
evt.preventDefault();
evt.stopPropagation();
}
return false;
},
_save: function(key, value, namespace){
this._printStatus("Saving '" + key + "'...");
var self = this;
var saveHandler = function(status, keyName){
if(status == dojox.storage.FAILED){
alert("You do not have permission to store data for this web site. "
+ "Press the Configure button to grant permission.");
}else if(status == dojox.storage.SUCCESS){
// clear out the old value
dojo.byId("storageKey").value = "";
dojo.byId("storageValue").value = "";
self._printStatus("Saved '" + key + "'");
if(typeof namespace != "undefined"
&& namespace != null){
self.currentNamespace = namespace;
}
// update the list of available keys and namespaces
// put this on a slight timeout, because saveHandler is called back
// from Flash, which can cause problems in Flash 8 communication
// which affects Safari
// FIXME: Find out what is going on in the Flash 8 layer and fix it
// there
window.setTimeout(function(){
self._printAvailableKeys();
self._printAvailableNamespaces();
}, 1);
}
};
try{
if(namespace == dojox.storage.DEFAULT_NAMESPACE){
dojox.storage.put(key, value, saveHandler);
}else{
dojox.storage.put(key, value, saveHandler, namespace);
}
}catch(exp){
alert(exp);
}
},
_printAvailableKeys: function(){
var directory = dojo.byId("directory");
// clear out any old keys
directory.innerHTML = "";
// add new ones
var availableKeys;
if(this.currentNamespace == dojox.storage.DEFAULT_NAMESPACE){
availableKeys = dojox.storage.getKeys();
}else{
availableKeys = dojox.storage.getKeys(this.currentNamespace);
}
for (var i = 0; i < availableKeys.length; i++){
var optionNode = document.createElement("option");
optionNode.appendChild(document.createTextNode(availableKeys[i]));
optionNode.value = availableKeys[i];
directory.appendChild(optionNode);
}
},
_printAvailableNamespaces: function(){
var namespacesDir = dojo.byId("namespaceDirectory");
// clear out any old namespaces
namespacesDir.innerHTML = "";
// add new ones
var availableNamespaces = dojox.storage.getNamespaces();
for (var i = 0; i < availableNamespaces.length; i++){
var optionNode = document.createElement("option");
optionNode.appendChild(document.createTextNode(availableNamespaces[i]));
optionNode.value = availableNamespaces[i];
namespacesDir.appendChild(optionNode);
}
},
_handleLoad: function(key){
this._printStatus("Loading '" + key + "'...");
// get the value
var results;
if(this.currentNamespace == dojox.storage.DEFAULT_NAMESPACE){
results = dojox.storage.get(key);
}else{
results = dojox.storage.get(key, this.currentNamespace);
}
// jsonify it if it is a JavaScript object
if(typeof results != "string"){
results = dojo.toJson(results);
}
// print out its value
this._printStatus("Loaded '" + key + "'");
dojo.byId("storageValue").value = results;
// print out the size of the value
this.printValueSize();
},
_printProviderMetadata: function(){
var storageType = dojox.storage.manager.currentProvider.declaredClass;
var isSupported = dojox.storage.isAvailable();
var maximumSize = dojox.storage.getMaximumSize();
var permanent = dojox.storage.isPermanent();
var uiConfig = dojox.storage.hasSettingsUI();
var moreInfo = "";
if(dojox.storage.manager.currentProvider.declaredClass
== "dojox.storage.FlashStorageProvider"){
moreInfo = "Flash Comm Version " + dojo.flash.info.commVersion;
}
dojo.byId("currentStorageProvider").innerHTML = storageType;
dojo.byId("isSupported").innerHTML = isSupported;
dojo.byId("isPersistent").innerHTML = permanent;
dojo.byId("hasUIConfig").innerHTML = uiConfig;
dojo.byId("maximumSize").innerHTML = maximumSize;
dojo.byId("moreInfo").innerHTML = moreInfo;
},
_printStatus: function(message){
// remove the old status
var top = dojo.byId("top");
for (var i = 0; i < top.childNodes.length; i++){
var currentNode = top.childNodes[i];
if (currentNode.nodeType == 1 &&
currentNode.className == "status"){
top.removeChild(currentNode);
}
}
var status = document.createElement("span");
status.className = "status";
status.innerHTML = message;
top.appendChild(status);
dojo.fadeOut({node: status, duration: 2000}).play();
}
};
 
// wait until the storage system is finished loading
if(dojox.storage.manager.isInitialized() == false){ // storage might already be loaded when we get here
dojo.connect(dojox.storage.manager, "loaded", TestStorage, TestStorage.initialize);
}else{
dojo.connect(dojo, "loaded", TestStorage, TestStorage.initialize);
}
/trunk/api/js/dojo1.0/dojox/storage/storage_dialog.fla
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/storage/storage_dialog.fla
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/storage/Provider.js
New file
0,0 → 1,327
if(!dojo._hasResource["dojox.storage.Provider"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.storage.Provider"] = true;
dojo.provide("dojox.storage.Provider");
 
dojo.declare("dojox.storage.Provider", null, {
// summary: A singleton for working with dojox.storage.
// description:
// dojox.storage exposes the current available storage provider on this
// platform. It gives you methods such as dojox.storage.put(),
// dojox.storage.get(), etc.
//
// For more details on dojox.storage, see the primary documentation
// page at
// http://manual.dojotoolkit.org/storage.html
//
// Note for storage provider developers who are creating subclasses-
// This is the base class for all storage providers Specific kinds of
// Storage Providers should subclass this and implement these methods.
// You should avoid initialization in storage provider subclass's
// constructor; instead, perform initialization in your initialize()
// method.
constructor: function(){
},
// SUCCESS: String
// Flag that indicates a put() call to a
// storage provider was succesful.
SUCCESS: "success",
// FAILED: String
// Flag that indicates a put() call to
// a storage provider failed.
FAILED: "failed",
// PENDING: String
// Flag that indicates a put() call to a
// storage provider is pending user approval.
PENDING: "pending",
// SIZE_NOT_AVAILABLE: String
// Returned by getMaximumSize() if this storage provider can not determine
// the maximum amount of data it can support.
SIZE_NOT_AVAILABLE: "Size not available",
// SIZE_NO_LIMIT: String
// Returned by getMaximumSize() if this storage provider has no theoretical
// limit on the amount of data it can store.
SIZE_NO_LIMIT: "No size limit",
 
// DEFAULT_NAMESPACE: String
// The namespace for all storage operations. This is useful if several
// applications want access to the storage system from the same domain but
// want different storage silos.
DEFAULT_NAMESPACE: "default",
// onHideSettingsUI: Function
// If a function is assigned to this property, then when the settings
// provider's UI is closed this function is called. Useful, for example,
// if the user has just cleared out all storage for this provider using
// the settings UI, and you want to update your UI.
onHideSettingsUI: null,
 
initialize: function(){
// summary:
// Allows this storage provider to initialize itself. This is
// called after the page has finished loading, so you can not do
// document.writes(). Storage Provider subclasses should initialize
// themselves inside of here rather than in their function
// constructor.
console.warn("dojox.storage.initialize not implemented");
},
isAvailable: function(){ /*Boolean*/
// summary:
// Returns whether this storage provider is available on this
// platform.
console.warn("dojox.storage.isAvailable not implemented");
},
 
put: function( /*string*/ key,
/*object*/ value,
/*function*/ resultsHandler,
/*string?*/ namespace){
// summary:
// Puts a key and value into this storage system.
// description:
// Example-
// var resultsHandler = function(status, key, message){
// alert("status="+status+", key="+key+", message="+message);
// };
// dojox.storage.put("test", "hello world", resultsHandler);
//
// Important note: if you are using Dojo Storage in conjunction with
// Dojo Offline, then you don't need to provide
// a resultsHandler; this is because for Dojo Offline we
// use Google Gears to persist data, which has unlimited data
// once the user has given permission. If you are using Dojo
// Storage apart from Dojo Offline, then under the covers hidden
// Flash might be used, which is both asychronous and which might
// get denied; in this case you must provide a resultsHandler.
// key:
// A string key to use when retrieving this value in the future.
// value:
// A value to store; this can be any JavaScript type.
// resultsHandler:
// A callback function that will receive three arguments. The
// first argument is one of three values: dojox.storage.SUCCESS,
// dojox.storage.FAILED, or dojox.storage.PENDING; these values
// determine how the put request went. In some storage systems
// users can deny a storage request, resulting in a
// dojox.storage.FAILED, while in other storage systems a storage
// request must wait for user approval, resulting in a
// dojox.storage.PENDING status until the request is either
// approved or denied, resulting in another call back with
// dojox.storage.SUCCESS.
// The second argument in the call back is the key name that was being stored.
// The third argument in the call back is an optional message that
// details possible error messages that might have occurred during
// the storage process.
// namespace:
// Optional string namespace that this value will be placed into;
// if left off, the value will be placed into dojox.storage.DEFAULT_NAMESPACE
console.warn("dojox.storage.put not implemented");
},
 
get: function(/*string*/ key, /*string?*/ namespace){ /*Object*/
// summary:
// Gets the value with the given key. Returns null if this key is
// not in the storage system.
// key:
// A string key to get the value of.
// namespace:
// Optional string namespace that this value will be retrieved from;
// if left off, the value will be retrieved from dojox.storage.DEFAULT_NAMESPACE
// return: Returns any JavaScript object type; null if the key is not present
console.warn("dojox.storage.get not implemented");
},
 
hasKey: function(/*string*/ key, /*string?*/ namespace){ /*Boolean*/
// summary: Determines whether the storage has the given key.
return (this.get(key) != null);
},
 
getKeys: function(/*string?*/ namespace){ /*Array*/
// summary: Enumerates all of the available keys in this storage system.
// return: Array of available keys
console.warn("dojox.storage.getKeys not implemented");
},
clear: function(/*string?*/ namespace){
// summary:
// Completely clears this storage system of all of it's values and
// keys. If 'namespace' is provided just clears the keys in that
// namespace.
console.warn("dojox.storage.clear not implemented");
},
remove: function(/*string*/ key, /*string?*/ namespace){
// summary: Removes the given key from this storage system.
console.warn("dojox.storage.remove not implemented");
},
getNamespaces: function(){ /*string[]*/
console.warn("dojox.storage.getNamespaces not implemented");
},
 
isPermanent: function(){ /*Boolean*/
// summary:
// Returns whether this storage provider's values are persisted
// when this platform is shutdown.
console.warn("dojox.storage.isPermanent not implemented");
},
 
getMaximumSize: function(){ /* mixed */
// summary: The maximum storage allowed by this provider
// returns:
// Returns the maximum storage size
// supported by this provider, in
// thousands of bytes (i.e., if it
// returns 60 then this means that 60K
// of storage is supported).
//
// If this provider can not determine
// it's maximum size, then
// dojox.storage.SIZE_NOT_AVAILABLE is
// returned; if there is no theoretical
// limit on the amount of storage
// this provider can return, then
// dojox.storage.SIZE_NO_LIMIT is
// returned
console.warn("dojox.storage.getMaximumSize not implemented");
},
putMultiple: function( /*array*/ keys,
/*array*/ values,
/*function*/ resultsHandler,
/*string?*/ namespace){
// summary:
// Puts multiple keys and values into this storage system.
// description:
// Example-
// var resultsHandler = function(status, key, message){
// alert("status="+status+", key="+key+", message="+message);
// };
// dojox.storage.put(["test"], ["hello world"], resultsHandler);
//
// Important note: if you are using Dojo Storage in conjunction with
// Dojo Offline, then you don't need to provide
// a resultsHandler; this is because for Dojo Offline we
// use Google Gears to persist data, which has unlimited data
// once the user has given permission. If you are using Dojo
// Storage apart from Dojo Offline, then under the covers hidden
// Flash might be used, which is both asychronous and which might
// get denied; in this case you must provide a resultsHandler.
// keys:
// An array of string keys to use when retrieving this value in the future,
// one per value to be stored
// values:
// An array of values to store; this can be any JavaScript type, though the
// performance of plain strings is considerably better
// resultsHandler:
// A callback function that will receive three arguments. The
// first argument is one of three values: dojox.storage.SUCCESS,
// dojox.storage.FAILED, or dojox.storage.PENDING; these values
// determine how the put request went. In some storage systems
// users can deny a storage request, resulting in a
// dojox.storage.FAILED, while in other storage systems a storage
// request must wait for user approval, resulting in a
// dojox.storage.PENDING status until the request is either
// approved or denied, resulting in another call back with
// dojox.storage.SUCCESS.
// The second argument in the call back is the key name that was being stored.
// The third argument in the call back is an optional message that
// details possible error messages that might have occurred during
// the storage process.
// namespace:
// Optional string namespace that this value will be placed into;
// if left off, the value will be placed into dojox.storage.DEFAULT_NAMESPACE
console.warn("dojox.storage.putMultiple not implemented");
// JAC: We could implement a 'default' puMultiple here by just doing each put individually
},
 
getMultiple: function(/*array*/ keys, /*string?*/ namespace){ /*Object*/
// summary:
// Gets the valuse corresponding to each of the given keys.
// Returns a null array element for each given key that is
// not in the storage system.
// keys:
// An array of string keys to get the value of.
// namespace:
// Optional string namespace that this value will be retrieved from;
// if left off, the value will be retrieved from dojox.storage.DEFAULT_NAMESPACE
// return: Returns any JavaScript object type; null if the key is not present
 
console.warn("dojox.storage.getMultiple not implemented");
// JAC: We could implement a 'default' getMultiple here by just doing each get individually
},
 
removeMultiple: function(/*array*/ keys, /*string?*/ namespace) {
// summary: Removes the given keys from this storage system.
 
// JAC: We could implement a 'default' removeMultiple here by just doing each remove individually
console.warn("dojox.storage.remove not implemented");
},
isValidKeyArray: function( keys) {
if(keys === null || typeof keys === "undefined" || ! keys instanceof Array){
return false;
}
// JAC: This could be optimized by running the key validity test directly over a joined string
for(var k=0;k<keys.length;k++){
if(!this.isValidKey(keys[k])){
return false;
}
}
return true;
},
 
hasSettingsUI: function(){ /*Boolean*/
// summary: Determines whether this provider has a settings UI.
return false;
},
 
showSettingsUI: function(){
// summary: If this provider has a settings UI, determined
// by calling hasSettingsUI(), it is shown.
console.warn("dojox.storage.showSettingsUI not implemented");
},
 
hideSettingsUI: function(){
// summary: If this provider has a settings UI, hides it.
console.warn("dojox.storage.hideSettingsUI not implemented");
},
isValidKey: function(/*string*/ keyName){ /*Boolean*/
// summary:
// Subclasses can call this to ensure that the key given is valid
// in a consistent way across different storage providers. We use
// the lowest common denominator for key values allowed: only
// letters, numbers, and underscores are allowed. No spaces.
if((keyName == null)||(typeof keyName == "undefined")){
return false;
}
return /^[0-9A-Za-z_]*$/.test(keyName);
},
getResourceList: function(){ /* Array[] */
// summary:
// Returns a list of URLs that this
// storage provider might depend on.
// description:
// This method returns a list of URLs that this
// storage provider depends on to do its work.
// This list is used by the Dojo Offline Toolkit
// to cache these resources to ensure the machinery
// used by this storage provider is available offline.
// What is returned is an array of URLs.
return [];
}
});
 
}
/trunk/api/js/dojo1.0/dojox/storage/manager.js
New file
0,0 → 1,251
if(!dojo._hasResource["dojox.storage.manager"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.storage.manager"] = true;
dojo.provide("dojox.storage.manager");
//dojo.require("dojo.AdapterRegistry");
// FIXME: refactor this to use an AdapterRegistry
 
dojox.storage.manager = new function(){
// summary: A singleton class in charge of the dojox.storage system
// description:
// Initializes the storage systems and figures out the best available
// storage options on this platform.
// currentProvider: Object
// The storage provider that was automagically chosen to do storage
// on this platform, such as dojox.storage.FlashStorageProvider.
this.currentProvider = null;
// available: Boolean
// Whether storage of some kind is available.
this.available = false;
this._initialized = false;
this._providers = [];
this._onLoadListeners = [];
this.initialize = function(){
// summary:
// Initializes the storage system and autodetects the best storage
// provider we can provide on this platform
this.autodetect();
};
this.register = function(/*string*/ name, /*Object*/ instance){
// summary:
// Registers the existence of a new storage provider; used by
// subclasses to inform the manager of their existence. The
// storage manager will select storage providers based on
// their ordering, so the order in which you call this method
// matters.
// name:
// The full class name of this provider, such as
// "dojox.storage.FlashStorageProvider".
// instance:
// An instance of this provider, which we will use to call
// isAvailable() on.
this._providers[this._providers.length] = instance; //FIXME: push?
this._providers[name] = instance; // FIXME: this._providers is an array, not a hash
};
this.setProvider = function(storageClass){
// summary:
// Instructs the storageManager to use the given storage class for
// all storage requests.
// description:
// Example-
// dojox.storage.setProvider(
// dojox.storage.IEStorageProvider)
};
this.autodetect = function(){
// summary:
// Autodetects the best possible persistent storage provider
// available on this platform.
//console.debug("dojox.storage.manager.autodetect");
if(this._initialized){ // already finished
//console.debug("dojox.storage.manager already initialized; returning");
return;
}
 
// a flag to force the storage manager to use a particular
// storage provider type, such as
// djConfig = {forceStorageProvider: "dojox.storage.WhatWGStorageProvider"};
var forceProvider = djConfig["forceStorageProvider"]||false;
 
// go through each provider, seeing if it can be used
var providerToUse;
//FIXME: use dojo.some
for(var i = 0; i < this._providers.length; i++){
providerToUse = this._providers[i];
if(forceProvider == providerToUse.declaredClass){
// still call isAvailable for this provider, since this helps some
// providers internally figure out if they are available
// FIXME: This should be refactored since it is non-intuitive
// that isAvailable() would initialize some state
providerToUse.isAvailable();
break;
}else if(providerToUse.isAvailable()){
break;
}
}
if(!providerToUse){ // no provider available
this._initialized = true;
this.available = false;
this.currentProvider = null;
console.warn("No storage provider found for this platform");
this.loaded();
return;
}
// create this provider and mix in it's properties
// so that developers can do dojox.storage.put rather
// than dojox.storage.currentProvider.put, for example
this.currentProvider = providerToUse;
dojo.mixin(dojox.storage, this.currentProvider);
// have the provider initialize itself
dojox.storage.initialize();
this._initialized = true;
this.available = true;
};
this.isAvailable = function(){ /*Boolean*/
// summary: Returns whether any storage options are available.
return this.available;
};
this.addOnLoad = function(func){ /* void */
// summary:
// Adds an onload listener to know when Dojo Offline can be used.
// description:
// Adds a listener to know when Dojo Offline can be used. This
// ensures that the Dojo Offline framework is loaded and that the
// local dojox.storage system is ready to be used. This method is
// useful if you don't want to have a dependency on Dojo Events
// when using dojox.storage.
// func: Function
// A function to call when Dojo Offline is ready to go
this._onLoadListeners.push(func);
if(this.isInitialized()){
this._fireLoaded();
}
};
this.removeOnLoad = function(func){ /* void */
// summary: Removes the given onLoad listener
for(var i = 0; i < this._onLoadListeners.length; i++){
if(func == this._onLoadListeners[i]){
this._onLoadListeners = this._onLoadListeners.splice(i, 1);
break;
}
}
};
this.isInitialized = function(){ /*Boolean*/
// summary:
// Returns whether the storage system is initialized and ready to
// be used.
 
// FIXME: This should REALLY not be in here, but it fixes a tricky
// Flash timing bug
if(this.currentProvider != null
&& this.currentProvider.declaredClass == "dojox.storage.FlashStorageProvider"
&& dojox.flash.ready == false){
return false;
}else{
return this._initialized;
}
};
 
this.supportsProvider = function(/*string*/ storageClass){ /* Boolean */
// summary: Determines if this platform supports the given storage provider.
// description:
// Example-
// dojox.storage.manager.supportsProvider(
// "dojox.storage.InternetExplorerStorageProvider");
 
// construct this class dynamically
try{
// dynamically call the given providers class level isAvailable()
// method
var provider = eval("new " + storageClass + "()");
var results = provider.isAvailable();
if(!results){ return false; }
return results;
}catch(e){
return false;
}
};
 
this.getProvider = function(){ /* Object */
// summary: Gets the current provider
return this.currentProvider;
};
this.loaded = function(){
// summary:
// The storage provider should call this method when it is loaded
// and ready to be used. Clients who will use the provider will
// connect to this method to know when they can use the storage
// system. You can either use dojo.connect to connect to this
// function, or can use dojox.storage.manager.addOnLoad() to add
// a listener that does not depend on the dojo.event package.
// description:
// Example 1-
// if(dojox.storage.manager.isInitialized() == false){
// dojo.connect(dojox.storage.manager, "loaded", TestStorage, "initialize");
// }else{
// dojo.connect(dojo, "loaded", TestStorage, "initialize");
// }
// Example 2-
// dojox.storage.manager.addOnLoad(someFunction);
 
 
// FIXME: we should just provide a Deferred for this. That way you
// don't care when this happens or has happened. Deferreds are in Base
this._fireLoaded();
};
this._fireLoaded = function(){
//console.debug("dojox.storage.manager._fireLoaded");
dojo.forEach(this._onLoadListeners, function(i){
try{
i();
}catch(e){ console.debug(e); }
});
};
this.getResourceList = function(){
// summary:
// Returns a list of whatever resources are necessary for storage
// providers to work.
// description:
// This will return all files needed by all storage providers for
// this particular environment type. For example, if we are in the
// browser environment, then this will return the hidden SWF files
// needed by the FlashStorageProvider, even if we don't need them
// for the particular browser we are working within. This is meant
// to faciliate Dojo Offline, which must retrieve all resources we
// need offline into the offline cache -- we retrieve everything
// needed, in case another browser that requires different storage
// mechanisms hits the local offline cache. For example, if we
// were to sync against Dojo Offline on Firefox 2, then we would
// not grab the FlashStorageProvider resources needed for Safari.
var results = [];
dojo.forEach(dojox.storage.manager._providers, function(currentProvider){
results = results.concat(currentProvider.getResourceList());
});
return results;
}
};
 
}
/trunk/api/js/dojo1.0/dojox/storage/Storage.as
New file
0,0 → 1,386
import DojoExternalInterface;
 
class Storage {
public static var SUCCESS = "success";
public static var FAILED = "failed";
public static var PENDING = "pending";
// Wait the following number of milliseconds before flushing
public static var FLUSH_DELAY_DEFAULT = 500;
public var flush_delay;
public var so;
public var timer;
private var _NAMESPACE_KEY = "allNamespaces";
public function Storage(){
flush_delay = Storage.FLUSH_DELAY_DEFAULT;
//getURL("javascript:console.debug('FLASH:Storage constructor')");
DojoExternalInterface.initialize();
DojoExternalInterface.addCallback("put", this, put);
DojoExternalInterface.addCallback("putMultiple", this, putMultiple);
DojoExternalInterface.addCallback("get", this, get);
DojoExternalInterface.addCallback("getMultiple", this, getMultiple);
DojoExternalInterface.addCallback("showSettings", this, showSettings);
DojoExternalInterface.addCallback("clear", this, clear);
DojoExternalInterface.addCallback("getKeys", this, getKeys);
DojoExternalInterface.addCallback("getNamespaces", this, getNamespaces);
DojoExternalInterface.addCallback("remove", this, remove);
DojoExternalInterface.addCallback("removeMultiple", this, removeMultiple);
DojoExternalInterface.addCallback("flush", this, flush);
DojoExternalInterface.addCallback("setFlushDelay", this, setFlushDelay);
DojoExternalInterface.addCallback("getFlushDelay", this, getFlushDelay);
DojoExternalInterface.loaded();
// preload the System Settings finished button movie for offline
// access so it is in the cache
_root.createEmptyMovieClip("_settingsBackground", 1);
// getURL("javascript:alert('"+DojoExternalInterface.dojoPath+"');");
_root._settingsBackground.loadMovie(DojoExternalInterface.dojoPath + "storage_dialog.swf");
}
 
// Set a new value for the flush delay timer.
// Possible values:
// 0 : Perform the flush synchronously after each "put" request
// > 0 : Wait until 'newDelay' ms have passed without any "put" request to flush
// -1 : Do not automatically flush
public function setFlushDelay(newDelay){
flush_delay = Number(newDelay);
}
public function getFlushDelay(){
return String(flush_delay);
}
public function flush(namespace){
if(timer){
_global.clearTimeout(timer);
delete timer;
}
var so = SharedObject.getLocal(namespace);
 
//var st = (new Date()).getTime();
var flushResults = so.flush();
//var end = (new Date()).getTime();
//getURL("javascript:dojo.debug('FLASH: flush - not a word game - took " + (end - st) + "ms')");
 
// return results of this command to JavaScript
var statusResults;
if(flushResults == true){
statusResults = Storage.SUCCESS;
}else if(flushResults == "pending"){
statusResults = Storage.PENDING;
}else{
statusResults = Storage.FAILED;
}
DojoExternalInterface.call("dojox.storage._onStatus", null, statusResults, null);
}
 
// FIXME: This code has gotten ugly -- refactor
public function put(keyName, keyValue, namespace){
// Get the SharedObject for these values and save it
so = SharedObject.getLocal(namespace);
// Save the key and value
so.data[keyName] = keyValue;
 
// Do all the flush/no-flush stuff
var keyNames = new Array(); keyNames[0] = keyName;
postWrite( so, keyNames, namespace);
}
public function putMultiple(metaKey, metaValue, metaLengths, namespace){
// Get the SharedObject for these values and save it
so = SharedObject.getLocal(namespace);
// Create array of keys and value lengths
var keys = metaKey.split(",");
var lengths = metaLengths.split(",");
// Loop through the array and write the values
for(var i=0;i<keys.length;i++){
so.data[keys[i]] = metaValue.slice(0,lengths[i]);
metaValue = metaValue.slice(lengths[i]);
}
// Do all the flush/no-flush stuff
postWrite( so, keys, namespace);
}
 
public function postWrite( so, keyNames, namespace){
// TODO: Review all this 'handler' stuff. In particular, the flush could now be with keys pending
// from several different requests, not only the ones passed in this method call
 
// prepare a storage status handler
var self = this;
so.onStatus = function(infoObject:Object){
//getURL("javascript:console.debug('FLASH: onStatus, infoObject="+infoObject.code+"')");
// delete the data value if the request was denied
if(infoObject.code == "SharedObject.Flush.Failed"){
for(var i=0;i<keyNames.length;i++){
delete self.so.data[keyNames[i]];
}
}
var statusResults;
if(infoObject.code == "SharedObject.Flush.Failed"){
statusResults = Storage.FAILED;
}else if(infoObject.code == "SharedObject.Flush.Pending"){
statusResults = Storage.PENDING;
}else if(infoObject.code == "SharedObject.Flush.Success"){
// if we have succeeded saving our value, see if we
// need to update our list of namespaces
if(self.hasNamespace(namespace) == true){
statusResults = Storage.SUCCESS;
}else{
// we have a new namespace we must store
self.addNamespace(namespace, keyNames[0]);
return;
}
}
//getURL("javascript:console.debug('FLASH: onStatus, statusResults="+statusResults+"')");
// give the status results to JavaScript
DojoExternalInterface.call("dojox.storage._onStatus", null, statusResults, keyNames[0]);
}
// Clear any pending flush timers
if(timer){
//getURL("javascript:dojo.debug('FLASH: clearing timer')");
_global.clearTimeout( timer);
}
// If we have a flush delay set, set a timer for its execution
if(flush_delay > 0){
timer = _global.setTimeout( flush, flush_delay, namespace);
// With a flush_delay value of 0, execute the flush request synchronously
}else if(flush_delay == 0){
//getURL("javascript:dojo.debug('FLASH: calling flush now')");
flush(namespace);
}
// Otherwise just don't flush - will be probably be flushed manually
}
 
public function get(keyName, namespace){
// Get the SharedObject for these values and save it
so = SharedObject.getLocal(namespace);
var results = so.data[keyName];
return results;
}
// Returns an array with the contents of each key value on the metaKeys array
public function getMultiple(metaKeys, namespace){
// get the storage object
so = SharedObject.getLocal(namespace);
// Create array of keys to read
var keys = metaKeys.split(",");
var results = new Array();
// Read from storage into results array
for(var i=0;i<keys.length;i++){
var val = so.data[keys[i]];
val = val.split("\\").join("\\\\");
val = val.split('"').join('\\"');
results.push( val);
}
// Make the results array into a string
var metaResults = '["' + results.join('","') + '"]';
return metaResults;
}
public function showSettings(){
// Show the configuration options for the Flash player, opened to the
// section for local storage controls (pane 1)
System.showSettings(1);
// there is no way we can intercept when the Close button is pressed, allowing us
// to hide the Flash dialog. Instead, we need to load a movie in the
// background that we can show a close button on.
_root.createEmptyMovieClip("_settingsBackground", 1);
_root._settingsBackground.loadMovie(DojoExternalInterface.dojoPath + "storage_dialog.swf");
}
public function clear(namespace){
so = SharedObject.getLocal(namespace);
so.clear();
so.flush();
// remove this namespace entry now
removeNamespace(namespace);
}
public function getKeys(namespace){
// Returns a list of the available keys in this namespace
// get the storage object
so = SharedObject.getLocal(namespace);
// get all of the keys
var results = new Array();
for(var i in so.data){
results.push(i);
}
// remove our key that records our list of namespaces
for(var i = 0; i < results.length; i++){
if(results[i] == _NAMESPACE_KEY){
results.splice(i, 1);
break;
}
}
// join the keys together in a comma seperated string
results = results.join(",");
return results;
}
public function getNamespaces(){
var allNamespaces = SharedObject.getLocal(_NAMESPACE_KEY);
var results = new Array();
for(var i in allNamespaces.data){
results.push(i);
}
return results.join(",");
}
public function remove(keyName, namespace){
// Removes a key
 
// get the storage object
so = SharedObject.getLocal(namespace);
// delete this value
delete so.data[keyName];
// save the changes
so.flush();
// see if we are the last entry for this namespace
var availableKeys = getKeys(namespace);
if(availableKeys == ""){
// we are empty
removeNamespace(namespace);
}
}
// Removes all the values for each keys on the metaKeys array
public function removeMultiple(metaKeys, namespace){
// get the storage object
so = SharedObject.getLocal(namespace);
// Create array of keys to read
var keys = metaKeys.split(",");
var results = new Array();
 
// Delete elements
for(var i=0;i<keys.length;i++){
delete so.data[keys[i]];
}
 
// see if there are no more entries for this namespace
var availableKeys = getKeys(namespace);
if(availableKeys == ""){
// we are empty
removeNamespace(namespace);
}
}
private function hasNamespace(namespace):Boolean{
// Get the SharedObject for the namespace list
var allNamespaces = SharedObject.getLocal(_NAMESPACE_KEY);
var results = false;
for(var i in allNamespaces.data){
if(i == namespace){
results = true;
break;
}
}
return results;
}
// FIXME: This code has gotten ugly -- refactor
private function addNamespace(namespace, keyName){
if(hasNamespace(namespace) == true){
return;
}
// Get the SharedObject for the namespace list
var allNamespaces = SharedObject.getLocal(_NAMESPACE_KEY);
// prepare a storage status handler if the keyName is
// not null
if(keyName != null && typeof keyName != "undefined"){
var self = this;
allNamespaces.onStatus = function(infoObject:Object){
// delete the data value if the request was denied
if(infoObject.code == "SharedObject.Flush.Failed"){
delete self.so.data[keyName];
}
var statusResults;
if(infoObject.code == "SharedObject.Flush.Failed"){
statusResults = Storage.FAILED;
}else if(infoObject.code == "SharedObject.Flush.Pending"){
statusResults = Storage.PENDING;
}else if(infoObject.code == "SharedObject.Flush.Success"){
statusResults = Storage.SUCCESS;
}
// give the status results to JavaScript
DojoExternalInterface.call("dojox.storage._onStatus", null, statusResults, keyName);
}
}
// save the namespace list
allNamespaces.data[namespace] = true;
var flushResults = allNamespaces.flush();
// return results of this command to JavaScript
if(keyName != null && typeof keyName != "undefined"){
var statusResults;
if(flushResults == true){
statusResults = Storage.SUCCESS;
}else if(flushResults == "pending"){
statusResults = Storage.PENDING;
}else{
statusResults = Storage.FAILED;
}
DojoExternalInterface.call("dojox.storage._onStatus", null, statusResults, keyName);
}
}
// FIXME: This code has gotten ugly -- refactor
private function removeNamespace(namespace){
if(hasNamespace(namespace) == false){
return;
}
// try to save the namespace list; don't have a return
// callback; if we fail on this, the worst that will happen
// is that we have a spurious namespace entry
var allNamespaces = SharedObject.getLocal(_NAMESPACE_KEY);
delete allNamespaces.data[namespace];
allNamespaces.flush();
}
 
static function main(mc){
//getURL("javascript:console.debug('FLASH: storage loaded')");
_root.app = new Storage();
}
}
 
/trunk/api/js/dojo1.0/dojox/storage/FlashStorageProvider.js
New file
0,0 → 1,333
if(!dojo._hasResource["dojox.storage.FlashStorageProvider"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.storage.FlashStorageProvider"] = true;
dojo.provide("dojox.storage.FlashStorageProvider");
dojo.require("dojox.flash");
dojo.require("dojox.storage.manager");
dojo.require("dojox.storage.Provider");
 
// summary:
// Storage provider that uses features in Flash to achieve permanent
// storage
// description:
// Authors of this storage provider-
// Brad Neuberg, bkn3@columbia.edu
dojo.declare("dojox.storage.FlashStorageProvider", [ dojox.storage.Provider ], {
initialized: false,
_available: null,
_statusHandler: null,
initialize: function(){
if(djConfig["disableFlashStorage"] == true){
return;
}
// initialize our Flash
var loadedListener = function(){
// indicate our Flash subsystem is now loaded
dojox.storage._flashLoaded();
}
dojox.flash.addLoadedListener(loadedListener);
dojox.flash.setSwf({
flash6: dojo.moduleUrl("dojox", "storage/Storage_version6.swf").toString(),
flash8: dojo.moduleUrl("dojox", "storage/Storage_version8.swf").toString(),
visible: false
});
},
// Set a new value for the flush delay timer.
// Possible values:
// 0 : Perform the flush synchronously after each "put" request
// > 0 : Wait until 'newDelay' ms have passed without any "put" request to flush
// -1 : Do not automatically flush
setFlushDelay: function(newDelay){
if(newDelay === null || typeof newDelay === "undefined" || isNaN(newDelay)){
throw new Error("Invalid argunment: " + newDelay);
}
dojox.flash.comm.setFlushDelay(String(newDelay));
},
getFlushDelay: function(){
return Number(dojox.flash.comm.getFlushDelay());
},
flush: function(namespace){
//FIXME: is this test necessary? Just use !namespace
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
dojox.flash.comm.flush(namespace);
},
 
isAvailable: function(){
return (this._available = !djConfig["disableFlashStorage"]);
},
 
put: function(key, value, resultsHandler, namespace){
if(this.isValidKey(key) == false){
throw new Error("Invalid key given: " + key);
}
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
this._statusHandler = resultsHandler;
// serialize the value;
// handle strings differently so they have better performance
if(dojo.isString(value)){
value = "string:" + value;
}else{
value = dojo.toJson(value);
}
dojox.flash.comm.put(key, value, namespace);
},
 
putMultiple: function(keys, values, resultsHandler, namespace){
if(this.isValidKeyArray(keys) === false || ! values instanceof Array || keys.length != values.length){
throw new Error("Invalid arguments: keys = [" + keys + "], values = [" + values + "]");
}
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
 
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
 
this._statusHandler = resultsHandler;
// Convert the arguments on strings we can pass along to Flash
var metaKey = keys.join(",");
var lengths = [];
for(var i=0;i<values.length;i++){
if(dojo.isString(values[i])){
values[i] = "string:" + values[i];
}else{
values[i] = dojo.toJson(values[i]);
}
lengths[i] = values[i].length;
}
var metaValue = values.join("");
var metaLengths = lengths.join(",");
dojox.flash.comm.putMultiple(metaKey, metaValue, metaLengths, this.namespace);
},
 
get: function(key, namespace){
if(this.isValidKey(key) == false){
throw new Error("Invalid key given: " + key);
}
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
var results = dojox.flash.comm.get(key, namespace);
 
if(results == ""){
return null;
}
return this._destringify(results);
},
 
getMultiple: function(/*array*/ keys, /*string?*/ namespace){ /*Object*/
if(this.isValidKeyArray(keys) === false){
throw new ("Invalid key array given: " + keys);
}
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
var metaKey = keys.join(",");
var metaResults = dojox.flash.comm.getMultiple(metaKey, this.namespace);
var results = eval("(" + metaResults + ")");
// destringify each entry back into a real JS object
//FIXME: use dojo.map
for(var i=0;i<results.length;i++){
results[i] = (results[i] == "") ? null : this._destringify(results[i]);
}
return results;
},
 
_destringify: function(results){
// destringify the content back into a
// real JavaScript object;
// handle strings differently so they have better performance
if(dojo.isString(results) && (/^string:/.test(results))){
results = results.substring("string:".length);
}else{
results = dojo.fromJson(results);
}
return results;
},
getKeys: function(namespace){
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
var results = dojox.flash.comm.getKeys(namespace);
if(results == ""){
return [];
}
 
// the results are returned comma seperated; split them
results = results.split(",");
return results;
},
getNamespaces: function(){
var results = dojox.flash.comm.getNamespaces();
if(results == ""){
return [dojox.storage.DEFAULT_NAMESPACE];
}
// the results are returned comma seperated; split them
results = results.split(",");
return results;
},
 
clear: function(namespace){
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
dojox.flash.comm.clear(namespace);
},
remove: function(key, namespace){
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
dojox.flash.comm.remove(key, namespace);
},
removeMultiple: function(/*array*/ keys, /*string?*/ namespace){ /*Object*/
if(this.isValidKeyArray(keys) === false){
dojo.raise("Invalid key array given: " + keys);
}
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
var metaKey = keys.join(",");
dojox.flash.comm.removeMultiple(metaKey, this.namespace);
},
 
isPermanent: function(){
return true;
},
 
getMaximumSize: function(){
return dojox.storage.SIZE_NO_LIMIT;
},
 
hasSettingsUI: function(){
return true;
},
 
showSettingsUI: function(){
dojox.flash.comm.showSettings();
dojox.flash.obj.setVisible(true);
dojox.flash.obj.center();
},
 
hideSettingsUI: function(){
// hide the dialog
dojox.flash.obj.setVisible(false);
// call anyone who wants to know the dialog is
// now hidden
if(dojo.isFunction(dojox.storage.onHideSettingsUI)){
dojox.storage.onHideSettingsUI.call(null);
}
},
getResourceList: function(){ /* Array[] */
var swfloc6 = dojo.moduleUrl("dojox", "storage/Storage_version6.swf").toString();
var swfloc8 = dojo.moduleUrl("dojox", "storage/Storage_version8.swf").toString();
var results = dojox.flash.info.getResourceList(swfloc6, swfloc8);
results.push(dojo.moduleUrl("dojox", "storage/storage_dialog.swf").toString());
return results;
},
/** Called when the Flash is finished loading. */
_flashLoaded: function(){
// get available namespaces
this._allNamespaces = this.getNamespaces();
this._initialized = true;
 
// indicate that this storage provider is now loaded
dojox.storage.manager.loaded();
},
// Called if the storage system needs to tell us about the status
// of a put() request.
_onStatus: function(statusResult, key){
var ds = dojox.storage;
var dfo = dojox.flash.obj;
if(statusResult == ds.PENDING){
dfo.center();
dfo.setVisible(true);
}else{
dfo.setVisible(false);
}
if(ds._statusHandler){
ds._statusHandler.call(null, statusResult, key);
}
}
}
);
 
dojox.storage.manager.register("dojox.storage.FlashStorageProvider",
new dojox.storage.FlashStorageProvider());
 
dojox.storage.manager.initialize(); // is this redundant? GearsStorageProvider does this.
 
}
/trunk/api/js/dojo1.0/dojox/storage/build.sh
New file
0,0 → 1,5
#!/bin/sh
mtasc -version 6 -cp ../flash/flash6 -swf Storage_version6.swf -main -header 215:138:10 Storage.as
mtasc -version 8 -cp ../flash/flash8 -swf Storage_version8.swf -main -header 215:138:10 Storage.as
 
# port buildFileStorageProvider task from old ant script to compile Java code for Opera/Safari?
/trunk/api/js/dojo1.0/dojox/storage/GearsStorageProvider.js
New file
0,0 → 1,324
if(!dojo._hasResource["dojox.storage.GearsStorageProvider"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.storage.GearsStorageProvider"] = true;
dojo.provide("dojox.storage.GearsStorageProvider");
dojo.require("dojox.storage.Provider");
dojo.require("dojox.storage.manager");
dojo.require("dojox.sql");
 
if(dojo.isGears){
(function(){
// make sure we don't define the gears provider if we're not gears
// enabled
dojo.declare("dojox.storage.GearsStorageProvider", dojox.storage.Provider, {
// summary:
// Storage provider that uses the features of Google Gears
// to store data (it is saved into the local SQL database
// provided by Gears, using dojox.sql)
// description:
//
//
// You can disable this storage provider with the following djConfig
// variable:
// var djConfig = { disableGearsStorage: true };
//
// Authors of this storage provider-
// Brad Neuberg, bkn3@columbia.edu
constructor: function(){
},
// instance methods and properties
TABLE_NAME: "__DOJO_STORAGE",
initialized: false,
_available: null,
initialize: function(){
//console.debug("dojox.storage.GearsStorageProvider.initialize");
if(djConfig["disableGearsStorage"] == true){
return;
}
// partition our storage data so that multiple apps
// on the same host won't collide
this.TABLE_NAME = "__DOJO_STORAGE";
// create the table that holds our data
try{
dojox.sql("CREATE TABLE IF NOT EXISTS " + this.TABLE_NAME + "( "
+ " namespace TEXT, "
+ " key TEXT, "
+ " value TEXT "
+ ")"
);
dojox.sql("CREATE UNIQUE INDEX IF NOT EXISTS namespace_key_index"
+ " ON " + this.TABLE_NAME
+ " (namespace, key)");
}catch(e){
console.debug("dojox.storage.GearsStorageProvider.initialize:", e);
this.initialized = false; // we were unable to initialize
dojox.storage.manager.loaded();
return;
}
// indicate that this storage provider is now loaded
this.initialized = true;
dojox.storage.manager.loaded();
},
isAvailable: function(){
// is Google Gears available and defined?
return this._available = dojo.isGears;
},
 
put: function(key, value, resultsHandler, namespace){
if(this.isValidKey(key) == false){
throw new Error("Invalid key given: " + key);
}
namespace = namespace||this.DEFAULT_NAMESPACE;
// serialize the value;
// handle strings differently so they have better performance
if(dojo.isString(value)){
value = "string:" + value;
}else{
value = dojo.toJson(value);
}
// try to store the value
try{
dojox.sql("DELETE FROM " + this.TABLE_NAME
+ " WHERE namespace = ? AND key = ?",
namespace, key);
dojox.sql("INSERT INTO " + this.TABLE_NAME
+ " VALUES (?, ?, ?)",
namespace, key, value);
}catch(e){
// indicate we failed
console.debug("dojox.storage.GearsStorageProvider.put:", e);
resultsHandler(this.FAILED, key, e.toString());
return;
}
if(resultsHandler){
resultsHandler(dojox.storage.SUCCESS, key, null);
}
},
 
get: function(key, namespace){
if(this.isValidKey(key) == false){
throw new Error("Invalid key given: " + key);
}
namespace = namespace||this.DEFAULT_NAMESPACE;
// try to find this key in the database
var results = dojox.sql("SELECT * FROM " + this.TABLE_NAME
+ " WHERE namespace = ? AND "
+ " key = ?",
namespace, key);
if(!results.length){
return null;
}else{
results = results[0].value;
}
// destringify the content back into a
// real JavaScript object;
// handle strings differently so they have better performance
if(dojo.isString(results) && (/^string:/.test(results))){
results = results.substring("string:".length);
}else{
results = dojo.fromJson(results);
}
return results;
},
getNamespaces: function(){
var results = [ dojox.storage.DEFAULT_NAMESPACE ];
var rs = dojox.sql("SELECT namespace FROM " + this.TABLE_NAME
+ " DESC GROUP BY namespace");
for(var i = 0; i < rs.length; i++){
if(rs[i].namespace != dojox.storage.DEFAULT_NAMESPACE){
results.push(rs[i].namespace);
}
}
return results;
},
 
getKeys: function(namespace){
namespace = namespace||this.DEFAULT_NAMESPACE;
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
var rs = dojox.sql("SELECT key FROM " + this.TABLE_NAME
+ " WHERE namespace = ?",
namespace);
var results = [];
for(var i = 0; i < rs.length; i++){
results.push(rs[i].key);
}
return results;
},
 
clear: function(namespace){
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
namespace = namespace||this.DEFAULT_NAMESPACE;
dojox.sql("DELETE FROM " + this.TABLE_NAME
+ " WHERE namespace = ?",
namespace);
},
remove: function(key, namespace){
namespace = namespace||this.DEFAULT_NAMESPACE;
dojox.sql("DELETE FROM " + this.TABLE_NAME
+ " WHERE namespace = ? AND"
+ " key = ?",
namespace,
key);
},
putMultiple: function(keys, values, resultsHandler, namespace) {
if(this.isValidKeyArray(keys) === false
|| ! values instanceof Array
|| keys.length != values.length){
throw new Error("Invalid arguments: keys = ["
+ keys + "], values = [" + values + "]");
}
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
this._statusHandler = resultsHandler;
 
// try to store the value
try{
dojox.sql.open();
dojox.sql.db.execute("BEGIN TRANSACTION");
var _stmt = "REPLACE INTO " + this.TABLE_NAME + " VALUES (?, ?, ?)";
for(var i=0;i<keys.length;i++) {
// serialize the value;
// handle strings differently so they have better performance
var value = values[i];
if(dojo.isString(value)){
value = "string:" + value;
}else{
value = dojo.toJson(value);
}
dojox.sql.db.execute( _stmt,
[namespace, keys[i], value]);
}
dojox.sql.db.execute("COMMIT TRANSACTION");
dojox.sql.close();
}catch(e){
// indicate we failed
console.debug("dojox.storage.GearsStorageProvider.putMultiple:", e);
if(resultsHandler){
resultsHandler(this.FAILED, keys, e.toString());
}
return;
}
if(resultsHandler){
resultsHandler(dojox.storage.SUCCESS, key, null);
}
},
 
getMultiple: function(keys, namespace){
// TODO: Maybe use SELECT IN instead
 
if(this.isValidKeyArray(keys) === false){
throw new ("Invalid key array given: " + keys);
}
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
var _stmt = "SELECT * FROM " + this.TABLE_NAME +
" WHERE namespace = ? AND " + " key = ?";
var results = [];
for(var i=0;i<keys.length;i++){
var result = dojox.sql( _stmt, namespace, keys[i]);
if( ! result.length){
results[i] = null;
}else{
result = result[0].value;
// destringify the content back into a
// real JavaScript object;
// handle strings differently so they have better performance
if(dojo.isString(result) && (/^string:/.test(result))){
results[i] = result.substring("string:".length);
}else{
results[i] = dojo.fromJson(result);
}
}
}
return results;
},
removeMultiple: function(keys, namespace){
namespace = namespace||this.DEFAULT_NAMESPACE;
dojox.sql.open();
dojox.sql.db.execute("BEGIN TRANSACTION");
var _stmt = "DELETE FROM " + this.TABLE_NAME + " WHERE namespace = ? AND key = ?";
 
for(var i=0;i<keys.length;i++){
dojox.sql.db.execute( _stmt,
[namespace, keys[i]]);
}
dojox.sql.db.execute("COMMIT TRANSACTION");
dojox.sql.close();
},
isPermanent: function(){ return true; },
 
getMaximumSize: function(){ return this.SIZE_NO_LIMIT; },
 
hasSettingsUI: function(){ return false; },
showSettingsUI: function(){
throw new Error(this.declaredClass
+ " does not support a storage settings user-interface");
},
hideSettingsUI: function(){
throw new Error(this.declaredClass
+ " does not support a storage settings user-interface");
}
});
 
// register the existence of our storage providers
dojox.storage.manager.register("dojox.storage.GearsStorageProvider",
new dojox.storage.GearsStorageProvider());
dojox.storage.manager.initialize();
})();
}
 
}
/trunk/api/js/dojo1.0/dojox/storage/WhatWGStorageProvider.js
New file
0,0 → 1,278
if(!dojo._hasResource["dojox.storage.WhatWGStorageProvider"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.storage.WhatWGStorageProvider"] = true;
dojo.provide("dojox.storage.WhatWGStorageProvider");
dojo.require("dojox.storage.Provider");
dojo.require("dojox.storage.manager");
 
dojo.declare("dojox.storage.WhatWGStorageProvider", [ dojox.storage.Provider ], {
// summary:
// Storage provider that uses WHAT Working Group features in Firefox 2
// to achieve permanent storage.
// description:
// The WHAT WG storage API is documented at
// http://www.whatwg.org/specs/web-apps/current-work/#scs-client-side
//
// You can disable this storage provider with the following djConfig
// variable:
// var djConfig = { disableWhatWGStorage: true };
//
// Authors of this storage provider-
// JB Boisseau, jb.boisseau@eutech-ssii.com
// Brad Neuberg, bkn3@columbia.edu
 
initialized: false,
_domain: null,
_available: null,
_statusHandler: null,
_allNamespaces: null,
_storageEventListener: null,
initialize: function(){
if(djConfig["disableWhatWGStorage"] == true){
return;
}
// get current domain
// see: https://bugzilla.mozilla.org/show_bug.cgi?id=357323
this._domain = (location.hostname == "localhost") ? "localhost.localdomain" : location.hostname;
// console.debug(this._domain);
// indicate that this storage provider is now loaded
this.initialized = true;
dojox.storage.manager.loaded();
},
isAvailable: function(){
try{
// see: https://bugzilla.mozilla.org/show_bug.cgi?id=357323
var myStorage = globalStorage[((location.hostname == "localhost") ? "localhost.localdomain" : location.hostname)];
}catch(e){
this._available = false;
return this._available;
}
this._available = true;
return this._available;
},
 
put: function(key, value, resultsHandler, namespace){
if(this.isValidKey(key) == false){
throw new Error("Invalid key given: " + key);
}
namespace = namespace||this.DEFAULT_NAMESPACE;
// get our full key name, which is namespace + key
key = this.getFullKey(key, namespace);
this._statusHandler = resultsHandler;
// serialize the value;
// handle strings differently so they have better performance
if(dojo.isString(value)){
value = "string:" + value;
}else{
value = dojo.toJson(value);
}
// register for successful storage events.
var storageListener = dojo.hitch(this, function(evt){
// remove any old storage event listener we might have added
// to the window on old put() requests; Firefox has a bug
// where it can occassionaly go into infinite loops calling
// our storage event listener over and over -- this is a
// workaround
// FIXME: Simplify this into a test case and submit it
// to Firefox
window.removeEventListener("storage", storageListener, false);
// indicate we succeeded
if(resultsHandler){
resultsHandler.call(null, this.SUCCESS, key);
}
});
window.addEventListener("storage", storageListener, false);
// try to store the value
try{
var myStorage = globalStorage[this._domain];
myStorage.setItem(key, value);
}catch(e){
// indicate we failed
this._statusHandler.call(null, this.FAILED, key, e.toString());
}
},
 
get: function(key, namespace){
if(this.isValidKey(key) == false){
throw new Error("Invalid key given: " + key);
}
namespace = namespace||this.DEFAULT_NAMESPACE;
// get our full key name, which is namespace + key
key = this.getFullKey(key, namespace);
// sometimes, even if a key doesn't exist, Firefox
// will return a blank string instead of a null --
// this _might_ be due to having underscores in the
// keyname, but I am not sure.
// FIXME: Simplify this bug into a testcase and
// submit it to Firefox
var myStorage = globalStorage[this._domain];
var results = myStorage.getItem(key);
if(results == null || results == ""){
return null;
}
results = results.value;
// destringify the content back into a
// real JavaScript object;
// handle strings differently so they have better performance
if(dojo.isString(results) && (/^string:/.test(results))){
results = results.substring("string:".length);
}else{
results = dojo.fromJson(results);
}
return results;
},
getNamespaces: function(){
var results = [ this.DEFAULT_NAMESPACE ];
// simply enumerate through our array and save any string
// that starts with __
var found = {};
var myStorage = globalStorage[this._domain];
var tester = /^__([^_]*)_/;
for(var i = 0; i < myStorage.length; i++){
var currentKey = myStorage.key(i);
if(tester.test(currentKey) == true){
var currentNS = currentKey.match(tester)[1];
// have we seen this namespace before?
if(typeof found[currentNS] == "undefined"){
found[currentNS] = true;
results.push(currentNS);
}
}
}
return results;
},
 
getKeys: function(namespace){
namespace = namespace||this.DEFAULT_NAMESPACE;
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
// create a regular expression to test the beginning
// of our key names to see if they match our namespace;
// if it is the default namespace then test for the presence
// of no namespace for compatibility with older versions
// of dojox.storage
var namespaceTester;
if(namespace == this.DEFAULT_NAMESPACE){
namespaceTester = new RegExp("^([^_]{2}.*)$");
}else{
namespaceTester = new RegExp("^__" + namespace + "_(.*)$");
}
var myStorage = globalStorage[this._domain];
var keysArray = [];
for(var i = 0; i < myStorage.length; i++){
var currentKey = myStorage.key(i);
if(namespaceTester.test(currentKey) == true){
// strip off the namespace portion
currentKey = currentKey.match(namespaceTester)[1];
keysArray.push(currentKey);
}
}
return keysArray;
},
 
clear: function(namespace){
namespace = namespace||this.DEFAULT_NAMESPACE;
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
// create a regular expression to test the beginning
// of our key names to see if they match our namespace;
// if it is the default namespace then test for the presence
// of no namespace for compatibility with older versions
// of dojox.storage
var namespaceTester;
if(namespace == this.DEFAULT_NAMESPACE){
namespaceTester = new RegExp("^[^_]{2}");
}else{
namespaceTester = new RegExp("^__" + namespace + "_");
}
var myStorage = globalStorage[this._domain];
var keys = [];
for(var i = 0; i < myStorage.length; i++){
if(namespaceTester.test(myStorage.key(i)) == true){
keys[keys.length] = myStorage.key(i);
}
}
dojo.forEach(keys, dojo.hitch(myStorage, "removeItem"));
},
remove: function(key, namespace){
// get our full key name, which is namespace + key
key = this.getFullKey(key, namespace);
var myStorage = globalStorage[this._domain];
myStorage.removeItem(key);
},
isPermanent: function(){
return true;
},
 
getMaximumSize: function(){
return this.SIZE_NO_LIMIT;
},
 
hasSettingsUI: function(){
return false;
},
showSettingsUI: function(){
throw new Error(this.declaredClass + " does not support a storage settings user-interface");
},
hideSettingsUI: function(){
throw new Error(this.declaredClass + " does not support a storage settings user-interface");
},
getFullKey: function(key, namespace){
namespace = namespace||this.DEFAULT_NAMESPACE;
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
// don't append a namespace string for the default namespace,
// for compatibility with older versions of dojox.storage
if(namespace == this.DEFAULT_NAMESPACE){
return key;
}else{
return "__" + namespace + "_" + key;
}
}
});
 
dojox.storage.manager.register("dojox.storage.WhatWGStorageProvider",
new dojox.storage.WhatWGStorageProvider());
 
}
/trunk/api/js/dojo1.0/dojox/storage/README
New file
0,0 → 1,42
-------------------------------------------------------------------------------
Project Name
-------------------------------------------------------------------------------
Version X.XXX
Release date: MM/DD/YYYY
-------------------------------------------------------------------------------
Project state:
experimental
-------------------------------------------------------------------------------
Credits
Brad Neuberg
Alex Russell
-------------------------------------------------------------------------------
Project description
 
dojox.storage provides a JavaScript abstraction for persistent storage
as well as pluggable implementations which typically use native browser extensions
(e.g. Flash player, Gears)
 
-------------------------------------------------------------------------------
Dependencies:
 
FlashStorageProvider requires the Flash player [ currently NOT operational ]
GearsStorageProvider requires the Gears extension
 
The open source mtasc compiler (www.mtasc.org) is needed to build the
ActionScript into SWF format. The SWF object is maintained within svn, so
this step is only necessary if Storage.as is modified. A sample build script
is provided (build.sh)
 
-------------------------------------------------------------------------------
Documentation
 
TBD
 
-------------------------------------------------------------------------------
Installation instructions
 
TBD
 
-------------------------------------------------------------------------------
Additional Notes
/trunk/api/js/dojo1.0/dojox/storage/Storage_version6.swf
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/storage/Storage_version6.swf
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/math.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.math"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.math"] = true;
dojo.provide("dojox.math");
dojo.require("dojox.math._base");
 
}
/trunk/api/js/dojo1.0/dojox/uuid/generateTimeBasedUuid.js
New file
0,0 → 1,290
if(!dojo._hasResource["dojox.uuid.generateTimeBasedUuid"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.uuid.generateTimeBasedUuid"] = true;
dojo.provide("dojox.uuid.generateTimeBasedUuid");
 
dojox.uuid.generateTimeBasedUuid = function(/*String?*/ node){
// summary:
// This function generates time-based UUIDs, meaning "version 1" UUIDs.
// description:
// For more info, see
// http://www.webdav.org/specs/draft-leach-uuids-guids-01.txt
// http://www.infonuovo.com/dma/csdocs/sketch/instidid.htm
// http://kruithof.xs4all.nl/uuid/uuidgen
// http://www.opengroup.org/onlinepubs/009629399/apdxa.htm#tagcjh_20
// http://jakarta.apache.org/commons/sandbox/id/apidocs/org/apache/commons/id/uuid/clock/Clock.html
// node:
// A 12-character hex string representing either a pseudo-node or
// hardware-node (an IEEE 802.3 network node). A hardware-node
// will be something like "017bf397618a", always with the first bit
// being 0. A pseudo-node will be something like "f17bf397618a",
// always with the first bit being 1.
// examples:
// string = dojox.uuid.generateTimeBasedUuid();
// string = dojox.uuid.generateTimeBasedUuid("017bf397618a");
// dojox.uuid.generateTimeBasedUuid.setNode("017bf397618a");
// string = dojox.uuid.generateTimeBasedUuid(); // the generated UUID has node == "017bf397618a"
var uuidString = dojox.uuid.generateTimeBasedUuid._generator.generateUuidString(node);
return uuidString; // String
};
 
dojox.uuid.generateTimeBasedUuid.isValidNode = function(/*String?*/ node){
var HEX_RADIX = 16;
var integer = parseInt(node, HEX_RADIX);
var valid = dojo.isString(node) && node.length == 12 && isFinite(integer);
return valid; // Boolean
};
 
dojox.uuid.generateTimeBasedUuid.setNode = function(/*String?*/ node){
// summary:
// Sets the 'node' value that will be included in generated UUIDs.
// node: A 12-character hex string representing a pseudoNode or hardwareNode.
dojox.uuid.assert((node === null) || this.isValidNode(node));
this._uniformNode = node;
};
 
dojox.uuid.generateTimeBasedUuid.getNode = function(){
// summary:
// Returns the 'node' value that will be included in generated UUIDs.
return this._uniformNode; // String (a 12-character hex string representing a pseudoNode or hardwareNode)
};
 
dojox.uuid.generateTimeBasedUuid._generator = new function(){
// Number of hours between October 15, 1582 and January 1, 1970:
this.GREGORIAN_CHANGE_OFFSET_IN_HOURS = 3394248;
// Number of seconds between October 15, 1582 and January 1, 1970:
// dojox.uuid.generateTimeBasedUuid.GREGORIAN_CHANGE_OFFSET_IN_SECONDS = 12219292800;
// --------------------------------------------------
// Private variables:
var _uuidPseudoNodeString = null;
var _uuidClockSeqString = null;
var _dateValueOfPreviousUuid = null;
var _nextIntraMillisecondIncrement = 0;
var _cachedMillisecondsBetween1582and1970 = null;
var _cachedHundredNanosecondIntervalsPerMillisecond = null;
// --------------------------------------------------
// Private constants:
var HEX_RADIX = 16;
 
function _carry(/* array */ arrayA){
// summary:
// Given an array which holds a 64-bit number broken into 4 16-bit
// elements, this method carries any excess bits (greater than 16-bits)
// from each array element into the next.
// arrayA: An array with 4 elements, each of which is a 16-bit number.
arrayA[2] += arrayA[3] >>> 16;
arrayA[3] &= 0xFFFF;
arrayA[1] += arrayA[2] >>> 16;
arrayA[2] &= 0xFFFF;
arrayA[0] += arrayA[1] >>> 16;
arrayA[1] &= 0xFFFF;
dojox.uuid.assert((arrayA[0] >>> 16) === 0);
}
 
function _get64bitArrayFromFloat(/* float */ x){
// summary:
// Given a floating point number, this method returns an array which
// holds a 64-bit number broken into 4 16-bit elements.
var result = new Array(0, 0, 0, 0);
result[3] = x % 0x10000;
x -= result[3];
x /= 0x10000;
result[2] = x % 0x10000;
x -= result[2];
x /= 0x10000;
result[1] = x % 0x10000;
x -= result[1];
x /= 0x10000;
result[0] = x;
return result; // Array with 4 elements, each of which is a 16-bit number.
}
 
function _addTwo64bitArrays(/* array */ arrayA, /* array */ arrayB){
// summary:
// Takes two arrays, each of which holds a 64-bit number broken into 4
// 16-bit elements, and returns a new array that holds a 64-bit number
// that is the sum of the two original numbers.
// arrayA: An array with 4 elements, each of which is a 16-bit number.
// arrayB: An array with 4 elements, each of which is a 16-bit number.
dojox.uuid.assert(dojo.isArray(arrayA));
dojox.uuid.assert(dojo.isArray(arrayB));
dojox.uuid.assert(arrayA.length == 4);
dojox.uuid.assert(arrayB.length == 4);
var result = new Array(0, 0, 0, 0);
result[3] = arrayA[3] + arrayB[3];
result[2] = arrayA[2] + arrayB[2];
result[1] = arrayA[1] + arrayB[1];
result[0] = arrayA[0] + arrayB[0];
_carry(result);
return result; // Array with 4 elements, each of which is a 16-bit number.
}
 
function _multiplyTwo64bitArrays(/* array */ arrayA, /* array */ arrayB){
// summary:
// Takes two arrays, each of which holds a 64-bit number broken into 4
// 16-bit elements, and returns a new array that holds a 64-bit number
// that is the product of the two original numbers.
// arrayA: An array with 4 elements, each of which is a 16-bit number.
// arrayB: An array with 4 elements, each of which is a 16-bit number.
dojox.uuid.assert(dojo.isArray(arrayA));
dojox.uuid.assert(dojo.isArray(arrayB));
dojox.uuid.assert(arrayA.length == 4);
dojox.uuid.assert(arrayB.length == 4);
var overflow = false;
if(arrayA[0] * arrayB[0] !== 0){ overflow = true; }
if(arrayA[0] * arrayB[1] !== 0){ overflow = true; }
if(arrayA[0] * arrayB[2] !== 0){ overflow = true; }
if(arrayA[1] * arrayB[0] !== 0){ overflow = true; }
if(arrayA[1] * arrayB[1] !== 0){ overflow = true; }
if(arrayA[2] * arrayB[0] !== 0){ overflow = true; }
dojox.uuid.assert(!overflow);
var result = new Array(0, 0, 0, 0);
result[0] += arrayA[0] * arrayB[3];
_carry(result);
result[0] += arrayA[1] * arrayB[2];
_carry(result);
result[0] += arrayA[2] * arrayB[1];
_carry(result);
result[0] += arrayA[3] * arrayB[0];
_carry(result);
result[1] += arrayA[1] * arrayB[3];
_carry(result);
result[1] += arrayA[2] * arrayB[2];
_carry(result);
result[1] += arrayA[3] * arrayB[1];
_carry(result);
result[2] += arrayA[2] * arrayB[3];
_carry(result);
result[2] += arrayA[3] * arrayB[2];
_carry(result);
result[3] += arrayA[3] * arrayB[3];
_carry(result);
return result; // Array with 4 elements, each of which is a 16-bit number.
}
 
function _padWithLeadingZeros(/* string */ string, /* int */ desiredLength){
// summary:
// Pads a string with leading zeros and returns the result.
// string: A string to add padding to.
// desiredLength: The number of characters the return string should have.
 
// examples:
// result = _padWithLeadingZeros("abc", 6);
// dojox.uuid.assert(result == "000abc");
while(string.length < desiredLength){
string = "0" + string;
}
return string; // string
}
 
function _generateRandomEightCharacterHexString() {
// summary:
// Returns a randomly generated 8-character string of hex digits.
 
// FIXME: This probably isn't a very high quality random number.
// Make random32bitNumber be a randomly generated floating point number
// between 0 and (4,294,967,296 - 1), inclusive.
var random32bitNumber = Math.floor( (Math.random() % 1) * Math.pow(2, 32) );
var eightCharacterString = random32bitNumber.toString(HEX_RADIX);
while(eightCharacterString.length < 8){
eightCharacterString = "0" + eightCharacterString;
}
return eightCharacterString; // String (an 8-character hex string)
}
this.generateUuidString = function(/*String?*/ node){
// summary:
// Generates a time-based UUID, meaning a version 1 UUID.
// description:
// JavaScript code running in a browser doesn't have access to the
// IEEE 802.3 address of the computer, so if a node value isn't
// supplied, we generate a random pseudonode value instead.
// node: An optional 12-character string to use as the node in the new UUID.
if(node){
dojox.uuid.assert(dojox.uuid.generateTimeBasedUuid.isValidNode(node));
}else{
if(dojox.uuid.generateTimeBasedUuid._uniformNode){
node = dojox.uuid.generateTimeBasedUuid._uniformNode;
}else{
if(!_uuidPseudoNodeString){
var pseudoNodeIndicatorBit = 0x8000;
var random15bitNumber = Math.floor( (Math.random() % 1) * Math.pow(2, 15) );
var leftmost4HexCharacters = (pseudoNodeIndicatorBit | random15bitNumber).toString(HEX_RADIX);
_uuidPseudoNodeString = leftmost4HexCharacters + _generateRandomEightCharacterHexString();
}
node = _uuidPseudoNodeString;
}
}
if(!_uuidClockSeqString){
var variantCodeForDCEUuids = 0x8000; // 10--------------, i.e. uses only first two of 16 bits.
var random14bitNumber = Math.floor( (Math.random() % 1) * Math.pow(2, 14) );
_uuidClockSeqString = (variantCodeForDCEUuids | random14bitNumber).toString(HEX_RADIX);
}
// Maybe we should think about trying to make the code more readable to
// newcomers by creating a class called "WholeNumber" that encapsulates
// the methods and data structures for working with these arrays that
// hold 4 16-bit numbers? And then these variables below have names
// like "wholeSecondsPerHour" rather than "arraySecondsPerHour"?
var now = new Date();
var millisecondsSince1970 = now.valueOf(); // milliseconds since midnight 01 January, 1970 UTC.
var nowArray = _get64bitArrayFromFloat(millisecondsSince1970);
if(!_cachedMillisecondsBetween1582and1970){
var arraySecondsPerHour = _get64bitArrayFromFloat(60 * 60);
var arrayHoursBetween1582and1970 = _get64bitArrayFromFloat(dojox.uuid.generateTimeBasedUuid._generator.GREGORIAN_CHANGE_OFFSET_IN_HOURS);
var arraySecondsBetween1582and1970 = _multiplyTwo64bitArrays(arrayHoursBetween1582and1970, arraySecondsPerHour);
var arrayMillisecondsPerSecond = _get64bitArrayFromFloat(1000);
_cachedMillisecondsBetween1582and1970 = _multiplyTwo64bitArrays(arraySecondsBetween1582and1970, arrayMillisecondsPerSecond);
_cachedHundredNanosecondIntervalsPerMillisecond = _get64bitArrayFromFloat(10000);
}
var arrayMillisecondsSince1970 = nowArray;
var arrayMillisecondsSince1582 = _addTwo64bitArrays(_cachedMillisecondsBetween1582and1970, arrayMillisecondsSince1970);
var arrayHundredNanosecondIntervalsSince1582 = _multiplyTwo64bitArrays(arrayMillisecondsSince1582, _cachedHundredNanosecondIntervalsPerMillisecond);
if(now.valueOf() == _dateValueOfPreviousUuid){
arrayHundredNanosecondIntervalsSince1582[3] += _nextIntraMillisecondIncrement;
_carry(arrayHundredNanosecondIntervalsSince1582);
_nextIntraMillisecondIncrement += 1;
if (_nextIntraMillisecondIncrement == 10000) {
// If we've gotten to here, it means we've already generated 10,000
// UUIDs in this single millisecond, which is the most that the UUID
// timestamp field allows for. So now we'll just sit here and wait
// for a fraction of a millisecond, so as to ensure that the next
// time this method is called there will be a different millisecond
// value in the timestamp field.
while (now.valueOf() == _dateValueOfPreviousUuid) {
now = new Date();
}
}
}else{
_dateValueOfPreviousUuid = now.valueOf();
_nextIntraMillisecondIncrement = 1;
}
var hexTimeLowLeftHalf = arrayHundredNanosecondIntervalsSince1582[2].toString(HEX_RADIX);
var hexTimeLowRightHalf = arrayHundredNanosecondIntervalsSince1582[3].toString(HEX_RADIX);
var hexTimeLow = _padWithLeadingZeros(hexTimeLowLeftHalf, 4) + _padWithLeadingZeros(hexTimeLowRightHalf, 4);
var hexTimeMid = arrayHundredNanosecondIntervalsSince1582[1].toString(HEX_RADIX);
hexTimeMid = _padWithLeadingZeros(hexTimeMid, 4);
var hexTimeHigh = arrayHundredNanosecondIntervalsSince1582[0].toString(HEX_RADIX);
hexTimeHigh = _padWithLeadingZeros(hexTimeHigh, 3);
var hyphen = "-";
var versionCodeForTimeBasedUuids = "1"; // binary2hex("0001")
var resultUuid = hexTimeLow + hyphen + hexTimeMid + hyphen +
versionCodeForTimeBasedUuids + hexTimeHigh + hyphen +
_uuidClockSeqString + hyphen + node;
resultUuid = resultUuid.toLowerCase();
return resultUuid; // String (a 36 character string, which will look something like "b4308fb0-86cd-11da-a72b-0800200c9a66")
}
 
}();
 
}
/trunk/api/js/dojo1.0/dojox/uuid/README
New file
0,0 → 1,43
-------------------------------------------------------------------------------
DojoX UUID
-------------------------------------------------------------------------------
Version 0.9
Release date: 06/21/2007
-------------------------------------------------------------------------------
Project state: stable
-------------------------------------------------------------------------------
Project authors
Brian Douglas Skinner (skinner@dojotoolkit.org)
-------------------------------------------------------------------------------
Project description
 
DojoX UUID is the port of the original Dojo 0.4.x UUID classes. The UUID
classes can be used to represent Universally Unique IDentifiers (UUIDs), as
described in the IETF's RFC 4122:
http://tools.ietf.org/html/rfc4122
 
The DojoX UUID classes provide support for generating both "time-based" UUIDs
and lightweight "random" UUIDs. DojoX UUID does not yet have support for
generating new "name-based" UUIDs, but the dojo.uuid.Uuid class can represent
existing name-based UUIDs, such as UUIDs read from a file or from a server.
 
-------------------------------------------------------------------------------
Dependencies:
 
DojoX UUID has no dependencies, outside of Dojo Core.
-------------------------------------------------------------------------------
Documentation
 
See the API documentation for Dojo (http://dojotoolkit.org/api).
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/uuid.js
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/uuid/*
 
Install into the following directory structure:
/dojox/uuid/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
/trunk/api/js/dojo1.0/dojox/uuid/generateRandomUuid.js
New file
0,0 → 1,56
if(!dojo._hasResource["dojox.uuid.generateRandomUuid"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.uuid.generateRandomUuid"] = true;
dojo.provide("dojox.uuid.generateRandomUuid");
 
dojox.uuid.generateRandomUuid = function(){
// summary:
// This function generates random UUIDs, meaning "version 4" UUIDs.
// description:
// A typical generated value would be something like this:
// "3b12f1df-5232-4804-897e-917bf397618a"
//
// For more information about random UUIDs, see sections 4.4 and
// 4.5 of RFC 4122: http://tools.ietf.org/html/rfc4122#section-4.4
//
// This generator function is designed to be small and fast,
// but not necessarily good.
//
// Small: This generator has a small footprint. Once comments are
// stripped, it's only about 25 lines of code, and it doesn't
// dojo.require() any other modules.
//
// Fast: This generator can generate lots of new UUIDs fairly quickly
// (at least, more quickly than the other dojo UUID generators).
//
// Not necessarily good: We use Math.random() as our source
// of randomness, which may or may not provide much randomness.
// examples:
// var string = dojox.uuid.generateRandomUuid();
var HEX_RADIX = 16;
 
function _generateRandomEightCharacterHexString(){
// Make random32bitNumber be a randomly generated floating point number
// between 0 and (4,294,967,296 - 1), inclusive.
var random32bitNumber = Math.floor( (Math.random() % 1) * Math.pow(2, 32) );
var eightCharacterHexString = random32bitNumber.toString(HEX_RADIX);
while(eightCharacterHexString.length < 8){
eightCharacterHexString = "0" + eightCharacterHexString;
}
return eightCharacterHexString; // for example: "3B12F1DF"
}
 
var hyphen = "-";
var versionCodeForRandomlyGeneratedUuids = "4"; // 8 == binary2hex("0100")
var variantCodeForDCEUuids = "8"; // 8 == binary2hex("1000")
var a = _generateRandomEightCharacterHexString();
var b = _generateRandomEightCharacterHexString();
b = b.substring(0, 4) + hyphen + versionCodeForRandomlyGeneratedUuids + b.substring(5, 8);
var c = _generateRandomEightCharacterHexString();
c = variantCodeForDCEUuids + c.substring(1, 4) + hyphen + c.substring(4, 8);
var d = _generateRandomEightCharacterHexString();
var returnValue = a + hyphen + b + hyphen + c + d;
returnValue = returnValue.toLowerCase();
return returnValue; // String
};
 
}
/trunk/api/js/dojo1.0/dojox/uuid/Uuid.js
New file
0,0 → 1,200
if(!dojo._hasResource["dojox.uuid.Uuid"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.uuid.Uuid"] = true;
dojo.provide("dojox.uuid.Uuid");
dojo.require("dojox.uuid");
 
dojox.uuid.Uuid = function(/*String?*/ input){
// summary:
// This is the constructor for the Uuid class. The Uuid class offers
// methods for inspecting existing UUIDs.
// input: A 36-character string that conforms to the UUID spec.
// examples:
// var uuid;
// uuid = new dojox.uuid.Uuid("3b12f1df-5232-4804-897e-917bf397618a");
// uuid = new dojox.uuid.Uuid(); // "00000000-0000-0000-0000-000000000000"
// uuid = new dojox.uuid.Uuid(dojox.uuid.generateRandomUuid());
// uuid = new dojox.uuid.Uuid(dojox.uuid.generateTimeBasedUuid());
// dojox.uuid.Uuid.setGenerator(dojox.uuid.generateRandomUuid);
// uuid = new dojox.uuid.Uuid();
// dojox.uuid.assert(!uuid.isEqual(dojox.uuid.NIL_UUID));
this._uuidString = dojox.uuid.NIL_UUID;
if(input){
dojox.uuid.assert(dojo.isString(input));
this._uuidString = input.toLowerCase();
dojox.uuid.assert(this.isValid());
}else{
var ourGenerator = dojox.uuid.Uuid.getGenerator();
if(ourGenerator){
this._uuidString = ourGenerator();
dojox.uuid.assert(this.isValid());
}
}
};
 
dojox.uuid.Uuid.compare = function(/*dojox.uuid.Uuid*/ uuidOne, /*dojox.uuid.Uuid*/ uuidTwo){
// summary:
// Given two UUIDs to compare, this method returns 0, 1, or -1.
// description:
// This method is designed to be used by sorting routines, like the
// JavaScript built-in Array sort() method. This implementation is
// intended to match the sample implementation in IETF RFC 4122:
// http://www.ietf.org/rfc/rfc4122.txt
// uuidOne: Any object that has toString() method that returns a 36-character string that conforms to the UUID spec.
// uuidTwo: Any object that has toString() method that returns a 36-character string that conforms to the UUID spec.
 
// examples:
// var uuid;
// var generator = dojox.uuid.TimeBasedGenerator;
// var a = new dojox.uuid.Uuid(generator);
// var b = new dojox.uuid.Uuid(generator);
// var c = new dojox.uuid.Uuid(generator);
// var array = new Array(a, b, c);
// array.sort(dojox.uuid.Uuid.compare);
var uuidStringOne = uuidOne.toString();
var uuidStringTwo = uuidTwo.toString();
if (uuidStringOne > uuidStringTwo) return 1; // integer
if (uuidStringOne < uuidStringTwo) return -1; // integer
return 0; // integer (either 0, 1, or -1)
};
 
dojox.uuid.Uuid.setGenerator = function(/*Function?*/ generator){
// summary:
// Sets the default generator, which will be used by the
// "new dojox.uuid.Uuid()" constructor if no parameters
// are passed in.
// generator: A UUID generator function, such as dojox.uuid.generateTimeBasedUuid.
dojox.uuid.assert(!generator || dojo.isFunction(generator));
dojox.uuid.Uuid._ourGenerator = generator;
};
 
dojox.uuid.Uuid.getGenerator = function(){
// summary:
// Returns the default generator. See setGenerator().
return dojox.uuid.Uuid._ourGenerator; // generator (A UUID generator, such as dojox.uuid.TimeBasedGenerator).
};
 
dojox.uuid.Uuid.prototype.toString = function(){
// summary:
// This method returns a standard 36-character string representing
// the UUID, such as "3b12f1df-5232-4804-897e-917bf397618a".
return this._uuidString; // string
};
 
dojox.uuid.Uuid.prototype.compare = function(/*dojox.uuid.Uuid*/ otherUuid){
// summary:
// Compares this UUID to another UUID, and returns 0, 1, or -1.
// description:
// This implementation is intended to match the sample implementation
// in IETF RFC 4122: http://www.ietf.org/rfc/rfc4122.txt
// otherUuid: Any object that has toString() method that returns a 36-character string that conforms to the UUID spec.
return dojox.uuid.Uuid.compare(this, otherUuid); // integer (either 0, 1, or -1)
};
 
dojox.uuid.Uuid.prototype.isEqual = function(/*dojox.uuid.Uuid*/ otherUuid){
// summary:
// Returns true if this UUID is equal to the otherUuid, or false otherwise.
// otherUuid: Any object that has toString() method that returns a 36-character string that conforms to the UUID spec.
return (this.compare(otherUuid) == 0); // boolean
};
 
dojox.uuid.Uuid.prototype.isValid = function(){
// summary:
// Returns true if the UUID was initialized with a valid value.
return dojox.uuid.isValid(this);
};
 
dojox.uuid.Uuid.prototype.getVariant = function(){
// summary:
// Returns a variant code that indicates what type of UUID this is.
// Returns one of the enumerated dojox.uuid.variant values.
 
// example:
// var uuid = new dojox.uuid.Uuid("3b12f1df-5232-4804-897e-917bf397618a");
// var variant = uuid.getVariant();
// dojox.uuid.assert(variant == dojox.uuid.variant.DCE);
// example:
// "3b12f1df-5232-4804-897e-917bf397618a"
// ^
// |
// (variant "10__" == DCE)
return dojox.uuid.getVariant(this);
};
 
dojox.uuid.Uuid.prototype.getVersion = function(){
// summary:
// Returns a version number that indicates what type of UUID this is.
// Returns one of the enumerated dojox.uuid.version values.
// example:
// var uuid = new dojox.uuid.Uuid("b4308fb0-86cd-11da-a72b-0800200c9a66");
// var version = uuid.getVersion();
// dojox.uuid.assert(version == dojox.uuid.version.TIME_BASED);
// exceptions:
// Throws an Error if this is not a DCE Variant UUID.
if(!this._versionNumber){
this._versionNumber = dojox.uuid.getVersion(this);
}
return this._versionNumber; // dojox.uuid.version
};
 
dojox.uuid.Uuid.prototype.getNode = function(){
// summary:
// If this is a version 1 UUID (a time-based UUID), getNode() returns a
// 12-character string with the "node" or "pseudonode" portion of the UUID,
// which is the rightmost 12 characters.
// exceptions:
// Throws an Error if this is not a version 1 UUID.
if (!this._nodeString) {
this._nodeString = dojox.uuid.getNode(this);
}
return this._nodeString; // String (a 12-character string, which will look something like "917bf397618a")
};
 
dojox.uuid.Uuid.prototype.getTimestamp = function(/*String?*/ returnType){
// summary:
// If this is a version 1 UUID (a time-based UUID), this method returns
// the timestamp value encoded in the UUID. The caller can ask for the
// timestamp to be returned either as a JavaScript Date object or as a
// 15-character string of hex digits.
// returnType: Any of these five values: "string", String, "hex", "date", Date
// returns:
// Returns the timestamp value as a JavaScript Date object or a 15-character string of hex digits.
// examples:
// var uuid = new dojox.uuid.Uuid("b4308fb0-86cd-11da-a72b-0800200c9a66");
// var date, string, hexString;
// date = uuid.getTimestamp(); // returns a JavaScript Date
// date = uuid.getTimestamp(Date); //
// string = uuid.getTimestamp(String); // "Mon, 16 Jan 2006 20:21:41 GMT"
// hexString = uuid.getTimestamp("hex"); // "1da86cdb4308fb0"
// exceptions:
// Throws an Error if this is not a version 1 UUID.
if(!returnType){returnType = null};
switch(returnType){
case "string":
case String:
return this.getTimestamp(Date).toUTCString(); // String (e.g. "Mon, 16 Jan 2006 20:21:41 GMT")
break;
case "hex":
// Return a 15-character string of hex digits containing the
// timestamp for this UUID, with the high-order bits first.
if (!this._timestampAsHexString) {
this._timestampAsHexString = dojox.uuid.getTimestamp(this, "hex");
}
return this._timestampAsHexString; // String (e.g. "1da86cdb4308fb0")
break;
case null: // no returnType was specified, so default to Date
case "date":
case Date:
// Return a JavaScript Date object.
if (!this._timestampAsDate) {
this._timestampAsDate = dojox.uuid.getTimestamp(this, Date);
}
return this._timestampAsDate; // Date
break;
default:
// we got passed something other than a valid returnType
dojox.uuid.assert(false, "The getTimestamp() method dojox.uuid.Uuid was passed a bogus returnType: " + returnType);
break;
}
};
 
}
/trunk/api/js/dojo1.0/dojox/uuid/tests/uuid.js
New file
0,0 → 1,377
if(!dojo._hasResource["dojox.uuid.tests.uuid"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.uuid.tests.uuid"] = true;
dojo.provide("dojox.uuid.tests.uuid");
dojo.require("dojox.uuid");
dojo.require("dojox.uuid.Uuid");
dojo.require("dojox.uuid.generateRandomUuid");
dojo.require("dojox.uuid.generateTimeBasedUuid");
 
dojox.uuid.tests.uuid.checkValidityOfUuidString = function(/*String*/uuidString){
// summary:
// A helper function that's used by the registered test functions
var NIL_UUID = "00000000-0000-0000-0000-000000000000";
if (uuidString == NIL_UUID) {
// We'll consider the Nil UUID to be valid, so now
// we can just return, with not further checks.
return;
}
doh.assertTrue(uuidString.length == 36); // UUIDs have 36 characters
 
var validCharacters = "0123456789abcedfABCDEF-";
var character;
var position;
for(var i = 0; i < 36; ++i){
character = uuidString.charAt(i);
position = validCharacters.indexOf(character);
doh.assertTrue(position != -1); // UUIDs have only valid characters
}
 
var arrayOfParts = uuidString.split("-");
doh.assertTrue(arrayOfParts.length == 5); // UUIDs have 5 sections separated by 4 hyphens
doh.assertTrue(arrayOfParts[0].length == 8); // Section 0 has 8 characters
doh.assertTrue(arrayOfParts[1].length == 4); // Section 1 has 4 characters
doh.assertTrue(arrayOfParts[2].length == 4); // Section 2 has 4 characters
doh.assertTrue(arrayOfParts[3].length == 4); // Section 3 has 4 characters
doh.assertTrue(arrayOfParts[4].length == 12); // Section 4 has 8 characters
 
// check to see that the "UUID variant code" starts with the binary bits '10'
var section3 = arrayOfParts[3];
var HEX_RADIX = 16;
var hex3 = parseInt(section3, HEX_RADIX);
var binaryString = hex3.toString(2);
// alert("section3 = " + section3 + "\n binaryString = " + binaryString);
doh.assertTrue(binaryString.length == 16); // section 3 has 16 bits
doh.assertTrue(binaryString.charAt(0) == '1'); // first bit of section 3 is 1
doh.assertTrue(binaryString.charAt(1) == '0'); // second bit of section 3 is 0
}
 
dojox.uuid.tests.uuid.checkValidityOfTimeBasedUuidString = function(/*String*/uuidString){
// summary:
// A helper function that's used by the registered test functions
dojox.uuid.tests.uuid.checkValidityOfUuidString(uuidString);
var arrayOfParts = uuidString.split("-");
var section2 = arrayOfParts[2];
doh.assertTrue(section2.charAt(0) == "1"); // Section 2 starts with a 1
}
 
dojox.uuid.tests.uuid.checkForPseudoNodeBitInTimeBasedUuidString = function(/*String*/uuidString){
// summary:
// A helper function that's used by the registered test functions
var arrayOfParts = uuidString.split("-");
var section4 = arrayOfParts[4];
var firstChar = section4.charAt(0);
var HEX_RADIX = 16;
var hexFirstChar = parseInt(firstChar, HEX_RADIX);
var binaryString = hexFirstChar.toString(2);
var firstBit;
if(binaryString.length == 4){
firstBit = binaryString.charAt(0);
}else{
firstBit = '0';
}
doh.assertTrue(firstBit == '1'); // first bit of section 4 is 1
}
 
doh.register("dojox.uuid.tests.uuid",
[
/*
function test_uuid_performance(){
var start = new Date();
var startMS = start.valueOf();
var nowMS = startMS;
var i;
var now;
var numTrials = 100000;
while(nowMS == startMS){
now = new Date();
nowMS = now.valueOf();
}
startMS = nowMS;
for(i = 0; i < numTrials; ++i){
var a = dojox.uuid.LightweightGenerator.generate();
}
now = new Date();
nowMS = now.valueOf();
var elapsedMS = nowMS - startMS;
// dojo.log.debug("created " + numTrials + " UUIDs in " + elapsedMS + " milliseconds");
},
*/
 
function test_uuid_capitalization(){
var randomLowercaseString = "3b12f1df-5232-4804-897e-917bf397618a";
var randomUppercaseString = "3B12F1DF-5232-4804-897E-917BF397618A";
var timebasedLowercaseString = "b4308fb0-86cd-11da-a72b-0800200c9a66";
var timebasedUppercaseString = "B4308FB0-86CD-11DA-A72B-0800200C9A66";
var uuidRL = new dojox.uuid.Uuid(randomLowercaseString);
var uuidRU = new dojox.uuid.Uuid(randomUppercaseString);
var uuidTL = new dojox.uuid.Uuid(timebasedLowercaseString);
var uuidTU = new dojox.uuid.Uuid(timebasedUppercaseString);
doh.assertTrue(uuidRL.isEqual(uuidRU));
doh.assertTrue(uuidRU.isEqual(uuidRL));
doh.assertTrue(uuidTL.isEqual(uuidTU));
doh.assertTrue(uuidTU.isEqual(uuidTL));
},
function test_uuid_constructor(){
var uuid, uuidToo;
var nilUuid = '00000000-0000-0000-0000-000000000000';
uuid = new dojox.uuid.Uuid();
doh.assertTrue(uuid == nilUuid); // 'new dojox.uuid.Uuid()' returns the Nil UUID
var randomUuidString = "3b12f1df-5232-4804-897e-917bf397618a";
uuid = new dojox.uuid.Uuid(randomUuidString);
doh.assertTrue(uuid.isValid());
doh.assertTrue(uuid.getVariant() == dojox.uuid.variant.DCE);
doh.assertTrue(uuid.getVersion() == dojox.uuid.version.RANDOM);
uuidToo = new dojox.uuid.Uuid(new String(randomUuidString));
doh.assertTrue(uuid.isEqual(uuidToo));
var timeBasedUuidString = "b4308fb0-86cd-11da-a72b-0800200c9a66";
uuid = new dojox.uuid.Uuid(timeBasedUuidString);
doh.assertTrue(uuid.isValid());
doh.assertTrue(uuid.getVariant() == dojox.uuid.variant.DCE);
doh.assertTrue(uuid.getVersion() == dojox.uuid.version.TIME_BASED);
doh.assertTrue(uuid.getNode() == "0800200c9a66");
var timestamp = uuid.getTimestamp();
var date = uuid.getTimestamp(Date);
var dateString = uuid.getTimestamp(String);
var hexString = uuid.getTimestamp("hex");
var now = new Date();
doh.assertTrue(timestamp.valueOf() == date.valueOf());
doh.assertTrue(hexString == "1da86cdb4308fb0");
doh.assertTrue(timestamp < now);
},
function test_uuid_generators(){
var generators = [
dojox.uuid.generateNilUuid,
dojox.uuid.generateRandomUuid,
dojox.uuid.generateTimeBasedUuid
];
for(var i in generators){
var generator = generators[i];
var uuidString = generator();
 
doh.assertTrue((typeof uuidString) == 'string');
dojox.uuid.tests.uuid.checkValidityOfUuidString(uuidString);
 
var uuid = new dojox.uuid.Uuid(uuidString);
if(generator != dojox.uuid.generateNilUuid){
doh.assertTrue(uuid.getVariant() == dojox.uuid.variant.DCE);
}
 
doh.assertTrue(uuid.isEqual(uuid));
doh.assertTrue(uuid.compare(uuid) == 0);
doh.assertTrue(dojox.uuid.Uuid.compare(uuid, uuid) == 0);
dojox.uuid.tests.uuid.checkValidityOfUuidString(uuid.toString());
doh.assertTrue(uuid.toString().length == 36);
if(generator != dojox.uuid.generateNilUuid){
var uuidStringOne = generator();
var uuidStringTwo = generator();
doh.assertTrue(uuidStringOne != uuidStringTwo);
dojox.uuid.Uuid.setGenerator(generator);
var uuidOne = new dojox.uuid.Uuid();
var uuidTwo = new dojox.uuid.Uuid();
doh.assertTrue(generator === dojox.uuid.Uuid.getGenerator());
dojox.uuid.Uuid.setGenerator(null);
doh.assertTrue(uuidOne != uuidTwo);
doh.assertTrue(!uuidOne.isEqual(uuidTwo));
doh.assertTrue(!uuidTwo.isEqual(uuidOne));
var oneVsTwo = dojox.uuid.Uuid.compare(uuidOne, uuidTwo); // either 1 or -1
var twoVsOne = dojox.uuid.Uuid.compare(uuidTwo, uuidOne); // either -1 or 1
doh.assertTrue(oneVsTwo + twoVsOne == 0);
doh.assertTrue(oneVsTwo != 0);
doh.assertTrue(twoVsOne != 0);
doh.assertTrue(!uuidTwo.isEqual(uuidOne));
}
if(generator == dojox.uuid.generateRandomUuid){
doh.assertTrue(uuid.getVersion() == dojox.uuid.version.RANDOM);
}
if(generator == dojox.uuid.generateTimeBasedUuid){
dojox.uuid.tests.uuid.checkValidityOfTimeBasedUuidString(uuid.toString());
doh.assertTrue(uuid.getVersion() == dojox.uuid.version.TIME_BASED);
doh.assertTrue(dojo.isString(uuid.getNode()));
doh.assertTrue(uuid.getNode().length == 12);
var timestamp = uuid.getTimestamp();
var date = uuid.getTimestamp(Date);
var dateString = uuid.getTimestamp(String);
var hexString = uuid.getTimestamp("hex");
doh.assertTrue(date instanceof Date);
doh.assertTrue(timestamp.valueOf() == date.valueOf());
doh.assertTrue(hexString.length == 15);
}
}
},
function test_uuid_nilGenerator(){
var nilUuidString = '00000000-0000-0000-0000-000000000000';
var uuidString = dojox.uuid.generateNilUuid();
doh.assertTrue(uuidString == nilUuidString);
},
function test_uuid_timeBasedGenerator(){
var uuid; // an instance of dojox.uuid.Uuid
var string; // a simple string literal
var generator = dojox.uuid.generateTimeBasedUuid;
 
var string1 = generator();
var uuid2 = new dojox.uuid.Uuid(generator());
var string3 = generator("017bf397618a"); // hardwareNode
var string4 = generator("f17bf397618a"); // pseudoNode
var string5 = generator(new String("017BF397618A"));
dojox.uuid.generateTimeBasedUuid.setNode("017bf397618a");
var string6 = generator(); // the generated UUID has node == "017bf397618a"
var uuid7 = new dojox.uuid.Uuid(generator()); // the generated UUID has node == "017bf397618a"
var returnedNode = dojox.uuid.generateTimeBasedUuid.getNode();
doh.assertTrue(returnedNode == "017bf397618a");
function getNode(string){
var arrayOfStrings = string.split('-');
return arrayOfStrings[4];
}
dojox.uuid.tests.uuid.checkForPseudoNodeBitInTimeBasedUuidString(string1);
dojox.uuid.tests.uuid.checkForPseudoNodeBitInTimeBasedUuidString(uuid2.toString());
dojox.uuid.tests.uuid.checkForPseudoNodeBitInTimeBasedUuidString(string4);
doh.assertTrue(getNode(string3) == "017bf397618a");
doh.assertTrue(getNode(string4) == "f17bf397618a");
doh.assertTrue(getNode(string5) == "017bf397618a");
doh.assertTrue(getNode(string6) == "017bf397618a");
doh.assertTrue(uuid7.getNode() == "017bf397618a");
dojox.uuid.tests.uuid.checkValidityOfTimeBasedUuidString(string1);
dojox.uuid.tests.uuid.checkValidityOfTimeBasedUuidString(uuid2.toString());
dojox.uuid.tests.uuid.checkValidityOfTimeBasedUuidString(string3);
dojox.uuid.tests.uuid.checkValidityOfTimeBasedUuidString(string4);
dojox.uuid.tests.uuid.checkValidityOfTimeBasedUuidString(string5);
dojox.uuid.tests.uuid.checkValidityOfTimeBasedUuidString(string6);
dojox.uuid.tests.uuid.checkValidityOfTimeBasedUuidString(uuid7.toString());
},
 
function test_uuid_invalidUuids(){
var uuidStrings = [];
uuidStrings.push("Hello world!"); // not a UUID
uuidStrings.push("3B12F1DF-5232-1804-897E-917BF39761"); // too short
uuidStrings.push("3B12F1DF-5232-1804-897E-917BF39761-8A"); // extra '-'
uuidStrings.push("3B12F1DF-5232-1804-897E917BF39761-8A"); // last '-' in wrong place
uuidStrings.push("HB12F1DF-5232-1804-897E-917BF397618A"); // "HB12F1DF" is not a hex string
var numberOfFailures = 0;
for(var i in uuidStrings){
var uuidString = uuidStrings[i];
try{
new dojox.uuid.Uuid(uuidString);
}catch (e){
++numberOfFailures;
}
}
doh.assertTrue(numberOfFailures == uuidStrings.length);
}
]
);
 
 
 
/*
function test_uuid_get64bitArrayFromFloat(){
// summary:
// This is a test we'd like to be able to run, but we can't run it
// because it tests a function which is private in generateTimeBasedUuid
var x = Math.pow(2, 63) + Math.pow(2, 15);
var result = dojox.uuid.generateTimeBasedUuid._get64bitArrayFromFloat(x);
doh.assertTrue(result[0] === 0x8000);
doh.assertTrue(result[1] === 0x0000);
doh.assertTrue(result[2] === 0x0000);
doh.assertTrue(result[3] === 0x8000);
 
var date = new Date();
x = date.valueOf();
result = dojox.uuid.generateTimeBasedUuid._get64bitArrayFromFloat(x);
var reconstructedFloat = result[0];
reconstructedFloat *= 0x10000;
reconstructedFloat += result[1];
reconstructedFloat *= 0x10000;
reconstructedFloat += result[2];
reconstructedFloat *= 0x10000;
reconstructedFloat += result[3];
 
doh.assertTrue(reconstructedFloat === x);
}
 
function test_uuid_addTwo64bitArrays(){
// summary:
// This is a test we'd like to be able to run, but we can't run it
// because it tests a function which is private in generateTimeBasedUuid
var a = [0x0000, 0x0000, 0x0000, 0x0001];
var b = [0x0FFF, 0xFFFF, 0xFFFF, 0xFFFF];
var result = dojox.uuid.generateTimeBasedUuid._addTwo64bitArrays(a, b);
doh.assertTrue(result[0] === 0x1000);
doh.assertTrue(result[1] === 0x0000);
doh.assertTrue(result[2] === 0x0000);
doh.assertTrue(result[3] === 0x0000);
 
a = [0x4000, 0x8000, 0x8000, 0x8000];
b = [0x8000, 0x8000, 0x8000, 0x8000];
result = dojox.uuid.generateTimeBasedUuid._addTwo64bitArrays(a, b);
doh.assertTrue(result[0] === 0xC001);
doh.assertTrue(result[1] === 0x0001);
doh.assertTrue(result[2] === 0x0001);
doh.assertTrue(result[3] === 0x0000);
 
a = [7, 6, 2, 5];
b = [1, 0, 3, 4];
result = dojox.uuid.generateTimeBasedUuid._addTwo64bitArrays(a, b);
doh.assertTrue(result[0] === 8);
doh.assertTrue(result[1] === 6);
doh.assertTrue(result[2] === 5);
doh.assertTrue(result[3] === 9);
}
 
function test_uuid_multiplyTwo64bitArrays(){
// summary:
// This is a test we'd like to be able to run, but we can't run it
// because it tests a function which is private in generateTimeBasedUuid
var a = [ 0, 0x0000, 0x0000, 0x0003];
var b = [0x1111, 0x1234, 0x0000, 0xFFFF];
var result = dojox.uuid.generateTimeBasedUuid._multiplyTwo64bitArrays(a, b);
doh.assertTrue(result[0] === 0x3333);
doh.assertTrue(result[1] === 0x369C);
doh.assertTrue(result[2] === 0x0002);
doh.assertTrue(result[3] === 0xFFFD);
 
a = [0, 0, 0, 5];
b = [0, 0, 0, 4];
result = dojox.uuid.generateTimeBasedUuid._multiplyTwo64bitArrays(a, b);
doh.assertTrue(result[0] === 0);
doh.assertTrue(result[1] === 0);
doh.assertTrue(result[2] === 0);
doh.assertTrue(result[3] === 20);
 
a = [0, 0, 2, 5];
b = [0, 0, 3, 4];
result = dojox.uuid.generateTimeBasedUuid._multiplyTwo64bitArrays(a, b);
doh.assertTrue(result[0] === 0);
doh.assertTrue(result[1] === 6);
doh.assertTrue(result[2] === 23);
doh.assertTrue(result[3] === 20);
}
*/
 
}
/trunk/api/js/dojo1.0/dojox/uuid/tests/runTests.html
New file
0,0 → 1,10
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dojox.uuid Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.uuid.tests.uuid">
</head>
<body>
Redirecting to D.O.H runner.
</body>
</html>
/trunk/api/js/dojo1.0/dojox/uuid/_base.js
New file
0,0 → 1,245
if(!dojo._hasResource["dojox.uuid._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.uuid._base"] = true;
dojo.provide("dojox.uuid._base");
 
// Public constants:
dojox.uuid.NIL_UUID = "00000000-0000-0000-0000-000000000000";
dojox.uuid.version = {
// Enumeration for the different UUID versions.
UNKNOWN: 0,
TIME_BASED: 1,
DCE_SECURITY: 2,
NAME_BASED_MD5: 3,
RANDOM: 4,
NAME_BASED_SHA1: 5 };
dojox.uuid.variant = {
// Enumeration for the different UUID variants.
NCS: "0",
DCE: "10",
MICROSOFT: "110",
UNKNOWN: "111" };
 
dojox.uuid.assert = function(/*Boolean*/ booleanValue, /*String?*/ message){
// summary:
// Throws an exception if the assertion fails.
// description:
// If the asserted condition is true, this method does nothing. If the
// condition is false, we throw an error with a error message.
// booleanValue: Must be true for the assertion to succeed.
// message: A string describing the assertion.
// throws: Throws an Error if 'booleanValue' is false.
if(!booleanValue){
if(!message){
message = "An assert statement failed.\n" +
"The method dojox.uuid.assert() was called with a 'false' value.\n";
}
throw new Error(message);
}
};
 
dojox.uuid.generateNilUuid = function(){
// summary:
// This function returns the Nil UUID: "00000000-0000-0000-0000-000000000000".
// description:
// The Nil UUID is described in section 4.1.7 of
// RFC 4122: http://tools.ietf.org/html/rfc4122#section-4.1.7
// examples:
// var string = dojox.uuid.generateNilUuid();
return dojox.uuid.NIL_UUID;; // String
};
 
dojox.uuid.isValid = function(/*String*/ uuidString){
// summary:
// Returns true if the UUID was initialized with a valid value.
uuidString = uuidString.toString();
var valid = (dojo.isString(uuidString) &&
(uuidString.length == 36) &&
(uuidString == uuidString.toLowerCase()));
if(valid){
var arrayOfParts = uuidString.split("-");
valid = ((arrayOfParts.length == 5) &&
(arrayOfParts[0].length == 8) &&
(arrayOfParts[1].length == 4) &&
(arrayOfParts[2].length == 4) &&
(arrayOfParts[3].length == 4) &&
(arrayOfParts[4].length == 12));
var HEX_RADIX = 16;
for (var i in arrayOfParts) {
var part = arrayOfParts[i];
var integer = parseInt(part, HEX_RADIX);
valid = valid && isFinite(integer);
}
}
return valid; // boolean
};
 
dojox.uuid.getVariant = function(/*String*/ uuidString){
// summary:
// Returns a variant code that indicates what type of UUID this is.
// Returns one of the enumerated dojox.uuid.variant values.
// example:
// var variant = dojox.uuid.getVariant("3b12f1df-5232-4804-897e-917bf397618a");
// dojox.uuid.assert(variant == dojox.uuid.variant.DCE);
// example:
// "3b12f1df-5232-4804-897e-917bf397618a"
// ^
// |
// (variant "10__" == DCE)
if(!dojox.uuid._ourVariantLookupTable){
var variant = dojox.uuid.variant;
var lookupTable = [];
 
lookupTable[0x0] = variant.NCS; // 0000
lookupTable[0x1] = variant.NCS; // 0001
lookupTable[0x2] = variant.NCS; // 0010
lookupTable[0x3] = variant.NCS; // 0011
 
lookupTable[0x4] = variant.NCS; // 0100
lookupTable[0x5] = variant.NCS; // 0101
lookupTable[0x6] = variant.NCS; // 0110
lookupTable[0x7] = variant.NCS; // 0111
 
lookupTable[0x8] = variant.DCE; // 1000
lookupTable[0x9] = variant.DCE; // 1001
lookupTable[0xA] = variant.DCE; // 1010
lookupTable[0xB] = variant.DCE; // 1011
 
lookupTable[0xC] = variant.MICROSOFT; // 1100
lookupTable[0xD] = variant.MICROSOFT; // 1101
lookupTable[0xE] = variant.UNKNOWN; // 1110
lookupTable[0xF] = variant.UNKNOWN; // 1111
dojox.uuid._ourVariantLookupTable = lookupTable;
}
 
uuidString = uuidString.toString();
var variantCharacter = uuidString.charAt(19);
var HEX_RADIX = 16;
var variantNumber = parseInt(variantCharacter, HEX_RADIX);
dojox.uuid.assert((variantNumber >= 0) && (variantNumber <= 16));
return dojox.uuid._ourVariantLookupTable[variantNumber]; // dojox.uuid.variant
};
 
dojox.uuid.getVersion = function(/*String*/ uuidString){
// summary:
// Returns a version number that indicates what type of UUID this is.
// Returns one of the enumerated dojox.uuid.version values.
// example:
// var version = dojox.uuid.getVersion("b4308fb0-86cd-11da-a72b-0800200c9a66");
// dojox.uuid.assert(version == dojox.uuid.version.TIME_BASED);
// exceptions:
// Throws an Error if this is not a DCE Variant UUID.
var errorMessage = "dojox.uuid.getVersion() was not passed a DCE Variant UUID.";
dojox.uuid.assert(dojox.uuid.getVariant(uuidString) == dojox.uuid.variant.DCE, errorMessage);
uuidString = uuidString.toString();
// "b4308fb0-86cd-11da-a72b-0800200c9a66"
// ^
// |
// (version 1 == TIME_BASED)
var versionCharacter = uuidString.charAt(14);
var HEX_RADIX = 16;
var versionNumber = parseInt(versionCharacter, HEX_RADIX);
return versionNumber; // dojox.uuid.version
};
 
dojox.uuid.getNode = function(/*String*/ uuidString){
// summary:
// If this is a version 1 UUID (a time-based UUID), getNode() returns a
// 12-character string with the "node" or "pseudonode" portion of the UUID,
// which is the rightmost 12 characters.
// exceptions:
// Throws an Error if this is not a version 1 UUID.
var errorMessage = "dojox.uuid.getNode() was not passed a TIME_BASED UUID.";
dojox.uuid.assert(dojox.uuid.getVersion(uuidString) == dojox.uuid.version.TIME_BASED, errorMessage);
 
uuidString = uuidString.toString();
var arrayOfStrings = uuidString.split('-');
var nodeString = arrayOfStrings[4];
return nodeString; // String (a 12-character string, which will look something like "917bf397618a")
};
 
dojox.uuid.getTimestamp = function(/*String*/ uuidString, /*String?*/ returnType){
// summary:
// If this is a version 1 UUID (a time-based UUID), this method returns
// the timestamp value encoded in the UUID. The caller can ask for the
// timestamp to be returned either as a JavaScript Date object or as a
// 15-character string of hex digits.
// returnType: Any of these five values: "string", String, "hex", "date", Date
// returns:
// Returns the timestamp value as a JavaScript Date object or a 15-character string of hex digits.
// examples:
// var uuidString = "b4308fb0-86cd-11da-a72b-0800200c9a66";
// var date, string, hexString;
// date = dojox.uuid.getTimestamp(uuidString); // returns a JavaScript Date
// date = dojox.uuid.getTimestamp(uuidString, Date); //
// string = dojox.uuid.getTimestamp(uuidString, String); // "Mon, 16 Jan 2006 20:21:41 GMT"
// hexString = dojox.uuid.getTimestamp(uuidString, "hex"); // "1da86cdb4308fb0"
// exceptions:
// Throws an Error if this is not a version 1 UUID.
var errorMessage = "dojox.uuid.getTimestamp() was not passed a TIME_BASED UUID.";
dojox.uuid.assert(dojox.uuid.getVersion(uuidString) == dojox.uuid.version.TIME_BASED, errorMessage);
uuidString = uuidString.toString();
if(!returnType){returnType = null};
switch(returnType){
case "string":
case String:
return dojox.uuid.getTimestamp(uuidString, Date).toUTCString(); // String (e.g. "Mon, 16 Jan 2006 20:21:41 GMT")
break;
case "hex":
// Return a 15-character string of hex digits containing the
// timestamp for this UUID, with the high-order bits first.
var arrayOfStrings = uuidString.split('-');
var hexTimeLow = arrayOfStrings[0];
var hexTimeMid = arrayOfStrings[1];
var hexTimeHigh = arrayOfStrings[2];
// Chop off the leading "1" character, which is the UUID
// version number for time-based UUIDs.
hexTimeHigh = hexTimeHigh.slice(1);
var timestampAsHexString = hexTimeHigh + hexTimeMid + hexTimeLow;
dojox.uuid.assert(timestampAsHexString.length == 15);
return timestampAsHexString; // String (e.g. "1da86cdb4308fb0")
break;
case null: // no returnType was specified, so default to Date
case "date":
case Date:
// Return a JavaScript Date object.
var GREGORIAN_CHANGE_OFFSET_IN_HOURS = 3394248;
var HEX_RADIX = 16;
var arrayOfParts = uuidString.split('-');
var timeLow = parseInt(arrayOfParts[0], HEX_RADIX);
var timeMid = parseInt(arrayOfParts[1], HEX_RADIX);
var timeHigh = parseInt(arrayOfParts[2], HEX_RADIX);
var hundredNanosecondIntervalsSince1582 = timeHigh & 0x0FFF;
hundredNanosecondIntervalsSince1582 <<= 16;
hundredNanosecondIntervalsSince1582 += timeMid;
// What we really want to do next is shift left 32 bits, but the
// result will be too big to fit in an int, so we'll multiply by 2^32,
// and the result will be a floating point approximation.
hundredNanosecondIntervalsSince1582 *= 0x100000000;
hundredNanosecondIntervalsSince1582 += timeLow;
var millisecondsSince1582 = hundredNanosecondIntervalsSince1582 / 10000;
// Again, this will be a floating point approximation.
// We can make things exact later if we need to.
var secondsPerHour = 60 * 60;
var hoursBetween1582and1970 = GREGORIAN_CHANGE_OFFSET_IN_HOURS;
var secondsBetween1582and1970 = hoursBetween1582and1970 * secondsPerHour;
var millisecondsBetween1582and1970 = secondsBetween1582and1970 * 1000;
var millisecondsSince1970 = millisecondsSince1582 - millisecondsBetween1582and1970;
var timestampAsDate = new Date(millisecondsSince1970);
return timestampAsDate; // Date
break;
default:
// we got passed something other than a valid returnType
dojox.uuid.assert(false, "dojox.uuid.getTimestamp was not passed a valid returnType: " + returnType);
break;
}
};
 
}
/trunk/api/js/dojo1.0/dojox/string/README
New file
0,0 → 1,39
-------------------------------------------------------------------------------
DojoX String Utilities
-------------------------------------------------------------------------------
Version 0.9
Release date: 05/08/2007
-------------------------------------------------------------------------------
Project state:
dojox.string.Builder: stable
dojox.string.sprintf: beta
dojox.string.tokenize: beta
-------------------------------------------------------------------------------
Project authors
Ben Lowery
Tom Trenka (ttrenka@gmail.com)
Neil Roberts
-------------------------------------------------------------------------------
Project description
 
The DojoX String utilties project is a placeholder for miscellaneous string
utility functions. At the time of writing, only the Builder object has been
added; but we anticipate other string utilities may end up living here as well.
-------------------------------------------------------------------------------
Dependencies:
 
Dojo Core (package loader).
-------------------------------------------------------------------------------
Documentation
 
See the Dojo Toolkit API docs (http://dojotookit.org/api), dojo.string.Builder.
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/string/*
 
Install into the following directory structure:
/dojox/string/
 
...which should be at the same level as your Dojo checkout.
/trunk/api/js/dojo1.0/dojox/string/sprintf.js
New file
0,0 → 1,406
if(!dojo._hasResource["dojox.string.sprintf"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.string.sprintf"] = true;
dojo.provide("dojox.string.sprintf");
 
dojo.require("dojox.string.tokenize");
 
dojox.string.sprintf = function(/*String*/ format, /*mixed...*/ filler){
for(var args = [], i = 1; i < arguments.length; i++){
args.push(arguments[i]);
}
var formatter = new dojox.string.sprintf.Formatter(format);
return formatter.format.apply(formatter, args);
}
 
dojox.string.sprintf.Formatter = function(/*String*/ format){
var tokens = [];
this._mapped = false;
this._format = format;
this._tokens = dojox.string.tokenize(format, this._re, this._parseDelim, this);
}
dojo.extend(dojox.string.sprintf.Formatter, {
_re: /\%(?:\(([\w_]+)\)|([1-9]\d*)\$)?([0 +\-\#]*)(\*|\d+)?(\.)?(\*|\d+)?[hlL]?([\%scdeEfFgGiouxX])/g,
_parseDelim: function(mapping, intmapping, flags, minWidth, period, precision, specifier){
if(mapping){
this._mapped = true;
}
return {
mapping: mapping,
intmapping: intmapping,
flags: flags,
_minWidth: minWidth, // May be dependent on parameters
period: period,
_precision: precision, // May be dependent on parameters
specifier: specifier
};
},
_specifiers: {
b: {
base: 2,
isInt: true
},
o: {
base: 8,
isInt: true
},
x: {
base: 16,
isInt: true
},
X: {
extend: ["x"],
toUpper: true
},
d: {
base: 10,
isInt: true
},
i: {
extend: ["d"]
},
u: {
extend: ["d"],
isUnsigned: true
},
c: {
setArg: function(token){
if(!isNaN(token.arg)){
var num = parseInt(token.arg);
if(num < 0 || num > 127){
throw new Error("invalid character code passed to %c in sprintf");
}
token.arg = isNaN(num) ? "" + num : String.fromCharCode(num);
}
}
},
s: {
setMaxWidth: function(token){
token.maxWidth = (token.period == ".") ? token.precision : -1;
}
},
e: {
isDouble: true,
doubleNotation: "e"
},
E: {
extend: ["e"],
toUpper: true
},
f: {
isDouble: true,
doubleNotation: "f"
},
F: {
extend: ["f"]
},
g: {
isDouble: true,
doubleNotation: "g"
},
G: {
extend: ["g"],
toUpper: true
}
},
format: function(/*mixed...*/ filler){
if(this._mapped && typeof filler != "object"){
throw new Error("format requires a mapping");
}
 
var str = "";
var position = 0;
for(var i = 0, token; i < this._tokens.length; i++){
token = this._tokens[i];
if(typeof token == "string"){
str += token;
}else{
if(this._mapped){
if(typeof filler[token.mapping] == "undefined"){
throw new Error("missing key " + token.mapping);
}
token.arg = filler[token.mapping];
}else{
if(token.intmapping){
var position = parseInt(token.intmapping) - 1;
}
if(position >= arguments.length){
throw new Error("got " + arguments.length + " printf arguments, insufficient for '" + this._format + "'");
}
token.arg = arguments[position++];
}
 
if(!token.compiled){
token.compiled = true;
token.sign = "";
token.zeroPad = false;
token.rightJustify = false;
token.alternative = false;
 
var flags = {};
for(var fi = token.flags.length; fi--;){
var flag = token.flags.charAt(fi);
flags[flag] = true;
switch(flag){
case " ":
token.sign = " ";
break;
case "+":
token.sign = "+";
break;
case "0":
token.zeroPad = (flags["-"]) ? false : true;
break;
case "-":
token.rightJustify = true;
token.zeroPad = false;
break;
case "\#":
token.alternative = true;
break;
default:
throw Error("bad formatting flag '" + token.flags.charAt(fi) + "'");
}
}
 
token.minWidth = (token._minWidth) ? parseInt(token._minWidth) : 0;
token.maxWidth = -1;
token.toUpper = false;
token.isUnsigned = false;
token.isInt = false;
token.isDouble = false;
token.precision = 1;
if(token.period == '.'){
if(token._precision){
token.precision = parseInt(token._precision);
}else{
token.precision = 0;
}
}
 
var mixins = this._specifiers[token.specifier];
if(typeof mixins == "undefined"){
throw new Error("unexpected specifier '" + token.specifier + "'");
}
if(mixins.extend){
dojo.mixin(mixins, this._specifiers[mixins.extend]);
delete mixins.extend;
}
dojo.mixin(token, mixins);
}
 
if(typeof token.setArg == "function"){
token.setArg(token);
}
 
if(typeof token.setMaxWidth == "function"){
token.setMaxWidth(token);
}
 
if(token._minWidth == "*"){
if(this._mapped){
throw new Error("* width not supported in mapped formats");
}
token.minWidth = parseInt(arguments[position++]);
if(isNaN(token.minWidth)){
throw new Error("the argument for * width at position " + position + " is not a number in " + this._format);
}
// negative width means rightJustify
if (token.minWidth < 0) {
token.rightJustify = true;
token.minWidth = -token.minWidth;
}
}
 
if(token._precision == "*" && token.period == "."){
if(this._mapped){
throw new Error("* precision not supported in mapped formats");
}
token.precision = parseInt(arguments[position++]);
if(isNaN(token.precision)){
throw Error("the argument for * precision at position " + position + " is not a number in " + this._format);
}
// negative precision means unspecified
if (token.precision < 0) {
token.precision = 1;
token.period = '';
}
}
 
if(token.isInt){
// a specified precision means no zero padding
if(token.period == '.'){
token.zeroPad = false;
}
this.formatInt(token);
}else if(token.isDouble){
if(token.period != '.'){
token.precision = 6;
}
this.formatDouble(token);
}
this.fitField(token);
 
str += "" + token.arg;
}
}
 
return str;
},
_zeros10: '0000000000',
_spaces10: ' ',
formatInt: function(token) {
var i = parseInt(token.arg);
if(!isFinite(i)){ // isNaN(f) || f == Number.POSITIVE_INFINITY || f == Number.NEGATIVE_INFINITY)
// allow this only if arg is number
if(typeof token.arg != "number"){
throw new Error("format argument '" + token.arg + "' not an integer; parseInt returned " + i);
}
//return '' + i;
i = 0;
}
 
// if not base 10, make negatives be positive
// otherwise, (-10).toString(16) is '-a' instead of 'fffffff6'
if(i < 0 && (token.isUnsigned || token.base != 10)){
i = 0xffffffff + i + 1;
}
 
if(i < 0){
token.arg = (- i).toString(token.base);
this.zeroPad(token);
token.arg = "-" + token.arg;
}else{
token.arg = i.toString(token.base);
// need to make sure that argument 0 with precision==0 is formatted as ''
if(!i && !token.precision){
token.arg = "";
}else{
this.zeroPad(token);
}
if(token.sign){
token.arg = token.sign + token.arg;
}
}
if(token.base == 16){
if(token.alternative){
token.arg = '0x' + token.arg;
}
toke.art = token.toUpper ? token.arg.toUpperCase() : token.arg.toLowerCase();
}
if(token.base == 8){
if(token.alternative && token.arg.charAt(0) != '0'){
token.arg = '0' + token.arg;
}
}
},
formatDouble: function(token) {
var f = parseFloat(token.arg);
if(!isFinite(f)){ // isNaN(f) || f == Number.POSITIVE_INFINITY || f == Number.NEGATIVE_INFINITY)
// allow this only if arg is number
if(typeof token.arg != "number"){
throw new Error("format argument '" + token.arg + "' not a float; parseFloat returned " + f);
}
// C99 says that for 'f':
// infinity -> '[-]inf' or '[-]infinity' ('[-]INF' or '[-]INFINITY' for 'F')
// NaN -> a string starting with 'nan' ('NAN' for 'F')
// this is not commonly implemented though.
//return '' + f;
f = 0;
}
 
switch(token.doubleNotation) {
case 'e': {
token.arg = f.toExponential(token.precision);
break;
}
case 'f': {
token.arg = f.toFixed(token.precision);
break;
}
case 'g': {
// C says use 'e' notation if exponent is < -4 or is >= prec
// ECMAScript for toPrecision says use exponential notation if exponent is >= prec,
// though step 17 of toPrecision indicates a test for < -6 to force exponential.
if(Math.abs(f) < 0.0001){
//print("forcing exponential notation for f=" + f);
token.arg = f.toExponential(token.precision > 0 ? token.precision - 1 : token.precision);
}else{
token.arg = f.toPrecision(token.precision);
}
 
// In C, unlike 'f', 'gG' removes trailing 0s from fractional part, unless alternative format flag ("#").
// But ECMAScript formats toPrecision as 0.00100000. So remove trailing 0s.
if(!token.alternative){
//print("replacing trailing 0 in '" + s + "'");
token.arg = token.arg.replace(/(\..*[^0])0*/, "$1");
// if fractional part is entirely 0, remove it and decimal point
token.arg = token.arg.replace(/\.0*e/, 'e').replace(/\.0$/,'');
}
break;
}
default: throw new Error("unexpected double notation '" + token.doubleNotation + "'");
}
 
// C says that exponent must have at least two digits.
// But ECMAScript does not; toExponential results in things like "1.000000e-8" and "1.000000e+8".
// Note that s.replace(/e([\+\-])(\d)/, "e$10$2") won't work because of the "$10" instead of "$1".
// And replace(re, func) isn't supported on IE50 or Safari1.
token.arg = token.arg.replace(/e\+(\d)$/, "e+0$1").replace(/e\-(\d)$/, "e-0$1");
 
// Ensure a '0' before the period.
// Opera implements (0.001).toString() as '0.001', but (0.001).toFixed(1) is '.001'
if(dojo.isOpera){
token.arg = token.arg.replace(/^\./, '0.');
}
 
// if alt, ensure a decimal point
if(token.alternative){
token.arg = token.arg.replace(/^(\d+)$/,"$1.");
token.arg = token.arg.replace(/^(\d+)e/,"$1.e");
}
 
if(f >= 0 && token.sign){
token.arg = token.sign + token.arg;
}
 
token.arg = token.toUpper ? token.arg.toUpperCase() : token.arg.toLowerCase();
},
zeroPad: function(token, /*Int*/ length) {
length = (arguments.length == 2) ? length : token.precision;
if(typeof token.arg != "string"){
token.arg = "" + token.arg;
}
 
var tenless = length - 10;
while(token.arg.length < tenless){
token.arg = (token.rightJustify) ? token.arg + this._zeros10 : this._zeros10 + token.arg;
}
var pad = length - token.arg.length;
token.arg = (token.rightJustify) ? token.arg + this._zeros10.substring(0, pad) : this._zeros10.substring(0, pad) + token.arg;
},
fitField: function(token) {
if(token.maxWidth >= 0 && token.arg.length > token.maxWidth){
return token.arg.substring(0, token.maxWidth);
}
if(token.zeroPad){
this.zeroPad(token, token.minWidth);
return;
}
this.spacePad(token);
},
spacePad: function(token, /*Int*/ length) {
length = (arguments.length == 2) ? length : token.minWidth;
if(typeof token.arg != 'string'){
token.arg = '' + token.arg;
}
 
var tenless = length - 10;
while(token.arg.length < tenless){
token.arg = (token.rightJustify) ? token.arg + this._spaces10 : this._spaces10 + token.arg;
}
var pad = length - token.arg.length;
token.arg = (token.rightJustify) ? token.arg + this._spaces10.substring(0, pad) : this._spaces10.substring(0, pad) + token.arg;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/string/Builder.js
New file
0,0 → 1,101
if(!dojo._hasResource["dojox.string.Builder"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.string.Builder"] = true;
dojo.provide("dojox.string.Builder");
 
(function(){
dojox.string.Builder = function(/*String?*/str){
// summary:
// A fast buffer for creating large strings
// str: The initial string to seed the buffer with
this.b = dojo.isIE ? [] : "";
if(str){ this.append(str); }
};
var m = {
append: function(/*String*/s){
// summary: Append all arguments to the end of the buffer
return this.appendArray(dojo._toArray(arguments)); // dojox.string.Builder
},
concat: function(/*String*/s){
return this.append(s);
},
appendArray: function(/*Array*/strings) {
this.b = String.prototype.concat.apply(this.b, strings);
return this;
},
clear: function(){
// summary: Remove all characters from the buffer
this._clear();
this.length = 0;
return this;
},
replace: function(oldStr,newStr){
// summary: Replace instances of one string with another in the buffer
var s = this.toString();
s = s.replace(oldStr,newStr);
this._reset(s);
this.length = s.length;
return this;
},
remove: function(start, len){
// summary: Remove len characters starting at index start
if(len == 0){ return this; }
var s = this.toString();
this.clear();
if(start > 0){
this.append(s.substring(0, start));
}
if(start+len < s.length){
this.append(s.substring(start+len));
}
return this;
},
insert: function(index, str){
// summary: Insert string str starting at index
var s = this.toString();
this.clear();
if(index == 0){
this.append(str);
this.append(s);
return this;
}else{
this.append(s.substring(0, index));
this.append(str);
this.append(s.substring(index));
}
return this;
},
toString: function(){
return this.b;
},
_clear: function(){
this.b = "";
},
_reset: function(s){
this.b = s;
}
}; // will hold methods for Builder
if(dojo.isIE){
dojo.mixin(m, {
toString: function(){
// Summary: Get the buffer as a string
return this.b.join("");
},
appendArray: function(strings){
this.b = this.b.concat(strings);
return this;
},
_clear: function(){
this.b = [];
},
_reset: function(s){
this.b = [ s ];
}
});
}
dojo.extend(dojox.string.Builder, m);
})();
 
}
/trunk/api/js/dojo1.0/dojox/string/tests/Builder.js
New file
0,0 → 1,91
if(!dojo._hasResource["dojox.string.tests.Builder"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.string.tests.Builder"] = true;
dojo.provide("dojox.string.tests.Builder");
 
dojo.require("dojox.string.Builder");
 
tests.register("dojox.string.tests.Builder", [
{
name: "Append",
runTest: function(t) {
var b = new dojox.string.Builder();
b.append("foo");
t.is("foo", b.toString());
b.append("bar", "baz");
t.is("foobarbaz", b.toString());
b.append("ben").append("zoo");
t.is("foobarbazbenzoo", b.toString());
b.append(5);
t.is("foobarbazbenzoo5", b.toString());
}
},
{
name: "Construction",
runTest: function(t){
var b = new dojox.string.Builder();
t.is("", b.toString());
b = new dojox.string.Builder("foo");
t.is("foo", b.toString());
}
},
{
name: "Replace",
runTest: function(t){
var b = new dojox.string.Builder("foobar");
t.is("foobar", b.toString());
b.replace("foo", "baz");
t.is("bazbar", b.toString());
b.replace("baz", "ben");
t.is("benbar", b.toString());
b.replace("foo", "moo");
t.is("benbar", b.toString());
b.replace("enba", "o");
t.is("bor", b.toString());
b.replace("o", "a").replace("b", "f");
t.is("far", b.toString());
}
},
{
name: "Insert",
runTest: function(t){
var b = new dojox.string.Builder();
//insert at 0 is prepend
b.insert(0, "foo");
t.is("foo", b.toString());
b.insert(0, "more");
t.is("morefoo", b.toString());
//insert positions stuff after the 4th character
b.insert(4, "fun");
t.is("morefunfoo", b.toString());
//insert at len of string is push_back
b.insert(10, "awesome");
t.is("morefunfooawesome", b.toString());
//insert past len of string is push_back
b.insert(100, "bad");
t.is("morefunfooawesomebad", b.toString());
b = new dojox.string.Builder();
b.insert(0, "foo").insert(3, "bar").insert(3, "zoo");
t.is("foozoobar", b.toString());
}
},
{
name: "Remove",
runTest: function(t){
var b = new dojox.string.Builder("foobarbaz");
b.remove(3,3);
t.is("foobaz", b.toString());
b.remove(0,3);
t.is("baz", b.toString());
b.remove(2, 100);
t.is("ba", b.toString());
b.remove(0,0);
t.is("ba", b.toString())
}
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/string/tests/string.js
New file
0,0 → 1,10
if(!dojo._hasResource["dojox.string.tests.string"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.string.tests.string"] = true;
dojo.provide("dojox.string.tests.string");
 
try{
dojo.require("dojox.string.tests.Builder");
dojo.require("dojox.string.tests.sprintf");
} catch(e){ }
 
}
/trunk/api/js/dojo1.0/dojox/string/tests/lipsum.js
New file
0,0 → 1,133
var lipsum = ["Lorem", "ipsum", "dolor", "sit", "amet,", "consectetuer",
"adipiscing", "elit.", "Suspendisse", "nisi.", "Pellentesque", "facilisis",
"pretium", "nulla.", "Sed", "semper", "accumsan", "quam.", "Donec",
"vulputate", "auctor", "neque.", "Aenean", "arcu", "pede,", "consequat",
"eget,", "molestie", "sed,", "bibendum", "quis,", "ante.", "Praesent", "sit",
"amet", "odio", "ut", "ipsum", "suscipit", "faucibus.", "Vestibulum",
"accumsan,", "nunc", "non", "adipiscing", "hendrerit,", "lorem", "arcu",
"dignissim", "mi,", "vel", "blandit", "urna", "velit", "dictum", "leo.",
"Aliquam", "ornare", "massa", "quis", "lacus.", "Cum", "sociis", "natoque",
"penatibus", "et", "magnis", "dis", "parturient", "montes,", "nascetur",
"ridiculus", "mus.", "Vivamus", "sit", "amet", "ligula.", "Pellentesque",
"vitae", "nunc", "sed", "mauris", "consequat", "condimentum.Lorem", "ipsum",
"dolor", "sit", "amet,", "consectetuer", "adipiscing", "elit.", "Donec", "in",
"lectus", "eu", "magna", "consectetuer", "pellentesque.", "Donec", "ante.",
"Integer", "ut", "turpis.", "Sed", "tincidunt", "consectetuer", "purus.",
"Cras", "lacus.", "Nunc", "et", "lacus.", "Ut", "aliquet", "urna", "ut",
"urna.", "Etiam", "vel", "urna.", "Nunc", "id", "diam.", "Fusce", "at",
"purus", "id", "velit", "molestie", "pretium.Aenean", "vel", "sapien", "et",
"justo", "ornare", "cursus.", "Donec", "facilisis.", "Vestibulum", "feugiat",
"magna", "in", "nulla.", "Curabitur", "orci.", "Vestibulum", "molestie",
"aliquet", "est.", "Sed", "eget", "erat", "non", "sem", "laoreet",
"pellentesque.", "Cras", "at", "odio", "nec", "leo", "egestas", "blandit.",
"Nullam", "at", "dui.", "Duis", "felis", "lacus,", "blandit", "non,",
"consequat", "ut,", "fringilla", "at,", "est.", "Etiam", "blandit", "porta",
"tellus.", "Etiam", "purus", "turpis,", "molestie", "ut,", "tristique",
"eget,", "elementum", "sit", "amet,", "orci.", "Pellentesque", "condimentum",
"ultrices", "neque.", "Duis", "dignissim.", "Curabitur", "condimentum",
"arcu", "id", "sapien.Nunc", "diam", "eros,", "pellentesque", "non,",
"lobortis", "et,", "venenatis", "eu,", "felis.", "Vestibulum", "vel", "dolor",
"quis", "nunc", "semper", "consectetuer.", "Nullam", "mollis.", "Aenean",
"molestie", "cursus", "mi.", "Mauris", "ante.", "In", "hac", "habitasse",
"platea", "dictumst.", "Nunc", "sem", "dui,", "fermentum", "ac,", "luctus",
"a,", "imperdiet", "in,", "neque.", "Cras", "mattis", "pretium", "metus.",
"Praesent", "ligula", "mi,", "imperdiet", "eu,", "rutrum", "volutpat,",
"blandit", "id,", "lectus.", "Duis", "sed", "mauris", "id", "lacus",
"lacinia", "rhoncus.", "Vivamus", "ultricies", "sem", "a", "nisi",
"fermentum", "pretium.", "Cras", "sagittis", "tempus", "velit.", "Mauris",
"eget", "quam.", "Sed", "facilisis", "tincidunt", "tellus.", "Vestibulum",
"rhoncus", "venenatis", "felis.", "Aliquam", "erat", "volutpat.Proin", "et",
"orci", "at", "libero", "faucibus", "iaculis.", "Nam", "id", "purus.", "Ut",
"aliquet,", "turpis", "id", "volutpat", "gravida,", "felis", "urna",
"viverra", "justo,", "id", "semper", "nulla", "ligula", "id", "libero.",
"Sed", "fringilla.", "Fusce", "vel", "lorem", "ut", "tortor", "porta",
"tincidunt.", "Nunc", "arcu.", "Class", "aptent", "taciti", "sociosqu", "ad",
"litora", "torquent", "per", "coubia", "ostra,", "per", "iceptos",
"hymeaeos.", "Doec", "ullamcorper", "ate", "vel", "felis.", "Mauris", "quis",
"dolor.", "Vestibulum", "ulla", "felis,", "laoreet", "ut,", "placerat", "at,",
"malesuada", "et,", "lacus.", "Suspedisse", "eget", "mi", "id", "dui",
"porttitor", "porttitor.", "Quisque", "elemetum.", "Sed", "tortor.", "Etiam",
"malesuada.", "Cum", "sociis", "atoque", "peatibus", "et", "magis", "dis",
"parturiet", "motes,", "ascetur", "ridiculus", "mus.Suspedisse", "euismod",
"sagittis", "eros.", "uc", "sollicitudi.", "Doec", "ac", "turpis.", "Mauris",
"feugiat", "isl", "vel", "ate.", "am", "isi.", "Etiam", "auctor", "elemetum",
"diam.", "uc", "ut", "elit", "auctor", "ibh", "orare", "viverra.", "Iteger",
"vulputate.", "Duis", "dictum", "justo", "sagittis", "tortor.", "Suspedisse",
"placerat.", "am", "faucibus", "eros", "eget", "odio.", "Proi", "et",
"lectus.", "uc", "massa", "ligula,", "vulputate", "eu,", "mattis", "ac,",
"euismod", "ec,", "isl.", "ullam", "sit", "amet", "turpis", "eu", "ura",
"elemetum", "auctor.", "Pelletesque", "lobortis", "orare", "justo.",
"Suspedisse", "metus", "felis,", "iterdum", "ac,", "placerat", "at,",
"frigilla", "mollis,", "erat.", "ullam", "sed", "odio", "eu", "mi", "egestas",
"scelerisque.", "Pelletesque", "habitat", "morbi", "tristique", "seectus",
"et", "etus", "et", "malesuada", "fames", "ac", "turpis", "egestas.", "Cras",
"purus", "leo,", "aliquam", "eget,", "accumsa", "volutpat,", "eleifed",
"vel,", "eros.", "I", "ultricies", "mattis", "turpis.Curabitur", "volutpat",
"aliquam", "lorem.", "Sed", "at", "risus.", "Quisque", "tristique.",
"Suspedisse", "mollis.", "I", "tellus", "quam,", "viverra", "eget,", "mollis",
"vitae,", "bibedum", "sit", "amet,", "eim.", "Pelletesque", "frigilla",
"tortor", "ac", "orci.", "Phasellus", "commodo", "porttitor", "elit.",
"Maeceas", "ate", "orci,", "vehicula", "ticidut,", "lobortis", "eu,",
"vehicula", "id,", "lorem.", "Quisque", "sapie", "ura,", "iaculis",
"laoreet,", "digissim", "ac,", "adipiscig", "vitae,", "elit.", "ulla",
"fermetum,", "leo", "ec", "posuere", "tempor,", "isi", "diam", "cursus",
"arcu,", "at", "egestas", "ibh", "maga", "i", "odio.", "Mauris", "o", "diam",
"sed", "dolor", "ultricies", "egestas.", "Aliquam", "erat", "volutpat.",
"Quisque", "rhocus.", "ulla", "vitae", "arcu", "o", "pede", "scelerisque",
"luctus.", "Pelletesque", "pretium", "massa.", "Fusce", "i", "leo", "eget",
"eros", "fermetum", "ticidut.", "ulla", "velit", "risus,", "malesuada",
"sed,", "auctor", "faucibus,", "porta", "sed,", "lacus.", "Aeea", "at",
"eque.Doec", "o", "maga.", "Suspedisse", "cosequat", "orci", "sit", "amet",
"velit.", "Ut", "est.", "Iteger", "sollicitudi,", "libero", "vitae",
"gravida", "imperdiet,", "sem", "lorem", "tristique", "odio,", "sed",
"pulviar", "tortor", "arcu", "vel", "mi.", "Aliquam", "erat", "volutpat.",
"Vivamus", "tellus.", "Cras", "semper.", "Cras", "dictum", "dictum", "eros.",
"Praeset", "et", "ulla", "i", "ulla", "ultricies", "auctor.", "Aeea",
"tortor", "odio,", "ticidut", "sit", "amet,", "vestibulum", "id,", "covallis",
"vel,", "pede.", "Vivamus", "volutpat", "elit", "i", "orci.", "Praeset",
"arcu", "justo,", "adipiscig", "ac,", "commodo", "quis,", "scelerisque",
"ac,", "libero.", "I", "odio", "ate,", "rutrum", "eu,", "aliquam", "vitae,",
"ullamcorper", "et,", "sapie.", "Ut", "augue", "purus,", "pelletesque", "ut,",
"auctor", "sit", "amet,", "laoreet", "eget,", "lectus.", "Vestibulum", "ate",
"ipsum", "primis", "i", "faucibus", "orci", "luctus", "et", "ultrices",
"posuere", "cubilia", "Curae;", "I", "orare,", "dui", "ac", "cosequat",
"posuere,", "justo", "odio", "fermetum", "sem,", "eget", "covallis", "lacus",
"quam", "o", "dui.", "Etiam", "mattis", "lacus", "cosectetuer", "pede",
"veeatis", "eleifed.", "Cras", "quis", "tortor.uc", "libero", "erat,",
"ultricies", "eget,", "ticidut", "sed,", "placerat", "eu,", "sapie.", "Cras",
"posuere,", "pede", "ec", "dictum", "egestas,", "tortor", "orci", "faucibus",
"lorem,", "eget", "iterdum", "mauris", "velit", "dapibus", "velit.", "ulla",
"digissim", "imperdiet", "sapie.", "Ut", "tempus", "tellus.", "Pelletesque",
"adipiscig", "varius", "tortor.", "Doec", "ligula", "dolor,", "pulviar",
"ut,", "rutrum", "ac,", "dictum", "eget,", "diam.", "Sed", "at", "justo.",
"Etiam", "orare", "scelerisque", "erat.", "am", "arcu.", "Iteger", "i",
"orci.", "Fusce", "cosectetuer,", "isi", "o", "iterdum", "bladit,", "velit",
"turpis", "codimetum", "tellus,", "i", "ullamcorper", "turpis", "leo", "at",
"tellus.", "Doec", "velit.", "Phasellus", "augue.", "Doec", "et", "dui",
"quis", "tortor", "fermetum", "eleifed.", "ulla", "facilisi.", "am",
"veeatis", "suscipit", "ate.", "Aeea", "volutpat.", "Pelletesque",
"ultricies", "accumsa", "orci.", "Pelletesque", "tellus", "diam,", "frigilla",
"eu,", "cursus", "at,", "porta", "eget,", "justo.am", "dui.", "Suspedisse",
"poteti.", "Vestibulum", "porttitor,", "purus", "a", "ullamcorper",
"placerat,", "justo", "libero", "digissim", "augue,", "quis", "pelletesque",
"ura", "tortor", "a", "orci.", "Duis", "eim.", "Aeea", "auctor,", "augue",
"sed", "facilisis", "vulputate,", "ipsum", "lacus", "vestibulum", "metus,",
"eu", "egestas", "felis", "diam", "a", "mauris.", "ulla", "imperdiet", "elit",
"vel", "lectus.", "Ut", "ac", "ibh", "vel", "pede", "gravida", "hedrerit.",
"Sed", "pelletesque,", "odio", "et", "eleifed", "cosequat,", "ulla", "ligula",
"pretium", "ura,", "vel", "ultricies", "eros", "orci", "ut", "pede.", "Doec",
"cosequat", "orare", "maga.", "Pelletesque", "ulla", "eim,", "bladit",
"eget,", "sollicitudi", "ticidut,", "posuere", "vel,", "dolor.", "Phasellus",
"facilisis", "arcu", "ut", "isi.", "Vivamus", "varius.", "Curabitur",
"hedrerit,", "ligula", "sit", "amet", "molestie", "facilisis,", "ligula",
"libero", "ultricies", "ulla,", "at", "bibedum", "libero", "dolor", "ticidut",
"ibh.", "Doec", "pede", "tellus,", "pharetra", "pelletesque,", "euismod",
"eget,", "placerat", "ut,", "dolor.Aeea", "mauris.", "Pelletesque", "sed",
"ligula.", "Quisque", "faucibus", "tristique", "eque.", "Maeceas", "tempus",
"auctor", "uc.", "Etiam", "et", "justo.", "Praeset", "ultrices", "odio", "id",
"arcu", "aliquam", "pretium.", "Sed", "pulviar", "purus", "eu", "lorem.",
"Suspedisse", "poteti.", "Aeea", "lacus.", "Vestibulum", "sit", "amet", "isi",
"sed", "justo", "bibedum", "ticidut.", "Aliquam", "semper", "vestibulum",
"quam.", "Sed."];
 
var lipsumLong = ["sed justo bibedum ticidut. Aliquam semper vestibulum quam. Sed. Lorem ipsum dolor sit amet, consecte...", "facilisis pretium nulla. Sed semper accumsan quam. Donec vulputate auctor", "neque. Aenean arcu pede, consequat eget, molestie sed, bibendum quis,", "ante. Praesent sit amet odio ut ipsum suscipit faucibus. Vestibulum", "accumsan, nunc non adipiscing hendrerit, lorem arcu dignissim mi, vel", "blandit urna velit dictum leo. Aliquam ornare massa quis lacus.", "Cum sociis natoque penatibus et magnis dis parturient montes, nascetur", "ridiculus mus. Vivamus sit amet ligula. Pellentesque vitae nunc sed", "mauris consequat condimentum.Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", "Donec in lectus eu magna consectetuer pellentesque. Donec ante. Integer", "ut turpis. Sed tincidunt consectetuer purus. Cras lacus. Nunc et", "lacus. Ut aliquet urna ut urna. Etiam vel urna. Nunc", "id diam. Fusce at purus id velit molestie pretium.Aenean vel", "sapien et justo ornare cursus. Donec facilisis. Vestibulum feugiat magna", "in nulla. Curabitur orci. Vestibulum molestie aliquet est. Sed eget", "erat non sem laoreet pellentesque. Cras at odio nec leo", "egestas blandit. Nullam at dui. Duis felis lacus, blandit non,", "consequat ut, fringilla at, est. Etiam blandit porta tellus. Etiam", "purus turpis, molestie ut, tristique eget, elementum sit amet, orci.", "Pellentesque condimentum ultrices neque. Duis dignissim. Curabitur condimentum arcu id", "sapien.Nunc diam eros, pellentesque non, lobortis et, venenatis eu, felis.", "Vestibulum vel dolor quis nunc semper consectetuer. Nullam mollis. Aenean", "molestie cursus mi. Mauris ante. In hac habitasse platea dictumst.", "Nunc sem dui, fermentum ac, luctus a, imperdiet in, neque.", "Cras mattis pretium metus. Praesent ligula mi, imperdiet eu, rutrum", "volutpat, blandit id, lectus. Duis sed mauris id lacus lacinia", "rhoncus. Vivamus ultricies sem a nisi fermentum pretium. Cras sagittis", "tempus velit. Mauris eget quam. Sed facilisis tincidunt tellus. Vestibulum", "rhoncus venenatis felis. Aliquam erat volutpat.Proin et orci at libero", "faucibus iaculis. Nam id purus. Ut aliquet, turpis id volutpat", "gravida, felis urna viverra justo, id semper nulla ligula id", "libero. Sed fringilla. Fusce vel lorem ut tortor porta tincidunt.", "Nunc arcu. Class aptent taciti sociosqu ad litora torquent per", "coubia ostra, per iceptos hymeaeos. Doec ullamcorper ate vel felis.", "Mauris quis dolor. Vestibulum ulla felis, laoreet ut, placerat at,", "malesuada et, lacus. Suspedisse eget mi id dui porttitor porttitor.", "Quisque elemetum. Sed tortor. Etiam malesuada. Cum sociis atoque peatibus", "et magis dis parturiet motes, ascetur ridiculus mus.Suspedisse euismod sagittis", "eros. uc sollicitudi. Doec ac turpis. Mauris feugiat isl vel", "ate. am isi. Etiam auctor elemetum diam. uc ut elit", "auctor ibh orare viverra. Iteger vulputate. Duis dictum justo sagittis", "tortor. Suspedisse placerat. am faucibus eros eget odio. Proi et", "lectus. uc massa ligula, vulputate eu, mattis ac, euismod ec,", "isl. ullam sit amet turpis eu ura elemetum auctor. Pelletesque", "lobortis orare justo. Suspedisse metus felis, iterdum ac, placerat at,", "frigilla mollis, erat. ullam sed odio eu mi egestas scelerisque.", "Pelletesque habitat morbi tristique seectus et etus et malesuada fames", "ac turpis egestas. Cras purus leo, aliquam eget, accumsa volutpat,", "eleifed vel, eros. I ultricies mattis turpis.Curabitur volutpat aliquam lorem.", "Sed at risus. Quisque tristique. Suspedisse mollis. I tellus quam,", "viverra eget, mollis vitae, bibedum sit amet, eim. Pelletesque frigilla", "tortor ac orci. Phasellus commodo porttitor elit. Maeceas ate orci,", "vehicula ticidut, lobortis eu, vehicula id, lorem. Quisque sapie ura,", "iaculis laoreet, digissim ac, adipiscig vitae, elit. ulla fermetum, leo", "ec posuere tempor, isi diam cursus arcu, at egestas ibh", "maga i odio. Mauris o diam sed dolor ultricies egestas.", "Aliquam erat volutpat. Quisque rhocus. ulla vitae arcu o pede", "scelerisque luctus. Pelletesque pretium massa. Fusce i leo eget eros", "fermetum ticidut. ulla velit risus, malesuada sed, auctor faucibus, porta", "sed, lacus. Aeea at eque.Doec o maga. Suspedisse cosequat orci", "sit amet velit. Ut est. Iteger sollicitudi, libero vitae gravida", "imperdiet, sem lorem tristique odio, sed pulviar tortor arcu vel", "mi. Aliquam erat volutpat. Vivamus tellus. Cras semper. Cras dictum", "dictum eros. Praeset et ulla i ulla ultricies auctor. Aeea", "tortor odio, ticidut sit amet, vestibulum id, covallis vel, pede.", "Vivamus volutpat elit i orci. Praeset arcu justo, adipiscig ac,", "commodo quis, scelerisque ac, libero. I odio ate, rutrum eu,", "aliquam vitae, ullamcorper et, sapie. Ut augue purus, pelletesque ut,", "auctor sit amet, laoreet eget, lectus. Vestibulum ate ipsum primis", "i faucibus orci luctus et ultrices posuere cubilia Curae; I", "orare, dui ac cosequat posuere, justo odio fermetum sem, eget", "covallis lacus quam o dui. Etiam mattis lacus cosectetuer pede", "veeatis eleifed. Cras quis tortor.uc libero erat, ultricies eget, ticidut", "sed, placerat eu, sapie. Cras posuere, pede ec dictum egestas,", "tortor orci faucibus lorem, eget iterdum mauris velit dapibus velit.", "ulla digissim imperdiet sapie. Ut tempus tellus. Pelletesque adipiscig varius", "tortor. Doec ligula dolor, pulviar ut, rutrum ac, dictum eget,", "diam. Sed at justo. Etiam orare scelerisque erat. am arcu.", "Iteger i orci. Fusce cosectetuer, isi o iterdum bladit, velit", "turpis codimetum tellus, i ullamcorper turpis leo at tellus. Doec", "velit. Phasellus augue. Doec et dui quis tortor fermetum eleifed.", "ulla facilisi. am veeatis suscipit ate. Aeea volutpat. Pelletesque ultricies", "accumsa orci. Pelletesque tellus diam, frigilla eu, cursus at, porta", "eget, justo.am dui. Suspedisse poteti. Vestibulum porttitor, purus a ullamcorper", "placerat, justo libero digissim augue, quis pelletesque ura tortor a", "orci. Duis eim. Aeea auctor, augue sed facilisis vulputate, ipsum", "lacus vestibulum metus, eu egestas felis diam a mauris. ulla", "imperdiet elit vel lectus. Ut ac ibh vel pede gravida", "hedrerit. Sed pelletesque, odio et eleifed cosequat, ulla ligula pretium", "ura, vel ultricies eros orci ut pede. Doec cosequat orare", "maga. Pelletesque ulla eim, bladit eget, sollicitudi ticidut, posuere vel,", "dolor. Phasellus facilisis arcu ut isi. Vivamus varius. Curabitur hedrerit,", "ligula sit amet molestie facilisis, ligula libero ultricies ulla, at", "bibedum libero dolor ticidut ibh. Doec pede tellus, pharetra pelletesque,", "euismod eget, placerat ut, dolor.Aeea mauris. Pelletesque sed ligula. Quisque", "faucibus tristique eque. Maeceas tempus auctor uc. Etiam et justo.", "Praeset ultrices odio id arcu aliquam pretium. Sed pulviar purus", "eu lorem. Suspedisse poteti. Aeea lacus. Vestibulum sit amet isi"];
/trunk/api/js/dojo1.0/dojox/string/tests/BuilderPerf.html
New file
0,0 → 1,403
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Builder Perf Tests</title>
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
<script type="text/javascript" src="../Builder.js"></script>
<script type="text/javascript" src="lipsum.js"></script>
<script type="text/javascript">
 
dojo.addOnLoad(function(){
dojo.byId("run").disabled="";
dojo.connect(dojo.byId("run"),
"onclick",
function(evt) {
setTimeout(function() {
var words = parseInt(dojo.byId("numWords").value) || 10;
var iters = parseInt(dojo.byId("numIters").value) || 1000;
var dict = eval(dojo.byId("dict").value);
buildAndRunSet(words, dict, iters);
}, 0);
});
});
function element(tag, textOrChildOrArray) {
var e = document.createElement(tag);
function append(n) {
if(dojo.isString(n)){
n = document.createTextNode(n);
}
e.appendChild(n);
}
if(dojo.isArray(textOrChildOrArray)) {
dojo.forEach(textOrChildOrArray, append);
}else{
append(textOrChildOrArray);
}
return e;
}
function log(t) {
dojo.byId("mess").innerHTML = t;
console.log(t);
}
function reportRun(results){
var runs = results.runs
var report = element("dl",
element("dt",
"Run with " + results.words + " words, " +
results.iterations + " iterations, for loop overhead of " +
results.overhead + ", average phrase of " +
results.wordSize + " characters"));
runs.sort(function(a,b) { return a.time - b.time; });
dojo.forEach(runs, function(r) {
report.appendChild(element("dd", r.time + " - " + r.name));
});
dojo.body().appendChild(report);
}
function runTest(test, iterations, expected) {
var i;
if(expected != test()) throw new Error("Test failed expecting " + expected + ", got " + test());
var start = new Date().getTime(), end;
for(i=0; i < iterations; i++){
test();
}
end = new Date().getTime();
return end-start;
}
function runSet(set, iterations){
function averagePhraseLen(words) {
var sizes = dojo.map(words, function(w) { return w.length; });
var total = 0;
dojo.forEach(sizes, function(s) { total += s; });
return total / sizes.length;
}
var tests = set.tests.concat(); //copy tests
var resultSet = {};
resultSet.words = set.words.length;
resultSet.overhead = runTest(set.overhead, iterations);
resultSet.iterations = iterations;
resultSet.wordSize = averagePhraseLen(set.words);
var runs = [];
function _run() {
var t = tests.pop();
try {
log("Running " + t.name);
if(t) runs.push({ name: t.name, time: runTest(t.test, iterations, set.expected)});
} catch(e) {
console.error("Error running " + t.name);
console.error(e);
}
if(tests.length > 0) {
setTimeout(_run, 0);
}
else {
log("Done!");
resultSet.runs = runs;
reportRun(resultSet);
dojo.publish("perf/run/done");
}
}
setTimeout(_run, 25);
}
function buildTestSet(numWords, dict) {
var words = [], i, dl = dict.length;
for(i = numWords; i > 0; i-=dl) {
if(i >= dl) { words = words.concat(dict); }
else { words = words.concat(dict.slice(-i)); }
}
if(words.length != numWords) throw new Error("wrong number of words, got " + words.length + ", expected " + numWords);
var expected = words.join("");
var _builder = new dojox.string.Builder();
return {
tests: [
{
name: "concatFor",
test: function() {
var s = "";
for(var i = 0; i < words.length; i++) {
s = s.concat(words[i]);
}
return s;
}
},
/*
{
name: "concatForAlias",
test: function() {
var s = "", w = words, l = w.length;
for(var i = 0; i < l; i++) {
s = s.concat(w[i]);
}
return s;
}
},
{
name: "concatForEach",
test: function() {
var s = "";
dojo.forEach(words, function(w) {
s = s.concat(w);
});
return s;
}
},
*/
{
name: "concatOnce",
test: function() {
var s = "";
s = String.prototype.concat.apply(s, words);
return s;
}
},
{
name: "builderFor",
test: function() {
var b = new dojox.string.Builder();
for(var i = 0; i < words.length; i++) {
b.append(words[i]);
}
return b.toString();
}
},
/*
{
name: "builderForEach",
test: function() {
var b = new dojox.string.Builder();
dojo.forEach(words, function(w) {
b.append(w);
});
return b.toString();
}
},
*/
{
name: "builderReusedFor",
test: function() {
_builder.clear();
for(var i = 0; i < words.length; i++) {
_builder.append(words[i]);
}
return _builder.toString();
}
},
{
name: "builderOnce",
test: function() {
var b = new dojox.string.Builder();
b.appendArray(words);
return b.toString();
}
},
{
name: "builderReusedOnce",
test: function() {
_builder.clear();
_builder.appendArray(words);
return _builder.toString();
}
},
{
name: "plusFor",
test: function() {
var s = "";
for(var i = 0; i < words.length; i++) {
s += words[i];
}
return s;
}
},
/*
{
name: "plusForAlias",
test: function() {
var s = "", w = words, l = w.length;
for(var i = 0; i < l; i++) {
s += w[i];
}
return s;
}
},
{
name: "plusForEach",
test: function() {
var s = "";
dojo.forEach(words, function(w) { s += w; });
return s;
}
},*/
{
name: "joinOnce",
test: function() {
return words.join("");
}
},
{
name: "joinFor",
test: function() {
var a = [];
for(var i = 0; i < words.length; i++) {
a.push(words[i]);
}
return a.join("");
}
}/*,
{
name: "joinForAlias",
test: function() {
var a = [], w = words, l = w.length;
for(var i = 0; i <l; i++) {
a.push(w[i]);
}
return a.join("");
}
},
{
name: "joinForEach",
test: function() {
var a = [];
dojo.forEach(words, function(w) { a.push(w); });
return a.join("");
}
}
*/
],
words: words,
expected: expected,
overhead: function() {
var w = words;
var l = w.length;
for(var i=0; i < l; i++) {
ident(w[i]);
}
}
};
}
function buildAndRunSet(words, dict, times) {
runSet(buildTestSet(words, dict), times);
}
function runSuite() {
var suite = [
{
words: 2,
times: 10000
},
{
words: 4,
times: 10000
},
{
words: 8,
times: 10000
},
{
words: 16,
times: 10000
},
{
words: 32,
times: 10000
},
{
words: 64,
times: 10000
},
{
words: 128,
times: 1000
},
{
words: 256,
times: 1000
},
{
words: 512,
times: 1000
},
{
words: 1024,
times: 1000
},
{
words: 2048,
times: 1000
},
{
words: 4096,
times: 100
},
{
words: 8192,
times: 100
}
];
var totalSuite = dojo.map(suite, function(s) { var n = {}; dojo.mixin(n,s); n.dict = lipsum; return n; });
totalSuite = totalSuite.concat(dojo.map(suite, function(s) { var n = {}; dojo.mixin(n,s); n.dict = lipsumLong; return n; }));
console.log(totalSuite);
var handle = dojo.subscribe("perf/run/done", _run);
dojo.subscribe("perf/run/done", function(){ console.log("perf run done"); });
function _run() {
var t = totalSuite.shift();
if(t) buildAndRunSet(t.words, t.dict, t.times);
if(totalSuite.length == 0) dojo.unsubscribe(handle);
}
_run();
}
function ident(i) { return i; }
</script>
<style type="text/css">
html {
font-family: Lucida Grande, Tahoma;
}
div { margin-bottom: 1em; }
#results {
border: 1px solid #999;
border-collapse: collapse;
}
#results caption {
font-size: medium;
font-weight: bold;
}
#results td, #results th {
text-align: right;
width: 10em;
font-size: small;
white-space: nowrap;
}
#wordsCol { background: yellow; }
td.max { color: red; font-weight: bold; }
td.min { color: green; font-weight: bold; }
</style>
</head>
<body>
<table>
<tr><td><label for="numWords">Words</label></td><td><input type="text" id="numWords" value="100"/></td></tr>
<tr><td><label for="numIters">Iterations</label></td><td><input type="text" id="numIters" value="1000"/></td></tr>
<tr><td><label for="dict">Dictionary</label></td><td><input type="text" id="dict" value="lipsum"></td></tr>
<tr><td></td><td><button id="run" disabled>Run Tests!</button></td></tr>
</table>
<div id="mess"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/string/tests/notes.txt
New file
0,0 → 1,153
notes:
reference:
Run with 100 words, 1000 iterations and overhead of 2
62 - concatOnce
73 - joinExisting
241 - plusForAlias
261 - plusFor
360 - concatFor
391 - joinForAlias
398 - concatForAlias
408 - joinFor
636 - plusForEach
763 - concatForEach
851 - joinForEach
4188 - builderReusedFor
4319 - builderFor
5155 - builderForEach
switch to for loop in append and ditch arraylike for array(r9607)
Run with 100 words, 1000 iterations and overhead of 3
62 - concatOnce
72 - joinExisting
235 - concatForAlias
242 - plusForAlias
263 - plusFor
361 - concatFor
394 - joinForAlias
414 - joinFor
635 - plusForEach
757 - concatForEach
855 - joinForEach
2005 - builderReusedFor
2073 - builderFor
2830 - builderForEach
inline append for array, remove string check
Run with 100 words, 1000 iterations and overhead of 4
55 - concatOnce
75 - joinExisting
243 - plusForAlias
263 - plusFor
363 - concatFor
382 - concatForAlias
398 - joinForAlias
410 - joinFor
629 - plusForEach
754 - concatForEach
857 - joinForEach
1854 - builderReusedFor
1922 - builderFor
2714 - builderForEach
add string check back in using typeof
Run with 100 words, 1000 iterations and overhead of 3
63 - concatOnce
72 - joinExisting
242 - plusForAlias
262 - plusFor
363 - concatFor
381 - concatForAlias
394 - joinForAlias
410 - joinFor
633 - plusForEach
773 - concatForEach
862 - joinForEach
1870 - builderReusedFor
1937 - builderFor
2702 - builderForEach
first cut less complex isArray
Run with 100 words, 1000 iterations and overhead of 3
63 - concatOnce
73 - joinExisting
184 - plusFor
251 - plusForAlias
282 - concatFor
381 - concatForAlias
395 - joinForAlias
412 - joinFor
629 - plusForEach
770 - concatForEach
851 - joinForEach
2027 - builderReusedFor
2129 - builderFor
2898 - builderForEach
switch to typeof for array, put string check back in using typeof (r9610)
Run with 100 words, 1000 iterations and overhead of 2
63 - concatOnce
77 - joinExisting
251 - plusForAlias
272 - plusFor
282 - concatFor
364 - concatForAlias
404 - joinForAlias
415 - joinFor
630 - plusForEach
766 - concatForEach
850 - joinForEach
1274 - builderReusedFor
1510 - builderFor
2108 - builderForEach
 
remove arguments-style array support. only support an explicit array.
Run with 100 words, 1000 iterations and overhead of 2
63 - concatOnce
75 - joinExisting
186 - plusFor
207 - builderReusedOnce
255 - plusForAlias
283 - concatFor
306 - builderOnce
367 - concatForAlias
408 - joinForAlias
419 - joinFor
639 - plusForEach
767 - concatForEach
817 - builderReusedFor
865 - joinForEach
975 - builderFor
1562 - builderForEach
just running for tests
Run with 100 words, 1000 iterations and overhead of 3
63 - concatOnce
203 - plusFor
204 - builderReusedOnce
303 - builderOnce
330 - joinFor
385 - concatFor
748 - builderFor
748 - builderReusedFor
remove array support in append
Run with 1000 words, 1000 iterations and overhead of 2
382 - concatOnce
1951 - plusFor
2779 - builderFor
2883 - builderReusedFor
3038 - concatFor
3549 - joinFor
 
add in appendArray support to match once, use += for append
Run with 1000 words, 1000 iterations and overhead of 3
379 - concatOnce
381 - builderReusedOnce
393 - builderOnce
2022 - plusFor
2862 - builderFor
2973 - builderReusedFor
3128 - concatFor
3548 - joinFor
/trunk/api/js/dojo1.0/dojox/string/tests/peller.html
New file
0,0 → 1,78
<html>
<head>
<title>peller's test</title>
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
<script type="text/javascript">
var lq = [];
function log(s) {
lq.push(s);
//console.log(s);
}
function dumpLog() {
dojo.forEach(lq, function(l) { console.log(l); });
lq = [];
}
dojo.addOnLoad(function() {
forLoop();
forEachLoop();
forAgain();
forEachAgain();
dumpLog();
});
function forLoop() {
var x=0;
var a = g_a;
var start=new Date();
for(var i=0;i<100000;i++){x=x+a[i];};
log("for loop elapsed:"+(new Date()-start)+" value="+x);
}
function forEachLoop() {
var x=0;
var a = g_a;
var start=new Date();
dojo.forEach(a, function(v,i){x=x+a[i];});
log("dojo.forEach elapsed:"+(new Date()-start)+" value="+x);
}
function forAgain(){
log("for results:");
var start=new Date();
var x=0;
for(var i=0;i<100000;i++){x=x+g_a[i];}
log("elapsed:"+(new Date()-start)+" value="+x);
}
function forEachAgain(){
log("forEach results:");
var a = g_a;
var x=0;
var start=new Date();
a.forEach(function(v,i){x=x+a[i];});
log("elapsed:"+(new Date()-start)+" value="+x);
}
var g_a = new Array(100000);
for(var i=0; i<100000;i++){g_a[i]=i;}
var start, x, i;
log("inline for results:");
start=new Date();
x=0;
for(i=0;i<100000;i++){x=x+g_a[i];}
log("elapsed:"+(new Date()-start)+" value="+x);
 
log("inline forEach results:");
start=new Date();
x=0;
g_a.forEach(function(v,i){x=x+g_a[i];});
log("elapsed:"+(new Date()-start)+" value="+x);
dumpLog();
</script>
</head>
<body>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/string/tests/PerfFun.html
New file
0,0 → 1,260
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Perf Tests</title>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true"></script>
<script type="text/javascript" src="lipsum.js"></script>
<script type="text/javascript">
dojo.addOnLoad(function(){
dojo.byId("run").disabled="";
dojo.connect(dojo.byId("run"),
"onclick",
function(evt) {
setTimeout(function() {
var words = parseInt(dojo.byId("numWords").value) || 10;
var iters = parseInt(dojo.byId("numIters").value) || 1000;
buildAndRunSet(words, iters);
}, 0);
});
});
function element(tag, textOrChild) {
var e = document.createElement(tag);
if(dojo.isArray(textOrChild)) dojo.forEach(textOrChild, function(c) { e.appendChild(c); });
if(dojo.isString(textOrChild)) e.appendChild(document.createTextNode(textOrChild));
else e.appendChild(textOrChild);
return e;
}
function log(t) {
dojo.byId("mess").innerHTML = t;
}
function reportRun(results){
var runs = results.runs
var report = element("dl",
element("dt",
"Run with " + results.words + " words, " +
results.iterations + " iterations and overhead of " +
results.overhead));
runs.sort(function(a,b) { return a.time - b.time; });
dojo.forEach(runs, function(r) {
report.appendChild(element("dd", r.time + " - " + r.name));
});
dojo.body().appendChild(report);
}
function runTest(test, iterations, expected) {
var i;
if(expected != test()) throw new Error("Test failed expecting " + expected + ", got " + test());
var start = new Date().getTime(), end;
for(i=0; i < iterations; i++){
test();
}
end = new Date().getTime();
return end-start;
}
function runSet(set, iterations){
var tests = set.tests.concat(); //copy tests
var resultSet = {};
resultSet.words = set.words.length;
resultSet.overhead = runTest(function(){}, iterations);
resultSet.iterations = iterations;
var runs = [];
function _run() {
var t = tests.pop();
try {
log("Running " + t.name);
if(t) runs.push({ name: t.name, time: runTest(t.test, iterations, set.expected)});
} catch(e) {
console.error("Error running " + t.name);
console.error(e);
}
if(tests.length > 0) {
setTimeout(_run, 0);
}
else {
log("Done!");
resultSet.runs = runs;
reportRun(resultSet);
}
}
setTimeout(_run, 0);
}
function buildTestSet(numWords) {
var words = [], i, wordsInLipsum = lipsum.length;
for(i = numWords; i > 0; i-=wordsInLipsum) {
if(i >= wordsInLipsum) { words = words.concat(lipsum); }
else { words = words.concat(lipsum.slice(-i)); }
}
if(words.length != numWords) throw new Error("wrong number of words, got " + words.length + ", expected " + numWords);
var expected = words.join("");
//console.log(words);
return {
tests: [
{
name: "dojoForEach",
test: function() {
var s = "";
dojo.forEach(words, function(w) { s+=w; });
return s;
}
},
{
name: "nativeForEach",
test: function() {
var s = "";
words.forEach(function(w) { s += w; });
return s;
}
},
{
name: "forLoop",
test: function() {
var s="",w=words; l=w.length;
for(var i = 0; i < l; i++) {
s += w[i];
}
return s;
}
},
{
name: "forLoopCallingInlineFunction",
test: function() {
var s="",w=words; l=w.length;
function fn(w) { s += w; };
for(var i = 0; i < l; i++) {
fn(w[i]);
}
return s;
}
},
{
name: "forLoopCallingExternalFunction",
test: function() {
g_s="",w=words; l=w.length;
for(var i = 0; i < l; i++) {
externalAppend(w[i]);
}
return g_s;
}
},
{
name: "forLoopWithInCheck",
test: function() {
var s="",w=words; l=w.length;
for(var i = 0; i < l; i++) {
if(i in w) s += w[i];
}
return s;
}
},
{
name: "emptyFor",
test: function() {
var w = words; l = w.length;
for(var i = 0; i < l; i++) empty(w[i]);
return expected;
}
},
{
name: "emptyForEach",
test: function() {
dojo.forEach(words, empty);
return expected;
}
} ,
{
name: "identFor",
test: function() {
var w = words; l = w.length;
for(var i = 0; i < l; i++) ident(w[i]);
return expected;
}
},
{
name: "identForEach",
test: function() {
dojo.forEach(words, ident);
return expected;
}
},
{
name: "addUsingFor",
test: function() {
var x=0;
for(var i=0;i<1000;i++){x=x+a[i];}
return expected; // fake
}
},
{
name: "addUsingForEach",
test: function() {
var x=0;
dojo.forEach(a, function(v,i){x=x+a[i];});
return expected; // fake
}
}
],
words: words,
expected: expected
};
}
function buildAndRunSet(words, times) {
runSet(buildTestSet(words), times);
}
function ident(w) { return w; }
function empty() { }
var g_s = "";
function externalAppend(w){ g_s += w; }
var a = new Array(1000);
for(var i=0; i<1000;i++){a[i]=i;}
</script>
<style type="text/css">
html {
font-family: Lucida Grande, Tahoma;
}
div { margin-bottom: 1em; }
#results {
border: 1px solid #999;
border-collapse: collapse;
}
#results caption {
font-size: medium;
font-weight: bold;
}
#results td, #results th {
text-align: right;
width: 10em;
font-size: small;
white-space: nowrap;
}
#wordsCol { background: yellow; }
td.max { color: red; font-weight: bold; }
td.min { color: green; font-weight: bold; }
</style>
</head>
<body>
<table>
<tr><td><label for="numWords">Words</label></td><td><input type="text" id="numWords" value="100"/></td></tr>
<tr><td><label for="numIters">Iterations</label></td><td><input type="text" id="numIters" value="1000"/></td></tr>
<tr><td></td><td><button id="run" disabled>Run Tests!</button></td></tr>
</table>
<div id="mess"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/string/tests/runTests.html
New file
0,0 → 1,9
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dojox Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.string.tests.string"></HEAD>
<BODY>
Redirecting to D.O.H runner.
</BODY>
</HTML>
/trunk/api/js/dojo1.0/dojox/string/tests/sprintf.js
New file
0,0 → 1,277
if(!dojo._hasResource["dojox.string.tests.sprintf"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.string.tests.sprintf"] = true;
dojo.provide("dojox.string.tests.sprintf");
 
dojo.require("dojox.string.sprintf");
dojo.require("dojo.string");
 
 
// Mapping using the %(var) format
 
// Flags:
// (space): Preceeds a positive number with a blank space
// +: Preceeds a positive number with a + sign
// 0: Pads numbers using zeroes
// -: Left justify a number (they're right justified by default)
// #: Alternate view for the specifier
 
tests.register("dojox.string.tests.sprintf", [
{
name: "Flag: (space)",
runTest: function(t){
var sprintf = dojox.string.sprintf;
 
t.is(" 42", sprintf("% d", 42));
t.is("-42", sprintf("% d", -42));
t.is(" 42", sprintf("% 5d", 42));
t.is(" -42", sprintf("% 5d", -42));
t.is(" 42", sprintf("% 15d", 42));
t.is(" -42", sprintf("% 15d", -42));
}
},
{
name: "Flag: +",
runTest: function(t){
var sprintf = dojox.string.sprintf;
 
t.is("+42", sprintf("%+d", 42));
t.is("-42", sprintf("%+d", -42));
t.is(" +42", sprintf("%+5d", 42));
t.is(" -42", sprintf("%+5d", -42));
t.is(" +42", sprintf("%+15d", 42));
t.is(" -42", sprintf("%+15d", -42));
}
},
{
name: "Flag: 0",
runTest: function(t){
var sprintf = dojox.string.sprintf;
 
t.is("42", sprintf("%0d", 42));
t.is("-42", sprintf("%0d", -42));
t.is("00042", sprintf("%05d", 42));
t.is("00-42", sprintf("%05d", -42));
t.is("000000000000042", sprintf("%015d", 42));
t.is("000000000000-42", sprintf("%015d", -42));
}
},
{
name: "Flag: -",
runTest: function(t){
var sprintf = dojox.string.sprintf;
 
t.is("42", sprintf("%-d", 42));
t.is("-42", sprintf("%-d", -42));
t.is("42 ", sprintf("%-5d", 42));
t.is("-42 ", sprintf("%-5d", -42));
t.is("42 ", sprintf("%-15d", 42));
t.is("-42 ", sprintf("%-15d", -42));
 
t.is("42", sprintf("%-0d", 42));
t.is("-42", sprintf("%-0d", -42));
t.is("42 ", sprintf("%-05d", 42));
t.is("-42 ", sprintf("%-05d", -42));
t.is("42 ", sprintf("%-015d", 42));
t.is("-42 ", sprintf("%-015d", -42));
 
t.is("42", sprintf("%0-d", 42));
t.is("-42", sprintf("%0-d", -42));
t.is("42 ", sprintf("%0-5d", 42));
t.is("-42 ", sprintf("%0-5d", -42));
t.is("42 ", sprintf("%0-15d", 42));
t.is("-42 ", sprintf("%0-15d", -42));
}
},
{
name: "Precision",
runTest: function(t){
var sprintf = dojox.string.sprintf;
 
t.is("42", sprintf("%d", 42.8952));
t.is("42", sprintf("%.2d", 42.8952)); // Note: the %d format is an int
t.is("42", sprintf("%.2i", 42.8952));
t.is("42.90", sprintf("%.2f", 42.8952));
t.is("42.90", sprintf("%.2F", 42.8952));
t.is("42.8952000000", sprintf("%.10f", 42.8952));
t.is("42.90", sprintf("%1.2f", 42.8952));
t.is(" 42.90", sprintf("%6.2f", 42.8952));
t.is("042.90", sprintf("%06.2f", 42.8952));
t.is("+42.90", sprintf("%+6.2f", 42.8952));
t.is("42.8952000000", sprintf("%5.10f", 42.8952));
}
},
{
name: "Bases",
runTest: function(t){
var sprintf = dojox.string.sprintf;
 
t.is("\x7f", sprintf("%c", 0x7f));
 
var error = false;
try {
sprintf("%c", -100);
}catch(e){
t.is("invalid character code passed to %c in sprintf", e.message);
error = true;
}
t.t(error);
 
error = false;
try {
sprintf("%c", 0x200000);
}catch(e){
t.is("invalid character code passed to %c in sprintf", e.message);
error = true;
}
t.t(error);
}
},
{
name: "Mapping",
runTest: function(t){
var sprintf = dojox.string.sprintf;
 
// %1$s format
t.is("%1$", sprintf("%1$"));
t.is("%0$s", sprintf("%0$s"));
t.is("Hot Pocket", sprintf("%1$s %2$s", "Hot", "Pocket"));
t.is("12.0 Hot Pockets", sprintf("%1$.1f %2$s %3$ss", 12, "Hot", "Pocket"));
t.is(" 42", sprintf("%1$*.f", "42", 3));
 
error = false;
try {
sprintf("%2$*s", "Hot Pocket");
}catch(e){
t.is("got 1 printf arguments, insufficient for '%2$*s'", e.message);
error = true;
}
t.t(error);
 
// %(map)s format
t.is("%(foo", sprintf("%(foo", {}));
t.is("Hot Pocket", sprintf("%(temperature)s %(crevace)s", {
temperature: "Hot",
crevace: "Pocket"
}));
t.is("12.0 Hot Pockets", sprintf("%(quantity).1f %(temperature)s %(crevace)ss", {
quantity: 12,
temperature: "Hot",
crevace: "Pocket"
}));
 
var error = false;
try {
sprintf("%(foo)s", 42);
}catch(e){
t.is("format requires a mapping", e.message);
error = true;
}
t.t(error);
 
error = false;
try {
sprintf("%(foo)s %(bar)s", "foo", 42);
}catch(e){
t.is("format requires a mapping", e.message);
error = true;
}
t.t(error);
 
error = false;
try {
sprintf("%(foo)*s", {
foo: "Hot Pocket"
});
}catch(e){
t.is("* width not supported in mapped formats", e.message);
error = true;
}
t.t(error);
}
},
{
name: "Positionals",
runTest: function(t){
var sprintf = dojox.string.sprintf;
 
t.is(" foo", sprintf("%*s", "foo", 4));
t.is(" 3.14", sprintf("%*.*f", 3.14159265, 10, 2));
t.is("0000003.14", sprintf("%0*.*f", 3.14159265, 10, 2));
t.is("3.14 ", sprintf("%-*.*f", 3.14159265, 10, 2));
 
var error = false;
try {
sprintf("%*s", "foo", "bar");
}catch(e){
t.is("the argument for * width at position 2 is not a number in %*s", e.message);
error = true;
}
t.t(error);
 
error = false;
try {
sprintf("%10.*f", "foo", 42);
}catch(e){
t.is("format argument 'foo' not a float; parseFloat returned NaN", e.message);
error = true;
}
t.t(error);
}
},
{
name: "vs. Formatter",
runTest: function(t){
var sprintf = dojox.string.sprintf;
 
for(var i = 0; i < 1000; i++){
sprintf("%d %s Pockets", i, "Hot");
}
}
},
{
name: "Formatter",
runTest: function(t){
var Formatter = dojox.string.sprintf.Formatter;
 
var str = new Formatter("%d %s Pockets");
for(var i = 0; i < 1000; i++){
str.format(i, "Hot");
}
}
},
{
name: "Miscellaneous",
runTest: function(t) {
var sprintf = dojox.string.sprintf;
 
t.is("+hello+", sprintf("+%s+", "hello"));
t.is("+10+", sprintf("+%d+", 10));
t.is("a", sprintf("%c", "a"));
t.is('"', sprintf("%c", 34));
t.is('$', sprintf("%c", 36));
t.is("10", sprintf("%d", 10));
 
var error = false;
try {
sprintf("%s%s", 42);
}catch(e){
t.is("got 1 printf arguments, insufficient for '%s%s'", e.message);
error = true;
}
t.t(error);
 
error = false;
try {
sprintf("%c");
}catch(e){
t.is("got 0 printf arguments, insufficient for '%c'", e.message);
error = true;
}
t.t(error);
 
t.is("%10", sprintf("%10", 42));
}
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/string/tokenize.js
New file
0,0 → 1,35
if(!dojo._hasResource["dojox.string.tokenize"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.string.tokenize"] = true;
dojo.provide("dojox.string.tokenize");
 
dojox.string.tokenize = function(/*String*/ str, /*RegExp*/ re, /*Function?*/ parseDelim, /*Object?*/ instance){
// summary:
// Split a string by a regular expression with the ability to capture the delimeters
// parseDelim:
// Each group (excluding the 0 group) is passed as a parameter. If the function returns
// a value, it's added to the list of tokens.
// instance:
// Used as the "this" instance when calling parseDelim
var tokens = [];
var match, content, lastIndex = 0;
while(match = re.exec(str)){
content = str.substring(lastIndex, re.lastIndex - match[0].length);
if(content.length){
tokens.push(content);
}
if(parseDelim){
var parsed = parseDelim.apply(instance, match.slice(1));
if(typeof parsed != "undefined"){
tokens.push(parsed);
}
}
lastIndex = re.lastIndex;
}
content = str.substr(lastIndex);
if(content.length){
tokens.push(content);
}
return tokens;
}
 
}
/trunk/api/js/dojo1.0/dojox/io/README
New file
0,0 → 1,45
-------------------------------------------------------------------------------
DojoX IO
-------------------------------------------------------------------------------
Version 0.3.1
Release date: 09/06/2007
-------------------------------------------------------------------------------
Project state:
experimental
-------------------------------------------------------------------------------
Credits
Bryan Forbes (bryan@reigndropsfall.net)
-------------------------------------------------------------------------------
Project description
 
-------------------------------------------------------------------------------
Dependencies:
 
DojoX IO depends on Dojo Core and DojoX UUID's generateRandomUuid function.
-------------------------------------------------------------------------------
Documentation
 
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/uuid.js
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/uuid/*
 
Install into the following directory structure:
/dojox/uuid/
 
AND
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/io/*
 
Install into the following directory structure:
/dojox/io/
 
...both of which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
Additional Notes
 
The information contained in this README does not pertain to DojoX XHR IFrame Proxy.
For that information see proxy/README.
/trunk/api/js/dojo1.0/dojox/io/xhrMultiPart.js
New file
0,0 → 1,81
if(!dojo._hasResource["dojox.io.xhrMultiPart"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.io.xhrMultiPart"] = true;
dojo.provide("dojox.io.xhrMultiPart");
 
dojo.require("dojo._base.xhr");
dojo.require("dojox.uuid.generateRandomUuid");
 
(function(){
function _createPart(args, boundary){
if(!args["name"] && !args["content"]){
throw new Error("Each part of a multi-part request requires 'name' and 'content'.");
}
 
var tmp = [];
tmp.push("--" + boundary,
"Content-Disposition: form-data; name=\"" + args.name + "\"" +
(args["filename"] ? "; filename=\"" + args.filename + "\"" : ""));
 
if(args["contentType"]){
var ct = "Content-Type: " + args.contentType;
if(args["charset"]){
ct += "; Charset=" + args.charset;
}
tmp.push(ct);
}
 
if(args["contentTransferEncoding"]){
tmp.push("Content-Transfer-Encoding: " + args.contentTransferEncoding);
}
 
tmp.push("", args.content);
 
return tmp;
}
 
function _needIframe(node){
return (!!(dojo.query("input[type=file]", node).length));
}
 
function _partsFromNode(node, boundary){
// TODO: write this function!
var tmp = [];
return tmp;
}
 
dojox.io.xhrMultiPart = function(args){
if(!args["file"] && !args["formNode"]){
throw new Error("file or formNode must be provided to dojox.io.xhrMultiPart's arguments");
}
 
// unique guid as a boundary value for multipart posts
var boundary = dojox.uuid.generateRandomUuid();
 
var tmp = [];
var out = "";
 
if(args["file"]){
var d = (dojo.isArray(args.file) ? args.file : [args.file]);
 
for(var i=0; i < d.length; i++){
tmp = tmp.concat(_createPart(d[i], boundary));
}
}
 
if(args["formNode"]){
tmp = tmp.concat(_partsFromNode(args["formNode"], boundary));
}
 
if(tmp.length){
tmp.push("--"+boundary+"--", "");
out = tmp.join("\r\n");
}
 
return dojo.rawXhrPost(dojo.mixin(args, {
contentType: "multipart/form-data; boundary=" + boundary,
postData: out
}));
}
})();
 
}
/trunk/api/js/dojo1.0/dojox/io/proxy/xip_server.html
New file
0,0 → 1,386
<!--
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
Pieces taken from Dojo source to make this file stand-alone
-->
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<script type="text/javascript" src="isAllowed.js"></script>
<!--
BY DEFAULT THIS FILE DOES NOT WORK SO THAT YOU DON'T ACCIDENTALLY EXPOSE
ALL OF YOUR XHR-ENABLED SERVICES ON YOUR SITE.
In order for this file to work, you need to uncomment the start and end script tags,
and you should define a function with the following signature:
function isAllowedRequest(request){
return false;
}
Return true out of the function if you want to allow the cross-domain request.
DON'T DEFINE THIS FUNCTION IN THIS FILE! Define it in a separate file called isAllowed.js
and include it in this page with a script tag that has a src attribute pointing to the file.
See the very first script tag in this file for an example. You do not have to place the
script file in the same directory as this file, just update the path above if you move it
somewhere else.
Customize the isAllowedRequest function to restrict what types of requests are allowed
for this server. The request object has the following properties:
- requestHeaders: an object with the request headers that are to be added to
the XHR request.
- method: the HTTP method (GET, POST, etc...)
- uri: The URI for the request.
- data: The URL-encoded data for the request. For a GET request, this would
be the querystring parameters. For a POST request, it wll be the
body data.
See xip_client.html for more info on the xip fragment identifier protocol.
-->
<!-- Security protection: uncomment the script tag to enable. -->
<!-- script type="text/javascript" -->
// <!--
//Core XHR handling taken from Dojo IO code.
dojo = {};
dojo.hostenv = {};
// These are in order of decreasing likelihood; this will change in time.
dojo.hostenv._XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
dojo.hostenv.getXmlhttpObject = function(){
var http = null;
var last_e = null;
try{ http = new XMLHttpRequest(); }catch(e){}
if(!http){
for(var i=0; i<3; ++i){
var progid = dojo.hostenv._XMLHTTP_PROGIDS[i];
try{
http = new ActiveXObject(progid);
}catch(e){
last_e = e;
}
if(http){
dojo.hostenv._XMLHTTP_PROGIDS = [progid]; // so faster next time
break;
}
}
/*if(http && !http.toString) {
http.toString = function() { "[object XMLHttpRequest]"; }
}*/
}
if(!http){
throw "xip_server.html: XMLHTTP not available: " + last_e;
}
return http;
}
 
dojo.setHeaders = function(http, headers){
if(headers) {
for(var header in headers) {
var headerValue = headers[header];
http.setRequestHeader(header, headerValue);
}
}
}
 
//MSIE has the lowest limit for URLs with fragment identifiers,
//at around 4K. Choosing a slightly smaller number for good measure.
xipUrlLimit = 4000;
xipIdCounter = 1;
 
function xipServerInit(){
xipStateId = "";
xipCurrentHash = "";
xipRequestMessage = "";
xipResponseParts = [];
xipPartIndex = 0;
}
 
function pollHash(){
//Can't use location.hash because at least Firefox does a decodeURIComponent on it.
var urlParts = window.location.href.split("#");
if(urlParts.length == 2){
var newHash = urlParts[1];
if(newHash != xipCurrentHash){
try{
messageReceived(newHash);
}catch(e){
//Make sure to not keep processing the error hash value.
xipCurrentHash = newHash;
throw e;
}
xipCurrentHash = newHash;
}
}
}
 
function messageReceived(encodedData){
var msg = unpackMessage(encodedData);
switch(msg.command){
case "ok":
sendResponsePart();
break;
case "start":
xipRequestMessage = "";
xipRequestMessage += msg.message;
setClientUrl("ok");
break;
case "part":
xipRequestMessage += msg.message;
setClientUrl("ok");
break;
case "end":
setClientUrl("ok");
xipRequestMessage += msg.message;
sendXhr();
break;
}
}
 
function sendResponse(encodedData){
//Break the message into parts, if necessary.
xipResponseParts = [];
var resData = encodedData;
var urlLength = xipClientUrl.length;
var partLength = xipUrlLimit - urlLength;
var resIndex = 0;
 
while((resData.length - resIndex) + urlLength > xipUrlLimit){
var part = resData.substring(resIndex, resIndex + partLength);
//Safari will do some extra hex escaping unless we keep the original hex
//escaping complete.
var percentIndex = part.lastIndexOf("%");
if(percentIndex == part.length - 1 || percentIndex == part.length - 2){
part = part.substring(0, percentIndex);
}
xipResponseParts.push(part);
resIndex += part.length;
}
xipResponseParts.push(resData.substring(resIndex, resData.length));
xipPartIndex = 0;
sendResponsePart();
}
function sendResponsePart(){
if(xipPartIndex < xipResponseParts.length){
//Get the message part.
var partData = xipResponseParts[xipPartIndex];
//Get the command.
var cmd = "part";
if(xipPartIndex + 1 == xipResponseParts.length){
cmd = "end";
}else if (xipPartIndex == 0){
cmd = "start";
}
 
setClientUrl(cmd, partData);
xipPartIndex++;
}else{
xipServerInit();
}
}
 
function setClientUrl(cmd, message){
var clientUrl = makeClientUrl(cmd, message);
//Safari won't let us replace across domains.
if(navigator.userAgent.indexOf("Safari") == -1){
parent.location.replace(clientUrl);
}else{
parent.location = clientUrl;
}
}
 
function makeClientUrl(cmd, message){
var clientUrl = xipClientUrl + "#" + (xipIdCounter++) + ":" + cmd;
if(message){
clientUrl += ":" + message;
}
return clientUrl
}
 
function xhrDone(xhr){
/* Need to pull off and return the following data:
- responseHeaders
- status
- statusText
- responseText
*/
var response = {};
if(typeof(xhr.getAllResponseHeaders) != "undefined"){
var allHeaders = xhr.getAllResponseHeaders();
if(allHeaders){
response.responseHeaders = allHeaders;
}
}
if(xhr.status == 0 || xhr.status){
response.status = xhr.status;
}
if(xhr.statusText){
response.statusText = xhr.statusText;
}
if(xhr.responseText){
response.responseText = xhr.responseText;
}
//Build a string of the response object.
var result = "";
var isFirst = true;
for (var param in response){
if(isFirst){
isFirst = false;
}else{
result += "&";
}
result += param + "=" + encodeURIComponent(response[param]);
}
sendResponse(result);
}
 
function sendXhr(){
var request = {};
var nvPairs = xipRequestMessage.split("&");
var i = 0;
var nameValue = null;
for(i = 0; i < nvPairs.length; i++){
if(nvPairs[i]){
var nameValue = nvPairs[i].split("=");
request[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]);
}
}
 
//Split up the request headers, if any.
var headers = {};
if(request.requestHeaders){
nvPairs = request.requestHeaders.split("\r\n");
for(i = 0; i < nvPairs.length; i++){
if(nvPairs[i]){
nameValue = nvPairs[i].split(": ");
headers[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]);
}
}
 
request.requestHeaders = headers;
}
if(isAllowedRequest(request)){
//The request is allowed, so set up the XHR object.
var xhr = dojo.hostenv.getXmlhttpObject();
//Start timer to look for readyState.
var xhrIntervalId = setInterval(function(){
if(xhr.readyState == 4){
clearInterval(xhrIntervalId);
xhrDone(xhr);
}
}, 10);
 
//Actually start up the XHR request.
xhr.open(request.method, request.uri, true);
dojo.setHeaders(xhr, request.requestHeaders);
var content = "";
if(request.data){
content = request.data;
}
 
try{
xhr.send(content);
}catch(e){
if(typeof xhr.abort == "function"){
xhr.abort();
xhrDone({status: 404, statusText: "xip_server.html error: " + e});
}
}
}
}
 
function unpackMessage(encodedMessage){
var parts = encodedMessage.split(":");
var command = parts[1];
encodedMessage = parts[2] || "";
 
var config = null;
if(command == "init"){
var configParts = encodedMessage.split("&");
config = {};
for(var i = 0; i < configParts.length; i++){
var nameValue = configParts[i].split("=");
config[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]);
}
}
return {command: command, message: encodedMessage, config: config};
}
 
function onServerLoad(){
xipServerInit();
 
//Decode the init params
var config = unpackMessage(window.location.href.split("#")[1]).config;
 
xipStateId = config.id;
xipClientUrl = config.client;
//Make sure we don't have a javascript: url, just for good measure.
if(xipClientUrl.split(":")[0].match(/javascript/i)){
throw "Invalid client URL";
}
if(!xipStateId.match(/^XhrIframeProxy[0-9]+$/)){
throw "Invalid state ID";
}
 
xipUseFrameRecursion = config["fr"];
 
setInterval(pollHash, 10);
if(xipUseFrameRecursion == "true"){
var serverUrl = window.location.href.split("#")[0];
document.getElementById("iframeHolder").innerHTML = '<iframe name="'
+ xipStateId + '_clientEndPoint'
+ '" src="javascript:false">'
+ '</iframe>';
var iframeNode = document.getElementsByTagName("iframe")[0];
iframeNode.src = makeClientUrl("init", 'id=' + xipStateId + '&server='
+ encodeURIComponent(serverUrl) + '&fr=endpoint');
}else{
setClientUrl("loaded");
}
}
 
if(typeof(window.addEventListener) == "undefined"){
window.attachEvent("onload", onServerLoad);
}else{
window.addEventListener('load', onServerLoad, false);
}
// -->
<!-- </script> -->
</head>
<body>
<h4>The Dojo Toolkit -- xip_server.html</h4>
 
<p>This file is used for Dojo's XMLHttpRequest Iframe Proxy. This is the the file
that should go on the server that will actually be doing the XHR request.</p>
<div id="iframeHolder"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/io/proxy/xip.js
New file
0,0 → 1,236
if(!dojo._hasResource["dojox.io.proxy.xip"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.io.proxy.xip"] = true;
dojo.provide("dojox.io.proxy.xip");
 
dojo.require("dojo.io.iframe");
dojo.require("dojox.data.dom");
 
dojox.io.proxy.xip = {
//summary: Object that implements the iframe handling for XMLHttpRequest
//IFrame Proxying.
//description: Do not use this object directly. See the Dojo Book page
//on XMLHttpRequest IFrame Proxying:
//http://dojotoolkit.org/book/dojo-book-0-4/part-5-connecting-pieces/i-o/cross-domain-xmlhttprequest-using-iframe-proxy
//Usage of XHR IFrame Proxying does not work from local disk in Safari.
 
xipClientUrl: djConfig["xipClientUrl"] || dojo.moduleUrl("dojox.io.proxy", "xip_client.html"),
 
_state: {},
_stateIdCounter: 0,
 
needFrameRecursion: function(){
return (dojo.isIE >= 7);
},
 
send: function(facade){
var stateId = "XhrIframeProxy" + (this._stateIdCounter++);
facade._stateId = stateId;
 
 
var frameUrl = this.xipClientUrl + "#0:init:id=" + stateId + "&server="
+ encodeURIComponent(facade._ifpServerUrl) + "&fr=false";
if(this.needFrameRecursion()){
//IE7 hack. Need to load server URL, and have that load the xip_client.html.
//Also, this server URL needs to different from the one eventually loaded by xip_client.html
//Otherwise, IE7 will not load it. Funky.
var fullClientUrl = window.location.href.split("#")[0].split("?")[0];
if((this.xipClientUrl + "").charAt(0) == "/"){
var endIndex = fullClientUrl.indexOf("://");
endIndex = fullClientUrl.indexOf("/", endIndex + 3);
fullClientUrl = fullClientUrl.substring(0, endIndex);
}else{
fullClientUrl = fullClientUrl.substring(0, fullClientUrl.lastIndexOf("/") + 1);
}
fullClientUrl += this.xipClientUrl;
var serverUrl = facade._ifpServerUrl
+ (facade._ifpServerUrl.indexOf("?") == -1 ? "?" : "&") + "dojo.fr=1";
 
frameUrl = serverUrl + "#0:init:id=" + stateId + "&client="
+ encodeURIComponent(fullClientUrl) + "&fr=" + this.needFrameRecursion(); //fr is for Frame Recursion
}
 
this._state[stateId] = {
facade: facade,
stateId: stateId,
clientFrame: dojo.io.iframe.create(stateId, "", frameUrl)
};
return stateId;
},
receive: function(/*String*/stateId, /*String*/urlEncodedData){
/* urlEncodedData should have the following params:
- responseHeaders
- status
- statusText
- responseText
*/
//Decode response data.
var response = {};
var nvPairs = urlEncodedData.split("&");
for(var i = 0; i < nvPairs.length; i++){
if(nvPairs[i]){
var nameValue = nvPairs[i].split("=");
response[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]);
}
}
 
//Set data on facade object.
var state = this._state[stateId];
var facade = state.facade;
 
facade._setResponseHeaders(response.responseHeaders);
if(response.status == 0 || response.status){
facade.status = parseInt(response.status, 10);
}
if(response.statusText){
facade.statusText = response.statusText;
}
if(response.responseText){
facade.responseText = response.responseText;
//Fix responseXML.
var contentType = facade.getResponseHeader("Content-Type");
if(contentType && (contentType == "application/xml" || contentType == "text/xml")){
facade.responseXML = dojox.data.dom.createDocument(response.responseText, contentType);
}
}
facade.readyState = 4;
this.destroyState(stateId);
},
 
clientFrameLoaded: function(/*String*/stateId){
var state = this._state[stateId];
var facade = state.facade;
 
if(this.needFrameRecursion()){
var clientWindow = window.open("", state.stateId + "_clientEndPoint");
}else{
var clientWindow = state.clientFrame.contentWindow;
}
 
var reqHeaders = [];
for(var param in facade._requestHeaders){
reqHeaders.push(param + ": " + facade._requestHeaders[param]);
}
var requestData = {
uri: facade._uri
};
if(reqHeaders.length > 0){
requestData.requestHeaders = reqHeaders.join("\r\n");
}
if(facade._method){
requestData.method = facade._method;
}
if(facade._bodyData){
requestData.data = facade._bodyData;
}
 
clientWindow.send(dojo.objectToQuery(requestData));
},
destroyState: function(/*String*/stateId){
var state = this._state[stateId];
if(state){
delete this._state[stateId];
var parentNode = state.clientFrame.parentNode;
parentNode.removeChild(state.clientFrame);
state.clientFrame = null;
state = null;
}
},
 
createFacade: function(){
if(arguments && arguments[0] && arguments[0].iframeProxyUrl){
return new dojox.io.proxy.xip.XhrIframeFacade(arguments[0].iframeProxyUrl);
}else{
return dojox.io.proxy.xip._xhrObjOld.apply(dojo, arguments);
}
}
}
 
//Replace the normal XHR factory with the proxy one.
dojox.io.proxy.xip._xhrObjOld = dojo._xhrObj;
dojo._xhrObj = dojox.io.proxy.xip.createFacade;
 
/**
Using this a reference: http://www.w3.org/TR/XMLHttpRequest/
 
Does not implement the onreadystate callback since dojo.xhr* does
not use it.
*/
dojox.io.proxy.xip.XhrIframeFacade = function(ifpServerUrl){
//summary: XMLHttpRequest facade object used by dojox.io.proxy.xip.
//description: Do not use this object directly. See the Dojo Book page
//on XMLHttpRequest IFrame Proxying:
//http://dojotoolkit.org/book/dojo-book-0-4/part-5-connecting-pieces/i-o/cross-domain-xmlhttprequest-using-iframe-proxy
this._requestHeaders = {};
this._allResponseHeaders = null;
this._responseHeaders = {};
this._method = null;
this._uri = null;
this._bodyData = null;
this.responseText = null;
this.responseXML = null;
this.status = null;
this.statusText = null;
this.readyState = 0;
this._ifpServerUrl = ifpServerUrl;
this._stateId = null;
}
 
dojo.extend(dojox.io.proxy.xip.XhrIframeFacade, {
//The open method does not properly reset since Dojo does not reuse XHR objects.
open: function(/*String*/method, /*String*/uri){
this._method = method;
this._uri = uri;
 
this.readyState = 1;
},
setRequestHeader: function(/*String*/header, /*String*/value){
this._requestHeaders[header] = value;
},
send: function(/*String*/stringData){
this._bodyData = stringData;
this._stateId = dojox.io.proxy.xip.send(this);
this.readyState = 2;
},
abort: function(){
dojox.io.proxy.xip.destroyState(this._stateId);
},
getAllResponseHeaders: function(){
return this._allResponseHeaders; //String
},
getResponseHeader: function(/*String*/header){
return this._responseHeaders[header]; //String
},
_setResponseHeaders: function(/*String*/allHeaders){
if(allHeaders){
this._allResponseHeaders = allHeaders;
//Make sure ther are now CR characters in the headers.
allHeaders = allHeaders.replace(/\r/g, "");
var nvPairs = allHeaders.split("\n");
for(var i = 0; i < nvPairs.length; i++){
if(nvPairs[i]){
var nameValue = nvPairs[i].split(": ");
this._responseHeaders[nameValue[0]] = nameValue[1];
}
}
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/io/proxy/README
New file
0,0 → 1,82
-------------------------------------------------------------------------------
Project Name
-------------------------------------------------------------------------------
Version 0.5
Release date: MM/DD/YYYY (in progres, porting)
-------------------------------------------------------------------------------
Project state:
experimental
-------------------------------------------------------------------------------
Credits
James Burke (jburke@dojotoolkit.org)
-------------------------------------------------------------------------------
Project description
 
The XHR IFrame Proxy (xip) allows you to do cross-domain XMLHttpRequests (XHRs).
It works by using two iframes, one your domain (xip_client.html), one on the
other domain (xip_server.html). They use fragment IDs in the iframe URLs to pass
messages to each other. The xip.js file defines dojox.io.proxy.xip. This module
intercepts XHR calls made by the Dojo XHR methods (dojo.xhr* methods). The module
returns a facade object that acts like an XHR object. Once send is called on the
facade, the facade's data is serialized, given to xip_client.html. xip_client.html
then passes the serialized data to xip_server.html by changing xip_server.html's
URL fragment ID (the #xxxx part of an URL). xip_server.html deserializes the
message fragments, and does an XHR call, gets the response, and serializes the
data. The serialized data is then passed back to xip_client.html by changing
xip_client.html's fragment ID. Then the response is deserialized and used as
the response inside the facade XHR object that was created by dojox.io.proxy.xip.
-------------------------------------------------------------------------------
Dependencies:
 
xip.js: Dojo Core, dojox.data.dom
xip_client.html: none
xip_server.html: none (but see Additional Notes section)
-------------------------------------------------------------------------------
Documentation
 
There is some documentation that applies to the Dojo 0.4.x version of these files:
http://dojotoolkit.org/book/dojo-book-0-4/part-5-connecting-pieces/i-o/cross-domain-xmlhttprequest-using-iframe-proxy
 
The general theory still applies to this code, but the specifics are different
for the Dojo 0.9+ codebase. Doc updates hopefully after the basic code is ported.
 
The current implementation destroys the iframes used for a request after the request
completes. This seems to cause a memory leak, particularly in IE. So, it is not
suited for doing polling cross-domain requests.
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojox SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/io/proxy/xip.js
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/io/proxy/xip_client.html
 
Install into the following directory structure:
/dojox/io/proxy/
 
...which should be at the same level as your Dojo checkout.
 
Grab the following from the Dojox SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/io/proxy/xip_server.html
 
and install it on the domain that you want to allow receiving cross-domain
requests. Be sure to read the documentation, the Additional Notes below, and
the in-file comments.
-------------------------------------------------------------------------------
Additional Notes
 
xip_client.html and xip_server.html do not work right away. You need to uncomment
out the script tags in the files. Additionally, xip_server.html requires a JS file,
isAllowed.js, to be defined. See the notes in xip_server.html for more informaiton.
 
XDOMAIN BUILD INSTRUCTIONS:
The dojox.io.proxy module requires some setup to use with an xdomain build.
The xip_client.html file has to be served from the same domain as your web page.
It cannot be served from the domain that has the xdomain build. Download xip_client.html
and install it on your server. Then set djConfig.xipClientUrl to the local path
of xip_client.html (just use a path, not a whole URL, since it will be on the same
domain as the page). The path to the file should be the path relative to the web
page that is using dojox.io.proxy.
 
 
 
 
/trunk/api/js/dojo1.0/dojox/io/proxy/xip_client.html
New file
0,0 → 1,267
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<!-- Security protection: uncomment the start and end script tags to enable. -->
<!-- script type="text/javascript" -->
// <!--
/*
This file is really focused on just sending one message to the server, and
receiving one response. The code does not expect to be re-used for multiple messages.
This might be reworked later if performance indicates a need for it.
xip fragment identifier/hash values have the form:
#id:cmd:realEncodedMessage
 
id: some ID that should be unique among messages. No inherent meaning,
just something to make sure the hash value is unique so the message
receiver knows a new message is available.
cmd: command to the receiver. Valid values are:
- init: message used to init the frame. Sent as the first URL when loading
the page. Contains some config parameters.
- loaded: the remote frame is loaded. Only sent from server to client.
- ok: the message that this page sent was received OK. The next message may
now be sent.
- start: the start message of a block of messages (a complete message may
need to be segmented into many messages to get around the limitiations
of the size of an URL that a browser accepts.
- part: indicates this is a part of a message.
- end: the end message of a block of messages. The message can now be acted upon.
If the message is small enough that it doesn't need to be segmented, then
just one hash value message can be sent with "end" as the command.
To reassemble a segmented message, the realEncodedMessage parts just have to be concatenated
together.
*/
 
//MSIE has the lowest limit for URLs with fragment identifiers,
//at around 4K. Choosing a slightly smaller number for good measure.
xipUrlLimit = 4000;
xipIdCounter = 1;
 
function xipInit(){
xipStateId = "";
xipIsSending = false;
xipServerUrl = null;
xipStateId = null;
xipRequestData = null;
xipCurrentHash = "";
xipResponseMessage = "";
xipRequestParts = [];
xipPartIndex = 0;
xipServerWindow = null;
xipUseFrameRecursion = false;
}
xipInit();
function send(encodedData){
if(xipUseFrameRecursion == "true"){
var clientEndPoint = window.open(xipStateId + "_clientEndPoint");
clientEndPoint.send(encodedData);
}else{
if(!xipIsSending){
xipIsSending = true;
xipRequestData = encodedData || "";
 
//Get a handle to the server iframe.
xipServerWindow = frames[xipStateId + "_frame"];
if (!xipServerWindow){
xipServerWindow = document.getElementById(xipStateId + "_frame").contentWindow;
}
sendRequestStart();
}
}
}
 
//Modify the server URL if it is a local path and
//This is done for local/same domain testing.
function fixServerUrl(ifpServerUrl){
if(ifpServerUrl.indexOf("..") == 0){
var parts = ifpServerUrl.split("/");
ifpServerUrl = parts[parts.length - 1];
}
return ifpServerUrl;
}
function pollHash(){
//Can't use location.hash because at least Firefox does a decodeURIComponent on it.
var urlParts = window.location.href.split("#");
if(urlParts.length == 2){
var newHash = urlParts[1];
if(newHash != xipCurrentHash){
try{
messageReceived(newHash);
}catch(e){
//Make sure to not keep processing the error hash value.
xipCurrentHash = newHash;
throw e;
}
xipCurrentHash = newHash;
}
}
}
 
function messageReceived(encodedData){
var msg = unpackMessage(encodedData);
 
switch(msg.command){
case "loaded":
xipMasterFrame.dojox.io.proxy.xip.clientFrameLoaded(xipStateId);
break;
case "ok":
sendRequestPart();
break;
case "start":
xipResponseMessage = "";
xipResponseMessage += msg.message;
setServerUrl("ok");
break;
case "part":
xipResponseMessage += msg.message;
setServerUrl("ok");
break;
case "end":
setServerUrl("ok");
xipResponseMessage += msg.message;
xipMasterFrame.dojox.io.proxy.xip.receive(xipStateId, xipResponseMessage);
break;
}
}
function sendRequestStart(){
//Break the message into parts, if necessary.
xipRequestParts = [];
var reqData = xipRequestData;
var urlLength = xipServerUrl.length;
var partLength = xipUrlLimit - urlLength;
var reqIndex = 0;
 
while((reqData.length - reqIndex) + urlLength > xipUrlLimit){
var part = reqData.substring(reqIndex, reqIndex + partLength);
//Safari will do some extra hex escaping unless we keep the original hex
//escaping complete.
var percentIndex = part.lastIndexOf("%");
if(percentIndex == part.length - 1 || percentIndex == part.length - 2){
part = part.substring(0, percentIndex);
}
xipRequestParts.push(part);
reqIndex += part.length;
}
xipRequestParts.push(reqData.substring(reqIndex, reqData.length));
xipPartIndex = 0;
sendRequestPart();
}
function sendRequestPart(){
if(xipPartIndex < xipRequestParts.length){
//Get the message part.
var partData = xipRequestParts[xipPartIndex];
 
//Get the command.
var cmd = "part";
if(xipPartIndex + 1 == xipRequestParts.length){
cmd = "end";
}else if (xipPartIndex == 0){
cmd = "start";
}
setServerUrl(cmd, partData);
xipPartIndex++;
}
}
function setServerUrl(cmd, message){
var serverUrl = makeServerUrl(cmd, message);
 
//Safari won't let us replace across domains.
if(navigator.userAgent.indexOf("Safari") == -1){
xipServerWindow.location.replace(serverUrl);
}else{
xipServerWindow.location = serverUrl;
}
}
function makeServerUrl(cmd, message){
var serverUrl = xipServerUrl + "#" + (xipIdCounter++) + ":" + cmd;
if(message){
serverUrl += ":" + message;
}
return serverUrl;
}
 
function unpackMessage(encodedMessage){
var parts = encodedMessage.split(":");
var command = parts[1];
encodedMessage = parts[2] || "";
 
var config = null;
if(command == "init"){
var configParts = encodedMessage.split("&");
config = {};
for(var i = 0; i < configParts.length; i++){
var nameValue = configParts[i].split("=");
config[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]);
}
}
return {command: command, message: encodedMessage, config: config};
}
 
function onClientLoad(){
//Decode the init params
var config = unpackMessage(window.location.href.split("#")[1]).config;
 
xipStateId = config.id;
 
//Remove the query param for the IE7 recursive case.
xipServerUrl = fixServerUrl(config.server).replace(/(\?|\&)dojo\.fr\=1/, "");
//Make sure we don't have a javascript: url, just for good measure.
if(xipServerUrl.split(":")[0].match(/javascript/i)){
throw "Invalid server URL";
}
 
xipUseFrameRecursion = config["fr"];
if(xipUseFrameRecursion == "endpoint"){
xipMasterFrame = parent.parent;
}else{
xipMasterFrame = parent;
}
//Start counter to inspect hash value.
setInterval(pollHash, 10);
 
var clientUrl = window.location.href.split("#")[0];
var iframeNode = document.getElementsByTagName("iframe")[0];
iframeNode.id = xipStateId + "_frame";
iframeNode.src = makeServerUrl("init", 'id=' + xipStateId + '&client='
+ encodeURIComponent(clientUrl) + '&fr=' + xipUseFrameRecursion);
}
 
if(typeof(window.addEventListener) == "undefined"){
window.attachEvent("onload", onClientLoad);
}else{
window.addEventListener('load', onClientLoad, false);
}
// -->
<!-- </script> -->
</head>
<body>
<h4>The Dojo Toolkit -- xip_client.html</h4>
 
<p>This file is used for Dojo's XMLHttpRequest Iframe Proxy. This is the "client" file used
internally by dojox.io.proxy.xip.</p>
<iframe src="javascript:false"></iframe>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/io/proxy/tests/frag.xml
New file
0,0 → 1,4
<response>
<foo>This is the foo text node value</foo>
<bar>This is the bar text node value</bar>
</response>
/trunk/api/js/dojo1.0/dojox/io/proxy/tests/xip.html
New file
0,0 → 1,62
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>XHR IFrame Proxy Tests</title>
<style type="text/css">
@import "../../../../dojo/resources/dojo.css";
@import "../../../../dijit/themes/tundra/tundra.css";
@import "../../../../dijit/themes/dijit.css";
</style>
 
<script type="text/javascript" src="../../../../dojo/dojo.js"
djConfig="isDebug:true"></script>
<script type="text/javascript" src="../xip.js"></script>
<script type="text/javascript">
dojo.require("dojox.io.proxy.xip");
 
function testXmlGet(){
/*
//Normal xhrGet call.
dojo.xhrGet({
url: "frag.xml",
handleAs: "xml",
load: function(result, ioArgs){
var foo = result.getElementsByTagName("foo").item(0);
 
dojo.byId("xmlGetOut").innerHTML = "Success: First foobar value is: " + foo.firstChild.nodeValue;
}
});
*/
 
//xip xhrGet call.
dojo.xhrGet({
iframeProxyUrl: "../xip_server.html",
url: "tests/frag.xml",
handleAs: "xml",
load: function(result, ioArgs){
var foo = result.getElementsByTagName("foo").item(0);
 
dojo.byId("xmlGetOut").innerHTML = "Success: First foobar value is: " + foo.firstChild.nodeValue;
}
});
 
}
 
dojo.addOnLoad(function(){
 
});
</script>
</head>
<body class="tundra">
 
<h1>XHR IFrame Proxy Tests</h1>
<p>Run this test from a web server, not from local disk.</p>
 
<p>
<button onclick="testXmlGet()">Test XML GET</button>
</p>
<div id="xmlGetOut"></div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/flash.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.flash"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.flash"] = true;
dojo.provide("dojox.flash");
dojo.require("dojox.flash._common");
 
}
/trunk/api/js/dojo1.0/dojox/sql.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.sql"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.sql"] = true;
dojo.require("dojox._sql.common");
dojo.provide("dojox.sql");
 
}
/trunk/api/js/dojo1.0/dojox/_cometd/README
New file
0,0 → 1,29
-------------------------------------------------------------------------------
Cometd (client)
-------------------------------------------------------------------------------
Version 0.4
Release date: May 29, 2007
-------------------------------------------------------------------------------
Project state: beta
-------------------------------------------------------------------------------
Project authors
Alex Russell (alex@dojotoolkit.org)
Greg Wilkins
-------------------------------------------------------------------------------
Project description
 
Low-latency data transfer from servers to clients. dojox.cometd implements a
Bayeux protocol client for use with most Bayeux servers. See cometd.com for
details on Cometd or on the Bayeux protocol.
-------------------------------------------------------------------------------
Dependencies:
 
Needs a cooperating Bayeux server
-------------------------------------------------------------------------------
Documentation
 
See http://cometd.com
-------------------------------------------------------------------------------
Installation instructions
 
Use this library with (preferably through) an existing Cometd server.
/trunk/api/js/dojo1.0/dojox/_cometd/cometd.js
New file
0,0 → 1,684
if(!dojo._hasResource["dojox._cometd.cometd"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox._cometd.cometd"] = true;
dojo.provide("dojox._cometd.cometd");
dojo.require("dojo.AdapterRegistry");
dojo.require("dojo.io.script");
 
// FIXME: need to add local topic support to advise about:
// successful handshake
// network failure of channel
// graceful disconnect
 
/*
* this file defines Comet protocol client. Actual message transport is
* deferred to one of several connection type implementations. The default is a
* long-polling implementation. A single global object named "dojox.cometd" is
* used to mediate for these connection types in order to provide a stable
* interface.
*/
 
dojox.cometd = new function(){
/* cometd states:
* DISCONNECTED: _initialized==false && _connected==false
* CONNECTING: _initialized==true && _connected==false (handshake sent)
* CONNECTED: _initialized==true && _connected==true (first successful connect)
* DISCONNECTING: _initialized==false && _connected==true (disconnect sent)
*/
this._initialized = false;
this._connected = false;
this._polling = false;
 
this.connectionTypes = new dojo.AdapterRegistry(true);
 
this.version = "1.0";
this.minimumVersion = "0.9";
this.clientId = null;
this.messageId = 0;
this.batch=0;
 
this._isXD = false;
this.handshakeReturn = null;
this.currentTransport = null;
this.url = null;
this.lastMessage = null;
this.topics = {};
this._messageQ = [];
this.handleAs="json-comment-optional";
this.advice;
this.pendingSubscriptions = {}
this.pendingUnsubscriptions = {}
 
this._subscriptions = [];
 
this.tunnelInit = function(childLocation, childDomain){
// placeholder
}
 
this.tunnelCollapse = function(){
console.debug("tunnel collapsed!");
// placeholder
}
 
this.init = function(root, props, bargs){
// FIXME: if the root isn't from the same host, we should automatically
// try to select an XD-capable transport
props = props||{};
// go ask the short bus server what we can support
props.version = this.version;
props.minimumVersion = this.minimumVersion;
props.channel = "/meta/handshake";
props.id = ""+this.messageId++;
 
this.url = root||djConfig["cometdRoot"];
if(!this.url){
console.debug("no cometd root specified in djConfig and no root passed");
return;
}
 
// Are we x-domain? borrowed from dojo.uri.Uri in lieu of fixed host and port properties
var regexp = "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$";
var r = (""+window.location).match(new RegExp(regexp));
if(r[4]){
var tmp = r[4].split(":");
var thisHost = tmp[0];
var thisPort = tmp[1]||"80"; // FIXME: match 443
 
r = this.url.match(new RegExp(regexp));
if(r[4]){
tmp = r[4].split(":");
var urlHost = tmp[0];
var urlPort = tmp[1]||"80";
this._isXD = ((urlHost != thisHost)||(urlPort != thisPort));
}
}
 
if(!this._isXD){
if(props.ext){
if(props.ext["json-comment-filtered"]!==true && props.ext["json-comment-filtered"]!==false){
props.ext["json-comment-filtered"] = true;
}
}else{
props.ext = { "json-comment-filtered": true };
}
}
 
var bindArgs = {
url: this.url,
handleAs: this.handleAs,
content: { "message": dojo.toJson([props]) },
load: dojo.hitch(this, "finishInit"),
error: function(e){ console.debug("handshake error!:", e); }
};
 
if(bargs){
dojo.mixin(bindArgs, bargs);
}
this._props=props;
this._initialized=true;
this.batch=0;
this.startBatch();
// if xdomain, then we assume jsonp for handshake
if(this._isXD){
bindArgs.callbackParamName="jsonp";
return dojo.io.script.get(bindArgs);
}
return dojo.xhrPost(bindArgs);
}
 
this.finishInit = function(data){
data = data[0];
this.handshakeReturn = data;
// pick a transport
if(data["advice"]){
this.advice = data.advice;
}
if(!data.successful){
console.debug("cometd init failed");
if(this.advice && this.advice["reconnect"]=="none"){
return;
}
 
if( this.advice && this.advice["interval"] && this.advice.interval>0 ){
var cometd=this;
setTimeout(function(){ cometd.init(cometd.url,cometd._props); }, this.advice.interval);
}else{
this.init(this.url,this._props);
}
 
return;
}
if(data.version < this.minimumVersion){
console.debug("cometd protocol version mismatch. We wanted", this.minimumVersion, "but got", data.version);
return;
}
this.currentTransport = this.connectionTypes.match(
data.supportedConnectionTypes,
data.version,
this._isXD
);
this.currentTransport._cometd = this;
this.currentTransport.version = data.version;
this.clientId = data.clientId;
this.tunnelInit = dojo.hitch(this.currentTransport, "tunnelInit");
this.tunnelCollapse = dojo.hitch(this.currentTransport, "tunnelCollapse");
 
this.currentTransport.startup(data);
}
 
// public API functions called by cometd or by the transport classes
this.deliver = function(messages){
// console.debug(messages);
dojo.forEach(messages, this._deliver, this);
return messages;
}
 
this._deliver = function(message){
// dipatch events along the specified path
 
if(!message["channel"]){
if(message["success"] !== true){
console.debug("cometd error: no channel for message!", message);
return;
}
}
this.lastMessage = message;
 
if(message.advice){
this.advice = message.advice; // TODO maybe merge?
}
 
// check to see if we got a /meta channel message that we care about
if( (message["channel"]) &&
(message.channel.length > 5)&&
(message.channel.substr(0, 5) == "/meta")){
// check for various meta topic actions that we need to respond to
switch(message.channel){
case "/meta/connect":
if(message.successful && !this._connected){
this._connected = this._initialized;
this.endBatch();
} else if(!this._initialized){
this._connected = false; // finish disconnect
}
break;
case "/meta/subscribe":
var pendingDef = this.pendingSubscriptions[message.subscription];
if(!message.successful){
if(pendingDef){
pendingDef.errback(new Error(message.error));
delete this.pendingSubscriptions[message.subscription];
}
return;
}
dojox.cometd.subscribed(message.subscription, message);
if(pendingDef){
pendingDef.callback(true);
delete this.pendingSubscriptions[message.subscription];
}
break;
case "/meta/unsubscribe":
var pendingDef = this.pendingUnsubscriptions[message.subscription];
if(!message.successful){
if(pendingDef){
pendingDef.errback(new Error(message.error));
delete this.pendingUnsubscriptions[message.subscription];
}
return;
}
this.unsubscribed(message.subscription, message);
if(pendingDef){
pendingDef.callback(true);
delete this.pendingUnsubscriptions[message.subscription];
}
break;
}
}
// send the message down for processing by the transport
this.currentTransport.deliver(message);
 
if(message.data){
// dispatch the message to any locally subscribed listeners
var tname = "/cometd"+message.channel;
dojo.publish(tname, [ message ]);
}
}
 
this.disconnect = function(){
dojo.forEach(this._subscriptions, dojo.unsubscribe);
this._subscriptions = [];
this._messageQ = [];
if(this._initialized && this.currentTransport){
this._initialized=false;
this.currentTransport.disconnect();
}
this._initialized=false;
if(!this._polling)
this._connected=false;
}
 
// public API functions called by end users
this.publish = function(/*string*/channel, /*object*/data, /*object*/properties){
// summary:
// publishes the passed message to the cometd server for delivery
// on the specified topic
// channel:
// the destination channel for the message
// data:
// a JSON object containing the message "payload"
// properties:
// Optional. Other meta-data to be mixed into the top-level of the
// message
var message = {
data: data,
channel: channel
};
if(properties){
dojo.mixin(message, properties);
}
this._sendMessage(message);
}
 
this._sendMessage = function(/* object */ message){
if(this.currentTransport && this._connected && this.batch==0){
return this.currentTransport.sendMessages([message]);
}
else{
this._messageQ.push(message);
}
}
 
this.subscribe = function( /*string */ channel,
/*object, optional*/ objOrFunc,
/*string, optional*/ funcName){ // return: boolean
// summary:
// inform the server of this client's interest in channel
// channel:
// name of the cometd channel to subscribe to
// objOrFunc:
// an object scope for funcName or the name or reference to a
// function to be called when messages are delivered to the
// channel
// funcName:
// the second half of the objOrFunc/funcName pair for identifying
// a callback function to notifiy upon channel message delivery
 
if(this.pendingSubscriptions[channel]){
// We already asked to subscribe to this channel, and
// haven't heard back yet. Fail the previous attempt.
var oldDef = this.pendingSubscriptions[channel];
oldDef.cancel();
delete this.pendingSubscriptions[channel];
}
 
var pendingDef = new dojo.Deferred();
this.pendingSubscriptions[channel] = pendingDef;
 
if(objOrFunc){
var tname = "/cometd"+channel;
if(this.topics[tname]){
dojo.unsubscribe(this.topics[tname]);
}
var topic = dojo.subscribe(tname, objOrFunc, funcName);
this.topics[tname] = topic;
}
 
this._sendMessage({
channel: "/meta/subscribe",
subscription: channel
});
 
return pendingDef;
 
}
 
this.subscribed = function( /*string*/ channel,
/*obj*/ message){
}
 
 
this.unsubscribe = function(/*string*/ channel){ // return: boolean
// summary:
// inform the server of this client's disinterest in channel
// channel:
// name of the cometd channel to unsubscribe from
 
if(this.pendingUnsubscriptions[channel]){
// We already asked to unsubscribe from this channel, and
// haven't heard back yet. Fail the previous attempt.
var oldDef = this.pendingUnsubscriptions[channel];
oldDef.cancel();
delete this.pendingUnsubscriptions[channel];
}
 
var pendingDef = new dojo.Deferred();
this.pendingUnsubscriptions[channel] = pendingDef;
 
var tname = "/cometd"+channel;
if(this.topics[tname]){
dojo.unsubscribe(this.topics[tname]);
}
 
this._sendMessage({
channel: "/meta/unsubscribe",
subscription: channel
});
 
return pendingDef;
 
}
 
this.unsubscribed = function( /*string*/ channel,
/*obj*/ message){
}
 
this.startBatch = function(){
this.batch++;
}
 
this.endBatch = function(){
if(--this.batch <= 0 && this.currentTransport && this._connected){
this.batch=0;
 
var messages=this._messageQ;
this._messageQ=[];
if(messages.length>0){
this.currentTransport.sendMessages(messages);
}
}
}
this._onUnload = function(){
// make this the last of the onUnload method
dojo.addOnUnload(dojox.cometd,"disconnect");
}
}
 
/*
transport objects MUST expose the following methods:
- check
- startup
- sendMessages
- deliver
- disconnect
optional, standard but transport dependent methods are:
- tunnelCollapse
- tunnelInit
 
Transports SHOULD be namespaced under the cometd object and transports MUST
register themselves with cometd.connectionTypes
 
here's a stub transport defintion:
 
cometd.blahTransport = new function(){
this._connectionType="my-polling";
this._cometd=null;
this.lastTimestamp = null;
 
this.check = function(types, version, xdomain){
// summary:
// determines whether or not this transport is suitable given a
// list of transport types that the server supports
return dojo.lang.inArray(types, "blah");
}
 
this.startup = function(){
if(dojox.cometd._polling){ return; }
// FIXME: fill in startup routine here
dojox.cometd._polling = true;
}
 
this.sendMessages = function(message){
// FIXME: fill in message array sending logic
}
 
this.deliver = function(message){
if(message["timestamp"]){
this.lastTimestamp = message.timestamp;
}
if( (message.channel.length > 5)&&
(message.channel.substr(0, 5) == "/meta")){
// check for various meta topic actions that we need to respond to
// switch(message.channel){
// case "/meta/connect":
// // FIXME: fill in logic here
// break;
// // case ...: ...
// }
}
}
 
this.disconnect = function(){
}
}
cometd.connectionTypes.register("blah", cometd.blahTransport.check, cometd.blahTransport);
*/
 
dojox.cometd.longPollTransport = new function(){
this._connectionType="long-polling";
this._cometd=null;
this.lastTimestamp = null;
 
this.check = function(types, version, xdomain){
return ((!xdomain)&&(dojo.indexOf(types, "long-polling") >= 0));
}
 
this.tunnelInit = function(){
if(this._cometd._polling){ return; }
this.openTunnelWith({
message: dojo.toJson([
{
channel: "/meta/connect",
clientId: this._cometd.clientId,
connectionType: this._connectionType,
id: ""+this._cometd.messageId++
}
])
});
}
 
this.tunnelCollapse = function(){
if(!this._cometd._polling){
// try to restart the tunnel
this._cometd._polling = false;
 
// TODO handle transport specific advice
 
if(this._cometd["advice"]){
if(this._cometd.advice["reconnect"]=="none"){
return;
}
 
if( (this._cometd.advice["interval"])&&
(this._cometd.advice.interval>0) ){
var transport = this;
setTimeout(function(){ transport._connect(); },
this._cometd.advice.interval);
}else{
this._connect();
}
}else{
this._connect();
}
}
}
 
this._connect = function(){
if( (this._cometd["advice"])&&
(this._cometd.advice["reconnect"]=="handshake")
){
this._cometd.init(this._cometd.url,this._cometd._props);
}else if(this._cometd._connected){
this.openTunnelWith({
message: dojo.toJson([
{
channel: "/meta/connect",
connectionType: this._connectionType,
clientId: this._cometd.clientId,
timestamp: this.lastTimestamp,
id: ""+this._cometd.messageId++
}
])
});
}
}
 
this.deliver = function(message){
// console.debug(message);
if(message["timestamp"]){
this.lastTimestamp = message.timestamp;
}
}
 
this.openTunnelWith = function(content, url){
// console.debug("openTunnelWith:", content, (url||cometd.url));
var d = dojo.xhrPost({
url: (url||this._cometd.url),
content: content,
handleAs: this._cometd.handleAs,
load: dojo.hitch(this, function(data){
// console.debug(evt.responseText);
// console.debug(data);
this._cometd._polling = false;
this._cometd.deliver(data);
this.tunnelCollapse();
}),
error: function(err){
console.debug("tunnel opening failed:", err);
dojo.cometd._polling = false;
 
// TODO - follow advice to reconnect or rehandshake?
}
});
this._cometd._polling = true;
}
 
this.sendMessages = function(messages){
for(var i=0; i<messages.length; i++){
messages[i].clientId = this._cometd.clientId;
messages[i].id = ""+this._cometd.messageId++;
}
return dojo.xhrPost({
url: this._cometd.url||djConfig["cometdRoot"],
handleAs: this._cometd.handleAs,
load: dojo.hitch(this._cometd, "deliver"),
content: {
message: dojo.toJson(messages)
}
});
}
 
this.startup = function(handshakeData){
if(this._cometd._connected){ return; }
this.tunnelInit();
}
 
this.disconnect = function(){
dojo.xhrPost({
url: this._cometd.url||djConfig["cometdRoot"],
handleAs: this._cometd.handleAs,
content: {
message: dojo.toJson([{
channel: "/meta/disconnect",
clientId: this._cometd.clientId,
id: ""+this._cometd.messageId++
}])
}
});
}
}
 
dojox.cometd.callbackPollTransport = new function(){
this._connectionType = "callback-polling";
this._cometd = null;
this.lastTimestamp = null;
 
this.check = function(types, version, xdomain){
// we handle x-domain!
return (dojo.indexOf(types, "callback-polling") >= 0);
}
 
this.tunnelInit = function(){
if(this._cometd._polling){ return; }
this.openTunnelWith({
message: dojo.toJson([
{
channel: "/meta/connect",
clientId: this._cometd.clientId,
connectionType: this._connectionType,
id: ""+this._cometd.messageId++
}
])
});
}
 
this.tunnelCollapse = dojox.cometd.longPollTransport.tunnelCollapse;
this._connect = dojox.cometd.longPollTransport._connect;
this.deliver = dojox.cometd.longPollTransport.deliver;
 
this.openTunnelWith = function(content, url){
// create a <script> element to generate the request
dojo.io.script.get({
load: dojo.hitch(this, function(data){
this._cometd._polling = false;
this._cometd.deliver(data);
this.tunnelCollapse();
}),
error: function(){
this._cometd._polling = false;
console.debug("tunnel opening failed");
},
url: (url||this._cometd.url),
content: content,
callbackParamName: "jsonp"
});
this._cometd._polling = true;
}
 
this.sendMessages = function(/*array*/ messages){
for(var i=0; i<messages.length; i++){
messages[i].clientId = this._cometd.clientId;
messages[i].id = ""+this._cometd.messageId++;
}
var bindArgs = {
url: this._cometd.url||djConfig["cometdRoot"],
load: dojo.hitch(this._cometd, "deliver"),
callbackParamName: "jsonp",
content: { message: dojo.toJson( messages ) }
};
return dojo.io.script.get(bindArgs);
}
 
this.startup = function(handshakeData){
if(this._cometd._connected){ return; }
this.tunnelInit();
}
 
this.disconnect = dojox.cometd.longPollTransport.disconnect;
 
this.disconnect = function(){
dojo.io.script.get({
url: this._cometd.url||djConfig["cometdRoot"],
callbackParamName: "jsonp",
content: {
message: dojo.toJson([{
channel: "/meta/disconnect",
clientId: this._cometd.clientId,
id: ""+this._cometd.messageId++
}])
}
});
}
}
dojox.cometd.connectionTypes.register("long-polling", dojox.cometd.longPollTransport.check, dojox.cometd.longPollTransport);
dojox.cometd.connectionTypes.register("callback-polling", dojox.cometd.callbackPollTransport.check, dojox.cometd.callbackPollTransport);
 
dojo.addOnUnload(dojox.cometd,"_onUnload");
 
 
}
/trunk/api/js/dojo1.0/dojox/presentation/README
New file
0,0 → 1,72
-------------------------------------------------------------------------------
dojox.presentation
-------------------------------------------------------------------------------
Version 0.9
Release date: 10/31/2007
-------------------------------------------------------------------------------
Project state:
experimental
-------------------------------------------------------------------------------
Credits
pete higgins (dante)
-------------------------------------------------------------------------------
 
Project description
 
This is the presentation base class. It provides a mechanism for various
display-oriented tasks. It includes a powerpoint-esque engine [prototype].
The SlideShow aspect of this project has been deprecated and lives now
in dojox.image project.
 
-------------------------------------------------------------------------------
 
Dependencies:
 
dojox.presentation requires both Dojo Base, Dojo FX Core, and Dijit system(s).
 
-------------------------------------------------------------------------------
 
Documentation
 
See the Dojo API tool (http://dojotoolkit.org/api)
 
-------------------------------------------------------------------------------
 
Installation instructions
 
This package is self-contained, but needs Dijit sytem.
 
Grab the following from the Dojo SVN Repository:
 
svn co http://svn.dojotoolkit.org/dojo/dojox/trunk/presentation*
svn co http://svn.dojotoolkit.org/dojo/dijit/*
 
into your:
/dojo root folder [checkout/release root]
 
and require in dependancies via dojo.require('dojox.presentation');
 
see /dojox/presentation/tests/test_presentation.html for example usage, but
basically the structure is this:
 
presentation />
Slide />
Slide />
Text Outside of Part is Static
Part />
Part />
Action forPart/>
Action forPart/>
Slide href="remote.html" />
Slide />
Part />
Action forPart/>
/presentation>
 
NOTE: project marked experimental, and API has a planned deprecation. To
participate in the formation of the new presentation class, visit
the dojotoolkit forums at:
 
http://dojotoolkit.org/forums
 
 
/trunk/api/js/dojo1.0/dojox/presentation/tests/_ext1.html
New file
0,0 → 1,21
<h2>WARNING:</h2>
 
<p style="font:14pt Arial,sans-serif; color:#666; float:left; ">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean<br>
semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin<br>
porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.<br>
Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis.<br>
Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitae<br>
risus.
</p>
 
<p style="font:8pt Arial,sans-serif; color:#666;" dojoType="dojox.presentation.Part" as="one">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin
porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.<br>
Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis.<br>
Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitae
risus.
</p>
 
<input dojoType="dojox.presentation.Action" forSlide="one" toggle="fade">
/trunk/api/js/dojo1.0/dojox/presentation/tests/test_presentation.html
New file
0,0 → 1,162
<html>
<head>
<title>dojox.presentation - Presentation Mechanism</title>
 
<script type="text/javascript"> djConfig = { isDebug: true, parseOnLoad: true }; </script>
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
<script type="text/javascript" src="../../../dijit/form/Button.js"></script>
<script type="text/javascript">
dojo.require("dojox.presentation");
dojo.require("dijit._Calendar");
dojo.require("dijit.TitlePane");
dojo.require("dojo.parser");
dojo.require("dojo.fx");
dojo.require("dojo.dnd.move");
</script>
 
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../resources/Show.css";
</style>
 
<script type="text/javascript">
var externalAnimation = null;
var titleCount=0;
var titles = [
"Just Kidding",
"The Title Will keep changing",
"but you can click to advance",
"nonthing fancy",
"just an example of",
"an external function controlling a slide."
];
function playIt() {
var node = dijit.byId('animated').slideTitle;
console.debug(node);
// this is the fanciest animation chain i could thing of atm
tmpTitle = titles[titleCount++] || titles[0];
externalAnimation = dojo.fx.chain([
dojo.fadeOut({ node: node,
duration: 500,
onEnd: dojo.hitch(this,function(){
node.innerHTML = tmpTitle;
})
}),
dojo.animateProperty({
node: node,
duration: 10,
properties: { letterSpacing: {
end:-26.3, unit: 'em', start:3.2
}
}
}),
dojo.fadeIn({ node: node,
duration:300
}),
dojo.animateProperty({
node: node,
duration: 800,
properties: { letterSpacing: {
end:2.8, unit: 'em' , start:-26.0
}
}
})
]);
setTimeout("externalAnimation.play()",50);
}
 
function makeDraggable(node) {
var tmp = new dojo.dnd.Moveable(node);
}
 
</script>
 
</head>
<body class="tundra">
<div dojoType="dojox.presentation.Deck" id="testPresentation">
<div dojoType="dojox.presentation.Slide" id="myFirstSlide" title="Introduction">
<p>This is a brief overview of what this presentation widget is capable of.</p>
 
<div dojoType="dojox.presentation.Part" as="one">... it's new, and completely different, so watch close</div>
 
<input dojoType="dojox.presentation.Action" forSlide="one" toggle="fade" duration="3000">
<input dojoType="dojox.presentation.Action" forSlide="one" toggle="wipe">
 
</div>
 
<div dojoType="dojox.presentation.Slide" title="Basic Actions">
<p>Click, and more text will appear</p>
 
<div dojoType="dojox.presentation.Part" as="one">
<p>Lorem something something. I am text, hear me _roar_.</p>
</div>
<input dojoType="dojox.presentation.Action" forSlide="one" on="click" toggle="fade">
<div dojoType="dojox.presentation.Part" as="me">
I am here to make sure click-advancing is disabled on normal input type elements:
<ul>
<li><a href="#">href</a></li>
<li>Input: <input type="text" name="foo"></li>
</ul>
 
</div>
<input dojoType="dojox.presentation.Action" forslide="me" toggle="slide">
 
 
</div>
<div dojoType="dojox.presentation.Slide" title="Automatically Advance">
<p dojoType="dojox.presentation.Part" as="one">First You See me ...</p>
<p dojoType="dojox.presentation.Part" as="two">Then you see ME ...</p>
<p dojoType="dojox.presentation.Part" as="three" style="padding:20px;">oh yeah!</p>
 
<input dojoType="dojox.presentation.Action" forSlide="one" on="click" toggle="fade" delay="1500">
<input dojoType="dojox.presentation.Action" forSlide="two" toggle="wipe" delay="1500">
<input dojoType="dojox.presentation.Action" forSlide="three" toggle="wipe" delay="1500">
 
</div>
<!--
<div dojoType="dojox.presentation.Slide" title="Remote Slide" href="_ext1.html"></div>
-->
<div dojoType="dojox.presentation.Slide" title="Click Blocking" id="animated">
<p>You cannot click on this page</p>
<p dojoType="dojox.presentation.Part" as="1">I told you that you can't click ...</p>
<a href="#" onClick="playIt()">click here to move the title</a>
<input dojoType="dojox.presentation.Action" forSlide="1" toggle="wipe">
<input dojoType="dojox.presentation.Action" forSlide="2">
<input dojoType="dojox.presentation.Action" forSlide="1" toggle="fade">
</div>
 
<div dojoType="dojox.presentation.Slide" title="Widgets in Slide" noClick="true" id="wdijit">
<p>There is a widget in this page:</p>
<p>clicking has been stopped on this page to demonstrate the usage ..</p>
<div dojoType="dojox.presentation.Part" as="foo" startVisible="true">
There _should_ be a _Calendar widget here<br>
<div dojoType="dijit._Calendar"></div>
</div>
<div dojoType="dijit.TitlePane" title="foobar" id="newTitlePane"
style="width:300px; position:absolute; right:40px; top:125px;">
I am a titlepane, you can do cool things with me.
<button onClick="makeDraggable('newTitlePane')">Make me Draggable!</button>
</div>
<div style="width:400px; position:absolute; right: 40px; bottom:40px;">
<p>... so I'm providing a next button: <button dojoType="dijit.form.Button" value="Next" onClick="dijit.byId('testPresentation').nextSlide();">Next</button></p>
</div>
<input type="dojox.presentation.Action" forSlide="foo" toggle="slide">
</div>
 
<div dojoType="dojox.presentation.Slide" title="The End">
<p>Thanks for watching!</p>
</div>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/presentation/_base.js
New file
0,0 → 1,556
if(!dojo._hasResource["dojox.presentation._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.presentation._base"] = true;
dojo.provide("dojox.presentation._base");
dojo.experimental("dojox.presentation");
 
dojo.require("dijit._Widget");
dojo.require("dijit._Container");
dojo.require("dijit._Templated");
dojo.require("dijit.layout.StackContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dojo.fx");
 
dojo.declare("dojox.presentation.Deck", [ dijit.layout.StackContainer, dijit._Templated ], {
// summary:
// dojox.presentation class
// basic powerpoint esque engine for handling transitons and control
// in a page-by-page and part-by-part way
//
// FIXME: parsing part(s)/widget(s) in href="" Slides not working
// TODO: make auto actions progress.
// FIXME: Safari keydown/press/up listener not working.
// noClick=true prevents progression of slides in that broweser
//
// fullScreen: Boolean
// unsupported (that i know of) just yet. Default it to take control
// of window. Would be nice to be able to contain presentation in a
// styled container, like StackContainer ... theoretically possible.
// [and may not need this variable?]
fullScreen: true,
 
// useNav: Boolean
// true to allow navigation popup, false to disallow
useNav: true,
 
// navDuration: Integer
// time in MS fadein/out of popup nav [default: 250]
navDuration: 250,
 
// noClick: Boolean
// if true, prevents _any_ click events to propagate actions
// (limiting control to keyboard and/or action.on="auto" or action.delay=""
// actions.
noClick: false,
 
// setHash: Boolean
// if true, window location bar will get a #link to slide for direct
// access to a particular slide number.
setHash: true,
 
// just to over-ride:
templateString: null,
templateString:"<div class=\"dojoShow\" dojoAttachPoint=\"showHolder\">\n\t<div class=\"dojoShowNav\" dojoAttachPoint=\"showNav\" dojoAttachEvent=\"onmouseover: _showNav, onmouseout: _hideNav\">\n\t<div class=\"dojoShowNavToggler\" dojoAttachPoint=\"showToggler\">\n\t\t<img dojoAttachPoint=\"prevNode\" src=\"${prevIcon}\" dojoAttachEvent=\"onclick:previousSlide\">\n\t\t<select dojoAttachEvent=\"onchange:_onEvent\" dojoAttachPoint=\"select\">\n\t\t\t<option dojoAttachPoint=\"_option\">Title</option>\n\t\t</select>\n\t\t<img dojoAttachPoint=\"nextNode\" src=\"${nextIcon}\" dojoAttachEvent=\"onclick:nextSlide\">\n\t</div>\n\t</div>\n\t<div dojoAttachPoint=\"containerNode\"></div>\n</div>\n",
 
// nextIcon: String
// icon for navigation "next" button
nextIcon: dojo.moduleUrl('dojox.presentation','resources/icons/next.png'),
 
// prevIcon: String
// icon for navigation "previous" button
prevIcon: dojo.moduleUrl('dojox.presentation','resources/icons/prev.png'),
 
_navOpacMin: 0,
_navOpacMax: 0.85,
_slideIndex: 0,
// Private:
_slides: [],
_navShowing: true,
_inNav: false,
startup: function(){
// summary: connect to the various handlers and controls for this presention
dojox.presentation.Deck.superclass.startup.call(this);
 
if(this.useNav){
this._hideNav();
}else{
this.showNav.style.display = "none";
}
 
this.connect(document,'onclick', '_onEvent');
this.connect(document,'onkeypress', '_onEvent');
// only if this.fullScreen == true?
this.connect(window, 'onresize', '_resizeWindow');
this._resizeWindow();
this._updateSlides();
this._readHash();
this._setHash();
},
 
moveTo: function(/* Integer */ number){
// summary: jump to slide based on param
var slideIndex = number - 1;
if(slideIndex < 0)
slideIndex = 0;
if(slideIndex > this._slides.length - 1)
slideIndex = this._slides.length - 1;
this._gotoSlide(slideIndex);
},
 
onMove: function (number){
// summary: stub function? TODOC: ?
},
nextSlide: function(/*Event*/ evt){
// summary: transition to the next slide.
if (!this.selectedChildWidget.isLastChild) {
this._gotoSlide(this._slideIndex+1);
}
if (evt) { evt.stopPropagation(); }
},
 
previousSlide: function(/*Event*/ evt){
// summary: transition to the previous slide
if (!this.selectedChildWidget.isFirstChild) {
this._gotoSlide(this._slideIndex-1);
} else { this.selectedChildWidget._reset(); }
if (evt) { evt.stopPropagation();}
},
 
getHash: function(id){
// summary: get the current hash to set in localtion
return this.id+"_SlideNo_"+id;
},
_hideNav: function(evt){
// summary: hides navigation
if(this._navAnim){ this._navAnim.stop(); }
this._navAnim = dojo.animateProperty({
node:this.showNav,
duration:this.navDuration,
properties: {
opacity: { end:this._navOpacMin }
}
}).play();
},
 
_showNav: function(evt){
// summary: shows navigation
if(this._navAnim){ this._navAnim.stop(); }
this._navAnim = dojo.animateProperty({
node:this.showNav,
duration:this.navDuration,
properties: {
opacity: { end:this._navOpacMax }
}
}).play();
},
 
_handleNav: function(evt){
// summary: does nothing? _that_ seems useful.
evt.stopPropagation();
},
 
_updateSlides: function(){
// summary:
// populate navigation select list with refs to slides call this
// if you add a node to your presentation dynamically.
this._slides = this.getChildren();
if(this.useNav){
// populate the select box with top-level slides
var i=0;
dojo.forEach(this._slides,dojo.hitch(this,function(slide){
i++;
var tmp = this._option.cloneNode(true);
tmp.text = slide.title+" ("+i+") ";
this._option.parentNode.insertBefore(tmp,this._option);
}));
if(this._option.parentNode){
this._option.parentNode.removeChild(this._option);
}
// dojo._destroyElement(this._option);
}
},
 
_onEvent: function(/* Event */ evt){
// summary:
// main presentation function, determines next 'best action' for a
// specified event.
var _node = evt.target;
var _type = evt.type;
 
if(_type == "click" || _type == "change"){
if(_node.index && _node.parentNode == this.select){
this._gotoSlide(_node.index);
}else if(_node == this.select){
this._gotoSlide(_node.selectedIndex);
}else{
if (this.noClick || this.selectedChildWidget.noClick || this._isUnclickable(evt)) return;
this.selectedChildWidget._nextAction(evt);
}
}else if(_type=="keydown" || _type == "keypress"){
// FIXME: safari doesn't report keydown/keypress?
var key = (evt.charCode == dojo.keys.SPACE ? dojo.keys.SPACE : evt.keyCode);
switch(key){
case dojo.keys.DELETE:
case dojo.keys.BACKSPACE:
case dojo.keys.LEFT_ARROW:
case dojo.keys.UP_ARROW:
case dojo.keys.PAGE_UP:
case 80: // key 'p'
this.previousSlide(evt);
break;
 
case dojo.keys.ENTER:
case dojo.keys.SPACE:
case dojo.keys.RIGHT_ARROW:
case dojo.keys.DOWN_ARROW:
case dojo.keys.PAGE_DOWN:
case 78: // key 'n'
this.selectedChildWidget._nextAction(evt);
break;
 
case dojo.keys.HOME: this._gotoSlide(0);
}
}
this._resizeWindow();
evt.stopPropagation();
},
_gotoSlide: function(/* Integer */ slideIndex){
// summary: goes to slide
this.selectChild(this._slides[slideIndex]);
this.selectedChildWidget._reset();
 
this._slideIndex = slideIndex;
if(this.useNav){
this.select.selectedIndex = slideIndex;
}
if(this.setHash){
this._setHash();
}
this.onMove(this._slideIndex+1);
},
 
_isUnclickable: function(/* Event */ evt){
// summary: returns true||false base of a nodes click-ability
var nodeName = evt.target.nodeName.toLowerCase();
// TODO: check for noClick='true' in target attrs & return true
// TODO: check for relayClick='true' in target attrs & return false
switch(nodeName){
case 'a' :
case 'input' :
case 'textarea' : return true; break;
}
return false;
},
 
_readHash: function(){
var th = window.location.hash;
if (th.length && this.setHash) {
var parts = (""+window.location).split(this.getHash(''));
if(parts.length>1){
this._gotoSlide(parseInt(parts[1])-1);
}
}
},
 
_setHash: function(){
// summary: sets url #mark to direct slide access
if(this.setHash){
var slideNo = this._slideIndex+1;
window.location.href = "#"+this.getHash(slideNo);
}
},
 
_resizeWindow: function(/*Event*/ evt){
// summary: resize this and children to fix this window/container
 
// only if this.fullScreen?
dojo.body().style.height = "auto";
var wh = dijit.getViewport();
var h = Math.max(
document.documentElement.scrollHeight || dojo.body().scrollHeight,
wh.h);
var w = wh.w;
this.selectedChildWidget.domNode.style.height = h +'px';
this.selectedChildWidget.domNode.style.width = w +'px';
},
 
_transition: function(newWidget,oldWidget){
// summary: over-ride stackcontainers _transition method
// but atm, i find it to be ugly with not way to call
// _showChild() without over-riding it too. hopefull
// basic toggles in superclass._transition will be available
// in dijit, and this won't be necessary.
var anims = [];
if(oldWidget){
/*
anims.push(dojo.fadeOut({ node: oldWidget.domNode,
duration:250,
onEnd: dojo.hitch(this,function(){
this._hideChild(oldWidget);
})
}));
*/
this._hideChild(oldWidget);
}
if(newWidget){
/*
anims.push(dojo.fadeIn({
node:newWidget.domNode, start:0, end:1,
duration:300,
onEnd: dojo.hitch(this,function(){
this._showChild(newWidget);
newWidget._reset();
})
})
);
*/
this._showChild(newWidget);
newWidget._reset();
}
//dojo.fx.combine(anims).play();
}
});
 
dojo.declare(
"dojox.presentation.Slide",
[dijit.layout.ContentPane,dijit._Contained,dijit._Container,dijit._Templated],
{
// summary:
// a Comonent of a dojox.presentation, and container for each 'Slide'
// made up of direct HTML (no part/action relationship), and dojox.presentation.Part(s),
// and their attached Actions.
 
// templatPath: String
// make a ContentPane templated, and style the 'titleNode'
templateString:"<div dojoAttachPoint=\"showSlide\" class=\"dojoShowPrint dojoShowSlide\">\n\t<h1 class=\"showTitle\" dojoAttachPoint=\"slideTitle\"><span class=\"dojoShowSlideTitle\" dojoAttachPoint=\"slideTitleText\">${title}</span></h1>\n\t<div class=\"dojoShowBody\" dojoAttachPoint=\"containerNode\"></div>\n</div>\n",
 
// title: String
// string to insert into titleNode, title of Slide
title: "",
 
// inherited from ContentPane FIXME: don't seem to work ATM?
refreshOnShow: true,
preLoad: false,
doLayout: true,
parseContent: true,
 
// noClick: Boolean
// true on slide tag prevents clicking, false allows
// (can also be set on base presentation for global control)
noClick: false,
 
// private holders:
_parts: [],
_actions: [],
_actionIndex: 0,
_runningDelay: false,
 
startup: function(){
// summary: setup this slide with actions and components (Parts)
this.slideTitleText.innerHTML = this.title;
var children = this.getChildren();
this._actions = [];
dojo.forEach(children,function(child){
var tmpClass = child.declaredClass.toLowerCase();
switch(tmpClass){
case "dojox.presentation.part" : this._parts.push(child); break;
case "dojox.presentation.action" : this._actions.push(child); break;
}
},this);
},
 
 
_nextAction: function(evt){
// summary: gotoAndPlay current cached action
var tmpAction = this._actions[this._actionIndex] || 0;
if (tmpAction){
// is this action a delayed action? [auto? thoughts?]
if(tmpAction.on == "delay"){
this._runningDelay = setTimeout(
dojo.hitch(tmpAction,"_runAction"),tmpAction.delay
);
console.debug('started delay action',this._runningDelay);
}else{
tmpAction._runAction();
}
 
// FIXME: it gets hairy here. maybe runAction should
// call _actionIndex++ onEnd? if a delayed action is running, do
// we want to prevent action++?
var tmpNext = this._getNextAction();
this._actionIndex++;
 
if(tmpNext.on == "delay"){
// FIXME: yeah it looks like _runAction() onend should report
// _actionIndex++
console.debug('started delay action',this._runningDelay);
setTimeout(dojo.hitch(tmpNext,"_runAction"),tmpNext.delay);
}
}else{
// no more actions in this slide
this.getParent().nextSlide(evt);
}
},
 
_getNextAction: function(){
// summary: returns the _next action in this sequence
return this._actions[this._actionIndex+1] || 0;
},
 
_reset: function(){
// summary: set action chain back to 0 and re-init each Part
this._actionIndex = [0];
dojo.forEach(this._parts,function(part){
part._reset();
},this);
}
});
 
dojo.declare("dojox.presentation.Part", [dijit._Widget,dijit._Contained], {
// summary:
// a node in a presentation.Slide that inherits control from a
// dojox.presentation.Action
// can be any element type, and requires styling before parsing
//
// as: String
// like an ID, attach to Action via (part) as="" / (action) forSlide="" tags
// this should be unique identifier?
as: null,
// startVisible: boolean
// true to leave in page on slide startup/reset
// false to hide on slide startup/reset
startVisible: false,
 
// isShowing: Boolean,
// private holder for _current_ state of Part
_isShowing: false,
 
postCreate: function(){
// summary: override and init() this component
this._reset();
},
 
_reset: function(){
// summary: set part back to initial calculate state
// these _seem_ backwards, but quickToggle flips it
this._isShowing =! this.startVisible;
this._quickToggle();
},
 
_quickToggle: function(){
// summary: ugly [unworking] fix to test setting state of component
// before/after an animation. display:none prevents fadeIns?
if(this._isShowing){
dojo.style(this.domNode,'display','none');
dojo.style(this.domNode,'visibility','hidden');
dojo.style(this.domNode,'opacity',0);
}else{
dojo.style(this.domNode,'display','');
dojo.style(this.domNode,'visibility','visible');
dojo.style(this.domNode,'opacity',1);
}
this._isShowing =! this._isShowing;
}
});
 
dojo.declare("dojox.presentation.Action", [dijit._Widget,dijit._Contained], {
// summary:
// a widget to attach to a dojox.presentation.Part to control
// it's properties based on an inherited chain of events ...
//
//
// on: String
// FIXME: only 'click' supported ATM. plans include on="delay",
// on="end" of="", and on="auto". those should make semantic sense
// to you.
on: 'click',
 
// forSlide: String
// attach this action to a dojox.presentation.Part with a matching 'as' attribute
forSlide: null,
 
// toggle: String
// will toggle attached [matching] node(s) via forSlide/as relationship(s)
toggle: 'fade',
// delay: Integer
//
delay: 0,
 
// duration: Integer
// default time in MS to run this action effect on it's 'forSlide' node
duration: 1000,
 
// private holders:
_attached: [],
_nullAnim: false,
 
_runAction: function(){
// summary: runs this action on attached node(s)
 
var anims = [];
// executes the action for each attached 'Part'
dojo.forEach(this._attached,function(node){
// FIXME: this is ugly, and where is toggle class? :(
var dir = (node._isShowing) ? "Out" : "In";
// node._isShowing =! node._isShowing;
node._quickToggle(); // (?) this is annoying
//var _anim = dojox.fx[ this.toggle ? this.toggle+dir : "fade"+dir]({
var _anim = dojo.fadeIn({
node:node.domNode,
duration: this.duration
//beforeBegin: dojo.hitch(node,"_quickToggle")
});
anims.push(_anim);
},this);
var _anim = dojo.fx.combine(anims);
if(_anim){ _anim.play(); }
},
 
_getSiblingsByType: function(/* String */ declaredClass){
// summary: quick replacement for getChildrenByType("class"), but in
// a child here ... so it's getSiblings. courtesy bill in #dojo
// could be moved into parent, and just call this.getChildren(),
// which makes more sense.
var siblings = dojo.filter( this.getParent().getChildren(), function(widget){
return widget.declaredClass==declaredClass;
}
);
return siblings; // dijit._Widget
},
postCreate: function(){
// summary: run this once, should this be startup: function()?
 
// prevent actions from being visible, _always_
dojo.style(this.domNode,"display","none");
var parents = this._getSiblingsByType('dojox.presentation.Part');
// create a list of "parts" we are attached to via forSlide/as
this._attached = [];
dojo.forEach(parents,function(parentPart){
if(this.forSlide == parentPart.as){
this._attached.push(parentPart);
}
},this);
}
 
});
 
}
/trunk/api/js/dojo1.0/dojox/presentation/resources/Show.css
New file
0,0 → 1,110
@media screen {
html, body {
margin: 0px;
padding: 0px;
}
h1.showTitle {
margin:0;
margin-left:0;
padding:0;
font-size: 60px;
background:transparent;
border-bottom:1px solid #000;
}
 
p, li {
font-size: 17pt;
}
 
.dojoShowNav {
border-top:1px solid #ccc;
background: #ededed;
overflow: hidden;
position: absolute;
bottom: 0px;
left: 0px;
width: 100%;
text-align: center;
z-index:420;
padding:0;
margin-bttom:5px; height:34px;
}
 
.dojoShowNav img { cursor:pointer; }
.dojoShowSlide {
/* width:100%; height:100%; */
}
 
.dojoShowNav option { font:6pt; color:#333; }
.dojoShowNav select {
margin: 0px;
color: #999;
margin-top: 5px;
padding: 2px;
border: 1px solid #ccc;
-moz-border-radius:6pt 6pt;
}
 
.dojoShowHider {
height: 5px;
overflow: hidden;
width: 100%;
z-index:421;
}
.dojoShowPrint {
position: absolute;
left: 0px;
top: 0px;
width:100%;
}
 
.dojoShowBody {
background:#fff url('../../../dijit/themes/tundra/images/testBodyBg.gif') repeat-x top left;
padding:10px;
}
 
.dojoShow {
width:100%; height:100%;
overflow:hidden;
}
}
 
@media print {
.dojoShow {
display: none !important;
}
.dojoShowPrint {
display: block !important;
}
.dojoShowPrintSlide {
border: 1px solid #aaa;
padding: 10px;
margin-bottom: 15px;
}
.dojoShowPrintSlide, ul {
page-break-inside: avoid;
}
h1 {
margin-top: 0;
page-break-after: avoid;
}
}
 
.dojoShowSlideTitle {
height: 100px;
width:100%;
display:block;
background-color: #ededed;
border-bottom:1px solid #666;
}
.dojoShowSlideTitle h1 {
margin-top: 0;
/* line-height: 100px;
margin-left: 30px; */
}
.dojoShowSlideBody {
margin: 15px;
background:#fff url('../../../dijit/themes/tundra/images/testBodyBg.gif') repeat-x top left;
}
/trunk/api/js/dojo1.0/dojox/presentation/resources/icons/up.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/presentation/resources/icons/up.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/presentation/resources/icons/down.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/presentation/resources/icons/down.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/presentation/resources/icons/prev.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/presentation/resources/icons/prev.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/presentation/resources/icons/next.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/presentation/resources/icons/next.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/presentation/resources/Show.html
New file
0,0 → 1,12
<div class="dojoShow" dojoAttachPoint="showHolder">
<div class="dojoShowNav" dojoAttachPoint="showNav" dojoAttachEvent="onmouseover: _showNav, onmouseout: _hideNav">
<div class="dojoShowNavToggler" dojoAttachPoint="showToggler">
<img dojoAttachPoint="prevNode" src="${prevIcon}" dojoAttachEvent="onclick:previousSlide">
<select dojoAttachEvent="onchange:_onEvent" dojoAttachPoint="select">
<option dojoAttachPoint="_option">Title</option>
</select>
<img dojoAttachPoint="nextNode" src="${nextIcon}" dojoAttachEvent="onclick:nextSlide">
</div>
</div>
<div dojoAttachPoint="containerNode"></div>
</div>
/trunk/api/js/dojo1.0/dojox/presentation/resources/Slide.html
New file
0,0 → 1,4
<div dojoAttachPoint="showSlide" class="dojoShowPrint dojoShowSlide">
<h1 class="showTitle" dojoAttachPoint="slideTitle"><span class="dojoShowSlideTitle" dojoAttachPoint="slideTitleText">${title}</span></h1>
<div class="dojoShowBody" dojoAttachPoint="containerNode"></div>
</div>
/trunk/api/js/dojo1.0/dojox/color/README
New file
0,0 → 1,41
-------------------------------------------------------------------------------
DojoX Color
-------------------------------------------------------------------------------
Version 0.9
Release date: 10/20/2007
-------------------------------------------------------------------------------
Project state:
dojox.color._base: stable
dojox.color.Colorspace: experimental
dojox.color.Generator: beta
-------------------------------------------------------------------------------
Credits
Cal Henderson
Tom Trenka (ttrenka AT gmail.com)
-------------------------------------------------------------------------------
Project description
 
Both a port of the older dojo.gfx.color work (Cal Henderson) as well as some
new additions (Generator, Tom Trenka). Everything is applied to an alias of
dojo.Color or dojo.color, so that you can just use dojox.color.Color instead
with extended methods.
-------------------------------------------------------------------------------
Dependencies:
 
Depends on the Dojo Core, v1.0
-------------------------------------------------------------------------------
Documentation
 
See the API documentation.
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/color.js
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/color/*
 
Install into the following directory structure:
/dojox/color/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
/trunk/api/js/dojo1.0/dojox/color/Generator.js
New file
0,0 → 1,257
if(!dojo._hasResource["dojox.color.Generator"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.color.Generator"] = true;
dojo.provide("dojox.color.Generator");
 
dojox.color.Generator = new (function(){
var dxc=dojox.color;
 
// common helper functions
var prep=function(obj, fnName){
if(!obj){
console.warn("dojox.color.Generator::", fnName, ": no base color was passed. ", obj);
return null;
}
if(!obj.toHsv){
// either a raw string or object, return a Color.
obj=new dxc.Color(obj);
}
return obj;
};
 
var factors=function(n, high, low){
var ret=[];
var i, step=(high-low)/n, cur=high;
for(i=0; i<n; i++,cur-=step){ ret.push(cur); }
return ret;
};
 
var fill=function(color, num, factors){
var c=factors.length-1, a=[], r, g, b;
for(var i=0; i<num; i++){
if(i<factors.length){
r=color.r+(255-color.r)*factors[i],
g=color.g+(255-color.g)*factors[i],
b=color.b+(255-color.b)*factors[i];
a.push(new dxc.Color({ r:r, g:g, b:b }));
}
else if(i==factors.length){
a.push(color);
}
else {
if(c<0){ c=factors.length-1; } // just in case.
r=color.r*(1-factors[c]),
g=color.g*(1-factors[c]),
b=color.b*(1-factors[c--]);
a.push(new dxc.Color({ r:r, g:g, b:b }));
}
}
return a;
};
var flatten=function(matrix, limit, ord){
// todo: set up the ordering thing.
var ret=[];
for(var i=0; i<matrix[0].length; i++){
for(var j=0; j<matrix.length; j++){
ret.push(matrix[j][i]);
}
}
ret.length=limit;
return ret;
};
 
// the color generator
this.analogous= function(kwArgs){
// summary
// generates n colors based on a base color, based on a fixed hue angle delta
// (relative to the base hue) with slight variations in saturation.
kwArgs=dojo.mixin({
series:4, // number of analogous lines to generate
num:32, // number of colors to derive
order:"bottom up", // the order of the returned color array
angle:30, // the angle of difference to use
high:0.5, // high part of range to generate tints and shades
low:0.15 // low part of range to generate tints and shades
}, kwArgs||{});
var base=prep(kwArgs.base, "analogous");
if(!base){ return []; }
 
// let start the generation. We use series to move further away from the center.
var num=kwArgs.num, hsv=base.toHsv();
var rows=kwArgs.series+1, cols=Math.ceil(num/rows);
var fs=factors(Math.floor(cols/2), kwArgs.high, kwArgs.low);
 
var m=[], cur=hsv.h-(kwArgs.angle*(kwArgs.series/2));
for(var i=0; i<rows; i++,cur+=kwArgs.angle){
if(cur<0) { cur+=360 ; }
if(cur>=360){ cur-=360; }
m.push(fill(dxc.fromHsv({ h: cur, s:hsv.s, v:hsv.v }), cols, fs));
}
return flatten(m, num, kwArgs.order); // Array
};
this.monochromatic = function(kwArgs){
// summary
// generates n colors based on a base color, using alterations to the RGB model only.
kwArgs=dojo.mixin({
num:32, // number of colors to derive
high:0.5, // high factor to generate tints and shades
low:0.15 // low factor to generate tints and shades
}, kwArgs||{});
var base=prep(kwArgs.base, "monochromatic");
if(!base){ return []; }
 
var fs=factors(Math.floor(kwArgs.num/2), kwArgs.high, kwArgs.low);
var a=fill(base, kwArgs.num, fs);
return a; // Array
};
this.triadic = function(kwArgs){
// summary
// generates n colors from a base color, using the triadic rules, rough
// approximation from kuler.adobe.com.
kwArgs=dojo.mixin({
num:32, // number of colors to derive
order:"bottom up", // the order of the returned color array
high:0.5, // high factor to generate tints and shades
low:0.15 // low factor to generate tints and shades
}, kwArgs||{});
var base=prep(kwArgs.base, "triadic");
if(!base){ return []; }
 
var num=kwArgs.num, rows=3, cols=Math.ceil(num/rows), fs=factors(Math.floor(cols/2), kwArgs.high, kwArgs.low);
var m=[], hsv=base.toHsv();
 
// hue calculations
var h1=hsv.h+57, h2=hsv.h-157;
if(h1>360){ h1-=360; }
if(h2<0){ h2+=360; }
 
// sat calculations
var s1=(hsv.s>=20) ? hsv.s-10 : hsv.s+10;
var s2=(hsv.s>=95) ? hsv.s-5 : hsv.s+5;
 
// value calcs
var v2=(hsv.v>=70) ? hsv.v-30 : hsv.v+30;
m.push(fill(dojox.color.fromHsv({ h:h1, s:s1, v:hsv.v }), cols, fs));
m.push(fill(base, cols, fs));
m.push(fill(dojox.color.fromHsv({ h:h2, s:s2, v:v2 }), cols, fs));
return flatten(m, num, kwArgs.order); // Array
};
this.complementary = function(kwArgs){
// summary
// generates n colors from a base color, using complimentary rules.
kwArgs=dojo.mixin({
num:32, // number of colors to derive
order:"bottom up", // the order of the returned color array
high:0.5, // high factor to generate tints and shades
low:0.15 // low factor to generate tints and shades
}, kwArgs||{});
var base=prep(kwArgs.base, "complimentary");
if(!base){ return []; }
 
var num=kwArgs.num, rows=2, cols=Math.ceil(num/rows), fs=factors(Math.floor(cols/2), kwArgs.high, kwArgs.low);
var m=[], hsv=base.toHsv();
var compliment=(hsv.h+120)%360;
m.push(fill(base, cols, fs));
m.push(fill(dojox.color.fromHsv({ h:compliment, s:hsv.s, v:hsv.v }), cols, fs));
return flatten(m, num, kwArgs.order); // Array
};
this.splitComplementary = function(kwArgs){
// summary
// generates n colors from a base color, using split complimentary rules.
kwArgs=dojo.mixin({
num:32, // number of colors to derive
order:"bottom up", // the order of the returned color array
angle:30, // the angle of difference to use
high:0.5, // high factor to generate tints and shades
low:0.15 // low factor to generate tints and shades
}, kwArgs||{});
var base=prep(kwArgs.base, "splitComplementary");
if(!base){ return []; }
 
var num=kwArgs.num, rows=3, cols=Math.ceil(num/rows), fs=factors(Math.floor(cols/2), kwArgs.high, kwArgs.low);
var m=[], hsv=base.toHsv();
var compliment=(hsv.h+120)%360;
var comp1=compliment-kwArgs.angle, comp2=(compliment+kwArgs.angle)%360;
if(comp1<0){ comp1+=360; }
m.push(fill(base, cols, fs));
m.push(fill(dojox.color.fromHsv({ h:comp1, s:hsv.s, v:hsv.v }), cols, fs));
m.push(fill(dojox.color.fromHsv({ h:comp2, s:hsv.s, v:hsv.v }), cols, fs));
return flatten(m, num, kwArgs.order); // Array
};
this.compound = function(kwArgs){
// summary
// generates n colors from a base color, using a *very* rough approximation
// of the Compound rules at http://kuler.adobe.com
kwArgs=dojo.mixin({
num:32, // number of colors to derive
order:"bottom up", // the order of the returned color array
angle:30, // the angle of difference to use
high:0.5, // high factor to generate tints and shades
low:0.15 // low factor to generate tints and shades
}, kwArgs||{});
var base=prep(kwArgs.base, "compound");
if(!base){ return []; }
 
var num=kwArgs.num, rows=4, cols=Math.ceil(num/rows), fs=factors(Math.floor(cols/2), kwArgs.high, kwArgs.low);
var m=[], hsv=base.toHsv();
var comp=(hsv.h+120)%360; // other base angle.
 
// hue calculations
var h1=(hsv.h+kwArgs.angle)%360, h2=comp-kwArgs.angle, h3=comp-(kwArgs.angle/2);
if(h2<0){ h2+=360; }
if(h3<0){ h3+=360; }
 
// saturation calculations
var s1=(hsv.s>=90 && hsv.s<=100)? hsv.s-10 : hsv.s+10;
var s2=(hsv.s<=35) ? hsv.s+25 : hsv.s-25;
 
// value calculations
var v1=hsv.v-20;
var v2=hsv.v;
m.push(fill(base, cols, fs));
m.push(fill(dojox.color.fromHsv({ h:h1, s:s1, v:v1 }), cols, fs));
m.push(fill(dojox.color.fromHsv({ h:h2, s:s1, v:v1 }), cols, fs));
m.push(fill(dojox.color.fromHsv({ h:h3, s:s2, v:v2 }), cols, fs));
return flatten(m, num, kwArgs.order); // Array
};
this.shades = function(kwArgs){
// summary
// generates n colors based on a base color using only changes
// in value. Similar to monochromatic but a bit more linear.
kwArgs=dojo.mixin({
num:32, // number of colors to derive
high:1.5, // high factor to generate tints and shades
low:0.5 // low factor to generate tints and shades
}, kwArgs||{});
var base=prep(kwArgs.base, "shades");
if(!base){ return []; }
 
var num=kwArgs.num, hsv=base.toHsv();
var step=(kwArgs.high-kwArgs.low)/num, cur=kwArgs.low;
var a=[];
for(var i=0; i<num; i++,cur+=step){
a.push(dxc.fromHsv({ h:hsv.h, s:hsv.s, v:Math.min(Math.round(hsv.v*cur),100) }));
}
 
console.log("generated color list from shades: ", a);
return a; // Array
};
})();
 
}
/trunk/api/js/dojo1.0/dojox/color/tests/Generator.js
New file
0,0 → 1,128
if(!dojo._hasResource["dojox.color.tests.Generator"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.color.tests.Generator"] = true;
dojo.provide("dojox.color.tests.Generator");
dojo.require("dojox.color.Generator");
 
tests.register("dojox.color.tests.Generator", [
function testAnalogous(t){
// test the defaults
var args={ base: new dojox.color.Color({ r:128, g:0, b:0 }) };
var a=dojox.color.Generator.analogous(args);
var s='<h3>dojox.color.Generator.analogous</h3><table cellpadding="0" cellspacing="1" border="0"><tr>';
var cols=5, c=0;
dojo.forEach(a, function(item){
if(c++%cols==0){ s+="</tr><tr>"; }
s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
});
if(c<cols){
for(; c<cols; c++){
s+='<td width="32">&nbsp;</td>';
}
}
t.debug(s+'</tr></table>');
},
 
function testMonochromatic(t){
// test the defaults
var a=dojox.color.Generator.monochromatic({ base:new dojox.color.Color({r:128, g:0, b:0}) });
var s='<h3>dojox.color.Generator.monochromatic</h3><table cellpadding="0" cellspacing="1" border="0"><tr>';
var cols=8, c=0;
dojo.forEach(a, function(item){
if(c++%cols==0){ s+="</tr><tr>"; }
s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
});
if(c<cols){
for(; c<cols; c++){
s+='<td width="32">&nbsp;</td>';
}
}
t.debug(s+'</tr></table>');
},
 
function testTriadic(t){
// test the defaults
var a=dojox.color.Generator.triadic({ base:new dojox.color.Color({r:128, g:0, b:0}) });
var s='<h3>dojox.color.Generator.triadic</h3><table cellpadding="0" cellspacing="1" border="0"><tr>';
var cols=3, c=0;
dojo.forEach(a, function(item){
if(c++%cols==0){ s+="</tr><tr>"; }
s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
});
if(c<cols){
for(; c<cols; c++){
s+='<td width="32">&nbsp;</td>';
}
}
t.debug(s+'</tr></table>');
},
 
function testComplementary(t){
// test the defaults
var a=dojox.color.Generator.complementary({ base:new dojox.color.Color({r:128, g:0, b:0}) });
var s='<h3>dojox.color.Generator.complementary</h3><table cellpadding="0" cellspacing="1" border="0"><tr>';
var cols=2, c=0;
dojo.forEach(a, function(item){
if(c++%cols==0){ s+="</tr><tr>"; }
s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
});
if(c<cols){
for(; c<cols; c++){
s+='<td width="32">&nbsp;</td>';
}
}
t.debug(s+'</tr></table>');
},
 
function testSplitComplementary(t){
// test the defaults
var a=dojox.color.Generator.splitComplementary({ base:new dojox.color.Color({r:128, g:0, b:0}) });
var s='<h3>dojox.color.Generator.splitComplementary</h3><table cellpadding="0" cellspacing="1" border="0"><tr>';
var cols=3, c=0;
dojo.forEach(a, function(item){
if(c++%cols==0){ s+="</tr><tr>"; }
s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
});
if(c<cols){
for(; c<cols; c++){
s+='<td width="32">&nbsp;</td>';
}
}
t.debug(s+'</tr></table>');
},
 
function testCompound(t){
// test the defaults
var a=dojox.color.Generator.compound({ base:new dojox.color.Color({r:128, g:0, b:0}) });
var s='<h3>dojox.color.Generator.compound</h3><table cellpadding="0" cellspacing="1" border="0"><tr>';
var cols=4, c=0;
dojo.forEach(a, function(item){
if(c++%cols==0){ s+="</tr><tr>"; }
s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
});
if(c<cols){
for(; c<cols; c++){
s+='<td width="32">&nbsp;</td>';
}
}
t.debug(s+'</tr></table>');
},
 
function testShades(t){
// test the defaults
var a=dojox.color.Generator.shades({ base:new dojox.color.Color({r:128, g:0, b:0}) });
var s='<table cellpadding="0" cellspacing="1" border="0"><tr>';
var cols=8, c=0;
dojo.forEach(a, function(item){
if(c++%cols==0){ s+="</tr><tr>"; }
s+='<td width="32" bgcolor="'+item.toHex()+'">&nbsp;</td>';
});
if(c<cols){
for(; c<cols; c++){
s+='<td width="32">&nbsp;</td>';
}
}
t.debug(s+'</tr></table>');
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/color/tests/_base.js
New file
0,0 → 1,82
if(!dojo._hasResource["dojox.color.tests._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.color.tests._base"] = true;
dojo.provide("dojox.color.tests._base");
dojo.require("dojox.color");
 
/************************************************************
* Note that some color translations are not exact,
* due to the need to round calculations in translation.
*
* These tests work with grey, the primary colors and
* one secondary color to ensure that extreme calculation
* is correct.
************************************************************/
 
tests.register("dojox.color.tests._base", [
function testStaticMethods(t){
// fromCmy
t.assertEqual(dojox.color.fromCmy({ c:50, m:50, y:50}), new dojo.Color({ r:128, g:128, b:128 }));
t.assertEqual(dojox.color.fromCmy({ c:0, m:100, y:100}), new dojo.Color({ r:255, g:0, b:0 }));
t.assertEqual(dojox.color.fromCmy({ c:100, m:0, y:100}), new dojo.Color({ r:0, g:255, b:0 }));
t.assertEqual(dojox.color.fromCmy({ c:100, m:100, y:0}), new dojo.Color({ r:0, g:0, b:255 }));
t.assertEqual(dojox.color.fromCmy({ c:0, m:0, y:100}), new dojo.Color({ r:255, g:255, b:0 }));
 
// fromCmyk
t.assertEqual(dojox.color.fromCmyk({ c:0, m:0, y:0, b:50}), new dojo.Color({ r:128, g:128, b:128 }));
t.assertEqual(dojox.color.fromCmyk({ c:0, m:100, y:100, b:0}), new dojo.Color({ r:255, g:0, b:0 }));
t.assertEqual(dojox.color.fromCmyk({ c:100, m:0, y:100, b:0}), new dojo.Color({ r:0, g:255, b:0 }));
t.assertEqual(dojox.color.fromCmyk({ c:100, m:100, y:0, b:0}), new dojo.Color({ r:0, g:0, b:255 }));
t.assertEqual(dojox.color.fromCmyk({ c:0, m:0, y:100, b:0}), new dojo.Color({ r:255, g:255, b:0 }));
 
// fromHsl
t.assertEqual(dojox.color.fromHsl({ h:0, s:0, l:50}), new dojo.Color({ r:128, g:128, b:128 }));
t.assertEqual(dojox.color.fromHsl({ h:0, s:100, l:50}), new dojo.Color({ r:255, g:0, b:0 }));
t.assertEqual(dojox.color.fromHsl({ h:120, s:100, l:50}), new dojo.Color({ r:0, g:255, b:0 }));
t.assertEqual(dojox.color.fromHsl({ h:240, s:100, l:50}), new dojo.Color({ r:0, g:0, b:255 }));
t.assertEqual(dojox.color.fromHsl({ h:60, s:100, l:50}), new dojo.Color({ r:255, g:255, b:0 }));
 
// fromHsv
t.assertEqual(dojox.color.fromHsv({ h:0, s:0, v:50}), new dojo.Color({ r:128, g:128, b:128 }));
t.assertEqual(dojox.color.fromHsv({ h:0, s:100, v:100}), new dojo.Color({ r:255, g:0, b:0 }));
t.assertEqual(dojox.color.fromHsv({ h:120, s:100, v:100}), new dojo.Color({ r:0, g:255, b:0 }));
t.assertEqual(dojox.color.fromHsv({ h:240, s:100, v:100}), new dojo.Color({ r:0, g:0, b:255 }));
t.assertEqual(dojox.color.fromHsv({ h:60, s:100, v:100}), new dojo.Color({ r:255, g:255, b:0 }));
},
function testColorExtensions(t){
var grey=new dojox.color.Color({ r:128, g:128, b:128 });
var red=new dojox.color.Color({ r:255, g:0, b:0 });
var green=new dojox.color.Color({ r:0, g:255, b:0 });
var blue=new dojox.color.Color({ r:0, g:0, b:255 });
var yellow=new dojox.color.Color({ r:255, g:255, b:0 });
 
// toCmy
t.assertEqual(grey.toCmy(), { c:50, m:50, y:50 });
t.assertEqual(red.toCmy(), { c:0, m:100, y:100 });
t.assertEqual(green.toCmy(), { c:100, m:0, y:100 });
t.assertEqual(blue.toCmy(), { c:100, m:100, y:0 });
t.assertEqual(yellow.toCmy(), { c:0, m:0, y:100 });
 
// toCmyk
t.assertEqual(grey.toCmyk(), { c:0, m:0, y:0, b:50 });
t.assertEqual(red.toCmyk(), { c:0, m:100, y:100, b:0 });
t.assertEqual(green.toCmyk(), { c:100, m:0, y:100, b:0 });
t.assertEqual(blue.toCmyk(), { c:100, m:100, y:0, b:0 });
t.assertEqual(yellow.toCmyk(), { c:0, m:0, y:100, b:0 });
 
// toHsl
t.assertEqual(grey.toHsl(), { h:0, s:0, l:50 });
t.assertEqual(red.toHsl(), { h:0, s:100, l:50 });
t.assertEqual(green.toHsl(), { h:120, s:100, l:50 });
t.assertEqual(blue.toHsl(), { h:240, s:100, l:50 });
t.assertEqual(yellow.toHsl(), { h:60, s:100, l:50 });
 
// toHsv
t.assertEqual(grey.toHsv(), { h:0, s:0, v:50 });
t.assertEqual(red.toHsv(), { h:0, s:100, v:100 });
t.assertEqual(green.toHsv(), { h:120, s:100, v:100 });
t.assertEqual(blue.toHsv(), { h:240, s:100, v:100 });
t.assertEqual(yellow.toHsv(), { h:60, s:100, v:100 });
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/color/tests/color.js
New file
0,0 → 1,14
if(!dojo._hasResource["dojox.color.tests.color"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.color.tests.color"] = true;
dojo.provide("dojox.color.tests.color");
dojo.require("dojox.color");
 
try{
dojo.require("dojox.color.tests._base");
// dojo.require("dojox.color.tests.Colorspace");
dojo.require("dojox.color.tests.Generator");
}catch(e){
doh.debug(e);
}
 
}
/trunk/api/js/dojo1.0/dojox/color/tests/runTests.html
New file
0,0 → 1,9
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dojox.wire Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.color.tests.color"></HEAD>
<BODY>
Redirecting to D.O.H runner.
</BODY>
</HTML>
/trunk/api/js/dojo1.0/dojox/color/_base.js
New file
0,0 → 1,197
if(!dojo._hasResource["dojox.color._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.color._base"] = true;
dojo.provide("dojox.color._base");
dojo.require("dojo.colors");
 
// alias all the dojo.Color mechanisms
dojox.color.Color=dojo.Color;
dojox.color.blend=dojo.blendColors;
dojox.color.fromRgb=dojo.colorFromRgb;
dojox.color.fromHex=dojo.colorFromHex;
dojox.color.fromArray=dojo.colorFromArray;
dojox.color.fromString=dojo.colorFromString;
 
// alias the dojo.colors mechanisms
dojox.color.greyscale=dojo.colors.makeGrey;
 
// static methods
dojo.mixin(dojox.color, {
fromCmy: function(/* Object|Array|int */cyan, /*int*/magenta, /*int*/yellow){
// summary
// Create a dojox.color.Color from a CMY defined color.
// All colors should be expressed as 0-100 (percentage)
 
if(dojo.isArray(cyan)){
magenta=cyan[1], yellow=cyan[2], cyan=cyan[0];
} else if(dojo.isObject(cyan)){
magenta=cyan.m, yellow=cyan.y, cyan=cyan.c;
}
cyan/=100, magenta/=100, yellow/=100;
 
var r=1-cyan, g=1-magenta, b=1-yellow;
return new dojox.color.Color({ r:Math.round(r*255), g:Math.round(g*255), b:Math.round(b*255) }); // dojox.color.Color
},
 
fromCmyk: function(/* Object|Array|int */cyan, /*int*/magenta, /*int*/yellow, /*int*/black){
// summary
// Create a dojox.color.Color from a CMYK defined color.
// All colors should be expressed as 0-100 (percentage)
 
if(dojo.isArray(cyan)){
magenta=cyan[1], yellow=cyan[2], black=cyan[3], cyan=cyan[0];
} else if(dojo.isObject(cyan)){
magenta=cyan.m, yellow=cyan.y, black=cyan.b, cyan=cyan.c;
}
cyan/=100, magenta/=100, yellow/=100, black/=100;
var r,g,b;
r = 1-Math.min(1, cyan*(1-black)+black);
g = 1-Math.min(1, magenta*(1-black)+black);
b = 1-Math.min(1, yellow*(1-black)+black);
return new dojox.color.Color({ r:Math.round(r*255), g:Math.round(g*255), b:Math.round(b*255) }); // dojox.color.Color
},
fromHsl: function(/* Object|Array|int */hue, /* int */saturation, /* int */luminosity){
// summary
// Create a dojox.color.Color from an HSL defined color.
// hue from 0-359 (degrees), saturation and luminosity 0-100.
 
if(dojo.isArray(hue)){
saturation=hue[1], luminosity=hue[2], hue=hue[0];
} else if(dojo.isObject(hue)){
saturation=hue.s, luminosity=hue.l, hue=hue.h;
}
saturation/=100;
luminosity/=100;
 
while(hue<0){ hue+=360; }
while(hue>=360){ hue-=360; }
var r, g, b;
if(hue<120){
r=(120-hue)/60, g=hue/60, b=0;
} else if (hue<240){
r=0, g=(240-hue)/60, b=(hue-120)/60;
} else {
r=(hue-240)/60, g=0, b=(360-hue)/60;
}
r=2*saturation*Math.min(r, 1)+(1-saturation);
g=2*saturation*Math.min(g, 1)+(1-saturation);
b=2*saturation*Math.min(b, 1)+(1-saturation);
if(luminosity<0.5){
r*=luminosity, g*=luminosity, b*=luminosity;
}else{
r=(1-luminosity)*r+2*luminosity-1;
g=(1-luminosity)*g+2*luminosity-1;
b=(1-luminosity)*b+2*luminosity-1;
}
return new dojox.color.Color({ r:Math.round(r*255), g:Math.round(g*255), b:Math.round(b*255) }); // dojox.color.Color
},
fromHsv: function(/* Object|Array|int */hue, /* int */saturation, /* int */value){
// summary
// Create a dojox.color.Color from an HSV defined color.
// hue from 0-359 (degrees), saturation and value 0-100.
 
if(dojo.isArray(hue)){
saturation=hue[1], value=hue[2], hue=hue[0];
} else if (dojo.isObject(hue)){
saturation=hue.s, value=hue.v, hue=hue.h;
}
if(hue==360){ hue=0; }
saturation/=100;
value/=100;
var r, g, b;
if(saturation==0){
r=value, b=value, g=value;
}else{
var hTemp=hue/60, i=Math.floor(hTemp), f=hTemp-i;
var p=value*(1-saturation);
var q=value*(1-(saturation*f));
var t=value*(1-(saturation*(1-f)));
switch(i){
case 0:{ r=value, g=t, b=p; break; }
case 1:{ r=q, g=value, b=p; break; }
case 2:{ r=p, g=value, b=t; break; }
case 3:{ r=p, g=q, b=value; break; }
case 4:{ r=t, g=p, b=value; break; }
case 5:{ r=value, g=p, b=q; break; }
}
}
return new dojox.color.Color({ r:Math.round(r*255), g:Math.round(g*255), b:Math.round(b*255) }); // dojox.color.Color
}
});
 
// Conversions directly on dojox.color.Color
dojo.extend(dojox.color.Color, {
toCmy: function(){
// summary
// Convert this Color to a CMY definition.
var cyan=1-(this.r/255), magenta=1-(this.g/255), yellow=1-(this.b/255);
return { c:Math.round(cyan*100), m:Math.round(magenta*100), y:Math.round(yellow*100) }; // Object
},
toCmyk: function(){
// summary
// Convert this Color to a CMYK definition.
var cyan, magenta, yellow, black;
var r=this.r/255, g=this.g/255, b=this.b/255;
black = Math.min(1-r, 1-g, 1-b);
cyan = (1-r-black)/(1-black);
magenta = (1-g-black)/(1-black);
yellow = (1-b-black)/(1-black);
return { c:Math.round(cyan*100), m:Math.round(magenta*100), y:Math.round(yellow*100), b:Math.round(black*100) }; // Object
},
toHsl: function(){
// summary
// Convert this Color to an HSL definition.
var r=this.r/255, g=this.g/255, b=this.b/255;
var min = Math.min(r, b, g), max = Math.max(r, g, b);
var delta = max-min;
var h=0, s=0, l=(min+max)/2;
if(l>0 && l<1){
s = delta/((l<0.5)?(2*l):(2-2*l));
}
if(delta>0){
if(max==r && max!=g){
h+=(g-b)/delta;
}
if(max==g && max!=b){
h+=(2+(b-r)/delta);
}
if(max==b && max!=r){
h+=(4+(r-g)/delta);
}
h*=60;
}
return { h:h, s:Math.round(s*100), l:Math.round(l*100) }; // Object
},
 
toHsv: function(){
// summary
// Convert this Color to an HSV definition.
var r=this.r/255, g=this.g/255, b=this.b/255;
var min = Math.min(r, b, g), max = Math.max(r, g, b);
var delta = max-min;
var h = null, s = (max==0)?0:(delta/max);
if(s==0){
h = 0;
}else{
if(r==max){
h = 60*(g-b)/delta;
}else if(g==max){
h = 120 + 60*(b-r)/delta;
}else{
h = 240 + 60*(r-g)/delta;
}
 
if(h<0){ h+=360; }
}
return { h:h, s:Math.round(s*100), v:Math.round(max*100) }; // Object
}
});
 
}
/trunk/api/js/dojo1.0/dojox/color/Colorspace.js
New file
0,0 → 1,556
if(!dojo._hasResource["dojox.color.Colorspace"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.color.Colorspace"] = true;
dojo.provide("dojox.color.Colorspace");
dojo.require("dojox.math.matrix");
 
dojox.color.Colorspace=new (function(){
var dxc=dojox.color;
var dxm=dojox.math.matrix;
var self=this;
var wpMap={
"2":{
"E": { x:1/3, y:1/3, t:5400 },
"D50": { x:0.34567, y:0.3585, t:5000 },
"D55": { x:0.33242, y:0.34743, t:5500 },
"D65": { x:0.31271, y:0.32902, t:6500 },
"D75": { x:0.29902, y:0.31485, t:7500 },
"A": { x:0.44757, y:0.40745, t:2856 },
"B": { x:0.34842, y:0.35161, t:4874 },
"C": { x:0.31006, y:0.31616, t:6774 },
"9300": { x:0.2848, y:0.2932, t:9300 },
"F2": { x:0.37207, y:0.37512, t:4200 },
"F7": { x:0.31285, y:0.32918, t:6500 },
"F11": { x:0.38054, y:0.37691, t:4000 }
},
"10":{
"E": { x:1/3, y:1/3, t:5400 },
"D50": { x:0.34773, y:0.35952, t:5000 },
"D55": { x:0.33411, y:0.34877, t:5500 },
"D65": { x:0.31382, y:0.331, t:6500 },
"D75": { x:0.29968, y:0.3174, t:7500 },
"A": { x:0.45117, y:0.40594, t:2856 },
"B": { x:0.3498, y:0.3527, t:4874 },
"C": { x:0.31039, y:0.31905, t:6774 },
"F2": { x:0.37928, y:0.36723, t:4200 },
"F7": { x:0.31565, y:0.32951, t:6500 },
"F11": { x:0.38543, y:0.3711, t:4000 }
}
};
 
var profiles={
"Adobe RGB 98":[2.2, "D65", 0.64, 0.33, 0.297361, 0.21, 0.71, 0.627355, 0.15, 0.06, 0.075285],
"Apple RGB":[1.8, "D65", 0.625, 0.34, 0.244634, 0.28, 0.595, 0.672034, 0.155, 0.07, 0.083332],
"Best RGB":[2.2, "D50", 0.7347, 0.2653, 0.228457, 0.215, 0.775, 0.737352, 0.13, 0.035, 0.034191],
"Beta RGB":[2.2, "D50", 0.6888, 0.3112, 0.303273, 0.1986, 0.7551, 0.663786, 0.1265, 0.0352, 0.032941],
"Bruce RGB":[2.2, "D65", 0.64, 0.33, 0.240995, 0.28, 0.65, 0.683554, 0.15, 0.06, 0.075452],
"CIE RGB":[2.2, "E", 0.735, 0.265, 0.176204, 0.274, 0.717, 0.812985, 0.167, 0.009, 0.010811],
"ColorMatch RGB":[1.8, "D50", 0.63, 0.34, 0.274884, 0.295, 0.605, 0.658132, 0.15, 0.075, 0.066985],
"DON RGB 4":[2.2, "D50", 0.696, 0.3, 0.27835, 0.215, 0.765, 0.68797, 0.13, 0.035, 0.03368],
"ECI RGB":[1.8, "D50", 0.67, 0.33, 0.32025, 0.21, 0.71, 0.602071, 0.14, 0.08, 0.077679],
"EktaSpace PS5":[2.2, "D50", 0.695, 0.305, 0.260629, 0.26, 0.7, 0.734946, 0.11, 0.005, 0.004425],
"NTSC RGB":[2.2, "C", 0.67, 0.33, 0.298839, 0.21, 0.71, 0.586811, 0.14, 0.08, 0.11435],
"PAL/SECAM RGB":[2.2, "D65", 0.64, 0.33, 0.222021, 0.29, 0.6, 0.706645, 0.15, 0.06, 0.071334],
"Pro Photo RGB":[1.8, "D50", 0.7347, 0.2653, 0.28804, 0.1596, 0.8404, 0.711874, 0.0366, 0.0001, 0.000086],
"SMPTE/C RGB":[2.2, "D65", 0.63, 0.34, 0.212395, 0.31, 0.595, 0.701049, 0.155, 0.07, 0.086556],
"sRGB":[2.2, "D65", 0.64, 0.33, 0.212656, 0.3, 0.6, 0.715158, 0.15, 0.06, 0.072186],
"Wide Gamut RGB":[2.2, "D50", 0.735, 0.265, 0.258187, 0.115, 0.826, 0.724938, 0.157, 0.018, 0.016875]
};
 
var adaptors={
"XYZ scaling":{
ma: [[1,0,0], [0,1,0], [0,0,1]],
mai: [[1,0,0], [0,1,0], [0,0,1]]
},
"Bradford":{
ma: [[0.8951, -0.7502, 0.0389], [0.2664, 1.7135, -0.0685], [-0.1614, 0.0367, 1.0296]],
mai: [[0.986993, 0.432305, -0.008529], [-0.147054, 0.51836, 0.040043], [0.159963, 0.049291, 0.968487]]
},
"Von Kries":{
ma: [[0.40024, -0.2263, 0], [0.7076, 1.16532, 0], [-0.08081, 0.0457, 0.91822]],
mai: [[1.859936, 0.361191, 0], [-1.129382, 0.638812, 0], [0.219897, -0.000006, 1.089064]]
}
};
 
var cMaps={
"XYZ":{
"xyY":function(xyz, kwArgs){
kwArgs=dojo.mixin({
whitepoint:"D65",
observer:"10",
useApproximation:true
}, kwArgs||{});
var wp=self.whitepoint(kwArgs.whitepoint, kwArgs.observer);
var sum=xyz.X+xyz.Y+xyz.Z;
if(sum==0){ var x=wp.x, y=wp.y; }
else{ var x=xyz.X/sum, y=xyz.Y/sum; }
return { x:x, y:y, Y:xyz.Y };
},
"Lab":function(xyz, kwArgs){
kwArgs=dojo.mixin({
whitepoint:"D65",
observer:"10",
useApproximation:true
}, kwArgs||{});
 
var kappa=self.kappa(kwArgs.useApproximation), epsilon=self.epsilon(kwArgs.useApproximation);
var wp=self.whitepoint(kwArgs.whitepoint, kwArgs.observer);
var xr=xyz.X/wp.x, yr=xyz.Y/wp.y, zr=xyz.z/wp.z;
var fx=(xr>epsilon)?Math.pow(xr,1/3):(kappa*xr+16)/116;
var fy=(yr>epsilon)?Math.pow(yr,1/3):(kappa*yr+16)/116;
var fz=(zr>epsilon)?Math.pow(zr,1/3):(kappa*zr+16)/116;
var L=116*fy-16, a=500*(fx-fy), b=200*(fy-fz);
return { L:L, a:a, b:b };
},
"Luv": function(xyz, kwArgs){
kwArgs=dojo.mixin({
whitepoint:"D65",
observer:"10",
useApproximation:true
}, kwArgs||{});
 
var kappa=self.kappa(kwArgs.useApproximation), epsilon=self.epsilon(kwArgs.useApproximation);
var wp=self.whitepoint(kwArgs.whitepoint, kwArgs.observer);
var ud=(4*xyz.X)/(xyz.X+15*xyz.Y+3*xyz.Z);
var vd=(9*xyz.Y)/(xyz.X+15*xyz.Y+3*xyz.Z);
var udr=(4*wp.x)/(wp.x+15*wp.y+3*wp.z);
var vdr=(9*wp.y)/(wp.x+15*wp.y+3*wp.z);
var yr=xyz.Y/wp.y;
var L=(yr>epsilon)?116*Math.pow(yr, 1/3)-16:kappa*yr;
var u=13*L*(ud-udr);
var v=13*L*(vd-vdr);
return { L:L, u:u, v:v };
}
},
"xyY":{
"XYZ":function(xyY){
if(xyY.y==0){ var X=0, Y=0, Z=0; }
else{
var X=(xyY.x*xyY.Y)/xyY.y;
var Y=xyY.Y;
var Z=((1-xyY.x-xyY.y)*xyY.Y)/xyY.y;
}
return { X:X, Y:Y, Z:Z };
}
},
"Lab":{
"XYZ": function(lab, kwArgs){
kwArgs=dojo.mixin({
whitepoint:"D65",
observer:"10",
useApproximation:true
}, kwArgs||{});
 
var b=kwArgs.useApproximation, kappa=self.kappa(b), epsilon=self.epsilon(b);
var wp=self.whitepoint(kwArgs.whitepoint, kwArgs.observer);
var yr=(lab.L>(kappa*epsilon))?Math.pow((lab.L+16)/116, 3):lab.L/kappa;
var fy=(yr>epsilon)?(lab.L+16)/116:(kappa*yr+16)/116;
var fx=(lab.a/500)+fy;
var fz=fy-(lab.b/200);
var fxcube=Math.pow(fx, 3), fzcube=Math.pow(fz, 3);
var xr=(fxcube>epsilon)?fxcube:(116*fx-16)/kappa;
var zr=(fzcube>epsilon)?fzcube:(116*fz-16)/kappa;
return { X: xr*wp.x, Y: yr*wp.y, Z: zr*wp.z };
},
"LCHab": function(lab){
var L=lab.L, C=Math.pow(lab.a*lab.a+lab.b*lab.b, 0.5), H=Math.atan(lab.b, lab.a)*(180/Math.PI);
if(H<0){ H+=360; }
if(H<360){ H-=360; }
return { L:L, C:C, H:H };
}
},
"LCHab":{
"Lab":function(lch){
var hRad=lch.H*(Math.PI/180), L=lch.L, a=lch.C/Math.pow(Math.pow(Math.tan(hRad),2)+1, 0.5);
if(90<lchH && lch.H<270){ a = -a; }
var b=Math.pow(Math.pow(lch.C,2)-Math.pow(a, 2), 0.5);
if(lch.H>180){ b = -b; }
return { L: L, a:a, b:b };
}
},
"Luv":{
"XYZ": function(Luv, kwArgs){
kwArgs=dojo.mixin({
whitepoint:"D65",
observer:"10",
useApproximation:true
}, kwArgs||{});
 
var b=kwArgs.useApproximation, kappa=self.kappa(b), epsilon=self.epsilon(b);
var wp=self.whitepoint(kwArgs.whitepoint, kwArgs.observer);
var uz=(4*wp.x)/(wp.x+15*wp.y+3*wp.z);
var vz=(9*wp.y)/(wp.x+15*wp.y+3*wp.z);
var Y=(Luv.L>kappa*epsilon)?Math.pow((Luv.L+16)/116, 3):Luv.L/kappa;
var a=(1/3)*(((52*Luv.L)/(Luv.u+13*Luv.L*uz))-1);
var b=-5*Y, c=-(1/3), d=Y*(((39*Luv.L)/(Luv.v+13*Luv.L*vz))-5);
var X=(d-b)/(a-c), Z=X*a+b;
return { X:X, Y:Y, Z:Z };
},
"LCHuv": function(Luv){
var L=Luv.L, C=Math.pow(Luv.u*Luv.u+Luv.v*Luv*v, 0.5), H=Math.atan(Luv.v, Luv.u)*(180/Math.PI);
if(H<0){ H+=360; }
if(H>360){ H-=360; }
return { L:L, C:C, H:H };
}
},
"LCHuv":{
"Luv": function(LCH){
var hRad=LCH.H*(Math.PI/180);
var L=LCH.L, u=LCH.C/Math.pow(Math.pow(Math.tan(hRad),2)+1, 0.5);
var v=Math.pow(LCH.C*LCH.C-u*u, 0.5);
if(90<LCH.H && LCH.H>270){ u*=-1; }
if(LCH.H>180){ v*=-1; }
return { L:L, u:u, v:v };
}
}
};
var converters={
"CMY":{
"CMYK":function(obj, kwArgs){ return dxc.fromCmy(obj).toCmyk(); },
"HSL":function(obj, kwArgs){ return dxc.fromCmy(obj).toHsl(); },
"HSV":function(obj, kwArgs){ return dxc.fromCmy(obj).toHsv(); },
"Lab":function(obj, kwArgs){ return cMaps["XYZ"]["Lab"](dxc.fromCmy(obj).toXYZ(kwArgs)); },
"LCHab":function(obj, kwArgs){ return cMaps["Lab"]["LCHab"](converters["CMY"]["Lab"](obj)); },
"LCHuv":function(obj, kwArgs){ return cMaps["LCHuv"]["Luv"](cMaps["Luv"]["XYZ"](dxc.fromCmy(obj).toXYZ(kwArgs))); },
"Luv":function(obj, kwArgs){ return cMaps["Luv"]["XYZ"](dxc.fromCmy(obj).toXYZ(kwArgs)); },
"RGB":function(obj, kwArgs){ return dxc.fromCmy(obj); },
"XYZ":function(obj, kwArgs){ return dxc.fromCmy(obj).toXYZ(kwArgs); },
"xyY":function(obj, kwArgs){ return cMaps["XYZ"]["xyY"](dxc.fromCmy(obj).toXYZ(kwArgs)); }
},
"CMYK":{
"CMY":function(obj, kwArgs){ return dxc.fromCmyk(obj).toCmy(); },
"HSL":function(obj, kwArgs){ return dxc.fromCmyk(obj).toHsl(); },
"HSV":function(obj, kwArgs){ return dxc.fromCmyk(obj).toHsv(); },
"Lab":function(obj, kwArgs){ return cMaps["XYZ"]["Lab"](dxc.fromCmyk(obj).toXYZ(kwArgs)); },
"LCHab":function(obj, kwArgs){ return cMaps["Lab"]["LCHab"](converters["CMYK"]["Lab"](obj)); },
"LCHuv":function(obj, kwArgs){ return cMaps["LCHuv"]["Luv"](cMaps["Luv"]["XYZ"](dxc.fromCmyk(obj).toXYZ(kwArgs))); },
"Luv":function(obj, kwArgs){ return cMaps["Luv"]["XYZ"](dxc.fromCmyk(obj).toXYZ(kwArgs)); },
"RGB":function(obj, kwArgs){ return dxc.fromCmyk(obj); },
"XYZ":function(obj, kwArgs){ return dxc.fromCmyk(obj).toXYZ(kwArgs); },
"xyY":function(obj, kwArgs){ return cMaps["XYZ"]["xyY"](dxc.fromCmyk(obj).toXYZ(kwArgs)); }
},
"HSL":{
"CMY":function(obj, kwArgs){ return dxc.fromHsl(obj).toCmy(); },
"CMYK":function(obj, kwArgs){ return dxc.fromHsl(obj).toCmyk(); },
"HSV":function(obj, kwArgs){ return dxc.fromHsl(obj).toHsv(); },
"Lab":function(obj, kwArgs){ return cMaps["XYZ"]["Lab"](dxc.fromHsl(obj).toXYZ(kwArgs)); },
"LCHab":function(obj, kwArgs){ return cMaps["Lab"]["LCHab"](converters["CMYK"]["Lab"](obj)); },
"LCHuv":function(obj, kwArgs){ return cMaps["LCHuv"]["Luv"](cMaps["Luv"]["XYZ"](dxc.fromHsl(obj).toXYZ(kwArgs))); },
"Luv":function(obj, kwArgs){ return cMaps["Luv"]["XYZ"](dxc.fromHsl(obj).toXYZ(kwArgs)); },
"RGB":function(obj, kwArgs){ return dxc.fromHsl(obj); },
"XYZ":function(obj, kwArgs){ return dxc.fromHsl(obj).toXYZ(kwArgs); },
"xyY":function(obj, kwArgs){ return cMaps["XYZ"]["xyY"](dxc.fromHsl(obj).toXYZ(kwArgs)); }
},
"HSV":{
"CMY":function(obj, kwArgs){ return dxc.fromHsv(obj).toCmy(); },
"CMYK":function(obj, kwArgs){ return dxc.fromHsv(obj).toCmyk(); },
"HSL":function(obj, kwArgs){ return dxc.fromHsv(obj).toHsl(); },
"Lab":function(obj, kwArgs){ return cMaps["XYZ"]["Lab"](dxc.fromHsv(obj).toXYZ(kwArgs)); },
"LCHab":function(obj, kwArgs){ return cMaps["Lab"]["LCHab"](converters["CMYK"]["Lab"](obj)); },
"LCHuv":function(obj, kwArgs){ return cMaps["LCHuv"]["Luv"](cMaps["Luv"]["XYZ"](dxc.fromHsv(obj).toXYZ(kwArgs))); },
"Luv":function(obj, kwArgs){ return cMaps["Luv"]["XYZ"](dxc.fromHsv(obj).toXYZ(kwArgs)); },
"RGB":function(obj, kwArgs){ return dxc.fromHsv(obj); },
"XYZ":function(obj, kwArgs){ return dxc.fromHsv(obj).toXYZ(kwArgs); },
"xyY":function(obj, kwArgs){ return cMaps["XYZ"]["xyY"](dxc.fromHsv(obj).toXYZ(kwArgs)); }
},
"Lab":{
"CMY":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Lab"]["XYZ"](obj, kwArgs)).toCmy(); },
"CMYK":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Lab"]["XYZ"](obj, kwArgs)).toCmyk(); },
"HSL":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Lab"]["XYZ"](obj, kwArgs)).toHsl(); },
"HSV":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Lab"]["XYZ"](obj, kwArgs)).toHsv(); },
"LCHab":function(obj, kwArgs){ return cMaps["Lab"]["LCHab"](obj, kwArgs); },
"LCHuv":function(obj, kwArgs){ return cMaps["Luv"]["LCHuv"](cMaps["Lab"]["XYZ"](obj, kwArgs), kwArgs); },
"Luv":function(obj, kwArgs){ return cMaps["XYZ"]["Luv"](cMaps["Lab"]["XYZ"](obj, kwArgs), kwArgs); },
"RGB":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Lab"]["XYZ"](obj, kwArgs)); },
"XYZ":function(obj, kwArgs){ return cMaps["Lab"]["XYZ"](obj, kwArgs); },
"xyY":function(obj, kwArgs){ return cMaps["XYZ"]["xyY"](cMaps["Lab"]["XYZ"](obj, kwArgs), kwArgs); }
},
"LCHab":{
"CMY":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Lab"]["XYZ"](cMaps["LCHab"]["Lab"](obj), kwArgs), kwArgs).toCmy(); },
"CMYK":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Lab"]["XYZ"](cMaps["LCHab"]["Lab"](obj), kwArgs), kwArgs).toCmyk(); },
"HSL":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Lab"]["XYZ"](cMaps["LCHab"]["Lab"](obj), kwArgs), kwArgs).toHsl(); },
"HSV":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Lab"]["XYZ"](cMaps["LCHab"]["Lab"](obj), kwArgs), kwArgs).toHsv(); },
"Lab":function(obj, kwArgs){ return cMaps["Lab"]["LCHab"](obj, kwArgs); },
"LCHuv":function(obj, kwArgs){ return cMaps["Luv"]["LCHuv"](cMaps["XYZ"]["Luv"](cMaps["Lab"]["XYZ"](cMaps["LCHab"]["Lab"](obj), kwArgs), kwArgs), kwArgs);},
"Luv":function(obj, kwArgs){ return cMaps["XYZ"]["Luv"](cMaps["Lab"]["XYZ"](cMaps["LCHab"]["Lab"](obj), kwArgs), kwArgs);},
"RGB":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Lab"]["XYZ"](cMaps["LCHab"]["Lab"](obj), kwArgs), kwArgs); },
"XYZ":function(obj, kwArgs){ return cMaps["Lab"]["XYZ"](cMaps["LCHab"]["Lab"](obj, kwArgs), kwArgs); },
"xyY":function(obj, kwArgs){ return cMaps["XYZ"]["xyY"](cMaps["Lab"]["XYZ"](cMaps["LCHab"]["Lab"](obj), kwArgs), kwArgs); }
},
"LCHuv":{
"CMY":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Luv"]["XYZ"](cMaps["LCHuv"]["Luv"](obj), kwArgs), kwArgs).toCmy(); },
"CMYK":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Luv"]["XYZ"](cMaps["LCHuv"]["Luv"](obj), kwArgs), kwArgs).toCmyk(); },
"HSL":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Luv"]["XYZ"](cMaps["LCHuv"]["Luv"](obj), kwArgs), kwArgs).toHsl(); },
"HSV":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Luv"]["XYZ"](cMaps["LCHuv"]["Luv"](obj), kwArgs), kwArgs).toHsv(); },
"Lab":function(obj, kwArgs){ return cMaps["XYZ"]["Lab"](cMaps["Luv"]["XYZ"](cMaps["LCHuv"]["Luv"](obj), kwArgs), kwArgs); },
"LCHab":function(obj, kwArgs){ return cMaps["Lab"]["LCHab"](cMaps["XYZ"]["Lab"](cMaps["Luv"]["XYZ"](cMaps["LCHuv"]["Luv"](obj), kwArgs), kwArgs), kwArgs); },
"Luv":function(obj, kwArgs){ return cMaps["LCHuv"]["Luv"](obj, kwArgs); },
"RGB":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Luv"]["XYZ"](cMaps["LCHuv"]["Luv"](obj), kwArgs), kwArgs); },
"XYZ":function(obj, kwArgs){ return cMaps["Luv"]["XYZ"](cMaps["LCHuv"]["Luv"](obj), kwArgs); },
"xyY":function(obj, kwArgs){ return cMaps["XYZ"]["xyY"](cMaps["Luv"]["XYZ"](cMaps["LCHuv"]["Luv"](obj), kwArgs), kwArgs); },
},
"Luv":{
"CMY":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Luv"]["XYZ"](obj, kwArgs), kwArgs).toCmy(); },
"CMYK":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Luv"]["XYZ"](obj, kwArgs), kwArgs).toCmyk(); },
"HSL":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Luv"]["XYZ"](obj, kwArgs), kwArgs).toHsl(); },
"HSV":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Luv"]["XYZ"](obj, kwArgs), kwArgs).toHsv(); },
"Lab":function(obj, kwArgs){ return cMaps["XYZ"]["Lab"](cMaps["Luv"]["XYZ"](obj, kwArgs), kwArgs); },
"LCHab":function(obj, kwArgs){ return cMaps["Lab"]["LCHab"](cMaps["XYZ"]["Lab"](cMaps["Luv"]["XYZ"](obj, kwArgs), kwArgs), kwArgs); },
"LCHuv":function(obj, kwArgs){ return cMaps["Luv"]["LCHuv"](obj, kwArgs); },
"RGB":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["Luv"]["XYZ"](obj, kwArgs), kwArgs); },
"XYZ":function(obj, kwArgs){ return cMaps["Luv"]["XYZ"](obj, kwArgs); },
"xyY":function(obj, kwArgs){ return cMaps["XYZ"]["xyY"](cMaps["Luv"]["XYZ"](obj, kwArgs), kwArgs); },
},
"RGB":{
"CMY":function(obj, kwArgs){ return obj.toCmy(); },
"CMYK":function(obj, kwArgs){ return obj.toCmyk(); },
"HSL":function(obj, kwArgs){ return obj.toHsl(); },
"HSV":function(obj, kwArgs){ return obj.toHsv(); },
"Lab":function(obj, kwArgs){ return cMaps["XYZ"]["Lab"](obj.toXYZ(kwArgs), kwArgs); },
"LCHab":function(obj, kwArgs){ return cMaps["LCHab"]["Lab"](cMaps["XYZ"]["Lab"](obj.toXYZ(kwArgs), kwArgs), kwArgs);},
"LCHuv":function(obj, kwArgs){ return cMaps["LCHuv"]["Luv"](cMaps["XYZ"]["Luv"](obj.toXYZ(kwArgs), kwArgs), kwArgs);},
"Luv":function(obj, kwArgs){ return cMaps["XYZ"]["Luv"](obj.toXYZ(kwArgs), kwArgs); },
"XYZ":function(obj, kwArgs){ return obj.toXYZ(kwArgs); },
"xyY":function(obj, kwArgs){ return cMaps["XYZ"]["xyY"](obj.toXYZ(kwArgs), kwArgs); }
},
"XYZ":{
"CMY":function(obj, kwArgs){ return dxc.fromXYZ(obj, kwArgs).toCmy(); },
"CMYK":function(obj, kwArgs){ return dxc.fromXYZ(obj, kwArgs).toCmyk(); },
"HSL":function(obj, kwArgs){ return dxc.fromXYZ(obj, kwArgs).toHsl(); },
"HSV":function(obj, kwArgs){ return dxc.fromXYZ(obj, kwArgs).toHsv(); },
"Lab":function(obj, kwArgs){ return cMaps["XYZ"]["Lab"](obj, kwArgs); },
"LCHab":function(obj, kwArgs){ return cMaps["Lab"]["LCHab"](cMaps["XYZ"]["Lab"](obj, kwArgs), kwArgs); },
"LCHuv":function(obj, kwArgs){ return cMaps["Luv"]["LCHuv"](cMaps["XYZ"]["Luv"](obj, kwArgs), kwArgs); },
"Luv":function(obj, kwArgs){ return cMaps["XYZ"]["Luv"](obj, kwArgs); },
"RGB":function(obj, kwArgs){ return dxc.fromXYZ(obj, kwArgs); },
"xyY":function(obj, kwArgs){ return cMaps["XYZ"]["xyY"](dxc.fromXYZ(obj, kwArgs), kwArgs); }
},
// TODO: revisit this. xyY represents a single color, not a spectrum of colors.
"xyY":{
"CMY":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["xyY"]["XYZ"](obj, kwArgs), kwArgs).toCmy(); },
"CMYK":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["xyY"]["XYZ"](obj, kwArgs), kwArgs).toCmyk(); },
"HSL":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["xyY"]["XYZ"](obj, kwArgs), kwArgs).toHsl(); },
"HSV":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["xyY"]["XYZ"](obj, kwArgs), kwArgs).toHsv(); },
"Lab":function(obj, kwArgs){ return cMaps["Lab"]["XYZ"](cMaps["xyY"]["XYZ"](obj, kwArgs), kwArgs); },
"LCHab":function(obj, kwArgs){ return cMaps["LCHab"]["Lab"](cMaps["Lab"]["XYZ"](cMaps["xyY"]["XYZ"](obj, kwArgs), kwArgs), kwArgs); },
"LCHuv":function(obj, kwArgs){ return cMaps["LCHuv"]["Luv"](cMaps["Luv"]["XYZ"](cMaps["xyY"]["XYZ"](obj, kwArgs), kwArgs), kwArgs); },
"Luv":function(obj, kwArgs){ return cMaps["Luv"]["XYZ"](cMaps["xyY"]["XYZ"](obj, kwArgs), kwArgs); },
"RGB":function(obj, kwArgs){ return dxc.fromXYZ(cMaps["xyY"]["XYZ"](obj, kwArgs), kwArgs); },
"XYZ":function(obj, kwArgs){ return cMaps["xyY"]["XYZ"](obj, kwArgs); }
}
};
 
this.whitepoint=function(/* String */wpName, /* String? */observer){
observer=observer||"10";
var x=0, y=0, t=0;
if(wpMap[observer] && wpMap[observer][wpName]){
x=wpMap[observer][wpName].x;
y=wpMap[observer][wpName].y;
t=wpMap[observer][wpName].t;
} else {
console.warn(
"dojox.color.Colorspace::whitepoint: either the observer or the whitepoint name was not found. ",
observer, wpName
);
}
var wp={ x:x, y:y, z:(1-x-y), t:t, Y:1 };
return this.convert(wp, "xyY", "XYZ");
};
 
this.tempToWhitepoint=function(/* Number */t){
if(t<4000){
console.warn("dojox.color.Colorspace::tempToWhitepoint: can't find a white point for temperatures less than 4000K. (Passed ", t, ").");
return { x:0, y:0 };
}
if(t>25000){
console.warn("dojox.color.Colorspace::tempToWhitepoint: can't find a white point for temperatures greater than 25000K. (Passed ", t, ").");
return { x:0, y:0 };
}
var t1=t, t2=t*t, t3=t2*t;
var ten9=Math.pow(10, 9), ten6=Math.pow(10, 6), ten3=Math.pow(10,3);
if(t<=7000){
var x=(-4.607*ten9/t3)+(2.9678*ten6/t2)+(0.09911*ten3/t)+0.2444063;
} else {
var x=(-2.0064*ten9/t3)+(1.9018*ten6/t2)+(0.24748*ten3/t)+0.23704;
}
var y=-3*x*x+2.87*x-0.275;
return { x:x, y:y };
};
 
this.primaries=function(/* Object */kwArgs){
// mix in the defaults.
kwArgs=dojo.mixin({
profile:"sRGB",
whitepoint:"D65",
observer:"10",
adaptor:"Bradford"
}, kwArgs||{});
 
var m=[];
if(profiles[kwArgs.profile]){
m=profiles[kwArgs.profile].slice(0);
} else {
console.warn(
"dojox.color.Colorspace::primaries: the passed profile was not found. ",
"Available profiles include: ", profiles,
". The profile passed was ", kwArgs.profile
);
}
var primary={
name:kwArgs.profile,
gamma:m[0], whitepoint:m[1],
xr:m[2], yr:m[3], Yr:m[4],
xg:m[5], yg:m[6], Yg:m[7],
xb:m[8], yb:m[9], Yb:m[10]
};
// convert for the whitepoint
if(kwArgs.whitepoint!=primary.whitepoint){
var r=this.convert(
this.adapt({
color:this.convert({ x:xr, y:yr, Y:Yr }, "xyY", "XYZ"),
adaptor:kwArgs.adaptor,
source:primary.whitepoint,
destination:kwArgs.whitepoint
}),
"XYZ",
"xyY"
);
var g=this.convert(
this.adapt({
color:this.convert({ x:xg, y:yg, Y:Yg }, "xyY", "XYZ"),
adaptor:kwArgs.adaptor,
source:primary.whitepoint,
destination:kwArgs.whitepoint
}),
"XYZ",
"xyY"
);
var b=this.convert(
this.adapt({
color:this.convert({ x:xb, y:yb, Y:Yb }, "xyY", "XYZ"),
adaptor:kwArgs.adaptor,
source:primary.whitepoint,
destination:kwArgs.whitepoint
}),
"XYZ",
"xyY"
);
primary=dojo.mixin(primary, {
xr: r.x, yr: r.y, Yr: r.Y,
xg: g.x, yg: g.y, Yg: g.Y,
xb: b.x, yb: b.y, Yb: b.Y,
whitepoint: kwArgs.whitepoint
});
}
return dojo.mixin(primary, {
zr: 1-primary.xr-primary.yr,
zg: 1-primary.xg-primary.yg,
zb: 1-primary.xb-primary.yb
}); // Object
};
 
this.adapt=function(/* Object */kwArgs){
// color is required in the form of XYZ, source whitepoint name is required.
if(!kwArgs.color || !kwArgs.source){
console.error("dojox.color.Colorspace::adapt: color and source arguments are required. ", kwArgs);
}
 
// defaults
kwArgs=dojo.mixin({
adaptor:"Bradford",
destination:"D65"
}, kwArgs);
 
// adapt
var swp = this.whitepoint(kwArgs.source);
var dwp = this.whitepoint(kwArgs.destination);
if(adaptors[kwArgs.adaptor]){
var ma=adaptors[kwArgs.adaptor].ma;
var mai=adaptors[kwArgs.adaptor].mai;
}else{
console.warn("dojox.color.Colorspace::adapt: the passed adaptor '", kwArgs.adaptor, "' was not found.");
}
var dSrc=dxm.multiply([[swp.x, swp.y, swp.z]], ma);
var dDest=dxm.multiply([[dwp.x, dwp.y, dwp.z]], ma);
var center=[
[dDest[0][0]/dSrc[0][0], 0, 0],
[0, dDest[0][1]/dSrc[0][1], 0],
[0, 0, dDest[0][2]/dSrc[0][2]]
];
var m=dxm.multiply(dxm.multiply(ma, center), mai);
var r=dxm.multiply([[ kwArgs.color.X, kwArgs.color.Y, kwArgs.color.Z ]], m)[0];
return { X:r[0], Y:r[1], Z:r[2] };
};
 
this.matrix=function(/* String */to, /* Object */primary){
var wp=this.whitepoint(primary.whitepoint);
var Xr = p.xr/p.yr, Yr = 1, Zr = (1-p.xr-p.yr)/p.yr;
var Xg = p.xg/p.yg, Yg = 1, Zg = (1-p.xg-p.yg)/p.yg;
var Xb = p.xb/p.yb, Yb = 1, Zr = (1-p.xb-p.yb)/p.yb;
 
var m1 = [[ Xr, Yr, Zr ], [ Xg, Yg, Zg ], [ Xb, Yb, Zb ]];
var m2 = [[ wp.X, wp.Y, wp.Z ]];
var sm = dojox.math.matrix.multiply(m2, dojox.math.matrix.inverse(m1));
var Sr = sm[0][0], Sg = sm[0][1], Sb = sm[0][2];
var result=[
[Sr*Xr, Sr*Yr, Sr*Zr],
[Sg*Xg, Sg*Yg, Sg*Zg],
[Sb*Xb, Sb*Yb, Sb*Zb]
];
if(to=="RGB"){ return dojox.math.inverse(result); }
return result;
};
 
this.epsilon=function(/* bool? */useApprox){
return (useApprox || typeof(useApprox)=="undefined")? 0.008856: 216/24289;
};
this.kappa=function(/* bool? */useApprox){
return (useApprox || typeof(useApprox)=="undefined")? 903.3: 24389/27;
};
 
this.convert=function(/* Object */color, /* string */from, /* string */to, /* Object? */kwArgs){
if(converters[from] && converters[from][to]){
return converters[from][to](obj, kwArgs);
}
console.warn("dojox.color.Colorspace::convert: Can't convert ", color, " from ", from, " to ", to, ".");
};
})();
 
// More dojox.color and dojox.color.Color extensions
dojo.mixin(dojox.color, {
fromXYZ: function(/* Object */xyz, /* Object?*/kwArgs){
kwArgs=kwArgs||{};
var p=dojox.color.Colorspace.primaries(kwArgs);
var m=dojox.color.Colorspace.matrix("RGB", p);
var rgb=dojox.math.matrix.mutliply([[ xyz.X, xyz.Y, xyz.Z ]], m);
var r=rgb[0][0], g=rgb[0][1], b=rgb[0][2];
if(p.profile=="sRGB"){
var R = (r>0.0031308)?(1.055*Math.pow(r, 1/2.4))-0.055: 12.92*r;
var G = (g>0.0031308)?(1.055*Math.pow(g, 1/2.4))-0.055: 12.92*g;
var B = (b>0.0031308)?(1.055*Math.pow(b, 1/2.4))-0.055: 12.92*b;
}else{
var R=Math.pow(r, 1/p.gamma), G=Math.pow(g, 1/p.gamma), B=Math.pow(b, 1/p.gamma);
}
return new dojox.color.Color({ r:Math.floor(R*255), g:Math.floor(G*255), b:Math.floor(B*255) });
}
});
 
dojo.extend(dojox.color.Color, {
toXYZ: function(/* Object */kwArgs){
kwArgs=kwArgs||{};
var p=dojox.color.Colorspace.primaries(kwArgs);
var m=dojox.color.Colorspace.matrix("XYZ", p);
var _r=this.r/255, _g=this.g/255, _b=this.b/255;
if(p.profile=="sRGB"){
var r=(_r>0.04045) ? Math.pow(((_r+0.055)/1.055), 2.4):_r/12.92;
var g=(_g>0.04045) ? Math.pow(((_g+0.055)/1.055), 2.4):_g/12.92;
var b=(_b>0.04045) ? Math.pow(((_b+0.055)/1.055), 2.4):_b/12.92;
} else {
var r=Math.pow(_r, p.gamma), g=Math.pow(_g, p.gamma), b=Math.pow(_b, p.gamma);
}
var xyz=dojox.math.matrix([[ r, g, b ]], m);
return { X: xyz[0][0], Y: xyz[0][1], Z: xyz[0][2] }; // Object
}
});
 
}
/trunk/api/js/dojo1.0/dojox/storage.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.storage"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.storage"] = true;
dojo.provide("dojox.storage");
dojo.require("dojox.storage._common");
 
}
/trunk/api/js/dojo1.0/dojox/uuid.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.uuid"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.uuid"] = true;
dojo.provide("dojox.uuid");
dojo.require("dojox.uuid._base");
 
}
/trunk/api/js/dojo1.0/dojox/LICENSE
New file
0,0 → 1,195
Dojo is availble under *either* the terms of the modified BSD license *or* the
Academic Free License version 2.1. As a recipient of Dojo, you may choose which
license to receive this code under (except as noted in per-module LICENSE
files). Some modules may not be the copyright of the Dojo Foundation. These
modules contain explicit declarations of copyright in both the LICENSE files in
the directories in which they reside and in the code itself. No external
contributions are allowed under licenses which are fundamentally incompatible
with the AFL or BSD licenses that Dojo is distributed under.
 
The text of the AFL and BSD licenses is reproduced below.
 
-------------------------------------------------------------------------------
The "New" BSD License:
**********************
 
Copyright (c) 2005-2007, The Dojo Foundation
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
 
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Dojo Foundation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-------------------------------------------------------------------------------
The Academic Free License, v. 2.1:
**********************************
 
This Academic Free License (the "License") applies to any original work of
authorship (the "Original Work") whose owner (the "Licensor") has placed the
following notice immediately following the copyright notice for the Original
Work:
 
Licensed under the Academic Free License version 2.1
 
1) Grant of Copyright License. Licensor hereby grants You a world-wide,
royalty-free, non-exclusive, perpetual, sublicenseable license to do the
following:
 
a) to reproduce the Original Work in copies;
 
b) to prepare derivative works ("Derivative Works") based upon the Original
Work;
 
c) to distribute copies of the Original Work and Derivative Works to the
public;
 
d) to perform the Original Work publicly; and
 
e) to display the Original Work publicly.
 
2) Grant of Patent License. Licensor hereby grants You a world-wide,
royalty-free, non-exclusive, perpetual, sublicenseable license, under patent
claims owned or controlled by the Licensor that are embodied in the Original
Work as furnished by the Licensor, to make, use, sell and offer for sale the
Original Work and Derivative Works.
 
3) Grant of Source Code License. The term "Source Code" means the preferred
form of the Original Work for making modifications to it and all available
documentation describing how to modify the Original Work. Licensor hereby
agrees to provide a machine-readable copy of the Source Code of the Original
Work along with each copy of the Original Work that Licensor distributes.
Licensor reserves the right to satisfy this obligation by placing a
machine-readable copy of the Source Code in an information repository
reasonably calculated to permit inexpensive and convenient access by You for as
long as Licensor continues to distribute the Original Work, and by publishing
the address of that information repository in a notice immediately following
the copyright notice that applies to the Original Work.
 
4) Exclusions From License Grant. Neither the names of Licensor, nor the names
of any contributors to the Original Work, nor any of their trademarks or
service marks, may be used to endorse or promote products derived from this
Original Work without express prior written permission of the Licensor. Nothing
in this License shall be deemed to grant any rights to trademarks, copyrights,
patents, trade secrets or any other intellectual property of Licensor except as
expressly stated herein. No patent license is granted to make, use, sell or
offer to sell embodiments of any patent claims other than the licensed claims
defined in Section 2. No right is granted to the trademarks of Licensor even if
such marks are included in the Original Work. Nothing in this License shall be
interpreted to prohibit Licensor from licensing under different terms from this
License any Original Work that Licensor otherwise would have a right to
license.
 
5) This section intentionally omitted.
 
6) Attribution Rights. You must retain, in the Source Code of any Derivative
Works that You create, all copyright, patent or trademark notices from the
Source Code of the Original Work, as well as any notices of licensing and any
descriptive text identified therein as an "Attribution Notice." You must cause
the Source Code for any Derivative Works that You create to carry a prominent
Attribution Notice reasonably calculated to inform recipients that You have
modified the Original Work.
 
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that
the copyright in and to the Original Work and the patent rights granted herein
by Licensor are owned by the Licensor or are sublicensed to You under the terms
of this License with the permission of the contributor(s) of those copyrights
and patent rights. Except as expressly stated in the immediately proceeding
sentence, the Original Work is provided under this License on an "AS IS" BASIS
and WITHOUT WARRANTY, either express or implied, including, without limitation,
the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU.
This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No
license to Original Work is granted hereunder except under this disclaimer.
 
8) Limitation of Liability. Under no circumstances and under no legal theory,
whether in tort (including negligence), contract, or otherwise, shall the
Licensor be liable to any person for any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License
or the use of the Original Work including, without limitation, damages for loss
of goodwill, work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses. This limitation of liability shall not
apply to liability for death or personal injury resulting from Licensor's
negligence to the extent applicable law prohibits such limitation. Some
jurisdictions do not allow the exclusion or limitation of incidental or
consequential damages, so this exclusion and limitation may not apply to You.
 
9) Acceptance and Termination. If You distribute copies of the Original Work or
a Derivative Work, You must make a reasonable effort under the circumstances to
obtain the express assent of recipients to the terms of this License. Nothing
else but this License (or another written agreement between Licensor and You)
grants You permission to create Derivative Works based upon the Original Work
or to exercise any of the rights granted in Section 1 herein, and any attempt
to do so except under the terms of this License (or another written agreement
between Licensor and You) is expressly prohibited by U.S. copyright law, the
equivalent laws of other countries, and by international treaty. Therefore, by
exercising any of the rights granted to You in Section 1 herein, You indicate
Your acceptance of this License and all of its terms and conditions.
 
10) Termination for Patent Action. This License shall terminate automatically
and You may no longer exercise any of the rights granted to You by this License
as of the date You commence an action, including a cross-claim or counterclaim,
against Licensor or any licensee alleging that the Original Work infringes a
patent. This termination provision shall not apply for an action alleging
patent infringement by combinations of the Original Work with other software or
hardware.
 
11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this
License may be brought only in the courts of a jurisdiction wherein the
Licensor resides or in which Licensor conducts its primary business, and under
the laws of that jurisdiction excluding its conflict-of-law provisions. The
application of the United Nations Convention on Contracts for the International
Sale of Goods is expressly excluded. Any use of the Original Work outside the
scope of this License or after its termination shall be subject to the
requirements and penalties of the U.S. Copyright Act, 17 U.S.C. § 101 et
seq., the equivalent laws of other countries, and international treaty. This
section shall survive the termination of this License.
 
12) Attorneys Fees. In any action to enforce the terms of this License or
seeking damages relating thereto, the prevailing party shall be entitled to
recover its costs and expenses, including, without limitation, reasonable
attorneys' fees and costs incurred in connection with such action, including
any appeal of such action. This section shall survive the termination of this
License.
 
13) Miscellaneous. This License represents the complete agreement concerning
the subject matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent necessary to
make it enforceable.
 
14) Definition of "You" in This License. "You" throughout this License, whether
in upper or lower case, means an individual or a legal entity exercising rights
under, and complying with all of the terms of, this License. For legal
entities, "You" includes any entity that controls, is controlled by, or is
under common control with you. For purposes of this definition, "control" means
(i) the power, direct or indirect, to cause the direction or management of such
entity, whether by contract or otherwise, or (ii) ownership of fifty percent
(50%) or more of the outstanding shares, or (iii) beneficial ownership of such
entity.
 
15) Right to Use. You may use the Original Work in all ways not otherwise
restricted or conditioned by this License or by law, and Licensor promises not
to interfere with or be responsible for such uses by You.
 
This license is Copyright (C) 2003-2004 Lawrence E. Rosen. All rights reserved.
Permission is hereby granted to copy and distribute this license without
modification. This license may not be modified without the express written
permission of its copyright owner.
/trunk/api/js/dojo1.0/dojox/widget/ColorPicker.js
New file
0,0 → 1,284
if(!dojo._hasResource["dojox.widget.ColorPicker"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.widget.ColorPicker"] = true;
dojo.provide("dojox.widget.ColorPicker");
dojo.experimental("dojox.widget.ColorPicker"); // level: prototype
 
dojo.require("dijit.form._FormWidget");
dojo.require("dojo.dnd.move");
dojo.require("dojo.fx");
 
dojo.declare("dojox.widget.ColorPicker",
dijit.form._FormWidget,
{
// summary: a HSV color picker - like PhotoShop
//
// description:
// provides an interactive HSV ColorPicker similar to
// PhotoShop's color selction tool. Will eventually
// mixin FormWidget and be used as a suplement or a
// 'more interactive' replacement for ColorPalette
//
// example:
//
// code:
// var picker = new dojox.widget.ColorPicker({
// // a couple of example toggles:
// animatePoint:false,
// showHsv: false,
// webSafe: false,
// showRgb: false
// });
//
// markup:
// <div dojoType="dojox.widget.ColorPicker"></div>
//
 
// showRgb: Boolean
// show/update RGB input nodes
showRgb: true,
// showHsv: Boolean
// show/update HSV input nodes
showHsv: true,
// showHex: Boolean
// show/update Hex value field
showHex: true,
 
// webSafe: Boolean
// deprecated? or just use a toggle to show/hide that node, too?
webSafe: true,
 
// animatePoint: Boolean
// toggle to use slideTo (true) or just place the cursor (false) on click
animatePoint: true,
 
// slideDuration: Integer
// time in ms picker node will slide to next location (non-dragging) when animatePoint=true
slideDuration: 250,
 
_underlay: dojo.moduleUrl("dojox.widget","ColorPicker/images/underlay.png"),
templateString:"<div class=\"dojoxColorPicker\">\n\t<div class=\"dojoxColorPickerBox\">\n\t\t<div dojoAttachPoint=\"cursorNode\" class=\"dojoxColorPickerPoint\"></div>\n\t\t<img dojoAttachPoint=\"colorUnderlay\" dojoAttachEvent=\"onclick: _setPoint\" class=\"dojoxColorPickerUnderlay\" src=\"${_underlay}\">\n\t</div>\n\t<div class=\"dojoxHuePicker\">\n\t\t<div dojoAttachPoint=\"hueCursorNode\" class=\"dojoxHuePickerPoint\"></div>\n\t\t<div dojoAttachPoint=\"hueNode\" class=\"dojoxHuePickerUnderlay\" dojoAttachEvent=\"onclick: _setHuePoint\"></div>\n\t</div>\n\t<div dojoAttachPoint=\"previewNode\" class=\"dojoxColorPickerPreview\"></div>\n\t<div dojoAttachPoint=\"safePreviewNode\" class=\"dojoxColorPickerWebSafePreview\"></div>\n\t<div class=\"dojoxColorPickerOptional\">\n\t\t<div class=\"dijitInline dojoxColorPickerRgb\" dojoAttachPoint=\"rgbNode\">\n\t\t\t<table>\n\t\t\t<tr><td>r</td><td><input dojoAttachPoint=\"Rval\" size=\"1\"></td></tr>\n\t\t\t<tr><td>g</td><td><input dojoAttachPoint=\"Gval\" size=\"1\"></td></tr>\n\t\t\t<tr><td>b</td><td><input dojoAttachPoint=\"Bval\" size=\"1\"></td></tr>\n\t\t\t</table>\n\t\t</div>\n\t\t<div class=\"dijitInline dojoxColorPickerHsv\" dojoAttachPoint=\"hsvNode\">\n\t\t\t<table>\n\t\t\t<tr><td>h</td><td><input dojoAttachPoint=\"Hval\"size=\"1\"> &deg;</td></tr>\n\t\t\t<tr><td>s</td><td><input dojoAttachPoint=\"Sval\" size=\"1\"> %</td></tr>\n\t\t\t<tr><td>v</td><td><input dojoAttachPoint=\"Vval\" size=\"1\"> %</td></tr>\n\t\t\t</table>\n\t\t</div>\n\t\t<div class=\"dojoxColorPickerHex\" dojoAttachPoint=\"hexNode\">\t\n\t\t\thex: <input dojoAttachPoint=\"hexCode, focusNode\" size=\"6\" class=\"dojoxColorPickerHexCode\">\n\t\t</div>\n\t</div>\n</div>\n",
 
postCreate: function(){
// summary: As quickly as we can, set up ie6 alpha-filter support for our
// underlay. we don't do image handles (done in css), just the 'core'
// of this widget: the underlay.
if(dojo.isIE && dojo.isIE<7){
this.colorUnderlay.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this._underlay+"', sizingMethod='scale')";
this.colorUnderlay.src = dojo.moduleUrl("dojox.widget","FisheyeList/blank.gif").toString();
}
// hide toggle-able nodes:
if (!this.showRgb){ this.rgbNode.style.display = "none"; }
if (!this.showHsv){ this.hsvNode.style.display = "none"; }
if (!this.showHex){ this.hexNode.style.display = "none"; }
if (!this.webSafe){ this.safePreviewNode.style.display = "none"; }
},
 
startup: function(){
// summary: defer all additional calls until we're started, and our
// embeded sliders are loaded? (not implemented yet)
 
// this._offset = ((dojo.marginBox(this.cursorNode).w)/2);
this._offset = 0;
 
this._mover = new dojo.dnd.Moveable(this.cursorNode, {
mover: dojo.dnd.boxConstrainedMover({ t:0, l:0, w:150, h:150 })
});
this._hueMover = new dojo.dnd.Moveable(this.hueCursorNode, {
mover: dojo.dnd.boxConstrainedMover({ t:0, l:0, w:0, h:150 })
});
 
// no dnd/move/move published ... use a timer:
dojo.subscribe("/dnd/move/stop",dojo.hitch(this,"_clearTimer"));
dojo.subscribe("/dnd/move/start",dojo.hitch(this,"_setTimer"));
 
// ugly scaling calculator. need a XYslider badly
this._sc = (1/dojo.coords(this.colorUnderlay).w);
this._hueSc = (255/(dojo.coords(this.hueNode).h+this._offset));
// initial color
this._updateColor();
},
 
_setTimer: function(/* dojo.dnd.Mover */mover){
this._timer = setInterval(dojo.hitch(this,"_updateColor"),45);
},
_clearTimer: function(/* dojo.dnd.Mover */mover){
clearInterval(this._timer);
this.onChange(this.value);
},
 
_setHue: function(/* Decimal */h){
// summary: sets a natural color background for the
// underlay image against closest hue value (full saturation)
// h: 0..255
 
// this is not a pretty conversion:
var hue = dojo.colorFromArray(this._hsv2rgb(h,1,1,{ inputRange: 1 })).toHex();
dojo.style(this.colorUnderlay,"backgroundColor",hue);
},
 
_updateColor: function(){
// summary: update the previewNode color, and input values [optional]
var h = Math.round((255+(this._offset))-((dojo.style(this.hueCursorNode,"top")+this._offset)*this._hueSc));
var s = Math.round((dojo.style(this.cursorNode,"left")*this._sc)*100);
var v = Math.round(100-(dojo.style(this.cursorNode,"top")*this._sc)*100);
 
// limit hue calculations to only when it changes
if(h != this._hue){ this._setHue(h); }
 
var rgb = this._hsv2rgb(h,s/100,v/100,{ inputRange: 1 });
var hex = (dojo.colorFromArray(rgb).toHex());
 
this.previewNode.style.backgroundColor = hex;
if(this.webSafe){ this.safePreviewNode.style.backgroundColor = hex; }
if(this.showHex){ this.hexCode.value = hex; }
if(this.showRgb){
this.Rval.value = rgb[0];
this.Gval.value = rgb[1];
this.Bval.value = rgb[2];
}
if(this.showHsv){
this.Hval.value = Math.round((h*360)/255); // convert to 0..360
this.Sval.value = s;
this.Vval.value = v;
}
this.value=hex;
 
// anytime we muck with the color, fire onChange?
if (!this._timer && !(arguments[1])){
this.setValue(this.value);
this.onChange(this.value);
}
},
 
_setHuePoint: function(/* Event */evt){
// summary: set the hue picker handle on relative y coordinates
if(this.animatePoint){
dojo.fx.slideTo({
node: this.hueCursorNode,
duration:this.slideDuration,
top: evt.layerY,
left: 0,
onEnd: dojo.hitch(this,"_updateColor")
}).play();
}else{
dojo.style(this.hueCursorNode,"top",(evt.layerY)+"px");
this._updateColor(false);
}
},
 
_setPoint: function(/* Event */evt){
// summary: set our picker point based on relative x/y coordinates
if(this.animatePoint){
dojo.fx.slideTo({
node: this.cursorNode,
duration:this.slideDuration,
top: evt.layerY-this._offset,
left: evt.layerX-this._offset,
onEnd: dojo.hitch(this,"_updateColor")
}).play();
}else{
dojo.style(this.cursorNode,"left",(evt.layerX-this._offset)+"px");
dojo.style(this.cursorNode,"top",(evt.layerY-this._offset)+"px");
this._updateColor(false);
}
},
 
// this ported directly from 0.4 dojo.gfx.colors.hsv, with bugs :)
// FIXME: use ttrenka's HSB ?
_hsv2rgb: function(/* int || Array */h, /* int */s, /* int */v, /* Object? */options){
// summary
// converts an HSV value set to RGB, ranges depending on optional options object.
// patch for options by Matthew Eernisse
if (dojo.isArray(h)) {
if(s){
options = s;
}
v = h[2] || 0;
s = h[1] || 0;
h = h[0] || 0;
}
var opt = {
inputRange: (options && options.inputRange) ? options.inputRange : [255, 255, 255],
outputRange: (options && options.outputRange) ? options.outputRange : 255
};
switch(opt.inputRange[0]) {
// 0.0-1.0
case 1: h = h * 360; break;
// 0-100
case 100: h = (h / 100) * 360; break;
// 0-360
case 360: h = h; break;
// 0-255
default: h = (h / 255) * 360;
}
if (h == 360){ h = 0;}
// no need to alter if inputRange[1] = 1
switch(opt.inputRange[1]){
case 100: s /= 100; break;
case 255: s /= 255;
}
// no need to alter if inputRange[1] = 1
switch(opt.inputRange[2]){
case 100: v /= 100; break;
case 255: v /= 255;
}
var r = null;
var g = null;
var b = null;
if (s == 0){
// color is on black-and-white center line
// achromatic: shades of gray
r = v;
g = v;
b = v;
}else{
// chromatic color
var hTemp = h / 60; // h is now IN [0,6]
var i = Math.floor(hTemp); // largest integer <= h
var f = hTemp - i; // fractional part of h
var p = v * (1 - s);
var q = v * (1 - (s * f));
var t = v * (1 - (s * (1 - f)));
switch(i){
case 0: r = v; g = t; b = p; break;
case 1: r = q; g = v; b = p; break;
case 2: r = p; g = v; b = t; break;
case 3: r = p; g = q; b = v; break;
case 4: r = t; g = p; b = v; break;
case 5: r = v; g = p; b = q; break;
}
}
switch(opt.outputRange){
case 1:
r = dojo.math.round(r, 2);
g = dojo.math.round(g, 2);
b = dojo.math.round(b, 2);
break;
case 100:
r = Math.round(r * 100);
g = Math.round(g * 100);
b = Math.round(b * 100);
break;
default:
r = Math.round(r * 255);
g = Math.round(g * 255);
b = Math.round(b * 255);
}
return [r, g, b];
}
});
 
}
/trunk/api/js/dojo1.0/dojox/widget/FisheyeList/FisheyeList.css
New file
0,0 → 1,28
.dojoxFisheyeListItemLabel {
font-family: Arial, Helvetica, sans-serif;
background-color: #eee;
border: 2px solid #666;
padding: 2px;
text-align: center;
position: absolute;
display: none;
white-space:pre;
}
 
.dojoxFisheyeListItemLabel.dojoxFishSelected {
display: block;
}
 
.dojoxFisheyeListItemImage {
border: 0px;
position: absolute;
}
 
.dojoxFisheyeListItem {
position: absolute;
z-index: 2;
}
 
.dojoxFisheyeListBar {
position: relative;
}
/trunk/api/js/dojo1.0/dojox/widget/FisheyeList/blank.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/FisheyeList/blank.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/Toaster.js
New file
0,0 → 1,252
if(!dojo._hasResource["dojox.widget.Toaster"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.widget.Toaster"] = true;
dojo.provide("dojox.widget.Toaster");
 
dojo.require("dojo.fx");
 
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
 
// This is mostly taken from Jesse Kuhnert's MessageNotifier.
// Modified by Bryan Forbes to support topics and a variable delay.
// Modified by Karl Tiedt to support 0 duration messages that require user interaction and message stacking
 
dojo.declare("dojox.widget.Toaster", [dijit._Widget, dijit._Templated], {
// summary
// Message that slides in from the corner of the screen, used for notifications
// like "new email".
templateString: '<div dojoAttachPoint="clipNode"><div dojoAttachPoint="containerNode" dojoAttachEvent="onclick:onSelect"><div dojoAttachPoint="contentNode"></div></div></div>',
 
// messageTopic: String
// Name of topic; anything published to this topic will be displayed as a message.
// Message format is either String or an object like
// {message: "hello word", type: "error", duration: 500}
messageTopic: "",
 
_uniqueId: 0,
// messageTypes: Enumeration
// Possible message types.
messageTypes: {
MESSAGE: "message",
WARNING: "warning",
ERROR: "error",
FATAL: "fatal"
},
 
// defaultType: String
// If message type isn't specified (see "messageTopic" parameter),
// then display message as this type.
// Possible values in messageTypes enumeration ("message", "warning", "error", "fatal")
defaultType: "message",
 
// positionDirection: String
// Position from which message slides into screen, one of
// ["br-up", "br-left", "bl-up", "bl-right", "tr-down", "tr-left", "tl-down", "tl-right"]
positionDirection: "br-up",
// positionDirectionTypes: Array
// Possible values for positionDirection parameter
positionDirectionTypes: ["br-up", "br-left", "bl-up", "bl-right", "tr-down", "tr-left", "tl-down", "tl-right"],
 
// duration: Integer
// Number of milliseconds to show message
duration: "2000",
 
//separator: String
// String used to separate messages if consecutive calls are made to setContent before previous messages go away
separator: "<hr></hr>",
 
postCreate: function(){
dojox.widget.Toaster.superclass.postCreate.apply(this);
this.hide();
 
this.clipNode.className = "dijitToasterClip";
this.containerNode.className += " dijitToasterContainer";
this.contentNode.className = "dijitToasterContent";
if(this.messageTopic){
dojo.subscribe(this.messageTopic, this, "_handleMessage");
}
},
 
_handleMessage: function(/*String|Object*/message){
if(dojo.isString(message)){
this.setContent(message);
}else{
this.setContent(message.message, message.type, message.duration);
}
},
 
setContent: function(/*String*/message, /*String*/messageType, /*int?*/duration){
// summary
// sets and displays the given message and show duration
// message:
// the message
// messageType:
// type of message; possible values in messageTypes enumeration ("message", "warning", "error", "fatal")
// duration:
// duration in milliseconds to display message before removing it. Widget has default value.
duration = duration||this.duration;
// sync animations so there are no ghosted fades and such
if(this.slideAnim){
if(this.slideAnim.status() != "playing"){
this.slideAnim.stop();
}
if(this.slideAnim.status() == "playing" || (this.fadeAnim && this.fadeAnim.status() == "playing")){
setTimeout(dojo.hitch(this, function(){
this.setContent(message, messageType);
}), 50);
return;
}
}
 
var capitalize = function(word){
return word.substring(0,1).toUpperCase() + word.substring(1);
};
 
// determine type of content and apply appropriately
for(var type in this.messageTypes){
dojo.removeClass(this.containerNode, "dijitToaster" + capitalize(this.messageTypes[type]));
}
 
dojo.style(this.containerNode, "opacity", 1);
 
if(message && this.isVisible){
message = this.contentNode.innerHTML + this.separator + message;
}
this.contentNode.innerHTML = message;
 
dojo.addClass(this.containerNode, "dijitToaster" + capitalize(messageType || this.defaultType));
 
// now do funky animation of widget appearing from
// bottom right of page and up
this.show();
var nodeSize = dojo.marginBox(this.containerNode);
if(this.isVisible){
this._placeClip();
}else{
var style = this.containerNode.style;
var pd = this.positionDirection;
// sets up initial position of container node and slide-out direction
if(pd.indexOf("-up") >= 0){
style.left=0+"px";
style.top=nodeSize.h + 10 + "px";
}else if(pd.indexOf("-left") >= 0){
style.left=nodeSize.w + 10 +"px";
style.top=0+"px";
}else if(pd.indexOf("-right") >= 0){
style.left = 0 - nodeSize.w - 10 + "px";
style.top = 0+"px";
}else if(pd.indexOf("-down") >= 0){
style.left = 0+"px";
style.top = 0 - nodeSize.h - 10 + "px";
}else{
throw new Error(this.id + ".positionDirection is invalid: " + pd);
}
 
this.slideAnim = dojo.fx.slideTo({
node: this.containerNode,
top: 0, left: 0,
duration: 450});
dojo.connect(this.slideAnim, "onEnd", this, function(nodes, anim){
//we build the fadeAnim here so we dont have to duplicate it later
// can't do a fadeHide because we're fading the
// inner node rather than the clipping node
this.fadeAnim = dojo.fadeOut({
node: this.containerNode,
duration: 1000});
dojo.connect(this.fadeAnim, "onEnd", this, function(evt){
this.isVisible = false;
this.hide();
});
//if duration == 0 we keep the message displayed until clicked
//TODO: fix so that if a duration > 0 is displayed when a duration==0 is appended to it, the fadeOut is canceled
if(duration>0){
setTimeout(dojo.hitch(this, function(evt){
// we must hide the iframe in order to fade
// TODO: figure out how to fade with a BackgroundIframe
if(this.bgIframe && this.bgIframe.iframe){
this.bgIframe.iframe.style.display="none";
}
this.fadeAnim.play();
}), duration);
}else{
dojo.connect(this, 'onSelect', this, function(evt){
this.fadeAnim.play();
});
}
this.isVisible = true;
});
this.slideAnim.play();
}
},
 
_placeClip: function(){
var view = dijit.getViewport();
 
var nodeSize = dojo.marginBox(this.containerNode);
 
var style = this.clipNode.style;
// sets up the size of the clipping node
style.height = nodeSize.h+"px";
style.width = nodeSize.w+"px";
 
// sets up the position of the clipping node
var pd = this.positionDirection;
if(pd.match(/^t/)){
style.top = view.t+"px";
}else if(pd.match(/^b/)){
style.top = (view.h - nodeSize.h - 2 + view.t)+"px";
}
if(pd.match(/^[tb]r-/)){
style.left = (view.w - nodeSize.w - 1 - view.l)+"px";
}else if(pd.match(/^[tb]l-/)){
style.left = 0 + "px";
}
 
style.clip = "rect(0px, " + nodeSize.w + "px, " + nodeSize.h + "px, 0px)";
if(dojo.isIE){
if(!this.bgIframe){
this.clipNode.id = "__dojoXToaster_"+this._uniqueId++;
this.bgIframe = new dijit.BackgroundIframe(this.clipNode);
//TODO this.bgIframe.setZIndex(this.clipNode);
}
//TODO this.bgIframe.onResized();
var iframe = this.bgIframe.iframe;
iframe && (iframe.style.display="block");
}
},
 
onSelect: function(/*Event*/e){
// summary: callback for when user clicks the message
},
 
show: function(){
// summary: show the Toaster
dojo.style(this.containerNode, 'display', '');
 
this._placeClip();
 
if(!this._scrollConnected){
this._scrollConnected = dojo.connect(window, "onscroll", this, this._placeClip);
}
},
 
hide: function(){
// summary: hide the Toaster
 
//Q: ALP: I didn't port all the toggler stuff from d.w.HtmlWidget. Is it needed? Ditto for show.
dojo.style(this.containerNode, 'display', 'none');
 
if(this._scrollConnected){
dojo.disconnect(this._scrollConnected);
this._scrollConnected = false;
}
 
dojo.style(this.containerNode, "opacity", 1);
}
}
);
 
}
/trunk/api/js/dojo1.0/dojox/widget/README
New file
0,0 → 1,65
-------------------------------------------------------------------------------
dojox.widget Collection
-------------------------------------------------------------------------------
Version 1.0
Release date: 10/31/2007
-------------------------------------------------------------------------------
Project state:
expermental | beta
-------------------------------------------------------------------------------
Credits
Peter Higgins (dante)
Karl Tiedt (ktiedt@gmail.com)
-------------------------------------------------------------------------------
Project description
 
This is a collection of standalone widgets for use in
your website. Each individual widget is independant
of the others.
-------------------------------------------------------------------------------
Dependencies:
 
Each widget has it's own requirements and dependencies.
Most inherit from dijit base-classes such as dijit._Widget,
dijit._Templated, etc ... So we will assume the availablility
of dojo (core), and dijit packages.
-------------------------------------------------------------------------------
Documentation
 
Please refer to the API-tool, or in-line documentation.
-------------------------------------------------------------------------------
Installation instructions
 
These are standalone Widgets, so putting the [widget].js file
in your dojox/widget folder, and copying any files in the
/dojox/widget/[widget]/ folder as supplements/templates/etc
should be all you need to do.
 
eg: FisheyeList:
/dojox/widget/FisheyeList.js
/dojox/widget/FisheyeList/blank.gif
/dojox/widget/FisheyeList/FisheyeList.css
 
should be all you need to use the Fisheye widget.
you can safely import the whole widget project into your
dojox/ root directory from the following SVN url:
 
http://svn.dojotoolkit.org/dojo/dojox/widget
 
-------------------------------------------------------------------------------
Other Notes (Brief widget list):
 
* ColorPicker - Photoshop-like color picker
* FileInput - experimental dijit-like input type="file"
* FileInputAuto/Blind - extension to FileInput for
added flair/automation
* FisheyeList - the classic FishEye Picker
* Iterator - Basic array and datastore iterator class
* SortList - a degradable UL with a fixed header, scrolling,
and sorting. Can be the direct descendat of a
LayoutContainer and will size to fit.
* TimeSpinner - a number spinner that revolves through
time constrainsts
* Toaster - a messaging system to display non-obstrusive
alerts on screen.
/trunk/api/js/dojo1.0/dojox/widget/SortList.js
New file
0,0 → 1,153
if(!dojo._hasResource["dojox.widget.SortList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.widget.SortList"] = true;
dojo.provide("dojox.widget.SortList");
dojo.experimental("dojox.widget.SortList"); // level: prototype, designed for dijit.chat.demo
 
dojo.require("dijit.layout._LayoutWidget");
dojo.require("dijit._Templated");
 
dojo.declare("dojox.widget.SortList",
[dijit.layout._LayoutWidget, dijit._Templated],
{
// summary: a sortable <ul> with a fixed header for use in dijit.demos.chat
// for demonstration purposes only for now. feel free to make API suggestions
// or fixes.
//
// title: String
// the title in the header
title: "",
// heading: String
// in the event a parent container is expecting a title="" attribute, set it for the parent
// via title, and the title of this widget via heading="" ... assuming you want different
// titles for each. eg: TabContainer, AccordionContainer, etc.
heading: "",
 
// descending: Boolean
// toggle sort order based on this value.
descending: true,
 
// selected: Array
// a list of the selected <li> nodes at any given time.
selected: null,
 
 
// sortable: Boolean
// toggle to enable/disable sorting
sortable: true,
 
// FIXME: this is really simple store support
store: "",
key: "name",
 
templateString:"<div class=\"sortList\" id=\"${id}\">\n\t\t<div class=\"sortListTitle\" dojoAttachPoint=\"titleNode\">\n\t\t<div class=\"sortListIcon\"></div>\n\t\t<span dojoAttachPoint=\"focusNode\">${title}</span>\n\t\t</div>\n\t\t<div class=\"sortListBodyWrapper\" dojoAttachEvent=\"onmouseover: _set, onmouseout: _unset, onclick:_handleClick\" dojoAttachPoint=\"bodyWrapper\">\n\t\t<ul dojoAttachPoint=\"containerNode\" class=\"sortListBody\"></ul>\n\t</div>\n</div>\n",
 
_addItem: function(item){
var node = document.createElement("li");
var text = this.store.getValue(item,this.key);
node.innerHTML = text;
this.containerNode.appendChild(node);
},
 
postCreate: function(){
if (this.store){
// FIXME: is this right?
this.store = eval(this.store);
var props = {
onItem: dojo.hitch(this,"_addItem"),
onComplete: dojo.hitch(this,"onSort")
};
this.store.fetch(props);
}else{ this.onSort(); }
this.inherited("postCreate",arguments);
},
 
startup: function(){
this.inherited("startup",arguments);
if(this.heading){
this.setTitle(this.heading); this.title=this.heading;
}
// we cheat, and give the browser just enough time so we know our height
setTimeout(dojo.hitch(this,"resize"),5);
if (this.sortable){ this.connect(this.titleNode,"onclick", "onSort"); }
},
 
resize: function(){
// summary: do our additional calculations when resize() is called by or in a parent
this.inherited("resize",arguments);
// FIXME:
// the 10 comes from the difference between the contentBox and calculated height
// because of badding and border extents. this shouldn't be done this way, a theme change will
// break it: but we also don't want to run getComputedStyle or dojo.coords() every time resize()
// is fired.
var offset = ((this._contentBox.h) - (dojo.style(this.titleNode,"height")))-10;
this.bodyWrapper.style.height = Math.abs(offset) + "px";
},
onSort: function(/* Event */e){
// summary: sort the data, and style the nodes.
 
var arr = dojo.query("li",this.domNode);
if (this.sortable){
this.descending = !this.descending;
dojo.addClass(this.titleNode,((this.descending)?"sortListDesc":"sortListAsc"));
dojo.removeClass(this.titleNode,((this.descending)?"sortListAsc":"sortListDesc"));
arr.sort(this._sorter);
if(this.descending){ arr.reverse(); }
}
var i=0;
dojo.forEach(arr,function(item){
dojo[(((i++)%2)===0)?"addClass":"removeClass"](item,"sortListItemOdd");
this.containerNode.appendChild(item);
},this);
},
_set: function(/* Event */e){
// summary: set hover state
if (e.target != this.bodyWrapper){
dojo.addClass(e.target,"sortListItemHover");
}
},
 
_unset: function(/* Event */e){
// summary: remove hover state (FIXME: combine with _set?)
dojo.removeClass(e.target,"sortListItemHover");
},
 
_handleClick: function(/* Event */e){
// summary: click listener for data portion of widget. toggle selected state
// of node, and update this.selected array accordingly
dojo.toggleClass(e.target,"sortListItemSelected");
e.target.focus();
this._updateValues(e.target.innerHTML);
},
 
_updateValues: function(){
this._selected = dojo.query("li.sortListItemSelected",this.containerNode);
this.selected = [];
dojo.forEach(this._selected,function(node){
this.selected.push(node.innerHTML);
},this);
this.onChanged(arguments);
},
 
_sorter: function(a,b){
// summary: a basic sort function, use query sort, or keep this?
var aStr = a.innerHTML;
var bStr = b.innerHTML;
if(aStr>bStr){ return 1; }
if(aStr<bStr){ return -1; }
return 0;
},
 
setTitle: function(/* String */title){
// summary: Sets the widget title to a String
this.focusNode.innerHTML = title;
},
 
onChanged: function(){
// summary: stub function, passes the last changed item, and is fired after current state
}
});
 
}
/trunk/api/js/dojo1.0/dojox/widget/FileInput/FileInput.html
New file
0,0 → 1,9
<div class="dijitFileInput">
<input id="${id}" class="dijitFileInputReal" type="file" dojoAttachPoint="fileInput" name="${name}" />
<div class="dijitFakeInput">
<input class="dijitFileInputVisible" type="text" dojoAttachPoint="focusNode, inputNode" />
<span class="dijitFileInputText" dojoAttachPoint="titleNode">${label}</span>
<span class="dijitFileInputButton" dojoAttachPoint="cancelNode"
dojoAttachEvent="onclick:_onClick">${cancelText}</span>
</div>
</div>
/trunk/api/js/dojo1.0/dojox/widget/FileInput/FileInput.css
New file
0,0 → 1,83
.dijitFileInput {
position:relative;
height:1.3em;
padding:2px;
}
 
.dijitFileInputReal {
position:absolute;
z-index:2;
opacity:0;
filter:alpha(opacity:0);
}
.dijitFileInputRealBlind {
right:0;
}
.dijitFileInputReal:hover { cursor:pointer; }
 
.dijitFileInputButton,
.dijitFileInputText {
border:1px solid #333;
padding:2px 12px 2px 12px;
cursor:pointer;
 
}
.dijitFileInputButton {
opacity:0;
filter:alpha(opacity:0);
z-index:3;
visibility:hidden;
}
.dijitFakeInput { position:absolute; top:0; left:0; z-index:1; }
 
.dijitProgressOverlay {
display:none;
width:250px;
height:1em;
position:absolute;
top:0; left:0;
border:1px solid #333;
background:#cad2de url('../../../dijit/themes/tundra/images/dijitProgressBarAnim.gif') repeat-x top left;
padding:2px;
}
 
/* tundra */
.tundra .dijitProgressOverlay {
border:1px solid #84a3d1;
background-color:#cad2de;
}
.tundra .dijitFakeInput input {
font-size: inherit;
background:#fff url("../../../dijit/themes/tundra/images/validationInputBg.png") repeat-x top left;
border:1px solid #9b9b9b;
line-height: normal;
padding: 0.2em 0.3em;
}
.tundra .dijitFileInputButton,
.tundra .dijitFileInputText {
border:1px solid #9b9b9b;
padding:2px 12px 2px 12px; /* .3em .4em .2em .4em; */
background:#e9e9e9 url("../../../dijit/themes/tundra/images/buttonEnabled.png") repeat-x top;
}
 
/* Soria */
.soria .dijitProgressOverlay {
border:1px solid #333;
background-color:#cad2de;
}
 
.soria .dijitFakeInput input {
border:1px solid #333;
background:#fff url("../../../dijit/themes/soria/images/gradientInverseTopBg.png") repeat-x top left;
line-height:normal;
background-position:0 -30px;
padding:0.2em 0.3em;
}
.soria .dijitFileInputButton,
.soria .dijitFileInputText {
border:1px solid #333;
padding:2px 12px 2px 12px;
background:#b7cdee url('../../../dijit/themes/soria/images/gradientTopBg.png') repeat-x;
 
}
/trunk/api/js/dojo1.0/dojox/widget/FileInput/ReceiveFile.php
New file
0,0 → 1,29
<?php
 
// THIS IS AN EXAMPLE
// you will obviously need to do more server side work than I am doing here to check and move your upload.
// API is up for discussion, jump on http://dojotoolkit.org/forums
 
// JSON.php is available in dojo svn checkout
require("../../../dojo/tests/resources/JSON.php");
$json = new Services_JSON();
 
// fake delay
sleep(3);
$name = empty($_REQUEST['name'])? "default" : $_REQUEST['name'];
if(is_array($_FILES)){
$ar = array(
'status' => "success",
'details' => $_FILES[$name]
);
}else{
$ar = array(
'status' => "failed",
'details' => ""
);
}
 
// yeah, seems you have to wrap iframeIO stuff in textareas?
$foo = $json->encode($ar);
?>
<textarea><?php print $foo; ?></textarea>
/trunk/api/js/dojo1.0/dojox/widget/FileInput/FileInputAuto.html
New file
0,0 → 1,9
<div class="dijitFileInput">
<input class="dijitFileInputReal" type="file" dojoAttachPoint="fileInput" />
<div class="dijitFakeInput" dojoAttachPoint="fakeNodeHolder">
<input class="dijitFileInputVisible" type="text" dojoAttachPoint="focusNode, inputNode" />
<span class="dijitInline dijitFileInputText" dojoAttachPoint="titleNode">${label}</span>
<span class="dijitInline dijitFileInputButton" dojoAttachPoint="cancelNode" dojoAttachEvent="onclick:_onClick">${cancelText}</span>
</div>
<div class="dijitProgressOverlay" dojoAttachPoint="overlay">&nbsp;</div>
</div>
/trunk/api/js/dojo1.0/dojox/widget/tests/test_ColorPicker.html
New file
0,0 → 1,41
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Dojox ColorPicker Test</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../ColorPicker/ColorPicker.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script>
<script type="text/javascript" src="../ColorPicker.js"></script>
<script type="text/javascript">
// dojo.require("dojox.widget.ColorPicker");
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
 
</script>
</head>
<body class="tundra">
 
<h1 class="testTitle">Dojox ColorPicker test</h1>
 
<h3>defaults:</h3>
<div id="picker" dojoType="dojox.widget.ColorPicker"
onChange="console.log('new val:',this.value)"
></div>
 
<h3>no animation, no hsv, no rgb, no webSafe info:</h3>
<div id="pickerToo" dojoType="dojox.widget.ColorPicker"
animatePoint="false"
showHsv="false"
showRgb="false"
webSafe="false"
onChange="console.log('new val:',this.value)"
></div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/widget/tests/demo_FisheyeList.html
New file
0,0 → 1,111
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>FisheyeList Widget Demonstration</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../FisheyeList/FisheyeList.css";
.dojoxFisheyeListBar {
margin: 0 auto;
text-align: center;
}
 
.outerbar {
background-color: #666;
text-align: center;
position: absolute;
left: 0px;
top: 0px;
width: 100%;
border-bottom:2px solid #333;
}
body {
font-family: Arial, Helvetica, sans-serif;
padding: 0;
margin: 0;
background-color:#fff;
background-image:none;
}
.page {
padding: 50px 20px 20px 20px;
}
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.widget.FisheyeList");
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
 
function load_app(id){
alert('icon '+id+' was clicked');
}
 
</script>
</head>
<body class="tundra"><div class="outerbar">
<div dojoType="dojox.widget.FisheyeList"
itemWidth="50" itemHeight="50"
itemMaxWidth="200" itemMaxHeight="200"
orientation="horizontal"
effectUnits="2"
itemPadding="10"
attachEdge="top"
labelEdge="bottom"
id="fisheye1"
>
<div dojoType="dojox.widget.FisheyeListItem"
id="item1"
onclick="alert('click on ' + this.label + '(from widget id ' + this.widgetid + ')!');"
label="Item 1"
iconSrc="images/icon_browser.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
label="Item 2"
iconSrc="images/icon_calendar.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
label="Item 3"
onclick="alert('click on ' + this.label + '(from widget id ' + this.widgetid + ')!');"
iconSrc="images/icon_email.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
iconSrc="images/icon_texteditor.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
label="Really Long Item Label"
iconSrc="images/icon_update.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
iconSrc="images/icon_users.png">
</div>
</div></div>
 
<div class="page">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam facilisis enim. Pellentesque in elit et lacus euismod dignissim. Aliquam dolor pede, convallis eget, dictum a, blandit ac, urna. Pellentesque sed nunc ut justo volutpat egestas. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. In erat. Suspendisse potenti. Fusce faucibus nibh sed nisi. Phasellus faucibus, dui a cursus dapibus, mauris nulla euismod velit, a lobortis turpis arcu vel dui. Pellentesque fermentum ultrices pede. Donec auctor lectus eu arcu. Curabitur non orci eget est porta gravida. Aliquam pretium orci id nisi. Duis faucibus, mi non adipiscing venenatis, erat urna aliquet elit, eu fringilla lacus tellus quis erat. Nam tempus ornare lorem. Nullam feugiat.</p>
 
<p>Sed congue. Aenean blandit sollicitudin mi. Maecenas pellentesque. Vivamus ac urna. Nunc consequat nisi vitae quam. Suspendisse sed nunc. Proin suscipit porta magna. Duis accumsan nunc in velit. Nam et nibh. Nulla facilisi. Cras venenatis urna et magna. Aenean magna mauris, bibendum sit amet, semper quis, aliquet nec, sapien. Aliquam aliquam odio quis erat. Etiam est nisi, condimentum non, lacinia ac, vehicula laoreet, elit. Sed interdum augue sit amet quam dapibus semper. Nulla facilisi. Pellentesque lobortis erat nec quam.</p>
 
<p>Sed arcu magna, molestie at, fringilla in, sodales eu, elit. Curabitur mattis lorem et est. Quisque et tortor. Integer bibendum vulputate odio. Nam nec ipsum. Vestibulum mollis eros feugiat augue. Integer fermentum odio lobortis odio. Nullam mollis nisl non metus. Maecenas nec nunc eget pede ultrices blandit. Ut non purus ut elit convallis eleifend. Fusce tincidunt, justo quis tempus euismod, magna nulla viverra libero, sit amet lacinia odio diam id risus. Ut varius viverra turpis. Morbi urna elit, imperdiet eu, porta ac, pharetra sed, nisi. Etiam ante libero, ultrices ac, faucibus ac, cursus sodales, nisl. Praesent nisl sem, fermentum eu, consequat quis, varius interdum, nulla. Donec neque tortor, sollicitudin sed, consequat nec, facilisis sit amet, orci. Aenean ut eros sit amet ante pharetra interdum.</p>
 
<p>Fusce rutrum pede eget quam. Praesent purus. Aenean at elit in sem volutpat facilisis. Nunc est augue, commodo at, pretium a, fermentum at, quam. Nam sit amet enim. Suspendisse potenti. Cras hendrerit rhoncus justo. Integer libero. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam erat volutpat. Sed adipiscing mi vel ipsum.</p>
 
<p>Sed aliquam, quam consectetuer condimentum bibendum, neque libero commodo metus, non consectetuer magna risus vitae eros. Pellentesque mollis augue id libero. Morbi nonummy hendrerit dui. Morbi nisi felis, fringilla ac, euismod vitae, dictum mollis, pede. Integer suscipit, est sed posuere ullamcorper, ipsum lectus interdum nunc, quis blandit erat eros hendrerit pede. Vestibulum varius, elit id mattis mattis, nulla est feugiat ante, eget vestibulum augue eros ut odio. Maecenas euismod purus quis felis. Ut hendrerit tincidunt est. Fusce euismod, nunc eu tempus tempor, purus ligula volutpat tellus, nec lacinia sapien enim id risus. Aliquam orci turpis, condimentum sed, sollicitudin vel, placerat in, purus. Proin tortor nisl, blandit quis, imperdiet quis, scelerisque at, nisl. Maecenas suscipit fringilla erat. Curabitur consequat, dui blandit suscipit dictum, felis lectus imperdiet tellus, sit amet ornare risus mauris non ipsum. Fusce a purus. Vestibulum sodales. Sed porta ultrices nibh. Vestibulum metus.</p>
 
 
</div>
 
 
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/widget/tests/test_TimeSpinner.html
New file
0,0 → 1,87
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Dojo Spinner Widget Test</title>
 
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script>
 
<script type="text/javascript">
dojo.require("dojox.widget.TimeSpinner");
dojo.require("dojo.parser"); // scan page for widgets
 
function displayData() {
var spinner = dijit.byId("timeSpinner");
 
//accessing the widget property directly
console.log("TimeSpinner Value (raw, unserialized): ", spinner.getValue());
 
//accessing the widget from the form elements
var theForm = dojo.byId("form1");
var s = "";
for (var i=0; i<theForm.elements.length;i++){
var elem = theForm.elements[i];
if (!elem.name || elem.name =="button") { continue ; }
s+=elem.name + ": " + elem.value + "\n";
}
console.log(s);
}
 
</script>
<style type="text/css">
#integerspinner2 .dojoSpinnerUpArrow {
border-bottom-color: blue;
}
#integerspinner2 .dojoSpinnerDownArrow {
border-top-color: red;
}
#integerspinner2 .dojoSpinnerButton {
background-color: yellow;
}
#integerspinner2 .dojoSpinnerButtonPushed {
background-color: gray;
}
#integerspinner2 .dojoSpinnerButtonPushed .dojoSpinnerDownArrow {
border-top-color: blue;
}
#integerspinner2 .dojoSpinnerButtonPushed .dojoSpinnerUpArrow {
border-bottom-color: red;
}
 
.dojoInputFieldValidationNormal#integerspinner2 {
color:blue;
background-color:pink;
}
</style>
</head>
 
<body class="tundra">
<h1 class="testTitle">Dojox TimeSpinner Test</h1>
Try typing values, and use the up/down arrow keys and/or the arrow push
buttons to spin
<br>
<form id="form1" action="" name="example" method="post">
<h1>time spinner</h1>
<br>
<input id="timeSpinner" dojoType="dojox.widget.TimeSpinner"
onChange="console.debug('onChange fired for widget id = ' + this.id + ' with value = ' + arguments[0]);"
value="12:30 PM"
name="timeSpinner"
hours="12"
id="timeSpinner" />
</form>
 
<div>
<button name="button" onclick="displayData(); return false;">view data</button>
</div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/widget/tests/test_FileInput.html
New file
0,0 → 1,116
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.widget.FileInput | The Dojo Toolkit</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../FileInput/FileInput.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script>
<script type="text/javascript" src="../FileInput.js"></script>
<script type="text/javascript" src="../FileInputAuto.js"></script>
<script type="text/javascript">
// dojo.require("dojox.widget.FileInput");
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
var sampleCallback = function(data,ioArgs,widget){
// this function is fired for every programatic FileUploadAuto
// when the upload is complete. It uses dojo.io.iframe, which
// expects the results to come wrapped in TEXTAREA tags.
// this is IMPORTANT. to utilize FileUploadAuto (or Blind)
// you have to pass your respose data in a TEXTAREA tag.
// in our sample file (if you have php5 installed and have
// file uploads enabled) it _should_ return some text in the
// form of valid JSON data, like:
// { status: "success", details: { size: "1024" } }
// you can do whatever.
//
// the ioArgs is the standard ioArgs ref found in all dojo.xhr* methods.
//
// widget is a reference to the calling widget. you can manipulate the widget
// from within this callback function
if(data){
var d = dojo.fromJson(data);
if(d.status && d.status == "success"){
widget.overlay.innerHTML = "success!";
}else{
widget.overlay.innerHTML = "error? ";
console.log(data,ioArgs);
}
}else{
// debug assist
console.log(arguments);
}
}
 
var i = 0;
function addNewUpload(){
var node = document.createElement('input');
dojo.byId('dynamic').appendChild(node);
var widget = new dojox.widget.FileInputAuto({
id: "dynamic"+(++i),
url: "../FileInput/ReceiveFile.php",
//url:"http://archive.dojotoolkit.org/nightly/checkout/dojox/widget/FileInput/ReceiveFile.php",
name: "dynamic"+i,
onComplete: sampleCallback
},node);
widget.startup();
}
 
</script>
</head>
<body>
 
<h1 class="testTitle">dojox FileInput widget:</h1>
<p>This is a prototype of a dojo input type="file" with a FormWidget mixin, to be styled to match tundra and soria themes</p>
<p>The API is up for discussion, nor is it known to drop into forms and "just work" yet</p>
<p>FileInputAuto API is up for discussion, as well, though by use of the url="" attrib, you can basically
do all your file-processing server side, and just use the filename sent that remains in the form input</p>
<p>There are two parts. dojo.require("dojox.widget.FileInput") for just the base class, or dojo.require("dojox.widget.FileInputAuto");
to provide the Auto Uploading widget (on blur), and the Blind Auto Upload widget.</p>
<p>Both themes are defined in the FileInput.css file, as well as basic styling needed to run</p>
 
<h3>A standard file input:</h3>
<input type="file" id="normal" name="inputFile" />
 
<h3>The default dojox.widget.FileInput:</h3>
<p>
<input dojoType="dojox.widget.FileInput" id="default" name="inputFile" />
</p>
 
<h3>default dojox.widget.FileInput, tundra:</h3>
<p class="tundra">
<input dojoType="dojox.widget.FileInput" id="default2" name="inputFile" />
</p>
 
<h3>dojox.widget.FileInputAuto, soria theme:</h3>
<p class="soria">
<input dojoType="dojox.widget.FileInputAuto" id="defaultAuto" name="inputFileAuto" url="../FileInput/ReceiveFile.php" />
</p>
 
<h3>another one, tundra theme (with callback)</h3>
<p class="tundra">
<input dojoType="dojox.widget.FileInputAuto" id="defaultAuto2" name="inputFileAuto2" url="../FileInput/ReceiveFile.php" onComplete="sampleCallback"/>
</p>
 
<h3>a blind auto upload widget, tundra:</h3>
<p class="tundra">
<input dojoType="dojox.widget.FileInputBlind" id="blind1" name="blind1" url="../FileInput/ReceiveFile.php" />
</p>
 
<h3>dojox.widget.FileInputBlind - soria</h3>
<p class="soria">
<input dojoType="dojox.widget.FileInputBlind" id="blind2" name="blind2" url="../FileInput/ReceiveFile.php" />
</p>
 
<h3>dynamic, tundra, dojox.widget.FileInputAuto:</h3>
<button onclick="addNewUpload()">add new file upload</button>
<br><br>
<div id="dynamic" class="tundra"></div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/widget/tests/test_Toaster.html
New file
0,0 → 1,147
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Toaster Widget Dojo Tests</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../Toaster/Toaster.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.widget.Toaster");
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
 
var toast = null;
function showTestMessage(){
dojo.publish("testMessageTopic",
[ "This is a message! It's kind of long to show message wrapping."]
);
}
function showAnotherMessage(){
dojo.publish("testMessageTopic",
[{
message: "This is another message!",
type: "warning",
duration: 500
}]
);
}
function showYetAnotherMessage(){
dojo.publish("testMessageTopic",
[{ message: "This is yet another message!" }]
);
}
 
dojo.addOnLoad(function(){
toast = dijit.byId("toast");
});
</script>
</head>
<body class="tundra">
<div dojoType="dojox.widget.Toaster" id="toast"
positionDirection="br-left" duration="0"
messageTopic="testMessageTopic"></div>
 
<div dojoType="dojox.widget.Toaster" id="toast2"
separator="&lt;hr&gt;" positionDirection="bl-up"
messageTopic="testMessageTopic"></div>
 
<button type="submit"
onclick="showTestMessage();">Click to show message</button>
<button type="submit"
onclick="showAnotherMessage();">Click to show another message</button>
<button type="submit"
onclick="showYetAnotherMessage();">Click to show yet another message</button>
 
<h1>dojox.widget.Toaster test</h1>
 
<div style="color: #FF0000;">
When you click any of the buttons above, the bottom right hand message will
stay on the screen until you acknowledge it by clicking inside the message
box. If you click one of the message buttons while a message is still
displayed in the bottom right corner it should append the new message below
the old one with a separator between them.
</div>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper
sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum
lacus. Etiam consequat scelerisque quam. Nulla facilisi. Maecenas luctus
venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie
tortor at ipsum. Morbi dictum rutrum magna. Sed vitae risus.
</p>
<p>
Aliquam vitae enim. Duis scelerisque metus auctor est venenatis imperdiet.
Fusce dignissim porta augue. Nulla vestibulum. Integer lorem nunc,
ullamcorper a, commodo ac, malesuada sed, dolor. Aenean id mi in massa
bibendum suscipit. Integer eros. Nullam suscipit mauris. In pellentesque.
Mauris ipsum est, pharetra semper, pharetra in, viverra quis, tellus. Etiam
purus. Quisque egestas, tortor ac cursus lacinia, felis leo adipiscing
nisi, et rhoncus elit dolor eget eros. Fusce ut quam. Suspendisse eleifend
leo vitae ligula. Nulla facilisi. Nulla rutrum, erat vitae lacinia dictum,
pede purus imperdiet lacus, ut semper velit ante id metus. Praesent massa
dolor, porttitor sed, pulvinar in, consequat ut, leo. Nullam nec est.
Aenean id risus blandit tortor pharetra congue. Suspendisse pulvinar.
</p>
<p>
Vestibulum convallis eros ac justo. Proin dolor. Etiam aliquam. Nam ornare
elit vel augue. Suspendisse potenti. Etiam sed mauris eu neque nonummy
mollis. Vestibulum vel purus ac pede semper accumsan. Vivamus lobortis, sem
vitae nonummy lacinia, nisl est gravida magna, non cursus est quam sed
urna. Phasellus adipiscing justo in ipsum. Duis sagittis dolor sit amet
magna. Suspendisse suscipit, neque eu dictum auctor, nisi augue tincidunt
arcu, non lacinia magna purus nec magna. Praesent pretium sollicitudin
sapien. Suspendisse imperdiet. Class aptent taciti sociosqu ad litora
torquent per conubia nostra, per inceptos hymenaeos.
</p>
<p>
Mauris pharetra lorem sit amet sapien. Nulla libero metus, tristique et,
dignissim a, tempus et, metus. Ut libero. Vivamus tempus purus vel ipsum.
Quisque mauris urna, vestibulum commodo, rutrum vitae, ultrices vitae,
nisl. Class aptent taciti sociosqu ad litora torquent per conubia nostra,
per inceptos hymenaeos. Nulla id erat sit amet odio luctus eleifend. Proin
massa libero, ultricies non, tincidunt a, vestibulum non, tellus. Nunc nunc
purus, lobortis a, pulvinar at, egestas a, mi. Cras adipiscing velit a
mauris. Morbi felis. Etiam at felis. Cras eget eros et justo mattis
pulvinar. Nullam at justo id risus porttitor dignissim. Vestibulum sed
velit vel metus tincidunt tempus. Nunc euismod nisl id dolor tristique
tincidunt. Nullam placerat turpis sed odio. Curabitur in est id nibh tempus
ultrices. Aliquam consectetuer dapibus eros. Aliquam nisl.
</p>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper
sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum
lacus. Etiam consequat scelerisque quam. Nulla facilisi. Maecenas luctus
venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie
tortor at ipsum. Morbi dictum rutrum magna. Sed vitae risus.
</p>
<p>
Aliquam vitae enim. Duis scelerisque metus auctor est venenatis imperdiet.
Fusce dignissim porta augue. Nulla vestibulum. Integer lorem nunc,
ullamcorper a, commodo ac, malesuada sed, dolor. Aenean id mi in massa
bibendum suscipit. Integer eros. Nullam suscipit mauris. In pellentesque.
Mauris ipsum est, pharetra semper, pharetra in, viverra quis, tellus. Etiam
purus. Quisque egestas, tortor ac cursus lacinia, felis leo adipiscing
nisi, et rhoncus elit dolor eget eros. Fusce ut quam. Suspendisse eleifend
leo vitae ligula. Nulla facilisi. Nulla rutrum, erat vitae lacinia dictum,
pede purus imperdiet lacus, ut semper velit ante id metus. Praesent massa
dolor, porttitor sed, pulvinar in, consequat ut, leo. Nullam nec est.
Aenean id risus blandit tortor pharetra congue. Suspendisse pulvinar.
</p>
<p>
Vestibulum convallis eros ac justo. Proin dolor. Etiam aliquam. Nam ornare
elit vel augue. Suspendisse potenti. Etiam sed mauris eu neque nonummy
mollis. Vestibulum vel purus ac pede semper accumsan. Vivamus lobortis, sem
vitae nonummy lacinia, nisl est gravida magna, non cursus est quam sed
urna. Phasellus adipiscing justo in ipsum. Duis sagittis dolor sit amet
magna. Suspendisse suscipit, neque eu dictum auctor, nisi augue tincidunt
arcu, non lacinia magna purus nec magna. Praesent pretium sollicitudin
sapien. Suspendisse imperdiet. Class aptent taciti sociosqu ad litora
torquent per conubia nostra, per inceptos hymenaeos.
</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/widget/tests/images/icon_calendar.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/tests/images/icon_calendar.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/tests/images/icon_texteditor.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/tests/images/icon_texteditor.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/tests/images/icon_users.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/tests/images/icon_users.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/tests/images/icon_update.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/tests/images/icon_update.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/tests/images/icon_browser.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/tests/images/icon_browser.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/tests/images/fisheye_1.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/tests/images/fisheye_1.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/tests/images/fisheye_2.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/tests/images/fisheye_2.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/tests/images/fisheye_3.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/tests/images/fisheye_3.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/tests/images/fisheye_4.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/tests/images/fisheye_4.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/tests/images/icon_email.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/tests/images/icon_email.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/tests/test_SortList.html
New file
0,0 → 1,74
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Dojox SortList Test</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../SortList/SortList.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
<script type="text/javascript" src="../SortList.js"></script>
<script type="text/javascript">
// dojo.require("dojox.widget.SortList");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.layout.SplitContainer");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
</script>
</head>
<body>
 
<h1 class="testTitle">Dojox SortList test</h1>
 
<div dojoType="dojo.data.ItemFileReadStore" url="../../../dijit/tests/_data/countries.json" jsId="stateStore"></div>
<h3>Simple sortable example</h3>
<ul dojoType="dojox.widget.SortList" store="stateStore" title="sortable List" style="width:200px; height:200px;"></ul>
 
<h3>Children of a TabContainer</h3>
<div dojoType="dijit.layout.TabContainer" style="width:300px; height:300px;">
<div dojoType="dojox.widget.SortList" store="stateStore" title="list 1" heading="countires"></div>
<div dojoType="dojox.widget.SortList" store="stateStore" title="list 2" heading="states"></div>
<div dojoType="dojox.widget.SortList" store="stateStore" title="closable" heading="countries" closable="true"></div>
</div>
 
<h3>Child of a SplitContainer</h3>
<div dojoType="dijit.layout.SplitContainer" sizerWidth="7" activeSizing="false" orientaton="vertical" style="width:600px; height:200px;">
<div dojoType="dojox.widget.SortList" store="stateStore" title="list 1" layoutAlign="left" sizeShare="33"></div>
<div dojoType="dojox.widget.SortList" store="stateStore" title="list 2" layoutAlign="client" sizeShare="33"></div>
<div dojoType="dojox.widget.SortList" store="stateStore" title="closable" layoutAlign="right" sizeShare="33"></div>
</div>
<br>
<h3>Raw, degradable UL list:</h3>
<ul dojoType="dojox.widget.SortList" title="SortList From Markup" sortable="false" style="width:200px; height:200px;">
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
<li>five</li>
<li>six</li>
<li>four</li>
<li>five</li>
<li>six</li>
<li>four</li>
<li>five</li>
<li>six</li>
<li>four</li>
<li>five</li>
<li>six</li>
</ul>
 
<h3>normal ul:</h3>
<ul style="width:200px; height:200px;">
<li>one</li><li>one</li><li>one</li><li>one</li><li>one</li><li>one</li><li>one</li><li>one</li>
</ul>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/widget/tests/test_Loader.html
New file
0,0 → 1,81
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Dojo Visual Loader Test</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../Loader/Loader.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script>
<script type="text/javascript" src="../Loader.js"></script>
<script type="text/javascript">
// dojo.require("dojox.widget.Loader");
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
 
function getHoney(){
// simple xhrGet example
var foo = dojo.xhrGet({
url: '../Loader/honey.php?delay=0',
handleAs: 'text',
load: function(result){
content.innerHTML = result;
}
});
}
 
function postHoney(){
// simple xhrPost example
var foo = dojo.xhrPost({
url: '../Loader/honey.php?delay=0',
handleAs: 'text',
load: function(result){
content.innerHTML = result;
}
});
}
 
function alertMe(){
console.log('subscription fired',arguments);
}
 
var content = null;
dojo.addOnLoad(function(){
 
content = dojo.byId("dataholder");
// FIXME: why aren't you working?
// var foo = dojo.subscribe("Loader",null,"alertMe");
// console.log(foo);
 
});
</script>
</head>
<body class="tundra">
<div id="globalLoader" dojoType="dojox.widget.Loader"></div>
 
<!-- Other examples:
<div id="globalLoader" dojoType="dojox.widget.Loader" hasVisuals="false"></div>
<div id="globalLoader" dojoType="dojox.widget.Loader" hasVisuals="true" attachToPointer="false"></div>
-->
 
<h1 class="testTitle">Dojox xhrListener test</h1>
 
<a href="javascript:getHoney();">start xhrGet demo</a>
<a href="javascript:postHoney();">start xhrPost demo</a>
 
<p>No additional code is required except for the existance of a
dojoType="dojox.widget.Loader" node. It will listen for the start
and end of xhr* requests (via _ioSetArgs [ugh] and Deferred.prototype._fire ..
</p>
 
<br>
<div id="dataholder" style="float:left; height:300px; overflow:auto; width:400px; border:1px solid #ccc; "></div>
<!-- make me a scrollbar. a Taaaaaall scrollbar -->
<div style="float:left; height:2000px; width:1px; overflow:hidden">spacer</div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/widget/tests/test_FisheyeList.html
New file
0,0 → 1,144
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>FisheyeList Widget Dojo Tests</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../FisheyeList/FisheyeList.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script>
<script type="text/javascript" src="../FisheyeList.js"></script>
<script type="text/javascript">
//dojo.require("dojox.widget.FisheyeList");
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
 
dojo.addOnLoad(function(){
fish1 = dijit.byId("fisheye1");
fish2 = dijit.byId("fisheye2");
});
var counter = 1;
function addToFirstList(){
var item = new dojox.widget.FisheyeListItem();
item.label = "Dynamically Added "+counter;
item.iconSrc = "images/fisheye_"+counter+".png"
item.postCreate();
counter++;
if(counter>4){counter=1;}
fish1.addChild(item);
fish1.startup();
item.startup();
}
</script>
</head>
<body class="tundra">
<h1>dojox.widget.FisheyeList test</h1>
<p>HTML before</p>
<button onclick="addToFirstList();">Add a new item to the first list</button>
<p>HTML before</p>
<p>HTML before</p>
<p>Liberal trigger: move the mouse anywhere near the menu and it will start to expand:</p>
<div dojoType="dojox.widget.FisheyeList"
itemWidth="40" itemHeight="40"
itemMaxWidth="150" itemMaxHeight="150"
orientation="horizontal"
effectUnits="2"
itemPadding="10"
attachEdge="center"
labelEdge="bottom"
id="fisheye1"
>
 
<div dojoType="dojox.widget.FisheyeListItem"
id="item1"
onclick="alert('click on ' + this.label + '(from widget id ' + this.widgetId + ')!');"
label="Item 1"
iconSrc="images/fisheye_1.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
label="Item 2"
iconSrc="images/fisheye_2.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
label="Item 3"
iconSrc="images/fisheye_3.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
iconSrc="images/fisheye_4.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
label="Really Long Item Label"
iconSrc="images/fisheye_3.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
iconSrc="images/fisheye_2.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
iconSrc="images/fisheye_1.png">
</div>
</div>
 
<p>HTML after</p>
<p>HTML after</p>
<p>HTML after</p>
<p>This one has strict triggering, so you actually have to mouse over the menu to make it start moving:</p>
<div dojoType="dojox.widget.FisheyeList"
itemWidth="40" itemHeight="40"
itemMaxWidth="150" itemMaxHeight="150"
orientation="horizontal"
effectUnits="2"
itemPadding="10"
attachEdge="center"
labelEdge="bottom"
conservativeTrigger="true"
id="fisheye2"
>
 
<div dojoType="dojox.widget.FisheyeListItem"
id="item1b"
onclick="alert('click on ' + this.label + '(from widget id ' + this.widgetId + ')!');"
label="Item 1"
iconSrc="images/fisheye_1.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
label="Item 2"
iconSrc="images/fisheye_2.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
label="Item 3"
iconSrc="images/fisheye_3.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
iconSrc="images/fisheye_4.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
label="Really Long Item Label"
iconSrc="images/fisheye_3.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
iconSrc="images/fisheye_2.png">
</div>
 
<div dojoType="dojox.widget.FisheyeListItem"
iconSrc="images/fisheye_1.png">
</div>
</div>
 
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/widget/tests/test_Iterator.html
New file
0,0 → 1,73
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Dojox Iterator Test</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug: true, debugAtAllCosts: false, parseOnLoad: true"></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
<script type="text/javascript">
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.layout.SplitContainer");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojox.widget.Iterator");
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
</script>
</head>
<body>
 
<h1 class="testTitle">Dojox Iterator test</h1>
 
<div dojoType="dojo.data.ItemFileReadStore"
url="../../../dijit/tests/_data/countries.json"
jsId="stateStore"></div>
<h3>Data store backed Iterator</h3>
<ul>
<li>before</li>
<li dojoType="dojox.widget.Iterator"
query="{ name: 'A*' }"
store="stateStore">
${name}
</li>
<li>after</li>
</ul>
 
<h3>Array backed Iterator</h3>
<ul>
<li>before</li>
<script>
var tdata = [
{ thinger: "blah", name: "named:" },
{ thinger: "..." },
{ thinger: "w00t!" }
];
</script>
<li dojoType="dojox.widget.Iterator"
defaultValue="*this space intentionally left blank*"
data="tdata">
${name} ${thinger}
</li>
<li>after</li>
</ul>
 
<h3>Array-property Iterator</h3>
<ul>
<li>before</li>
<li>blah</li>
<li dojoType="dojox.widget.Iterator"
dataValues="thinger, blah, blah">
${value}
</li>
<li>after</li>
</ul>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/widget/FileInputAuto.js
New file
0,0 → 1,178
if(!dojo._hasResource["dojox.widget.FileInputAuto"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.widget.FileInputAuto"] = true;
dojo.provide("dojox.widget.FileInputAuto");
 
dojo.require("dojox.widget.FileInput");
dojo.require("dojo.io.iframe");
 
dojo.declare("dojox.widget.FileInputAuto",
dojox.widget.FileInput,
{
// summary: An extension on dojox.widget.FileInput providing background upload progress
//
// description: An extended version of FileInput - when the user focuses away from the input
// the selected file is posted via dojo.io.iframe to the url. example implementation
// comes with PHP solution for handling upload, and returning required data.
//
// notes: the return data from the io.iframe is used to populate the input element with
// data regarding the results. it will be a JSON object, like:
//
// results = { size: "1024", filename: "file.txt" }
//
// all the parameters allowed to dojox.widget.FileInput apply
 
// url: String
// the URL where our background FileUpload will be sent
url: "",
 
// blurDelay: Integer
// time in ms before an un-focused widget will wait before uploading the file to the url="" specified
// default: 2 seconds
blurDelay: 2000,
 
// duration: Integer
// The time in ms to use as the generic timing mechanism for the animations
// set to 1 or 0 for "immediate respose"
duration: 500,
 
// uploadMessage: String
//
// FIXME: i18n somehow?
uploadMessage: "Uploading ...",
_sent: false,
 
// small template changes, new attachpoint: overlay
templateString:"<div class=\"dijitFileInput\">\n\t<input class=\"dijitFileInputReal\" type=\"file\" dojoAttachPoint=\"fileInput\" />\n\t<div class=\"dijitFakeInput\" dojoAttachPoint=\"fakeNodeHolder\">\n\t\t<input class=\"dijitFileInputVisible\" type=\"text\" dojoAttachPoint=\"focusNode, inputNode\" />\n\t\t<span class=\"dijitInline dijitFileInputText\" dojoAttachPoint=\"titleNode\">${label}</span>\n\t\t<span class=\"dijitInline dijitFileInputButton\" dojoAttachPoint=\"cancelNode\" dojoAttachEvent=\"onclick:_onClick\">${cancelText}</span>\n\t</div>\n\t<div class=\"dijitProgressOverlay\" dojoAttachPoint=\"overlay\">&nbsp;</div>\n</div>\n",
 
startup: function(){
// summary: add our extra blur listeners
this._blurListener = dojo.connect(this.fileInput,"onblur",this,"_onBlur");
this._focusListener = dojo.connect(this.fileInput,"onfocus",this,"_onFocus");
this.inherited("startup",arguments);
},
 
_onFocus: function(){
// summary: clear the upload timer
if(this._blurTimer){ clearTimeout(this._blurTimer); }
},
 
_onBlur: function(){
// summary: start the upload timer
if(this._blurTimer){ clearTimeout(this._blurTimer); }
if(!this._sent){
this._blurTimer = setTimeout(dojo.hitch(this,"_sendFile"),this.blurDelay);
}
},
 
 
setMessage: function(/*String*/title){
// summary: set the text of the progressbar
// FIXME: this throws errors in IE?!?!?!? egads.
if(!dojo.isIE){ this.overlay.innerHTML = title; }
},
_sendFile: function(/* Event */e){
// summary: triggers the chain of events needed to upload a file in the background.
if(!this.fileInput.value || this._sent){ return; }
dojo.style(this.fakeNodeHolder,"display","none");
dojo.style(this.overlay,"opacity","0");
dojo.style(this.overlay,"display","block");
 
this.setMessage(this.uploadMessage);
 
dojo.fadeIn({ node: this.overlay, duration:this.duration }).play();
 
var _newForm = document.createElement('form');
_newForm.setAttribute("enctype","multipart/form-data");
var node = dojo.clone(this.fileInput);
_newForm.appendChild(this.fileInput);
dojo.body().appendChild(_newForm);
 
dojo.io.iframe.send({
url: this.url+"?name="+this.name,
form: _newForm,
handleAs: "text",
handle: dojo.hitch(this,"_handleSend")
});
},
 
_handleSend: function(data,ioArgs){
// summary: The callback to toggle the progressbar, and fire the user-defined callback
if(!dojo.isIE){
// otherwise, this throws errors in ie? FIXME:
this.overlay.innerHTML = "";
}
this._sent = true;
dojo.style(this.overlay,"opacity","0");
dojo.style(this.overlay,"border","none");
dojo.style(this.overlay,"background","none");
 
this.overlay.style.backgroundImage = "none";
this.fileInput.style.display = "none";
this.fakeNodeHolder.style.display = "none";
dojo.fadeIn({ node:this.overlay, duration:this.duration }).play(250);
dojo.disconnect(this._blurListener);
dojo.disconnect(this._focusListener);
this.onComplete(data,ioArgs,this);
},
 
_onClick: function(e){
// summary: accomodate our extra focusListeners
if(this._blurTimer){ clearTimeout(this._blurTimer); }
 
dojo.disconnect(this._blurListener);
dojo.disconnect(this._focusListener);
 
this.inherited("_onClick",arguments);
 
this._blurListener = dojo.connect(this.fileInput,"onblur",this,"_onBlur");
this._focusListener = dojo.connect(this.fileInput,"onfocus",this,"_onFocus");
},
 
onComplete: function(/* Object */data, /* dojo.Deferred._ioArgs */ioArgs, /* this */widgetRef){
// summary: stub function fired when an upload has finished.
// data: the raw data found in the first [TEXTAREA] tag of the post url
// ioArgs: the dojo.Deferred data being passed from the handle: callback
}
});
 
dojo.declare("dojox.widget.FileInputBlind",
dojox.widget.FileInputAuto,
{
// summary: An extended version of dojox.widget.FileInputAuto
// that does not display an input node, but rather only a button
// and otherwise behaves just like FileInputAuto
startup: function(){
// summary: hide our fileInput input field
this.inherited("startup",arguments);
this._off = dojo.style(this.inputNode,"width");
this.inputNode.style.display = "none";
this._fixPosition();
},
_fixPosition: function(){
// summary: in this case, set the button under where the visible button is
if(dojo.isIE){
dojo.style(this.fileInput,"width","1px");
//dojo.style(this.fileInput,"height",this.overlay.scrollHeight+"px")
}else{
dojo.style(this.fileInput,"left","-"+(this._off)+"px");
}
},
 
_onClick: function(e){
// summary: onclick, we need to reposition our newly created input type="file"
this.inherited("_onClick",arguments);
this._fixPosition();
}
});
 
}
/trunk/api/js/dojo1.0/dojox/widget/FisheyeList.js
New file
0,0 → 1,708
if(!dojo._hasResource["dojox.widget.FisheyeList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.widget.FisheyeList"] = true;
dojo.provide("dojox.widget.FisheyeList");
 
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dijit._Container");
 
dojo.declare("dojox.widget.FisheyeList", [dijit._Widget, dijit._Templated, dijit._Container], {
// summary:
// Menu similar to the fish eye menu on the Mac OS
// example:
// | <div dojoType="FisheyeList"
// | itemWidth="40" itemHeight="40"
// | itemMaxWidth="150" itemMaxHeight="150"
// | orientation="horizontal"
// | effectUnits="2"
// | itemPadding="10"
// | attachEdge="center"
// | labelEdge="bottom">
// |
// | <div dojoType="FisheyeListItem"
// | id="item1"
// | onclick="alert('click on' + this.label + '(from widget id ' + this.widgetId + ')!');"
// | label="Item 1"
// | iconSrc="images/fisheye_1.png">
// | </div>
// | ...
// | </div>
//
constructor: function(){
//
// TODO
// fix really long labels in vertical mode
//
this.pos = {'x': -1, 'y': -1}; // current cursor position, relative to the grid
// for conservative trigger mode, when triggered, timerScale is gradually increased from 0 to 1
this.timerScale = 1.0;
},
 
EDGE: {
CENTER: 0,
LEFT: 1,
RIGHT: 2,
TOP: 3,
BOTTOM: 4
},
 
templateString: '<div class="dojoxFisheyeListBar" dojoAttachPoint="containerNode"></div>',
 
snarfChildDomOutput: true,
// itemWidth: Integer
// width of menu item (in pixels) in it's dormant state (when the mouse is far away)
itemWidth: 40,
// itemHeight: Integer
// height of menu item (in pixels) in it's dormant state (when the mouse is far away)
itemHeight: 40,
// itemMaxWidth: Integer
// width of menu item (in pixels) in it's fully enlarged state (when the mouse is directly over it)
itemMaxWidth: 150,
// itemMaxHeight: Integer
// height of menu item (in pixels) in it's fully enlarged state (when the mouse is directly over it)
itemMaxHeight: 150,
 
imgNode: null,
// orientation: String
// orientation of the menu, either "horizontal" or "vertical"
orientation: 'horizontal',
 
// isFixed: Boolean
// toggle to enable additional listener (window scroll) if FisheyeList is in a fixed postion
isFixed: false,
// conservativeTrigger: Boolean
// if true, don't start enlarging menu items until mouse is over an image;
// if false, start enlarging menu items as the mouse moves near them.
conservativeTrigger: false,
// effectUnits: Number
// controls how much reaction the menu makes, relative to the distance of the mouse from the menu
effectUnits: 2,
// itemPadding: Integer
// padding (in pixels) betweeen each menu item
itemPadding: 10,
// attachEdge: String
// controls the border that the menu items don't expand past;
// for example, if set to "top", then the menu items will drop downwards as they expand.
// values
// "center", "left", "right", "top", "bottom".
attachEdge: 'center',
 
// labelEdge: String
// controls were the labels show up in relation to the menu item icons
// values
// "center", "left", "right", "top", "bottom".
labelEdge: 'bottom',
 
postCreate: function(){
var e = this.EDGE;
dojo.setSelectable(this.domNode, false);
 
var isHorizontal = this.isHorizontal = (this.orientation == 'horizontal');
this.selectedNode = -1;
 
this.isOver = false;
this.hitX1 = -1;
this.hitY1 = -1;
this.hitX2 = -1;
this.hitY2 = -1;
 
//
// only some edges make sense...
//
this.anchorEdge = this._toEdge(this.attachEdge, e.CENTER);
this.labelEdge = this._toEdge(this.labelEdge, e.TOP);
 
if(this.labelEdge == e.CENTER){ this.labelEdge = e.TOP; }
 
if(isHorizontal){
if(this.anchorEdge == e.LEFT){ this.anchorEdge = e.CENTER; }
if(this.anchorEdge == e.RIGHT){ this.anchorEdge = e.CENTER; }
if(this.labelEdge == e.LEFT){ this.labelEdge = e.TOP; }
if(this.labelEdge == e.RIGHT){ this.labelEdge = e.TOP; }
}else{
if(this.anchorEdge == e.TOP){ this.anchorEdge = e.CENTER; }
if(this.anchorEdge == e.BOTTOM){ this.anchorEdge = e.CENTER; }
if(this.labelEdge == e.TOP){ this.labelEdge = e.LEFT; }
if(this.labelEdge == e.BOTTOM){ this.labelEdge = e.LEFT; }
}
 
//
// figure out the proximity size
//
var effectUnits = this.effectUnits;
this.proximityLeft = this.itemWidth * (effectUnits - 0.5);
this.proximityRight = this.itemWidth * (effectUnits - 0.5);
this.proximityTop = this.itemHeight * (effectUnits - 0.5);
this.proximityBottom = this.itemHeight * (effectUnits - 0.5);
if(this.anchorEdge == e.LEFT){
this.proximityLeft = 0;
}
if(this.anchorEdge == e.RIGHT){
this.proximityRight = 0;
}
if(this.anchorEdge == e.TOP){
this.proximityTop = 0;
}
if(this.anchorEdge == e.BOTTOM){
this.proximityBottom = 0;
}
if(this.anchorEdge == e.CENTER){
this.proximityLeft /= 2;
this.proximityRight /= 2;
this.proximityTop /= 2;
this.proximityBottom /= 2;
}
},
startup: function(){
// summary: create our connections and setup our FisheyeList
this.children = this.getChildren();
//original postCreate() --tk
this._initializePositioning();
//
// in liberal trigger mode, activate menu whenever mouse is close
//
if(!this.conservativeTrigger){
this._onMouseMoveHandle = dojo.connect(document.documentElement, "onmousemove", this, "_onMouseMove");
}
if (this.isFixed){
this._onScrollHandle = dojo.connect(document,"onscroll",this,"_onScroll");
}
// Deactivate the menu if mouse is moved off screen (doesn't work for FF?)
this._onMouseOutHandle = dojo.connect(document.documentElement, "onmouseout", this, "_onBodyOut");
this._addChildHandle = dojo.connect(this, "addChild", this, "_initializePositioning");
this._onResizeHandle = dojo.connect(window,"onresize", this, "_initializePositioning");
},
_initializePositioning: function(){
this.itemCount = this.children.length;
this.barWidth = (this.isHorizontal ? this.itemCount : 1) * this.itemWidth;
this.barHeight = (this.isHorizontal ? 1 : this.itemCount) * this.itemHeight;
this.totalWidth = this.proximityLeft + this.proximityRight + this.barWidth;
this.totalHeight = this.proximityTop + this.proximityBottom + this.barHeight;
//
// calculate effect ranges for each item
//
 
for(var i=0; i<this.children.length; i++){
 
this.children[i].posX = this.itemWidth * (this.isHorizontal ? i : 0);
this.children[i].posY = this.itemHeight * (this.isHorizontal ? 0 : i);
 
this.children[i].cenX = this.children[i].posX + (this.itemWidth / 2);
this.children[i].cenY = this.children[i].posY + (this.itemHeight / 2);
 
var isz = this.isHorizontal ? this.itemWidth : this.itemHeight;
var r = this.effectUnits * isz;
var c = this.isHorizontal ? this.children[i].cenX : this.children[i].cenY;
var lhs = this.isHorizontal ? this.proximityLeft : this.proximityTop;
var rhs = this.isHorizontal ? this.proximityRight : this.proximityBottom;
var siz = this.isHorizontal ? this.barWidth : this.barHeight;
 
var range_lhs = r;
var range_rhs = r;
 
if(range_lhs > c+lhs){ range_lhs = c+lhs; }
if(range_rhs > (siz-c+rhs)){ range_rhs = siz-c+rhs; }
 
this.children[i].effectRangeLeft = range_lhs / isz;
this.children[i].effectRangeRght = range_rhs / isz;
 
//dojo.debug('effect range for '+i+' is '+range_lhs+'/'+range_rhs);
}
 
//
// create the bar
//
this.domNode.style.width = this.barWidth + 'px';
this.domNode.style.height = this.barHeight + 'px';
 
//
// position the items
//
for(var i=0; i<this.children.length; i++){
var itm = this.children[i];
var elm = itm.domNode;
elm.style.left = itm.posX + 'px';
elm.style.top = itm.posY + 'px';
elm.style.width = this.itemWidth + 'px';
elm.style.height = this.itemHeight + 'px';
itm.imgNode.style.left = this.itemPadding+'%';
itm.imgNode.style.top = this.itemPadding+'%';
itm.imgNode.style.width = (100 - 2 * this.itemPadding) + '%';
itm.imgNode.style.height = (100 - 2 * this.itemPadding) + '%';
}
 
//
// calc the grid
//
this._calcHitGrid();
},
 
_overElement: function(/* DomNode|String */node, /* Event */e){
// summary:
// Returns whether the mouse is over the passed element.
// Node: Must must be display:block (ie, not a <span>)
node = dojo.byId(node);
var mouse = {x: e.pageX, y: e.pageY};
var bb = dojo._getBorderBox(node);
var absolute = dojo.coords(node, true);
var top = absolute.y;
var bottom = top + bb.h;
var left = absolute.x;
var right = left + bb.w;
 
return (mouse.x >= left
&& mouse.x <= right
&& mouse.y >= top
&& mouse.y <= bottom
); // boolean
},
 
_onBodyOut: function(/*Event*/ e){
// clicking over an object inside of body causes this event to fire; ignore that case
if( this._overElement(dojo.body(), e) ){
return;
}
this._setDormant(e);
},
 
_setDormant: function(/*Event*/ e){
// summary: called when mouse moves out of menu's range
 
if(!this.isOver){ return; } // already dormant?
this.isOver = false;
 
if(this.conservativeTrigger){
// user can't re-trigger the menu expansion
// until he mouses over a icon again
dojo.disconnect(this._onMouseMoveHandle);
}
this._onGridMouseMove(-1, -1);
},
 
_setActive: function(/*Event*/ e){
// summary: called when mouse is moved into menu's range
 
if(this.isOver){ return; } // already activated?
this.isOver = true;
 
if(this.conservativeTrigger){
// switch event handlers so that we handle mouse events from anywhere near
// the menu
this._onMouseMoveHandle = dojo.connect(document.documentElement, "onmousemove", this, "_onMouseMove");
 
this.timerScale=0.0;
 
// call mouse handler to do some initial necessary calculations/positioning
this._onMouseMove(e);
 
// slowly expand the icon size so it isn't jumpy
this._expandSlowly();
}
},
 
_onMouseMove: function(/*Event*/ e){
// summary: called when mouse is moved
if( (e.pageX >= this.hitX1) && (e.pageX <= this.hitX2) &&
(e.pageY >= this.hitY1) && (e.pageY <= this.hitY2) ){
if(!this.isOver){
this._setActive(e);
}
this._onGridMouseMove(e.pageX-this.hitX1, e.pageY-this.hitY1);
}else{
if(this.isOver){
this._setDormant(e);
}
}
},
 
_onScroll: function(){
this._calcHitGrid();
},
 
onResized: function(){
this._calcHitGrid();
},
 
_onGridMouseMove: function(x, y){
// summary: called when mouse is moved in the vicinity of the menu
this.pos = {x:x, y:y};
this._paint();
},
 
_paint: function(){
var x=this.pos.x;
var y=this.pos.y;
 
if(this.itemCount <= 0){ return; }
 
//
// figure out our main index
//
var pos = this.isHorizontal ? x : y;
var prx = this.isHorizontal ? this.proximityLeft : this.proximityTop;
var siz = this.isHorizontal ? this.itemWidth : this.itemHeight;
var sim = this.isHorizontal ?
(1.0-this.timerScale)*this.itemWidth + this.timerScale*this.itemMaxWidth :
(1.0-this.timerScale)*this.itemHeight + this.timerScale*this.itemMaxHeight ;
 
var cen = ((pos - prx) / siz) - 0.5;
var max_off_cen = (sim / siz) - 0.5;
 
if(max_off_cen > this.effectUnits){ max_off_cen = this.effectUnits; }
 
//
// figure out our off-axis weighting
//
var off_weight = 0;
 
if(this.anchorEdge == this.EDGE.BOTTOM){
var cen2 = (y - this.proximityTop) / this.itemHeight;
off_weight = (cen2 > 0.5) ? 1 : y / (this.proximityTop + (this.itemHeight / 2));
}
if(this.anchorEdge == this.EDGE.TOP){
var cen2 = (y - this.proximityTop) / this.itemHeight;
off_weight = (cen2 < 0.5) ? 1 : (this.totalHeight - y) / (this.proximityBottom + (this.itemHeight / 2));
}
if(this.anchorEdge == this.EDGE.RIGHT){
var cen2 = (x - this.proximityLeft) / this.itemWidth;
off_weight = (cen2 > 0.5) ? 1 : x / (this.proximityLeft + (this.itemWidth / 2));
}
if(this.anchorEdge == this.EDGE.LEFT){
var cen2 = (x - this.proximityLeft) / this.itemWidth;
off_weight = (cen2 < 0.5) ? 1 : (this.totalWidth - x) / (this.proximityRight + (this.itemWidth / 2));
}
if(this.anchorEdge == this.EDGE.CENTER){
if(this.isHorizontal){
off_weight = y / (this.totalHeight);
}else{
off_weight = x / (this.totalWidth);
}
 
if(off_weight > 0.5){
off_weight = 1 - off_weight;
}
 
off_weight *= 2;
}
 
//
// set the sizes
//
for(var i=0; i<this.itemCount; i++){
var weight = this._weighAt(cen, i);
if(weight < 0){weight = 0;}
this._setItemSize(i, weight * off_weight);
}
 
//
// set the positions
//
 
var main_p = Math.round(cen);
var offset = 0;
 
if(cen < 0){
 
main_p = 0;
 
}else if(cen > this.itemCount - 1){
 
main_p = this.itemCount -1;
 
}else{
 
offset = (cen - main_p) * ((this.isHorizontal ? this.itemWidth : this.itemHeight) - this.children[main_p].sizeMain);
}
 
this._positionElementsFrom(main_p, offset);
},
 
_weighAt: function(/*Integer*/ cen, /*Integer*/ i){
var dist = Math.abs(cen - i);
var limit = ((cen - i) > 0) ? this.children[i].effectRangeRght : this.children[i].effectRangeLeft;
return (dist > limit) ? 0 : (1 - dist / limit); // Integer
},
 
_setItemSize: function(p, scale){
scale *= this.timerScale;
var w = Math.round(this.itemWidth + ((this.itemMaxWidth - this.itemWidth ) * scale));
var h = Math.round(this.itemHeight + ((this.itemMaxHeight - this.itemHeight) * scale));
 
if(this.isHorizontal){
 
this.children[p].sizeW = w;
this.children[p].sizeH = h;
 
this.children[p].sizeMain = w;
this.children[p].sizeOff = h;
 
var y = 0;
if(this.anchorEdge == this.EDGE.TOP){
y = (this.children[p].cenY - (this.itemHeight / 2));
}else if(this.anchorEdge == this.EDGE.BOTTOM){
y = (this.children[p].cenY - (h - (this.itemHeight / 2)));
}else{
y = (this.children[p].cenY - (h / 2));
}
 
this.children[p].usualX = Math.round(this.children[p].cenX - (w / 2));
this.children[p].domNode.style.top = y + 'px';
this.children[p].domNode.style.left = this.children[p].usualX + 'px';
 
}else{
 
this.children[p].sizeW = w;
this.children[p].sizeH = h;
 
this.children[p].sizeOff = w;
this.children[p].sizeMain = h;
 
var x = 0;
if(this.anchorEdge == this.EDGE.LEFT){
x = this.children[p].cenX - (this.itemWidth / 2);
}else if (this.anchorEdge == this.EDGE.RIGHT){
x = this.children[p].cenX - (w - (this.itemWidth / 2));
}else{
x = this.children[p].cenX - (w / 2);
}
 
this.children[p].domNode.style.left = x + 'px';
this.children[p].usualY = Math.round(this.children[p].cenY - (h / 2));
 
this.children[p].domNode.style.top = this.children[p].usualY + 'px';
}
 
this.children[p].domNode.style.width = w + 'px';
this.children[p].domNode.style.height = h + 'px';
 
if(this.children[p].svgNode){
this.children[p].svgNode.setSize(w, h);
}
},
 
_positionElementsFrom: function(p, offset){
var pos = 0;
 
if(this.isHorizontal){
pos = Math.round(this.children[p].usualX + offset);
this.children[p].domNode.style.left = pos + 'px';
}else{
pos = Math.round(this.children[p].usualY + offset);
this.children[p].domNode.style.top = pos + 'px';
}
this._positionLabel(this.children[p]);
 
// position before
var bpos = pos;
for(var i=p-1; i>=0; i--){
bpos -= this.children[i].sizeMain;
 
if (this.isHorizontal){
this.children[i].domNode.style.left = bpos + 'px';
}else{
this.children[i].domNode.style.top = bpos + 'px';
}
this._positionLabel(this.children[i]);
}
 
// position after
var apos = pos;
for(var i=p+1; i<this.itemCount; i++){
apos += this.children[i-1].sizeMain;
if(this.isHorizontal){
this.children[i].domNode.style.left = apos + 'px';
}else{
this.children[i].domNode.style.top = apos + 'px';
}
this._positionLabel(this.children[i]);
}
 
},
 
_positionLabel: function(itm){
var x = 0;
var y = 0;
var mb = dojo.marginBox(itm.lblNode);
 
if(this.labelEdge == this.EDGE.TOP){
x = Math.round((itm.sizeW / 2) - (mb.w / 2));
y = -mb.h;
}
 
if(this.labelEdge == this.EDGE.BOTTOM){
x = Math.round((itm.sizeW / 2) - (mb.w / 2));
y = itm.sizeH;
}
 
if(this.labelEdge == this.EDGE.LEFT){
x = -mb.w;
y = Math.round((itm.sizeH / 2) - (mb.h / 2));
}
 
if(this.labelEdge == this.EDGE.RIGHT){
x = itm.sizeW;
y = Math.round((itm.sizeH / 2) - (mb.h / 2));
}
 
itm.lblNode.style.left = x + 'px';
itm.lblNode.style.top = y + 'px';
},
 
_calcHitGrid: function(){
 
var pos = dojo.coords(this.domNode, true);
 
this.hitX1 = pos.x - this.proximityLeft;
this.hitY1 = pos.y - this.proximityTop;
this.hitX2 = this.hitX1 + this.totalWidth;
this.hitY2 = this.hitY1 + this.totalHeight;
 
},
 
_toEdge: function(inp, def){
return this.EDGE[inp.toUpperCase()] || def;
},
 
_expandSlowly: function(){
// summary: slowly expand the image to user specified max size
if(!this.isOver){ return; }
this.timerScale += 0.2;
this._paint();
if(this.timerScale<1.0){
setTimeout(dojo.hitch(this, "_expandSlowly"), 10);
}
},
 
destroyRecursive: function(){
// need to disconnect when we destroy
dojo.disconnect(this._onMouseOutHandle);
dojo.disconnect(this._onMouseMoveHandle);
dojo.disconnect(this._addChildHandle);
if (this.isFixed) { dojo.disconnect(this._onScrollHandle); }
dojo.disconnect(this._onResizeHandle);
this.inherited("destroyRecursive",arguments);
}
});
 
dojo.declare("dojox.widget.FisheyeListItem", [dijit._Widget, dijit._Templated, dijit._Contained], {
/*
* summary
* Menu item inside of a FisheyeList.
* See FisheyeList documentation for details on usage.
*/
 
// iconSrc: String
// pathname to image file (jpg, gif, png, etc.) of icon for this menu item
iconSrc: "",
 
// label: String
// label to print next to the icon, when it is moused-over
label: "",
 
// id: String
// will be set to the id of the orginal div element
id: "",
 
_blankImgPath: dojo.moduleUrl("dojox.widget", "FisheyeList/blank.gif"),
 
templateString:
'<div class="dojoxFisheyeListItem">' +
' <img class="dojoxFisheyeListItemImage" dojoAttachPoint="imgNode" dojoAttachEvent="onmouseover:onMouseOver,onmouseout:onMouseOut,onclick:onClick">' +
' <div class="dojoxFisheyeListItemLabel" dojoAttachPoint="lblNode"></div>' +
'</div>',
 
_isNode: function(/* object */wh){
// summary:
// checks to see if wh is actually a node.
if(typeof Element == "function") {
try{
return wh instanceof Element; // boolean
}catch(e){}
}else{
// best-guess
return wh && !isNaN(wh.nodeType); // boolean
}
},
 
_hasParent: function(/*Node*/node){
// summary:
// returns whether or not node is a child of another node.
return Boolean(node && node.parentNode && this._isNode(node.parentNode)); // boolean
},
 
postCreate: function() {
 
// set image
if((this.iconSrc.toLowerCase().substring(this.iconSrc.length-4)==".png")&&(dojo.isIE)&&(dojo.isIE<7)){
/* we set the id of the new fisheyeListItem to the id of the div defined in the HTML */
if(this._hasParent(this.imgNode) && this.id != ""){
var parent = this.imgNode.parentNode;
parent.setAttribute("id", this.id);
}
this.imgNode.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.iconSrc+"', sizingMethod='scale')";
this.imgNode.src = this._blankImgPath.toString();
}else{
if(this._hasParent(this.imgNode) && this.id != ""){
var parent = this.imgNode.parentNode;
parent.setAttribute("id", this.id);
}
this.imgNode.src = this.iconSrc;
}
 
// Label
if(this.lblNode){
this.lblNode.appendChild(document.createTextNode(this.label));
}
dojo.setSelectable(this.domNode, false);
this.startup();
},
 
startup: function(){
this.parent = this.getParent();
},
onMouseOver: function(/*Event*/ e){
// summary: callback when user moves mouse over this menu item
// in conservative mode, don't activate the menu until user mouses over an icon
if(!this.parent.isOver){
this.parent._setActive(e);
}
if(this.label != "" ){
dojo.addClass(this.lblNode, "dojoxFishSelected");
this.parent._positionLabel(this);
}
},
onMouseOut: function(/*Event*/ e){
// summary: callback when user moves mouse off of this menu item
dojo.removeClass(this.lblNode, "dojoxFishSelected");
},
 
onClick: function(/*Event*/ e){
// summary: user overridable callback when user clicks this menu item
}
});
 
}
/trunk/api/js/dojo1.0/dojox/widget/Iterator.js
New file
0,0 → 1,177
if(!dojo._hasResource["dojox.widget.Iterator"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.widget.Iterator"] = true;
dojo.provide("dojox.widget.Iterator");
dojo.require("dijit.Declaration");
 
dojo.experimental("dojox.widget.Iterator"); // level: prototype, designed for dijit.chat.demo
 
/*
example:
from markup:
| <span dojoType="dojo.data.ItemFileReadStore"
| jsId="cstore" url="countries.json"></span>
|
| <div>
| <div dojoType="dojox.widget.Iterator" store="cstore"
| query="{ name: 'A*'}">
| ${name} is a ${type}
| </div>
| </div>
 
example:
programmatic:
| var store = new dojo.data.ItemFileReadStore({ url: "countries.json" });
|
| var iter = new dojox.widget.Iterator({
| store: store,
| template: ""
| });
|
 
example:
programmatic from an array of objects:
| var dataArr = [
| { name: "foo", valueAttr: "bar" },
| { name: "thinger", valueAttr: "blah" }
| ];
|
| var iter = new dojox.widget.Iterator({
| data: dataArr,
| template: ""
| });
 
example:
programmatic from an array of strings:
| var dataArr = [
| { name: "foo", valueAttr: "bar" },
| { name: "thinger", valueAttr: "blah" }
| ];
|
| var iter = new dojox.widget.Iterator({
| data: dataArr,
| template: ""
| });
 
*/
 
 
dojo.declare("dojox.widget.Iterator",
[ dijit.Declaration ],
{
 
constructor: (function(){
var ctr = 0;
return function(){
this.attrs = [];
this.children = [];
this.widgetClass = "dojox.widget.Iterator._classes._"+(ctr++);
}
})(),
 
start: 0,
fetchMax: 1000,
query: { name: "*" },
attrs: [],
defaultValue: "",
widgetCtor: null,
dataValues: [], // an array of strings
data: null, // should be a reference to an Array
store: null,
_srcIndex: 0,
_srcParent: null,
 
_setSrcIndex: function(s){
this._srcIndex = 0;
this._srcParent = s.parentNode;
var ts = s;
while(ts.previousSibling){
this._srcIndex++;
ts = ts.previousSibling;
};
},
 
postscript: function(p, s){
// figure out the position of the source node in it's parent
this._setSrcIndex(s);
// this._srcIndex = dojo.query(">", this._srcParent).indexOf(s);
 
this.inherited("postscript", arguments);
var wc = this.widgetCtor = dojo.getObject(this.widgetClass);
 
this.attrs = dojo.map(
wc.prototype.templateString.match(/\$\{([^\s\:\}]+)(?:\:([^\s\:\}]+))?\}/g),
function(s){ return s.slice(2, -1); }
);
dojo.forEach(
this.attrs,
function(m){ wc.prototype[m] = ""; }
);
this.update();
},
 
clear: function(){
if(this.children.length){
this._setSrcIndex(this.children[0].domNode);
}
dojo.forEach(this.children, "item.destroy();");
this.children = [];
},
 
update: function(){
if(this.store){
// we're executing a query
this.fetch();
}else{
// we came from an array of objects. Easier!
this.onDataAvailable(this.data||this.dataValues);
}
},
 
_addItem: function(/*Object*/config, idx){
if(dojo.isString(config)){
config = { value: config };
}
var widget = new this.widgetCtor(config);
this.children.push(widget);
dojo.place(widget.domNode, this._srcParent, this._srcIndex+idx);
},
 
getAttrValuesObj: function(item){
var obj = {};
if(dojo.isString(item)){
dojo.forEach(this.attrs, function(attr){
obj[attr] = (attr == "value") ? item : this.defaultValue;
}, this);
}else{
dojo.forEach(this.attrs, function(attr){
if(this.store){
obj[attr] = this.store.getValue(item, attr)||this.defaultValue;
}else{
obj[attr] = item[attr]||this.defaultValue;
}
}, this);
}
return obj;
},
 
onDataAvailable: function(data){
this.clear();
// console.debug(data);
dojo.forEach(data, function(item, idx){
this._addItem(this.getAttrValuesObj(item), idx);
}, this);
},
 
fetch: function(query, start, end){
this.store.fetch({
query: query||this.query,
start: start||this.start,
count: end||this.fetchMax,
onComplete: dojo.hitch(this,"onDataAvailable"),
});
}
});
 
dojox.widget.Iterator._classes = {};
 
}
/trunk/api/js/dojo1.0/dojox/widget/Loader/honey.php
New file
0,0 → 1,27
<?
/* honey.php - sample fake delay script to push data
- should use ob_flush() to send chunks rather than
just take a long time ...
*/
 
session_start();
 
$char = " ";
$fakeDelay = (empty($_GET['delay'])) ? 1 : $_GET['delay'];
$dataSize = (empty($_GET['size'])) ? 2*1024 : $_GET['size'];
if (empty($_SESSION['counter'])) $_SESSION['counter'] = 1;
$dataSent = 0;
$blockSize = 1024;
 
if ($fakeDelay) { sleep($fakeDelay); }
 
print "view num: ".$_SESSION['counter']++;
while ($dataSent<=$dataSize) {
for ($i=0; $i<$blockSize/4; $i++) {
print $char;
} print "<br />";
$dataSent += $blockSize;
sleep(1);
}
 
?>
/trunk/api/js/dojo1.0/dojox/widget/Loader/icons/loading.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/Loader/icons/loading.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/Loader/Loader.css
New file
0,0 → 1,27
.dojoxLoaderPointer {
position:absolute;
z-index:999;
}
 
.dojoxLoader {
float:right;
position:fixed;
height:25px;
width:100px;
top:0;
right:0;
padding:3px;
border:1px solid #ccc;
background:#fff;
min-width:42px;
}
 
.dojoxLoaderIcon {
height:22px; width:22px;
vertical-align:middle;
}
 
.dojoxLoaderMessage {
font:8pt Arial,san-serif;
color:#666;
}
/trunk/api/js/dojo1.0/dojox/widget/Loader/README
New file
0,0 → 1,39
-------------------------------------------------------------------------------
dojox.widget.Loader
-------------------------------------------------------------------------------
Version 0.1
Release date: 07/15/2007
-------------------------------------------------------------------------------
Project state:
prototype / expermental
-------------------------------------------------------------------------------
Credits: Pete Higgins (phiggins@gmail.com)
-------------------------------------------------------------------------------
Description:
a class to indicatie some xhr request
is going on via topics, with optional
eye-candy indicators either offset
from mouse pointer, or in a fixed position
node.
 
-------------------------------------------------------------------------------
Dependencies:
widget: none.
test page: to enhance visual effect, a .php
file is used to slowly pass data to an xhr
request. You will need a php-enabled
webserver to view /dojox/tests/test_Loader.html
 
-------------------------------------------------------------------------------
Documentation
 
-------------------------------------------------------------------------------
Installation instructions
 
simply dojo.require("dojox.widget.Loader") and
attach to a div:
<div dojoType="dojox.widget.Loader"></div>
 
Configuration options can be found in the API tool.
 
/trunk/api/js/dojo1.0/dojox/widget/TimeSpinner.js
New file
0,0 → 1,48
if(!dojo._hasResource["dojox.widget.TimeSpinner"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.widget.TimeSpinner"] = true;
dojo.provide("dojox.widget.TimeSpinner");
 
dojo.require("dijit.form._Spinner");
dojo.require("dijit.form.NumberTextBox");
dojo.require("dojo.date");
dojo.require("dojo.date.locale");
dojo.require("dojo.date.stamp");
 
dojo.declare(
"dojox.widget.TimeSpinner",
[dijit.form._Spinner],
{
// summary: Time Spinner
// description: This widget is the same as a normal NumberSpinner, but for the time component of a date object instead
 
required: false,
 
adjust: function(/* Object */ val, /*Number*/ delta){
return dojo.date.add(val, "minute", delta)
},
 
//FIXME should we allow for constraints in this widget?
isValid: function(){return true;},
 
smallDelta: 5,
 
largeDelta: 30,
 
timeoutChangeRate: 0.50,
 
parse: function(time, locale){
return dojo.date.locale.parse(time, {selector:"time", formatLength:"short"});
},
 
format: function(time, locale){
if (dojo.isString(time)) { return time; }
return dojo.date.locale.format(time, {selector:"time", formatLength:"short"});
},
 
serialize: dojo.date.stamp.toISOString,
 
value: "12:00 AM"
 
});
 
}
/trunk/api/js/dojo1.0/dojox/widget/FileInput.js
New file
0,0 → 1,76
if(!dojo._hasResource["dojox.widget.FileInput"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.widget.FileInput"] = true;
dojo.provide("dojox.widget.FileInput");
dojo.experimental("dojox.widget.FileInput");
 
dojo.require("dijit.form._FormWidget");
dojo.require("dijit._Templated");
 
dojo.declare("dojox.widget.FileInput",
[dijit.form._FormWidget,dijit._Templated],
{
// summary: A styled input type="file"
//
// description: A input type="file" form widget, with a button for uploading to be styled via css,
// a cancel button to clear selection, and FormWidget mixin to provide standard dijit.form.Form
// support (FIXME: maybe not fully implemented)
 
// label: String
// the title text of the "Browse" button
label: "Browse ...",
 
// cancelText: String
// the title of the "Cancel" button
cancelText: "Cancel",
 
// name: String
// ugh, this should be pulled from this.domNode
name: "uploadFile",
 
templateString:"<div class=\"dijitFileInput\">\n\t<input id=\"${id}\" class=\"dijitFileInputReal\" type=\"file\" dojoAttachPoint=\"fileInput\" name=\"${name}\" />\n\t<div class=\"dijitFakeInput\">\n\t\t<input class=\"dijitFileInputVisible\" type=\"text\" dojoAttachPoint=\"focusNode, inputNode\" />\n\t\t<span class=\"dijitFileInputText\" dojoAttachPoint=\"titleNode\">${label}</span>\n\t\t<span class=\"dijitFileInputButton\" dojoAttachPoint=\"cancelNode\" \n\t\t\tdojoAttachEvent=\"onclick:_onClick\">${cancelText}</span>\n\t</div>\n</div>\n",
startup: function(){
// summary: listen for changes on our real file input
this.inherited("startup",arguments);
this._listener = dojo.connect(this.fileInput,"onchange",this,"_matchValue");
this._keyListener = dojo.connect(this.fileInput,"onkeyup",this,"_matchValue");
},
 
_matchValue: function(){
// summary: set the content of the upper input based on the semi-hidden file input
this.inputNode.value = this.fileInput.value;
if(this.inputNode.value){
this.cancelNode.style.visibility = "visible";
dojo.fadeIn({ node: this.cancelNode, duration:275 }).play();
}
},
 
setLabel: function(/* String */label,/* String? */cssClass){
// summary: method to allow use to change button label
this.titleNode.innerHTML = label;
},
 
_onClick: function(/* Event */e){
// summary: on click of cancel button, since we can't clear the input because of
// security reasons, we destroy it, and add a new one in it's place.
dojo.disconnect(this._listener);
dojo.disconnect(this._keyListener);
this.domNode.removeChild(this.fileInput);
dojo.fadeOut({ node: this.cancelNode, duration:275 }).play();
 
// should we use cloneNode()? can we?
this.fileInput = document.createElement('input');
this.fileInput.setAttribute("type","file");
this.fileInput.setAttribute("id",this.id);
this.fileInput.setAttribute("name",this.name);
dojo.addClass(this.fileInput,"dijitFileInputReal");
this.domNode.appendChild(this.fileInput);
 
this._keyListener = dojo.connect(this.fileInput,"onkeyup",this,"_matchValue");
this._listener = dojo.connect(this.fileInput,"onchange",this,"_matchValue");
this.inputNode.value = "";
}
 
});
 
}
/trunk/api/js/dojo1.0/dojox/widget/ColorPicker/ColorPicker.html
New file
0,0 → 1,31
<div class="dojoxColorPicker">
<div class="dojoxColorPickerBox">
<div dojoAttachPoint="cursorNode" class="dojoxColorPickerPoint"></div>
<img dojoAttachPoint="colorUnderlay" dojoAttachEvent="onclick: _setPoint" class="dojoxColorPickerUnderlay" src="${_underlay}">
</div>
<div class="dojoxHuePicker">
<div dojoAttachPoint="hueCursorNode" class="dojoxHuePickerPoint"></div>
<div dojoAttachPoint="hueNode" class="dojoxHuePickerUnderlay" dojoAttachEvent="onclick: _setHuePoint"></div>
</div>
<div dojoAttachPoint="previewNode" class="dojoxColorPickerPreview"></div>
<div dojoAttachPoint="safePreviewNode" class="dojoxColorPickerWebSafePreview"></div>
<div class="dojoxColorPickerOptional">
<div class="dijitInline dojoxColorPickerRgb" dojoAttachPoint="rgbNode">
<table>
<tr><td>r</td><td><input dojoAttachPoint="Rval" size="1"></td></tr>
<tr><td>g</td><td><input dojoAttachPoint="Gval" size="1"></td></tr>
<tr><td>b</td><td><input dojoAttachPoint="Bval" size="1"></td></tr>
</table>
</div>
<div class="dijitInline dojoxColorPickerHsv" dojoAttachPoint="hsvNode">
<table>
<tr><td>h</td><td><input dojoAttachPoint="Hval"size="1"> &deg;</td></tr>
<tr><td>s</td><td><input dojoAttachPoint="Sval" size="1"> %</td></tr>
<tr><td>v</td><td><input dojoAttachPoint="Vval" size="1"> %</td></tr>
</table>
</div>
<div class="dojoxColorPickerHex" dojoAttachPoint="hexNode">
hex: <input dojoAttachPoint="hexCode, focusNode" size="6" class="dojoxColorPickerHexCode">
</div>
</div>
</div>
/trunk/api/js/dojo1.0/dojox/widget/ColorPicker/ColorPicker.css
New file
0,0 → 1,89
.dojoxColorPicker {
padding:8px;
border:1px solid #a0a0a0;
background:#ededed;
width:300px;
height:150px;
-moz-border-radius:4pt;
-webkit-border-radius:5pt;
}
 
 
.dojoxColorPickerBox {
position:relative;
width:150px;
height:150px;
margin:0; padding:0;
}
 
.dojoxColorPickerUnderlay {
position:absolute;
top:0; left:0;
width:150px;
height:150px;
z-index:1;
border:1px solid #a0a0a0;
}
 
.dojoxHuePickerUnderlay {
background:url(images/hue.png) no-repeat top center;
position:absolute;
top:0; left:0;
height:150px;
width:20px;
z-index:1;
}
 
.dojoxHuePicker { position:relative; top:-150px; left:157px; }
 
.dojoxHuePickerPoint {
position:absolute;
top:0; left:0;
width:20px;
height:8px;
z-index:3;
background-color:#666;
cursor:pointer;
background:url(images/hueHandle.png) no-repeat center center;
}
 
 
.dojoxColorPickerPoint {
position:absolute;
width:10px;
height:10px;
background: url(images/pickerPointer.png) no-repeat center center;
border:0;
z-index:3;
cursor:pointer;
}
 
.dojoxColorPickerPreview {
display:block;
width:45px;
height:45px;
border:1px solid #333;
background-color:#fff;
position:relative;
top:-150px;
left: 185px;
}
.dojoxColorPickerWebSafePreview {
display:block;
width:25px;
height:25px;
position:relative;
top:-197px;
left:240px;
border:1px solid #333;
}
 
.dojoxColorPickerOptional {
position:relative;
top:-170px;
left:185px;
}
 
.dojoxColorPickerRgb { position:absolute; top:0; left:0; }
.dojoxColorPickerHsv { position:absolute; top:0; left:50px; }
.dojoxColorPickerHex { position:absolute; top:73px; left:2px; }
/trunk/api/js/dojo1.0/dojox/widget/ColorPicker/images/hue.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/ColorPicker/images/hue.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/ColorPicker/images/underlay.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/ColorPicker/images/underlay.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/ColorPicker/images/hueHandle.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/ColorPicker/images/hueHandle.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/ColorPicker/images/pickerPointer.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/widget/ColorPicker/images/pickerPointer.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/widget/Loader.js
New file
0,0 → 1,103
if(!dojo._hasResource["dojox.widget.Loader"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.widget.Loader"] = true;
dojo.provide("dojox.widget.Loader");
dojo.experimental("dojox.widget.Loader");
 
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
 
dojo.declare("dojox.widget.Loader", [dijit._Widget,dijit._Templated], {
// summary: a configurable global xhr-listener to display
// a loading message during running xhr's or to simply provide
// base-level topic to subscribe to for custom loading messages
 
// loadIcon: String
// location to the icon used.
loadIcon: dojo.moduleUrl("dojox.widget.Loader","icons/loading.gif"),
 
// loadMessage: String
// string to use for progress loading
loadMessage: 'Loading ...',
 
// hasVisuals: Boolean
// true to display a fixed loading message in TR cornder, false to unly provide
// "Loader" topic to subscribe to for your own custom loading message.
hasVisuals: true,
 
// attachToPointer
// true to use visual indicator where cursor is
attachToPointer: true,
 
// duration: Integer
// time in ms to toggle in/out the visual load indicator
duration: 125,
 
// _offset: Integer
// distance in px from the mouse pointer to show attachToPointer avatar
_offset: 16,
 
// holder for mousemove connection
_pointerConnect: null,
_xhrStart: null,
_xhrEnd: null,
 
templateString: '<div dojoAttachPoint="loadNode" class="dojoxLoader">'
+'<img src="${loadIcon}" class="dojoxLoaderIcon"> <span dojoAttachPoint="loadMessageNode" class="dojoxLoaderMessage"></span>'
+'</div>',
postCreate: function(){
// summary: setup the loader
 
if(!this.hasVisuals){
this.loadNode.style.display = "none"; // _destroy()?
}else{
if(this.attachToPointer){
dojo.removeClass(this.loadNode,"dojoxLoader");
dojo.addClass(this.loadNode,"dojoxLoaderPointer");
}
this._hide();
}
this._setMessage(this.loadMessage);
 
// FIXME: create our connections. would be easier, and this might be redundant
// if Deferred published something
this._xhrStart = dojo.connect(dojo,"_ioSetArgs",this,"_show");
this._xhrEnd = dojo.connect(dojo.Deferred.prototype,"_fire",this,"_hide");
 
},
 
_setMessage: function(/* String */ message){
// summary: set's the message in the loader
this.loadMessageNode.innerHTML = message;
},
 
_putLoader: function(/* Event */ e){
// summary: place the floating loading element based on mousemove connection position
dijit.placeOnScreen(this.loadNode,{ x: e.clientX+this._offset, y:e.clientY+this._offset }, ["TL","BR"]);
},
 
_show: function(){
// summary: publish and show progress indicator
dojo.publish("Loader",[{ message: 'started' }]);
if(this.hasVisuals){
if(this.attachToPointer){
this._pointerConnect = dojo.connect(document,"onmousemove",this,"_putLoader");
}
dojo.fadeIn({ node: this.loadNode, duration:this.duration }).play();
}
},
 
_hide: function(){
// summary: publish "xhr ended" and hide progress indicator
dojo.publish("Loader",[{ message: 'ended' }]);
if(this.hasVisuals){
if(this.attachPointer){
dojo.disconnect(this._pointerConnect);
}
dojo.fadeOut({ node: this.loadNode, duration:this.duration }).play();
}
}
 
});
 
}
/trunk/api/js/dojo1.0/dojox/widget/Toaster/Toaster.css
New file
0,0 → 1,47
/* main classes for dojox.widget.Toaster */
 
.tundra .dijitToasterContent{
padding:1em;
padding-top:0.25em;
background:#73c74a;
}
 
.tundra .dijitToasterMessage{
color:#fff;
}
.tundra .dijitToasterWarning{ }
.tundra .dijitToasterError,
.tundra .dijitToasterFatal{
font-weight:bold;
color:#fff;
}
 
.tundra .dijitToasterWarning .dijitToasterContent{
padding:1em;
padding-top:0.25em;
background:#d4d943;
}
 
.tundra .dijitToasterError .dijitToasterContent{
padding:1em;
padding-top:0.25em;
background:#c46600;
}
 
 
/* imported from dijit.css */
.dijitToasterClip {
position: absolute;
overflow: hidden;
}
 
.dijitToasterContainer {
display: block;
position: absolute;
width: 17.5em;
z-index: 5000;
margin: 0px;
font:0.75em Tahoma, Helvetica, Verdana, Arial;
}
/trunk/api/js/dojo1.0/dojox/widget/SortList/SortList.css
New file
0,0 → 1,64
.sortListBody { margin:0; padding:0; background:#fff; }
 
.soria .sortListBody li,
.tundra .sortListBody li {
border-bottom:1px solid #b7b7b7;
padding:2px 2px 2px 5px;
}
.sortListTitle {
cursor:pointer;
padding:4px 4px 3px 4px;
}
.sortList { height:100%; width:100%; }
.sortListBodyWrapper {
border:1px solid #b7b7b7;
overflow:auto;
height:100%;
cursor:pointer;
}
 
.soria .sortListBodyWrapper {
border:1px solid #333;
}
 
.soria .sortListItemOdd,
.tundra .sortListItemOdd { background:#f2f5f9; }
.tundra .sortListTitle {
background:#fafafa url('../../../dijit/themes/tundra/images/titleBarBg.gif') repeat-x top left;
border:1px solid #bfbfbf;
border-bottom:0;
}
.soria .sortListTitle {
background:#4f8ce5 url('../../../dijit/themes/soria/images/gradientTopBg.png') repeat-x top left;
background-position:0px -1px;
border:1px solid #333;
border-bottom:0;
font-weight:bold;
color:#fff;
}
 
.sortListItemSelected { background:#b7cdee !important; }
.sortListItemHover { background:#ff6 !important; }
 
.soria .sortListIcon,
.tundra .sortListIcon {
float:right;
height:16px;
width:16px;
}
.tundra .sortListDesc .sortListIcon {
background:url('../../../dijit/themes/tundra/images/arrowDown.png') no-repeat center center;
}
.tundra .sortListAsc .sortListIcon {
background:url('../../../dijit/themes/tundra/images/arrowUp.png') no-repeat center center;
}
 
.soria .sortListDesc .sortListIcon,
.soria .sortListAsc .sortListIcon {
background:url('../../../dijit/themes/soria/images/arrows.png') no-repeat center center;
background-position:0px 0px;
}
 
.soria .sortListDesc .sortListIcon {
background-position:-32px 0px;
}
/trunk/api/js/dojo1.0/dojox/widget/SortList/SortList.html
New file
0,0 → 1,9
<div class="sortList" id="${id}">
<div class="sortListTitle" dojoAttachPoint="titleNode">
<div class="sortListIcon"></div>
<span dojoAttachPoint="focusNode">${title}</span>
</div>
<div class="sortListBodyWrapper" dojoAttachEvent="onmouseover: _set, onmouseout: _unset, onclick:_handleClick" dojoAttachPoint="bodyWrapper">
<ul dojoAttachPoint="containerNode" class="sortListBody"></ul>
</div>
</div>
/trunk/api/js/dojo1.0/dojox/gfx3d.js
New file
0,0 → 1,11
if(!dojo._hasResource["dojox.gfx3d"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx3d"] = true;
dojo.provide("dojox.gfx3d");
 
dojo.require("dojox.gfx3d.matrix");
dojo.require("dojox.gfx3d._base");
dojo.require("dojox.gfx3d.object");
 
 
 
}
/trunk/api/js/dojo1.0/dojox/encoding/tests/runTests.html
New file
0,0 → 1,9
<html>
<head>
<title>DojoX Compression Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.encoding.tests.encoding" />
</head>
<body>
<p>Redirecting to D.O.H runner.</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/encoding/tests/bits.js
New file
0,0 → 1,74
if(!dojo._hasResource["dojox.encoding.tests.bits"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.tests.bits"] = true;
dojo.provide("dojox.encoding.tests.bits");
dojo.require("dojox.encoding.bits");
 
(function(){
var msg1 = "The rain in Spain falls mainly on the plain.";
var msg2 = "The rain in Spain falls mainly on the plain.1";
var msg3 = "The rain in Spain falls mainly on the plain.ab";
var msg4 = "The rain in Spain falls mainly on the plain.!@#";
var dcb = dojox.encoding.bits;
var s2b = function(s){
var b = [];
for(var i = 0; i < s.length; ++i){
b.push(s.charCodeAt(i));
}
return b;
};
 
var b2s = function(b){
var s = [];
dojo.forEach(b, function(c){ s.push(String.fromCharCode(c)); });
return s.join("");
};
var testOut = function(msg){
var a = new dojox.encoding.bits.OutputStream();
for(var i = 0; i < msg.length; ++i){
var v = msg.charCodeAt(i);
var j = Math.floor(Math.random() * 7) + 1;
a.putBits(v >>> (8 - j), j);
a.putBits(v, 8 - j);
}
return b2s(a.getBuffer());
};
 
var testIn = function(msg){
var a = new dojox.encoding.bits.InputStream(s2b(msg), msg.length * 8);
var r = [];
for(var i = 0; i < msg.length; ++i){
var j = Math.floor(Math.random() * 7) + 1;
r.push((a.getBits(j) << (8 - j)) | a.getBits(8 - j));
}
return b2s(r);
};
var test = function(msg){
var a = new dojox.encoding.bits.InputStream(s2b(msg), msg.length * 8);
var o = new dojox.encoding.bits.OutputStream();
while(a.getWidth() > 0){
var w = Math.min(a.getWidth(), 3);
o.putBits(a.getBits(w), w);
}
return b2s(o.getBuffer());
};
 
tests.register("dojox.encoding.tests.bits", [
function testBitsOut1(t){ t.assertEqual(msg1, testOut(msg1)); },
function testBitsOut2(t){ t.assertEqual(msg2, testOut(msg2)); },
function testBitsOut3(t){ t.assertEqual(msg3, testOut(msg3)); },
function testBitsOut4(t){ t.assertEqual(msg4, testOut(msg4)); },
function testBitsIn1(t){ t.assertEqual(msg1, testIn(msg1)); },
function testBitsIn2(t){ t.assertEqual(msg2, testIn(msg2)); },
function testBitsIn3(t){ t.assertEqual(msg3, testIn(msg3)); },
function testBitsIn4(t){ t.assertEqual(msg4, testIn(msg4)); },
function testBits1(t){ t.assertEqual(msg1, test(msg1)); },
function testBits2(t){ t.assertEqual(msg2, test(msg2)); },
function testBits3(t){ t.assertEqual(msg3, test(msg3)); },
function testBits4(t){ t.assertEqual(msg4, test(msg4)); }
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/encoding/tests/colors.js
New file
0,0 → 1,156
if(!dojo._hasResource["dojox.encoding.tests.colors"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.tests.colors"] = true;
dojo.provide("dojox.encoding.tests.colors");
 
// all CSS3 colors
dojox.encoding.tests.colors = {
aliceblue: [240,248,255],
antiquewhite: [250,235,215],
aqua: [0,255,255],
aquamarine: [127,255,212],
azure: [240,255,255],
beige: [245,245,220],
bisque: [255,228,196],
black: [0,0,0],
blanchedalmond: [255,235,205],
blue: [0,0,255],
blueviolet: [138,43,226],
brown: [165,42,42],
burlywood: [222,184,135],
cadetblue: [95,158,160],
chartreuse: [127,255,0],
chocolate: [210,105,30],
coral: [255,127,80],
cornflowerblue: [100,149,237],
cornsilk: [255,248,220],
crimson: [220,20,60],
cyan: [0,255,255],
darkblue: [0,0,139],
darkcyan: [0,139,139],
darkgoldenrod: [184,134,11],
darkgray: [169,169,169],
darkgreen: [0,100,0],
darkgrey: [169,169,169],
darkkhaki: [189,183,107],
darkmagenta: [139,0,139],
darkolivegreen: [85,107,47],
darkorange: [255,140,0],
darkorchid: [153,50,204],
darkred: [139,0,0],
darksalmon: [233,150,122],
darkseagreen: [143,188,143],
darkslateblue: [72,61,139],
darkslategray: [47,79,79],
darkslategrey: [47,79,79],
darkturquoise: [0,206,209],
darkviolet: [148,0,211],
deeppink: [255,20,147],
deepskyblue: [0,191,255],
dimgray: [105,105,105],
dimgrey: [105,105,105],
dodgerblue: [30,144,255],
firebrick: [178,34,34],
floralwhite: [255,250,240],
forestgreen: [34,139,34],
fuchsia: [255,0,255],
gainsboro: [220,220,220],
ghostwhite: [248,248,255],
gold: [255,215,0],
goldenrod: [218,165,32],
gray: [128,128,128],
green: [0,128,0],
greenyellow: [173,255,47],
grey: [128,128,128],
honeydew: [240,255,240],
hotpink: [255,105,180],
indianred: [205,92,92],
indigo: [75,0,130],
ivory: [255,255,240],
khaki: [240,230,140],
lavender: [230,230,250],
lavenderblush: [255,240,245],
lawngreen: [124,252,0],
lemonchiffon: [255,250,205],
lightblue: [173,216,230],
lightcoral: [240,128,128],
lightcyan: [224,255,255],
lightgoldenrodyellow: [250,250,210],
lightgray: [211,211,211],
lightgreen: [144,238,144],
lightgrey: [211,211,211],
lightpink: [255,182,193],
lightsalmon: [255,160,122],
lightseagreen: [32,178,170],
lightskyblue: [135,206,250],
lightslategray: [119,136,153],
lightslategrey: [119,136,153],
lightsteelblue: [176,196,222],
lightyellow: [255,255,224],
lime: [0,255,0],
limegreen: [50,205,50],
linen: [250,240,230],
magenta: [255,0,255],
maroon: [128,0,0],
mediumaquamarine: [102,205,170],
mediumblue: [0,0,205],
mediumorchid: [186,85,211],
mediumpurple: [147,112,219],
mediumseagreen: [60,179,113],
mediumslateblue: [123,104,238],
mediumspringgreen: [0,250,154],
mediumturquoise: [72,209,204],
mediumvioletred: [199,21,133],
midnightblue: [25,25,112],
mintcream: [245,255,250],
mistyrose: [255,228,225],
moccasin: [255,228,181],
navajowhite: [255,222,173],
navy: [0,0,128],
oldlace: [253,245,230],
olive: [128,128,0],
olivedrab: [107,142,35],
orange: [255,165,0],
orangered: [255,69,0],
orchid: [218,112,214],
palegoldenrod: [238,232,170],
palegreen: [152,251,152],
paleturquoise: [175,238,238],
palevioletred: [219,112,147],
papayawhip: [255,239,213],
peachpuff: [255,218,185],
peru: [205,133,63],
pink: [255,192,203],
plum: [221,160,221],
powderblue: [176,224,230],
purple: [128,0,128],
red: [255,0,0],
rosybrown: [188,143,143],
royalblue: [65,105,225],
saddlebrown: [139,69,19],
salmon: [250,128,114],
sandybrown: [244,164,96],
seagreen: [46,139,87],
seashell: [255,245,238],
sienna: [160,82,45],
silver: [192,192,192],
skyblue: [135,206,235],
slateblue: [106,90,205],
slategray: [112,128,144],
slategrey: [112,128,144],
snow: [255,250,250],
springgreen: [0,255,127],
steelblue: [70,130,180],
tan: [210,180,140],
teal: [0,128,128],
thistle: [216,191,216],
tomato: [255,99,71],
turquoise: [64,224,208],
violet: [238,130,238],
wheat: [245,222,179],
white: [255,255,255],
whitesmoke: [245,245,245],
yellow: [255,255,0],
yellowgreen: [154,205,50]
};
 
}
/trunk/api/js/dojo1.0/dojox/encoding/tests/colors2.js
New file
0,0 → 1,64
if(!dojo._hasResource["dojox.encoding.tests.colors2"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.tests.colors2"] = true;
dojo.provide("dojox.encoding.tests.colors2");
 
// all CSS3 colors
dojox.encoding.tests.colors2 = {};
 
(function(){
var n = "!mi-='%@Md%8;F\"=E5(:$@nHf!(;HYAOL),#XJKa#UHDMYQ0@q6C8='JBa#m1`YRS;3_\\P=@.(bN\\!)0d:Nar*Fo]]G`\\[X7Cb@r#pc;D3!k*8^\"bS8DAYbu'J5[`7Fh5S1e8`@1^N\"n8R:+ZQt]Ab.S>NP-jkO\"N$oQpbVbYtZl1&rSs%_;'!e8\"ij:*R!%9&P.+o0%cF&0F<\"eWn+rm!a<(02!d\\-J\\O@`K![IaPrqh6H4S!U<Nh]PS,\"!C;0W&Y]X[<[E&`1gQ?_;g\\mbQn^c!eV!05V['T@)Lio1O0QV>7CU!\"5jICR2\\X?!FilaO:$aE\"G1NIfMJ<.)1d;?OH9VU%LiGhi9=d?$EjW!BM0)1mGfg@\"os1\\E*A>+>YdjUK:P>T'7tj.UQ?<89]$:\\Li]GF*H8o*Z,o]Q_E]tq?C^%'^cfU9B9sH-^t.-R;J6P9!buNg*%$9#>Y'*n;MPc7=>*]sb&NmgKSZcd2nWt6I@SX7agi3!0)M'T3O@@/>W+I:H9?@A7tjT8':(9PG\\m@_T8Ws\\\".VLCkg7IYKZ7M3.XQqX$4V`bEQF?<#jJ>#4Z#6:ZeYffa.W#0CW3@s2*ESkiD6hN#EAhXBm5F%&U_=k*tFq@rYS/!:$=M9epZ<`=HN:X\"!CRI(`>iqTRe(S@A\"&0!Dib&)1p9P)$NZb^e+i_UHHq\\_8AYC+oiIMLj_TW=u'3Nn?c=#_6Z^s/;EY/3Z(cZ\"CaOq6g>>I+;'H>Nh`>\"-3N</&5*&\\7KQKk5tM(]O9-gi%iL^#RH+KW@$+oOOO9;*#)6$,]ge#)$j.>DnX+!(g67=pRcf38l7XNQ:_FJ,l2V)C@@A;H1dN#\\$n75qg6-:\".KQkn!?a7e\"J7C0p3Pn`]hKrG_4WG*5qo\\tH,20o2QOZljnj_lZ&C6!.u8Qu:_L$8$4.[V@`&A0J,fQL";
var c = "nG*%[ldl.:s*t'unGiO]p\"]T._uKc;s6Io0!<7p,ih\\+ShRJ>JStLT5!7GR&s*mjUQ0nVHgtWT+!<<'!!/gi8Mn\"KLWMuisA,rU.WP,cVMZAZ8CG5^H!1>UdMZ<bAQ?nV)O%;El02G@s:JUu9d?FX[rtLXs^]/\"^Bk_9q*g$E-+sR'`n03c7rrE)Sgt_]\"s8U[Ng8,pBJ:IWM!3Q8SJ:N1>s7$&&[*;i\\9)sSDs7#O?N99:!s7#]/quHcnc)oX\\n:6&Is8VrldaQ[oORA4Ze'n?*_>g0S+L8#&cMDa@R<OITYf,Dus53nW!&DeSqXEYI!<7QL!+sKU!!(9T<R[.NgH;f^HYDgIqO0t&bf:HP)&[Dds8)cViW%uHs5'jX!.b%@k(%s^CQ9Y>V#^Na!8;DCmc^[<qj=STmb;]Es6nM<g:>I^5QAOBh4WT.i9#OiJH#TL]T8+>C#Ot='Dd6\"oV>kIMc]rOm\\!H0^qda@cKf4Kc#A2pE.F&MqYC3lIn#$sd^4r5J:Q:ef`,GO5iC#WK'r<gZiC(*p%A\"XrrAM41&q:S";
var a = function(s){
var n = s.length, r = [], b = [0, 0, 0, 0, 0], i, j, t, x, y, d;
for(i = 0; i < n; i += 5){
for(j = 0; j < 5; ++j){ b[j] = s.charCodeAt(i + j) - 33; }
t = (((b[0] * 85 + b[1]) * 85 + b[2]) * 85 + b[3]) * 85 + b[4];
x = t & 255; t >>>= 8; y = t & 255; t >>>= 8;
r.push(t >>> 8, t & 255, y, x);
}
return r;
};
var B = function(f){ this.f = f; this.y = this.t = 0; };
B.prototype.g = function(b){
var r = 0;
while(b){
var w = Math.min(b, 8 - this.t), v = this.f[this.y] >>> (8 - this.t - w);
r <<= w; r |= v & ~(~0 << w);
if((this.t += w) == 8){ ++this.y; this.t = 0; }
b -= w;
}
return r;
};
var D = function(n, w){
this.c = new Array(n); this.w = w; this.p = -1;
for(var i = 0; i < n; ++i){ this.c[i] = [i + 97]; }
};
D.prototype.d = function(s){
var c = s.g(this.w), v;
if(c < this.c.length){
v = this.c[c];
if(this.p >= 0){
this.c.push(this.c[this.p].concat(v[0]));
}
}else{
this.c.push([]);
++this.w;
return [];
}
this.p = c;
return v;
};
var i = new B(a(n)), d = new D(27, 5), t = [];
while(t.length < 1455){
var v = d.d(i);
dojo.forEach(v, function(x){ t.push(x); });
}
var n2 = dojo.map(t, function(x){ return String.fromCharCode(x); }).join("").split("{");
i = a(c);
for(var j = 0, k = 0; j < n2.length; ++j){
dojox.encoding.tests.colors2[n2[j]] = [i[k++], i[k++], i[k++]];
}
 
})();
 
}
/trunk/api/js/dojo1.0/dojox/encoding/tests/colors3.js
New file
0,0 → 1,53
if(!dojo._hasResource["dojox.encoding.tests.colors3"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.tests.colors3"] = true;
dojo.provide("dojox.encoding.tests.colors3");
 
// all CSS3 colors
dojox.encoding.tests.colors3 = {};
 
(function(){
var n = "!N!C@\",5%;!.4)1D7()4E!K!FS-!2).Q:52E`!B\"!;!)*+I!M!#&'E+9%(#!T9Q=.\"TE5F'6%$B91H/)DCQW=^&G#QY>:\"!!?*#D.57Z.]5**+0]/!G!!,X=/%2O'%1U&#W9%%86_BQU3#!N.!DA-%F>X'#9;6\"%+EK)X#A+A;+-+\"G\"T$76:L1;)'+?ENA1%L+C\\O+U+\"Q!+#,E+.E1H-[VA#\"5%O\\X)BS:%V2&2#,3I0NWE%F7?L8U!U\\\\B3C_GZ?P3N]A3\\]$)%TUK$E9EL6ZA`T%IFY$Q?/3;=Q)$QE#AQ\\11$&M!'$$XK!T?2%C7QU\"110A#/#:'U=C!7,\"=*!+BQ)%AG[)W&#CFBG\"A!/1E!5/$AU\"A/$J:*E+LQ77;%M6H/XD,H1'!)#U=&K1\"&R02U'$H5*[%Y+$3;/1'#\"-XQV8C(/GABVQQW+RS5U3QE!V<6[=YS@!0=1!:Z=93M$7W\":3;!Z0!GJM'\"QGAJ*=3(C&5I=0,6AP6H4+=:M:B)CO-D?]<,2^H-`7S<E8%#\\\\G=1ZM^B)8$9VJHI]>EB(B5N5%Z9P!8BM`FK@D!9*!ZQ]]/D1SF[%RG.D+HO(8QI.BK.RS*/C#/GJOTUU/WSTX19$R[$T#'P&L\"]V03\\_Y5_UH!?/!;\"J>YHO%8S_`2]/H`T_'%?B4?AX!.:^X!Z9E0A!!S\"5M\"A:2^?AA2R*9;!.!!&1!!E:AN)7'16,AM\"+\"Y'D0.'*Q=.%!S)!'*S)@5*$7D*9H@#U710\"MUG4,)<Q;DI95OE%9DY\"1_I4E3!2C7+/I[+\"*A0E!\"\",!>Z'!F-%15E\"\"J!#+$A0':>#G?1%8G#29I31U:2H\"I:3A<V'DC!-!RB2]:BI;>K4C&C;ZY\"J[C]HG6!3&*4K!!AP9:IA#T2\"'A%-+9]WWJ*MU3I\"MWY\")$79\"*]QZ@:[ZZ#^43G=Q;!P)E%QN3RZQ4!Y.KP\"J_8\\B/3RD#S6+YB]*&!3M6A+#2Q'9M-&DI!!";
var c = "]0D`_OP8!0``@``5]0``^@8=`_4%!!!!`_P.!!$`CCPCJ3IKXLC(8Z[A@`]!UGE?`X^1:*8N``D=X\"1]!0``!!#,!)O,O)9,K;GJ!'1!K;GJP<>LCQ#,67MP`YQ!G4,-CQ!![::[D\\S03$W,,U^0,U^0!-\\2F!$4`R34!,``;7FJ;7FJ(J$`MC)C``LQ)IMC`Q$`X.T=_0D``^=!WK5AA)#!!)!!L@]PA)#!]0`Q`WGUT6R=3Q##```Q]/;-ZO<[``$V@0Q!``L.L>DG])#!Y0``_PL3U^04E/[1U^04`\\<\"`[\"[),+KB]\\[>YC:>YC:M-4?```A!0]!-MUS_P$G`Q$`A!!!:MWK!!$.OF84EX$<0,.R?WDO!0K;3.(-RR7&'2FQ^@`[`_4B`_3V`^[N!!#!`@8GA)!!;YYD`[5!`U5!WH$7\\OCKG0O9L_\\OWX#4`_`6`^KZT95``]$,X;$>M/$GA!#!`Q!!P)_017HBCU54_I\"S^+2A,IN8``8OI&)NQ-$!B]\\L;FL.=)#1=)#1``L[!0^`2I+UUL3-!)#!W,`9`W.(1/$1\\I,O^>[T````^@8V``]!GMUS!!!!";
var B = function(f){ var t = this; t.f = f; t.y = t.t = 0; t.x = f.charCodeAt(0) - 33; };
B.prototype.g = function(b){
var r = 0, t = this;
while(b){
var w = Math.min(b, 6 - t.t), v = t.x >>> (6 - t.t - w);
r <<= w; r |= v & ~(~0 << w);
if((t.t += w) == 6){ t.x = t.f.charCodeAt(++t.y) - 33; t.t = 0; }
b -= w;
}
return r;
};
var D = function(n, w){
this.c = new Array(n); this.w = w; this.p = -1;
for(var i = 0; i < n; ++i){ this.c[i] = [i + 97]; }
};
D.prototype.d = function(s){
var c = s.g(this.w), t = this, v;
if(c < t.c.length){
v = t.c[c];
if(t.p >= 0){
t.c.push(t.c[t.p].concat(v[0]));
}
}else{
t.c.push([]);
++t.w;
return [];
}
t.p = c;
return v;
};
var i = new B(n), d = new D(27, 5), t = [];
while(t.length < 1455){
var v = d.d(i);
dojo.forEach(v, function(x){ t.push(x); });
}
var n2 = dojo.map(t, function(x){ return String.fromCharCode(x); }).join("").split("{");
i = new B(c);
for(var j = 0; j < n2.length; ++j){
dojox.encoding.tests.colors3[n2[j]] = [i.g(8), i.g(8), i.g(8)];
}
})();
 
}
/trunk/api/js/dojo1.0/dojox/encoding/tests/ascii85.js
New file
0,0 → 1,35
if(!dojo._hasResource["dojox.encoding.tests.ascii85"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.tests.ascii85"] = true;
dojo.provide("dojox.encoding.tests.ascii85");
dojo.require("dojox.encoding.ascii85");
 
(function(){
var msg1 = "The rain in Spain falls mainly on the plain.";
var msg2 = "The rain in Spain falls mainly on the plain.1";
var msg3 = "The rain in Spain falls mainly on the plain.ab";
var msg4 = "The rain in Spain falls mainly on the plain.!@#";
var dca = dojox.encoding.ascii85;
var s2b = function(s){
var b = [];
for(var i = 0; i < s.length; ++i){
b.push(s.charCodeAt(i));
}
return b;
};
 
var b2s = function(b){
var s = [];
dojo.forEach(b, function(c){ s.push(String.fromCharCode(c)); });
return s.join("");
};
 
tests.register("dojox.encoding.tests.ascii85", [
function testMsg1(t){ t.assertEqual(msg1, b2s(dca.decode(dca.encode(s2b(msg1))))); },
function testMsg2(t){ t.assertEqual(msg2, b2s(dca.decode(dca.encode(s2b(msg2))))); },
function testMsg3(t){ t.assertEqual(msg3, b2s(dca.decode(dca.encode(s2b(msg3))))); },
function testMsg4(t){ t.assertEqual(msg4, b2s(dca.decode(dca.encode(s2b(msg4))))); }
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/encoding/tests/encoding.js
New file
0,0 → 1,15
if(!dojo._hasResource["dojox.encoding.tests.encoding"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.tests.encoding"] = true;
dojo.provide("dojox.encoding.tests.encoding");
 
try{
dojo.require("dojox.encoding.tests.ascii85");
dojo.require("dojox.encoding.tests.easy64");
dojo.require("dojox.encoding.tests.bits");
dojo.require("dojox.encoding.tests.splay");
dojo.require("dojox.encoding.tests.lzw");
}catch(e){
doh.debug(e);
}
 
}
/trunk/api/js/dojo1.0/dojox/encoding/tests/test.html
New file
0,0 → 1,61
<html>
<head>
<title>Test colors</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
.pane { margin-top: 2em; }
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="colors2.js"></script>
<script type="text/javascript">
dojo.require("dojox.encoding.tests.colors");
//dojo.require("dojox.encoding.tests.colors2");
dojo.require("dojox.encoding.tests.colors3");
var dct = dojox.encoding.tests;
var test = function(c1, c2, result){
var empty = {};
for(var i in c1){
if(i in empty){ continue; }
if(!(i in c2)){
result.push("<div>" + i + " is missing.</div>");
continue;
}
var v1 = c1[i], v2 = c2[i];
if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]){
result.push("<div>" + i + " doesn't match.</div>");
continue;
}
result.push("<div style='color: green'>" + i + " is ok.</div>");
}
};
var run = function(){
var result = [];
result.push("<p><strong>Comparing colors to colors3.</strong></p>");
test(dct.colors, dct.colors3, result);
result.push("<p><strong>Comparing colors3 to colors.</strong></p>");
test(dct.colors3, dct.colors, result);
/*
result.push("<p><strong>Comparing colors to colors2.</strong></p>");
test(dct.colors, dct.colors2, result);
result.push("<p><strong>Comparing colors2 to colors.</strong></p>");
test(dct.colors2, dct.colors, result);
*/
dojo.byId("status").innerHTML = result.join("\n");
};
dojo.addOnLoad(function(){
dojo.connect(dojo.byId("run"), "onclick", run);
});
</script>
</head>
<body>
<h1>Test colors</h1>
<p><button id="run">Run</button></p>
<div id="status" class="pane"><em>No status yet.</em></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/encoding/tests/splay.js
New file
0,0 → 1,49
if(!dojo._hasResource["dojox.encoding.tests.splay"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.tests.splay"] = true;
dojo.provide("dojox.encoding.tests.splay");
dojo.require("dojox.encoding.splay");
dojo.require("dojox.encoding.bits");
 
(function(){
var msg1 = "The rain in Spain falls mainly on the plain.";
var msg2 = "The rain in Spain falls mainly on the plain.1";
var msg3 = "The rain in Spain falls mainly on the plain.ab";
var msg4 = "The rain in Spain falls mainly on the plain.!@#";
var dc = dojox.encoding, dcb = dc.bits;
var s2b = function(s){
var b = [];
for(var i = 0; i < s.length; ++i){
b.push(s.charCodeAt(i));
}
return b;
};
 
var b2s = function(b){
var s = [];
dojo.forEach(b, function(c){ s.push(String.fromCharCode(c)); });
return s.join("");
};
var encode = function(msg){
var x = new dcb.OutputStream(), encoder = new dc.Splay(256);
dojo.forEach(s2b(msg), function(v){ encoder.encode(v, x); });
console.debug("bits =", x.getWidth());
return x.getBuffer();
};
var decode = function(n, buf){
var x = new dcb.InputStream(buf, buf.length * 8), decoder = new dc.Splay(256), t = [];
for(var i = 0; i < n; ++i){ t.push(decoder.decode(x)); }
return b2s(t);
};
 
tests.register("dojox.encoding.tests.splay", [
function testSplayMsg1(t){ t.assertEqual(msg1, decode(msg1.length, encode(msg1))); },
function testSplayMsg2(t){ t.assertEqual(msg2, decode(msg2.length, encode(msg2))); },
function testSplayMsg3(t){ t.assertEqual(msg3, decode(msg3.length, encode(msg3))); },
function testSplayMsg4(t){ t.assertEqual(msg4, decode(msg4.length, encode(msg4))); }
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/encoding/tests/colors2.html
New file
0,0 → 1,104
<html>
<head>
<title>Compress colors</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
.pane { margin-top: 2em; }
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
dojo.require("dojox.encoding.tests.colors");
dojo.require("dojox.encoding.ascii85");
dojo.require("dojox.encoding.bits");
dojo.require("dojox.encoding.splay");
dojo.require("dojox.encoding.lzw");
var dc = dojox.encoding, colors = dc.tests.colors;
var run = function(){
var empty = {}, names = [];
for(var i in colors){
if(i in empty){ continue; }
names.push(i);
}
names.sort();
var output = new dc.bits.OutputStream(), result = [];
// encode names
var s = names.join("{"), encoder = new dc.lzw.Encoder(27);
result.push("<div>Input is " + s.length + " bytes long.</div>");
result.push("<div>Input: " + s + ".</div>");
for(var i = 0; i < s.length; ++i){
var v = s.charCodeAt(i) - 97;
if(v < 0 || v > 26) console.debug("error!", v);
encoder.encode(v, output);
}
encoder.flush(output);
var w = output.getWidth();
result.push("<div>Output is " + Math.ceil(w / 8) + " bytes (" + w + " bits) long.</div>");
var buf = output.getBuffer();
{
var input = new dc.bits.InputStream(buf, buf.length * 8), decoder = new dc.lzw.Decoder(27);
var t = [];
for(var w = 0; w < s.length;){
var v = decoder.decode(input);
t.push(v);
w += v.length;
}
t = t.join("");
var p = [];
for(var i = 0; i < t.length; ++i){
p.push(String.fromCharCode(t.charCodeAt(i) + 97));
}
p = p.join("");
result.push("<div>Control: " + p + ".</div>");
}
while(buf.length % 4){ buf.push(0); }
var a85 = dc.ascii85.encode(buf);
result.push("<div>Encoded output is " + a85.length + " bytes.</div>");
result.push("<div><textarea>" + a85 + "</textarea></div>");
// test
{
var buf = dc.ascii85.decode(a85);
var input = new dc.bits.InputStream(buf, buf.length * 8), decoder = new dc.lzw.Decoder(27);
var t = [];
for(var w = 0; w < s.length;){
var v = decoder.decode(input);
t.push(v);
w += v.length;
}
t = t.join("");
var p = [];
for(var i = 0; i < t.length; ++i){
p.push(String.fromCharCode(t.charCodeAt(i) + 97));
}
p = p.join("");
result.push("<div>Control: " + p + ".</div>");
}
// encode values
buf = [];
for(var i = 0; i < names.length; ++i){
var c = colors[names[i]];
buf.push(c[0], c[1], c[2]);
}
result.push("<div>Output is " + buf.length + " bytes long.</div>");
while(buf.length % 4){ buf.push(0); }
a85 = dc.ascii85.encode(buf);
result.push("<div>Encoded output is " + a85.length + " bytes.</div>");
result.push("<div><textarea>" + a85 + "</textarea></div>");
dojo.byId("status").innerHTML = result.join("\n");
};
dojo.addOnLoad(function(){
dojo.connect(dojo.byId("run"), "onclick", run);
});
</script>
</head>
<body>
<h1>Compress colors</h1>
<p><button id="run">Run</button></p>
<div id="status" class="pane"><em>No status yet.</em></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/encoding/tests/easy64.js
New file
0,0 → 1,35
if(!dojo._hasResource["dojox.encoding.tests.easy64"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.tests.easy64"] = true;
dojo.provide("dojox.encoding.tests.easy64");
dojo.require("dojox.encoding.easy64");
 
(function(){
var msg1 = "The rain in Spain falls mainly on the plain.";
var msg2 = "The rain in Spain falls mainly on the plain.1";
var msg3 = "The rain in Spain falls mainly on the plain.ab";
var msg4 = "The rain in Spain falls mainly on the plain.!@#";
var dce = dojox.encoding.easy64;
var s2b = function(s){
var b = [];
for(var i = 0; i < s.length; ++i){
b.push(s.charCodeAt(i));
}
return b;
};
 
var b2s = function(b){
var s = [];
dojo.forEach(b, function(c){ s.push(String.fromCharCode(c)); });
return s.join("");
};
 
tests.register("dojox.encoding.tests.easy64", [
function testEasyMsg1(t){ t.assertEqual(msg1, b2s(dce.decode(dce.encode(s2b(msg1))))); },
function testEasyMsg2(t){ t.assertEqual(msg2, b2s(dce.decode(dce.encode(s2b(msg2))))); },
function testEasyMsg3(t){ t.assertEqual(msg3, b2s(dce.decode(dce.encode(s2b(msg3))))); },
function testEasyMsg4(t){ t.assertEqual(msg4, b2s(dce.decode(dce.encode(s2b(msg4))))); }
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/encoding/tests/colors3.html
New file
0,0 → 1,104
<html>
<head>
<title>Compress colors</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
.pane { margin-top: 2em; }
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
dojo.require("dojox.encoding.tests.colors");
dojo.require("dojox.encoding.easy64");
dojo.require("dojox.encoding.bits");
dojo.require("dojox.encoding.splay");
dojo.require("dojox.encoding.lzw");
var dc = dojox.encoding, colors = dc.tests.colors;
var run = function(){
var empty = {}, names = [];
for(var i in colors){
if(i in empty){ continue; }
names.push(i);
}
names.sort();
var output = new dc.bits.OutputStream(), result = [];
// encode names
var s = names.join("{"), encoder = new dc.lzw.Encoder(27);
result.push("<div>Input is " + s.length + " bytes long.</div>");
result.push("<div>Input: " + s + ".</div>");
for(var i = 0; i < s.length; ++i){
var v = s.charCodeAt(i) - 97;
if(v < 0 || v > 26) console.debug("error!", v);
encoder.encode(v, output);
}
encoder.flush(output);
var w = output.getWidth();
result.push("<div>Output is " + Math.ceil(w / 8) + " bytes (" + w + " bits) long.</div>");
var buf = output.getBuffer();
{
var input = new dc.bits.InputStream(buf, buf.length * 8), decoder = new dc.lzw.Decoder(27);
var t = [];
for(var w = 0; w < s.length;){
var v = decoder.decode(input);
t.push(v);
w += v.length;
}
t = t.join("");
var p = [];
for(var i = 0; i < t.length; ++i){
p.push(String.fromCharCode(t.charCodeAt(i) + 97));
}
p = p.join("");
result.push("<div>Control: " + p + ".</div>");
}
while(buf.length % 3){ buf.push(0); }
var e64 = dc.easy64.encode(buf);
result.push("<div>Encoded output is " + e64.length + " bytes.</div>");
result.push("<div><textarea>" + e64 + "</textarea></div>");
// test
{
var buf = dc.easy64.decode(e64);
var input = new dc.bits.InputStream(buf, buf.length * 8), decoder = new dc.lzw.Decoder(27);
var t = [];
for(var w = 0; w < s.length;){
var v = decoder.decode(input);
t.push(v);
w += v.length;
}
t = t.join("");
var p = [];
for(var i = 0; i < t.length; ++i){
p.push(String.fromCharCode(t.charCodeAt(i) + 97));
}
p = p.join("");
result.push("<div>Control: " + p + ".</div>");
}
// encode values
buf = [];
for(var i = 0; i < names.length; ++i){
var c = colors[names[i]];
buf.push(c[0], c[1], c[2]);
}
result.push("<div>Output is " + buf.length + " bytes long.</div>");
while(buf.length % 4){ buf.push(0); }
e64 = dc.easy64.encode(buf);
result.push("<div>Encoded output is " + e64.length + " bytes.</div>");
result.push("<div><textarea>" + e64 + "</textarea></div>");
dojo.byId("status").innerHTML = result.join("\n");
};
dojo.addOnLoad(function(){
dojo.connect(dojo.byId("run"), "onclick", run);
});
</script>
</head>
<body>
<h1>Compress colors</h1>
<p><button id="run">Run</button></p>
<div id="status" class="pane"><em>No status yet.</em></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/encoding/tests/lzw.js
New file
0,0 → 1,54
if(!dojo._hasResource["dojox.encoding.tests.lzw"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.tests.lzw"] = true;
dojo.provide("dojox.encoding.tests.lzw");
dojo.require("dojox.encoding.lzw");
dojo.require("dojox.encoding.bits");
 
(function(){
var msg1 = "The rain in Spain falls mainly on the plain.";
var msg2 = "The rain in Spain falls mainly on the plain.1";
var msg3 = "The rain in Spain falls mainly on the plain.ab";
var msg4 = "The rain in Spain falls mainly on the plain.!@#";
var dc = dojox.encoding, dcb = dc.bits, dcl = dc.lzw;
var s2b = function(s){
var b = [];
for(var i = 0; i < s.length; ++i){
b.push(s.charCodeAt(i));
}
return b;
};
 
var b2s = function(b){
var s = [];
dojo.forEach(b, function(c){ s.push(String.fromCharCode(c)); });
return s.join("");
};
var encode = function(msg){
var x = new dcb.OutputStream(), encoder = new dcl.Encoder(128);
dojo.forEach(s2b(msg), function(v){ encoder.encode(v, x); });
encoder.flush(x);
console.debug("bits =", x.getWidth());
return x.getBuffer();
};
var decode = function(n, buf){
var x = new dcb.InputStream(buf, buf.length * 8), decoder = new dcl.Decoder(128), t = [], w = 0;
while(w < n){
var v = decoder.decode(x);
t.push(v);
w += v.length;
}
return t.join("");
};
 
tests.register("dojox.encoding.tests.lzw", [
function testLzwMsg1(t){ t.assertEqual(msg1, decode(msg1.length, encode(msg1))); },
function testLzwMsg2(t){ t.assertEqual(msg2, decode(msg2.length, encode(msg2))); },
function testLzwMsg3(t){ t.assertEqual(msg3, decode(msg3.length, encode(msg3))); },
function testLzwMsg4(t){ t.assertEqual(msg4, decode(msg4.length, encode(msg4))); }
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/encoding/tests/vq.html
New file
0,0 → 1,185
<html>
<head>
<title>Compress colors using VQ</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
.pane { margin-top: 2em; }
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
dojo.require("dojox.encoding.tests.colors");
dojo.require("dojox.encoding.splay");
dojo.require("dojox.encoding.bits");
var colors = dojox.encoding.tests.colors;
var dist = function(a, b){
var r = a[0] - b[0], g = a[1] - b[1], b = a[2] - b[2];
return r * r + g * g + b * b;
};
var hexcolor = function(c){
return "#" + (c[0] < 16 ? "0" : "") + c[0].toString(16) +
(c[1] < 16 ? "0" : "") + c[1].toString(16) +
(c[2] < 16 ? "0" : "") + c[2].toString(16);
};
var maxdist = function(a, b, maxdist){
var r = Math.abs(a[0] - b[0]), g = Math.abs(a[1] - b[1]), b = Math.abs(a[2] - b[2]);
++maxdist[bits(r)];
++maxdist[bits(g)];
++maxdist[bits(b)];
};
var encodeColor = function(a, b, splay, stream){
var r = a[0] - b[0], g = a[1] - b[1], b = a[2] - b[2];
stream.putBits(r < 0 ? 1 : 0, 1);
splay.encode(Math.abs(r), stream);
stream.putBits(g < 0 ? 1 : 0, 1);
splay.encode(Math.abs(g), stream);
stream.putBits(b < 0 ? 1 : 0, 1);
splay.encode(Math.abs(b), stream);
};
var bits = function(x){
var w = 1;
for(var v = 2; x >= v; v <<= 1, ++w);
return w;
};
var runVQ = function(n){
dojo.byId("status").innerHTML = "<em>Initializing...</em>";
dojo.byId("report").innerHTML = "<em>Running VQ...</em>";
var clusters = [];
// select initial cluster centers
var empty = {};
for(var i in colors){
if(i in empty){ continue; }
clusters.push({center: colors[i]});
if(clusters.length == n){ break; }
}
/*
for(var i = 0; i < n; ++i){
var r = Math.floor(Math.random() * 256), g = Math.floor(Math.random() * 256), b = Math.floor(Math.random() * 256);
clusters.push({center: [r, g, b]});
}
*/
// do runs
dojo.byId("status").innerHTML = "<div>Starting runs...</div>";
var jitter = 0, niter = 1;
do {
// save previous centers
var old_clusters = [];
dojo.forEach(clusters, function(c){ old_clusters.push({center: c.center}); c.members = []; });
// assign colors to clusters
for(var i in colors){
if(i in empty){ continue; }
var c = colors[i], k = -1, kd = Number.MAX_VALUE;
for(var j = 0; j < clusters.length; ++j){
var jd = dist(clusters[j].center, c);
if(jd < kd){ k = j, kd = jd; }
}
clusters[k].members.push(i);
}
// recalculate cluster centers
for(var i = 0; i < clusters.length; ++i){
if(!clusters[i].members.length){ continue; }
var r = 0, g = 0, b = 0;
dojo.forEach(clusters[i].members, function(name){
var c = colors[name];
r += c[0];
g += c[1];
b += c[2];
});
r = Math.round(r / clusters[i].members.length);
g = Math.round(g / clusters[i].members.length);
b = Math.round(b / clusters[i].members.length);
clusters[i].center = [r, g, b];
}
// calculate the jitter
jitter = 0;
for(var i = 0; i < clusters.length; ++i){
jitter = Math.max(jitter, dist(clusters[i].center, old_clusters[i].center));
}
var node = dojo.doc.createElement("div");
node.innerHTML = "Run #" + niter + ", jitter = " + jitter;
dojo.byId("status").appendChild(node);
++niter;
}while(jitter > 1 && niter < 1000);
// calculate the required number of bytes
var output = new dojox.encoding.bits.OutputStream(),
splay = new dojox.encoding.Splay(256);
for(var i = 0; i < clusters.length; ++i){
var c = clusters[i], m = c.members, d = 0, ol = output.getWidth();
output.putBits(c.center[0], 8);
output.putBits(c.center[1], 8);
output.putBits(c.center[2], 8);
splay.init();
c.maxdist = [0, 0, 0, 0, 0, 0, 0, 0, 0];
for(var j = 0; j < m.length; ++j){
var color = colors[m[j]];
maxdist(c.center, color, c.maxdist);
encodeColor(c.center, color, splay, output);
}
c.bits = output.getWidth() - ol;
}
var node = dojo.doc.createElement("div");
node.innerHTML = "Required " + Math.ceil(output.getWidth() / 8) + " bytes";
dojo.byId("status").appendChild(node);
// generate color tables
var reps = [];
for(var i = 0; i < clusters.length; ++i){
var c = clusters[i], m = c.members;
reps.push("<p>Cluster #" + i + " contains " + m.length + " members. Length histogram:");
for(var j = 0; j < c.maxdist.length; ++j){
if(c.maxdist[j]){
reps.push(" " + j + "&mdash;" + c.maxdist[j]);
}
}
reps.push(". It requires " + c.bits + " bits (" + Math.ceil(c.bits / 8) + " bytes) to be encoded.</p>");
reps.push("<table>");
var wd = dist([255,255,255], c.center), bd = dist([0,0,0], c.center);
reps.push("<tr><td style='background: " + hexcolor(c.center) + "; color: " +
(wd < bd ? "black" : "white") + "'><strong>CENTER</strong></td><td>" +
c.center[0] + "</td><td>" + c.center[1] + "</td><td>" + c.center[2] + "</td></tr>");
for(var j = 0; j < m.length; ++j){
var color = colors[m[j]];
wd = dist([255,255,255], color);
bd = dist([0,0,0], color);
reps.push("<tr><td style='background: " + m[j] + "; color: " +
(wd < bd ? "black" : "white") + "'><strong>" + m[j] + "</strong></td><td>" +
color[0] + "</td><td>" + color[1] + "</td><td>" + color[2] + "</td></tr>");
}
reps.push("</table>");
}
dojo.byId("report").innerHTML = reps.join("\n");
};
run = function(){
var n = parseInt(dojo.byId("ncluster").value);
runVQ(n);
};
dojo.addOnLoad(function(){
dojo.connect(dojo.byId("run"), "onclick", run);
});
</script>
</head>
<body>
<h1>Compress colors using VQ</h1>
<p>Select desirable number of clusters:&nbsp;<select id="ncluster">
<option value="1">1</option>
<option value="2">2</option>
<option value="4">4</option>
<option value="8">8</option>
<option value="16">16</option>
<option value="32">32</option>
<option value="64">64</option>
</select>&nbsp;<button id="run">Run</button></p>
<div id="status" class="pane"><em>No status yet.</em></div>
<div id="report" class="pane"><em>No results yet.</em></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/encoding/splay.js
New file
0,0 → 1,63
if(!dojo._hasResource["dojox.encoding.splay"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.splay"] = true;
dojo.provide("dojox.encoding.splay");
 
dojox.encoding.Splay = function(n){
this.up = new Array(2 * n + 1);
this.left = new Array(n);
this.right = new Array(n);
this.reset();
};
 
dojo.extend(dojox.encoding.Splay, {
reset: function(){
for(var i = 1; i < this.up.length; this.up[i] = Math.floor((i - 1) / 2), ++i);
for(var i = 0; i < this.left.length; this.left[i] = 2 * i + 1, this.right[i] = 2 * i + 2, ++i);
},
splay: function(i){
var a = i + this.left.length;
do{
var c = this.up[a];
if(c){ // root
// rotated pair
var d = this.up[c];
// swap descendants
var b = this.left[d];
if(c == b){
b = this.right[d];
this.right[d] = a;
} else {
this.left[d] = a;
}
this[a == this.left[c] ? "left" : "right"][c] = b;
this.up[a] = d;
this.up[b] = c;
a = d;
}else{
a = c;
}
}while(a); // root
},
encode: function(value, stream){
var s = [], a = value + this.left.length;
do{
s.push(this.right[this.up[a]] == a);
a = this.up[a];
}while(a); // root
this.splay(value);
var l = s.length;
while(s.length){ stream.putBits(s.pop() ? 1 : 0, 1); }
return l;
},
decode: function(stream){
var a = 0; // root;
do{
a = this[stream.getBits(1) ? "right" : "left"][a];
}while(a < this.left.length);
a -= this.left.length;
this.splay(a);
return a;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/encoding/easy64.js
New file
0,0 → 1,50
if(!dojo._hasResource["dojox.encoding.easy64"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.easy64"] = true;
dojo.provide("dojox.encoding.easy64");
 
(function(){
var c = function(input, length, result){
for(var i = 0; i < length; i += 3){
result.push(
String.fromCharCode((input[i] >>> 2) + 33),
String.fromCharCode(((input[i] & 3) << 4) + (input[i + 1] >>> 4) + 33),
String.fromCharCode(((input[i + 1] & 15) << 2) + (input[i + 2] >>> 6) + 33),
String.fromCharCode((input[i + 2] & 63) + 33)
);
}
};
dojox.encoding.easy64.encode = function(input){
// summary: encodes input data in easy64 string
// input: Array: an array of numbers (0-255) to encode
var result = [], reminder = input.length % 3, length = input.length - reminder;
c(input, length, result);
if(reminder){
var t = input.slice(length);
while(t.length < 3){ t.push(0); }
c(t, 3, result);
for(var i = 3; i > reminder; result.pop(), --i);
}
return result.join(""); // String
};
 
dojox.encoding.easy64.decode = function(input){
// summary: decodes the input string back to array of numbers
// input: String: the input string to decode
var n = input.length, r = [], b = [0, 0, 0, 0], i, j, d;
for(i = 0; i < n; i += 4){
for(j = 0; j < 4; ++j){ b[j] = input.charCodeAt(i + j) - 33; }
d = n - i;
for(j = d; j < 4; b[++j] = 0);
r.push(
(b[0] << 2) + (b[1] >>> 4),
((b[1] & 15) << 4) + (b[2] >>> 2),
((b[2] & 3) << 6) + b[3]
);
for(j = d; j < 4; ++j, r.pop());
}
return r;
};
})();
 
}
/trunk/api/js/dojo1.0/dojox/encoding/lzw.js
New file
0,0 → 1,90
if(!dojo._hasResource["dojox.encoding.lzw"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.lzw"] = true;
dojo.provide("dojox.encoding.lzw");
 
(function(){
var _bits = function(x){
var w = 1;
for(var v = 2; x >= v; v <<= 1, ++w);
return w;
};
 
dojox.encoding.lzw.Encoder = function(n){
this.size = n;
this.init();
};
 
dojo.extend(dojox.encoding.lzw.Encoder, {
init: function(){
this.dict = {};
for(var i = 0; i < this.size; ++i){
this.dict[String.fromCharCode(i)] = i;
}
this.width = _bits(this.code = this.size);
this.p = "";
},
encode: function(value, stream){
var c = String.fromCharCode(value), p = this.p + c, r = 0;
// if already in the dictionary
if(p in this.dict){
this.p = p;
return r;
}
stream.putBits(this.dict[this.p], this.width);
// if we need to increase the code length
if((this.code & (this.code + 1)) == 0){
stream.putBits(this.code++, r = this.width++);
}
// add new string
this.dict[p] = this.code++;
this.p = c;
return r + this.width;
},
flush: function(stream){
if(this.p.length == 0){
return 0;
}
stream.putBits(this.dict[this.p], this.width);
this.p = "";
return this.width;
}
});
 
dojox.encoding.lzw.Decoder = function(n){
this.size = n;
this.init();
};
 
dojo.extend(dojox.encoding.lzw.Decoder, {
init: function(){
this.codes = new Array(this.size);
for(var i = 0; i < this.size; ++i){
this.codes[i] = String.fromCharCode(i);
}
this.width = _bits(this.size);
this.p = -1;
},
decode: function(stream){
var c = stream.getBits(this.width), v;
if(c < this.codes.length){
v = this.codes[c];
if(this.p >= 0){
this.codes.push(this.codes[this.p] + v.substr(0, 1));
}
}else{
if((c & (c + 1)) == 0){
this.codes.push("");
++this.width;
return "";
}
var x = this.codes[this.p];
v = x + x.substr(0, 1);
this.codes.push(v);
}
this.p = c;
return v;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/encoding/bits.js
New file
0,0 → 1,68
if(!dojo._hasResource["dojox.encoding.bits"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.bits"] = true;
dojo.provide("dojox.encoding.bits");
 
dojox.encoding.bits.OutputStream = function(){
this.reset();
};
 
dojo.extend(dojox.encoding.bits.OutputStream, {
reset: function(){
this.buffer = [];
this.accumulator = 0;
this.available = 8;
},
putBits: function(value, width){
while(width){
var w = Math.min(width, this.available);
var v = (w <= width ? value >>> (width - w) : value) << (this.available - w);
this.accumulator |= v & (255 >>> (8 - this.available));
this.available -= w;
if(!this.available){
this.buffer.push(this.accumulator);
this.accumulator = 0;
this.available = 8;
}
width -= w;
}
},
getWidth: function(){
return this.buffer.length * 8 + (8 - this.available);
},
getBuffer: function(){
var b = this.buffer;
if(this.available < 8){ b.push(this.accumulator & (255 << this.available)); }
this.reset();
return b;
}
});
 
dojox.encoding.bits.InputStream = function(buffer, width){
this.buffer = buffer;
this.width = width;
this.bbyte = this.bit = 0;
};
 
dojo.extend(dojox.encoding.bits.InputStream, {
getBits: function(width){
var r = 0;
while(width){
var w = Math.min(width, 8 - this.bit);
var v = this.buffer[this.bbyte] >>> (8 - this.bit - w);
r <<= w;
r |= v & ~(~0 << w);
this.bit += w;
if(this.bit == 8){
++this.bbyte;
this.bit = 0;
}
width -= w;
}
return r;
},
getWidth: function(){
return this.width - this.bbyte * 8 - this.bit;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/encoding/README
New file
0,0 → 1,35
-------------------------------------------------------------------------------
DojoX Encoding
-------------------------------------------------------------------------------
Version 0.1.0
Release date: 7/30/2007
-------------------------------------------------------------------------------
Project state:
expermental
-------------------------------------------------------------------------------
Credits
Eugene Lazutkin
Tom Trenka
-------------------------------------------------------------------------------
Project description
 
DojoX Encoding provides a set of routines for common encoding algorithms.
-------------------------------------------------------------------------------
Dependencies:
 
Encoding only depends on the Dojo Core.
-------------------------------------------------------------------------------
Documentation
 
See the API documentation for details.
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/encoding/*
 
Install into the following directory structure:
/dojox/encoding/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
/trunk/api/js/dojo1.0/dojox/encoding/ascii85.js
New file
0,0 → 1,63
if(!dojo._hasResource["dojox.encoding.ascii85"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.encoding.ascii85"] = true;
dojo.provide("dojox.encoding.ascii85");
 
(function(){
var c = function(input, length, result){
var i, j, n, b = [0, 0, 0, 0, 0];
for(i = 0; i < length; i += 4){
n = ((input[i] * 256 + input[i+1]) * 256 + input[i+2]) * 256 + input[i+3];
if(!n){
result.push("z");
}else{
for(j = 0; j < 5; b[j++] = n % 85 + 33, n = Math.floor(n / 85));
}
result.push(String.fromCharCode(b[4], b[3], b[2], b[1], b[0]));
}
};
dojox.encoding.ascii85.encode = function(input){
// summary: encodes input data in ascii85 string
// input: Array: an array of numbers (0-255) to encode
var result = [], reminder = input.length % 4, length = input.length - reminder;
c(input, length, result);
if(reminder){
var t = input.slice(length);
while(t.length < 4){ t.push(0); }
c(t, 4, result);
var x = result.pop();
if(x == "z"){ x = "!!!!!"; }
result.push(x.substr(0, reminder + 1));
}
return result.join(""); // String
};
 
dojox.encoding.ascii85.decode = function(input){
// summary: decodes the input string back to array of numbers
// input: String: the input string to decode
var n = input.length, r = [], b = [0, 0, 0, 0, 0], i, j, t, x, y, d;
for(i = 0; i < n; ++i){
if(input.charAt(i) == "z"){
r.push(0, 0, 0, 0);
continue;
}
for(j = 0; j < 5; ++j){ b[j] = input.charCodeAt(i + j) - 33; }
d = n - i;
if(d < 5){
for(j = d; j < 4; b[++j] = 0);
b[d] = 85;
}
t = (((b[0] * 85 + b[1]) * 85 + b[2]) * 85 + b[3]) * 85 + b[4];
x = t & 255;
t >>>= 8;
y = t & 255;
t >>>= 8;
r.push(t >>> 8, t & 255, y, x);
for(j = d; j < 5; ++j, r.pop());
i += 4;
}
return r;
};
})();
 
}
/trunk/api/js/dojo1.0/dojox/fx.js
New file
0,0 → 1,7
if(!dojo._hasResource["dojox.fx"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.fx"] = true;
dojo.provide("dojox.fx");
 
dojo.require("dojox.fx._base");
 
}
/trunk/api/js/dojo1.0/dojox/math/matrix.js
New file
0,0 → 1,294
if(!dojo._hasResource["dojox.math.matrix"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.math.matrix"] = true;
dojo.provide("dojox.math.matrix");
 
dojo.mixin(dojox.math.matrix, {
iDF:0,
ALMOST_ZERO: 1e-10,
multiply: function(/* Array */a, /* Array */b){
// summary
// Multiply matrix a by matrix b.
var ay=a.length, ax=a[0].length, by=b.length, bx=b[0].length;
if(ax!=by){
console.warn("Can't multiply matricies of sizes " + ax + "," + ay + " and " + bx + "," + by);
return [[0]];
}
var c=[];
for (var k=0; k<ay; k++) {
c[k]=[];
for(var i=0; i<bx; i++){
c[k][i]=0;
for(var m=0; m<ax; m++){
c[k][i]+=a[k][m]*b[m][i];
}
}
}
return c; // Array
},
product: function(/* Array... */){
// summary
// Return the product of N matrices
if (arguments.length==0){
console.warn("can't multiply 0 matrices!");
return 1;
}
var m=arguments[0];
for(var i=1; i<arguments.length; i++){
m=this.multiply(m, arguments[i]);
}
return m; // Array
},
sum: function(/* Array... */){
// summary
// Return the sum of N matrices
if(arguments.length==0){
console.warn("can't sum 0 matrices!");
return 0; // Number
}
var m=this.copy(arguments[0]);
var rows=m.length;
if(rows==0){
console.warn("can't deal with matrices of 0 rows!");
return 0;
}
var cols=m[0].length;
if(cols==0){
console.warn("can't deal with matrices of 0 cols!");
return 0;
}
for(var i=1; i<arguments.length; ++i){
var arg=arguments[i];
if(arg.length!=rows || arg[0].length!=cols){
console.warn("can't add matrices of different dimensions: first dimensions were " + rows + "x" + cols + ", current dimensions are " + arg.length + "x" + arg[0].length);
return 0;
}
for(var r=0; r<rows; r++) {
for(var c=0; c<cols; c++) {
m[r][c]+=arg[r][c];
}
}
}
return m; // Array
},
inverse: function(/* Array */a){
// summary
// Return the inversion of the passed matrix
if(a.length==1 && a[0].length==1){
return [[1/a[0][0]]]; // Array
}
var tms=a.length, m=this.create(tms, tms), mm=this.adjoint(a), det=this.determinant(a), dd=0;
if(det==0){
console.warn("Determinant Equals 0, Not Invertible.");
return [[0]];
}else{
dd=1/det;
}
for(var i=0; i<tms; i++) {
for (var j=0; j<tms; j++) {
m[i][j]=dd*mm[i][j];
}
}
return m; // Array
},
determinant: function(/* Array */a){
// summary
// Calculate the determinant of the passed square matrix.
if(a.length!=a[0].length){
console.warn("Can't calculate the determinant of a non-squre matrix!");
return 0;
}
var tms=a.length, det=1, b=this.upperTriangle(a);
for (var i=0; i<tms; i++){
var bii=b[i][i];
if (Math.abs(bii)<this.ALMOST_ZERO) {
return 0; // Number
}
det*=bii;
}
det*=this.iDF;
return det; // Number
},
upperTriangle: function(/* Array */m){
// Summary
// Find the upper triangle of the passed matrix and return it.
m=this.copy(m);
var f1=0, temp=0, tms=m.length, v=1;
this.iDF=1;
for(var col=0; col<tms-1; col++){
if(typeof m[col][col]!="number") {
console.warn("non-numeric entry found in a numeric matrix: m[" + col + "][" + col + "]=" + m[col][col]);
}
v=1;
var stop_loop=0;
while((m[col][col] == 0) && !stop_loop){
if (col+v>=tms){
this.iDF=0;
stop_loop=1;
}else{
for(var r=0; r<tms; r++){
temp=m[col][r];
m[col][r]=m[col+v][r];
m[col+v][r]=temp;
}
v++;
this.iDF*=-1;
}
}
for(var row=col+1; row<tms; row++){
if(typeof m[row][col]!="number"){
console.warn("non-numeric entry found in a numeric matrix: m[" + row + "][" + col + "]=" + m[row][col]);
}
if(typeof m[col][row]!="number"){
console.warn("non-numeric entry found in a numeric matrix: m[" + col + "][" + row + "]=" + m[col][row]);
}
if(m[col][col]!=0){
var f1=(-1)* m[row][col]/m[col][col];
for (var i=col; i<tms; i++){
m[row][i]=f1*m[col][i]+m[row][i];
}
}
}
}
return m; // Array
},
create: function(/* Number */a, /* Number */b, /* Number? */value){
// summary
// Create a new matrix with rows a and cols b, and pre-populate with value.
value=value||0;
var m=[];
for (var i=0; i<b; i++){
m[i]=[];
for(var j=0; j<a; j++) {
m[i][j]=value;
}
}
return m; // Array
},
ones: function(/* Number */a, /* Number */b){
// summary
// Create a matrix pre-populated with ones
return this.create(a, b, 1); // Array
},
zeros: function(/* Number */a, /* Number */b){
// summary
// Create a matrix pre-populated with zeros
return this.create(a, b); // Array
},
identity: function(/* Number */size, /* Number? */scale){
// summary
// Create an identity matrix based on the size and scale.
scale=scale||1;
var m=[];
for(var i=0; i<size; i++){
m[i]=[];
for(var j=0; j<size; j++){
m[i][j]=(i==j?scale:0);
}
}
return m; // Array
},
adjoint: function(/* Array */a){
// summary
// Find the adjoint of the passed matrix
var tms=a.length;
if(tms<=1){
console.warn("Can't find the adjoint of a matrix with a dimension less than 2");
return [[0]];
}
if(a.length!=a[0].length){
console.warn("Can't find the adjoint of a non-square matrix");
return [[0]];
}
var m=this.create(tms, tms), ap=this.create(tms-1, tms-1);
var ii=0, jj=0, ia=0, ja=0, det=0;
for(var i=0; i<tms; i++){
for (var j=0; j<tms; j++){
ia=0;
for(ii=0; ii<tms; ii++){
if(ii==i){
continue;
}
ja = 0;
for(jj=0; jj<tms; jj++){
if(jj==j){
continue;
}
ap[ia][ja] = a[ii][jj];
ja++;
}
ia++;
}
det=this.determinant(ap);
m[i][j]=Math.pow(-1, (i+j))*det;
}
}
return this.transpose(m); // Array
},
transpose: function(/* Array */a){
// summary
// Transpose the passed matrix (i.e. rows to columns)
var m=this.create(a.length, a[0].length);
for(var i=0; i<a.length; i++){
for(var j=0; j<a[i].length; j++){
m[j][i]=a[i][j];
}
}
return m; // Array
},
format: function(/* Array */a, /* Number? */points){
// summary
// Return a string representation of the matrix, rounded to points (if needed)
points=points||5;
function format_int(x, dp){
var fac=Math.pow(10, dp);
var a=Math.round(x*fac)/fac;
var b=a.toString();
if(b.charAt(0)!="-"){
b=" "+b;
}
if(b.indexOf(".")>-1){
b+=".";
}
while(b.length<dp+3){
b+="0";
}
return b;
}
var ya=a.length;
var xa=ya>0?a[0].length:0;
var buffer="";
for(var y=0; y<ya; y++){
buffer+="| ";
for(var x=0; x<xa; x++){
buffer+=format_int(a[y][x], points)+" ";
}
buffer+="|\n";
}
return buffer; // string
},
copy: function(/* Array */a){
// summary
// Create a copy of the passed matrix
var ya=a.length, xa=a[0].length, m=this.create(xa, ya);
for(var y=0; y<ya; y++){
for(var x=0; x<xa; x++){
m[y][x]=a[y][x];
}
}
return m; // Array
},
scale: function(/* Array */a, /* Number */factor){
// summary
// Create a copy of passed matrix and scale each member by factor.
a=this.copy(a);
var ya=a.length, xa=a[0].length;
for(var y=0; y<ya; y++){
for(var x=0; x<xa; x++){
a[y][x]*=factor;
}
}
return a;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/math/curves.js
New file
0,0 → 1,193
if(!dojo._hasResource["dojox.math.curves"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.math.curves"] = true;
dojo.provide("dojox.math.curves");
 
dojo.mixin(dojox.math.curves, {
Line:function (start, end) {
this.start = start;
this.end = end;
this.dimensions = start.length;
for (var i = 0; i < start.length; i++) {
start[i] = Number(start[i]);
}
for (var i = 0; i < end.length; i++) {
end[i] = Number(end[i]);
}
this.getValue = function (n) {
var retVal = new Array(this.dimensions);
for (var i = 0; i < this.dimensions; i++) {
retVal[i] = ((this.end[i] - this.start[i]) * n) + this.start[i];
}
return retVal;
};
return this;
},
Bezier:function(pnts) {
this.getValue = function (step) {
if (step >= 1) {
return this.p[this.p.length - 1];
}
if (step <= 0) {
return this.p[0];
}
var retVal = new Array(this.p[0].length);
for (var k = 0; j < this.p[0].length; k++) {
retVal[k] = 0;
}
for (var j = 0; j < this.p[0].length; j++) {
var C = 0;
var D = 0;
for (var i = 0; i < this.p.length; i++) {
C += this.p[i][j] * this.p[this.p.length - 1][0] * dojox.math.bernstein(step, this.p.length, i);
}
for (var l = 0; l < this.p.length; l++) {
D += this.p[this.p.length - 1][0] * dojox.math.bernstein(step, this.p.length, l);
}
retVal[j] = C / D;
}
return retVal;
};
this.p = pnts;
return this;
},
CatmullRom:function (pnts, c) {
this.getValue = function (step) {
var percent = step * (this.p.length - 1);
var node = Math.floor(percent);
var progress = percent - node;
var i0 = node - 1;
if (i0 < 0) {
i0 = 0;
}
var i = node;
var i1 = node + 1;
if (i1 >= this.p.length) {
i1 = this.p.length - 1;
}
var i2 = node + 2;
if (i2 >= this.p.length) {
i2 = this.p.length - 1;
}
var u = progress;
var u2 = progress * progress;
var u3 = progress * progress * progress;
var retVal = new Array(this.p[0].length);
for (var k = 0; k < this.p[0].length; k++) {
var x1 = (-this.c * this.p[i0][k]) + ((2 - this.c) * this.p[i][k]) + ((this.c - 2) * this.p[i1][k]) + (this.c * this.p[i2][k]);
var x2 = (2 * this.c * this.p[i0][k]) + ((this.c - 3) * this.p[i][k]) + ((3 - 2 * this.c) * this.p[i1][k]) + (-this.c * this.p[i2][k]);
var x3 = (-this.c * this.p[i0][k]) + (this.c * this.p[i1][k]);
var x4 = this.p[i][k];
retVal[k] = x1 * u3 + x2 * u2 + x3 * u + x4;
}
return retVal;
};
if (!c) {
this.c = 0.7;
} else {
this.c = c;
}
this.p = pnts;
return this;
},
Arc:function (start, end, ccw){
function translate(a,b){
var c=new Array(a.length);
for(var i=0; i<a.length; i++){ c[i]=a[i]+b[i]; }
return c;
}
function invert(a){
var b = new Array(a.length);
for(var i=0; i<a.length; i++){ b[i]=-a[i]; }
return b;
}
var center = dojox.math.midpoint(start, end);
var sides = translate(invert(center), start);
var rad = Math.sqrt(Math.pow(sides[0], 2) + Math.pow(sides[1], 2));
var theta = dojox.math.radiansToDegrees(Math.atan(sides[1] / sides[0]));
if (sides[0] < 0){
theta -= 90;
} else {
theta += 90;
}
dojox.math.curves.CenteredArc.call(this, center, rad, theta, theta + (ccw ? -180 : 180));
},
CenteredArc:function (center, radius, start, end) {
this.center = center;
this.radius = radius;
this.start = start || 0;
this.end = end;
this.getValue = function (n) {
var retVal = new Array(2);
var theta = dojox.math.degreesToRadians(this.start + ((this.end - this.start) * n));
retVal[0] = this.center[0] + this.radius * Math.sin(theta);
retVal[1] = this.center[1] - this.radius * Math.cos(theta);
return retVal;
};
return this;
},
Circle:function(center, radius){
dojox.math.curves.CenteredArc.call(this, center, radius, 0, 360);
return this;
},
Path:function () {
var curves = [];
var weights = [];
var ranges = [];
var totalWeight = 0;
this.add = function (curve, weight) {
if (weight < 0) {
console.error("dojox.math.curves.Path.add: weight cannot be less than 0");
}
curves.push(curve);
weights.push(weight);
totalWeight += weight;
computeRanges();
};
this.remove = function (curve) {
for (var i = 0; i < curves.length; i++) {
if (curves[i] == curve) {
curves.splice(i, 1);
totalWeight -= weights.splice(i, 1)[0];
break;
}
}
computeRanges();
};
this.removeAll = function () {
curves = [];
weights = [];
totalWeight = 0;
};
this.getValue = function (n) {
var found = false, value = 0;
for (var i = 0; i < ranges.length; i++) {
var r = ranges[i];
if (n >= r[0] && n < r[1]) {
var subN = (n - r[0]) / r[2];
value = curves[i].getValue(subN);
found = true;
break;
}
}
if (!found) {
value = curves[curves.length - 1].getValue(1);
}
for (var j = 0; j < i; j++) {
value = dojox.math.points.translate(value, curves[j].getValue(1));
}
return value;
};
function computeRanges() {
var start = 0;
for (var i = 0; i < weights.length; i++) {
var end = start + weights[i] / totalWeight;
var len = end - start;
ranges[i] = [start, end, len];
start = end;
}
}
return this;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/math/_base.js
New file
0,0 → 1,122
if(!dojo._hasResource["dojox.math._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.math._base"] = true;
dojo.provide("dojox.math._base");
 
dojo.mixin(dojox.math, {
degreesToRadians: function(/* Number */n){
// summary
// Convert the passed number to radians.
return (n*Math.PI)/180; // Number
},
radiansToDegrees: function(/* Number */n){
// summary
// Convert the passed number to degrees.
return (n*180)/Math.PI; // Number
},
 
factoral: function(/* Number */n){
// summary
// Return the factoral of n.
if(n<1){
return 0; // Number
}
var ret=1;
for(var i=1; i<=n; i++){
ret*=i;
}
return ret; // Number
},
permutations: function(/* Number */n, /* Number */k){
// summary
// TODO
if(n==0 || k==0){
return 1; // Number
}
return (this.factoral(n)/this.factoral(n-k));
},
combinations: function(/* Number */n, /* Number */r){
// summary
// TODO
if(n==0 || r==0){
return 1; // Number
}
return (this.factoral(n)/(this.factoral(n-r)*this.factoral(r))); // Number
},
bernstein: function(/* Number */t, /* Number */n, /* Number */ i){
// summary
// TODO
return (this.combinations(n, i)*Math.pow(t, i)*Math.pow(1-t, n-i)); // Number
},
gaussian: function(){
// summary
// Return a random number based on the Gaussian algo.
var k=2;
do{
var i=2*Math.random()-1;
var j=2*Math.random()-1;
k = i*i+j*j;
}while(k>=1);
return (i * Math.sqrt((-2*Math.log(k))/k)); // Number
},
 
// basic statistics
sd: function(/* Array */a){
// summary
// Returns the standard deviation of the passed arguments.
return Math.sqrt(this.variance(a)); // Number
},
variance: function(/* Array */a){
// summary
// Find the variance in the passed array of numbers.
var mean=0, squares=0;
dojo.forEach(a, function(item){
mean+=item;
squares+=Math.pow(item,2);
});
return (squares/a.length)-Math.pow(mean/a.length, 2); // Number
},
 
// create a range of numbers
range: function(/* Number */a, /* Number? */b, /* Number? */step){
// summary
// Create a range of numbers based on the parameters.
if(arguments.length<2){
b=a,a=0;
}
var s=step||1;
var range=[];
if(s>0){
for(var i=a; i<b; i+=s){
range.push(i);
}
}else{
if(s<0){
for(var i=a; i>b; i+=s){
range.push(i);
}
}else{
throw new Error("dojox.math.range: step must not be zero.");
}
}
return range; // Array
},
distance: function(/* Array */a, /* Array */b){
// summary
// Calculate the distance between point A and point B
return Math.sqrt(Math.pow(b[0]-a[0],2)+Math.pow(b[1]-a[1],2)); // Number
},
midpoint: function(/* Array */a, /* Array */b){
// summary
// Calculate the midpoint between points A and B. A and B may be multidimensional.
if(a.length!=b.length){
console.error("dojox.math.midpoint: Points A and B are not the same dimensionally.", a, b);
}
var m=[];
for(var i=0; i<a.length; i++){
m[i]=(a[i]+b[i])/2;
}
return m; // Array
}
});
 
}
/trunk/api/js/dojo1.0/dojox/math/README
New file
0,0 → 1,38
-------------------------------------------------------------------------------
DojoX Math
-------------------------------------------------------------------------------
Version 0.9
Release date: 10/20/2007
-------------------------------------------------------------------------------
Project state:
expermental
-------------------------------------------------------------------------------
Credits
Cal Henderson
Dan Pupius
Tom Trenka (ttrenka AT gmail.com)
-------------------------------------------------------------------------------
Project description
 
A port of the main functionality of dojo.math 0.4. Includes advanced math
functions, abstract curve definitions, and some point calculations.
-------------------------------------------------------------------------------
Dependencies:
 
Depends on the Dojo Core, v1.0
-------------------------------------------------------------------------------
Documentation
 
See the API documentation.
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/math.js
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/math/*
 
Install into the following directory structure:
/dojox/math/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
/trunk/api/js/dojo1.0/dojox/color.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.color"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.color"] = true;
dojo.provide("dojox.color");
dojo.require("dojox.color._base");
 
}
/trunk/api/js/dojo1.0/dojox/validate/creditCard.js
New file
0,0 → 1,95
if(!dojo._hasResource["dojox.validate.creditCard"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.validate.creditCard"] = true;
dojo.provide("dojox.validate.creditCard");
 
dojo.require("dojox.validate._base");
 
/*
Validates Credit Cards using account number rules in conjunction with the Luhn algorigthm
*/
 
dojox.validate.isValidCreditCard = function(/*String|Int*/value, /*String*/ccType){
//Summary:
// checks if type matches the # scheme, and if Luhn checksum is accurate (unless its an Enroute card, the checkSum is skipped)
//Value: Boolean
if(value&&ccType&&((ccType.toLowerCase()=='er'||dojox.validate.isValidLuhn(value))&&(dojox.validate.isValidCreditCardNumber(value,ccType.toLowerCase())))){
return true; //Boolean
}
return false; //Boolean
}
dojox.validate.isValidCreditCardNumber = function(/*String|Int*/value,/*String?*/ccType) {
//Summary:
// checks if the # matches the pattern for that card or any card types if none is specified
// value == CC #, white spaces and dashes are ignored
// ccType is of the values in cardinfo -- if Omitted it it returns a | delimited string of matching card types, or false if no matches found
//Value: Boolean
if(typeof value!='string'){
value = String(value);
}
value = value.replace(/[- ]/g,''); //ignore dashes and whitespaces
/* FIXME: not sure on all the abbreviations for credit cards,below is what each stands for atleast to my knowledge
mc: Mastercard
ec: Eurocard
vi: Visa
ax: American Express
dc: Diners Club
bl: Carte Blanch
di: Discover
jcb: JCB
er: Enroute
*/
var results=[];
var cardinfo = {
'mc':'5[1-5][0-9]{14}','ec':'5[1-5][0-9]{14}','vi':'4([0-9]{12}|[0-9]{15})',
'ax':'3[47][0-9]{13}', 'dc':'3(0[0-5][0-9]{11}|[68][0-9]{12})',
'bl':'3(0[0-5][0-9]{11}|[68][0-9]{12})','di':'6011[0-9]{12}',
'jcb':'(3[0-9]{15}|(2131|1800)[0-9]{11})','er':'2(014|149)[0-9]{11}'
};
if(ccType&&dojo.indexOf(cardinfo,ccType.toLowerCase())){
return Boolean(value.match(cardinfo[ccType.toLowerCase()])); // boolean
}else{
for(var p in cardinfo){
if(value.match('^'+cardinfo[p]+'$')!=null){
results.push(p);
}
}
return (results.length)?results.join('|'):false; // string | boolean
}
}
 
dojox.validate.isValidCvv = function(/*String|Int*/value, /*String*/ccType) {
//Summary:
// returns true if the security code (CCV) matches the correct format for supplied ccType
//Value: Boolean
if(typeof value!='string'){
value=String(value);
}
var format;
switch (ccType.toLowerCase()){
case 'mc':
case 'ec':
case 'vi':
case 'di':
format = '###';
break;
case 'ax':
format = '####';
break;
default:
return false; //Boolean
}
var flags = {format:format};
//FIXME? Why does isNumberFormat take an object for flags when its only parameter is either a string or an array inside the object?
if ((value.length == format.length)&&(dojox.validate.isNumberFormat(value, flags))){
return true; //Boolean
}
return false; //Boolean
}
 
}
/trunk/api/js/dojo1.0/dojox/validate/tests/validate.js
New file
0,0 → 1,545
if(!dojo._hasResource["dojox.validate.tests.validate"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.validate.tests.validate"] = true;
dojo.provide("dojox.validate.tests.validate");
 
dojo.require("dojox.validate._base");
dojo.require("dojox.validate.check");
dojo.require("dojox.validate.us");
dojo.require("dojox.validate.ca");
dojo.require("dojox.validate.web");
dojo.require("dojox.validate.isbn");
 
tests.register("dojox.validate.tests.validate",
[{
name: "isText",
runTest: function(tests){
tests.t(dojox.validate.isValidIsbn('0596007590')); //test string input
tests.t(dojox.validate.isValidIsbn('0-596-00759-0')); //test string input with dashes
tests.f(dojox.validate.isValidIsbn(0596007590)); //test numerical input as well
tests.t(dojox.validate.isValidIsbn("960-425-059-0"));
tests.t(dojox.validate.isValidIsbn(9604250590)); //test numerical input as well
tests.t(dojox.validate.isValidIsbn('0-9752298-0-X')); // test string with X
tests.t(dojox.validate.isValidIsbn('0-9752298-0-x'));
tests.t(dojox.validate.isValidIsbn('097522980x'));
tests.t(dojox.validate.isValidIsbn('097522980X'));
tests.f(dojox.validate.isValidIsbn(0596007598)); //testing failures
tests.f(dojox.validate.isValidIsbn('059-600759-X')); //testing failures
tests.f(dojox.validate.isValidIsbn('059600')); // too short
 
tests.t(dojox.validate.isValidIsbn('9780596007591'));
tests.t(dojox.validate.isValidIsbn('978-0-596 00759-1'));
tests.t(dojox.validate.isValidIsbn(9780596007591));
tests.f(dojox.validate.isValidIsbn('978059600759X'));
tests.f(dojox.validate.isValidIsbn('978-3250-596 00759-1 '));
tests.f(dojox.validate.isValidIsbn('3250-596 00759 '));
 
tests.t(dojox.validate.isText(' x'));
tests.t(dojox.validate.isText('x '));
tests.t(dojox.validate.isText(' x '));
tests.f(dojox.validate.isText(' '));
tests.f(dojox.validate.isText(''));
// test lengths
tests.t(dojox.validate.isText('123456', {length: 6} ));
tests.f(dojox.validate.isText('1234567', {length: 6} ));
tests.t(dojox.validate.isText('1234567', {minlength: 6} ));
tests.t(dojox.validate.isText('123456', {minlength: 6} ));
tests.f(dojox.validate.isText('12345', {minlength: 6} ));
tests.f(dojox.validate.isText('1234567', {maxlength: 6} ));
tests.t(dojox.validate.isText('123456', {maxlength: 6} ));
}
},
{
name: "isIpAddress",
runTest: function(tests){
tests.t(dojox.validate.isIpAddress('24.17.155.40'));
tests.f(dojox.validate.isIpAddress('024.17.155.040'));
tests.t(dojox.validate.isIpAddress('255.255.255.255'));
tests.f(dojox.validate.isIpAddress('256.255.255.255'));
tests.f(dojox.validate.isIpAddress('255.256.255.255'));
tests.f(dojox.validate.isIpAddress('255.255.256.255'));
tests.f(dojox.validate.isIpAddress('255.255.255.256'));
 
// test dotted hex
tests.t(dojox.validate.isIpAddress('0x18.0x11.0x9b.0x28'));
tests.f(dojox.validate.isIpAddress('0x18.0x11.0x9b.0x28', {allowDottedHex: false}) );
tests.t(dojox.validate.isIpAddress('0x18.0x000000011.0x9b.0x28'));
tests.t(dojox.validate.isIpAddress('0xff.0xff.0xff.0xff'));
tests.f(dojox.validate.isIpAddress('0x100.0xff.0xff.0xff'));
 
// test dotted octal
tests.t(dojox.validate.isIpAddress('0030.0021.0233.0050'));
tests.f(dojox.validate.isIpAddress('0030.0021.0233.0050', {allowDottedOctal: false}) );
tests.t(dojox.validate.isIpAddress('0030.0000021.0233.00000050'));
tests.t(dojox.validate.isIpAddress('0377.0377.0377.0377'));
tests.f(dojox.validate.isIpAddress('0400.0377.0377.0377'));
tests.f(dojox.validate.isIpAddress('0377.0378.0377.0377'));
tests.f(dojox.validate.isIpAddress('0377.0377.0380.0377'));
tests.f(dojox.validate.isIpAddress('0377.0377.0377.377'));
// test decimal
tests.t(dojox.validate.isIpAddress('3482223595'));
tests.t(dojox.validate.isIpAddress('0'));
tests.t(dojox.validate.isIpAddress('4294967295'));
tests.f(dojox.validate.isIpAddress('4294967296'));
tests.f(dojox.validate.isIpAddress('3482223595', {allowDecimal: false}));
// test hex
tests.t(dojox.validate.isIpAddress('0xCF8E83EB'));
tests.t(dojox.validate.isIpAddress('0x0'));
tests.t(dojox.validate.isIpAddress('0x00ffffffff'));
tests.f(dojox.validate.isIpAddress('0x100000000'));
tests.f(dojox.validate.isIpAddress('0xCF8E83EB', {allowHex: false}));
// IPv6
tests.t(dojox.validate.isIpAddress('fedc:BA98:7654:3210:FEDC:BA98:7654:3210'));
tests.t(dojox.validate.isIpAddress('1080:0:0:0:8:800:200C:417A'));
tests.f(dojox.validate.isIpAddress('1080:0:0:0:8:800:200C:417A', {allowIPv6: false}));
// Hybrid of IPv6 and IPv4
tests.t(dojox.validate.isIpAddress('0:0:0:0:0:0:13.1.68.3'));
tests.t(dojox.validate.isIpAddress('0:0:0:0:0:FFFF:129.144.52.38'));
tests.f(dojox.validate.isIpAddress('0:0:0:0:0:FFFF:129.144.52.38', {allowHybrid: false}));
}
},
{
name:"isUrl",
runTests: function(tests){
 
tests.t(dojox.validate.isUrl('www.yahoo.com'));
tests.t(dojox.validate.isUrl('http://www.yahoo.com'));
tests.t(dojox.validate.isUrl('https://www.yahoo.com'));
tests.f(dojox.validate.isUrl('http://.yahoo.com'));
tests.f(dojox.validate.isUrl('http://www.-yahoo.com'));
tests.f(dojox.validate.isUrl('http://www.yahoo-.com'));
tests.t(dojox.validate.isUrl('http://y-a---h-o-o.com'));
tests.t(dojox.validate.isUrl('http://www.y.com'));
tests.t(dojox.validate.isUrl('http://www.yahoo.museum'));
tests.t(dojox.validate.isUrl('http://www.yahoo.co.uk'));
tests.f(dojox.validate.isUrl('http://www.micro$oft.com'));
tests.t(dojox.validate.isUrl('http://www.y.museum:8080'));
tests.t(dojox.validate.isUrl('http://12.24.36.128:8080'));
tests.f(dojox.validate.isUrl('http://12.24.36.128:8080', {allowIP: false} ));
tests.t(dojox.validate.isUrl('www.y.museum:8080'));
tests.f(dojox.validate.isUrl('www.y.museum:8080', {scheme: true} ));
tests.t(dojox.validate.isUrl('localhost:8080', {allowLocal: true} ));
tests.f(dojox.validate.isUrl('localhost:8080', {} ));
tests.t(dojox.validate.isUrl('http://www.yahoo.com/index.html?a=12&b=hello%20world#anchor'));
tests.f(dojox.validate.isUrl('http://www.yahoo.xyz'));
tests.t(dojox.validate.isUrl('http://www.yahoo.com/index.html#anchor'));
tests.t(dojox.validate.isUrl('http://cocoon.apache.org/2.1/'));
}
},
{
name: "isEmailAddress",
runTests: function(tests) {
tests.t(dojox.validate.isEmailAddress('x@yahoo.com'));
tests.t(dojox.validate.isEmailAddress('x.y.z.w@yahoo.com'));
tests.f(dojox.validate.isEmailAddress('x..y.z.w@yahoo.com'));
tests.f(dojox.validate.isEmailAddress('x.@yahoo.com'));
tests.t(dojox.validate.isEmailAddress('x@z.com'));
tests.f(dojox.validate.isEmailAddress('x@yahoo.x'));
tests.t(dojox.validate.isEmailAddress('x@yahoo.museum'));
tests.t(dojox.validate.isEmailAddress("o'mally@yahoo.com"));
tests.f(dojox.validate.isEmailAddress("'mally@yahoo.com"));
tests.t(dojox.validate.isEmailAddress("fred&barney@stonehenge.com"));
tests.f(dojox.validate.isEmailAddress("fred&&barney@stonehenge.com"));
// local addresses
tests.t(dojox.validate.isEmailAddress("fred&barney@localhost", {allowLocal: true} ));
tests.f(dojox.validate.isEmailAddress("fred&barney@localhost"));
// addresses with cruft
tests.t(dojox.validate.isEmailAddress("mailto:fred&barney@stonehenge.com", {allowCruft: true} ));
tests.t(dojox.validate.isEmailAddress("<fred&barney@stonehenge.com>", {allowCruft: true} ));
tests.f(dojox.validate.isEmailAddress("mailto:fred&barney@stonehenge.com"));
tests.f(dojox.validate.isEmailAddress("<fred&barney@stonehenge.com>"));
// local addresses with cruft
tests.t(dojox.validate.isEmailAddress("<mailto:fred&barney@localhost>", {allowLocal: true, allowCruft: true} ));
tests.f(dojox.validate.isEmailAddress("<mailto:fred&barney@localhost>", {allowCruft: true} ));
tests.f(dojox.validate.isEmailAddress("<mailto:fred&barney@localhost>", {allowLocal: true} ));
}
},
{
name: "isEmailsAddressList",
runTests: function(tests) {
tests.t(dojox.validate.isEmailAddressList(
"x@yahoo.com \n x.y.z.w@yahoo.com ; o'mally@yahoo.com , fred&barney@stonehenge.com \n" )
);
tests.t(dojox.validate.isEmailAddressList(
"x@yahoo.com \n x.y.z.w@localhost \n o'mally@yahoo.com \n fred&barney@localhost",
{allowLocal: true} )
);
tests.f(dojox.validate.isEmailAddressList(
"x@yahoo.com; x.y.z.w@localhost; o'mally@yahoo.com; fred&barney@localhost", {listSeparator: ";"} )
);
tests.t(dojox.validate.isEmailAddressList(
"mailto:x@yahoo.com; <x.y.z.w@yahoo.com>; <mailto:o'mally@yahoo.com>; fred&barney@stonehenge.com",
{allowCruft: true, listSeparator: ";"} )
);
tests.f(dojox.validate.isEmailAddressList(
"mailto:x@yahoo.com; <x.y.z.w@yahoo.com>; <mailto:o'mally@yahoo.com>; fred&barney@stonehenge.com",
{listSeparator: ";"} )
);
tests.t(dojox.validate.isEmailAddressList(
"mailto:x@yahoo.com; <x.y.z.w@localhost>; <mailto:o'mally@localhost>; fred&barney@localhost",
{allowLocal: true, allowCruft: true, listSeparator: ";"} )
);
}
},
{
name: "getEmailAddressList",
runTests: function(tests) {
var list = "x@yahoo.com \n x.y.z.w@yahoo.com ; o'mally@yahoo.com , fred&barney@stonehenge.com";
tests.assertEquals(4, dojox.validate.getEmailAddressList(list).length);
 
var localhostList = "x@yahoo.com; x.y.z.w@localhost; o'mally@yahoo.com; fred&barney@localhost";
tests.assertEquals(0, dojox.validate.getEmailAddressList(localhostList).length);
tests.assertEquals(4, dojox.validate.getEmailAddressList(localhostList, {allowLocal: true} ).length);
}
},
{
name: "isInRange",
runTests: function(tests) {
// test integers
tests.f(dojox.validate.isInRange( '0', {min: 1, max: 100} ));
tests.t(dojox.validate.isInRange( '1', {min: 1, max: 100} ));
tests.f(dojox.validate.isInRange( '-50', {min: 1, max: 100} ));
tests.t(dojox.validate.isInRange( '+50', {min: 1, max: 100} ));
tests.t(dojox.validate.isInRange( '100', {min: 1, max: 100} ));
tests.f(dojox.validate.isInRange( '101', {min: 1, max: 100} ));
//test real numbers
tests.f(dojox.validate.isInRange( '0.9', {min: 1.0, max: 10.0} ));
tests.t(dojox.validate.isInRange( '1.0', {min: 1.0, max: 10.0} ));
tests.f(dojox.validate.isInRange( '-5.0', {min: 1.0, max: 10.0} ));
tests.t(dojox.validate.isInRange( '+5.50', {min: 1.0, max: 10.0} ));
tests.t(dojox.validate.isInRange( '10.0', {min: 1.0, max: 10.0} ));
tests.f(dojox.validate.isInRange( '10.1', {min: 1.0, max: 10.0} ));
tests.f(dojox.validate.isInRange( '5.566e28', {min: 5.567e28, max: 6.000e28} ));
tests.t(dojox.validate.isInRange( '5.7e28', {min: 5.567e28, max: 6.000e28} ));
tests.f(dojox.validate.isInRange( '6.00000001e28', {min: 5.567e28, max: 6.000e28} ));
tests.f(dojox.validate.isInRange( '10.000.000,12345e-5', {decimal: ",", max: 10000000.1e-5} ));
tests.f(dojox.validate.isInRange( '10.000.000,12345e-5', {decimal: ",", min: 10000000.2e-5} ));
tests.t(dojox.validate.isInRange('1,500,000', {separator: ',', min: 0}));
tests.f(dojox.validate.isInRange('1,500,000', {separator: ',', min: 1000, max: 20000}));
// test currency
tests.f(dojox.validate.isInRange('\u20AC123,456,789', {max: 123456788, symbol: '\u20AC'} ));
tests.f(dojox.validate.isInRange('\u20AC123,456,789', { min: 123456790, symbol: '\u20AC'} ));
tests.f(dojox.validate.isInRange('$123,456,789.07', { max: 123456789.06} ));
tests.f(dojox.validate.isInRange('$123,456,789.07', { min: 123456789.08} ));
tests.f(dojox.validate.isInRange('123.456.789,00 \u20AC', {max: 123456788, decimal: ",", symbol: '\u20AC'} ));
tests.f(dojox.validate.isInRange('123.456.789,00 \u20AC', {min: 123456790, decimal: ",", symbol: '\u20AC'} ));
tests.f(dojox.validate.isInRange('- T123 456 789-00', {decimal: "-", min:0} ));
tests.t(dojox.validate.isInRange('\u20AC123,456,789', { max: 123456790, symbol: '\u20AC'} ));
tests.t(dojox.validate.isInRange('$123,456,789.07', { min: 123456789.06} ));
// test non number
//tests.f("test25", dojox.validate.isInRange( 'a'));
}
},
{
name: "isUsPhoneNumber",
runTests: function(tests) {
tests.t(dojox.validate.us.isPhoneNumber('(111) 111-1111'));
tests.t(dojox.validate.us.isPhoneNumber('(111) 111 1111'));
tests.t(dojox.validate.us.isPhoneNumber('111 111 1111'));
tests.t(dojox.validate.us.isPhoneNumber('111.111.1111'));
tests.t(dojox.validate.us.isPhoneNumber('111-111-1111'));
tests.t(dojox.validate.us.isPhoneNumber('111/111-1111'));
tests.f(dojox.validate.us.isPhoneNumber('111 111-1111'));
tests.f(dojox.validate.us.isPhoneNumber('111-1111'));
tests.f(dojox.validate.us.isPhoneNumber('(111)-111-1111'));
// test extensions
tests.t(dojox.validate.us.isPhoneNumber('111-111-1111 x1'));
tests.t(dojox.validate.us.isPhoneNumber('111-111-1111 x12'));
tests.t(dojox.validate.us.isPhoneNumber('111-111-1111 x1234'));
}
},
{
name:"isUsSocialSecurityNumber",
runtests: function(tests) {
tests.t(dojox.validate.us.isSocialSecurityNumber('123-45-6789'));
tests.t(dojox.validate.us.isSocialSecurityNumber('123 45 6789'));
tests.t(dojox.validate.us.isSocialSecurityNumber('123456789'));
tests.f(dojox.validate.us.isSocialSecurityNumber('123-45 6789'));
tests.f(dojox.validate.us.isSocialSecurityNumber('12345 6789'));
tests.f(dojox.validate.us.isSocialSecurityNumber('123-456789'));
}
},
{
name:"isUsZipCode",
runtests: function(tests) {
tests.t(dojox.validate.us.isZipCode('12345-6789'));
tests.t(dojox.validate.us.isZipCode('12345 6789'));
tests.t(dojox.validate.us.isZipCode('123456789'));
tests.t(dojox.validate.us.isZipCode('12345'));
}
},
{
name:"isCaZipCode",
runtests: function(tests) {
tests.t(dojox.validate.ca.isPostalCode('A1Z 3F3'));
tests.f(dojox.validate.ca.isPostalCode('1AZ 3F3'));
tests.t(dojox.validate.ca.isPostalCode('a1z 3f3'));
tests.f(dojox.validate.ca.isPostalCode('xxxxxx'));
tests.t(dojox.validate.ca.isPostalCode('A1Z3F3'));
}
},
{
name:"isUsState",
runtests: function(tests) {
tests.t(dojox.validate.us.isState('CA'));
tests.t(dojox.validate.us.isState('ne'));
tests.t(dojox.validate.us.isState('PR'));
tests.f(dojox.validate.us.isState('PR', {allowTerritories: false} ));
tests.t(dojox.validate.us.isState('AA'));
tests.f(dojox.validate.us.isState('AA', {allowMilitary: false} ));
}
},
{
name:"formCheck",
runtests: function(tests) {
var f = {
// textboxes
tx1: {type: "text", value: " 1001 ", name: "tx1"},
tx2: {type: "text", value: " x", name: "tx2"},
tx3: {type: "text", value: "10/19/2005", name: "tx3"},
tx4: {type: "text", value: "10/19/2005", name: "tx4"},
tx5: {type: "text", value: "Foo@Localhost", name: "tx5"},
tx6: {type: "text", value: "Foo@Localhost", name: "tx6"},
tx7: {type: "text", value: "<Foo@Gmail.Com>", name: "tx7"},
tx8: {type: "text", value: " ", name: "tx8"},
tx9: {type: "text", value: "ca", name: "tx9"},
tx10: {type: "text", value: "homer SIMPSON", name: "tx10"},
tx11: {type: "text", value: "$1,000,000 (US)", name: "tx11"},
tx12: {type: "text", value: "as12.a13", name: "tx12"},
tx13: {type: "text", value: "4.13", name: "tx13"},
tx14: {type: "text", value: "15.681", name: "tx14"},
tx15: {value: "1", name: "tx15"},
cc_no: {type: "text", value: "5434 1111 1111 1111", name: "cc_no"},
cc_exp: {type: "text", value: "", name: "cc_exp"},
cc_type: {type: "text", value: "Visa", name: "cc_type"},
email: {type: "text", value: "foo@gmail.com", name: "email"},
email_confirm: {type: "text", value: "foo2@gmail.com", name: "email_confirm"},
// password
pw1: {type: "password", value: "123456", name: "pw1"},
pw2: {type: "password", value: "123456", name: "pw2"},
// textarea - they have a type property, even though no html attribute
ta1: {type: "textarea", value: "", name: "ta1"},
ta2: {type: "textarea", value: "", name: "ta2"},
// radio button groups
rb1: [
{type: "radio", value: "v0", name: "rb1", checked: false},
{type: "radio", value: "v1", name: "rb1", checked: false},
{type: "radio", value: "v2", name: "rb1", checked: true}
],
rb2: [
{type: "radio", value: "v0", name: "rb2", checked: false},
{type: "radio", value: "v1", name: "rb2", checked: false},
{type: "radio", value: "v2", name: "rb2", checked: false}
],
rb3: [
{type: "radio", value: "v0", name: "rb3", checked: false},
{type: "radio", value: "v1", name: "rb3", checked: false},
{type: "radio", value: "v2", name: "rb3", checked: false}
],
// checkboxes
cb1: {type: "checkbox", value: "cb1", name: "cb1", checked: false},
cb2: {type: "checkbox", value: "cb2", name: "cb2", checked: false},
// checkbox group with the same name
cb3: [
{type: "checkbox", value: "v0", name: "cb3", checked: false},
{type: "checkbox", value: "v1", name: "cb3", checked: false},
{type: "checkbox", value: "v2", name: "cb3", checked: false}
],
doubledip: [
{type: "checkbox", value: "vanilla", name: "doubledip", checked: false},
{type: "checkbox", value: "chocolate", name: "doubledip", checked: false},
{type: "checkbox", value: "chocolate chip", name: "doubledip", checked: false},
{type: "checkbox", value: "lemon custard", name: "doubledip", checked: true},
{type: "checkbox", value: "pistachio almond", name: "doubledip", checked: false}
],
// <select>
s1: {
type: "select-one",
name: "s1",
selectedIndex: -1,
options: [
{text: "option 1", value: "v0", selected: false},
{text: "option 2", value: "v1", selected: false},
{text: "option 3", value: "v2", selected: false}
]
},
// <select multiple>
s2: {
type: "select-multiple",
name: "s2",
selectedIndex: 1,
options: [
{text: "option 1", value: "v0", selected: false},
{text: "option 2", value: "v1", selected: true},
{text: "option 3", value: "v2", selected: true}
]
},
tripledip: {
type: "select-multiple",
name: "tripledip",
selectedIndex: 3,
options: [
{text: "option 1", value: "vanilla", selected: false},
{text: "option 2", value: "chocolate", selected: false},
{text: "option 3", value: "chocolate chip", selected: false},
{text: "option 4", value: "lemon custard", selected: true},
{text: "option 5", value: "pistachio almond", selected: true},
{text: "option 6", value: "mocha almond chip", selected: false}
]
},
doublea: {
type: "select-multiple",
name: "doublea",
selectedIndex: 2,
options: [
{text: "option 1", value: "vanilla", selected: false},
{text: "option 2", value: "chocolate", selected: true},
{text: "option 3", value: "", selected: true}
]
},
// <select> null selection
s3: {
type: "select-one",
name: "s3",
selectedIndex: 0,
options: [
{text: "option 1", value: "", selected: true},
{text: "option 2", value: "v1", selected: false},
{text: "option 3", value: "v2", selected: false}
]
},
selectAlien: {
name: "selectAlien",
multiple: "multiple",
id: "selectAlient",
size: "10",
length: 0,
options: [],
value:[]
}
};
// Profile for form input
var profile = {
// filters
trim: ["tx1", "tx2"],
uppercase: ["tx9"],
lowercase: ["tx5", "tx6", "tx7"],
ucfirst: ["tx10"],
digit: ["tx11"],
// required fields
required: ["tx2", "tx3", "tx4", "tx5", "tx6", "tx7", "tx8", "tx15", "pw1", "ta1", "rb1", "rb2",
"cb3", "s1", "s2", "s3",
{"doubledip":2}, {"tripledip":3}, {"doublea":2} ],
// dependant/conditional fields
dependencies: {
cc_exp: "cc_no",
cc_type: "cc_no"
},
// validated fields
constraints: {
tx1: dojox.validate.isInteger,
tx2: dojox.validate.isInteger,
tx3: [dojo.date.parse, {locale: 'en-us'}],
tx4: [dojo.date.parse, {locale: 'fr-fr'}],
tx5: [dojox.validate.isEmailAddress],
tx6: [dojox.validate.isEmailAddress, {allowLocal: true}],
tx7: [dojox.validate.isEmailAddress, {allowCruft: true}],
tx8: dojox.validate.isURL,
tx12: [[dojox.validate.isRealNumber],[dojox.validate.isInRange, {max:100.00,min:5.0}]],
tx13: [[dojox.validate.isRealNumber],[dojox.validate.isInRange, {max:100.00,min:5.0}]],
tx14: [[dojox.validate.isRealNumber],[dojox.validate.isInRange, {max:100.00,min:5.0}]]
},
// confirm fields
confirm: {
email_confirm: "email",
pw2: "pw1"
}
};
// results object
var results = dojox.validate.check(f, profile);
// test filter stuff
tests.asserEquals("1001", f.tx1.value );
tests.asserEquals("x", f.tx2.value );
tests.asserEquals("CA", f.tx9.value );
tests.asserEquals("foo@localhost", f.tx5.value );
tests.asserEquals("foo@localhost", f.tx6.value );
tests.asserEquals("<foo@gmail.com>", f.tx7.value );
tests.asserEquals("Homer Simpson", f.tx10.value );
tests.asserEquals("1000000", f.tx11.value );
// test missing stuff
tests.f(results.isSuccessful() );
tests.t(results.hasMissing() );
tests.f(results.isMissing("tx1") );
tests.f(results.isMissing("tx2") );
tests.f(results.isMissing("tx3") );
tests.f(results.isMissing("tx4") );
tests.f(results.isMissing("tx5") );
tests.f(results.isMissing("tx6") );
tests.f(results.isMissing("tx7") );
tests.t(results.isMissing("tx8") );
tests.f(results.isMissing("pw1") );
tests.f(results.isMissing("pw2") );
tests.t(results.isMissing("ta1") );
tests.f(results.isMissing("ta2") );
tests.f(results.isMissing("rb1") );
tests.t(results.isMissing("rb2") );
tests.f(results.isMissing("rb3") );
tests.t(results.isMissing("cb3") );
tests.t(results.isMissing("s1") );
tests.f(results.isMissing("s2") );
tests.t(results.isMissing("s3"));
tests.t(results.isMissing("doubledip") );
tests.t(results.isMissing("tripledip") );
tests.t(results.isMissing("doublea"));
tests.f(results.isMissing("cc_no") );
tests.t(results.isMissing("cc_exp") );
tests.f(results.isMissing("cc_type") );
// missing: tx8, ta1, rb2, cb3, s1, s3, doubledip, tripledip, cc_exp
tests.asserEquals(10, results.getMissing().length );
// test constraint stuff
tests.t(results.hasInvalid() );
tests.f(results.isInvalid("tx1") );
tests.t(results.isInvalid("tx2") );
tests.f(results.isInvalid("tx3") );
tests.t(results.isInvalid("tx4") );
tests.t(results.isInvalid("tx5") );
tests.f(results.isInvalid("tx6") );
tests.f(results.isInvalid("tx7") );
tests.f(results.isInvalid("tx8") );
tests.f(results.isInvalid("pw1") );
tests.f(results.isInvalid("pw2") );
tests.f(results.isInvalid("ta1") );
tests.f(results.isInvalid("ta2") );
tests.f(results.isInvalid("email") );
tests.t(results.isInvalid("email_confirm") );
// invlaid: txt2, txt4, txt5, email_confirm, selectAlien
tests.asserEquals(7, results.getInvalid().length);
tests.t(results.isInvalid("tx12"));
tests.t(results.isInvalid("tx13"));
tests.f(results.isInvalid("tx14"));
tests.t(results.isInvalid("selectAlien"));
}
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/validate/tests/runTests.html
New file
0,0 → 1,9
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dijit Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.validate.tests.module"></HEAD>
<BODY>
Redirecting to D.O.H runner.
</BODY>
</HTML>
/trunk/api/js/dojo1.0/dojox/validate/tests/creditcard.js
New file
0,0 → 1,119
if(!dojo._hasResource["dojox.validate.tests.creditcard"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.validate.tests.creditcard"] = true;
dojo.provide("dojox.validate.tests.creditcard");
dojo.require("dojox.validate.creditCard");
 
tests.register("dojox.validate.tests.creditcard",
[{
name:"isValidLuhn",
runTests: function(tests) {
tests.t(dojox.validate.isValidLuhn('5105105105105100')); //test string input
tests.t(dojox.validate.isValidLuhn('5105-1051 0510-5100')); //test string input with dashes and spaces (commonly used when entering card #'s)
tests.t(dojox.validate.isValidLuhn(38520000023237)); //test numerical input as well
tests.f(dojox.validate.isValidLuhn(3852000002323)); //testing failures
tests.t(dojox.validate.isValidLuhn(18)); //length doesnt matter
tests.f(dojox.validate.isValidLuhn(818181)); //short length failure
}
},
{
name:"isValidCvv",
runTests: function(tests) {
tests.t(dojox.validate.isValidCvv('123','mc')); //string is ok
tests.f(dojox.validate.isValidCvv('5AA','ec')); //invalid characters are not ok
tests.t(dojox.validate.isValidCvv(723,'mc')); //numbers are ok too
tests.f(dojox.validate.isValidCvv(7234,'mc')); //too long
tests.t(dojox.validate.isValidCvv(612,'ec'));
tests.t(dojox.validate.isValidCvv(421,'vi'));
tests.t(dojox.validate.isValidCvv(543,'di'));
tests.t(dojox.validate.isValidCvv('1234','ax'));
tests.t(dojox.validate.isValidCvv(4321,'ax'));
tests.f(dojox.validate.isValidCvv(43215,'ax')); //too long
tests.f(dojox.validate.isValidCvv(215,'ax')); //too short
}
},
{
name:"isValidCreditCard",
runTests: function(tests) {
//misc checks
tests.t(dojox.validate.isValidCreditCard('5105105105105100','mc')); //test string input
tests.t(dojox.validate.isValidCreditCard('5105-1051 0510-5100','mc')); //test string input with dashes and spaces (commonly used when entering card #'s)
tests.t(dojox.validate.isValidCreditCard(5105105105105100,'mc')); //test numerical input as well
tests.f(dojox.validate.isValidCreditCard('5105105105105100','vi')); //fails, wrong card type
//Mastercard/Eurocard checks
tests.t(dojox.validate.isValidCreditCard('5105105105105100','mc'));
tests.t(dojox.validate.isValidCreditCard('5204105105105100','ec'));
tests.t(dojox.validate.isValidCreditCard('5303105105105100','mc'));
tests.t(dojox.validate.isValidCreditCard('5402105105105100','ec'));
tests.t(dojox.validate.isValidCreditCard('5501105105105100','mc'));
//Visa card checks
tests.t(dojox.validate.isValidCreditCard('4111111111111111','vi'));
tests.t(dojox.validate.isValidCreditCard('4111111111010','vi'));
//American Express card checks
tests.t(dojox.validate.isValidCreditCard('378 2822 4631 0005','ax'));
tests.t(dojox.validate.isValidCreditCard('341-1111-1111-1111','ax'));
//Diners Club/Carte Blanch card checks
tests.t(dojox.validate.isValidCreditCard('36400000000000','dc'));
tests.t(dojox.validate.isValidCreditCard('38520000023237','bl'));
tests.t(dojox.validate.isValidCreditCard('30009009025904','dc'));
tests.t(dojox.validate.isValidCreditCard('30108009025904','bl'));
tests.t(dojox.validate.isValidCreditCard('30207009025904','dc'));
tests.t(dojox.validate.isValidCreditCard('30306009025904','bl'));
tests.t(dojox.validate.isValidCreditCard('30405009025904','dc'));
tests.t(dojox.validate.isValidCreditCard('30504009025904','bl'));
//Discover card checks
tests.t(dojox.validate.isValidCreditCard('6011111111111117','di'));
//JCB card checks
tests.t(dojox.validate.isValidCreditCard('3530111333300000','jcb'));
tests.t(dojox.validate.isValidCreditCard('213100000000001','jcb'));
tests.t(dojox.validate.isValidCreditCard('180000000000002','jcb'));
tests.f(dojox.validate.isValidCreditCard('1800000000000002','jcb')); //should fail, good checksum, good prefix, but wrong length'
//Enroute card checks
tests.t(dojox.validate.isValidCreditCard('201400000000000','er'));
tests.t(dojox.validate.isValidCreditCard('214900000000000','er'));
}
},
{
name:"isValidCreditCardNumber",
runTests: function(tests) {
//misc checks
tests.t(dojox.validate.isValidCreditCardNumber('5105105105105100','mc')); //test string input
tests.t(dojox.validate.isValidCreditCardNumber('5105-1051 0510-5100','mc')); //test string input with dashes and spaces (commonly used when entering card #'s)
tests.t(dojox.validate.isValidCreditCardNumber(5105105105105100,'mc')); //test numerical input as well
tests.f(dojox.validate.isValidCreditCardNumber('5105105105105100','vi')); //fails, wrong card type
//Mastercard/Eurocard checks
tests.is("mc|ec", dojox.validate.isValidCreditCardNumber('5100000000000000')); //should match 'mc|ec'
tests.is("mc|ec", dojox.validate.isValidCreditCardNumber('5200000000000000')); //should match 'mc|ec'
tests.is("mc|ec", dojox.validate.isValidCreditCardNumber('5300000000000000')); //should match 'mc|ec'
tests.is("mc|ec", dojox.validate.isValidCreditCardNumber('5400000000000000')); //should match 'mc|ec'
tests.is("mc|ec", dojox.validate.isValidCreditCardNumber('5500000000000000')); //should match 'mc|ec'
tests.f(dojox.validate.isValidCreditCardNumber('55000000000000000')); //should fail, too long
//Visa card checks
tests.is("vi", dojox.validate.isValidCreditCardNumber('4111111111111111')); //should match 'vi'
tests.is("vi", dojox.validate.isValidCreditCardNumber('4111111111010')); //should match 'vi'
//American Express card checks
tests.is("ax", dojox.validate.isValidCreditCardNumber('378 2822 4631 0005')); //should match 'ax'
tests.is("ax", dojox.validate.isValidCreditCardNumber('341-1111-1111-1111')); //should match 'ax'
//Diners Club/Carte Blanch card checks
tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('36400000000000')); //should match 'dc|bl'
tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('38520000023237')); //should match 'dc|bl'
tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('30009009025904')); //should match 'di|bl'
tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('30108009025904')); //should match 'di|bl'
tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('30207009025904')); //should match 'di|bl'
tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('30306009025904')); //should match 'di|bl'
tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('30405009025904')); //should match 'di|bl'
tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('30504009025904')); //should match 'di|bl'
//Discover card checks
tests.is("di", dojox.validate.isValidCreditCardNumber('6011111111111117')); //should match 'di'
//JCB card checks
tests.is("jcb", dojox.validate.isValidCreditCardNumber('3530111333300000')); //should match 'jcb'
tests.is("jcb", dojox.validate.isValidCreditCardNumber('213100000000001')); //should match 'jcb'
tests.is("jcb", dojox.validate.isValidCreditCardNumber('180000000000002')); //should match 'jcb'
tests.f(dojox.validate.isValidCreditCardNumber('1800000000000002')); //should fail, good checksum, good prefix, but wrong length'
//Enroute card checks
tests.is("er", dojox.validate.isValidCreditCardNumber('201400000000000')); //should match 'er'
tests.is("er", dojox.validate.isValidCreditCardNumber('214900000000000')); //should match 'er'
}
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/validate/tests/module.js
New file
0,0 → 1,14
if(!dojo._hasResource["dojox.validate.tests.module"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.validate.tests.module"] = true;
dojo.provide("dojox.validate.tests.module");
 
try{
dojo.require("dojox.validate.tests.creditcard");
dojo.require("dojox.validate.tests.validate");
 
}catch(e){
doh.debug(e);
console.debug(e);
}
 
}
/trunk/api/js/dojo1.0/dojox/validate/us.js
New file
0,0 → 1,67
if(!dojo._hasResource["dojox.validate.us"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.validate.us"] = true;
dojo.provide("dojox.validate.us");
dojo.require("dojox.validate._base");
 
dojox.validate.us.isState = function(/*String*/value, /*Object?*/flags){
// summary: Validates US state and territory abbreviations.
//
// value: A two character string
// flags: An object
// flags.allowTerritories Allow Guam, Puerto Rico, etc. Default is true.
// flags.allowMilitary Allow military 'states', e.g. Armed Forces Europe (AE). Default is true.
 
var re = new RegExp("^" + dojox.regexp.us.state(flags) + "$", "i");
return re.test(value); // Boolean
}
 
dojox.validate.us.isPhoneNumber = function(/*String*/value){
// summary: Validates 10 US digit phone number for several common formats
// value: The telephone number string
 
var flags = {
format: [
"###-###-####",
"(###) ###-####",
"(###) ### ####",
"###.###.####",
"###/###-####",
"### ### ####",
"###-###-#### x#???",
"(###) ###-#### x#???",
"(###) ### #### x#???",
"###.###.#### x#???",
"###/###-#### x#???",
"### ### #### x#???",
"##########"
]
};
return dojox.validate.isNumberFormat(value, flags); // Boolean
}
 
dojox.validate.us.isSocialSecurityNumber = function(/*String*/value){
// summary: Validates social security number
var flags = {
format: [
"###-##-####",
"### ## ####",
"#########"
]
};
return dojox.validate.isNumberFormat(value, flags); // Boolean
}
 
dojox.validate.us.isZipCode = function(/*String*/value){
// summary: Validates U.S. zip-code
var flags = {
format: [
"#####-####",
"##### ####",
"#########",
"#####"
]
};
return dojox.validate.isNumberFormat(value, flags); // Boolean
}
 
}
/trunk/api/js/dojo1.0/dojox/validate/_base.js
New file
0,0 → 1,183
if(!dojo._hasResource["dojox.validate._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.validate._base"] = true;
dojo.provide("dojox.validate._base");
 
dojo.require("dojo.regexp"); // dojo core expressions
dojo.require("dojo.number"); // dojo number expressions
dojo.require("dojox.validate.regexp"); // additional expressions
 
dojox.validate.isText = function(/*String*/value, /*Object?*/flags){
// summary:
// Checks if a string has non whitespace characters.
// Parameters allow you to constrain the length.
//
// value: A string
// flags: {length: Number, minlength: Number, maxlength: Number}
// flags.length If set, checks if there are exactly flags.length number of characters.
// flags.minlength If set, checks if there are at least flags.minlength number of characters.
// flags.maxlength If set, checks if there are at most flags.maxlength number of characters.
flags = (typeof flags == "object") ? flags : {};
// test for text
if(/^\s*$/.test(value)){ return false; } // Boolean
// length tests
if(typeof flags.length == "number" && flags.length != value.length){ return false; } // Boolean
if(typeof flags.minlength == "number" && flags.minlength > value.length){ return false; } // Boolean
if(typeof flags.maxlength == "number" && flags.maxlength < value.length){ return false; } // Boolean
return true; // Boolean
 
}
 
dojox.validate._isInRangeCache = {};
dojox.validate.isInRange = function(/*String*/value, /*Object?*/flags){
// summary:
// Validates whether a string denoting an integer,
// real number, or monetary value is between a max and min.
//
// value: A string
// flags: {max:Number, min:Number, decimal:String}
// flags.max A number, which the value must be less than or equal to for the validation to be true.
// flags.min A number, which the value must be greater than or equal to for the validation to be true.
// flags.decimal The character used for the decimal point. Default is ".".
// fixes ticket #2908
value = dojo.number.parse(value, flags);
if(isNaN(value)){
return false; // Boolean
}
// assign default values to missing paramters
flags = (typeof flags == "object") ? flags : {};
var max = (typeof flags.max == "number") ? flags.max : Infinity;
var min = (typeof flags.min == "number") ? flags.min : -Infinity;
var dec = (typeof flags.decimal == "string") ? flags.decimal : ".";
var cache = dojox.validate._isInRangeCache;
var cacheIdx = value+"max"+max+"min"+min+"dec"+dec;
if(typeof cache[cacheIdx] != "undefined"){
return cache[cacheIdx];
}
 
if ( value < min || value > max ) { cache[cacheIdx] = false; return false; } // Boolean
 
cache[cacheIdx] = true; return true; // Boolean
}
 
dojox.validate.isNumberFormat = function(/*String*/value, /*Object?*/flags){
// summary:
// Validates any sort of number based format
//
// description:
// Use it for phone numbers, social security numbers, zip-codes, etc.
// The value can be validated against one format or one of multiple formats.
//
// Format
// # Stands for a digit, 0-9.
// ? Stands for an optional digit, 0-9 or nothing.
// All other characters must appear literally in the expression.
//
// Example
// "(###) ###-####" -> (510) 542-9742
// "(###) ###-#### x#???" -> (510) 542-9742 x153
// "###-##-####" -> 506-82-1089 i.e. social security number
// "#####-####" -> 98225-1649 i.e. zip code
//
// value: A string
// flags: {format:String}
// flags.format A string or an Array of strings for multiple formats.
 
var re = new RegExp("^" + dojox.regexp.numberFormat(flags) + "$", "i");
return re.test(value); // Boolean
}
 
dojox.validate.isValidLuhn = function(/*String*/value){
//summary: Compares value against the Luhn algorithm to verify its integrity
var sum, parity, curDigit;
if(typeof value!='string'){
value = String(value);
}
value = value.replace(/[- ]/g,''); //ignore dashes and whitespaces
parity = value.length%2;
sum=0;
for(var i=0;i<value.length;i++){
curDigit = parseInt(value.charAt(i));
if(i%2==parity){
curDigit*=2;
}
if(curDigit>9){
curDigit-=9;
}
sum+=curDigit;
}
return !(sum%10); //Boolean
}
 
/**
Procedural API Description
 
The main aim is to make input validation expressible in a simple format.
You define profiles which declare the required and optional fields and any constraints they might have.
The results are provided as an object that makes it easy to handle missing and invalid input.
 
Usage
 
var results = dojo.validate.check(form, profile);
 
Profile Object
 
var profile = {
// filters change the field value and are applied before validation.
trim: ["tx1", "tx2"],
uppercase: ["tx9"],
lowercase: ["tx5", "tx6", "tx7"],
ucfirst: ["tx10"],
digit: ["tx11"],
 
// required input fields that are blank will be reported missing.
// required radio button groups and drop-down lists with no selection will be reported missing.
// checkbox groups and selectboxes can be required to have more than one value selected.
// List required fields by name and use this notation to require more than one value: {checkboxgroup: 2}, {selectboxname: 3}.
required: ["tx7", "tx8", "pw1", "ta1", "rb1", "rb2", "cb3", "s1", {"doubledip":2}, {"tripledip":3}],
 
// dependant/conditional fields are required if the target field is present and not blank.
// At present only textbox, password, and textarea fields are supported.
dependencies: {
cc_exp: "cc_no",
cc_type: "cc_no",
},
 
// Fields can be validated using any boolean valued function.
// Use arrays to specify parameters in addition to the field value.
constraints: {
field_name1: myValidationFunction,
field_name2: dojo.validate.isInteger,
field_name3: [myValidationFunction, additional parameters],
field_name4: [dojo.validate.isValidDate, "YYYY.MM.DD"],
field_name5: [dojo.validate.isEmailAddress, false, true],
},
 
// Confirm is a sort of conditional validation.
// It associates each field in its property list with another field whose value should be equal.
// If the values are not equal, the field in the property list is reported as Invalid. Unless the target field is blank.
confirm: {
email_confirm: "email",
pw2: "pw1",
}
};
 
Results Object
 
isSuccessful(): Returns true if there were no invalid or missing fields, else it returns false.
hasMissing(): Returns true if the results contain any missing fields.
getMissing(): Returns a list of required fields that have values missing.
isMissing(field): Returns true if the field is required and the value is missing.
hasInvalid(): Returns true if the results contain fields with invalid data.
getInvalid(): Returns a list of fields that have invalid values.
isInvalid(field): Returns true if the field has an invalid value.
 
*/
 
}
/trunk/api/js/dojo1.0/dojox/validate/regexp.js
New file
0,0 → 1,329
if(!dojo._hasResource["dojox.validate.regexp"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.validate.regexp"] = true;
dojo.provide("dojox.validate.regexp");
 
dojo.require("dojo.regexp");
 
// *** Regular Expression Generator does not entirely live here ***
// FIXME: is this useful enough to be in /dojox/regexp/_base.js, or
// should it respect namespace and be dojox.validate.regexp?
// some say a generic regexp to match zipcodes and urls would be useful
// others would say it's a spare tire.
dojox.regexp = { ca: {}, us: {} };
 
dojox.regexp.tld = function(/*Object?*/flags){
// summary: Builds a RE that matches a top-level domain
//
// flags:
// flags.allowCC Include 2 letter country code domains. Default is true.
// flags.allowGeneric Include the generic domains. Default is true.
// flags.allowInfra Include infrastructure domains. Default is true.
 
// assign default values to missing paramters
flags = (typeof flags == "object") ? flags : {};
if(typeof flags.allowCC != "boolean"){ flags.allowCC = true; }
if(typeof flags.allowInfra != "boolean"){ flags.allowInfra = true; }
if(typeof flags.allowGeneric != "boolean"){ flags.allowGeneric = true; }
 
// Infrastructure top-level domain - only one at present
var infraRE = "arpa";
 
// Generic top-level domains RE.
var genericRE =
"aero|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|xxx|jobs|mobi|post";
// Country Code top-level domains RE
var ccRE =
"ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|" +
"bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|" +
"ec|ee|eg|er|eu|es|et|fi|fj|fk|fm|fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|"
+
"gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kr|kw|ky|kz|" +
"la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|" +
"my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|" +
"re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sk|sl|sm|sn|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|" +
"tn|to|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw";
 
// Build top-level domain RE
var a = [];
if(flags.allowInfra){ a.push(infraRE); }
if(flags.allowGeneric){ a.push(genericRE); }
if(flags.allowCC){ a.push(ccRE); }
 
var tldRE = "";
if (a.length > 0) {
tldRE = "(" + a.join("|") + ")";
}
 
return tldRE; // String
}
 
dojox.regexp.ipAddress = function(/*Object?*/flags){
// summary: Builds a RE that matches an IP Address
//
// description:
// Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal.
// Supports 2 formats for Ipv6.
//
// flags An object. All flags are boolean with default = true.
// flags.allowDottedDecimal Example, 207.142.131.235. No zero padding.
// flags.allowDottedHex Example, 0x18.0x11.0x9b.0x28. Case insensitive. Zero padding allowed.
// flags.allowDottedOctal Example, 0030.0021.0233.0050. Zero padding allowed.
// flags.allowDecimal Example, 3482223595. A decimal number between 0-4294967295.
// flags.allowHex Example, 0xCF8E83EB. Hexadecimal number between 0x0-0xFFFFFFFF.
// Case insensitive. Zero padding allowed.
// flags.allowIPv6 IPv6 address written as eight groups of four hexadecimal digits.
// FIXME: ipv6 can be written multiple ways IIRC
// flags.allowHybrid IPv6 address written as six groups of four hexadecimal digits
// followed by the usual 4 dotted decimal digit notation of IPv4. x:x:x:x:x:x:d.d.d.d
 
// assign default values to missing paramters
flags = (typeof flags == "object") ? flags : {};
if(typeof flags.allowDottedDecimal != "boolean"){ flags.allowDottedDecimal = true; }
if(typeof flags.allowDottedHex != "boolean"){ flags.allowDottedHex = true; }
if(typeof flags.allowDottedOctal != "boolean"){ flags.allowDottedOctal = true; }
if(typeof flags.allowDecimal != "boolean"){ flags.allowDecimal = true; }
if(typeof flags.allowHex != "boolean"){ flags.allowHex = true; }
if(typeof flags.allowIPv6 != "boolean"){ flags.allowIPv6 = true; }
if(typeof flags.allowHybrid != "boolean"){ flags.allowHybrid = true; }
 
// decimal-dotted IP address RE.
var dottedDecimalRE =
// Each number is between 0-255. Zero padding is not allowed.
"((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";
 
// dotted hex IP address RE. Each number is between 0x0-0xff. Zero padding is allowed, e.g. 0x00.
var dottedHexRE = "(0[xX]0*[\\da-fA-F]?[\\da-fA-F]\\.){3}0[xX]0*[\\da-fA-F]?[\\da-fA-F]";
 
// dotted octal IP address RE. Each number is between 0000-0377.
// Zero padding is allowed, but each number must have at least 4 characters.
var dottedOctalRE = "(0+[0-3][0-7][0-7]\\.){3}0+[0-3][0-7][0-7]";
 
// decimal IP address RE. A decimal number between 0-4294967295.
var decimalRE = "(0|[1-9]\\d{0,8}|[1-3]\\d{9}|4[01]\\d{8}|42[0-8]\\d{7}|429[0-3]\\d{6}|" +
"4294[0-8]\\d{5}|42949[0-5]\\d{4}|429496[0-6]\\d{3}|4294967[01]\\d{2}|42949672[0-8]\\d|429496729[0-5])";
 
// hexadecimal IP address RE.
// A hexadecimal number between 0x0-0xFFFFFFFF. Case insensitive. Zero padding is allowed.
var hexRE = "0[xX]0*[\\da-fA-F]{1,8}";
 
// IPv6 address RE.
// The format is written as eight groups of four hexadecimal digits, x:x:x:x:x:x:x:x,
// where x is between 0000-ffff. Zero padding is optional. Case insensitive.
var ipv6RE = "([\\da-fA-F]{1,4}\\:){7}[\\da-fA-F]{1,4}";
 
// IPv6/IPv4 Hybrid address RE.
// The format is written as six groups of four hexadecimal digits,
// followed by the 4 dotted decimal IPv4 format. x:x:x:x:x:x:d.d.d.d
var hybridRE = "([\\da-fA-F]{1,4}\\:){6}" +
"((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";
 
// Build IP Address RE
var a = [];
if(flags.allowDottedDecimal){ a.push(dottedDecimalRE); }
if(flags.allowDottedHex){ a.push(dottedHexRE); }
if(flags.allowDottedOctal){ a.push(dottedOctalRE); }
if(flags.allowDecimal){ a.push(decimalRE); }
if(flags.allowHex){ a.push(hexRE); }
if(flags.allowIPv6){ a.push(ipv6RE); }
if(flags.allowHybrid){ a.push(hybridRE); }
 
var ipAddressRE = "";
if(a.length > 0){
ipAddressRE = "(" + a.join("|") + ")";
}
return ipAddressRE; // String
}
 
dojox.regexp.host = function(/*Object?*/flags){
// summary: Builds a RE that matches a host
// description: A host is a domain name or an IP address, possibly followed by a port number.
// flags: An object.
// flags.allowIP Allow an IP address for hostname. Default is true.
// flags.allowLocal Allow the host to be "localhost". Default is false.
// flags.allowPort Allow a port number to be present. Default is true.
// flags in regexp.ipAddress can be applied.
// flags in regexp.tld can be applied.
 
// assign default values to missing paramters
flags = (typeof flags == "object") ? flags : {};
if(typeof flags.allowIP != "boolean"){ flags.allowIP = true; }
if(typeof flags.allowLocal != "boolean"){ flags.allowLocal = false; }
if(typeof flags.allowPort != "boolean"){ flags.allowPort = true; }
 
// Domain names can not end with a dash.
var domainNameRE = "([0-9a-zA-Z]([-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?\\.)+" + dojox.regexp.tld(flags);
 
// port number RE
var portRE = ( flags.allowPort ) ? "(\\:" + dojox.regexp.integer({signed: false}) + ")?" : "";
 
// build host RE
var hostNameRE = domainNameRE;
if(flags.allowIP){ hostNameRE += "|" + dojox.regexp.ipAddress(flags); }
if(flags.allowLocal){ hostNameRE += "|localhost"; }
 
return "(" + hostNameRE + ")" + portRE; // String
}
 
dojox.regexp.url = function(/*Object?*/flags){
// summary: Builds a regular expression that matches a URL
//
// flags: An object
// flags.scheme Can be true, false, or [true, false].
// This means: required, not allowed, or match either one.
// flags in regexp.host can be applied.
// flags in regexp.ipAddress can be applied.
// flags in regexp.tld can be applied.
 
// assign default values to missing paramters
flags = (typeof flags == "object") ? flags : {};
if(typeof flags.scheme == "undefined"){ flags.scheme = [true, false]; }
 
// Scheme RE
var protocolRE = dojo.regexp.buildGroupRE(flags.scheme,
function(q){ if(q){ return "(https?|ftps?)\\://"; } return ""; }
);
 
// Path and query and anchor RE
var pathRE = "(/([^?#\\s/]+/)*)?([^?#\\s/]+(\\?[^?#\\s/]*)?(#[A-Za-z][\\w.:-]*)?)?";
 
return protocolRE + dojox.regexp.host(flags) + pathRE;
}
 
dojox.regexp.emailAddress = function(/*Object?*/flags){
 
// summary: Builds a regular expression that matches an email address
//
//flags: An object
// flags.allowCruft Allow address like <mailto:foo@yahoo.com>. Default is false.
// flags in regexp.host can be applied.
// flags in regexp.ipAddress can be applied.
// flags in regexp.tld can be applied.
 
// assign default values to missing paramters
flags = (typeof flags == "object") ? flags : {};
if (typeof flags.allowCruft != "boolean") { flags.allowCruft = false; }
flags.allowPort = false; // invalid in email addresses
 
// user name RE - apostrophes are valid if there's not 2 in a row
var usernameRE = "([\\da-zA-Z]+[-._+&'])*[\\da-zA-Z]+";
 
// build emailAddress RE
var emailAddressRE = usernameRE + "@" + dojox.regexp.host(flags);
 
// Allow email addresses with cruft
if ( flags.allowCruft ) {
emailAddressRE = "<?(mailto\\:)?" + emailAddressRE + ">?";
}
 
return emailAddressRE; // String
}
 
dojox.regexp.emailAddressList = function(/*Object?*/flags){
// summary: Builds a regular expression that matches a list of email addresses.
//
// flags: An object.
// flags.listSeparator The character used to separate email addresses. Default is ";", ",", "\n" or " ".
// flags in regexp.emailAddress can be applied.
// flags in regexp.host can be applied.
// flags in regexp.ipAddress can be applied.
// flags in regexp.tld can be applied.
 
// assign default values to missing paramters
flags = (typeof flags == "object") ? flags : {};
if(typeof flags.listSeparator != "string"){ flags.listSeparator = "\\s;,"; }
 
// build a RE for an Email Address List
var emailAddressRE = dojox.regexp.emailAddress(flags);
var emailAddressListRE = "(" + emailAddressRE + "\\s*[" + flags.listSeparator + "]\\s*)*" +
emailAddressRE + "\\s*[" + flags.listSeparator + "]?\\s*";
 
return emailAddressListRE; // String
}
 
dojox.regexp.us.state = function(/*Object?*/flags){
// summary: A regular expression to match US state and territory abbreviations
//
// flags An object.
// flags.allowTerritories Allow Guam, Puerto Rico, etc. Default is true.
// flags.allowMilitary Allow military 'states', e.g. Armed Forces Europe (AE). Default is true.
 
// assign default values to missing paramters
flags = (typeof flags == "object") ? flags : {};
if(typeof flags.allowTerritories != "boolean"){ flags.allowTerritories = true; }
if(typeof flags.allowMilitary != "boolean"){ flags.allowMilitary = true; }
 
// state RE
var statesRE =
"AL|AK|AZ|AR|CA|CO|CT|DE|DC|FL|GA|HI|ID|IL|IN|IA|KS|KY|LA|ME|MD|MA|MI|MN|MS|MO|MT|" +
"NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VT|VA|WA|WV|WI|WY";
 
// territories RE
var territoriesRE = "AS|FM|GU|MH|MP|PW|PR|VI";
 
// military states RE
var militaryRE = "AA|AE|AP";
 
// Build states and territories RE
if(flags.allowTerritories){ statesRE += "|" + territoriesRE; }
if(flags.allowMilitary){ statesRE += "|" + militaryRE; }
 
return "(" + statesRE + ")"; // String
}
 
dojox.regexp.ca.postalCode = function(){
var postalRE =
"[A-Z][0-9][A-Z] [0-9][A-Z][0-9]";
return "(" + postalRE + ")";
}
 
dojox.regexp.ca.province = function(){
// summary: a regular expression to match Canadian Province Abbreviations
var stateRE =
"AB|BC|MB|NB|NL|NS|NT|NU|ON|PE|QC|SK|YT";
return "(" + statesRE + ")";
}
 
dojox.regexp.numberFormat = function(/*Object?*/flags){
// summary: Builds a regular expression to match any sort of number based format
// description:
// Use this method for phone numbers, social security numbers, zip-codes, etc.
// The RE can match one format or one of multiple formats.
//
// Format
// # Stands for a digit, 0-9.
// ? Stands for an optional digit, 0-9 or nothing.
// All other characters must appear literally in the expression.
//
// Example
// "(###) ###-####" -> (510) 542-9742
// "(###) ###-#### x#???" -> (510) 542-9742 x153
// "###-##-####" -> 506-82-1089 i.e. social security number
// "#####-####" -> 98225-1649 i.e. zip code
//
// flags: An object
// flags.format A string or an Array of strings for multiple formats.
 
// assign default values to missing paramters
flags = (typeof flags == "object") ? flags : {};
if(typeof flags.format == "undefined"){ flags.format = "###-###-####"; }
 
// Converts a number format to RE.
var digitRE = function(format){
// escape all special characters, except '?'
format = dojo.regexp.escapeString(format, "?");
 
// Now replace '?' with Regular Expression
format = format.replace(/\?/g, "\\d?");
 
// replace # with Regular Expression
format = format.replace(/#/g, "\\d");
 
return format; // String
};
 
// build RE for multiple number formats
return dojo.regexp.buildGroupRE(flags.format, digitRE); //String
}
 
}
/trunk/api/js/dojo1.0/dojox/validate/isbn.js
New file
0,0 → 1,37
if(!dojo._hasResource["dojox.validate.isbn"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.validate.isbn"] = true;
dojo.provide("dojox.validate.isbn");
 
dojox.validate.isValidIsbn = function(/* String */value) {
// summary: Vadlidate ISBN-10 or ISBN-13 based on the length of value
// returns: Boolean
var len, sum, weight;
if(typeof value!='string'){
value = String(value);
}
value = value.replace(/[- ]/g,''); //ignore dashes and whitespaces
len = value.length;
sum = 0;
if(len == 10){
weight = 10;
// ISBN-10 validation algorithm
for(var i = 0; i< 9; i++){
sum += parseInt(value.charAt(i)) * weight;
weight --;
}
var t = value.charAt(9).toUpperCase();
sum += t == 'X' ? 10 : parseInt(t);
return sum % 11 == 0;
}else if(len == 13) {
weight = -1;
for(var i=0; i< len; i++){
sum += parseInt(value.charAt(i)) * (2 + weight);
weight *= -1;
}
return sum % 10 == 0;
}else{
return false;
}
}
 
}
/trunk/api/js/dojo1.0/dojox/validate/check.js
New file
0,0 → 1,261
if(!dojo._hasResource["dojox.validate.check"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.validate.check"] = true;
dojo.provide("dojox.validate.check");
 
dojo.require("dojox.validate._base");
 
dojox.validate.check = function(/*HTMLFormElement*/form, /*Object*/profile){
// summary: validates user input of an HTML form based on input profile
//
// description:
// returns an object that contains several methods summarizing the results of the validation
//
// form: form to be validated
// profile: specifies how the form fields are to be validated
// {trim:Array, uppercase:Array, lowercase:Array, ucfirst:Array, digit:Array,
// required:Array, dependencies:Object, constraints:Object, confirm:Object}
 
// Essentially private properties of results object
var missing = [];
var invalid = [];
 
// results object summarizes the validation
var results = {
isSuccessful: function() {return ( !this.hasInvalid() && !this.hasMissing() );},
hasMissing: function() {return ( missing.length > 0 );},
getMissing: function() {return missing;},
isMissing: function(elemname) {
for(var i = 0; i < missing.length; i++){
if(elemname == missing[i]){ return true; }
}
return false;
},
hasInvalid: function() {return ( invalid.length > 0 );},
getInvalid: function() {return invalid;},
isInvalid: function(elemname){
for(var i = 0; i < invalid.length; i++){
if(elemname == invalid[i]){ return true; }
}
return false;
}
};
 
var _undef = function(name,object){
return (typeof object[name] == "undefined");
};
 
// Filters are applied before fields are validated.
// Trim removes white space at the front and end of the fields.
if(profile.trim instanceof Array){
for(var i = 0; i < profile.trim.length; i++){
var elem = form[profile.trim[i]];
if(_undef("type", elem) || elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
elem.value = elem.value.replace(/(^\s*|\s*$)/g, "");
}
}
// Convert to uppercase
if(profile.uppercase instanceof Array){
for(var i = 0; i < profile.uppercase.length; i++){
var elem = form[profile.uppercase[i]];
if(_undef("type", elem) || elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
elem.value = elem.value.toUpperCase();
}
}
// Convert to lowercase
if(profile.lowercase instanceof Array){
for (var i = 0; i < profile.lowercase.length; i++){
var elem = form[profile.lowercase[i]];
if(_undef("type", elem) || elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
elem.value = elem.value.toLowerCase();
}
}
// Uppercase first letter
if(profile.ucfirst instanceof Array){
for(var i = 0; i < profile.ucfirst.length; i++){
var elem = form[profile.ucfirst[i]];
if(_undef("type", elem) || elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
elem.value = elem.value.replace(/\b\w+\b/g, function(word) { return word.substring(0,1).toUpperCase() + word.substring(1).toLowerCase(); });
}
}
// Remove non digits characters from the input.
if(profile.digit instanceof Array){
for(var i = 0; i < profile.digit.length; i++){
var elem = form[profile.digit[i]];
if(_undef("type", elem) || elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
elem.value = elem.value.replace(/\D/g, "");
}
}
 
// See if required input fields have values missing.
if(profile.required instanceof Array){
for(var i = 0; i < profile.required.length; i++){
if(!dojo.isString(profile.required[i])){ continue; }
var elem = form[profile.required[i]];
// Are textbox, textarea, or password fields blank.
if(!_undef("type", elem)
&& (elem.type == "text" || elem.type == "textarea" || elem.type == "password" || elem.type == "file")
&& /^\s*$/.test(elem.value)){
missing[missing.length] = elem.name;
}
// Does drop-down box have option selected.
else if(!_undef("type", elem) && (elem.type == "select-one" || elem.type == "select-multiple")
&& (elem.selectedIndex == -1
|| /^\s*$/.test(elem.options[elem.selectedIndex].value))){
missing[missing.length] = elem.name;
}
// Does radio button group (or check box group) have option checked.
else if(elem instanceof Array){
var checked = false;
for(var j = 0; j < elem.length; j++){
if (elem[j].checked) { checked = true; }
}
if(!checked){
missing[missing.length] = elem[0].name;
}
}
}
}
 
// See if checkbox groups and select boxes have x number of required values.
if(profile.required instanceof Array){
for (var i = 0; i < profile.required.length; i++){
if(!dojo.isObject(profile.required[i])){ continue; }
var elem, numRequired;
for(var name in profile.required[i]){
elem = form[name];
numRequired = profile.required[i][name];
}
// case 1: elem is a check box group
if(elem instanceof Array){
var checked = 0;
for(var j = 0; j < elem.length; j++){
if(elem[j].checked){ checked++; }
}
if(checked < numRequired){
missing[missing.length] = elem[0].name;
}
}
// case 2: elem is a select box
else if(!_undef("type", elem) && elem.type == "select-multiple" ){
var selected = 0;
for(var j = 0; j < elem.options.length; j++){
if (elem.options[j].selected && !/^\s*$/.test(elem.options[j].value)) { selected++; }
}
if(selected < numRequired){
missing[missing.length] = elem.name;
}
}
}
}
 
// Dependent fields are required when the target field is present (not blank).
// Todo: Support dependent and target fields that are radio button groups, or select drop-down lists.
// Todo: Make the dependency based on a specific value of the target field.
// Todo: allow dependent fields to have several required values, like {checkboxgroup: 3}.
if(dojo.isObject(profile.dependencies)){
// properties of dependencies object are the names of dependent fields to be checked
for(name in profile.dependencies){
var elem = form[name]; // the dependent element
if(_undef("type", elem)){continue;}
if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; } // limited support
if(/\S+/.test(elem.value)){ continue; } // has a value already
if(results.isMissing(elem.name)){ continue; } // already listed as missing
var target = form[profile.dependencies[name]];
if(target.type != "text" && target.type != "textarea" && target.type != "password"){ continue; } // limited support
if(/^\s*$/.test(target.value)){ continue; } // skip if blank
missing[missing.length] = elem.name; // ok the dependent field is missing
}
}
 
// Find invalid input fields.
if(dojo.isObject(profile.constraints)){
// constraint properties are the names of fields to bevalidated
for(name in profile.constraints){
var elem = form[name];
if(!elem) {continue;}
// skip if blank - its optional unless required, in which case it
// is already listed as missing.
if(!_undef("tagName",elem)
&& (elem.tagName.toLowerCase().indexOf("input") >= 0
|| elem.tagName.toLowerCase().indexOf("textarea") >= 0)
&& /^\s*$/.test(elem.value)){
continue;
}
var isValid = true;
// case 1: constraint value is validation function
if(dojo.isFunction(profile.constraints[name])){
isValid = profile.constraints[name](elem.value);
}else if(dojo.isArray(profile.constraints[name])){
// handle nested arrays for multiple constraints
if(dojo.isArray(profile.constraints[name][0])){
for (var i=0; i<profile.constraints[name].length; i++){
isValid = dojox.validate.evaluateConstraint(profile, profile.constraints[name][i], name, elem);
if(!isValid){ break; }
}
}else{
// case 2: constraint value is array, first elem is function,
// tail is parameters
isValid = dojox.validate.evaluateConstraint(profile, profile.constraints[name], name, elem);
}
}
if(!isValid){
invalid[invalid.length] = elem.name;
}
}
}
 
// Find unequal confirm fields and report them as Invalid.
if(dojo.isObject(profile.confirm)){
for(name in profile.confirm){
var elem = form[name]; // the confirm element
var target = form[profile.confirm[name]];
if (_undef("type", elem) || _undef("type", target) || (elem.type != "text" && elem.type != "textarea" && elem.type != "password")
||(target.type != elem.type)
||(target.value == elem.value) // it's valid
||(results.isInvalid(elem.name))// already listed as invalid
||(/^\s*$/.test(target.value))) // skip if blank - only confirm if target has a value
{
continue;
}
invalid[invalid.length] = elem.name;
}
}
return results; // Object
};
 
//TODO: evaluateConstraint doesn't use profile or fieldName args?
dojox.validate.evaluateConstraint=function(profile, /*Array*/constraint, fieldName, elem){
// summary:
// Evaluates dojo.validate.check() constraints that are specified as array
// arguments
//
// description: The arrays are expected to be in the format of:
// constraints:{
// fieldName: [functionToCall, param1, param2, etc.],
// fieldName: [[functionToCallFirst, param1],[functionToCallSecond,param2]]
// }
//
// This function evaluates a single array function in the format of:
// [functionName, argument1, argument2, etc]
//
// The function will be parsed out and evaluated against the incoming parameters.
//
// profile: The dojo.validate.check() profile that this evaluation is against.
// constraint: The single [] array of function and arguments for the function.
// fieldName: The form dom name of the field being validated.
// elem: The form element field.
var isValidSomething = constraint[0];
var params = constraint.slice(1);
params.unshift(elem.value);
if(typeof isValidSomething != "undefined"){
return isValidSomething.apply(null, params);
}
return false; // Boolean
}
 
}
/trunk/api/js/dojo1.0/dojox/validate/web.js
New file
0,0 → 1,89
if(!dojo._hasResource["dojox.validate.web"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.validate.web"] = true;
dojo.provide("dojox.validate.web");
dojo.require("dojox.validate._base");
 
dojox.validate.isIpAddress = function(/*String*/value, /*Object?*/flags) {
// summary: Validates an IP address
//
// description:
// Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal.
// Supports 2 formats for Ipv6.
//
// value A string.
// flags An object. All flags are boolean with default = true.
// flags.allowDottedDecimal Example, 207.142.131.235. No zero padding.
// flags.allowDottedHex Example, 0x18.0x11.0x9b.0x28. Case insensitive. Zero padding allowed.
// flags.allowDottedOctal Example, 0030.0021.0233.0050. Zero padding allowed.
// flags.allowDecimal Example, 3482223595. A decimal number between 0-4294967295.
// flags.allowHex Example, 0xCF8E83EB. Hexadecimal number between 0x0-0xFFFFFFFF.
// Case insensitive. Zero padding allowed.
// flags.allowIPv6 IPv6 address written as eight groups of four hexadecimal digits.
// flags.allowHybrid IPv6 address written as six groups of four hexadecimal digits
// followed by the usual 4 dotted decimal digit notation of IPv4. x:x:x:x:x:x:d.d.d.d
 
var re = new RegExp("^" + dojox.regexp.ipAddress(flags) + "$", "i");
return re.test(value); // Boolean
}
 
 
dojox.validate.isUrl = function(/*String*/value, /*Object?*/flags) {
// summary: Checks if a string could be a valid URL
// value: A string
// flags: An object
// flags.scheme Can be true, false, or [true, false].
// This means: required, not allowed, or either.
// flags in regexp.host can be applied.
// flags in regexp.ipAddress can be applied.
// flags in regexp.tld can be applied.
 
var re = new RegExp("^" + dojox.regexp.url(flags) + "$", "i");
return re.test(value); // Boolean
}
 
dojox.validate.isEmailAddress = function(/*String*/value, /*Object?*/flags) {
// summary: Checks if a string could be a valid email address
//
// value: A string
// flags: An object
// flags.allowCruft Allow address like <mailto:foo@yahoo.com>. Default is false.
// flags in regexp.host can be applied.
// flags in regexp.ipAddress can be applied.
// flags in regexp.tld can be applied.
 
var re = new RegExp("^" + dojox.regexp.emailAddress(flags) + "$", "i");
return re.test(value); // Boolean
}
 
dojox.validate.isEmailAddressList = function(/*String*/value, /*Object?*/flags) {
// summary: Checks if a string could be a valid email address list.
//
// value A string.
// flags An object.
// flags.listSeparator The character used to separate email addresses. Default is ";", ",", "\n" or " ".
// flags in regexp.emailAddress can be applied.
// flags in regexp.host can be applied.
// flags in regexp.ipAddress can be applied.
// flags in regexp.tld can be applied.
 
var re = new RegExp("^" + dojox.regexp.emailAddressList(flags) + "$", "i");
return re.test(value); // Boolean
}
 
dojox.validate.getEmailAddressList = function(/*String*/value, /*Object?*/flags) {
// summary: Check if value is an email address list. If an empty list
// is returned, the value didn't pass the test or it was empty.
//
// value: A string
// flags: An object (same as dojo.validate.isEmailAddressList)
 
if(!flags) { flags = {}; }
if(!flags.listSeparator) { flags.listSeparator = "\\s;,"; }
 
if ( dojox.validate.isEmailAddressList(value, flags) ) {
return value.split(new RegExp("\\s*[" + flags.listSeparator + "]\\s*")); // Array
}
return []; // Array
}
 
}
/trunk/api/js/dojo1.0/dojox/validate/README
New file
0,0 → 1,37
-------------------------------------------------------------------------------
dojox.validate
-------------------------------------------------------------------------------
Version 0.01
Release date: 07/12/2007
-------------------------------------------------------------------------------
Project state: experimental / beta
-------------------------------------------------------------------------------
Credits
port: Peter Higgins (dante)
contributions: Kun Xi (bookstack@gmail.com)
-------------------------------------------------------------------------------
Project description
 
Provides a set of validation functions to match
values against known constants for use in form
validation, such as email address, TLD, ipAddress,
country-specific phone numbers and SSN, among
others..
 
-------------------------------------------------------------------------------
Dependencies:
 
Requires dojo base and dojo.regexp.
 
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
 
http://svn.dojotoolkit.org/dojo/dojox/trunk/validate.js
http://svn.dojotoolkit.org/dojo/dojox/trunk/validate
 
Install into the following directory structure:
/dojox/validate/
 
...which should be at the same level as your Dojo checkout.
/trunk/api/js/dojo1.0/dojox/validate/ca.js
New file
0,0 → 1,44
if(!dojo._hasResource["dojox.validate.ca"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.validate.ca"] = true;
dojo.provide("dojox.validate.ca");
 
dojo.require("dojox.validate._base");
 
dojox.validate.ca.isPhoneNumber = function(/* String */value) {
// summary: Validates 10 Canadian digit phone number for several common formats
// returns: Boolean
return dojox.validate.us.isPhoneNumber(value); // same as US
};
 
dojox.validate.ca.isProvince = function(/* String[2] */value) {
// summary: Validates Canadian province abbreviations (2 chars)
// returns: Boolean
var re = new RegExp("^" + dojox.regexp.ca.province() + "$", "i");
return re.test(value);
};
dojox.validate.ca.isSocialInsuranceNumber = function(/* String */value) {
// summary: Validates Canadian 9 digit social insurance number for several common formats
// This routine only pattern matches and does not use the Luhn Algorithm to validate number.
// returns: Boolean
var flags = {
format: [
"###-###-###",
"### ### ###",
"#########"
]
};
return dojox.validate.isNumberFormat(value, flags);
};
 
dojox.validate.ca.isPostalCode = function(value) {
// summary: Validates Canadian 6 digit postal code:
// Canadian postal codes are in the format ANA NAN,
// where A is a letter and N is a digit, with a space
// separating the third and fourth characters.
// returns: Boolean
var re = new RegExp("^" + dojox.regexp.ca.postalCode() + "$", "i");
return re.test(value);
};
 
}
/trunk/api/js/dojo1.0/dojox/flash/_common.js
New file
0,0 → 1,1289
if(!dojo._hasResource["dojox.flash._common"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.flash._common"] = true;
dojo.provide("dojox.flash._common");
 
dojox.flash = function(){
// summary:
// The goal of dojox.flash is to make it easy to extend Flash's capabilities
// into an AJAX/DHTML environment.
// description:
// The goal of dojox.flash is to make it easy to extend Flash's capabilities
// into an AJAX/DHTML environment. Robust, performant, reliable
// JavaScript/Flash communication is harder than most realize when they
// delve into the topic, especially if you want it
// to work on Internet Explorer, Firefox, and Safari, and to be able to
// push around hundreds of K of information quickly. dojox.flash makes it
// possible to support these platforms; you have to jump through a few
// hoops to get its capabilites, but if you are a library writer
// who wants to bring Flash's storage or streaming sockets ability into
// DHTML, for example, then dojox.flash is perfect for you.
//
// dojox.flash provides an easy object for interacting with the Flash plugin.
// This object provides methods to determine the current version of the Flash
// plugin (dojox.flash.info); execute Flash instance methods
// independent of the Flash version
// being used (dojox.flash.comm); write out the necessary markup to
// dynamically insert a Flash object into the page (dojox.flash.Embed; and
// do dynamic installation and upgrading of the current Flash plugin in
// use (dojox.flash.Install).
//
// To use dojox.flash, you must first wait until Flash is finished loading
// and initializing before you attempt communication or interaction.
// To know when Flash is finished use dojo.connect:
//
// dojo.connect(dojox.flash, "loaded", myInstance, "myCallback");
//
// Then, while the page is still loading provide the file name
// and the major version of Flash that will be used for Flash/JavaScript
// communication (see "Flash Communication" below for information on the
// different kinds of Flash/JavaScript communication supported and how they
// depend on the version of Flash installed):
//
// dojox.flash.setSwf({flash6: dojo.moduleUrl("dojox", "_storage/storage_flash6.swf"),
// flash8: dojo.moduleUrl("dojox", "_storage/storage_flash8.swf")});
//
// This will cause dojox.flash to pick the best way of communicating
// between Flash and JavaScript based on the platform.
//
// If no SWF files are specified, then Flash is not initialized.
//
// Your Flash must use DojoExternalInterface to expose Flash methods and
// to call JavaScript; see "Flash Communication" below for details.
//
// setSwf can take an optional 'visible' attribute to control whether
// the Flash object is visible or not on the page; the default is visible:
//
// dojox.flash.setSwf({flash6: dojo.moduleUrl("dojox", "_storage/storage_flash6.swf"),
// flash8: dojo.moduleUrl("dojox", "_storage/storage_flash8.swf"),
// visible: false });
//
// Once finished, you can query Flash version information:
//
// dojox.flash.info.version
//
// Or can communicate with Flash methods that were exposed:
//
// var results = dojox.flash.comm.sayHello("Some Message");
//
// Only string values are currently supported for both arguments and
// for return results. Everything will be cast to a string on both
// the JavaScript and Flash sides.
//
// -------------------
// Flash Communication
// -------------------
//
// dojox.flash allows Flash/JavaScript communication in
// a way that can pass large amounts of data back and forth reliably and
// very fast. The dojox.flash
// framework encapsulates the specific way in which this communication occurs,
// presenting a common interface to JavaScript irrespective of the underlying
// Flash version.
//
// There are currently three major ways to do Flash/JavaScript communication
// in the Flash community:
//
// 1) Flash 6+ - Uses Flash methods, such as SetVariable and TCallLabel,
// and the fscommand handler to do communication. Strengths: Very fast,
// mature, and can send extremely large amounts of data; can do
// synchronous method calls. Problems: Does not work on Safari; works on
// Firefox/Mac OS X only if Flash 8 plugin is installed; cryptic to work with.
//
// 2) Flash 8+ - Uses ExternalInterface, which provides a way for Flash
// methods to register themselves for callbacks from JavaScript, and a way
// for Flash to call JavaScript. Strengths: Works on Safari; elegant to
// work with; can do synchronous method calls. Problems: Extremely buggy
// (fails if there are new lines in the data, for example); performance
// degrades drastically in O(n^2) time as data grows; locks up the browser while
// it is communicating; does not work in Internet Explorer if Flash
// object is dynamically added to page with document.writeln, DOM methods,
// or innerHTML.
//
// 3) Flash 6+ - Uses two seperate Flash applets, one that we
// create over and over, passing input data into it using the PARAM tag,
// which then uses a Flash LocalConnection to pass the data to the main Flash
// applet; communication back to Flash is accomplished using a getURL
// call with a javascript protocol handler, such as "javascript:myMethod()".
// Strengths: the most cross browser, cross platform pre-Flash 8 method
// of Flash communication known; works on Safari. Problems: Timing issues;
// clunky and complicated; slow; can only send very small amounts of
// data (several K); all method calls are asynchronous.
//
// dojox.flash.comm uses only the first two methods. This framework
// was created primarily for dojox.storage, which needs to pass very large
// amounts of data synchronously and reliably across the Flash/JavaScript
// boundary. We use the first method, the Flash 6 method, on all platforms
// that support it, while using the Flash 8 ExternalInterface method
// only on Safari with some special code to help correct ExternalInterface's
// bugs.
//
// Since dojox.flash needs to have two versions of the Flash
// file it wants to generate, a Flash 6 and a Flash 8 version to gain
// true cross-browser compatibility, several tools are provided to ease
// development on the Flash side.
//
// In your Flash file, if you want to expose Flash methods that can be
// called, use the DojoExternalInterface class to register methods. This
// class is an exact API clone of the standard ExternalInterface class, but
// can work in Flash 6+ browsers. Under the covers it uses the best
// mechanism to do communication:
//
// class HelloWorld{
// function HelloWorld(){
// // Initialize the DojoExternalInterface class
// DojoExternalInterface.initialize();
//
// // Expose your methods
// DojoExternalInterface.addCallback("sayHello", this, this.sayHello);
//
// // Tell JavaScript that you are ready to have method calls
// DojoExternalInterface.loaded();
//
// // Call some JavaScript
// var resultsReady = function(results){
// trace("Received the following results from JavaScript: " + results);
// }
// DojoExternalInterface.call("someJavaScriptMethod", resultsReady,
// someParameter);
// }
//
// function sayHello(){ ... }
//
// static main(){ ... }
// }
//
// DojoExternalInterface adds two new functions to the ExternalInterface
// API: initialize() and loaded(). initialize() must be called before
// any addCallback() or call() methods are run, and loaded() must be
// called after you are finished adding your callbacks. Calling loaded()
// will fire the dojox.flash.loaded() event, so that JavaScript can know that
// Flash has finished loading and adding its callbacks, and can begin to
// interact with the Flash file.
//
// To generate your SWF files, use the ant task
// "buildFlash". You must have the open source Motion Twin ActionScript
// compiler (mtasc) installed and in your path to use the "buildFlash"
// ant task; download and install mtasc from http://www.mtasc.org/.
//
//
//
// buildFlash usage:
//
// // FIXME: this is not correct in the 0.9 world!
// ant buildFlash -Ddojox.flash.file=../tests/flash/HelloWorld.as
//
// where "dojox.flash.file" is the relative path to your Flash
// ActionScript file.
//
// This will generate two SWF files, one ending in _flash6.swf and the other
// ending in _flash8.swf in the same directory as your ActionScript method:
//
// HelloWorld_flash6.swf
// HelloWorld_flash8.swf
//
// Initialize dojox.flash with the filename and Flash communication version to
// use during page load; see the documentation for dojox.flash for details:
//
// dojox.flash.setSwf({flash6: dojo.moduleUrl("dojox", "flash/tests/flash/HelloWorld_flash6.swf"),
// flash8: dojo.moduleUrl("dojox", "flash/tests/flash/HelloWorld_flash8.swf")});
//
// Now, your Flash methods can be called from JavaScript as if they are native
// Flash methods, mirrored exactly on the JavaScript side:
//
// dojox.flash.comm.sayHello();
//
// Only Strings are supported being passed back and forth currently.
//
// JavaScript to Flash communication is synchronous; i.e., results are returned
// directly from the method call:
//
// var results = dojox.flash.comm.sayHello();
//
// Flash to JavaScript communication is asynchronous due to limitations in
// the underlying technologies; you must use a results callback to handle
// results returned by JavaScript in your Flash AS files:
//
// var resultsReady = function(results){
// trace("Received the following results from JavaScript: " + results);
// }
// DojoExternalInterface.call("someJavaScriptMethod", resultsReady);
//
//
//
// -------------------
// Notes
// -------------------
//
// If you have both Flash 6 and Flash 8 versions of your file:
//
// dojox.flash.setSwf({flash6: dojo.moduleUrl("dojox", "flash/tests/flash/HelloWorld_flash6.swf"),
// flash8: dojo.moduleUrl("dojox", "flash/tests/flash/HelloWorld_flash8.swf")});
//
// but want to force the browser to use a certain version of Flash for
// all platforms (for testing, for example), use the djConfig
// variable 'forceFlashComm' with the version number to force:
//
// var djConfig = { forceFlashComm: 6 };
//
// Two values are currently supported, 6 and 8, for the two styles of
// communication described above. Just because you force dojox.flash
// to use a particular communication style is no guarantee that it will
// work; for example, Flash 8 communication doesn't work in Internet
// Explorer due to bugs in Flash, and Flash 6 communication does not work
// in Safari. It is best to let dojox.flash determine the best communication
// mechanism, and to use the value above only for debugging the dojox.flash
// framework itself.
//
// Also note that dojox.flash can currently only work with one Flash object
// on the page; it and the API do not yet support multiple Flash objects on
// the same page.
//
// We use some special tricks to get decent, linear performance
// out of Flash 8's ExternalInterface on Safari; see the blog
// post
// http://codinginparadise.org/weblog/2006/02/how-to-speed-up-flash-8s.html
// for details.
//
// Your code can detect whether the Flash player is installing or having
// its version revved in two ways. First, if dojox.flash detects that
// Flash installation needs to occur, it sets dojox.flash.info.installing
// to true. Second, you can detect if installation is necessary with the
// following callback:
//
// dojo.connect(dojox.flash, "installing", myInstance, "myCallback");
//
// You can use this callback to delay further actions that might need Flash;
// when installation is finished the full page will be refreshed and the
// user will be placed back on your page with Flash installed.
//
// -------------------
// Todo/Known Issues
// -------------------
//
// There are several tasks I was not able to do, or did not need to fix
// to get dojo.storage out:
//
// * When using Flash 8 communication, Flash method calls to JavaScript
// are not working properly; serialization might also be broken for certain
// invalid characters when it is Flash invoking JavaScript methods.
// The Flash side needs to have more sophisticated serialization/
// deserialization mechanisms like JavaScript currently has. The
// test_flash2.html unit tests should also be updated to have much more
// sophisticated Flash to JavaScript unit tests, including large
// amounts of data.
//
// * On Internet Explorer, after doing a basic install, the page is
// not refreshed or does not detect that Flash is now available. The way
// to fix this is to create a custom small Flash file that is pointed to
// during installation; when it is finished loading, it does a callback
// that says that Flash installation is complete on IE, and we can proceed
// to initialize the dojox.flash subsystem.
//
// Author- Brad Neuberg, bkn3@columbia.edu
}
 
dojox.flash = {
flash6_version: null,
flash8_version: null,
ready: false,
_visible: true,
_loadedListeners: new Array(),
_installingListeners: new Array(),
setSwf: function(/* Object */ fileInfo){
// summary: Sets the SWF files and versions we are using.
// fileInfo: Object
// An object that contains two attributes, 'flash6' and 'flash8',
// each of which contains the path to our Flash 6 and Flash 8
// versions of the file we want to script.
// example:
// var swfloc6 = dojo.moduleUrl("dojox.storage", "Storage_version6.swf").toString();
// var swfloc8 = dojo.moduleUrl("dojox.storage", "Storage_version8.swf").toString();
// dojox.flash.setSwf({flash6: swfloc6, flash8: swfloc8, visible: false});
if(!fileInfo){
return;
}
if(fileInfo["flash6"]){
this.flash6_version = fileInfo.flash6;
}
if(fileInfo["flash8"]){
this.flash8_version = fileInfo.flash8;
}
if(fileInfo["visible"]){
this._visible = fileInfo.visible;
}
// initialize ourselves
this._initialize();
},
useFlash6: function(){ /* Boolean */
// summary: Returns whether we are using Flash 6 for communication on this platform.
if(this.flash6_version == null){
return false;
}else if (this.flash6_version != null && dojox.flash.info.commVersion == 6){
// if we have a flash 6 version of this SWF, and this browser supports
// communicating using Flash 6 features...
return true;
}else{
return false;
}
},
useFlash8: function(){ /* Boolean */
// summary: Returns whether we are using Flash 8 for communication on this platform.
if(this.flash8_version == null){
return false;
}else if (this.flash8_version != null && dojox.flash.info.commVersion == 8){
// if we have a flash 8 version of this SWF, and this browser supports
// communicating using Flash 8 features...
return true;
}else{
return false;
}
},
addLoadedListener: function(/* Function */ listener){
// summary:
// Adds a listener to know when Flash is finished loading.
// Useful if you don't want a dependency on dojo.event.
// listener: Function
// A function that will be called when Flash is done loading.
this._loadedListeners.push(listener);
},
 
addInstallingListener: function(/* Function */ listener){
// summary:
// Adds a listener to know if Flash is being installed.
// Useful if you don't want a dependency on dojo.event.
// listener: Function
// A function that will be called if Flash is being
// installed
this._installingListeners.push(listener);
},
loaded: function(){
// summary: Called back when the Flash subsystem is finished loading.
// description:
// A callback when the Flash subsystem is finished loading and can be
// worked with. To be notified when Flash is finished loading, connect
// your callback to this method using the following:
//
// dojo.event.connect(dojox.flash, "loaded", myInstance, "myCallback");
//dojo.debug("dojox.flash.loaded");
dojox.flash.ready = true;
if(dojox.flash._loadedListeners.length > 0){
for(var i = 0;i < dojox.flash._loadedListeners.length; i++){
dojox.flash._loadedListeners[i].call(null);
}
}
},
installing: function(){
// summary: Called if Flash is being installed.
// description:
// A callback to know if Flash is currently being installed or
// having its version revved. To be notified if Flash is installing, connect
// your callback to this method using the following:
//
// dojo.event.connect(dojox.flash, "installing", myInstance, "myCallback");
//dojo.debug("installing");
if(dojox.flash._installingListeners.length > 0){
for(var i = 0; i < dojox.flash._installingListeners.length; i++){
dojox.flash._installingListeners[i].call(null);
}
}
},
// Initializes dojox.flash.
_initialize: function(){
//dojo.debug("dojox.flash._initialize");
// see if we need to rev or install Flash on this platform
var installer = new dojox.flash.Install();
dojox.flash.installer = installer;
 
if(installer.needed() == true){
installer.install();
}else{
//dojo.debug("Writing object out");
// write the flash object into the page
dojox.flash.obj = new dojox.flash.Embed(this._visible);
dojox.flash.obj.write(dojox.flash.info.commVersion);
// initialize the way we do Flash/JavaScript communication
dojox.flash.comm = new dojox.flash.Communicator();
}
}
};
 
 
dojox.flash.Info = function(){
// summary: A class that helps us determine whether Flash is available.
// description:
// A class that helps us determine whether Flash is available,
// it's major and minor versions, and what Flash version features should
// be used for Flash/JavaScript communication. Parts of this code
// are adapted from the automatic Flash plugin detection code autogenerated
// by the Macromedia Flash 8 authoring environment.
//
// An instance of this class can be accessed on dojox.flash.info after
// the page is finished loading.
//
// This constructor must be called before the page is finished loading.
// Visual basic helper required to detect Flash Player ActiveX control
// version information on Internet Explorer
if(dojo.isIE){
document.write([
'<script language="VBScript" type="text/vbscript"\>',
'Function VBGetSwfVer(i)',
' on error resume next',
' Dim swControl, swVersion',
' swVersion = 0',
' set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))',
' if (IsObject(swControl)) then',
' swVersion = swControl.GetVariable("$version")',
' end if',
' VBGetSwfVer = swVersion',
'End Function',
'</script\>'].join("\r\n"));
}
this._detectVersion();
this._detectCommunicationVersion();
}
 
dojox.flash.Info.prototype = {
// version: String
// The full version string, such as "8r22".
version: -1,
// versionMajor, versionMinor, versionRevision: String
// The major, minor, and revisions of the plugin. For example, if the
// plugin is 8r22, then the major version is 8, the minor version is 0,
// and the revision is 22.
versionMajor: -1,
versionMinor: -1,
versionRevision: -1,
// capable: Boolean
// Whether this platform has Flash already installed.
capable: false,
// commVersion: int
// The major version number for how our Flash and JavaScript communicate.
// This can currently be the following values:
// 6 - We use a combination of the Flash plugin methods, such as SetVariable
// and TCallLabel, along with fscommands, to do communication.
// 8 - We use the ExternalInterface API.
// -1 - For some reason neither method is supported, and no communication
// is possible.
commVersion: 6,
// installing: Boolean
// Set if we are in the middle of a Flash installation session.
installing: false,
isVersionOrAbove: function(
/* int */ reqMajorVer,
/* int */ reqMinorVer,
/* int */ reqVer){ /* Boolean */
// summary:
// Asserts that this environment has the given major, minor, and revision
// numbers for the Flash player.
// description:
// Asserts that this environment has the given major, minor, and revision
// numbers for the Flash player.
//
// Example- To test for Flash Player 7r14:
//
// dojox.flash.info.isVersionOrAbove(7, 0, 14)
// returns:
// Returns true if the player is equal
// or above the given version, false otherwise.
// make the revision a decimal (i.e. transform revision 14 into
// 0.14
reqVer = parseFloat("." + reqVer);
if(this.versionMajor >= reqMajorVer && this.versionMinor >= reqMinorVer
&& this.versionRevision >= reqVer){
return true;
}else{
return false;
}
},
getResourceList: function(/*string*/ swfloc6, /*String*/ swfloc8){ /*String[]*/
// summary:
// Returns all resources required for embedding.
// description:
// This is a convenience method for Dojo Offline, meant to
// encapsulate us from the specific resources necessary for
// embedding. Dojo Offline requires that we sync our offline
// resources for offline availability; this method will return all
// offline resources, including any possible query parameters that
// might be used since caches treat resources with query
// parameters as different than ones that have query parameters.
// If offline and we request a resource with a query parameter
// that was not cached with a query parameter, then we will have a
// cache miss and not be able to work offline
var results = [];
// flash 6
var swfloc = swfloc6;
results.push(swfloc);
swfloc = swfloc + "?baseRelativePath=" + escape(dojo.baseUrl); // FIXME: should this be encodeURIComponent?
results.push(swfloc);
// Safari has a strange bug where it appends '%20'%20quality=
// to the end of Flash movies taken through XHR while offline;
// append this so we don't get a cache miss
swfloc += "'%20'%20quality=";
results.push(swfloc);
// flash 8
swfloc = swfloc8;
results.push(swfloc);
swfloc += "?baseRelativePath="+escape(dojo.baseUrl); // FIXME: should this be encodeURIComponent?
results.push(swfloc);
// Safari has a strange bug where it appends '%20'%20quality=
// to the end of Flash movies taken through XHR while offline;
// append this so we don't get a cache miss
swfloc += "'%20'%20quality=";
results.push(swfloc);
// flash 6 gateway
results.push(dojo.moduleUrl("dojox", "flash/flash6/flash6_gateway.swf")+"");
return results;
},
_detectVersion: function(){
var versionStr;
// loop backwards through the versions until we find the newest version
for(var testVersion = 25; testVersion > 0; testVersion--){
if(dojo.isIE){
versionStr = VBGetSwfVer(testVersion);
}else{
versionStr = this._JSFlashInfo(testVersion);
}
if(versionStr == -1 ){
this.capable = false;
return;
}else if(versionStr != 0){
var versionArray;
if(dojo.isIE){
var tempArray = versionStr.split(" ");
var tempString = tempArray[1];
versionArray = tempString.split(",");
}else{
versionArray = versionStr.split(".");
}
this.versionMajor = versionArray[0];
this.versionMinor = versionArray[1];
this.versionRevision = versionArray[2];
// 7.0r24 == 7.24
var versionString = this.versionMajor + "." + this.versionRevision;
this.version = parseFloat(versionString);
this.capable = true;
break;
}
}
},
// JavaScript helper required to detect Flash Player PlugIn version
// information. Internet Explorer uses a corresponding Visual Basic
// version to interact with the Flash ActiveX control.
_JSFlashInfo: function(testVersion){
// NS/Opera version >= 3 check for Flash plugin in plugin array
if(navigator.plugins != null && navigator.plugins.length > 0){
if(navigator.plugins["Shockwave Flash 2.0"] ||
navigator.plugins["Shockwave Flash"]){
var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
var descArray = flashDescription.split(" ");
var tempArrayMajor = descArray[2].split(".");
var versionMajor = tempArrayMajor[0];
var versionMinor = tempArrayMajor[1];
if(descArray[3] != ""){
var tempArrayMinor = descArray[3].split("r");
}else{
var tempArrayMinor = descArray[4].split("r");
}
var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
var version = versionMajor + "." + versionMinor + "."
+ versionRevision;
return version;
}
}
return -1;
},
// Detects the mechanisms that should be used for Flash/JavaScript
// communication, setting 'commVersion' to either 6 or 8. If the value is
// 6, we use Flash Plugin 6+ features, such as GetVariable, TCallLabel,
// and fscommand, to do Flash/JavaScript communication; if the value is
// 8, we use the ExternalInterface API for communication.
_detectCommunicationVersion: function(){
if(this.capable == false){
this.commVersion = null;
return;
}
// detect if the user has over-ridden the default flash version
if (typeof djConfig["forceFlashComm"] != "undefined" &&
typeof djConfig["forceFlashComm"] != null){
this.commVersion = djConfig["forceFlashComm"];
return;
}
// we prefer Flash 6 features over Flash 8, because they are much faster
// and much less buggy
// at this point, we don't have a flash file to detect features on,
// so we need to instead look at the browser environment we are in
if(dojo.isSafari||dojo.isOpera){
this.commVersion = 8;
}else{
this.commVersion = 6;
}
}
};
 
dojox.flash.Embed = function(visible){
// summary: A class that is used to write out the Flash object into the page.
this._visible = visible;
}
 
dojox.flash.Embed.prototype = {
// width: int
// The width of this Flash applet. The default is the minimal width
// necessary to show the Flash settings dialog. Current value is
// 215 pixels.
width: 215,
// height: int
// The height of this Flash applet. The default is the minimal height
// necessary to show the Flash settings dialog. Current value is
// 138 pixels.
height: 138,
// id: String
// The id of the Flash object. Current value is 'flashObject'.
id: "flashObject",
// Controls whether this is a visible Flash applet or not.
_visible: true,
 
protocol: function(){
switch(window.location.protocol){
case "https:":
return "https";
break;
default:
return "http";
break;
}
},
write: function(/* String */ flashVer, /* Boolean? */ doExpressInstall){
// summary: Writes the Flash into the page.
// description:
// This must be called before the page
// is finished loading.
// flashVer: String
// The Flash version to write.
// doExpressInstall: Boolean
// Whether to write out Express Install
// information. Optional value; defaults to false.
//dojo.debug("write");
doExpressInstall = !!doExpressInstall;
// determine our container div's styling
var containerStyle = "";
containerStyle += ("width: " + this.width + "px; ");
containerStyle += ("height: " + this.height + "px; ");
if(this._visible == false){
containerStyle += "position: absolute; z-index: 10000; top: -1000px; left: -1000px; ";
}
 
// figure out the SWF file to get and how to write out the correct HTML
// for this Flash version
var objectHTML;
var swfloc;
// Flash 6
if(flashVer == 6){
swfloc = dojox.flash.flash6_version;
var dojoPath = djConfig.baseRelativePath;
swfloc = swfloc + "?baseRelativePath=" + escape(dojoPath);
objectHTML =
'<embed id="' + this.id + '" src="' + swfloc + '" '
+ ' quality="high" bgcolor="#ffffff" '
+ ' width="' + this.width + '" height="' + this.height + '" '
+ ' name="' + this.id + '" '
+ ' align="middle" allowScriptAccess="sameDomain" '
+ ' type="application/x-shockwave-flash" swLiveConnect="true" '
+ ' pluginspage="'
+ this.protocol()
+ '://www.macromedia.com/go/getflashplayer">';
}else{ // Flash 8
swfloc = dojox.flash.flash8_version;
var swflocObject = swfloc;
var swflocEmbed = swfloc;
var dojoPath = djConfig.baseRelativePath;
if(doExpressInstall){
// the location to redirect to after installing
var redirectURL = escape(window.location);
document.title = document.title.slice(0, 47) + " - Flash Player Installation";
var docTitle = escape(document.title);
swflocObject += "?MMredirectURL=" + redirectURL
+ "&MMplayerType=ActiveX"
+ "&MMdoctitle=" + docTitle
+ "&baseRelativePath=" + escape(dojoPath);
swflocEmbed += "?MMredirectURL=" + redirectURL
+ "&MMplayerType=PlugIn"
+ "&baseRelativePath=" + escape(dojoPath);
}
 
if(swflocEmbed.indexOf("?") == -1){
swflocEmbed += "?baseRelativePath="+escape(dojoPath)+"' ";
}
objectHTML =
'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
+ 'codebase="'
+ this.protocol()
+ '://fpdownload.macromedia.com/pub/shockwave/cabs/flash/'
+ 'swflash.cab#version=8,0,0,0" '
+ 'width="' + this.width + '" '
+ 'height="' + this.height + '" '
+ 'id="' + this.id + '" '
+ 'align="middle"> '
+ '<param name="allowScriptAccess" value="sameDomain" /> '
+ '<param name="movie" value="' + swflocObject + '" /> '
+ '<param name="quality" value="high" /> '
+ '<param name="bgcolor" value="#ffffff" /> '
+ '<embed src="' + swflocEmbed + "' "
+ 'quality="high" '
+ 'bgcolor="#ffffff" '
+ 'width="' + this.width + '" '
+ 'height="' + this.height + '" '
+ 'id="' + this.id + '" '
+ 'name="' + this.id + '" '
+ 'swLiveConnect="true" '
+ 'align="middle" '
+ 'allowScriptAccess="sameDomain" '
+ 'type="application/x-shockwave-flash" '
+ 'pluginspage="'
+ this.protocol()
+'://www.macromedia.com/go/getflashplayer" />'
+ '</object>';
}
 
// now write everything out
objectHTML = '<div id="' + this.id + 'Container" style="' + containerStyle + '"> '
+ objectHTML
+ '</div>';
document.writeln(objectHTML);
},
get: function(){ /* Object */
// summary: Gets the Flash object DOM node.
//return (dojo.render.html.ie) ? window[this.id] : document[this.id];
// more robust way to get Flash object; version above can break
// communication on IE sometimes
return document.getElementById(this.id);
},
setVisible: function(/* Boolean */ visible){
// summary: Sets the visibility of this Flash object.
var container = dojo.byId(this.id + "Container");
if(visible == true){
container.style.visibility = "visible";
}else{
container.style.position = "absolute";
container.style.x = "-1000px";
container.style.y = "-1000px";
container.style.visibility = "hidden";
}
},
center: function(){
// summary: Centers the flash applet on the page.
/*
var elementWidth = this.width;
var elementHeight = this.height;
 
var scroll_offset = dojo._docScroll();
var viewport_size = dojo.html.getViewport();
 
// compute the centered position
var x = scroll_offset.x + (viewport_size.width - elementWidth) / 2;
var y = scroll_offset.y + (viewport_size.height - elementHeight) / 2;
*/
var x = 100;
var y = 100;
 
// set the centered position
var container = dojo.byId(this.id + "Container");
container.style.top = y + "px";
container.style.left = x + "px";
}
};
 
 
dojox.flash.Communicator = function(){
// summary:
// A class that is used to communicate between Flash and JavaScript in
// a way that can pass large amounts of data back and forth reliably,
// very fast, and with synchronous method calls.
// description:
// A class that is used to communicate between Flash and JavaScript in
// a way that can pass large amounts of data back and forth reliably,
// very fast, and with synchronous method calls. This class encapsulates the
// specific way in which this communication occurs,
// presenting a common interface to JavaScript irrespective of the underlying
// Flash version.
 
if(dojox.flash.useFlash6()){
this._writeFlash6();
}else if(dojox.flash.useFlash8()){
this._writeFlash8();
}
}
 
dojox.flash.Communicator.prototype = {
_writeFlash6: function(){
var id = dojox.flash.obj.id;
// global function needed for Flash 6 callback;
// we write it out as a script tag because the VBScript hook for IE
// callbacks does not work properly if this function is evalled() from
// within the Dojo system
document.writeln('<script language="JavaScript">');
document.writeln(' function ' + id + '_DoFSCommand(command, args){ ');
document.writeln(' dojox.flash.comm._handleFSCommand(command, args); ');
document.writeln('}');
document.writeln('</script>');
// hook for Internet Explorer to receive FSCommands from Flash
if(dojo.isIE){
document.writeln('<SCRIPT LANGUAGE=VBScript\> ');
document.writeln('on error resume next ');
document.writeln('Sub ' + id + '_FSCommand(ByVal command, ByVal args)');
document.writeln(' call ' + id + '_DoFSCommand(command, args)');
document.writeln('end sub');
document.writeln('</SCRIPT\> ');
}
},
_writeFlash8: function(){
// nothing needs to be written out for Flash 8 communication;
// happens automatically
},
//Flash 6 communication.
// Handles fscommand's from Flash to JavaScript. Flash 6 communication.
_handleFSCommand: function(command, args){
//console.debug("fscommand, command="+command+", args="+args);
// Flash 8 on Mac/Firefox precedes all commands with the string "FSCommand:";
// strip it off if it is present
if((command) && dojo.isString(command) && (/^FSCommand:(.*)/.test(command) == true)){
command = command.match(/^FSCommand:(.*)/)[1];
}
if(command == "addCallback"){ // add Flash method for JavaScript callback
this._fscommandAddCallback(command, args);
}else if(command == "call"){ // Flash to JavaScript method call
this._fscommandCall(command, args);
}else if(command == "fscommandReady"){ // see if fscommands are ready
this._fscommandReady();
}
},
// Handles registering a callable Flash function. Flash 6 communication.
_fscommandAddCallback: function(command, args){
var functionName = args;
// do a trick, where we link this function name to our wrapper
// function, _call, that does the actual JavaScript to Flash call
var callFunc = function(){
return dojox.flash.comm._call(functionName, arguments);
};
dojox.flash.comm[functionName] = callFunc;
// indicate that the call was successful
dojox.flash.obj.get().SetVariable("_succeeded", true);
},
// Handles Flash calling a JavaScript function. Flash 6 communication.
_fscommandCall: function(command, args){
var plugin = dojox.flash.obj.get();
var functionName = args;
// get the number of arguments to this method call and build them up
var numArgs = parseInt(plugin.GetVariable("_numArgs"));
var flashArgs = new Array();
for(var i = 0; i < numArgs; i++){
var currentArg = plugin.GetVariable("_" + i);
flashArgs.push(currentArg);
}
// get the function instance; we technically support more capabilities
// than ExternalInterface, which can only call global functions; if
// the method name has a dot in it, such as "dojox.flash.loaded", we
// eval it so that the method gets run against an instance
var runMe;
if(functionName.indexOf(".") == -1){ // global function
runMe = window[functionName];
}else{
// instance function
runMe = eval(functionName);
}
// make the call and get the results
var results = null;
if(dojo.isFunction(runMe)){
results = runMe.apply(null, flashArgs);
}
// return the results to flash
plugin.SetVariable("_returnResult", results);
},
// Reports that fscommands are ready to run if executed from Flash.
_fscommandReady: function(){
var plugin = dojox.flash.obj.get();
plugin.SetVariable("fscommandReady", "true");
},
// The actual function that will execute a JavaScript to Flash call; used
// by the Flash 6 communication method.
_call: function(functionName, args){
// we do JavaScript to Flash method calls by setting a Flash variable
// "_functionName" with the function name; "_numArgs" with the number
// of arguments; and "_0", "_1", etc for each numbered argument. Flash
// reads these, executes the function call, and returns the result
// in "_returnResult"
var plugin = dojox.flash.obj.get();
plugin.SetVariable("_functionName", functionName);
plugin.SetVariable("_numArgs", args.length);
for(var i = 0; i < args.length; i++){
// unlike Flash 8's ExternalInterface, Flash 6 has no problem with
// any special characters _except_ for the null character \0; double
// encode this so the Flash side never sees it, but we can get it
// back if the value comes back to JavaScript
var value = args[i];
value = value.replace(/\0/g, "\\0");
plugin.SetVariable("_" + i, value);
}
// now tell Flash to execute this method using the Flash Runner
plugin.TCallLabel("/_flashRunner", "execute");
// get the results
var results = plugin.GetVariable("_returnResult");
// we double encoded all null characters as //0 because Flash breaks
// if they are present; turn the //0 back into /0
results = results.replace(/\\0/g, "\0");
return results;
},
// Flash 8 communication.
// Registers the existence of a Flash method that we can call with
// JavaScript, using Flash 8's ExternalInterface.
_addExternalInterfaceCallback: function(methodName){
var wrapperCall = function(){
// some browsers don't like us changing values in the 'arguments' array, so
// make a fresh copy of it
var methodArgs = new Array(arguments.length);
for(var i = 0; i < arguments.length; i++){
methodArgs[i] = arguments[i];
}
return dojox.flash.comm._execFlash(methodName, methodArgs);
};
dojox.flash.comm[methodName] = wrapperCall;
},
// Encodes our data to get around ExternalInterface bugs.
// Flash 8 communication.
_encodeData: function(data){
// double encode all entity values, or they will be mis-decoded
// by Flash when returned
var entityRE = /\&([^;]*)\;/g;
data = data.replace(entityRE, "&amp;$1;");
// entity encode XML-ish characters, or Flash's broken XML serializer
// breaks
data = data.replace(/</g, "&lt;");
data = data.replace(/>/g, "&gt;");
// transforming \ into \\ doesn't work; just use a custom encoding
data = data.replace("\\", "&custom_backslash;&custom_backslash;");
data = data.replace(/\n/g, "\\n");
data = data.replace(/\r/g, "\\r");
data = data.replace(/\f/g, "\\f");
data = data.replace(/\0/g, "\\0"); // null character
data = data.replace(/\'/g, "\\\'");
data = data.replace(/\"/g, '\\\"');
return data;
},
// Decodes our data to get around ExternalInterface bugs.
// Flash 8 communication.
_decodeData: function(data){
if(data == null || typeof data == "undefined"){
return data;
}
// certain XMLish characters break Flash's wire serialization for
// ExternalInterface; these are encoded on the
// DojoExternalInterface side into a custom encoding, rather than
// the standard entity encoding, because otherwise we won't be able to
// differentiate between our own encoding and any entity characters
// that are being used in the string itself
data = data.replace(/\&custom_lt\;/g, "<");
data = data.replace(/\&custom_gt\;/g, ">");
// Unfortunately, Flash returns us our String with special characters
// like newlines broken into seperate characters. So if \n represents
// a new line, Flash returns it as "\" and "n". This means the character
// is _not_ a newline. This forces us to eval() the string to cause
// escaped characters to turn into their real special character values.
data = eval('"' + data + '"');
return data;
},
// Sends our method arguments over to Flash in chunks in order to
// have ExternalInterface's performance not be O(n^2).
// Flash 8 communication.
_chunkArgumentData: function(value, argIndex){
var plugin = dojox.flash.obj.get();
// cut up the string into pieces, and push over each piece one
// at a time
var numSegments = Math.ceil(value.length / 1024);
for(var i = 0; i < numSegments; i++){
var startCut = i * 1024;
var endCut = i * 1024 + 1024;
if(i == (numSegments - 1)){
endCut = i * 1024 + value.length;
}
var piece = value.substring(startCut, endCut);
// encode each piece seperately, rather than the entire
// argument data, because ocassionally a special
// character, such as an entity like &foobar;, will fall between
// piece boundaries, and we _don't_ want to encode that value if
// it falls between boundaries, or else we will end up with incorrect
// data when we patch the pieces back together on the other side
piece = this._encodeData(piece);
// directly use the underlying CallFunction method used by
// ExternalInterface, which is vastly faster for large strings
// and lets us bypass some Flash serialization bugs
plugin.CallFunction('<invoke name="chunkArgumentData" '
+ 'returntype="javascript">'
+ '<arguments>'
+ '<string>' + piece + '</string>'
+ '<number>' + argIndex + '</number>'
+ '</arguments>'
+ '</invoke>');
}
},
// Gets our method return data in chunks for better performance.
// Flash 8 communication.
_chunkReturnData: function(){
var plugin = dojox.flash.obj.get();
var numSegments = plugin.getReturnLength();
var resultsArray = new Array();
for(var i = 0; i < numSegments; i++){
// directly use the underlying CallFunction method used by
// ExternalInterface, which is vastly faster for large strings
var piece =
plugin.CallFunction('<invoke name="chunkReturnData" '
+ 'returntype="javascript">'
+ '<arguments>'
+ '<number>' + i + '</number>'
+ '</arguments>'
+ '</invoke>');
// remove any leading or trailing JavaScript delimiters, which surround
// our String when it comes back from Flash since we bypass Flash's
// deserialization routines by directly calling CallFunction on the
// plugin
if(piece == '""' || piece == "''"){
piece = "";
}else{
piece = piece.substring(1, piece.length-1);
}
resultsArray.push(piece);
}
var results = resultsArray.join("");
return results;
},
// Executes a Flash method; called from the JavaScript wrapper proxy we
// create on dojox.flash.comm.
// Flash 8 communication.
_execFlash: function(methodName, methodArgs){
var plugin = dojox.flash.obj.get();
// begin Flash method execution
plugin.startExec();
// set the number of arguments
plugin.setNumberArguments(methodArgs.length);
// chunk and send over each argument
for(var i = 0; i < methodArgs.length; i++){
this._chunkArgumentData(methodArgs[i], i);
}
// execute the method
plugin.exec(methodName);
// get the return result
var results = this._chunkReturnData();
// decode the results
results = this._decodeData(results);
// reset everything
plugin.endExec();
return results;
}
}
 
// FIXME: dojo.declare()-ify this
 
dojox.flash.Install = function(){
// summary: Helps install Flash plugin if needed.
// description:
// Figures out the best way to automatically install the Flash plugin
// for this browser and platform. Also determines if installation or
// revving of the current plugin is needed on this platform.
}
 
dojox.flash.Install.prototype = {
needed: function(){ /* Boolean */
// summary:
// Determines if installation or revving of the current plugin is
// needed.
// do we even have flash?
if(dojox.flash.info.capable == false){
return true;
}
 
var isMac = (navigator.appVersion.indexOf("Macintosh") >= 0);
 
// are we on the Mac? Safari needs Flash version 8 to do Flash 8
// communication, while Firefox/Mac needs Flash 8 to fix bugs it has
// with Flash 6 communication
if(isMac && (!dojox.flash.info.isVersionOrAbove(8, 0, 0))){
return true;
}
 
// other platforms need at least Flash 6 or above
if(!dojox.flash.info.isVersionOrAbove(6, 0, 0)){
return true;
}
 
// otherwise we don't need installation
return false;
},
 
install: function(){
// summary: Performs installation or revving of the Flash plugin.
//dojo.debug("install");
// indicate that we are installing
dojox.flash.info.installing = true;
dojox.flash.installing();
if(dojox.flash.info.capable == false){ // we have no Flash at all
//dojo.debug("Completely new install");
// write out a simple Flash object to force the browser to prompt
// the user to install things
var installObj = new dojox.flash.Embed(false);
installObj.write(8); // write out HTML for Flash 8 version+
}else if(dojox.flash.info.isVersionOrAbove(6, 0, 65)){ // Express Install
//dojo.debug("Express install");
var installObj = new dojox.flash.Embed(false);
installObj.write(8, true); // write out HTML for Flash 8 version+
installObj.setVisible(true);
installObj.center();
}else{ // older Flash install than version 6r65
alert("This content requires a more recent version of the Macromedia "
+" Flash Player.");
window.location.href = + dojox.flash.Embed.protocol() +
"://www.macromedia.com/go/getflashplayer";
}
},
// Called when the Express Install is either finished, failed, or was
// rejected by the user.
_onInstallStatus: function(msg){
if (msg == "Download.Complete"){
// Installation is complete.
dojox.flash._initialize();
}else if(msg == "Download.Cancelled"){
alert("This content requires a more recent version of the Macromedia "
+" Flash Player.");
window.location.href = dojox.flash.Embed.protocol() +
"://www.macromedia.com/go/getflashplayer";
}else if (msg == "Download.Failed"){
// The end user failed to download the installer due to a network failure
alert("There was an error downloading the Flash Player update. "
+ "Please try again later, or visit macromedia.com to download "
+ "the latest version of the Flash plugin.");
}
}
}
 
// find out if Flash is installed
dojox.flash.info = new dojox.flash.Info();
 
// vim:ts=4:noet:tw=0:
 
}
/trunk/api/js/dojo1.0/dojox/flash/flash6/DojoExternalInterface.as
New file
0,0 → 1,205
/**
An implementation of Flash 8's ExternalInterface that works with Flash 6
and which is source-compatible with Flash 8.
@author Brad Neuberg, bkn3@columbia.edu
*/
 
class DojoExternalInterface{
public static var available:Boolean;
public static var dojoPath = "";
public static var _fscommandReady = false;
public static var _callbacks = new Array();
 
public static function initialize(){
//getURL("javascript:console.debug('FLASH:DojoExternalInterface initialize')");
// FIXME: Set available variable by testing for capabilities
DojoExternalInterface.available = true;
// extract the dojo base path
DojoExternalInterface.dojoPath = DojoExternalInterface.getDojoPath();
//getURL("javascript:console.debug('FLASH:dojoPath="+DojoExternalInterface.dojoPath+"')");
// Sometimes, on IE, the fscommand infrastructure can take a few hundred
// milliseconds the first time a page loads. Set a timer to keep checking
// to make sure we can issue fscommands; otherwise, our calls to fscommand
// for setCallback() and loaded() will just "disappear"
_root.fscommandReady = false;
var fsChecker = function(){
// issue a test fscommand
fscommand("fscommandReady");
// JavaScript should set _root.fscommandReady if it got the call
if(_root.fscommandReady == "true"){
DojoExternalInterface._fscommandReady = true;
clearInterval(_root.fsTimer);
}
};
_root.fsTimer = setInterval(fsChecker, 100);
}
public static function addCallback(methodName:String, instance:Object,
method:Function) : Boolean{
// A variable that indicates whether the call below succeeded
_root._succeeded = null;
// Callbacks are registered with the JavaScript side as follows.
// On the Flash side, we maintain a lookup table that associates
// the methodName with the actual instance and method that are
// associated with this method.
// Using fscommand, we send over the action "addCallback", with the
// argument being the methodName to add, such as "foobar".
// The JavaScript takes these values and registers the existence of
// this callback point.
// precede the method name with a _ character in case it starts
// with a number
_callbacks["_" + methodName] = {_instance: instance, _method: method};
_callbacks[_callbacks.length] = methodName;
// The API for ExternalInterface says we have to make sure the call
// succeeded; check to see if there is a value
// for _succeeded, which is set by the JavaScript side
if(_root._succeeded == null){
return false;
}else{
return true;
}
}
public static function call(methodName:String,
resultsCallback:Function) : Void{
// FIXME: support full JSON serialization
// First, we pack up all of the arguments to this call and set them
// as Flash variables, which the JavaScript side will unpack using
// plugin.GetVariable(). We set the number of arguments as "_numArgs",
// and add each argument as a variable, such as "_1", "_2", etc., starting
// from 0.
// We then execute an fscommand with the action "call" and the
// argument being the method name. JavaScript takes the method name,
// retrieves the arguments using GetVariable, executes the method,
// and then places the return result in a Flash variable
// named "_returnResult".
_root._numArgs = arguments.length - 2;
for(var i = 2; i < arguments.length; i++){
var argIndex = i - 2;
_root["_" + argIndex] = arguments[i];
}
_root._returnResult = undefined;
fscommand("call", methodName);
// immediately return if the caller is not waiting for return results
if(resultsCallback == undefined || resultsCallback == null){
return;
}
// check at regular intervals for return results
var resultsChecker = function(){
if((typeof _root._returnResult != "undefined")&&
(_root._returnResult != "undefined")){
clearInterval(_root._callbackID);
resultsCallback.call(null, _root._returnResult);
}
};
_root._callbackID = setInterval(resultsChecker, 100);
}
/**
Called by Flash to indicate to JavaScript that we are ready to have
our Flash functions called. Calling loaded()
will fire the dojox.flash.loaded() event, so that JavaScript can know that
Flash has finished loading and adding its callbacks, and can begin to
interact with the Flash file.
*/
public static function loaded(){
//getURL("javascript:console.debug('FLASH:loaded')");
// one more step: see if fscommands are ready to be executed; if not,
// set an interval that will keep running until fscommands are ready;
// make sure the gateway is loaded as well
var execLoaded = function(){
if(DojoExternalInterface._fscommandReady == true){
clearInterval(_root.loadedInterval);
// initialize the small Flash file that helps gateway JS to Flash
// calls
DojoExternalInterface._initializeFlashRunner();
}
};
if(_fscommandReady == true){
execLoaded();
}else{
_root.loadedInterval = setInterval(execLoaded, 50);
}
}
/**
Handles and executes a JavaScript to Flash method call. Used by
initializeFlashRunner.
*/
public static function _handleJSCall(){
// get our parameters
var numArgs = parseInt(_root._numArgs);
var jsArgs = new Array();
for(var i = 0; i < numArgs; i++){
var currentValue = _root["_" + i];
jsArgs.push(currentValue);
}
// get our function name
var functionName = _root._functionName;
// now get the actual instance and method object to execute on,
// using our lookup table that was constructed by calls to
// addCallback on initialization
var instance = _callbacks["_" + functionName]._instance;
var method = _callbacks["_" + functionName]._method;
// execute it
var results = method.apply(instance, jsArgs);
// return the results
_root._returnResult = results;
}
/** Called by the flash6_gateway.swf to indicate that it is loaded. */
public static function _gatewayReady(){
for(var i = 0; i < _callbacks.length; i++){
fscommand("addCallback", _callbacks[i]);
}
call("dojox.flash.loaded");
}
/**
When JavaScript wants to communicate with Flash it simply sets
the Flash variable "_execute" to true; this method creates the
internal Movie Clip, called the Flash Runner, that makes this
magic happen.
*/
public static function _initializeFlashRunner(){
// figure out where our Flash movie is
var swfLoc = DojoExternalInterface.dojoPath + "flash6_gateway.swf";
// load our gateway helper file
_root.createEmptyMovieClip("_flashRunner", 5000);
_root._flashRunner._lockroot = true;
_root._flashRunner.loadMovie(swfLoc);
}
private static function getDojoPath(){
var url = _root._url;
var start = url.indexOf("baseRelativePath=") + "baseRelativePath=".length;
var path = url.substring(start);
var end = path.indexOf("&");
if(end != -1){
path = path.substring(0, end);
}
return path;
}
}
 
// vim:ts=4:noet:tw=0:
/trunk/api/js/dojo1.0/dojox/flash/flash6/flash6_gateway.fla
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/flash/flash6/flash6_gateway.fla
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/flash/flash8/DojoExternalInterface.as
New file
0,0 → 1,224
/**
A wrapper around Flash 8's ExternalInterface; DojoExternalInterface is needed so that we
can do a Flash 6 implementation of ExternalInterface, and be able
to support having a single codebase that uses DojoExternalInterface
across Flash versions rather than having two seperate source bases,
where one uses ExternalInterface and the other uses DojoExternalInterface.
DojoExternalInterface class does a variety of optimizations to bypass ExternalInterface's
unbelievably bad performance so that we can have good performance
on Safari; see the blog post
http://codinginparadise.org/weblog/2006/02/how-to-speed-up-flash-8s.html
for details.
@author Brad Neuberg, bkn3@columbia.edu
*/
import flash.external.ExternalInterface;
 
class DojoExternalInterface{
public static var available:Boolean;
public static var dojoPath = "";
private static var flashMethods:Array = new Array();
private static var numArgs:Number;
private static var argData:Array;
private static var resultData = null;
public static function initialize(){
// extract the dojo base path
DojoExternalInterface.dojoPath = DojoExternalInterface.getDojoPath();
// see if we need to do an express install
var install:ExpressInstall = new ExpressInstall();
if(install.needsUpdate){
install.init();
}
// register our callback functions
ExternalInterface.addCallback("startExec", DojoExternalInterface, startExec);
ExternalInterface.addCallback("setNumberArguments", DojoExternalInterface,
setNumberArguments);
ExternalInterface.addCallback("chunkArgumentData", DojoExternalInterface,
chunkArgumentData);
ExternalInterface.addCallback("exec", DojoExternalInterface, exec);
ExternalInterface.addCallback("getReturnLength", DojoExternalInterface,
getReturnLength);
ExternalInterface.addCallback("chunkReturnData", DojoExternalInterface,
chunkReturnData);
ExternalInterface.addCallback("endExec", DojoExternalInterface, endExec);
// set whether communication is available
DojoExternalInterface.available = ExternalInterface.available;
DojoExternalInterface.call("loaded");
}
public static function addCallback(methodName:String, instance:Object,
method:Function) : Boolean{
// register DojoExternalInterface methodName with it's instance
DojoExternalInterface.flashMethods[methodName] = instance;
// tell JavaScript about DojoExternalInterface new method so we can create a proxy
ExternalInterface.call("dojox.flash.comm._addExternalInterfaceCallback",
methodName);
return true;
}
public static function call(methodName:String,
resultsCallback:Function) : Void{
// we might have any number of optional arguments, so we have to
// pass them in dynamically; strip out the results callback
var parameters = new Array();
for(var i = 0; i < arguments.length; i++){
if(i != 1){ // skip the callback
parameters.push(arguments[i]);
}
}
var results = ExternalInterface.call.apply(ExternalInterface, parameters);
// immediately give the results back, since ExternalInterface is
// synchronous
if(resultsCallback != null && typeof resultsCallback != "undefined"){
resultsCallback.call(null, results);
}
}
/**
Called by Flash to indicate to JavaScript that we are ready to have
our Flash functions called. Calling loaded()
will fire the dojox.flash.loaded() event, so that JavaScript can know that
Flash has finished loading and adding its callbacks, and can begin to
interact with the Flash file.
*/
public static function loaded(){
DojoExternalInterface.call("dojox.flash.loaded");
}
public static function startExec():Void{
DojoExternalInterface.numArgs = null;
DojoExternalInterface.argData = null;
DojoExternalInterface.resultData = null;
}
public static function setNumberArguments(numArgs):Void{
DojoExternalInterface.numArgs = numArgs;
DojoExternalInterface.argData = new Array(DojoExternalInterface.numArgs);
}
public static function chunkArgumentData(value, argIndex:Number):Void{
//getURL("javascript:console.debug('FLASH: chunkArgumentData, value="+value+", argIndex="+argIndex+"')");
var currentValue = DojoExternalInterface.argData[argIndex];
if(currentValue == null || typeof currentValue == "undefined"){
DojoExternalInterface.argData[argIndex] = value;
}else{
DojoExternalInterface.argData[argIndex] += value;
}
}
public static function exec(methodName):Void{
// decode all of the arguments that were passed in
for(var i = 0; i < DojoExternalInterface.argData.length; i++){
DojoExternalInterface.argData[i] =
DojoExternalInterface.decodeData(DojoExternalInterface.argData[i]);
}
var instance = DojoExternalInterface.flashMethods[methodName];
DojoExternalInterface.resultData = instance[methodName].apply(
instance, DojoExternalInterface.argData);
// encode the result data
DojoExternalInterface.resultData =
DojoExternalInterface.encodeData(DojoExternalInterface.resultData);
//getURL("javascript:console.debug('FLASH: encoded result data="+DojoExternalInterface.resultData+"')");
}
public static function getReturnLength():Number{
if(DojoExternalInterface.resultData == null ||
typeof DojoExternalInterface.resultData == "undefined"){
return 0;
}
var segments = Math.ceil(DojoExternalInterface.resultData.length / 1024);
return segments;
}
public static function chunkReturnData(segment:Number):String{
var numSegments = DojoExternalInterface.getReturnLength();
var startCut = segment * 1024;
var endCut = segment * 1024 + 1024;
if(segment == (numSegments - 1)){
endCut = segment * 1024 + DojoExternalInterface.resultData.length;
}
var piece = DojoExternalInterface.resultData.substring(startCut, endCut);
//getURL("javascript:console.debug('FLASH: chunking return piece="+piece+"')");
return piece;
}
public static function endExec():Void{
}
private static function decodeData(data):String{
// we have to use custom encodings for certain characters when passing
// them over; for example, passing a backslash over as //// from JavaScript
// to Flash doesn't work
data = DojoExternalInterface.replaceStr(data, "&custom_backslash;", "\\");
data = DojoExternalInterface.replaceStr(data, "\\\'", "\'");
data = DojoExternalInterface.replaceStr(data, "\\\"", "\"");
return data;
}
private static function encodeData(data){
//getURL("javascript:console.debug('inside flash, data before="+data+"')");
 
// double encode all entity values, or they will be mis-decoded
// by Flash when returned
data = DojoExternalInterface.replaceStr(data, "&", "&amp;");
// certain XMLish characters break Flash's wire serialization for
// ExternalInterface; encode these into a custom encoding, rather than
// the standard entity encoding, because otherwise we won't be able to
// differentiate between our own encoding and any entity characters
// that are being used in the string itself
data = DojoExternalInterface.replaceStr(data, '<', '&custom_lt;');
data = DojoExternalInterface.replaceStr(data, '>', '&custom_gt;');
// encode control characters and JavaScript delimiters
data = DojoExternalInterface.replaceStr(data, "\n", "\\n");
data = DojoExternalInterface.replaceStr(data, "\r", "\\r");
data = DojoExternalInterface.replaceStr(data, "\f", "\\f");
data = DojoExternalInterface.replaceStr(data, "'", "\\'");
data = DojoExternalInterface.replaceStr(data, '"', '\"');
//getURL("javascript:console.debug('inside flash, data after="+data+"')");
return data;
}
/**
Flash ActionScript has no String.replace method or support for
Regular Expressions! We roll our own very simple one.
*/
private static function replaceStr(inputStr:String, replaceThis:String,
withThis:String):String {
var splitStr = inputStr.split(replaceThis)
inputStr = splitStr.join(withThis)
return inputStr;
}
private static function getDojoPath(){
var url = _root._url;
var start = url.indexOf("baseRelativePath=") + "baseRelativePath=".length;
var path = url.substring(start);
var end = path.indexOf("&");
if(end != -1){
path = path.substring(0, end);
}
return path;
}
}
 
// vim:ts=4:noet:tw=0:
/trunk/api/js/dojo1.0/dojox/flash/flash8/ExpressInstall.as
New file
0,0 → 1,71
/**
* Based on the expressinstall.as class created by Geoff Stearns as part
* of the FlashObject library.
*
* Use this file to invoke the Macromedia Flash Player Express Install functionality
* This file is intended for use with the FlashObject embed script. You can download FlashObject
* and this file at the following URL: http://blog.deconcept.com/flashobject/
*
* Usage:
* var ExpressInstall = new ExpressInstall();
*
* // test to see if install is needed:
* if (ExpressInstall.needsUpdate) { // returns true if update is needed
* ExpressInstall.init(); // starts the update
* }
*
* NOTE: Your Flash movie must be at least 214px by 137px in order to use ExpressInstall.
*
*/
 
class ExpressInstall {
public var needsUpdate:Boolean;
private var updater:MovieClip;
private var hold:MovieClip;
public function ExpressInstall(){
// does the user need to update?
this.needsUpdate = (_root.MMplayerType == undefined) ? false : true;
}
 
public function init():Void{
this.loadUpdater();
}
 
public function loadUpdater():Void {
System.security.allowDomain("fpdownload.macromedia.com");
 
// hope that nothing is at a depth of 10000000, you can change this depth if needed, but you want
// it to be on top of your content if you have any stuff on the first frame
this.updater = _root.createEmptyMovieClip("expressInstallHolder", 10000000);
 
// register the callback so we know if they cancel or there is an error
var _self = this;
this.updater.installStatus = _self.onInstallStatus;
this.hold = this.updater.createEmptyMovieClip("hold", 1);
 
// can't use movieClipLoader because it has to work in 6.0.65
this.updater.onEnterFrame = function():Void {
if(typeof this.hold.startUpdate == 'function'){
_self.initUpdater();
this.onEnterFrame = null;
}
}
 
var cacheBuster:Number = Math.random();
 
this.hold.loadMovie("http://fpdownload.macromedia.com/pub/flashplayer/"
+"update/current/swf/autoUpdater.swf?"+ cacheBuster);
}
 
private function initUpdater():Void{
this.hold.redirectURL = _root.MMredirectURL;
this.hold.MMplayerType = _root.MMplayerType;
this.hold.MMdoctitle = _root.MMdoctitle;
this.hold.startUpdate();
}
 
public function onInstallStatus(msg):Void{
getURL("javascript:dojox.flash.install._onInstallStatus('"+msg+"')");
}
}
/trunk/api/js/dojo1.0/dojox/flash/README
New file
0,0 → 1,31
-------------------------------------------------------------------------------
dojox.flash
-------------------------------------------------------------------------------
Version 0.4
Release date: MM/DD/YYYY
-------------------------------------------------------------------------------
Project state: beta
-------------------------------------------------------------------------------
Project authors
Brad Neuberg (BradNeuberg@dojotoolkit.org)
Alex Russell (alex@dojotoolkit.org, only handled minor porting issues)
-------------------------------------------------------------------------------
Project description
 
Infrastructure for high-performance Flash/JS communication
-------------------------------------------------------------------------------
Dependencies:
 
MTASC for creating builds
-------------------------------------------------------------------------------
Documentation
 
TODOC
-------------------------------------------------------------------------------
Installation instructions
 
Not intended as a stand-alone module.
-------------------------------------------------------------------------------
Additional Notes
 
TODOC
/trunk/api/js/dojo1.0/dojox/dtl.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.dtl"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl"] = true;
dojo.provide("dojox.dtl");
dojo.require("dojox.dtl._base");
 
}
/trunk/api/js/dojo1.0/dojox/charting/_color.js
New file
0,0 → 1,62
if(!dojo._hasResource["dojox.charting._color"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting._color"] = true;
dojo.provide("dojox.charting._color");
 
dojox.charting._color={};
dojox.charting._color.fromHsb=function(/* int */hue, /* int */saturation, /* int */brightness){
// summary
// Creates an instance of dojo.Color based on HSB input (360, %, %)
hue=Math.round(hue);
saturation=Math.round((saturation/100)*255);
brightness=Math.round((brightness/100)*255);
 
var r, g, b;
if(saturation==0){
r=g=b=brightness;
} else {
var tint1=brightness,
tint2=(255-saturation)*brightness/255,
tint3=(tint1-tint2)*(hue%60)/60;
if(hue<60){ r=tint1, g=tint2+tint3, b=tint2; }
else if(hue<120){ r=tint1-tint3, g=tint1, b=tint2; }
else if(hue<180){ r=tint2, g=tint1, b=tint2+tint3; }
else if(hue<240){ r=tint2, g=tint1-tint3, b=tint1; }
else if(hue<300){ r=tint2+tint3, g=tint2, b=tint1; }
else if(hue<360){ r=tint1, g=tint2, b=tint1-tint3; }
}
 
r=Math.round(r); g=Math.round(g); b=Math.round(b);
return new dojo.Color({ r:r, g:g, b:b });
};
 
dojox.charting._color.toHsb=function(/* int|Object|dojo.Color */ red, /* int? */ green, /* int? */blue){
// summary
// Returns the color in HSB representation (360, %, %)
var r=red,g=green,b=blue;
if(dojo.isObject(red)){
r=red.r,g=red.g,b=red.b;
}
var min=Math.min(r,g,b);
var max=Math.max(r,g,b);
var delta=max-min;
 
var hue=0, saturation=(max!=0?delta/max:0), brightness=max/255;
if(saturation==0){ hue=0; }
else {
if(r==max){ hue=((max-b)/delta)-((max-g)/delta); }
else if(g==max){ hue=2+(((max-r)/delta)-((max-b)/delta)); }
else { hue=4+(((max-g)/delta)-((max-r)/delta)); }
hue/=6;
if(hue<0) hue++;
}
hue=Math.round(hue*360);
saturation=Math.round(saturation*100);
brightness=Math.round(brightness*100);
return {
h:hue, s:saturation, b:brightness,
hue:hue, saturation:saturation, brightness:brightness
}; // Object
};
 
}
/trunk/api/js/dojo1.0/dojox/charting/axis2d/Default.js
New file
0,0 → 1,307
if(!dojo._hasResource["dojox.charting.axis2d.Default"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.axis2d.Default"] = true;
dojo.provide("dojox.charting.axis2d.Default");
 
dojo.require("dojox.charting.scaler");
dojo.require("dojox.charting.axis2d.common");
dojo.require("dojox.charting.axis2d.Base");
 
dojo.require("dojo.colors");
dojo.require("dojox.gfx");
dojo.require("dojox.lang.functional");
dojo.require("dojox.lang.utils");
 
(function(){
var dc = dojox.charting,
df = dojox.lang.functional,
du = dojox.lang.utils,
g = dojox.gfx,
labelGap = 4, // in pixels
labelFudgeFactor = 0.8; // in percents (to convert font's heigth to label width)
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
};
 
dojo.declare("dojox.charting.axis2d.Default", dojox.charting.axis2d.Base, {
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
majorLabels: true, // draw major labels
minorTicks: true, // draw minor ticks
minorLabels: true, // draw minor labels
microTicks: false, // draw micro ticks
htmlLabels: true // use HTML to draw labels
},
optionalParams: {
"min": 0, // minimal value on this axis
"max": 1, // maximal value on this axis
"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
// theme components
"stroke": {}, // stroke for an axis
"majorTick": {}, // stroke + length for a tick
"minorTick": {}, // stroke + length for a tick
"font": "", // font for labels
"fontColor": "" // color for labels as a string
},
 
constructor: function(chart, kwArgs){
this.opt = dojo.clone(this.defaultParams);
du.updateWithObject(this.opt, kwArgs);
du.updateWithPattern(this.opt, kwArgs, this.optionalParams);
},
dependOnData: function(){
return !("min" in this.opt) || !("max" in this.opt);
},
clear: function(){
delete this.scaler;
this.dirty = true;
return this;
},
initialized: function(){
return "scaler" in this;
},
calculate: function(min, max, span, labels){
if(this.initialized()){ return this; }
this.labels = "labels" in this.opt ? this.opt.labels : labels;
if("min" in this.opt){ min = this.opt.min; }
if("max" in this.opt){ max = this.opt.max; }
if(this.opt.includeZero){
if(min > 0){ min = 0; }
if(max < 0){ max = 0; }
}
var minMinorStep = 0, ta = this.chart.theme.axis,
taFont = "font" in this.opt ? this.opt.font : ta.font,
size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0;
if(this.vertical){
if(size){
minMinorStep = size + labelGap;
}
}else{
if(size){
var labelLength = Math.ceil(Math.log(Math.max(Math.abs(min), Math.abs(max))) / Math.LN10);
if(min < 0 || max < 0){ ++labelLength; }
var precision = Math.floor(Math.log(max - min) / Math.LN10);
if(precision > 0){ labelLength += precision; }
if(this.labels){
labelLength = df.foldl(df.map(this.labels, "x.text.length"), "Math.max(a, b)", labelLength);
}
minMinorStep = Math.floor(size * labelLength * labelFudgeFactor) + labelGap;
}
}
var kwArgs = {
fixUpper: this.opt.fixUpper,
fixLower: this.opt.fixLower,
natural: this.opt.natural
};
if("majorTickStep" in this.opt){ kwArgs.majorTick = this.opt.majorTickStep; }
if("minorTickStep" in this.opt){ kwArgs.minorTick = this.opt.minorTickStep; }
if("microTickStep" in this.opt){ kwArgs.microTick = this.opt.microTickStep; }
this.scaler = dojox.charting.scaler(min, max, span, kwArgs);
this.scaler.minMinorStep = minMinorStep;
return this;
},
getScaler: function(){
return this.scaler;
},
getOffsets: function(){
var offsets = {l: 0, r: 0, t: 0, b: 0};
var offset = 0, ta = this.chart.theme.axis,
taFont = "font" in this.opt ? this.opt.font : ta.font,
taMajorTick = "majorTick" in this.opt ? this.opt.majorTick : ta.majorTick,
taMinorTick = "minorTick" in this.opt ? this.opt.minorTick : ta.minorTick,
size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0;
if(this.vertical){
if(size){
var s = this.scaler,
a = this._getLabel(s.major.start, s.major.prec).length,
b = this._getLabel(s.major.start + s.major.count * s.major.tick, s.major.prec).length,
c = this._getLabel(s.minor.start, s.minor.prec).length,
d = this._getLabel(s.minor.start + s.minor.count * s.minor.tick, s.minor.prec).length,
labelLength = Math.max(a, b, c, d);
if(this.labels){
labelLength = df.foldl(df.map(this.labels, "x.text.length"), "Math.max(a, b)", labelLength);
}
offset = Math.floor(size * labelLength * labelFudgeFactor) + labelGap;
}
offset += labelGap + Math.max(taMajorTick.length, taMinorTick.length);
offsets[this.opt.leftBottom ? "l" : "r"] = offset;
offsets.t = offsets.b = size / 2;
}else{
if(size){
offset = size + labelGap;
}
offset += labelGap + Math.max(taMajorTick.length, taMinorTick.length);
offsets[this.opt.leftBottom ? "b" : "t"] = offset;
if(size){
var s = this.scaler,
a = this._getLabel(s.major.start, s.major.prec).length,
b = this._getLabel(s.major.start + s.major.count * s.major.tick, s.major.prec).length,
c = this._getLabel(s.minor.start, s.minor.prec).length,
d = this._getLabel(s.minor.start + s.minor.count * s.minor.tick, s.minor.prec).length,
labelLength = Math.max(a, b, c, d);
if(this.labels){
labelLength = df.foldl(df.map(this.labels, "x.text.length"), "Math.max(a, b)", labelLength);
}
offsets.l = offsets.r = Math.floor(size * labelLength * labelFudgeFactor) / 2;
}
}
return offsets;
},
render: function(dim, offsets){
if(!this.dirty){ return this; }
// prepare variable
var start, stop, axisVector, tickVector, labelOffset, labelAlign,
ta = this.chart.theme.axis,
taStroke = "stroke" in this.opt ? this.opt.stroke : ta.stroke,
taMajorTick = "majorTick" in this.opt ? this.opt.majorTick : ta.majorTick,
taMinorTick = "minorTick" in this.opt ? this.opt.minorTick : ta.minorTick,
taFont = "font" in this.opt ? this.opt.font : ta.font,
taFontColor = "fontColor" in this.opt ? this.opt.fontColor : ta.fontColor,
tickSize = Math.max(taMajorTick.length, taMinorTick.length),
size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0;
if(this.vertical){
start = {y: dim.height - offsets.b};
stop = {y: offsets.t};
axisVector = {x: 0, y: -1};
if(this.opt.leftBottom){
start.x = stop.x = offsets.l;
tickVector = {x: -1, y: 0};
labelAlign = "end";
}else{
start.x = stop.x = dim.width - offsets.r;
tickVector = {x: 1, y: 0};
labelAlign = "start";
}
labelOffset = {x: tickVector.x * (tickSize + labelGap), y: size * 0.4};
}else{
start = {x: offsets.l};
stop = {x: dim.width - offsets.r};
axisVector = {x: 1, y: 0};
labelAlign = "middle";
if(this.opt.leftBottom){
start.y = stop.y = dim.height - offsets.b;
tickVector = {x: 0, y: 1};
labelOffset = {y: tickSize + labelGap + size};
}else{
start.y = stop.y = offsets.t;
tickVector = {x: 0, y: -1};
labelOffset = {y: -tickSize - labelGap};
}
labelOffset.x = 0;
}
// render shapes
this.cleanGroup();
var s = this.group, c = this.scaler, step, next,
nextMajor = c.major.start, nextMinor = c.minor.start, nextMicro = c.micro.start;
s.createLine({x1: start.x, y1: start.y, x2: stop.x, y2: stop.y}).setStroke(taStroke);
if(this.opt.microTicks && c.micro.tick){
step = c.micro.tick, next = nextMicro;
}else if(this.opt.minorTicks && c.minor.tick){
step = c.minor.tick, next = nextMinor;
}else if(c.major.tick){
step = c.major.tick, next = nextMajor;
}else{
// don't draw anything
return this;
}
while(next <= c.bounds.upper + 1/c.scale){
var offset = (next - c.bounds.lower) * c.scale,
x = start.x + axisVector.x * offset,
y = start.y + axisVector.y * offset;
if(Math.abs(nextMajor - next) < step / 2){
// major tick
s.createLine({
x1: x, y1: y,
x2: x + tickVector.x * taMajorTick.length,
y2: y + tickVector.y * taMajorTick.length
}).setStroke(taMajorTick);
if(this.opt.majorLabels){
var elem = dc.axis2d.common.createText[this.opt.htmlLabels ? "html" : "gfx"]
(this.chart, s, x + labelOffset.x, y + labelOffset.y, labelAlign,
this._getLabel(nextMajor, c.major.prec), taFont, taFontColor);
if(this.opt.htmlLabels){ this.htmlElements.push(elem); }
}
nextMajor += c.major.tick;
nextMinor += c.minor.tick;
nextMicro += c.micro.tick;
}else if(Math.abs(nextMinor - next) < step / 2){
// minor tick
if(this.opt.minorTicks){
s.createLine({
x1: x, y1: y,
x2: x + tickVector.x * taMinorTick.length,
y2: y + tickVector.y * taMinorTick.length
}).setStroke(taMinorTick);
if(this.opt.minorLabels && (c.minMinorStep <= c.minor.tick * c.scale)){
var elem = dc.axis2d.common.createText[this.opt.htmlLabels ? "html" : "gfx"]
(this.chart, s, x + labelOffset.x, y + labelOffset.y, labelAlign,
this._getLabel(nextMinor, c.minor.prec), taFont, taFontColor);
if(this.opt.htmlLabels){ this.htmlElements.push(elem); }
}
}
nextMinor += c.minor.tick;
nextMicro += c.micro.tick;
}else{
// micro tick
if(this.opt.microTicks){
s.createLine({
x1: x, y1: y,
// use minor ticks for now
x2: x + tickVector.x * taMinorTick.length,
y2: y + tickVector.y * taMinorTick.length
}).setStroke(taMinorTick);
}
nextMicro += c.micro.tick;
}
next += step;
}
this.dirty = false;
return this;
},
// utilities
_getLabel: function(number, precision){
if(this.opt.labels){
// classic binary search
var l = this.opt.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 < 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 this.opt.fixed ? number.toFixed(precision < 0 ? -precision : 0) : number.toString();
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/axis2d/common.js
New file
0,0 → 1,58
if(!dojo._hasResource["dojox.charting.axis2d.common"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.axis2d.common"] = true;
dojo.provide("dojox.charting.axis2d.common");
 
dojo.require("dojox.gfx");
 
(function(){
var g = dojox.gfx;
dojo.mixin(dojox.charting.axis2d.common, {
createText: {
gfx: function(chart, creator, x, y, align, text, font, fontColor){
return creator.createText({
x: x, y: y, text: text, align: align
}).setFont(font).setFill(fontColor);
},
html: function(chart, creator, x, y, align, text, font, fontColor){
var p = dojo.doc.createElement("div"), s = p.style;
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";
s.position = "absolute";
s.font = font;
p.innerHTML = text;
s.color = fontColor;
chart.node.appendChild(p);
var parent = chart.getCoords(),
box = dojo.marginBox(p),
size = g.normalizedLength(g.splitFontString(font).size),
top = parent.y + Math.floor(y - size);
switch(align){
case "middle":
dojo.marginBox(p, {l: parent.x + Math.floor(x - box.w / 2), t: top});
break;
case "end":
dojo.marginBox(p, {l: parent.x + Math.floor(x - box.w), t: top});
break;
//case "start":
default:
dojo.marginBox(p, {l: parent.x + Math.floor(x), t: top});
break;
}
return p;
}
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/axis2d/Base.js
New file
0,0 → 1,31
if(!dojo._hasResource["dojox.charting.axis2d.Base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.axis2d.Base"] = true;
dojo.provide("dojox.charting.axis2d.Base");
 
dojo.require("dojox.charting.Element");
 
dojo.declare("dojox.charting.axis2d.Base", dojox.charting.Element, {
constructor: function(chart, kwArgs){
this.vertical = kwArgs && kwArgs.vertical;
},
clear: function(){
return this;
},
initialized: function(){
return false;
},
calculate: function(min, max, span){
return this;
},
getScaler: function(){
return null;
},
getOffsets: function(){
return {l: 0, r: 0, t: 0, b: 0};
},
render: function(dim, offsets){
return this;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/charting/README
New file
0,0 → 1,31
-------------------------------------------------------------------------------
dojox.charting
-------------------------------------------------------------------------------
Version 0.800
Release date: 10/31/2007
-------------------------------------------------------------------------------
Project state:
beta
-------------------------------------------------------------------------------
Credits
Tom Trenka (ttrenka@gmail.com)
Eugene Lazutkin (eugene.lazutkin@gmail.com)
-------------------------------------------------------------------------------
Project description
 
Implementation of simple charting library based on dojox.gfx/dojox.gfx3d.
-------------------------------------------------------------------------------
Dependencies:
 
Dojo Core, dojox.gfx, dojox.gfx3d, dojox.lang.
-------------------------------------------------------------------------------
Documentation
 
Not ready yet.
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/
-------------------------------------------------------------------------------
/trunk/api/js/dojo1.0/dojox/charting/Theme.js
New file
0,0 → 1,235
if(!dojo._hasResource["dojox.charting.Theme"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.Theme"] = true;
dojo.provide("dojox.charting.Theme");
dojo.require("dojox.charting._color");
 
(function(){
var dxc=dojox.charting;
// TODO: Legend information
dxc.Theme=function(/*object?*/kwArgs){
kwArgs=kwArgs||{};
this.chart=dojo.mixin(dojo.clone(dxc.Theme._def.chart), kwArgs.chart||{});
this.plotarea=dojo.mixin(dojo.clone(dxc.Theme._def.plotarea), kwArgs.plotarea||{});
this.axis=dojo.mixin(dojo.clone(dxc.Theme._def.axis), kwArgs.axis||{});
this.series=dojo.mixin(dojo.clone(dxc.Theme._def.series), kwArgs.series||{});
this.marker=dojo.mixin(dojo.clone(dxc.Theme._def.marker), kwArgs.marker||{});
this.markers=dojo.mixin(dojo.clone(dxc.Theme.Markers), kwArgs.markers||{});
this.colors=[];
this.antiAlias=("antiAlias" in kwArgs)?kwArgs.antiAlias:true;
this.assignColors=("assignColors" in kwArgs)?kwArgs.assignColors:true;
this.assignMarkers=("assignMarkers" in kwArgs)?kwArgs.assignMarkers:true;
this._colorCache=null;
 
// push the colors, use _def colors if none passed.
kwArgs.colors=kwArgs.colors||dxc.Theme._def.colors;
dojo.forEach(kwArgs.colors, function(item){
this.colors.push(item);
}, this);
 
// private variables for color and marker indexing
this._current={ color:0, marker: 0 };
this._markers=[];
this._buildMarkerArray();
};
 
// "static" fields
// default markers.
// A marker is defined by an SVG path segment; it should be defined as
// relative motion, and with the assumption that the path segment
// will be moved to the value point (i.e prepend Mx,y)
dxc.Theme.Markers={
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"
};
dxc.Theme._def={
// all objects are structs used directly in dojox.gfx
chart:{
stroke:null,
fill: "white"
},
plotarea:{
stroke:null,
fill: "white"
},
// TODO: label rotation on axis
axis:{
stroke:{ color:"#333",width:1 }, // the axis itself
line:{ color:"#ccc",width:1,style:"Dot",cap:"round" }, // gridlines
majorTick:{ color:"#666", width:1, length:6, position:"center" }, // major ticks on axis
minorTick:{ color:"#666", width:0.8, length:3, position:"center" }, // minor ticks on axis
font:"normal normal normal 7pt Tahoma", // labels on axis
fontColor:"#333" // color of labels
},
series:{
outline: {width: 2, color: "#ccc"}, // line or outline
stroke: {width: 2, color: "#333"}, // line or outline
fill: "#ccc", // fill, if appropriate
font: "normal normal normal 7pt Tahoma", // if there's a label
fontColor: "#000" // color of labels
},
marker:{ // any markers on a series.
stroke: {width:1}, // stroke or outline
fill: "#333", // fill if needed
font: "normal normal normal 7pt Tahoma", // label
fontColor: "#000"
},
colors:[
"#000","#111","#222","#333",
"#444","#555","#666","#777",
"#888","#999","#aaa","#bbb",
"#ccc"
]
};
// prototype methods
dojo.extend(dxc.Theme, {
defineColors: function(obj){
// we can generate a set of colors based on keyword arguments
var kwArgs=obj||{};
 
// deal with caching
var cache=false;
if(kwArgs.cache===undefined){ cache=true; }
if(kwArgs.cache==true){ cache=true; }
if(cache){
this._colorCache=kwArgs;
} else {
var mix=this._colorCache||{};
kwArgs=dojo.mixin(dojo.clone(mix), kwArgs);
}
 
var c=[], n=kwArgs.num||32; // the number of colors to generate
if(kwArgs.colors){
// we have an array of colors predefined, so fix for the number of series.
var l=kwArgs.colors.length;
for(var i=0; i<n; i++){
c.push(kwArgs.colors[i%l]);
}
this.colors=c;
}
else if(kwArgs.hue){
// single hue, generate a set based on brightness
var s=kwArgs.saturation||100; // saturation
var st=kwArgs.low||30;
var end=kwArgs.high||90;
var step=(end-st)/n; // brightness steps
for(var i=0; i<n; i++){
c.push(dxc._color.fromHsb(kwArgs.hue, s, st+(step*i)).toHex());
}
this.colors=c;
}
else if(kwArgs.stops){
// create color ranges that are either equally distributed, or
// (optionally) based on a passed "offset" property. If you
// pass an array of Colors, it will equally distribute, if
// you pass an array of structs { color, offset }, it will
// use the offset (0.0 - 1.0) to distribute. Note that offset
// values should be plotted on a line from 0.0 to 1.0--i.e.
// they should be additive. For example:
// [ {color, offset:0}, { color, offset:0.2 }, { color, offset:0.5 }, { color, offset:1.0 } ]
//
// If you use stops for colors, you MUST have a color at 0.0 and one
// at 1.0.
// figure out how many stops we have
var l=kwArgs.stops.length;
if(l<2){
throw new Error(
"dojox.charting.Theme::defineColors: when using stops to "
+ "define a color range, you MUST specify at least 2 colors."
);
}
 
// figure out if the distribution is equal or not. Note that
// colors may not exactly match the stops you define; because
// color generation is linear (i.e. evenly divided on a linear
// axis), it's very possible that a color will land in between
// two stops and not exactly *at* a stop.
//
// The only two colors guaranteed will be the end stops (i.e.
// the first and last stop), which will *always* be set as
// the end stops.
if(typeof(kwArgs.stops[0].offset)=="undefined"){
// set up equal offsets
var off=1/(l-1);
for(var i=0; i<l; i++){
kwArgs.stops[i]={
color:kwArgs.stops[i],
offset:off*i
};
}
}
// ensure the ends.
kwArgs.stops[0].offset=0;
kwArgs.stops[l-1].offset=1;
kwArgs.stops.sort(function(a,b){ return a.offset-b.offset; });
 
// create the colors.
// first stop.
c.push(kwArgs.stops[0].color.toHex());
 
// TODO: calculate the blend at n/steps and set the color
 
// last stop
c.push(kwArgs.stops[l-1].color.toHex());
this.colors=c;
}
},
_buildMarkerArray: function(){
this._markers=[];
for(var p in this.markers){ this._markers.push(this.markers[p]); }
// reset the position
this._current.marker=0;
},
 
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();
},
 
next: function(/* string? */type){
// summary
// get either the next color or the next marker, depending on what was
// passed. If type is not passed, it assumes color.
//
// example
// var color=myTheme.next();
// var color=myTheme.next("color");
// var marker=myTheme.next("marker");
if(!type) type="color";
if(type=="color"){
return this.colors[this._current.color++%this.colors.length];
}
else if(type=="marker"){
return this._markers[this._current.marker++%this._markers.length];
}
},
clear: function(){
this._current = {color: 0, marker: 0};
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/Chart2D.js
New file
0,0 → 1,339
if(!dojo._hasResource["dojox.charting.Chart2D"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.Chart2D"] = true;
dojo.provide("dojox.charting.Chart2D");
 
dojo.require("dojox.gfx");
dojo.require("dojox.lang.functional");
 
dojo.require("dojox.charting.Theme");
dojo.require("dojox.charting.Series");
 
dojo.require("dojox.charting.axis2d.Default");
 
dojo.require("dojox.charting.plot2d.Default");
dojo.require("dojox.charting.plot2d.Lines");
dojo.require("dojox.charting.plot2d.Areas");
dojo.require("dojox.charting.plot2d.Markers");
dojo.require("dojox.charting.plot2d.MarkersOnly");
dojo.require("dojox.charting.plot2d.Scatter");
dojo.require("dojox.charting.plot2d.Stacked");
dojo.require("dojox.charting.plot2d.StackedLines");
dojo.require("dojox.charting.plot2d.StackedAreas");
dojo.require("dojox.charting.plot2d.Columns");
dojo.require("dojox.charting.plot2d.StackedColumns");
dojo.require("dojox.charting.plot2d.ClusteredColumns");
dojo.require("dojox.charting.plot2d.Bars");
dojo.require("dojox.charting.plot2d.StackedBars");
dojo.require("dojox.charting.plot2d.ClusteredBars");
dojo.require("dojox.charting.plot2d.Grid");
dojo.require("dojox.charting.plot2d.Pie");
 
(function(){
var df = dojox.lang.functional, dc = dojox.charting,
clear = df.lambda("item.clear()"),
purge = df.lambda("item.purgeGroup()"),
destroy = df.lambda("item.destroy()"),
makeClean = df.lambda("item.dirty = false"),
makeDirty = df.lambda("item.dirty = true");
dojo.declare("dojox.charting.Chart2D", null, {
constructor: function(node, kwArgs){
// initialize parameters
if(!kwArgs){ kwArgs = {}; }
this.margins = kwArgs.margins ? kwArgs.margins : {l: 10, t: 10, r: 10, b: 10};
this.stroke = kwArgs.stroke;
this.fill = kwArgs.fill;
// 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;
this.coords = null;
// create a surface
this.node = dojo.byId(node);
var box = dojo.marginBox(node);
this.surface = dojox.gfx.createSurface(this.node, box.w, box.h);
},
destroy: function(){
dojo.forEach(this.series, destroy);
dojo.forEach(this.stack, destroy);
df.forIn(this.axes, destroy);
},
getCoords: function(){
if(!this.coords){
this.coords = dojo.coords(this.node, true);
}
return this.coords;
},
setTheme: function(theme){
this.theme = theme;
this.dirty = true;
return this;
},
addAxis: function(name, kwArgs){
var axis;
if(!kwArgs || !("type" in kwArgs)){
axis = new dc.axis2d.Default(this, kwArgs);
}else{
axis = typeof kwArgs.type == "string" ?
new dc.axis2d[kwArgs.type](this, kwArgs) :
new kwArgs.type(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;
},
addPlot: function(name, kwArgs){
var plot;
if(!kwArgs || !("type" in kwArgs)){
plot = new dc.plot2d.Default(this, kwArgs);
}else{
plot = typeof kwArgs.type == "string" ?
new dc.plot2d[kwArgs.type](this, kwArgs) :
new kwArgs.type(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;
},
addSeries: function(name, data, kwArgs){
var run = new dc.Series(this, data, kwArgs);
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;
},
updateSeries: function(name, data){
if(name in this.runs){
var run = this.series[this.runs[name]],
plot = this.stack[this.plots[run.plot]], axis;
run.data = data;
run.dirty = true;
// check to see if axes and plot should be updated
if(plot.hAxis){
axis = this.axes[plot.hAxis];
if(axis.dependOnData()){
axis.dirty = true;
// find all plots and mark them dirty
dojo.forEach(this.stack, function(p){
if(p.hAxis && p.hAxis == plot.hAxis){
p.dirty = true;
}
});
}
}else{
plot.dirty = true;
}
if(plot.vAxis){
axis = this.axes[plot.vAxis];
if(axis.dependOnData()){
axis.dirty = true;
// find all plots and mark them dirty
dojo.forEach(this.stack, function(p){
if(p.vAxis && p.vAxis == plot.vAxis){
p.dirty = true;
}
});
}
}else{
plot.dirty = true;
}
}
return this;
},
resize: function(width, height){
var box;
switch(arguments.length){
case 0:
box = dojo.marginBox(this.node);
break;
case 1:
box = width;
break;
default:
box = {w: width, h: height};
break;
}
dojo.marginBox(this.node, box);
this.surface.setDimensions(box.w, box.h);
this.dirty = true;
this.coords = null;
return this.render();
},
render: function(){
if(this.dirty){
return this.fullRender();
}
// calculate geometry
dojo.forEach(this.stack, function(plot){
if(plot.dirty || (plot.hAxis && this.axes[plot.hAxis].dirty) ||
(plot.vAxis && this.axes[plot.vAxis].dirty)){
plot.calculateAxes(this.plotArea);
}
}, this);
 
// go over the stack backwards
df.forEachReversed(this.stack, function(plot){ plot.render(this.dim, this.offsets); }, this);
// go over axes
df.forIn(this.axes, function(axis){ axis.render(this.dim, this.offsets); }, this);
 
this._makeClean();
 
// BEGIN FOR HTML CANVAS
if(this.surface.render){ this.surface.render(); };
// END FOR HTML CANVAS
return this;
},
fullRender: function(){
this._makeDirty();
// clear old values
dojo.forEach(this.stack, clear);
dojo.forEach(this.series, purge);
df.forIn(this.axes, purge);
dojo.forEach(this.stack, purge);
this.surface.clear();
// rebuild new connections, and add defaults
// assign series
dojo.forEach(this.series, function(run){
if(!(run.plot in this.plots)){
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
dojo.forEach(this.stack, function(plot){
if(plot.hAxis){
plot.setAxis(this.axes[plot.hAxis]);
}
if(plot.vAxis){
plot.setAxis(this.axes[plot.vAxis]);
}
}, this);
// set up a theme
if(!this.theme){
this.theme = new dojox.charting.Theme(dojox.charting._def);
}
var requiredColors = df.foldl(this.stack, "z + plot.getRequiredColors()", 0);
this.theme.defineColors({num: requiredColors, cache: false});
// calculate geometry
// 1st pass
var dim = this.dim = this.surface.getDimensions();
dim.width = dojox.gfx.normalizedLength(dim.width);
dim.height = dojox.gfx.normalizedLength(dim.height);
df.forIn(this.axes, clear);
dojo.forEach(this.stack, function(plot){ plot.calculateAxes(dim); });
// assumption: we don't have stacked axes yet
var offsets = this.offsets = {l: 0, r: 0, t: 0, b: 0};
df.forIn(this.axes, function(axis){
df.forIn(axis.getOffsets(), function(o, i){ offsets[i] += o; });
});
// add margins
df.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};
df.forIn(this.axes, clear);
dojo.forEach(this.stack, function(plot){ plot.calculateAxes(this.plotArea); }, this);
// generate shapes
// draw a chart background
var t = this.theme,
fill = this.fill ? this.fill : (t.chart && t.chart.fill),
stroke = this.stroke ? this.stroke : (t.chart && t.chart.stroke);
if(fill){
this.surface.createRect({
width: dim.width,
height: dim.height
}).setFill(fill);
}
if(stroke){
this.surface.createRect({
width: dim.width - 1,
height: dim.height - 1
}).setStroke(stroke);
}
// draw a plot background
fill = t.plotarea && t.plotarea.fill;
stroke = t.plotarea && t.plotarea.stroke;
if(fill){
this.surface.createRect({
x: offsets.l, y: offsets.t,
width: dim.width - offsets.l - offsets.r,
height: dim.height - offsets.t - offsets.b
}).setFill(fill);
}
if(stroke){
this.surface.createRect({
x: offsets.l, y: offsets.t,
width: dim.width - offsets.l - offsets.r - 1,
height: dim.height - offsets.t - offsets.b - 1
}).setStroke(stroke);
}
// go over the stack backwards
df.foldr(this.stack, function(z, plot){ return plot.render(dim, offsets), 0; }, 0);
// go over axes
df.forIn(this.axes, function(axis){ axis.render(dim, offsets); });
this._makeClean();
return this;
},
_makeClean: function(){
// reset dirty flags
dojo.forEach(this.axes, makeClean);
dojo.forEach(this.stack, makeClean);
dojo.forEach(this.series, makeClean);
this.dirty = false;
},
_makeDirty: function(){
// reset dirty flags
dojo.forEach(this.axes, makeDirty);
dojo.forEach(this.stack, makeDirty);
dojo.forEach(this.series, makeDirty);
this.dirty = true;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/tests/test_chart2d_updating.html
New file
0,0 → 1,80
<html>
<head>
<title>Chart 2D</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../../lang/functional.js"></script>
<script type="text/javascript" src="../Theme.js"></script>
<script type="text/javascript" src="../scaler.js"></script>
<script type="text/javascript" src="../Chart2D.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.charting.Chart2D");
dojo.require("dojox.charting.themes.PlotKit.orange");
 
var chart, limit = 10, magnitude = 30;
 
var randomValue = function(){
return Math.random() * magnitude;
};
 
var makeSeries = function(len){
var s = [];
do{
s.push(randomValue());
}while(s.length < len);
return s;
};
 
var seriesA = makeSeries(limit),
seriesB = makeSeries(limit),
seriesC = makeSeries(limit);
 
var makeObjects = function(){
chart = new dojox.charting.Chart2D("test");
chart.setTheme(dojox.charting.themes.PlotKit.orange);
chart.addAxis("x", {fixLower: "minor", natural: true, min: 1, max: limit});
chart.addAxis("y", {vertical: true, min: 0, max: 30, majorTickStep: 5, minorTickStep: 1});
chart.addPlot("default", {type: "Areas"});
chart.addSeries("Series A", seriesA);
chart.addSeries("Series B", seriesB);
chart.addSeries("Series C", seriesC);
chart.addPlot("grid", {type: "Grid", hMinorLines: true});
chart.render();
setInterval("updateTest()", 200);
};
 
var updateTest = function(){
seriesA.shift();
seriesA.push(randomValue());
chart.updateSeries("Series A", seriesA);
 
seriesB.shift();
seriesB.push(randomValue());
chart.updateSeries("Series B", seriesB);
 
seriesC.shift();
seriesC.push(randomValue());
chart.updateSeries("Series C", seriesC);
 
chart.render();
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Chart 2D Updating Data</h1>
<p>Areas, orange theme, axes, grid. Very crude example to show a chart with updating values.</p>
<div id="test" style="width: 400px; height: 400px;"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/charting/tests/test_pie2d.html
New file
0,0 → 1,94
<html>
<head>
<title>Pie 2D</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../../lang/functional.js"></script>
<script type="text/javascript" src="../../lang/utils.js"></script>
<script type="text/javascript" src="../Theme.js"></script>
<script type="text/javascript" src="../scaler.js"></script>
<script type="text/javascript" src="../Element.js"></script>
<script type="text/javascript" src="../plot2d/Pie.js"></script>
<script type="text/javascript" src="../Chart2D.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.charting.Chart2D");
dojo.require("dojox.charting.themes.PlotKit.blue");
dojo.require("dojox.charting.themes.PlotKit.green");
 
makeObjects = function(){
var chart1 = new dojox.charting.Chart2D("test1");
chart1.setTheme(dojox.charting.themes.PlotKit.blue);
chart1.addPlot("default", {
type: "Pie",
font: "normal normal bold 12pt Tahoma",
fontColor: "white",
labelOffset: 40
});
chart1.addSeries("Series A", [4, 2, 1, 1]);
chart1.render();
 
var chart2 = new dojox.charting.Chart2D("test2");
chart2.setTheme(dojox.charting.themes.PlotKit.blue);
chart2.addPlot("default", {
type: "Pie",
font: "normal normal bold 12pt Tahoma",
fontColor: "black",
labelOffset: -25,
precision: 0
});
chart2.addSeries("Series A", [4, 2, 1, 1]);
chart2.render();
 
var chart3 = new dojox.charting.Chart2D("test3");
chart3.setTheme(dojox.charting.themes.PlotKit.green);
chart3.addPlot("default", {
type: "Pie",
font: "normal normal bold 10pt Tahoma",
fontColor: "white",
labelOffset: 25,
radius: 90
});
chart3.addSeries("Series A", [4, 2, 1, 1]);
chart3.render();
 
var chart4 = new dojox.charting.Chart2D("test4");
chart4.setTheme(dojox.charting.themes.PlotKit.green);
chart4.addPlot("default", {
type: "Pie",
font: "normal normal bold 10pt Tahoma",
fontColor: "black",
labelOffset: -25,
radius: 90
});
chart4.addSeries("Series A", [4, 2, 1, 1]);
chart4.render();
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Pie 2D</h1>
<!--<p><button onclick="makeObjects();">Go</button></p>-->
<p>1: Pie with internal labels.</p>
<div id="test1" style="width: 400px; height: 400px;"></div>
<p>2: Pie with external labels and precision=0.</p>
<div id="test2" style="width: 400px; height: 400px;"></div>
<p>3/4: Two pies with internal and external labels with a constant radius.</p>
<table border="1"><tr>
<td><div id="test3" style="width: 300px; height: 300px;"></div></td>
<td><div id="test4" style="width: 300px; height: 300px;"></div></td>
</tr></table>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/charting/tests/_color.js
New file
0,0 → 1,82
if(!dojo._hasResource["dojox.charting.tests._color"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.tests._color"] = true;
dojo.provide("dojox.charting.tests._color");
dojo.require("dojox.charting._color");
 
/*
Note that there are some minor inaccuracies that
can be introduced for comparison purposes; the
formulae used in Photoshop may produce *slightly*
different numbers. But numbers will be off by
1, if at all.
*/
(function(){
var dxc=dojox.charting;
var rgb=[
{ r:0x4f, g:0xc8, b:0xd6 },
{ r:0x40, g:0x9e, b:0x02 },
{ r:0xff, g:0xfb, b:0x85 },
{ r:0x7b, g:0x5a, b:0x7d }
];
var hsb=[
{ h:186, s:63, b: 84 },
{ h: 96, s:99, b: 62 },
{ h: 58, s:48, b:100 },
{ h:297, s:28, b: 49 }
];
tests.register("dojox.charting.tests._util", [
function testToHsb(t){
var c=rgb[0];
var oHsb=dxc._color.toHsb(c.r, c.g, c.b);
t.assertEqual(hsb[0].h, oHsb.h);
t.assertEqual(hsb[0].s, oHsb.s);
t.assertEqual(hsb[0].b, oHsb.b);
 
var c=rgb[1];
var oHsb=dxc._color.toHsb(c.r, c.g, c.b);
t.assertEqual(hsb[1].h, oHsb.h);
t.assertEqual(hsb[1].s, oHsb.s);
t.assertEqual(hsb[1].b, oHsb.b);
var c=rgb[2];
var oHsb=dxc._color.toHsb(c.r, c.g, c.b);
t.assertEqual(hsb[2].h, oHsb.h);
t.assertEqual(hsb[2].s, oHsb.s);
t.assertEqual(hsb[2].b, oHsb.b);
 
var c=rgb[3];
var oHsb=dxc._color.toHsb(c.r, c.g, c.b);
t.assertEqual(hsb[3].h, oHsb.h);
t.assertEqual(hsb[3].s, oHsb.s);
t.assertEqual(hsb[3].b, oHsb.b);
},
function testFromHsb(t){
var c1=dxc._color.fromHsb(hsb[0].h, hsb[0].s, hsb[0].b);
var c2=rgb[0];
t.assertEqual(c1.r, c2.r);
t.assertEqual(c1.g, c2.g);
t.assertEqual(c1.b, c2.b);
 
var c1=dxc._color.fromHsb(hsb[1].h, hsb[1].s, hsb[1].b);
var c2=rgb[1];
t.assertEqual(c1.r, c2.r);
t.assertEqual(c1.g, c2.g);
t.assertEqual(c1.b, c2.b);
 
var c1=dxc._color.fromHsb(hsb[2].h, hsb[2].s, hsb[2].b);
var c2=rgb[2];
t.assertEqual(c1.r, c2.r);
t.assertEqual(c1.g, c2.g);
t.assertEqual(c1.b, c2.b);
 
var c1=dxc._color.fromHsb(hsb[3].h, hsb[3].s, hsb[3].b);
var c2=rgb[3];
t.assertEqual(c1.r, c2.r);
t.assertEqual(c1.g, c2.g);
t.assertEqual(c1.b, c2.b);
}
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/tests/test_bars.html
New file
0,0 → 1,65
<html>
<head>
<title>Bar chart</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../Chart3D.js"></script>
<script type="text/javascript" src="../plot3d/Base.js"></script>
<script type="text/javascript" src="../plot3d/Bars.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.charting.Chart3D");
dojo.require("dojox.charting.plot3d.Bars");
 
makeObjects = function(){
var m = dojox.gfx3d.matrix;
var chart = new dojox.charting.Chart3D("test",
{
lights: [{direction: {x: 5, y: 5, z: -5}, color: "white"}],
ambient: {color:"white", intensity: 2},
specular: "white"
},
[m.cameraRotateXg(10), m.cameraRotateYg(-10), m.scale(0.8), m.cameraTranslate(-50, -50, 0)]
);
var plot1 = new dojox.charting.plot3d.Bars(500, 500, {gap: 10, material: "yellow"});
plot1.setData([1,2,3,2,1,2,3,4,5]);
chart.addPlot(plot1);
var plot2 = new dojox.charting.plot3d.Bars(500, 500, {gap: 10, material: "red"});
plot2.setData([2,3,4,3,2,3,4,5,5]);
chart.addPlot(plot2);
var plot3 = new dojox.charting.plot3d.Bars(500, 500, {gap: 10, material: "blue"});
plot3.setData([3,4,5,4,3,4,5,5,5]);
chart.addPlot(plot3);
chart.generate().render();
//dojo.byId("out1").value = dojo.byId("test").innerHTML;
//dojo.byId("out2").value = dojox.gfx.utils.toJson(surface, true);
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Bar chart</h1>
<div id="test" style="width: 500px; height: 500px;"></div>
<!--
<p><button onclick="makeObjects();">Go</button></p>
<p><textarea id="out1" cols="40" rows="5"></textarea></p>
<p><textarea id="out2" cols="40" rows="5"></textarea></p>
-->
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/charting/tests/test_chart2d.html
New file
0,0 → 1,338
<html>
<head>
<title>Chart 2D</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../../lang/functional.js"></script>
<script type="text/javascript" src="../../lang/utils.js"></script>
<script type="text/javascript" src="../Theme.js"></script>
<script type="text/javascript" src="../scaler.js"></script>
<script type="text/javascript" src="../Element.js"></script>
<script type="text/javascript" src="../axis2d/common.js"></script>
<script type="text/javascript" src="../axis2d/Base.js"></script>
<script type="text/javascript" src="../axis2d/Default.js"></script>
<script type="text/javascript" src="../plot2d/common.js"></script>
<script type="text/javascript" src="../plot2d/Base.js"></script>
<script type="text/javascript" src="../plot2d/Default.js"></script>
<script type="text/javascript" src="../plot2d/Lines.js"></script>
<script type="text/javascript" src="../plot2d/Areas.js"></script>
<script type="text/javascript" src="../plot2d/Markers.js"></script>
<script type="text/javascript" src="../plot2d/MarkersOnly.js"></script>
<script type="text/javascript" src="../plot2d/Scatter.js"></script>
<script type="text/javascript" src="../plot2d/Stacked.js"></script>
<script type="text/javascript" src="../plot2d/StackedLines.js"></script>
<script type="text/javascript" src="../plot2d/StackedAreas.js"></script>
<script type="text/javascript" src="../plot2d/Columns.js"></script>
<script type="text/javascript" src="../plot2d/StackedColumns.js"></script>
<script type="text/javascript" src="../plot2d/ClusteredColumns.js"></script>
<script type="text/javascript" src="../plot2d/Bars.js"></script>
<script type="text/javascript" src="../plot2d/StackedBars.js"></script>
<script type="text/javascript" src="../plot2d/ClusteredBars.js"></script>
<script type="text/javascript" src="../plot2d/Grid.js"></script>
<script type="text/javascript" src="../plot2d/Pie.js"></script>
<script type="text/javascript" src="../Chart2D.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.charting.Chart2D");
dojo.require("dojox.charting.themes.PlotKit.blue");
dojo.require("dojox.charting.themes.PlotKit.cyan");
dojo.require("dojox.charting.themes.PlotKit.green");
dojo.require("dojox.charting.themes.PlotKit.orange");
dojo.require("dojox.charting.themes.PlotKit.purple");
dojo.require("dojox.charting.themes.PlotKit.red");
 
makeObjects = function(){
var chart1 = new dojox.charting.Chart2D("test1");
chart1.addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]);
chart1.addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]);
chart1.render();
 
var chart2 = new dojox.charting.Chart2D("test2");
chart2.addSeries("Series A", [1, 2, 1, 2, 1, 2, 1], {stroke: "red"});
chart2.addSeries("Series B", [2, 1, 2, 1, 2, 1, 2], {stroke: "blue"});
chart2.render();
 
var chart3 = new dojox.charting.Chart2D("test3");
chart3.addPlot("default", {type: "Areas"});
chart3.setTheme(dojox.charting.themes.PlotKit.orange);
chart3.addSeries("Series A", [1, 2, 0.5, 1.5, 1, 2.8, 0.4]);
chart3.addSeries("Series B", [2.6, 1.8, 2, 1, 1.4, 0.7, 2]);
chart3.addSeries("Series C", [6.3, 1.8, 3, 0.5, 4.4, 2.7, 2]);
chart3.render();
 
var chart4 = new dojox.charting.Chart2D("test4");
chart4.addPlot("default", {type: "Areas"});
chart4.addSeries("Series A", [1, 2, 1, 2, 1, 2, 1], {stroke: {color: "red", width: 2}, fill: "lightpink"});
chart4.addSeries("Series B", [2, 1, 2, 1, 2, 1, 2], {stroke: {color: "blue", width: 2}, fill: "lightblue"});
chart4.render();
 
var chart5 = new dojox.charting.Chart2D("test5");
chart5.setTheme(dojox.charting.themes.PlotKit.blue);
chart5.addAxis("x");
chart5.addAxis("y", {vertical: true});
chart5.addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]);
chart5.addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]);
chart5.render();
 
var chart6 = new dojox.charting.Chart2D("test6");
chart6.setTheme(dojox.charting.themes.PlotKit.cyan);
chart6.addAxis("x", {fixLower: "minor", fixUpper: "minor"});
chart6.addAxis("y", {vertical: true, fixLower: "minor", fixUpper: "minor"});
chart6.addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]);
chart6.addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]);
chart6.render();
 
var chart7 = new dojox.charting.Chart2D("test7");
chart7.setTheme(dojox.charting.themes.PlotKit.green);
chart7.addAxis("x", {fixLower: "major", fixUpper: "major"});
chart7.addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major"});
chart7.addSeries("Series A", [1, 2, 1, 2, 1, 2, 1]);
chart7.addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]);
chart7.render();
 
var chart8 = new dojox.charting.Chart2D("test8");
chart8.setTheme(dojox.charting.themes.PlotKit.purple);
chart8.addPlot("default", {type: "Markers"});
chart8.addSeries("Series A", [1, 2, 1, 2, 1, 2, 1], {min: 0, max: 3});
chart8.addSeries("Series B", [2, 1, 2, 1, 2, 1, 2]);
chart8.render();
 
var chart9 = new dojox.charting.Chart2D("test9");
chart9.addPlot("default", {type: "MarkersOnly"});
chart9.addSeries("Series A", [1, 2, 1, 2, 1, 2, 1], {min: 0, max: 3, stroke: {color: "red", width: 2}, marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0"});
chart9.addSeries("Series B", [2, 1, 2, 1, 2, 1, 2], {stroke: {color: "blue", width: 2}, marker: "m-3,-3 l0,6 6,0 0,-6 z"});
chart9.render();
 
var chart10 = new dojox.charting.Chart2D("test10");
chart10.addPlot("default", {type: "Markers", shadows: {dx: 2, dy: 2, dw: 2}});
chart10.addSeries("Series A", [1, 2, 1, 2, 1, 2, 1], {min: 0, max: 3, stroke: {color: "red", width: 2, join: "round"}, marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0"});
chart10.addSeries("Series B", [2, 1, 2, 1, 2, 1, 2], {stroke: {color: "blue", width: 2, join: "round"}, marker: "m-3,-3 l0,6 6,0 0,-6 z"});
chart10.render();
 
var chart11 = new dojox.charting.Chart2D("test11");
chart11.addPlot("default", {type: "StackedLines", markers: true, shadows: {dx: 2, dy: 2, dw: 2}});
chart11.addSeries("Series A", [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6], {stroke: {color: "red", width: 2}, fill: "lightpink", marker: "m-3,-3 l0,6 6,0 0,-6 z"});
chart11.addSeries("Series B", [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6], {stroke: {color: "blue", width: 2}, fill: "lightblue", marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0"});
chart11.addSeries("Series C", [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6], {stroke: {color: "green", width: 2}, fill: "lightgreen", marker: "m0,-3 l3,3 -3,3 -3,-3 z"});
chart11.render();
 
var chart12 = new dojox.charting.Chart2D("test12");
chart12.addAxis("x", {fixLower: "major", fixUpper: "major"});
chart12.addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major"});
chart12.addPlot("default", {type: "StackedAreas"});
chart12.addSeries("Series A", [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6], {stroke: {color: "red", width: 2}, fill: "lightpink"});
chart12.addSeries("Series B", [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6], {stroke: {color: "blue", width: 2}, fill: "lightblue"});
chart12.addSeries("Series C", [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6], {stroke: {color: "green", width: 2}, fill: "lightgreen"});
chart12.render();
 
var chart13 = new dojox.charting.Chart2D("test13");
chart13.addPlot("default", {type: "Columns"});
chart13.addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"});
chart13.addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"});
chart13.render();
 
var chart14 = new dojox.charting.Chart2D("test14");
chart14.addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major"});
chart14.addPlot("default", {type: "Columns", gap: 2});
chart14.addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"});
chart14.addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"});
chart14.render();
 
var chart15 = new dojox.charting.Chart2D("test15");
chart15.addPlot("default", {type: "StackedColumns"});
chart15.addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"});
chart15.addSeries("Series B", [2, 1, 2, 1, 2], {stroke: {color: "blue"}, fill: "lightblue"});
chart15.render();
 
var chart16 = new dojox.charting.Chart2D("test16");
chart16.addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true});
chart16.addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true});
chart16.addPlot("default", {type: "Bars"});
chart16.addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"});
chart16.addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"});
chart16.render();
 
var chart17 = new dojox.charting.Chart2D("test17");
chart17.addPlot("default", {type: "StackedBars"});
chart17.addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"});
chart17.addSeries("Series B", [2, 1, 2, 1, 2], {stroke: {color: "blue"}, fill: "lightblue"});
chart17.render();
 
var chart18 = new dojox.charting.Chart2D("test18");
chart18.addAxis("x", {fixLower: "minor", fixUpper: "minor", natural: true});
chart18.addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", includeZero: true});
chart18.addPlot("default", {type: "ClusteredColumns", gap: 2});
chart18.addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"});
chart18.addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"});
chart18.render();
 
var chart19 = new dojox.charting.Chart2D("test19");
chart19.addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true});
chart19.addAxis("y", {vertical: true, fixLower: "minor", fixUpper: "minor", natural: true});
chart19.addPlot("default", {type: "ClusteredBars", gap: 2});
chart19.addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"});
chart19.addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"});
chart19.render();
 
var chart20 = new dojox.charting.Chart2D("test20");
chart20.addAxis("x", {fixLower: "minor", fixUpper: "minor", natural: true});
chart20.addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", minorTicks: false, includeZero: true});
chart20.addPlot("front_grid", {type: "Grid", hMajorLines: true, vMajorLines: false});
chart20.addPlot("default", {type: "Columns", gap: 2});
chart20.addPlot("back_grid", {type: "Grid", hMajorLines: false, vMajorLines: true});
chart20.addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"});
chart20.addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"});
chart20.render();
 
var chart21 = new dojox.charting.Chart2D("test21");
chart21.addAxis("x", {fixLower: "minor", fixUpper: "minor", natural: true});
chart21.addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major",
includeZero: true, min: 0, max: 8, minorLabels: false,
majorTicks: true, minorTicks: true, microTicks: false,
majorTickStep: 2, minorTickStep: 1, microTickStep: 0.5});
chart21.addPlot("front_grid", {type: "Grid", hMajorLines: true, vMajorLines: false});
chart21.addPlot("default", {type: "Columns", gap: 2});
chart21.addPlot("back_grid", {type: "Grid", hMajorLines: false, vMajorLines: true});
chart21.addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"});
chart21.addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"});
chart21.render();
 
var chart22 = new dojox.charting.Chart2D("test22");
chart22.addAxis("x");
chart22.addAxis("y", {vertical: true});
chart22.addPlot("default", {type: "Columns", gap: 2});
chart22.addPlot("grid", {type: "Grid"});
chart22.addSeries("Series A", [2, 1, 0.5, -1, -2], {stroke: {color: "red"}, fill: "lightpink"});
chart22.addSeries("Series B", [-2, -1, -0.5, 1, 2], {stroke: {color: "blue"}, fill: "lightblue"});
chart22.render();
 
var chart23 = new dojox.charting.Chart2D("test23");
chart23.addAxis("x");
chart23.addAxis("y", {vertical: true});
chart23.addPlot("default", {type: "ClusteredColumns", gap: 2});
chart23.addPlot("grid", {type: "Grid"});
chart23.addSeries("Series A", [2, 1, 0.5, -1, -2], {stroke: {color: "red"}, fill: "lightpink"});
chart23.addSeries("Series B", [-2, -1, -0.5, 1, 2], {stroke: {color: "blue"}, fill: "lightblue"});
chart23.addSeries("Series C", [1, 0.5, -1, -2, -3], {stroke: {color: "green"}, fill: "lightgreen"});
chart23.render();
 
var chart24 = new dojox.charting.Chart2D("test24");
chart24.addAxis("x");
chart24.addAxis("y", {vertical: true});
chart24.addPlot("default", {type: "Bars", gap: 2});
chart24.addPlot("grid", {type: "Grid"});
chart24.addSeries("Series A", [2, 1, 0.5, -1, -2], {stroke: {color: "red"}, fill: "lightpink"});
chart24.addSeries("Series B", [-2, -1, -0.5, 1, 2], {stroke: {color: "blue"}, fill: "lightblue"});
chart24.render();
 
var chart25 = new dojox.charting.Chart2D("test25");
chart25.addAxis("x");
chart25.addAxis("y", {vertical: true});
chart25.addPlot("default", {type: "ClusteredBars", gap: 2});
chart25.addPlot("grid", {type: "Grid"});
chart25.addSeries("Series A", [2, 1, 0.5, -1, -2], {stroke: {color: "red"}, fill: "lightpink"});
chart25.addSeries("Series B", [-2, -1, -0.5, 1, 2], {stroke: {color: "blue"}, fill: "lightblue"});
chart25.addSeries("Series C", [1, 0.5, -1, -2, -3], {stroke: {color: "green"}, fill: "lightgreen"});
chart25.render();
 
var chart26 = new dojox.charting.Chart2D("test26");
chart26.setTheme(dojox.charting.themes.PlotKit.red);
chart26.addAxis("x", {min: 0, max: 6, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
chart26.addAxis("y", {vertical: true, min: 0, max: 10, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
chart26.addSeries("Series A", [{x: 0.5, y: 5}, {x: 1.5, y: 1.5}, {x: 2, y: 9}, {x: 5, y: 0.3}]);
chart26.addSeries("Series B", [{x: 0.3, y: 8}, {x: 4, y: 6}, {x: 5.5, y: 2}]);
chart26.render();
 
var chart27 = new dojox.charting.Chart2D("test27");
chart27.setTheme(dojox.charting.themes.PlotKit.purple);
chart27.addPlot("default", {type: "Scatter"});
chart27.addAxis("x", {min: 0, max: 6, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
chart27.addAxis("y", {vertical: true, min: 0, max: 10, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
chart27.addSeries("Series A", [{x: 0.5, y: 5}, {x: 1.5, y: 1.5}, {x: 2, y: 9}, {x: 5, y: 0.3}]);
chart27.addSeries("Series B", [{x: 0.3, y: 8}, {x: 4, y: 6}, {x: 5.5, y: 2}]);
chart27.render();
 
var chart28 = new dojox.charting.Chart2D("test28");
chart28.setTheme(dojox.charting.themes.PlotKit.blue);
chart28.addPlot("default", {type: "Default", lines: true, markers: true});
chart28.addAxis("x", {min: 0, max: 6, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
chart28.addAxis("y", {vertical: true, min: 0, max: 10, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
chart28.addSeries("Series A", [{x: 0.5, y: 5}, {x: 1.5, y: 1.5}, {x: 2, y: 9}, {x: 5, y: 0.3}]);
chart28.addSeries("Series B", [{x: 0.3, y: 8}, {x: 4, y: 6}, {x: 5.5, y: 2}]);
chart28.render();
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Chart 2D</h1>
<!--<p><button onclick="makeObjects();">Go</button></p>-->
<p>1: Defaults: lines, no axes.</p>
<div id="test1" style="width: 400px; height: 400px;"></div>
<p>2: Defaults: lines, no axes, and custom strokes.</p>
<div id="test2" style="width: 400px; height: 400px;"></div>
<p>3: Areas, orange theme, no axes.</p>
<div id="test3" style="width: 400px; height: 400px;"></div>
<p>4: Areas, no axes, custom strokes and fills.</p>
<div id="test4" style="width: 400px; height: 400px;"></div>
<p>5: Lines, axes, blue theme.</p>
<div id="test5" style="width: 400px; height: 400px;"></div>
<p>6: Lines, axes (aligned on minor ticks), cyan theme.</p>
<div id="test6" style="width: 400px; height: 400px;"></div>
<p>7: Lines, axes (aligned on major ticks), green theme.</p>
<div id="test7" style="width: 400px; height: 400px;"></div>
<p>8: Lines and markers, no axes, purple theme, custom min/max.</p>
<div id="test8" style="width: 200px; height: 200px;"></div>
<p>9: Markers only, no axes, custom theme, custom markers, custom min/max.</p>
<div id="test9" style="width: 200px; height: 200px;"></div>
<p>10: Lines and markers, shadows, no axes, custom theme, custom markers, custom min/max.</p>
<div id="test10" style="width: 200px; height: 200px;"></div>
<p>11: Stacked lines, markers, shadows, no axes, custom strokes, fills, and markers.</p>
<div id="test11" style="width: 200px; height: 200px;"></div>
<p>12: Stacked areas, axes (aligned on major ticks), custom strokes and fills.</p>
<div id="test12" style="width: 200px; height: 200px;"></div>
<p>13: Columns, no axes, custom strokes and fills.</p>
<div id="test13" style="width: 200px; height: 200px;"></div>
<p>14: Columns with gaps beetwen them, vertical axis aligned on major ticks, custom strokes, fills.</p>
<div id="test14" style="width: 200px; height: 200px;"></div>
<p>15: Stacked columns, no axes, custom strokes and fills.</p>
<div id="test15" style="width: 200px; height: 200px;"></div>
<p>16: Bars, axes aligned on major ticks, no minor ticks, custom strokes and fills.</p>
<div id="test16" style="width: 200px; height: 200px;"></div>
<p>17: Stacked bars, no axes, custom strokes and fills.</p>
<div id="test17" style="width: 200px; height: 200px;"></div>
<p>18: Clustered columns, custom axes, custom strokes, fills, and gap.</p>
<div id="test18" style="width: 200px; height: 200px;"></div>
<p>19: Clustered bars, custom axes, custom strokes, fills, and gap.</p>
<div id="test19" style="width: 200px; height: 200px;"></div>
<p>20: Columns with gaps beetwen them, grids, custom strokes, fills, axes.</p>
<div id="test20" style="width: 200px; height: 200px;"></div>
<p>21: Columns with gaps beetwen them, grids, custom strokes, fills, axes, with min=0, max=8, and manually specified ticks on the vertical axis.</p>
<div id="test21" style="width: 200px; height: 200px;"></div>
<p>22: Columns with positive and negative values, axes, and grid.</p>
<div id="test22" style="width: 200px; height: 200px;"></div>
<p>23: Clustered columns with positive and negative values, axes, and grid.</p>
<div id="test23" style="width: 200px; height: 200px;"></div>
<p>24: Bars with positive and negative values, axes, and grid.</p>
<div id="test24" style="width: 200px; height: 200px;"></div>
<p>25: Clustered bars with positive and negative values, axes, and grid.</p>
<div id="test25" style="width: 200px; height: 200px;"></div>
<p>26: Default lines with 2D data, custom axis, red theme.</p>
<div id="test26" style="width: 200px; height: 200px;"></div>
<p>27: Scatter chart, custom axis, purple theme.</p>
<div id="test27" style="width: 200px; height: 200px;"></div>
<p>28: Markers, lines, 2D data, custom axis, blue theme.</p>
<div id="test28" style="width: 200px; height: 200px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/charting/tests/charting.js
New file
0,0 → 1,12
if(!dojo._hasResource["dojox.charting.tests.charting"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.tests.charting"] = true;
dojo.provide("dojox.charting.tests.charting");
 
try{
dojo.require("dojox.charting.tests._color");
dojo.require("dojox.charting.tests.Theme");
}catch(e){
doh.debug(e);
}
 
}
/trunk/api/js/dojo1.0/dojox/charting/tests/runTests.html
New file
0,0 → 1,9
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dojox.wire Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.charting.tests.charting"></HEAD>
<BODY>
Redirecting to D.O.H runner.
</BODY>
</HTML>
/trunk/api/js/dojo1.0/dojox/charting/tests/test_labels2d.html
New file
0,0 → 1,90
<html>
<head>
<title>Chart 2D</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../../lang/functional.js"></script>
<script type="text/javascript" src="../../lang/utils.js"></script>
<script type="text/javascript" src="../Theme.js"></script>
<script type="text/javascript" src="../scaler.js"></script>
<script type="text/javascript" src="../Element.js"></script>
<script type="text/javascript" src="../axis2d/common.js"></script>
<script type="text/javascript" src="../axis2d/Base.js"></script>
<script type="text/javascript" src="../axis2d/Default.js"></script>
<script type="text/javascript" src="../plot2d/common.js"></script>
<script type="text/javascript" src="../plot2d/Base.js"></script>
<script type="text/javascript" src="../plot2d/Default.js"></script>
<script type="text/javascript" src="../plot2d/Lines.js"></script>
<script type="text/javascript" src="../plot2d/Areas.js"></script>
<script type="text/javascript" src="../plot2d/Markers.js"></script>
<script type="text/javascript" src="../plot2d/MarkersOnly.js"></script>
<script type="text/javascript" src="../plot2d/Stacked.js"></script>
<script type="text/javascript" src="../plot2d/StackedLines.js"></script>
<script type="text/javascript" src="../plot2d/StackedAreas.js"></script>
<script type="text/javascript" src="../plot2d/Columns.js"></script>
<script type="text/javascript" src="../plot2d/StackedColumns.js"></script>
<script type="text/javascript" src="../plot2d/ClusteredColumns.js"></script>
<script type="text/javascript" src="../plot2d/Bars.js"></script>
<script type="text/javascript" src="../plot2d/StackedBars.js"></script>
<script type="text/javascript" src="../plot2d/ClusteredBars.js"></script>
<script type="text/javascript" src="../plot2d/Grid.js"></script>
<script type="text/javascript" src="../plot2d/Pie.js"></script>
<script type="text/javascript" src="../Chart2D.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.charting.Chart2D");
dojo.require("dojox.charting.themes.PlotKit.blue");
dojo.require("dojox.charting.themes.PlotKit.cyan");
dojo.require("dojox.charting.themes.PlotKit.green");
dojo.require("dojox.charting.themes.PlotKit.orange");
dojo.require("dojox.charting.themes.PlotKit.purple");
dojo.require("dojox.charting.themes.PlotKit.red");
 
makeObjects = function(){
var chart1 = new dojox.charting.Chart2D("test1");
chart1.addAxis("x", {fixLower: "major", fixUpper: "major", includeZero: true});
chart1.addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", natural: true});
chart1.addPlot("default", {type: "Bars"});
chart1.addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"});
chart1.addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"});
chart1.render();
var chart2 = new dojox.charting.Chart2D("test2");
chart2.addAxis("x", {
fixLower: "major", fixUpper: "major", includeZero: true,
labels: [{value: 0, text: "zero"}, {value: 2, text: "two"}, {value: 4, text: "four"}]
});
chart2.addAxis("y", {
vertical: true, fixLower: "major", fixUpper: "major", natural: true,
labels: [{value: 0, text: ""}, {value: 1, text: "Jan"}, {value: 2, text: "Feb"},
{value: 3, text: "Mar"}, {value: 4, text: "Apr"},
{value: 5, text: "May"}, {value: 6, text: "Jun"}]
});
chart2.addPlot("default", {type: "Bars"});
chart2.addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"});
chart2.addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"});
chart2.render();
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Chart 2D</h1>
<!--<p><button onclick="makeObjects();">Go</button></p>-->
<p>1: Bars, axes aligned on major ticks, no minor ticks, custom strokes and fills.</p>
<div id="test1" style="width: 200px; height: 200px;"></div>
<p>2: Bars, axes aligned on major ticks, no minor ticks, custom strokes and fills, custom labels.</p>
<div id="test2" style="width: 200px; height: 200px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/charting/tests/test_scaler.html
New file
0,0 → 1,97
<html>
<head>
<title>Scaler/tick generator</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../scaler.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.charting.scaler");
 
calc = function(){
var min = parseFloat(dojo.byId("imin").value);
var max = parseFloat(dojo.byId("imax").value);
var span = parseFloat(dojo.byId("ispan").value);
var o = dojox.charting.scaler(
min, max, span, {
fixLower: dojo.byId("ifl").value,
fixUpper: dojo.byId("ifu").value,
natural: Boolean(dojo.byId("inat").checked)
}
);
dojo.byId("imin").value = min;
dojo.byId("imax").value = max;
dojo.byId("ispan").value = span;
dojo.byId("olb").innerHTML = o.bounds.lower;
dojo.byId("oub").innerHTML = o.bounds.upper;
dojo.byId("omajt").innerHTML = o.major.tick;
dojo.byId("omajs").innerHTML = o.major.start;
dojo.byId("omajc").innerHTML = o.major.count;
dojo.byId("omajp").innerHTML = o.major.prec;
dojo.byId("omint").innerHTML = o.minor.tick;
dojo.byId("omins").innerHTML = o.minor.start;
dojo.byId("ominc").innerHTML = o.minor.count;
dojo.byId("ominp").innerHTML = o.minor.prec;
dojo.byId("omict").innerHTML = o.micro.tick;
dojo.byId("omics").innerHTML = o.micro.start;
dojo.byId("omicc").innerHTML = o.micro.count;
dojo.byId("omicp").innerHTML = o.micro.prec;
dojo.byId("oscale").innerHTML = o.scale;
};
 
</script>
</head>
<body>
<h1>Scaler/tick generator</h1>
<h2>Input</h2>
<table>
<tr><th>Name</th><th>Value</th></tr>
<tr><td>min</td><td><input type="text" id="imin" /></td></tr>
<tr><td>max</td><td><input type="text" id="imax" /></td></tr>
<tr><td>span</td><td><input type="text" id="ispan" /></td></tr>
<tr><td>natural</td><td><input type="checkbox" id="inat" /></td></tr>
<tr><td>fixLower</td><td><input type="text" id="ifl" /></td></tr>
<tr><td>fixUpper</td><td><input type="text" id="ifu" /></td></tr>
</table>
<p><button onclick="calc()">Calculate!</button></p>
<h2>Output</h2>
<table>
<tr><th>Name</th><th>Value</th></tr>
<tr><td>lowerBound</td><td><span id="olb">&nbsp;</span></td></tr>
<tr><td>upperBound</td><td><span id="oub">&nbsp;</span></td></tr>
<tr><td>major.tick</td><td><span id="omajt">&nbsp;</span></td></tr>
<tr><td>major.start</td><td><span id="omajs">&nbsp;</span></td></tr>
<tr><td>major.count</td><td><span id="omajc">&nbsp;</span></td></tr>
<tr><td>major.prec</td><td><span id="omajp">&nbsp;</span></td></tr>
 
<tr><td>minor.tick</td><td><span id="omint">&nbsp;</span></td></tr>
<tr><td>minor.start</td><td><span id="omins">&nbsp;</span></td></tr>
<tr><td>minor.count</td><td><span id="ominc">&nbsp;</span></td></tr>
<tr><td>minor.prec</td><td><span id="ominp">&nbsp;</span></td></tr>
 
<tr><td>micro.tick</td><td><span id="omict">&nbsp;</span></td></tr>
<tr><td>micro.start</td><td><span id="omics">&nbsp;</span></td></tr>
<tr><td>micro.count</td><td><span id="omicc">&nbsp;</span></td></tr>
<tr><td>micro.prec</td><td><span id="omicp">&nbsp;</span></td></tr>
 
<tr><td>scale</td><td><span id="oscale">&nbsp;</span></td></tr>
</table>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/charting/tests/test_widget2d.html
New file
0,0 → 1,98
<html>
<head>
<title>Chart 2D</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript" src="../../lang/functional.js"></script>
<script type="text/javascript" src="../Theme.js"></script>
<script type="text/javascript" src="../scaler.js"></script>
<script type="text/javascript" src="../Chart2D.js"></script>
<script type="text/javascript" src="../widget/Chart2D.js"></script>
 
<script type="text/javascript">
dojo.require("dojox.charting.widget.Chart2D");
dojo.require("dojox.charting.themes.PlotKit.orange");
dojo.require("dojox.charting.themes.PlotKit.blue");
dojo.require("dojox.charting.themes.PlotKit.green");
dojo.require("dojox.data.HtmlTableStore");
seriesB = [2.6, 1.8, 2, 1, 1.4, 0.7, 2];
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
</script>
 
</head>
<body>
<h1>Chart 2D</h1>
<p>Examples of charts using widgets.</p>
<div dojoType="dojox.data.HtmlTableStore" tableId="tableExample" jsId="tableStore"></div>
<table id="tableExample" style="display: none;">
<thead>
<tr><th>value</th></tr>
</thead>
<tbody>
<tr><td>6.3</td></tr>
<tr><td>1.8</td></tr>
<tr><td>3 </td></tr>
<tr><td>0.5</td></tr>
<tr><td>4.4</td></tr>
<tr><td>2.7</td></tr>
<tr><td>2 </td></tr>
</tbody>
</table>
<table border="1">
<tr>
<td>
<div dojoType="dojox.charting.widget.Chart2D" style="width: 300px; height: 300px;">
<div class="axis" name="x" font="italic normal normal 8pt Tahoma"></div>
<div class="axis" name="y" vertical="true" fixUpper="major" includeZero="true"
font="italic normal normal 8pt Tahoma"></div>
<div class="plot" name="default" type="Areas"></div>
<div class="plot" name="grid" type="Grid"></div>
<div class="series" name="Series A" data="1, 2, 0.5, 1.5, 1, 2.8, 0.4"></div>
<div class="series" name="Series B" array="seriesB"></div>
<div class="series" name="Series C" store="tableStore" valueFn="Number(x)"></div>
</div>
</td>
<td>
<div dojoType="dojox.charting.widget.Chart2D" theme="dojox.charting.themes.PlotKit.orange"
fill="'lightgrey'" style="width: 300px; height: 300px;">
<div class="axis" name="x" font="italic normal bold 10pt Tahoma"></div>
<div class="axis" name="y" vertical="true" fixUpper="major" includeZero="true"
font="italic normal bold 10pt Tahoma"></div>
<div class="plot" name="default" type="Areas"></div>
<div class="plot" name="grid" type="Grid"></div>
<div class="series" name="Series A" data="1, 2, 0.5, 1.5, 1, 2.8, 0.4"></div>
<div class="series" name="Series B" array="seriesB"></div>
<div class="series" name="Series C" store="tableStore" valueFn="Number(x)" stroke="'blue'" fill="'green'"></div>
</div>
</td>
</tr>
<tr>
<td>
<div dojoType="dojox.charting.widget.Chart2D" theme="dojox.charting.themes.PlotKit.blue"
style="width: 300px; height: 300px;">
<div class="plot" name="default" type="Pie" radius="100" fontColor="white"></div>
<div class="series" name="Series B" array="seriesB"></div>
</div>
</td>
<td>
<div dojoType="dojox.charting.widget.Chart2D" theme="dojox.charting.themes.PlotKit.green"
style="width: 300px; height: 300px;">
<div class="plot" name="default" type="Pie" radius="100" fontColor="black" labelOffset="-20"></div>
<div class="series" name="Series C" store="tableStore" valueFn="Number(x)"></div>
</div>
</td>
</tr>
</table>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/charting/tests/Theme.js
New file
0,0 → 1,71
if(!dojo._hasResource["dojox.charting.tests.Theme"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.tests.Theme"] = true;
dojo.provide("dojox.charting.tests.Theme");
dojo.require("dojox.charting.Theme");
dojo.require("dojox.charting.themes.PlotKit.blue");
 
(function(){
var dxc=dojox.charting;
var blue=dxc.themes.PlotKit.blue;
tests.register("dojox.charting.tests.Theme", [
function testDefineColor(t){
var args={ num:16, cache:false };
blue.defineColors(args);
var a=blue.colors;
var s="<table border=1>";
for(var i=0; i<a.length; i++){
if(i%8==0){
if(i>0) s+="</tr>";
s+="<tr>";
}
s+='<td width=16 bgcolor='+a[i]+'>&nbsp;</td>';
}
s+="</tr></table>";
doh.debug(s);
 
var args={ num:32, cache: false };
blue.defineColors(args);
var a=blue.colors;
var s="<table border=1 style=margin-top:12px;>";
for(var i=0; i<a.length; i++){
if(i%8==0){
if(i>0) s+="</tr>";
s+="<tr>";
}
s+='<td width=16 bgcolor='+a[i]+'>&nbsp;</td>';
}
s+="</tr></table>";
doh.debug(s);
 
var args={ saturation:20, num:32, cache:false };
blue.defineColors(args);
var a=blue.colors;
var s="<table border=1 style=margin-top:12px;>";
for(var i=0; i<a.length; i++){
if(i%8==0){
if(i>0) s+="</tr>";
s+="<tr>";
}
s+='<td width=16 bgcolor='+a[i]+'>&nbsp;</td>';
}
s+="</tr></table>";
doh.debug(s);
 
var args={ low:10, high:90, num:32, cache: false };
blue.defineColors(args);
var a=blue.colors;
var s="<table border=1 style=margin-top:12px;>";
for(var i=0; i<a.length; i++){
if(i%8==0){
if(i>0) s+="</tr>";
s+="<tr>";
}
s+='<td width=16 bgcolor='+a[i]+'>&nbsp;</td>';
}
s+="</tr></table>";
doh.debug(s);
}
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/tests/test_cylinders.html
New file
0,0 → 1,65
<html>
<head>
<title>Cylinder chart</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../Chart3D.js"></script>
<script type="text/javascript" src="../plot3d/Base.js"></script>
<script type="text/javascript" src="../plot3d/Cylinders.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.charting.Chart3D");
dojo.require("dojox.charting.plot3d.Cylinders");
 
makeObjects = function(){
var m = dojox.gfx3d.matrix;
var chart = new dojox.charting.Chart3D("test",
{
lights: [{direction: {x: 5, y: 5, z: -5}, color: "white"}],
ambient: {color:"white", intensity: 2},
specular: "white"
},
[m.cameraRotateXg(10), m.cameraRotateYg(-10), m.scale(0.8), m.cameraTranslate(-50, -50, 0)]
);
var plot1 = new dojox.charting.plot3d.Cylinders(500, 500, {gap: 10, material: "yellow"});
plot1.setData([1,2,3,2,1,2,3,4,5]);
chart.addPlot(plot1);
var plot2 = new dojox.charting.plot3d.Cylinders(500, 500, {gap: 10, material: "red"});
plot2.setData([2,3,4,3,2,3,4,5,5]);
chart.addPlot(plot2);
var plot3 = new dojox.charting.plot3d.Cylinders(500, 500, {gap: 10, material: "blue"});
plot3.setData([3,4,5,4,3,4,5,5,5]);
chart.addPlot(plot3);
chart.generate().render();
//dojo.byId("out1").value = dojo.byId("test").innerHTML;
//dojo.byId("out2").value = dojox.gfx.utils.toJson(surface, true);
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Cylinder chart</h1>
<div id="test" style="width: 500px; height: 500px;"></div>
<!--
<p><button onclick="makeObjects();">Go</button></p>
<p><textarea id="out1" cols="40" rows="5"></textarea></p>
<p><textarea id="out2" cols="40" rows="5"></textarea></p>
-->
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/charting/Chart3D.js
New file
0,0 → 1,86
if(!dojo._hasResource["dojox.charting.Chart3D"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.Chart3D"] = true;
dojo.provide("dojox.charting.Chart3D");
 
dojo.require("dojox.gfx3d");
 
(function(){
var observerVector = {x: 0, y: 0, z: 1}, v = dojox.gfx3d.vector, n = dojox.gfx.normalizedLength;
 
dojo.declare("dojox.charting.Chart3D", null, {
constructor: function(node, lights, camera, theme){
// setup a view
this.node = dojo.byId(node);
this.surface = dojox.gfx.createSurface(this.node, n(this.node.style.width), n(this.node.style.height));
this.view = this.surface.createViewport();
this.view.setLights(lights.lights, lights.ambient, lights.specular);
this.view.setCameraTransform(camera);
this.theme = theme;
// initialize internal variables
this.walls = [];
this.plots = [];
},
// public API
generate: function(){
return this._generateWalls()._generatePlots();
},
invalidate: function(){
this.view.invalidate();
return this;
},
render: function(){
this.view.render();
return this;
},
addPlot: function(plot){
return this._add(this.plots, plot);
},
removePlot: function(plot){
return this._remove(this.plots, plot);
},
addWall: function(wall){
return this._add(this.walls, wall);
},
removeWall: function(wall){
return this._remove(this.walls, wall);
},
// internal API
_add: function(array, item){
if(!dojo.some(array, function(i){ return i == item; })){
array.push(item);
this.view.invalidate();
}
return this;
},
_remove: function(array, item){
var a = dojo.filter(array, function(i){ return i != item; });
return a.length < array.length ? (array = a, this.invalidate()) : this;
},
_generateWalls: function(){
for(var i = 0; i < this.walls.length; ++i){
if(v.dotProduct(observerVector, this.walls[i].normal) > 0){
this.walls[i].generate(this);
}
}
return this;
},
_generatePlots: function(){
var depth = 0, m = dojox.gfx3d.matrix, i = 0;
for(; i < this.plots.length; ++i){
depth += this.plots[i].getDepth();
}
for(--i; i >= 0; --i){
var scene = this.view.createScene();
scene.setTransform(m.translate(0, 0, -depth));
this.plots[i].generate(this, scene);
depth -= this.plots[i].getDepth();
}
return this;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/widget/Chart2D.js
New file
0,0 → 1,200
if(!dojo._hasResource["dojox.charting.widget.Chart2D"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.widget.Chart2D"] = true;
dojo.provide("dojox.charting.widget.Chart2D");
 
dojo.require("dijit._Widget");
dojo.require("dojox.charting.Chart2D");
dojo.require("dojox.lang.functional");
 
(function(){
var collectAxisParams, collectPlotParams, collectDataParams,
notNull = function(o){ return o; },
df = dojox.lang.functional,
du = dojox.lang.utils;
dojo.declare("dojox.charting.widget.Chart2D", dijit._Widget, {
// parameters for the markup
// theme for the chart
theme: null,
// margins for the chart: {l: 10, r: 10, t: 10, b: 10}
margins: null,
// chart area
stroke: null,
fill: null,
// methods
buildRendering: function(){
var n = this.domNode = this.srcNodeRef;
// collect chart parameters
var axes = dojo.filter(dojo.query("> .axis", n).map(collectAxisParams), notNull);
var plots = dojo.filter(dojo.query("> .plot", n).map(collectPlotParams), notNull);
var series = dojo.filter(dojo.query("> .series", n).map(collectDataParams), notNull);
// build the chart
n.innerHTML = "";
var c = this.chart = new dojox.charting.Chart2D(n, {
margins: this.margins,
stroke: this.stroke,
fill: this.fill
});
// add collected parameters
if(this.theme){
c.setTheme(this.theme);
}
dojo.forEach(axes, function(axis){
c.addAxis(axis.name, axis.kwArgs);
});
dojo.forEach(plots, function(plot){
c.addPlot(plot.name, plot.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);
dojo.mixin(kw, {
onComplete: function(data){
var values;
if("valueFn" in series.kwArgs){
var fn = series.kwArgs.valueFn;
values = dojo.map(data, function(x){
return fn(series.data.getValue(x, series.field, 0));
});
}else{
values = dojo.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(); }
},
resize: function(box){
dojo.marginBox(this.domNode, box);
this.chart.resize();
}
});
collectAxisParams = function(node){
var name = node.getAttribute("name"), type = node.getAttribute("type");
if(!name){ return null; }
var o = {name: name, kwArgs: {}}, kw = o.kwArgs;
if(type){
if(dojox.charting.axis2d[type]){
type = "dojox.charting.axis2d." + type;
}
var axis = eval("(" + type + ")");
if(axis){ kw.type = axis; }
}else{
type = "dojox.charting.axis2d.Default";
}
var dp = eval("(" + type + ".prototype.defaultParams)");
for(var x in dp){
if(x in kw){ continue; }
var attr = node.getAttribute(x);
kw[x] = du.coerceType(dp[x], attr == null ? dp[x] : attr);
}
var op = eval("(" + type + ".prototype.optionalParams)");
for(var x in op){
if(x in kw){ continue; }
var attr = node.getAttribute(x);
if(attr != null){
kw[x] = du.coerceType(op[x], attr);
}
}
return o;
};
collectPlotParams = function(node){
var name = node.getAttribute("name"), type = node.getAttribute("type");
if(!name){ return null; }
var o = {name: name, kwArgs: {}}, kw = o.kwArgs;
if(type){
if(dojox.charting.plot2d[type]){
type = "dojox.charting.plot2d." + type;
}
var plot = eval("(" + type + ")");
if(plot){ kw.type = plot; }
}else{
type = "dojox.charting.plot2d.Default";
}
var dp = eval("(" + type + ".prototype.defaultParams)");
for(var x in dp){
if(x in kw){ continue; }
var attr = node.getAttribute(x);
kw[x] = du.coerceType(dp[x], attr == null ? dp[x] : attr);
}
var op = eval("(" + type + ".prototype.optionalParams)");
for(var x in op){
if(x in kw){ continue; }
var attr = node.getAttribute(x);
if(attr != null){
kw[x] = du.coerceType(op[x], attr);
}
}
return o;
};
collectDataParams = function(node){
var name = node.getAttribute("name");
if(!name){ return null; }
var o = {name: name, kwArgs: {}}, kw = o.kwArgs, t;
t = node.getAttribute("plot");
if(t != null){ kw.plot = t; }
t = node.getAttribute("marker");
if(t != null){ kw.marker = t; }
t = node.getAttribute("stroke");
if(t != null){ kw.stroke = eval("(" + t + ")"); }
t = node.getAttribute("fill");
if(t != null){ kw.fill = eval("(" + t + ")"); }
t = node.getAttribute("data");
if(t != null){
o.type = "data";
o.data = dojo.map(String(t).split(','), Number);
return o;
}
t = node.getAttribute("array");
if(t != null){
o.type = "data";
o.data = eval("(" + t + ")");
return o;
}
t = node.getAttribute("store");
if(t != null){
o.type = "store";
o.data = eval("(" + t + ")");
t = node.getAttribute("field");
o.field = t != null ? t : "value";
t = node.getAttribute("query");
if(t != null){ kw.query = t; }
t = node.getAttribute("queryOptions");
if(t != null){ kw.queryOptions = eval("(" + t + ")"); }
t = node.getAttribute("start");
if(t != null){ kw.start = Number(t); }
t = node.getAttribute("count");
if(t != null){ kw.count = Number(t); }
t = node.getAttribute("sort");
if(t != null){ kw.sort = eval("(" + t + ")"); }
t = node.getAttribute("valueFn");
if(t != null){ kw.valueFn = df.lambda(t); }
return o;
}
return null;
};
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/Element.js
New file
0,0 → 1,49
if(!dojo._hasResource["dojox.charting.Element"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.Element"] = true;
dojo.provide("dojox.charting.Element");
 
dojo.declare("dojox.charting.Element", null, {
constructor: function(chart){
this.chart = chart;
this.group = null;
this.htmlElements = [];
this.dirty = true;
},
createGroup: function(creator){
if(!creator){ creator = this.chart.surface; }
if(!this.group){
this.group = creator.createGroup();
}
return this;
},
purgeGroup: function(){
this.destroyHtmlElements();
if(this.group){
this.group.clear();
this.group.removeShape();
this.group = null;
}
this.dirty = true;
return this;
},
cleanGroup: function(creator){
this.destroyHtmlElements();
if(!creator){ creator = this.chart.surface; }
if(this.group){
this.group.clear();
}else{
this.group = creator.createGroup();
}
this.dirty = true;
return this;
},
destroyHtmlElements: function(){
dojo.forEach(this.htmlElements, dojo._destroyElement);
this.htmlElements = [];
},
destroy: function(){
this.purgeGroup();
}
});
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/MarkersOnly.js
New file
0,0 → 1,14
if(!dojo._hasResource["dojox.charting.plot2d.MarkersOnly"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.MarkersOnly"] = true;
dojo.provide("dojox.charting.plot2d.MarkersOnly");
 
dojo.require("dojox.charting.plot2d.Default");
 
dojo.declare("dojox.charting.plot2d.MarkersOnly", dojox.charting.plot2d.Default, {
constructor: function(){
this.opt.lines = false;
this.opt.markers = true;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/StackedLines.js
New file
0,0 → 1,13
if(!dojo._hasResource["dojox.charting.plot2d.StackedLines"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.StackedLines"] = true;
dojo.provide("dojox.charting.plot2d.StackedLines");
 
dojo.require("dojox.charting.plot2d.Stacked");
 
dojo.declare("dojox.charting.plot2d.StackedLines", dojox.charting.plot2d.Stacked, {
constructor: function(){
this.opt.lines = true;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/Base.js
New file
0,0 → 1,60
if(!dojo._hasResource["dojox.charting.plot2d.Base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.Base"] = true;
dojo.provide("dojox.charting.plot2d.Base");
 
dojo.require("dojox.charting.Element");
dojo.require("dojox.charting.plot2d.common");
 
dojo.declare("dojox.charting.plot2d.Base", dojox.charting.Element, {
clear: function(){
this.series = [];
this._hAxis = null;
this._vAxis = null;
this.dirty = true;
return this;
},
setAxis: function(axis){
if(axis){
this[axis.vertical ? "_vAxis" : "_hAxis"] = axis;
}
return this;
},
addSeries: function(run){
this.series.push(run);
return this;
},
calculateAxes: function(dim){
return this;
},
render: function(dim, offsets){
return this;
},
getRequiredColors: function(){
return this.series.length;
},
// utilities
_calc: function(dim, stats){
// calculate scaler
if(this._hAxis){
if(!this._hAxis.initialized()){
this._hAxis.calculate(stats.hmin, stats.hmax, dim.width);
}
this._hScaler = this._hAxis.getScaler();
}else{
this._hScaler = {bounds: {lower: stats.hmin, upper: stats.hmax},
scale: dim.width / (stats.hmax - stats.hmin)};
}
if(this._vAxis){
if(!this._vAxis.initialized()){
this._vAxis.calculate(stats.vmin, stats.vmax, dim.height);
}
this._vScaler = this._vAxis.getScaler();
}else{
this._vScaler = {bounds: {lower: stats.vmin, upper: stats.vmax},
scale: dim.height / (stats.vmax - stats.vmin)};
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/Lines.js
New file
0,0 → 1,13
if(!dojo._hasResource["dojox.charting.plot2d.Lines"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.Lines"] = true;
dojo.provide("dojox.charting.plot2d.Lines");
 
dojo.require("dojox.charting.plot2d.Default");
 
dojo.declare("dojox.charting.plot2d.Lines", dojox.charting.plot2d.Default, {
constructor: function(){
this.opt.lines = true;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/Pie.js
New file
0,0 → 1,179
if(!dojo._hasResource["dojox.charting.plot2d.Pie"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.Pie"] = true;
dojo.provide("dojox.charting.plot2d.Pie");
 
dojo.require("dojox.charting.Element");
dojo.require("dojox.charting.axis2d.common");
dojo.require("dojox.charting.plot2d.common");
 
dojo.require("dojox.lang.functional");
dojo.require("dojox.gfx");
 
(function(){
var df = dojox.lang.functional, du = dojox.lang.utils,
dc = dojox.charting.plot2d.common,
da = dojox.charting.axis2d.common,
g = dojox.gfx,
labelFudgeFactor = 0.8; // in percents (to convert font's heigth to label width)
 
dojo.declare("dojox.charting.plot2d.Pie", dojox.charting.Element, {
defaultParams: {
labels: true,
ticks: false,
fixed: true,
precision: 1,
labelOffset: 20,
labelStyle: "default", // default/rows/auto
htmlLabels: true // use HTML to draw labels
},
optionalParams: {
font: "",
fontColor: "",
radius: 0
},
 
constructor: function(chart, kwArgs){
this.opt = dojo.clone(this.defaultParams);
du.updateWithObject(this.opt, kwArgs);
du.updateWithPattern(this.opt, kwArgs, this.optionalParams);
this.run = null;
this.dyn = [];
},
clear: function(){
this.dirty = true;
this.dyn = [];
return this;
},
setAxis: function(axis){
// nothing
return this;
},
addSeries: function(run){
this.run = run;
return this;
},
calculateAxes: function(dim){
// nothing
return this;
},
getRequiredColors: function(){
return this.run ? this.run.data.length : 0;
},
render: function(dim, offsets){
if(!this.dirty){ return this; }
this.dirty = false;
this.cleanGroup();
var s = this.group, color, t = this.chart.theme;
 
// calculate the geometry
var rx = (dim.width - offsets.l - offsets.r) / 2,
ry = (dim.height - offsets.t - offsets.b) / 2,
r = Math.min(rx, ry),
taFont = "font" in this.opt ? this.opt.font : t.axis.font,
taFontColor = "fontColor" in this.opt ? this.opt.fontColor : t.axis.fontColor,
sum = df.foldl1(this.run.data, "+"), start = 0, step,
slices = dojo.map(this.run.data, function(x){ return x / sum; }),
shift, size, labelR;
if(this.opt.labels){
var labels = dojo.map(slices, function(x){
return this._getLabel(x * 100) + "%";
}, this);
shift = df.foldl1(dojo.map(labels, df.pluck("length")), "x, y -> Math.max(x, y)");
size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0;
shift = Math.max(shift * labelFudgeFactor, 1) / 2 * size;
if(this.opt.labelOffset < 0){
r = Math.min(rx - 2 * shift, ry - size) + this.opt.labelOffset;
}
labelR = r - this.opt.labelOffset;
}
if("radius" in this.opt){
r = this.opt.radius;
labelR = r - this.opt.labelOffset;
}
var circle = {
cx: offsets.l + rx,
cy: offsets.t + ry,
r: r
};
 
this.dyn = [];
if(!this.run || !this.run.data.length){
return this;
}
if(this.run.data.length == 1){
// need autogenerated color
color = new dojo.Color(t.next("color"));
var shape = s.createCircle(circle).
setFill(dc.augmentFill(t.run.fill, color)).
setStroke(dc.augmentStroke(t.series.stroke, color));
this.dyn.push({color: color, fill: shape.getFill(), stroke: shape.getStroke()});
if(this.opt.labels){
var shift = 4,
taFont = "font" in this.opt ? this.opt.font : t.axis.font,
taFontColor = "fontColor" in this.opt ? this.opt.fontColor : t.axis.fontColor,
size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0;
shift = Math.max(shift * labelFudgeFactor, 1) / 2 * size;
// draw the label
var elem = da.createText[this.opt.htmlLabels ? "html" : "gfx"]
(this.chart, s, circle.cx, circle.cy + size / 2, "middle",
"100%", taFont, taFontColor);
if(this.opt.htmlLabels){ this.htmlElements.push(elem); }
}
return this;
}
// draw slices
dojo.forEach(slices, function(x, i){
// calculate the geometry of the slice
var end = start + x * 2 * Math.PI;
if(i + 1 == slices.length){
end = 2 * Math.PI;
}
var step = end - start,
x1 = circle.cx + r * Math.cos(start),
y1 = circle.cy + r * Math.sin(start),
x2 = circle.cx + r * Math.cos(end),
y2 = circle.cy + r * Math.sin(end);
// draw the slice
color = new dojo.Color(t.next("color"));
var shape = s.createPath({}).
moveTo(circle.cx, circle.cy).
lineTo(x1, y1).
arcTo(r, r, 0, step > Math.PI, true, x2, y2).
lineTo(circle.cx, circle.cy).
closePath().
setFill(dc.augmentFill(t.series.fill, color)).
setStroke(dc.augmentStroke(t.series.stroke, color));
this.dyn.push({color: color, fill: shape.getFill(), stroke: shape.getStroke()});
start = end;
}, this);
// draw labels
if(this.opt.labels){
start = 0;
dojo.forEach(slices, function(x, i){
// calculate the geometry of the slice
var end = start + x * 2 * Math.PI;
if(i + 1 == slices.length){
end = 2 * Math.PI;
}
var labelAngle = (start + end) / 2,
x = circle.cx + labelR * Math.cos(labelAngle),
y = circle.cy + labelR * Math.sin(labelAngle) + size / 2;
// draw the label
var elem = da.createText[this.opt.htmlLabels ? "html" : "gfx"]
(this.chart, s, x, y, "middle",
labels[i], taFont, taFontColor);
if(this.opt.htmlLabels){ this.htmlElements.push(elem); }
start = end;
}, this);
}
return this;
},
// utilities
_getLabel: function(number){
return this.opt.fixed ? number.toFixed(this.opt.precision) : number.toString();
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/Stacked.js
New file
0,0 → 1,121
if(!dojo._hasResource["dojox.charting.plot2d.Stacked"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.Stacked"] = true;
dojo.provide("dojox.charting.plot2d.Stacked");
 
dojo.require("dojox.charting.plot2d.common");
dojo.require("dojox.charting.plot2d.Default");
 
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, dc = dojox.charting.plot2d.common,
purgeGroup = df.lambda("item.purgeGroup()");
 
dojo.declare("dojox.charting.plot2d.Stacked", dojox.charting.plot2d.Default, {
calculateAxes: function(dim){
var stats = dc.collectStackedStats(this.series);
this._maxRunLength = stats.hmax;
this._calc(dim, stats);
return this;
},
render: function(dim, offsets){
// stack all values
var acc = df.repeat(this._maxRunLength, "-> 0", 0);
for(var i = 0; i < this.series.length; ++i){
var run = this.series[i];
for(var j = 0; j < run.data.length; ++j){
var v = run.data[j];
if(isNaN(v)){ v = 0; }
acc[j] += v;
}
}
// draw runs in backwards
if(this.dirty){
dojo.forEach(this.series, purgeGroup);
this.cleanGroup();
var s = this.group;
df.forEachReversed(this.series, function(item){ item.cleanGroup(s); });
}
var t = this.chart.theme, stroke, outline, color, marker;
for(var i = this.series.length - 1; i >= 0; --i){
var run = this.series[i];
if(!this.dirty && !run.dirty){ continue; }
run.cleanGroup();
var s = run.group,
lpoly = dojo.map(acc, function(v, i){
return {
x: this._hScaler.scale * (i + 1 - this._hScaler.bounds.lower) + offsets.l,
y: dim.height - offsets.b - this._vScaler.scale * (v - this._vScaler.bounds.lower)
};
}, this);
if(!run.fill || !run.stroke){
// need autogenerated color
color = new dojo.Color(t.next("color"));
}
if(this.opt.areas){
var apoly = dojo.clone(lpoly);
apoly.push({x: lpoly[lpoly.length - 1].x, y: dim.height - offsets.b});
apoly.push({x: lpoly[0].x, y: dim.height - offsets.b});
apoly.push(lpoly[0]);
var fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
s.createPolyline(apoly).setFill(fill);
}
if(this.opt.lines || this.opt.markers){
// need a stroke
stroke = run.stroke ? dc.makeStroke(run.stroke) : dc.augmentStroke(t.series.stroke, color);
if(run.outline || t.series.outline){
outline = dc.makeStroke(run.outline ? run.outline : t.series.outline);
outline.width = 2 * outline.width + stroke.width;
}
}
if(this.opt.markers){
// need a marker
marker = run.marker ? run.marker : t.next("marker");
}
if(this.opt.shadows && stroke){
var sh = this.opt.shadows, shadowColor = new dojo.Color([0, 0, 0, 0.3]),
spoly = dojo.map(lpoly, function(c){
return {x: c.x + sh.dx, y: c.y + sh.dy};
}),
shadowStroke = dojo.clone(outline ? outline : stroke);
shadowStroke.color = shadowColor;
shadowStroke.width += sh.dw ? sh.dw : 0;
if(this.opt.lines){
s.createPolyline(spoly).setStroke(shadowStroke);
}
if(this.opt.markers){
dojo.forEach(spoly, function(c){
s.createPath("M" + c.x + " " + c.y + " " + marker).setStroke(shadowStroke).setFill(shadowColor);
}, this);
}
}
if(this.opt.lines){
if(outline){
s.createPolyline(lpoly).setStroke(outline);
}
s.createPolyline(lpoly).setStroke(stroke);
}
if(this.opt.markers){
dojo.forEach(lpoly, function(c){
var path = "M" + c.x + " " + c.y + " " + marker;
if(outline){
s.createPath(path).setStroke(outline);
}
s.createPath(path).setStroke(stroke).setFill(stroke.color);
}, this);
}
run.dirty = false;
// update the accumulator
for(var j = 0; j < run.data.length; ++j){
var v = run.data[j];
if(isNaN(v)){ v = 0; }
acc[j] -= v;
}
}
this.dirty = false;
return this;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/StackedColumns.js
New file
0,0 → 1,82
if(!dojo._hasResource["dojox.charting.plot2d.StackedColumns"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.StackedColumns"] = true;
dojo.provide("dojox.charting.plot2d.StackedColumns");
 
dojo.require("dojox.charting.plot2d.common");
dojo.require("dojox.charting.plot2d.Columns");
 
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, dc = dojox.charting.plot2d.common,
purgeGroup = df.lambda("item.purgeGroup()");
 
dojo.declare("dojox.charting.plot2d.StackedColumns", dojox.charting.plot2d.Columns, {
calculateAxes: function(dim){
var stats = dc.collectStackedStats(this.series);
this._maxRunLength = stats.hmax;
stats.hmin -= 0.5;
stats.hmax += 0.5;
this._calc(dim, stats);
return this;
},
render: function(dim, offsets){
// stack all values
var acc = df.repeat(this._maxRunLength, "-> 0", 0);
for(var i = 0; i < this.series.length; ++i){
var run = this.series[i];
for(var j = 0; j < run.data.length; ++j){
var v = run.data[j];
if(isNaN(v)){ v = 0; }
acc[j] += v;
}
}
// draw runs in backwards
if(this.dirty){
dojo.forEach(this.series, purgeGroup);
this.cleanGroup();
var s = this.group;
df.forEachReversed(this.series, function(item){ item.cleanGroup(s); });
}
var t = this.chart.theme, color, stroke, fill, f,
gap = this.opt.gap < this._hScaler.scale / 3 ? this.opt.gap : 0;
for(var i = this.series.length - 1; i >= 0; --i){
var run = this.series[i];
if(!this.dirty && !run.dirty){ continue; }
run.cleanGroup();
var s = run.group;
if(!run.fill || !run.stroke){
// need autogenerated color
color = run.dyn.color = new dojo.Color(t.next("color"));
}
stroke = run.stroke ? run.stroke : dc.augmentStroke(t.series.stroke, color);
fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
for(var j = 0; j < acc.length; ++j){
var v = acc[j],
width = this._hScaler.scale - 2 * gap,
height = this._vScaler.scale * (v - this._vScaler.bounds.lower);
if(width >= 1 && height >= 1){
var shape = s.createRect({
x: offsets.l + this._hScaler.scale * (j + 0.5 - this._hScaler.bounds.lower) + gap,
y: dim.height - offsets.b - this._vScaler.scale * (v - this._vScaler.bounds.lower),
width: width, height: height
}).setFill(fill).setStroke(stroke);
run.dyn.fill = shape.getFill();
run.dyn.stroke = shape.getStroke();
}
}
run.dirty = false;
// update the accumulator
for(var j = 0; j < run.data.length; ++j){
var v = run.data[j];
if(isNaN(v)){ v = 0; }
acc[j] -= v;
}
}
this.dirty = false;
return this;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/Columns.js
New file
0,0 → 1,87
if(!dojo._hasResource["dojox.charting.plot2d.Columns"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.Columns"] = true;
dojo.provide("dojox.charting.plot2d.Columns");
 
dojo.require("dojox.charting.plot2d.common");
dojo.require("dojox.charting.plot2d.Base");
 
dojo.require("dojox.lang.utils");
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, du = dojox.lang.utils,
dc = dojox.charting.plot2d.common,
purgeGroup = df.lambda("item.purgeGroup()");
 
dojo.declare("dojox.charting.plot2d.Columns", dojox.charting.plot2d.Base, {
defaultParams: {
hAxis: "x", // use a horizontal axis named "x"
vAxis: "y", // use a vertical axis named "y"
gap: 0, // gap between columns in pixels
shadows: null // draw shadows
},
optionalParams: {}, // no optional parameters
constructor: function(chart, kwArgs){
this.opt = dojo.clone(this.defaultParams);
du.updateWithObject(this.opt, kwArgs);
this.series = [];
this.hAxis = this.opt.hAxis;
this.vAxis = this.opt.vAxis;
},
calculateAxes: function(dim){
var stats = dc.collectSimpleStats(this.series);
stats.hmin -= 0.5;
stats.hmax += 0.5;
this._calc(dim, stats);
return this;
},
render: function(dim, offsets){
if(this.dirty){
dojo.forEach(this.series, purgeGroup);
this.cleanGroup();
var s = this.group;
df.forEachReversed(this.series, function(item){ item.cleanGroup(s); });
}
var t = this.chart.theme, color, stroke, fill, f,
gap = this.opt.gap < this._hScaler.scale / 3 ? this.opt.gap : 0;
for(var i = this.series.length - 1; i >= 0; --i){
var run = this.series[i];
if(!this.dirty && !run.dirty){ continue; }
run.cleanGroup();
var s = run.group;
if(!run.fill || !run.stroke){
// need autogenerated color
color = run.dyn.color = new dojo.Color(t.next("color"));
}
stroke = run.stroke ? run.stroke : dc.augmentStroke(t.series.stroke, color);
fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
var baseline = Math.max(0, this._vScaler.bounds.lower),
xoff = offsets.l + this._hScaler.scale * (0.5 - this._hScaler.bounds.lower) + gap,
yoff = dim.height - offsets.b - this._vScaler.scale * (baseline - this._vScaler.bounds.lower);
for(var j = 0; j < run.data.length; ++j){
var v = run.data[j],
width = this._hScaler.scale - 2 * gap,
height = this._vScaler.scale * (v - baseline),
h = Math.abs(height);
if(width >= 1 && h >= 1){
var rect = {
x: xoff + this._hScaler.scale * j,
y: yoff - (height < 0 ? 0 : height),
width: width, height: h
},
shape = s.createRect(rect).setFill(fill).setStroke(stroke);
run.dyn.fill = shape.getFill();
run.dyn.stroke = shape.getStroke();
}
}
run.dirty = false;
}
this.dirty = false;
return this;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/Default.js
New file
0,0 → 1,135
if(!dojo._hasResource["dojox.charting.plot2d.Default"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.Default"] = true;
dojo.provide("dojox.charting.plot2d.Default");
 
dojo.require("dojox.charting.plot2d.common");
dojo.require("dojox.charting.plot2d.Base");
 
dojo.require("dojox.lang.utils");
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, du = dojox.lang.utils,
dc = dojox.charting.plot2d.common,
purgeGroup = df.lambda("item.purgeGroup()");
 
dojo.declare("dojox.charting.plot2d.Default", dojox.charting.plot2d.Base, {
defaultParams: {
hAxis: "x", // use a horizontal axis named "x"
vAxis: "y", // use a vertical axis named "y"
lines: true, // draw lines
areas: false, // draw areas
markers: false, // draw markers
shadows: 0 // draw shadows
},
optionalParams: {}, // no optional parameters
constructor: function(chart, kwArgs){
this.opt = dojo.clone(this.defaultParams);
du.updateWithObject(this.opt, kwArgs);
this.series = [];
this.hAxis = this.opt.hAxis;
this.vAxis = this.opt.vAxis;
},
calculateAxes: function(dim){
this._calc(dim, dc.collectSimpleStats(this.series));
return this;
},
render: function(dim, offsets){
if(this.dirty){
dojo.forEach(this.series, purgeGroup);
this.cleanGroup();
var s = this.group;
df.forEachReversed(this.series, function(item){ item.cleanGroup(s); });
}
var t = this.chart.theme, stroke, outline, color, marker;
for(var i = this.series.length - 1; i >= 0; --i){
var run = this.series[i];
if(!this.dirty && !run.dirty){ continue; }
run.cleanGroup();
if(!run.data.length){
run.dirty = false;
continue;
}
var s = run.group, lpoly;
if(typeof run.data[0] == "number"){
lpoly = dojo.map(run.data, function(v, i){
return {
x: this._hScaler.scale * (i + 1 - this._hScaler.bounds.lower) + offsets.l,
y: dim.height - offsets.b - this._vScaler.scale * (v - this._vScaler.bounds.lower)
};
}, this);
}else{
lpoly = dojo.map(run.data, function(v, i){
return {
x: this._hScaler.scale * (v.x - this._hScaler.bounds.lower) + offsets.l,
y: dim.height - offsets.b - this._vScaler.scale * (v.y - this._vScaler.bounds.lower)
};
}, this);
}
if(!run.fill || !run.stroke){
// need autogenerated color
color = run.dyn.color = new dojo.Color(t.next("color"));
}
if(this.opt.areas){
var apoly = dojo.clone(lpoly);
apoly.push({x: lpoly[lpoly.length - 1].x, y: dim.height - offsets.b});
apoly.push({x: lpoly[0].x, y: dim.height - offsets.b});
apoly.push(lpoly[0]);
var fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
run.dyn.fill = s.createPolyline(apoly).setFill(fill).getFill();
}
if(this.opt.lines || this.opt.markers){
// need a stroke
stroke = run.stroke ? dc.makeStroke(run.stroke) : dc.augmentStroke(t.series.stroke, color);
if(run.outline || t.series.outline){
outline = dc.makeStroke(run.outline ? run.outline : t.series.outline);
outline.width = 2 * outline.width + stroke.width;
}
}
if(this.opt.markers){
// need a marker
marker = run.dyn.marker = run.marker ? run.marker : t.next("marker");
}
if(this.opt.shadows && stroke){
var sh = this.opt.shadows, shadowColor = new dojo.Color([0, 0, 0, 0.3]),
spoly = dojo.map(lpoly, function(c){
return {x: c.x + sh.dx, y: c.y + sh.dy};
}),
shadowStroke = dojo.clone(outline ? outline : stroke);
shadowStroke.color = shadowColor;
shadowStroke.width += sh.dw ? sh.dw : 0;
if(this.opt.lines){
s.createPolyline(spoly).setStroke(shadowStroke);
}
if(this.opt.markers){
dojo.forEach(spoly, function(c){
s.createPath("M" + c.x + " " + c.y + " " + marker).setStroke(shadowStroke).setFill(shadowColor);
}, this);
}
}
if(this.opt.lines){
if(outline){
run.dyn.outline = s.createPolyline(lpoly).setStroke(outline).getStroke();
}
run.dyn.stroke = s.createPolyline(lpoly).setStroke(stroke).getStroke();
}
if(this.opt.markers){
dojo.forEach(lpoly, function(c){
var path = "M" + c.x + " " + c.y + " " + marker;
if(outline){
s.createPath(path).setStroke(outline);
}
s.createPath(path).setStroke(stroke).setFill(stroke.color);
}, this);
}
run.dirty = false;
}
this.dirty = false;
return this;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/Grid.js
New file
0,0 → 1,116
if(!dojo._hasResource["dojox.charting.plot2d.Grid"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.Grid"] = true;
dojo.provide("dojox.charting.plot2d.Grid");
 
dojo.require("dojox.charting.Element");
dojo.require("dojox.charting.plot2d.common");
dojo.require("dojox.lang.functional");
 
(function(){
var du = dojox.lang.utils;
 
dojo.declare("dojox.charting.plot2d.Grid", dojox.charting.Element, {
defaultParams: {
hAxis: "x", // use a horizontal axis named "x"
vAxis: "y", // use a vertical axis named "y"
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: "none", // TBD
vStripes: "none" // TBD
},
optionalParams: {}, // no optional parameters
constructor: function(chart, kwArgs){
this.opt = dojo.clone(this.defaultParams);
du.updateWithObject(this.opt, kwArgs);
this.hAxis = this.opt.hAxis;
this.vAxis = this.opt.vAxis;
},
clear: function(){
this._hAxis = null;
this._vAxis = null;
this.dirty = true;
return this;
},
setAxis: function(axis){
if(axis){
this[axis.vertical ? "_vAxis" : "_hAxis"] = axis;
}
return this;
},
addSeries: function(run){
// nothing
return this;
},
calculateAxes: function(dim){
// nothing
return this;
},
getRequiredColors: function(){
return 0;
},
render: function(dim, offsets){
// draw horizontal stripes and lines
if(!this.dirty){ return this; }
this.cleanGroup();
var s = this.group, ta = this.chart.theme.axis,
scaler = this._vAxis.getScaler();
if(this.opt.hMinorLines && scaler.minor.tick){
for(var i = 0; i < scaler.minor.count; ++i){
var y = dim.height - offsets.b - scaler.scale *
(scaler.minor.start - scaler.bounds.lower + i * scaler.minor.tick);
s.createLine({
x1: offsets.l,
y1: y,
x2: dim.width - offsets.r,
y2: y
}).setStroke(ta.minorTick);
}
}
if(this.opt.hMajorLines && scaler.major.tick){
for(var i = 0; i < scaler.major.count; ++i){
var y = dim.height - offsets.b - scaler.scale *
(scaler.major.start - scaler.bounds.lower + i * scaler.major.tick);
s.createLine({
x1: offsets.l,
y1: y,
x2: dim.width - offsets.r,
y2: y
}).setStroke(ta.majorTick);
}
}
// draw vertical stripes and lines
scaler = this._hAxis.getScaler();
if(this.opt.vMinorLines && scaler.minor.tick){
for(var i = 0; i < scaler.minor.count; ++i){
var x = offsets.l + scaler.scale *
(scaler.minor.start - scaler.bounds.lower + i * scaler.minor.tick);
s.createLine({
x1: x,
y1: offsets.t,
x2: x,
y2: dim.height - offsets.b
}).setStroke(ta.minorTick);
}
}
if(this.opt.vMajorLines && scaler.major.tick){
for(var i = 0; i < scaler.major.count; ++i){
var x = offsets.l + scaler.scale *
(scaler.major.start - scaler.bounds.lower + i * scaler.major.tick);
s.createLine({
x1: x,
y1: offsets.t,
x2: x,
y2: dim.height - offsets.b
}).setStroke(ta.majorTick);
}
}
this.dirty = false;
return this;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/StackedBars.js
New file
0,0 → 1,84
if(!dojo._hasResource["dojox.charting.plot2d.StackedBars"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.StackedBars"] = true;
dojo.provide("dojox.charting.plot2d.StackedBars");
 
dojo.require("dojox.charting.plot2d.common");
dojo.require("dojox.charting.plot2d.Bars");
 
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, dc = dojox.charting.plot2d.common,
purgeGroup = df.lambda("item.purgeGroup()");
 
dojo.declare("dojox.charting.plot2d.StackedBars", dojox.charting.plot2d.Bars, {
calculateAxes: function(dim){
var stats = dc.collectStackedStats(this.series), t;
this._maxRunLength = stats.hmax;
stats.hmin -= 0.5;
stats.hmax += 0.5;
t = stats.hmin, stats.hmin = stats.vmin, stats.vmin = t;
t = stats.hmax, stats.hmax = stats.vmax, stats.vmax = t;
this._calc(dim, stats);
return this;
},
render: function(dim, offsets){
// stack all values
var acc = df.repeat(this._maxRunLength, "-> 0", 0);
for(var i = 0; i < this.series.length; ++i){
var run = this.series[i];
for(var j = 0; j < run.data.length; ++j){
var v = run.data[j];
if(isNaN(v)){ v = 0; }
acc[j] += v;
}
}
// draw runs in backwards
if(this.dirty){
dojo.forEach(this.series, purgeGroup);
this.cleanGroup();
var s = this.group;
df.forEachReversed(this.series, function(item){ item.cleanGroup(s); });
}
var t = this.chart.theme, color, stroke, fill, f,
gap = this.opt.gap < this._vScaler.scale / 3 ? this.opt.gap : 0;
for(var i = this.series.length - 1; i >= 0; --i){
var run = this.series[i];
if(!this.dirty && !run.dirty){ continue; }
run.cleanGroup();
var s = run.group;
if(!run.fill || !run.stroke){
// need autogenerated color
color = run.dyn.color = new dojo.Color(t.next("color"));
}
stroke = run.stroke ? run.stroke : dc.augmentStroke(t.series.stroke, color);
fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
for(var j = 0; j < acc.length; ++j){
var v = acc[j],
width = this._hScaler.scale * (v - this._hScaler.bounds.lower),
height = this._vScaler.scale - 2 * gap;
if(width >= 1 && height >= 1){
var shape = s.createRect({
x: offsets.l,
y: dim.height - offsets.b - this._vScaler.scale * (j + 1.5 - this._vScaler.bounds.lower) + gap,
width: width, height: height
}).setFill(fill).setStroke(stroke);
run.dyn.fill = shape.getFill();
run.dyn.stroke = shape.getStroke();
}
}
run.dirty = false;
// update the accumulator
for(var j = 0; j < run.data.length; ++j){
var v = run.data[j];
if(isNaN(v)){ v = 0; }
acc[j] -= v;
}
}
this.dirty = false;
return this;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/Bars.js
New file
0,0 → 1,88
if(!dojo._hasResource["dojox.charting.plot2d.Bars"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.Bars"] = true;
dojo.provide("dojox.charting.plot2d.Bars");
 
dojo.require("dojox.charting.plot2d.common");
dojo.require("dojox.charting.plot2d.Base");
 
dojo.require("dojox.lang.utils");
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, du = dojox.lang.utils,
dc = dojox.charting.plot2d.common,
purgeGroup = df.lambda("item.purgeGroup()");
 
dojo.declare("dojox.charting.plot2d.Bars", dojox.charting.plot2d.Base, {
defaultParams: {
hAxis: "x", // use a horizontal axis named "x"
vAxis: "y", // use a vertical axis named "y"
gap: 0, // gap between columns in pixels
shadows: null // draw shadows
},
optionalParams: {}, // no optional parameters
constructor: function(chart, kwArgs){
this.opt = dojo.clone(this.defaultParams);
du.updateWithObject(this.opt, kwArgs);
this.series = [];
this.hAxis = this.opt.hAxis;
this.vAxis = this.opt.vAxis;
},
calculateAxes: function(dim){
var stats = dc.collectSimpleStats(this.series), t;
stats.hmin -= 0.5;
stats.hmax += 0.5;
t = stats.hmin, stats.hmin = stats.vmin, stats.vmin = t;
t = stats.hmax, stats.hmax = stats.vmax, stats.vmax = t;
this._calc(dim, stats);
return this;
},
render: function(dim, offsets){
if(this.dirty){
dojo.forEach(this.series, purgeGroup);
this.cleanGroup();
var s = this.group;
df.forEachReversed(this.series, function(item){ item.cleanGroup(s); });
}
var t = this.chart.theme, color, stroke, fill, f,
gap = this.opt.gap < this._vScaler.scale / 3 ? this.opt.gap : 0;
for(var i = this.series.length - 1; i >= 0; --i){
var run = this.series[i];
if(!this.dirty && !run.dirty){ continue; }
run.cleanGroup();
var s = run.group;
if(!run.fill || !run.stroke){
// need autogenerated color
color = run.dyn.color = new dojo.Color(t.next("color"));
}
stroke = run.stroke ? run.stroke : dc.augmentStroke(t.series.stroke, color);
fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
var baseline = Math.max(0, this._hScaler.bounds.lower),
xoff = offsets.l + this._hScaler.scale * (baseline - this._hScaler.bounds.lower),
yoff = dim.height - offsets.b - this._vScaler.scale * (1.5 - this._vScaler.bounds.lower) + gap;
for(var j = 0; j < run.data.length; ++j){
var v = run.data[j],
width = this._hScaler.scale * (v - baseline),
height = this._vScaler.scale - 2 * gap,
w = Math.abs(width);
if(w >= 1 && height >= 1){
var shape = s.createRect({
x: xoff + (width < 0 ? width : 0),
y: yoff - this._vScaler.scale * j,
width: w, height: height
}).setFill(fill).setStroke(stroke);
run.dyn.fill = shape.getFill();
run.dyn.stroke = shape.getStroke();
}
}
run.dirty = false;
}
this.dirty = false;
return this;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/common.js
New file
0,0 → 1,113
if(!dojo._hasResource["dojox.charting.plot2d.common"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.common"] = true;
dojo.provide("dojox.charting.plot2d.common");
 
dojo.require("dojo.colors");
dojo.require("dojox.gfx");
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, dc = dojox.charting.plot2d.common;
dojo.mixin(dojox.charting.plot2d.common, {
makeStroke: function(stroke){
if(!stroke){ return stroke; }
if(typeof stroke == "string" || stroke instanceof dojo.Color){
stroke = {color: stroke};
}
return dojox.gfx.makeParameters(dojox.gfx.defaultStroke, stroke);
},
augmentColor: function(target, color){
var t = new dojo.Color(target),
c = new dojo.Color(color);
c.a = t.a;
return c;
},
augmentStroke: function(stroke, color){
var s = dc.makeStroke(stroke);
if(s){
s.color = dc.augmentColor(s.color, color);
}
return s;
},
augmentFill: function(fill, color){
var fc, c = new dojo.Color(color);
if(typeof fill == "string" || fill instanceof dojo.Color){
return dc.augmentColor(fill, color);
}
return fill;
},
defaultStats: {hmin: Number.POSITIVE_INFINITY, hmax: Number.NEGATIVE_INFINITY,
vmin: Number.POSITIVE_INFINITY, vmax: Number.NEGATIVE_INFINITY},
collectSimpleStats: function(series){
var stats = dojo.clone(dc.defaultStats);
for(var i = 0; i < series.length; ++i){
var run = series[i];
if(!run.data.length){ continue; }
if(typeof run.data[0] == "number"){
// 1D case
var old_vmin = stats.vmin, old_vmax = stats.vmax;
if(!("ymin" in run) || !("ymax" in run)){
dojo.forEach(run.data, function(val, i){
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)){
dojo.forEach(run.data, function(val, i){
var x = val.x, 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); }
}
}
return stats;
},
collectStackedStats: function(series){
// collect statistics
var stats = dojo.clone(dc.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];
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];
if(isNaN(t)){ t = 0; }
v += t;
}
stats.vmax = Math.max(stats.vmax, v);
}
}
return stats;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/StackedAreas.js
New file
0,0 → 1,14
if(!dojo._hasResource["dojox.charting.plot2d.StackedAreas"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.StackedAreas"] = true;
dojo.provide("dojox.charting.plot2d.StackedAreas");
 
dojo.require("dojox.charting.plot2d.Stacked");
 
dojo.declare("dojox.charting.plot2d.StackedAreas", dojox.charting.plot2d.Stacked, {
constructor: function(){
this.opt.lines = true;
this.opt.areas = true;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/Areas.js
New file
0,0 → 1,14
if(!dojo._hasResource["dojox.charting.plot2d.Areas"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.Areas"] = true;
dojo.provide("dojox.charting.plot2d.Areas");
 
dojo.require("dojox.charting.plot2d.Default");
 
dojo.declare("dojox.charting.plot2d.Areas", dojox.charting.plot2d.Default, {
constructor: function(){
this.opt.lines = true;
this.opt.areas = true;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/ClusteredColumns.js
New file
0,0 → 1,62
if(!dojo._hasResource["dojox.charting.plot2d.ClusteredColumns"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.ClusteredColumns"] = true;
dojo.provide("dojox.charting.plot2d.ClusteredColumns");
 
dojo.require("dojox.charting.plot2d.common");
dojo.require("dojox.charting.plot2d.Columns");
 
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, dc = dojox.charting.plot2d.common,
purgeGroup = df.lambda("item.purgeGroup()");
 
dojo.declare("dojox.charting.plot2d.ClusteredColumns", dojox.charting.plot2d.Columns, {
render: function(dim, offsets){
if(this.dirty){
dojo.forEach(this.series, purgeGroup);
this.cleanGroup();
var s = this.group;
df.forEachReversed(this.series, function(item){ item.cleanGroup(s); });
}
var t = this.chart.theme, color, stroke, fill, f,
gap = this.opt.gap < this._hScaler.scale / 3 ? this.opt.gap : 0,
thickness = (this._hScaler.scale - 2 * gap) / this.series.length;
for(var i = 0; i < this.series.length; ++i){
var run = this.series[i];
if(!this.dirty && !run.dirty){ continue; }
run.cleanGroup();
var s = run.group;
if(!run.fill || !run.stroke){
// need autogenerated color
color = run.dyn.color = new dojo.Color(t.next("color"));
}
stroke = run.stroke ? run.stroke : dc.augmentStroke(t.series.stroke, color);
fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
var baseline = Math.max(0, this._vScaler.bounds.lower),
xoff = offsets.l + this._hScaler.scale * (0.5 - this._hScaler.bounds.lower) + gap + thickness * i,
yoff = dim.height - offsets.b - this._vScaler.scale * (baseline - this._vScaler.bounds.lower);
for(var j = 0; j < run.data.length; ++j){
var v = run.data[j],
width = thickness,
height = this._vScaler.scale * (v - baseline),
h = Math.abs(height);
if(width >= 1 && h >= 1){
var shape = s.createRect({
x: xoff + this._hScaler.scale * j,
y: yoff - (height < 0 ? 0 : height),
width: width, height: h
}).setFill(fill).setStroke(stroke);
run.dyn.fill = shape.getFill();
run.dyn.stroke = shape.getStroke();
}
}
run.dirty = false;
}
this.dirty = false;
return this;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/ClusteredBars.js
New file
0,0 → 1,62
if(!dojo._hasResource["dojox.charting.plot2d.ClusteredBars"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.ClusteredBars"] = true;
dojo.provide("dojox.charting.plot2d.ClusteredBars");
 
dojo.require("dojox.charting.plot2d.common");
dojo.require("dojox.charting.plot2d.Bars");
 
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, dc = dojox.charting.plot2d.common,
purgeGroup = df.lambda("item.purgeGroup()");
 
dojo.declare("dojox.charting.plot2d.ClusteredBars", dojox.charting.plot2d.Bars, {
render: function(dim, offsets){
if(this.dirty){
dojo.forEach(this.series, purgeGroup);
this.cleanGroup();
var s = this.group;
df.forEachReversed(this.series, function(item){ item.cleanGroup(s); });
}
var t = this.chart.theme, color, stroke, fill, f,
gap = this.opt.gap < this._vScaler.scale / 3 ? this.opt.gap : 0,
thickness = (this._vScaler.scale - 2 * gap) / this.series.length;
for(var i = this.series.length - 1; i >= 0; --i){
var run = this.series[i];
if(!this.dirty && !run.dirty){ continue; }
run.cleanGroup();
var s = run.group;
if(!run.fill || !run.stroke){
// need autogenerated color
color = run.dyn.color = new dojo.Color(t.next("color"));
}
stroke = run.stroke ? run.stroke : dc.augmentStroke(t.series.stroke, color);
fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
var baseline = Math.max(0, this._hScaler.bounds.lower),
xoff = offsets.l + this._hScaler.scale * (baseline - this._hScaler.bounds.lower),
yoff = dim.height - offsets.b - this._vScaler.scale * (1.5 - this._vScaler.bounds.lower) +
gap + thickness * (this.series.length - i - 1);
for(var j = 0; j < run.data.length; ++j){
var v = run.data[j],
width = this._hScaler.scale * (v - baseline),
height = thickness, w = Math.abs(width);
if(w >= 1 && height >= 1){
var shape = s.createRect({
x: xoff + (width < 0 ? width : 0),
y: yoff - this._vScaler.scale * j,
width: w, height: height
}).setFill(fill).setStroke(stroke);
run.dyn.fill = shape.getFill();
run.dyn.stroke = shape.getStroke();
}
}
run.dirty = false;
}
this.dirty = false;
return this;
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/Markers.js
New file
0,0 → 1,13
if(!dojo._hasResource["dojox.charting.plot2d.Markers"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.Markers"] = true;
dojo.provide("dojox.charting.plot2d.Markers");
 
dojo.require("dojox.charting.plot2d.Default");
 
dojo.declare("dojox.charting.plot2d.Markers", dojox.charting.plot2d.Default, {
constructor: function(){
this.opt.markers = true;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot2d/Scatter.js
New file
0,0 → 1,14
if(!dojo._hasResource["dojox.charting.plot2d.Scatter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot2d.Scatter"] = true;
dojo.provide("dojox.charting.plot2d.Scatter");
 
dojo.require("dojox.charting.plot2d.Default");
 
dojo.declare("dojox.charting.plot2d.Scatter", dojox.charting.plot2d.Default, {
constructor: function(){
this.opt.lines = false;
this.opt.markers = true;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/charting/scaler.js
New file
0,0 → 1,161
if(!dojo._hasResource["dojox.charting.scaler"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.scaler"] = true;
dojo.provide("dojox.charting.scaler");
 
(function(){
var deltaLimit = 3; // pixels
var isText = function(val, text){
val = val.toLowerCase();
for(var i = 0; i < text.length; ++i){
if(val == text[i]){ return true; }
}
return false;
};
var calcTicks = function(min, max, kwArgs, majorTick, minorTick, microTick, span){
kwArgs = dojo.clone(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 = isText(kwArgs.fixLower, ["major"]) ?
Math.floor(min / majorTick) * majorTick :
isText(kwArgs.fixLower, ["minor"]) ?
Math.floor(min / minorTick) * minorTick :
isText(kwArgs.fixLower, ["micro"]) ?
Math.floor(min / microTick) * unit : min,
upperBound = isText(kwArgs.fixUpper, ["major"]) ?
Math.ceil(max / majorTick) * majorTick :
isText(kwArgs.fixUpper, ["minor"]) ?
Math.ceil(max / minorTick) * minorTick :
isText(kwArgs.fixUpper, ["unit"]) ?
Math.ceil(max / unit) * unit : max,
majorStart = (isText(kwArgs.fixLower, ["major"]) || !majorTick) ?
lowerBound : Math.ceil(lowerBound / majorTick) * majorTick,
minorStart = (isText(kwArgs.fixLower, ["major", "minor"]) || !minorTick) ?
lowerBound : Math.ceil(lowerBound / minorTick) * minorTick,
microStart = (isText(kwArgs.fixLower, ["major", "minor", "micro"]) || ! microTick) ?
lowerBound : Math.ceil(lowerBound / microTick) * microTick,
majorCount = !majorTick ? 0 : (isText(kwArgs.fixUpper, ["major"]) ?
Math.round((upperBound - majorStart) / majorTick) :
Math.floor((upperBound - majorStart) / majorTick)) + 1,
minorCount = !minorTick ? 0 : (isText(kwArgs.fixUpper, ["major", "minor"]) ?
Math.round((upperBound - minorStart) / minorTick) :
Math.floor((upperBound - minorStart) / minorTick)) + 1,
microCount = !microTick ? 0 : (isText(kwArgs.fixUpper, ["major", "minor", "micro"]) ?
Math.round((upperBound - microStart) / microTick) :
Math.floor((upperBound - 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 / (upperBound - lowerBound);
if(!isFinite(scale)){ scale = 1; }
return {
bounds: {
lower: lowerBound,
upper: upperBound
},
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,
scale: scale
};
};
 
dojox.charting.scaler = function(min, max, span, kwArgs){
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); }
}
if(max <= min){
return calcTicks(min, max, h, 0, 0, 0, span); // Object
}
var mag = Math.floor(Math.log(max - min) / Math.LN10),
major = kwArgs && ("majorTick" in kwArgs) ? kwArgs.majorTick : Math.pow(10, mag),
minor = 0, micro = 0, ticks;
// calculate minor ticks
if(kwArgs && ("minorTick" in kwArgs)){
minor = kwArgs.minorTick;
}else{
do{
minor = major / 10;
if(!h.natural || minor > 0.9){
ticks = calcTicks(min, max, h, major, minor, 0, span);
if(ticks.scale * ticks.minor.tick > deltaLimit){ break; }
}
minor = major / 5;
if(!h.natural || minor > 0.9){
ticks = calcTicks(min, max, h, major, minor, 0, span);
if(ticks.scale * ticks.minor.tick > deltaLimit){ break; }
}
minor = major / 2;
if(!h.natural || minor > 0.9){
ticks = calcTicks(min, max, h, major, minor, 0, span);
if(ticks.scale * ticks.minor.tick > deltaLimit){ break; }
}
return calcTicks(min, max, h, major, 0, 0, span); // Object
}while(false);
}
 
// calculate micro ticks
if(kwArgs && ("microTick" in kwArgs)){
micro = kwArgs.microTick;
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.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.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.scale * ticks.micro.tick > deltaLimit){ break; }
}
micro = 0;
}while(false);
}
 
return micro ? ticks : calcTicks(min, max, h, major, minor, 0, span); // Object
};
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/Series.js
New file
0,0 → 1,20
if(!dojo._hasResource["dojox.charting.Series"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.Series"] = true;
dojo.provide("dojox.charting.Series");
 
dojo.require("dojox.charting.Element");
 
dojo.declare("dojox.charting.Series", dojox.charting.Element, {
constructor: function(chart, data, kwArgs){
dojo.mixin(this, kwArgs);
if(typeof this.plot != "string"){ this.plot = "default"; }
this.data = data;
this.dirty = true;
this.clear();
},
clear: function(){
this.dyn = {};
}
});
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot3d/Bars.js
New file
0,0 → 1,66
if(!dojo._hasResource["dojox.charting.plot3d.Bars"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot3d.Bars"] = true;
dojo.provide("dojox.charting.plot3d.Bars");
 
dojo.require("dojox.charting.plot3d.Base");
 
(function(){
 
// reduce function borrowed from dojox.fun
var reduce = function(/*Array*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary: repeatedly applies a binary function to an array from left
// to right; returns the final value.
a = typeof a == "string" ? a.split("") : a; o = o || dojo.global;
var z = a[0];
for(var i = 1; i < a.length; z = f.call(o, z, a[i++]));
return z; // Object
};
 
dojo.declare("dojox.charting.plot3d.Bars", dojox.charting.plot3d.Base, {
constructor: function(width, height, kwArgs){
this.depth = "auto";
this.gap = 0;
this.data = [];
this.material = {type: "plastic", finish: "dull", color: "lime"};
if(kwArgs){
if("depth" in kwArgs){ this.depth = kwArgs.depth; }
if("gap" in kwArgs){ this.gap = kwArgs.gap; }
if("material" in kwArgs){
var m = kwArgs.material;
if(typeof m == "string" || m instanceof dojo.Color){
this.material.color = m;
}else{
this.material = m;
}
}
}
},
getDepth: function(){
if(this.depth == "auto"){
var w = this.width;
if(this.data && this.data.length){
w = w / this.data.length;
}
return w - 2 * this.gap;
}
return this.depth;
},
generate: function(chart, creator){
if(!this.data){ return this; }
var step = this.width / this.data.length, org = 0,
depth = this.depth == "auto" ? step - 2 * this.gap : this.depth,
scale = this.height / reduce(this.data, Math.max);
if(!creator){ creator = chart.view; }
for(var i = 0; i < this.data.length; ++i, org += step){
creator
.createCube({
bottom: {x: org + this.gap, y: 0, z: 0},
top: {x: org + step - this.gap, y: this.data[i] * scale, z: depth}
})
.setFill(this.material);
}
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot3d/Base.js
New file
0,0 → 1,23
if(!dojo._hasResource["dojox.charting.plot3d.Base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot3d.Base"] = true;
dojo.provide("dojox.charting.plot3d.Base");
 
dojo.require("dojox.charting.Chart3D");
 
dojo.declare("dojox.charting.plot3d.Base", null, {
constructor: function(width, height, kwArgs){
this.width = width;
this.height = height;
},
setData: function(data){
this.data = data ? data : [];
return this;
},
getDepth: function(){
return this.depth;
},
generate: function(chart, creator){
}
});
 
}
/trunk/api/js/dojo1.0/dojox/charting/plot3d/Cylinders.js
New file
0,0 → 1,69
if(!dojo._hasResource["dojox.charting.plot3d.Cylinders"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.plot3d.Cylinders"] = true;
dojo.provide("dojox.charting.plot3d.Cylinders");
 
dojo.require("dojox.charting.plot3d.Base");
 
(function(){
 
// reduce function borrowed from dojox.fun
var reduce = function(/*Array*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary: repeatedly applies a binary function to an array from left
// to right; returns the final value.
a = typeof a == "string" ? a.split("") : a; o = o || dojo.global;
var z = a[0];
for(var i = 1; i < a.length; z = f.call(o, z, a[i++]));
return z; // Object
};
 
dojo.declare("dojox.charting.plot3d.Cylinders", dojox.charting.plot3d.Base, {
constructor: function(width, height, kwArgs){
this.depth = "auto";
this.gap = 0;
this.data = [];
this.material = {type: "plastic", finish: "shiny", color: "lime"};
this.outline = null;
if(kwArgs){
if("depth" in kwArgs){ this.depth = kwArgs.depth; }
if("gap" in kwArgs){ this.gap = kwArgs.gap; }
if("material" in kwArgs){
var m = kwArgs.material;
if(typeof m == "string" || m instanceof dojo.Color){
this.material.color = m;
}else{
this.material = m;
}
}
if("outline" in kwArgs){ this.outline = kwArgs.outline; }
}
},
getDepth: function(){
if(this.depth == "auto"){
var w = this.width;
if(this.data && this.data.length){
w = w / this.data.length;
}
return w - 2 * this.gap;
}
return this.depth;
},
generate: function(chart, creator){
if(!this.data){ return this; }
var step = this.width / this.data.length, org = 0,
scale = this.height / reduce(this.data, Math.max);
if(!creator){ creator = chart.view; }
for(var i = 0; i < this.data.length; ++i, org += step){
creator
.createCylinder({
center: {x: org + step / 2, y: 0, z: 0},
radius: step / 2 - this.gap,
height: this.data[i] * scale
})
.setTransform(dojox.gfx3d.matrix.rotateXg(-90))
.setFill(this.material).setStroke(this.outline);
}
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/themes/GreySkies.js
New file
0,0 → 1,11
if(!dojo._hasResource["dojox.charting.themes.GreySkies"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.themes.GreySkies"] = true;
dojo.provide("dojox.charting.themes.GreySkies");
dojo.require("dojox.charting.Theme");
 
(function(){
var dxc=dojox.charting;
dxc.themes.GreySkies=new dxc.Theme(dxc.Theme._def);
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/themes/PlotKit/blue.js
New file
0,0 → 1,43
if(!dojo._hasResource["dojox.charting.themes.PlotKit.blue"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.themes.PlotKit.blue"] = true;
dojo.provide("dojox.charting.themes.PlotKit.blue");
dojo.require("dojox.charting.Theme");
 
(function(){
var dxc=dojox.charting;
dxc.themes.PlotKit.blue=new dxc.Theme({
chart:{
stroke:null,
fill: "white"
},
plotarea:{
stroke:null,
fill: "#e7eef6"
},
axis:{
stroke:{ color:"#fff",width:2 },
line:{ color:"#fff",width:1 },
majorTick:{ color:"#fff", width:2, length:12 },
minorTick:{ color:"#fff", width:1, length:8 },
font:"normal normal normal 8pt Tahoma",
fontColor:"#999"
},
series:{
outline:{ width:1, color:"#fff" },
stroke:{ width:2, color:"#666" },
fill:new dojo.Color([0x66, 0x66, 0x66, 0.8]),
font:"normal normal normal 7pt Tahoma", // label
fontColor:"#000"
},
marker:{ // any markers on a series.
stroke:{ width:2 },
fill:"#333",
font:"normal normal normal 7pt Tahoma", // label
fontColor:"#000"
},
colors:[]
});
dxc.themes.PlotKit.blue.defineColors({ hue:217, saturation:60, low:40, high:88 });
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/themes/PlotKit/purple.js
New file
0,0 → 1,43
if(!dojo._hasResource["dojox.charting.themes.PlotKit.purple"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.themes.PlotKit.purple"] = true;
dojo.provide("dojox.charting.themes.PlotKit.purple");
dojo.require("dojox.charting.Theme");
 
(function(){
var dxc=dojox.charting;
dxc.themes.PlotKit.purple=new dxc.Theme({
chart:{
stroke:null,
fill: "white"
},
plotarea:{
stroke:null,
fill: "#eee6f5"
},
axis:{
stroke:{ color:"#fff",width:2 },
line:{ color:"#fff",width:1 },
majorTick:{ color:"#fff", width:2, length:12 },
minorTick:{ color:"#fff", width:1, length:8 },
font:"normal normal normal 8pt Tahoma",
fontColor:"#999"
},
series:{
outline:{ width:1, color:"#fff" },
stroke:{ width:2, color:"#666" },
fill:new dojo.Color([0x66, 0x66, 0x66, 0.8]),
font:"normal normal normal 7pt Tahoma", // label
fontColor:"#000"
},
marker:{ // any markers on a series.
stroke:{ width:2 },
fill:"#333",
font:"normal normal normal 7pt Tahoma", // label
fontColor:"#000"
},
colors:[]
});
dxc.themes.PlotKit.purple.defineColors({ hue:271, saturation:60, low:40, high:88 });
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/themes/PlotKit/cyan.js
New file
0,0 → 1,43
if(!dojo._hasResource["dojox.charting.themes.PlotKit.cyan"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.themes.PlotKit.cyan"] = true;
dojo.provide("dojox.charting.themes.PlotKit.cyan");
dojo.require("dojox.charting.Theme");
 
(function(){
var dxc=dojox.charting;
dxc.themes.PlotKit.cyan=new dxc.Theme({
chart:{
stroke:null,
fill: "white"
},
plotarea:{
stroke:null,
fill: "#e6f1f5"
},
axis:{
stroke:{ color:"#fff",width:2 },
line:{ color:"#fff",width:1 },
majorTick:{ color:"#fff", width:2, length:12 },
minorTick:{ color:"#fff", width:1, length:8 },
font:"normal normal normal 8pt Tahoma",
fontColor:"#999"
},
series:{
outline:{ width:1, color:"#fff" },
stroke:{ width:2, color:"#666" },
fill:new dojo.Color([0x66, 0x66, 0x66, 0.8]),
font:"normal normal normal 7pt Tahoma", // label
fontColor:"#000"
},
marker:{ // any markers on a series.
stroke:{ width:2 },
fill:"#333",
font:"normal normal normal 7pt Tahoma", // label
fontColor:"#000"
},
colors:[]
});
dxc.themes.PlotKit.cyan.defineColors({ hue:194, saturation:60, low:40, high:88 });
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/themes/PlotKit/red.js
New file
0,0 → 1,43
if(!dojo._hasResource["dojox.charting.themes.PlotKit.red"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.themes.PlotKit.red"] = true;
dojo.provide("dojox.charting.themes.PlotKit.red");
dojo.require("dojox.charting.Theme");
 
(function(){
var dxc=dojox.charting;
dxc.themes.PlotKit.red=new dxc.Theme({
chart:{
stroke:null,
fill: "white"
},
plotarea:{
stroke:null,
fill: "#f5e6e6"
},
axis:{
stroke:{ color:"#fff",width:2 },
line:{ color:"#fff",width:1 },
majorTick:{ color:"#fff", width:2, length:12 },
minorTick:{ color:"#fff", width:1, length:8 },
font:"normal normal normal 8pt Tahoma",
fontColor:"#999"
},
series:{
outline:{ width:1, color:"#fff" },
stroke:{ width:2, color:"#666" },
fill:new dojo.Color([0x66, 0x66, 0x66, 0.8]),
font:"normal normal normal 7pt Tahoma", // label
fontColor:"#000"
},
marker:{ // any markers on a series.
stroke:{ width:2 },
fill:"#333",
font:"normal normal normal 7pt Tahoma", // label
fontColor:"#000"
},
colors:[]
});
dxc.themes.PlotKit.red.defineColors({ hue:1, saturation:60, low:40, high:88 });
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/themes/PlotKit/orange.js
New file
0,0 → 1,43
if(!dojo._hasResource["dojox.charting.themes.PlotKit.orange"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.themes.PlotKit.orange"] = true;
dojo.provide("dojox.charting.themes.PlotKit.orange");
dojo.require("dojox.charting.Theme");
 
(function(){
var dxc=dojox.charting;
dxc.themes.PlotKit.orange=new dxc.Theme({
chart:{
stroke:null,
fill: "white"
},
plotarea:{
stroke:null,
fill: "#f5eee6"
},
axis:{
stroke:{ color:"#fff",width:2 },
line:{ color:"#fff",width:1 },
majorTick:{ color:"#fff", width:2, length:12 },
minorTick:{ color:"#fff", width:1, length:8 },
font:"normal normal normal 8pt Tahoma",
fontColor:"#999"
},
series:{
outline:{ width:1, color:"#fff" },
stroke:{ width:2, color:"#666" },
fill:new dojo.Color([0x66, 0x66, 0x66, 0.8]),
font:"normal normal normal 7pt Tahoma", // label
fontColor:"#000"
},
marker:{ // any markers on a series.
stroke:{ width:2 },
fill:"#333",
font:"normal normal normal 7pt Tahoma", // label
fontColor:"#000"
},
colors:[]
});
dxc.themes.PlotKit.orange.defineColors({ hue:31, saturation:60, low:40, high:88 });
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/themes/PlotKit/green.js
New file
0,0 → 1,43
if(!dojo._hasResource["dojox.charting.themes.PlotKit.green"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.charting.themes.PlotKit.green"] = true;
dojo.provide("dojox.charting.themes.PlotKit.green");
dojo.require("dojox.charting.Theme");
 
(function(){
var dxc=dojox.charting;
dxc.themes.PlotKit.green=new dxc.Theme({
chart:{
stroke:null,
fill: "white"
},
plotarea:{
stroke:null,
fill: "#eff5e6"
},
axis:{
stroke:{ color:"#fff",width:2 },
line:{ color:"#fff",width:1 },
majorTick:{ color:"#fff", width:2, length:12 },
minorTick:{ color:"#fff", width:1, length:8 },
font:"normal normal normal 8pt Tahoma",
fontColor:"#999"
},
series:{
outline:{ width:1, color:"#fff" },
stroke:{ width:2, color:"#666" },
fill:new dojo.Color([0x66, 0x66, 0x66, 0.8]),
font:"normal normal normal 7pt Tahoma", // label
fontColor:"#000"
},
marker:{ // any markers on a series.
stroke:{ width:2 },
fill:"#333",
font:"normal normal normal 7pt Tahoma", // label
fontColor:"#000"
},
colors:[]
});
dxc.themes.PlotKit.green.defineColors({ hue:82, saturation:60, low:40, high:88 });
})();
 
}
/trunk/api/js/dojo1.0/dojox/charting/themes/PlotKit/README
New file
0,0 → 1,11
This directory contains a set of themes for the DojoX Charting
engine that are based on the visual stylings of the PlotKit
chart kit, created by Alastair Tse:
 
http://www.liquidx.net/plotkit/
 
...whose work we admire. Consider these themes to not be a
ripoff of his fine work, but instead a true homage: his charts
are beautiful, and we stand in awe.
 
--trt, 2007-06-08
/trunk/api/js/dojo1.0/dojox/xml/DomParser.js
New file
0,0 → 1,373
if(!dojo._hasResource["dojox.xml.DomParser"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.xml.DomParser"] = true;
dojo.provide("dojox.xml.DomParser");
 
dojox.xml.DomParser=new (function(){
/**********************************************************
* The DomParser is a close-to (but not entirely)
* conforming XML parser based on regular
* expressions. It will take any XML fragment
* and return a lightweight JS structure that is
* similar to (but not exactly) the DOM specification.
*
* Getter and setter methods are NOT available; the goal
* was to keep the resulting object model entirely JS-like.
*
* All node types but document fragments are supported;
* all nodes support getElementsByTagName and
* getElementsByTagNameNS (with short names byName and
* byNameNS). The document node supports getElementById
* (byId), and all nodes support a supplimental
* childrenByName/childrenByNameNS method as well.
*
* The object model is intended to be a READONLY format;
* mutation events are NOT supported, and though you
* can change properties on a node-by-node basis, certain
* operations are not supported (such as changing the ID
* of an element).
**********************************************************/
 
// internal use only.
var nodeTypes={ ELEMENT:1, ATTRIBUTE:2, TEXT:3, CDATA_SECTION:4, PROCESSING_INSTRUCTION:7, COMMENT:8, DOCUMENT:9 };
 
// compile the regular expressions once.
var reTags=/<([^>\/\s+]*)([^>]*)>([^<]*)/g;
var reAttr=/([^=]*)="([^"]*)"/g;
var reEntity=/<!ENTITY\s+([^"]*)\s+"([^"]*)">/g;
var reCData=/<!\[CDATA\[([\u0001-\uFFFF]*?)\]\]>/g;
var reComments=/<!--([\u0001-\uFFFF]*?)-->/g;
var trim=/^\s+|\s+$/g;
var normalize=/\s+/g;
var egt=/\&gt;/g;
var elt=/\&lt;/g;
var equot=/\&quot;/g;
var eapos=/\&apos;/g;
var eamp=/\&amp;/g;
var dNs="_def_";
 
// create a root node.
function _doc(){
return new (function(){
var all={};
this.nodeType=nodeTypes.DOCUMENT;
this.nodeName="#document";
this.namespaces={};
this._nsPaths={};
this.childNodes=[];
this.documentElement=null;
 
// any element with an ID attribute will be added to the internal hashtable.
this._add=function(obj){
if(typeof(obj.id)!="undefined"){ all[obj.id]=obj; }
};
this._remove=function(id){
if(all[id]){ delete all[id]; }
};
 
this.byId=this.getElementById=function(id){ return keys[id]; };
this.byName=this.getElementsByTagName=byName;
this.byNameNS=this.getElementsByTagNameNS=byNameNS;
this.childrenByName=childrenByName;
})();
}
 
// functions attached to element nodes
function byName(name){
// return all descendants with name. Fully qualified (i.e. svg:svg)
function __(node, name, arr){
dojo.forEach(node.childNodes, function(c){
if(c.nodeType==nodeTypes.ELEMENT){
if(name=="*"){ arr.push(c); }
else if(c.nodeName==name){ arr.push(c); }
__(c, name, arr);
}
});
}
var a=[];
__(this, name, a);
return a;
}
function byNameNS(name, ns){
// return all descendants with name by namespace. If no namespace passed, the default is used.
function __(node, name, ns, arr){
dojo.forEach(node.childNodes, function(c){
if(c.nodeType==nodeTypes.ELEMENT){
if(name=="*"&&c.ownerDocument._nsPaths[ns]==c.namespace){ arr.push(c); }
else if(c.localName==name&&c.ownerDocument._nsPaths[ns]==c.namespace){ arr.push(c); }
__(c, name, ns, arr);
}
});
}
if(!ns){ ns=dNs; }
var a=[];
__(this, name, ns, a);
return a;
}
// Only child nodes with name.
function childrenByName(name){
var a=[];
dojo.forEach(this.childNodes, function(c){
if(c.nodeType==nodeTypes.ELEMENT){
if(name=="*"){ a.push(c); }
else if(c.nodeName==name){ a.push(c); }
}
});
return a;
}
 
// attribute functions
function getAttr(name){
for(var i=0; i<this.attributes.length; i++){
if(this.attributes[i].nodeName==name){
return this.attributes[i].nodeValue;
}
}
return null;
}
function getAttrNS(name, ns){
for(var i=0; i<this.attributes.length; i++){
if(this.ownerDocument._nsPaths[ns]==this.attributes[i].namespace
&&this.attributes[i].localName==name
){
return this.attributes[i].nodeValue;
}
}
return null;
}
// note that you can only swap IDs using setAttribute, NOT with setAttributeNS.
function setAttr(name, val){
var old=null;
for(var i=0; i<this.attributes.length; i++){
if(this.attributes[i].nodeName==name){
old=this.attributes[i].nodeValue;
this.attributes[i].nodeValue=val;
break;
}
}
if(name=="id"){
if(old!=null){ this.ownerDocument._remove(old); }
this.ownerDocument._add(this);
}
}
function setAttrNS(name, val, ns){
for(var i=0; i<this.attributes.length; i++){
if(this.ownerDocument._nsPaths[ns]==this.attributes[i].namespace
&&this.attributes[i].localName==name
){
this.attributes[i].nodeValue=val;
return;
}
}
}
 
// navigation
function prev(){
var p=this.parentNode;
if(p){
for(var i=0;i<p.childNodes.length;i++){
if(p.childNodes[i]==this&&i>0){
return p.childNodes[i-1];
}
}
}
return null;
}
function next(){
var p=this.parentNode;
if(p){
for(var i=0;i<p.childNodes.length;i++){
if(p.childNodes[i]==this&&(i+1)<p.childNodes.length){
return p.childNodes[i+1];
}
}
}
return null;
}
 
// the main method.
this.parse=function(/* String */str){
var root=_doc();
if(str==null){ return root; }
if(str.length==0){ return root; }
 
// preprocess custom entities
if(str.indexOf("<!ENTITY")>0){
var entity, eRe=[];
if(reEntity.test(str)){
reEntity.lastIndex=0;
// match entities
while((entity=reEntity.exec(str))!=null){
eRe.push({
entity:"&"+entity[1].replace(trim,"")+";",
expression:entity[2]
});
}
// replace instances in the document.
for(var i=0; i<eRe.length; i++){
str=str.replace(new RegExp(eRe[i].entity, "g"), eRe[i].expression);
}
}
}
 
// pre-parse for CData, and tokenize.
var cdSections=[], cdata;
while((cdata=reCData.exec(str))!=null){ cdSections.push(cdata[1]); }
for(var i=0; i<cdSections.length; i++){ str=str.replace(cdSections[i], i); }
// pre-parse for comments, and tokenize.
var comments=[], comment;
while((comment=reComments.exec(str))!=null){ comments.push(comment[1]); }
for(i=0; i<comments.length; i++){ str=str.replace(comments[i], i); }
 
// parse the document
var res, obj=root;
while((res=reTags.exec(str))!=null){
// closing tags.
if(res[2].charAt(0)=="/"){
if(obj.parentNode){
obj=obj.parentNode;
}
continue;
}
 
// open tags.
if(res[1].length>0){
// figure out the type of node.
if(res[1].charAt(0)=="?"){
// processing instruction
var name=res[1].substr(1);
var target=res[2].substr(0,res[2].length-2);
obj.childNodes.push({
nodeType:nodeTypes.PROCESSING_INSTRUCTION,
nodeName:name,
nodeValue:target
});
}
else if(res[1].charAt(0)=="!"){
// CDATA; skip over any declaration elements.
if(res[1].indexOf("![CDATA[")==0){
var val=parseInt(res[1].replace("![CDATA[","").replace("]]",""));
obj.childNodes.push({
nodeType:nodeTypes.CDATA_SECTION,
nodeName:"#cdata-section",
nodeValue:cdSections[val]
});
}
// Comments.
else if(res[1].substr(0,3)=="!--"){
var val=parseInt(res[1].replace("!--","").replace("--",""));
obj.childNodes.push({
nodeType:nodeTypes.COMMENT,
nodeName:"#comment",
nodeValue:comments[val]
});
}
}
else {
// Elements (with attribute and text)
var name=res[1].replace(trim,"");
var o={
nodeType:nodeTypes.ELEMENT,
nodeName:name,
localName:name,
namespace:dNs,
ownerDocument:root,
attributes:[],
parentNode:null,
childNodes:[]
};
 
// check to see if it's namespaced.
if(name.indexOf(":")>-1){
var t=name.split(":");
o.namespace=t[0];
o.localName=t[1];
}
 
// set the function references.
o.byName=o.getElementsByTagName=byName;
o.byNameNS=o.getElementsByTagNameNS=byNameNS;
o.childrenByName=childrenByName;
o.getAttribute=getAttr;
o.getAttributeNS=getAttrNS;
o.setAttribute=setAttr;
o.setAttributeNS=setAttrNS;
o.previous=o.previousSibling=prev;
o.next=o.nextSibling=next;
 
// parse the attribute string.
var attr;
while((attr=reAttr.exec(res[2]))!=null){
if(attr.length>0){
var name=attr[1].replace(trim,"");
var val=attr[2].replace(normalize," ")
.replace(egt,">")
.replace(elt,"<")
.replace(eapos,"'")
.replace(equot,'"')
.replace(eamp,"&");
if(name.indexOf("xmlns")==0){
if(name.indexOf(":")>0){
var ns=name.split(":");
root.namespaces[ns[1]]=val;
root._nsPaths[val]=ns[1];
} else {
root.namespaces[dNs]=val;
root._nsPaths[val]=dNs;
}
} else {
var ln=name;
var ns=dNs;
if(name.indexOf(":")>0){
var t=name.split(":");
ln=t[1];
ns=t[0];
}
o.attributes.push({
nodeType:nodeTypes.ATTRIBUTE,
nodeName:name,
localName:ln,
namespace:ns,
nodeValue:val
});
 
// only add id as a property.
if(ln=="id"){ o.id=val; }
}
}
}
root._add(o);
 
var text=res[3].replace(trim,"");
if(text.length>0)
o.childNodes.push({
nodeType:nodeTypes.TEXT,
nodeName:"#text",
nodeValue:text.replace(normalize," ").replace(egt,">").replace(elt,"<").replace(eapos,"'").replace(equot,'"').replace(eamp,"&")
});
 
if(obj){
obj.childNodes.push(o);
o.parentNode=obj;
// if it's not a self-closing node.
if(res[2].charAt(res[2].length-1)!="/"){
obj=o;
}
}
}
}
}
 
// set the document element
for(var i=0; i<root.childNodes.length; i++){
var e=root.childNodes[i];
if(e.nodeType==nodeTypes.ELEMENT){
root.documentElement=e;
break;
}
}
return root;
};
})();
 
}
/trunk/api/js/dojo1.0/dojox/xml/README
New file
0,0 → 1,40
-------------------------------------------------------------------------------
DojoX XML Utilities
-------------------------------------------------------------------------------
Version 0.1
Release date: 05/30/2007
-------------------------------------------------------------------------------
Project state:
expermental
-------------------------------------------------------------------------------
Credits
Tom Trenka (ttrenka@gmail.com): DomParser
-------------------------------------------------------------------------------
Project description
 
The goal of DojoX XML Utilities is provide differing XML utilities for use
in various places. Currently this includes a native JS DomParser, but will
most likely be expanded to include things as dealing with x-browser forks
(like the Sarissa project), various DOM utilites, and more.
-------------------------------------------------------------------------------
Dependencies:
 
DojoX XML relies only on the Dojo Base package system.
-------------------------------------------------------------------------------
Documentation
 
None at the time of writing. The only object is dojox.xml.DomParser (a singleton),
which has one method: parse:
 
dojox.xml.DomParser.parse(xmlString)
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/xml/*
 
Install into the following directory structure:
/dojox/xml/
 
...which should be at the same level as your Dojo checkout.
/trunk/api/js/dojo1.0/dojox/timing.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.timing"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.timing"] = true;
dojo.provide("dojox.timing");
dojo.require("dojox.timing._base");
 
}
/trunk/api/js/dojo1.0/dojox/wire/CompositeWire.js
New file
0,0 → 1,103
if(!dojo._hasResource["dojox.wire.CompositeWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.CompositeWire"] = true;
dojo.provide("dojox.wire.CompositeWire");
 
dojo.require("dojox.wire._base");
dojo.require("dojox.wire.Wire");
 
dojo.declare("dojox.wire.CompositeWire", dojox.wire.Wire, {
// summary:
// A Wire for composite values in object or array
// description:
// This class has multiple child Wires for object properties or array
// elements.
// When an object with Wires is specified to 'children' property, they
// are used to get or set an object with property values.
// When an array of Wiares is specified to 'children' property, they
// are used to get or set an array with element values.
_wireClass: "dojox.wire.CompositeWire",
 
constructor: function(/*Object*/args){
// summary:
// Initialize properties
// description:
// If object properties or array elements specified in 'children'
// property are not Wires, Wires are created from them as
// arguments, with 'parent' property set to this Wire instance.
// args:
// Arguments to initialize properties
// children:
// An object or array containing child Wires
this._initializeChildren(this.children);
},
_getValue: function(/*Object||Array*/object){
// summary:
// Return an object with property values or an array with element
// values
// description:
// This method calls getValue() method of the child Wires with
// 'object' argument and returns an object with the values as
// properties or an arary of the values as elements.
// object:
// A root object
// returns:
// An object or array with values
if(!object || !this.children){
return object; //Object||Array
}
 
var value = (dojo.isArray(this.children) ? [] : {}); // array or object
for(var c in this.children){
value[c] = this.children[c].getValue(object);
}
return value;//Object||Array
},
 
_setValue: function(/*Object||Array*/object, /*Object||Array*/value){
// summary:
// Set an object properties or an array elements to an object
// desription:
// This method calls setValues() method of the child Wires with
// a corresponding property or element in 'value' argument and
// 'object' argument.
// object:
// A root object
// value:
// An object or array with values to set
// returns:
// 'object'
if(!object || !this.children){
return object; //Object||Array
}
 
for(var c in this.children){
this.children[c].setValue(value[c], object);
}
return object; //Object||Array
},
 
_initializeChildren: function(/*Object||Array*/children){
// summary:
// Initialize child Wires
// description:
// If object properties or array elements specified in 'children'
// argument are not Wires, Wires are created from them as
// arguments, with 'parent' property set to this Wire instance.
// children:
// An object or array containing child Wires
if(!children){
return; //undefined
}
 
for(var c in children){
var child = children[c];
child.parent = this;
if(!dojox.wire.isWire(child)){
children[c] = dojox.wire.create(child);
}
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/_base.js
New file
0,0 → 1,195
if(!dojo._hasResource["dojox.wire._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire._base"] = true;
dojo.provide("dojox.wire._base");
 
dojox.wire._defaultWireClass = "dojox.wire.Wire";
 
dojox.wire._wireClasses = {
"attribute": "dojox.wire.DataWire",
"path": "dojox.wire.XmlWire",
"children": "dojox.wire.CompositeWire",
"columns": "dojox.wire.TableAdapter",
"nodes": "dojox.wire.TreeAdapter",
"segments": "dojox.wire.TextAdapter"
};
 
dojox.wire.register = function(/*Function||String*/wireClass, /*String*/key){
// summary:
// Register a Wire class
// desription:
// The specified Wire class or a class name is registered with
// a key property of arguments to create a Wire
// wireClass:
// A class or full qualified class name
// key:
// A key property of arguments to create a Wire
if(!wireClass || !key){
return; //undefined
}
if(dojox.wire._wireClasses[key]){ // key already in use
return; //undefined
}
dojox.wire._wireClasses[key] = wireClass;
};
 
dojox.wire._getClass = function(/*String*/name){
// summary:
// Returns a class
// description:
// The class is loaded by dojo.require() and returned
// by dojo.getObject().
// name:
// A class name
// returns:
// A class
dojo["require"](name); // use dojo["require"] instead of dojo.require to avoid a build problem
return dojo.getObject(name); //Function
};
 
dojox.wire.create = function(/*Object*/args){
// summary:
// Create a Wire from arguments
// description:
// If 'args' specifies 'wireClass', it is used as a class or full
// qualified class name to create a Wire with 'args' as arguments.
// Otherwise, a Wire class is determined by other proeprties of 'args'
// checking if 'args' specifies a key property for a Wire class.
// If no key property found, the default Wire class is used.
// args:
// Arguments to create a Wire
// returns:
// A Wire
if(!args){
args = {};
}
var wireClass = args.wireClass;
if(wireClass){
if(dojo.isString(wireClass)){
wireClass = dojox.wire._getClass(wireClass);
}
}else{
for(var key in args){
if(!args[key]){
continue;
}
wireClass = dojox.wire._wireClasses[key];
if(wireClass){
if(dojo.isString(wireClass)){
wireClass = dojox.wire._getClass(wireClass);
dojox.wire._wireClasses[key] = wireClass;
}
break;
}
}
}
if(!wireClass){
if(dojo.isString(dojox.wire._defaultWireClass)){
dojox.wire._defaultWireClass = dojox.wire._getClass(dojox.wire._defaultWireClass);
}
wireClass = dojox.wire._defaultWireClass;
}
return new wireClass(args); //Object
};
 
dojox.wire.isWire = function(/*Object*/wire){
// summary:
// Check if an object is a Wire
// description:
// If the specified object is a Wire, true is returned.
// Otherwise, false is returned.
// wire:
// An object to check
// returns:
// True if the object is a Wire, otherwise false
return (wire && wire._wireClass); //Boolean
};
 
dojox.wire.transfer = function(/*Wire||Object*/source, /*Wire||Object*/target, /*Object?*/defaultObject, /*Object?*/defaultTargetObject){
// summary:
// Transfer a source value to a target value
// description:
// If 'source' and/or 'target' are not Wires, Wires are created with
// them as arguments.
// A value is got through the source Wire and set through the target
// Wire.
// 'defaultObject' is passed to Wires as a default root object.
// If 'defaultTargetObject' is specified, it is passed to the target
// Wire as a default root object, instead of 'defaultObject'.
// source:
// A Wire or arguments to create a Wire for a source value
// target:
// A Wire or arguments to create a Wire for a target value
// defaultObject:
// defaultTargetObject;
// Optional default root objects passed to Wires
if(!source || !target){
return; //undefined
}
if(!dojox.wire.isWire(source)){
source = dojox.wire.create(source);
}
if(!dojox.wire.isWire(target)){
target = dojox.wire.create(target);
}
 
var value = source.getValue(defaultObject);
target.setValue(value, (defaultTargetObject || defaultObject));
};
 
dojox.wire.connect = function(/*Object*/trigger, /*Wire||Object*/source, /*Wire||Object*/target){
// summary:
// Transfer a source value to a target value on a trigger event or
// topic
// description:
// If 'trigger' specifies 'topic', the topic is subscribed to transer
// a value on the topic.
// Otherwise, the event specified to 'event' of 'trigger' is listened
// to transfer a value.
// On the specified event or topic, transfer() is called with
// 'source', 'target' and the arguments of the event or topic (as
// default root objects).
// trigger:
// An event or topic to trigger a transfer
// source:
// A Wire or arguments to create a Wire for a source value
// target:
// A Wire or arguments to create a Wire for a target value
// returns:
// A connection handle for disconnect()
if(!trigger || !source || !target){
return; //undefined
}
 
var connection = {topic: trigger.topic};
if(trigger.topic){
connection.handle = dojo.subscribe(trigger.topic, function(){
dojox.wire.transfer(source, target, arguments);
});
}else if(trigger.event){
connection.handle = dojo.connect(trigger.scope, trigger.event, function(){
dojox.wire.transfer(source, target, arguments);
});
}
return connection; //Object
};
 
dojox.wire.disconnect = function(/*Object*/connection){
// summary:
// Remove a connection or subscription for transfer
// description:
// If 'handle' has 'topic', the topic is unsubscribed.
// Otherwise, the listener to an event is removed.
// connection:
// A connection handle returned by connect()
if(!connection || !connection.handle){
return; //undefined
}
 
if(connection.topic){
dojo.unsubscribe(connection.handle);
}else{
dojo.disconnect(connection.handle);
}
};
 
}
/trunk/api/js/dojo1.0/dojox/wire/demos/TableContainer.js
New file
0,0 → 1,68
if(!dojo._hasResource["dojox.wire.demos.TableContainer"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.demos.TableContainer"] = true;
dojo.provide("dojox.wire.demos.TableContainer");
 
dojo.require("dojo.parser");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
 
dojo.declare("dojox.wire.demos.TableContainer", [ dijit._Widget, dijit._Templated, dijit._Container ], {
// summary:
// Extremely simple 'widget' that is a table generator with an addRow function that takes an array
// as the row to add, where each entry is a cell in the row. This demo widget is for use with the
// wire demos.
 
templateString: "<table class='tablecontainer'><tbody dojoAttachPoint='tableContainer'></tbody></table>",
rowCount: 0,
headers: "",
addRow: function(array){
// summary:
// Function to add in a new row from the elements in the array map to cells in the row.
// array:
// Array of row values to add.
try{
var row = document.createElement("tr");
if((this.rowCount%2) === 0){
dojo.addClass(row, "alternate");
}
this.rowCount++;
for(var i in array){
var cell = document.createElement("td");
var text = document.createTextNode(array[i]);
cell.appendChild(text);
row.appendChild(cell);
}
this.tableContainer.appendChild(row);
}catch(e){ console.debug(e); }
},
 
clearTable: function(){
// summary:
// Function to clear all the current rows in the table, except for the header.
 
//Always leave the first row, which is the table header.
while(this.tableContainer.firstChild.nextSibling){
this.tableContainer.removeChild(this.tableContainer.firstChild.nextSibling);
}
this.rowCount = 0;
},
 
postCreate: function(){
// summary:
// Widget lifecycle function to handle generation of the header elements in the table.
var headers = this.headers.split(",");
var tr = document.createElement("tr");
for(i in headers){
var header = headers[i];
var th = document.createElement("th");
var text = document.createTextNode(header);
th.appendChild(text);
tr.appendChild(th);
}
this.tableContainer.appendChild(tr);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/demos/WidgetRepeater.js
New file
0,0 → 1,33
if(!dojo._hasResource["dojox.wire.demos.WidgetRepeater"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.demos.WidgetRepeater"] = true;
dojo.provide("dojox.wire.demos.WidgetRepeater")
dojo.require("dojo.parser");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dijit._Container");
 
dojo.declare("dojox.wire.demos.WidgetRepeater", [ dijit._Widget, dijit._Templated, dijit._Container ], {
// summary:
// Simple widget that does generation of widgets repetatively, based on calls to
// the createNew function and contains them as child widgets.
templateString: "<div class='WidgetRepeater' dojoAttachPoint='repeaterNode'></div>",
widget: null,
repeater: null,
createNew: function(obj){
// summary:
// Function to handle the creation of a new widget and appending it into the widget tree.
// obj:
// The parameters to pass to the widget.
try{
if(dojo.isString(this.widget)){
dojo.require(this.widget);
this.widget = dojo.getObject(this.widget);
}
this.addChild(new this.widget(obj));
this.repeaterNode.appendChild(document.createElement("br"));
}catch(e){ console.debug(e); }
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/demos/markup/countries.json
New file
0,0 → 1,43
{ identifier: 'name',
items: [
{ name:'Africa', type:'continent',
children:[{_reference:'Egypt'}, {_reference:'Kenya'}, {_reference:'Sudan'}] },
{ name:'Egypt', type:'country' },
{ name:'Kenya', type:'country',
children:[{_reference:'Nairobi'}, {_reference:'Mombasa'}] },
{ name:'Nairobi', type:'city' },
{ name:'Mombasa', type:'city' },
{ name:'Sudan', type:'country',
children:{_reference:'Khartoum'} },
{ name:'Khartoum', type:'city' },
{ name:'Asia', type:'continent',
children:[{_reference:'China'}, {_reference:'India'}, {_reference:'Russia'}, {_reference:'Mongolia'}] },
{ name:'China', type:'country' },
{ name:'India', type:'country' },
{ name:'Russia', type:'country' },
{ name:'Mongolia', type:'country' },
{ name:'Australia', type:'continent', population:'21 million',
children:{_reference:'Commonwealth of Australia'}},
{ name:'Commonwealth of Australia', type:'country', population:'21 million'},
{ name:'Europe', type:'continent',
children:[{_reference:'Germany'}, {_reference:'France'}, {_reference:'Spain'}, {_reference:'Italy'}] },
{ name:'Germany', type:'country' },
{ name:'France', type:'country' },
{ name:'Spain', type:'country' },
{ name:'Italy', type:'country' },
{ name:'North America', type:'continent',
children:[{_reference:'Mexico'}, {_reference:'Canada'}, {_reference:'United States of America'}] },
{ name:'Mexico', type:'country', population:'108 million', area:'1,972,550 sq km',
children:[{_reference:'Mexico City'}, {_reference:'Guadalajara'}] },
{ name:'Mexico City', type:'city', population:'19 million', timezone:'-6 UTC'},
{ name:'Guadalajara', type:'city', population:'4 million', timezone:'-6 UTC' },
{ name:'Canada', type:'country', population:'33 million', area:'9,984,670 sq km',
children:[{_reference:'Ottawa'}, {_reference:'Toronto'}] },
{ name:'Ottawa', type:'city', population:'0.9 million', timezone:'-5 UTC'},
{ name:'Toronto', type:'city', population:'2.5 million', timezone:'-5 UTC' },
{ name:'United States of America', type:'country' },
{ name:'South America', type:'continent',
children:[{_reference:'Brazil'}, {_reference:'Argentina'}] },
{ name:'Brazil', type:'country', population:'186 million' },
{ name:'Argentina', type:'country', population:'40 million' }
]}
/trunk/api/js/dojo1.0/dojox/wire/demos/markup/demo_BasicChildWire.html
New file
0,0 → 1,77
<!--
This file demonstrates how the dojox.wire code can be used to do declarative
wiring of properties/attributes of some object to the properties/attributes of
another object. It specifically uses the Child (Composite) wire type to perform
the mapping.
 
Note that this demo expects dojo, digit, and dojox to all be peers in the same directory
in order for it to execute.
-->
<html>
<head>
<title>Sample Composite (Child) Wire usage.</title>
<style type="text/css">
@import "../../../../dijit/themes/tundra/tundra.css";
@import "../../../../dojo/resources/dojo.css";
@import "../../../../dijit/tests/css/dijitTests.css";
</style>
 
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojox.wire.ml.Invocation");
dojo.require("dojox.wire.ml.DataStore");
dojo.require("dojox.wire.ml.Transfer");
dojo.require("dojox.wire");
dojo.require("dojox.wire.demos.WidgetRepeater");
 
dataHolder = {
request: {onItem: function(item){}},
result: null
};
</script>
</head>
<body class="tundra">
<!--
On load of the page, invoke the fetch method of the object 'DataStore1',
get its parameters from the JS object 'sample.request
-->
<div dojoType="dojox.wire.ml.Invocation"
triggerEvent="onLoad"
object="DataStore1" method="fetch" parameters="dataHolder.request">
</div>
 
<!--
The store that is queried in this demo
-->
<div dojoType="dojo.data.ItemFileReadStore"
jsId="DataStore1"
url="countries.json">
</div>
 
<!--
Simple container widget for creating a 'list' of some set of widgets
As defined by the widget type it contains.
-->
<div dojoType="dojox.wire.demos.WidgetRepeater"
widget="dijit.form.Button" jsId="r1">
</div>
 
<!--
On the call of the onItem function of 'sample', trigger a binding/mapping of the
item's attribute 'name' to the target object property: dataHolder.result.caption
Then invoke the WidgetRepeater (r1)'s createNew method, using the parameters from
dataHolder.result.
-->
<div dojoType="dojox.wire.ml.Action"
trigger="dataHolder.request" triggerEvent="onItem">
<div dojoType="dojox.wire.ml.Transfer"
source="arguments[0]" sourceStore="DataStore1"
target="dataHolder.result">
<div dojoType="dojox.wire.ml.ChildWire" name="label" attribute="name"></div>
</div>
<div dojoType="dojox.wire.ml.Invocation" object="r1" method="createNew" parameters='dataHolder.result'></div>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/demos/markup/demo_ActionWiring.html
New file
0,0 → 1,142
<!--
This file demonstrates how the dojox.wire code can be used to do declarative
wiring of events on one item to trigger event on other widgets. It also shows
how you can use the Transfer object to morph data values from one format to
another. In this specific case, it maps the values from a dojo.data Datastore
item into values stored in a JavaScript Array, which is the format required for
the addRow method of the demonstration TableContainer.
 
Note that this demo expects dojo, digit, and dojox to all be peers in the same directory
in order for it to execute.
-->
<html>
<head>
<title>Sample declarative data binding</title>
<style type="text/css">
 
@import "../../../../dijit/themes/tundra/tundra.css";
@import "../../../../dojo/resources/dojo.css";
@import "../../../../dijit/tests/css/dijitTests.css";
@import "../TableContainer.css";
 
.splitView {
width: 90%;
height: 90%;
border: 1px solid #bfbfbf;
border-collapse: separate;
}
</style>
 
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojox.wire.ml.Invocation");
dojo.require("dojox.wire.ml.DataStore");
dojo.require("dojox.wire.ml.Transfer");
 
dojo.require("dijit.layout.SplitContainer");
dojo.require("dijit.layout.LayoutContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.TextBox");
 
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojox.wire");
dojo.require("dojox.wire.demos.TableContainer");
 
//Toplevel JS Object to contain a few basics for us, such as the request to pass to the store and a stub onItem function
// to trap on for triggering other events.
dataHolder = {
//Simple object definition to get all items and sort it by the attribute 'type'.
request: {query: {name: "*"}, onItem: function(item, req){}, sort: [{attribute: "type"}]},
//Spot to store off data values as they're generated by the declarative binding.
result: null
};
 
</script>
</head>
 
<body class="tundra">
 
<!-- The following is the basic layout. A split container with a button and a text field. Data will be displayed on the right. -->
<div dojoType="dijit.layout.SplitContainer"
orientation="horizontal"
sizerWidth="7"
activeSizing="true"
class="splitView">
<div dojoType="dijit.layout.ContentPane" sizeMin="50" sizeShare="50">
<font size="3"><b>Demo Searcher (Searches on Attribute 'name'):</b></font><br/><br/>
<b>Usage:</b><br/>
Enter the name you want to search the store for. Wildcards * (multiple character), and ? (single character), are allowed.
<br/>
<br/>
<table style="width: 90%;">
<tr>
<td align="left">
<div dojoType="dijit.form.Button" jsId="searchButton">Search Datastore</div>
</td>
<td align="right">
<div dojoType="dijit.form.TextBox" jsId="inputField" value="*"></div>
</td>
</tr>
</table>
</div>
<div dojoType="dijit.layout.ContentPane" sizeMin="50" sizeShare="50">
<div class="dataTable" dojoType="dojox.wire.demos.TableContainer" jsId="dataTable" headers="Name,Location Type"></div>
</div>
</div>
 
 
<!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
 
<!-- The store that is queried in this demo -->
<div dojoType="dojo.data.ItemFileReadStore"
jsId="DataStore1"
url="countries.json">
</div>
 
<!--
When the search button is clicked, clear existing rows from table,
Then invoke the fetch to repopulate the table.
-->
<div dojoType="dojox.wire.ml.Action"
trigger="searchButton"
triggerEvent="onClick">
<div dojoType="dojox.wire.ml.Invocation" object="dataTable" method="clearTable"></div>
<div dojoType="dojox.wire.ml.Invocation" object="DataStore1" method="fetch" parameters="dataHolder.request"></div>
</div>
 
<!--
Link existing of the text box to transfering the search string to the query param.
We are wiring the value of TextBox value of the widget to the name property of our request
object. The copy of values to the search should occur on each keyup event (each keypress)
-->
<div dojoType="dojox.wire.ml.Transfer"
trigger="inputField" triggerEvent="onkeyup"
source="inputField.textbox.value"
target="dataHolder.request.query.name">
</div>
 
<!--
On the call of the onItem function of 'dataHolder', trigger a binding/mapping of the
item's attribute 'name' and 'type' attributes to specific columns in an array. Note here that since
sourceStore is set, it treats the arguments as items from that store and accesses the attributes
appropriately. In this case 'name' becomes array entry 0, type, array entry 1, and so on.
 
Then take the result of the data mapping and pass it into the invoke of the addRow function on the
TableContainer widget.
-->
<div dojoType="dojox.wire.ml.Action"
trigger="dataHolder.request" triggerEvent="onItem">
<div dojoType="dojox.wire.ml.Transfer"
source="arguments[0]" sourceStore="DataStore1"
target="dataHolder.result">
<div dojoType="dojox.wire.ml.ColumnWire" attribute="name"></div>
<div dojoType="dojox.wire.ml.ColumnWire" attribute="type"></div>
</div>
<div dojoType="dojox.wire.ml.Invocation"
object="dataTable" method="addRow" parameters='dataHolder.result'>
</div>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/demos/markup/demo_ActionChaining.html
New file
0,0 → 1,108
<!--
This file demonstrates how the dojox.wire code can be used to do declarative
wiring of events. Specifically, it shows how you can chain actions together
in a sequence. In this case the setting of a value on one textbox triggers a
copy over to another textbox. That in turn triggers yet another copy to another
text box.
-->
<html>
<head>
<title>Sample Action Chaining</title>
<style type="text/css">
 
@import "../../../../dijit/themes/tundra/tundra.css";
@import "../../../../dojo/resources/dojo.css";
@import "../../../../dijit/tests/css/dijitTests.css";
@import "../TableContainer.css";
 
.splitView {
width: 90%;
height: 90%;
border: 1px solid #bfbfbf;
border-collapse: separate;
}
</style>
 
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojox.wire");
dojo.require("dojox.wire.ml.Invocation");
dojo.require("dojox.wire.ml.DataStore");
dojo.require("dojox.wire.ml.Transfer");
dojo.require("dojox.wire.ml.Data");
dojo.require("dijit.form.TextBox");
</script>
</head>
 
<body class="tundra">
 
<!-- Layout -->
<font size="3"><b>Demo of Chaining Actions:</b></font><br/><br/>
This demo shows how you can chain actions together to fire in a sequence.
Such as the completion of setting one value on a widget triggers the setting of another value on the widget
<br/>
<br/>
<table>
<tr>
<td>
<div dojoType="dijit.form.TextBox" id="inputField" value="" size="50"></div>
</td>
</tr>
<tr>
<td>
<div dojoType="dijit.form.TextBox" id="targetField1" value="" disabled="true" size="50"></div>
</td>
</tr>
<tr>
<td>
<div dojoType="dijit.form.TextBox" id="targetField2" value="" disabled="true" size="50"></div>
</td>
</tr>
</table>
 
 
<!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
 
<!--
This is an example of using the declarative data value definition.
These are effectively declarative variables to act as placeholders
for data values.
-->
<div dojoType="dojox.wire.ml.Data"
id="data">
<div dojoType="dojox.wire.ml.DataProperty"
name="tempData"
value="">
</div>
</div>
 
<!--
Whenever a key is entered into the textbox, copy the value somewhere, then invoke a method on another widget, in this case
on just another text box.
-->
<div dojoType="dojox.wire.ml.Action"
id="action1"
trigger="inputField"
triggerEvent="onkeyup">
<div dojoType="dojox.wire.ml.Invocation" object="inputField" method="getValue" result="data.tempData"></div>
<div dojoType="dojox.wire.ml.Invocation" id="targetCopy" object="targetField1" method="setValue" parameters="data.tempData"></div>
</div>
 
<!--
Whenever the primary cloning invocation completes, invoke a secondary cloning action.
-->
<div dojoType="dojox.wire.ml.Action"
id="action2"
trigger="targetCopy"
triggerEvent="onComplete">
<!--
Note that this uses the basic 'property' form of copying the property over and setting it. The Wire
code supports both getX and setX functions of setting a property as well as direct access. It first looks
for the getX/setX functions and if present, uses them. If missing, it will just do direct access. Because
of the standard getValue/setValue API of dijit form widgets, these transfers work really well and are very compact.
-->
<div dojoType="dojox.wire.ml.Transfer" source="targetField1.value" target="targetField2.value"></div>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/demos/markup/demo_FlickrStoreWire.html
New file
0,0 → 1,281
<!--
This file is a demo of the FlickrStore, a simple wrapper to the public feed service
of Flickr. This just does very basic queries against Flickr and loads the results
into a list viewing widget.
-->
<html>
<head>
<title>Demo of FlickrStore</title>
<style type="text/css">
 
@import "../../../../dijit/themes/tundra/tundra.css";
@import "../../../../dojo/resources/dojo.css";
@import "../../../../dijit/tests/css/dijitTests.css";
@import "./flickrDemo.css";
</style>
 
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.ComboBox");
dojo.require("dijit.form.NumberSpinner");
dojo.require("dojox.data.FlickrStore");
dojo.require("dojox.wire.ml.Invocation");
dojo.require("dojox.wire.ml.Transfer");
dojo.require("dojox.wire.ml.Data");
dojo.require("dojox.wire");
dojo.require("dojox.data.demos.widgets.FlickrViewList");
dojo.require("dojox.data.demos.widgets.FlickrView");
 
//Toplevel JS Object to contain a few basics for us, such as the request to pass to the store and a stub onItem and onComplete function
// to trap on for triggering other events.
var dataHolder = {
//Simple stub datastore request
request: {query: {}, onItem: function(item, req){}, onComplete: function(items, req){}},
//Spot to store off data values as they're generated by the declarative binding.
result: null
};
 
//Function to convert the input from a widget into a comma separated list.
//that is the format of the store parameter.
var tagsInputConverter = function(tags){
if(tags && tags !== ""){
var tagsArray = tags.split(" ");
tags = "";
for(var i = 0; i < tagsArray.length; i++){
tags = tags + tagsArray[i];
if(i < (tagsArray.length - 1)){
tags += ","
}
}
}
return tags
}
 
</script>
</head>
 
<body class="tundra">
<h1>
DEMO: FlickrStore Search
</h1>
<hr>
<h3>
Description:
</h3>
<p>
This simple demo shows how services, such as Flickr, can be wrapped by the datastore API. In this demo, you can search public
Flickr images through a simple FlickrStore by specifying a series of tags (separated by spaces) to search on. The results
will be displayed below the search box. This demo is the same as the example demo provided in dojox/data/demos/demo_FlickrStore.html,
except that all the interactions are implemented via Wire instead of a script that runs at dojo.addOnLoad().
</p>
<p>
For fun, search on the 3dny tag!
</p>
 
<blockquote>
 
<!--
Layout.
-->
<table>
<tbody>
<tr>
<td>
<b>Status:</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="status" jsId="statusWidget" disabled="true"></div>
</td>
</tr>
<tr>
<td>
<b>ID:</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="userid" jsId="idWidget"></div>
</td>
</tr>
<tr>
<td>
<b>Tags:</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="tags" jsId="tagsWidget" value="3dny"></div>
</td>
</tr>
<tr>
<td>
<b>Tagmode:</b>
</td>
<td>
<select id="tagmode"
jsId="tagmodeWidget"
dojoType="dijit.form.ComboBox"
autocomplete="false"
value="any"
>
<option>any</option>
<option>all</option>
</select>
</td>
</tr>
<tr>
<td>
<b>Number of Pictures:</b>
</td>
<td>
<div
id="count"
jsId="countWidget"
dojoType="dijit.form.NumberSpinner"
value="20"
constraints="{min:1,max:20,places:0}"
></div>
</td>
</tr>
<tr>
<td>
</td>
<td>
<div dojoType="dijit.form.Button" label="Search" id="searchButton" jsId="searchButtonWidget"></div>
</td>
</tr>
</tbody>
</table>
</blockquote>
<!--
The store instance used by this demo.
-->
<div dojoType="dojox.data.FlickrStore" jsId="flickrStore" label="title"></div>
<div dojoType="dojox.data.demos.widgets.FlickrViewList" id="flickrViews" jsId="flickrViewsWidget"></div>
 
<!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
 
 
<!--
This is an example of using the declarative data value definition.
These are effectively declarative variables to act as placeholders
for data values.
-->
<div dojoType="dojox.wire.ml.Data"
id="messageData"
jsId="messageData">
<div dojoType="dojox.wire.ml.DataProperty"
name="processingStart"
value="PROCESSING REQUEST">
</div>
<div dojoType="dojox.wire.ml.DataProperty"
name="processingDone"
value="PROCESSING COMPLETE">
</div>
</div>
 
 
<!--
When the search button is clicked, do the following in order:
1.) Map the widget values over to the request properties.
2.) Clear existing rows from table,
3.) Set the status to processing
4.) Invoke the fetch to repopulate the table.
-->
<div dojoType="dojox.wire.ml.Action"
trigger="searchButtonWidget"
triggerEvent="onClick">
<!--
Read in the values from the widgets and bind them to the appropriate data locations
For basic properties, you could use transfer directly, but since the text boxes are
designed to be accessed through getValue/setValue, it's better to do these as
Invocations on widget methods.
-->
<div dojoType="dojox.wire.ml.Invocation"
object="idWidget"
method="getValue"
result="dataHolder.request.query.id">
</div>
 
<!--
For the tags, we need to get the value and then perform a conversion on the result
This is done by doing an invoke, then a transfer through a converter.
-->
<div dojoType="dojox.wire.ml.Invocation"
object="tagsWidget"
method="getValue"
result="dataHolder.request.query.tags">
</div>
<div dojoType="dojox.wire.ml.Transfer"
source="dataHolder.request.query.tags"
target="dataHolder.request.query.tags"
converter="tagsInputConverter">
</div>
 
<div dojoType="dojox.wire.ml.Invocation"
object="tagmodeWidget"
method="getValue"
result="dataHolder.request.query.tagmode">
</div>
 
<div dojoType="dojox.wire.ml.Invocation"
object="countWidget"
method="getValue"
result="dataHolder.request.count">
</div>
 
 
<!-- Now invoke the actions in order. -->
<div dojoType="dojox.wire.ml.Invocation" object="flickrViewsWidget" method="clearList"></div>
<div dojoType="dojox.wire.ml.Invocation" object="statusWidget" method="setValue" parameters="messageData.processingStart"></div>
<div dojoType="dojox.wire.ml.Invocation" object="flickrStore" method="fetch" parameters="dataHolder.request"></div>
</div>
 
<!--
When the fetch processing finishes (onComplete is called), then set status to complete.
-->
<div dojoType="dojox.wire.ml.Action"
trigger="dataHolder.request"
triggerEvent="onComplete">
<div dojoType="dojox.wire.ml.Invocation" object="statusWidget" method="setValue" parameters="messageData.processingDone"></div>
</div>
 
 
<!--
On the call of the onItem function of 'dataHolder', trigger a binding/mapping of the
item's attributes to the requires parameters that are passed into addView. In this case
FlikrItemAttribute -> viewItemParam
title title
imageUrlSmall iconUrl
imageUrl imageUrl
author author
 
Then take the result of the data mapping and pass it into the invoke of the addView function on the
FlickerViews widget.
-->
<div dojoType="dojox.wire.ml.Action"
trigger="dataHolder.request" triggerEvent="onItem">
<div dojoType="dojox.wire.ml.Transfer"
source="arguments[0]" sourceStore="flickrStore"
target="dataHolder.result">
<!--
Map the attributes of the items to the property name defined
in the wire on the object in the target
-->
<div dojoType="dojox.wire.ml.ChildWire"
name="title" attribute="title"></div>
<div dojoType="dojox.wire.ml.ChildWire"
name="imageUrl" attribute="imageUrl"></div>
<div dojoType="dojox.wire.ml.ChildWire"
name="iconUrl" attribute="imageUrlSmall"></div>
<div dojoType="dojox.wire.ml.ChildWire"
name="author" attribute="author"></div>
</div>
<div dojoType="dojox.wire.ml.Invocation"
object="flickrViewsWidget" method="addView" parameters='dataHolder.result'>
</div>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/demos/markup/demo_TopicWiring.html
New file
0,0 → 1,78
<!--
This file demonstrates how the dojox.wire code can be used to do declarative
wiring of events. Specifically, it shows how you can publish and subscribe
to topics. In this case the setting of a value on one textbox triggers a
publish of that value to a topic. Another invoke is wired to fire when
values are published to that topic which is then displayed in another
textbox.
-->
<html>
<head>
<title>Sample Topic Wiring</title>
<style type="text/css">
 
@import "../../../../dijit/themes/tundra/tundra.css";
@import "../../../../dojo/resources/dojo.css";
@import "../../../../dijit/tests/css/dijitTests.css";
@import "../TableContainer.css";
 
.splitView {
width: 90%;
height: 90%;
border: 1px solid #bfbfbf;
border-collapse: separate;
}
</style>
 
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojox.wire");
dojo.require("dojox.wire.ml.Invocation");
dojo.require("dojox.wire.ml.DataStore");
dojo.require("dojox.wire.ml.Transfer");
dojo.require("dojox.wire.ml.Data");
 
dojo.require("dijit.form.TextBox");
</script>
</head>
 
<body class="tundra">
 
<!-- Layout -->
<font size="3"><b>Demo of Topic Wiring</b></font><br/><br/>
This demo shows how you can wire events to publish to a topic as well as recieve topic events
<br/>
<br/>
<table>
<tr>
<td>
<div dojoType="dijit.form.TextBox" jsId="inputField" value="" size="50"></div>
</td>
</tr>
<tr>
<td>
<div dojoType="dijit.form.TextBox" jsId="targetField1" value="" disabled="true" size="50"></div>
</td>
</tr>
</table>
 
 
<!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
<!--
Whenever a key is entered into the textbox, publish the value of it to a topic.
-->
<div dojoType="dojox.wire.ml.Action"
id="action1"
trigger="inputField"
triggerEvent="onkeyup">
<div dojoType="dojox.wire.ml.Invocation" topic="sampleTopic" parameters="inputField.value"></div>
</div>
 
<!--
Whenever a value is published to a topic, set it as the value of the textbox by calling the setValue function.
-->
<div dojoType="dojox.wire.ml.Invocation" triggerTopic="sampleTopic" object="targetField1" method="setValue" parameters="arguments[0]"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/demos/markup/demo_BasicColumnWiring.html
New file
0,0 → 1,90
<!--
This file demonstrates how the dojox.wire code can be used to do declarative
wiring of events on one item to trigger event on other items. It also shows
how you can use the Transfer object to morph data values from one format to
another. In this specific case, it maps the values from a dojo.data Datastore
item into values stored in a JavaScript Array, which is the format required for
the addRow method of the demonstration TableContainer.
 
Note that this demo expects dojo, digit, and dojox to all be peers in the same directory
in order for it to execute.
-->
<html>
<head>
<title>Sample Declarative Data Binding using ColumnWire</title>
<style type="text/css">
@import "../../../../dijit/themes/tundra/tundra.css";
@import "../../../../dojo/resources/dojo.css";
@import "../../../../dijit/tests/css/dijitTests.css";
@import "../TableContainer.css";
</style>
 
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojox.wire.ml.Invocation");
dojo.require("dojox.wire.ml.DataStore");
dojo.require("dojox.wire.ml.Transfer");
 
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojox.wire");
dojo.require("dojox.wire.demos.TableContainer");
 
//Toplevel JS Object to contain a few basics for us, such as the request to pass to the store and a stub onItem function
// to trap on for triggering other events.
dataHolder = {
//Simple object definition to get all items and sort it by the attribute 'type'.
request: {onItem: function(item){}, sort: [{attribute: "type"}]},
//Spot to store off data values as they're generated by the declarative binding.
result: null
};
</script>
</head>
 
<body class="tundra">
<!--
The store that is queried in this demo
-->
<div dojoType="dojo.data.ItemFileReadStore"
jsId="DataStore1"
url="countries.json">
</div>
 
<!--
On load of the page, invoke the fetch method of the object 'DataStore1',
get its parameters from the JS object 'sample.request
-->
<div dojoType="dojox.wire.ml.Invocation"
triggerEvent="onLoad"
object="DataStore1" method="fetch" parameters="dataHolder.request"></div>
 
<!--
Simple container widget for creating a 'table from rows defined by an array
-->
<div dojoType="dojox.wire.demos.TableContainer" jsId="r1" headers="Name,Location Type"></div>
 
<!--
On the call of the onItem function of 'dataHolder', trigger a binding/mapping of the
item's attribute 'name' and 'type' attributes to specific columns in an array. Note here that since
sourceStore is set, it treats the arguments as items from that store and accesses the attributes
appropriately. In this case 'name' becomes array entry 0, type, array entry 1, and so on.
 
Then take the result of the data mapping and pass it into the invoke of the addRow function on the
TableContainer widget.
-->
<div dojoType="dojox.wire.ml.Action"
trigger="dataHolder.request" triggerEvent="onItem">
<div dojoType="dojox.wire.ml.Transfer"
source="arguments[0]" sourceStore="DataStore1"
target="dataHolder.result">
<div dojoType="dojox.wire.ml.ColumnWire" attribute="name"></div>
<div dojoType="dojox.wire.ml.ColumnWire" attribute="type"></div>
</div>
<div dojoType="dojox.wire.ml.Invocation"
object="r1" method="addRow" parameters='dataHolder.result'>
</div>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/demos/markup/flickrDemo.css
New file
0,0 → 1,35
.flickrView {
padding: 3 3 3 3;
border-width: 1px;
border-style: solid;
border-color: #000000;
border-collapse: separate;
width: 100%;
}
 
.flickrView th {
text-align: left;
}
 
.flickrView tr {
padding: 3 3 3 3;
border-width: 1px;
border-style: solid;
border-color: #000000;
}
 
.flickrView tr td {
padding: 3 3 3 3;
border-width: 1px;
border-style: solid;
border-color: #000000;
}
 
.flickrView {
background-color: #EFEFEF;
}
 
.flickrTitle {
background-color: #CCCCCC;
}
 
/trunk/api/js/dojo1.0/dojox/wire/demos/markup/demo_ConditionalActions.html
New file
0,0 → 1,208
<!--
This file demonstrates how the dojox.wire code can be used to do declarative
wiring of events. Specifically, it shows how you can wire actions to set values
across to other widgets, but only if certain conditions are met.
-->
<html>
<head>
<title>Conditional Actions Demo</title>
<style type="text/css">
 
@import "../../../../dijit/themes/tundra/tundra.css";
@import "../../../../dojo/resources/dojo.css";
@import "../../../../dijit/tests/css/dijitTests.css";
@import "../TableContainer.css";
 
.splitView {
width: 90%;
height: 90%;
border: 1px solid #bfbfbf;
border-collapse: separate;
}
 
b {
float: left;
}
 
.rJustified {
float: right;
}
 
</style>
 
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojox.wire");
dojo.require("dojox.wire.ml.Invocation");
dojo.require("dojox.wire.ml.DataStore");
dojo.require("dojox.wire.ml.Transfer");
dojo.require("dojox.wire.ml.Data");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.CheckBox");
dojo.require("dijit.form.ComboBox");
</script>
</head>
 
<body class="tundra">
 
<!-- Layout -->
<font size="3"><b>Demo of Conditional Actions:</b></font><br/><br/>
This demo shows how you can use actions to read and set widget values, as well as have actions only occur if
if certain conditions are met, such as cloning values as they are typed from the billing address over to the
shipping address if the 'Use Same Address' checkbox is checked true.
<br/>
<br/>
<div dojoType="dojo.data.ItemFileReadStore" url="states.json" jsId="statesStore"></div>
<table width="100%">
<tr>
<td colspan="2" align="center">
Use Same Address: <div dojoType="dijit.form.CheckBox" id="useSameAddress" checked="true"></div>
</td>
</tr>
<tr>
<td>
<b>Billing Address</b>
</td>
<td>
<b>Shipping Address</b>
</td>
</tr>
 
<tr>
<td>
<b>Name:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="BillingName" name="billingname" value="" size="50"></div>
</td>
<td>
<b>Name:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="ShippingName" name="shippingname" value="" disabled="true" size="50"></div>
</td>
</tr>
<tr>
<td>
<b>Address 1:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="BillingAddress1" name="billingaddress1" value="" size="50"></div>
</td>
<td>
<b>Address 1:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="ShippingAddress1" name="shippingaddress1" value="" disabled="true" size="50"></div>
</td>
</tr>
<tr>
<td>
<b>Address 2:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="BillingAddress2" name="billingaddress2" value="" size="50"></div>
</td>
<td>
<b>Address 2:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="ShippingAddress2" name="shippingaddress2" value="" disabled="true" size="50"></div>
</td>
</tr>
<tr>
<td>
<b>City:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="BillingCity" name="billingcity" value="" size="50"></div>
</td>
<td>
<b>City:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="ShippingCity" name="shippingcity" value="" disabled="true" size="50"></div>
</td>
</tr>
<tr>
<td>
<b>State:</b> <div class="rJustified" dojoType="dijit.form.ComboBox" searchAttr="name" id="BillingState" name="billingstate" value="" store="statesStore" size="46"></div>
</td>
<td>
<b>State:</b> <div class="rJustified" dojoType="dijit.form.ComboBox" searchAttr="name" id="ShippingState" name="shippingstate" value="" store="statesStore" disabled="true" size="46"></div>
</td>
</tr>
<tr>
<td>
<b>Zip code:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="BillingZip" name="billingzip" value="" size="50"></div>
</td>
<td>
<b>Zip code:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="ShippingZip" name="shippingzip" value="" disabled="true" size="50"></div>
</td>
</tr>
</table>
 
 
<!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
 
<!--
Enable/disable the Right hand side of the shipping address view based on the checkbox events.
-->
<div dojoType="dojox.wire.ml.Action"
trigger="useSameAddress"
triggerEvent="setChecked">
<!--
Trigger a setting of the Shipping fields' input state based on the state of the checkbox.
-->
<div dojoType="dojox.wire.ml.Invocation" object="ShippingName" method="setDisabled" parameters="arguments[0]"></div>
<div dojoType="dojox.wire.ml.Invocation" object="ShippingAddress1" method="setDisabled" parameters="arguments[0]"></div>
<div dojoType="dojox.wire.ml.Invocation" object="ShippingAddress2" method="setDisabled" parameters="arguments[0]"></div>
<div dojoType="dojox.wire.ml.Invocation" object="ShippingCity" method="setDisabled" parameters="arguments[0]"></div>
<div dojoType="dojox.wire.ml.Invocation" object="ShippingState" method="setDisabled" parameters="arguments[0]"></div>
<div dojoType="dojox.wire.ml.Invocation" object="ShippingZip" method="setDisabled" parameters="arguments[0]"></div>
</div>
 
<!--
Clone the values of form fields while typing based on the setting of the checkbox.
-->
<div dojoType="dojox.wire.ml.Action"
trigger="BillingName"
triggerEvent="onkeyup">
<div dojoType="dojox.wire.ml.ActionFilter" required="useSameAddress.checked" requiredValue="true" type="boolean"></div>
<div dojoType="dojox.wire.ml.Transfer" source="BillingName.value" target="ShippingName.value"></div>
</div>
<div dojoType="dojox.wire.ml.Action"
trigger="BillingAddress1"
triggerEvent="onkeyup">
<div dojoType="dojox.wire.ml.ActionFilter" required="useSameAddress.checked" requiredValue="true" type="boolean"></div>
<div dojoType="dojox.wire.ml.Transfer" source="BillingAddress1.value" target="ShippingAddress1.value"></div>
</div>
<div dojoType="dojox.wire.ml.Action"
trigger="BillingAddress2"
triggerEvent="onkeyup">
<div dojoType="dojox.wire.ml.ActionFilter" required="useSameAddress.checked" requiredValue="true" type="boolean"></div>
<div dojoType="dojox.wire.ml.Transfer" source="BillingAddress2.value" target="ShippingAddress2.value"></div>
</div>
<div dojoType="dojox.wire.ml.Action"
trigger="BillingCity"
triggerEvent="onkeyup">
<div dojoType="dojox.wire.ml.ActionFilter" required="useSameAddress.checked" requiredValue="true" type="boolean"></div>
<div dojoType="dojox.wire.ml.Transfer" source="BillingCity.value" target="ShippingCity.value"></div>
</div>
<div dojoType="dojox.wire.ml.Action"
trigger="BillingState"
triggerEvent="onChange">
<div dojoType="dojox.wire.ml.ActionFilter" required="useSameAddress.checked" requiredValue="true" type="boolean"></div>
<div dojoType="dojox.wire.ml.Transfer" source="BillingState.value" target="ShippingState.value"></div>
</div>
 
<div dojoType="dojox.wire.ml.Action"
trigger="BillingZip"
triggerEvent="onkeyup">
<div dojoType="dojox.wire.ml.ActionFilter" required="useSameAddress.checked" requiredValue="true" type="boolean"></div>
<div dojoType="dojox.wire.ml.Transfer" source="BillingZip.value" target="ShippingZip.value"></div>
</div>
 
 
<!--
Clone the values of form fields from billing over to shipping over if the
useSameAddress checkbox is set back to true.
-->
<div dojoType="dojox.wire.ml.Action"
trigger="useSameAddress"
triggerEvent="setChecked">
<div dojoType="dojox.wire.ml.ActionFilter" required="arguments[0]" requiredValue="true" type="boolean"></div>
 
<!--
Note that this uses the basic 'property' form of copying the property over and setting it. The Wire
code supports both getX and setX functions of setting a property as well as direct access. It first looks
for the getX/setX functions and if present, uses them. If missing, it will just do direct access. Because
of the standard getValue/setValue API of dijit form widgets, transfers work well and are compact.
-->
<div dojoType="dojox.wire.ml.Transfer" source="BillingName.value" target="ShippingName.value"></div>
<div dojoType="dojox.wire.ml.Transfer" source="BillingAddress1.value" target="ShippingAddress1.value"></div>
<div dojoType="dojox.wire.ml.Transfer" source="BillingAddress2.value" target="ShippingAddress2.value"></div>
<div dojoType="dojox.wire.ml.Transfer" source="BillingCity.value" target="ShippingCity.value"></div>
<div dojoType="dojox.wire.ml.Transfer" source="BillingState.value" target="ShippingState.value"></div>
<div dojoType="dojox.wire.ml.Transfer" source="BillingZip.value" target="ShippingZip.value"></div>
</div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/demos/markup/states.json
New file
0,0 → 1,56
{"identifier":"abbreviation",
"label": "label",
"items": [
{"name":"Alabama", "label":"Alabama","abbreviation":"AL"},
{"name":"Alaska", "label":"Alaska","abbreviation":"AK"},
{"name":"American Samoa", "label":"American Samoa","abbreviation":"AS"},
{"name":"Arizona", "label":"Arizona","abbreviation":"AZ"},
{"name":"Arkansas", "label":"Arkansas","abbreviation":"AR"},
{"name":"California", "label":"California","abbreviation":"CA"},
{"name":"Colorado", "label":"Colorado","abbreviation":"CO"},
{"name":"Connecticut", "label":"Connecticut","abbreviation":"CT"},
{"name":"Delaware", "label":"Delaware","abbreviation":"DE"},
{"name":"Florida", "label":"Florida","abbreviation":"FL"},
{"name":"Georgia", "label":"Georgia","abbreviation":"GA"},
{"name":"Hawaii", "label":"Hawaii","abbreviation":"HI"},
{"name":"Idaho", "label":"Idaho","abbreviation":"ID"},
{"name":"Illinois", "label":"Illinois","abbreviation":"IL"},
{"name":"Indiana", "label":"Indiana","abbreviation":"IN"},
{"name":"Iowa", "label":"Iowa","abbreviation":"IA"},
{"name":"Kansas", "label":"Kansas","abbreviation":"KS"},
{"name":"Kentucky", "label":"Kentucky","abbreviation":"KY"},
{"name":"Louisiana", "label":"Louisiana","abbreviation":"LA"},
{"name":"Maine", "label":"Maine","abbreviation":"ME"},
{"name":"Marshall Islands", "label":"Marshall Islands","abbreviation":"MH"},
{"name":"Maryland", "label":"Maryland","abbreviation":"MD"},
{"name":"Massachusetts", "label":"Massachusetts","abbreviation":"MA"},
{"name":"Michigan", "label":"Michigan","abbreviation":"MI"},
{"name":"Minnesota", "label":"Minnesota","abbreviation":"MN"},
{"name":"Mississippi", "label":"Mississippi","abbreviation":"MS"},
{"name":"Missouri", "label":"Missouri","abbreviation":"MO"},
{"name":"Montana", "label":"Montana","abbreviation":"MT"},
{"name":"Nebraska", "label":"Nebraska","abbreviation":"NE"},
{"name":"Nevada", "label":"Nevada","abbreviation":"NV"},
{"name":"New Hampshire", "label":"New Hampshire","abbreviation":"NH"},
{"name":"New Jersey", "label":"New Jersey","abbreviation":"NJ"},
{"name":"New Mexico", "label":"New Mexico","abbreviation":"NM"},
{"name":"New York", "label":"New York","abbreviation":"NY"},
{"name":"North Carolina", "label":"North Carolina","abbreviation":"NC"},
{"name":"North Dakota", "label":"North Dakota","abbreviation":"ND"},
{"name":"Ohio", "label":"Ohio","abbreviation":"OH"},
{"name":"Oklahoma", "label":"Oklahoma","abbreviation":"OK"},
{"name":"Oregon", "label":"Oregon","abbreviation":"OR"},
{"name":"Pennsylvania", "label":"Pennsylvania","abbreviation":"PA"},
{"name":"Rhode Island", "label":"Rhode Island","abbreviation":"RI"},
{"name":"South Carolina", "label":"South Carolina","abbreviation":"SC"},
{"name":"South Dakota", "label":"South Dakota","abbreviation":"SD"},
{"name":"Tennessee", "label":"Tennessee","abbreviation":"TN"},
{"name":"Texas", "label":"Texas","abbreviation":"TX"},
{"name":"Utah", "label":"Utah","abbreviation":"UT"},
{"name":"Vermont", "label":"Vermont","abbreviation":"VT"},
{"name":"Virginia", "label":"Virginia","abbreviation":"VA"},
{"name":"Washington", "label":"Washington","abbreviation":"WA"},
{"name":"West Virginia", "label":"West Virginia","abbreviation":"WV"},
{"name":"Wisconsin", "label":"Wisconsin","abbreviation":"WI"},
{"name":"Wyoming", "label":"Wyoming","abbreviation":"WY"}
]}
/trunk/api/js/dojo1.0/dojox/wire/demos/TableContainer.css
New file
0,0 → 1,30
.tablecontainer {
padding: 3 3 3 3;
border-width: 1px;
border-style: solid;
border-color: #000000;
border-collapse: separate;
}
 
.tablecontainer th {
text-align: left;
}
 
.tablecontainer tr {
padding: 3 3 3 3;
border-width: 1px;
border-style: solid;
border-color: #000000;
}
 
.tablecontainer tr td {
padding: 3 3 3 3;
border-width: 1px;
border-style: solid;
border-color: #000000;
}
 
.alternate {
background-color: #EEEEEE;
}
 
/trunk/api/js/dojo1.0/dojox/wire/ml/Transfer.js
New file
0,0 → 1,359
if(!dojo._hasResource["dojox.wire.ml.Transfer"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.ml.Transfer"] = true;
dojo.provide("dojox.wire.ml.Transfer");
dojo.provide("dojox.wire.ml.ChildWire");
dojo.provide("dojox.wire.ml.ColumnWire");
dojo.provide("dojox.wire.ml.NodeWire");
dojo.provide("dojox.wire.ml.SegmentWire");
 
dojo.require("dijit._Widget");
dojo.require("dijit._Container");
dojo.require("dojox.wire._base");
dojo.require("dojox.wire.ml.Action");
 
dojo.declare("dojox.wire.ml.Transfer", dojox.wire.ml.Action, {
// summary:
// A widget to transfer values through source and target Wires
// description:
// This widget represents a controller task to transfer a value from
// a source to a target, through a source and a target Wires, when
// an event (a function) or a topic is issued.
// If this widget has child ChildWire widgets, their _addWire()
// methods are called to add Wire arguments to a source or a target
// Wire.
// source:
// A source object and/or property
// sourceStore:
// A data store for a source data item
// sourceAttribute:
// An attribute of a source data item
// sourcePath:
// A simplified XPath to a source property of an XML element
// type:
// A type of the value to be transferred
// converter:
// A class name of a converter for the value to be transferred
// target:
// A target object and/or property
// targetStore:
// A data store for a target data item
// targetAttribute:
// An attribute of a target data item
// targetPath:
// A simplified XPath to a target property of an XML element
source: "",
sourceStore: "",
sourceAttribute: "",
sourcePath: "",
type: "",
converter: "",
delimiter: "",
target: "",
targetStore: "",
targetAttribute: "",
targetPath: "",
 
_run: function(){
// summary:
// Transfer a value from a source to a target
// description:
// First, Wires for a source and a target are created from attributes.
// Then, a value is obtained by getValue() of the source Wire is set
// by setValue() of the target Wire.
// The arguments to this method is passed to getValue() and setValue()
// of Wires, so that they can be used to identify the root objects off
// the arguments.
var sourceWire = this._getWire("source");
var targetWire = this._getWire("target");
dojox.wire.transfer(sourceWire, targetWire, arguments);
},
 
_getWire: function(/*String*/which){
// summary:
// Build Wire arguments from attributes
// description:
// Arguments object for a source or a target Wire, specified by
// 'which' argument, are build from corresponding attributes,
// including '*Store' (for 'dataStore'), '*Attribute'
// (for 'attribute), '*Path' (for 'path'), 'type' and 'converter'.
// 'source' or 'target' attribute is parsed as:
// "object_id.property_name[.sub_property_name...]"
// If 'source' or 'target' starts with "arguments", 'object'
// argument for a Wire is set to null, so that the root object is
// given as an event or topic arguments.
// If this widget has child ChildWire widgets with a corresponding
// 'which' attribute, their _addWire() methods are called to add
// additional Wire arguments and nested Wire is created,
// specifying the Wire defined by this widget to 'object' argument.
// which:
// Which Wire arguments to build, "source" or "target"
// returns:
// Wire arguments object
var args = undefined;
if(which == "source"){
args = {
object: this.source,
dataStore: this.sourceStore,
attribute: this.sourceAttribute,
path: this.sourcePath,
type: this.type,
converter: this.converter
};
}else{ // "target"
args = {
object: this.target,
dataStore: this.targetStore,
attribute: this.targetAttribute,
path: this.targetPath
};
}
if(args.object){
if(args.object.length >= 9 && args.object.substring(0, 9) == "arguments"){
args.property = args.object.substring(9);
args.object = null;
}else{
var i = args.object.indexOf('.');
if(i < 0){
args.object = dojox.wire.ml._getValue(args.object);
}else{
args.property = args.object.substring(i + 1);
args.object = dojox.wire.ml._getValue(args.object.substring(0, i));
}
}
}
if(args.dataStore){
args.dataStore = dojox.wire.ml._getValue(args.dataStore);
}
var childArgs = undefined;
var children = this.getChildren();
for(var i in children){
var child = children[i];
if(child instanceof dojox.wire.ml.ChildWire && child.which == which){
if(!childArgs){
childArgs = {};
}
child._addWire(this, childArgs);
}
}
if(childArgs){ // make nested Wires
childArgs.object = dojox.wire.create(args);
childArgs.dataStore = args.dataStore;
args = childArgs;
}
return args; //Object
}
});
 
dojo.declare("dojox.wire.ml.ChildWire", dijit._Widget, {
// summary:
// A widget to add a child wire
// description:
// Attributes of this widget are used to add a child Wire to
// a composite Wire of the parent Transfer widget.
// which:
// Which Wire to add a child Wire, "source" or "target", default to
// "source"
// object:
// A root object for the value
// property:
// A property for the value
// type:
// A type of the value
// converter:
// A class name of a converter for the value
// attribute:
// A data item attribute for the value
// path:
// A simplified XPath for the value
// name:
// A composite property name
which: "source",
object: "",
property: "",
type: "",
converter: "",
attribute: "",
path: "",
name: "",
 
_addWire: function(/*Transfer*/parent, /*Object*/args){
// summary:
// Add a child Wire to Wire arguments
// description:
// If 'name' attribute is specified, a child Wire is added as
// the named property of 'children' object of 'args'.
// Otherwise, a child Wire is added to 'children' array of 'args'.
// parent:
// A parent Transfer widget
// args:
// Wire arguments
if(this.name){ // object
if(!args.children){
args.children = {};
}
args.children[this.name] = this._getWire(parent);
}else{ // array
if(!args.children){
args.children = [];
}
args.children.push(this._getWire(parent));
}
},
 
_getWire: function(/*Transfer*/parent){
// summary:
// Build child Wire arguments from attributes
// description:
// Arguments object for a child Wire are build from attributes,
// including 'object', 'property', 'type', 'converter',
// 'attribute' and 'path'.
// parent:
// A parent Transfer widget
// returns:
// Wire arguments object
return {
object: (this.object ? dojox.wire.ml._getValue(this.object) : undefined),
property: this.property,
type: this.type,
converter: this.converter,
attribute: this.attribute,
path: this.path
}; //Object
}
});
 
dojo.declare("dojox.wire.ml.ColumnWire", dojox.wire.ml.ChildWire, {
// summary:
// A widget to add a column wire
// description:
// Attributes of this widget are used to add a column Wire to
// a TableAdapter of the parent Transfer widget.
// column:
// A column name
column: "",
 
_addWire: function(/*Transfer*/parent, /*Object*/args){
// summary:
// Add a column Wire to Wire arguments
// description:
// If 'column' attribute is specified, a column Wire is added as
// the named property of 'columns' object of 'args'.
// Otherwise, a column Wire is added to 'columns' array of 'args'.
// parent:
// A parent Transfer widget
// args:
// Wire arguments
if(this.column){ // object
if(!args.columns){
args.columns = {};
}
args.columns[this.column] = this._getWire(parent);
}else{ // array
if(!args.columns){
args.columns = [];
}
args.columns.push(this._getWire(parent));
}
}
});
 
dojo.declare("dojox.wire.ml.NodeWire", [dojox.wire.ml.ChildWire, dijit._Container], {
// summary:
// A widget to add node wires
// description:
// Attributes of this widget are used to add node Wires to
// a TreeAdapter of the parent Transfer widget.
// titleProperty:
// A property for the node title
// titleAttribute:
// A data item attribute for the node title
// titlePath:
// A simplified XPath for the node title
titleProperty: "",
titleAttribute: "",
titlePath: "",
 
_addWire: function(/*Transfer*/parent, /*Object*/args){
// summary:
// Add node Wires to Wire arguments
// description:
// Node Wires are added to 'nodes' array of 'args'.
// parent:
// A parent Transfer widget
// args:
// Wire arguments
if(!args.nodes){
args.nodes = [];
}
args.nodes.push(this._getWires(parent));
},
 
_getWires: function(/*Transfer*/parent){
// summary:
// Build node Wires arguments from attributes
// description:
// Arguments object for 'node' Wire are build from attributes,
// including 'object', 'property', 'type', 'converter',
// 'attribute' and 'path'.
// Arguments object for 'title' Wire are build from another set of
// attributes, 'titleProperty', 'titleAttribute' and 'titlePath'.
// If this widget has child NodeWire widgets, their _getWires()
// methods are called recursively to build 'children' array of
// 'args'.
// parent:
// A parent Transfer widget
// returns:
// Wire arguments object
var args = {
node: this._getWire(parent),
title: {
type: "string",
property: this.titleProperty,
attribute: this.titleAttribute,
path: this.titlePath
}
};
var childArgs = [];
var children = this.getChildren();
for(var i in children){
var child = children[i];
if(child instanceof dojox.wire.ml.NodeWire){
childArgs.push(child._getWires(parent));
}
}
if(childArgs.length > 0){
args.children = childArgs;
}
return args; //Object
}
});
 
dojo.declare("dojox.wire.ml.SegmentWire", dojox.wire.ml.ChildWire, {
// summary:
// A widget to add a segment wire
// description:
// Attributes of this widget are used to add a segment Wire to
// a TextAdapter of the parent Transfer widget.
 
_addWire: function(/*Transfer*/parent, /*Object*/args){
// summary:
// Add a segument Wire to Wire arguments
// description:
// A segment Wire is added to 'segments' array of 'args'.
// If 'parent' has 'delimiter' attribute, it is used for
// 'delimiter' property of 'args'.
// parent:
// A parent Transfer widget
// args:
// Wire arguments
if(!args.segments){
args.segments = [];
}
args.segments.push(this._getWire(parent));
if(parent.delimiter && !args.delimiter){
args.delimiter = parent.delimiter;
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/ml/DataStore.js
New file
0,0 → 1,116
if(!dojo._hasResource["dojox.wire.ml.DataStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.ml.DataStore"] = true;
dojo.provide("dojox.wire.ml.DataStore");
 
dojo.require("dijit._Widget");
dojo.require("dojox.wire._base");
 
dojo.declare("dojox.wire.ml.DataStore", dijit._Widget, {
// summary:
// A widget for a data store
// description:
// This widget represents a data store of 'storeClass' attribute.
// storeClass:
// A class name of a data store
storeClass: "",
 
postCreate: function(){
// summary:
// Call _createStore()
// description:
// See _createStore().
this.store = this._createStore();
},
 
_createStore: function(){
// summary:
// Create a data store
// desription:
// A data store of 'storeClass' is created with arguments
// specified with attributes.
// returns:
// A data store
if(!this.storeClass){
return null; //null
}
var storeClass = dojox.wire._getClass(this.storeClass);
if(!storeClass){
return null; //null
}
var args = {};
var attributes = this.domNode.attributes;
for(var i = 0; i < attributes.length; i++){
var a = attributes.item(i);
if(a.specified && !this[a.nodeName]){
args[a.nodeName] = a.nodeValue;
}
}
return new storeClass(args); //Object
},
 
getFeatures: function(){
// summary:
// Call getFeatures() method of a data store
// description:
// See dojo.data.api.Read.getFeatures().
// returns:
// A features object
return this.store.getFeatures(); //Object
},
 
fetch: function(/*Object*/request){
// summary:
// Call fetch() method of a data store
// description:
// See dojo.data.api.Read.fetch().
// request:
// A request object
// returns:
// A request object
return this.store.fetch(request); //Object
},
 
save: function(/*Object*/args){
// summary:
// Call save() method of a data store
// description:
// See dojo.data.api.Write.save().
// args:
// A save arguments object
this.store.save(args);
},
 
newItem: function(/*Object*/args){
// summary:
// Call newItem() method of a data store
// description:
// See dojo.data.api.Write.newItem().
// args:
// A new item arguments object
// returns:
// A new item
return this.store.newItem(args); //Object
},
 
deleteItem: function(/*Object*/item){
// summary:
// Call deleteItem() method of a data store
// description:
// See dojo.data.api.Write.deleteItem().
// returns:
// A boolean
return this.store.deleteItem(item); //Boolean
},
 
revert: function(){
// summary:
// Call revert() method of a data store
// description:
// See dojo.data.api.Write.revert().
// returns:
// A boolean
return this.store.revert(); //Boolean
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/ml/Data.js
New file
0,0 → 1,143
if(!dojo._hasResource["dojox.wire.ml.Data"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.ml.Data"] = true;
dojo.provide("dojox.wire.ml.Data");
dojo.provide("dojox.wire.ml.DataProperty");
 
dojo.require("dijit._Widget");
dojo.require("dijit._Container");
dojo.require("dojox.wire.ml.util");
 
dojo.declare("dojox.wire.ml.Data", [dijit._Widget, dijit._Container], {
// summary:
// A widget for a data object
// description:
// This widget represents an object with '_properties' property.
// If child 'DataProperty' widgets exist, they are used to initialize
// propertiy values of '_properties' object.
 
startup: function(){
// summary:
// Call _initializeProperties()
// description:
// See _initializeProperties().
this._initializeProperties();
},
 
_initializeProperties: function(/*Boolean*/reset){
// summary:
// Initialize a data object
// description:
// If this widget has child DataProperty widgets, their getValue()
// methods are called and set the return value to a property
// specified by 'name' attribute of the child widgets.
// reset:
// A boolean to reset current properties
if(!this._properties || reset){
this._properties = {};
}
var children = this.getChildren();
for(var i in children){
var child = children[i];
if((child instanceof dojox.wire.ml.DataProperty) && child.name){
this.setPropertyValue(child.name, child.getValue());
}
}
},
 
getPropertyValue: function(/*String*/property){
// summary:
// Return a property value
// description:
// This method returns the value of a property, specified with
// 'property' argument, in '_properties' object.
// property:
// A property name
// returns:
// A property value
return this._properties[property]; //anything
},
 
setPropertyValue: function(/*String*/property, /*anything*/value){
// summary:
// Store a property value
// description:
// This method stores 'value' as a property, specified with
// 'property' argument, in '_properties' object.
// property:
// A property name
// value:
// A property value
this._properties[property] = value;
}
});
 
dojo.declare("dojox.wire.ml.DataProperty", [dijit._Widget, dijit._Container], {
// summary:
// A widget to define a data property
// description:
// Attributes of this widget are used to add a property to the parent
// Data widget.
// 'type' attribute specifies one of "string", "number", "boolean",
// "array", "object" and "element" (DOM Element)
// (default to "string").
// If 'type' is "array" or "object", child DataProperty widgets are
// used to initialize the array elements or the object properties.
// name:
// A property name
// type:
// A property type name
// value:
// A property value
name: "",
type: "",
value: "",
 
getValue: function(){
// summary:
// Returns a property value
// description:
// If 'type' is specified, 'value' attribute is converted to
// the specified type and returned.
// Otherwise, 'value' attribute is returned as is.
// returns:
// A property value
var value = this.value;
if(this.type){
if(this.type == "number"){
value = parseInt(value);
}else if(this.type == "boolean"){
value = (value == "true");
}else if(this.type == "array"){
value = [];
var children = this.getChildren();
for(var i in children){
var child = children[i];
if(child instanceof dojox.wire.ml.DataProperty){
value.push(child.getValue());
}
}
}else if(this.type == "object"){
value = {};
var children = this.getChildren();
for(var i in children){
var child = children[i];
if((child instanceof dojox.wire.ml.DataProperty) && child.name){
value[child.name] = child.getValue();
}
}
}else if(this.type == "element"){
value = new dojox.wire.ml.XmlElement(value);
var children = this.getChildren();
for(var i in children){
var child = children[i];
if((child instanceof dojox.wire.ml.DataProperty) && child.name){
value.setPropertyValue(child.name, child.getValue());
}
}
}
}
return value; //anything
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/ml/Invocation.js
New file
0,0 → 1,171
if(!dojo._hasResource["dojox.wire.ml.Invocation"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.ml.Invocation"] = true;
dojo.provide("dojox.wire.ml.Invocation");
 
dojo.require("dojox.wire.ml.Action");
 
dojo.declare("dojox.wire.ml.Invocation", dojox.wire.ml.Action, {
// summary:
// A widget to invoke a method or publish a topic
// description:
// This widget represents a controller task to invoke a method or
// publish a topic when an event (a function) or a topic is issued.
// object:
// A scope of a method to invoke
// method:
// A name of a method to invoke
// topic:
// A name of a topic to publish
// parameters:
// Arguments for the method or the topic
// result:
// A property to store a return value of the method call
// error:
// A property to store an error on the method call
object: "",
method: "",
topic: "",
parameters: "",
result: "",
error: "",
 
_run: function(){
// summary:
// Invoke a method or publish a topic
// description:
// If 'topic' is specified, the topic is published with arguments
// specified to 'parameters'.
// If 'method' and 'object' are specified, the method is invoked
// with arguments specified to 'parameters' and set the return
// value to a property specified to 'result'.
// 'object', 'parameters' and 'result' can specify properties of
// a widget or an DOM element with the dotted notation.
// If 'parameters' are omitted, the arguments to this method are
// passed as is.
if(this.topic){
var args = this._getParameters(arguments);
try{
dojo.publish(this.topic, args);
this.onComplete();
}catch(e){
this.onError(e);
}
}else if(this.method){
var scope = (this.object ? dojox.wire.ml._getValue(this.object) : dojo.global);
if(!scope){
return; //undefined
}
var args = this._getParameters(arguments);
var func = scope[this.method];
if(!func){
func = scope.callMethod;
if(!func){
return; //undefined
}
args = [this.method, args];
}
try{
var connected = false;
if(scope.getFeatures){
var features = scope.getFeatures();
if((this.method == "fetch" && features["dojo.data.api.Read"]) ||
(this.method == "save" && features["dojo.data.api.Write"])){
var arg = args[0];
if(!arg.onComplete){
arg.onComplete = function(){};
}
//dojo.connect(arg, "onComplete", this, "onComplete");
this.connect(arg, "onComplete", "onComplete");
if(!arg.onError){
arg.onError = function(){};
}
//dojo.connect(arg, "onError", this, "onError");
this.connect(arg, "onError", "onError");
connected = true;
}
}
var r = func.apply(scope, args);
if(!connected){
if(r && (r instanceof dojo.Deferred)){
var self = this;
r.addCallbacks(
function(result){self.onComplete(result);},
function(error){self.onError(error);}
);
}else{
this.onComplete(r);
}
}
}catch(e){
this.onError(e);
}
}
},
 
onComplete: function(/*anything*/result){
// summary:
// A function called when the method or the topic publish
// completed
// description:
// If 'result' attribute is specified, the result object also set
// to the specified property.
// result:
// The return value of a method or undefined for a topic
if(this.result){
dojox.wire.ml._setValue(this.result, result);
}
if(this.error){ // clear error
dojox.wire.ml._setValue(this.error, "");
}
},
 
onError: function(/*anything*/error){
// summary:
// A function called on an error occurs
// description:
// If 'error' attribute is specified, the error object also set to
// the specified property.
// error:
// The exception or error occurred
if(this.error){
if(error && error.message){
error = error.message;
}
dojox.wire.ml._setValue(this.error, error);
}
},
 
_getParameters: function(/*Array*/args){
// summary:
// Returns arguments to a method or topic to invoke
// description:
// This method retunrs an array of arguments specified by
// 'parameters' attribute, a comma-separated list of IDs and
// their properties in a dotted notation.
// If 'parameters' are omitted, the original arguments are
// used.
// args:
// Arguments to a trigger event or topic
if(!this.parameters){
// use arguments as is
return args; //Array
}
var parameters = [];
var list = this.parameters.split(",");
if(list.length == 1){
var parameter = dojox.wire.ml._getValue(list[0], args);
if(dojo.isArray(parameter)){
parameters = parameter;
}else{
parameters.push(parameter);
}
}else{
for(var i in list){
parameters.push(dojox.wire.ml._getValue(list[i], args));
}
}
return parameters; //Array
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/ml/Action.js
New file
0,0 → 1,225
if(!dojo._hasResource["dojox.wire.ml.Action"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.ml.Action"] = true;
dojo.provide("dojox.wire.ml.Action");
dojo.provide("dojox.wire.ml.ActionFilter");
 
dojo.require("dijit._Widget");
dojo.require("dijit._Container");
dojo.require("dojox.wire.Wire");
dojo.require("dojox.wire.ml.util");
 
dojo.declare("dojox.wire.ml.Action", [dijit._Widget, dijit._Container], {
// summary:
// A base widget to "run" a task on an event or a topic
// description:
// This widget represents a controller task to be run when an event
// (a function) or a topic is issued.
// Sub-classes must implement _run() method to implement their tasks.
// 'trigger' specifies an event scope, an ID of a widget or an DOM
// element, or its property with the optional dotted notation.
// If this widget has child ActionFilter widgets, their filter()
// methods are called with the arguments to the event or the topic.
// If one of filter() methods returns false, run() won't be invoked.
// This widget also can serve as a composite task to run child
// Actions on an event or a topic specified to this widget.
// trigger:
// An event scope
// triggerEvent:
// An event (function) name
// triggerTopic:
// A topic name
trigger: "",
triggerEvent: "",
triggerTopic: "",
 
postCreate: function(){
// summary:
// Call _connect()
// description:
// See _connect().
this._connect();
},
 
_connect: function(){
// summary:
// Connect run() method to an event or a topic
// description:
// If 'triggerEvent' and 'trigger' are specified, connect() is
// used to set up run() to be called on the event.
// If 'triggerTopic' is specified, subscribe() is used to set up
// run() to be called on the topic.
if(this.triggerEvent){
if(this.trigger){
var scope = dojox.wire.ml._getValue(this.trigger);
if(scope){
if(!scope[this.triggerEvent]){
// set a dummy function for an anonymous object
scope[this.triggerEvent] = function(){};
}
this._triggerHandle = dojo.connect(scope, this.triggerEvent, this, "run");
}
}else{
var event = this.triggerEvent.toLowerCase();
if(event == "onload"){
var self = this;
dojo.addOnLoad(function(){
self._run.apply(self, arguments);
});
}
}
}else if(this.triggerTopic){
this._triggerHandle = dojo.subscribe(this.triggerTopic, this, "run");
}
},
 
_disconnect: function(){
// summary:
// Disconnect run() method from an event or a topic
// description:
// If 'triggerEvent' and 'trigger' are specified, disconnect() is
// used to set up run() not to be called on the event.
// If 'triggerTopic' is specified, unsubscribe() is used to set up
// run() not to be called on the topic.
if(this._triggerHandle){
if(this.triggerTopic){
dojo.unsubscribe(this.triggerTopic, this._triggerHandle);
}else{
dojo.disconnect(this._triggerHandle);
}
}
},
 
run: function(){
// summary:
// Run a task
// description:
// This method calls filter() method of child ActionFilter
// widgets.
// If one of them returns false, this method returns.
// Otherwise, _run() method is called.
var children = this.getChildren();
for(var i in children){
var child = children[i];
if(child instanceof dojox.wire.ml.ActionFilter){
if(!child.filter.apply(child, arguments)){
return;
}
}
}
this._run.apply(this, arguments);
},
 
_run: function(){
// summary:
// Call run() methods of child Action widgets
// description:
// If this widget has child Action widgets, their run() methods
// are called.
var children = this.getChildren();
for(var i in children){
var child = children[i];
if(child instanceof dojox.wire.ml.Action){
child.run.apply(child, arguments);
}
}
},
 
uninitialize: function(){
// summary:
// Over-ride of base widget unitialize function to do some connection cleanup.
this._disconnect();
return true;
}
});
 
dojo.declare("dojox.wire.ml.ActionFilter", dijit._Widget, {
// summary:
// A widget to define a filter for the parent Action to run
// description:
// This base class checks a required property specified with
// 'required' attribute.
// If 'message' is specified, the message is set to a property
// specified with 'error'.
// Subclasses may implement their own filter() method.
// required:
// A property required
// requiredValue:
// Optional. A specific value the property is required to have. If this isn't provided
// than any non-false/non-null value of the required propery will cause this filter
// to pass.
// type:
// Optional. A specific type to compare the values as (if requiredValue is set)
// Valid values for type are boolean, int, string. Default is string.
// message:
// An error message to emit if the filter doesn't execute due to property mismatch.
// error:
// A property to store an error due to property mismatch.
required: "",
requiredValue: "",
type: "",
message: "",
error: "",
 
 
filter: function(){
// summary:
// Check if a required property is specified. Also, if provided, check to see
// if the required property contains a specific value.
// description:
// If a value is undefined for a property, specified with
// 'required', this method returns false.
// If the value for a property is defined, but there isn't a requiredValue for it
// then any non-false value will cause the method to return true.
// if requiredValue is set, then filter compares that value with the value from
// the required property and returns true if and only if they match.
// The type option just allows for a way to convert the required property values
// into a proper form for comparison (boolean, number, etc).
// If 'message' is specified, it is set to a proeprty specified
// with 'error' or shown with alert().
// If 'required' starts with "arguments", a property of
// the method arguments are checked.
// returns:
// True if a required property is specified (and if requiredValue is specified,
// that they match), otherwise false
if(this.required === ""){
return true; //Boolean
}else{
var value = dojox.wire.ml._getValue(this.required, arguments);
if(this.requiredValue === ""){
//Just see if there's a value, nothing to compare it to.
if(value){
return true; //Boolean
}
}else{
//See if we need to type convert.
var reqValue = this.requiredValue;
if(this.type !== ""){
var lType = this.type.toLowerCase();
if(lType === "boolean"){
if(reqValue.toLowerCase() === "false"){
reqValue = false;
}else{
reqValue = true;
}
}else if(lType === "number"){
reqValue = parseInt(reqValue, 10);
}
}
if(value === reqValue){
return true; //boolean
}
}
}
if(this.message){
if(this.error){
dojox.wire.ml._setValue(this.error, this.message);
}else{
alert(this.message);
}
}
return false; //Boolean
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/ml/util.js
New file
0,0 → 1,295
if(!dojo._hasResource["dojox.wire.ml.util"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.ml.util"] = true;
dojo.provide("dojox.wire.ml.util");
 
dojo.require("dojox.data.dom");
dojo.require("dojox.wire.Wire");
 
dojox.wire.ml._getValue = function(/*String*/source, /*Array*/args){
// summary:
// Return a value
// description:
// This method obtains an object by an ID of a widget or an DOM
// element.
// If 'source' specifies a dotted notation to its property, a Wire is
// used to get the object property.
// If 'source' starts with "arguments", 'args' is used as a root
// object for the Wire.
// source:
// A string to specify an object and its property
// args:
// An optional arguments array
// returns:
// A value
if(!source){
return undefined; //undefined
}
var property = undefined;
if(args && source.length >= 9 && source.substring(0, 9) == "arguments"){
property = source.substring(9);
return new dojox.wire.Wire({property: property}).getValue(args);
}
var i = source.indexOf('.');
if(i >= 0){
property = source.substring(i + 1);
source = source.substring(0, i);
}
var object = (dijit.byId(source) || dojo.byId(source) || dojo.getObject(source));
if(!object){
return undefined; //undefined
}
if(!property){
return object; //Object
}else{
return new dojox.wire.Wire({object: object, property: property}).getValue(); //anything
}
};
 
dojox.wire.ml._setValue = function(/*String*/target, /*anything*/value){
// summary:
// Store a value
// description:
// This method stores a value by an ID of a widget or an DOM
// element with a dotted notation to its property, using a Wire.
// target:
// A string to specify an object and its property
// value:
// A value
if(!target){
return; //undefined
}
var i = target.indexOf('.');
if(i < 0){
return; //undefined
}
var object = this._getValue(target.substring(0, i));
if(!object){
return; //undefined
}
var property = target.substring(i + 1);
new dojox.wire.Wire({object: object, property: property}).setValue(value);
};
 
dojo.declare("dojox.wire.ml.XmlElement", null, {
// summary:
// An object wrapping an XML element
// description:
// This class represents an XML element.
 
constructor: function(/*Element||String*/element){
// summary:
// Initialize with an XML element or a tag name
// element:
// An XML element or a tag name
if(dojo.isString(element)){
element = this._getDocument().createElement(element);
}
this.element = element;
},
getPropertyValue: function(/*String*/property){
// summary:
// Return a property value
// description:
// If 'property' starts with '@', the attribute value is returned.
// If 'property' specifies "text()", the value of the first child
// text is returned.
// Otherwise, child elements of the tag name specified with
// 'property' are returned.
// property:
// A property name
// returns:
// A property value
var value = undefined;
if(!this.element){
return value; //undefined
}
if(!property){
return value; //undefined
}
 
if(property.charAt(0) == '@'){
var attribute = property.substring(1);
value = this.element.getAttribute(attribute);
}else if(property == "text()"){
var text = this.element.firstChild;
if(text){
value = text.nodeValue;
}
}else{ // child elements
var elements = [];
for(var i = 0; i < this.element.childNodes.length; i++){
var child = this.element.childNodes[i];
if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == property){
elements.push(new dojox.wire.ml.XmlElement(child));
}
}
if(elements.length > 0){
if(elements.length === 1){
value = elements[0];
}else{
value = elements;
}
}
}
return value; //String||Array||XmlElement
},
 
setPropertyValue: function(/*String*/property, /*String||Array||XmlElement*/value){
// summary:
// Store a property value
// description:
// If 'property' starts with '@', 'value' is set to the attribute.
// If 'property' specifies "text()", 'value' is set as the first
// child text.
// If 'value' is a string, a child element of the tag name
// specified with 'property' is created and 'value' is set as
// the first child text of the child element.
// Otherwise, 'value' is set to as child elements.
// property:
// A property name
// value:
// A property value
if(!this.element){
return; //undefined
}
if(!property){
return; //undefined
}
 
if(property.charAt(0) == '@'){
var attribute = property.substring(1);
if(value){
this.element.setAttribute(attribute, value);
}else{
this.element.removeAttribute(attribute);
}
}else if(property == "text()"){
while(this.element.firstChild){
this.element.removeChild(this.element.firstChild);
}
if(value){
var text = this._getDocument().createTextNode(value);
this.element.appendChild(text);
}
}else{ // child elements
var nextChild = null;
for(var i = this.element.childNodes.length - 1; i >= 0; i--){
var child = this.element.childNodes[i];
if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == property){
if(!nextChild){
nextChild = child.nextSibling;
}
this.element.removeChild(child);
}
}
if(value){
if(dojo.isArray(value)){
for(var i in value){
var e = value[i];
if(e.element){
this.element.insertBefore(e.element, nextChild);
}
}
}else if(value instanceof dojox.wire.ml.XmlElement){
if(value.element){
this.element.insertBefore(value.element, nextChild);
}
}else{ // assume string
var child = this._getDocument().createElement(property);
var text = this._getDocument().createTextNode(value);
child.appendChild(text);
this.element.insertBefore(child, nextChild);
}
}
}
},
 
toString: function(){
// summary:
// Return a value of the first text child of the element
// description:
// A value of the first text child of the element is returned.
// returns:
// A value of the first text child of the element
var s = "";
if(this.element){
var text = this.element.firstChild;
if(text){
s = text.nodeValue;
}
}
return s; //String
},
 
toObject: function(){
// summary:
// Return an object representation of the element
// description:
// An object with properties for child elements, attributes and
// text is returned.
// returns:
// An object representation of the element
if(!this.element){
return null; //null
}
var text = "";
var obj = {};
var elements = 0;
for(var i = 0; i < this.element.childNodes.length; i++){
var child = this.element.childNodes[i];
if(child.nodeType === 1 /* ELEMENT_NODE */){
elements++;
var o = new dojox.wire.ml.XmlElement(child).toObject();
var name = child.nodeName;
var p = obj[name];
if(!p){
obj[name] = o;
}else if(dojo.isArray(p)){
p.push(o);
}else{
obj[name] = [p, o]; // make them array
}
}else if(child.nodeType === 3 /* TEXT_NODE */ ||
child.nodeType === 4 /* CDATA_SECTION_NODE */){
text += child.nodeValue;
}
}
var attributes = 0;
if(this.element.nodeType === 1 /* ELEMENT_NODE */){
attributes = this.element.attributes.length;
for(var i = 0; i < attributes; i++){
var attr = this.element.attributes[i];
obj["@" + attr.nodeName] = attr.nodeValue;
}
}
if(elements === 0){
if(attributes === 0){
// text only
return text; //String
}
// text with attributes
obj["text()"] = text;
}
// else ignore text
return obj; //Object
},
 
_getDocument: function(){
// summary:
// Return a DOM document
// description:
// If 'element' is specified, a DOM document of the element is
// returned.
// Otherwise, a DOM document is created.
// returns:
// A DOM document
if(this.element){
return (this.element.nodeType == 9 /* DOCUMENT_NODE */ ?
this.element : this.element.ownerDocument); //Document
}else{
return dojox.data.dom.createDocument(); //Document
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/ml/Service.js
New file
0,0 → 1,331
if(!dojo._hasResource["dojox.wire.ml.Service"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.ml.Service"] = true;
dojo.provide("dojox.wire.ml.Service");
dojo.provide("dojox.wire.ml.RestHandler");
dojo.provide("dojox.wire.ml.XmlHandler");
dojo.provide("dojox.wire.ml.JsonHandler");
 
dojo.require("dijit._Widget");
dojo.require("dojox.data.dom");
dojo.require("dojox.wire._base");
dojo.require("dojox.wire.ml.util");
 
dojo.declare("dojox.wire.ml.Service", dijit._Widget, {
// summary:
// A widget for a service
// description:
// This widget represents a service defined by a service description
// specified with 'url' attribute.
// If 'serviceType' and 'serviceUrl' attributes are specified, 'url'
// attribute can be omitted.
// url:
// A URL to a service description
// serviceUrl:
// A URL to a service
// serviceType:
// A service type
// handlerClass:
// A service handler class name
url: "",
serviceUrl: "",
serviceType: "",
handlerClass: "",
preventCache: true,
 
postCreate: function(){
// summary:
// Call _createHandler()
// description:
// See _createHandler().
this.handler = this._createHandler();
},
 
_handlerClasses: {
"TEXT": "dojox.wire.ml.RestHandler",
"XML": "dojox.wire.ml.XmlHandler",
"JSON": "dojox.wire.ml.JsonHandler",
"JSON-RPC": "dojo.rpc.JsonService"
},
 
_createHandler: function(){
// summary:
// Create a service handler
// desription:
// A service handler class is determined by:
// 1. 'handlerClass' attribute
// 2. 'serviceType' attribute
// 3. 'serviceType' property in a service description
// returns:
// A service handler
if(this.url){
var self = this;
var d = dojo.xhrGet({
url: this.url,
handleAs: "json",
sync: true
});
d.addCallback(function(result){
self.smd = result;
});
if(this.smd && !this.serviceUrl){
this.serviceUrl = (this.smd.serviceUrl || this.smd.serviceURL);
}
}
var handlerClass = undefined;
if(this.handlerClass){
handlerClass = dojox.wire._getClass(this.handlerClass);
}else if(this.serviceType){
handlerClass = this._handlerClasses[this.serviceType];
if(handlerClass && dojo.isString(handlerClass)){
handlerClass = dojox.wire._getClass(handlerClass);
this._handlerClasses[this.serviceType] = handlerClass;
}
}else if(this.smd && this.smd.serviceType){
handlerClass = this._handlerClasses[this.smd.serviceType];
if(handlerClass && dojo.isString(handlerClass)){
handlerClass = dojox.wire._getClass(handlerClass);
this._handlerClasses[this.smd.serviceType] = handlerClass;
}
}
if(!handlerClass){
return null; //null
}
return new handlerClass(); //Object
},
 
callMethod: function(method, parameters){
// summary:
// Call a service method with parameters
// method:
// A method name
// parameters:
// An array parameters
var deferred = new dojo.Deferred();
this.handler.bind(method, parameters, deferred, this.serviceUrl);
return deferred;
}
});
 
dojo.declare("dojox.wire.ml.RestHandler", null, {
// summary:
// A REST service handler
// description:
// This class serves as a base REST service.
// Sub-classes may override _getContent() and _getResult() to handle
// specific content types.
contentType: "text/plain",
handleAs: "text",
 
bind: function(method, parameters, deferred, url){
// summary:
// Call a service method with parameters.
// description:
// A service is called with a URL generated by _getUrl() and
// an HTTP method specified with 'method'.
// For "POST" and "PUT", a content is generated by _getContent().
// When data is loaded, _getResult() is used to pass the result to
// Deferred.callback().
// method:
// A method name
// parameters:
// An array of parameters
// deferred:
// 'Deferred'
// url:
// A URL for the method
method = method.toUpperCase();
var self = this;
var args = {
url: this._getUrl(method, parameters, url),
contentType: this.contentType,
handleAs: this.handleAs,
headers: this.headers,
preventCache: this.preventCache
};
var d = null;
if(method == "POST"){
args.postData = this._getContent(method, parameters);
d = dojo.rawXhrPost(args);
}else if(method == "PUT"){
args.putData = this._getContent(method, parameters);
d = dojo.rawXhrPut(args);
}else if(method == "DELETE"){
d = dojo.xhrDelete(args);
}else{ // "GET"
d = dojo.xhrGet(args);
}
d.addCallbacks(function(result){
deferred.callback(self._getResult(result));
}, function(error){
deferred.errback(error);
});
},
 
_getUrl: function(/*String*/method, /*Array*/parameters, /*String*/url){
// summary:
// Generate a URL
// description:
// If 'method' is "GET" or "DELETE", a query string is generated
// from a query object specified to the first parameter in
// 'parameters' and appended to 'url'.
// If 'url' contains variable seguments ("{parameter_name}"),
// they are replaced with corresponding parameter values, instead.
// method:
// A method name
// parameters:
// An array of parameters
// url:
// A base URL
// returns:
// A URL
if(method == "GET" || method == "DELETE"){
var query = parameters[0];
var queryString = "";
for(var name in query){
var value = query[name];
if(value){
value = encodeURIComponent(value);
var variable = "{" + name + "}";
var index = url.indexOf(variable);
if(index >= 0){ // encode in path
url = url.substring(0, index) + value + url.substring(index + variable.length);
}else{ // encode as query string
if(queryString){
queryString += "&";
}
queryString += (name + "=" + value);
}
}
}
if(queryString){
url += "?" + queryString;
}
}
return url; //String
},
 
_getContent: function(/*String*/method, /*Array*/parameters){
// summary:
// Generate a request content
// description:
// If 'method' is "POST" or "PUT", the first parameter in
// 'parameters' is returned.
// method:
// A method name
// parameters:
// An array of parameters
// returns:
// A request content
if(method == "POST" || method == "PUT"){
return (parameters ? parameters[0] : null); //anything
}else{
return null; //null
}
},
 
_getResult: function(/*anything*/data){
// summary:
// Extract a result
// description:
// A response data is returned as is.
// data:
// A response data returned by a service
// returns:
// A result object
return data; //anything
}
});
 
dojo.declare("dojox.wire.ml.XmlHandler", dojox.wire.ml.RestHandler, {
// summary:
// A REST service handler for XML
// description:
// This class provides XML handling for a REST service.
contentType: "text/xml",
handleAs: "xml",
 
_getContent: function(/*String*/method, /*Array*/parameters){
// description:
// If 'method' is "POST" or "PUT", the first parameter in
// 'parameters' is used to generate an XML content.
// method:
// A method name
// parameters:
// An array of parameters
// returns:
// A request content
var content = null;
if(method == "POST" || method == "PUT"){
var p = parameters[0];
if(p){
if(dojo.isString(p)){
content = p;
}else{
var element = p;
if(element instanceof dojox.wire.ml.XmlElement){
element = element.element;
}else if(element.nodeType === 9 /* DOCUMENT_NODE */){
element = element.documentElement;
}
var declaration = "<?xml version=\"1.0\"?>"; // TODO: encoding?
content = declaration + dojox.data.dom.innerXML(element);
}
}
}
return content;
},
 
_getResult: function(/*Document*/data){
// summary:
// Extract a result
// description:
// A response data (XML Document) is returned wrapped with
// XmlElement.
// data:
// A response data returned by a service
// returns:
// A result object
if(data){
data = new dojox.wire.ml.XmlElement(data);
}
return data;
}
});
 
dojo.declare("dojox.wire.ml.JsonHandler", dojox.wire.ml.RestHandler, {
// summary:
// A REST service handler for JSON
// description:
// This class provides JSON handling for a REST service.
contentType: "text/json",
handleAs: "json",
headers: {"Accept": "*/json"},
 
_getContent: function(/*String*/method, /*Array*/parameters){
// summary:
// Generate a request content
// description:
// If 'method' is "POST" or "PUT", the first parameter in
// 'parameter' is used to generate a JSON content.
// method:
// A method name
// parameters:
// An array of parameters
// returns:
// A request content
var content = null;
if(method == "POST" || method == "PUT"){
var p = (parameters ? parameters[0] : undefined);
if(p){
if(dojo.isString(p)){
content = p;
}else{
content = dojo.toJson(p);
}
}
}
return content; //String
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/DataWire.js
New file
0,0 → 1,179
if(!dojo._hasResource["dojox.wire.DataWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.DataWire"] = true;
dojo.provide("dojox.wire.DataWire");
 
dojo.require("dojox.wire.Wire");
 
dojo.declare("dojox.wire.DataWire", dojox.wire.Wire, {
// summary:
// A Wire for item attributes of data stores
// description:
// This class accesses item attributes of data stores with a dotted
// notation of attribute names specified to 'attribute' property,
// using data APIs of a data store specified to 'dataStore' property.
// The root object for this class must be an item of the data store.
// Intermediate attribute names in the dotted notation specify
// attributes for child items, which are used for repeated calls to
// data APIs until reached to a descendant attribute.
// Attribute names may have an array index, such as "a[0]", to
// identify an array element of the attribute value.
_wireClass: "dojox.wire.DataWire",
 
constructor: function(/*Object*/args){
// summary:
// Initialize properties
// description:
// If 'dataStore' property is not specified, but 'parent' property
// is specified, 'dataStore' property is copied from the parent.
// args:
// Arguments to initialize properties
// dataStore:
// A data store
// attribute:
// A dotted notation to a descendant attribute
if(!this.dataStore && this.parent){
this.dataStore = this.parent.dataStore;
}
},
_getValue: function(/*Object*/object){
// summary:
// Return an attribute value of an item
// description:
// This method uses a root item passed in 'object' argument and
// 'attribute' property to call getValue() method of
// 'dataStore'.
// If an attribute name have an array suffix ("[]"), getValues()
// method is called, instead.
// If an index is specified in the array suffix, an array element
// for the index is returned, instead of the array itself.
// object:
// A root item
// returns:
// A value found, otherwise 'undefined'
if(!object || !this.attribute || !this.dataStore){
return object; //Object
}
 
var value = object;
var list = this.attribute.split('.');
for(var i in list){
value = this._getAttributeValue(value, list[i]);
if(!value){
return undefined; //undefined
}
}
return value; //anything
},
 
_setValue: function(/*Object*/object, /*anything*/value){
// summary:
// Set an attribute value to an item
// description:
// This method uses a root item passed in 'object' argument and
// 'attribute' property to identify an item.
// Then, setValue() method of 'dataStore' is called with a leaf
// attribute name and 'value' argument.
// If an attribute name have an array suffix ("[]"), setValues()
// method is called, instead.
// If an index is specified in the array suffix, an array element
// for the index is set to 'value', instead of the array itself.
// object:
// A root item
// value:
// A value to set
// returns:
// 'object', or 'undefined' for invalid attribute
if(!object || !this.attribute || !this.dataStore){
return object; //Object
}
 
var item = object;
var list = this.attribute.split('.');
var last = list.length - 1;
for(var i = 0; i < last; i++){
item = this._getAttributeValue(item, list[i]);
if(!item){
return undefined; //undefined
}
}
this._setAttributeValue(item, list[last], value);
return object; //Object
},
 
_getAttributeValue: function(/*Object*/item, /*String*/attribute){
// summary:
// Return an attribute value of an item
// description:
// This method uses an item passed in 'item' argument and
// 'attribute' argument to call getValue() method of 'dataStore'.
// If an attribute name have an array suffix ("[]"), getValues()
// method is called, instead.
// If an index is specified in the array suffix, an array element
// for the index is returned, instead of the array itself.
// item:
// An item
// attribute
// An attribute name
// returns:
// A value found, otherwise 'undefined'
var value = undefined;
var i1 = attribute.indexOf('[');
if(i1 >= 0){
var i2 = attribute.indexOf(']');
var index = attribute.substring(i1 + 1, i2);
attribute = attribute.substring(0, i1);
var array = this.dataStore.getValues(item, attribute);
if(array){
if(!index){ // return array for "attribute[]"
value = array;
}else{
value = array[index];
}
}
}else{
value = this.dataStore.getValue(item, attribute);
}
return value; //anything
},
 
_setAttributeValue: function(/*Object*/item, /*String*/attribute, /*anything*/value){
// summary:
// Set an attribute value to an item
// description:
// This method uses an item passed in 'item' argument and
// 'attribute' argument to call setValue() method of 'dataStore'
// with 'value' argument.
// If an attribute name have an array suffix ("[]"), setValues()
// method is called, instead.
// If an index is specified in the array suffix, an array element
// for the index is set to 'value', instead of the array itself.
// item:
// An item
// attribute:
// An attribute name
// value:
// A value to set
var i1 = attribute.indexOf('[');
if(i1 >= 0){
var i2 = attribute.indexOf(']');
var index = attribute.substring(i1 + 1, i2);
attribute = attribute.substring(0, i1);
var array = null;
if(!index){ // replace whole array for "attribute[]"
array = value;
}else{
array = this.dataStore.getValues(item, attribute);
if(!array){
array = [];
}
array[index] = value;
}
this.dataStore.setValues(item, attribute, array);
}else{
this.dataStore.setValue(item, attribute, value);
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/TreeAdapter.js
New file
0,0 → 1,188
if(!dojo._hasResource["dojox.wire.TreeAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.TreeAdapter"] = true;
dojo.provide("dojox.wire.TreeAdapter");
 
dojo.require("dojox.wire.CompositeWire");
 
dojo.declare("dojox.wire.TreeAdapter", dojox.wire.CompositeWire, {
// summary:
// A composite Wire for tree nodes
// description:
// This class has multiple child Wires for tree nodes, their title and
// child nodes.
// The root object for this class must be an array.
// 'node' Wires in 'nodes' property is used to identify an object
// representing a node.
// 'title' Wires in 'nodes' property is used to get the title string
// of a node.
// 'children' Wires in 'nodes' property is used to iterate over child
// node objects.
// The node values are returned in an array as follows:
// [
// {title: title1,
// children: [
// {title: title2,
// child: ...},
// {title: title3,
// child: ...},
// ...
// ]},
// ...
// ]
// This class only supports getValue(), but not setValue().
_wireClass: "dojox.wire.TreeAdapter",
constructor: function(/*Object*/args){
// summary:
// Initialize properties
// description:
// If object properties ('node', 'title' and 'children') of array
// elements specified in 'nodes' property are not Wires, Wires are
// created from them as arguments, with 'parent' property set to
// this Wire instance.
// args:
// Arguments to initialize properties
// nodes:
// An array containing objects for child Wires for node values
this._initializeChildren(this.nodes);
},
_getValue: function(/*Array*/object){
// summary:
// Return an array of tree node values
// description:
// This method iterates over an array specified to 'object'
// argument and calls getValue() method of 'node' Wires with each
// element of the array to get object(s) that represetns nodes.
// (If 'node' Wires are omitted, the array element is used for
// further processing.)
// Then, getValue() method of 'title' Wires are called to get
// title strings for nodes.
// (If 'title' Wires are omitted, the objects representing nodes
// are used as title strings.)
// And if an array of objects with 'node' and 'title' Wires is
// specified to 'children', it is used to gather child nodes and
// their title strings in the same way recursively.
// Finally, an array of the top-level node objects are retuned.
// object:
// A root array
// returns:
// An array of tree node values
if(!object || !this.nodes){
return object; //Array
}
 
var array = object;
if(!dojo.isArray(array)){
array = [array];
}
 
var nodes = [];
for(var i in array){
for(var i2 in this.nodes){
nodes = nodes.concat(this._getNodes(array[i], this.nodes[i2]));
}
}
return nodes; //Array
},
 
_setValue: function(/*Array*/object, /*Array*/value){
// summary:
// Not supported
throw new Error("Unsupported API: " + this._wireClass + "._setValue");
},
 
_initializeChildren: function(/*Array*/children){
// summary:
// Initialize child Wires
// description:
// If 'node' or 'title' properties of array elements specified in
// 'children' argument are not Wires, Wires are created from them
// as arguments, with 'parent' property set to this Wire instance.
// If an array element has 'children' property, this method is
// called recursively with it.
// children:
// An array of objects containing child Wires
if(!children){
return; //undefined
}
 
for(var i in children){
var child = children[i];
if(child.node){
child.node.parent = this;
if(!dojox.wire.isWire(child.node)){
child.node = dojox.wire.create(child.node);
}
}
if(child.title){
child.title.parent = this;
if(!dojox.wire.isWire(child.title)){
child.title = dojox.wire.create(child.title);
}
}
if(child.children){
this._initializeChildren(child.children);
}
}
},
 
_getNodes: function(/*Object*/object, /*Object*/child){
// summary:
// Return an array of tree node values
// description:
// This method calls getValue() method of 'node' Wires with
// 'object' argument to get object(s) that represents nodes.
// (If 'node' Wires are omitted, 'object' is used for further
// processing.)
// Then, getValue() method of 'title' Wires are called to get
// title strings for nodes.
// (If 'title' Wires are omitted, the objects representing nodes
// are used as title strings.)
// And if an array of objects with 'node' and 'title' Wires is
// specified to 'children', it is used to gather child nodes and
// their title strings in the same way recursively.
// Finally, an array of node objects are returned.
// object:
// An object
// child:
// An object with child Wires
// returns:
var array = null;
if(child.node){
array = child.node.getValue(object);
if(!array){
return [];
}
if(!dojo.isArray(array)){
array = [array];
}
}else{
array = [object];
}
 
var nodes = [];
for(var i in array){
object = array[i];
var node = {};
if(child.title){
node.title = child.title.getValue(object);
}else{
node.title = object;
}
if(child.children){
var children = [];
for(var i2 in child.children){
children = children.concat(this._getNodes(object, child.children[i2]));
}
if(children.length > 0){
node.children = children;
}
}
nodes.push(node);
}
return nodes; //Array
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/README
New file
0,0 → 1,53
-------------------------------------------------------------------------------
DojoX Wire
-------------------------------------------------------------------------------
Version 1.0
Release date: 05/29/2007
-------------------------------------------------------------------------------
Project state: stable
-------------------------------------------------------------------------------
Project authors
Jared Jurkiewicz (jared.jurkiewicz@gmail.com)
-------------------------------------------------------------------------------
Project description
 
The DojoX Wire project is a set of functions that build a generic data binding
and service invocation library to simplify how data values across a wide
variety of widget and non-widget JavaScript constructs are accessed, updated,
and passed to and from services. It also provides a set of widgets
within the dojox.wire.ml package to allow for declarative data binding
definitions in addition to the programmatic APIs.
 
In essense, this project is an API to provide a simplified way of doing MVC
patterns in the client.
 
-------------------------------------------------------------------------------
Dependencies:
 
DojoX Wire has dependencies on core dojo, the dijit widget system (for classes
in the dojox.wire.ml package), dojox.data, and the D.O.H. unit test framework.
-------------------------------------------------------------------------------
Documentation:
 
See the Dojo API tool (http://dojotoolkit.org/api)
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/wire.js
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/wire/*
 
Install into the following directory structure:
/dojox/wire/
 
...which should be at the same level as your Dojo checkout.
 
It should look like:
/dojox/wire.js
/dojox/wire/*
 
Require in dojox.wire for all baseline functions (dojox.wire.connect,
dojox.wire.register, etc). For specific Wire classes,
require in the appropriate dojox.wire.<Class>.
-------------------------------------------------------------------------------
 
/trunk/api/js/dojo1.0/dojox/wire/TextAdapter.js
New file
0,0 → 1,88
if(!dojo._hasResource["dojox.wire.TextAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.TextAdapter"] = true;
dojo.provide("dojox.wire.TextAdapter");
 
dojo.require("dojox.wire.CompositeWire");
 
dojo.declare("dojox.wire.TextAdapter", dojox.wire.CompositeWire, {
// summary:
// A composite Wire for a concatenated text
// description:
// This class has multiple child Wires for text segment values.
// Wires in 'segments' property are used to get text segments and
// values are concatenated with an optional delimiter string specified
// to 'delimiter' property.
_wireClass: "dojox.wire.TextAdapter",
constructor: function(/*Object*/args){
// summary:
// Initialize properties
// description:
// If array elements specified in 'segments' are not Wires, Wires
// are created from them as arguments, with 'parent' property set
// to this Wire instance.
// args:
// Arguments to initialize properties
// segments:
// An array containing child Wires for text segment values
// delimiter:
// A delimiter string
this._initializeChildren(this.segments);
if(!this.delimiter){
this.delimiter = "";
}
},
 
_getValue: function(/*Object||Array*/object){
// summary:
// Return a concatenated text
// description:
// This method calls getValue() method of the child Wires wuth
// 'object' argument and concatenate the values with 'delimiter'
// property to return.
// arg:
// A root object
// returns:
// A concatinated text
if(!object || !this.segments){
return object; //Object||Array
}
 
var text = "";
for(var i in this.segments){
var segment = this.segments[i].getValue(object);
text = this._addSegment(text, segment);
}
return text; //String
},
 
_setValue: function(/*Object||Array*/object, /*String*/value){
// summary:
// Not supported
throw new Error("Unsupported API: " + this._wireClass + "._setValue");
},
 
_addSegment: function(/*String*/text, /*String*/segment){
// summary:
// Return a concatenated text
// description:
// This method add a text segment specified to 'segment' argument
// to a base text specified to 'text', with 'delimiter' property.
// text:
// A base text
// segment:
// A text segment to add
// returns:
// A concatinated text
if(!segment){
return text; //String
}else if(!text){
return segment; //String
}else{
return text + this.delimiter + segment; //String
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/Wire.js
New file
0,0 → 1,336
if(!dojo._hasResource["dojox.wire.Wire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.Wire"] = true;
dojo.provide("dojox.wire.Wire");
 
dojo.require("dojox.wire._base");
 
dojo.declare("dojox.wire.Wire", null, {
// summary:
// A default and base Wire to access an object property
// description:
// This class accesses a property of an object with a dotted notation
// specified to 'property' property, such as "a.b.c", which identifies
// a descendant property, "object.a.b.c".
// Property names in the dotted notation may have an array index, such
// as "a[0]", to identify an array element, literally, "object.a[0]".
// When a notation start with an array index, such as "[0].a", it
// specifies an array element of the root object (array),
// "object[0].a".
// This class also serves as a base class for other Wire classes,
// preparing a root object and converting a return value, so that
// sub-classes just can implement _getValue() and _setValue() called
// from getValue() and setValue() implemented by this calss.
_wireClass: "dojox.wire.Wire",
constructor: function(/*Object*/args){
// summary:
// Initialize properties
// description:
// If 'converter' property is specified and is a string for
// a converter class, an instanceof the converter class is
// created.
// args:
// Arguments to initialize properties
// object:
// A root object (or another Wire to access a root object)
// property:
// A dotted notation to a descendant property
// type:
// A type of the return value (for the source Wire)
// converter:
// A converter object (or class name) to convert the return
// value (for the source Wire)
dojo.mixin(this, args);
 
if(this.converter){
if(dojo.isString(this.converter)){
//First check the object tree for it. Might be defined variable
//name/global function (like a jsId, or just a function name).
var convertObject = dojo.getObject(this.converter);
if (dojo.isFunction(convertObject)){
//We need to see if this is a pure function or an object constructor...
try{
var testObj = new convertObject();
if(testObj && !dojo.isFunction(testObj["convert"])){
//Looks like a 'pure' function...
this.converter = {convert: convertObject};
}else{
this.converter = testObj;
}
}catch(e){
//Do if this fails.
}
}else if(dojo.isObject(convertObject)){
//It's an object, like a jsId ... see if it has a convert function
if(dojo.isFunction(convertObject["convert"])){
this.converter = convertObject;
}
}
 
//No object with that name (Converter is still a string),
//then look for a class that needs to be dynamically loaded...
if (dojo.isString(this.converter)) {
var converterClass = dojox.wire._getClass(this.converter);
if(converterClass){
this.converter = new converterClass();
}else{
this.converter = undefined;
}
}
}else if(dojo.isFunction(this.converter)){
this.converter = {convert: this.converter};
}
}
},
 
getValue: function(/*Object||Array*/defaultObject){
// summary:
// Return a value of an object
// description:
// This method first determins a root object as follows:
// 1. If 'object' property specified,
// 1.1 If 'object' is a Wire, its getValue() method is called to
// obtain a root object.
// 1.2 Otherwise, use 'object' as a root object.
// 2. Otherwise, use 'defaultObject' argument.
// 3. If 'property' is specified, it is used to get a property
// value.
// Then, if a sub-class implements _getValue() method, it is
// called with the root object to get the return value.
// Otherwise, the root object (typically, a property valye) is
// used for the return value.
// Finally, if 'type' property is specified, the return value is
// converted to the specified primitive type ("string", "number",
// "boolean" and "array").
// If 'converter' property is specified, its convert() method is
// called to convert the value.
// defaultObject:
// A default root object
// returns:
// A value found
var object = undefined;
if(dojox.wire.isWire(this.object)){
object = this.object.getValue(defaultObject);
}else{
object = (this.object || defaultObject);
}
 
if(this.property){
var list = this.property.split('.');
for(var i in list){
if(!object){
return object; //anything (null, undefined, etc)
}
object = this._getPropertyValue(object, list[i]);
}
}
 
var value = undefined;
if(this._getValue){
value = this._getValue(object);
}else{
value = object;
}
 
if(value){
if(this.type){
if(this.type == "string"){
value = value.toString();
}else if(this.type == "number"){
value = parseInt(value);
}else if(this.type == "boolean"){
value = (value != "false");
}else if(this.type == "array"){
if(!dojo.isArray(value)){
value = [value];
}
}
}
if(this.converter && this.converter.convert){
value = this.converter.convert(value, this); // optional "this" context
}
}
return value; //anything
},
 
setValue: function(/*anything*/value, /*Object||Array*/defaultObject){
// summary:
// Set a value to an object
// description:
// This method first determins a root object as follows:
// 1. If 'object' property specified,
// 1.1 If 'object' is a Wire, its getValue() method is called to
// obtain a root object.
// 1.2 Otherwise, use 'object' as a root object.
// 2. Otherwise, use 'defaultObject' argument.
// 3. If 'property' is specified, it is used to get a property
// value.
// Then, if a sub-class implements _setValue() method, it is
// called with the root object and 'value' argument to set
// the value.
// Otherwise, 'value' is set to a property specified with
// 'property' property.
// If the root object is undefined and 'object' property is a Wire
// and a new object is created and returned by _setValue() it is
// set through 'object' (setValue() method).
// value:
// A value to set
// defaultObject:
// A default root object
var object = undefined;
if(dojox.wire.isWire(this.object)){
object = this.object.getValue(defaultObject);
}else{
object = (this.object || defaultObject);
}
 
var property = undefined;
if(this.property){
if(!object){
if(dojox.wire.isWire(this.object)){
object = {};
this.object.setValue(object, defaultObject);
}else{
throw new Error(this._wireClass + ".setValue(): invalid object");
}
}
var list = this.property.split('.');
var last = list.length - 1;
for(var i = 0; i < last; i++){
var p = list[i];
var o = this._getPropertyValue(object, p);
if(!o){
o = {};
this._setPropertyValue(object, p, o);
}
object = o;
}
property = list[last];
}
 
if(this._setValue){
if(property){
var o = this._getPropertyValue(object, property);
if(!o){
o = {};
this._setPropertyValue(object, property, o);
}
object = o;
}
var newObject = this._setValue(object, value);
if(!object && newObject){
if(dojox.wire.isWire(this.object)){
this.object.setValue(newObject, defaultObject);
}else{
throw new Error(this._wireClass + ".setValue(): invalid object");
}
}
}else{
if(property){
this._setPropertyValue(object, property, value);
}else{
if(dojox.wire.isWire(this.object)){
this.object.setValue(value, defaultObject);
}else{
throw new Error(this._wireClass + ".setValue(): invalid property");
}
}
}
},
 
_getPropertyValue: function(/*Object||Array*/object, /*String*/property){
// summary:
// Return a property value of an object
// description:
// A value for 'property' of 'object' is returned.
// If 'property' ends with an array index, it is used to indentify
// an element of an array property.
// If 'object' implements getPropertyValue(), it is called with
// 'property' to obtain the property value.
// If 'object' implements a getter for the property, it is called
// to obtain the property value.
// object:
// A default root object
// property:
// A property name
// returns:
// A value found, otherwise 'undefined'
var value = undefined;
var i1 = property.indexOf('[');
if(i1 >= 0){
var i2 = property.indexOf(']');
var index = property.substring(i1 + 1, i2);
var array = null;
if(i1 === 0){ // object is array
array = object;
}else{
property = property.substring(0, i1);
array = this._getPropertyValue(object, property);
if(array && !dojo.isArray(array)){
array = [array];
}
}
if(array){
value = array[index];
}
}else if(object.getPropertyValue){
value = object.getPropertyValue(property);
}else{
var getter = "get" + property.charAt(0).toUpperCase() + property.substring(1);
if(object[getter]){
value = object[getter]();
}else{
value = object[property];
}
}
return value; //anything
},
 
_setPropertyValue: function(/*Object||Array*/object, /*String*/property, /*anything*/value){
// summary:
// Set a property value to an object
// description:
// 'value' is set to 'property' of 'object'.
// If 'property' ends with an array index, it is used to indentify
// an element of an array property to set the value.
// If 'object' implements setPropertyValue(), it is called with
// 'property' and 'value' to set the property value.
// If 'object' implements a setter for the property, it is called
// with 'value' to set the property value.
// object:
// An object
// property:
// A property name
// value:
// A value to set
var i1 = property.indexOf('[');
if(i1 >= 0){
var i2 = property.indexOf(']');
var index = property.substring(i1 + 1, i2);
var array = null;
if(i1 === 0){ // object is array
array = object;
}else{
property = property.substring(0, i1);
array = this._getPropertyValue(object, property);
if(!array){
array = [];
this._setPropertyValue(object, property, array);
}
}
array[index] = value;
}else if(object.setPropertyValue){
object.setPropertyValue(property, value);
}else{
var setter = "set" + property.charAt(0).toUpperCase() + property.substring(1);
if(object[setter]){
object[setter](value);
}else{
object[property] = value;
}
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/XmlWire.js
New file
0,0 → 1,244
if(!dojo._hasResource["dojox.wire.XmlWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.XmlWire"] = true;
dojo.provide("dojox.wire.XmlWire");
 
dojo.require("dojox.data.dom");
dojo.require("dojox.wire.Wire");
 
dojo.declare("dojox.wire.XmlWire", dojox.wire.Wire, {
// summary:
// A Wire for XML nodes or values (element, attribute and text)
// description:
// This class accesses XML nodes or value with a simplified XPath
// specified to 'path' property.
// The root object for this class must be an DOM document or element
// node.
// "@name" accesses to an attribute value of an element and "text()"
// accesses to a text value of an element.
// The hierarchy of the elements from the root node can be specified
// with slash-separated list, such as "a/b/@c", which specifies
// the value of an attribute named "c" of an element named "b" as
// a child of another element named "a" of a child of the root node.
_wireClass: "dojox.wire.XmlWire",
constructor: function(/*Object*/args){
// summary:
// Initialize properties
// description:
// 'args' is just mixed in with no further processing.
// args:
// Arguments to initialize properties
// path:
// A simplified XPath to an attribute, a text or elements
},
_getValue: function(/*Node*/object){
// summary:
// Return an attribute value, a text value or an array of elements
// description:
// This method first uses a root node passed in 'object' argument
// and 'path' property to identify an attribute, a text or
// elements.
// If 'path' starts with a slash (absolute), the first path
// segment is ignored assuming it point to the root node.
// (That is, "/a/b/@c" and "b/@c" against a root node access
// the same attribute value, assuming the root node is an element
// with a tag name, "a".)
// object:
// A root node
// returns:
// A value found, otherwise 'undefined'
if(!object || !this.path){
return object; //Node
}
 
var node = object;
var path = this.path;
if(path.charAt(0) == '/'){ // absolute
// skip the first expression (supposed to select the top node)
var i = path.indexOf('/', 1);
path = path.substring(i + 1);
}
var list = path.split('/');
var last = list.length - 1;
for(var i = 0; i < last; i++){
node = this._getChildNode(node, list[i]);
if(!node){
return undefined; //undefined
}
}
var value = this._getNodeValue(node, list[last]);
return value; //String||Array
},
 
_setValue: function(/*Node*/object, /*String*/value){
// summary:
// Set an attribute value or a child text value to an element
// description:
// This method first uses a root node passed in 'object' argument
// and 'path' property to identify an attribute, a text or
// elements.
// If an intermediate element does not exist, it creates
// an element of the tag name in the 'path' segment as a child
// node of the current node.
// Finally, 'value' argument is set to an attribute or a text
// (a child node) of the leaf element.
// object:
// A root node
// value:
// A value to set
if(!this.path){
return object; //Node
}
 
var node = object;
var doc = this._getDocument(node);
var path = this.path;
if(path.charAt(0) == '/'){ // absolute
var i = path.indexOf('/', 1);
if(!node){
var name = path.substring(1, i);
node = doc.createElement(name);
object = node; // to be returned as a new object
}
// skip the first expression (supposed to select the top node)
path = path.substring(i + 1);
}else{
if(!node){
return undefined; //undefined
}
}
 
var list = path.split('/');
var last = list.length - 1;
for(var i = 0; i < last; i++){
var child = this._getChildNode(node, list[i]);
if(!child){
child = doc.createElement(list[i]);
node.appendChild(child);
}
node = child;
}
this._setNodeValue(node, list[last], value);
return object; //Node
},
 
_getNodeValue: function(/*Node*/node, /*String*/exp){
// summary:
// Return an attribute value, a text value or an array of elements
// description:
// If 'exp' starts with '@', an attribute value of the specified
// attribute is returned.
// If 'exp' is "text()", a child text value is returned.
// Otherwise, an array of child elements, the tag name of which
// match 'exp', is returned.
// node:
// A node
// exp:
// An expression for attribute, text or elements
// returns:
// A value found, otherwise 'undefined'
var value = undefined;
if(exp.charAt(0) == '@'){
var attribute = exp.substring(1);
value = node.getAttribute(attribute);
}else if(exp == "text()"){
var text = node.firstChild;
if(text){
value = text.nodeValue;
}
}else{ // assume elements
value = [];
for(var i = 0; i < node.childNodes.length; i++){
var child = node.childNodes[i];
if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == exp){
value.push(child);
}
}
}
return value; //String||Array
},
 
_setNodeValue: function(/*Node*/node, /*String*/exp, /*String*/value){
// summary:
// Set an attribute value or a child text value to an element
// description:
// If 'exp' starts with '@', 'value' is set to the specified
// attribute.
// If 'exp' is "text()", 'value' is set to a child text.
// node:
// A node
// exp:
// An expression for attribute or text
// value:
// A value to set
if(exp.charAt(0) == '@'){
var attribute = exp.substring(1);
if(value){
node.setAttribute(attribute, value);
}else{
node.removeAttribute(attribute);
}
}else if(exp == "text()"){
while(node.firstChild){
node.removeChild(node.firstChild);
}
if(value){
var text = this._getDocument(node).createTextNode(value);
node.appendChild(text);
}
}
// else not supported
},
 
_getChildNode: function(/*Node*/node, /*String*/name){
// summary:
// Return a child node
// description:
// A child element of the tag name specified with 'name' is
// returned.
// If 'name' ends with an array index, it is used to pick up
// the corresponding element from multiple child elements.
// node:
// A parent node
// name:
// A tag name
// returns:
// A child node
var index = 1;
var i1 = name.indexOf('[');
if(i1 >= 0){
var i2 = name.indexOf(']');
index = name.substring(i1 + 1, i2);
name = name.substring(0, i1);
}
var count = 1;
for(var i = 0; i < node.childNodes.length; i++){
var child = node.childNodes[i];
if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == name){
if(count == index){
return child; //Node
}
count++;
}
}
return null; //null
},
 
_getDocument: function(/*Node*/node){
// summary:
// Return a DOM document
// description:
// If 'node' is specified, a DOM document of the node is returned.
// Otherwise, a DOM document is created.
// returns:
// A DOM document
if(node){
return (node.nodeType == 9 /* DOCUMENT_NODE */ ? node : node.ownerDocument); //Document
}else{
return dojox.data.dom.createDocument(); //Document
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/module.js
New file
0,0 → 1,13
if(!dojo._hasResource["dojox.tests.module"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.tests.module"] = true;
dojo.provide("dojox.tests.module");
 
try{
dojo.require("dojox.wire.tests.wire");
dojo.require("dojox.wire.tests.wireml");
}catch(e){
doh.debug(e);
}
 
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/wire.js
New file
0,0 → 1,18
if(!dojo._hasResource["dojox.wire.tests.wire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.tests.wire"] = true;
dojo.provide("dojox.wire.tests.wire");
 
try{
dojo.require("dojox.wire.tests.programmatic._base");
dojo.require("dojox.wire.tests.programmatic.Wire");
dojo.requireIf(dojo.isBrowser, "dojox.wire.tests.programmatic.DataWire");
dojo.requireIf(dojo.isBrowser, "dojox.wire.tests.programmatic.XmlWire");
dojo.require("dojox.wire.tests.programmatic.CompositeWire");
dojo.require("dojox.wire.tests.programmatic.TableAdapter");
dojo.require("dojox.wire.tests.programmatic.TreeAdapter");
dojo.require("dojox.wire.tests.programmatic.TextAdapter");
}catch(e){
doh.debug(e);
}
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/programmatic/DataWire.js
New file
0,0 → 1,25
if(!dojo._hasResource["dojox.wire.tests.programmatic.DataWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.tests.programmatic.DataWire"] = true;
dojo.provide("dojox.wire.tests.programmatic.DataWire");
 
dojo.require("dojox.wire.DataWire");
dojo.require("dojox.data.XmlStore");
 
tests.register("dojox.wire.tests.programmatic.DataWire", [
 
function test_DataWire_attribute(t){
var store = new dojox.data.XmlStore();
var item = store.newItem({tagName: "x"});
new dojox.wire.DataWire({dataStore: store, object: item, attribute: "y"}).setValue("Y");
var value = new dojox.wire.DataWire({dataStore: store, object: item, attribute: "y"}).getValue();
t.assertEqual("Y", value);
 
// nested attribute
new dojox.wire.DataWire({dataStore: store, object: item, attribute: "y.z"}).setValue("Z");
value = new dojox.wire.DataWire({dataStore: store, object: item, attribute: "y.z"}).getValue();
t.assertEqual("Z", value);
}
 
]);
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/programmatic/TreeAdapter.js
New file
0,0 → 1,29
if(!dojo._hasResource["dojox.wire.tests.programmatic.TreeAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.tests.programmatic.TreeAdapter"] = true;
dojo.provide("dojox.wire.tests.programmatic.TreeAdapter");
 
dojo.require("dojox.wire.TreeAdapter");
 
tests.register("dojox.wire.tests.programmatic.TreeAdapter", [
 
function test_TreeAdapter_nodes(t){
var source = [
{a: "A1", b: "B1", c: "C1"},
{a: "A2", b: "B2", c: "C2"},
{a: "A3", b: "B3", c: "C3"}
];
var nodes = [
{title: {property: "a"}, children: [
{node: {property: "b"}},
{title: {property: "c"}}
]}
];
var value = new dojox.wire.TreeAdapter({object: source, nodes: nodes}).getValue();
t.assertEqual(source[0].a, value[0].title);
t.assertEqual(source[1].b, value[1].children[0].title);
t.assertEqual(source[2].c, value[2].children[1].title);
}
 
]);
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/programmatic/TextAdapter.js
New file
0,0 → 1,25
if(!dojo._hasResource["dojox.wire.tests.programmatic.TextAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.tests.programmatic.TextAdapter"] = true;
dojo.provide("dojox.wire.tests.programmatic.TextAdapter");
 
dojo.require("dojox.wire.TextAdapter");
 
tests.register("dojox.wire.tests.programmatic.TextAdapter", [
 
function test_TextAdapter_segments(t){
var source = {a: "a", b: "b", c: "c"};
var segments = [{property: "a"}, {property: "b"}, {property: "c"}];
var value = new dojox.wire.TextAdapter({object: source, segments: segments}).getValue();
t.assertEqual("abc", value);
},
 
function test_TextAdapter_delimiter(t){
var source = {a: "a", b: "b", c: "c"};
var segments = [{property: "a"}, {property: "b"}, {property: "c"}];
var value = new dojox.wire.TextAdapter({object: source, segments: segments, delimiter: "/"}).getValue();
t.assertEqual("a/b/c", value);
}
 
]);
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/programmatic/Wire.js
New file
0,0 → 1,123
if(!dojo._hasResource["dojox.wire.tests.programmatic.Wire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.tests.programmatic.Wire"] = true;
dojo.provide("dojox.wire.tests.programmatic.Wire");
dojo.require("dojox.wire.Wire");
 
//Simple connverter class to try to use.
dojo.declare("dojox.wire.tests.programmatic.Wire.Converter", null, {
convert: function(v){
return v + 1;
}
});
 
//Simple converter function to try to use.
//To get it in the global namespace, gotta assign it to the
//'window' toplevel object. Otherwise it ends up in the
//dojo NS and can't be found.
if (dojo.isBrowser) {
window["__wireTestConverterFunction"] = function(v){
return v + 1;
};
}else{
var __wireTestConverterFunction = function(v){
return v + 1;
};
}
 
tests.register("dojox.wire.tests.programmatic.Wire", [
 
function test_Wire_property(t){
var source = {a: "A", b: {c: "B.C"}};
var target = {a: "a", b: {c: "b.c"}};
var value = new dojox.wire.Wire({object: source, property: "a"}).getValue();
new dojox.wire.Wire({object: target, property: "a"}).setValue(value);
t.assertEqual(source.a, target.a);
 
// child property
value = new dojox.wire.Wire({object: source, property: "b.c"}).getValue();
new dojox.wire.Wire({object: target, property: "b.c"}).setValue(value);
t.assertEqual(source.b.c, target.b.c);
 
// new property
target = {};
value = new dojox.wire.Wire({object: source, property: "a"}).getValue();
new dojox.wire.Wire({object: target, property: "a"}).setValue(value);
t.assertEqual(source.a, target.a);
 
// new parent and child property
target.b = {};
value = new dojox.wire.Wire({object: source, property: "b.c"}).getValue();
new dojox.wire.Wire({object: target, property: "b.c"}).setValue(value);
t.assertEqual(source.b.c, target.b.c);
 
// new parent and child property
target = {};
value = new dojox.wire.Wire({object: source, property: "b.c"}).getValue();
new dojox.wire.Wire({object: target, property: "b.c"}).setValue(value);
t.assertEqual(source.b.c, target.b.c);
 
// new array property
source = {a: ["A"]};
target = {};
value = new dojox.wire.Wire({object: source, property: "a[0]"}).getValue();
new dojox.wire.Wire({object: target, property: "a[0]"}).setValue(value);
t.assertEqual(source.a[0], target.a[0]);
 
// by getter/setter
source = {getA: function() { return this._a; }, _a: "A"};
target = {setA: function(a) { this._a = a; }};
value = new dojox.wire.Wire({object: source, property: "a"}).getValue();
new dojox.wire.Wire({object: target, property: "a"}).setValue(value);
t.assertEqual(source._a, target._a);
 
// by get/setPropertyValue
source = {getPropertyValue: function(p) { return this["_" + p]; }, _a: "A"};
target = {setPropertyValue: function(p, v) { this["_" + p] = v; }};
value = new dojox.wire.Wire({object: source, property: "a"}).getValue();
new dojox.wire.Wire({object: target, property: "a"}).setValue(value);
t.assertEqual(source._a, target._a);
},
 
function test_Wire_type(t){
var source = {a: "1"};
var string = new dojox.wire.Wire({object: source, property: "a"}).getValue();
t.assertEqual("11", string + 1);
var number = new dojox.wire.Wire({object: source, property: "a", type: "number"}).getValue();
t.assertEqual(2, number + 1);
},
 
function test_Wire_converterObject(t){
var source = {a: "1"};
var converter = {convert: function(v) { return v + 1; }};
var string = new dojox.wire.Wire({object: source, property: "a", converter: converter}).getValue();
t.assertEqual("11", string);
},
 
function test_Wire_converterFunction(t){
var source = {a: "1"};
var converter = {convert: function(v) { return v + 1; }};
var number = new dojox.wire.Wire({object: source, property: "a", type: "number", converter: converter.convert}).getValue();
t.assertEqual(2, number);
},
 
function test_Wire_converterObjectByString(t){
var source = {a: "1"};
var number = new dojox.wire.Wire({object: source, property: "a", type: "number", converter: "dojox.wire.tests.programmatic.Wire.Converter"}).getValue();
t.assertEqual(2, number);
},
 
function test_Wire_converterFunctionByString(t){
var source = {a: "1"};
var number = new dojox.wire.Wire({object: source, property: "a", type: "number", converter: "__wireTestConverterFunction"}).getValue();
t.assertEqual(2, number);
},
 
function test_Wire_converterObjectByStringDynamic(t){
var source = {a: "1"};
var number = new dojox.wire.Wire({object: source, property: "a", type: "number", converter: "dojox.wire.tests.programmatic.ConverterDynamic"}).getValue();
t.assertEqual(2, number);
}
 
]);
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/programmatic/XmlWire.js
New file
0,0 → 1,32
if(!dojo._hasResource["dojox.wire.tests.programmatic.XmlWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.tests.programmatic.XmlWire"] = true;
dojo.provide("dojox.wire.tests.programmatic.XmlWire");
 
dojo.require("dojox.wire.XmlWire");
 
tests.register("dojox.wire.tests.programmatic.XmlWire", [
 
function test_XmlWire_path(t){
var object = {};
var wire = dojox.wire.create({object: object, property: "element"});
new dojox.wire.XmlWire({object: wire, path: "/x/y/text()"}).setValue("Y");
var value = new dojox.wire.XmlWire({object: object, property: "element", path: "y/text()"}).getValue();
t.assertEqual("Y", value);
 
// attribute
new dojox.wire.XmlWire({object: object, property: "element", path: "y/@z"}).setValue("Z");
value = new dojox.wire.XmlWire({object: wire, path: "/x/y/@z"}).getValue();
t.assertEqual("Z", value);
 
// with index
var document = object.element.ownerDocument;
var element = document.createElement("y");
element.appendChild(document.createTextNode("Y2"));
object.element.appendChild(element);
value = new dojox.wire.XmlWire({object: object.element, path: "y[2]/text()"}).getValue();
t.assertEqual("Y2", value);
}
 
]);
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/programmatic/TableAdapter.js
New file
0,0 → 1,24
if(!dojo._hasResource["dojox.wire.tests.programmatic.TableAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.tests.programmatic.TableAdapter"] = true;
dojo.provide("dojox.wire.tests.programmatic.TableAdapter");
 
dojo.require("dojox.wire.TableAdapter");
 
tests.register("dojox.wire.tests.programmatic.TableAdapter", [
 
function test_TableAdapter_columns(t){
var source = [
{a: "A1", b: "B1", c: "C1"},
{a: "A2", b: "B2", c: "C2"},
{a: "A3", b: "B3", c: "C3"}
];
var columns = {x: {property: "a"}, y: {property: "b"}, z: {property: "c"}};
var value = new dojox.wire.TableAdapter({object: source, columns: columns}).getValue();
t.assertEqual(source[0].a, value[0].x);
t.assertEqual(source[1].b, value[1].y);
t.assertEqual(source[2].c, value[2].z);
}
 
]);
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/programmatic/CompositeWire.js
New file
0,0 → 1,51
if(!dojo._hasResource["dojox.wire.tests.programmatic.CompositeWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.tests.programmatic.CompositeWire"] = true;
dojo.provide("dojox.wire.tests.programmatic.CompositeWire");
 
dojo.require("dojox.wire.CompositeWire");
 
tests.register("dojox.wire.tests.programmatic.CompositeWire", [
 
function test_CompositeWire_children(t){
var source = {a: "A", b: "B"};
var target = {};
var children = {x: {property: "a"}, y: {property: "b"}};
var value = new dojox.wire.CompositeWire({object: source, children: children}).getValue();
t.assertEqual(source.a, value.x);
t.assertEqual(source.b, value.y);
new dojox.wire.CompositeWire({object: target, children: children}).setValue(value);
t.assertEqual(source.a, target.a);
t.assertEqual(source.b, target.b);
 
// with argument
target = {};
value = new dojox.wire.CompositeWire({children: children}).getValue(source);
t.assertEqual(source.a, value.x);
t.assertEqual(source.b, value.y);
new dojox.wire.CompositeWire({children: children}).setValue(value, target);
t.assertEqual(source.a, target.a);
t.assertEqual(source.b, target.b);
 
// by array
target = {};
children = [{property: "a"}, {property: "b"}];
value = new dojox.wire.CompositeWire({object: source, children: children}).getValue();
t.assertEqual(source.a, value[0]);
t.assertEqual(source.b, value[1]);
new dojox.wire.CompositeWire({object: target, children: children}).setValue(value);
t.assertEqual(source.a, target.a);
t.assertEqual(source.b, target.b);
 
// by array with argument
target = {};
value = new dojox.wire.CompositeWire({children: children}).getValue(source);
t.assertEqual(source.a, value[0]);
t.assertEqual(source.b, value[1]);
new dojox.wire.CompositeWire({children: children}).setValue(value, target);
t.assertEqual(source.a, target.a);
t.assertEqual(source.b, target.b);
}
 
]);
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/programmatic/_base.js
New file
0,0 → 1,111
if(!dojo._hasResource["dojox.wire.tests.programmatic._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.tests.programmatic._base"] = true;
dojo.provide("dojox.wire.tests.programmatic._base");
 
dojo.require("dojox.wire._base");
 
tests.register("dojox.wire.tests.programmatic._base", [
 
function test_create(t){
var wire = dojox.wire.create({});
t.assertTrue(wire instanceof dojox.wire.Wire);
 
wire = dojox.wire.create({property: "a"});
t.assertTrue(wire instanceof dojox.wire.Wire);
 
wire = dojox.wire.create({attribute: "a"});
t.assertTrue(wire instanceof dojox.wire.DataWire);
 
wire = dojox.wire.create({path: "a"});
t.assertTrue(wire instanceof dojox.wire.XmlWire);
 
wire = dojox.wire.create({children: "a"});
t.assertTrue(wire instanceof dojox.wire.CompositeWire);
 
wire = dojox.wire.create({columns: "a"});
t.assertTrue(wire instanceof dojox.wire.TableAdapter);
 
wire = dojox.wire.create({nodes: "a"});
t.assertTrue(wire instanceof dojox.wire.TreeAdapter);
 
wire = dojox.wire.create({segments: "a"});
t.assertTrue(wire instanceof dojox.wire.TextAdapter);
 
wire = dojox.wire.create({wireClass: "dojox.wire.DataWire"});
t.assertTrue(wire instanceof dojox.wire.DataWire);
},
function test_transfer(t){
var source = {a: "A"};
var target = {};
dojox.wire.transfer(
{object: source, property: "a"},
{object: target, property: "a"});
t.assertEqual(source.a, target.a);
},
 
function test_connect(t){
var trigger = {transfer: function() {}, transferArgument: function() {}};
var source = {a: "A"};
var target = {};
dojox.wire.connect({scope: trigger, event: "transfer"},
{object: source, property: "a"},
{object: target, property: "a"});
trigger.transfer();
t.assertEqual(source.a, target.a);
 
// with argument
target = {};
dojox.wire.connect({scope: trigger, event: "transferArgument"},
{property: "[0].a"},
{object: target, property: "a"});
trigger.transferArgument(source);
t.assertEqual(source.a, target.a);
 
// by topic
target = {};
dojox.wire.connect({topic: "transfer"},
{object: source, property: "a"},
{object: target, property: "a"});
dojo.publish("transfer");
t.assertEqual(source.a, target.a);
 
// by topic with argument
target = {};
dojox.wire.connect({topic: "transferArgument"},
{property: "[0].a"},
{object: target, property: "a"});
dojo.publish("transferArgument", [source]);
t.assertEqual(source.a, target.a);
},
 
function test_disconnect(t){
var trigger = {transferDisconnect: function() {}};
var source = {a: "A"};
var target = {};
var connection = dojox.wire.connect({scope: trigger, event: "transferDisconnect"},
{object: source, property: "a"},
{object: target, property: "a"});
trigger.transferDisconnect();
t.assertEqual(source.a, target.a);
delete target.a;
dojox.wire.disconnect(connection);
trigger.transferDisconnect();
t.assertEqual(undefined, target.a);
 
// by topic
target = {};
connection = dojox.wire.connect({topic: "transferDisconnect"},
{object: source, property: "a"},
{object: target, property: "a"});
dojo.publish("transferDisconnect");
t.assertEqual(source.a, target.a);
delete target.a;
dojox.wire.disconnect(connection);
dojo.publish("transferDisconnect");
t.assertEqual(undefined, target.a);
}
 
]);
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/programmatic/ConverterDynamic.js
New file
0,0 → 1,12
if(!dojo._hasResource["dojox.wire.tests.programmatic.ConverterDynamic"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.tests.programmatic.ConverterDynamic"] = true;
dojo.provide("dojox.wire.tests.programmatic.ConverterDynamic");
 
dojo.declare("dojox.wire.tests.programmatic.ConverterDynamic", null, {
convert: function(v){
return v + 1;
}
});
 
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/runTests.html
New file
0,0 → 1,9
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dojox.wire Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.wire.tests.module"></HEAD>
<BODY>
Redirecting to D.O.H runner.
</BODY>
</HTML>
/trunk/api/js/dojo1.0/dojox/wire/tests/wireml.js
New file
0,0 → 1,18
if(!dojo._hasResource["dojox.wire.tests.wireml"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.tests.wireml"] = true;
dojo.provide("dojox.wire.tests.wireml");
 
try{
if(dojo.isBrowser){
doh.registerUrl("dojox.wire.tests.ml.Action", dojo.moduleUrl("dojox", "wire/tests/markup/Action.html"));
doh.registerUrl("dojox.wire.tests.ml.Transfer", dojo.moduleUrl("dojox", "wire/tests/markup/Transfer.html"));
doh.registerUrl("dojox.wire.tests.ml.Invocation", dojo.moduleUrl("dojox", "wire/tests/markup/Invocation.html"));
doh.registerUrl("dojox.wire.tests.ml.Data", dojo.moduleUrl("dojox", "wire/tests/markup/Data.html"));
doh.registerUrl("dojox.wire.tests.ml.DataStore", dojo.moduleUrl("dojox", "wire/tests/markup/DataStore.html"));
doh.registerUrl("dojox.wire.tests.ml.Service", dojo.moduleUrl("dojox", "wire/tests/markup/Service.html"));
}
}catch(e){
doh.debug(e);
}
 
}
/trunk/api/js/dojo1.0/dojox/wire/tests/markup/DataStore.html
New file
0,0 → 1,66
<html>
<head>
<title>Test DataStore</title>
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.provide("dojox.wire.ml.tests.markup.DataStore");
 
dojo.require("dojo.parser");
dojo.require("doh.runner");
dojo.require("dojox.wire.ml.DataStore");
dojo.require("dojox.wire.ml.Invocation");
dojo.require("dojox.wire.ml.Transfer");
 
dojox.wire.ml.tests.markup.DataStore = {
request: {onComplete: function(){}, onError: function(){}}
};
 
dojo.addOnLoad(function(){
doh.register("dojox.wire.ml.tests.markup.DataStore", [
 
function test_DataStore_url(t){
var d = new doh.Deferred();
dojo.connect(dojox.wire.ml.tests.markup.DataStore.request, "onComplete", function(){
t.assertEqual("X1", dojox.wire.ml.tests.markup.DataStore.target[0].a);
t.assertEqual("Y2", dojox.wire.ml.tests.markup.DataStore.target[1].b);
t.assertEqual("Z3", dojox.wire.ml.tests.markup.DataStore.target[2].c);
d.callback(true);
});
dojo.connect(dojox.wire.ml.tests.markup.DataStore.request, "onError", function(error){
d.errback(error);
});
dojo.publish("invokeFetch");
return d;
}
 
]);
doh.run();
});
</script>
</head>
<body>
<div dojoType="dojox.wire.ml.DataStore"
id="DataStore1"
storeClass="dojox.data.XmlStore"
url="DataStore.xml"></div>
<div dojoType="dojox.wire.ml.Invocation"
triggerTopic="invokeFetch"
object="DataStore1"
method="fetch"
parameters="dojox.wire.ml.tests.markup.DataStore.request">
</div>
<div dojoType="dojox.wire.ml.Transfer"
trigger="dojox.wire.ml.tests.markup.DataStore.request"
triggerEvent="onComplete"
source="arguments[0]"
sourceStore="DataStore1.store"
target="dojox.wire.ml.tests.markup.DataStore.target">
<div dojoType="dojox.wire.ml.ColumnWire"
column="a" attribute="x"></div>
<div dojoType="dojox.wire.ml.ColumnWire"
column="b" attribute="y"></div>
<div dojoType="dojox.wire.ml.ColumnWire"
column="c" attribute="z"></div>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/tests/markup/Data.html
New file
0,0 → 1,105
<html>
<head>
<title>Test Data</title>
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.provide("dojox.wire.ml.tests.markup.Data");
 
dojo.require("dojo.parser");
dojo.require("doh.runner");
dojo.require("dojox.wire.ml.Action");
dojo.require("dojox.wire.ml.Data");
dojo.require("dojox.wire.ml.Transfer");
 
dojox.wire.ml.tests.markup.Data = {};
 
dojo.addOnLoad(function(){
doh.register("dojox.wire.ml.tests.markup.Data", [
 
function test_DataProperty(t){
dojox.wire.ml.tests.markup.Data.target = {};
dojo.publish("transfer");
t.assertEqual("A", dojox.wire.ml.tests.markup.Data.target.a);
t.assertEqual(1, dojox.wire.ml.tests.markup.Data.target.b);
t.assertEqual(true, dojox.wire.ml.tests.markup.Data.target.c);
t.assertEqual("DA", dojox.wire.ml.tests.markup.Data.target.d.a);
t.assertEqual("DB", dojox.wire.ml.tests.markup.Data.target.d.b);
t.assertEqual("E1", dojox.wire.ml.tests.markup.Data.target.e[0]);
t.assertEqual("E2", dojox.wire.ml.tests.markup.Data.target.e[1]);
t.assertEqual("F", dojox.wire.ml.tests.markup.Data.target.f);
t.assertEqual("G", dojox.wire.ml.tests.markup.Data.target.g);
}
 
]);
doh.run();
});
</script>
</head>
<body>
<div dojoType="dojox.wire.ml.Data"
id="Data1">
<div dojoType="dojox.wire.ml.DataProperty"
name="a"
value="A"></div>
<div dojoType="dojox.wire.ml.DataProperty"
name="b"
type="number" value="1"></div>
<div dojoType="dojox.wire.ml.DataProperty"
name="c"
type="boolean" value="true"></div>
<div dojoType="dojox.wire.ml.DataProperty"
name="d"
type="object">
<div dojoType="dojox.wire.ml.DataProperty"
name="a"
value="DA"></div>
<div dojoType="dojox.wire.ml.DataProperty"
name="b"
value="DB"></div>
</div>
<div dojoType="dojox.wire.ml.DataProperty"
name="e"
type="array">
<div dojoType="dojox.wire.ml.DataProperty"
value="E1"></div>
<div dojoType="dojox.wire.ml.DataProperty"
value="E2"></div>
</div>
<div dojoType="dojox.wire.ml.DataProperty"
name="f"
type="element"
value="x">
<div dojoType="dojox.wire.ml.DataProperty"
name="text()"
value="F"></div>
<div dojoType="dojox.wire.ml.DataProperty"
name="@y"
value="G"></div>
</div>
</div>
<div dojoType="dojox.wire.ml.Action"
triggerTopic="transfer">
<div dojoType="dojox.wire.ml.Transfer"
source="Data1.a"
target="dojox.wire.ml.tests.markup.Data.target.a"></div>
<div dojoType="dojox.wire.ml.Transfer"
source="Data1.b"
target="dojox.wire.ml.tests.markup.Data.target.b"></div>
<div dojoType="dojox.wire.ml.Transfer"
source="Data1.c"
target="dojox.wire.ml.tests.markup.Data.target.c"></div>
<div dojoType="dojox.wire.ml.Transfer"
source="Data1.d"
target="dojox.wire.ml.tests.markup.Data.target.d"></div>
<div dojoType="dojox.wire.ml.Transfer"
source="Data1.e"
target="dojox.wire.ml.tests.markup.Data.target.e"></div>
<div dojoType="dojox.wire.ml.Transfer"
source="Data1.f"
target="dojox.wire.ml.tests.markup.Data.target.f"></div>
<div dojoType="dojox.wire.ml.Transfer"
source="Data1.f.@y"
target="dojox.wire.ml.tests.markup.Data.target.g"></div>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/tests/markup/Invocation.html
New file
0,0 → 1,53
<html>
<head>
<title>Test Invocation</title>
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad:true "></script>
<script type="text/javascript">
dojo.provide("dojox.wire.ml.tests.markup.Invocation");
 
dojo.require("dojo.parser");
dojo.require("doh.runner");
dojo.require("dojox.wire.ml.Invocation");
 
dojox.wire.ml.tests.markup.Invocation = {
invoke: function(p1, p2){return p1 + p2;},
invokeError: function(p){throw new Error(p);},
parameters: {a: "A", b: "B", c: "C"}
};
 
dojo.addOnLoad(function(){
doh.register("dojox.wire.ml.tests.markup.Invocation", [
 
function test_Invocation_method(t){
dojo.publish("invokeMethod");
t.assertEqual("AB", dojox.wire.ml.tests.markup.Invocation.result);
},
 
function test_Invocation_topic(t){
dojo.publish("invokeTopic");
t.assertEqual("C", dojox.wire.ml.tests.markup.Invocation.error);
}
 
]);
doh.run();
});
</script>
</head>
<body>
<div dojoType="dojox.wire.ml.Invocation"
triggerTopic="invokeMethod"
object="dojox.wire.ml.tests.markup.Invocation"
method="invoke"
parameters="dojox.wire.ml.tests.markup.Invocation.parameters.a,dojox.wire.ml.tests.markup.Invocation.parameters.b"
result="dojox.wire.ml.tests.markup.Invocation.result"></div>
<div dojoType="dojox.wire.ml.Invocation"
triggerTopic="invokeTopic"
topic="invokeError"
parameters="dojox.wire.ml.tests.markup.Invocation.parameters.c"></div>
<div dojoType="dojox.wire.ml.Invocation"
triggerTopic="invokeError"
object="dojox.wire.ml.tests.markup.Invocation"
method="invokeError"
error="dojox.wire.ml.tests.markup.Invocation.error"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/tests/markup/Action.html
New file
0,0 → 1,147
<html>
<head>
<title>Test Action</title>
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.provide("dojox.wire.ml.tests.markup.Action");
 
dojo.require("dojo.parser");
dojo.require("doh.runner");
dojo.require("dojox.wire.ml.Action");
dojo.require("dojox.wire.ml.Transfer");
 
dojox.wire.ml.tests.markup.Action = {
transfer: function(){},
source: {a: "A", b: "B"}
};
 
dojo.addOnLoad(function(){
doh.register("dojox.wire.ml.tests.markup.Action", [
function test_Action_triggerEvent(t){
dojox.wire.ml.tests.markup.Action.target = {};
dojox.wire.ml.tests.markup.Action.transfer();
t.assertEqual(dojox.wire.ml.tests.markup.Action.source.a, dojox.wire.ml.tests.markup.Action.target.a);
t.assertEqual(dojox.wire.ml.tests.markup.Action.source.b, dojox.wire.ml.tests.markup.Action.target.b);
},
 
function test_Action_triggerTopic(t){
dojox.wire.ml.tests.markup.Action.target = {};
dojo.publish("transfer");
t.assertEqual(dojox.wire.ml.tests.markup.Action.source.a, dojox.wire.ml.tests.markup.Action.target.a);
},
 
function test_ActionFilter_required(t){
dojox.wire.ml.tests.markup.Action.target = {};
dojo.publish("transferFilter");
t.assertEqual(undefined, dojox.wire.ml.tests.markup.Action.target.a);
t.assertEqual("no required", dojox.wire.ml.tests.markup.Action.error);
dojox.wire.ml.tests.markup.Action.required = true;
dojo.publish("transferFilter");
t.assertEqual(dojox.wire.ml.tests.markup.Action.source.a, dojox.wire.ml.tests.markup.Action.target.a);
},
 
function test_ActionFilter_requiredSpecificNumber(t){
dojox.wire.ml.tests.markup.Action.value = null
dojox.wire.ml.tests.markup.Action.target = {};
dojo.publish("transferFilterNumber");
 
t.assertEqual(undefined, dojox.wire.ml.tests.markup.Action.target.a);
 
dojox.wire.ml.tests.markup.Action.value = 20;
dojo.publish("transferFilterNumber");
t.assertEqual(dojox.wire.ml.tests.markup.Action.source.a, dojox.wire.ml.tests.markup.Action.target.a);
},
 
function test_ActionFilter_requiredSpecificBoolean(t){
dojox.wire.ml.tests.markup.Action.value = null;
dojox.wire.ml.tests.markup.Action.target = {};
dojo.publish("transferFilterBoolean");
t.assertEqual(undefined, dojox.wire.ml.tests.markup.Action.target.a);
dojox.wire.ml.tests.markup.Action.value = true;
dojo.publish("transferFilterBoolean");
t.assertEqual(dojox.wire.ml.tests.markup.Action.source.a, dojox.wire.ml.tests.markup.Action.target.a);
},
 
function test_ActionFilter_requiredSpecificString(t){
dojox.wire.ml.tests.markup.Action.target = {};
dojox.wire.ml.tests.markup.Action.value = null;
dojo.publish("transferFilterString");
t.assertEqual(undefined, dojox.wire.ml.tests.markup.Action.target.a);
dojox.wire.ml.tests.markup.Action.value = "executeThis";
dojo.publish("transferFilterString");
t.assertEqual(dojox.wire.ml.tests.markup.Action.source.a, dojox.wire.ml.tests.markup.Action.target.a);
}
]);
doh.run();
});
</script>
</head>
<body>
<div dojoType="dojox.wire.ml.Action"
trigger="dojox.wire.ml.tests.markup.Action"
triggerEvent="transfer">
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Action.source.a"
target="dojox.wire.ml.tests.markup.Action.target.a"></div>
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Action.source.b"
target="dojox.wire.ml.tests.markup.Action.target.b"></div>
</div>
<div dojoType="dojox.wire.ml.Action"
triggerTopic="transfer">
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Action.source.a"
target="dojox.wire.ml.tests.markup.Action.target.a"></div>
</div>
<div dojoType="dojox.wire.ml.Action"
triggerTopic="transferFilter">
<div dojoType="dojox.wire.ml.ActionFilter"
required="dojox.wire.ml.tests.markup.Action.required"
message="no required"
error="dojox.wire.ml.tests.markup.Action.error"></div>
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Action.source.a"
target="dojox.wire.ml.tests.markup.Action.target.a"></div>
</div>
 
<div dojoType="dojox.wire.ml.Action"
triggerTopic="transferFilterNumber">
<div dojoType="dojox.wire.ml.ActionFilter"
required="dojox.wire.ml.tests.markup.Action.value"
requiredValue="20"
type="number">
</div>
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Action.source.a"
target="dojox.wire.ml.tests.markup.Action.target.a"></div>
</div>
 
<div dojoType="dojox.wire.ml.Action"
triggerTopic="transferFilterBoolean">
<div dojoType="dojox.wire.ml.ActionFilter"
required="dojox.wire.ml.tests.markup.Action.value"
requiredValue="true"
type="boolean">
</div>
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Action.source.a"
target="dojox.wire.ml.tests.markup.Action.target.a"></div>
</div>
 
<div dojoType="dojox.wire.ml.Action"
triggerTopic="transferFilterString">
<div dojoType="dojox.wire.ml.ActionFilter"
required="dojox.wire.ml.tests.markup.Action.value"
requiredValue="executeThis">
</div>
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Action.source.a"
target="dojox.wire.ml.tests.markup.Action.target.a"></div>
</div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/tests/markup/Service/a.xml
New file
0,0 → 1,5
<?xml version="1.0" encoding="ISO-8859-1"?>
<item>
<name>a</name>
<data><![CDATA[b]]></data>
</item>
/trunk/api/js/dojo1.0/dojox/wire/tests/markup/Service/XML.smd
New file
0,0 → 1,11
{
"serviceType": "XML",
"serviceURL": "Service/{name}.xml",
"methods": [{
"name": "get",
"parameters": [{
"name": "name",
"type": "str"
}]
}]
}
/trunk/api/js/dojo1.0/dojox/wire/tests/markup/Service/a.json
New file
0,0 → 1,5
{
"item": {
"name": "a"
}
}
/trunk/api/js/dojo1.0/dojox/wire/tests/markup/Service/JSON.smd
New file
0,0 → 1,11
{
"serviceType": "JSON",
"serviceURL": "Service/{name}.json",
"methods": [{
"name": "get",
"parameters": [{
"name": "name",
"type": "str"
}]
}]
}
/trunk/api/js/dojo1.0/dojox/wire/tests/markup/Service.html
New file
0,0 → 1,84
<html>
<head>
<title>Test Service</title>
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.provide("dojox.wire.ml.tests.markup.Service");
 
dojo.require("dojo.parser");
dojo.require("doh.runner");
dojo.require("dojox.wire.ml.Service");
dojo.require("dojox.wire.ml.Invocation");
dojo.require("dojox.wire.ml.Transfer");
 
dojox.wire.ml.tests.markup.Service = {
query: {name: "a"}
};
 
dojo.addOnLoad(function(){
doh.register("dojox.wire.ml.tests.markup.Service", [
 
function test_Service_url(t){
var d = new doh.Deferred();
dojo.connect(dijit.byId("Invocation1"), "onComplete", function(result){
t.assertEqual("a", dojox.wire.ml.tests.markup.Service.target.a);
var o = result.toObject();
t.assertEqual("a", o.item.name); // test XmlElement.toObject()
t.assertEqual("b", o.item.data); // test XmlElement.toObject()
 
d.callback(true);
});
dojo.connect(dijit.byId("Invocation1"), "onError", function(error){
d.errback(error);
});
dojo.publish("invokeGetXml");
return d;
},
 
function test_Service_serviceUrl(t){
var d = new doh.Deferred();
dojo.connect(dijit.byId("Invocation2"), "onComplete", function(){
t.assertEqual("a", dojox.wire.ml.tests.markup.Service.result.item.name);
d.callback(true);
});
dojo.connect(dijit.byId("Invocation2"), "onError", function(error){
d.errback(error);
});
dojo.publish("invokeGetJson");
return d;
}
 
]);
doh.run();
});
</script>
</head>
<body>
<div dojoType="dojox.wire.ml.Service"
id="Service1"
url="Service/XML.smd"></div>
<div dojoType="dojox.wire.ml.Invocation"
id="Invocation1"
triggerTopic="invokeGetXml"
object="Service1"
method="get"
parameters="dojox.wire.ml.tests.markup.Service.query">
</div>
<div dojoType="dojox.wire.ml.Transfer"
trigger="Invocation1"
triggerEvent="onComplete"
source="arguments[0].item.name"
target="dojox.wire.ml.tests.markup.Service.target.a"></div>
<div dojoType="dojox.wire.ml.Service"
id="Service2"
serviceType="JSON"
serviceUrl="Service/{name}.json"></div>
<div dojoType="dojox.wire.ml.Invocation"
id="Invocation2"
triggerTopic="invokeGetJson"
object="Service2"
method="get"
parameters="dojox.wire.ml.tests.markup.Service.query"
result="dojox.wire.ml.tests.markup.Service.result"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/tests/markup/DataStore.xml
New file
0,0 → 1,18
<?xml version="1.0" encoding="ISO-8859-1"?>
<dataStore>
<item>
<x>X1</x>
<y>Y1</y>
<z>Z1</z>
</item>
<item>
<x>X2</x>
<y>Y2</y>
<z>Z2</z>
</item>
<item>
<x>X3</x>
<y>Y3</y>
<z>Z3</z>
</item>
</dataStore>
/trunk/api/js/dojo1.0/dojox/wire/tests/markup/Transfer.html
New file
0,0 → 1,157
<html>
<head>
<title>Test Transfer</title>
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.provide("dojox.wire.ml.tests.markup.Transfer");
 
dojo.require("dojo.parser");
dojo.require("doh.runner");
dojo.require("dojox.data.dom");
dojo.require("dojox.data.XmlStore");
dojo.require("dojox.wire.ml.Action");
dojo.require("dojox.wire.ml.Transfer");
 
dojox.wire.ml.tests.markup.Transfer = {
source: {a: "A", b: "B", c: [
{d: "D1", e: "E1"},
{d: "D2", e: "E2"}
]}
};
 
dojo.addOnLoad(function(){
doh.register("dojox.wire.ml.tests.markup.Transfer", [
 
function test_Transfer_attribute(t){
dojox.wire.ml.tests.markup.Transfer.store = new dojox.data.XmlStore();
dojox.wire.ml.tests.markup.Transfer.item = dojox.wire.ml.tests.markup.Transfer.store.newItem({tagName: "x"});
dojox.wire.ml.tests.markup.Transfer.target = {};
dojo.publish("transferData");
t.assertEqual(dojox.wire.ml.tests.markup.Transfer.source.a, dojox.wire.ml.tests.markup.Transfer.target.a);
},
 
function test_Transfer_path(t){
dojox.wire.ml.tests.markup.Transfer.element = dojox.data.dom.createDocument().createElement("x");
dojox.wire.ml.tests.markup.Transfer.target = {};
dojo.publish("transferXml");
t.assertEqual(dojox.wire.ml.tests.markup.Transfer.source.a, dojox.wire.ml.tests.markup.Transfer.target.a);
},
 
function test_ChildWire(t){
dojox.wire.ml.tests.markup.Transfer.target = {};
dojo.publish("transferComposite");
t.assertEqual(dojox.wire.ml.tests.markup.Transfer.source.a, dojox.wire.ml.tests.markup.Transfer.target.c);
t.assertEqual(dojox.wire.ml.tests.markup.Transfer.source.b, dojox.wire.ml.tests.markup.Transfer.target.d);
},
 
function test_ColumnWire(t){
dojox.wire.ml.tests.markup.Transfer.target = {};
dojo.publish("transferTable");
t.assertEqual(dojox.wire.ml.tests.markup.Transfer.source.c[0].d, dojox.wire.ml.tests.markup.Transfer.target.a[0].b);
t.assertEqual(dojox.wire.ml.tests.markup.Transfer.source.c[1].e, dojox.wire.ml.tests.markup.Transfer.target.a[1].c);
},
 
function test_NodeWire(t){
dojox.wire.ml.tests.markup.Transfer.target = {};
dojo.publish("transferTree");
t.assertEqual(dojox.wire.ml.tests.markup.Transfer.source.c[0].d, dojox.wire.ml.tests.markup.Transfer.target.a[0].title);
t.assertEqual(dojox.wire.ml.tests.markup.Transfer.source.c[1].e, dojox.wire.ml.tests.markup.Transfer.target.a[1].children[0].title);
},
 
function test_SegimentWire(t){
dojox.wire.ml.tests.markup.Transfer.target = {};
dojo.publish("transferText");
t.assertEqual("A/B", dojox.wire.ml.tests.markup.Transfer.target.c);
}
 
]);
doh.run();
});
</script>
</head>
<body>
<div dojoType="dojox.wire.ml.Action"
triggerTopic="transferData">
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Transfer.source.a"
target="dojox.wire.ml.tests.markup.Transfer.item"
targetStore="dojox.wire.ml.tests.markup.Transfer.store"
targetAttribute="y"></div>
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Transfer.item"
sourceStore="dojox.wire.ml.tests.markup.Transfer.store"
sourceAttribute="y"
target="dojox.wire.ml.tests.markup.Transfer.target.a"></div>
</div>
<div dojoType="dojox.wire.ml.Action"
triggerTopic="transferXml">
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Transfer.source.a"
target="dojox.wire.ml.tests.markup.Transfer.element"
targetPath="y/text()"></div>
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Transfer.element"
sourcePath="y/text()"
target="dojox.wire.ml.tests.markup.Transfer.target.a"></div>
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Transfer.source.b"
target="dojox.wire.ml.tests.markup.Transfer.element"
targetPath="y/@z"></div>
<div dojoType="dojox.wire.ml.Transfer"
source="dojox.wire.ml.tests.markup.Transfer.element"
sourcePath="y/@z"
target="dojox.wire.ml.tests.markup.Transfer.target.b"></div>
</div>
<div dojoType="dojox.wire.ml.Transfer"
triggerTopic="transferComposite"
source="dojox.wire.ml.tests.markup.Transfer.source"
target="dojox.wire.ml.tests.markup.Transfer.target">
<div dojoType="dojox.wire.ml.ChildWire"
name="x"
property="a"></div>
<div dojoType="dojox.wire.ml.ChildWire"
which="source"
name="y"
property="b"></div>
<div dojoType="dojox.wire.ml.ChildWire"
which="target"
name="x"
property="c"></div>
<div dojoType="dojox.wire.ml.ChildWire"
which="target"
name="y"
property="d"></div>
</div>
<div dojoType="dojox.wire.ml.Transfer"
triggerTopic="transferTable"
source="dojox.wire.ml.tests.markup.Transfer.source.c"
target="dojox.wire.ml.tests.markup.Transfer.target.a">
<div dojoType="dojox.wire.ml.ColumnWire"
column="b"
property="d"></div>
<div dojoType="dojox.wire.ml.ColumnWire"
column="c"
property="e"></div>
</div>
<div dojoType="dojox.wire.ml.Transfer"
triggerTopic="transferTree"
source="dojox.wire.ml.tests.markup.Transfer.source.c"
target="dojox.wire.ml.tests.markup.Transfer.target.a">
<div dojoType="dojox.wire.ml.NodeWire"
titleProperty="d">
<div dojoType="dojox.wire.ml.NodeWire"
titleProperty="e"></div>
</div>
</div>
<div dojoType="dojox.wire.ml.Transfer"
triggerTopic="transferText"
source="dojox.wire.ml.tests.markup.Transfer.source"
delimiter="/"
target="dojox.wire.ml.tests.markup.Transfer.target.c">
<div dojoType="dojox.wire.ml.SegmentWire"
property="a"></div>
<div dojoType="dojox.wire.ml.SegmentWire"
property="b"></div>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/wire/TableAdapter.js
New file
0,0 → 1,88
if(!dojo._hasResource["dojox.wire.TableAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire.TableAdapter"] = true;
dojo.provide("dojox.wire.TableAdapter");
 
dojo.require("dojox.wire.CompositeWire");
 
dojo.declare("dojox.wire.TableAdapter", dojox.wire.CompositeWire, {
// summary:
// A composite Wire for table rows
// description:
// This class has multiple child Wires for object properties or array
// elements of a table row.
// The root object for this class must be an array.
// When an object with Wires is specified to 'columns' property, they
// are used to get a row object with property values.
// When an array of Wires is specified to 'columns' property, they
// are used to get a row array with element values.
// The row values are returned in an array.
// This class only supports getValue(), but not setValue().
_wireClass: "dojox.wire.TableAdapter",
constructor: function(/*Object*/args){
// summary:
// Initialize properties
// description:
// If object properties or array elements specified in 'columns'
// property are not Wires, Wires are created from them as
// arguments, with 'parent' property set to this Wire instance.
// args:
// Arguments to initialize properties
// columns:
// An object or array containing child Wires for column values
this._initializeChildren(this.columns);
},
 
_getValue: function(/*Array*/object){
// summary:
// Return an array of table row value (object or array)
// description:
// This method iterates over an array specified to 'object'
// argument and calls getValue() method of the child Wires with
// each element of the array to get a row object or array.
// Finally, an array with the row objects or arrays are retuned.
// object:
// A root array
// returns:
// An array of table row value
if(!object || !this.columns){
return object; //Array
}
 
var array = object;
if(!dojo.isArray(array)){
array = [array];
}
 
var rows = [];
for(var i in array){
var row = this._getRow(array[i]);
rows.push(row);
}
return rows; //Array
},
 
_setValue: function(/*Array*/object, /*Array*/value){
// summary:
// Not supported
throw new Error("Unsupported API: " + this._wireClass + "._setValue");
},
 
_getRow: function(/*Object||Array*/object){
// summary:
// Return an array or object for a table row
// description:
// This method calls getValue() method of the child Wires to
// create a row object or array.
// returns:
// An array or object for a table row
var row = (dojo.isArray(this.columns) ? [] : {}); // array or object
for(var c in this.columns){
row[c] = this.columns[c].getValue(object);
}
return row; //Array||Object
}
});
 
}
/trunk/api/js/dojo1.0/dojox/data/demos/demo_PicasaStore.html
New file
0,0 → 1,188
<!--
This file is a demo of the PicasaStore, a simple wrapper to the public feed service
of Picasa. This just does very basic queries against Picasa and loads the results
into a list viewing widget.
-->
<html>
<head>
<title>Demo of PicasaStore</title>
<style type="text/css">
 
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "./picasaDemo.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.ComboBox");
dojo.require("dijit.form.NumberSpinner");
dojo.require("dijit.Tree");
dojo.require("dojox.data.PicasaStore");
dojo.require("dojox.data.demos.widgets.PicasaViewList");
dojo.require("dojox.data.demos.widgets.PicasaView");
function init(){
var fViewWidgets = [];
 
//Set up an onComplete handler for flickrData
function onComplete(items, request){
flickrViewsWidget.clearList();
if(items.length > 0){
for(var i = 0; i < items.length; i++){
var flickrData = {
title: flickrStore.getValue(items[i],"title"),
author: flickrStore.getValue(items[i],"author"),
description: flickrStore.getValue(items[i],"description"),
iconUrl: flickrStore.getValue(items[i],"imageUrlSmall"),
imageUrl: flickrStore.getValue(items[i],"imageUrl")
}
flickrViewsWidget.addView(flickrData);
}
}
statusWidget.setValue("PROCESSING COMPLETE.");
 
}
//What to do if a search fails...
function onError(error, request){
flickrViewsWidget.clearList();
statusWidget.setValue("PROCESSING ERROR.");
}
 
//Function to invoke the search of the FlickrStore
function invokeSearch(){
var request = {
query: {},
onComplete: onComplete,
onError: onError
};
 
if(idWidget){
var userid = idWidget.getValue();
if(userid && userid !== ""){
request.query.userid = userid;
}
}
if(tagsWidget){
var tags = tagsWidget.getValue();
if(tags && tags !== ""){
var tagsArray = tags.split(" ");
tags = "";
for(var i = 0; i < tagsArray.length; i++){
tags = tags + tagsArray[i];
if(i < (tagsArray.length - 1)){
tags += ","
}
}
request.query.tags = tags;
}
}
if(countWidget){
request.count = countWidget.getValue();
}
 
if(startWidget){
request.query.start = startWidget.getValue();
}
 
if(statusWidget){
statusWidget.setValue("PROCESSING REQUEST");
}
 
flickrStore.fetch(request);
}
 
//Lastly, link up the search event.
var button = dijit.byId("searchButton");
dojo.connect(button, "onClick", invokeSearch);
}
dojo.addOnLoad(init);
</script>
</head>
 
<body class="tundra">
<h1>
DEMO: PicasaStore Search
</h1>
<hr>
<h3>
Description:
</h3>
<p>
This simple demo shows how services, such as Flickr, can be wrapped by the datastore API. In this demo, you can search public Flickr images through a simple FlickrStore by specifying a series of tags (separated by spaces) to search on. The results will be displayed below the search box.
</p>
<p>
For fun, search on the 3dny tag!
</p>
 
<blockquote>
 
<!--
The store instance used by this demo.
-->
<table>
<tbody>
<tr>
<td>
<b>Status:</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="status" jsId="statusWidget" disabled="true"></div>
</td>
</tr>
<tr>
<td>
<b>ID:</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="userid" jsId="idWidget"></div>
</td>
</tr>
<tr>
<td>
<b>Query:</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="tags" jsId="tagsWidget" value="flower"></div>
</td>
</tr>
<tr>
<td>
<b>Number of Pictures:</b>
</td>
<td>
<div
id="start"
jsId="startWidget"
dojoType="dijit.form.NumberSpinner"
value="1"
constraints="{min:1,places:0}"
></div>
<div
id="count"
jsId="countWidget"
dojoType="dijit.form.NumberSpinner"
value="20"
constraints="{min:1,max:100,places:0}"
></div>
</td>
</tr>
<tr>
<td>
</td>
<td>
<div dojoType="dijit.form.Button" label="Search" id="searchButton" jsId="searchButtonWidget"></div>
</td>
</tr>
</tbody>
</table>
<hr/>
<div dojoType="dojox.data.PicasaStore" jsId="flickrStore" label="title"></div>
<div dojoType="dojox.data.demos.widgets.PicasaViewList" id="flickrViews" jsId="flickrViewsWidget"></div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/data/demos/geography.xml
New file
0,0 → 1,51
<?xml version="1.0" encoding="ISO-8859-1"?>
<opml version="1.0">
<head>
<title>geography.opml</title>
<dateCreated>2006-11-10</dateCreated>
<dateModified>2006-11-13</dateModified>
<ownerName>Magellan, Ferdinand</ownerName>
</head>
<body>
<outline text="Africa" type="continent">
<outline text="Egypt" type="country"/>
<outline text="Kenya" type="country">
<outline text="Nairobi" type="city"/>
<outline text="Mombasa" type="city"/>
</outline>
<outline text="Sudan" type="country">
<outline text="Khartoum" type="city"/>
</outline>
</outline>
<outline text="Asia" type="continent">
<outline text="China" type="country"/>
<outline text="India" type="country"/>
<outline text="Russia" type="country"/>
<outline text="Mongolia" type="country"/>
</outline>
<outline text="Australia" type="continent" population="21 million">
<outline text="Australia" type="country" population="21 million"/>
</outline>
<outline text="Europe" type="continent">
<outline text="Germany" type="country"/>
<outline text="France" type="country"/>
<outline text="Spain" type="country"/>
<outline text="Italy" type="country"/>
</outline>
<outline text="North America" type="continent">
<outline text="Mexico" type="country" population="108 million" area="1,972,550 sq km">
<outline text="Mexico City" type="city" population="19 million" timezone="-6 UTC"/>
<outline text="Guadalajara" type="city" population="4 million" timezone="-6 UTC"/>
</outline>
<outline text="Canada" type="country" population="33 million" area="9,984,670 sq km">
<outline text="Ottawa" type="city" population="0.9 million" timezone="-5 UTC"/>
<outline text="Toronto" type="city" population="2.5 million" timezone="-5 UTC"/>
</outline>
<outline text="United States of America" type="country"/>
</outline>
<outline text="South America" type="continent">
<outline text="Brazil" type="country" population="186 million"/>
<outline text="Argentina" type="country" population="40 million"/>
</outline>
</body>
</opml>
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Germany/data.json
New file
0,0 → 1,4
{
name:'Germany',
type:'country'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Mongolia/data.json
New file
0,0 → 1,4
{
name:'Mongolia',
type:'country'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Russia/data.json
New file
0,0 → 1,4
{
name:'Russia',
type:'country'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Canada/Ottawa/data.json
New file
0,0 → 1,6
{
name:'Ottawa',
type:'city',
population:'0.9 million',
timezone:'-5 UTC'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Canada/data.json
New file
0,0 → 1,10
{
name:'Canada',
type:'country',
population:'33 million', area:'9,984,670 sq km',
children:[
{stub:'Ottawa'},
{stub:'Toronto'}
]
}
 
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Canada/Toronto/data.json
New file
0,0 → 1,6
{
name:'Toronto',
type:'city',
population:'2.5 million',
timezone:'-5 UTC'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Kenya/Mombasa/data.json
New file
0,0 → 1,5
{
name:'Mombasa',
type:'city',
population: "Unknown"
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Kenya/data.json
New file
0,0 → 1,9
{
name:'Kenya',
type:'country',
children:[
{stub:'Nairobi'},
{stub:'Mombasa'}
]
}
 
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Kenya/Nairobi/data.json
New file
0,0 → 1,5
{
name:'Nairobi',
type:'city',
population: "Unknown"
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Argentina/data.json
New file
0,0 → 1,5
{
name:'Argentina',
type:'country',
population:'40 million'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Spain/data.json
New file
0,0 → 1,4
{
name:'Spain',
type:'country'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Sudan/Khartoum/data.json
New file
0,0 → 1,5
{
name:'Khartoum',
type:'city'
}
 
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Sudan/data.json
New file
0,0 → 1,6
{
name:'Sudan',
type:'country',
children:{stub:'Khartoum'}
}
 
/trunk/api/js/dojo1.0/dojox/data/demos/geography/China/data.json
New file
0,0 → 1,4
{
name:'China',
type:'country'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Italy/data.json
New file
0,0 → 1,4
{
name:'Italy',
type:'country'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/United States of America/data.json
New file
0,0 → 1,4
{
name:'United States of America',
type:'country'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Brazil/data.json
New file
0,0 → 1,5
{
name:'Brazil',
type:'country',
population:'186 million'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Mexico/Guadalajara/data.json
New file
0,0 → 1,7
{
name:'Guadalajara',
type:'city',
population:'4 million',
timezone:'-6 UTC'
}
 
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Mexico/Mexico City/data.json
New file
0,0 → 1,6
{
name:'Mexico City',
type:'city',
population:'19 million',
timezone:'-6 UTC'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Mexico/data.json
New file
0,0 → 1,10
{
name:'Mexico',
type:'country',
population:'108 million',
area:'1,972,550 sq km',
children:[
{stub:'Mexico City'},
{stub:'Guadalajara'}
]
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/India/data.json
New file
0,0 → 1,4
{
name:'India',
type:'country'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Commonwealth of Australia/data.json
New file
0,0 → 1,5
{
name:'Commonwealth of Australia',
type:'country',
population:'21 million'
}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/Egypt/data.json
New file
0,0 → 1,5
{
name:'Egypt',
type:'country'
}
 
/trunk/api/js/dojo1.0/dojox/data/demos/geography/root.json
New file
0,0 → 1,39
{
identifier: 'name',
label: 'name',
items: [
{ name:'Africa', type:'continent',
children:[{_reference:'Egypt'}, {_reference:'Kenya'}, {_reference:'Sudan'}] },
{ name:'Egypt', type:'stub', parent: 'geography'},
{ name:'Kenya', type:'stub', parent: 'geography'},
{ name:'Sudan', type:'stub', parent: 'geography'},
 
{ name:'Asia', type:'continent',
children:[{_reference:'China'}, {_reference:'India'}, {_reference:'Russia'}, {_reference:'Mongolia'}] },
{ name:'China', type:'stub', parent: 'geography'},
{ name:'India', type:'stub', parent: 'geography'},
{ name:'Russia', type:'stub', parent: 'geography'},
{ name:'Mongolia', type:'stub', parent: 'geography'},
 
{ name:'Australia', type:'continent', population:'21 million',
children:{_reference:'Commonwealth of Australia'}},
{ name:'Commonwealth of Australia', type:'stub', parent:'geography'},
 
{ name:'Europe', type:'continent',
children:[{_reference:'Germany'}, {_reference:'France'}, {_reference:'Spain'}, {_reference:'Italy'}] },
{ name:'Germany', type:'stub', parent: 'geography'},
{ name:'France', type:'stub', parent: 'geography'},
{ name:'Spain', type:'stub', parent: 'geography'},
{ name:'Italy', type:'stub', parent: 'geography'},
 
{ name:'North America', type:'continent',
children:[{_reference:'Mexico'}, {_reference:'Canada'}, {_reference:'United States of America'}] },
{ name:'Mexico', type:'stub', parent: 'geography'},
{ name:'Canada', type:'stub', parent: 'geography'},
{ name:'United States of America', type:'stub', parent: 'geography'},
 
{ name:'South America', type:'continent',
children:[{_reference:'Brazil'}, {_reference:'Argentina'}] },
{ name:'Brazil', type:'stub', parent: 'geography'},
{ name:'Argentina', type:'stub', parent: 'geography'}
]}
/trunk/api/js/dojo1.0/dojox/data/demos/geography/France/data.json
New file
0,0 → 1,4
{
name:'France',
type:'country'
}
/trunk/api/js/dojo1.0/dojox/data/demos/demo_LazyLoad.html
New file
0,0 → 1,66
<!--
This file is a simple loader for the Lazy Load demo of a Datastore. In this
Example, a simple extension of ItemFileReadStore that can do rudimentary lazy-loading
of items into the store is used to showcase how Datastores can hide how data
is loaded from the widget. As long as the widget implements to the Dojo.data API
spec, then it should be able to use most datastores as input sources for its
values.
-->
<html>
<head>
<title>Demo of Lazy Loading Datastore</title>
<style type="text/css">
 
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true, usePlainJson: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojox.data.demos.stores.LazyLoadJSIStore");
dojo.require("dijit.Tree");
</script>
</head>
 
<body class="tundra">
<h1>
DEMO: Lazy Loading Datastore used by dijit.Tree
</h1>
<hr>
<h3>
Description:
</h3>
<p>
This simple demo shows how the dijit.Tree widget can work with a Datastore that does lazy-loading of values into the tree.
In this demo, the Datastore is an extension of ItemFileReadStore that overrides the <i>isItemLoaded()</i> and <i>loadItem()</i> functions of
with ones that can detect 'stub' items and use the data in the stub item to load the real data for that item when it
is required. In this demo, the real data is required when one of the tree nodes is expanded.
</p>
<p>
The key thing to note is that all the lazy-loading logic (how to locate the data from the backend and so forth) is encapsulated
into the store functions. The dijit.Tree widget only knows about and uses the dojo.data.Read API interfaces to call to the store to
get items, test if child items are fully loaded or not, and to invoke the <i>loadItem()</i> function on items that are not yet fully
loaded but have been requested to be expanded into view. It has no knowledge of how the store actually goes and gets the data.
</p>
 
<blockquote>
 
<!--
The store instance used by this demo.
-->
<div dojoType="dojox.data.demos.stores.LazyLoadJSIStore" jsId="continentStore"
url="geography/root.json"></div>
 
<!--
Display the toplevel tree with items that have an attribute of 'type',
with value of 'contintent'
-->
<b>Continents</b>
<div dojoType="dijit.Tree" id=tree label="Continents" store="continentStore" query="{type:'continent'}"
labelAttr="name" typeAttr="type"></div>
</blockquote>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/data/demos/flickrDemo.css
New file
0,0 → 1,35
.flickrView {
padding: 3 3 3 3;
border-width: 1px;
border-style: solid;
border-color: #000000;
border-collapse: separate;
width: 100%;
}
 
.flickrView th {
text-align: left;
}
 
.flickrView tr {
padding: 3 3 3 3;
border-width: 1px;
border-style: solid;
border-color: #000000;
}
 
.flickrView tr td {
padding: 3 3 3 3;
border-width: 1px;
border-style: solid;
border-color: #000000;
}
 
.flickrView {
background-color: #EFEFEF;
}
 
.flickrTitle {
background-color: #CCCCCC;
}
 
/trunk/api/js/dojo1.0/dojox/data/demos/widgets/FlickrViewList.js
New file
0,0 → 1,37
if(!dojo._hasResource["dojox.data.demos.widgets.FlickrViewList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.demos.widgets.FlickrViewList"] = true;
dojo.provide("dojox.data.demos.widgets.FlickrViewList");
dojo.require("dijit._Templated");
dojo.require("dijit._Widget");
dojo.require("dojox.data.demos.widgets.FlickrView");
 
dojo.declare("dojox.data.demos.widgets.FlickrViewList", [dijit._Widget, dijit._Templated], {
//Simple demo widget that is just a list of FlickrView Widgets.
 
templateString:"<div dojoAttachPoint=\"list\"></div>\n\n",
 
//Attach points for reference.
listNode: null,
 
postCreate: function(){
this.fViewWidgets = [];
},
 
clearList: function(){
while(this.list.firstChild){
this.list.removeChild(this.list.firstChild);
}
for(var i = 0; i < this.fViewWidgets.length; i++){
this.fViewWidgets[i].destroy();
}
this.fViewWidgets = [];
},
 
addView: function(viewData){
var newView = new dojox.data.demos.widgets.FlickrView(viewData);
this.fViewWidgets.push(newView);
this.list.appendChild(newView.domNode);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/data/demos/widgets/templates/FlickrView.html
New file
0,0 → 1,34
<table class="flickrView">
<tbody>
<tr class="flickrTitle">
<td>
<b>
Title:
</b>
</td>
<td dojoAttachPoint="titleNode">
</td>
</tr>
<tr>
<td>
<b>
Author:
</b>
</td>
<td dojoAttachPoint="authorNode">
</td>
</tr>
<tr>
<td colspan="2">
<b>
Image:
</b>
</td>
</tr>
<tr>
<td dojoAttachPoint="imageNode" colspan="2">
</td>
</tr>
</tbody>
</table>
 
/trunk/api/js/dojo1.0/dojox/data/demos/widgets/templates/PicasaViewList.html
New file
0,0 → 1,2
<div dojoAttachPoint="list"></div>
 
/trunk/api/js/dojo1.0/dojox/data/demos/widgets/templates/PicasaView.html
New file
0,0 → 1,35
<table class="picasaView">
<tbody>
<tr class="picasaTitle">
<td>
<b>
Title:
</b>
</td>
<td dojoAttachPoint="titleNode">
</td>
</tr>
<tr>
<td>
<b>
Author:
</b>
</td>
<td dojoAttachPoint="authorNode">
</td>
</tr>
<tr>
<td colspan="2">
<b>
Summary:
</b>
<span class="picasaSummary" dojoAttachPoint="descriptionNode"></span>
</td>
</tr>
<tr>
<td dojoAttachPoint="imageNode" colspan="2">
</td>
</tr>
</tbody>
</table>
 
/trunk/api/js/dojo1.0/dojox/data/demos/widgets/templates/FlickrViewList.html
New file
0,0 → 1,2
<div dojoAttachPoint="list"></div>
 
/trunk/api/js/dojo1.0/dojox/data/demos/widgets/FlickrView.js
New file
0,0 → 1,36
if(!dojo._hasResource["dojox.data.demos.widgets.FlickrView"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.demos.widgets.FlickrView"] = true;
dojo.provide("dojox.data.demos.widgets.FlickrView");
dojo.require("dijit._Templated");
dojo.require("dijit._Widget");
 
dojo.declare("dojox.data.demos.widgets.FlickrView", [dijit._Widget, dijit._Templated], {
//Simple demo widget for representing a view of a Flickr Item.
 
templateString:"<table class=\"flickrView\">\n\t<tbody>\n\t\t<tr class=\"flickrTitle\">\n\t\t\t<td>\n\t\t\t\t<b>\n\t\t\t\t\tTitle:\n\t\t\t\t</b>\n\t\t\t</td>\n\t\t\t<td dojoAttachPoint=\"titleNode\">\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t<b>\n\t\t\t\t\tAuthor:\n\t\t\t\t</b>\n\t\t\t</td>\n\t\t\t<td dojoAttachPoint=\"authorNode\">\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td colspan=\"2\">\n\t\t\t\t<b>\n\t\t\t\t\tImage:\n\t\t\t\t</b>\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td dojoAttachPoint=\"imageNode\" colspan=\"2\">\n\t\t\t</td>\n\t\t</tr>\n\t</tbody>\n</table>\n\n",
 
//Attach points for reference.
titleNode: null,
descriptionNode: null,
imageNode: null,
authorNode: null,
 
title: "",
author: "",
imageUrl: "",
iconUrl: "",
 
postCreate: function(){
this.titleNode.appendChild(document.createTextNode(this.title));
this.authorNode.appendChild(document.createTextNode(this.author));
var href = document.createElement("a");
href.setAttribute("href", this.imageUrl);
href.setAttribute("target", "_blank");
var imageTag = document.createElement("img");
imageTag.setAttribute("src", this.iconUrl);
href.appendChild(imageTag);
this.imageNode.appendChild(href);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/data/demos/widgets/PicasaViewList.js
New file
0,0 → 1,37
if(!dojo._hasResource["dojox.data.demos.widgets.PicasaViewList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.demos.widgets.PicasaViewList"] = true;
dojo.provide("dojox.data.demos.widgets.PicasaViewList");
dojo.require("dijit._Templated");
dojo.require("dijit._Widget");
dojo.require("dojox.data.demos.widgets.PicasaView");
 
dojo.declare("dojox.data.demos.widgets.PicasaViewList", [dijit._Widget, dijit._Templated], {
//Simple demo widget that is just a list of PicasaView Widgets.
 
templateString:"<div dojoAttachPoint=\"list\"></div>\n\n",
 
//Attach points for reference.
listNode: null,
 
postCreate: function(){
this.fViewWidgets = [];
},
 
clearList: function(){
while(this.list.firstChild){
this.list.removeChild(this.list.firstChild);
}
for(var i = 0; i < this.fViewWidgets.length; i++){
this.fViewWidgets[i].destroy();
}
this.fViewWidgets = [];
},
 
addView: function(viewData){
var newView = new dojox.data.demos.widgets.PicasaView(viewData);
this.fViewWidgets.push(newView);
this.list.appendChild(newView.domNode);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/data/demos/widgets/PicasaView.js
New file
0,0 → 1,37
if(!dojo._hasResource["dojox.data.demos.widgets.PicasaView"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.demos.widgets.PicasaView"] = true;
dojo.provide("dojox.data.demos.widgets.PicasaView");
dojo.require("dijit._Templated");
dojo.require("dijit._Widget");
 
dojo.declare("dojox.data.demos.widgets.PicasaView", [dijit._Widget, dijit._Templated], {
//Simple demo widget for representing a view of a Picasa Item.
 
templateString:"<table class=\"picasaView\">\n\t<tbody>\n\t\t<tr class=\"picasaTitle\">\n\t\t\t<td>\n\t\t\t\t<b>\n\t\t\t\t\tTitle:\n\t\t\t\t</b>\n\t\t\t</td>\n\t\t\t<td dojoAttachPoint=\"titleNode\">\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t<b>\n\t\t\t\t\tAuthor:\n\t\t\t\t</b>\n\t\t\t</td>\n\t\t\t<td dojoAttachPoint=\"authorNode\">\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td colspan=\"2\">\n\t\t\t\t<b>\n\t\t\t\t\tSummary:\n\t\t\t\t</b>\n\t\t\t\t<span class=\"picasaSummary\" dojoAttachPoint=\"descriptionNode\"></span>\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td dojoAttachPoint=\"imageNode\" colspan=\"2\">\n\t\t\t</td>\n\t\t</tr>\n\t</tbody>\n</table>\n\n",
 
//Attach points for reference.
titleNode: null,
descriptionNode: null,
imageNode: null,
authorNode: null,
 
title: "",
author: "",
imageUrl: "",
iconUrl: "",
 
postCreate: function(){
this.titleNode.appendChild(document.createTextNode(this.title));
this.authorNode.appendChild(document.createTextNode(this.author));
this.descriptionNode.appendChild(document.createTextNode(this.description));
var href = document.createElement("a");
href.setAttribute("href", this.imageUrl);
href.setAttribute("target", "_blank");
var imageTag = document.createElement("img");
imageTag.setAttribute("src", this.iconUrl);
href.appendChild(imageTag);
this.imageNode.appendChild(href);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/data/demos/demo_FlickrRestStore.html
New file
0,0 → 1,275
<!--
This file is a demo of the FlickrStore, a simple wrapper to the public feed service
of Flickr. This just does very basic queries against Flickr and loads the results
into a list viewing widget.
-->
<html>
<head>
<title>Demo of FlickrRestStore</title>
<style type="text/css">
 
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "./flickrDemo.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.ComboBox");
dojo.require("dijit.form.NumberSpinner");
dojo.require("dijit.Tree");
dojo.require("dojox.data.FlickrStore");
dojo.require("dojox.data.FlickrRestStore");
dojo.require("dojox.data.demos.widgets.FlickrViewList");
dojo.require("dojox.data.demos.widgets.FlickrView");
 
function init(){
var fViewWidgets = [];
 
//Set up an onComplete handler for flickrData
function onComplete(items, request){
flickrViewsWidget.clearList();
if(items.length > 0){
for(var i = 0; i < items.length; i++){
var flickrData = {
title: flickrStore.getValue(items[i],"title"),
author: flickrStore.getValue(items[i],"author"),
iconUrl: flickrStore.getValue(items[i],"imageUrlSmall"),
imageUrl: flickrStore.getValue(items[i],"imageUrl")
}
flickrViewsWidget.addView(flickrData);
}
}
statusWidget.setValue("PROCESSING COMPLETE.");
 
}
//What to do if a search fails...
function onError(error, request){
flickrViewsWidget.clearList();
statusWidget.setValue("PROCESSING ERROR.");
}
 
//Function to invoke the search of the FlickrStore
function invokeSearch(){
var request = {
query: {
apikey: "8c6803164dbc395fb7131c9d54843627"
},
onComplete: onComplete,
onError: onError
};
 
if(idWidget){
var userid = idWidget.getValue();
if(userid && userid !== ""){
request.query.userid = userid;
}
}
if(tagsWidget){
var tags = tagsWidget.getValue();
if(tags && tags !== ""){
var tagsArray = tags.split(" ");
tags = "";
for(var i = 0; i < tagsArray.length; i++){
tags = tags + tagsArray[i];
if(i < (tagsArray.length - 1)){
tags += ","
}
}
request.query.tags = tags;
}
}
if(tagmodeWidget){
var tagmode = tagmodeWidget.getValue();
if(tagmode !== ""){
request.query.tagmode = tagmode;
}
}
if(setIdWidget){
var setId = setIdWidget.getValue();
if(setId != ""){
request.query.setId = setId;
}
}
if(fullTextWidget){
var fullText = fullTextWidget.getValue();
if(fullText != ""){
request.query.text = fullText;
}
}
if(sortTypeWidget && sortDirWidget){
var sortType = sortTypeWidget.getValue();
var sortDirection = sortDirWidget.getValue();
if(sortType != "" && sortDirection != ""){
request.query.sort = [
{
attribute: sortType,
descending: (sortDirection.toLowerCase() == "descending")
}
];
}
}
if(countWidget){
request.count = countWidget.getValue();
}
if(pageWidget){
request.start = request.count * (pageWidget.getValue() -1);
}
 
if(statusWidget){
statusWidget.setValue("PROCESSING REQUEST");
}
 
flickrStore.fetch(request);
}
 
//Lastly, link up the search event.
var button = dijit.byId("searchButton");
dojo.connect(button, "onClick", invokeSearch);
}
dojo.addOnLoad(init);
</script>
</head>
 
<body class="tundra">
<h1>
DEMO: FlickrRestStore Search
</h1>
<hr>
<h3>
Description:
</h3>
<p>
This simple demo shows how services, such as Flickr, can be wrapped by the datastore API.
In this demo, you can search public Flickr images through a FlickrRestStore by specifying
a series of tags (separated by spaces) to search on. The results will be displayed below the search box.
</p>
<p>
For fun, search on the 3dny tag!
</p>
 
<blockquote>
 
<!--
The store instance used by this demo.
-->
<table>
<tbody>
<tr>
<td>
<b>Status:</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="status" jsId="statusWidget" disabled="true"></div>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td>
<b>User ID:</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="userid" jsId="idWidget" value="44153025@N00"></div>
</td>
<td>
<b>Set ID</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="setid" jsId="setIdWidget"></div>
</td>
</tr>
<tr>
<td>
<b>Tags:</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="tags" jsId="tagsWidget" value="rollingstones,kinsale"></div>
</td>
<td>
<b>Full Text</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="fulltext" jsId="fullTextWidget"></div>
</td>
</tr>
<tr>
<td>
<b>Tagmode:</b>
</td>
<td>
<select id="tagmode"
jsId="tagmodeWidget"
dojoType="dijit.form.ComboBox"
autocomplete="false"
value="any"
>
<option>any</option>
<option>all</option>
</select>
</td>
<td>
<b>Sort</b>
</td>
<td>
<select dojoType="dijit.form.ComboBox" size="15" id="sorttype" jsId="sortTypeWidget">
<option>date-posted</option>
<option>date-taken</option>
<option>interestingness</option>
</select>
<select dojoType="dijit.form.ComboBox" size="15" id="sortdirection" jsId="sortDirWidget">
<option>ascending</option>
<option>descending</option>
</select>
</td>
</tr>
<tr>
<td>
<b>Number of Pictures:</b>
</td>
<td>
<div
id="count"
jsId="countWidget"
dojoType="dijit.form.NumberSpinner"
value="20"
constraints="{min:1,max:20,places:0}"
></div>
</td>
<td>
<b>Page:</b>
</td>
<td>
<div
id="page"
jsId="pageWidget"
dojoType="dijit.form.NumberSpinner"
value="1"
constraints="{min:1,max:5,places:0}"
></div>
</td>
</tr>
<tr>
<td>
</td>
<td>
<div dojoType="dijit.form.Button" label="Search" id="searchButton" jsId="searchButtonWidget"></div>
</td>
</tr>
</tbody>
</table>
<hr/>
<div dojoType="dojox.data.FlickrRestStore" jsId="flickrStore" label="title"></div>
<div dojoType="dojox.data.demos.widgets.FlickrViewList" id="flickrViews" jsId="flickrViewsWidget"></div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/data/demos/picasaDemo.css
New file
0,0 → 1,44
.picasaView {
padding: 3 3 3 3;
border-width: 1px;
border-style: solid;
border-color: #000000;
border-collapse: separate;
width: 100%;
}
 
.picasaView th {
text-align: left;
}
 
.picasaView tr {
padding: 3 3 3 3;
border-width: 1px;
border-style: solid;
border-color: #000000;
}
 
.picasaView tr td {
padding: 3 3 3 3;
border-width: 1px;
border-style: solid;
border-color: #000000;
}
 
.picasaView {
background-color: #EFEFEF;
float: left;
width: 250px;
height: 250px;
}
 
.picasaSummary {
width: 250px;
height: 30px;
overflow: hidden;
}
 
.picasaTitle {
background-color: #CCCCCC;
}
 
/trunk/api/js/dojo1.0/dojox/data/demos/demo_DataDemoTable.html
New file
0,0 → 1,130
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Dojo Visual Loader Test</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/tests/css/dijitTests.css";
 
.oddRow { background-color: #f2f5f9; }
.population { text-align: right; }
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug: false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dijit.dijit");
dojo.require("dojo.parser");
dojo.require("dijit.Declaration");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojox.data.FlickrStore");
</script>
</head>
<body class="tundra">
<span dojoType="dojo.data.ItemFileReadStore"
jsId="continentStore"
url="../../../dijit/tests/_data/countries.json"></span>
<span dojoType="dojox.data.FlickrStore" jsId="flickrStore"></span>
 
 
<h1 class="testTitle">Dojox Data Demo Table</h1>
 
<table dojoType="dijit.Declaration"
widgetClass="demo.Table" class="dojoTabular"
defaults="{ store: null, query: { query: { name: '*' } }, columns: [ { name: 'Name', attribute: 'name' } ] }">
<thead dojoAttachPoint="head">
<tr dojoAttachPoint="headRow"></tr>
</thead>
<tbody dojoAttachPoint="body">
<tr dojoAttachPoint="row">
</tr>
</tbody>
 
<script type="dojo/method">
dojo.forEach(this.columns, function(item, idx){
var icn = item.className||"";
// add a header for each column
var tth = document.createElement("th");
tth.innerHTML = item.name;
tth.className = icn;
dojo.connect(tth, "onclick", dojo.hitch(this, "onSort", idx));
this.headRow.appendChild(tth);
 
// and fill in the column cell in the template row
this.row.appendChild(document.createElement("td"));
this.row.lastChild.className = icn;
}, this);
this.runQuery();
</script>
<script type="dojo/method" event="onSort" args="index">
var ca = this.columns[index].attribute;
var qs = this.query.sort;
// clobber an existing sort arrow
dojo.query("> th", this.headRow).styles("background", "").styles("paddingRight", "");
if(qs && qs[0].attribute == ca){
qs[0].descending = !qs[0].descending;
}else{
this.query.sort = [{
attribute: ca,
descending: false
}];
}
var th = dojo.query("> th", this.headRow)[index];
th.style.paddingRight = "16px"; // space for the sort arrow
th.style.background = "url(\""+dojo.moduleUrl("dijit", "themes/tundra/images/arrow"+(this.query.sort[0].descending ? "Up" : "Down")+((dojo.isIE == 6) ? ".gif" : ".png")) + "\") no-repeat 98% 4px";
this.runQuery();
</script>
<script type="dojo/method" event="runQuery">
this.query.onBegin = dojo.hitch(this, function(){ dojo.query("tr", this.body).orphan(); });
this.query.onItem = dojo.hitch(this, "onItem");
this.query.onComplete = dojo.hitch(this, function(){
dojo.query("tr:nth-child(odd)", this.body).addClass("oddRow");
dojo.query("tr:nth-child(even)", this.body).removeClass("oddRow");
});
this.store.fetch(this.query);
</script>
<script type="dojo/method" event="onItem" args="item">
var tr = this.row.cloneNode(true);
dojo.query("td", tr).forEach(function(n, i, a){
var tc = this.columns[i];
var tv = this.store.getValue(item, tc.attribute)||"";
if(tc.format){ tv = tc.format(tv, item, this.store); }
n.innerHTML = tv;
}, this);
this.body.appendChild(tr);
</script>
</table>
 
<span dojoType="demo.Table" store="continentStore"
query="{ query: { type: 'country' }, sort: [ { attribute: 'name', descending: true } ] }"
id="foo">
<script type="dojo/method" event="preamble">
this.columns = [
{ name: "Name", attribute: "name" },
{ name: "Population",
attribute: "population",
className: "population"
}
];
</script>
</span>
<span dojoType="demo.Table" store="continentStore"
query="{ query: { name: 'A*' } }"></span>
<span dojoType="demo.Table" store="flickrStore"
query="{ query: { tags: '3dny' } }">
<script type="dojo/method" event="preamble">
this.columns = [
{ name: "", attribute: "imageUrlSmall",
format: function(value, item, store){
return (value.length) ? "<img src='"+value+"'>" : "";
}
},
{ name: "Title", attribute: "title" }
];
</script>
</span>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/data/demos/geography.json
New file
0,0 → 1,45
{ identifier: 'name',
label: 'name',
items: [
{ name:'Africa', type:'continent', children:[
{ name:'Egypt', type:'country' },
{ name:'Kenya', type:'country', children:[
{ name:'Nairobi', type:'city' },
{ name:'Mombasa', type:'city' } ]
},
{ name:'Sudan', type:'country', children:
{ name:'Khartoum', type:'city' }
} ]
},
{ name:'Asia', type:'continent', children:[
{ name:'China', type:'country' },
{ name:'India', type:'country' },
{ name:'Russia', type:'country' },
{ name:'Mongolia', type:'country' } ]
},
{ name:'Australia', type:'continent', population:'21 million', children:
{ name:'Commonwealth of Australia', type:'country', population:'21 million'}
},
{ name:'Europe', type:'continent', children:[
{ name:'Germany', type:'country' },
{ name:'France', type:'country' },
{ name:'Spain', type:'country' },
{ name:'Italy', type:'country' } ]
},
{ name:'North America', type:'continent', children:[
{ name:'Mexico', type:'country', population:'108 million', area:'1,972,550 sq km', children:[
{ name:'Mexico City', type:'city', population:'19 million', timezone:'-6 UTC'},
{ name:'Guadalajara', type:'city', population:'4 million', timezone:'-6 UTC' } ]
},
{ name:'Canada', type:'country', population:'33 million', area:'9,984,670 sq km', children:[
{ name:'Ottawa', type:'city', population:'0.9 million', timezone:'-5 UTC'},
{ name:'Toronto', type:'city', population:'2.5 million', timezone:'-5 UTC' }]
},
{ name:'United States of America', type:'country' } ]
},
{ name:'South America', type:'continent', children:[
{ name:'Brazil', type:'country', population:'186 million' },
{ name:'Argentina', type:'country', population:'40 million' } ]
} ]
}
 
/trunk/api/js/dojo1.0/dojox/data/demos/demo_FlickrStore.html
New file
0,0 → 1,199
<!--
This file is a demo of the FlickrStore, a simple wrapper to the public feed service
of Flickr. This just does very basic queries against Flickr and loads the results
into a list viewing widget.
-->
<html>
<head>
<title>Demo of FlickrStore</title>
<style type="text/css">
 
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "./flickrDemo.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.ComboBox");
dojo.require("dijit.form.NumberSpinner");
dojo.require("dijit.Tree");
dojo.require("dojox.data.FlickrStore");
dojo.require("dojox.data.demos.widgets.FlickrViewList");
dojo.require("dojox.data.demos.widgets.FlickrView");
 
function init(){
var fViewWidgets = [];
 
//Set up an onComplete handler for flickrData
function onComplete(items, request){
flickrViewsWidget.clearList();
if(items.length > 0){
for(var i = 0; i < items.length; i++){
var flickrData = {
title: flickrStore.getValue(items[i],"title"),
author: flickrStore.getValue(items[i],"author"),
iconUrl: flickrStore.getValue(items[i],"imageUrlSmall"),
imageUrl: flickrStore.getValue(items[i],"imageUrl")
}
flickrViewsWidget.addView(flickrData);
}
}
statusWidget.setValue("PROCESSING COMPLETE.");
 
}
//What to do if a search fails...
function onError(error, request){
flickrViewsWidget.clearList();
statusWidget.setValue("PROCESSING ERROR.");
}
 
//Function to invoke the search of the FlickrStore
function invokeSearch(){
var request = {
query: {},
onComplete: onComplete,
onError: onError
};
 
if(idWidget){
var userid = idWidget.getValue();
if(userid && userid !== ""){
request.query.userid = userid;
}
}
if(tagsWidget){
var tags = tagsWidget.getValue();
if(tags && tags !== ""){
var tagsArray = tags.split(" ");
tags = "";
for(var i = 0; i < tagsArray.length; i++){
tags = tags + tagsArray[i];
if(i < (tagsArray.length - 1)){
tags += ","
}
}
request.query.tags = tags;
}
}
if(tagmodeWidget){
var tagmode = tagmodeWidget.getValue();
if(tagmode !== ""){
request.query.tagmode = tagmode;
}
}
 
if(countWidget){
request.count = countWidget.getValue();
}
 
if(statusWidget){
statusWidget.setValue("PROCESSING REQUEST");
}
 
flickrStore.fetch(request);
}
 
//Lastly, link up the search event.
var button = dijit.byId("searchButton");
dojo.connect(button, "onClick", invokeSearch);
}
dojo.addOnLoad(init);
</script>
</head>
 
<body class="tundra">
<h1>
DEMO: FlickrStore Search
</h1>
<hr>
<h3>
Description:
</h3>
<p>
This simple demo shows how services, such as Flickr, can be wrapped by the datastore API. In this demo, you can search public Flickr images through a simple FlickrStore by specifying a series of tags (separated by spaces) to search on. The results will be displayed below the search box.
</p>
<p>
For fun, search on the 3dny tag!
</p>
 
<blockquote>
 
<!--
The store instance used by this demo.
-->
<table>
<tbody>
<tr>
<td>
<b>Status:</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="status" jsId="statusWidget" disabled="true"></div>
</td>
</tr>
<tr>
<td>
<b>ID:</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="userid" jsId="idWidget"></div>
</td>
</tr>
<tr>
<td>
<b>Tags:</b>
</td>
<td>
<div dojoType="dijit.form.TextBox" size="50" id="tags" jsId="tagsWidget" value="3dny"></div>
</td>
</tr>
<tr>
<td>
<b>Tagmode:</b>
</td>
<td>
<select id="tagmode"
jsId="tagmodeWidget"
dojoType="dijit.form.ComboBox"
autocomplete="false"
value="any"
>
<option>any</option>
<option>all</option>
</select>
</td>
</tr>
<tr>
<td>
<b>Number of Pictures:</b>
</td>
<td>
<div
id="count"
jsId="countWidget"
dojoType="dijit.form.NumberSpinner"
value="20"
constraints="{min:1,max:20,places:0}"
></div>
</td>
</tr>
<tr>
<td>
</td>
<td>
<div dojoType="dijit.form.Button" label="Search" id="searchButton" jsId="searchButtonWidget"></div>
</td>
</tr>
</tbody>
</table>
<hr/>
<div dojoType="dojox.data.FlickrStore" jsId="flickrStore" label="title"></div>
<div dojoType="dojox.data.demos.widgets.FlickrViewList" id="flickrViews" jsId="flickrViewsWidget"></div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/data/demos/stores/LazyLoadJSIStore.js
New file
0,0 → 1,142
if(!dojo._hasResource["dojox.data.demos.stores.LazyLoadJSIStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.demos.stores.LazyLoadJSIStore"] = true;
dojo.provide("dojox.data.demos.stores.LazyLoadJSIStore");
dojo.require("dojo.data.ItemFileReadStore");
 
dojo.declare("dojox.data.demos.stores.LazyLoadJSIStore", dojo.data.ItemFileReadStore, {
constructor: function(/* object */ keywordParameters){
// LazyLoadJSIStore extends ItemFileReadStore to implement an
// example of lazy-loading/faulting in items on-demand.
// Note this is certianly not a perfect implementation, it is
// an example.
},
isItemLoaded: function(/*object*/ item) {
// summary:
// Overload of the isItemLoaded function to look for items of type 'stub', which indicate
// the data hasn't been loaded in yet.
//
// item:
// The item to examine.
//For this store, if it has the value of stub for its type attribute,
//then the item basn't been fully loaded yet. It's just a placeholder.
if(this.getValue(item, "type") === "stub"){
return false;
}
return true;
},
loadItem: function(keywordArgs){
// summary:
// Overload of the loadItem function to fault in items. This assumes the data for an item is laid out
// in a RESTful sort of pattern name0/name1/data.json and so on and uses that to load the data.
// It will also detect stub items in the newly loaded item and insert the stubs into the ItemFileReadStore
// list so they can also be loaded in on-demand.
//
// item:
// The item to examine.
 
var item = keywordArgs.item;
this._assertIsItem(item);
 
//Build the path to the data.json for this item
//The path consists of where its parent was loaded from
//plus the item name.
var itemName = this.getValue(item, "name");
var parent = this.getValue(item, "parent");
var dataUrl = "";
if (parent){
dataUrl += (parent + "/");
}
 
//For this store, all child input data is loaded from a url that ends with data.json
dataUrl += itemName + "/data.json";
 
//Need a reference to the store to call back to its structures.
var self = this;
 
// Callback for handling a successful load.
var gotData = function(data){
//Now we need to modify the existing item a bit to take it out of stub state
//Since we extend the store and have knowledge of the internal
//structure, this can be done here. Now, is we extended
//a write store, we could call the write APIs to do this too
//But for a simple demo the diretc modification in the store function
//is sufficient.
 
//Clear off the stub indicators.
delete item.type;
delete item.parent;
 
//Set up the loaded values in the format ItemFileReadStore uses for attributes.
for (i in data) {
if (dojo.isArray(data[i])) {
item[i] = data[i];
}else{
item[i] = [data[i]];
}
}
 
//Reset the item in the reference.
self._arrayOfAllItems[item[self._itemNumPropName]] = item;
 
//Scan the new values in the item for extra stub items we need to
//add to the items array of the store so they can be lazy-loaded later...
var attributes = self.getAttributes(item);
for(i in attributes){
var values = self.getValues(item, attributes[i]);
for (var j = 0; j < values.length; j++) {
var value = values[j];
if(typeof value === "object"){
if(value["stub"] ){
//We have a stub reference here, we need to create the stub item
var stub = {
type: ["stub"],
name: [value["stub"]], //
parent: [itemName] //The child stub item is parented by this item name...
};
if (parent) {
//Add in any parents to your parent so URL construstruction is accurate.
stub.parent[0] = parent + "/" + stub.parent[0];
}
//Finalize the addition of the new stub item into the ItemFileReadStore list.
self._arrayOfAllItems.push(stub);
stub[self._storeRefPropName] = self;
stub[self._itemNumPropName] = (self._arrayOfAllItems.length - 1); //Last one pushed in should be the item
values[j] = stub; //Set the stub item back in its place and replace the stub notation.
}
}
}
}
 
//Done processing! Call the onItem, if any.
if(keywordArgs.onItem){
var scope = keywordArgs.scope ? keywordArgs.scope : dojo.global;
keywordArgs.onItem.call(scope, item);
}
};
 
//Callback for any errors that occur during load.
var gotError = function(error){
//Call the onComplete, if any
if(keywordArgs.onError){
var scope = keywordArgs.scope ? keywordArgs.scope : dojo.global;
keywordArgs.onError.call(scope, error);
}
};
 
//Fire the get and pass the proper callbacks to the deferred.
var xhrArgs = {
url: dataUrl,
handleAs: "json-comment-optional"
};
var d = dojo.xhrGet(xhrArgs);
d.addCallback(gotData);
d.addErrback(gotError);
}
});
 
 
}
/trunk/api/js/dojo1.0/dojox/data/demos/demo_MultiStores.html
New file
0,0 → 1,72
<!--
This file is a demo of multiple dojo.data aware widgets using different datastore implementations for displaying data.
-->
<html>
<head>
<title>Demo of Multiple Widgets using different Datastores</title>
<style type="text/css">
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dijit.form.ComboBox");
dojo.require("dijit.Tree");
 
dojo.require("dojox.data.OpmlStore");
dojo.require("dojo.data.ItemFileReadStore");
 
</script>
</head>
 
<body class="tundra">
<h1>
DEMO: Multiple DataStore implementations with dojo.data aware Widgets
</h1>
<hr>
<h3>
Description:
</h3>
<p>
This simple demo shows how widgets which know only the dojo.data interfaces can work with data sources of varying formats. In this case an OpmlStore
and a ItemFileReadStore are used to house the same data in different formats.
</p>
 
<blockquote>
 
<!--
The store instances used by this demo.
-->
<div dojoType="dojo.data.ItemFileReadStore" url="geography.json" jsId="ifrGeoStore"></div>
<div dojoType="dojox.data.OpmlStore" url="geography.xml" label="text" jsId="opmlGeoStore"></div>
 
<h3>
Widgets using OpmlStore:
</h3>
<blockquote>
<b>ComboBox:</b><br>
<input dojoType="dijit.form.ComboBox" id="combo1" name="combo1" class="medium" store="opmlGeoStore" searchAttr="text" query="{}"></input>
<br>
<br>
 
<b>Tree:</b><br>
<div dojoType="dijit.Tree" id="tree1" label="Continents" store="opmlGeoStore"></div>
</blockquote>
 
<h3>
Widgets using ItemFileReadStore:
</h3>
<blockquote>
<b>ComboBox:</b><br>
<input dojoType="dijit.form.ComboBox" id="combo2" name="combo2" class="medium" store="ifrGeoStore" searchAttr="name" query="{}"></input>
<br>
<br>
 
<b>Tree:</b><br>
<div dojoType="dijit.Tree" id="tree2" label="Continents" store="ifrGeoStore"></div>
</blockquote>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/data/PicasaStore.js
New file
0,0 → 1,254
if(!dojo._hasResource["dojox.data.PicasaStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.PicasaStore"] = true;
dojo.provide("dojox.data.PicasaStore");
 
dojo.require("dojo.data.util.simpleFetch");
dojo.require("dojo.io.script");
dojo.require("dojo.date.stamp");
 
dojo.declare("dojox.data.PicasaStore", null, {
constructor: function(/*Object*/args){
// summary:
// Initializer for the PicasaStore store.
// description:
// The PicasaStore is a Datastore interface to one of the basic services
// of the Picasa service, the public photo feed. This does not provide
// access to all the services of Picasa.
// This store cannot do * and ? filtering as the picasa service
// provides no interface for wildcards.
if(args && args.label){
this.label = args.label;
}
},
 
_picasaUrl: "http://picasaweb.google.com/data/feed/api/all",
 
_storeRef: "_S",
 
label: "title",
 
_assertIsItem: function(/* item */ item){
// summary:
// This function tests whether the item passed in is indeed an item in the store.
// item:
// The item to test for being contained by the store.
if(!this.isItem(item)){
throw new Error("dojox.data.PicasaStore: a function was passed an item argument that was not an item");
}
},
 
_assertIsAttribute: function(/* attribute-name-string */ attribute){
// summary:
// This function tests whether the item passed in is indeed a valid 'attribute' like type for the store.
// attribute:
// The attribute to test for being contained by the store.
if(typeof attribute !== "string"){
throw new Error("dojox.data.PicasaStore: a function was passed an attribute argument that was not an attribute name string");
}
},
 
getFeatures: function(){
// summary:
// See dojo.data.api.Read.getFeatures()
return {
'dojo.data.api.Read': true
};
},
 
getValue: function(item, attribute){
// summary:
// See dojo.data.api.Read.getValue()
var values = this.getValues(item, attribute);
if(values){
return values[0];
}
return undefined;
},
 
getAttributes: function(item){
// summary:
// See dojo.data.api.Read.getAttributes()
return ["id", "published", "updated", "category", "title$type", "title", "summary$type", "summary", "rights$type", "rights", "link", "author", "gphoto$id", "gphoto$name", "location"];
},
 
hasAttribute: function(item, attribute){
// summary:
// See dojo.data.api.Read.hasAttributes()
if(this.getValue(item,attribute)){
return true;
}
return false;
},
 
isItemLoaded: function(item){
// summary:
// See dojo.data.api.Read.isItemLoaded()
return this.isItem(item);
},
 
loadItem: function(keywordArgs){
// summary:
// See dojo.data.api.Read.loadItem()
},
 
getLabel: function(item){
// summary:
// See dojo.data.api.Read.getLabel()
return this.getValue(item,this.label);
},
getLabelAttributes: function(item){
// summary:
// See dojo.data.api.Read.getLabelAttributes()
return [this.label];
},
 
containsValue: function(item, attribute, value){
// summary:
// See dojo.data.api.Read.containsValue()
var values = this.getValues(item,attribute);
for(var i = 0; i < values.length; i++){
if(values[i] === value){
return true;
}
}
return false;
},
 
getValues: function(item, attribute){
// summary:
// See dojo.data.api.Read.getValue()
 
this._assertIsItem(item);
this._assertIsAttribute(attribute);
if(attribute === "title"){
return [this._unescapeHtml(item.title)];
}else if(attribute === "author"){
return [this._unescapeHtml(item.author[0].name)];
}else if(attribute === "datePublished"){
return [dojo.date.stamp.fromISOString(item.published)];
}else if(attribute === "dateTaken"){
return [dojo.date.stamp.fromISOString(item.date_taken)];
}else if(attribute === "imageUrlSmall"){
return [item.media.thumbnail[1].url];
}else if(attribute === "imageUrl"){
return [item.content$src];
}else if(attribute === "imageUrlMedium"){
return [item.media.thumbnail[2].url];
}else if(attribute === "link"){
return [item.link[1]];
}else if(attribute === "tags"){
return item.tags.split(" ");
}else if(attribute === "description"){
return [this._unescapeHtml(item.summary)];
}
return undefined;
},
 
isItem: function(item){
// summary:
// See dojo.data.api.Read.isItem()
if(item && item[this._storeRef] === this){
return true;
}
return false;
},
close: function(request){
// summary:
// See dojo.data.api.Read.close()
},
 
_fetchItems: function(request, fetchHandler, errorHandler){
// summary:
// Fetch picasa items that match to a query
// request:
// A request object
// fetchHandler:
// A function to call for fetched items
// errorHandler:
// A function to call on error
 
if(!request.query){
request.query={};
}
 
//Build up the content to send the request for.
var content = {alt: "jsonm", pp: "1", psc: "G"};
content['start-index'] = "1";
if(request.query.start){
content['start-index'] = request.query.start;
}
if(request.query.tags){
content.q = request.query.tags;
}
if(request.query.userid){
content.uname = request.query.userid;
}
if(request.query.userids){
content.ids = request.query.userids;
}
if(request.query.lang){
content.hl = request.query.lang;
}
if(request.count){
content['max-results'] = request.count;
}else{
content['max-results'] = "20";
}
 
//Linking this up to Picasa is a JOY!
var self = this;
var handle = null;
var myHandler = function(data){
if(handle !== null){
dojo.disconnect(handle);
}
 
//Process the items...
fetchHandler(self._processPicasaData(data), request);
};
var getArgs = {
url: this._picasaUrl,
// preventCache: true,
content: content,
callbackParamName: 'callback',
handle: myHandler
};
var deferred = dojo.io.script.get(getArgs);
deferred.addErrback(function(error){
dojo.disconnect(handle);
errorHandler(error, request);
});
},
 
_processPicasaData: function(data){
var items = [];
if(data.feed){
items = data.feed.entry;
//Add on the store ref so that isItem can work.
for(var i = 0; i < items.length; i++){
var item = items[i];
item[this._storeRef] = this;
}
}
return items;
},
 
_unescapeHtml: function(str){
// summary: Utility function to un-escape XML special characters in an HTML string.
// description: Utility function to un-escape XML special characters in an HTML string.
// str: String.
// The string to un-escape
// returns: HTML String converted back to the normal text (unescaped) characters (<,>,&, ", etc,).
//
//TODO: Check to see if theres already compatible escape() in dojo.string or dojo.html
str = str.replace(/&amp;/gm, "&").replace(/&lt;/gm, "<").replace(/&gt;/gm, ">").replace(/&quot;/gm, "\"");
str = str.replace(/&#39;/gm, "'");
return str;
}
});
dojo.extend(dojox.data.PicasaStore,dojo.data.util.simpleFetch);
 
}
/trunk/api/js/dojo1.0/dojox/data/XmlStore.js
New file
0,0 → 1,1126
if(!dojo._hasResource["dojox.data.XmlStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.XmlStore"] = true;
dojo.provide("dojox.data.XmlStore");
dojo.provide("dojox.data.XmlItem");
 
dojo.require("dojo.data.util.simpleFetch");
dojo.require("dojo.data.util.filter");
dojo.require("dojox.data.dom");
 
dojo.declare("dojox.data.XmlStore", null, {
// summary:
// A data store for XML based services or documents
// description:
// A data store for XML based services or documents
constructor: function(/* object */ args) {
// summary:
// Constructor for the XML store.
// args:
// An anonymous object to initialize properties. It expects the following values:
// url: The url to a service or an XML document that represents the store
// rootItem: A tag name for root items
// keyAttribute: An attribute name for a key or an indentify
// attributeMap: An anonymous object contains properties for attribute mapping,
// {"tag_name.item_attribute_name": "@xml_attribute_name", ...}
// sendQuery: A boolean indicate to add a query string to the service URL
console.log("XmlStore()");
if(args){
this._url = args.url;
this._rootItem = (args.rootItem || args.rootitem);
this._keyAttribute = (args.keyAttribute || args.keyattribute);
this._attributeMap = (args.attributeMap || args.attributemap);
this._labelAttr = args.label;
this._sendQuery = (args.sendQuery || args.sendquery);
}
this._newItems = [];
this._deletedItems = [];
this._modifiedItems = [];
},
 
/* dojo.data.api.Read */
 
getValue: function(/* item */ item, /* attribute || attribute-name-string */ attribute, /* value? */ defaultValue){
// summary:
// Return an attribute value
// description:
// 'item' must be an instance of a dojox.data.XmlItem from the store instance.
// If 'attribute' specifies "tagName", the tag name of the element is
// returned.
// If 'attribute' specifies "childNodes", the first element child is
// returned.
// If 'attribute' specifies "text()", the value of the first text
// child is returned.
// For generic attributes, if '_attributeMap' is specified,
// an actual attribute name is looked up with the tag name of
// the element and 'attribute' (concatenated with '.').
// Then, if 'attribute' starts with "@", the value of the XML
// attribute is returned.
// Otherwise, the first child element of the tag name specified with
// 'attribute' is returned.
// item:
// An XML element that holds the attribute
// attribute:
// A tag name of a child element, An XML attribute name or one of
// special names
// defaultValue:
// A default value
// returns:
// An attribute value found, otherwise 'defaultValue'
var element = item.element;
if(attribute === "tagName"){
return element.nodeName;
}else if (attribute === "childNodes"){
for (var i = 0; i < element.childNodes.length; i++) {
var node = element.childNodes[i];
if (node.nodeType === 1 /*ELEMENT_NODE*/) {
return this._getItem(node); //object
}
}
return defaultValue;
}else if(attribute === "text()"){
for(var i = 0; i < element.childNodes.length; i++){
var node = element.childNodes[i];
if(node.nodeType === 3 /*TEXT_NODE*/ ||
node.nodeType === 4 /*CDATA_SECTION_NODE*/){
return node.nodeValue; //string
}
}
return defaultValue;
}else{
attribute = this._getAttribute(element.nodeName, attribute);
if(attribute.charAt(0) === '@'){
var name = attribute.substring(1);
var value = element.getAttribute(name);
return (value !== undefined) ? value : defaultValue; //object
}else{
for(var i = 0; i < element.childNodes.length; i++){
var node = element.childNodes[i];
if( node.nodeType === 1 /*ELEMENT_NODE*/ &&
node.nodeName === attribute){
return this._getItem(node); //object
}
}
return defaultValue; //object
}
}
},
 
getValues: function(/* item */ item, /* attribute || attribute-name-string */ attribute){
// summary:
// Return an array of attribute values
// description:
// 'item' must be an instance of a dojox.data.XmlItem from the store instance.
// If 'attribute' specifies "tagName", the tag name of the element is
// returned.
// If 'attribute' specifies "childNodes", child elements are returned.
// If 'attribute' specifies "text()", the values of child text nodes
// are returned.
// For generic attributes, if '_attributeMap' is specified,
// an actual attribute name is looked up with the tag name of
// the element and 'attribute' (concatenated with '.').
// Then, if 'attribute' starts with "@", the value of the XML
// attribute is returned.
// Otherwise, child elements of the tag name specified with
// 'attribute' are returned.
// item:
// An XML element that holds the attribute
// attribute:
// A tag name of child elements, An XML attribute name or one of
// special names
// returns:
// An array of attribute values found, otherwise an empty array
var element = item.element;
if(attribute === "tagName"){
return [element.nodeName];
}else if(attribute === "childNodes"){
var values = [];
for(var i = 0; i < element.childNodes.length; i++){
var node = element.childNodes[i];
if(node.nodeType === 1 /*ELEMENT_NODE*/){
values.push(this._getItem(node));
}
}
return values; //array
}else if(attribute === "text()"){
var values = [];
for(var i = 0; i < element.childNodes.length; i++){
var node = childNodes[i];
if(node.nodeType === 3){
values.push(node.nodeValue);
}
}
return values; //array
}else{
attribute = this._getAttribute(element.nodeName, attribute);
if(attribute.charAt(0) === '@'){
var name = attribute.substring(1);
var value = element.getAttribute(name);
return (value !== undefined) ? [value] : []; //array
}else{
var values = [];
for(var i = 0; i < element.childNodes.length; i++){
var node = element.childNodes[i];
if( node.nodeType === 1 /*ELEMENT_NODE*/ &&
node.nodeName === attribute){
values.push(this._getItem(node));
}
}
return values; //array
}
}
},
 
getAttributes: function(/* item */ item) {
// summary:
// Return an array of attribute names
// description:
// 'item' must be an instance of a dojox.data.XmlItem from the store instance.
// tag names of child elements and XML attribute names of attributes
// specified to the element are returned along with special attribute
// names applicable to the element including "tagName", "childNodes"
// if the element has child elements, "text()" if the element has
// child text nodes, and attribute names in '_attributeMap' that match
// the tag name of the element.
// item:
// An XML element
// returns:
// An array of attributes found
var element = item.element;
var attributes = [];
attributes.push("tagName");
if(element.childNodes.length > 0){
var names = {};
var childNodes = true;
var text = false;
for(var i = 0; i < element.childNodes.length; i++){
var node = element.childNodes[i];
if (node.nodeType === 1 /*ELEMENT_NODE*/) {
var name = node.nodeName;
if(!names[name]){
attributes.push(name);
names[name] = name;
}
childNodes = true;
}else if(node.nodeType === 3){
text = true;
}
}
if(childNodes){
attributes.push("childNodes");
}
if(text){
attributes.push("text()");
}
}
for(var i = 0; i < element.attributes.length; i++){
attributes.push("@" + element.attributes[i].nodeName);
}
if(this._attributeMap){
for (var key in this._attributeMap){
var i = key.indexOf('.');
if(i > 0){
var tagName = key.substring(0, i);
if (tagName === element.nodeName){
attributes.push(key.substring(i + 1));
}
}else{ // global attribute
attributes.push(key);
}
}
}
return attributes; //array
},
 
hasAttribute: function(/* item */ item, /* attribute || attribute-name-string */ attribute){
// summary:
// Check whether an element has the attribute
// item:
// 'item' must be an instance of a dojox.data.XmlItem from the store instance.
// attribute:
// A tag name of a child element, An XML attribute name or one of
// special names
// returns:
// True if the element has the attribute, otherwise false
return (this.getValue(item, attribute) !== undefined); //boolean
},
 
containsValue: function(/* item */ item, /* attribute || attribute-name-string */ attribute, /* anything */ value){
// summary:
// Check whether the attribute values contain the value
// item:
// 'item' must be an instance of a dojox.data.XmlItem from the store instance.
// attribute:
// A tag name of a child element, An XML attribute name or one of
// special names
// returns:
// True if the attribute values contain the value, otherwise false
var values = this.getValues(item, attribute);
for(var i = 0; i < values.length; i++){
if((typeof value === "string")){
if(values[i].toString && values[i].toString() === value){
return true;
}
}else if (values[i] === value){
return true; //boolean
}
}
return false;//boolean
},
 
isItem: function(/* anything */ something){
// summary:
// Check whether the object is an item (XML element)
// item:
// An object to check
// returns:
// True if the object is an XML element, otherwise false
if(something && something.element && something.store && something.store === this){
return true; //boolean
}
return false; //boolran
},
 
isItemLoaded: function(/* anything */ something){
// summary:
// Check whether the object is an item (XML element) and loaded
// item:
// An object to check
// returns:
// True if the object is an XML element, otherwise false
return this.isItem(something); //boolean
},
 
loadItem: function(/* object */ keywordArgs){
// summary:
// Load an item (XML element)
// keywordArgs:
// object containing the args for loadItem. See dojo.data.api.Read.loadItem()
},
 
getFeatures: function() {
// summary:
// Return supported data APIs
// returns:
// "dojo.data.api.Read" and "dojo.data.api.Write"
var features = {
"dojo.data.api.Read": true,
"dojo.data.api.Write": true
};
return features; //array
},
 
getLabel: function(/* item */ item){
// summary:
// See dojo.data.api.Read.getLabel()
if(this._labelAttr && this.isItem(item)){
var label = this.getValue(item,this._labelAttr);
if(label){
return label.toString();
}
}
return undefined; //undefined
},
 
getLabelAttributes: function(/* item */ item){
// summary:
// See dojo.data.api.Read.getLabelAttributes()
if(this._labelAttr){
return [this._labelAttr]; //array
}
return null; //null
},
 
_fetchItems: function(request, fetchHandler, errorHandler) {
// summary:
// Fetch items (XML elements) that match to a query
// description:
// If '_sendQuery' is true, an XML document is loaded from
// '_url' with a query string.
// Otherwise, an XML document is loaded and list XML elements that
// match to a query (set of element names and their text attribute
// values that the items to contain).
// A wildcard, "*" can be used to query values to match all
// occurrences.
// If '_rootItem' is specified, it is used to fetch items.
// request:
// A request object
// fetchHandler:
// A function to call for fetched items
// errorHandler:
// A function to call on error
var url = this._getFetchUrl(request);
console.log("XmlStore._fetchItems(): url=" + url);
if(!url){
errorHandler(new Error("No URL specified."));
return;
}
var localRequest = (!this._sendQuery ? request : null); // use request for _getItems()
 
var self = this;
var getArgs = {
url: url,
handleAs: "xml",
preventCache: true
};
var getHandler = dojo.xhrGet(getArgs);
getHandler.addCallback(function(data){
var items = self._getItems(data, localRequest);
console.log("XmlStore._fetchItems(): length=" + (items ? items.length : 0));
if (items && items.length > 0) {
fetchHandler(items, request);
}
else {
fetchHandler([], request);
}
});
getHandler.addErrback(function(data){
errorHandler(data, request);
});
},
 
_getFetchUrl: function(request){
// summary:
// Generate a URL for fetch
// description:
// This default implementation generates a query string in the form of
// "?name1=value1&name2=value2..." off properties of 'query' object
// specified in 'request' and appends it to '_url', if '_sendQuery'
// is set to false.
// Otherwise, '_url' is returned as is.
// Sub-classes may override this method for the custom URL generation.
// request:
// A request object
// returns:
// A fetch URL
if(!this._sendQuery){
return this._url;
}
var query = request.query;
if(!query){
return this._url;
}
if(dojo.isString(query)){
return this._url + query;
}
var queryString = "";
for(var name in query){
var value = query[name];
if(value){
if(queryString){
queryString += "&";
}
queryString += (name + "=" + value);
}
}
if(!queryString){
return this._url;
}
//Check to see if the URL already has query params or not.
var fullUrl = this._url;
if(fullUrl.indexOf("?") < 0){
fullUrl += "?";
}else{
fullUrl += "&";
}
return fullUrl + queryString;
},
 
_getItems: function(document, request) {
// summary:
// Fetch items (XML elements) in an XML document based on a request
// description:
// This default implementation walks through child elements of
// the document element to see if all properties of 'query' object
// match corresponding attributes of the element (item).
// If 'request' is not specified, all child elements are returned.
// Sub-classes may override this method for the custom search in
// an XML document.
// document:
// An XML document
// request:
// A request object
// returns:
// An array of items
var query = null;
if(request){
query = request.query;
}
var items = [];
var nodes = null;
if(this._rootItem){
nodes = document.getElementsByTagName(this._rootItem);
}
else{
nodes = document.documentElement.childNodes;
}
for(var i = 0; i < nodes.length; i++){
var node = nodes[i];
if(node.nodeType != 1 /*ELEMENT_NODE*/){
continue;
}
var item = this._getItem(node);
if(query){
var found = true;
var ignoreCase = request.queryOptions ? request.queryOptions.ignoreCase : false;
 
//See if there are any string values that can be regexp parsed first to avoid multiple regexp gens on the
//same value for each item examined. Much more efficient.
var regexpList = {};
for(var key in query){
var value = query[key];
if(typeof value === "string"){
regexpList[key] = dojo.data.util.filter.patternToRegExp(value, ignoreCase);
}
}
 
for(var attribute in query){
var value = this.getValue(item, attribute);
if(value){
var queryValue = query[attribute];
if ((typeof value) === "string" &&
(regexpList[attribute])){
if((value.match(regexpList[attribute])) !== null){
continue;
}
}else if((typeof value) === "object"){
if( value.toString &&
(regexpList[attribute])){
var stringValue = value.toString();
if((stringValue.match(regexpList[attribute])) !== null){
continue;
}
}else{
if(queryValue === "*" || queryValue === value){
continue;
}
}
}
}
found = false;
break;
}
if(!found){
continue;
}
}
items.push(item);
}
dojo.forEach(items,function(item){
item.element.parentNode.removeChild(item.element); // make it root
},this);
return items;
},
 
close: function(/*dojo.data.api.Request || keywordArgs || null */ request){
// summary:
// See dojo.data.api.Read.close()
},
 
/* dojo.data.api.Write */
 
newItem: function(/* object? */ keywordArgs){
// summary:
// Return a new dojox.data.XmlItem
// description:
// At least, 'keywordArgs' must contain "tagName" to be used for
// the new element.
// Other attributes in 'keywordArgs' are set to the new element,
// including "text()", but excluding "childNodes".
// keywordArgs:
// An object containing initial attributes
// returns:
// An XML element
console.log("XmlStore.newItem()");
keywordArgs = (keywordArgs || {});
var tagName = keywordArgs.tagName;
if(!tagName){
tagName = this._rootItem;
if(!tagName){
return null;
}
}
 
var document = this._getDocument();
var element = document.createElement(tagName);
for(var attribute in keywordArgs){
if(attribute === "tagName"){
continue;
}else if(attribute === "text()"){
var text = document.createTextNode(keywordArgs[attribute]);
element.appendChild(text);
}else{
attribute = this._getAttribute(tagName, attribute);
if(attribute.charAt(0) === '@'){
var name = attribute.substring(1);
element.setAttribute(name, keywordArgs[attribute]);
}else{
var child = document.createElement(attribute);
var text = document.createTextNode(keywordArgs[attribute]);
child.appendChild(text);
element.appendChild(child);
}
}
}
 
var item = this._getItem(element);
this._newItems.push(item);
return item; //object
},
deleteItem: function(/* item */ item){
// summary:
// Delete an dojox.data.XmlItem (wrapper to a XML element).
// item:
// An XML element to delete
// returns:
// True
console.log("XmlStore.deleteItem()");
var element = item.element;
if(element.parentNode){
this._backupItem(item);
element.parentNode.removeChild(element);
return true;
}
this._forgetItem(item);
this._deletedItems.push(item);
return true; //boolean
},
setValue: function(/* item */ item, /* attribute || string */ attribute, /* almost anything */ value){
// summary:
// Set an attribute value
// description:
// 'item' must be an instance of a dojox.data.XmlItem from the store instance.
// If 'attribute' specifies "tagName", nothing is set and false is
// returned.
// If 'attribute' specifies "childNodes", the value (XML element) is
// added to the element.
// If 'attribute' specifies "text()", a text node is created with
// the value and set it to the element as a child.
// For generic attributes, if '_attributeMap' is specified,
// an actual attribute name is looked up with the tag name of
// the element and 'attribute' (concatenated with '.').
// Then, if 'attribute' starts with "@", the value is set to the XML
// attribute.
// Otherwise, a text node is created with the value and set it to
// the first child element of the tag name specified with 'attribute'.
// If the child element does not exist, it is created.
// item:
// An XML element that holds the attribute
// attribute:
// A tag name of a child element, An XML attribute name or one of
// special names
// value:
// A attribute value to set
// returns:
// False for "tagName", otherwise true
if(attribute === "tagName"){
return false; //boolean
}
 
this._backupItem(item);
 
var element = item.element;
if(attribute === "childNodes"){
var child = value.element;
element.appendChild(child);
}else if(attribute === "text()"){
while (element.firstChild){
element.removeChild(element.firstChild);
}
var text = this._getDocument(element).createTextNode(value);
element.appendChild(text);
}else{
attribute = this._getAttribute(element.nodeName, attribute);
if(attribute.charAt(0) === '@'){
var name = attribute.substring(1);
element.setAttribute(name, value);
}else{
var child = null;
for(var i = 0; i < element.childNodes.length; i++){
var node = element.childNodes[i];
if( node.nodeType === 1 /*ELEMENT_NODE*/&&
node.nodeName === attribute){
child = node;
break;
}
}
var document = this._getDocument(element);
if(child){
while(child.firstChild){
child.removeChild(child.firstChild);
}
}else{
child = document.createElement(attribute);
element.appendChild(child);
}
var text = document.createTextNode(value);
child.appendChild(text);
}
}
return true; //boolean
},
setValues: function(/* item */ item, /* attribute || string */ attribute, /* array */ values){
// summary:
// Set attribute values
// description:
// 'item' must be an instance of a dojox.data.XmlItem from the store instance.
// If 'attribute' specifies "tagName", nothing is set and false is
// returned.
// If 'attribute' specifies "childNodes", the value (array of XML
// elements) is set to the element's childNodes.
// If 'attribute' specifies "text()", a text node is created with
// the values and set it to the element as a child.
// For generic attributes, if '_attributeMap' is specified,
// an actual attribute name is looked up with the tag name of
// the element and 'attribute' (concatenated with '.').
// Then, if 'attribute' starts with "@", the first value is set to
// the XML attribute.
// Otherwise, child elements of the tag name specified with
// 'attribute' are replaced with new child elements and their
// child text nodes of values.
// item:
// An XML element that holds the attribute
// attribute:
// A tag name of child elements, an XML attribute name or one of
// special names
// value:
// A attribute value to set
// returns:
// False for "tagName", otherwise true
if(attribute === "tagName"){
return false; //boolean
}
 
this._backupItem(item);
 
var element = item.element;
if(attribute === "childNodes"){
while(element.firstChild){
element.removeChild(element.firstChild);
}
for(var i = 0; i < values.length; i++){
var child = values[i].element;
element.appendChild(child);
}
}else if(attribute === "text()"){
while (element.firstChild){
element.removeChild(element.firstChild);
}
var value = "";
for(var i = 0; i < values.length; i++){
value += values[i];
}
var text = this._getDocument(element).createTextNode(value);
element.appendChild(text);
}else{
attribute = this._getAttribute(element.nodeName, attribute);
if(attribute.charAt(0) === '@'){
var name = attribute.substring(1);
element.setAttribute(name, values[0]);
}else{
for(var i = element.childNodes.length - 1; i >= 0; i--){
var node = element.childNodes[i];
if( node.nodeType === 1 /*ELEMENT_NODE*/ &&
node.nodeName === attribute){
element.removeChild(node);
}
}
var document = this._getDocument(element);
for(var i = 0; i < values.length; i++){
var child = document.createElement(attribute);
var text = document.createTextNode(values[i]);
child.appendChild(text);
element.appendChild(child);
}
}
}
return true; //boolean
},
unsetAttribute: function(/* item */ item, /* attribute || string */ attribute){
// summary:
// Remove an attribute
// description:
// 'item' must be an instance of a dojox.data.XmlItem from the store instance.
// 'attribute' can be an XML attribute name of the element or one of
// special names described below.
// If 'attribute' specifies "tagName", nothing is removed and false is
// returned.
// If 'attribute' specifies "childNodes" or "text()", all child nodes
// are removed.
// For generic attributes, if '_attributeMap' is specified,
// an actual attribute name is looked up with the tag name of
// the element and 'attribute' (concatenated with '.').
// Then, if 'attribute' starts with "@", the XML attribute is removed.
// Otherwise, child elements of the tag name specified with
// 'attribute' are removed.
// item:
// An XML element that holds the attribute
// attribute:
// A tag name of child elements, an XML attribute name or one of
// special names
// returns:
// False for "tagName", otherwise true
if(attribute === "tagName"){
return false; //boolean
}
 
this._backupItem(item);
 
var element = item.element;
if(attribute === "childNodes" || attribute === "text()"){
while(element.firstChild){
element.removeChild(element.firstChild);
}
}else{
attribute = this._getAttribute(element.nodeName, attribute);
if(attribute.charAt(0) === '@'){
var name = attribute.substring(1);
element.removeAttribute(name);
}else{
for(var i = element.childNodes.length - 1; i >= 0; i--){
var node = element.childNodes[i];
if( node.nodeType === 1 /*ELEMENT_NODE*/ &&
node.nodeName === attribute){
element.removeChild(node);
}
}
}
}
return true; //boolean
},
save: function(/* object */ keywordArgs){
// summary:
// Save new and/or modified items (XML elements)
// description:
// '_url' is used to save XML documents for new, modified and/or
// deleted XML elements.
// keywordArgs:
// An object for callbacks
if(!keywordArgs){
keywordArgs = {};
}
for(var i = 0; i < this._modifiedItems.length; i++){
this._saveItem(this._modifiedItems[i], keywordArgs, "PUT");
}
for(var i = 0; i < this._newItems.length; i++){
var item = this._newItems[i];
if(item.element.parentNode){ // reparented
this._newItems.splice(i, 1);
i--;
continue;
}
this._saveItem(this._newItems[i], keywordArgs, "POST");
}
for(var i = 0; i < this._deletedItems.length; i++){
this._saveItem(this._deletedItems[i], keywordArgs, "DELETE");
}
},
 
revert: function(){
// summary:
// Invalidate changes (new and/or modified elements)
// returns:
// True
console.log("XmlStore.revert() _newItems=" + this._newItems.length);
console.log("XmlStore.revert() _deletedItems=" + this._deletedItems.length);
console.log("XmlStore.revert() _modifiedItems=" + this._modifiedItems.length);
this._newItems = [];
this._restoreItems(this._deletedItems);
this._deletedItems = [];
this._restoreItems(this._modifiedItems);
this._modifiedItems = [];
return true; //boolean
},
isDirty: function(/* item? */ item){
// summary:
// Check whether an item is new, modified or deleted
// description:
// If 'item' is specified, true is returned if the item is new,
// modified or deleted.
// Otherwise, true is returned if there are any new, modified
// or deleted items.
// item:
// An item (XML element) to check
// returns:
// True if an item or items are new, modified or deleted, otherwise
// false
if (item) {
var element = this._getRootElement(item.element);
return (this._getItemIndex(this._newItems, element) >= 0 ||
this._getItemIndex(this._deletedItems, element) >= 0 ||
this._getItemIndex(this._modifiedItems, element) >= 0); //boolean
}
else {
return (this._newItems.length > 0 ||
this._deletedItems.length > 0 ||
this._modifiedItems.length > 0); //boolean
}
},
 
_saveItem: function(item, keywordArgs, method){
if(method === "PUT"){
url = this._getPutUrl(item);
}else if(method === "DELETE"){
url = this._getDeleteUrl(item);
}else{ // POST
url = this._getPostUrl(item);
}
if(!url){
if(keywordArgs.onError){
keywordArgs.onError.call(scope, new Error("No URL for saving content: " + postContent));
}
return;
}
 
var saveArgs = {
url: url,
method: (method || "POST"),
contentType: "text/xml",
handleAs: "xml"
};
var saveHander;
if(method === "PUT"){
saveArgs.putData = this._getPutContent(item);
saveHandler = dojo.rawXhrPut(saveArgs);
}else if(method === "DELETE"){
saveHandler = dojo.xhrDelete(saveArgs);
}else{ // POST
saveArgs.postData = this._getPostContent(item);
saveHandler = dojo.rawXhrPost(saveArgs);
}
var scope = (keywordArgs.scope || dojo.global);
var self = this;
saveHandler.addCallback(function(data){
self._forgetItem(item);
if(keywordArgs.onComplete){
keywordArgs.onComplete.call(scope);
}
});
saveHandler.addErrback(function(error){
if(keywordArgs.onError){
keywordArgs.onError.call(scope, error);
}
});
},
 
_getPostUrl: function(item){
// summary:
// Generate a URL for post
// description:
// This default implementation just returns '_url'.
// Sub-classes may override this method for the custom URL.
// item:
// An item to save
// returns:
// A post URL
return this._url; //string
},
 
_getPutUrl: function(item){
// summary:
// Generate a URL for put
// description:
// This default implementation just returns '_url'.
// Sub-classes may override this method for the custom URL.
// item:
// An item to save
// returns:
// A put URL
return this._url; //string
},
 
_getDeleteUrl: function(item){
// summary:
// Generate a URL for delete
// description:
// This default implementation returns '_url' with '_keyAttribute'
// as a query string.
// Sub-classes may override this method for the custom URL based on
// changes (new, deleted, or modified).
// item:
// An item to delete
// returns:
// A delete URL
if (!this._url) {
return this._url; //string
}
var url = this._url;
if (item && this._keyAttribute) {
var value = this.getValue(item, this._keyAttribute);
if (value) {
url = url + '?' + this._keyAttribute + '=' + value;
}
}
return url; //string
},
 
_getPostContent: function(item){
// summary:
// Generate a content to post
// description:
// This default implementation generates an XML document for one
// (the first only) new or modified element.
// Sub-classes may override this method for the custom post content
// generation.
// item:
// An item to save
// returns:
// A post content
var element = item.element;
var declaration = "<?xml version=\"1.0\"?>"; // FIXME: encoding?
return declaration + dojox.data.dom.innerXML(element); //XML string
},
 
_getPutContent: function(item){
// summary:
// Generate a content to put
// description:
// This default implementation generates an XML document for one
// (the first only) new or modified element.
// Sub-classes may override this method for the custom put content
// generation.
// item:
// An item to save
// returns:
// A post content
var element = item.element;
var declaration = "<?xml version=\"1.0\"?>"; // FIXME: encoding?
return declaration + dojox.data.dom.innerXML(element); //XML string
},
 
/* internal API */
 
_getAttribute: function(tagName, attribute){
if(this._attributeMap){
var key = tagName + "." + attribute;
var value = this._attributeMap[key];
if(value){
attribute = value;
}else{ // look for global attribute
value = this._attributeMap[attribute];
if(value){
attribute = value;
}
}
}
return attribute; //object
},
 
_getItem: function(element){
return new dojox.data.XmlItem(element, this); //object
},
 
_getItemIndex: function(items, element){
for(var i = 0; i < items.length; i++){
if(items[i].element === element){
return i; //int
}
}
return -1; //int
},
 
_backupItem: function(item){
var element = this._getRootElement(item.element);
if( this._getItemIndex(this._newItems, element) >= 0 ||
this._getItemIndex(this._modifiedItems, element) >= 0){
return; // new or already modified
}
if(element != item.element){
item = this._getItem(element);
}
item._backup = element.cloneNode(true);
this._modifiedItems.push(item);
},
 
_restoreItems: function(items){
 
dojo.forEach(items,function(item){
if(item._backup){
item.element = item._backup;
item._backup = null;
}
},this);
},
 
_forgetItem: function(item){
var element = item.element;
var index = this._getItemIndex(this._newItems, element);
if(index >= 0){
this._newItems.splice(index, 1);
}
index = this._getItemIndex(this._deletedItems, element);
if(index >= 0){
this._deletedItems.splice(index, 1);
}
index = this._getItemIndex(this._modifiedItems, element);
if(index >= 0){
this._modifiedItems.splice(index, 1);
}
},
 
_getDocument: function(element){
if(element){
return element.ownerDocument; //DOMDocument
}else if(!this._document){
return dojox.data.dom.createDocument(); // DOMDocument
}
},
 
_getRootElement: function(element){
while(element.parentNode){
element = element.parentNode;
}
return element; //DOMElement
}
 
});
 
//FIXME: Is a full class here really needed for containment of the item or would
//an anon object work fine?
dojo.declare("dojox.data.XmlItem", null, {
constructor: function(element, store) {
// summary:
// Initialize with an XML element
// element:
// An XML element
// store:
// The containing store, if any.
this.element = element;
this.store = store;
},
// summary:
// A data item of 'XmlStore'
// description:
// This class represents an item of 'XmlStore' holding an XML element.
// 'element'
// element:
// An XML element
 
toString: function() {
// summary:
// Return a value of the first text child of the element
// returns:
// a value of the first text child of the element
var str = "";
if (this.element) {
for (var i = 0; i < this.element.childNodes.length; i++) {
var node = this.element.childNodes[i];
if (node.nodeType === 3) {
str = node.nodeValue;
break;
}
}
}
return str; //String
}
 
});
dojo.extend(dojox.data.XmlStore,dojo.data.util.simpleFetch);
 
}
/trunk/api/js/dojo1.0/dojox/data/QueryReadStore.js
New file
0,0 → 1,474
if(!dojo._hasResource["dojox.data.QueryReadStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.QueryReadStore"] = true;
dojo.provide("dojox.data.QueryReadStore");
dojo.provide("dojox.data.QueryReadStore.InvalidItemError");
dojo.provide("dojox.data.QueryReadStore.InvalidAttributeError");
 
dojo.require("dojo.string");
dojo.require("dojo.data.util.simpleFetch");
 
dojo.declare("dojox.data.QueryReadStore", null, {
/*
// summary:
// This class provides a store that is mainly intended to be used
// for loading data dynamically from the server, used i.e. for
// retreiving chunks of data from huge data stores on the server (by server-side filtering!).
// Upon calling the fetch() method of this store the data are requested from
// the server if they are not yet loaded for paging (or cached).
//
// For example used for a combobox which works on lots of data. It
// can be used to retreive the data partially upon entering the
// letters "ac" it returns only items like "action", "acting", etc.
//
// note:
// The field name "id" in a query is reserved for looking up data
// by id. This is necessary as before the first fetch, the store
// has no way of knowing which field the server will declare as
// identifier.
//
// examples:
// // The parameter "query" contains the data that are sent to the server.
// var store = new dojox.data.QueryReadStore({url:'/search.php'});
// store.fetch({query:{name:'a'}, queryOptions:{ignoreCase:false}});
//
// // Since "serverQuery" is given, it overrules and those data are
// // sent to the server.
// var store = new dojox.data.QueryReadStore({url:'/search.php'});
// store.fetch({serverQuery:{name:'a'}, queryOptions:{ignoreCase:false}});
//
// todo:
// - there is a bug in the paging, when i set start:2, count:5 after an initial fetch() and doClientPaging:true
// it returns 6 elemetns, though count=5, try it in QueryReadStore.html
// - allow configuring if the paging shall takes place on the client or the server
// - add optional caching
// - when the first query searched for "a" and the next for a subset of
// the first, i.e. "ab" then we actually dont need a server request, if
// we have client paging, we just need to filter the items we already have
// that might also be tooo much logic
*/
url:"",
requestMethod:"get",
//useCache:false,
// We use the name in the errors, once the name is fixed hardcode it, may be.
_className:"dojox.data.QueryReadStore",
// This will contain the items we have loaded from the server.
// The contents of this array is optimized to satisfy all read-api requirements
// and for using lesser storage, so the keys and their content need some explaination:
// this._items[0].i - the item itself
// this._items[0].r - a reference to the store, so we can identify the item
// securly. We set this reference right after receiving the item from the
// server.
_items:[],
// Store the last query that triggered xhr request to the server.
// So we can compare if the request changed and if we shall reload
// (this also depends on other factors, such as is caching used, etc).
_lastServerQuery:null,
// Store a hash of the last server request. Actually I introduced this
// for testing, so I can check if no unnecessary requests were issued for
// client-side-paging.
lastRequestHash:null,
// If this is false, every request is sent to the server.
// If it's true a second request with the same query will not issue another
// request, but use the already returned data. This assumes that the server
// does not do the paging.
doClientPaging:true,
 
// Items by identify for Identify API
_itemsByIdentity:null,
// Identifier used
_identifier:null,
 
_features: {'dojo.data.api.Read':true, 'dojo.data.api.Identity':true},
constructor: function(/* Object */ params){
dojo.mixin(this,params);
},
getValue: function(/* item */ item, /* attribute-name-string */ attribute, /* value? */ defaultValue){
// According to the Read API comments in getValue() and exception is
// thrown when an item is not an item or the attribute not a string!
this._assertIsItem(item);
if (!dojo.isString(attribute)) {
throw new Error(this._className+".getValue(): Invalid attribute, string expected!");
}
if(!this.hasAttribute(item, attribute)){
// read api says: return defaultValue "only if *item* does not have a value for *attribute*."
// Is this the case here? The attribute doesn't exist, but a defaultValue, sounds reasonable.
if(defaultValue){
return defaultValue;
}
console.log(this._className+".getValue(): Item does not have the attribute '"+attribute+"'.");
}
return item.i[attribute];
},
getValues: function(/* item */ item, /* attribute-name-string */ attribute){
var ret = [];
if(this.hasAttribute(item, attribute)){
ret.push(item.i[attribute]);
}
return ret;
},
getAttributes: function(/* item */ item){
this._assertIsItem(item);
var ret = [];
for(var i in item.i){
ret.push(i);
}
return ret;
},
 
hasAttribute: function(/* item */ item, /* attribute-name-string */ attribute) {
// summary:
// See dojo.data.api.Read.hasAttribute()
return this.isItem(item) && typeof item.i[attribute]!="undefined";
},
containsValue: function(/* item */ item, /* attribute-name-string */ attribute, /* anything */ value){
var values = this.getValues(item, attribute);
var len = values.length;
for(var i=0; i<len; i++){
if(values[i]==value){
return true;
}
}
return false;
},
isItem: function(/* anything */ something){
// Some basic tests, that are quick and easy to do here.
// >>> var store = new dojox.data.QueryReadStore({});
// >>> store.isItem("");
// false
//
// >>> var store = new dojox.data.QueryReadStore({});
// >>> store.isItem({});
// false
//
// >>> var store = new dojox.data.QueryReadStore({});
// >>> store.isItem(0);
// false
//
// >>> var store = new dojox.data.QueryReadStore({});
// >>> store.isItem({name:"me", label:"me too"});
// false
//
if(something){
return typeof something.r!="undefined" && something.r==this;
}
return false;
},
isItemLoaded: function(/* anything */ something) {
// Currently we dont have any state that tells if an item is loaded or not
// if the item exists its also loaded.
// This might change when we start working with refs inside items ...
return this.isItem(something);
},
 
loadItem: function(/* object */ args){
if(this.isItemLoaded(args.item)){
return;
}
// Actually we have nothing to do here, or at least I dont know what to do here ...
},
 
fetch:function(/* Object? */ request){
// summary:
// See dojo.data.util.simpleFetch.fetch() this is just a copy and I adjusted
// only the paging, since it happens on the server if doClientPaging is
// false, thx to http://trac.dojotoolkit.org/ticket/4761 reporting this.
// Would be nice to be able to use simpleFetch() to reduce copied code,
// but i dont know how yet. Ideas please!
request = request || {};
if(!request.store){
request.store = this;
}
var self = this;
var _errorHandler = function(errorData, requestObject){
if(requestObject.onError){
var scope = requestObject.scope || dojo.global;
requestObject.onError.call(scope, errorData, requestObject);
}
};
var _fetchHandler = function(items, requestObject){
var oldAbortFunction = requestObject.abort || null;
var aborted = false;
var startIndex = requestObject.start?requestObject.start:0;
if (self.doClientPaging==false) {
// For client paging we dont need no slicing of the result.
startIndex = 0;
}
var endIndex = requestObject.count?(startIndex + requestObject.count):items.length;
requestObject.abort = function(){
aborted = true;
if(oldAbortFunction){
oldAbortFunction.call(requestObject);
}
};
var scope = requestObject.scope || dojo.global;
if(!requestObject.store){
requestObject.store = self;
}
if(requestObject.onBegin){
requestObject.onBegin.call(scope, items.length, requestObject);
}
if(requestObject.sort){
items.sort(dojo.data.util.sorter.createSortFunction(requestObject.sort, self));
}
if(requestObject.onItem){
for(var i = startIndex; (i < items.length) && (i < endIndex); ++i){
var item = items[i];
if(!aborted){
requestObject.onItem.call(scope, item, requestObject);
}
}
}
if(requestObject.onComplete && !aborted){
var subset = null;
if (!requestObject.onItem) {
subset = items.slice(startIndex, endIndex);
}
requestObject.onComplete.call(scope, subset, requestObject);
}
};
this._fetchItems(request, _fetchHandler, _errorHandler);
return request; // Object
},
 
getFeatures: function(){
return this._features;
},
 
close: function(/*dojo.data.api.Request || keywordArgs || null */ request){
// I have no idea if this is really needed ...
},
 
getLabel: function(/* item */ item){
// Override it to return whatever the label shall be, see Read-API.
return undefined;
},
 
getLabelAttributes: function(/* item */ item){
return null;
},
_fetchItems: function(request, fetchHandler, errorHandler){
// summary:
// The request contains the data as defined in the Read-API.
// Additionally there is following keyword "serverQuery".
//
// The *serverQuery* parameter, optional.
// This parameter contains the data that will be sent to the server.
// If this parameter is not given the parameter "query"'s
// data are sent to the server. This is done for some reasons:
// - to specify explicitly which data are sent to the server, they
// might also be a mix of what is contained in "query", "queryOptions"
// and the paging parameters "start" and "count" or may be even
// completely different things.
// - don't modify the request.query data, so the interface using this
// store can rely on unmodified data, as the combobox dijit currently
// does it, it compares if the query has changed
// - request.query is required by the Read-API
//
// I.e. the following examples might be sent via GET:
// fetch({query:{name:"abc"}, queryOptions:{ignoreCase:true}})
// the URL will become: /url.php?name=abc
//
// fetch({serverQuery:{q:"abc", c:true}, query:{name:"abc"}, queryOptions:{ignoreCase:true}})
// the URL will become: /url.php?q=abc&c=true
// // The serverQuery-parameter has overruled the query-parameter
// // but the query parameter stays untouched, but is not sent to the server!
// // The serverQuery contains more data than the query, so they might differ!
//
 
var serverQuery = request.serverQuery || request.query || {};
//Need to add start and count
if(!this.doClientPaging){
serverQuery.start = request.start || 0;
// Count might not be sent if not given.
if (request.count) {
serverQuery.count = request.count;
}
}
// Compare the last query and the current query by simply json-encoding them,
// so we dont have to do any deep object compare ... is there some dojo.areObjectsEqual()???
if(this.doClientPaging && this._lastServerQuery!==null &&
dojo.toJson(serverQuery)==dojo.toJson(this._lastServerQuery)
){
fetchHandler(this._items, request);
}else{
var xhrFunc = this.requestMethod.toLowerCase()=="post" ? dojo.xhrPost : dojo.xhrGet;
var xhrHandler = xhrFunc({url:this.url, handleAs:"json-comment-optional", content:serverQuery});
xhrHandler.addCallback(dojo.hitch(this, function(data){
data=this._filterResponse(data);
this._items = [];
// Store a ref to "this" in each item, so we can simply check if an item
// really origins form here (idea is from ItemFileReadStore, I just don't know
// how efficient the real storage use, garbage collection effort, etc. is).
dojo.forEach(data.items,function(e){
this._items.push({i:e, r:this});
},this);
var identifier = data.identifier;
this._itemsByIdentity = {};
if(identifier){
this._identifier = identifier;
for(i = 0; i < this._items.length; ++i){
var item = this._items[i].i;
var identity = item[identifier];
if(!this._itemsByIdentity[identity]){
this._itemsByIdentity[identity] = item;
}else{
throw new Error("dojo.data.QueryReadStore: The json data as specified by: [" + this.url + "] is malformed. Items within the list have identifier: [" + identifier + "]. Value collided: [" + identity + "]");
}
}
}else{
this._identifier = Number;
for(i = 0; i < this._items.length; ++i){
this._items[i].n = i;
}
}
// TODO actually we should do the same as dojo.data.ItemFileReadStore._getItemsFromLoadedData() to sanitize
// (does it really sanititze them) and store the data optimal. should we? for security reasons???
fetchHandler(this._items, request);
}));
xhrHandler.addErrback(function(error){
errorHandler(error, request);
});
// Generate the hash using the time in milliseconds and a randon number.
// Since Math.randon() returns something like: 0.23453463, we just remove the "0."
// probably just for esthetic reasons :-).
this.lastRequestHash = new Date().getTime()+"-"+String(Math.random()).substring(2);
this._lastServerQuery = dojo.mixin({}, serverQuery);
}
},
_filterResponse: function(data){
// summary:
// If the data from servers needs to be processed before it can be processed by this
// store, then this function should be re-implemented in subclass. This default
// implementation just return the data unchanged.
// data:
// The data received from server
return data;
},
 
_assertIsItem: function(/* item */ item){
// summary:
// It throws an error if item is not valid, so you can call it in every method that needs to
// throw an error when item is invalid.
// item:
// The item to test for being contained by the store.
if(!this.isItem(item)){
throw new dojox.data.QueryReadStore.InvalidItemError(this._className+": a function was passed an item argument that was not an item");
}
},
 
_assertIsAttribute: function(/* attribute-name-string */ attribute){
// summary:
// This function tests whether the item passed in is indeed a valid 'attribute' like type for the store.
// attribute:
// The attribute to test for being contained by the store.
if(typeof attribute !== "string"){
throw new dojox.data.QueryReadStore.InvalidAttributeError(this._className+": '"+attribute+"' is not a valid attribute identifier.");
}
},
 
fetchItemByIdentity: function(/* Object */ keywordArgs){
// summary:
// See dojo.data.api.Identity.fetchItemByIdentity()
 
// See if we have already loaded the item with that id
// In case there hasn't been a fetch yet, _itemsByIdentity is null
// and thus a fetch will be triggered below.
if(this._itemsByIdentity){
var item = this._itemsByIdentity[keywordArgs.identity];
if(!(item === undefined)){
if(keywordArgs.onItem){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
keywordArgs.onItem.call(scope, {i:item, r:this});
}
return;
}
}
 
// Otherwise we need to go remote
// Set up error handler
var _errorHandler = function(errorData, requestObject){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
if(keywordArgs.onError){
keywordArgs.onError.call(scope, error);
}
};
// Set up fetch handler
var _fetchHandler = function(items, requestObject){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
try{
// There is supposed to be only one result
var item = null;
if(items && items.length == 1){
item = items[0];
}
// If no item was found, item is still null and we'll
// fire the onItem event with the null here
if(keywordArgs.onItem){
keywordArgs.onItem.call(scope, item);
}
}catch(error){
if(keywordArgs.onError){
keywordArgs.onError.call(scope, error);
}
}
};
// Construct query
var request = {serverQuery:{id:keywordArgs.identity}};
// Dispatch query
this._fetchItems(request, _fetchHandler, _errorHandler);
},
getIdentity: function(/* item */ item){
// summary:
// See dojo.data.api.Identity.getIdentity()
var identifier = null;
if(this._identifier === Number){
identifier = item.n; // Number
}else{
identifier = item.i[this._identifier];
}
return identifier;
},
getIdentityAttributes: function(/* item */ item){
// summary:
// See dojo.data.api.Identity.getIdentityAttributes()
return [this._identifier];
}
});
 
dojo.declare("dojox.data.QueryReadStore.InvalidItemError", Error, {});
dojo.declare("dojox.data.QueryReadStore.InvalidAttributeError", Error, {});
 
 
 
 
}
/trunk/api/js/dojo1.0/dojox/data/dom.js
New file
0,0 → 1,187
if(!dojo._hasResource["dojox.data.dom"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.dom"] = true;
dojo.provide("dojox.data.dom");
 
//DOM type to int value for reference.
//Ints make for more compact code than full constant names.
//ELEMENT_NODE = 1;
//ATTRIBUTE_NODE = 2;
//TEXT_NODE = 3;
//CDATA_SECTION_NODE = 4;
//ENTITY_REFERENCE_NODE = 5;
//ENTITY_NODE = 6;
//PROCESSING_INSTRUCTION_NODE = 7;
//COMMENT_NODE = 8;
//DOCUMENT_NODE = 9;
//DOCUMENT_TYPE_NODE = 10;
//DOCUMENT_FRAGMENT_NODE = 11;
//NOTATION_NODE = 12;
 
//FIXME: Remove this file when possible.
//This file contains internal/helper APIs as holders until the true DOM apis of Dojo 0.9 are finalized.
//Therefore, these should not be generally used, they are present only for the use by XmlStore and the
//wires project until proper dojo replacements are available. When such exist, XmlStore and the like
//will be ported off these and this file will be deleted.
dojo.experimental("dojox.data.dom");
 
dojox.data.dom.createDocument = function(/*string?*/ str, /*string?*/ mimetype){
// summary:
// cross-browser implementation of creating an XML document object.
//
// str:
// Optional text to create the document from. If not provided, an empty XML document will be created.
// mimetype:
// Optional mimetype of the text. Typically, this is text/xml. Will be defaulted to text/xml if not provided.
var _document = dojo.doc;
 
if(!mimetype){ mimetype = "text/xml"; }
if(str && (typeof dojo.global["DOMParser"]) !== "undefined"){
var parser = new DOMParser();
return parser.parseFromString(str, mimetype); // DOMDocument
}else if((typeof dojo.global["ActiveXObject"]) !== "undefined"){
var prefixes = [ "MSXML2", "Microsoft", "MSXML", "MSXML3" ];
for(var i = 0; i<prefixes.length; i++){
try{
var doc = new ActiveXObject(prefixes[i]+".XMLDOM");
if(str){
if(doc){
doc.async = false;
doc.loadXML(str);
return doc; // DOMDocument
}else{
console.log("loadXML didn't work?");
}
}else{
if(doc){
return doc; //DOMDocument
}
}
}catch(e){ /* squelch */ };
}
}else if((_document.implementation)&&
(_document.implementation.createDocument)){
if(str){
if(_document.createElement){
// FIXME: this may change all tags to uppercase!
var tmp = _document.createElement("xml");
tmp.innerHTML = str;
var xmlDoc = _document.implementation.createDocument("foo", "", null);
for(var i = 0; i < tmp.childNodes.length; i++) {
xmlDoc.importNode(tmp.childNodes.item(i), true);
}
return xmlDoc; // DOMDocument
}
}else{
return _document.implementation.createDocument("", "", null); // DOMDocument
}
}
return null; // DOMDocument
}
 
dojox.data.dom.textContent = function(/*Node*/node, /*string?*/text){
// summary:
// Implementation of the DOM Level 3 attribute; scan node for text
// description:
// Implementation of the DOM Level 3 attribute; scan node for text
// This function can also update the text of a node by replacing all child
// content of the node.
// node:
// The node to get the text off of or set the text on.
// text:
// Optional argument of the text to apply to the node.
if(arguments.length>1){
var _document = node.ownerDocument || dojo.doc; //Preference is to get the node owning doc first or it may fail
dojox.data.dom.replaceChildren(node, _document.createTextNode(text));
return text; // string
} else {
if(node.textContent !== undefined){ //FF 1.5
return node.textContent; // string
}
var _result = "";
if(node == null){
return _result; //empty string.
}
for(var i = 0; i < node.childNodes.length; i++){
switch(node.childNodes[i].nodeType){
case 1: // ELEMENT_NODE
case 5: // ENTITY_REFERENCE_NODE
_result += dojox.data.dom.textContent(node.childNodes[i]);
break;
case 3: // TEXT_NODE
case 2: // ATTRIBUTE_NODE
case 4: // CDATA_SECTION_NODE
_result += node.childNodes[i].nodeValue;
break;
default:
break;
}
}
return _result; // string
}
}
 
dojox.data.dom.replaceChildren = function(/*Element*/node, /*Node || array*/ newChildren){
// summary:
// Removes all children of node and appends newChild. All the existing
// children will be destroyed.
// description:
// Removes all children of node and appends newChild. All the existing
// children will be destroyed.
// node:
// The node to modify the children on
// newChildren:
// The children to add to the node. It can either be a single Node or an
// array of Nodes.
var nodes = [];
if(dojo.isIE){
for(var i=0;i<node.childNodes.length;i++){
nodes.push(node.childNodes[i]);
}
}
 
dojox.data.dom.removeChildren(node);
for(var i=0;i<nodes.length;i++){
dojo._destroyElement(nodes[i]);
}
 
if(!dojo.isArray(newChildren)){
node.appendChild(newChildren);
}else{
for(var i=0;i<newChildren.length;i++){
node.appendChild(newChildren[i]);
}
}
}
 
dojox.data.dom.removeChildren = function(/*Element*/node){
// summary:
// removes all children from node and returns the count of children removed.
// The children nodes are not destroyed. Be sure to call dojo._destroyElement on them
// after they are not used anymore.
// node:
// The node to remove all the children from.
var count = node.childNodes.length;
while(node.hasChildNodes()){
node.removeChild(node.firstChild);
}
return count; // int
}
 
 
dojox.data.dom.innerXML = function(/*Node*/node){
// summary:
// Implementation of MS's innerXML function.
// node:
// The node from which to generate the XML text representation.
if(node.innerXML){
return node.innerXML; // string
}else if (node.xml){
return node.xml; // string
}else if(typeof XMLSerializer != "undefined"){
return (new XMLSerializer()).serializeToString(node); // string
}
}
 
 
}
/trunk/api/js/dojo1.0/dojox/data/README
New file
0,0 → 1,62
-------------------------------------------------------------------------------
DojoX Data
-------------------------------------------------------------------------------
Version 1.0
Release date: 05/29/2007
-------------------------------------------------------------------------------
Project state: stable
-------------------------------------------------------------------------------
Project authors
Jared Jurkiewicz (jared.jurkiewicz@gmail.com)
Shane O'Sullivan (shaneosullivan1@gmail.com) (FlickrRestStore)
Wolfram Kriesing (wolfram@kriesing.de) (QueryReadStore)
-------------------------------------------------------------------------------
Project description
 
The DojoX Data project is a container for extensions and extra example stores
that implement the dojo.data APIs. It may also contain utility functions for
working with specific types of data.
 
-------------------------------------------------------------------------------
Dependencies:
 
DojoX Data has dependencies on core dojo (dojo.data) and the D.O.H. unit test
framework.
-------------------------------------------------------------------------------
Documentation:
 
See the Dojo API tool (http://dojotoolkit.org/api)
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/data/*
 
Install into the following directory structure:
/dojox/data/
 
...which should be at the same level as your Dojo checkout.
 
/dojox/data/*
 
Require in the dojox.data stores you wish to use.
-------------------------------------------------------------------------------
Additional Notes:
dojox.data.CvsStore - comma-separated (spreadsheet output)
datastore implementation
dojox.data.FlickrRestStore - advanced version of: dojox.data.FlickrStore
(Caching + user key support)
dojox.data.FlickrStore - data store driven by Flickr.com public API.
dojox.data.HtmlTableStore - Implementation of an HTML Table reading
datastore
dojox.data.OpmlStore - Store for reading OMPL formatted data
dojox.data.XmlStore - datastore for XML based services or
documents.
 
dojox.data.QueryReadStore - datastore to provide serverside URL query
matching. Similar to the 0.4.X ComboBox dataUrl parameter.
/trunk/api/js/dojo1.0/dojox/data/OpmlStore.js
New file
0,0 → 1,515
if(!dojo._hasResource["dojox.data.OpmlStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.OpmlStore"] = true;
dojo.provide("dojox.data.OpmlStore");
 
dojo.require("dojo.data.util.filter");
dojo.require("dojo.data.util.simpleFetch");
 
dojo.declare("dojox.data.OpmlStore", null, {
/* summary:
* The OpmlStore implements the dojo.data.api.Read API.
*/
/* examples:
* var opmlStore = new dojo.data.OpmlStore({url:"geography.xml"});
* var opmlStore = new dojo.data.OpmlStore({url:"http://example.com/geography.xml"});
*/
constructor: function(/* Object */ keywordParameters){
// summary: constructor
// keywordParameters: {url: String, label: String} Where label is optional and configures what should be used as the return from getLabel()
this._xmlData = null;
this._arrayOfTopLevelItems = [];
this._arrayOfAllItems = [];
this._metadataNodes = null;
this._loadFinished = false;
this.url = keywordParameters.url;
this._opmlData = keywordParameters.data; // XML DOM Document
if(keywordParameters.label){
this.label = keywordParameters.label;
}
this._loadInProgress = false; //Got to track the initial load to prevent duelling loads of the dataset.
this._queuedFetches = [];
this._identityMap = {};
this._identCount = 0;
this._idProp = "_I";
},
 
label: "text",
 
url: "",
 
_assertIsItem: function(/* item */ item){
if(!this.isItem(item)){
throw new Error("dojo.data.OpmlStore: a function was passed an item argument that was not an item");
}
},
_assertIsAttribute: function(/* item || String */ attribute){
// summary:
// This function tests whether the item passed in is indeed a valid 'attribute' like type for the store.
// attribute:
// The attribute to test for being contained by the store.
if(!dojo.isString(attribute)){
throw new Error("dojox.data.OpmlStore: a function was passed an attribute argument that was not an attribute object nor an attribute name string");
}
},
_removeChildNodesThatAreNotElementNodes: function(/* node */ node, /* boolean */ recursive){
var childNodes = node.childNodes;
if(childNodes.length === 0){
return;
}
var nodesToRemove = [];
var i, childNode;
for(i = 0; i < childNodes.length; ++i){
childNode = childNodes[i];
if(childNode.nodeType != 1){
nodesToRemove.push(childNode);
}
}
for(i = 0; i < nodesToRemove.length; ++i){
childNode = nodesToRemove[i];
node.removeChild(childNode);
}
if(recursive){
for(i = 0; i < childNodes.length; ++i){
childNode = childNodes[i];
this._removeChildNodesThatAreNotElementNodes(childNode, recursive);
}
}
},
_processRawXmlTree: function(/* xmlDoc */ rawXmlTree){
this._loadFinished = true;
this._xmlData = rawXmlTree;
var headNodes = rawXmlTree.getElementsByTagName('head');
var headNode = headNodes[0];
if(headNode){
this._removeChildNodesThatAreNotElementNodes(headNode);
this._metadataNodes = headNode.childNodes;
}
var bodyNodes = rawXmlTree.getElementsByTagName('body');
var bodyNode = bodyNodes[0];
if(bodyNode){
this._removeChildNodesThatAreNotElementNodes(bodyNode, true);
var bodyChildNodes = bodyNodes[0].childNodes;
for(var i = 0; i < bodyChildNodes.length; ++i){
var node = bodyChildNodes[i];
if(node.tagName == 'outline'){
this._identityMap[this._identCount] = node;
this._identCount++;
this._arrayOfTopLevelItems.push(node);
this._arrayOfAllItems.push(node);
this._checkChildNodes(node);
}
}
}
},
 
_checkChildNodes: function(node /*Node*/){
// summary:
// Internal function to recurse over all child nodes from the store and add them
// As non-toplevel items
// description:
// Internal function to recurse over all child nodes from the store and add them
// As non-toplevel items
//
// node:
// The child node to walk.
if(node.firstChild){
for(var i = 0; i < node.childNodes.length; i++){
var child = node.childNodes[i];
if(child.tagName == 'outline'){
this._identityMap[this._identCount] = child;
this._identCount++;
this._arrayOfAllItems.push(child);
this._checkChildNodes(child);
}
}
}
},
 
_getItemsArray: function(/*object?*/queryOptions){
// summary:
// Internal function to determine which list of items to search over.
// queryOptions: The query options parameter, if any.
if(queryOptions && queryOptions.deep) {
return this._arrayOfAllItems;
}
return this._arrayOfTopLevelItems;
},
 
/***************************************
dojo.data.api.Read API
***************************************/
getValue: function( /* item */ item,
/* attribute || attribute-name-string */ attribute,
/* value? */ defaultValue){
// summary:
// See dojo.data.api.Read.getValue()
this._assertIsItem(item);
this._assertIsAttribute(attribute);
if(attribute == 'children'){
return (item.firstChild || defaultValue); //Object
} else {
var value = item.getAttribute(attribute);
return (value !== undefined) ? value : defaultValue; //Object
}
},
getValues: function(/* item */ item,
/* attribute || attribute-name-string */ attribute){
// summary:
// See dojo.data.api.Read.getValues()
this._assertIsItem(item);
this._assertIsAttribute(attribute);
var array = [];
if(attribute == 'children'){
for(var i = 0; i < item.childNodes.length; ++i){
array.push(item.childNodes[i]);
}
} else if(item.getAttribute(attribute) !== null){
array.push(item.getAttribute(attribute));
}
return array; // Array
},
getAttributes: function(/* item */ item){
// summary:
// See dojo.data.api.Read.getAttributes()
this._assertIsItem(item);
var attributes = [];
var xmlNode = item;
var xmlAttributes = xmlNode.attributes;
for(var i = 0; i < xmlAttributes.length; ++i){
var xmlAttribute = xmlAttributes.item(i);
attributes.push(xmlAttribute.nodeName);
}
if(xmlNode.childNodes.length > 0){
attributes.push('children');
}
return attributes; //Array
},
hasAttribute: function( /* item */ item,
/* attribute || attribute-name-string */ attribute){
// summary:
// See dojo.data.api.Read.hasAttribute()
return (this.getValues(item, attribute).length > 0); //Boolean
},
containsValue: function(/* item */ item,
/* attribute || attribute-name-string */ attribute,
/* anything */ value){
// summary:
// See dojo.data.api.Read.containsValue()
var regexp = undefined;
if(typeof value === "string"){
regexp = dojo.data.util.filter.patternToRegExp(value, false);
}
return this._containsValue(item, attribute, value, regexp); //boolean.
},
 
_containsValue: function( /* item */ item,
/* attribute || attribute-name-string */ attribute,
/* anything */ value,
/* RegExp?*/ regexp){
// summary:
// Internal function for looking at the values contained by the item.
// description:
// Internal function for looking at the values contained by the item. This
// function allows for denoting if the comparison should be case sensitive for
// strings or not (for handling filtering cases where string case should not matter)
//
// item:
// The data item to examine for attribute values.
// attribute:
// The attribute to inspect.
// value:
// The value to match.
// regexp:
// Optional regular expression generated off value if value was of string type to handle wildcarding.
// If present and attribute values are string, then it can be used for comparison instead of 'value'
var values = this.getValues(item, attribute);
for(var i = 0; i < values.length; ++i){
var possibleValue = values[i];
if(typeof possibleValue === "string" && regexp){
return (possibleValue.match(regexp) !== null);
}else{
//Non-string matching.
if(value === possibleValue){
return true; // Boolean
}
}
}
return false; // Boolean
},
isItem: function(/* anything */ something){
// summary:
// See dojo.data.api.Read.isItem()
// description:
// Four things are verified to ensure that "something" is an item:
// something can not be null, the nodeType must be an XML Element,
// the tagName must be "outline", and the node must be a member of
// XML document for this datastore.
return (something &&
something.nodeType == 1 &&
something.tagName == 'outline' &&
something.ownerDocument === this._xmlData); //Boolean
},
isItemLoaded: function(/* anything */ something){
// summary:
// See dojo.data.api.Read.isItemLoaded()
// OpmlStore loads every item, so if it's an item, then it's loaded.
return this.isItem(something); //Boolean
},
loadItem: function(/* item */ item){
// summary:
// See dojo.data.api.Read.loadItem()
// description:
// The OpmlStore always loads all items, so if it's an item, then it's loaded.
// From the dojo.data.api.Read.loadItem docs:
// If a call to isItemLoaded() returns true before loadItem() is even called,
// then loadItem() need not do any work at all and will not even invoke the callback handlers.
},
 
getLabel: function(/* item */ item){
// summary:
// See dojo.data.api.Read.getLabel()
if(this.isItem(item)){
return this.getValue(item,this.label); //String
}
return undefined; //undefined
},
 
getLabelAttributes: function(/* item */ item){
// summary:
// See dojo.data.api.Read.getLabelAttributes()
return [this.label]; //array
},
 
// The dojo.data.api.Read.fetch() function is implemented as
// a mixin from dojo.data.util.simpleFetch.
// That mixin requires us to define _fetchItems().
_fetchItems: function( /* Object */ keywordArgs,
/* Function */ findCallback,
/* Function */ errorCallback){
// summary:
// See dojo.data.util.simpleFetch.fetch()
var self = this;
var filter = function(requestArgs, arrayOfItems){
var items = null;
if(requestArgs.query){
items = [];
var ignoreCase = requestArgs.queryOptions ? requestArgs.queryOptions.ignoreCase : false;
 
//See if there are any string values that can be regexp parsed first to avoid multiple regexp gens on the
//same value for each item examined. Much more efficient.
var regexpList = {};
for(var key in requestArgs.query){
var value = requestArgs.query[key];
if(typeof value === "string"){
regexpList[key] = dojo.data.util.filter.patternToRegExp(value, ignoreCase);
}
}
 
for(var i = 0; i < arrayOfItems.length; ++i){
var match = true;
var candidateItem = arrayOfItems[i];
for(var key in requestArgs.query){
var value = requestArgs.query[key];
if(!self._containsValue(candidateItem, key, value, regexpList[key])){
match = false;
}
}
if(match){
items.push(candidateItem);
}
}
}else{
// We want a copy to pass back in case the parent wishes to sort the array. We shouldn't allow resort
// of the internal list so that multiple callers can get lists and sort without affecting each other.
if(arrayOfItems.length> 0){
items = arrayOfItems.slice(0,arrayOfItems.length);
}
}
findCallback(items, requestArgs);
};
 
if(this._loadFinished){
filter(keywordArgs, this._getItemsArray(keywordArgs.queryOptions));
}else{
 
//If fetches come in before the loading has finished, but while
//a load is in progress, we have to defer the fetching to be
//invoked in the callback.
if(this._loadInProgress){
this._queuedFetches.push({args: keywordArgs, filter: filter});
}else{
if(this.url !== ""){
this._loadInProgress = true;
var getArgs = {
url: self.url,
handleAs: "xml"
};
var getHandler = dojo.xhrGet(getArgs);
getHandler.addCallback(function(data){
self._processRawXmlTree(data);
filter(keywordArgs, self._getItemsArray(keywordArgs.queryOptions));
self._handleQueuedFetches();
});
getHandler.addErrback(function(error){
throw error;
});
}else if(this._opmlData){
this._processRawXmlTree(this._opmlData);
this._opmlData = null;
filter(keywordArgs, this._getItemsArray(keywordArgs.queryOptions));
}else{
throw new Error("dojox.data.OpmlStore: No OPML source data was provided as either URL or XML data input.");
}
}
}
},
getFeatures: function(){
// summary: See dojo.data.api.Read.getFeatures()
var features = {
'dojo.data.api.Read': true,
'dojo.data.api.Identity': true
};
return features; //Object
},
 
/***************************************
dojo.data.api.Identity API
***************************************/
getIdentity: function(/* item */ item){
// summary:
// See dojo.data.api.Identity.getIdentity()
if(this.isItem(item)){
//No ther way to do this other than O(n) without
//complete rework of how the tree stores nodes.
for(var i in this._identityMap){
if(this._identityMap[i] === item){
return i;
}
}
}
return null; //null
},
 
fetchItemByIdentity: function(/* Object */ keywordArgs){
// summary:
// See dojo.data.api.Identity.fetchItemByIdentity()
 
//Hasn't loaded yet, we have to trigger the load.
if(!this._loadFinished){
var self = this;
if(this.url !== ""){
//If fetches come in before the loading has finished, but while
//a load is in progress, we have to defer the fetching to be
//invoked in the callback.
if(this._loadInProgress){
this._queuedFetches.push({args: keywordArgs});
}else{
this._loadInProgress = true;
var getArgs = {
url: self.url,
handleAs: "xml"
};
var getHandler = dojo.xhrGet(getArgs);
getHandler.addCallback(function(data){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
try{
self._processRawXmlTree(data);
var item = self._identityMap[keywordArgs.identity];
if(!self.isItem(item)){
item = null;
}
if(keywordArgs.onItem){
keywordArgs.onItem.call(scope, item);
}
self._handleQueuedFetches();
}catch(error){
if(keywordArgs.onError){
keywordArgs.onError.call(scope, error);
}
}
});
getHandler.addErrback(function(error){
this._loadInProgress = false;
if(keywordArgs.onError){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
keywordArgs.onError.call(scope, error);
}
});
}
}else if(this._opmlData){
this._processRawXmlTree(this._opmlData);
this._opmlData = null;
var item = this._identityMap[keywordArgs.identity];
if(!self.isItem(item)){
item = null;
}
if(keywordArgs.onItem){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
keywordArgs.onItem.call(scope, item);
}
}
}else{
//Already loaded. We can just look it up and call back.
var item = this._identityMap[keywordArgs.identity];
if(!this.isItem(item)){
item = null;
}
if(keywordArgs.onItem){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
keywordArgs.onItem.call(scope, item);
}
}
},
 
getIdentityAttributes: function(/* item */ item){
// summary:
// See dojo.data.api.Identity.getIdentifierAttributes()
//Identity isn't a public attribute in the item, it's the node count.
//So, return null.
return null;
},
 
_handleQueuedFetches: function(){
// summary:
// Internal function to execute delayed request in the store.
//Execute any deferred fetches now.
if (this._queuedFetches.length > 0) {
for(var i = 0; i < this._queuedFetches.length; i++){
var fData = this._queuedFetches[i];
var delayedQuery = fData.args;
var delayedFilter = fData.filter;
if(delayedFilter){
delayedFilter(delayedQuery, this._getItemsArray(delayedQuery.queryOptions));
}else{
this.fetchItemByIdentity(delayedQuery);
}
}
this._queuedFetches = [];
}
},
 
close: function(/*dojo.data.api.Request || keywordArgs || null */ request){
// summary:
// See dojo.data.api.Read.close()
}
});
//Mix in the simple fetch implementation to this class.
dojo.extend(dojox.data.OpmlStore,dojo.data.util.simpleFetch);
 
}
/trunk/api/js/dojo1.0/dojox/data/FlickrRestStore.js
New file
0,0 → 1,471
if(!dojo._hasResource["dojox.data.FlickrRestStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.FlickrRestStore"] = true;
dojo.provide("dojox.data.FlickrRestStore");
 
dojo.require("dojox.data.FlickrStore");
 
dojo.declare("dojox.data.FlickrRestStore",
dojox.data.FlickrStore, {
constructor: function(/*Object*/args){
// summary:
// Initializer for the FlickrRestStore store.
// description:
// The FlickrRestStore is a Datastore interface to one of the basic services
// of the Flickr service, the public photo feed. This does not provide
// access to all the services of Flickr.
// This store cannot do * and ? filtering as the flickr service
// provides no interface for wildcards.
if(args && args.label){
if(args.label) {
this.label = args.label;
}
if(args.apikey) {
this._apikey = args.apikey;
}
}
this._cache = [];
this._prevRequests = {};
this._handlers = {};
this._prevRequestRanges = [];
this._maxPhotosPerUser = {};
this._id = dojox.data.FlickrRestStore.prototype._id++;
},
// _id: Integer
// A unique identifier for this store.
_id: 0,
// _requestCount: Integer
// A counter for the number of requests made. This is used to define
// the callback function that Flickr will use.
_requestCount: 0,
// _flickrRestUrl: String
// The URL to the Flickr REST services.
_flickrRestUrl: "http://www.flickr.com/services/rest/",
// _apikey: String
// The users API key to be used when accessing Flickr REST services.
_apikey: null,
// _storeRef: String
// A key used to mark an data store item as belonging to this store.
_storeRef: "_S",
// _cache: Array
// An Array of all previously downloaded picture info.
_cache: null,
// _prevRequests: Object
// A HashMap used to record the signature of a request to prevent duplicate
// request being made.
_prevRequests: null,
// _handlers: Object
// A HashMap used to record the handlers registered for a single remote request. Multiple
// requests may be made for the same information before the first request has finished.
// Each element of this Object is an array of handlers to call back when the request finishes.
// This prevents multiple requests being made for the same information.
_handlers: null,
// _sortAttributes: Object
// A quick lookup of valid attribute names in a sort query.
_sortAttributes: {
"date-posted": true,
"date-taken": true,
"interestingness": true
},
_fetchItems: function(request, fetchHandler, errorHandler){
// summary: Fetch flickr items that match to a query
// request:
// A request object
// fetchHandler:
// A function to call for fetched items
// errorHandler:
// A function to call on error
var query = {};
if(!request.query){
request.query = query = {};
} else {
dojo.mixin(query, request.query);
}
var primaryKey = [];
var secondaryKey = [];
//Generate a unique function to be called back
var callbackFn = "FlickrRestStoreCallback_" + this._id + "_" + (++this._requestCount);
//Build up the content to send the request for.
var content = {
format: "json",
method: "flickr.photos.search",
api_key: this._apikey,
extras: "owner_name,date_upload,date_taken",
jsoncallback: callbackFn
};
var isRest = false;
if(query.userid){
isRest = true;
content.user_id = request.query.userid;
primaryKey.push("userid"+request.query.userid);
}
if(query.apikey){
isRest = true;
content.api_key = request.query.apikey;
secondaryKey.push("api"+request.query.apikey);
} else{
throw Error("dojox.data.FlickrRestStore: An API key must be specified.");
}
request._curCount = request.count;
if(query.page){
content.page = request.query.page;
secondaryKey.push("page" + content.page);
}else if(typeof(request.start) != "undefined" && request.start != null) {
if(!request.count){
request.count = 20;
}
var diff = request.start % request.count;
var start = request.start, count = request.count;
//If the count does not divide cleanly into the start number,
//more work has to be done to figure out the best page to request
if(diff != 0) {
if(start < count / 2) {
//If the first record requested is less than half the amount requested,
//then request from 0 to the count record
count = start + count;
start = 0;
} else {
var divLimit = 20, div = 2;
for(var i = divLimit; i > 0; i--) {
if(start % i == 0 && (start/i) >= count){
div = i;
break;
}
}
count = start/div;
}
request._realStart = request.start;
request._realCount = request.count;
request._curStart = start;
request._curCount = count;
} else {
request._realStart = request._realCount = null;
request._curStart = request.start;
request._curCount = request.count;
}
content.page = (start / count) + 1;
secondaryKey.push("page" + content.page);
}
if(request._curCount){
content.per_page = request._curCount;
secondaryKey.push("count" + request._curCount);
}
if(query.lang){
content.lang = request.query.lang;
primaryKey.push("lang" + request.lang);
}
var url = this._flickrRestUrl;
if(query.setid){
content.method = "flickr.photosets.getPhotos";
content.photoset_id = request.query.set;
primaryKey.push("set" + request.query.set);
}
if(query.tags){
if(query.tags instanceof Array){
content.tags = query.tags.join(",");
} else {
content.tags=query.tags;
}
primaryKey.push("tags" + content.tags);
if(query["tag_mode"] && (query.tag_mode.toLowerCase() == "any"
|| query.tag_mode.toLowerCase() == "all")){
content.tag_mode = query.tag_mode;
}
}
if(query.text){
content.text=query.text;
primaryKey.push("text:"+query.text);
}
//The store only supports a single sort attribute, even though the
//Read API technically allows multiple sort attributes
if(query.sort && query.sort.length > 0){
//The default sort attribute is 'date-posted'
if(!query.sort[0].attribute){
query.sort[0].attribute = "date-posted";
}
//If the sort attribute is valid, check if it is ascending or
//descending.
if(this._sortAttributes[query.sort[0].attribute]) {
if(query.sort[0].descending){
content.sort = query.sort[0].attribute + "-desc";
} else {
content.sort = query.sort[0].attribute + "-asc";
}
}
} else {
//The default sort in the Dojo Data API is ascending.
content.sort = "date-posted-asc";
}
primaryKey.push("sort:"+content.sort);
//Generate a unique key for this request, so the store can
//detect duplicate requests.
primaryKey = primaryKey.join(".");
secondaryKey = secondaryKey.length > 0 ? "." + secondaryKey.join(".") : "";
var requestKey = primaryKey + secondaryKey;
//Make a copy of the request, in case the source object is modified
//before the request completes
request = {
query: query,
count: request._curCount,
start: request._curStart,
_realCount: request._realCount,
_realStart: request._realStart,
onBegin: request.onBegin,
onComplete: request.onComplete,
onItem: request.onItem
};
 
var thisHandler = {
request: request,
fetchHandler: fetchHandler,
errorHandler: errorHandler
};
 
//If the request has already been made, but not yet completed,
//then add the callback handler to the list of handlers
//for this request, and finish.
if(this._handlers[requestKey]){
this._handlers[requestKey].push(thisHandler);
return;
}
 
this._handlers[requestKey] = [thisHandler];
 
//Linking this up to Flickr is a PAIN!
var self = this;
var handle = null;
var getArgs = {
url: this._flickrRestUrl,
preventCache: true,
content: content
};
var doHandle = function(processedData, data, handler){
var onBegin = handler.request.onBegin;
handler.request.onBegin = null;
var maxPhotos;
var req = handler.request;
if(typeof(req._realStart) != undefined && req._realStart != null) {
req.start = req._realStart;
req.count = req._realCount;
req._realStart = req._realCount = null;
}
 
//If the request contains an onBegin method, the total number
//of photos must be calculated.
if(onBegin){
if(data && typeof(data.photos.perpage) != "undefined" && typeof(data.photos.pages) != "undefined"){
if(data.photos.perpage * data.photos.pages <= handler.request.start + handler.request.count){
//If the final page of results has been received, it is possible to
//know exactly how many photos there are
maxPhotos = handler.request.start + data.photos.photo.length;
}else{
//If the final page of results has not yet been received,
//it is not possible to tell exactly how many photos exist, so
//return the number of pages multiplied by the number of photos per page.
maxPhotos = data.photos.perpage * data.photos.pages;
}
self._maxPhotosPerUser[primaryKey] = maxPhotos;
onBegin(maxPhotos, handler.request);
} else if(self._maxPhotosPerUser[primaryKey]) {
onBegin(self._maxPhotosPerUser[primaryKey], handler.request);
}
}
//Call whatever functions the caller has defined on the request object, except for onBegin
handler.fetchHandler(processedData, handler.request);
if(onBegin){
//Replace the onBegin function, if it existed.
handler.request.onBegin = onBegin;
}
};
//Define a callback for the script that iterates through a list of
//handlers for this piece of data. Multiple requests can come into
//the store for the same data.
var myHandler = function(data){
//The handler should not be called more than once, so disconnect it.
//if(handle !== null){ dojo.disconnect(handle); }
if(data.stat != "ok"){
errorHandler(null, request);
}else{ //Process the items...
var handlers = self._handlers[requestKey];
if(!handlers){
console.log("FlickrRestStore: no handlers for data", data);
return;
}
 
self._handlers[requestKey] = null;
self._prevRequests[requestKey] = data;
 
//Process the data once.
var processedData = self._processFlickrData(data, request, primaryKey);
if(!self._prevRequestRanges[primaryKey]) {
self._prevRequestRanges[primaryKey] = [];
}
self._prevRequestRanges[primaryKey].push({
start: request.start,
end: request.start + data.photos.photo.length
});
 
//Iterate through the array of handlers, calling each one.
for(var i = 0; i < handlers.length; i++ ){
doHandle(processedData, data, handlers[i]);
}
}
};
 
var data = this._prevRequests[requestKey];
//If the data was previously retrieved, there is no need to fetch it again.
if(data){
this._handlers[requestKey] = null;
doHandle(this._cache[primaryKey], data, thisHandler);
return;
} else if(this._checkPrevRanges(primaryKey, request.start, request.count)) {
//If this range of data has already been retrieved, reuse it.
this._handlers[requestKey] = null;
doHandle(this._cache[primaryKey], null, thisHandler);
return;
}
dojo.global[callbackFn] = function(data){
myHandler(data);
//Clean up the function, it should never be called again
dojo.global[callbackFn] = null;
};
var deferred = dojo.io.script.get(getArgs);
//We only set up the errback, because the callback isn't ever really used because we have
//to link to the jsonFlickrFeed function....
deferred.addErrback(function(error){
dojo.disconnect(handle);
errorHandler(error, request);
});
},
getAttributes: function(item){
// summary:
// See dojo.data.api.Read.getAttributes()
return ["title", "author", "imageUrl", "imageUrlSmall",
"imageUrlMedium", "imageUrlThumb", "link",
"dateTaken", "datePublished"];
},
getValues: function(item, attribute){
// summary:
// See dojo.data.api.Read.getValue()
this._assertIsItem(item);
this._assertIsAttribute(attribute);
if(attribute === "title"){
return [this._unescapeHtml(item.title)]; // String
}else if(attribute === "author"){
return [item.ownername]; // String
}else if(attribute === "imageUrlSmall"){
return [item.media.s]; // String
}else if(attribute === "imageUrl"){
return [item.media.l]; // String
}else if(attribute === "imageUrlMedium"){
return [item.media.m]; // String
}else if(attribute === "imageUrlThumb"){
return [item.media.t]; // String
}else if(attribute === "link"){
return ["http://www.flickr.com/photos/" + item.owner + "/" + item.id]; // String
}else if(attribute === "dateTaken"){
return item.datetaken;
}else if(attribute === "datePublished"){
return item.datepublished;
}
return undefined;
},
 
_processFlickrData: function(/* Object */data, /* Object */request, /* String */ cacheKey){
// summary: Processes the raw data from Flickr and updates the internal cache.
// data:
// Data returned from Flickr
// request:
// The original dojo.data.Request object passed in by the user.
//If the data contains an 'item' object, it has not come from the REST services,
//so process it using the FlickrStore.
if(data.items){
return dojox.data.FlickrStore.prototype._processFlickrData.apply(this,arguments);
}
 
var template = ["http://farm", null, ".static.flickr.com/", null, "/", null, "_", null];
var items = [];
if(data.stat == "ok" && data.photos && data.photos.photo){
items = data.photos.photo;
//Add on the store ref so that isItem can work.
for(var i = 0; i < items.length; i++){
var item = items[i];
item[this._storeRef] = this;
template[1] = item.farm;
template[3] = item.server;
template[5] = item.id;
template[7] = item.secret;
var base = template.join("");
item.media = {
s: base + "_s.jpg",
m: base + "_m.jpg",
l: base + ".jpg",
t: base + "_t.jpg"
};
}
}
var start = request.start ? request.start : 0;
var arr = this._cache[cacheKey];
if(!arr) {
this._cache[cacheKey] = arr = [];
}
for(var count = 0; count < items.length; count++){
arr[count + start] = items[count];
}
 
return arr; // Array
},
_checkPrevRanges: function(primaryKey, start, count) {
var end = start + count;
var arr = this._prevRequestRanges[primaryKey];
if(!arr) {
return false;
}
for(var i = 0; i< arr.length; i++) {
if(start >= arr[i].start &&
end <= arr[i].end) {
return true;
}
}
return false;
}
});
 
 
}
/trunk/api/js/dojo1.0/dojox/data/FlickrStore.js
New file
0,0 → 1,257
if(!dojo._hasResource["dojox.data.FlickrStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.FlickrStore"] = true;
dojo.provide("dojox.data.FlickrStore");
 
dojo.require("dojo.data.util.simpleFetch");
dojo.require("dojo.io.script");
dojo.require("dojo.date.stamp");
 
dojo.declare("dojox.data.FlickrStore", null, {
constructor: function(/*Object*/args){
// summary:
// Initializer for the FlickrStore store.
// description:
// The FlickrStore is a Datastore interface to one of the basic services
// of the Flickr service, the public photo feed. This does not provide
// access to all the services of Flickr.
// This store cannot do * and ? filtering as the flickr service
// provides no interface for wildcards.
if(args && args.label){
this.label = args.label;
}
},
 
_flickrUrl: "http://api.flickr.com/services/feeds/photos_public.gne",
 
_storeRef: "_S",
 
label: "title",
 
_assertIsItem: function(/* item */ item){
// summary:
// This function tests whether the item passed in is indeed an item in the store.
// item:
// The item to test for being contained by the store.
if(!this.isItem(item)){
throw new Error("dojox.data.FlickrStore: a function was passed an item argument that was not an item");
}
},
 
_assertIsAttribute: function(/* attribute-name-string */ attribute){
// summary:
// This function tests whether the item passed in is indeed a valid 'attribute' like type for the store.
// attribute:
// The attribute to test for being contained by the store.
if(typeof attribute !== "string"){
throw new Error("dojox.data.FlickrStore: a function was passed an attribute argument that was not an attribute name string");
}
},
 
getFeatures: function(){
// summary:
// See dojo.data.api.Read.getFeatures()
return {
'dojo.data.api.Read': true
};
},
 
getValue: function(item, attribute){
// summary:
// See dojo.data.api.Read.getValue()
var values = this.getValues(item, attribute);
if(values){
return values[0];
}
return undefined;
},
 
getAttributes: function(item){
// summary:
// See dojo.data.api.Read.getAttributes()
return ["title", "description", "author", "datePublished", "dateTaken", "imageUrl", "imageUrlSmall", "imageUrlMedium", "tags", "link"];
},
 
hasAttribute: function(item, attribute){
// summary:
// See dojo.data.api.Read.hasAttributes()
if(this.getValue(item,attribute)){
return true;
}
return false;
},
 
isItemLoaded: function(item){
// summary:
// See dojo.data.api.Read.isItemLoaded()
return this.isItem(item);
},
 
loadItem: function(keywordArgs){
// summary:
// See dojo.data.api.Read.loadItem()
},
 
getLabel: function(item){
// summary:
// See dojo.data.api.Read.getLabel()
return this.getValue(item,this.label);
},
getLabelAttributes: function(item){
// summary:
// See dojo.data.api.Read.getLabelAttributes()
return [this.label];
},
 
containsValue: function(item, attribute, value){
// summary:
// See dojo.data.api.Read.containsValue()
var values = this.getValues(item,attribute);
for(var i = 0; i < values.length; i++){
if(values[i] === value){
return true;
}
}
return false;
},
 
getValues: function(item, attribute){
// summary:
// See dojo.data.api.Read.getValue()
 
this._assertIsItem(item);
this._assertIsAttribute(attribute);
if(attribute === "title"){
return [this._unescapeHtml(item.title)];
}else if(attribute === "author"){
return [this._unescapeHtml(item.author)];
}else if(attribute === "datePublished"){
return [dojo.date.stamp.fromISOString(item.published)];
}else if(attribute === "dateTaken"){
return [dojo.date.stamp.fromISOString(item.date_taken)];
}else if(attribute === "imageUrlSmall"){
return [item.media.m.replace(/_m\./, "_s.")];
}else if(attribute === "imageUrl"){
return [item.media.m.replace(/_m\./, ".")];
}else if(attribute === "imageUrlMedium"){
return [item.media.m];
}else if(attribute === "link"){
return [item.link];
}else if(attribute === "tags"){
return item.tags.split(" ");
}else if(attribute === "description"){
return [this._unescapeHtml(item.description)];
}
return undefined;
},
 
isItem: function(item){
// summary:
// See dojo.data.api.Read.isItem()
if(item && item[this._storeRef] === this){
return true;
}
return false;
},
close: function(request){
// summary:
// See dojo.data.api.Read.close()
},
 
_fetchItems: function(request, fetchHandler, errorHandler){
// summary:
// Fetch flickr items that match to a query
// request:
// A request object
// fetchHandler:
// A function to call for fetched items
// errorHandler:
// A function to call on error
 
if(!request.query){
request.query={};
}
 
//Build up the content to send the request for.
var content = {format: "json", tagmode:"any"};
if (request.query.tags) {
content.tags = request.query.tags;
}
if (request.query.tagmode) {
content.tagmode = request.query.tagmode;
}
if (request.query.userid) {
content.id = request.query.userid;
}
if (request.query.userids) {
content.ids = request.query.userids;
}
if (request.query.lang) {
content.lang = request.query.lang;
}
 
//Linking this up to Flickr is a PAIN!
var self = this;
var handle = null;
var getArgs = {
url: this._flickrUrl,
preventCache: true,
content: content
};
var myHandler = function(data){
if(handle !== null){
dojo.disconnect(handle);
}
 
//Process the items...
fetchHandler(self._processFlickrData(data), request);
};
handle = dojo.connect("jsonFlickrFeed", myHandler);
var deferred = dojo.io.script.get(getArgs);
//We only set up the errback, because the callback isn't ever really used because we have
//to link to the jsonFlickrFeed function....
deferred.addErrback(function(error){
dojo.disconnect(handle);
errorHandler(error, request);
});
},
 
_processFlickrData: function(data){
var items = [];
if(data.items){
items = data.items;
//Add on the store ref so that isItem can work.
for(var i = 0; i < data.items.length; i++){
var item = data.items[i];
item[this._storeRef] = this;
}
}
return items;
},
 
_unescapeHtml: function(str){
// summary: Utility function to un-escape XML special characters in an HTML string.
// description: Utility function to un-escape XML special characters in an HTML string.
//
// str: String.
// The string to un-escape
// returns: HTML String converted back to the normal text (unescaped) characters (<,>,&, ", etc,).
//
//TODO: Check to see if theres already compatible escape() in dojo.string or dojo.html
str = str.replace(/&amp;/gm, "&").replace(/&lt;/gm, "<").replace(/&gt;/gm, ">").replace(/&quot;/gm, "\"");
str = str.replace(/&#39;/gm, "'");
return str;
}
});
dojo.extend(dojox.data.FlickrStore,dojo.data.util.simpleFetch);
//We have to define this because of how the Flickr API works.
//This somewhat stinks, but what can you do?
if (!jsonFlickrFeed) {
var jsonFlickrFeed = function(data){};
}
 
 
}
/trunk/api/js/dojo1.0/dojox/data/tests/ml/test_HtmlTableStore_declaratively.html
New file
0,0 → 1,120
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Dojox HtmlDataStore Widget</title>
<style>
@import "../../../../dijit/themes/tundra/tundra.css";
@import "../../../../dojo/resources/dojo.css";
@import "../../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript">
djConfig = {
isDebug: true,
parseOnLoad: true
};
</script>
<script type="text/javascript" src="../../../../dojo/dojo.js"></script>
<!--
<script language="JavaScript" type="text/javascript">
dojo.require("doh.runner");
function registerTests() {
doh.register("t",
[
function testTableLoaded(t){
t.assertTrue(tableStore !== null);
t.assertTrue(tableStore !== undefined);
}
]
);
doh.run();
};
dojo.addOnLoad(registerTests);
</script>
-->
 
<script language="JavaScript" type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojox.data.HtmlTableStore");
dojo.require("dijit.Tree");
function init() {
var table = tableStore;
function testComplete(items, request){
console.debug("Completed!");
 
var attributes = null;
for(var i = 0; i < items.length; i++){
attributes = table.getAttributes(items[i]);
for(var j=0; j < attributes.length; j++){
console.debug("attribute: [" + attributes[j] + "] have value: " + table.getValue(items[i], attributes[j]));
}
}
}
table.fetch({query:{X:1}, onComplete: testComplete});
table.fetch({query:{X:2}, onComplete: testComplete});
table.fetch({query:{X:3}, onComplete: testComplete});
table.fetch({query:{X:4}, onComplete: testComplete});
table.fetch({query:{X:5}, onComplete: testComplete}); // Should be empty
}
dojo.addOnLoad(init);
</script>
 
</head>
<body class="tundra">
<h1>Dojox HtmlDataStore Widget</h1>
<hr/>
<br/>
<br/>
 
<!-- Instantiate the HtmlTableStore and bind it to global name tableStore -->
<div dojoType="dojox.data.HtmlTableStore" tableId="tableExample" jsId="tableStore"></div>
 
<!-- The table to link into with the HtmlTableStore-->
<table id="tableExample">
<thead>
<tr>
<th>X</th>
<th>Y</th>
<th>A</th>
<th>B</th>
</tr>
</thead>
<tbody>
<tr id="test">
<td>2</td>
<td>3</td>
<td></td>
<td>8</td>
</tr>
<tr>
<td>1</td>
<td>3</td>
<td>5</td>
<td>7</td>
</tr>
<tr>
<td>4</td>
<td>9</td>
<td>22</td>
<td>777</td>
</tr>
<tr>
<td>3231</td>
<td>3</td>
<td>535</td>
<td>747</td>
</tr>
 
</tbody>
</table>
 
<br/>
<br/>
<blockquote>
<b>Table Rows: <br/><i>(Just to show that the tree can determine that the tableStore works like a store).<br/>Should have three branches, where the row had attr Y value of 3.</i></b>
<div dojoType="dijit.Tree" id="tree" store="tableStore" query="{Y:3}" label="Test tree"></div>
</blockquote>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/data/tests/dom.js
New file
0,0 → 1,133
if(!dojo._hasResource["dojox.data.tests.dom"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.tests.dom"] = true;
dojo.provide("dojox.data.tests.dom");
dojo.require("dojox.data.dom");
 
tests.register("dojox.data.tests.dom",
[
function testCreateDocument(t){
var document = dojox.data.dom.createDocument();
t.assertTrue(document !== null);
},
function testCreateDocumentFromText(t){
var simpleXml = "<parentNode><childNode><grandchildNode/></childNode><childNode/></parentNode>";
var document = dojox.data.dom.createDocument(simpleXml, "text/xml");
var parent = document.firstChild;
t.assertTrue(parent !== null);
t.assertTrue(parent.tagName === "parentNode");
t.assertTrue(parent.childNodes.length == 2);
var firstChild = parent.firstChild;
t.assertTrue(firstChild !== null);
t.assertTrue(firstChild.tagName === "childNode");
t.assertTrue(firstChild.childNodes.length == 1);
var secondChild = firstChild.nextSibling;
t.assertTrue(secondChild !== null);
t.assertTrue(secondChild.tagName === "childNode");
 
var grandChild = firstChild.firstChild;
t.assertTrue(grandChild !== null);
t.assertTrue(grandChild.tagName === "grandchildNode");
 
},
function testReadTextContent(t){
var text = "This is a bunch of child text on the node";
var simpleXml = "<parentNode>" + text + "</parentNode>";
var document = dojox.data.dom.createDocument(simpleXml, "text/xml");
var topNode = document.firstChild;
t.assertTrue(topNode !== null);
t.assertTrue(topNode.tagName === "parentNode");
t.assertTrue(text === dojox.data.dom.textContent(topNode));
dojo._destroyElement(topNode);
t.assertTrue(document.firstChild === null);
},
function testSetTextContent(t){
var text = "This is a bunch of child text on the node";
var text2 = "This is the new text";
var simpleXml = "<parentNode>" + text + "</parentNode>";
var document = dojox.data.dom.createDocument(simpleXml, "text/xml");
var topNode = document.firstChild;
t.assertTrue(topNode !== null);
t.assertTrue(topNode.tagName === "parentNode");
t.assertTrue(text === dojox.data.dom.textContent(topNode));
dojox.data.dom.textContent(topNode, text2);
t.assertTrue(text2 === dojox.data.dom.textContent(topNode));
dojo._destroyElement(topNode);
t.assertTrue(document.firstChild === null);
 
},
function testReplaceChildrenArray(t){
var simpleXml1 = "<parentNode><child1/><child2/><child3/></parentNode>";
var simpleXml2 = "<parentNode><child4/><child5/><child6/><child7/></parentNode>";
var doc1 = dojox.data.dom.createDocument(simpleXml1, "text/xml");
var doc2 = dojox.data.dom.createDocument(simpleXml2, "text/xml");
var topNode1 = doc1.firstChild;
var topNode2 = doc2.firstChild;
t.assertTrue(topNode1 !== null);
t.assertTrue(topNode1.tagName === "parentNode");
t.assertTrue(topNode2 !== null);
t.assertTrue(topNode2.tagName === "parentNode");
dojox.data.dom.removeChildren(topNode1);
var newChildren=[];
for(var i=0;i<topNode2.childNodes.length;i++){
newChildren.push(topNode2.childNodes[i]);
}
dojox.data.dom.removeChildren(topNode2);
dojox.data.dom.replaceChildren(topNode1,newChildren);
t.assertTrue(topNode1.childNodes.length === 4);
t.assertTrue(topNode1.firstChild.tagName === "child4");
t.assertTrue(topNode1.lastChild.tagName === "child7");
 
},
function testReplaceChildrenSingle(t){
var simpleXml1 = "<parentNode><child1/><child2/><child3/></parentNode>";
var simpleXml2 = "<parentNode><child4/></parentNode>";
var doc1 = dojox.data.dom.createDocument(simpleXml1, "text/xml");
var doc2 = dojox.data.dom.createDocument(simpleXml2, "text/xml");
var topNode1 = doc1.firstChild;
var topNode2 = doc2.firstChild;
t.assertTrue(topNode1 !== null);
t.assertTrue(topNode1.tagName === "parentNode");
t.assertTrue(topNode2 !== null);
t.assertTrue(topNode2.tagName === "parentNode");
dojox.data.dom.removeChildren(topNode1);
var newChildren = topNode2.firstChild;
dojox.data.dom.removeChildren(topNode2);
dojox.data.dom.replaceChildren(topNode1,newChildren);
t.assertTrue(topNode1.childNodes.length === 1);
t.assertTrue(topNode1.firstChild.tagName === "child4");
t.assertTrue(topNode1.lastChild.tagName === "child4");
},
function testRemoveChildren(t){
var simpleXml1 = "<parentNode><child1/><child2/><child3/></parentNode>";
var doc1 = dojox.data.dom.createDocument(simpleXml1, "text/xml");
var topNode1 = doc1.firstChild;
t.assertTrue(topNode1 !== null);
t.assertTrue(topNode1.tagName === "parentNode");
dojox.data.dom.removeChildren(topNode1);
t.assertTrue(topNode1.childNodes.length === 0);
t.assertTrue(topNode1.firstChild === null);
},
function testInnerXML(t){
var simpleXml1 = "<parentNode><child1/><child2/><child3/></parentNode>";
var doc1 = dojox.data.dom.createDocument(simpleXml1, "text/xml");
var topNode1 = doc1.firstChild;
t.assertTrue(topNode1 !== null);
t.assertTrue(topNode1.tagName === "parentNode");
 
var innerXml = dojox.data.dom.innerXML(topNode1);
t.assertTrue(simpleXml1 === innerXml);
}
]
);
 
}
/trunk/api/js/dojo1.0/dojox/data/tests/runTests.html
New file
0,0 → 1,9
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dojox Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.data.tests.module"></HEAD>
<BODY>
Redirecting to D.O.H runner.
</BODY>
</HTML>
/trunk/api/js/dojo1.0/dojox/data/tests/stores/books_isbnAttr.xml
New file
0,0 → 1,23
<?xml version="1.0" encoding="ISO-8859-1"?>
<books>
<book isbn="1">
<title>Title of 1</title>
<author>Author of 1</author>
</book>
<book isbn="2">
<title>Title of 2</title>
<author>Author of 2</author>
</book>
<book isbn="3">
<title>Title of 3</title>
<author>Author of 3</author>
</book>
<book isbn="4">
<title>Title of 4</title>
<author>Author of 4</author>
</book>
<book isbn="5">
<title>Title of 5</title>
<author>Author of 5</author>
</book>
</books>
/trunk/api/js/dojo1.0/dojox/data/tests/stores/CsvStore.js
New file
0,0 → 1,1127
if(!dojo._hasResource["dojox.data.tests.stores.CsvStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.tests.stores.CsvStore"] = true;
dojo.provide("dojox.data.tests.stores.CsvStore");
dojo.require("dojox.data.CsvStore");
dojo.require("dojo.data.api.Read");
dojo.require("dojo.data.api.Identity");
 
dojox.data.tests.stores.CsvStore.getDatasource = function(filepath){
// summary:
// A simple helper function for getting the sample data used in each of the tests.
// description:
// A simple helper function for getting the sample data used in each of the tests.
 
var dataSource = {};
if(dojo.isBrowser){
dataSource.url = dojo.moduleUrl("dojox.data.tests", filepath).toString();
}else{
// When running tests in Rhino, xhrGet is not available,
// so we have the file data in the code below.
switch(filepath){
case "stores/movies.csv":
var csvData = "";
csvData += "Title, Year, Producer\n";
csvData += "City of God, 2002, Katia Lund\n";
csvData += "Rain,, Christine Jeffs\n";
csvData += "2001: A Space Odyssey, 1968, Stanley Kubrick\n";
csvData += '"This is a ""fake"" movie title", 1957, Sidney Lumet\n';
csvData += "Alien, 1979 , Ridley Scott\n";
csvData += '"The Sequel to ""Dances With Wolves.""", 1982, Ridley Scott\n';
csvData += '"Caine Mutiny, The", 1954, "Dymtryk ""the King"", Edward"\n';
break;
case "stores/movies2.csv":
var csvData = "";
csvData += "Title, Year, Producer\n";
csvData += "City of God, 2002, Katia Lund\n";
csvData += "Rain,\"\", Christine Jeffs\n";
csvData += "2001: A Space Odyssey, 1968, Stanley Kubrick\n";
csvData += '"This is a ""fake"" movie title", 1957, Sidney Lumet\n';
csvData += "Alien, 1979 , Ridley Scott\n";
csvData += '"The Sequel to ""Dances With Wolves.""", 1982, Ridley Scott\n';
csvData += '"Caine Mutiny, The", 1954, "Dymtryk ""the King"", Edward"\n';
break;
case "stores/books.csv":
var csvData = "";
csvData += "Title, Author\n";
csvData += "The Transparent Society, David Brin\n";
csvData += "The First Measured Century, Theodore Caplow\n";
csvData += "Maps in a Mirror, Orson Scott Card\n";
csvData += "Princess Smartypants, Babette Cole\n";
csvData += "Carfree Cities, Crawford J.H.\n";
csvData += "Down and Out in the Magic Kingdom, Cory Doctorow\n";
csvData += "Tax Shift, Alan Thein Durning\n";
csvData += "The Sneetches and other stories, Dr. Seuss\n";
csvData += "News from Tartary, Peter Fleming\n";
break;
case "stores/patterns.csv":
var csvData = "";
csvData += "uniqueId, value\n";
csvData += "9, jfq4@#!$!@Rf14r14i5u\n";
csvData += "6, BaBaMaSaRa***Foo\n";
csvData += "2, bar*foo\n";
csvData += "8, 123abc\n";
csvData += "4, bit$Bite\n";
csvData += "3, 123abc\n";
csvData += "10, 123abcdefg\n";
csvData += "1, foo*bar\n";
csvData += "7, \n";
csvData += "5, 123abc\n"
break;
}
dataSource.data = csvData;
}
return dataSource; //Object
}
 
dojox.data.tests.stores.CsvStore.verifyItems = function(csvStore, items, attribute, compareArray){
// summary:
// A helper function for validating that the items array is ordered
// the same as the compareArray
if(items.length != compareArray.length){ return false; }
for(var i = 0; i < items.length; i++){
if(!(csvStore.getValue(items[i], attribute) === compareArray[i])){
return false; //Boolean
}
}
return true; //Boolean
}
 
dojox.data.tests.stores.CsvStore.error = function(t, d, errData){
// summary:
// The error callback function to be used for all of the tests.
for (i in errData) {
console.log(errData[i]);
}
d.errback(errData);
}
 
doh.register("dojox.data.tests.stores.CsvStore",
[
function testReadAPI_fetch_all(t){
// summary:
// Simple test of a basic fetch on CsvStore.
// description:
// Simple test of a basic fetch on CsvStore.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function completedAll(items){
t.assertTrue((items.length === 7));
d.callback(true);
}
 
//Get everything...
csvStore.fetch({ onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_all_withEmptyStringField(t){
// summary:
// Simple test of a basic fetch on CsvStore.
// description:
// Simple test of a basic fetch on CsvStore.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies2.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function completedAll(items){
t.assertTrue((items.length === 7));
d.callback(true);
}
 
//Get everything...
csvStore.fetch({ onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_one(t){
// summary:
// Simple test of a basic fetch on CsvStore of a single item.
// description:
// Simple test of a basic fetch on CsvStore of a single item.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function onComplete(items, request){
t.is(1, items.length);
d.callback(true);
}
csvStore.fetch({ query: {Title: "*Sequel*"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)
});
return d; //Object
},
function testReadAPI_fetch_Multiple(t){
// summary:
// Simple test of a basic fetch on CsvStore of a single item.
// description:
// Simple test of a basic fetch on CsvStore of a single item.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
 
var done = [false, false];
 
function onCompleteOne(items, request){
done[0] = true;
t.is(1, items.length);
if(done[0] && done[1]){
d.callback(true);
}
}
function onCompleteTwo(items, request){
done[1] = true;
t.is(1, items.length);
if(done[0] && done[1]){
d.callback(true);
}
}
try
{
csvStore.fetch({ query: {Title: "*Sequel*"},
onComplete: onCompleteOne,
onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)
});
csvStore.fetch({ query: {Title: "2001:*"},
onComplete: onCompleteTwo,
onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)
});
}
catch(e)
{
for (i in e) {
console.log(e[i]);
}
}
 
return d; //Object
},
function testReadAPI_fetch_MultipleMixed(t){
// summary:
// Simple test of a basic fetch on CsvStore of a single item.
// description:
// Simple test of a basic fetch on CsvStore of a single item.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
 
var done = [false, false];
function onComplete(items, request){
done[0] = true;
t.is(1, items.length);
if(done[0] && done[1]){
d.callback(true);
}
}
function onItem(item){
done[1] = true;
t.assertTrue(item !== null);
t.is('Dymtryk "the King", Edward', csvStore.getValue(item,"Producer"));
t.is('Caine Mutiny, The', csvStore.getValue(item,"Title"));
if(done[0] && done[1]){
d.callback(true);
}
}
 
csvStore.fetch({ query: {Title: "*Sequel*"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)
});
csvStore.fetchItemByIdentity({identity: "6", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_all_streaming(t){
// summary:
// Simple test of a basic fetch on CsvStore.
// description:
// Simple test of a basic fetch on CsvStore.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
count = 0;
 
function onBegin(size, requestObj){
t.assertTrue(size === 7);
}
function onItem(item, requestObj){
t.assertTrue(csvStore.isItem(item));
count++;
}
function onComplete(items, request){
t.is(7, count);
t.is(null, items);
d.callback(true);
}
 
//Get everything...
csvStore.fetch({ onBegin: onBegin,
onItem: onItem,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)
});
return d; //Object
},
function testReadAPI_fetch_paging(t){
// summary:
// Test of multiple fetches on a single result. Paging, if you will.
// description:
// Test of multiple fetches on a single result. Paging, if you will.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function dumpFirstFetch(items, request){
t.is(5, items.length);
request.start = 3;
request.count = 1;
request.onComplete = dumpSecondFetch;
csvStore.fetch(request);
}
 
function dumpSecondFetch(items, request){
t.is(1, items.length);
request.start = 0;
request.count = 5;
request.onComplete = dumpThirdFetch;
csvStore.fetch(request);
}
 
function dumpThirdFetch(items, request){
t.is(5, items.length);
request.start = 2;
request.count = 20;
request.onComplete = dumpFourthFetch;
csvStore.fetch(request);
}
 
function dumpFourthFetch(items, request){
t.is(5, items.length);
request.start = 9;
request.count = 100;
request.onComplete = dumpFifthFetch;
csvStore.fetch(request);
}
 
function dumpFifthFetch(items, request){
t.is(0, items.length);
request.start = 2;
request.count = 20;
request.onComplete = dumpSixthFetch;
csvStore.fetch(request);
}
 
function dumpSixthFetch(items, request){
t.is(5, items.length);
d.callback(true);
}
 
function completed(items, request){
t.is(7, items.length);
request.start = 1;
request.count = 5;
request.onComplete = dumpFirstFetch;
csvStore.fetch(request);
}
 
csvStore.fetch({onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
 
},
function testReadAPI_getLabel(t){
// summary:
// Simple test of the getLabel function against a store set that has a label defined.
// description:
// Simple test of the getLabel function against a store set that has a label defined.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
args.label = "Title";
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var label = csvStore.getLabel(items[0]);
t.assertTrue(label !== null);
t.assertEqual("The Sequel to \"Dances With Wolves.\"", label);
d.callback(true);
}
csvStore.fetch({ query: {Title: "*Sequel*"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)
});
return d;
},
function testReadAPI_getLabelAttributes(t){
// summary:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
// description:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
args.label = "Title";
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var labelList = csvStore.getLabelAttributes(items[0]);
t.assertTrue(dojo.isArray(labelList));
t.assertEqual("Title", labelList[0]);
d.callback(true);
}
csvStore.fetch({ query: {Title: "*Sequel*"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)
});
return d;
},
function testReadAPI_getValue(t){
// summary:
// Simple test of the getValue function of the store.
// description:
// Simple test of the getValue function of the store.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item !== null);
t.is('Dymtryk "the King", Edward', csvStore.getValue(item,"Producer"));
t.is('Caine Mutiny, The', csvStore.getValue(item,"Title"));
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "6", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
function testReadAPI_getValue_2(t){
// summary:
// Simple test of the getValue function of the store.
// description:
// Simple test of the getValue function of the store.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item !== null);
t.is("City of God", csvStore.getValue(item,"Title"));
t.is("2002", csvStore.getValue(item,"Year"));
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "0", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
function testReadAPI_getValue_3(t){
// summary:
// Simple test of the getValue function of the store.
// description:
// Simple test of the getValue function of the store.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item !== null);
t.is("1979", csvStore.getValue(item,"Year"));
t.is("Alien", csvStore.getValue(item,"Title"));
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "4", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
function testReadAPI_getValue_4(t){
// summary:
// Simple test of the getValue function of the store.
// description:
// Simple test of the getValue function of the store.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item !== null);
t.is("2001: A Space Odyssey", csvStore.getValue(item,"Title"));
t.is("Stanley Kubrick", csvStore.getValue(item,"Producer"));
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "2", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
 
function testReadAPI_getValues(t){
// summary:
// Simple test of the getValues function of the store.
// description:
// Simple test of the getValues function of the store.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item !== null);
var names = csvStore.getValues(item,"Title");
t.assertTrue(dojo.isArray(names));
t.is(1, names.length);
t.is("Rain", names[0]);
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
function testIdentityAPI_fetchItemByIdentity(t){
// summary:
// Simple test of the fetchItemByIdentity function of the store.
// description:
// Simple test of the fetchItemByIdentity function of the store.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item !== null);
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
 
function testIdentityAPI_fetchItemByIdentity_bad1(t){
// summary:
// Simple test of the fetchItemByIdentity function of the store.
// description:
// Simple test of the fetchItemByIdentity function of the store.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item === null);
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "7", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
function testIdentityAPI_fetchItemByIdentity_bad2(t){
// summary:
// Simple test of the fetchItemByIdentity function of the store.
// description:
// Simple test of the fetchItemByIdentity function of the store.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item === null);
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "-1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
function testIdentityAPI_fetchItemByIdentity_bad3(t){
// summary:
// Simple test of the fetchItemByIdentity function of the store.
// description:
// Simple test of the fetchItemByIdentity function of the store.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item === null);
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "999999", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
function testIdentityAPI_getIdentity(t){
// summary:
// Simple test of the fetchItemByIdentity function of the store.
// description:
// Simple test of the fetchItemByIdentity function of the store.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function completed(items, request){
t.is(7, items.length);
var passed = true;
for(var i = 0; i < items.length; i++){
if(!(csvStore.getIdentity(items[i]) === i)){
passed=false;
break;
}
}
t.assertTrue(passed);
d.callback(true);
}
//Get everything...
csvStore.fetch({ onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testIdentityAPI_getIdentityAttributes(t){
// summary:
// Simple test of the getIdentityAttributes
// description:
// Simple test of the fetchItemByIdentity function of the store.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(csvStore.isItem(item));
t.assertEqual(null, csvStore.getIdentityAttributes(item));
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
function testReadAPI_isItem(t){
// summary:
// Simple test of the isItem function of the store
// description:
// Simple test of the isItem function of the store
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(csvStore.isItem(item));
t.assertTrue(!csvStore.isItem({}));
t.assertTrue(!csvStore.isItem({ item: "not an item" }));
t.assertTrue(!csvStore.isItem("not an item"));
t.assertTrue(!csvStore.isItem(["not an item"]));
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
function testReadAPI_hasAttribute(t){
// summary:
// Simple test of the hasAttribute function of the store
// description:
// Simple test of the hasAttribute function of the store
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item !== null);
t.assertTrue(csvStore.hasAttribute(item, "Title"));
t.assertTrue(csvStore.hasAttribute(item, "Producer"));
t.assertTrue(!csvStore.hasAttribute(item, "Year"));
t.assertTrue(!csvStore.hasAttribute(item, "Nothing"));
t.assertTrue(!csvStore.hasAttribute(item, "title"));
 
//Test that null attributes throw an exception
var passed = false;
try{
csvStore.hasAttribute(item, null);
}catch (e){
passed = true;
}
t.assertTrue(passed);
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
function testReadAPI_containsValue(t){
// summary:
// Simple test of the containsValue function of the store
// description:
// Simple test of the containsValue function of the store
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item !== null);
t.assertTrue(csvStore.containsValue(item, "Title", "Alien"));
t.assertTrue(csvStore.containsValue(item, "Year", "1979"));
t.assertTrue(csvStore.containsValue(item, "Producer", "Ridley Scott"));
t.assertTrue(!csvStore.containsValue(item, "Title", "Alien2"));
t.assertTrue(!csvStore.containsValue(item, "Year", "1979 "));
t.assertTrue(!csvStore.containsValue(item, "Title", null));
 
//Test that null attributes throw an exception
var passed = false;
try{
csvStore.containsValue(item, null, "foo");
}catch (e){
passed = true;
}
t.assertTrue(passed);
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "4", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
function testReadAPI_getAttributes(t){
// summary:
// Simple test of the getAttributes function of the store
// description:
// Simple test of the getAttributes function of the store
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item !== null);
t.assertTrue(csvStore.isItem(item));
 
var attributes = csvStore.getAttributes(item);
t.is(3, attributes.length);
for(var i = 0; i < attributes.length; i++){
t.assertTrue((attributes[i] === "Title" || attributes[i] === "Year" || attributes[i] === "Producer"));
}
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "4", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
 
function testReadAPI_getAttributes_onlyTwo(t){
// summary:
// Simple test of the getAttributes function of the store
// description:
// Simple test of the getAttributes function of the store
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
function onItem(item){
// Test an item that does not have all of the attributes
t.assertTrue(item !== null);
t.assertTrue(csvStore.isItem(item));
 
var attributes = csvStore.getAttributes(item);
t.assertTrue(attributes.length === 2);
t.assertTrue(attributes[0] === "Title");
t.assertTrue(attributes[1] === "Producer");
d.callback(true);
}
csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d;
},
 
function testReadAPI_getFeatures(t){
// summary:
// Simple test of the getFeatures function of the store
// description:
// Simple test of the getFeatures function of the store
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var features = csvStore.getFeatures();
var count = 0;
for(i in features){
t.assertTrue((i === "dojo.data.api.Read" || i === "dojo.data.api.Identity"));
count++;
}
t.assertTrue(count === 2);
},
function testReadAPI_fetch_patternMatch0(t){
// summary:
// Function to test pattern matching of everything starting with lowercase e
// description:
// Function to test pattern matching of everything starting with lowercase e
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
function completed(items, request){
t.is(2, items.length);
var valueArray = [ "Alien", "The Sequel to \"Dances With Wolves.\""];
t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "Title", valueArray));
d.callback(true);
}
csvStore.fetch({query: {Producer: "* Scott"}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_patternMatch1(t){
// summary:
// Function to test pattern matching of everything with $ in it.
// description:
// Function to test pattern matching of everything with $ in it.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function completed(items, request){
t.assertTrue(items.length === 2);
var valueArray = [ "jfq4@#!$!@Rf14r14i5u", "bit$Bite"];
t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "value", valueArray));
d.callback(true);
}
csvStore.fetch({query: {value: "*$*"}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_patternMatch2(t){
// summary:
// Function to test exact pattern match
// description:
// Function to test exact pattern match
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function completed(items, request){
t.is(1, items.length);
t.assertTrue(csvStore.getValue(items[0], "value") === "bar*foo");
d.callback(true);
}
csvStore.fetch({query: {value: "bar\*foo"}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_patternMatch_caseInsensitive(t){
// summary:
// Function to test exact pattern match with case insensitivity set.
// description:
// Function to test exact pattern match with case insensitivity set.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function completed(items, request){
t.is(1, items.length);
t.assertTrue(csvStore.getValue(items[0], "value") === "bar*foo");
d.callback(true);
}
csvStore.fetch({query: {value: "BAR\\*foo"}, queryOptions: {ignoreCase: true}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_patternMatch_caseSensitive(t){
// summary:
// Function to test exact pattern match with case insensitivity set.
// description:
// Function to test exact pattern match with case insensitivity set.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function completed(items, request){
t.is(0, items.length);
d.callback(true);
}
csvStore.fetch({query: {value: "BAR\\*foo"}, queryOptions: {ignoreCase: false}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_sortNumeric(t){
// summary:
// Function to test sorting numerically.
// description:
// Function to test sorting numerically.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");
var csvStore = new dojox.data.CsvStore(args);
 
var d = new doh.Deferred();
function completed(items, request){
t.assertTrue(items.length === 10);
// TODO: CsvStore treats everything like a string, so these numbers will be sorted lexicographically.
var orderedArray = [ "1", "10", "2", "3", "4", "5", "6", "7", "8", "9" ];
t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray));
d.callback(true);
}
 
var sortAttributes = [{attribute: "uniqueId"}];
csvStore.fetch({onComplete: completed,
onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d),
sort: sortAttributes});
return d; //Object
},
function testReadAPI_fetch_sortNumericDescending(t){
// summary:
// Function to test sorting numerically.
// description:
// Function to test sorting numerically.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function completed(items, request){
t.is(10, items.length);
// TODO: CsvStore treats everything like a string, so these numbers will be sorted lexicographically.
var orderedArray = [ "9", "8", "7", "6", "5", "4", "3", "2", "10", "1" ];
t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray));
d.callback(true);
}
var sortAttributes = [{attribute: "uniqueId", descending: true}];
csvStore.fetch({ sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_sortNumericWithCount(t){
// summary:
// Function to test sorting numerically in descending order, returning only a specified number of them.
// description:
// Function to test sorting numerically in descending order, returning only a specified number of them.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function completed(items, request){
t.is(5, items.length);
// TODO: CsvStore treats everything like a string, so these numbers will be sorted lexicographically.
var orderedArray = [ "9", "8", "7", "6", "5" ];
t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray));
d.callback(true);
}
var sortAttributes = [{attribute: "uniqueId", descending: true}];
csvStore.fetch({sort: sortAttributes,
count: 5,
onComplete: completed,
onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_sortAlphabetic(t){
// summary:
// Function to test sorting alphabetic ordering.
// description:
// Function to test sorting alphabetic ordering.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function completed(items, request){
//Output should be in this order...
var orderedArray = [ "123abc",
"123abc",
"123abc",
"123abcdefg",
"BaBaMaSaRa***Foo",
"bar*foo",
"bit$Bite",
"foo*bar",
"jfq4@#!$!@Rf14r14i5u",
undefined
];
t.is(10, items.length);
t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "value", orderedArray));
d.callback(true);
}
var sortAttributes = [{attribute: "value"}];
csvStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_sortAlphabeticDescending(t){
// summary:
// Function to test sorting alphabetic ordering in descending mode.
// description:
// Function to test sorting alphabetic ordering in descending mode.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function completed(items, request){
//Output should be in this order...
var orderedArray = [ undefined,
"jfq4@#!$!@Rf14r14i5u",
"foo*bar",
"bit$Bite",
"bar*foo",
"BaBaMaSaRa***Foo",
"123abcdefg",
"123abc",
"123abc",
"123abc"
];
t.is(10, items.length);
t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "value", orderedArray));
d.callback(true);
}
var sortAttributes = [{attribute: "value", descending: true}];
csvStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_sortMultiple(t){
// summary:
// Function to test sorting on multiple attributes.
// description:
// Function to test sorting on multiple attributes.
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");
var csvStore = new dojox.data.CsvStore(args);
var d = new doh.Deferred();
function completed(items, request){
var orderedArray0 = [ "8", "5", "3", "10", "6", "2", "4", "1", "9", "7" ];
var orderedArray1 = [ "123abc",
"123abc",
"123abc",
"123abcdefg",
"BaBaMaSaRa***Foo",
"bar*foo",
"bit$Bite",
"foo*bar",
"jfq4@#!$!@Rf14r14i5u",
undefined
];
t.is(10, items.length);
t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray0));
t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "value", orderedArray1));
d.callback(true);
}
var sortAttributes = [{ attribute: "value"}, { attribute: "uniqueId", descending: true}];
csvStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_sortMultipleSpecialComparator(t){
// summary:
// Function to test sorting on multiple attributes with a custom comparator.
// description:
// Function to test sorting on multiple attributes with a custom comparator.
 
var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");
var csvStore = new dojox.data.CsvStore(args);
csvStore.comparatorMap = {};
csvStore.comparatorMap["Producer"] = function(a,b){
var ret = 0;
// We want to sort authors alphabetical by their last name
function lastName(name){
if(typeof name === "undefined"){ return undefined; }
var matches = name.match(/\s*(\S+)$/); // Grab the last word in the string.
return matches ? matches[1] : name; // Strings with only whitespace will not match.
}
var lastNameA = lastName(a);
var lastNameB = lastName(b);
if(lastNameA > lastNameB || typeof lastNameA === "undefined"){
ret = 1;
}else if(lastNameA < lastNameB || typeof lastNameB === "undefined"){
ret = -1;
}
return ret;
};
var sortAttributes = [{attribute: "Producer", descending: true}, { attribute: "Title", descending: true}];
var d = new doh.Deferred();
function completed(items, findResult){
var orderedArray = [5,4,0,3,2,1,6];
t.assertTrue(items.length === 7);
var passed = true;
for(var i = 0; i < items.length; i++){
if(!(csvStore.getIdentity(items[i]) === orderedArray[i])){
passed=false;
break;
}
}
t.assertTrue(passed);
d.callback(true);
}
csvStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});
return d; //Object
},
function testReadAPI_functionConformance(t){
// summary:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
// description:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
 
var testStore = new dojox.data.CsvStore(dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"));
var readApi = new dojo.data.api.Read();
var passed = true;
 
for(i in readApi){
if(i.toString().charAt(0) !== '_')
{
var member = readApi[i];
//Check that all the 'Read' defined functions exist on the test store.
if(typeof member === "function"){
console.log("Looking at function: [" + i + "]");
var testStoreMember = testStore[i];
if(!(typeof testStoreMember === "function")){
console.log("Problem with function: [" + i + "]. Got value: " + testStoreMember);
passed = false;
break;
}
}
}
}
t.assertTrue(passed);
},
function testIdentityAPI_functionConformance(t){
// summary:
// Simple test identity API conformance. Checks to see all declared functions are actual functions on the instances.
// description:
// Simple test identity API conformance. Checks to see all declared functions are actual functions on the instances.
 
var testStore = new dojox.data.CsvStore(dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"));
var identityApi = new dojo.data.api.Identity();
var passed = true;
 
for(i in identityApi){
if(i.toString().charAt(0) !== '_')
{
var member = identityApi[i];
//Check that all the 'Read' defined functions exist on the test store.
if(typeof member === "function"){
console.log("Looking at function: [" + i + "]");
var testStoreMember = testStore[i];
if(!(typeof testStoreMember === "function")){
passed = false;
break;
}
}
}
}
t.assertTrue(passed);
}
]
);
 
 
}
/trunk/api/js/dojo1.0/dojox/data/tests/stores/geography.xml
New file
0,0 → 1,51
<?xml version="1.0" encoding="ISO-8859-1"?>
<opml version="1.0">
<head>
<title>geography.opml</title>
<dateCreated>2006-11-10</dateCreated>
<dateModified>2006-11-13</dateModified>
<ownerName>Magellan, Ferdinand</ownerName>
</head>
<body>
<outline text="Africa" type="continent">
<outline text="Egypt" type="country"/>
<outline text="Kenya" type="country">
<outline text="Nairobi" type="city"/>
<outline text="Mombasa" type="city"/>
</outline>
<outline text="Sudan" type="country">
<outline text="Khartoum" type="city"/>
</outline>
</outline>
<outline text="Asia" type="continent">
<outline text="China" type="country"/>
<outline text="India" type="country"/>
<outline text="Russia" type="country"/>
<outline text="Mongolia" type="country"/>
</outline>
<outline text="Australia" type="continent" population="21 million">
<outline text="Australia" type="country" population="21 million"/>
</outline>
<outline text="Europe" type="continent">
<outline text="Germany" type="country"/>
<outline text="France" type="country"/>
<outline text="Spain" type="country"/>
<outline text="Italy" type="country"/>
</outline>
<outline text="North America" type="continent">
<outline text="Mexico" type="country" population="108 million" area="1,972,550 sq km">
<outline text="Mexico City" type="city" population="19 million" timezone="-6 UTC"/>
<outline text="Guadalajara" type="city" population="4 million" timezone="-6 UTC"/>
</outline>
<outline text="Canada" type="country" population="33 million" area="9,984,670 sq km">
<outline text="Ottawa" type="city" population="0.9 million" timezone="-5 UTC"/>
<outline text="Toronto" type="city" population="2.5 million" timezone="-5 UTC"/>
</outline>
<outline text="United States of America" type="country"/>
</outline>
<outline text="South America" type="continent">
<outline text="Brazil" type="country" population="186 million"/>
<outline text="Argentina" type="country" population="40 million"/>
</outline>
</body>
</opml>
/trunk/api/js/dojo1.0/dojox/data/tests/stores/XmlStore.js
New file
0,0 → 1,881
if(!dojo._hasResource["dojox.data.tests.stores.XmlStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.tests.stores.XmlStore"] = true;
dojo.provide("dojox.data.tests.stores.XmlStore");
dojo.require("dojox.data.XmlStore");
dojo.require("dojo.data.api.Read");
dojo.require("dojo.data.api.Write");
 
 
dojox.data.tests.stores.XmlStore.getBooks2Store = function(){
return new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books2.xml").toString(), label: "title"});
};
 
dojox.data.tests.stores.XmlStore.getBooksStore = function(){
return new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books.xml").toString(), label: "title"});
};
 
doh.register("dojox.data.tests.stores.XmlStore",
[
function testReadAPI_fetch_all(t){
// summary:
// Simple test of fetching all xml items through an XML element called isbn
// description:
// Simple test of fetching all xml items through an XML element called isbn
var store = dojox.data.tests.stores.XmlStore.getBooksStore();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(20, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"*"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_one(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn
// description:
// Simple test of fetching one xml items through an XML element called isbn
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
{
name: "testReadAPI_fetch_paging",
timeout: 10000,
runTest: function(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn
// description:
// Simple test of fetching one xml items through an XML element called isbn
var store = dojox.data.tests.stores.XmlStore.getBooksStore();
var d = new doh.Deferred();
function dumpFirstFetch(items, request){
t.assertEqual(5, items.length);
request.start = 3;
request.count = 1;
request.onComplete = dumpSecondFetch;
store.fetch(request);
}
function dumpSecondFetch(items, request){
t.assertEqual(1, items.length);
request.start = 0;
request.count = 5;
request.onComplete = dumpThirdFetch;
store.fetch(request);
}
function dumpThirdFetch(items, request){
t.assertEqual(5, items.length);
request.start = 2;
request.count = 20;
request.onComplete = dumpFourthFetch;
store.fetch(request);
}
function dumpFourthFetch(items, request){
t.assertEqual(18, items.length);
request.start = 9;
request.count = 100;
request.onComplete = dumpFifthFetch;
store.fetch(request);
}
function dumpFifthFetch(items, request){
t.assertEqual(11, items.length);
request.start = 2;
request.count = 20;
request.onComplete = dumpSixthFetch;
store.fetch(request);
}
function dumpSixthFetch(items, request){
t.assertEqual(18, items.length);
d.callback(true);
}
function completed(items, request){
t.assertEqual(20, items.length);
request.start = 1;
request.count = 5;
request.onComplete = dumpFirstFetch;
store.fetch(request);
}
function error(errData, request){
d.errback(errData);
}
store.fetch({onComplete: completed, onError: error});
return d; //Object
}
},
function testReadAPI_fetch_pattern0(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
// description:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"?9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_pattern1(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
// description:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(4, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B57?"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_pattern2(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with * pattern match
// description:
// Simple test of fetching one xml items through an XML element called isbn with * pattern match
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(5, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9*"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_pattern_caseInsensitive(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case insensitive mode.
// description:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case insensitive mode.
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"?9b574"}, queryOptions: {ignoreCase: true}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_pattern_caseSensitive(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case sensitive mode.
// description:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case sensitive mode.
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"?9B574"}, queryOptions: {ignoreCase: false}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_all_rootItem(t){
// summary:
// Simple test of fetching all xml items through an XML element called isbn
// description:
// Simple test of fetching all xml items through an XML element called isbn
var store = new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books3.xml").toString(),
rootItem:"book"});
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(5, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"*"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_withAttrMap_all(t){
var store = new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books_isbnAttr.xml").toString(),
attributeMap: {"book.isbn": "@isbn"}});
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(5, items.length);
d.callback(true);
}
function onError(error, request) {
console.debug(error);
d.errback(error);
}
store.fetch({query:{isbn:"*"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_withAttrMap_one(t){
var store = new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books_isbnAttr.xml").toString(),
attributeMap: {"book.isbn": "@isbn"}});
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
d.callback(true);
}
function onError(error, request) {
console.debug(error);
d.errback(error);
}
store.fetch({query:{isbn:"2"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_withAttrMap_pattern0(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
// description:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
var store = new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books_isbnAttr2.xml").toString(),
attributeMap: {"book.isbn": "@isbn"}});
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(3, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"ABC?"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_withAttrMap_pattern1(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
// description:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
var store = new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books_isbnAttr2.xml").toString(),
attributeMap: {"book.isbn": "@isbn"}});
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(5, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A*"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_withAttrMap_pattern2(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
// description:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
var store = new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books_isbnAttr2.xml").toString(),
attributeMap: {"book.isbn": "@isbn"}});
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(2, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"?C*"}, onComplete: onComplete, onError: onError});
return d; //Object
},
 
function testReadAPI_getLabel(t){
// summary:
// Simple test of the getLabel function against a store set that has a label defined.
// description:
// Simple test of the getLabel function against a store set that has a label defined.
 
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var label = store.getLabel(items[0]);
t.assertTrue(label !== null);
t.assertEqual("Title of 4", label);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d;
},
function testReadAPI_getLabelAttributes(t){
// summary:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
// description:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
 
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var labelList = store.getLabelAttributes(items[0]);
t.assertTrue(dojo.isArray(labelList));
t.assertEqual("title", labelList[0]);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d;
},
 
function testReadAPI_getValue(t){
// summary:
// Simple test of the getValue API
// description:
// Simple test of the getValue API
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.hasAttribute(item,"isbn"));
t.assertEqual(store.getValue(item,"isbn"), "A9B574");
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_getValues(t){
// summary:
// Simple test of the getValues API
// description:
// Simple test of the getValues API
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.hasAttribute(item,"isbn"));
var values = store.getValues(item,"isbn");
t.assertEqual(1,values.length);
t.assertEqual("A9B574", values[0]);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_isItem(t){
// summary:
// Simple test of the isItem API
// description:
// Simple test of the isItem API
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.isItem(item));
t.assertTrue(!store.isItem({}));
t.assertTrue(!store.isItem("Foo"));
t.assertTrue(!store.isItem(1));
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_isItem_multistore(t){
// summary:
// Simple test of the isItem API across multiple store instances.
// description:
// Simple test of the isItem API across multiple store instances.
var store1 = dojox.data.tests.stores.XmlStore.getBooks2Store();
var store2 = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete1(items, request) {
t.assertEqual(1, items.length);
var item1 = items[0];
t.assertTrue(store1.isItem(item1));
 
function onComplete2(items, request) {
t.assertEqual(1, items.length);
var item2 = items[0];
t.assertTrue(store2.isItem(item2));
t.assertTrue(!store1.isItem(item2));
t.assertTrue(!store2.isItem(item1));
d.callback(true);
}
store2.fetch({query:{isbn:"A9B574"}, onComplete: onComplete2, onError: onError});
}
function onError(error, request) {
d.errback(error);
}
store1.fetch({query:{isbn:"A9B574"}, onComplete: onComplete1, onError: onError});
return d; //Object
},
function testReadAPI_hasAttribute(t){
// summary:
// Simple test of the hasAttribute API
// description:
// Simple test of the hasAttribute API
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.hasAttribute(item,"isbn"));
t.assertTrue(!store.hasAttribute(item,"bob"));
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_containsValue(t){
// summary:
// Simple test of the containsValue API
// description:
// Simple test of the containsValue API
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.containsValue(item,"isbn", "A9B574"));
t.assertTrue(!store.containsValue(item,"isbn", "bob"));
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_sortDescending(t){
// summary:
// Simple test of the sorting API in descending order.
// description:
// Simple test of the sorting API in descending order.
var store = dojox.data.tests.stores.XmlStore.getBooksStore();
 
//Comparison is done as a string type (toString comparison), so the order won't be numeric
//So have to compare in 'alphabetic' order.
var order = [9,8,7,6,5,4,3,20,2,19,18,17,16,15,14,13,12,11,10,1];
var d = new doh.Deferred();
function onComplete(items, request) {
console.log("Number of items: " + items.length);
t.assertEqual(20, items.length);
 
for(var i = 0; i < items.length; i++){
t.assertEqual(order[i], store.getValue(items[i],"isbn").toString());
}
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
 
var sortAttributes = [{attribute: "isbn", descending: true}];
store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_sortAscending(t){
// summary:
// Simple test of the sorting API in ascending order.
// description:
// Simple test of the sorting API in ascending order.
var store = dojox.data.tests.stores.XmlStore.getBooksStore();
 
//Comparison is done as a string type (toString comparison), so the order won't be numeric
//So have to compare in 'alphabetic' order.
var order = [1,10,11,12,13,14,15,16,17,18,19,2,20,3,4,5,6,7,8,9];
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(20, items.length);
var itemId = 1;
for(var i = 0; i < items.length; i++){
t.assertEqual(order[i], store.getValue(items[i],"isbn").toString());
}
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
 
var sortAttributes = [{attribute: "isbn"}];
store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_sortDescendingNumeric(t){
// summary:
// Simple test of the sorting API in descending order using a numeric comparator.
// description:
// Simple test of the sorting API in descending order using a numeric comparator.
var store = dojox.data.tests.stores.XmlStore.getBooksStore();
 
//isbn should be treated as a numeric, not as a string comparison
store.comparatorMap = {};
store.comparatorMap["isbn"] = function(a, b){
var ret = 0;
if(parseInt(a.toString()) > parseInt(b.toString())){
ret = 1;
}else if(parseInt(a.toString()) < parseInt(b.toString())){
ret = -1;
}
return ret; //int, {-1,0,1}
};
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(20, items.length);
var itemId = 20;
for(var i = 0; i < items.length; i++){
t.assertEqual(itemId, store.getValue(items[i],"isbn").toString());
itemId--;
}
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
 
var sortAttributes = [{attribute: "isbn", descending: true}];
store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_sortAscendingNumeric(t){
// summary:
// Simple test of the sorting API in ascending order using a numeric comparator.
// description:
// Simple test of the sorting API in ascending order using a numeric comparator.
var store = dojox.data.tests.stores.XmlStore.getBooksStore();
 
//isbn should be treated as a numeric, not as a string comparison
store.comparatorMap = {};
store.comparatorMap["isbn"] = function(a, b){
var ret = 0;
if(parseInt(a.toString()) > parseInt(b.toString())){
ret = 1;
}else if(parseInt(a.toString()) < parseInt(b.toString())){
ret = -1;
}
return ret; //int, {-1,0,1}
};
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(20, items.length);
var itemId = 1;
for(var i = 0; i < items.length; i++){
t.assertEqual(itemId, store.getValue(items[i],"isbn").toString());
itemId++;
}
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
 
var sortAttributes = [{attribute: "isbn"}];
store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_isItemLoaded(t){
// summary:
// Simple test of the isItemLoaded API
// description:
// Simple test of the isItemLoaded API
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.isItemLoaded(item));
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_getFeatures(t){
// summary:
// Simple test of the getFeatures function of the store
// description:
// Simple test of the getFeatures function of the store
 
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
var features = store.getFeatures();
var count = 0;
for(i in features){
t.assertTrue((i === "dojo.data.api.Read" || i === "dojo.data.api.Write"));
count++;
}
t.assertEqual(2, count);
},
function testReadAPI_getAttributes(t){
// summary:
// Simple test of the getAttributes API
// description:
// Simple test of the getAttributes API
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
var attributes = store.getAttributes(item);
 
//Should be six, as all items should have tagName, childNodes, and text() special attributes
//in addition to any doc defined ones, which in this case are author, title, and isbn
//FIXME: Figure out why IE returns 5! Need to get firebug lite working in IE for that.
//Suspect it's childNodes, may not be defined if there are no child nodes.
for(var i = 0; i < attributes.length; i++){
console.log("attribute found: " + attributes[i]);
}
if(dojo.isIE){
t.assertEqual(5,attributes.length);
}else{
t.assertEqual(6,attributes.length);
}
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testWriteAPI_setValue(t){
// summary:
// Simple test of the setValue API
// description:
// Simple test of the setValue API
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.containsValue(item,"isbn", "A9B574"));
store.setValue(item, "isbn", "A9B574-new");
t.assertEqual(store.getValue(item,"isbn").toString(), "A9B574-new");
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testWriteAPI_setValues(t){
// summary:
// Simple test of the setValues API
// description:
// Simple test of the setValues API
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.containsValue(item,"isbn", "A9B574"));
store.setValues(item, "isbn", ["A9B574-new1", "A9B574-new2"]);
var values = store.getValues(item,"isbn");
t.assertEqual(values[0].toString(), "A9B574-new1");
t.assertEqual(values[1].toString(), "A9B574-new2");
store.setValues(values[0], "text()", ["A9B574", "-new3"]);
t.assertEqual(store.getValue(values[0],"text()").toString(), "A9B574-new3");
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testWriteAPI_unsetAttribute(t){
// summary:
// Simple test of the unsetAttribute API
// description:
// Simple test of the unsetAttribute API
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.containsValue(item,"isbn", "A9B574"));
store.unsetAttribute(item,"isbn");
t.assertTrue(!store.hasAttribute(item,"isbn"));
t.assertTrue(store.isDirty(item));
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testWriteAPI_isDirty(t){
// summary:
// Simple test of the isDirty API
// description:
// Simple test of the isDirty API
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.containsValue(item,"isbn", "A9B574"));
store.setValue(item, "isbn", "A9B574-new");
t.assertEqual(store.getValue(item,"isbn").toString(), "A9B574-new");
t.assertTrue(store.isDirty(item));
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testWriteAPI_revert(t){
// summary:
// Simple test of the isDirty API
// description:
// Simple test of the isDirty API
var store = dojox.data.tests.stores.XmlStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.containsValue(item,"isbn", "A9B574"));
t.assertTrue(!store.isDirty(item));
store.setValue(item, "isbn", "A9B574-new");
t.assertEqual(store.getValue(item,"isbn").toString(), "A9B574-new");
t.assertTrue(store.isDirty(item));
store.revert();
//Fetch again to see if it reset the state.
function onComplete1(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.containsValue(item,"isbn", "A9B574"));
d.callback(true);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete1, onError: onError});
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_functionConformance(t){
// summary:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
// description:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
 
var testStore = dojox.data.tests.stores.XmlStore.getBooksStore();
var readApi = new dojo.data.api.Read();
var passed = true;
 
for(i in readApi){
var member = readApi[i];
//Check that all the 'Read' defined functions exist on the test store.
if(typeof member === "function"){
var testStoreMember = testStore[i];
if(!(typeof testStoreMember === "function")){
console.log("Problem with function: [" + i + "]");
passed = false;
break;
}
}
}
t.assertTrue(passed);
},
function testWriteAPI_functionConformance(t){
// summary:
// Simple test write API conformance. Checks to see all declared functions are actual functions on the instances.
// description:
// Simple test write API conformance. Checks to see all declared functions are actual functions on the instances.
 
var testStore = dojox.data.tests.stores.XmlStore.getBooksStore();
var writeApi = new dojo.data.api.Write();
var passed = true;
 
for(i in writeApi){
var member = writeApi[i];
//Check that all the 'Write' defined functions exist on the test store.
if(typeof member === "function"){
var testStoreMember = testStore[i];
if(!(typeof testStoreMember === "function")){
passed = false;
break;
}
}
}
t.assertTrue(passed);
}
]
);
 
 
 
 
 
}
/trunk/api/js/dojo1.0/dojox/data/tests/stores/QueryReadStore.js
New file
0,0 → 1,338
if(!dojo._hasResource["dojox.data.tests.stores.QueryReadStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.tests.stores.QueryReadStore"] = true;
dojo.provide("dojox.data.tests.stores.QueryReadStore");
dojo.require("dojox.data.QueryReadStore");
dojo.require("dojo.data.api.Read");
 
//dojo.require("dojox.testing.DocTest");
 
dojox.data.tests.stores.QueryReadStore.getStore = function(){
return new dojox.data.QueryReadStore({
url: dojo.moduleUrl("dojox.data.tests", "stores/QueryReadStore.php").toString(),
doClientPaging:true // "true" is actually also the default, but make sure :-).
});
};
 
 
tests.register("dojox.data.tests.stores.QueryReadStore",
[
/*
function testDocTests(t) {
// summary:
// Run all the doc comments.
var doctest = new dojox.testing.DocTest();
doctest.run("dojox.data.QueryReadStore");
t.assertTrue(doctest.errors.length==0);
},
*/
function testReadApi_getValue(t){
// summary:
// description:
var store = dojox.data.tests.stores.QueryReadStore.getStore();
var d = new doh.Deferred();
function onComplete(items, request){
var item = items[0];
// The good cases.
t.assertEqual("Alabama", store.getValue(item, "name"));
t.assertEqual("<img src='images/Alabama.jpg'/>Alabama", store.getValue(item, "label"));
t.assertEqual("AL", store.getValue(item, "abbreviation"));
// Test the defaultValue cases (the third paramter).
t.assertEqual("default value", store.getValue(item, "NAME", "default value"));
// TODO Test for null somehow ...
// Read api says: Returns null if and only if null was explicitly set as the attribute value.
// According to Read-API getValue() an exception is thrown when
// the item is not an item or when the attribute is not a string.
t.assertError(Error, store, "getValue", ["not an item", "NOT THERE"]);
t.assertError(Error, store, "getValue", [item, {}]);
d.callback(true);
}
store.fetch({query:{q:"Alabama"}, onComplete: onComplete});
return d; //Object
},
 
function testReadApi_getValues(t){
// summary:
// description:
var store = dojox.data.tests.stores.QueryReadStore.getStore();
var d = new doh.Deferred();
function onComplete(items, request){
var item = items[0];
// The good cases.
t.assertEqual(["Alabama"], store.getValues(item, "name"));
t.assertEqual(["<img src='images/Alabama.jpg'/>Alabama"], store.getValues(item, "label"));
t.assertEqual(["AL"], store.getValues(item, "abbreviation"));
// TODO Test for null somehow ...
// Read api says: Returns null if and only if null was explicitly set as the attribute value.
 
// Test for not-existing attributes without defaultValues and invalid items.
// TODO
//dojox.data.tests.stores.QueryReadStore.assertError(dojox.data.QueryReadStore.InvalidAttributeError, store, "getValues", [item, "NOT THERE"]);
//dojox.data.tests.stores.QueryReadStore.assertError(dojox.data.QueryReadStore.InvalidItemError, store, "getValues", ["not an item", "NOT THERE"]);
d.callback(true);
}
store.fetch({query:{q:"Alabama"}, onComplete: onComplete});
return d; //Object
},
function testReadApi_getAttributes(t){
// summary:
// description:
var store = dojox.data.tests.stores.QueryReadStore.getStore();
var d = new doh.Deferred();
function onComplete(items, request){
var item = items[0];
// The good case(s).
t.assertEqual(['name', 'label', 'abbreviation'], store.getAttributes(item));
t.assertError(dojox.data.QueryReadStore.InvalidItemError, store, "getAttributes", [{}]);
d.callback(true);
}
store.fetch({query:{q:"Alabama"}, onComplete: onComplete});
return d; //Object
},
 
function testReadApi_hasAttribute(t){
// summary:
// description:
var store = dojox.data.tests.stores.QueryReadStore.getStore();
var d = new doh.Deferred();
function onComplete(items, request){
var item = items[0];
// The positive cases.
t.assertEqual(true, store.hasAttribute(item, "name"));
t.assertEqual(true, store.hasAttribute(item, "label"));
t.assertEqual(true, store.hasAttribute(item, "abbreviation"));
// Make sure attribute case doesnt matter.
t.assertEqual(false, store.hasAttribute(item, "NAME"));
t.assertEqual(false, store.hasAttribute(item, "Name"));
t.assertEqual(false, store.hasAttribute(item, "Label"));
// Pass in an invalid item.
t.assertEqual(false, store.hasAttribute({}, "abbreviation"));
// pass in something that looks like the item with the attribute.
t.assertEqual(false, store.hasAttribute({name:"yo"}, "name"));
d.callback(true);
}
store.fetch({query:{q:"Alaska"}, onComplete: onComplete});
return d; //Object
},
 
function testReadApi_containsValue(t){
// summary:
// description:
var store = dojox.data.tests.stores.QueryReadStore.getStore();
 
var d = new doh.Deferred();
function onComplete(items, request){
var item = items[0];
t.assertTrue(store.containsValue(item, "name", "Alaska"));
d.callback(true);
}
store.fetch({query:{q:"Alaska"}, onComplete: onComplete});
return d; //Object
},
 
function testReadApi_isItem(t){
// summary:
// description:
var store = dojox.data.tests.stores.QueryReadStore.getStore();
var d = new doh.Deferred();
function onComplete(items, request){
// The good case.
t.assertEqual(true, store.isItem(items[0]));
// Try a pure object.
t.assertEqual(false, store.isItem({}));
// Try to look like an item.
t.assertEqual(false, store.isItem({name:"Alaska", label:"Alaska", abbreviation:"AK"}));
d.callback(true);
}
store.fetch({query:{q:"Alaska"}, onComplete: onComplete});
return d; //Object
},
 
function testReadApi_isItemLoaded(t){
// summary:
// description:
var store = dojox.data.tests.stores.QueryReadStore.getStore();
var d = new doh.Deferred();
function onComplete(items, request){
var item = items[0];
// The good case(s).
t.assertTrue(store.isItemLoaded(item));
d.callback(true);
}
store.fetch({query:{q:"Alabama"}, onComplete: onComplete});
return d; //Object
},
 
//function testReadApi_loadItem(t){
// // summary:
// // description:
// t.assertTrue(false);
//},
 
function testReadApi_fetch_all(t){
// summary:
// Simple test of fetching all items.
// description:
// Simple test of fetching all items.
var store = dojox.data.tests.stores.QueryReadStore.getStore();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(8, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{q:"a"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadApi_fetch_one(t){
// summary:
// description:
var store = dojox.data.tests.stores.QueryReadStore.getStore();
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(1, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{q:"Alaska"}, onComplete: onComplete, onError: onError});
return d; //Object
},
 
function testReadApi_fetch_client_paging(t){
// summary:
// Lets test that paging on the same request does not trigger
// server requests.
// description:
var store = dojox.data.tests.stores.QueryReadStore.getStore();
 
var lastRequestHash = null;
var firstItems = [];
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(5, items.length);
lastRequestHash = store.lastRequestHash;
firstItems = items;
// Do the next request AFTER the previous one, so we are sure its sequential.
// We need to be sure so we can compare to the data from the first request.
function onComplete1(items, request) {
t.assertEqual(5, items.length);
t.assertEqual(lastRequestHash, store.lastRequestHash);
t.assertEqual(firstItems[1], items[0]);
d.callback(true);
}
req.start = 1;
req.onComplete = onComplete1;
store.fetch(req);
}
function onError(error, request) {
d.errback(error);
}
var req = {query:{q:"a"}, start:0, count:5,
onComplete: onComplete, onError: onError};
store.fetch(req);
return d; //Object
},
function testReadApi_fetch_server_paging(t) {
// Verify that the paging on the server side does work.
// This is the test for http://trac.dojotoolkit.org/ticket/4761
//
// How? We request 10 items from the server, start=0, count=10.
// The second request requests 5 items: start=5, count=5 and those
// 5 items should have the same values as the last 5 of the first
// request.
// This tests if the server side paging does work.
var store = dojox.data.tests.stores.QueryReadStore.getStore();
 
var lastRequestHash = null;
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(10, items.length);
lastRequestHash = store.lastRequestHash;
firstItems = items;
// Do the next request AFTER the previous one, so we are sure its sequential.
// We need to be sure so we can compare to the data from the first request.
function onComplete1(items, request) {
t.assertEqual(5, items.length);
// Compare the hash of the last request, they must be different,
// since another server request was issued.
t.assertTrue(lastRequestHash!=store.lastRequestHash);
t.assertEqual(store.getValue(firstItems[5], "name"), store.getValue(items[0], "name"));
t.assertEqual(store.getValue(firstItems[6], "name"), store.getValue(items[1], "name"));
t.assertEqual(store.getValue(firstItems[7], "name"), store.getValue(items[2], "name"));
t.assertEqual(store.getValue(firstItems[8], "name"), store.getValue(items[3], "name"));
t.assertEqual(store.getValue(firstItems[9], "name"), store.getValue(items[4], "name"));
d.callback(true);
}
// Init a new store, or it will use the old data, since the query has not changed.
store.doClientPaging = false;
store.fetch({start:5, count:5, onComplete: onComplete1, onError: onError});
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{}, start:0, count:10, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadApi_getFeatures(t) {
var store = dojox.data.tests.stores.QueryReadStore.getStore();
var features = store.getFeatures();
t.assertTrue(features["dojo.data.api.Read"]);
t.assertTrue(features["dojo.data.api.Identity"]);
var count = 0;
for (i in features){
count++;
}
t.assertEqual(2, count);
},
function testReadAPI_functionConformance(t){
// summary:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
// description:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
 
var testStore = dojox.data.tests.stores.QueryReadStore.getStore();
var readApi = new dojo.data.api.Read();
var passed = true;
 
for(i in readApi){
var member = readApi[i];
//Check that all the 'Read' defined functions exist on the test store.
if(typeof member === "function"){
var testStoreMember = testStore[i];
if(!(typeof testStoreMember === "function")){
console.log("Problem with function: [" + i + "]");
passed = false;
break;
}
}
}
t.assertTrue(passed);
}
]
);
 
}
/trunk/api/js/dojo1.0/dojox/data/tests/stores/patterns.csv
New file
0,0 → 1,11
uniqueId, value
9, jfq4@#!$!@Rf14r14i5u
6, BaBaMaSaRa***Foo
2, bar*foo
8, 123abc
4, bit$Bite
3, 123abc
10, 123abcdefg
1, foo*bar
7,
5, 123abc
/trunk/api/js/dojo1.0/dojox/data/tests/stores/movies.csv
New file
0,0 → 1,9
Title, Year, Producer
City of God, 2002, Katia Lund
Rain,, Christine Jeffs
2001: A Space Odyssey, , Stanley Kubrick
"This is a ""fake"" movie title", 1957, Sidney Lumet
Alien, 1979 , Ridley Scott
"The Sequel to ""Dances With Wolves.""", 1982, Ridley Scott
"Caine Mutiny, The", 1954, "Dymtryk ""the King"", Edward"
 
/trunk/api/js/dojo1.0/dojox/data/tests/stores/books2.xml
New file
0,0 → 1,28
<?xml version="1.0" encoding="ISO-8859-1"?>
<books>
<book>
<isbn>A9B57C</isbn>
<title>Title of 1</title>
<author>Author of 1</author>
</book>
<book>
<isbn>A9B57F</isbn>
<title>Title of 2</title>
<author>Author of 2</author>
</book>
<book>
<isbn>A9B577</isbn>
<title>Title of 3</title>
<author>Author of 3</author>
</book>
<book>
<isbn>A9B574</isbn>
<title>Title of 4</title>
<author>Author of 4</author>
</book>
<book>
<isbn>A9B5CC</isbn>
<title>Title of 5</title>
<author>Author of 5</author>
</book>
</books>
/trunk/api/js/dojo1.0/dojox/data/tests/stores/OpmlStore.js
New file
0,0 → 1,1075
if(!dojo._hasResource["dojox.data.tests.stores.OpmlStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.tests.stores.OpmlStore"] = true;
dojo.provide("dojox.data.tests.stores.OpmlStore");
dojo.require("dojox.data.OpmlStore");
dojo.require("dojo.data.api.Read");
 
dojox.data.tests.stores.OpmlStore.getDatasource = function(filepath){
// summary:
// A simple helper function for getting the sample data used in each of the tests.
// description:
// A simple helper function for getting the sample data used in each of the tests.
var dataSource = {};
if(dojo.isBrowser){
dataSource.url = dojo.moduleUrl("dojox.data.tests", filepath).toString();
}else{
// When running tests in Rhino, xhrGet is not available,
// so we have the file data in the code below.
switch(filepath){
case "stores/geography.xml":
var opmlData = "";
opmlData += '<?xml version="1.0" encoding="ISO-8859-1"?>\n';
opmlData += ' <opml version="1.0">\n';
opmlData += ' <head>\n';
opmlData += ' <title>geography.opml</title>\n';
opmlData += ' <dateCreated>2006-11-10</dateCreated>\n';
opmlData += ' <dateModified>2006-11-13</dateModified>\n';
opmlData += ' <ownerName>Magellan, Ferdinand</ownerName>\n';
opmlData += ' </head>\n';
opmlData += ' <body>\n';
opmlData += ' <outline text="Africa" type="continent">\n';
opmlData += ' <outline text="Egypt" type="country"/>\n';
opmlData += ' <outline text="Kenya" type="country">\n';
opmlData += ' <outline text="Nairobi" type="city"/>\n';
opmlData += ' <outline text="Mombasa" type="city"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="Sudan" type="country">\n';
opmlData += ' <outline text="Khartoum" type="city"/>\n';
opmlData += ' </outline>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="Asia" type="continent">\n';
opmlData += ' <outline text="China" type="country"/>\n';
opmlData += ' <outline text="India" type="country"/>\n';
opmlData += ' <outline text="Russia" type="country"/>\n';
opmlData += ' <outline text="Mongolia" type="country"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="Australia" type="continent" population="21 million">\n';
opmlData += ' <outline text="Australia" type="country" population="21 million"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="Europe" type="continent">\n';
opmlData += ' <outline text="Germany" type="country"/>\n';
opmlData += ' <outline text="France" type="country"/>\n';
opmlData += ' <outline text="Spain" type="country"/>\n';
opmlData += ' <outline text="Italy" type="country"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="North America" type="continent">\n';
opmlData += ' <outline text="Mexico" type="country" population="108 million" area="1,972,550 sq km">\n';
opmlData += ' <outline text="Mexico City" type="city" population="19 million" timezone="-6 UTC"/>\n';
opmlData += ' <outline text="Guadalajara" type="city" population="4 million" timezone="-6 UTC"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="Canada" type="country" population="33 million" area="9,984,670 sq km">\n';
opmlData += ' <outline text="Ottawa" type="city" population="0.9 million" timezone="-5 UTC"/>\n';
opmlData += ' <outline text="Toronto" type="city" population="2.5 million" timezone="-5 UTC"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="United States of America" type="country"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="South America" type="continent">\n';
opmlData += ' <outline text="Brazil" type="country" population="186 million"/>\n';
opmlData += ' <outline text="Argentina" type="country" population="40 million"/>\n';
opmlData += ' </outline>\n';
opmlData += ' </body>\n';
opmlData += ' </opml>\n';
break;
case "stores/geography_withspeciallabel.xml":
var opmlData = "";
opmlData += '<?xml version="1.0" encoding="ISO-8859-1"?>\n';
opmlData += '<opml version="1.0">\n';
opmlData += ' <head>\n';
opmlData += ' <title>geography.opml</title>\n';
opmlData += ' <dateCreated>2006-11-10</dateCreated>\n';
opmlData += ' <dateModified>2006-11-13</dateModified>\n';
opmlData += ' <ownerName>Magellan, Ferdinand</ownerName>\n';
opmlData += ' </head>\n';
opmlData += ' <body>\n';
opmlData += ' <outline text="Africa" type="continent" label="Continent/Africa">\n';
opmlData += ' <outline text="Egypt" type="country" label="Country/Egypt"/>\n';
opmlData += ' <outline text="Kenya" type="country" label="Country/Kenya">\n';
opmlData += ' <outline text="Nairobi" type="city" label="City/Nairobi"/>\n';
opmlData += ' <outline text="Mombasa" type="city" label="City/Mombasa"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="Sudan" type="country" label="Country/Sudan">\n';
opmlData += ' <outline text="Khartoum" type="city" label="City/Khartoum"/>\n';
opmlData += ' </outline>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="Asia" type="continent" label="Continent/Asia">\n';
opmlData += ' <outline text="China" type="country" label="Country/China"/>\n';
opmlData += ' <outline text="India" type="country" label="Country/India"/>\n';
opmlData += ' <outline text="Russia" type="country" label="Country/Russia"/>\n';
opmlData += ' <outline text="Mongolia" type="country" label="Country/Mongolia"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="Australia" type="continent" population="21 million" label="Continent/Australia">\n';
opmlData += ' <outline text="Australia" type="country" population="21 million" label="Country/Australia"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="Europe" type="continent" label="Contintent/Europe">\n';
opmlData += ' <outline text="Germany" type="country" label="Country/Germany"/>\n';
opmlData += ' <outline text="France" type="country" label="Country/France"/>\n';
opmlData += ' <outline text="Spain" type="country" label="Country/Spain"/>\n';
opmlData += ' <outline text="Italy" type="country" label="Country/Italy"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="North America" type="continent" label="Continent/North America">\n';
opmlData += ' <outline text="Mexico" type="country" population="108 million" area="1,972,550 sq km" label="Country/Mexico">\n';
opmlData += ' <outline text="Mexico City" type="city" population="19 million" timezone="-6 UTC" label="City/Mexico City"/>\n';
opmlData += ' <outline text="Guadalajara" type="city" population="4 million" timezone="-6 UTC" label="City/Guadalajara"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="Canada" type="country" population="33 million" area="9,984,670 sq km" label="Country/Canada">\n';
opmlData += ' <outline text="Ottawa" type="city" population="0.9 million" timezone="-5 UTC" label="City/Ottawa"/>\n';
opmlData += ' <outline text="Toronto" type="city" population="2.5 million" timezone="-5 UTC" label="City/Toronto"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="United States of America" type="country" label="Country/United States of America"/>\n';
opmlData += ' </outline>\n';
opmlData += ' <outline text="South America" type="continent" label="Continent/South America">\n';
opmlData += ' <outline text="Brazil" type="country" population="186 million" label="Country/Brazil"/>\n';
opmlData += ' <outline text="Argentina" type="country" population="40 million" label="Country/Argentina"/>\n';
opmlData += ' </outline>\n';
opmlData += ' </body>\n';
opmlData += '</opml>\n';
break;
}
dataSource.data = opmlData;
}
return dataSource; //Object
}
 
dojox.data.tests.stores.OpmlStore.verifyItems = function(opmlStore, items, attribute, compareArray){
// summary:
// A helper function for validating that the items array is ordered
// the same as the compareArray
if(items.length != compareArray.length){ return false; }
for(var i = 0; i < items.length; i++){
if(!(opmlStore.getValue(items[i], attribute) === compareArray[i])){
return false; //Boolean
}
}
return true; //Boolean
}
 
dojox.data.tests.stores.OpmlStore.error = function(t, d, errData){
// summary:
// The error callback function to be used for all of the tests.
d.errback(errData);
}
 
doh.register("dojox.data.tests.stores.OpmlStore",
[
function testReadAPI_fetch_all(t){
// summary:
// Simple test of a basic fetch on OpmlStore.
// description:
// Simple test of a basic fetch on OpmlStore.
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function completedAll(items){
t.is(6, items.length);
d.callback(true);
}
 
//Get everything...
opmlStore.fetch({ onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_one(t){
// summary:
// Simple test of a basic fetch on OpmlStore of a single item.
// description:
// Simple test of a basic fetch on OpmlStore of a single item.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function onComplete(items, request){
t.is(1, items.length);
d.callback(true);
}
opmlStore.fetch({ query: {text: "Asia"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
return d; //Object
},
 
function testReadAPI_fetch_one_Multiple(t){
// summary:
// Simple test of a basic fetch on OpmlStore of a single item.
// description:
// Simple test of a basic fetch on OpmlStore of a single item.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
var done = [false,false];
function onCompleteOne(items, request){
done[0] = true;
t.is(1, items.length);
if(done[0] && done[1]){
d.callback(true);
}
}
function onCompleteTwo(items, request){
done[1] = true;
t.is(1, items.length);
if(done[0] && done[1]){
d.callback(true);
}
}
 
opmlStore.fetch({ query: {text: "Asia"},
onComplete: onCompleteOne,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
 
opmlStore.fetch({ query: {text: "North America"},
onComplete: onCompleteTwo,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
 
return d; //Object
},
 
function testReadAPI_fetch_one_MultipleMixed(t){
// summary:
// Simple test of a basic fetch on OpmlStore of a single item mixing two fetch types.
// description:
// Simple test of a basic fetch on Cpmltore of a single item mixing two fetch types.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
 
var done = [false, false];
function onComplete(items, request){
done[0] = true;
t.is(1, items.length);
console.log("Found item: " + opmlStore.getValue(items[0],"text") + " with identity: " + opmlStore.getIdentity(items[0]));
t.is(0, opmlStore.getIdentity(items[0]));
if(done[0] && done[1]){
d.callback(true);
}
}
function onItem(item){
done[1] = true;
t.assertTrue(item !== null);
console.log("Found item: " + opmlStore.getValue(item,"text"));
t.is('Egypt', opmlStore.getValue(item,"text")); //Should be the second node parsed, ergo id 1, first node is id 0.
t.is(1, opmlStore.getIdentity(item));
if(done[0] && done[1]){
d.callback(true);
}
}
 
opmlStore.fetch({ query: {text: "Africa"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
opmlStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
 
return d; //Object
},
 
function testReadAPI_fetch_one_deep(t){
// summary:
// Simple test of a basic fetch on OpmlStore of a single item that's nested down as a child item.
// description:
// Simple test of a basic fetch on OpmlStore of a single item that's nested down as a child item.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function onComplete(items, request){
t.is(1, items.length);
d.callback(true);
}
opmlStore.fetch({ query: {text: "Mexico City"},
queryOptions: {deep:true},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
return d; //Object
},
 
function testReadAPI_fetch_one_deep_off(t){
// summary:
// Simple test of a basic fetch on OpmlStore of a single item that's nested down as a child item.
// description:
// Simple test of a basic fetch on OpmlStore of a single item that's nested down as a child item.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function onComplete(items, request){
//Nothing should be found.
t.is(0, items.length);
d.callback(true);
}
opmlStore.fetch({ query: {text: "Mexico City"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
return d; //Object
},
 
function testReadAPI_fetch_all_streaming(t){
// summary:
// Simple test of a basic fetch on OpmlStore.
// description:
// Simple test of a basic fetch on OpmlStore.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
 
var d = new doh.Deferred();
count = 0;
 
function onBegin(size, requestObj){
t.is(6, size);
}
function onItem(item, requestObj){
t.assertTrue(opmlStore.isItem(item));
count++;
}
function onComplete(items, request){
t.is(6, count);
t.is(null, items);
d.callback(true);
}
 
//Get everything...
opmlStore.fetch({ onBegin: onBegin,
onItem: onItem,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
return d; //Object
},
function testReadAPI_fetch_paging(t){
// summary:
// Test of multiple fetches on a single result. Paging, if you will.
// description:
// Test of multiple fetches on a single result. Paging, if you will.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function dumpFirstFetch(items, request){
t.is(5, items.length);
request.start = 3;
request.count = 1;
request.onComplete = dumpSecondFetch;
opmlStore.fetch(request);
}
 
function dumpSecondFetch(items, request){
t.is(1, items.length);
request.start = 0;
request.count = 5;
request.onComplete = dumpThirdFetch;
opmlStore.fetch(request);
}
 
function dumpThirdFetch(items, request){
t.is(5, items.length);
request.start = 2;
request.count = 20;
request.onComplete = dumpFourthFetch;
opmlStore.fetch(request);
}
 
function dumpFourthFetch(items, request){
t.is(4, items.length);
request.start = 9;
request.count = 100;
request.onComplete = dumpFifthFetch;
opmlStore.fetch(request);
}
 
function dumpFifthFetch(items, request){
t.is(0, items.length);
request.start = 2;
request.count = 20;
request.onComplete = dumpSixthFetch;
opmlStore.fetch(request);
}
 
function dumpSixthFetch(items, request){
t.is(4, items.length);
d.callback(true);
}
 
function completed(items, request){
t.is(6, items.length);
request.start = 1;
request.count = 5;
request.onComplete = dumpFirstFetch;
opmlStore.fetch(request);
}
 
opmlStore.fetch({onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
 
},
function testReadAPI_getLabel(t){
// summary:
// Simple test of the getLabel function against a store set that has a label defined.
// description:
// Simple test of the getLabel function against a store set that has a label defined.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var label = opmlStore.getLabel(items[0]);
t.assertTrue(label !== null);
t.assertEqual("Asia", label);
d.callback(true);
}
opmlStore.fetch({ query: {text: "Asia"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
return d;
},
function testReadAPI_getLabelAttributes(t){
// summary:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
// description:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var labelList = opmlStore.getLabelAttributes(items[0]);
t.assertTrue(dojo.isArray(labelList));
t.assertEqual("text", labelList[0]);
d.callback(true);
}
opmlStore.fetch({ query: {text: "Asia"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
return d;
},
 
function testReadAPI_getLabel_nondefault(t){
// summary:
// Simple test of the getLabel function against a store set that has a label defined.
// description:
// Simple test of the getLabel function against a store set that has a label defined.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography_withspeciallabel.xml");
args.label="label";
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var label = opmlStore.getLabel(items[0]);
t.assertTrue(label !== null);
t.assertEqual("Continent/Asia", label);
d.callback(true);
}
opmlStore.fetch({ query: {text: "Asia"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
return d;
},
function testReadAPI_getLabelAttributes_nondefault(t){
// summary:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
// description:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography_withspeciallabel.xml");
args.label="label";
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var labelList = opmlStore.getLabelAttributes(items[0]);
t.assertTrue(dojo.isArray(labelList));
t.assertEqual("label", labelList[0]);
d.callback(true);
}
opmlStore.fetch({ query: {text: "Asia"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
return d;
},
 
function testReadAPI_getValue(t){
// summary:
// Simple test of the getValue function of the store.
// description:
// Simple test of the getValue function of the store.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function completedAll(items){
t.is(6, items.length);
t.is("Africa", opmlStore.getValue(items[0],"text"));
t.is("Asia", opmlStore.getValue(items[1],"text"));
t.is("Australia", opmlStore.getValue(items[2],"text"));
t.is("Europe", opmlStore.getValue(items[3],"text"));
t.is("North America", opmlStore.getValue(items[4],"text"));
t.is("South America", opmlStore.getValue(items[5],"text"));
t.is("continent", opmlStore.getValue(items[1],"type"));
t.is("21 million", opmlStore.getValue(items[2],"population"));
var firstChild = opmlStore.getValue(items[4],"children");
t.assertTrue(opmlStore.isItem(firstChild));
t.is("Mexico", opmlStore.getValue(firstChild,"text"));
t.is("country", opmlStore.getValue(firstChild,"type"));
t.is("108 million", opmlStore.getValue(firstChild,"population"));
t.is("1,972,550 sq km", opmlStore.getValue(firstChild,"area"));
firstChild = opmlStore.getValue(firstChild,"children");
t.assertTrue(opmlStore.isItem(firstChild));
t.is("Mexico City", opmlStore.getValue(firstChild,"text"));
t.is("city", opmlStore.getValue(firstChild,"type"));
t.is("19 million", opmlStore.getValue(firstChild,"population"));
t.is("-6 UTC", opmlStore.getValue(firstChild,"timezone"));
d.callback(true);
}
 
//Get everything...
opmlStore.fetch({ onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_getValues(t){
// summary:
// Simple test of the getValues function of the store.
// description:
// Simple test of the getValues function of the store.
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
 
var d = new doh.Deferred();
function completed(items){
t.is(1, items.length);
var children = opmlStore.getValues(items[0],"children");
t.is(3, children.length);
for(var i=0; i<children.length; i++){
t.assertTrue(opmlStore.isItem(children[i]));
}
t.is("Mexico", opmlStore.getValues(children[0],"text")[0]);
t.is("country", opmlStore.getValues(children[0],"type")[0]);
t.is("108 million", opmlStore.getValues(children[0],"population")[0]);
t.is("1,972,550 sq km", opmlStore.getValues(children[0],"area")[0]);
t.is("Canada", opmlStore.getValues(children[1],"text")[0]);
t.is("country", opmlStore.getValues(children[1],"type")[0]);
children = opmlStore.getValues(children[1],"children");
t.is(2, children.length);
for(var i=0; i<children.length; i++){
t.assertTrue(opmlStore.isItem(children[i]));
}
t.is("Ottawa", opmlStore.getValues(children[0],"text")[0]);
t.is("Toronto", opmlStore.getValues(children[1],"text")[0]);
d.callback(true);
}
 
//Get one item...
opmlStore.fetch({ query: {text: "North America"},
onComplete: completed,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_isItem(t){
// summary:
// Simple test of the isItem function of the store
// description:
// Simple test of the isItem function of the store
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
 
var d = new doh.Deferred();
function completedAll(items){
t.is(6, items.length);
for(var i=0; i<6; i++){
t.assertTrue(opmlStore.isItem(items[i]));
}
t.assertTrue(!opmlStore.isItem({}));
t.assertTrue(!opmlStore.isItem({ item: "not an item" }));
t.assertTrue(!opmlStore.isItem("not an item"));
t.assertTrue(!opmlStore.isItem(["not an item"]));
d.callback(true);
}
 
//Get everything...
opmlStore.fetch({ onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_hasAttribute(t){
// summary:
// Simple test of the hasAttribute function of the store
// description:
// Simple test of the hasAttribute function of the store
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
 
var d = new doh.Deferred();
function onComplete(items){
t.is(1, items.length);
t.assertTrue(items[0] !== null);
t.assertTrue(opmlStore.hasAttribute(items[0], "text"));
t.assertTrue(opmlStore.hasAttribute(items[0], "type"));
t.assertTrue(!opmlStore.hasAttribute(items[0], "population"));
t.assertTrue(!opmlStore.hasAttribute(items[0], "Nothing"));
t.assertTrue(!opmlStore.hasAttribute(items[0], "Text"));
//Test that null attributes throw an exception
var passed = false;
try{
opmlStore.hasAttribute(items[0], null);
}catch (e){
passed = true;
}
t.assertTrue(passed);
d.callback(true);
}
 
//Get one item...
opmlStore.fetch({ query: {text: "Asia"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
return d; //Object
},
function testReadAPI_containsValue(t){
// summary:
// Simple test of the containsValue function of the store
// description:
// Simple test of the containsValue function of the store
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function onComplete(items){
t.is(1, items.length);
t.assertTrue(items[0] !== null);
t.assertTrue(opmlStore.containsValue(items[0], "text", "North America"));
t.assertTrue(opmlStore.containsValue(items[0], "type", "continent"));
t.assertTrue(!opmlStore.containsValue(items[0], "text", "America"));
t.assertTrue(!opmlStore.containsValue(items[0], "Type", "continent"));
t.assertTrue(!opmlStore.containsValue(items[0], "text", null));
var children = opmlStore.getValues(items[0], "children");
t.assertTrue(opmlStore.containsValue(items[0], "children", children[0]));
t.assertTrue(opmlStore.containsValue(items[0], "children", children[1]));
t.assertTrue(opmlStore.containsValue(items[0], "children", children[2]));
//Test that null attributes throw an exception
var passed = false;
try{
opmlStore.containsValue(items[0], null, "foo");
}catch (e){
passed = true;
}
t.assertTrue(passed);
d.callback(true);
}
 
//Get one item...
opmlStore.fetch({ query: {text: "North America"},
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)
});
return d; //Object
},
function testReadAPI_getAttributes(t){
// summary:
// Simple test of the getAttributes function of the store
// description:
// Simple test of the getAttributes function of the store
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
 
var d = new doh.Deferred();
function onComplete(items){
t.is(6, items.length);
t.assertTrue(opmlStore.isItem(items[0]));
var attributes = opmlStore.getAttributes(items[0]);
t.is(3, attributes.length);
for(var i = 0; i < attributes.length; i++){
t.assertTrue((attributes[i] === "text" || attributes[i] === "type" || attributes[i] === "children"));
}
d.callback(true);
}
 
//Get everything...
opmlStore.fetch({ onComplete: onComplete, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_getFeatures(t){
// summary:
// Simple test of the getFeatures function of the store
// description:
// Simple test of the getFeatures function of the store
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
 
var features = opmlStore.getFeatures();
var count = 0;
for(i in features){
t.assertTrue((i === "dojo.data.api.Read") || (i === "dojo.data.api.Identity"));
count++;
}
t.assertTrue(count === 2);
},
function testReadAPI_fetch_patternMatch0(t){
// summary:
// Function to test pattern matching of everything starting with Capital A
// description:
// Function to test pattern matching of everything starting with Capital A
 
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
 
var d = new doh.Deferred();
function completed(items, request){
t.is(3, items.length);
var valueArray = [ "Africa", "Asia", "Australia"];
t.assertTrue(dojox.data.tests.stores.OpmlStore.verifyItems(opmlStore, items, "text", valueArray));
d.callback(true);
}
opmlStore.fetch({query: {text: "A*"}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_patternMatch1(t){
// summary:
// Function to test pattern matching of everything with America in it.
// description:
// Function to test pattern matching of everything with America in it.
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function completed(items, request){
t.assertTrue(items.length === 2);
var valueArray = [ "North America", "South America"];
t.assertTrue(dojox.data.tests.stores.OpmlStore.verifyItems(opmlStore, items, "text", valueArray));
d.callback(true);
}
opmlStore.fetch({query: {text: "*America*"}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_patternMatch2(t){
// summary:
// Function to test exact pattern match
// description:
// Function to test exact pattern match
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function completed(items, request){
t.is(1, items.length);
t.assertTrue(opmlStore.getValue(items[0], "text") === "Europe");
d.callback(true);
}
opmlStore.fetch({query: {text: "Europe"}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_patternMatch_caseInsensitive(t){
// summary:
// Function to test exact pattern match with case insensitivity set.
// description:
// Function to test exact pattern match with case insensitivity set.
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function completed(items, request){
t.is(1, items.length);
t.assertTrue(opmlStore.getValue(items[0], "text") === "Asia");
d.callback(true);
}
opmlStore.fetch({query: {text: "asia"}, queryOptions: {ignoreCase: true}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_patternMatch_caseSensitive(t){
// summary:
// Function to test exact pattern match with case sensitivity set.
// description:
// Function to test exact pattern match with case sensitivity set.
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function completed(items, request){
t.is(0, items.length);
d.callback(true);
}
opmlStore.fetch({query: {text: "ASIA"}, queryOptions: {ignoreCase: false}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_sortAlphabetic(t){
// summary:
// Function to test sorting alphabetic ordering.
// description:
// Function to test sorting alphabetic ordering.
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function completed(items, request){
//Output should be in this order...
var orderedArray = [ "Africa", "Asia", "Australia", "Europe", "North America", "South America"];
t.is(6, items.length);
t.assertTrue(dojox.data.tests.stores.OpmlStore.verifyItems(opmlStore, items, "text", orderedArray));
d.callback(true);
}
var sortAttributes = [{attribute: "text"}];
opmlStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_sortAlphabeticDescending(t){
// summary:
// Function to test sorting alphabetic ordering in descending mode.
// description:
// Function to test sorting alphabetic ordering in descending mode.
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function completed(items, request){
//Output should be in this order...
var orderedArray = [ "South America", "North America", "Europe", "Australia", "Asia", "Africa"
];
t.is(6, items.length);
t.assertTrue(dojox.data.tests.stores.OpmlStore.verifyItems(opmlStore, items, "text", orderedArray));
d.callback(true);
}
var sortAttributes = [{attribute: "text", descending: true}];
opmlStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_fetch_sortAlphabeticWithCount(t){
// summary:
// Function to test sorting numerically in descending order, returning only a specified number of them.
// description:
// Function to test sorting numerically in descending order, returning only a specified number of them.
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function completed(items, request){
//Output should be in this order...
var orderedArray = [ "South America", "North America", "Europe", "Australia"
];
t.is(4, items.length);
t.assertTrue(dojox.data.tests.stores.OpmlStore.verifyItems(opmlStore, items, "text", orderedArray));
d.callback(true);
}
var sortAttributes = [{attribute: "text", descending: true}];
opmlStore.fetch({sort: sortAttributes,
count: 4,
onComplete: completed,
onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d; //Object
},
function testReadAPI_functionConformance(t){
// summary:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
// description:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
 
var testStore = new dojox.data.OpmlStore(dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"));
var readApi = new dojo.data.api.Read();
var passed = true;
 
for(i in readApi){
if(i.toString().charAt(0) !== '_')
{
var member = readApi[i];
//Check that all the 'Read' defined functions exist on the test store.
if(typeof member === "function"){
var testStoreMember = testStore[i];
if(!(typeof testStoreMember === "function")){
passed = false;
break;
}
}
}
}
t.assertTrue(passed);
},
function testIdentityAPI_fetchItemByIdentity(t){
// summary:
// Simple test of the fetchItemByIdentity function of the store.
// description:
// Simple test of the fetchItemByIdentity function of the store.
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item !== null);
d.callback(true);
}
opmlStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d;
},
 
function testIdentityAPI_fetchItemByIdentity_bad1(t){
// summary:
// Simple test of the fetchItemByIdentity function of the store.
// description:
// Simple test of the fetchItemByIdentity function of the store.
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item === null);
d.callback(true);
}
opmlStore.fetchItemByIdentity({identity: "200", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d;
},
function testIdentityAPI_fetchItemByIdentity_bad2(t){
// summary:
// Simple test of the fetchItemByIdentity function of the store.
// description:
// Simple test of the fetchItemByIdentity function of the store.
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item === null);
d.callback(true);
}
opmlStore.fetchItemByIdentity({identity: "-1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d;
},
function testIdentityAPI_fetchItemByIdentity_bad3(t){
// summary:
// Simple test of the fetchItemByIdentity function of the store.
// description:
// Simple test of the fetchItemByIdentity function of the store.
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function onItem(item){
t.assertTrue(item === null);
d.callback(true);
}
opmlStore.fetchItemByIdentity({identity: "999999", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)});
return d;
},
function testIdentityAPI_getIdentity(t){
// summary:
// Simple test of the fetchItemByIdentity function of the store.
// description:
// Simple test of the fetchItemByIdentity function of the store.
var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml");
var opmlStore = new dojox.data.OpmlStore(args);
var d = new doh.Deferred();
function completed(items, request){
var passed = true;
for(var i = 0; i < items.length; i++){
console.log("Identity is: " + opmlStore.getIdentity(items[i]) + " count is : "+ i);
if(!(opmlStore.getIdentity(items[i]) == i)){
passed=false;
break;
}
}
t.assertTrue(passed);
d.callback(true);
}
//Get everything...
opmlStore.fetch({ onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d), queryOptions: {deep: true}});
return d; //Object
},
function testIdentityAPI_functionConformance(t){
// summary:
// Simple test identity API conformance. Checks to see all declared functions are actual functions on the instances.
// description:
// Simple test identity API conformance. Checks to see all declared functions are actual functions on the instances.
 
var testStore = new dojox.data.OpmlStore(dojox.data.tests.stores.CsvStore.getDatasource("stores/geography.xml"));
var identityApi = new dojo.data.api.Identity();
var passed = true;
 
for(i in identityApi){
if(i.toString().charAt(0) !== '_')
{
var member = identityApi[i];
//Check that all the 'Read' defined functions exist on the test store.
if(typeof member === "function"){
console.log("Looking at function: [" + i + "]");
var testStoreMember = testStore[i];
if(!(typeof testStoreMember === "function")){
passed = false;
break;
}
}
}
}
t.assertTrue(passed);
}
]
);
 
 
}
/trunk/api/js/dojo1.0/dojox/data/tests/stores/books3.xml
New file
0,0 → 1,31
<?xml version="1.0" encoding="ISO-8859-1"?>
<books>
<category>
<name>Category 1</name>
<book>
<isbn>1</isbn>
<title>Title of 1</title>
<author>Author of 1</author>
</book>
<book>
<isbn>2</isbn>
<title>Title of 2</title>
<author>Author of 2</author>
</book>
<book>
<isbn>3</isbn>
<title>Title of 3</title>
<author>Author of 3</author>
</book>
<book>
<isbn>4</isbn>
<title>Title of 4</title>
<author>Author of 4</author>
</book>
<book>
<isbn>5</isbn>
<title>Title of 5</title>
<author>Author of 5</author>
</book>
</category>
</books>
/trunk/api/js/dojo1.0/dojox/data/tests/stores/FlickrRestStore.js
New file
0,0 → 1,476
if(!dojo._hasResource["dojox.data.tests.stores.FlickrRestStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.tests.stores.FlickrRestStore"] = true;
dojo.provide("dojox.data.tests.stores.FlickrRestStore");
dojo.require("dojox.data.FlickrRestStore");
dojo.require("dojo.data.api.Read");
 
 
dojox.data.tests.stores.FlickrRestStore.error = function(t, d, errData){
// summary:
// The error callback function to be used for all of the tests.
d.errback(errData);
}
 
doh.register("dojox.data.tests.stores.FlickrRestStore",
[
{
name: "ReadAPI: Fetch_One",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of a basic fetch on FlickrRestStore of a single item.
// description:
// Simple test of a basic fetch on FlickrRestStore of a single item.
 
var flickrStore = new dojox.data.FlickrRestStore();
 
var d = new doh.Deferred();
function onComplete(items, request){
t.is(1, items.length);
d.callback(true);
}
flickrStore.fetch({
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627"
},
count: 1,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, doh, d)
});
return d; //Object
}
},
{
name: "ReadAPI: Fetch_20_Streaming",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of a basic fetch on FlickrRestStore.
// description:
// Simple test of a basic fetch on FlickrRestStore.
var flickrStore = new dojox.data.FlickrRestStore();
 
var d = new doh.Deferred();
var count = 0;
 
function onItem(item, requestObj){
t.assertTrue(flickrStore.isItem(item));
count++;
}
function onComplete(items, request){
t.is(5, count);
t.is(null, items);
d.callback(true);
}
//Get everything...
flickrStore.fetch({
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627"
},
onBegin: null,
count: 5,
onItem: onItem,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d)
});
return d; //Object
}
},
{
name: "ReadAPI: Fetch_Paging",
timeout: 30000, //30 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Test of multiple fetches on a single result. Paging, if you will.
// description:
// Test of multiple fetches on a single result. Paging, if you will.
 
var flickrStore = new dojox.data.FlickrRestStore();
 
var d = new doh.Deferred();
function dumpFirstFetch(items, request){
t.is(5, items.length);
request.start = 3;
request.count = 1;
request.onComplete = dumpSecondFetch;
flickrStore.fetch(request);
}
 
function dumpSecondFetch(items, request){
t.is(1, items.length);
request.start = 0;
request.count = 5;
request.onComplete = dumpThirdFetch;
flickrStore.fetch(request);
}
 
function dumpThirdFetch(items, request){
t.is(5, items.length);
request.start = 2;
request.count = 18;
request.onComplete = dumpFourthFetch;
flickrStore.fetch(request);
}
 
function dumpFourthFetch(items, request){
t.is(18, items.length);
request.start = 9;
request.count = 11;
request.onComplete = dumpFifthFetch;
flickrStore.fetch(request);
}
 
function dumpFifthFetch(items, request){
t.is(11, items.length);
request.start = 4;
request.count = 16;
request.onComplete = dumpSixthFetch;
flickrStore.fetch(request);
}
 
function dumpSixthFetch(items, request){
t.is(16, items.length);
d.callback(true);
}
 
function completed(items, request){
t.is(7, items.length);
request.start = 1;
request.count = 5;
request.onComplete = dumpFirstFetch;
flickrStore.fetch(request);
}
flickrStore.fetch({
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627"
},
count: 7,
onComplete: completed,
onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d)
});
return d; //Object
}
},
{
name: "ReadAPI: getLabel",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the getLabel function against a store set that has a label defined.
// description:
// Simple test of the getLabel function against a store set that has a label defined.
 
var flickrStore = new dojox.data.FlickrRestStore();
 
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var label = flickrStore.getLabel(items[0]);
t.assertTrue(label !== null);
d.callback(true);
}
flickrStore.fetch({
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627"
},
count: 1,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d)
});
return d;
}
},
{
name: "ReadAPI: getLabelAttributes",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
// description:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
 
var flickrStore = new dojox.data.FlickrRestStore();
 
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var labelList = flickrStore.getLabelAttributes(items[0]);
t.assertTrue(dojo.isArray(labelList));
t.assertEqual("title", labelList[0]);
d.callback(true);
}
flickrStore.fetch({
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627"
},
count: 1,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d)
});
return d;
}
},
{
name: "ReadAPI: getValue",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the getValue function of the store.
// description:
// Simple test of the getValue function of the store.
var flickrStore = new dojox.data.FlickrRestStore();
 
var d = new doh.Deferred();
function completedAll(items){
t.is(1, items.length);
t.assertTrue(flickrStore.getValue(items[0], "title") !== null);
t.assertTrue(flickrStore.getValue(items[0], "imageUrl") !== null);
t.assertTrue(flickrStore.getValue(items[0], "imageUrlSmall") !== null);
t.assertTrue(flickrStore.getValue(items[0], "imageUrlMedium") !== null);
d.callback(true);
}
 
//Get one item and look at it.
flickrStore.fetch({
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627"
},
count: 1,
onComplete: completedAll,
onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d)});
return d; //Object
}
},
{
name: "ReadAPI: getValues",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the getValue function of the store.
// description:
// Simple test of the getValue function of the store.
var flickrStore = new dojox.data.FlickrRestStore();
 
var d = new doh.Deferred();
function completedAll(items){
t.is(1, items.length);
var title = flickrStore.getValues(items[0], "title");
t.assertTrue(title instanceof Array);
var imgUrl = flickrStore.getValues(items[0], "imageUrl");
t.assertTrue(imgUrl instanceof Array);
var imgUrlSmall = flickrStore.getValues(items[0], "imageUrlSmall");
t.assertTrue(imgUrlSmall instanceof Array);
var imgUrlMedium = flickrStore.getValues(items[0], "imageUrlMedium");
t.assertTrue(imgUrlMedium instanceof Array);
d.callback(true);
}
//Get one item and look at it.
flickrStore.fetch({
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627"
},
count: 1,
onComplete: completedAll,
onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error,
t,
d)});
return d; //Object
}
},
{
name: "ReadAPI: isItem",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the isItem function of the store
// description:
// Simple test of the isItem function of the store
var flickrStore = new dojox.data.FlickrRestStore();
 
var d = new doh.Deferred();
function completedAll(items){
t.is(5, items.length);
for(var i=0; i < items.length; i++){
t.assertTrue(flickrStore.isItem(items[i]));
}
d.callback(true);
}
 
//Get everything...
flickrStore.fetch({
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627"
},
count: 5,
onComplete: completedAll,
onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d)
});
return d; //Object
}
},
{
name: "ReadAPI: hasAttribute",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the hasAttribute function of the store
// description:
// Simple test of the hasAttribute function of the store
 
var flickrStore = new dojox.data.FlickrRestStore();
 
var d = new doh.Deferred();
function onComplete(items){
t.is(1, items.length);
t.assertTrue(items[0] !== null);
t.assertTrue(flickrStore.hasAttribute(items[0], "title"));
t.assertTrue(flickrStore.hasAttribute(items[0], "author"));
t.assertTrue(!flickrStore.hasAttribute(items[0], "Nothing"));
t.assertTrue(!flickrStore.hasAttribute(items[0], "Text"));
 
//Test that null attributes throw an exception
var passed = false;
try{
flickrStore.hasAttribute(items[0], null);
}catch (e){
passed = true;
}
t.assertTrue(passed);
d.callback(true);
}
 
//Get one item...
flickrStore.fetch({
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627"
},
count: 1,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d)
});
return d; //Object
}
},
{
name: "ReadAPI: containsValue",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the containsValue function of the store
// description:
// Simple test of the containsValue function of the store
 
var flickrStore = new dojox.data.FlickrRestStore();
 
var d = new doh.Deferred();
function onComplete(items){
t.is(1, items.length);
d.callback(true);
}
 
//Get one item...
flickrStore.fetch({
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627"
},
count: 1,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d)
});
return d; //Object
}
},
{
name: "ReadAPI: getAttributes",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the getAttributes function of the store
// description:
// Simple test of the getAttributes function of the store
 
var flickrStore = new dojox.data.FlickrRestStore();
 
var d = new doh.Deferred();
function onComplete(items){
t.is(1, items.length);
t.assertTrue(flickrStore.isItem(items[0]));
 
var attributes = flickrStore.getAttributes(items[0]);
t.is(9, attributes.length);
d.callback(true);
}
 
//Get everything...
flickrStore.fetch({
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627"
},
count: 1,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d)
});
return d; //Object
}
},
function testReadAPI_getFeatures(t){
// summary:
// Simple test of the getFeatures function of the store
// description:
// Simple test of the getFeatures function of the store
 
var flickrStore = new dojox.data.FlickrRestStore();
 
var features = flickrStore.getFeatures();
var count = 0;
for(i in features){
t.assertTrue((i === "dojo.data.api.Read"));
count++;
}
t.assertTrue(count === 1);
},
function testReadAPI_functionConformance(t){
// summary:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
// description:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
 
var testStore = new dojox.data.FlickrRestStore();
var readApi = new dojo.data.api.Read();
var passed = true;
 
for(i in readApi){
if(i.toString().charAt(0) !== '_')
{
var member = readApi[i];
//Check that all the 'Read' defined functions exist on the test store.
if(typeof member === "function"){
var testStoreMember = testStore[i];
if(!(typeof testStoreMember === "function")){
passed = false;
break;
}
}
}
}
}
]
);
 
 
}
/trunk/api/js/dojo1.0/dojox/data/tests/stores/FlickrStore.js
New file
0,0 → 1,410
if(!dojo._hasResource["dojox.data.tests.stores.FlickrStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.tests.stores.FlickrStore"] = true;
dojo.provide("dojox.data.tests.stores.FlickrStore");
dojo.require("dojox.data.FlickrStore");
dojo.require("dojo.data.api.Read");
 
 
dojox.data.tests.stores.FlickrStore.error = function(t, d, errData){
// summary:
// The error callback function to be used for all of the tests.
d.errback(errData);
}
 
doh.register("dojox.data.tests.stores.FlickrStore",
[
{
name: "ReadAPI: Fetch_One",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of a basic fetch on FlickrStore of a single item.
// description:
// Simple test of a basic fetch on FlickrStore of a single item.
 
var flickrStore = new dojox.data.FlickrStore();
 
var d = new doh.Deferred();
function onComplete(items, request){
t.is(1, items.length);
d.callback(true);
}
flickrStore.fetch({ query: {tags: "animals"},
count: 1,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, doh, d)
});
return d; //Object
}
},
{
name: "ReadAPI: Fetch_20_Streaming",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of a basic fetch on FlickrStore.
// description:
// Simple test of a basic fetch on FlickrStore.
var flickrStore = new dojox.data.FlickrStore();
 
var d = new doh.Deferred();
count = 0;
 
function onBegin(size, requestObj){
t.is(20, size);
}
function onItem(item, requestObj){
t.assertTrue(flickrStore.isItem(item));
count++;
}
function onComplete(items, request){
t.is(20, count);
t.is(null, items);
d.callback(true);
}
 
//Get everything...
flickrStore.fetch({ onBegin: onBegin,
count: 20,
onItem: onItem,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)
});
return d; //Object
}
},
{
name: "ReadAPI: Fetch_Paging",
timeout: 30000, //30 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Test of multiple fetches on a single result. Paging, if you will.
// description:
// Test of multiple fetches on a single result. Paging, if you will.
 
var flickrStore = new dojox.data.FlickrStore();
 
var d = new doh.Deferred();
function dumpFirstFetch(items, request){
t.is(5, items.length);
request.start = 3;
request.count = 1;
request.onComplete = dumpSecondFetch;
flickrStore.fetch(request);
}
 
function dumpSecondFetch(items, request){
t.is(1, items.length);
request.start = 0;
request.count = 5;
request.onComplete = dumpThirdFetch;
flickrStore.fetch(request);
}
 
function dumpThirdFetch(items, request){
t.is(5, items.length);
request.start = 2;
request.count = 20;
request.onComplete = dumpFourthFetch;
flickrStore.fetch(request);
}
 
function dumpFourthFetch(items, request){
t.is(18, items.length);
request.start = 9;
request.count = 100;
request.onComplete = dumpFifthFetch;
flickrStore.fetch(request);
}
 
function dumpFifthFetch(items, request){
t.is(11, items.length);
request.start = 2;
request.count = 20;
request.onComplete = dumpSixthFetch;
flickrStore.fetch(request);
}
 
function dumpSixthFetch(items, request){
t.is(18, items.length);
d.callback(true);
}
 
function completed(items, request){
t.is(7, items.length);
request.start = 1;
request.count = 5;
request.onComplete = dumpFirstFetch;
flickrStore.fetch(request);
}
flickrStore.fetch({count: 7, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)});
return d; //Object
}
},
{
name: "ReadAPI: getLabel",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the getLabel function against a store set that has a label defined.
// description:
// Simple test of the getLabel function against a store set that has a label defined.
 
var flickrStore = new dojox.data.FlickrStore();
 
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var label = flickrStore.getLabel(items[0]);
t.assertTrue(label !== null);
d.callback(true);
}
flickrStore.fetch({ query: {tags: "animals"},
count: 1,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)
});
return d;
}
},
{
name: "ReadAPI: getLabelAttributes",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
// description:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
 
var flickrStore = new dojox.data.FlickrStore();
 
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var labelList = flickrStore.getLabelAttributes(items[0]);
t.assertTrue(dojo.isArray(labelList));
t.assertEqual("title", labelList[0]);
d.callback(true);
}
flickrStore.fetch({ query: {tags: "animals"},
count: 1,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)
});
return d;
}
},
{
name: "ReadAPI: getValue",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the getValue function of the store.
// description:
// Simple test of the getValue function of the store.
var flickrStore = new dojox.data.FlickrStore();
 
var d = new doh.Deferred();
function completedAll(items){
t.is(1, items.length);
t.assertTrue(flickrStore.getValue(items[0], "title") !== null);
t.assertTrue(flickrStore.getValue(items[0], "imageUrl") !== null);
t.assertTrue(flickrStore.getValue(items[0], "imageUrlSmall") !== null);
t.assertTrue(flickrStore.getValue(items[0], "imageUrlMedium") !== null);
d.callback(true);
}
 
//Get one item and look at it.
flickrStore.fetch({ count: 1, onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)});
return d; //Object
}
},
{
name: "ReadAPI: getValues",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the getValue function of the store.
// description:
// Simple test of the getValue function of the store.
var flickrStore = new dojox.data.FlickrStore();
 
var d = new doh.Deferred();
function completedAll(items){
t.is(1, items.length);
t.assertTrue(flickrStore.getValues(items[0], "title") instanceof Array);
t.assertTrue(flickrStore.getValues(items[0], "description") instanceof Array);
t.assertTrue(flickrStore.getValues(items[0], "imageUrl") instanceof Array);
t.assertTrue(flickrStore.getValues(items[0], "imageUrlSmall") instanceof Array);
t.assertTrue(flickrStore.getValues(items[0], "imageUrlMedium") instanceof Array);
d.callback(true);
}
//Get one item and look at it.
flickrStore.fetch({ count: 1, onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)});
return d; //Object
}
},
{
name: "ReadAPI: isItem",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the isItem function of the store
// description:
// Simple test of the isItem function of the store
var flickrStore = new dojox.data.FlickrStore();
 
var d = new doh.Deferred();
function completedAll(items){
t.is(5, items.length);
for(var i=0; i < items.length; i++){
t.assertTrue(flickrStore.isItem(items[i]));
}
d.callback(true);
}
 
//Get everything...
flickrStore.fetch({ count: 5, onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)});
return d; //Object
}
},
{
name: "ReadAPI: hasAttribute",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the hasAttribute function of the store
// description:
// Simple test of the hasAttribute function of the store
 
var flickrStore = new dojox.data.FlickrStore();
 
var d = new doh.Deferred();
function onComplete(items){
t.is(1, items.length);
t.assertTrue(items[0] !== null);
t.assertTrue(flickrStore.hasAttribute(items[0], "title"));
t.assertTrue(flickrStore.hasAttribute(items[0], "description"));
t.assertTrue(flickrStore.hasAttribute(items[0], "author"));
t.assertTrue(!flickrStore.hasAttribute(items[0], "Nothing"));
t.assertTrue(!flickrStore.hasAttribute(items[0], "Text"));
 
//Test that null attributes throw an exception
var passed = false;
try{
flickrStore.hasAttribute(items[0], null);
}catch (e){
passed = true;
}
t.assertTrue(passed);
d.callback(true);
}
 
//Get one item...
flickrStore.fetch({ query: {tags: "animals"},
count: 1,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)
});
return d; //Object
}
},
{
name: "ReadAPI: containsValue",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the containsValue function of the store
// description:
// Simple test of the containsValue function of the store
 
var flickrStore = new dojox.data.FlickrStore();
 
var d = new doh.Deferred();
function onComplete(items){
t.is(1, items.length);
d.callback(true);
}
 
//Get one item...
flickrStore.fetch({ query: {tags: "animals"},
count: 1,
onComplete: onComplete,
onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)
});
return d; //Object
}
},
{
name: "ReadAPI: getAttributes",
timeout: 10000, //10 seconds. Flickr can sometimes be slow.
runTest: function(t) {
// summary:
// Simple test of the getAttributes function of the store
// description:
// Simple test of the getAttributes function of the store
 
var flickrStore = new dojox.data.FlickrStore();
 
var d = new doh.Deferred();
function onComplete(items){
t.is(1, items.length);
t.assertTrue(flickrStore.isItem(items[0]));
 
var attributes = flickrStore.getAttributes(items[0]);
t.is(10, attributes.length);
d.callback(true);
}
 
//Get everything...
flickrStore.fetch({ count: 1, onComplete: onComplete, onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)});
return d; //Object
}
},
function testReadAPI_getFeatures(t){
// summary:
// Simple test of the getFeatures function of the store
// description:
// Simple test of the getFeatures function of the store
 
var flickrStore = new dojox.data.FlickrStore();
 
var features = flickrStore.getFeatures();
var count = 0;
for(i in features){
t.assertTrue((i === "dojo.data.api.Read"));
count++;
}
t.assertTrue(count === 1);
},
function testReadAPI_functionConformance(t){
// summary:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
// description:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
 
var testStore = new dojox.data.FlickrStore();
var readApi = new dojo.data.api.Read();
var passed = true;
 
for(i in readApi){
if(i.toString().charAt(0) !== '_')
{
var member = readApi[i];
//Check that all the 'Read' defined functions exist on the test store.
if(typeof member === "function"){
var testStoreMember = testStore[i];
if(!(typeof testStoreMember === "function")){
passed = false;
break;
}
}
}
}
t.assertTrue(passed);
}
]
);
 
 
}
/trunk/api/js/dojo1.0/dojox/data/tests/stores/books2.html
New file
0,0 → 1,43
<html>
<head>
<title>Books2.html</title>
</head>
<body>
<table id="books2">
<thead>
<tr>
<th>isbn</th>
<th>title</th>
<th>author</th>
</tr>
</thead>
<tbody>
<tr>
<td>A9B57C</td>
<td>Title of 1</td>
<td>Author of 1</td>
</tr>
<tr>
<td>A9B57F</td>
<td>Title of 2</td>
<td>Author of 2</td>
</tr>
<tr>
<td>A9B577</td>
<td>Title of 3</td>
<td>Author of 3</td>
</tr>
<tr>
<td>A9B574</td>
<td>Title of 4</td>
<td>Author of 4</td>
</tr>
<tr>
<td>A9B5CC</td>
<td>Title of 5</td>
<td>Author of 5</td>
</tr>
</tbody>
</table>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/data/tests/stores/books_isbnAttr2.xml
New file
0,0 → 1,23
<?xml version="1.0" encoding="ISO-8859-1"?>
<books>
<book isbn="ABC1">
<title>Title of 1</title>
<author>Author of 1</author>
</book>
<book isbn="ABC2">
<title>Title of 2</title>
<author>Author of 2</author>
</book>
<book isbn="ABC3">
<title>Title of 3</title>
<author>Author of 3</author>
</book>
<book isbn="ACB4">
<title>Title of 4</title>
<author>Author of 4</author>
</book>
<book isbn="ACF5">
<title>Title of 5</title>
<author>Author of 5</author>
</book>
</books>
/trunk/api/js/dojo1.0/dojox/data/tests/stores/QueryReadStore.php
New file
0,0 → 1,92
<?php
 
header("Content-Type", "text/json");
 
$allItems = array(
array('name'=>"Alabama", 'label'=>"<img src='images/Alabama.jpg'/>Alabama", 'abbreviation'=>"AL"),
array('name'=>"Alaska", 'label'=>"Alaska", 'abbreviation'=>"AK"),
array('name'=>"American Samoa", 'label'=>"American Samoa", 'abbreviation'=>"AS"),
array('name'=>"Arizona", 'label'=>"Arizona", 'abbreviation'=>"AZ"),
array('name'=>"Arkansas", 'label'=>"Arkansas", 'abbreviation'=>"AR"),
array('name'=>"Armed Forces Europe", 'label'=>"Armed Forces Europe", 'abbreviation'=>"AE"),
array('name'=>"Armed Forces Pacific", 'label'=>"Armed Forces Pacific", 'abbreviation'=>"AP"),
array('name'=>"Armed Forces the Americas", 'label'=>"Armed Forces the Americas", 'abbreviation'=>"AA"),
array('name'=>"California", 'label'=>"California", 'abbreviation'=>"CA"),
array('name'=>"Colorado", 'label'=>"Colorado", 'abbreviation'=>"CO"),
array('name'=>"Connecticut", 'label'=>"Connecticut", 'abbreviation'=>"CT"),
array('name'=>"Delaware", 'label'=>"Delaware", 'abbreviation'=>"DE"),
array('name'=>"District of Columbia", 'label'=>"District of Columbia", 'abbreviation'=>"DC"),
array('name'=>"Federated States of Micronesia", 'label'=>"Federated States of Micronesia", 'abbreviation'=>"FM"),
array('name'=>"Florida", 'label'=>"Florida", 'abbreviation'=>"FL"),
array('name'=>"Georgia", 'label'=>"Georgia", 'abbreviation'=>"GA"),
array('name'=>"Guam", 'label'=>"Guam", 'abbreviation'=>"GU"),
array('name'=>"Hawaii", 'label'=>"Hawaii", 'abbreviation'=>"HI"),
array('name'=>"Idaho", 'label'=>"Idaho", 'abbreviation'=>"ID"),
array('name'=>"Illinois", 'label'=>"Illinois", 'abbreviation'=>"IL"),
array('name'=>"Indiana", 'label'=>"Indiana", 'abbreviation'=>"IN"),
array('name'=>"Iowa", 'label'=>"Iowa", 'abbreviation'=>"IA"),
array('name'=>"Kansas", 'label'=>"Kansas", 'abbreviation'=>"KS"),
array('name'=>"Kentucky", 'label'=>"Kentucky", 'abbreviation'=>"KY"),
array('name'=>"Louisiana", 'label'=>"Louisiana", 'abbreviation'=>"LA"),
array('name'=>"Maine", 'label'=>"Maine", 'abbreviation'=>"ME"),
array('name'=>"Marshall Islands", 'label'=>"Marshall Islands", 'abbreviation'=>"MH"),
array('name'=>"Maryland", 'label'=>"Maryland", 'abbreviation'=>"MD"),
array('name'=>"Massachusetts", 'label'=>"Massachusetts", 'abbreviation'=>"MA"),
array('name'=>"Michigan", 'label'=>"Michigan", 'abbreviation'=>"MI"),
array('name'=>"Minnesota", 'label'=>"Minnesota", 'abbreviation'=>"MN"),
array('name'=>"Mississippi", 'label'=>"Mississippi", 'abbreviation'=>"MS"),
array('name'=>"Missouri", 'label'=>"Missouri", 'abbreviation'=>"MO"),
array('name'=>"Montana", 'label'=>"Montana", 'abbreviation'=>"MT"),
array('name'=>"Nebraska", 'label'=>"Nebraska", 'abbreviation'=>"NE"),
array('name'=>"Nevada", 'label'=>"Nevada", 'abbreviation'=>"NV"),
array('name'=>"New Hampshire", 'label'=>"New Hampshire", 'abbreviation'=>"NH"),
array('name'=>"New Jersey", 'label'=>"New Jersey", 'abbreviation'=>"NJ"),
array('name'=>"New Mexico", 'label'=>"New Mexico", 'abbreviation'=>"NM"),
array('name'=>"New York", 'label'=>"New York", 'abbreviation'=>"NY"),
array('name'=>"North Carolina", 'label'=>"North Carolina", 'abbreviation'=>"NC"),
array('name'=>"North Dakota", 'label'=>"North Dakota", 'abbreviation'=>"ND"),
array('name'=>"Northern Mariana Islands", 'label'=>"Northern Mariana Islands", 'abbreviation'=>"MP"),
array('name'=>"Ohio", 'label'=>"Ohio", 'abbreviation'=>"OH"),
array('name'=>"Oklahoma", 'label'=>"Oklahoma", 'abbreviation'=>"OK"),
array('name'=>"Oregon", 'label'=>"Oregon", 'abbreviation'=>"OR"),
array('name'=>"Pennsylvania", 'label'=>"Pennsylvania", 'abbreviation'=>"PA"),
array('name'=>"Puerto Rico", 'label'=>"Puerto Rico", 'abbreviation'=>"PR"),
array('name'=>"Rhode Island", 'label'=>"Rhode Island", 'abbreviation'=>"RI"),
array('name'=>"South Carolina", 'label'=>"South Carolina", 'abbreviation'=>"SC"),
array('name'=>"South Dakota", 'label'=>"South Dakota", 'abbreviation'=>"SD"),
array('name'=>"Tennessee", 'label'=>"Tennessee", 'abbreviation'=>"TN"),
array('name'=>"Texas", 'label'=>"Texas", 'abbreviation'=>"TX"),
array('name'=>"Utah", 'label'=>"Utah", 'abbreviation'=>"UT"),
array('name'=>"Vermont", 'label'=>"Vermont", 'abbreviation'=>"VT"),
array('name'=> "Virgin Islands, U.S.", 'label'=>"Virgin Islands, U.S.", 'abbreviation'=>"VI"),
array('name'=>"Virginia", 'label'=>"Virginia", 'abbreviation'=>"VA"),
array('name'=>"Washington", 'label'=>"Washington", 'abbreviation'=>"WA"),
array('name'=>"West Virginia", 'label'=>"West Virginia", 'abbreviation'=>"WV"),
array('name'=>"Wisconsin", 'label'=>"Wisconsin", 'abbreviation'=>"WI"),
array('name'=>"Wyoming", 'label'=>"Wyoming", 'abbreviation'=>"WY"),
// array('id'=>, 'name'=>''),
);
 
$q = "";
if (array_key_exists("q", $_REQUEST)) {
$q = $_REQUEST['q'];
}
if (strlen($q) && $q[strlen($q)-1]=="*") {
$q = substr($q, 0, strlen($q)-1);
}
$ret = array();
foreach ($allItems as $item) {
if (!$q || strpos(strtolower($item['name']), strtolower($q))===0) {
$ret[] = $item;
}
}
 
// Handle paging, if given.
if (array_key_exists("start", $_REQUEST)) {
$ret = array_slice($ret, $_REQUEST['start']);
}
if (array_key_exists("count", $_REQUEST)) {
$ret = array_slice($ret, 0, $_REQUEST['count']);
}
 
print '/*'.json_encode(array('items'=>$ret)).'*/';
/trunk/api/js/dojo1.0/dojox/data/tests/stores/HtmlTableStore.js
New file
0,0 → 1,702
if(!dojo._hasResource["dojox.data.tests.stores.HtmlTableStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.tests.stores.HtmlTableStore"] = true;
dojo.provide("dojox.data.tests.stores.HtmlTableStore");
dojo.require("dojox.data.HtmlTableStore");
dojo.require("dojo.data.api.Read");
dojo.require("dojo.data.api.Identity");
 
 
dojox.data.tests.stores.HtmlTableStore.getBooks2Store = function(){
return new dojox.data.HtmlTableStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books2.html").toString(), tableId: "books2"});
};
 
dojox.data.tests.stores.HtmlTableStore.getBooksStore = function(){
return new dojox.data.HtmlTableStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books.html").toString(), tableId: "books"});
};
 
doh.register("dojox.data.tests.stores.HtmlTableStore",
[
/***************************************
dojo.data.api.Read API
***************************************/
function testReadAPI_fetch_all(t){
// summary:
// Simple test of fetching all xml items through an XML element called isbn
// description:
// Simple test of fetching all xml items through an XML element called isbn
var store = dojox.data.tests.stores.HtmlTableStore.getBooksStore();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(20, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"*"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_one(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn
// description:
// Simple test of fetching one xml items through an XML element called isbn
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_paging(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn
// description:
// Simple test of fetching one xml items through an XML element called isbn
var store = dojox.data.tests.stores.HtmlTableStore.getBooksStore();
var d = new doh.Deferred();
function dumpFirstFetch(items, request){
t.assertEqual(5, items.length);
request.start = 3;
request.count = 1;
request.onComplete = dumpSecondFetch;
store.fetch(request);
}
 
function dumpSecondFetch(items, request){
t.assertEqual(1, items.length);
request.start = 0;
request.count = 5;
request.onComplete = dumpThirdFetch;
store.fetch(request);
}
 
function dumpThirdFetch(items, request){
t.assertEqual(5, items.length);
request.start = 2;
request.count = 20;
request.onComplete = dumpFourthFetch;
store.fetch(request);
}
 
function dumpFourthFetch(items, request){
t.assertEqual(18, items.length);
request.start = 9;
request.count = 100;
request.onComplete = dumpFifthFetch;
store.fetch(request);
}
 
function dumpFifthFetch(items, request){
t.assertEqual(11, items.length);
request.start = 2;
request.count = 20;
request.onComplete = dumpSixthFetch;
store.fetch(request);
}
 
function dumpSixthFetch(items, request){
t.assertEqual(18, items.length);
d.callback(true);
}
 
function completed(items, request){
t.assertEqual(20, items.length);
request.start = 1;
request.count = 5;
request.onComplete = dumpFirstFetch;
store.fetch(request);
}
 
function error(errData, request){
d.errback(errData);
}
 
store.fetch({onComplete: completed, onError: error});
return d; //Object
},
function testReadAPI_fetch_pattern0(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
// description:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"?9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_pattern1(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
// description:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(4, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B57?"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_pattern2(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with * pattern match
// description:
// Simple test of fetching one xml items through an XML element called isbn with * pattern match
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(5, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9*"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_pattern_caseInsensitive(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case insensitive mode.
// description:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case insensitive mode.
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"?9b574"}, queryOptions: {ignoreCase: true}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_fetch_pattern_caseSensitive(t){
// summary:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case sensitive mode.
// description:
// Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case sensitive mode.
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"?9B574"}, queryOptions: {ignoreCase: false}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_getLabel(t){
// summary:
// Simple test of the getLabel function against a store set that has a label defined.
// description:
// Simple test of the getLabel function against a store set that has a label defined.
 
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var label = store.getLabel(items[0]);
t.assertTrue(label !== null);
t.assertEqual("Table Row #3", label);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d;
},
function testReadAPI_getLabelAttributes(t){
// summary:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
// description:
// Simple test of the getLabelAttributes function against a store set that has a label defined.
 
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
var d = new doh.Deferred();
function onComplete(items, request){
t.assertEqual(items.length, 1);
var labelList = store.getLabelAttributes(items[0]);
t.assertTrue(labelList === null);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d;
},
 
function testReadAPI_getValue(t){
// summary:
// Simple test of the getValue API
// description:
// Simple test of the getValue API
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.hasAttribute(item,"isbn"));
t.assertEqual(store.getValue(item,"isbn"), "A9B574");
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_getValues(t){
// summary:
// Simple test of the getValues API
// description:
// Simple test of the getValues API
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.hasAttribute(item,"isbn"));
var values = store.getValues(item,"isbn");
t.assertEqual(1,values.length);
t.assertEqual("A9B574", values[0]);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_isItem(t){
// summary:
// Simple test of the isItem API
// description:
// Simple test of the isItem API
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.isItem(item));
t.assertTrue(!store.isItem({}));
t.assertTrue(!store.isItem("Foo"));
t.assertTrue(!store.isItem(1));
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_isItem_multistore(t){
// summary:
// Simple test of the isItem API across multiple store instances.
// description:
// Simple test of the isItem API across multiple store instances.
var store1 = dojox.data.tests.stores.HtmlTableStore.getBooksStore();
var store2 = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete1(items, request) {
t.assertEqual(1, items.length);
var item1 = items[0];
t.assertTrue(store1.isItem(item1));
 
function onComplete2(items, request) {
t.assertEqual(1, items.length);
var item2 = items[0];
t.assertTrue(store2.isItem(item2));
t.assertTrue(!store1.isItem(item2));
t.assertTrue(!store2.isItem(item1));
d.callback(true);
}
store2.fetch({query:{isbn:"A9B574"}, onComplete: onComplete2, onError: onError});
}
function onError(error, request) {
d.errback(error);
}
store1.fetch({query:{isbn:"1"}, onComplete: onComplete1, onError: onError});
return d; //Object
},
function testReadAPI_hasAttribute(t){
// summary:
// Simple test of the hasAttribute API
// description:
// Simple test of the hasAttribute API
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.hasAttribute(item,"isbn"));
t.assertTrue(!store.hasAttribute(item,"bob"));
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_containsValue(t){
// summary:
// Simple test of the containsValue API
// description:
// Simple test of the containsValue API
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.containsValue(item,"isbn", "A9B574"));
t.assertTrue(!store.containsValue(item,"isbn", "bob"));
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_sortDescending(t){
// summary:
// Simple test of the sorting API in descending order.
// description:
// Simple test of the sorting API in descending order.
var store = dojox.data.tests.stores.HtmlTableStore.getBooksStore();
 
//Comparison is done as a string type (toString comparison), so the order won't be numeric
//So have to compare in 'alphabetic' order.
var order = [9,8,7,6,5,4,3,20,2,19,18,17,16,15,14,13,12,11,10,1];
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(20, items.length);
 
for(var i = 0; i < items.length; i++){
t.assertEqual(order[i], store.getValue(items[i],"isbn").toString());
}
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
 
var sortAttributes = [{attribute: "isbn", descending: true}];
store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_sortAscending(t){
// summary:
// Simple test of the sorting API in ascending order.
// description:
// Simple test of the sorting API in ascending order.
var store = dojox.data.tests.stores.HtmlTableStore.getBooksStore();
 
//Comparison is done as a string type (toString comparison), so the order won't be numeric
//So have to compare in 'alphabetic' order.
var order = [1,10,11,12,13,14,15,16,17,18,19,2,20,3,4,5,6,7,8,9];
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(20, items.length);
var itemId = 1;
for(var i = 0; i < items.length; i++){
t.assertEqual(order[i], store.getValue(items[i],"isbn").toString());
}
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
 
var sortAttributes = [{attribute: "isbn"}];
store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_sortDescendingNumeric(t){
// summary:
// Simple test of the sorting API in descending order using a numeric comparator.
// description:
// Simple test of the sorting API in descending order using a numeric comparator.
var store = dojox.data.tests.stores.HtmlTableStore.getBooksStore();
 
//isbn should be treated as a numeric, not as a string comparison
store.comparatorMap = {};
store.comparatorMap["isbn"] = function(a, b){
var ret = 0;
if(parseInt(a.toString()) > parseInt(b.toString())){
ret = 1;
}else if(parseInt(a.toString()) < parseInt(b.toString())){
ret = -1;
}
return ret; //int, {-1,0,1}
};
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(20, items.length);
var itemId = 20;
for(var i = 0; i < items.length; i++){
t.assertEqual(itemId, store.getValue(items[i],"isbn").toString());
itemId--;
}
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
 
var sortAttributes = [{attribute: "isbn", descending: true}];
store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_sortAscendingNumeric(t){
// summary:
// Simple test of the sorting API in ascending order using a numeric comparator.
// description:
// Simple test of the sorting API in ascending order using a numeric comparator.
var store = dojox.data.tests.stores.HtmlTableStore.getBooksStore();
 
//isbn should be treated as a numeric, not as a string comparison
store.comparatorMap = {};
store.comparatorMap["isbn"] = function(a, b){
var ret = 0;
if(parseInt(a.toString()) > parseInt(b.toString())){
ret = 1;
}else if(parseInt(a.toString()) < parseInt(b.toString())){
ret = -1;
}
return ret; //int, {-1,0,1}
};
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(20, items.length);
var itemId = 1;
for(var i = 0; i < items.length; i++){
t.assertEqual(itemId, store.getValue(items[i],"isbn").toString());
itemId++;
}
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
 
var sortAttributes = [{attribute: "isbn"}];
store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_isItemLoaded(t){
// summary:
// Simple test of the isItemLoaded API
// description:
// Simple test of the isItemLoaded API
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertTrue(store.isItemLoaded(item));
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_getFeatures(t){
// summary:
// Simple test of the getFeatures function of the store
// description:
// Simple test of the getFeatures function of the store
 
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
var features = store.getFeatures();
var count = 0;
for(i in features){
t.assertTrue((i === "dojo.data.api.Read" || i === "dojo.data.api.Identity"));
count++;
}
t.assertEqual(2, count);
},
function testReadAPI_getAttributes(t){
// summary:
// Simple test of the getAttributes API
// description:
// Simple test of the getAttributes API
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
var attributes = store.getAttributes(item);
t.assertEqual(3,attributes.length);
for(var i=0; i<attributes.length; i++){
t.assertTrue((attributes[i] === "isbn" || attributes[i] === "title" || attributes[i] === "author"));
}
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testReadAPI_functionConformance(t){
// summary:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
// description:
// Simple test read API conformance. Checks to see all declared functions are actual functions on the instances.
 
var testStore = dojox.data.tests.stores.HtmlTableStore.getBooksStore();
var readApi = new dojo.data.api.Read();
var passed = true;
 
for(i in readApi){
var member = readApi[i];
//Check that all the 'Read' defined functions exist on the test store.
if(typeof member === "function"){
var testStoreMember = testStore[i];
if(!(typeof testStoreMember === "function")){
console.log("Problem with function: [" + i + "]");
passed = false;
break;
}
}
}
t.assertTrue(passed);
},
/***************************************
dojo.data.api.Identity API
***************************************/
function testIdentityAPI_getIdentity(t){
// summary:
// Simple test of the getAttributes API
// description:
// Simple test of the getAttributes API
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
t.assertEqual(3,store.getIdentity(item));
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testIdentityAPI_getIdentityAttributes(t){
// summary:
// Simple test of the getAttributes API
// description:
// Simple test of the getAttributes API
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
 
var d = new doh.Deferred();
function onComplete(items, request) {
t.assertEqual(1, items.length);
var item = items[0];
//Should have none, as it's not a public attribute.
var attributes = store.getIdentityAttributes(item);
t.assertEqual(null, attributes);
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
return d; //Object
},
function testIdentityAPI_fetchItemByIdentity(t){
// summary:
// Simple test of the fetchItemByIdentity API
// description:
// Simple test of the fetchItemByIdentity API
var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store();
 
var d = new doh.Deferred();
function onItem(item, request) {
t.assertTrue(item !== null);
t.assertTrue(store.isItem(item));
t.assertEqual("A9B574", store.getValue(item, "isbn"));
d.callback(true);
}
function onError(error, request) {
d.errback(error);
}
store.fetchItemByIdentity({identity: 3, onItem: onItem, onError: onError});
return d; //Object
},
function testIdentityAPI_functionConformance(t){
// summary:
// Simple test identity API conformance. Checks to see all declared functions are actual functions on the instances.
// description:
// Simple test identity API conformance. Checks to see all declared functions are actual functions on the instances.
 
var testStore = dojox.data.tests.stores.HtmlTableStore.getBooksStore();
var identityApi = new dojo.data.api.Identity();
var passed = true;
 
for(i in identityApi){
var member = identityApi[i];
//Check that all the 'Read' defined functions exist on the test store.
if(typeof member === "function"){
var testStoreMember = testStore[i];
if(!(typeof testStoreMember === "function")){
console.log("Problem with function: [" + i + "]");
passed = false;
break;
}
}
}
t.assertTrue(passed);
}
]
);
 
//Register the remote tests ... when they work.
//doh.registerUrl("dojox.data.tests.stores.HtmlTableStore.remote", dojo.moduleUrl("dojox.data.tests", "ml/test_HtmlTableStore_declaratively.html"));
 
}
/trunk/api/js/dojo1.0/dojox/data/tests/stores/books.xml
New file
0,0 → 1,103
<?xml version="1.0" encoding="ISO-8859-1"?>
<books>
<book>
<isbn>1</isbn>
<title>Title of 1</title>
<author>Author of 1</author>
</book>
<book>
<isbn>2</isbn>
<title>Title of 2</title>
<author>Author of 2</author>
</book>
<book>
<isbn>3</isbn>
<title>Title of 3</title>
<author>Author of 3</author>
</book>
<book>
<isbn>4</isbn>
<title>Title of 4</title>
<author>Author of 4</author>
</book>
<book>
<isbn>5</isbn>
<title>Title of 5</title>
<author>Author of 5</author>
</book>
<book>
<isbn>6</isbn>
<title>Title of 6</title>
<author>Author of 6</author>
</book>
<book>
<isbn>7</isbn>
<title>Title of 7</title>
<author>Author of 7</author>
</book>
<book>
<isbn>8</isbn>
<title>Title of 8</title>
<author>Author of 8</author>
</book>
<book>
<isbn>9</isbn>
<title>Title of 9</title>
<author>Author of 9</author>
</book>
<book>
<isbn>10</isbn>
<title>Title of 10</title>
<author>Author of 10</author>
</book>
<book>
<isbn>11</isbn>
<title>Title of 11</title>
<author>Author of 11</author>
</book>
<book>
<isbn>12</isbn>
<title>Title of 12</title>
<author>Author of 12</author>
</book>
<book>
<isbn>13</isbn>
<title>Title of 13</title>
<author>Author of 13</author>
</book>
<book>
<isbn>14</isbn>
<title>Title of 14</title>
<author>Author of 14</author>
</book>
<book>
<isbn>15</isbn>
<title>Title of 15</title>
<author>Author of 15</author>
</book>
<book>
<isbn>16</isbn>
<title>Title of 16</title>
<author>Author of 16</author>
</book>
<book>
<isbn>17</isbn>
<title>Title of 17</title>
<author>Author of 17</author>
</book>
<book>
<isbn>18</isbn>
<title>Title of 18</title>
<author>Author of 18</author>
</book>
<book>
<isbn>19</isbn>
<title>Title of 19</title>
<author>Author of 19</author>
</book>
<book>
<isbn>20</isbn>
<title>Title of 20</title>
<author>Author of 20</author>
</book>
</books>
/trunk/api/js/dojo1.0/dojox/data/tests/stores/movies2.csv
New file
0,0 → 1,9
Title, Year, Producer
City of God, 2002, Katia Lund
Rain,"", Christine Jeffs
2001: A Space Odyssey, , Stanley Kubrick
"This is a ""fake"" movie title", 1957, Sidney Lumet
Alien, 1979 , Ridley Scott
"The Sequel to ""Dances With Wolves.""", 1982, Ridley Scott
"Caine Mutiny, The", 1954, "Dymtryk ""the King"", Edward"
 
/trunk/api/js/dojo1.0/dojox/data/tests/stores/geography_withspeciallabel.xml
New file
0,0 → 1,51
<?xml version="1.0" encoding="ISO-8859-1"?>
<opml version="1.0">
<head>
<title>geography.opml</title>
<dateCreated>2006-11-10</dateCreated>
<dateModified>2006-11-13</dateModified>
<ownerName>Magellan, Ferdinand</ownerName>
</head>
<body>
<outline text="Africa" type="continent" label="Continent/Africa">
<outline text="Egypt" type="country" label="Country/Egypt"/>
<outline text="Kenya" type="country" label="Country/Kenya">
<outline text="Nairobi" type="city" label="City/Nairobi"/>
<outline text="Mombasa" type="city" label="City/Mombasa"/>
</outline>
<outline text="Sudan" type="country" label="Country/Sudan">
<outline text="Khartoum" type="city" label="City/Khartoum"/>
</outline>
</outline>
<outline text="Asia" type="continent" label="Continent/Asia">
<outline text="China" type="country" label="Country/China"/>
<outline text="India" type="country" label="Country/India"/>
<outline text="Russia" type="country" label="Country/Russia"/>
<outline text="Mongolia" type="country" label="Country/Mongolia"/>
</outline>
<outline text="Australia" type="continent" population="21 million" label="Continent/Australia">
<outline text="Australia" type="country" population="21 million" label="Country/Australia"/>
</outline>
<outline text="Europe" type="continent" label="Contintent/Europe">
<outline text="Germany" type="country" label="Country/Germany"/>
<outline text="France" type="country" label="Country/France"/>
<outline text="Spain" type="country" label="Country/Spain"/>
<outline text="Italy" type="country" label="Country/Italy"/>
</outline>
<outline text="North America" type="continent" label="Continent/North America">
<outline text="Mexico" type="country" population="108 million" area="1,972,550 sq km" label="Country/Mexico">
<outline text="Mexico City" type="city" population="19 million" timezone="-6 UTC" label="City/Mexico City"/>
<outline text="Guadalajara" type="city" population="4 million" timezone="-6 UTC" label="City/Guadalajara"/>
</outline>
<outline text="Canada" type="country" population="33 million" area="9,984,670 sq km" label="Country/Canada">
<outline text="Ottawa" type="city" population="0.9 million" timezone="-5 UTC" label="City/Ottawa"/>
<outline text="Toronto" type="city" population="2.5 million" timezone="-5 UTC" label="City/Toronto"/>
</outline>
<outline text="United States of America" type="country" label="Country/United States of America"/>
</outline>
<outline text="South America" type="continent" label="Continent/South America">
<outline text="Brazil" type="country" population="186 million" label="Country/Brazil"/>
<outline text="Argentina" type="country" population="40 million" label="Country/Argentina"/>
</outline>
</body>
</opml>
/trunk/api/js/dojo1.0/dojox/data/tests/stores/books.html
New file
0,0 → 1,118
<html>
<head>
<title>Books2.html</title>
</head>
<body>
<table id="books">
<thead>
<tr>
<th>isbn</th>
<th>title</th>
<th>author</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Title of 1</td>
<td>Author of 1</td>
</tr>
<tr>
<td>2</td>
<td>Title of 2</td>
<td>Author of 2</td>
</tr>
<tr>
<td>3</td>
<td>Title of 3</td>
<td>Author of 3</td>
</tr>
<tr>
<td>4</td>
<td>Title of 4</td>
<td>Author of 4</td>
</tr>
<tr>
<td>5</td>
<td>Title of 5</td>
<td>Author of 5</td>
</tr>
<tr>
<td>6</td>
<td>Title of 6</td>
<td>Author of 6</td>
</tr>
<tr>
<td>7</td>
<td>Title of 7</td>
<td>Author of 7</td>
</tr>
<tr>
<td>8</td>
<td>Title of 8</td>
<td>Author of 8</td>
</tr>
<tr>
<td>9</td>
<td>Title of 9</td>
<td>Author of 9</td>
</tr>
<tr>
<td>10</td>
<td>Title of 10</td>
<td>Author of 10</td>
</tr>
<tr>
<td>11</td>
<td>Title of 11</td>
<td>Author of 11</td>
</tr>
<tr>
<td>12</td>
<td>Title of 12</td>
<td>Author of 12</td>
</tr>
<tr>
<td>13</td>
<td>Title of 13</td>
<td>Author of 13</td>
</tr>
<tr>
<td>14</td>
<td>Title of 14</td>
<td>Author of 14</td>
</tr>
<tr>
<td>15</td>
<td>Title of 15</td>
<td>Author of 15</td>
</tr>
<tr>
<td>16</td>
<td>Title of 16</td>
<td>Author of 16</td>
</tr>
<tr>
<td>17</td>
<td>Title of 17</td>
<td>Author of 17</td>
</tr>
<tr>
<td>18</td>
<td>Title of 18</td>
<td>Author of 18</td>
</tr>
<tr>
<td>19</td>
<td>Title of 19</td>
<td>Author of 19</td>
</tr>
<tr>
<td>20</td>
<td>Title of 20</td>
<td>Author of 20</td>
</tr>
</tbody>
</table>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/data/tests/module.js
New file
0,0 → 1,24
if(!dojo._hasResource["dojox.data.tests.module"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.tests.module"] = true;
dojo.provide("dojox.data.tests.module");
 
try{
dojo.require("dojox.data.tests.stores.CsvStore");
dojo.requireIf(dojo.isBrowser, "dojox.data.tests.stores.HtmlTableStore");
dojo.requireIf(dojo.isBrowser, "dojox.data.tests.stores.OpmlStore");
dojo.requireIf(dojo.isBrowser, "dojox.data.tests.stores.XmlStore");
dojo.requireIf(dojo.isBrowser, "dojox.data.tests.stores.FlickrStore");
dojo.requireIf(dojo.isBrowser, "dojox.data.tests.stores.FlickrRestStore");
//Load only if in a browser AND if the location is remote (not file. As it needs a PHP server to work).
if(dojo.isBrowser){
if(window.location.protocol !== "file:"){
dojo.require("dojox.data.tests.stores.QueryReadStore");
}
}
dojo.requireIf(dojo.isBrowser, "dojox.data.tests.dom");
}catch(e){
doh.debug(e);
}
 
 
}
/trunk/api/js/dojo1.0/dojox/data/tests/QueryReadStore.html
New file
0,0 → 1,221
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/themes/tundra/tundra_rtl.css";
</style>
 
<title>Query read store</title>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript" src="../../../dojo/data/util/simpleFetch.js"></script>
<script type="text/javascript" src="../../../dojox/data/QueryReadStore.js"></script>
<script type="text/javascript">
dojo.require("dijit.form.ComboBox");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dojox.data.QueryReadStore");
 
dojo.provide("ComboBoxReadStore");
dojo.declare("ComboBoxReadStore", dojox.data.QueryReadStore, {
fetch:function(request) {
// Copy the GET/POST parameters (request.query) we need into
// request.serverQuery. We actually want to have
// the query added to the URL like so: /url.php?q=<searchString>
// The data in "queryOptions" are useless for our backend,
// we ignore them, they are not sent to the server.
// The combobox puts this into the request-parameter:
// {
// query: {name:<searchString>},
// queryOptions: {ignoreCase:true, deep:true},
// ...
// }
// We generate request.serverQuery to be this, since those values will
// be sent to the server.
// {
// q:<searchString>}
// }
// This results in a xhr request to the following URL (in case of GET):
// /url.php?q=<searchString>
//
 
request.serverQuery = {q:request.query.name};
// If we wanted to send the queryOptions too, we could simply do:
// request.serverQuery = {
// q:request.query.name,
// ignoreCase:request.queryOptions.ignoreCase,
// deep:request.queryOptions.deep
// };
// This would then result in this URL, for ignoreCase and deep
// assumed to be true:
// /url.php?q=<searchString>&ignoreCase=true&deep=true
return this.inherited("fetch", arguments);
}
});
 
dojo.provide("ServerPagingReadStore");
dojo.declare("ServerPagingReadStore", dojox.data.QueryReadStore, {
fetch:function(request) {
request.serverQuery = {q:request.query.name, start:request.start, count:request.count};
return this.inherited("fetch", arguments);
}
});
 
var testStore = new dojox.data.QueryReadStore({url:'stores/QueryReadStore.php'});;
function doSearch() {
var queryOptions = {};
if (dojo.byId("ignoreCaseEnabled").checked) {
queryOptions.ignoreCase = dojo.query("#fetchForm")[0].ignoreCase[0].checked;
}
if (dojo.byId("deepEnabled").checked) {
queryOptions.deep = dojo.query("#fetchForm")[0].deep[0].checked;
}
var query = {};
query.q = dojo.byId("searchText").value;
var request = {query:query, queryOptions:queryOptions};
request.start = parseInt(dojo.query("#fetchForm")[0].pagingStart.value);
request.count = parseInt(dojo.query("#fetchForm")[0].pagingCount.value);
 
var requestMethod = "get";
var radioButtons = dojo.query("#fetchForm")[0].requestMethod;
for (var i=0; i<radioButtons.length; i++){
if (radioButtons[i].checked) {
requestMethod = radioButtons[i].value;
}
}
testStore.requestMethod = requestMethod;
testStore.doClientPaging = dojo.query("#fetchForm")[0].doClientPaging.checked;
if (!testStore.doClientPaging) {
// We have to fill the serverQuery, since we also want to send the
// paging data "start" and "count" along with what is in query.
request.serverQuery = {q:request.query.q, start:request.start, count:request.count};
}
request.onComplete = function (items) {
var s = "number of items: "+items.length+"<br /><br />";
for (var i=0; i<items.length; i++) {
s += i+": name: '"+testStore.getValue(items[i], "name")+"'<br />";
}
//s += "<pre>"+dojo.toJson(items)+"</pre>";
dojo.byId("fetchOutput").innerHTML = s;
};
 
console.log(dojo.toJson(request));
testStore.fetch(request);
}
</script>
</head>
<body class="tundra" style="margin:20px;">
<div dojoType="ComboBoxReadStore" jsId="store" url="stores/QueryReadStore.php" requestMethod="get"></div>
This is a ComboBox: <input id="cb" dojoType="dijit.form.ComboBox" store="store" pageSize="5" />
<br /><br /><hr />
 
This is a FilteringSelect: <input id="fs" dojoType="dijit.form.FilteringSelect" store="store" pageSize="5" />
<br />
<form id="filteringSelectForm">
<input id="selectById" value="0" size="3" />
<input type="button" value="set by id" onclick="dijit.byId('fs').setValue(dojo.byId('selectById').value)" />
</form>
<br /><br /><hr />
 
This ComboBox uses a customized QueryReadStore, it prepares the query-string for the URL that
way that the paging parameters "start" and "count" are also send.<br />
<div dojoType="ServerPagingReadStore" jsId="serverPagingStore" url="stores/QueryReadStore.php" requestMethod="get" doClientPaging="false"></div>
<input dojoType="dijit.form.ComboBox" store="serverPagingStore" pageSize="5" />
<br />
<a href="javascript://" onclick="var d = dojo.byId('pagingCode'); d.style.display= d.style.display=='none'?'block':'none';">Click here to see the code!</a>
<div id="pagingCode" style="display:none;">
The HTML might look like this, the important attribute: <em>doClientPaging="false"</em> this takes care that the same query is fired to the server
and its not assumed that the client (the store) does the paging on the old data.
<pre>
&lt;div dojoType="ServerPagingReadStore" jsId="serverPagingStore" url="stores/QueryReadStore.php" requestMethod="get" doClientPaging="false"&gt;&lt;/div&gt;
&lt;input dojoType="dijit.form.ComboBox" store="serverPagingStore" pageSize="10" /&gt;
</pre>
<pre>
dojo.require("dojox.data.QueryReadStore");
dojo.provide("ServerPagingReadStore");
dojo.declare("ServerPagingReadStore", dojox.data.QueryReadStore, {
fetch:function(request) {
request.serverQuery = {q:request.query.name, start:request.start, count:request.count};
return this.inherited("fetch", arguments);
}
});
</pre>
</div>
<br /><br />
<hr />
<style>
fieldset {
border:1px solid black;
display:inline;
padding:10px;
}
div.disabled {
opacity:0.1;
}
</style>
<form id="fetchForm">
<fieldset title="requestMethod">
<legend>requestMethod</legend>
get <input type="radio" value="get" checked="checked" name="requestMethod" />
post <input type="radio" value="post" name="requestMethod" />
</fieldset>
<fieldset title="queryOptions">
<legend>queryOptions</legend>
 
<fieldset id="ignoreCaseFieldset">
<legend><input type="checkbox" id="ignoreCaseEnabled" /> ignoreCase</legend>
<div class="disabled">
true <input type="radio" value="0" checked="checked" name="ignoreCase" />
false <input type="radio" value="1" name="ignoreCase" />
</div>
</fieldset>
<fieldset id="deepFieldset">
<legend><input type="checkbox" id="deepEnabled" /> deep</legend>
<div class="disabled">
true <input type="radio" value="0" name="deep" />
false <input type="radio" value="1" name="deep" checked="checked" />
</div>
</fieldset>
</fieldset>
<fieldset title="paging">
<legend>paging</legend>
start: <input id="pagingStart" value="0" size="3" />
count: <input id="pagingCount" value="10" size="3" />
<br /><br />
do client paging: <input id="doClientPaging" type="checkbox" checked="checked" />
</fieldset>
<script>
var fieldsets = ["ignoreCaseFieldset", "deepFieldset"];
for (var i=0; i<fieldsets.length; i++) {
dojo.connect(dojo.byId(fieldsets[i]), "onchange", toggleFieldset);
}
function toggleFieldset(el) {
var divs = dojo.query("div", el.target.parentNode.parentNode);
if (divs.length) {
var div = divs[0];
if (el.target.checked) {
dojo.removeClass(div, "disabled");
} else {
dojo.addClass(div, "disabled");
}
}
}
</script>
<br /><br />
<input id="searchText" type="text" value="a">
<input id="searchButton" type="button" value="store.fetch()" onclick="doSearch()" />
</form>
<div id="fetchOutput" style="background-color:#FFDDDD; margin-top:1em; float:left;"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/data/CsvStore.js
New file
0,0 → 1,552
if(!dojo._hasResource["dojox.data.CsvStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.CsvStore"] = true;
dojo.provide("dojox.data.CsvStore");
 
dojo.require("dojo.data.util.filter");
dojo.require("dojo.data.util.simpleFetch");
 
dojo.declare("dojox.data.CsvStore", null, {
// summary:
// The CsvStore implements the dojo.data.api.Read API and reads
// data from files in CSV (Comma Separated Values) format.
// All values are simple string values. References to other items
// are not supported as attribute values in this datastore.
//
// Example data file:
// name, color, age, tagline
// Kermit, green, 12, "Hi, I'm Kermit the Frog."
// Fozzie Bear, orange, 10, "Wakka Wakka Wakka!"
// Miss Piggy, pink, 11, "Kermie!"
//
// Note that values containing a comma must be enclosed with quotes ("")
// Also note that values containing quotes must be escaped with two consecutive quotes (""quoted"")
/* examples:
* var csvStore = new dojox.data.CsvStore({url:"movies.csv");
* var csvStore = new dojox.data.CsvStore({url:"http://example.com/movies.csv");
*/
 
constructor: function(/* Object */ keywordParameters){
// summary: initializer
// keywordParameters: {url: String}
// keywordParameters: {data: String}
// keywordParameters: {label: String} The column label for the column to use for the label returned by getLabel.
this._attributes = []; // e.g. ["Title", "Year", "Producer"]
this._attributeIndexes = {}; // e.g. {Title: 0, Year: 1, Producer: 2}
this._dataArray = []; // e.g. [[<Item0>],[<Item1>],[<Item2>]]
this._arrayOfAllItems = []; // e.g. [{_csvId:0,_csvStore:store},...]
this._loadFinished = false;
if(keywordParameters.url){
this.url = keywordParameters.url;
}
this._csvData = keywordParameters.data;
if(keywordParameters.label){
this.label = keywordParameters.label;
}else if(this.label === ""){
this.label = undefined;
}
this._storeProp = "_csvStore"; // Property name for the store reference on every item.
this._idProp = "_csvId"; // Property name for the Item Id on every item.
this._features = {
'dojo.data.api.Read': true,
'dojo.data.api.Identity': true
};
this._loadInProgress = false; //Got to track the initial load to prevent duelling loads of the dataset.
this._queuedFetches = [];
},
 
url: "", //Declarative hook for setting Csv source url.
 
label: "", //Declarative hook for setting the label attribute.
_assertIsItem: function(/* item */ item){
// summary:
// This function tests whether the item passed in is indeed an item in the store.
// item:
// The item to test for being contained by the store.
if(!this.isItem(item)){
throw new Error("dojox.data.CsvStore: a function was passed an item argument that was not an item");
}
},
_assertIsAttribute: function(/* item || String */ attribute){
// summary:
// This function tests whether the item passed in is indeed a valid 'attribute' like type for the store.
// attribute:
// The attribute to test for being contained by the store.
if(!dojo.isString(attribute)){
throw new Error("dojox.data.CsvStore: a function was passed an attribute argument that was not an attribute object nor an attribute name string");
}
},
 
/***************************************
dojo.data.api.Read API
***************************************/
getValue: function( /* item */ item,
/* attribute || attribute-name-string */ attribute,
/* value? */ defaultValue){
// summary:
// See dojo.data.api.Read.getValue()
// Note that for the CsvStore, an empty string value is the same as no value,
// so the defaultValue would be returned instead of an empty string.
this._assertIsItem(item);
this._assertIsAttribute(attribute);
var itemValue = defaultValue;
if(this.hasAttribute(item, attribute)){
var itemData = this._dataArray[this.getIdentity(item)];
itemValue = itemData[this._attributeIndexes[attribute]];
}
return itemValue; //String
},
 
getValues: function(/* item */ item,
/* attribute || attribute-name-string */ attribute){
// summary:
// See dojo.data.api.Read.getValues()
// CSV syntax does not support multi-valued attributes, so this is just a
// wrapper function for getValue().
var value = this.getValue(item, attribute);
return (value ? [value] : []); //Array
},
 
getAttributes: function(/* item */ item){
// summary:
// See dojo.data.api.Read.getAttributes()
this._assertIsItem(item);
var attributes = [];
var itemData = this._dataArray[this.getIdentity(item)];
for(var i=0; i<itemData.length; i++){
// Check for empty string values. CsvStore treats empty strings as no value.
if(itemData[i] != ""){
attributes.push(this._attributes[i]);
}
}
return attributes; //Array
},
 
hasAttribute: function( /* item */ item,
/* attribute || attribute-name-string */ attribute){
// summary:
// See dojo.data.api.Read.hasAttribute()
// The hasAttribute test is true if attribute has an index number within the item's array length
// AND if the item has a value for that attribute. Note that for the CsvStore, an
// empty string value is the same as no value.
this._assertIsItem(item);
this._assertIsAttribute(attribute);
var attributeIndex = this._attributeIndexes[attribute];
var itemData = this._dataArray[this.getIdentity(item)];
return (typeof attributeIndex != "undefined" && attributeIndex < itemData.length && itemData[attributeIndex] != ""); //Boolean
},
 
containsValue: function(/* item */ item,
/* attribute || attribute-name-string */ attribute,
/* anything */ value){
// summary:
// See dojo.data.api.Read.containsValue()
var regexp = undefined;
if(typeof value === "string"){
regexp = dojo.data.util.filter.patternToRegExp(value, false);
}
return this._containsValue(item, attribute, value, regexp); //boolean.
},
 
_containsValue: function( /* item */ item,
/* attribute || attribute-name-string */ attribute,
/* anything */ value,
/* RegExp?*/ regexp){
// summary:
// Internal function for looking at the values contained by the item.
// description:
// Internal function for looking at the values contained by the item. This
// function allows for denoting if the comparison should be case sensitive for
// strings or not (for handling filtering cases where string case should not matter)
//
// item:
// The data item to examine for attribute values.
// attribute:
// The attribute to inspect.
// value:
// The value to match.
// regexp:
// Optional regular expression generated off value if value was of string type to handle wildcarding.
// If present and attribute values are string, then it can be used for comparison instead of 'value'
var values = this.getValues(item, attribute);
for(var i = 0; i < values.length; ++i){
var possibleValue = values[i];
if(typeof possibleValue === "string" && regexp){
return (possibleValue.match(regexp) !== null);
}else{
//Non-string matching.
if(value === possibleValue){
return true; // Boolean
}
}
}
return false; // Boolean
},
 
isItem: function(/* anything */ something){
// summary:
// See dojo.data.api.Read.isItem()
if(something && something[this._storeProp] === this){
var identity = something[this._idProp];
if(identity >= 0 && identity < this._dataArray.length){
return true; //Boolean
}
}
return false; //Boolean
},
 
isItemLoaded: function(/* anything */ something){
// summary:
// See dojo.data.api.Read.isItemLoaded()
// The CsvStore always loads all items, so if it's an item, then it's loaded.
return this.isItem(something); //Boolean
},
 
loadItem: function(/* item */ item){
// summary:
// See dojo.data.api.Read.loadItem()
// description:
// The CsvStore always loads all items, so if it's an item, then it's loaded.
// From the dojo.data.api.Read.loadItem docs:
// If a call to isItemLoaded() returns true before loadItem() is even called,
// then loadItem() need not do any work at all and will not even invoke
// the callback handlers.
},
 
getFeatures: function(){
// summary:
// See dojo.data.api.Read.getFeatures()
return this._features; //Object
},
 
getLabel: function(/* item */ item){
// summary:
// See dojo.data.api.Read.getLabel()
if(this.label && this.isItem(item)){
return this.getValue(item,this.label); //String
}
return undefined; //undefined
},
 
getLabelAttributes: function(/* item */ item){
// summary:
// See dojo.data.api.Read.getLabelAttributes()
if(this.label){
return [this.label]; //array
}
return null; //null
},
 
 
// The dojo.data.api.Read.fetch() function is implemented as
// a mixin from dojo.data.util.simpleFetch.
// That mixin requires us to define _fetchItems().
_fetchItems: function( /* Object */ keywordArgs,
/* Function */ findCallback,
/* Function */ errorCallback){
// summary:
// See dojo.data.util.simpleFetch.fetch()
var self = this;
 
var filter = function(requestArgs, arrayOfAllItems){
var items = null;
if(requestArgs.query){
items = [];
var ignoreCase = requestArgs.queryOptions ? requestArgs.queryOptions.ignoreCase : false;
 
//See if there are any string values that can be regexp parsed first to avoid multiple regexp gens on the
//same value for each item examined. Much more efficient.
var regexpList = {};
for(var key in requestArgs.query){
var value = requestArgs.query[key];
if(typeof value === "string"){
regexpList[key] = dojo.data.util.filter.patternToRegExp(value, ignoreCase);
}
}
 
for(var i = 0; i < arrayOfAllItems.length; ++i){
var match = true;
var candidateItem = arrayOfAllItems[i];
for(var key in requestArgs.query){
var value = requestArgs.query[key];
if(!self._containsValue(candidateItem, key, value, regexpList[key])){
match = false;
}
}
if(match){
items.push(candidateItem);
}
}
}else{
// We want a copy to pass back in case the parent wishes to sort the array. We shouldn't allow resort
// of the internal list so that multiple callers can get lists and sort without affecting each other.
if(arrayOfAllItems.length> 0){
items = arrayOfAllItems.slice(0,arrayOfAllItems.length);
}
}
findCallback(items, requestArgs);
};
 
if(this._loadFinished){
filter(keywordArgs, this._arrayOfAllItems);
}else{
if(this.url !== ""){
//If fetches come in before the loading has finished, but while
//a load is in progress, we have to defer the fetching to be
//invoked in the callback.
if(this._loadInProgress){
this._queuedFetches.push({args: keywordArgs, filter: filter});
}else{
this._loadInProgress = true;
var getArgs = {
url: self.url,
handleAs: "text"
};
var getHandler = dojo.xhrGet(getArgs);
getHandler.addCallback(function(data){
self._processData(data);
filter(keywordArgs, self._arrayOfAllItems);
self._handleQueuedFetches();
});
getHandler.addErrback(function(error){
self._loadInProgress = false;
throw error;
});
}
}else if(this._csvData){
this._processData(this._csvData);
this._csvData = null;
filter(keywordArgs, this._arrayOfAllItems);
}else{
throw new Error("dojox.data.CsvStore: No CSV source data was provided as either URL or String data input.");
}
}
},
close: function(/*dojo.data.api.Request || keywordArgs || null */ request){
// summary:
// See dojo.data.api.Read.close()
},
// -------------------------------------------------------------------
// Private methods
_getArrayOfArraysFromCsvFileContents: function(/* string */ csvFileContents){
/* summary:
* Parses a string of CSV records into a nested array structure.
* description:
* Given a string containing CSV records, this method parses
* the string and returns a data structure containing the parsed
* content. The data structure we return is an array of length
* R, where R is the number of rows (lines) in the CSV data. The
* return array contains one sub-array for each CSV line, and each
* sub-array contains C string values, where C is the number of
* columns in the CSV data.
*/
/* example:
* For example, given this CSV string as input:
* "Title, Year, Producer \n Alien, 1979, Ridley Scott \n Blade Runner, 1982, Ridley Scott"
* this._dataArray will be set to:
* [["Alien", "1979", "Ridley Scott"],
* ["Blade Runner", "1982", "Ridley Scott"]]
* And this._attributes will be set to:
* ["Title", "Year", "Producer"]
* And this._attributeIndexes will be set to:
* { "Title":0, "Year":1, "Producer":2 }
*/
if(dojo.isString(csvFileContents)){
var lineEndingCharacters = new RegExp("\r\n|\n|\r");
var leadingWhiteSpaceCharacters = new RegExp("^\\s+",'g');
var trailingWhiteSpaceCharacters = new RegExp("\\s+$",'g');
var doubleQuotes = new RegExp('""','g');
var arrayOfOutputRecords = [];
var arrayOfInputLines = csvFileContents.split(lineEndingCharacters);
for(var i = 0; i < arrayOfInputLines.length; ++i){
var singleLine = arrayOfInputLines[i];
if(singleLine.length > 0){
var listOfFields = singleLine.split(',');
var j = 0;
while(j < listOfFields.length){
var space_field_space = listOfFields[j];
var field_space = space_field_space.replace(leadingWhiteSpaceCharacters, ''); // trim leading whitespace
var field = field_space.replace(trailingWhiteSpaceCharacters, ''); // trim trailing whitespace
var firstChar = field.charAt(0);
var lastChar = field.charAt(field.length - 1);
var secondToLastChar = field.charAt(field.length - 2);
var thirdToLastChar = field.charAt(field.length - 3);
if(field.length === 2 && field == "\"\""){
listOfFields[j] = ""; //Special case empty string field.
}else if((firstChar == '"') &&
((lastChar != '"') ||
((lastChar == '"') && (secondToLastChar == '"') && (thirdToLastChar != '"')))){
if(j+1 === listOfFields.length){
// alert("The last field in record " + i + " is corrupted:\n" + field);
return null; //null
}
var nextField = listOfFields[j+1];
listOfFields[j] = field_space + ',' + nextField;
listOfFields.splice(j+1, 1); // delete element [j+1] from the list
}else{
if((firstChar == '"') && (lastChar == '"')){
field = field.slice(1, (field.length - 1)); // trim the " characters off the ends
field = field.replace(doubleQuotes, '"'); // replace "" with "
}
listOfFields[j] = field;
j += 1;
}
}
arrayOfOutputRecords.push(listOfFields);
}
}
// The first item of the array must be the header row with attribute names.
this._attributes = arrayOfOutputRecords.shift();
for(var i=0; i<this._attributes.length; i++){
// Store the index of each attribute
this._attributeIndexes[this._attributes[i]] = i;
}
this._dataArray = arrayOfOutputRecords; //Array
}
},
_processData: function(/* String */ data){
this._getArrayOfArraysFromCsvFileContents(data);
this._arrayOfAllItems = [];
for(var i=0; i<this._dataArray.length; i++){
this._arrayOfAllItems.push(this._createItemFromIdentity(i));
}
this._loadFinished = true;
this._loadInProgress = false;
},
_createItemFromIdentity: function(/* String */ identity){
var item = {};
item[this._storeProp] = this;
item[this._idProp] = identity;
return item; //Object
},
/***************************************
dojo.data.api.Identity API
***************************************/
getIdentity: function(/* item */ item){
// summary:
// See dojo.data.api.Identity.getIdentity()
if(this.isItem(item)){
return item[this._idProp]; //String
}
return null; //null
},
 
fetchItemByIdentity: function(/* Object */ keywordArgs){
// summary:
// See dojo.data.api.Identity.fetchItemByIdentity()
 
//Hasn't loaded yet, we have to trigger the load.
 
if(!this._loadFinished){
var self = this;
if(this.url !== ""){
//If fetches come in before the loading has finished, but while
//a load is in progress, we have to defer the fetching to be
//invoked in the callback.
if(this._loadInProgress){
this._queuedFetches.push({args: keywordArgs});
}else{
this._loadInProgress = true;
var getArgs = {
url: self.url,
handleAs: "text"
};
var getHandler = dojo.xhrGet(getArgs);
getHandler.addCallback(function(data){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
try{
self._processData(data);
var item = self._createItemFromIdentity(keywordArgs.identity);
if(!self.isItem(item)){
item = null;
}
if(keywordArgs.onItem){
keywordArgs.onItem.call(scope, item);
}
self._handleQueuedFetches();
}catch(error){
if(keywordArgs.onError){
keywordArgs.onError.call(scope, error);
}
}
});
getHandler.addErrback(function(error){
this._loadInProgress = false;
if(keywordArgs.onError){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
keywordArgs.onError.call(scope, error);
}
});
}
}else if(this._csvData){
self._processData(self._csvData);
self._csvData = null;
var item = self._createItemFromIdentity(keywordArgs.identity);
if(!self.isItem(item)){
item = null;
}
if(keywordArgs.onItem){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
keywordArgs.onItem.call(scope, item);
}
}
}else{
//Already loaded. We can just look it up and call back.
var item = this._createItemFromIdentity(keywordArgs.identity);
if(!this.isItem(item)){
item = null;
}
if(keywordArgs.onItem){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
keywordArgs.onItem.call(scope, item);
}
}
},
 
getIdentityAttributes: function(/* item */ item){
// summary:
// See dojo.data.api.Identity.getIdentifierAttributes()
//Identity isn't a public attribute in the item, it's the row position index.
//So, return null.
return null;
},
 
_handleQueuedFetches: function(){
// summary:
// Internal function to execute delayed request in the store.
//Execute any deferred fetches now.
if (this._queuedFetches.length > 0) {
for(var i = 0; i < this._queuedFetches.length; i++){
var fData = this._queuedFetches[i];
var delayedFilter = fData.filter;
var delayedQuery = fData.args;
if(delayedFilter){
delayedFilter(delayedQuery, this._arrayOfAllItems);
}else{
this.fetchItemByIdentity(fData.args);
}
}
this._queuedFetches = [];
}
}
});
//Mix in the simple fetch implementation to this class.
dojo.extend(dojox.data.CsvStore,dojo.data.util.simpleFetch);
 
}
/trunk/api/js/dojo1.0/dojox/data/HtmlTableStore.js
New file
0,0 → 1,466
if(!dojo._hasResource["dojox.data.HtmlTableStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.data.HtmlTableStore"] = true;
dojo.provide("dojox.data.HtmlTableStore");
 
dojo.require("dojox.data.dom");
dojo.require("dojo.data.util.simpleFetch");
dojo.require("dojo.data.util.filter");
 
dojo.declare("dojox.data.HtmlTableStore", null, {
constructor: function(/*Object*/args){
// summary:
// Initializer for the HTML table store.
// description:
// The HtmlTableStore can be created in one of two ways: a) by parsing an existing
// table DOM node on the current page or b) by referencing an external url and giving
// the id of the table in that page. The remote url will be parsed as an html page.
//
// The HTML table should be of the following form:
// <table id="myTable">
// <thead>
// <tr>
// <th>Attribute1</th>
// <th>Attribute2</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>Value1.1</td>
// <td>Value1.2</td>
// </tr>
// <tr>
// <td>Value2.1</td>
// <td>Value2.2</td>
// </tr>
// </tbody>
// </table>
//
// args:
// An anonymous object to initialize properties. It expects the following values:
// tableId: The id of the HTML table to use.
// OR
// url: The url of the remote page to load
// tableId: The id of the table element in the remote page
if(args.url){
if(!args.tableId)
throw new Error("dojo.data.HtmlTableStore: Cannot instantiate using url without an id!");
this.url = args.url;
this.tableId = args.tableId;
}else{
if(args.tableId){
this._rootNode = dojo.byId(args.tableId);
this.tableId = this._rootNode.id;
}else{
this._rootNode = dojo.byId(this.tableId);
}
this._getHeadings();
for(var i=0; i<this._rootNode.rows.length; i++){
this._rootNode.rows[i].store = this;
}
}
},
 
url: "", // So the parser can instantiate the store via markup.
tableId: "", // So the parser can instantiate the store via markup.
 
_getHeadings: function(){
// summary:
// Function to load the attribute names from the table header so that the
// attributes (cells in a row), can have a reasonable name.
this._headings = [];
dojo.forEach(this._rootNode.tHead.rows[0].cells, dojo.hitch(this, function(th){
this._headings.push(dojox.data.dom.textContent(th));
}));
},
_getAllItems: function(){
// summary:
// Function to return all rows in the table as an array of items.
var items = [];
for(var i=1; i<this._rootNode.rows.length; i++){
items.push(this._rootNode.rows[i]);
}
return items; //array
},
_assertIsItem: function(/* item */ item){
// summary:
// This function tests whether the item passed in is indeed an item in the store.
// item:
// The item to test for being contained by the store.
if(!this.isItem(item)){
throw new Error("dojo.data.HtmlTableStore: a function was passed an item argument that was not an item");
}
},
 
_assertIsAttribute: function(/* String */ attribute){
// summary:
// This function tests whether the item passed in is indeed a valid 'attribute' like type for the store.
// attribute:
// The attribute to test for being contained by the store.
//
// returns:
// Returns the index (column) that the attribute resides in the row.
if(typeof attribute !== "string"){
throw new Error("dojo.data.HtmlTableStore: a function was passed an attribute argument that was not an attribute name string");
return;
}
return dojo.indexOf(this._headings, attribute); //int
},
 
/***************************************
dojo.data.api.Read API
***************************************/
getValue: function( /* item */ item,
/* attribute-name-string */ attribute,
/* value? */ defaultValue){
// summary:
// See dojo.data.api.Read.getValue()
var values = this.getValues(item, attribute);
return (values.length > 0)?values[0]:defaultValue; //Object || int || Boolean
},
 
getValues: function(/* item */ item,
/* attribute-name-string */ attribute){
// summary:
// See dojo.data.api.Read.getValues()
 
this._assertIsItem(item);
var index = this._assertIsAttribute(attribute);
 
if(index>-1){
return [dojox.data.dom.textContent(item.cells[index])] ;
}
return []; //Array
},
 
getAttributes: function(/* item */ item){
// summary:
// See dojo.data.api.Read.getAttributes()
this._assertIsItem(item);
var attributes = [];
for(var i=0; i<this._headings.length; i++){
if(this.hasAttribute(item, this._headings[i]))
attributes.push(this._headings[i]);
}
return attributes; //Array
},
 
hasAttribute: function( /* item */ item,
/* attribute-name-string */ attribute){
// summary:
// See dojo.data.api.Read.hasAttribute()
return this.getValues(item, attribute).length > 0;
},
 
containsValue: function(/* item */ item,
/* attribute-name-string */ attribute,
/* anything */ value){
// summary:
// See dojo.data.api.Read.containsValue()
var regexp = undefined;
if(typeof value === "string"){
regexp = dojo.data.util.filter.patternToRegExp(value, false);
}
return this._containsValue(item, attribute, value, regexp); //boolean.
},
 
_containsValue: function( /* item */ item,
/* attribute-name-string */ attribute,
/* anything */ value,
/* RegExp?*/ regexp){
// summary:
// Internal function for looking at the values contained by the item.
// description:
// Internal function for looking at the values contained by the item. This
// function allows for denoting if the comparison should be case sensitive for
// strings or not (for handling filtering cases where string case should not matter)
//
// item:
// The data item to examine for attribute values.
// attribute:
// The attribute to inspect.
// value:
// The value to match.
// regexp:
// Optional regular expression generated off value if value was of string type to handle wildcarding.
// If present and attribute values are string, then it can be used for comparison instead of 'value'
var values = this.getValues(item, attribute);
for(var i = 0; i < values.length; ++i){
var possibleValue = values[i];
if(typeof possibleValue === "string" && regexp){
return (possibleValue.match(regexp) !== null);
}else{
//Non-string matching.
if(value === possibleValue){
return true; // Boolean
}
}
}
return false; // Boolean
},
 
isItem: function(/* anything */ something){
// summary:
// See dojo.data.api.Read.isItem()
if(something && something.store && something.store === this){
return true; //boolean
}
return false; //boolean
},
 
isItemLoaded: function(/* anything */ something){
// summary:
// See dojo.data.api.Read.isItemLoaded()
return this.isItem(something);
},
 
loadItem: function(/* Object */ keywordArgs){
// summary:
// See dojo.data.api.Read.loadItem()
this._assertIsItem(keywordArgs.item);
},
_fetchItems: function(request, fetchHandler, errorHandler) {
// summary:
// Fetch items (XML elements) that match to a query
// description:
// If '_fetchUrl' is specified, it is used to load an XML document
// with a query string.
// Otherwise and if 'url' is specified, the XML document is
// loaded and list XML elements that match to a query (set of element
// names and their text attribute values that the items to contain).
// A wildcard, "*" can be used to query values to match all
// occurrences.
// If '_rootItem' is specified, it is used to fetch items.
// request:
// A request object
// fetchHandler:
// A function to call for fetched items
// errorHandler:
// A function to call on error
if(this._rootNode){
this._finishFetchItems(request, fetchHandler, errorHandler);
}else{
if(!this.url){
this._rootNode = dojo.byId(this.tableId);
this._getHeadings();
for(var i=0; i<this._rootNode.rows.length; i++){
this._rootNode.rows[i].store = this;
}
}else{
var getArgs = {
url: this.url,
handleAs: "text"
};
var self = this;
var getHandler = dojo.xhrGet(getArgs);
getHandler.addCallback(function(data){
var findNode = function(node, id){
if(node.id == id){
return node; //object
}
if(node.childNodes){
for(var i=0; i<node.childNodes.length; i++){
var returnNode = findNode(node.childNodes[i], id);
if(returnNode){
return returnNode; //object
}
}
}
return null; //null
}
 
var d = document.createElement("div");
d.innerHTML = data;
self._rootNode = findNode(d, self.tableId);
self._getHeadings.call(self);
for(var i=0; i<self._rootNode.rows.length; i++) {
self._rootNode.rows[i].store = self;
}
self._finishFetchItems(request, fetchHandler, errorHandler);
});
getHandler.addErrback(function(error){
errorHandler(error, request);
});
}
}
},
_finishFetchItems: function(request, fetchHandler, errorHandler){
// summary:
// Internal function for processing the passed in request and locating the requested items.
var items = null;
var arrayOfAllItems = this._getAllItems();
if(request.query){
var ignoreCase = request.queryOptions ? request.queryOptions.ignoreCase : false;
items = [];
 
//See if there are any string values that can be regexp parsed first to avoid multiple regexp gens on the
//same value for each item examined. Much more efficient.
var regexpList = {};
for(var key in request.query){
var value = request.query[key]+'';
if(typeof value === "string"){
regexpList[key] = dojo.data.util.filter.patternToRegExp(value, ignoreCase);
}
}
 
for(var i = 0; i < arrayOfAllItems.length; ++i){
var match = true;
var candidateItem = arrayOfAllItems[i];
for(var key in request.query){
var value = request.query[key]+'';
if (!this._containsValue(candidateItem, key, value, regexpList[key])){
match = false;
}
}
if(match){
items.push(candidateItem);
}
}
fetchHandler(items, request);
}else{
// We want a copy to pass back in case the parent wishes to sort the array. We shouldn't allow resort
// of the internal list so that multiple callers can get listsand sort without affecting each other.
if(arrayOfAllItems.length> 0){
items = arrayOfAllItems.slice(0,arrayOfAllItems.length);
}
fetchHandler(items, request);
}
},
 
getFeatures: function(){
// summary:
// See dojo.data.api.Read.getFeatures()
return {
'dojo.data.api.Read': true,
'dojo.data.api.Identity': true
};
},
close: function(/*dojo.data.api.Request || keywordArgs || null */ request){
// summary:
// See dojo.data.api.Read.close()
// nothing to do here!
},
 
getLabel: function(/* item */ item){
// summary:
// See dojo.data.api.Read.getLabel()
if(this.isItem(item))
return "Table Row #" + this.getIdentity(item);
return undefined;
},
 
getLabelAttributes: function(/* item */ item){
// summary:
// See dojo.data.api.Read.getLabelAttributes()
return null;
},
 
/***************************************
dojo.data.api.Identity API
***************************************/
 
getIdentity: function(/* item */ item){
// summary:
// See dojo.data.api.Identity.getIdentity()
this._assertIsItem(item);
//Opera doesn't support the sectionRowIndex,
//So, have to call the indexOf to locate it.
//Blah.
if(!dojo.isOpera){
return item.sectionRowIndex; // int
}else{
return (dojo.indexOf(this._rootNode.rows, item) - 1) // int
}
},
 
getIdentityAttributes: function(/* item */ item){
// summary:
// See dojo.data.api.Identity.getIdentityAttributes()
//Identity isn't taken from a public attribute.
return null;
},
 
fetchItemByIdentity: function(keywordArgs){
// summary:
// See dojo.data.api.Identity.fetchItemByIdentity()
var identity = keywordArgs.identity;
var self = this;
var item = null
 
if(!this._rootNode){
if(!this.url){
this._rootNode = dojo.byId(this.tableId);
this._getHeadings();
for(var i=0; i<this._rootNode.rows.length; i++){
this._rootNode.rows[i].store = this;
}
item = this._rootNode.rows[identity+1];
if (keywordArgs.onItem){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
keywordArgs.onItem.call(scope, item);
}
 
}else{
var getArgs = {
url: this.url,
handleAs: "text"
};
var self = this;
var getHandler = dojo.xhrGet(getArgs);
getHandler.addCallback(function(data){
var findNode = function(node, id){
if(node.id == id){
return node; //object
}
if(node.childNodes) {
for(var i=0; i<node.childNodes.length; i++){
var returnNode = findNode(node.childNodes[i], id);
if(returnNode){
return returnNode; //object
}
}
}
return null; //null
}
var d = document.createElement("div");
d.innerHTML = data;
self._rootNode = findNode(d, self.tableId);
self._getHeadings.call(self);
for(var i=0; i<self._rootNode.rows.length; i++){
self._rootNode.rows[i].store = self;
}
item = self._rootNode.rows[identity+1];
if (keywordArgs.onItem){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
keywordArgs.onItem.call(scope, item);
}
});
getHandler.addErrback(function(error){
if(keywordArgs.onError){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
keywordArgs.onError.call(scope, error);
 
}
});
}
}else{
if(this._rootNode.rows[identity+1]){
item = this._rootNode.rows[identity+1];
if (keywordArgs.onItem){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
keywordArgs.onItem.call(scope, item);
}
}
}
}
});
dojo.extend(dojox.data.HtmlTableStore,dojo.data.util.simpleFetch);
 
}
/trunk/api/js/dojo1.0/dojox/off/resources/learnhow.html
New file
0,0 → 1,43
<html>
<head>
<link rel="stylesheet" type="text/css" href="offline-widget.css"></link>
<script type="text/javascript" src="learnhow.js"></script>
</head>
<body id="dot-learn-how-body">
<div id="dot-learn-how-contents">
<h1><b>Want to use <span id="dot-learn-how-app-name">Application</span> offline?</b></h1>
<p id="dot-toolkit-info">It's simple with Dojo Offline! Dojo Offline is a free open source utility that makes it easy
for this web application to work, even if you're offline. Now you can
access your data even when away from the network!</p>
<p>Dojo Offline is an open source project brought to you by
<a href="http://dojotoolkit.org">Dojo</a>, <a href="http://sitepen.com">SitePen</a>,
and <a href="http://codinginparadise.org">Brad Neuberg</a>. It incorporates
technologies created by <a href="http://google.com">Google</a>.</p>
<h2>To get started:</h2>
<ol>
<li id="dot-download-step">
<a target="_new" href="http://gears.google.com">Download Gears</a>, a small, open source utility created by Google that allows this web site
to work offline. This tool is safe and secure for your machine, and only takes
a few seconds to download.
</li>
<li id="dot-install-step">
Once downloaded, run the installer. Restart your web browser when finished installing.
</li>
<li id="dot-drag-link-step">
To access this website even when offline, drag the following link to your
desktop or your browser's link toolbar above: <a id="dot-learn-how-run-link" href="#">Run Application</a>.
</li>
<li id="dot-run-link-step">
Double-click the link on your desktop to start this web application, even
if offline.
</li>
</ol>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/off/resources/roller.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/off/resources/roller.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/off/resources/offline-widget.html
New file
0,0 → 1,40
<!--
Note: The elements in this UI can be broken apart
and spread around your page, as long as you keep the
IDs intact. Elements can also be dropped without
Dojo Offline's default UI breaking.
-->
 
<div id="dot-widget-container" style="visibility: hidden;">
<div id="dot-widget-title-bar">
<span id="dot-widget-network-indicator">
<img id="dot-widget-network-indicator-online" />
<img id="dot-widget-network-indicator-offline" />
</span>
<span id="dot-widget-title-text"></span>
</div>
<div id="dot-widget-contents">
<div id="dot-widget-browser-restart">
Please restart your browser to
use <span id="dot-widget-browser-restart-app-name"></span> Offline
</div>
<div id="dot-sync-status">
<img id="dot-roller" />
<img id="dot-success-checkmark" />
<span id="dot-sync-messages"></span>
<span id="dot-sync-details">
(<a id="dot-sync-details-button" href="#">details</a>)
</span>
<span id="dot-sync-cancel">
(<a id="dot-sync-cancel-button" href="#">cancel</a>)
</span>
</div>
<div id="dot-widget-learn-how">
<a id="dot-widget-learn-how-link" target="_blank" href="#">Learn How</a>
to use <span id="dot-widget-learn-how-app-name"></span>&nbsp;Offline!
</div>
</div>
</div>
/trunk/api/js/dojo1.0/dojox/off/resources/redball.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/off/resources/redball.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/off/resources/learnhow.js
New file
0,0 → 1,43
window.onload = function(){
// get the app name from our URL
var href = window.location.href;
var matches = href.match(/appName=([a-z0-9 \%]*)/i);
var appName = "Application";
if(matches && matches.length > 0){
appName = decodeURIComponent(matches[1]);
}
// set it in our UI
var appNameSpan = document.getElementById("dot-learn-how-app-name");
appNameSpan.innerHTML = "";
appNameSpan.appendChild(document.createTextNode(appName));
// if we need an offline cache, and we already have one installed,
// update the UI
matches = href.match(/hasOfflineCache=(true|false)/);
var hasOfflineCache = false;
if(matches && matches.length > 0){
hasOfflineCache = matches[1];
// convert to boolean
hasOfflineCache = (hasOfflineCache == "true") ? true : false;
}
if(hasOfflineCache == true){
// delete the download and install steps
var downloadStep = document.getElementById("dot-download-step");
var installStep = document.getElementById("dot-install-step");
downloadStep.parentNode.removeChild(downloadStep);
installStep.parentNode.removeChild(installStep);
}
// get our run link info and update the UI
matches = href.match(/runLink=([^\&]*)\&runLinkText=([^\&]*)/);
if(matches && matches.length > 0){
var runLink = decodeURIComponent(matches[1]);
var runLinkElem = document.getElementById("dot-learn-how-run-link");
runLinkElem.setAttribute("href", runLink);
var runLinkText = decodeURIComponent(matches[2]);
runLinkElem.innerHTML = "";
runLinkElem.appendChild(document.createTextNode(runLinkText));
}
}
/trunk/api/js/dojo1.0/dojox/off/resources/offline-widget.css
New file
0,0 → 1,112
/** Offline Widget Styles */
 
#dot-widget-container{
/**
Keep these as EMs so widget reflows fluidly based on
user-font size settings
*/
width: 13em;
height: auto;
border: 2px solid #CDDDE9; /* light tundra blue */
position: relative;
visibility: visible !important;
}
 
#dot-widget-title-bar{
background-color: #CDDDE9; /* light tundra blue */
padding-top: 0.2em;
padding-bottom: 0.2em;
}
 
#dot-widget-network-indicator{
height: 8px;
width: 8px;
padding-left: 0.3em;
}
 
#dot-widget-title-text{
vertical-align: middle;
font-weight: bold;
font-size: 14pt;
padding-left: 2px;
}
 
#dot-widget-contents{
padding: 8px 5px 8px 5px;
}
 
#dot-widget-learn-how{
font-size: 11pt;
}
 
#dot-sync-cancel,
#dot-sync-status{
font-size: 11pt;
}
 
#dot-success-checkmark{
display: none;
}
 
#dot-roller{
display: none;
padding-right: 4px;
}
 
.dot-sync-error{
color: red;
}
 
#dot-sync-details{
display: none;
padding-left: 0.2em;
}
 
#dot-sync-status{
height: 2em;
margin-top: 0.8em;
margin-bottom: 0.8em;
}
 
.dot-needs-offline-cache #dot-widget-learn-how,
.dot-needs-browser-restart{
text-align: center;
line-height: 1.2;
font-size: 16pt !important;
}
 
.dot-needs-offline-cache #dot-sync-status,
.dot-needs-offline-cache #dot-widget-browser-restart{
display: none;
}
 
.dot-needs-browser-restart{
font-size: 14pt !important;
padding-bottom: 1em;
padding-top: 1em;
}
 
/** Learn How Page Styles */
#dot-learn-how-body{
padding: 3em;
background-color: #CDDDE9; /* light tundra blue */
}
 
#dot-learn-how-contents{
border: 1px solid black;
background-color: white;
padding: 0.4em 0.6em 0.4em 0.6em;
font-size: 16pt;
}
 
#dot-learn-how-contents h1{
font-size: 24pt;
}
 
#dot-learn-how-contents h2{
font-size: 18pt;
}
 
#dot-learn-how-contents li{
padding-bottom: 0.6em;
}
/trunk/api/js/dojo1.0/dojox/off/resources/checkmark.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/off/resources/checkmark.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/off/resources/greenball.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/off/resources/greenball.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/off/README
New file
0,0 → 1,0
See http://docs.google.com/View?docid=dhkhksk4_8gdp9gr for documentation and a tutorial on using Dojo Offline.
/trunk/api/js/dojo1.0/dojox/off/files.js
New file
0,0 → 1,449
if(!dojo._hasResource["dojox.off.files"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.off.files"] = true;
dojo.provide("dojox.off.files");
 
// Author: Brad Neuberg, bkn3@columbia.edu, http://codinginparadise.org
 
// summary:
// Helps maintain resources that should be
// available offline, such as CSS files.
// description:
// dojox.off.files makes it easy to indicate
// what resources should be available offline,
// such as CSS files, JavaScript, HTML, etc.
dojox.off.files = {
// versionURL: String
// An optional file, that if present, records the version
// of our bundle of files to make available offline. If this
// file is present, and we are not currently debugging,
// then we only refresh our offline files if the version has
// changed.
versionURL: "version.js",
// listOfURLs: Array
// For advanced usage; most developers can ignore this.
// Our list of URLs that will be cached and made available
// offline.
listOfURLs: [],
// refreshing: boolean
// For advanced usage; most developers can ignore this.
// Whether we are currently in the middle
// of refreshing our list of offline files.
refreshing: false,
 
_cancelID: null,
_error: false,
_errorMessages: [],
_currentFileIndex: 0,
_store: null,
_doSlurp: false,
slurp: function(){
// summary:
// Autoscans the page to find all resources to
// cache. This includes scripts, images, CSS, and hyperlinks
// to pages that are in the same scheme/port/host as this
// page. We also scan the embedded CSS of any stylesheets
// to find @import statements and url()'s.
// You should call this method from the top-level, outside of
// any functions and before the page loads:
//
// <script>
// dojo.require("dojox.sql");
// dojo.require("dojox.off");
// dojo.require("dojox.off.ui");
// dojo.require("dojox.off.sync");
//
// // configure how we should work offline
//
// // set our application name
// dojox.off.ui.appName = "Moxie";
//
// // automatically "slurp" the page and
// // capture the resources we need offline
// dojox.off.files.slurp();
//
// // tell Dojo Offline we are ready for it to initialize itself now
// // that we have finished configuring it for our application
// dojox.off.initialize();
// </script>
//
// Note that inline styles on elements are not handled (i.e.
// if you somehow have an inline style that uses a URL);
// object and embed tags are not scanned since their format
// differs based on type; and elements created by JavaScript
// after page load are not found. For these you must manually
// add them with a dojox.off.files.cache() method call.
// just schedule the slurp once the page is loaded and
// Dojo Offline is ready to slurp; dojox.off will call
// our _slurp() method before indicating it is finished
// loading
this._doSlurp = true;
},
cache: function(urlOrList){ /* void */
// summary:
// Caches a file or list of files to be available offline. This
// can either be a full URL, such as http://foobar.com/index.html,
// or a relative URL, such as ../index.html. This URL is not
// actually cached until dojox.off.sync.synchronize() is called.
// urlOrList: String or Array[]
// A URL of a file to cache or an Array of Strings of files to
// cache
//console.debug("dojox.off.files.cache, urlOrList="+urlOrList);
if(dojo.isString(urlOrList)){
var url = this._trimAnchor(urlOrList+"");
if(!this.isAvailable(url)){
this.listOfURLs.push(url);
}
}else if(urlOrList instanceof dojo._Url){
var url = this._trimAnchor(urlOrList.uri);
if(!this.isAvailable(url)){
this.listOfURLs.push(url);
}
}else{
dojo.forEach(urlOrList, function(url){
url = this._trimAnchor(url);
if(!this.isAvailable(url)){
this.listOfURLs.push(url);
}
}, this);
}
},
printURLs: function(){
// summary:
// A helper function that will dump and print out
// all of the URLs that are cached for offline
// availability. This can help with debugging if you
// are trying to make sure that all of your URLs are
// available offline
console.debug("The following URLs are cached for offline use:");
dojo.forEach(this.listOfURLs, function(i){
console.debug(i);
});
},
remove: function(url){ /* void */
// summary:
// Removes a URL from the list of files to cache.
// description:
// Removes a URL from the list of URLs to cache. Note that this
// does not actually remove the file from the offline cache;
// instead, it just prevents us from refreshing this file at a
// later time, so that it will naturally time out and be removed
// from the offline cache
// url: String
// The URL to remove
for(var i = 0; i < this.listOfURLs.length; i++){
if(this.listOfURLs[i] == url){
this.listOfURLs = this.listOfURLs.splice(i, 1);
break;
}
}
},
isAvailable: function(url){ /* boolean */
// summary:
// Determines whether the given resource is available offline.
// url: String
// The URL to check
for(var i = 0; i < this.listOfURLs.length; i++){
if(this.listOfURLs[i] == url){
return true;
}
}
return false;
},
refresh: function(callback){ /* void */
//console.debug("dojox.off.files.refresh");
// summary:
// For advanced usage; most developers can ignore this.
// Refreshes our list of offline resources,
// making them available offline.
// callback: Function
// A callback that receives two arguments: whether an error
// occurred, which is a boolean; and an array of error message strings
// with details on errors encountered. If no error occured then message is
// empty array with length 0.
try{
if(djConfig.isDebug){
this.printURLs();
}
this.refreshing = true;
if(this.versionURL){
this._getVersionInfo(function(oldVersion, newVersion, justDebugged){
//console.warn("getVersionInfo, oldVersion="+oldVersion+", newVersion="+newVersion
// + ", justDebugged="+justDebugged+", isDebug="+djConfig.isDebug);
if(djConfig.isDebug || !newVersion || justDebugged
|| !oldVersion || oldVersion != newVersion){
console.warn("Refreshing offline file list");
this._doRefresh(callback, newVersion);
}else{
console.warn("No need to refresh offline file list");
callback(false, []);
}
});
}else{
console.warn("Refreshing offline file list");
this._doRefresh(callback);
}
}catch(e){
this.refreshing = false;
// can't refresh files -- core operation --
// fail fast
dojox.off.coreOpFailed = true;
dojox.off.enabled = false;
dojox.off.onFrameworkEvent("coreOperationFailed");
}
},
abortRefresh: function(){
// summary:
// For advanced usage; most developers can ignore this.
// Aborts and cancels a refresh.
if(!this.refreshing){
return;
}
this._store.abortCapture(this._cancelID);
this.refreshing = false;
},
_slurp: function(){
if(!this._doSlurp){
return;
}
var handleUrl = dojo.hitch(this, function(url){
if(this._sameLocation(url)){
this.cache(url);
}
});
handleUrl(window.location.href);
dojo.query("script").forEach(function(i){
try{
handleUrl(i.getAttribute("src"));
}catch(exp){
//console.debug("dojox.off.files.slurp 'script' error: "
// + exp.message||exp);
}
});
dojo.query("link").forEach(function(i){
try{
if(!i.getAttribute("rel")
|| i.getAttribute("rel").toLowerCase() != "stylesheet"){
return;
}
handleUrl(i.getAttribute("href"));
}catch(exp){
//console.debug("dojox.off.files.slurp 'link' error: "
// + exp.message||exp);
}
});
dojo.query("img").forEach(function(i){
try{
handleUrl(i.getAttribute("src"));
}catch(exp){
//console.debug("dojox.off.files.slurp 'img' error: "
// + exp.message||exp);
}
});
dojo.query("a").forEach(function(i){
try{
handleUrl(i.getAttribute("href"));
}catch(exp){
//console.debug("dojox.off.files.slurp 'a' error: "
// + exp.message||exp);
}
});
// FIXME: handle 'object' and 'embed' tag
// parse our style sheets for inline URLs and imports
dojo.forEach(document.styleSheets, function(sheet){
try{
if(sheet.cssRules){ // Firefox
dojo.forEach(sheet.cssRules, function(rule){
var text = rule.cssText;
if(text){
var matches = text.match(/url\(\s*([^\) ]*)\s*\)/i);
if(!matches){
return;
}
for(var i = 1; i < matches.length; i++){
handleUrl(matches[i])
}
}
});
}else if(sheet.cssText){ // IE
var matches;
var text = sheet.cssText.toString();
// unfortunately, using RegExp.exec seems to be flakey
// for looping across multiple lines on IE using the
// global flag, so we have to simulate it
var lines = text.split(/\f|\r|\n/);
for(var i = 0; i < lines.length; i++){
matches = lines[i].match(/url\(\s*([^\) ]*)\s*\)/i);
if(matches && matches.length){
handleUrl(matches[1]);
}
}
}
}catch(exp){
//console.debug("dojox.off.files.slurp stylesheet parse error: "
// + exp.message||exp);
}
});
//this.printURLs();
},
_sameLocation: function(url){
if(!url){ return false; }
// filter out anchors
if(url.length && url.charAt(0) == "#"){
return false;
}
// FIXME: dojo._Url should be made public;
// it's functionality is very useful for
// parsing URLs correctly, which is hard to
// do right
url = new dojo._Url(url);
// totally relative -- ../../someFile.html
if(!url.scheme && !url.port && !url.host){
return true;
}
// scheme relative with port specified -- brad.com:8080
if(!url.scheme && url.host && url.port
&& window.location.hostname == url.host
&& window.location.port == url.port){
return true;
}
// scheme relative with no-port specified -- brad.com
if(!url.scheme && url.host && !url.port
&& window.location.hostname == url.host
&& window.location.port == 80){
return true;
}
// else we have everything
return window.location.protocol == (url.scheme + ":")
&& window.location.hostname == url.host
&& (window.location.port == url.port || !window.location.port && !url.port);
},
_trimAnchor: function(url){
return url.replace(/\#.*$/, "");
},
_doRefresh: function(callback, newVersion){
// get our local server
var localServer;
try{
localServer = google.gears.factory.create("beta.localserver", "1.0");
}catch(exp){
dojo.setObject("google.gears.denied", true);
dojox.off.onFrameworkEvent("coreOperationFailed");
throw "Google Gears must be allowed to run";
}
var storeName = "dot_store_"
+ window.location.href.replace(/[^0-9A-Za-z_]/g, "_");
// refresh everything by simply removing
// any older stores
localServer.removeStore(storeName);
// open/create the resource store
localServer.openStore(storeName);
var store = localServer.createStore(storeName);
this._store = store;
 
// add our list of files to capture
var self = this;
this._currentFileIndex = 0;
this._cancelID = store.capture(this.listOfURLs, function(url, success, captureId){
//console.debug("store.capture, url="+url+", success="+success);
if(!success && self.refreshing){
self._cancelID = null;
self.refreshing = false;
var errorMsgs = [];
errorMsgs.push("Unable to capture: " + url);
callback(true, errorMsgs);
return;
}else if(success){
self._currentFileIndex++;
}
if(success && self._currentFileIndex >= self.listOfURLs.length){
self._cancelID = null;
self.refreshing = false;
if(newVersion){
dojox.storage.put("oldVersion", newVersion, null,
dojox.off.STORAGE_NAMESPACE);
}
dojox.storage.put("justDebugged", djConfig.isDebug, null,
dojox.off.STORAGE_NAMESPACE);
callback(false, []);
}
});
},
_getVersionInfo: function(callback){
var justDebugged = dojox.storage.get("justDebugged",
dojox.off.STORAGE_NAMESPACE);
var oldVersion = dojox.storage.get("oldVersion",
dojox.off.STORAGE_NAMESPACE);
var newVersion = null;
callback = dojo.hitch(this, callback);
dojo.xhrGet({
url: this.versionURL + "?browserbust=" + new Date().getTime(),
timeout: 5 * 1000,
handleAs: "javascript",
error: function(err){
//console.warn("dojox.off.files._getVersionInfo, err=",err);
dojox.storage.remove("oldVersion", dojox.off.STORAGE_NAMESPACE);
dojox.storage.remove("justDebugged", dojox.off.STORAGE_NAMESPACE);
callback(oldVersion, newVersion, justDebugged);
},
load: function(data){
//console.warn("dojox.off.files._getVersionInfo, load=",data);
// some servers incorrectly return 404's
// as a real page
if(data){
newVersion = data;
}
callback(oldVersion, newVersion, justDebugged);
}
});
}
}
 
}
/trunk/api/js/dojo1.0/dojox/off/offline.js
New file
0,0 → 1,20
/*
Copyright (c) 2004-2007, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/book/dojo-book-0-9/introduction/licensing
*/
 
/*
This is a compiled version of Dojo, built for deployment and not for
development. To get an editable version, please visit:
 
http://dojotoolkit.org
 
for documentation and information on getting the source.
*/
 
if(!dojo._hasResource["dojox.storage.Provider"]){dojo._hasResource["dojox.storage.Provider"]=true;dojo.provide("dojox.storage.Provider");dojo.declare("dojox.storage.Provider",null,{constructor:function(){},SUCCESS:"success",FAILED:"failed",PENDING:"pending",SIZE_NOT_AVAILABLE:"Size not available",SIZE_NO_LIMIT:"No size limit",DEFAULT_NAMESPACE:"default",onHideSettingsUI:null,initialize:function(){console.warn("dojox.storage.initialize not implemented");},isAvailable:function(){console.warn("dojox.storage.isAvailable not implemented");},put:function(_1,_2,_3,_4){console.warn("dojox.storage.put not implemented");},get:function(_5,_6){console.warn("dojox.storage.get not implemented");},hasKey:function(_7,_8){return (this.get(_7)!=null);},getKeys:function(_9){console.warn("dojox.storage.getKeys not implemented");},clear:function(_a){console.warn("dojox.storage.clear not implemented");},remove:function(_b,_c){console.warn("dojox.storage.remove not implemented");},getNamespaces:function(){console.warn("dojox.storage.getNamespaces not implemented");},isPermanent:function(){console.warn("dojox.storage.isPermanent not implemented");},getMaximumSize:function(){console.warn("dojox.storage.getMaximumSize not implemented");},putMultiple:function(_d,_e,_f,_10){console.warn("dojox.storage.putMultiple not implemented");},getMultiple:function(_11,_12){console.warn("dojox.storage.getMultiple not implemented");},removeMultiple:function(_13,_14){console.warn("dojox.storage.remove not implemented");},isValidKeyArray:function(_15){if(_15===null||typeof _15==="undefined"||!_15 instanceof Array){return false;}for(var k=0;k<_15.length;k++){if(!this.isValidKey(_15[k])){return false;}}return true;},hasSettingsUI:function(){return false;},showSettingsUI:function(){console.warn("dojox.storage.showSettingsUI not implemented");},hideSettingsUI:function(){console.warn("dojox.storage.hideSettingsUI not implemented");},isValidKey:function(_17){if((_17==null)||(typeof _17=="undefined")){return false;}return /^[0-9A-Za-z_]*$/.test(_17);},getResourceList:function(){return [];}});}if(!dojo._hasResource["dojox.storage.manager"]){dojo._hasResource["dojox.storage.manager"]=true;dojo.provide("dojox.storage.manager");dojox.storage.manager=new function(){this.currentProvider=null;this.available=false;this._initialized=false;this._providers=[];this._onLoadListeners=[];this.initialize=function(){this.autodetect();};this.register=function(_18,_19){this._providers[this._providers.length]=_19;this._providers[_18]=_19;};this.setProvider=function(_1a){};this.autodetect=function(){if(this._initialized){return;}var _1b=djConfig["forceStorageProvider"]||false;var _1c;for(var i=0;i<this._providers.length;i++){_1c=this._providers[i];if(_1b==_1c.declaredClass){_1c.isAvailable();break;}else{if(_1c.isAvailable()){break;}}}if(!_1c){this._initialized=true;this.available=false;this.currentProvider=null;console.warn("No storage provider found for this platform");this.loaded();return;}this.currentProvider=_1c;dojo.mixin(dojox.storage,this.currentProvider);dojox.storage.initialize();this._initialized=true;this.available=true;};this.isAvailable=function(){return this.available;};this.addOnLoad=function(_1e){this._onLoadListeners.push(_1e);if(this.isInitialized()){this._fireLoaded();}};this.removeOnLoad=function(_1f){for(var i=0;i<this._onLoadListeners.length;i++){if(_1f==this._onLoadListeners[i]){this._onLoadListeners=this._onLoadListeners.splice(i,1);break;}}};this.isInitialized=function(){if(this.currentProvider!=null&&this.currentProvider.declaredClass=="dojox.storage.FlashStorageProvider"&&dojox.flash.ready==false){return false;}else{return this._initialized;}};this.supportsProvider=function(_21){try{var _22=eval("new "+_21+"()");var _23=_22.isAvailable();if(!_23){return false;}return _23;}catch(e){return false;}};this.getProvider=function(){return this.currentProvider;};this.loaded=function(){this._fireLoaded();};this._fireLoaded=function(){dojo.forEach(this._onLoadListeners,function(i){try{i();}catch(e){console.debug(e);}});};this.getResourceList=function(){var _25=[];dojo.forEach(dojox.storage.manager._providers,function(_26){_25=_25.concat(_26.getResourceList());});return _25;};};}if(!dojo._hasResource["dojox._sql._crypto"]){dojo._hasResource["dojox._sql._crypto"]=true;dojo.provide("dojox._sql._crypto");dojo.mixin(dojox._sql._crypto,{_POOL_SIZE:100,encrypt:function(_27,_28,_29){this._initWorkerPool();var msg={plaintext:_27,password:_28};msg=dojo.toJson(msg);msg="encr:"+String(msg);this._assignWork(msg,_29);},decrypt:function(_2b,_2c,_2d){this._initWorkerPool();var msg={ciphertext:_2b,password:_2c};msg=dojo.toJson(msg);msg="decr:"+String(msg);this._assignWork(msg,_2d);},_initWorkerPool:function(){if(!this._manager){try{this._manager=google.gears.factory.create("beta.workerpool","1.0");this._unemployed=[];this._employed={};this._handleMessage=[];var _2f=this;this._manager.onmessage=function(msg,_31){var _32=_2f._employed["_"+_31];_2f._employed["_"+_31]=undefined;_2f._unemployed.push("_"+_31);if(_2f._handleMessage.length){var _33=_2f._handleMessage.shift();_2f._assignWork(_33.msg,_33.callback);}_32(msg);};var _34="function _workerInit(){"+"gearsWorkerPool.onmessage = "+String(this._workerHandler)+";"+"}";var _35=_34+" _workerInit();";for(var i=0;i<this._POOL_SIZE;i++){this._unemployed.push("_"+this._manager.createWorker(_35));}}catch(exp){throw exp.message||exp;}}},_assignWork:function(msg,_38){if(!this._handleMessage.length&&this._unemployed.length){var _39=this._unemployed.shift().substring(1);this._employed["_"+_39]=_38;this._manager.sendMessage(msg,_39);}else{this._handleMessage={msg:msg,callback:_38};}},_workerHandler:function(msg,_3b){var _3c=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22];var _3d=[[0,0,0,0],[1,0,0,0],[2,0,0,0],[4,0,0,0],[8,0,0,0],[16,0,0,0],[32,0,0,0],[64,0,0,0],[128,0,0,0],[27,0,0,0],[54,0,0,0]];function Cipher(_3e,w){var Nb=4;var Nr=w.length/Nb-1;var _42=[[],[],[],[]];for(var i=0;i<4*Nb;i++){_42[i%4][Math.floor(i/4)]=_3e[i];}_42=AddRoundKey(_42,w,0,Nb);for(var _44=1;_44<Nr;_44++){_42=SubBytes(_42,Nb);_42=ShiftRows(_42,Nb);_42=MixColumns(_42,Nb);_42=AddRoundKey(_42,w,_44,Nb);}_42=SubBytes(_42,Nb);_42=ShiftRows(_42,Nb);_42=AddRoundKey(_42,w,Nr,Nb);var _45=new Array(4*Nb);for(var i=0;i<4*Nb;i++){_45[i]=_42[i%4][Math.floor(i/4)];}return _45;};function SubBytes(s,Nb){for(var r=0;r<4;r++){for(var c=0;c<Nb;c++){s[r][c]=_3c[s[r][c]];}}return s;};function ShiftRows(s,Nb){var t=new Array(4);for(var r=1;r<4;r++){for(var c=0;c<4;c++){t[c]=s[r][(c+r)%Nb];}for(var c=0;c<4;c++){s[r][c]=t[c];}}return s;};function MixColumns(s,Nb){for(var c=0;c<4;c++){var a=new Array(4);var b=new Array(4);for(var i=0;i<4;i++){a[i]=s[i][c];b[i]=s[i][c]&128?s[i][c]<<1^283:s[i][c]<<1;}s[0][c]=b[0]^a[1]^b[1]^a[2]^a[3];s[1][c]=a[0]^b[1]^a[2]^b[2]^a[3];s[2][c]=a[0]^a[1]^b[2]^a[3]^b[3];s[3][c]=a[0]^b[0]^a[1]^a[2]^b[3];}return s;};function AddRoundKey(_55,w,rnd,Nb){for(var r=0;r<4;r++){for(var c=0;c<Nb;c++){_55[r][c]^=w[rnd*4+c][r];}}return _55;};function KeyExpansion(key){var Nb=4;var Nk=key.length/4;var Nr=Nk+6;var w=new Array(Nb*(Nr+1));var _60=new Array(4);for(var i=0;i<Nk;i++){var r=[key[4*i],key[4*i+1],key[4*i+2],key[4*i+3]];w[i]=r;}for(var i=Nk;i<(Nb*(Nr+1));i++){w[i]=new Array(4);for(var t=0;t<4;t++){_60[t]=w[i-1][t];}if(i%Nk==0){_60=SubWord(RotWord(_60));for(var t=0;t<4;t++){_60[t]^=_3d[i/Nk][t];}}else{if(Nk>6&&i%Nk==4){_60=SubWord(_60);}}for(var t=0;t<4;t++){w[i][t]=w[i-Nk][t]^_60[t];}}return w;};function SubWord(w){for(var i=0;i<4;i++){w[i]=_3c[w[i]];}return w;};function RotWord(w){w[4]=w[0];for(var i=0;i<4;i++){w[i]=w[i+1];}return w;};function AESEncryptCtr(_68,_69,_6a){if(!(_6a==128||_6a==192||_6a==256)){return "";}var _6b=_6a/8;var _6c=new Array(_6b);for(var i=0;i<_6b;i++){_6c[i]=_69.charCodeAt(i)&255;}var key=Cipher(_6c,KeyExpansion(_6c));key=key.concat(key.slice(0,_6b-16));var _6f=16;var _70=new Array(_6f);var _71=(new Date()).getTime();for(var i=0;i<4;i++){_70[i]=(_71>>>i*8)&255;}for(var i=0;i<4;i++){_70[i+4]=(_71/4294967296>>>i*8)&255;}var _72=KeyExpansion(key);var _73=Math.ceil(_68.length/_6f);var _74=new Array(_73);for(var b=0;b<_73;b++){for(var c=0;c<4;c++){_70[15-c]=(b>>>c*8)&255;}for(var c=0;c<4;c++){_70[15-c-4]=(b/4294967296>>>c*8);}var _77=Cipher(_70,_72);var _78=b<_73-1?_6f:(_68.length-1)%_6f+1;var ct="";for(var i=0;i<_78;i++){var _7a=_68.charCodeAt(b*_6f+i);var _7b=_7a^_77[i];ct+=String.fromCharCode(_7b);}_74[b]=escCtrlChars(ct);}var _7c="";for(var i=0;i<8;i++){_7c+=String.fromCharCode(_70[i]);}_7c=escCtrlChars(_7c);return _7c+"-"+_74.join("-");};function AESDecryptCtr(_7d,_7e,_7f){if(!(_7f==128||_7f==192||_7f==256)){return "";}var _80=_7f/8;var _81=new Array(_80);for(var i=0;i<_80;i++){_81[i]=_7e.charCodeAt(i)&255;}var _83=KeyExpansion(_81);var key=Cipher(_81,_83);key=key.concat(key.slice(0,_80-16));var _85=KeyExpansion(key);_7d=_7d.split("-");var _86=16;var _87=new Array(_86);var _88=unescCtrlChars(_7d[0]);for(var i=0;i<8;i++){_87[i]=_88.charCodeAt(i);}var _89=new Array(_7d.length-1);for(var b=1;b<_7d.length;b++){for(var c=0;c<4;c++){_87[15-c]=((b-1)>>>c*8)&255;}for(var c=0;c<4;c++){_87[15-c-4]=((b/4294967296-1)>>>c*8)&255;}var _8c=Cipher(_87,_85);_7d[b]=unescCtrlChars(_7d[b]);var pt="";for(var i=0;i<_7d[b].length;i++){var _8e=_7d[b].charCodeAt(i);var _8f=_8e^_8c[i];pt+=String.fromCharCode(_8f);}_89[b-1]=pt;}return _89.join("");};function escCtrlChars(str){return str.replace(/[\0\t\n\v\f\r\xa0!-]/g,function(c){return "!"+c.charCodeAt(0)+"!";});};function unescCtrlChars(str){return str.replace(/!\d\d?\d?!/g,function(c){return String.fromCharCode(c.slice(1,-1));});};function encrypt(_94,_95){return AESEncryptCtr(_94,_95,256);};function decrypt(_96,_97){return AESDecryptCtr(_96,_97,256);};var cmd=msg.substr(0,4);var arg=msg.substr(5);if(cmd=="encr"){arg=eval("("+arg+")");var _9a=arg.plaintext;var _9b=arg.password;var _9c=encrypt(_9a,_9b);gearsWorkerPool.sendMessage(String(_9c),_3b);}else{if(cmd=="decr"){arg=eval("("+arg+")");var _9d=arg.ciphertext;var _9b=arg.password;var _9c=decrypt(_9d,_9b);gearsWorkerPool.sendMessage(String(_9c),_3b);}}}});}if(!dojo._hasResource["dojox._sql.common"]){dojo._hasResource["dojox._sql.common"]=true;dojo.provide("dojox._sql.common");dojox.sql=new Function("return dojox.sql._exec(arguments);");dojo.mixin(dojox.sql,{dbName:null,debug:(dojo.exists("dojox.sql.debug")?dojox.sql.debug:false),open:function(_9e){if(this._dbOpen&&(!_9e||_9e==this.dbName)){return;}if(!this.dbName){this.dbName="dot_store_"+window.location.href.replace(/[^0-9A-Za-z_]/g,"_");}if(!_9e){_9e=this.dbName;}try{this._initDb();this.db.open(_9e);this._dbOpen=true;}catch(exp){throw exp.message||exp;}},close:function(_9f){if(dojo.isIE){return;}if(!this._dbOpen&&(!_9f||_9f==this.dbName)){return;}if(!_9f){_9f=this.dbName;}try{this.db.close(_9f);this._dbOpen=false;}catch(exp){throw exp.message||exp;}},_exec:function(_a0){try{this._initDb();if(!this._dbOpen){this.open();this._autoClose=true;}var sql=null;var _a2=null;var _a3=null;var _a4=dojo._toArray(_a0);sql=_a4.splice(0,1)[0];if(this._needsEncrypt(sql)||this._needsDecrypt(sql)){_a2=_a4.splice(_a4.length-1,1)[0];_a3=_a4.splice(_a4.length-1,1)[0];}if(this.debug){this._printDebugSQL(sql,_a4);}if(this._needsEncrypt(sql)){var _a5=new dojox.sql._SQLCrypto("encrypt",sql,_a3,_a4,_a2);return;}else{if(this._needsDecrypt(sql)){var _a5=new dojox.sql._SQLCrypto("decrypt",sql,_a3,_a4,_a2);return;}}var rs=this.db.execute(sql,_a4);rs=this._normalizeResults(rs);if(this._autoClose){this.close();}return rs;}catch(exp){exp=exp.message||exp;console.debug("SQL Exception: "+exp);if(this._autoClose){try{this.close();}catch(e){console.debug("Error closing database: "+e.message||e);}}throw exp;}},_initDb:function(){if(!this.db){try{this.db=google.gears.factory.create("beta.database","1.0");}catch(exp){dojo.setObject("google.gears.denied",true);dojox.off.onFrameworkEvent("coreOperationFailed");throw "Google Gears must be allowed to run";}}},_printDebugSQL:function(sql,_a8){var msg="dojox.sql(\""+sql+"\"";for(var i=0;i<_a8.length;i++){if(typeof _a8[i]=="string"){msg+=", \""+_a8[i]+"\"";}else{msg+=", "+_a8[i];}}msg+=")";console.debug(msg);},_normalizeResults:function(rs){var _ac=[];if(!rs){return [];}while(rs.isValidRow()){var row={};for(var i=0;i<rs.fieldCount();i++){var _af=rs.fieldName(i);var _b0=rs.field(i);row[_af]=_b0;}_ac.push(row);rs.next();}rs.close();return _ac;},_needsEncrypt:function(sql){return /encrypt\([^\)]*\)/i.test(sql);},_needsDecrypt:function(sql){return /decrypt\([^\)]*\)/i.test(sql);}});dojo.declare("dojox.sql._SQLCrypto",null,{constructor:function(_b3,sql,_b5,_b6,_b7){if(_b3=="encrypt"){this._execEncryptSQL(sql,_b5,_b6,_b7);}else{this._execDecryptSQL(sql,_b5,_b6,_b7);}},_execEncryptSQL:function(sql,_b9,_ba,_bb){var _bc=this._stripCryptoSQL(sql);var _bd=this._flagEncryptedArgs(sql,_ba);var _be=this;this._encrypt(_bc,_b9,_ba,_bd,function(_bf){var _c0=false;var _c1=[];var exp=null;try{_c1=dojox.sql.db.execute(_bc,_bf);}catch(execError){_c0=true;exp=execError.message||execError;}if(exp!=null){if(dojox.sql._autoClose){try{dojox.sql.close();}catch(e){}}_bb(null,true,exp.toString());return;}_c1=dojox.sql._normalizeResults(_c1);if(dojox.sql._autoClose){dojox.sql.close();}if(dojox.sql._needsDecrypt(sql)){var _c3=_be._determineDecryptedColumns(sql);_be._decrypt(_c1,_c3,_b9,function(_c4){_bb(_c4,false,null);});}else{_bb(_c1,false,null);}});},_execDecryptSQL:function(sql,_c6,_c7,_c8){var _c9=this._stripCryptoSQL(sql);var _ca=this._determineDecryptedColumns(sql);var _cb=false;var _cc=[];var exp=null;try{_cc=dojox.sql.db.execute(_c9,_c7);}catch(execError){_cb=true;exp=execError.message||execError;}if(exp!=null){if(dojox.sql._autoClose){try{dojox.sql.close();}catch(e){}}_c8(_cc,true,exp.toString());return;}_cc=dojox.sql._normalizeResults(_cc);if(dojox.sql._autoClose){dojox.sql.close();}this._decrypt(_cc,_ca,_c6,function(_ce){_c8(_ce,false,null);});},_encrypt:function(sql,_d0,_d1,_d2,_d3){this._totalCrypto=0;this._finishedCrypto=0;this._finishedSpawningCrypto=false;this._finalArgs=_d1;for(var i=0;i<_d1.length;i++){if(_d2[i]){var _d5=_d1[i];var _d6=i;this._totalCrypto++;dojox._sql._crypto.encrypt(_d5,_d0,dojo.hitch(this,function(_d7){this._finalArgs[_d6]=_d7;this._finishedCrypto++;if(this._finishedCrypto>=this._totalCrypto&&this._finishedSpawningCrypto){_d3(this._finalArgs);}}));}}this._finishedSpawningCrypto=true;},_decrypt:function(_d8,_d9,_da,_db){this._totalCrypto=0;this._finishedCrypto=0;this._finishedSpawningCrypto=false;this._finalResultSet=_d8;for(var i=0;i<_d8.length;i++){var row=_d8[i];for(var _de in row){if(_d9=="*"||_d9[_de]){this._totalCrypto++;var _df=row[_de];this._decryptSingleColumn(_de,_df,_da,i,function(_e0){_db(_e0);});}}}this._finishedSpawningCrypto=true;},_stripCryptoSQL:function(sql){sql=sql.replace(/DECRYPT\(\*\)/ig,"*");var _e2=sql.match(/ENCRYPT\([^\)]*\)/ig);if(_e2!=null){for(var i=0;i<_e2.length;i++){var _e4=_e2[i];var _e5=_e4.match(/ENCRYPT\(([^\)]*)\)/i)[1];sql=sql.replace(_e4,_e5);}}_e2=sql.match(/DECRYPT\([^\)]*\)/ig);if(_e2!=null){for(var i=0;i<_e2.length;i++){var _e6=_e2[i];var _e7=_e6.match(/DECRYPT\(([^\)]*)\)/i)[1];sql=sql.replace(_e6,_e7);}}return sql;},_flagEncryptedArgs:function(sql,_e9){var _ea=new RegExp(/([\"][^\"]*\?[^\"]*[\"])|([\'][^\']*\?[^\']*[\'])|(\?)/ig);var _eb;var _ec=0;var _ed=[];while((_eb=_ea.exec(sql))!=null){var _ee=RegExp.lastMatch+"";if(/^[\"\']/.test(_ee)){continue;}var _ef=false;if(/ENCRYPT\([^\)]*$/i.test(RegExp.leftContext)){_ef=true;}_ed[_ec]=_ef;_ec++;}return _ed;},_determineDecryptedColumns:function(sql){var _f1={};if(/DECRYPT\(\*\)/i.test(sql)){_f1="*";}else{var _f2=/DECRYPT\((?:\s*\w*\s*\,?)*\)/ig;var _f3;while(_f3=_f2.exec(sql)){var _f4=new String(RegExp.lastMatch);var _f5=_f4.replace(/DECRYPT\(/i,"");_f5=_f5.replace(/\)/,"");_f5=_f5.split(/\s*,\s*/);dojo.forEach(_f5,function(_f6){if(/\s*\w* AS (\w*)/i.test(_f6)){_f6=_f6.match(/\s*\w* AS (\w*)/i)[1];}_f1[_f6]=true;});}}return _f1;},_decryptSingleColumn:function(_f7,_f8,_f9,_fa,_fb){dojox._sql._crypto.decrypt(_f8,_f9,dojo.hitch(this,function(_fc){this._finalResultSet[_fa][_f7]=_fc;this._finishedCrypto++;if(this._finishedCrypto>=this._totalCrypto&&this._finishedSpawningCrypto){_fb(this._finalResultSet);}}));}});}if(!dojo._hasResource["dojox.sql"]){dojo._hasResource["dojox.sql"]=true;dojo.provide("dojox.sql");}if(!dojo._hasResource["dojox.storage.GearsStorageProvider"]){dojo._hasResource["dojox.storage.GearsStorageProvider"]=true;dojo.provide("dojox.storage.GearsStorageProvider");if(dojo.isGears){(function(){dojo.declare("dojox.storage.GearsStorageProvider",dojox.storage.Provider,{constructor:function(){},TABLE_NAME:"__DOJO_STORAGE",initialized:false,_available:null,initialize:function(){if(djConfig["disableGearsStorage"]==true){return;}this.TABLE_NAME="__DOJO_STORAGE";try{dojox.sql("CREATE TABLE IF NOT EXISTS "+this.TABLE_NAME+"( "+" namespace TEXT, "+" key TEXT, "+" value TEXT "+")");dojox.sql("CREATE UNIQUE INDEX IF NOT EXISTS namespace_key_index"+" ON "+this.TABLE_NAME+" (namespace, key)");}catch(e){console.debug("dojox.storage.GearsStorageProvider.initialize:",e);this.initialized=false;dojox.storage.manager.loaded();return;}this.initialized=true;dojox.storage.manager.loaded();},isAvailable:function(){return this._available=dojo.isGears;},put:function(key,_fe,_ff,_100){if(this.isValidKey(key)==false){throw new Error("Invalid key given: "+key);}_100=_100||this.DEFAULT_NAMESPACE;if(dojo.isString(_fe)){_fe="string:"+_fe;}else{_fe=dojo.toJson(_fe);}try{dojox.sql("DELETE FROM "+this.TABLE_NAME+" WHERE namespace = ? AND key = ?",_100,key);dojox.sql("INSERT INTO "+this.TABLE_NAME+" VALUES (?, ?, ?)",_100,key,_fe);}catch(e){console.debug("dojox.storage.GearsStorageProvider.put:",e);_ff(this.FAILED,key,e.toString());return;}if(_ff){_ff(dojox.storage.SUCCESS,key,null);}},get:function(key,_102){if(this.isValidKey(key)==false){throw new Error("Invalid key given: "+key);}_102=_102||this.DEFAULT_NAMESPACE;var _103=dojox.sql("SELECT * FROM "+this.TABLE_NAME+" WHERE namespace = ? AND "+" key = ?",_102,key);if(!_103.length){return null;}else{_103=_103[0].value;}if(dojo.isString(_103)&&(/^string:/.test(_103))){_103=_103.substring("string:".length);}else{_103=dojo.fromJson(_103);}return _103;},getNamespaces:function(){var _104=[dojox.storage.DEFAULT_NAMESPACE];var rs=dojox.sql("SELECT namespace FROM "+this.TABLE_NAME+" DESC GROUP BY namespace");for(var i=0;i<rs.length;i++){if(rs[i].namespace!=dojox.storage.DEFAULT_NAMESPACE){_104.push(rs[i].namespace);}}return _104;},getKeys:function(_107){_107=_107||this.DEFAULT_NAMESPACE;if(this.isValidKey(_107)==false){throw new Error("Invalid namespace given: "+_107);}var rs=dojox.sql("SELECT key FROM "+this.TABLE_NAME+" WHERE namespace = ?",_107);var _109=[];for(var i=0;i<rs.length;i++){_109.push(rs[i].key);}return _109;},clear:function(_10b){if(this.isValidKey(_10b)==false){throw new Error("Invalid namespace given: "+_10b);}_10b=_10b||this.DEFAULT_NAMESPACE;dojox.sql("DELETE FROM "+this.TABLE_NAME+" WHERE namespace = ?",_10b);},remove:function(key,_10d){_10d=_10d||this.DEFAULT_NAMESPACE;dojox.sql("DELETE FROM "+this.TABLE_NAME+" WHERE namespace = ? AND"+" key = ?",_10d,key);},putMultiple:function(keys,_10f,_110,_111){if(this.isValidKeyArray(keys)===false||!_10f instanceof Array||keys.length!=_10f.length){throw new Error("Invalid arguments: keys = ["+keys+"], values = ["+_10f+"]");}if(_111==null||typeof _111=="undefined"){_111=dojox.storage.DEFAULT_NAMESPACE;}if(this.isValidKey(_111)==false){throw new Error("Invalid namespace given: "+_111);}this._statusHandler=_110;try{dojox.sql.open();dojox.sql.db.execute("BEGIN TRANSACTION");var _112="REPLACE INTO "+this.TABLE_NAME+" VALUES (?, ?, ?)";for(var i=0;i<keys.length;i++){var _114=_10f[i];if(dojo.isString(_114)){_114="string:"+_114;}else{_114=dojo.toJson(_114);}dojox.sql.db.execute(_112,[_111,keys[i],_114]);}dojox.sql.db.execute("COMMIT TRANSACTION");dojox.sql.close();}catch(e){console.debug("dojox.storage.GearsStorageProvider.putMultiple:",e);if(_110){_110(this.FAILED,keys,e.toString());}return;}if(_110){_110(dojox.storage.SUCCESS,key,null);}},getMultiple:function(keys,_116){if(this.isValidKeyArray(keys)===false){throw new ("Invalid key array given: "+keys);}if(_116==null||typeof _116=="undefined"){_116=dojox.storage.DEFAULT_NAMESPACE;}if(this.isValidKey(_116)==false){throw new Error("Invalid namespace given: "+_116);}var _117="SELECT * FROM "+this.TABLE_NAME+" WHERE namespace = ? AND "+" key = ?";var _118=[];for(var i=0;i<keys.length;i++){var _11a=dojox.sql(_117,_116,keys[i]);if(!_11a.length){_118[i]=null;}else{_11a=_11a[0].value;if(dojo.isString(_11a)&&(/^string:/.test(_11a))){_118[i]=_11a.substring("string:".length);}else{_118[i]=dojo.fromJson(_11a);}}}return _118;},removeMultiple:function(keys,_11c){_11c=_11c||this.DEFAULT_NAMESPACE;dojox.sql.open();dojox.sql.db.execute("BEGIN TRANSACTION");var _11d="DELETE FROM "+this.TABLE_NAME+" WHERE namespace = ? AND key = ?";for(var i=0;i<keys.length;i++){dojox.sql.db.execute(_11d,[_11c,keys[i]]);}dojox.sql.db.execute("COMMIT TRANSACTION");dojox.sql.close();},isPermanent:function(){return true;},getMaximumSize:function(){return this.SIZE_NO_LIMIT;},hasSettingsUI:function(){return false;},showSettingsUI:function(){throw new Error(this.declaredClass+" does not support a storage settings user-interface");},hideSettingsUI:function(){throw new Error(this.declaredClass+" does not support a storage settings user-interface");}});dojox.storage.manager.register("dojox.storage.GearsStorageProvider",new dojox.storage.GearsStorageProvider());dojox.storage.manager.initialize();})();}}if(!dojo._hasResource["dojox.storage._common"]){dojo._hasResource["dojox.storage._common"]=true;dojo.provide("dojox.storage._common");dojox.storage.manager.initialize();}if(!dojo._hasResource["dojox.storage"]){dojo._hasResource["dojox.storage"]=true;dojo.provide("dojox.storage");}if(!dojo._hasResource["dojox.off.files"]){dojo._hasResource["dojox.off.files"]=true;dojo.provide("dojox.off.files");dojox.off.files={versionURL:"version.js",listOfURLs:[],refreshing:false,_cancelID:null,_error:false,_errorMessages:[],_currentFileIndex:0,_store:null,_doSlurp:false,slurp:function(){this._doSlurp=true;},cache:function(_11f){if(dojo.isString(_11f)){var url=this._trimAnchor(_11f+"");if(!this.isAvailable(url)){this.listOfURLs.push(url);}}else{if(_11f instanceof dojo._Url){var url=this._trimAnchor(_11f.uri);if(!this.isAvailable(url)){this.listOfURLs.push(url);}}else{dojo.forEach(_11f,function(url){url=this._trimAnchor(url);if(!this.isAvailable(url)){this.listOfURLs.push(url);}},this);}}},printURLs:function(){console.debug("The following URLs are cached for offline use:");dojo.forEach(this.listOfURLs,function(i){console.debug(i);});},remove:function(url){for(var i=0;i<this.listOfURLs.length;i++){if(this.listOfURLs[i]==url){this.listOfURLs=this.listOfURLs.splice(i,1);break;}}},isAvailable:function(url){for(var i=0;i<this.listOfURLs.length;i++){if(this.listOfURLs[i]==url){return true;}}return false;},refresh:function(_127){try{if(djConfig.isDebug){this.printURLs();}this.refreshing=true;if(this.versionURL){this._getVersionInfo(function(_128,_129,_12a){if(djConfig.isDebug||!_129||_12a||!_128||_128!=_129){console.warn("Refreshing offline file list");this._doRefresh(_127,_129);}else{console.warn("No need to refresh offline file list");_127(false,[]);}});}else{console.warn("Refreshing offline file list");this._doRefresh(_127);}}catch(e){this.refreshing=false;dojox.off.coreOpFailed=true;dojox.off.enabled=false;dojox.off.onFrameworkEvent("coreOperationFailed");}},abortRefresh:function(){if(!this.refreshing){return;}this._store.abortCapture(this._cancelID);this.refreshing=false;},_slurp:function(){if(!this._doSlurp){return;}var _12b=dojo.hitch(this,function(url){if(this._sameLocation(url)){this.cache(url);}});_12b(window.location.href);dojo.query("script").forEach(function(i){try{_12b(i.getAttribute("src"));}catch(exp){}});dojo.query("link").forEach(function(i){try{if(!i.getAttribute("rel")||i.getAttribute("rel").toLowerCase()!="stylesheet"){return;}_12b(i.getAttribute("href"));}catch(exp){}});dojo.query("img").forEach(function(i){try{_12b(i.getAttribute("src"));}catch(exp){}});dojo.query("a").forEach(function(i){try{_12b(i.getAttribute("href"));}catch(exp){}});dojo.forEach(document.styleSheets,function(_131){try{if(_131.cssRules){dojo.forEach(_131.cssRules,function(rule){var text=rule.cssText;if(text){var _134=text.match(/url\(\s*([^\) ]*)\s*\)/i);if(!_134){return;}for(var i=1;i<_134.length;i++){_12b(_134[i]);}}});}else{if(_131.cssText){var _136;var text=_131.cssText.toString();var _138=text.split(/\f|\r|\n/);for(var i=0;i<_138.length;i++){_136=_138[i].match(/url\(\s*([^\) ]*)\s*\)/i);if(_136&&_136.length){_12b(_136[1]);}}}}}catch(exp){}});},_sameLocation:function(url){if(!url){return false;}if(url.length&&url.charAt(0)=="#"){return false;}url=new dojo._Url(url);if(!url.scheme&&!url.port&&!url.host){return true;}if(!url.scheme&&url.host&&url.port&&window.location.hostname==url.host&&window.location.port==url.port){return true;}if(!url.scheme&&url.host&&!url.port&&window.location.hostname==url.host&&window.location.port==80){return true;}return window.location.protocol==(url.scheme+":")&&window.location.hostname==url.host&&(window.location.port==url.port||!window.location.port&&!url.port);},_trimAnchor:function(url){return url.replace(/\#.*$/,"");},_doRefresh:function(_13c,_13d){var _13e;try{_13e=google.gears.factory.create("beta.localserver","1.0");}catch(exp){dojo.setObject("google.gears.denied",true);dojox.off.onFrameworkEvent("coreOperationFailed");throw "Google Gears must be allowed to run";}var _13f="dot_store_"+window.location.href.replace(/[^0-9A-Za-z_]/g,"_");_13e.removeStore(_13f);_13e.openStore(_13f);var _140=_13e.createStore(_13f);this._store=_140;var self=this;this._currentFileIndex=0;this._cancelID=_140.capture(this.listOfURLs,function(url,_143,_144){if(!_143&&self.refreshing){self._cancelID=null;self.refreshing=false;var _145=[];_145.push("Unable to capture: "+url);_13c(true,_145);return;}else{if(_143){self._currentFileIndex++;}}if(_143&&self._currentFileIndex>=self.listOfURLs.length){self._cancelID=null;self.refreshing=false;if(_13d){dojox.storage.put("oldVersion",_13d,null,dojox.off.STORAGE_NAMESPACE);}dojox.storage.put("justDebugged",djConfig.isDebug,null,dojox.off.STORAGE_NAMESPACE);_13c(false,[]);}});},_getVersionInfo:function(_146){var _147=dojox.storage.get("justDebugged",dojox.off.STORAGE_NAMESPACE);var _148=dojox.storage.get("oldVersion",dojox.off.STORAGE_NAMESPACE);var _149=null;_146=dojo.hitch(this,_146);dojo.xhrGet({url:this.versionURL+"?browserbust="+new Date().getTime(),timeout:5*1000,handleAs:"javascript",error:function(err){dojox.storage.remove("oldVersion",dojox.off.STORAGE_NAMESPACE);dojox.storage.remove("justDebugged",dojox.off.STORAGE_NAMESPACE);_146(_148,_149,_147);},load:function(data){if(data){_149=data;}_146(_148,_149,_147);}});}};}if(!dojo._hasResource["dojox.off.sync"]){dojo._hasResource["dojox.off.sync"]=true;dojo.provide("dojox.off.sync");dojo.mixin(dojox.off.sync,{isSyncing:false,cancelled:false,successful:true,details:[],error:false,actions:null,autoSync:true,onSync:function(type){},synchronize:function(){if(this.isSyncing||dojox.off.goingOnline||(!dojox.off.isOnline)){return;}this.isSyncing=true;this.successful=false;this.details=[];this.cancelled=false;this.start();},cancel:function(){if(!this.isSyncing){return;}this.cancelled=true;if(dojox.off.files.refreshing){dojox.off.files.abortRefresh();}this.onSync("cancel");},finishedDownloading:function(_14d,_14e){if(typeof _14d=="undefined"){_14d=true;}if(!_14d){this.successful=false;this.details.push(_14e);this.error=true;}this.finished();},start:function(){if(this.cancelled){this.finished();return;}this.onSync("start");this.refreshFiles();},refreshFiles:function(){if(this.cancelled){this.finished();return;}this.onSync("refreshFiles");dojox.off.files.refresh(dojo.hitch(this,function(_14f,_150){if(_14f){this.error=true;this.successful=false;for(var i=0;i<_150.length;i++){this.details.push(_150[i]);}}this.upload();}));},upload:function(){if(this.cancelled){this.finished();return;}this.onSync("upload");dojo.connect(this.actions,"onReplayFinished",this,this.download);this.actions.replay();},download:function(){if(this.cancelled){this.finished();return;}this.onSync("download");},finished:function(){this.isSyncing=false;this.successful=(!this.cancelled&&!this.error);this.onSync("finished");},_save:function(_152){this.actions._save(function(){_152();});},_load:function(_153){this.actions._load(function(){_153();});}});dojo.declare("dojox.off.sync.ActionLog",null,{entries:[],reasonHalted:null,isReplaying:false,autoSave:true,add:function(_154){if(this.isReplaying){throw "Programming error: you can not call "+"dojox.off.sync.actions.add() while "+"we are replaying an action log";}this.entries.push(_154);if(this.autoSave){this._save();}},onReplay:function(_155,_156){},length:function(){return this.entries.length;},haltReplay:function(_157){if(!this.isReplaying){return;}if(_157){this.reasonHalted=_157.toString();}if(this.autoSave){var self=this;this._save(function(){self.isReplaying=false;self.onReplayFinished();});}else{this.isReplaying=false;this.onReplayFinished();}},continueReplay:function(){if(!this.isReplaying){return;}this.entries.shift();if(!this.entries.length){if(this.autoSave){var self=this;this._save(function(){self.isReplaying=false;self.onReplayFinished();});return;}else{this.isReplaying=false;this.onReplayFinished();return;}}var _15a=this.entries[0];this.onReplay(_15a,this);},clear:function(){if(this.isReplaying){return;}this.entries=[];if(this.autoSave){this._save();}},replay:function(){if(this.isReplaying){return;}this.reasonHalted=null;if(!this.entries.length){this.onReplayFinished();return;}this.isReplaying=true;var _15b=this.entries[0];this.onReplay(_15b,this);},onReplayFinished:function(){},toString:function(){var _15c="";_15c+="[";for(var i=0;i<this.entries.length;i++){_15c+="{";for(var j in this.entries[i]){_15c+=j+": \""+this.entries[i][j]+"\"";_15c+=", ";}_15c+="}, ";}_15c+="]";return _15c;},_save:function(_15f){if(!_15f){_15f=function(){};}try{var self=this;var _161=function(_162,key,_164){if(_162==dojox.storage.FAILED){dojox.off.onFrameworkEvent("save",{status:dojox.storage.FAILED,isCoreSave:true,key:key,value:_164,namespace:dojox.off.STORAGE_NAMESPACE});_15f();}else{if(_162==dojox.storage.SUCCESS){_15f();}}};dojox.storage.put("actionlog",this.entries,_161,dojox.off.STORAGE_NAMESPACE);}catch(exp){console.debug("dojox.off.sync._save: "+exp.message||exp);dojox.off.onFrameworkEvent("save",{status:dojox.storage.FAILED,isCoreSave:true,key:"actionlog",value:this.entries,namespace:dojox.off.STORAGE_NAMESPACE});_15f();}},_load:function(_165){var _166=dojox.storage.get("actionlog",dojox.off.STORAGE_NAMESPACE);if(!_166){_166=[];}this.entries=_166;_165();}});dojox.off.sync.actions=new dojox.off.sync.ActionLog();}if(!dojo._hasResource["dojox.off._common"]){dojo._hasResource["dojox.off._common"]=true;dojo.provide("dojox.off._common");dojo.mixin(dojox.off,{isOnline:false,NET_CHECK:5,STORAGE_NAMESPACE:"_dot",enabled:true,availabilityURL:dojo.moduleUrl("dojox","off/network_check.txt"),goingOnline:false,coreOpFailed:false,doNetChecking:true,hasOfflineCache:null,browserRestart:false,_STORAGE_APP_NAME:window.location.href.replace(/[^0-9A-Za-z_]/g,"_"),_initializeCalled:false,_storageLoaded:false,_pageLoaded:false,onLoad:function(){},onNetwork:function(type){},initialize:function(){this._initializeCalled=true;if(this._storageLoaded&&this._pageLoaded){this._onLoad();}},goOffline:function(){if((dojox.off.sync.isSyncing)||(this.goingOnline)){return;}this.goingOnline=false;this.isOnline=false;},goOnline:function(_168){if(dojox.off.sync.isSyncing||dojox.off.goingOnline){return;}this.goingOnline=true;this.isOnline=false;this._isSiteAvailable(_168);},onFrameworkEvent:function(type,_16a){if(type=="save"){if(_16a.isCoreSave&&(_16a.status==dojox.storage.FAILED)){dojox.off.coreOpFailed=true;dojox.off.enabled=false;dojox.off.onFrameworkEvent("coreOperationFailed");}}else{if(type=="coreOperationFailed"){dojox.off.coreOpFailed=true;dojox.off.enabled=false;}}},_checkOfflineCacheAvailable:function(_16b){this.hasOfflineCache=dojo.isGears;_16b();},_onLoad:function(){dojox.off.files.cache(dojo.moduleUrl("dojo","dojo.js"));this._cacheDojoResources();dojox.off.files.cache(dojox.storage.manager.getResourceList());dojox.off.files._slurp();this._checkOfflineCacheAvailable(dojo.hitch(this,"_onOfflineCacheChecked"));},_onOfflineCacheChecked:function(){if(this.hasOfflineCache&&this.enabled){this._load(dojo.hitch(this,"_finishStartingUp"));}else{if(this.hasOfflineCache&&!this.enabled){this._finishStartingUp();}else{this._keepCheckingUntilInstalled();}}},_keepCheckingUntilInstalled:function(){this._finishStartingUp();},_finishStartingUp:function(){if(!this.hasOfflineCache){this.onLoad();}else{if(this.enabled){this._startNetworkThread();this.goOnline(dojo.hitch(this,function(){dojox.off.onLoad();}));}else{if(this.coreOpFailed){this.onFrameworkEvent("coreOperationFailed");}else{this.onLoad();}}}},_onPageLoad:function(){this._pageLoaded=true;if(this._storageLoaded&&this._initializeCalled){this._onLoad();}},_onStorageLoad:function(){this._storageLoaded=true;if(!dojox.storage.manager.isAvailable()&&dojox.storage.manager.isInitialized()){this.coreOpFailed=true;this.enabled=false;}if(this._pageLoaded&&this._initializeCalled){this._onLoad();}},_isSiteAvailable:function(_16c){dojo.xhrGet({url:this._getAvailabilityURL(),handleAs:"text",timeout:this.NET_CHECK*1000,error:dojo.hitch(this,function(err){this.goingOnline=false;this.isOnline=false;if(_16c){_16c(false);}}),load:dojo.hitch(this,function(data){this.goingOnline=false;this.isOnline=true;if(_16c){_16c(true);}else{this.onNetwork("online");}})});},_startNetworkThread:function(){if(!this.doNetChecking){return;}window.setInterval(dojo.hitch(this,function(){var d=dojo.xhrGet({url:this._getAvailabilityURL(),handleAs:"text",timeout:this.NET_CHECK*1000,error:dojo.hitch(this,function(err){if(this.isOnline){this.isOnline=false;try{if(typeof d.ioArgs.xhr.abort=="function"){d.ioArgs.xhr.abort();}}catch(e){}dojox.off.sync.isSyncing=false;this.onNetwork("offline");}}),load:dojo.hitch(this,function(data){if(!this.isOnline){this.isOnline=true;this.onNetwork("online");}})});}),this.NET_CHECK*1000);},_getAvailabilityURL:function(){var url=this.availabilityURL.toString();if(url.indexOf("?")==-1){url+="?";}else{url+="&";}url+="browserbust="+new Date().getTime();return url;},_onOfflineCacheInstalled:function(){this.onFrameworkEvent("offlineCacheInstalled");},_cacheDojoResources:function(){var _173=true;dojo.forEach(dojo.query("script"),function(i){var src=i.getAttribute("src");if(!src){return;}if(src.indexOf("_base/_loader/bootstrap.js")!=-1){_173=false;}});if(!_173){dojox.off.files.cache(dojo.moduleUrl("dojo","_base.js").uri);dojox.off.files.cache(dojo.moduleUrl("dojo","_base/_loader/loader.js").uri);dojox.off.files.cache(dojo.moduleUrl("dojo","_base/_loader/bootstrap.js").uri);dojox.off.files.cache(dojo.moduleUrl("dojo","_base/_loader/hostenv_browser.js").uri);}for(var i=0;i<dojo._loadedUrls.length;i++){dojox.off.files.cache(dojo._loadedUrls[i]);}},_save:function(){},_load:function(_177){dojox.off.sync._load(_177);}});dojox.storage.manager.addOnLoad(dojo.hitch(dojox.off,"_onStorageLoad"));dojo.addOnLoad(dojox.off,"_onPageLoad");}if(!dojo._hasResource["dojox.off"]){dojo._hasResource["dojox.off"]=true;dojo.provide("dojox.off");}if(!dojo._hasResource["dojox.off.ui"]){dojo._hasResource["dojox.off.ui"]=true;dojo.provide("dojox.off.ui");dojo.mixin(dojox.off.ui,{appName:"setme",autoEmbed:true,autoEmbedID:"dot-widget",runLink:window.location.href,runLinkTitle:"Run Application",learnHowPath:dojo.moduleUrl("dojox","off/resources/learnhow.html"),customLearnHowPath:false,htmlTemplatePath:dojo.moduleUrl("dojox","off/resources/offline-widget.html").uri,cssTemplatePath:dojo.moduleUrl("dojox","off/resources/offline-widget.css").uri,onlineImagePath:dojo.moduleUrl("dojox","off/resources/greenball.png").uri,offlineImagePath:dojo.moduleUrl("dojox","off/resources/redball.png").uri,rollerImagePath:dojo.moduleUrl("dojox","off/resources/roller.gif").uri,checkmarkImagePath:dojo.moduleUrl("dojox","off/resources/checkmark.png").uri,learnHowJSPath:dojo.moduleUrl("dojox","off/resources/learnhow.js").uri,_initialized:false,onLoad:function(){},_initialize:function(){if(this._validateAppName(this.appName)==false){alert("You must set dojox.off.ui.appName; it can only contain "+"letters, numbers, and spaces; right now it "+"is incorrectly set to '"+dojox.off.ui.appName+"'");dojox.off.enabled=false;return;}this.runLinkText="Run "+this.appName;dojo.connect(dojox.off,"onNetwork",this,"_onNetwork");dojo.connect(dojox.off.sync,"onSync",this,"_onSync");dojox.off.files.cache([this.htmlTemplatePath,this.cssTemplatePath,this.onlineImagePath,this.offlineImagePath,this.rollerImagePath,this.checkmarkImagePath]);if(this.autoEmbed){this._doAutoEmbed();}},_doAutoEmbed:function(){dojo.xhrGet({url:this.htmlTemplatePath,handleAs:"text",error:function(err){dojox.off.enabled=false;err=err.message||err;alert("Error loading the Dojo Offline Widget from "+this.htmlTemplatePath+": "+err);},load:dojo.hitch(this,this._templateLoaded)});},_templateLoaded:function(data){var _17a=dojo.byId(this.autoEmbedID);if(_17a){_17a.innerHTML=data;}this._initImages();this._updateNetIndicator();this._initLearnHow();this._initialized=true;if(!dojox.off.hasOfflineCache){this._showNeedsOfflineCache();return;}if(dojox.off.hasOfflineCache&&dojox.off.browserRestart){this._needsBrowserRestart();return;}else{var _17b=dojo.byId("dot-widget-browser-restart");if(_17b){_17b.style.display="none";}}this._updateSyncUI();this._initMainEvtHandlers();this._setOfflineEnabled(dojox.off.enabled);this._onNetwork(dojox.off.isOnline?"online":"offline");this._testNet();},_testNet:function(){dojox.off.goOnline(dojo.hitch(this,function(_17c){this._onNetwork(_17c?"online":"offline");this.onLoad();}));},_updateNetIndicator:function(){var _17d=dojo.byId("dot-widget-network-indicator-online");var _17e=dojo.byId("dot-widget-network-indicator-offline");var _17f=dojo.byId("dot-widget-title-text");if(_17d&&_17e){if(dojox.off.isOnline==true){_17d.style.display="inline";_17e.style.display="none";}else{_17d.style.display="none";_17e.style.display="inline";}}if(_17f){if(dojox.off.isOnline){_17f.innerHTML="Online";}else{_17f.innerHTML="Offline";}}},_initLearnHow:function(){var _180=dojo.byId("dot-widget-learn-how-link");if(!_180){return;}if(!this.customLearnHowPath){var _181=djConfig.baseRelativePath;this.learnHowPath+="?appName="+encodeURIComponent(this.appName)+"&hasOfflineCache="+dojox.off.hasOfflineCache+"&runLink="+encodeURIComponent(this.runLink)+"&runLinkText="+encodeURIComponent(this.runLinkText)+"&baseRelativePath="+encodeURIComponent(_181);dojox.off.files.cache(this.learnHowJSPath);dojox.off.files.cache(this.learnHowPath);}_180.setAttribute("href",this.learnHowPath);var _182=dojo.byId("dot-widget-learn-how-app-name");if(!_182){return;}_182.innerHTML="";_182.appendChild(document.createTextNode(this.appName));},_validateAppName:function(_183){if(!_183){return false;}return (/^[a-z0-9 ]*$/i.test(_183));},_updateSyncUI:function(){var _184=dojo.byId("dot-roller");var _185=dojo.byId("dot-success-checkmark");var _186=dojo.byId("dot-sync-messages");var _187=dojo.byId("dot-sync-details");var _188=dojo.byId("dot-sync-cancel");if(dojox.off.sync.isSyncing){this._clearSyncMessage();if(_184){_184.style.display="inline";}if(_185){_185.style.display="none";}if(_186){dojo.removeClass(_186,"dot-sync-error");}if(_187){_187.style.display="none";}if(_188){_188.style.display="inline";}}else{if(_184){_184.style.display="none";}if(_188){_188.style.display="none";}if(_186){dojo.removeClass(_186,"dot-sync-error");}}},_setSyncMessage:function(_189){var _18a=dojo.byId("dot-sync-messages");if(_18a){while(_18a.firstChild){_18a.removeChild(_18a.firstChild);}_18a.appendChild(document.createTextNode(_189));}},_clearSyncMessage:function(){this._setSyncMessage("");},_initImages:function(){var _18b=dojo.byId("dot-widget-network-indicator-online");if(_18b){_18b.setAttribute("src",this.onlineImagePath);}var _18c=dojo.byId("dot-widget-network-indicator-offline");if(_18c){_18c.setAttribute("src",this.offlineImagePath);}var _18d=dojo.byId("dot-roller");if(_18d){_18d.setAttribute("src",this.rollerImagePath);}var _18e=dojo.byId("dot-success-checkmark");if(_18e){_18e.setAttribute("src",this.checkmarkImagePath);}},_showDetails:function(evt){evt.preventDefault();evt.stopPropagation();if(!dojox.off.sync.details.length){return;}var html="";html+="<html><head><title>Sync Details</title><head><body>";html+="<h1>Sync Details</h1>\n";html+="<ul>\n";for(var i=0;i<dojox.off.sync.details.length;i++){html+="<li>";html+=dojox.off.sync.details[i];html+="</li>";}html+="</ul>\n";html+="<a href='javascript:window.close()' "+"style='text-align: right; padding-right: 2em;'>"+"Close Window"+"</a>\n";html+="</body></html>";var _192="height=400,width=600,resizable=true,"+"scrollbars=true,toolbar=no,menubar=no,"+"location=no,directories=no,dependent=yes";var _193=window.open("","SyncDetails",_192);if(!_193){alert("Please allow popup windows for this domain; can't display sync details window");return;}_193.document.open();_193.document.write(html);_193.document.close();if(_193.focus){_193.focus();}},_cancel:function(evt){evt.preventDefault();evt.stopPropagation();dojox.off.sync.cancel();},_needsBrowserRestart:function(){var _195=dojo.byId("dot-widget-browser-restart");if(_195){dojo.addClass(_195,"dot-needs-browser-restart");}var _196=dojo.byId("dot-widget-browser-restart-app-name");if(_196){_196.innerHTML="";_196.appendChild(document.createTextNode(this.appName));}var _197=dojo.byId("dot-sync-status");if(_197){_197.style.display="none";}},_showNeedsOfflineCache:function(){var _198=dojo.byId("dot-widget-container");if(_198){dojo.addClass(_198,"dot-needs-offline-cache");}},_hideNeedsOfflineCache:function(){var _199=dojo.byId("dot-widget-container");if(_199){dojo.removeClass(_199,"dot-needs-offline-cache");}},_initMainEvtHandlers:function(){var _19a=dojo.byId("dot-sync-details-button");if(_19a){dojo.connect(_19a,"onclick",this,this._showDetails);}var _19b=dojo.byId("dot-sync-cancel-button");if(_19b){dojo.connect(_19b,"onclick",this,this._cancel);}},_setOfflineEnabled:function(_19c){var _19d=[];_19d.push(dojo.byId("dot-sync-status"));for(var i=0;i<_19d.length;i++){if(_19d[i]){_19d[i].style.visibility=(_19c?"visible":"hidden");}}},_syncFinished:function(){this._updateSyncUI();var _19f=dojo.byId("dot-success-checkmark");var _1a0=dojo.byId("dot-sync-details");if(dojox.off.sync.successful==true){this._setSyncMessage("Sync Successful");if(_19f){_19f.style.display="inline";}}else{if(dojox.off.sync.cancelled==true){this._setSyncMessage("Sync Cancelled");if(_19f){_19f.style.display="none";}}else{this._setSyncMessage("Sync Error");var _1a1=dojo.byId("dot-sync-messages");if(_1a1){dojo.addClass(_1a1,"dot-sync-error");}if(_19f){_19f.style.display="none";}}}if(dojox.off.sync.details.length&&_1a0){_1a0.style.display="inline";}},_onFrameworkEvent:function(type,_1a3){if(type=="save"){if(_1a3.status==dojox.storage.FAILED&&!_1a3.isCoreSave){alert("Please increase the amount of local storage available "+"to this application");if(dojox.storage.hasSettingsUI()){dojox.storage.showSettingsUI();}}}else{if(type=="coreOperationFailed"){console.log("Application does not have permission to use Dojo Offline");if(!this._userInformed){alert("This application will not work if Google Gears is not allowed to run");this._userInformed=true;}}else{if(type=="offlineCacheInstalled"){this._hideNeedsOfflineCache();if(dojox.off.hasOfflineCache==true&&dojox.off.browserRestart==true){this._needsBrowserRestart();return;}else{var _1a4=dojo.byId("dot-widget-browser-restart");if(_1a4){_1a4.style.display="none";}}this._updateSyncUI();this._initMainEvtHandlers();this._setOfflineEnabled(dojox.off.enabled);this._testNet();}}}},_onSync:function(type){switch(type){case "start":this._updateSyncUI();break;case "refreshFiles":this._setSyncMessage("Downloading UI...");break;case "upload":this._setSyncMessage("Uploading new data...");break;case "download":this._setSyncMessage("Downloading new data...");break;case "finished":this._syncFinished();break;case "cancel":this._setSyncMessage("Canceling Sync...");break;default:dojo.warn("Programming error: "+"Unknown sync type in dojox.off.ui: "+type);break;}},_onNetwork:function(type){if(!this._initialized){return;}this._updateNetIndicator();if(type=="offline"){this._setSyncMessage("You are working offline");var _1a7=dojo.byId("dot-sync-details");if(_1a7){_1a7.style.display="none";}this._updateSyncUI();}else{if(dojox.off.sync.autoSync){window.setTimeout("dojox.off.sync.synchronize()",1000);}}}});dojo.connect(dojox.off,"onFrameworkEvent",dojox.off.ui,"_onFrameworkEvent");dojo.connect(dojox.off,"onLoad",dojox.off.ui,dojox.off.ui._initialize);}if(!dojo._hasResource["dojox.off.offline"]){dojo._hasResource["dojox.off.offline"]=true;dojo.provide("dojox.off.offline");}
/trunk/api/js/dojo1.0/dojox/off/offline.js.uncompressed.js
New file
0,0 → 1,4276
/*
Copyright (c) 2004-2007, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/book/dojo-book-0-9/introduction/licensing
*/
 
/*
This is a compiled version of Dojo, built for deployment and not for
development. To get an editable version, please visit:
 
http://dojotoolkit.org
 
for documentation and information on getting the source.
*/
 
if(!dojo._hasResource["dojox.storage.Provider"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.storage.Provider"] = true;
dojo.provide("dojox.storage.Provider");
 
dojo.declare("dojox.storage.Provider", null, {
// summary: A singleton for working with dojox.storage.
// description:
// dojox.storage exposes the current available storage provider on this
// platform. It gives you methods such as dojox.storage.put(),
// dojox.storage.get(), etc.
//
// For more details on dojox.storage, see the primary documentation
// page at
// http://manual.dojotoolkit.org/storage.html
//
// Note for storage provider developers who are creating subclasses-
// This is the base class for all storage providers Specific kinds of
// Storage Providers should subclass this and implement these methods.
// You should avoid initialization in storage provider subclass's
// constructor; instead, perform initialization in your initialize()
// method.
constructor: function(){
},
// SUCCESS: String
// Flag that indicates a put() call to a
// storage provider was succesful.
SUCCESS: "success",
// FAILED: String
// Flag that indicates a put() call to
// a storage provider failed.
FAILED: "failed",
// PENDING: String
// Flag that indicates a put() call to a
// storage provider is pending user approval.
PENDING: "pending",
// SIZE_NOT_AVAILABLE: String
// Returned by getMaximumSize() if this storage provider can not determine
// the maximum amount of data it can support.
SIZE_NOT_AVAILABLE: "Size not available",
// SIZE_NO_LIMIT: String
// Returned by getMaximumSize() if this storage provider has no theoretical
// limit on the amount of data it can store.
SIZE_NO_LIMIT: "No size limit",
 
// DEFAULT_NAMESPACE: String
// The namespace for all storage operations. This is useful if several
// applications want access to the storage system from the same domain but
// want different storage silos.
DEFAULT_NAMESPACE: "default",
// onHideSettingsUI: Function
// If a function is assigned to this property, then when the settings
// provider's UI is closed this function is called. Useful, for example,
// if the user has just cleared out all storage for this provider using
// the settings UI, and you want to update your UI.
onHideSettingsUI: null,
 
initialize: function(){
// summary:
// Allows this storage provider to initialize itself. This is
// called after the page has finished loading, so you can not do
// document.writes(). Storage Provider subclasses should initialize
// themselves inside of here rather than in their function
// constructor.
console.warn("dojox.storage.initialize not implemented");
},
isAvailable: function(){ /*Boolean*/
// summary:
// Returns whether this storage provider is available on this
// platform.
console.warn("dojox.storage.isAvailable not implemented");
},
 
put: function( /*string*/ key,
/*object*/ value,
/*function*/ resultsHandler,
/*string?*/ namespace){
// summary:
// Puts a key and value into this storage system.
// description:
// Example-
// var resultsHandler = function(status, key, message){
// alert("status="+status+", key="+key+", message="+message);
// };
// dojox.storage.put("test", "hello world", resultsHandler);
//
// Important note: if you are using Dojo Storage in conjunction with
// Dojo Offline, then you don't need to provide
// a resultsHandler; this is because for Dojo Offline we
// use Google Gears to persist data, which has unlimited data
// once the user has given permission. If you are using Dojo
// Storage apart from Dojo Offline, then under the covers hidden
// Flash might be used, which is both asychronous and which might
// get denied; in this case you must provide a resultsHandler.
// key:
// A string key to use when retrieving this value in the future.
// value:
// A value to store; this can be any JavaScript type.
// resultsHandler:
// A callback function that will receive three arguments. The
// first argument is one of three values: dojox.storage.SUCCESS,
// dojox.storage.FAILED, or dojox.storage.PENDING; these values
// determine how the put request went. In some storage systems
// users can deny a storage request, resulting in a
// dojox.storage.FAILED, while in other storage systems a storage
// request must wait for user approval, resulting in a
// dojox.storage.PENDING status until the request is either
// approved or denied, resulting in another call back with
// dojox.storage.SUCCESS.
// The second argument in the call back is the key name that was being stored.
// The third argument in the call back is an optional message that
// details possible error messages that might have occurred during
// the storage process.
// namespace:
// Optional string namespace that this value will be placed into;
// if left off, the value will be placed into dojox.storage.DEFAULT_NAMESPACE
console.warn("dojox.storage.put not implemented");
},
 
get: function(/*string*/ key, /*string?*/ namespace){ /*Object*/
// summary:
// Gets the value with the given key. Returns null if this key is
// not in the storage system.
// key:
// A string key to get the value of.
// namespace:
// Optional string namespace that this value will be retrieved from;
// if left off, the value will be retrieved from dojox.storage.DEFAULT_NAMESPACE
// return: Returns any JavaScript object type; null if the key is not present
console.warn("dojox.storage.get not implemented");
},
 
hasKey: function(/*string*/ key, /*string?*/ namespace){ /*Boolean*/
// summary: Determines whether the storage has the given key.
return (this.get(key) != null);
},
 
getKeys: function(/*string?*/ namespace){ /*Array*/
// summary: Enumerates all of the available keys in this storage system.
// return: Array of available keys
console.warn("dojox.storage.getKeys not implemented");
},
clear: function(/*string?*/ namespace){
// summary:
// Completely clears this storage system of all of it's values and
// keys. If 'namespace' is provided just clears the keys in that
// namespace.
console.warn("dojox.storage.clear not implemented");
},
remove: function(/*string*/ key, /*string?*/ namespace){
// summary: Removes the given key from this storage system.
console.warn("dojox.storage.remove not implemented");
},
getNamespaces: function(){ /*string[]*/
console.warn("dojox.storage.getNamespaces not implemented");
},
 
isPermanent: function(){ /*Boolean*/
// summary:
// Returns whether this storage provider's values are persisted
// when this platform is shutdown.
console.warn("dojox.storage.isPermanent not implemented");
},
 
getMaximumSize: function(){ /* mixed */
// summary: The maximum storage allowed by this provider
// returns:
// Returns the maximum storage size
// supported by this provider, in
// thousands of bytes (i.e., if it
// returns 60 then this means that 60K
// of storage is supported).
//
// If this provider can not determine
// it's maximum size, then
// dojox.storage.SIZE_NOT_AVAILABLE is
// returned; if there is no theoretical
// limit on the amount of storage
// this provider can return, then
// dojox.storage.SIZE_NO_LIMIT is
// returned
console.warn("dojox.storage.getMaximumSize not implemented");
},
putMultiple: function( /*array*/ keys,
/*array*/ values,
/*function*/ resultsHandler,
/*string?*/ namespace){
// summary:
// Puts multiple keys and values into this storage system.
// description:
// Example-
// var resultsHandler = function(status, key, message){
// alert("status="+status+", key="+key+", message="+message);
// };
// dojox.storage.put(["test"], ["hello world"], resultsHandler);
//
// Important note: if you are using Dojo Storage in conjunction with
// Dojo Offline, then you don't need to provide
// a resultsHandler; this is because for Dojo Offline we
// use Google Gears to persist data, which has unlimited data
// once the user has given permission. If you are using Dojo
// Storage apart from Dojo Offline, then under the covers hidden
// Flash might be used, which is both asychronous and which might
// get denied; in this case you must provide a resultsHandler.
// keys:
// An array of string keys to use when retrieving this value in the future,
// one per value to be stored
// values:
// An array of values to store; this can be any JavaScript type, though the
// performance of plain strings is considerably better
// resultsHandler:
// A callback function that will receive three arguments. The
// first argument is one of three values: dojox.storage.SUCCESS,
// dojox.storage.FAILED, or dojox.storage.PENDING; these values
// determine how the put request went. In some storage systems
// users can deny a storage request, resulting in a
// dojox.storage.FAILED, while in other storage systems a storage
// request must wait for user approval, resulting in a
// dojox.storage.PENDING status until the request is either
// approved or denied, resulting in another call back with
// dojox.storage.SUCCESS.
// The second argument in the call back is the key name that was being stored.
// The third argument in the call back is an optional message that
// details possible error messages that might have occurred during
// the storage process.
// namespace:
// Optional string namespace that this value will be placed into;
// if left off, the value will be placed into dojox.storage.DEFAULT_NAMESPACE
console.warn("dojox.storage.putMultiple not implemented");
// JAC: We could implement a 'default' puMultiple here by just doing each put individually
},
 
getMultiple: function(/*array*/ keys, /*string?*/ namespace){ /*Object*/
// summary:
// Gets the valuse corresponding to each of the given keys.
// Returns a null array element for each given key that is
// not in the storage system.
// keys:
// An array of string keys to get the value of.
// namespace:
// Optional string namespace that this value will be retrieved from;
// if left off, the value will be retrieved from dojox.storage.DEFAULT_NAMESPACE
// return: Returns any JavaScript object type; null if the key is not present
 
console.warn("dojox.storage.getMultiple not implemented");
// JAC: We could implement a 'default' getMultiple here by just doing each get individually
},
 
removeMultiple: function(/*array*/ keys, /*string?*/ namespace) {
// summary: Removes the given keys from this storage system.
 
// JAC: We could implement a 'default' removeMultiple here by just doing each remove individually
console.warn("dojox.storage.remove not implemented");
},
isValidKeyArray: function( keys) {
if(keys === null || typeof keys === "undefined" || ! keys instanceof Array){
return false;
}
// JAC: This could be optimized by running the key validity test directly over a joined string
for(var k=0;k<keys.length;k++){
if(!this.isValidKey(keys[k])){
return false;
}
}
return true;
},
 
hasSettingsUI: function(){ /*Boolean*/
// summary: Determines whether this provider has a settings UI.
return false;
},
 
showSettingsUI: function(){
// summary: If this provider has a settings UI, determined
// by calling hasSettingsUI(), it is shown.
console.warn("dojox.storage.showSettingsUI not implemented");
},
 
hideSettingsUI: function(){
// summary: If this provider has a settings UI, hides it.
console.warn("dojox.storage.hideSettingsUI not implemented");
},
isValidKey: function(/*string*/ keyName){ /*Boolean*/
// summary:
// Subclasses can call this to ensure that the key given is valid
// in a consistent way across different storage providers. We use
// the lowest common denominator for key values allowed: only
// letters, numbers, and underscores are allowed. No spaces.
if((keyName == null)||(typeof keyName == "undefined")){
return false;
}
return /^[0-9A-Za-z_]*$/.test(keyName);
},
getResourceList: function(){ /* Array[] */
// summary:
// Returns a list of URLs that this
// storage provider might depend on.
// description:
// This method returns a list of URLs that this
// storage provider depends on to do its work.
// This list is used by the Dojo Offline Toolkit
// to cache these resources to ensure the machinery
// used by this storage provider is available offline.
// What is returned is an array of URLs.
return [];
}
});
 
}
 
if(!dojo._hasResource["dojox.storage.manager"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.storage.manager"] = true;
dojo.provide("dojox.storage.manager");
//dojo.require("dojo.AdapterRegistry");
// FIXME: refactor this to use an AdapterRegistry
 
dojox.storage.manager = new function(){
// summary: A singleton class in charge of the dojox.storage system
// description:
// Initializes the storage systems and figures out the best available
// storage options on this platform.
// currentProvider: Object
// The storage provider that was automagically chosen to do storage
// on this platform, such as dojox.storage.FlashStorageProvider.
this.currentProvider = null;
// available: Boolean
// Whether storage of some kind is available.
this.available = false;
this._initialized = false;
this._providers = [];
this._onLoadListeners = [];
this.initialize = function(){
// summary:
// Initializes the storage system and autodetects the best storage
// provider we can provide on this platform
this.autodetect();
};
this.register = function(/*string*/ name, /*Object*/ instance){
// summary:
// Registers the existence of a new storage provider; used by
// subclasses to inform the manager of their existence. The
// storage manager will select storage providers based on
// their ordering, so the order in which you call this method
// matters.
// name:
// The full class name of this provider, such as
// "dojox.storage.FlashStorageProvider".
// instance:
// An instance of this provider, which we will use to call
// isAvailable() on.
this._providers[this._providers.length] = instance; //FIXME: push?
this._providers[name] = instance; // FIXME: this._providers is an array, not a hash
};
this.setProvider = function(storageClass){
// summary:
// Instructs the storageManager to use the given storage class for
// all storage requests.
// description:
// Example-
// dojox.storage.setProvider(
// dojox.storage.IEStorageProvider)
};
this.autodetect = function(){
// summary:
// Autodetects the best possible persistent storage provider
// available on this platform.
//console.debug("dojox.storage.manager.autodetect");
if(this._initialized){ // already finished
//console.debug("dojox.storage.manager already initialized; returning");
return;
}
 
// a flag to force the storage manager to use a particular
// storage provider type, such as
// djConfig = {forceStorageProvider: "dojox.storage.WhatWGStorageProvider"};
var forceProvider = djConfig["forceStorageProvider"]||false;
 
// go through each provider, seeing if it can be used
var providerToUse;
//FIXME: use dojo.some
for(var i = 0; i < this._providers.length; i++){
providerToUse = this._providers[i];
if(forceProvider == providerToUse.declaredClass){
// still call isAvailable for this provider, since this helps some
// providers internally figure out if they are available
// FIXME: This should be refactored since it is non-intuitive
// that isAvailable() would initialize some state
providerToUse.isAvailable();
break;
}else if(providerToUse.isAvailable()){
break;
}
}
if(!providerToUse){ // no provider available
this._initialized = true;
this.available = false;
this.currentProvider = null;
console.warn("No storage provider found for this platform");
this.loaded();
return;
}
// create this provider and mix in it's properties
// so that developers can do dojox.storage.put rather
// than dojox.storage.currentProvider.put, for example
this.currentProvider = providerToUse;
dojo.mixin(dojox.storage, this.currentProvider);
// have the provider initialize itself
dojox.storage.initialize();
this._initialized = true;
this.available = true;
};
this.isAvailable = function(){ /*Boolean*/
// summary: Returns whether any storage options are available.
return this.available;
};
this.addOnLoad = function(func){ /* void */
// summary:
// Adds an onload listener to know when Dojo Offline can be used.
// description:
// Adds a listener to know when Dojo Offline can be used. This
// ensures that the Dojo Offline framework is loaded and that the
// local dojox.storage system is ready to be used. This method is
// useful if you don't want to have a dependency on Dojo Events
// when using dojox.storage.
// func: Function
// A function to call when Dojo Offline is ready to go
this._onLoadListeners.push(func);
if(this.isInitialized()){
this._fireLoaded();
}
};
this.removeOnLoad = function(func){ /* void */
// summary: Removes the given onLoad listener
for(var i = 0; i < this._onLoadListeners.length; i++){
if(func == this._onLoadListeners[i]){
this._onLoadListeners = this._onLoadListeners.splice(i, 1);
break;
}
}
};
this.isInitialized = function(){ /*Boolean*/
// summary:
// Returns whether the storage system is initialized and ready to
// be used.
 
// FIXME: This should REALLY not be in here, but it fixes a tricky
// Flash timing bug
if(this.currentProvider != null
&& this.currentProvider.declaredClass == "dojox.storage.FlashStorageProvider"
&& dojox.flash.ready == false){
return false;
}else{
return this._initialized;
}
};
 
this.supportsProvider = function(/*string*/ storageClass){ /* Boolean */
// summary: Determines if this platform supports the given storage provider.
// description:
// Example-
// dojox.storage.manager.supportsProvider(
// "dojox.storage.InternetExplorerStorageProvider");
 
// construct this class dynamically
try{
// dynamically call the given providers class level isAvailable()
// method
var provider = eval("new " + storageClass + "()");
var results = provider.isAvailable();
if(!results){ return false; }
return results;
}catch(e){
return false;
}
};
 
this.getProvider = function(){ /* Object */
// summary: Gets the current provider
return this.currentProvider;
};
this.loaded = function(){
// summary:
// The storage provider should call this method when it is loaded
// and ready to be used. Clients who will use the provider will
// connect to this method to know when they can use the storage
// system. You can either use dojo.connect to connect to this
// function, or can use dojox.storage.manager.addOnLoad() to add
// a listener that does not depend on the dojo.event package.
// description:
// Example 1-
// if(dojox.storage.manager.isInitialized() == false){
// dojo.connect(dojox.storage.manager, "loaded", TestStorage, "initialize");
// }else{
// dojo.connect(dojo, "loaded", TestStorage, "initialize");
// }
// Example 2-
// dojox.storage.manager.addOnLoad(someFunction);
 
 
// FIXME: we should just provide a Deferred for this. That way you
// don't care when this happens or has happened. Deferreds are in Base
this._fireLoaded();
};
this._fireLoaded = function(){
//console.debug("dojox.storage.manager._fireLoaded");
dojo.forEach(this._onLoadListeners, function(i){
try{
i();
}catch(e){ console.debug(e); }
});
};
this.getResourceList = function(){
// summary:
// Returns a list of whatever resources are necessary for storage
// providers to work.
// description:
// This will return all files needed by all storage providers for
// this particular environment type. For example, if we are in the
// browser environment, then this will return the hidden SWF files
// needed by the FlashStorageProvider, even if we don't need them
// for the particular browser we are working within. This is meant
// to faciliate Dojo Offline, which must retrieve all resources we
// need offline into the offline cache -- we retrieve everything
// needed, in case another browser that requires different storage
// mechanisms hits the local offline cache. For example, if we
// were to sync against Dojo Offline on Firefox 2, then we would
// not grab the FlashStorageProvider resources needed for Safari.
var results = [];
dojo.forEach(dojox.storage.manager._providers, function(currentProvider){
results = results.concat(currentProvider.getResourceList());
});
return results;
}
};
 
}
 
if(!dojo._hasResource["dojox._sql._crypto"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox._sql._crypto"] = true;
// Taken from http://www.movable-type.co.uk/scripts/aes.html by
// Chris Veness (CLA signed); adapted for Dojo and Google Gears Worker Pool
// by Brad Neuberg, bkn3@columbia.edu
 
dojo.provide("dojox._sql._crypto");
 
dojo.mixin(dojox._sql._crypto,{
// _POOL_SIZE:
// Size of worker pool to create to help with crypto
_POOL_SIZE: 100,
encrypt: function(plaintext, password, callback){
// summary:
// Use Corrected Block TEA to encrypt plaintext using password
// (note plaintext & password must be strings not string objects).
// Results will be returned to the 'callback' asychronously.
this._initWorkerPool();
var msg ={plaintext: plaintext, password: password};
msg = dojo.toJson(msg);
msg = "encr:" + String(msg);
this._assignWork(msg, callback);
},
 
decrypt: function(ciphertext, password, callback){
// summary:
// Use Corrected Block TEA to decrypt ciphertext using password
// (note ciphertext & password must be strings not string objects).
// Results will be returned to the 'callback' asychronously.
this._initWorkerPool();
var msg ={ciphertext: ciphertext, password: password};
msg = dojo.toJson(msg);
msg = "decr:" + String(msg);
this._assignWork(msg, callback);
},
_initWorkerPool: function(){
// bugs in Google Gears prevents us from dynamically creating
// and destroying workers as we need them -- the worker
// pool functionality stops working after a number of crypto
// cycles (probably related to a memory leak in Google Gears).
// this is too bad, since it results in much simpler code.
// instead, we have to create a pool of workers and reuse them. we
// keep a stack of 'unemployed' Worker IDs that are currently not working.
// if a work request comes in, we pop off the 'unemployed' stack
// and put them to work, storing them in an 'employed' hashtable,
// keyed by their Worker ID with the value being the callback function
// that wants the result. when an employed worker is done, we get
// a message in our 'manager' which adds this worker back to the
// unemployed stack and routes the result to the callback that
// wanted it. if all the workers were employed in the past but
// more work needed to be done (i.e. it's a tight labor pool ;)
// then the work messages are pushed onto
// a 'handleMessage' queue as an object tuple{msg: msg, callback: callback}
if(!this._manager){
try{
this._manager = google.gears.factory.create("beta.workerpool", "1.0");
this._unemployed = [];
this._employed ={};
this._handleMessage = [];
var self = this;
this._manager.onmessage = function(msg, sender){
// get the callback necessary to serve this result
var callback = self._employed["_" + sender];
// make this worker unemployed
self._employed["_" + sender] = undefined;
self._unemployed.push("_" + sender);
// see if we need to assign new work
// that was queued up needing to be done
if(self._handleMessage.length){
var handleMe = self._handleMessage.shift();
self._assignWork(handleMe.msg, handleMe.callback);
}
// return results
callback(msg);
}
var workerInit = "function _workerInit(){"
+ "gearsWorkerPool.onmessage = "
+ String(this._workerHandler)
+ ";"
+ "}";
var code = workerInit + " _workerInit();";
// create our worker pool
for(var i = 0; i < this._POOL_SIZE; i++){
this._unemployed.push("_" + this._manager.createWorker(code));
}
}catch(exp){
throw exp.message||exp;
}
}
},
 
_assignWork: function(msg, callback){
// can we immediately assign this work?
if(!this._handleMessage.length && this._unemployed.length){
// get an unemployed worker
var workerID = this._unemployed.shift().substring(1); // remove _
// list this worker as employed
this._employed["_" + workerID] = callback;
// do the worke
this._manager.sendMessage(msg, workerID);
}else{
// we have to queue it up
this._handleMessage ={msg: msg, callback: callback};
}
},
 
_workerHandler: function(msg, sender){
/* Begin AES Implementation */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
// Sbox is pre-computed multiplicative inverse in GF(2^8) used in SubBytes and KeyExpansion [§5.1.1]
var Sbox = [0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16];
 
// Rcon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [§5.2]
var Rcon = [ [0x00, 0x00, 0x00, 0x00],
[0x01, 0x00, 0x00, 0x00],
[0x02, 0x00, 0x00, 0x00],
[0x04, 0x00, 0x00, 0x00],
[0x08, 0x00, 0x00, 0x00],
[0x10, 0x00, 0x00, 0x00],
[0x20, 0x00, 0x00, 0x00],
[0x40, 0x00, 0x00, 0x00],
[0x80, 0x00, 0x00, 0x00],
[0x1b, 0x00, 0x00, 0x00],
[0x36, 0x00, 0x00, 0x00] ];
 
/*
* AES Cipher function: encrypt 'input' with Rijndael algorithm
*
* takes byte-array 'input' (16 bytes)
* 2D byte-array key schedule 'w' (Nr+1 x Nb bytes)
*
* applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage
*
* returns byte-array encrypted value (16 bytes)
*/
function Cipher(input, w) { // main Cipher function [§5.1]
var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
 
var state = [[],[],[],[]]; // initialise 4xNb byte-array 'state' with input [§3.4]
for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i];
 
state = AddRoundKey(state, w, 0, Nb);
 
for (var round=1; round<Nr; round++) {
state = SubBytes(state, Nb);
state = ShiftRows(state, Nb);
state = MixColumns(state, Nb);
state = AddRoundKey(state, w, round, Nb);
}
 
state = SubBytes(state, Nb);
state = ShiftRows(state, Nb);
state = AddRoundKey(state, w, Nr, Nb);
 
var output = new Array(4*Nb); // convert state to 1-d array before returning [§3.4]
for (var i=0; i<4*Nb; i++) output[i] = state[i%4][Math.floor(i/4)];
return output;
}
 
 
function SubBytes(s, Nb) { // apply SBox to state S [§5.1.1]
for (var r=0; r<4; r++) {
for (var c=0; c<Nb; c++) s[r][c] = Sbox[s[r][c]];
}
return s;
}
 
 
function ShiftRows(s, Nb) { // shift row r of state S left by r bytes [§5.1.2]
var t = new Array(4);
for (var r=1; r<4; r++) {
for (var c=0; c<4; c++) t[c] = s[r][(c+r)%Nb]; // shift into temp copy
for (var c=0; c<4; c++) s[r][c] = t[c]; // and copy back
} // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
return s; // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf
}
 
 
function MixColumns(s, Nb) { // combine bytes of each col of state S [§5.1.3]
for (var c=0; c<4; c++) {
var a = new Array(4); // 'a' is a copy of the current column from 's'
var b = new Array(4); // 'b' is a•{02} in GF(2^8)
for (var i=0; i<4; i++) {
a[i] = s[i][c];
b[i] = s[i][c]&0x80 ? s[i][c]<<1 ^ 0x011b : s[i][c]<<1;
}
// a[n] ^ b[n] is a•{03} in GF(2^8)
s[0][c] = b[0] ^ a[1] ^ b[1] ^ a[2] ^ a[3]; // 2*a0 + 3*a1 + a2 + a3
s[1][c] = a[0] ^ b[1] ^ a[2] ^ b[2] ^ a[3]; // a0 * 2*a1 + 3*a2 + a3
s[2][c] = a[0] ^ a[1] ^ b[2] ^ a[3] ^ b[3]; // a0 + a1 + 2*a2 + 3*a3
s[3][c] = a[0] ^ b[0] ^ a[1] ^ a[2] ^ b[3]; // 3*a0 + a1 + a2 + 2*a3
}
return s;
}
 
 
function AddRoundKey(state, w, rnd, Nb) { // xor Round Key into state S [§5.1.4]
for (var r=0; r<4; r++) {
for (var c=0; c<Nb; c++) state[r][c] ^= w[rnd*4+c][r];
}
return state;
}
 
 
function KeyExpansion(key) { // generate Key Schedule (byte-array Nr+1 x Nb) from Key [§5.2]
var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
var Nk = key.length/4 // key length (in words): 4/6/8 for 128/192/256-bit keys
var Nr = Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys
 
var w = new Array(Nb*(Nr+1));
var temp = new Array(4);
 
for (var i=0; i<Nk; i++) {
var r = [key[4*i], key[4*i+1], key[4*i+2], key[4*i+3]];
w[i] = r;
}
 
for (var i=Nk; i<(Nb*(Nr+1)); i++) {
w[i] = new Array(4);
for (var t=0; t<4; t++) temp[t] = w[i-1][t];
if (i % Nk == 0) {
temp = SubWord(RotWord(temp));
for (var t=0; t<4; t++) temp[t] ^= Rcon[i/Nk][t];
} else if (Nk > 6 && i%Nk == 4) {
temp = SubWord(temp);
}
for (var t=0; t<4; t++) w[i][t] = w[i-Nk][t] ^ temp[t];
}
 
return w;
}
 
function SubWord(w) { // apply SBox to 4-byte word w
for (var i=0; i<4; i++) w[i] = Sbox[w[i]];
return w;
}
 
function RotWord(w) { // rotate 4-byte word w left by one byte
w[4] = w[0];
for (var i=0; i<4; i++) w[i] = w[i+1];
return w;
}
 
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
/*
* Use AES to encrypt 'plaintext' with 'password' using 'nBits' key, in 'Counter' mode of operation
* - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
* for each block
* - outputblock = cipher(counter, key)
* - cipherblock = plaintext xor outputblock
*/
function AESEncryptCtr(plaintext, password, nBits) {
if (!(nBits==128 || nBits==192 || nBits==256)) return ''; // standard allows 128/192/256 bit keys
// for this example script, generate the key by applying Cipher to 1st 16/24/32 chars of password;
// for real-world applications, a more secure approach would be to hash the password e.g. with SHA-1
var nBytes = nBits/8; // no bytes in key
var pwBytes = new Array(nBytes);
for (var i=0; i<nBytes; i++) pwBytes[i] = password.charCodeAt(i) & 0xff;
 
var key = Cipher(pwBytes, KeyExpansion(pwBytes));
 
key = key.concat(key.slice(0, nBytes-16)); // key is now 16/24/32 bytes long
 
// initialise counter block (NIST SP800-38A §B.2): millisecond time-stamp for nonce in 1st 8 bytes,
// block counter in 2nd 8 bytes
var blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
var counterBlock = new Array(blockSize); // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
var nonce = (new Date()).getTime(); // milliseconds since 1-Jan-1970
 
// encode nonce in two stages to cater for JavaScript 32-bit limit on bitwise ops
for (var i=0; i<4; i++) counterBlock[i] = (nonce >>> i*8) & 0xff;
for (var i=0; i<4; i++) counterBlock[i+4] = (nonce/0x100000000 >>> i*8) & 0xff;
 
// generate key schedule - an expansion of the key into distinct Key Rounds for each round
var keySchedule = KeyExpansion(key);
 
var blockCount = Math.ceil(plaintext.length/blockSize);
var ciphertext = new Array(blockCount); // ciphertext as array of strings
for (var b=0; b<blockCount; b++) {
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
// again done in two stages for 32-bit ops
for (var c=0; c<4; c++) counterBlock[15-c] = (b >>> c*8) & 0xff;
for (var c=0; c<4; c++) counterBlock[15-c-4] = (b/0x100000000 >>> c*8)
 
var cipherCntr = Cipher(counterBlock, keySchedule); // -- encrypt counter block --
// calculate length of final block:
var blockLength = b<blockCount-1 ? blockSize : (plaintext.length-1)%blockSize+1;
 
var ct = '';
for (var i=0; i<blockLength; i++) { // -- xor plaintext with ciphered counter byte-by-byte --
var plaintextByte = plaintext.charCodeAt(b*blockSize+i);
var cipherByte = plaintextByte ^ cipherCntr[i];
ct += String.fromCharCode(cipherByte);
}
// ct is now ciphertext for this block
 
ciphertext[b] = escCtrlChars(ct); // escape troublesome characters in ciphertext
}
 
// convert the nonce to a string to go on the front of the ciphertext
var ctrTxt = '';
for (var i=0; i<8; i++) ctrTxt += String.fromCharCode(counterBlock[i]);
ctrTxt = escCtrlChars(ctrTxt);
 
// use '-' to separate blocks, use Array.join to concatenate arrays of strings for efficiency
return ctrTxt + '-' + ciphertext.join('-');
}
 
 
/*
* Use AES to decrypt 'ciphertext' with 'password' using 'nBits' key, in Counter mode of operation
*
* for each block
* - outputblock = cipher(counter, key)
* - cipherblock = plaintext xor outputblock
*/
function AESDecryptCtr(ciphertext, password, nBits) {
if (!(nBits==128 || nBits==192 || nBits==256)) return ''; // standard allows 128/192/256 bit keys
 
var nBytes = nBits/8; // no bytes in key
var pwBytes = new Array(nBytes);
for (var i=0; i<nBytes; i++) pwBytes[i] = password.charCodeAt(i) & 0xff;
var pwKeySchedule = KeyExpansion(pwBytes);
var key = Cipher(pwBytes, pwKeySchedule);
key = key.concat(key.slice(0, nBytes-16)); // key is now 16/24/32 bytes long
 
var keySchedule = KeyExpansion(key);
 
ciphertext = ciphertext.split('-'); // split ciphertext into array of block-length strings
 
// recover nonce from 1st element of ciphertext
var blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
var counterBlock = new Array(blockSize);
var ctrTxt = unescCtrlChars(ciphertext[0]);
for (var i=0; i<8; i++) counterBlock[i] = ctrTxt.charCodeAt(i);
 
var plaintext = new Array(ciphertext.length-1);
 
for (var b=1; b<ciphertext.length; b++) {
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
for (var c=0; c<4; c++) counterBlock[15-c] = ((b-1) >>> c*8) & 0xff;
for (var c=0; c<4; c++) counterBlock[15-c-4] = ((b/0x100000000-1) >>> c*8) & 0xff;
 
var cipherCntr = Cipher(counterBlock, keySchedule); // encrypt counter block
 
ciphertext[b] = unescCtrlChars(ciphertext[b]);
 
var pt = '';
for (var i=0; i<ciphertext[b].length; i++) {
// -- xor plaintext with ciphered counter byte-by-byte --
var ciphertextByte = ciphertext[b].charCodeAt(i);
var plaintextByte = ciphertextByte ^ cipherCntr[i];
pt += String.fromCharCode(plaintextByte);
}
// pt is now plaintext for this block
 
plaintext[b-1] = pt; // b-1 'cos no initial nonce block in plaintext
}
 
return plaintext.join('');
}
 
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
function escCtrlChars(str) { // escape control chars which might cause problems handling ciphertext
return str.replace(/[\0\t\n\v\f\r\xa0!-]/g, function(c) { return '!' + c.charCodeAt(0) + '!'; });
} // \xa0 to cater for bug in Firefox; include '-' to leave it free for use as a block marker
 
function unescCtrlChars(str) { // unescape potentially problematic control characters
return str.replace(/!\d\d?\d?!/g, function(c) { return String.fromCharCode(c.slice(1,-1)); });
}
 
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function encrypt(plaintext, password){
return AESEncryptCtr(plaintext, password, 256);
}
 
function decrypt(ciphertext, password){
return AESDecryptCtr(ciphertext, password, 256);
}
/* End AES Implementation */
var cmd = msg.substr(0,4);
var arg = msg.substr(5);
if(cmd == "encr"){
arg = eval("(" + arg + ")");
var plaintext = arg.plaintext;
var password = arg.password;
var results = encrypt(plaintext, password);
gearsWorkerPool.sendMessage(String(results), sender);
}else if(cmd == "decr"){
arg = eval("(" + arg + ")");
var ciphertext = arg.ciphertext;
var password = arg.password;
var results = decrypt(ciphertext, password);
gearsWorkerPool.sendMessage(String(results), sender);
}
}
});
 
}
 
if(!dojo._hasResource["dojox._sql.common"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox._sql.common"] = true;
dojo.provide("dojox._sql.common");
 
 
 
// summary:
// Executes a SQL expression.
// description:
// There are four ways to call this:
// 1) Straight SQL: dojox.sql("SELECT * FROM FOOBAR");
// 2) SQL with parameters: dojox.sql("INSERT INTO FOOBAR VALUES (?)", someParam)
// 3) Encrypting particular values:
// dojox.sql("INSERT INTO FOOBAR VALUES (ENCRYPT(?))", someParam, "somePassword", callback)
// 4) Decrypting particular values:
// dojox.sql("SELECT DECRYPT(SOMECOL1), DECRYPT(SOMECOL2) FROM
// FOOBAR WHERE SOMECOL3 = ?", someParam,
// "somePassword", callback)
//
// For encryption and decryption the last two values should be the the password for
// encryption/decryption, and the callback function that gets the result set.
//
// Note: We only support ENCRYPT(?) statements, and
// and DECRYPT(*) statements for now -- you can not have a literal string
// inside of these, such as ENCRYPT('foobar')
//
// Note: If you have multiple columns to encrypt and decrypt, you can use the following
// convenience form to not have to type ENCRYPT(?)/DECRYPT(*) many times:
//
// dojox.sql("INSERT INTO FOOBAR VALUES (ENCRYPT(?, ?, ?))",
// someParam1, someParam2, someParam3,
// "somePassword", callback)
//
// dojox.sql("SELECT DECRYPT(SOMECOL1, SOMECOL2) FROM
// FOOBAR WHERE SOMECOL3 = ?", someParam,
// "somePassword", callback)
dojox.sql = new Function("return dojox.sql._exec(arguments);");
 
dojo.mixin(dojox.sql, {
dbName: null,
// summary:
// If true, then we print out any SQL that is executed
// to the debug window
debug: (dojo.exists("dojox.sql.debug")?dojox.sql.debug:false),
 
open: function(dbName){
if(this._dbOpen && (!dbName || dbName == this.dbName)){
return;
}
if(!this.dbName){
this.dbName = "dot_store_"
+ window.location.href.replace(/[^0-9A-Za-z_]/g, "_");
//console.debug("Using Google Gears database " + this.dbName);
}
if(!dbName){
dbName = this.dbName;
}
try{
this._initDb();
this.db.open(dbName);
this._dbOpen = true;
}catch(exp){
throw exp.message||exp;
}
},
 
close: function(dbName){
// on Internet Explorer, Google Gears throws an exception
// "Object not a collection", when we try to close the
// database -- just don't close it on this platform
// since we are running into a Gears bug; the Gears team
// said it's ok to not close a database connection
if(dojo.isIE){ return; }
if(!this._dbOpen && (!dbName || dbName == this.dbName)){
return;
}
if(!dbName){
dbName = this.dbName;
}
try{
this.db.close(dbName);
this._dbOpen = false;
}catch(exp){
throw exp.message||exp;
}
},
_exec: function(params){
try{
// get the Gears Database object
this._initDb();
// see if we need to open the db; if programmer
// manually called dojox.sql.open() let them handle
// it; otherwise we open and close automatically on
// each SQL execution
if(!this._dbOpen){
this.open();
this._autoClose = true;
}
// determine our parameters
var sql = null;
var callback = null;
var password = null;
 
var args = dojo._toArray(params);
 
sql = args.splice(0, 1)[0];
 
// does this SQL statement use the ENCRYPT or DECRYPT
// keywords? if so, extract our callback and crypto
// password
if(this._needsEncrypt(sql) || this._needsDecrypt(sql)){
callback = args.splice(args.length - 1, 1)[0];
password = args.splice(args.length - 1, 1)[0];
}
 
// 'args' now just has the SQL parameters
 
// print out debug SQL output if the developer wants that
if(this.debug){
this._printDebugSQL(sql, args);
}
 
// handle SQL that needs encryption/decryption differently
// do we have an ENCRYPT SQL statement? if so, handle that first
if(this._needsEncrypt(sql)){
var crypto = new dojox.sql._SQLCrypto("encrypt", sql,
password, args,
callback);
return; // encrypted results will arrive asynchronously
}else if(this._needsDecrypt(sql)){ // otherwise we have a DECRYPT statement
var crypto = new dojox.sql._SQLCrypto("decrypt", sql,
password, args,
callback);
return; // decrypted results will arrive asynchronously
}
 
// execute the SQL and get the results
var rs = this.db.execute(sql, args);
// Gears ResultSet object's are ugly -- normalize
// these into something JavaScript programmers know
// how to work with, basically an array of
// JavaScript objects where each property name is
// simply the field name for a column of data
rs = this._normalizeResults(rs);
if(this._autoClose){
this.close();
}
return rs;
}catch(exp){
exp = exp.message||exp;
console.debug("SQL Exception: " + exp);
if(this._autoClose){
try{
this.close();
}catch(e){
console.debug("Error closing database: "
+ e.message||e);
}
}
throw exp;
}
},
 
_initDb: function(){
if(!this.db){
try{
this.db = google.gears.factory.create('beta.database', '1.0');
}catch(exp){
dojo.setObject("google.gears.denied", true);
dojox.off.onFrameworkEvent("coreOperationFailed");
throw "Google Gears must be allowed to run";
}
}
},
 
_printDebugSQL: function(sql, args){
var msg = "dojox.sql(\"" + sql + "\"";
for(var i = 0; i < args.length; i++){
if(typeof args[i] == "string"){
msg += ", \"" + args[i] + "\"";
}else{
msg += ", " + args[i];
}
}
msg += ")";
console.debug(msg);
},
 
_normalizeResults: function(rs){
var results = [];
if(!rs){ return []; }
while(rs.isValidRow()){
var row = {};
for(var i = 0; i < rs.fieldCount(); i++){
var fieldName = rs.fieldName(i);
var fieldValue = rs.field(i);
row[fieldName] = fieldValue;
}
results.push(row);
rs.next();
}
rs.close();
return results;
},
 
_needsEncrypt: function(sql){
return /encrypt\([^\)]*\)/i.test(sql);
},
 
_needsDecrypt: function(sql){
return /decrypt\([^\)]*\)/i.test(sql);
}
});
 
// summary:
// A private class encapsulating any cryptography that must be done
// on a SQL statement. We instantiate this class and have it hold
// it's state so that we can potentially have several encryption
// operations happening at the same time by different SQL statements.
dojo.declare("dojox.sql._SQLCrypto", null, {
constructor: function(action, sql, password, args, callback){
if(action == "encrypt"){
this._execEncryptSQL(sql, password, args, callback);
}else{
this._execDecryptSQL(sql, password, args, callback);
}
},
_execEncryptSQL: function(sql, password, args, callback){
// strip the ENCRYPT/DECRYPT keywords from the SQL
var strippedSQL = this._stripCryptoSQL(sql);
// determine what arguments need encryption
var encryptColumns = this._flagEncryptedArgs(sql, args);
// asynchronously encrypt each argument that needs it
var self = this;
this._encrypt(strippedSQL, password, args, encryptColumns, function(finalArgs){
// execute the SQL
var error = false;
var resultSet = [];
var exp = null;
try{
resultSet = dojox.sql.db.execute(strippedSQL, finalArgs);
}catch(execError){
error = true;
exp = execError.message||execError;
}
// was there an error during SQL execution?
if(exp != null){
if(dojox.sql._autoClose){
try{ dojox.sql.close(); }catch(e){}
}
callback(null, true, exp.toString());
return;
}
// normalize SQL results into a JavaScript object
// we can work with
resultSet = dojox.sql._normalizeResults(resultSet);
if(dojox.sql._autoClose){
dojox.sql.close();
}
// are any decryptions necessary on the result set?
if(dojox.sql._needsDecrypt(sql)){
// determine which of the result set columns needs decryption
var needsDecrypt = self._determineDecryptedColumns(sql);
 
// now decrypt columns asynchronously
// decrypt columns that need it
self._decrypt(resultSet, needsDecrypt, password, function(finalResultSet){
callback(finalResultSet, false, null);
});
}else{
callback(resultSet, false, null);
}
});
},
 
_execDecryptSQL: function(sql, password, args, callback){
// strip the ENCRYPT/DECRYPT keywords from the SQL
var strippedSQL = this._stripCryptoSQL(sql);
// determine which columns needs decryption; this either
// returns the value *, which means all result set columns will
// be decrypted, or it will return the column names that need
// decryption set on a hashtable so we can quickly test a given
// column name; the key is the column name that needs
// decryption and the value is 'true' (i.e. needsDecrypt["someColumn"]
// would return 'true' if it needs decryption, and would be 'undefined'
// or false otherwise)
var needsDecrypt = this._determineDecryptedColumns(sql);
// execute the SQL
var error = false;
var resultSet = [];
var exp = null;
try{
resultSet = dojox.sql.db.execute(strippedSQL, args);
}catch(execError){
error = true;
exp = execError.message||execError;
}
// was there an error during SQL execution?
if(exp != null){
if(dojox.sql._autoClose){
try{ dojox.sql.close(); }catch(e){}
}
callback(resultSet, true, exp.toString());
return;
}
// normalize SQL results into a JavaScript object
// we can work with
resultSet = dojox.sql._normalizeResults(resultSet);
if(dojox.sql._autoClose){
dojox.sql.close();
}
// decrypt columns that need it
this._decrypt(resultSet, needsDecrypt, password, function(finalResultSet){
callback(finalResultSet, false, null);
});
},
 
_encrypt: function(sql, password, args, encryptColumns, callback){
//console.debug("_encrypt, sql="+sql+", password="+password+", encryptColumns="+encryptColumns+", args="+args);
this._totalCrypto = 0;
this._finishedCrypto = 0;
this._finishedSpawningCrypto = false;
this._finalArgs = args;
for(var i = 0; i < args.length; i++){
if(encryptColumns[i]){
// we have an encrypt() keyword -- get just the value inside
// the encrypt() parantheses -- for now this must be a ?
var sqlParam = args[i];
var paramIndex = i;
// update the total number of encryptions we know must be done asynchronously
this._totalCrypto++;
// FIXME: This currently uses DES as a proof-of-concept since the
// DES code used is quite fast and was easy to work with. Modify dojox.sql
// to be able to specify a different encryption provider through a
// a SQL-like syntax, such as dojox.sql("SET ENCRYPTION BLOWFISH"),
// and modify the dojox.crypto.Blowfish code to be able to work using
// a Google Gears Worker Pool
// do the actual encryption now, asychronously on a Gears worker thread
dojox._sql._crypto.encrypt(sqlParam, password, dojo.hitch(this, function(results){
// set the new encrypted value
this._finalArgs[paramIndex] = results;
this._finishedCrypto++;
// are we done with all encryption?
if(this._finishedCrypto >= this._totalCrypto
&& this._finishedSpawningCrypto){
callback(this._finalArgs);
}
}));
}
}
this._finishedSpawningCrypto = true;
},
 
_decrypt: function(resultSet, needsDecrypt, password, callback){
//console.debug("decrypt, resultSet="+resultSet+", needsDecrypt="+needsDecrypt+", password="+password);
this._totalCrypto = 0;
this._finishedCrypto = 0;
this._finishedSpawningCrypto = false;
this._finalResultSet = resultSet;
for(var i = 0; i < resultSet.length; i++){
var row = resultSet[i];
// go through each of the column names in row,
// seeing if they need decryption
for(var columnName in row){
if(needsDecrypt == "*" || needsDecrypt[columnName]){
this._totalCrypto++;
var columnValue = row[columnName];
// forming a closure here can cause issues, with values not cleanly
// saved on Firefox/Mac OS X for some of the values above that
// are needed in the callback below; call a subroutine that will form
// a closure inside of itself instead
this._decryptSingleColumn(columnName, columnValue, password, i,
function(finalResultSet){
callback(finalResultSet);
});
}
}
}
this._finishedSpawningCrypto = true;
},
 
_stripCryptoSQL: function(sql){
// replace all DECRYPT(*) occurrences with a *
sql = sql.replace(/DECRYPT\(\*\)/ig, "*");
// match any ENCRYPT(?, ?, ?, etc) occurrences,
// then replace with just the question marks in the
// middle
var matches = sql.match(/ENCRYPT\([^\)]*\)/ig);
if(matches != null){
for(var i = 0; i < matches.length; i++){
var encryptStatement = matches[i];
var encryptValue = encryptStatement.match(/ENCRYPT\(([^\)]*)\)/i)[1];
sql = sql.replace(encryptStatement, encryptValue);
}
}
// match any DECRYPT(COL1, COL2, etc) occurrences,
// then replace with just the column names
// in the middle
matches = sql.match(/DECRYPT\([^\)]*\)/ig);
if(matches != null){
for(var i = 0; i < matches.length; i++){
var decryptStatement = matches[i];
var decryptValue = decryptStatement.match(/DECRYPT\(([^\)]*)\)/i)[1];
sql = sql.replace(decryptStatement, decryptValue);
}
}
return sql;
},
 
_flagEncryptedArgs: function(sql, args){
// capture literal strings that have question marks in them,
// and also capture question marks that stand alone
var tester = new RegExp(/([\"][^\"]*\?[^\"]*[\"])|([\'][^\']*\?[^\']*[\'])|(\?)/ig);
var matches;
var currentParam = 0;
var results = [];
while((matches = tester.exec(sql)) != null){
var currentMatch = RegExp.lastMatch+"";
 
// are we a literal string? then ignore it
if(/^[\"\']/.test(currentMatch)){
continue;
}
 
// do we have an encrypt keyword to our left?
var needsEncrypt = false;
if(/ENCRYPT\([^\)]*$/i.test(RegExp.leftContext)){
needsEncrypt = true;
}
 
// set the encrypted flag
results[currentParam] = needsEncrypt;
 
currentParam++;
}
return results;
},
 
_determineDecryptedColumns: function(sql){
var results = {};
 
if(/DECRYPT\(\*\)/i.test(sql)){
results = "*";
}else{
var tester = /DECRYPT\((?:\s*\w*\s*\,?)*\)/ig;
var matches;
while(matches = tester.exec(sql)){
var lastMatch = new String(RegExp.lastMatch);
var columnNames = lastMatch.replace(/DECRYPT\(/i, "");
columnNames = columnNames.replace(/\)/, "");
columnNames = columnNames.split(/\s*,\s*/);
dojo.forEach(columnNames, function(column){
if(/\s*\w* AS (\w*)/i.test(column)){
column = column.match(/\s*\w* AS (\w*)/i)[1];
}
results[column] = true;
});
}
}
 
return results;
},
 
_decryptSingleColumn: function(columnName, columnValue, password, currentRowIndex,
callback){
//console.debug("decryptSingleColumn, columnName="+columnName+", columnValue="+columnValue+", currentRowIndex="+currentRowIndex)
dojox._sql._crypto.decrypt(columnValue, password, dojo.hitch(this, function(results){
// set the new decrypted value
this._finalResultSet[currentRowIndex][columnName] = results;
this._finishedCrypto++;
// are we done with all encryption?
if(this._finishedCrypto >= this._totalCrypto
&& this._finishedSpawningCrypto){
//console.debug("done with all decrypts");
callback(this._finalResultSet);
}
}));
}
});
 
}
 
if(!dojo._hasResource["dojox.sql"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.sql"] = true;
 
dojo.provide("dojox.sql");
 
}
 
if(!dojo._hasResource["dojox.storage.GearsStorageProvider"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.storage.GearsStorageProvider"] = true;
dojo.provide("dojox.storage.GearsStorageProvider");
 
 
 
 
if(dojo.isGears){
(function(){
// make sure we don't define the gears provider if we're not gears
// enabled
dojo.declare("dojox.storage.GearsStorageProvider", dojox.storage.Provider, {
// summary:
// Storage provider that uses the features of Google Gears
// to store data (it is saved into the local SQL database
// provided by Gears, using dojox.sql)
// description:
//
//
// You can disable this storage provider with the following djConfig
// variable:
// var djConfig = { disableGearsStorage: true };
//
// Authors of this storage provider-
// Brad Neuberg, bkn3@columbia.edu
constructor: function(){
},
// instance methods and properties
TABLE_NAME: "__DOJO_STORAGE",
initialized: false,
_available: null,
initialize: function(){
//console.debug("dojox.storage.GearsStorageProvider.initialize");
if(djConfig["disableGearsStorage"] == true){
return;
}
// partition our storage data so that multiple apps
// on the same host won't collide
this.TABLE_NAME = "__DOJO_STORAGE";
// create the table that holds our data
try{
dojox.sql("CREATE TABLE IF NOT EXISTS " + this.TABLE_NAME + "( "
+ " namespace TEXT, "
+ " key TEXT, "
+ " value TEXT "
+ ")"
);
dojox.sql("CREATE UNIQUE INDEX IF NOT EXISTS namespace_key_index"
+ " ON " + this.TABLE_NAME
+ " (namespace, key)");
}catch(e){
console.debug("dojox.storage.GearsStorageProvider.initialize:", e);
this.initialized = false; // we were unable to initialize
dojox.storage.manager.loaded();
return;
}
// indicate that this storage provider is now loaded
this.initialized = true;
dojox.storage.manager.loaded();
},
isAvailable: function(){
// is Google Gears available and defined?
return this._available = dojo.isGears;
},
 
put: function(key, value, resultsHandler, namespace){
if(this.isValidKey(key) == false){
throw new Error("Invalid key given: " + key);
}
namespace = namespace||this.DEFAULT_NAMESPACE;
// serialize the value;
// handle strings differently so they have better performance
if(dojo.isString(value)){
value = "string:" + value;
}else{
value = dojo.toJson(value);
}
// try to store the value
try{
dojox.sql("DELETE FROM " + this.TABLE_NAME
+ " WHERE namespace = ? AND key = ?",
namespace, key);
dojox.sql("INSERT INTO " + this.TABLE_NAME
+ " VALUES (?, ?, ?)",
namespace, key, value);
}catch(e){
// indicate we failed
console.debug("dojox.storage.GearsStorageProvider.put:", e);
resultsHandler(this.FAILED, key, e.toString());
return;
}
if(resultsHandler){
resultsHandler(dojox.storage.SUCCESS, key, null);
}
},
 
get: function(key, namespace){
if(this.isValidKey(key) == false){
throw new Error("Invalid key given: " + key);
}
namespace = namespace||this.DEFAULT_NAMESPACE;
// try to find this key in the database
var results = dojox.sql("SELECT * FROM " + this.TABLE_NAME
+ " WHERE namespace = ? AND "
+ " key = ?",
namespace, key);
if(!results.length){
return null;
}else{
results = results[0].value;
}
// destringify the content back into a
// real JavaScript object;
// handle strings differently so they have better performance
if(dojo.isString(results) && (/^string:/.test(results))){
results = results.substring("string:".length);
}else{
results = dojo.fromJson(results);
}
return results;
},
getNamespaces: function(){
var results = [ dojox.storage.DEFAULT_NAMESPACE ];
var rs = dojox.sql("SELECT namespace FROM " + this.TABLE_NAME
+ " DESC GROUP BY namespace");
for(var i = 0; i < rs.length; i++){
if(rs[i].namespace != dojox.storage.DEFAULT_NAMESPACE){
results.push(rs[i].namespace);
}
}
return results;
},
 
getKeys: function(namespace){
namespace = namespace||this.DEFAULT_NAMESPACE;
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
var rs = dojox.sql("SELECT key FROM " + this.TABLE_NAME
+ " WHERE namespace = ?",
namespace);
var results = [];
for(var i = 0; i < rs.length; i++){
results.push(rs[i].key);
}
return results;
},
 
clear: function(namespace){
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
namespace = namespace||this.DEFAULT_NAMESPACE;
dojox.sql("DELETE FROM " + this.TABLE_NAME
+ " WHERE namespace = ?",
namespace);
},
remove: function(key, namespace){
namespace = namespace||this.DEFAULT_NAMESPACE;
dojox.sql("DELETE FROM " + this.TABLE_NAME
+ " WHERE namespace = ? AND"
+ " key = ?",
namespace,
key);
},
putMultiple: function(keys, values, resultsHandler, namespace) {
if(this.isValidKeyArray(keys) === false
|| ! values instanceof Array
|| keys.length != values.length){
throw new Error("Invalid arguments: keys = ["
+ keys + "], values = [" + values + "]");
}
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
this._statusHandler = resultsHandler;
 
// try to store the value
try{
dojox.sql.open();
dojox.sql.db.execute("BEGIN TRANSACTION");
var _stmt = "REPLACE INTO " + this.TABLE_NAME + " VALUES (?, ?, ?)";
for(var i=0;i<keys.length;i++) {
// serialize the value;
// handle strings differently so they have better performance
var value = values[i];
if(dojo.isString(value)){
value = "string:" + value;
}else{
value = dojo.toJson(value);
}
dojox.sql.db.execute( _stmt,
[namespace, keys[i], value]);
}
dojox.sql.db.execute("COMMIT TRANSACTION");
dojox.sql.close();
}catch(e){
// indicate we failed
console.debug("dojox.storage.GearsStorageProvider.putMultiple:", e);
if(resultsHandler){
resultsHandler(this.FAILED, keys, e.toString());
}
return;
}
if(resultsHandler){
resultsHandler(dojox.storage.SUCCESS, key, null);
}
},
 
getMultiple: function(keys, namespace){
// TODO: Maybe use SELECT IN instead
 
if(this.isValidKeyArray(keys) === false){
throw new ("Invalid key array given: " + keys);
}
if(namespace == null || typeof namespace == "undefined"){
namespace = dojox.storage.DEFAULT_NAMESPACE;
}
if(this.isValidKey(namespace) == false){
throw new Error("Invalid namespace given: " + namespace);
}
var _stmt = "SELECT * FROM " + this.TABLE_NAME +
" WHERE namespace = ? AND " + " key = ?";
var results = [];
for(var i=0;i<keys.length;i++){
var result = dojox.sql( _stmt, namespace, keys[i]);
if( ! result.length){
results[i] = null;
}else{
result = result[0].value;
// destringify the content back into a
// real JavaScript object;
// handle strings differently so they have better performance
if(dojo.isString(result) && (/^string:/.test(result))){
results[i] = result.substring("string:".length);
}else{
results[i] = dojo.fromJson(result);
}
}
}
return results;
},
removeMultiple: function(keys, namespace){
namespace = namespace||this.DEFAULT_NAMESPACE;
dojox.sql.open();
dojox.sql.db.execute("BEGIN TRANSACTION");
var _stmt = "DELETE FROM " + this.TABLE_NAME + " WHERE namespace = ? AND key = ?";
 
for(var i=0;i<keys.length;i++){
dojox.sql.db.execute( _stmt,
[namespace, keys[i]]);
}
dojox.sql.db.execute("COMMIT TRANSACTION");
dojox.sql.close();
},
isPermanent: function(){ return true; },
 
getMaximumSize: function(){ return this.SIZE_NO_LIMIT; },
 
hasSettingsUI: function(){ return false; },
showSettingsUI: function(){
throw new Error(this.declaredClass
+ " does not support a storage settings user-interface");
},
hideSettingsUI: function(){
throw new Error(this.declaredClass
+ " does not support a storage settings user-interface");
}
});
 
// register the existence of our storage providers
dojox.storage.manager.register("dojox.storage.GearsStorageProvider",
new dojox.storage.GearsStorageProvider());
dojox.storage.manager.initialize();
})();
}
 
}
 
if(!dojo._hasResource["dojox.storage._common"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.storage._common"] = true;
dojo.provide("dojox.storage._common");
 
 
 
 
 
// FIXME: Find way to set isGears from offline.profile.js file; it didn't
// work for me
//dojo.requireIf(!dojo.isGears, "dojox.storage.FlashStorageProvider");
//dojo.requireIf(!dojo.isGears, "dojox.storage.WhatWGStorageProvider");
 
// now that we are loaded and registered tell the storage manager to
// initialize itself
dojox.storage.manager.initialize();
 
}
 
if(!dojo._hasResource["dojox.storage"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.storage"] = true;
dojo.provide("dojox.storage");
 
 
}
 
if(!dojo._hasResource["dojox.off.files"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.off.files"] = true;
dojo.provide("dojox.off.files");
 
// Author: Brad Neuberg, bkn3@columbia.edu, http://codinginparadise.org
 
// summary:
// Helps maintain resources that should be
// available offline, such as CSS files.
// description:
// dojox.off.files makes it easy to indicate
// what resources should be available offline,
// such as CSS files, JavaScript, HTML, etc.
dojox.off.files = {
// versionURL: String
// An optional file, that if present, records the version
// of our bundle of files to make available offline. If this
// file is present, and we are not currently debugging,
// then we only refresh our offline files if the version has
// changed.
versionURL: "version.js",
// listOfURLs: Array
// For advanced usage; most developers can ignore this.
// Our list of URLs that will be cached and made available
// offline.
listOfURLs: [],
// refreshing: boolean
// For advanced usage; most developers can ignore this.
// Whether we are currently in the middle
// of refreshing our list of offline files.
refreshing: false,
 
_cancelID: null,
_error: false,
_errorMessages: [],
_currentFileIndex: 0,
_store: null,
_doSlurp: false,
slurp: function(){
// summary:
// Autoscans the page to find all resources to
// cache. This includes scripts, images, CSS, and hyperlinks
// to pages that are in the same scheme/port/host as this
// page. We also scan the embedded CSS of any stylesheets
// to find @import statements and url()'s.
// You should call this method from the top-level, outside of
// any functions and before the page loads:
//
// <script>
//
//
//
//
//
// // configure how we should work offline
//
// // set our application name
// dojox.off.ui.appName = "Moxie";
//
// // automatically "slurp" the page and
// // capture the resources we need offline
// dojox.off.files.slurp();
//
// // tell Dojo Offline we are ready for it to initialize itself now
// // that we have finished configuring it for our application
// dojox.off.initialize();
// </script>
//
// Note that inline styles on elements are not handled (i.e.
// if you somehow have an inline style that uses a URL);
// object and embed tags are not scanned since their format
// differs based on type; and elements created by JavaScript
// after page load are not found. For these you must manually
// add them with a dojox.off.files.cache() method call.
// just schedule the slurp once the page is loaded and
// Dojo Offline is ready to slurp; dojox.off will call
// our _slurp() method before indicating it is finished
// loading
this._doSlurp = true;
},
cache: function(urlOrList){ /* void */
// summary:
// Caches a file or list of files to be available offline. This
// can either be a full URL, such as http://foobar.com/index.html,
// or a relative URL, such as ../index.html. This URL is not
// actually cached until dojox.off.sync.synchronize() is called.
// urlOrList: String or Array[]
// A URL of a file to cache or an Array of Strings of files to
// cache
//console.debug("dojox.off.files.cache, urlOrList="+urlOrList);
if(dojo.isString(urlOrList)){
var url = this._trimAnchor(urlOrList+"");
if(!this.isAvailable(url)){
this.listOfURLs.push(url);
}
}else if(urlOrList instanceof dojo._Url){
var url = this._trimAnchor(urlOrList.uri);
if(!this.isAvailable(url)){
this.listOfURLs.push(url);
}
}else{
dojo.forEach(urlOrList, function(url){
url = this._trimAnchor(url);
if(!this.isAvailable(url)){
this.listOfURLs.push(url);
}
}, this);
}
},
printURLs: function(){
// summary:
// A helper function that will dump and print out
// all of the URLs that are cached for offline
// availability. This can help with debugging if you
// are trying to make sure that all of your URLs are
// available offline
console.debug("The following URLs are cached for offline use:");
dojo.forEach(this.listOfURLs, function(i){
console.debug(i);
});
},
remove: function(url){ /* void */
// summary:
// Removes a URL from the list of files to cache.
// description:
// Removes a URL from the list of URLs to cache. Note that this
// does not actually remove the file from the offline cache;
// instead, it just prevents us from refreshing this file at a
// later time, so that it will naturally time out and be removed
// from the offline cache
// url: String
// The URL to remove
for(var i = 0; i < this.listOfURLs.length; i++){
if(this.listOfURLs[i] == url){
this.listOfURLs = this.listOfURLs.splice(i, 1);
break;
}
}
},
isAvailable: function(url){ /* boolean */
// summary:
// Determines whether the given resource is available offline.
// url: String
// The URL to check
for(var i = 0; i < this.listOfURLs.length; i++){
if(this.listOfURLs[i] == url){
return true;
}
}
return false;
},
refresh: function(callback){ /* void */
//console.debug("dojox.off.files.refresh");
// summary:
// For advanced usage; most developers can ignore this.
// Refreshes our list of offline resources,
// making them available offline.
// callback: Function
// A callback that receives two arguments: whether an error
// occurred, which is a boolean; and an array of error message strings
// with details on errors encountered. If no error occured then message is
// empty array with length 0.
try{
if(djConfig.isDebug){
this.printURLs();
}
this.refreshing = true;
if(this.versionURL){
this._getVersionInfo(function(oldVersion, newVersion, justDebugged){
//console.warn("getVersionInfo, oldVersion="+oldVersion+", newVersion="+newVersion
// + ", justDebugged="+justDebugged+", isDebug="+djConfig.isDebug);
if(djConfig.isDebug || !newVersion || justDebugged
|| !oldVersion || oldVersion != newVersion){
console.warn("Refreshing offline file list");
this._doRefresh(callback, newVersion);
}else{
console.warn("No need to refresh offline file list");
callback(false, []);
}
});
}else{
console.warn("Refreshing offline file list");
this._doRefresh(callback);
}
}catch(e){
this.refreshing = false;
// can't refresh files -- core operation --
// fail fast
dojox.off.coreOpFailed = true;
dojox.off.enabled = false;
dojox.off.onFrameworkEvent("coreOperationFailed");
}
},
abortRefresh: function(){
// summary:
// For advanced usage; most developers can ignore this.
// Aborts and cancels a refresh.
if(!this.refreshing){
return;
}
this._store.abortCapture(this._cancelID);
this.refreshing = false;
},
_slurp: function(){
if(!this._doSlurp){
return;
}
var handleUrl = dojo.hitch(this, function(url){
if(this._sameLocation(url)){
this.cache(url);
}
});
handleUrl(window.location.href);
dojo.query("script").forEach(function(i){
try{
handleUrl(i.getAttribute("src"));
}catch(exp){
//console.debug("dojox.off.files.slurp 'script' error: "
// + exp.message||exp);
}
});
dojo.query("link").forEach(function(i){
try{
if(!i.getAttribute("rel")
|| i.getAttribute("rel").toLowerCase() != "stylesheet"){
return;
}
handleUrl(i.getAttribute("href"));
}catch(exp){
//console.debug("dojox.off.files.slurp 'link' error: "
// + exp.message||exp);
}
});
dojo.query("img").forEach(function(i){
try{
handleUrl(i.getAttribute("src"));
}catch(exp){
//console.debug("dojox.off.files.slurp 'img' error: "
// + exp.message||exp);
}
});
dojo.query("a").forEach(function(i){
try{
handleUrl(i.getAttribute("href"));
}catch(exp){
//console.debug("dojox.off.files.slurp 'a' error: "
// + exp.message||exp);
}
});
// FIXME: handle 'object' and 'embed' tag
// parse our style sheets for inline URLs and imports
dojo.forEach(document.styleSheets, function(sheet){
try{
if(sheet.cssRules){ // Firefox
dojo.forEach(sheet.cssRules, function(rule){
var text = rule.cssText;
if(text){
var matches = text.match(/url\(\s*([^\) ]*)\s*\)/i);
if(!matches){
return;
}
for(var i = 1; i < matches.length; i++){
handleUrl(matches[i])
}
}
});
}else if(sheet.cssText){ // IE
var matches;
var text = sheet.cssText.toString();
// unfortunately, using RegExp.exec seems to be flakey
// for looping across multiple lines on IE using the
// global flag, so we have to simulate it
var lines = text.split(/\f|\r|\n/);
for(var i = 0; i < lines.length; i++){
matches = lines[i].match(/url\(\s*([^\) ]*)\s*\)/i);
if(matches && matches.length){
handleUrl(matches[1]);
}
}
}
}catch(exp){
//console.debug("dojox.off.files.slurp stylesheet parse error: "
// + exp.message||exp);
}
});
//this.printURLs();
},
_sameLocation: function(url){
if(!url){ return false; }
// filter out anchors
if(url.length && url.charAt(0) == "#"){
return false;
}
// FIXME: dojo._Url should be made public;
// it's functionality is very useful for
// parsing URLs correctly, which is hard to
// do right
url = new dojo._Url(url);
// totally relative -- ../../someFile.html
if(!url.scheme && !url.port && !url.host){
return true;
}
// scheme relative with port specified -- brad.com:8080
if(!url.scheme && url.host && url.port
&& window.location.hostname == url.host
&& window.location.port == url.port){
return true;
}
// scheme relative with no-port specified -- brad.com
if(!url.scheme && url.host && !url.port
&& window.location.hostname == url.host
&& window.location.port == 80){
return true;
}
// else we have everything
return window.location.protocol == (url.scheme + ":")
&& window.location.hostname == url.host
&& (window.location.port == url.port || !window.location.port && !url.port);
},
_trimAnchor: function(url){
return url.replace(/\#.*$/, "");
},
_doRefresh: function(callback, newVersion){
// get our local server
var localServer;
try{
localServer = google.gears.factory.create("beta.localserver", "1.0");
}catch(exp){
dojo.setObject("google.gears.denied", true);
dojox.off.onFrameworkEvent("coreOperationFailed");
throw "Google Gears must be allowed to run";
}
var storeName = "dot_store_"
+ window.location.href.replace(/[^0-9A-Za-z_]/g, "_");
// refresh everything by simply removing
// any older stores
localServer.removeStore(storeName);
// open/create the resource store
localServer.openStore(storeName);
var store = localServer.createStore(storeName);
this._store = store;
 
// add our list of files to capture
var self = this;
this._currentFileIndex = 0;
this._cancelID = store.capture(this.listOfURLs, function(url, success, captureId){
//console.debug("store.capture, url="+url+", success="+success);
if(!success && self.refreshing){
self._cancelID = null;
self.refreshing = false;
var errorMsgs = [];
errorMsgs.push("Unable to capture: " + url);
callback(true, errorMsgs);
return;
}else if(success){
self._currentFileIndex++;
}
if(success && self._currentFileIndex >= self.listOfURLs.length){
self._cancelID = null;
self.refreshing = false;
if(newVersion){
dojox.storage.put("oldVersion", newVersion, null,
dojox.off.STORAGE_NAMESPACE);
}
dojox.storage.put("justDebugged", djConfig.isDebug, null,
dojox.off.STORAGE_NAMESPACE);
callback(false, []);
}
});
},
_getVersionInfo: function(callback){
var justDebugged = dojox.storage.get("justDebugged",
dojox.off.STORAGE_NAMESPACE);
var oldVersion = dojox.storage.get("oldVersion",
dojox.off.STORAGE_NAMESPACE);
var newVersion = null;
callback = dojo.hitch(this, callback);
dojo.xhrGet({
url: this.versionURL + "?browserbust=" + new Date().getTime(),
timeout: 5 * 1000,
handleAs: "javascript",
error: function(err){
//console.warn("dojox.off.files._getVersionInfo, err=",err);
dojox.storage.remove("oldVersion", dojox.off.STORAGE_NAMESPACE);
dojox.storage.remove("justDebugged", dojox.off.STORAGE_NAMESPACE);
callback(oldVersion, newVersion, justDebugged);
},
load: function(data){
//console.warn("dojox.off.files._getVersionInfo, load=",data);
// some servers incorrectly return 404's
// as a real page
if(data){
newVersion = data;
}
callback(oldVersion, newVersion, justDebugged);
}
});
}
}
 
}
 
if(!dojo._hasResource["dojox.off.sync"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.off.sync"] = true;
dojo.provide("dojox.off.sync");
 
 
 
 
 
// Author: Brad Neuberg, bkn3@columbia.edu, http://codinginparadise.org
 
// summary:
// Exposes syncing functionality to offline applications
dojo.mixin(dojox.off.sync, {
// isSyncing: boolean
// Whether we are in the middle of a syncing session.
isSyncing: false,
// cancelled: boolean
// Whether we were cancelled during our last sync request or not. If
// we are cancelled, then successful will be false.
cancelled: false,
// successful: boolean
// Whether the last sync was successful or not. If false, an error
// occurred.
successful: true,
// details: String[]
// Details on the sync. If the sync was successful, this will carry
// any conflict or merging messages that might be available; if the
// sync was unsuccessful, this will have an error message. For both
// of these, this should be an array of Strings, where each string
// carries details on the sync.
// Example:
// dojox.off.sync.details = ["The document 'foobar' had conflicts - yours one",
// "The document 'hello world' was automatically merged"];
details: [],
// error: boolean
// Whether an error occurred during the syncing process.
error: false,
// actions: dojox.off.sync.ActionLog
// Our ActionLog that we store offline actions into for later
// replaying when we go online
actions: null,
// autoSync: boolean
// For advanced usage; most developers can ignore this.
// Whether we do automatically sync on page load or when we go online.
// If true we do, if false syncing must be manually initiated.
// Defaults to true.
autoSync: true,
// summary:
// An event handler that is called during the syncing process with
// the state of syncing. It is important that you connect to this
// method and respond to certain sync events, especially the
// "download" event.
// description:
// This event handler is called during the syncing process. You can
// do a dojo.connect to receive sync feedback:
//
// dojo.connect(dojox.off.sync, "onSync", someFunc);
//
// You will receive one argument, which is the type of the event
// and which can have the following values.
//
// The most common two types that you need to care about are "download"
// and "finished", especially if you are using the default
// Dojo Offline UI widget that does the hard work of informing
// the user through the UI about what is occuring during syncing.
//
// If you receive the "download" event, you should make a network call
// to retrieve and store your data somehow for offline access. The
// "finished" event indicates that syncing is done. An example:
//
// dojo.connect(dojox.off.sync, "onSync", function(type){
// if(type == "download"){
// // make a network call to download some data
// // for use offline
// dojo.xhrGet({
// url: "downloadData.php",
// handleAs: "javascript",
// error: function(err){
// dojox.off.sync.finishedDownloading(false, "Can't download data");
// },
// load: function(data){
// // store our data
// dojox.storage.put("myData", data);
//
// // indicate we are finished downloading
// dojox.off.sync.finishedDownloading(true);
// }
// });
// }else if(type == "finished"){
// // update UI somehow to indicate we are finished,
// // such as using the download data to change the
// // available data
// }
// })
//
// Here is the full list of event types if you want to do deep
// customization, such as updating your UI to display the progress
// of syncing (note that the default Dojo Offline UI widget does
// this for you if you choose to pull that in). Most of these
// are only appropriate for advanced usage and can be safely
// ignored:
//
// * "start"
// syncing has started
// * "refreshFiles"
// syncing will begin refreshing
// our offline file cache
// * "upload"
// syncing will begin uploading
// any local data changes we have on the client.
// This event is fired before we fire
// the dojox.off.sync.actions.onReplay event for
// each action to replay; use it to completely
// over-ride the replaying behavior and prevent
// it entirely, perhaps rolling your own sync
// protocol if needed.
// * "download"
// syncing will begin downloading any new data that is
// needed into persistent storage. Applications are required to
// implement this themselves, storing the required data into
// persistent local storage using Dojo Storage.
// * "finished"
// syncing is finished; this
// will be called whether an error ocurred or not; check
// dojox.off.sync.successful and dojox.off.sync.error for sync details
// * "cancel"
// Fired when canceling has been initiated; canceling will be
// attempted, followed by the sync event "finished".
onSync: function(/* String */ type){},
synchronize: function(){ /* void */
// summary: Starts synchronizing
 
//dojo.debug("synchronize");
if(this.isSyncing || dojox.off.goingOnline || (!dojox.off.isOnline)){
return;
}
this.isSyncing = true;
this.successful = false;
this.details = [];
this.cancelled = false;
this.start();
},
cancel: function(){ /* void */
// summary:
// Attempts to cancel this sync session
if(!this.isSyncing){ return; }
this.cancelled = true;
if(dojox.off.files.refreshing){
dojox.off.files.abortRefresh();
}
this.onSync("cancel");
},
finishedDownloading: function(successful /* boolean? */,
errorMessage /* String? */){
// summary:
// Applications call this method from their
// after getting a "download" event in
// dojox.off.sync.onSync to signal that
// they are finished downloading any data
// that should be available offline
// successful: boolean?
// Whether our downloading was successful or not.
// If not present, defaults to true.
// errorMessage: String?
// If unsuccessful, a message explaining why
if(typeof successful == "undefined"){
successful = true;
}
if(!successful){
this.successful = false;
this.details.push(errorMessage);
this.error = true;
}
this.finished();
},
start: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Called at the start of the syncing process. Advanced
// developers can over-ride this method to use their
// own sync mechanism to start syncing.
if(this.cancelled){
this.finished();
return;
}
this.onSync("start");
this.refreshFiles();
},
refreshFiles: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Called when we are going to refresh our list
// of offline files during syncing. Advanced developers
// can over-ride this method to do some advanced magic related to
// refreshing files.
//dojo.debug("refreshFiles");
if(this.cancelled){
this.finished();
return;
}
this.onSync("refreshFiles");
dojox.off.files.refresh(dojo.hitch(this, function(error, errorMessages){
if(error){
this.error = true;
this.successful = false;
for(var i = 0; i < errorMessages.length; i++){
this.details.push(errorMessages[i]);
}
// even if we get an error while syncing files,
// keep syncing so we can upload and download
// data
}
this.upload();
}));
},
upload: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Called when syncing wants to upload data. Advanced
// developers can over-ride this method to completely
// throw away the Action Log and replaying system
// and roll their own advanced sync mechanism if needed.
if(this.cancelled){
this.finished();
return;
}
this.onSync("upload");
// when we are done uploading start downloading
dojo.connect(this.actions, "onReplayFinished", this, this.download);
// replay the actions log
this.actions.replay();
},
download: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Called when syncing wants to download data. Advanced
// developers can over-ride this method to use their
// own sync mechanism.
if(this.cancelled){
this.finished();
return;
}
// apps should respond to the "download"
// event to download their data; when done
// they must call dojox.off.sync.finishedDownloading()
this.onSync("download");
},
finished: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Called when syncing is finished. Advanced
// developers can over-ride this method to clean
// up after finishing their own sync
// mechanism they might have rolled.
this.isSyncing = false;
this.successful = (!this.cancelled && !this.error);
this.onSync("finished");
},
_save: function(callback){
this.actions._save(function(){
callback();
});
},
_load: function(callback){
this.actions._load(function(){
callback();
});
}
});
 
 
// summary:
// A class that records actions taken by a user when they are offline,
// suitable for replaying when the network reappears.
// description:
// The basic idea behind this method is to record user actions that would
// normally have to contact a server into an action log when we are
// offline, so that later when we are online we can simply replay this log
// in the order user actions happened so that they can be executed against
// the server, causing synchronization to happen.
//
// When we replay, for each of the actions that were added, we call a
// method named onReplay that applications should connect to and
// which will be called over and over for each of our actions --
// applications should take the offline action
// information and use it to talk to a server to have this action
// actually happen online, 'syncing' themselves with the server.
//
// For example, if the action was "update" with the item that was updated, we
// might call some RESTian server API that exists for updating an item in
// our application. The server could either then do sophisticated merging
// and conflict resolution on the server side, for example, allowing you
// to pop up a custom merge UI, or could do automatic merging or nothing
// of the sort. When you are finished with this particular action, your
// application is then required to call continueReplay() on the actionLog object
// passed to onReplay() to continue replaying the action log, or haltReplay()
// with the reason for halting to completely stop the syncing/replaying
// process.
//
// For example, imagine that we have a web application that allows us to add
// contacts. If we are offline, and we update a contact, we would add an action;
// imagine that the user has to click an Update button after changing the values
// for a given contact:
//
// dojox.off.whenOffline(dojo.byId("updateButton"), "onclick", function(evt){
// // get the updated customer values
// var customer = getCustomerValues();
//
// // we are offline -- just record this action
// var action = {name: "update", customer: customer};
// dojox.off.sync.actions.add(action)
//
// // persist this customer data into local storage as well
// dojox.storage.put(customer.name, customer);
// })
//
// Then, when we go back online, the dojox.off.sync.actions.onReplay event
// will fire over and over, once for each action that was recorded while offline:
//
// dojo.connect(dojox.off.sync.actions, "onReplay", function(action, actionLog){
// // called once for each action we added while offline, in the order
// // they were added
// if(action.name == "update"){
// var customer = action.customer;
//
// // call some network service to update this customer
// dojo.xhrPost({
// url: "updateCustomer.php",
// content: {customer: dojo.toJson(customer)},
// error: function(err){
// actionLog.haltReplay(err);
// },
// load: function(data){
// actionLog.continueReplay();
// }
// })
// }
// })
//
// Note that the actions log is always automatically persisted locally while using it, so
// that if the user closes the browser or it crashes the actions will safely be stored
// for later replaying.
dojo.declare("dojox.off.sync.ActionLog", null, {
// entries: Array
// An array of our action entries, where each one is simply a custom
// object literal that were passed to add() when this action entry
// was added.
entries: [],
// reasonHalted: String
// If we halted, the reason why
reasonHalted: null,
// isReplaying: boolean
// If true, we are in the middle of replaying a command log; if false,
// then we are not
isReplaying: false,
// autoSave: boolean
// Whether we automatically save the action log after each call to
// add(); defaults to true. For applications that are rapidly adding
// many action log entries in a short period of time, it can be
// useful to set this to false and simply call save() yourself when
// you are ready to persist your command log -- otherwise performance
// could be slow as the default action is to attempt to persist the
// actions log constantly with calls to add().
autoSave: true,
add: function(action /* Object */){ /* void */
// summary:
// Adds an action to our action log
// description:
// This method will add an action to our
// action log, later to be replayed when we
// go from offline to online. 'action'
// will be available when this action is
// replayed and will be passed to onReplay.
//
// Example usage:
//
// dojox.off.sync.log.add({actionName: "create", itemType: "document",
// {title: "Message", content: "Hello World"}});
//
// The object literal is simply a custom object appropriate
// for our application -- it can be anything that preserves the state
// of a user action that will be executed when we go back online
// and replay this log. In the above example,
// "create" is the name of this action; "documents" is the
// type of item this command is operating on, such as documents, contacts,
// tasks, etc.; and the final argument is the document that was created.
if(this.isReplaying){
throw "Programming error: you can not call "
+ "dojox.off.sync.actions.add() while "
+ "we are replaying an action log";
}
this.entries.push(action);
// save our updated state into persistent
// storage
if(this.autoSave){
this._save();
}
},
onReplay: function(action /* Object */,
actionLog /* dojox.off.sync.ActionLog */){ /* void */
// summary:
// Called when we replay our log, for each of our action
// entries.
// action: Object
// A custom object literal representing an action for this
// application, such as
// {actionName: "create", item: {title: "message", content: "hello world"}}
// actionLog: dojox.off.sync.ActionLog
// A reference to the dojox.off.sync.actions log so that developers
// can easily call actionLog.continueReplay() or actionLog.haltReplay().
// description:
// This callback should be connected to by applications so that
// they can sync themselves when we go back online:
//
// dojo.connect(dojox.off.sync.actions, "onReplay", function(action, actionLog){
// // do something
// })
//
// When we replay our action log, this callback is called for each
// of our action entries in the order they were added. The
// 'action' entry that was passed to add() for this action will
// also be passed in to onReplay, so that applications can use this information
// to do their syncing, such as contacting a server web-service
// to create a new item, for example.
//
// Inside the method you connected to onReplay, you should either call
// actionLog.haltReplay(reason) if an error occurred and you would like to halt
// action replaying or actionLog.continueReplay() to have the action log
// continue replaying its log and proceed to the next action;
// the reason you must call these is the action you execute inside of
// onAction will probably be asynchronous, since it will be talking on
// the network, and you should call one of these two methods based on
// the result of your network call.
},
length: function(){ /* Number */
// summary:
// Returns the length of this
// action log
return this.entries.length;
},
haltReplay: function(reason /* String */){ /* void */
// summary: Halts replaying this command log.
// reason: String
// The reason we halted.
// description:
// This method is called as we are replaying an action log; it
// can be called from dojox.off.sync.actions.onReplay, for
// example, for an application to indicate an error occurred
// while replaying this action, halting further processing of
// the action log. Note that any action log entries that
// were processed before have their effects retained (i.e.
// they are not rolled back), while the action entry that was
// halted stays in our list of actions to later be replayed.
if(!this.isReplaying){
return;
}
if(reason){
this.reasonHalted = reason.toString();
}
// save the state of our action log, then
// tell anyone who is interested that we are
// done when we are finished saving
if(this.autoSave){
var self = this;
this._save(function(){
self.isReplaying = false;
self.onReplayFinished();
});
}else{
this.isReplaying = false;
this.onReplayFinished();
}
},
continueReplay: function(){ /* void */
// summary:
// Indicates that we should continue processing out list of
// actions.
// description:
// This method is called by applications that have overridden
// dojox.off.sync.actions.onReplay() to continue replaying our
// action log after the application has finished handling the
// current action.
if(!this.isReplaying){
return;
}
// shift off the old action we just ran
this.entries.shift();
// are we done?
if(!this.entries.length){
// save the state of our action log, then
// tell anyone who is interested that we are
// done when we are finished saving
if(this.autoSave){
var self = this;
this._save(function(){
self.isReplaying = false;
self.onReplayFinished();
});
return;
}else{
this.isReplaying = false;
this.onReplayFinished();
return;
}
}
// get the next action
var nextAction = this.entries[0];
this.onReplay(nextAction, this);
},
clear: function(){ /* void */
// summary:
// Completely clears this action log of its entries
if(this.isReplaying){
return;
}
this.entries = [];
// save our updated state into persistent
// storage
if(this.autoSave){
this._save();
}
},
replay: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Replays all of the commands that have been
// cached in this command log when we go back online;
// onCommand will be called for each command we have
if(this.isReplaying){
return;
}
this.reasonHalted = null;
if(!this.entries.length){
this.onReplayFinished();
return;
}
this.isReplaying = true;
var nextAction = this.entries[0];
this.onReplay(nextAction, this);
},
// onReplayFinished: Function
// For advanced usage; most developers can ignore this.
// Called when we are finished replaying our commands;
// called if we have successfully exhausted all of our
// commands, or if an error occurred during replaying.
// The default implementation simply continues the
// synchronization process. Connect to this to register
// for the event:
//
// dojo.connect(dojox.off.sync.actions, "onReplayFinished",
// someFunc)
onReplayFinished: function(){
},
 
toString: function(){
var results = "";
results += "[";
for(var i = 0; i < this.entries.length; i++){
results += "{";
for(var j in this.entries[i]){
results += j + ": \"" + this.entries[i][j] + "\"";
results += ", ";
}
results += "}, ";
}
results += "]";
return results;
},
_save: function(callback){
if(!callback){
callback = function(){};
}
try{
var self = this;
var resultsHandler = function(status, key, message){
//console.debug("resultsHandler, status="+status+", key="+key+", message="+message);
if(status == dojox.storage.FAILED){
dojox.off.onFrameworkEvent("save",
{status: dojox.storage.FAILED,
isCoreSave: true,
key: key,
value: message,
namespace: dojox.off.STORAGE_NAMESPACE});
callback();
}else if(status == dojox.storage.SUCCESS){
callback();
}
};
dojox.storage.put("actionlog", this.entries, resultsHandler,
dojox.off.STORAGE_NAMESPACE);
}catch(exp){
console.debug("dojox.off.sync._save: " + exp.message||exp);
dojox.off.onFrameworkEvent("save",
{status: dojox.storage.FAILED,
isCoreSave: true,
key: "actionlog",
value: this.entries,
namespace: dojox.off.STORAGE_NAMESPACE});
callback();
}
},
_load: function(callback){
var entries = dojox.storage.get("actionlog", dojox.off.STORAGE_NAMESPACE);
if(!entries){
entries = [];
}
this.entries = entries;
callback();
}
}
);
 
dojox.off.sync.actions = new dojox.off.sync.ActionLog();
 
}
 
if(!dojo._hasResource["dojox.off._common"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.off._common"] = true;
dojo.provide("dojox.off._common");
 
 
 
 
 
// Author: Brad Neuberg, bkn3@columbia.edu, http://codinginparadise.org
 
// summary:
// dojox.off is the main object for offline applications.
dojo.mixin(dojox.off, {
// isOnline: boolean
// true if we are online, false if not
isOnline: false,
// NET_CHECK: int
// For advanced usage; most developers can ignore this.
// Time in seconds on how often we should check the status of the
// network with an automatic background timer. The current default
// is 5 seconds.
NET_CHECK: 5,
// STORAGE_NAMESPACE: String
// For advanced usage; most developers can ignore this.
// The namespace we use to save core data into Dojo Storage.
STORAGE_NAMESPACE: "_dot",
// enabled: boolean
// For advanced usage; most developers can ignore this.
// Whether offline ability is enabled or not. Defaults to true.
enabled: true,
// availabilityURL: String
// For advanced usage; most developers can ignore this.
// The URL to check for site availability. We do a GET request on
// this URL to check for site availability. By default we check for a
// simple text file in src/off/network_check.txt that has one value
// it, the value '1'.
availabilityURL: dojo.moduleUrl("dojox", "off/network_check.txt"),
// goingOnline: boolean
// For advanced usage; most developers can ignore this.
// True if we are attempting to go online, false otherwise
goingOnline: false,
// coreOpFailed: boolean
// For advanced usage; most developers can ignore this.
// A flag set by the Dojo Offline framework that indicates that the
// user denied some operation that required the offline cache or an
// operation failed in some critical way that was unrecoverable. For
// example, if the offline cache is Google Gears and we try to get a
// Gears database, a popup window appears asking the user whether they
// will approve or deny this request. If the user denies the request,
// and we are doing some operation that is core to Dojo Offline, then
// we set this flag to 'true'. This flag causes a 'fail fast'
// condition, turning off offline ability.
coreOpFailed: false,
// doNetChecking: boolean
// For advanced usage; most developers can ignore this.
// Whether to have a timing interval in the background doing automatic
// network checks at regular intervals; the length of time between
// checks is controlled by dojox.off.NET_CHECK. Defaults to true.
doNetChecking: true,
// hasOfflineCache: boolean
// For advanced usage; most developers can ignore this.
// Determines if an offline cache is available or installed; an
// offline cache is a facility that can truely cache offline
// resources, such as JavaScript, HTML, etc. in such a way that they
// won't be removed from the cache inappropriately like a browser
// cache would. If this is false then an offline cache will be
// installed. Only Google Gears is currently supported as an offline
// cache. Future possible offline caches include Firefox 3.
hasOfflineCache: null,
// browserRestart: boolean
// For advanced usage; most developers can ignore this.
// If true, the browser must be restarted to register the existence of
// a new host added offline (from a call to addHostOffline); if false,
// then nothing is needed.
browserRestart: false,
_STORAGE_APP_NAME: window.location.href.replace(/[^0-9A-Za-z_]/g, "_"),
_initializeCalled: false,
_storageLoaded: false,
_pageLoaded: false,
onLoad: function(){
// summary:
// Called when Dojo Offline can be used.
// description:
// Do a dojo.connect to this to know when you can
// start using Dojo Offline:
// dojo.connect(dojox.off, "onLoad", myFunc);
},
onNetwork: function(type){
// summary:
// Called when our on- or offline- status changes.
// description:
// If we move online, then this method is called with the
// value "online". If we move offline, then this method is
// called with the value "offline". You can connect to this
// method to do add your own behavior:
//
// dojo.connect(dojox.off, "onNetwork", someFunc)
//
// Note that if you are using the default Dojo Offline UI
// widget that most of the on- and off-line notification
// and syncing is automatically handled and provided to the
// user.
// type: String
// Either "online" or "offline".
},
initialize: function(){ /* void */
// summary:
// Called when a Dojo Offline-enabled application is finished
// configuring Dojo Offline, and is ready for Dojo Offline to
// initialize itself.
// description:
// When an application has finished filling out the variables Dojo
// Offline needs to work, such as dojox.off.ui.appName, it must
// this method to tell Dojo Offline to initialize itself.
// Note:
// This method is needed for a rare edge case. In some conditions,
// especially if we are dealing with a compressed Dojo build, the
// entire Dojo Offline subsystem might initialize itself and be
// running even before the JavaScript for an application has had a
// chance to run and configure Dojo Offline, causing Dojo Offline
// to have incorrect initialization parameters for a given app,
// such as no value for dojox.off.ui.appName. This method is
// provided to prevent this scenario, to slightly 'slow down' Dojo
// Offline so it can be configured before running off and doing
// its thing.
 
//console.debug("dojox.off.initialize");
this._initializeCalled = true;
if(this._storageLoaded && this._pageLoaded){
this._onLoad();
}
},
goOffline: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Manually goes offline, away from the network.
if((dojox.off.sync.isSyncing)||(this.goingOnline)){ return; }
this.goingOnline = false;
this.isOnline = false;
},
goOnline: function(callback){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Attempts to go online.
// description:
// Attempts to go online, making sure this web application's web
// site is available. 'callback' is called asychronously with the
// result of whether we were able to go online or not.
// callback: Function
// An optional callback function that will receive one argument:
// whether the site is available or not and is boolean. If this
// function is not present we call dojo.xoff.onOnline instead if
// we are able to go online.
//console.debug("goOnline");
if(dojox.off.sync.isSyncing || dojox.off.goingOnline){
return;
}
this.goingOnline = true;
this.isOnline = false;
// see if can reach our web application's web site
this._isSiteAvailable(callback);
},
onFrameworkEvent: function(type /* String */, saveData /* Object? */){
// summary:
// For advanced usage; most developers can ignore this.
// A standard event handler that can be attached to to find out
// about low-level framework events. Most developers will not need to
// attach to this method; it is meant for low-level information
// that can be useful for updating offline user-interfaces in
// exceptional circumstances. The default Dojo Offline UI
// widget takes care of most of these situations.
// type: String
// The type of the event:
//
// * "offlineCacheInstalled"
// An event that is fired when a user
// has installed an offline cache after the page has been loaded.
// If a user didn't have an offline cache when the page loaded, a
// UI of some kind might have prompted them to download one. This
// method is called if they have downloaded and installed an
// offline cache so a UI can reinitialize itself to begin using
// this offline cache.
// * "coreOperationFailed"
// Fired when a core operation during interaction with the
// offline cache is denied by the user. Some offline caches, such
// as Google Gears, prompts the user to approve or deny caching
// files, using the database, and more. If the user denies a
// request that is core to Dojo Offline's operation, we set
// dojox.off.coreOpFailed to true and call this method for
// listeners that would like to respond some how to Dojo Offline
// 'failing fast'.
// * "save"
// Called whenever the framework saves data into persistent
// storage. This could be useful for providing save feedback
// or providing appropriate error feedback if saving fails
// due to a user not allowing the save to occur
// saveData: Object?
// If the type was 'save', then a saveData object is provided with
// further save information. This object has the following properties:
//
// * status - dojox.storage.SUCCESS, dojox.storage.PENDING, dojox.storage.FAILED
// Whether the save succeeded, whether it is pending based on a UI
// dialog asking the user for permission, or whether it failed.
//
// * isCoreSave - boolean
// If true, then this save was for a core piece of data necessary
// for the functioning of Dojo Offline. If false, then it is a
// piece of normal data being saved for offline access. Dojo
// Offline will 'fail fast' if some core piece of data could not
// be saved, automatically setting dojox.off.coreOpFailed to
// 'true' and dojox.off.enabled to 'false'.
//
// * key - String
// The key that we are attempting to persist
//
// * value - Object
// The object we are trying to persist
//
// * namespace - String
// The Dojo Storage namespace we are saving this key/value pair
// into, such as "default", "Documents", "Contacts", etc.
// Optional.
if(type == "save"){
if(saveData.isCoreSave && (saveData.status == dojox.storage.FAILED)){
dojox.off.coreOpFailed = true;
dojox.off.enabled = false;
// FIXME: Stop the background network thread
dojox.off.onFrameworkEvent("coreOperationFailed");
}
}else if(type == "coreOperationFailed"){
dojox.off.coreOpFailed = true;
dojox.off.enabled = false;
// FIXME: Stop the background network thread
}
},
_checkOfflineCacheAvailable: function(callback){
// is a true, offline cache running on this machine?
this.hasOfflineCache = dojo.isGears;
callback();
},
_onLoad: function(){
//console.debug("dojox.off._onLoad");
// both local storage and the page are finished loading
// cache the Dojo JavaScript -- just use the default dojo.js
// name for the most common scenario
// FIXME: TEST: Make sure syncing doesn't break if dojo.js
// can't be found, or report an error to developer
dojox.off.files.cache(dojo.moduleUrl("dojo", "dojo.js"));
// pull in the files needed by Dojo
this._cacheDojoResources();
// FIXME: need to pull in the firebug lite files here!
// workaround or else we will get an error on page load
// from Dojo that it can't find 'console.debug' for optimized builds
// dojox.off.files.cache(djConfig.baseRelativePath + "src/debug.js");
// make sure that resources needed by all of our underlying
// Dojo Storage storage providers will be available
// offline
dojox.off.files.cache(dojox.storage.manager.getResourceList());
// slurp the page if the end-developer wants that
dojox.off.files._slurp();
// see if we have an offline cache; when done, move
// on to the rest of our startup tasks
this._checkOfflineCacheAvailable(dojo.hitch(this, "_onOfflineCacheChecked"));
},
_onOfflineCacheChecked: function(){
// this method is part of our _onLoad series of startup tasks
// if we have an offline cache, see if we have been added to the
// list of available offline web apps yet
if(this.hasOfflineCache && this.enabled){
// load framework data; when we are finished, continue
// initializing ourselves
this._load(dojo.hitch(this, "_finishStartingUp"));
}else if(this.hasOfflineCache && !this.enabled){
// we have an offline cache, but it is disabled for some reason
// perhaps due to the user denying a core operation
this._finishStartingUp();
}else{
this._keepCheckingUntilInstalled();
}
},
_keepCheckingUntilInstalled: function(){
// this method is part of our _onLoad series of startup tasks
// kick off a background interval that keeps
// checking to see if an offline cache has been
// installed since this page loaded
// FIXME: Gears: See if we are installed somehow after the
// page has been loaded
// now continue starting up
this._finishStartingUp();
},
_finishStartingUp: function(){
//console.debug("dojox.off._finishStartingUp");
// this method is part of our _onLoad series of startup tasks
if(!this.hasOfflineCache){
this.onLoad();
}else if(this.enabled){
// kick off a thread to check network status on
// a regular basis
this._startNetworkThread();
 
// try to go online
this.goOnline(dojo.hitch(this, function(){
//console.debug("Finished trying to go online");
// indicate we are ready to be used
dojox.off.onLoad();
}));
}else{ // we are disabled or a core operation failed
if(this.coreOpFailed){
this.onFrameworkEvent("coreOperationFailed");
}else{
this.onLoad();
}
}
},
_onPageLoad: function(){
//console.debug("dojox.off._onPageLoad");
this._pageLoaded = true;
if(this._storageLoaded && this._initializeCalled){
this._onLoad();
}
},
_onStorageLoad: function(){
//console.debug("dojox.off._onStorageLoad");
this._storageLoaded = true;
// were we able to initialize storage? if
// not, then this is a core operation, and
// let's indicate we will need to fail fast
if(!dojox.storage.manager.isAvailable()
&& dojox.storage.manager.isInitialized()){
this.coreOpFailed = true;
this.enabled = false;
}
if(this._pageLoaded && this._initializeCalled){
this._onLoad();
}
},
_isSiteAvailable: function(callback){
// summary:
// Determines if our web application's website is available.
// description:
// This method will asychronously determine if our web
// application's web site is available, which is a good proxy for
// network availability. The URL dojox.off.availabilityURL is
// used, which defaults to this site's domain name (ex:
// foobar.com). We check for dojox.off.AVAILABILITY_TIMEOUT (in
// seconds) and abort after that
// callback: Function
// An optional callback function that will receive one argument:
// whether the site is available or not and is boolean. If this
// function is not present we call dojox.off.onNetwork instead if we
// are able to go online.
dojo.xhrGet({
url: this._getAvailabilityURL(),
handleAs: "text",
timeout: this.NET_CHECK * 1000,
error: dojo.hitch(this, function(err){
//console.debug("dojox.off._isSiteAvailable.error: " + err);
this.goingOnline = false;
this.isOnline = false;
if(callback){ callback(false); }
}),
load: dojo.hitch(this, function(data){
//console.debug("dojox.off._isSiteAvailable.load, data="+data);
this.goingOnline = false;
this.isOnline = true;
if(callback){ callback(true);
}else{ this.onNetwork("online"); }
})
});
},
_startNetworkThread: function(){
//console.debug("startNetworkThread");
// kick off a thread that does periodic
// checks on the status of the network
if(!this.doNetChecking){
return;
}
window.setInterval(dojo.hitch(this, function(){
var d = dojo.xhrGet({
url: this._getAvailabilityURL(),
handleAs: "text",
timeout: this.NET_CHECK * 1000,
error: dojo.hitch(this,
function(err){
if(this.isOnline){
this.isOnline = false;
// FIXME: xhrGet() is not
// correctly calling abort
// on the XHR object when
// it times out; fix inside
// there instead of externally
// here
try{
if(typeof d.ioArgs.xhr.abort == "function"){
d.ioArgs.xhr.abort();
}
}catch(e){}
// if things fell in the middle of syncing,
// stop syncing
dojox.off.sync.isSyncing = false;
this.onNetwork("offline");
}
}
),
load: dojo.hitch(this,
function(data){
if(!this.isOnline){
this.isOnline = true;
this.onNetwork("online");
}
}
)
});
 
}), this.NET_CHECK * 1000);
},
_getAvailabilityURL: function(){
var url = this.availabilityURL.toString();
// bust the browser's cache to make sure we are really talking to
// the server
if(url.indexOf("?") == -1){
url += "?";
}else{
url += "&";
}
url += "browserbust=" + new Date().getTime();
return url;
},
_onOfflineCacheInstalled: function(){
this.onFrameworkEvent("offlineCacheInstalled");
},
_cacheDojoResources: function(){
// if we are a non-optimized build, then the core Dojo bootstrap
// system was loaded as separate JavaScript files;
// add these to our offline cache list. these are
// loaded before the dojo.require() system exists
// FIXME: create a better mechanism in the Dojo core to
// expose whether you are dealing with an optimized build;
// right now we just scan the SCRIPT tags attached to this
// page and see if there is one for _base/_loader/bootstrap.js
var isOptimizedBuild = true;
dojo.forEach(dojo.query("script"), function(i){
var src = i.getAttribute("src");
if(!src){ return; }
if(src.indexOf("_base/_loader/bootstrap.js") != -1){
isOptimizedBuild = false;
}
});
if(!isOptimizedBuild){
dojox.off.files.cache(dojo.moduleUrl("dojo", "_base.js").uri);
dojox.off.files.cache(dojo.moduleUrl("dojo", "_base/_loader/loader.js").uri);
dojox.off.files.cache(dojo.moduleUrl("dojo", "_base/_loader/bootstrap.js").uri);
// FIXME: pull in the host environment file in a more generic way
// for other host environments
dojox.off.files.cache(dojo.moduleUrl("dojo", "_base/_loader/hostenv_browser.js").uri);
}
// add anything that was brought in with a
// dojo.require() that resulted in a JavaScript
// URL being fetched
// FIXME: modify dojo/_base/_loader/loader.js to
// expose a public API to get this information
for(var i = 0; i < dojo._loadedUrls.length; i++){
dojox.off.files.cache(dojo._loadedUrls[i]);
}
// FIXME: add the standard Dojo CSS file
},
_save: function(){
// summary:
// Causes the Dojo Offline framework to save its configuration
// data into local storage.
},
_load: function(callback){
// summary:
// Causes the Dojo Offline framework to load its configuration
// data from local storage
dojox.off.sync._load(callback);
}
});
 
 
// wait until the storage system is finished loading
dojox.storage.manager.addOnLoad(dojo.hitch(dojox.off, "_onStorageLoad"));
 
// wait until the page is finished loading
dojo.addOnLoad(dojox.off, "_onPageLoad");
 
}
 
if(!dojo._hasResource["dojox.off"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.off"] = true;
dojo.provide("dojox.off");
 
 
}
 
if(!dojo._hasResource["dojox.off.ui"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.off.ui"] = true;
dojo.provide("dojox.off.ui");
 
 
 
 
 
// Author: Brad Neuberg, bkn3@columbia.edu, http://codinginparadise.org
 
// summary:
// dojox.off.ui provides a standard,
// default user-interface for a
// Dojo Offline Widget that can easily
// be dropped into applications that would
// like to work offline.
dojo.mixin(dojox.off.ui, {
// appName: String
// This application's name, such as "Foobar". Note that
// this is a string, not HTML, so embedded markup will
// not work, including entities. Only the following
// characters are allowed: numbers, letters, and spaces.
// You must set this property.
appName: "setme",
// autoEmbed: boolean
// For advanced usage; most developers can ignore this.
// Whether to automatically auto-embed the default Dojo Offline
// widget into this page; default is true.
autoEmbed: true,
// autoEmbedID: String
// For advanced usage; most developers can ignore this.
// The ID of the DOM element that will contain our
// Dojo Offline widget; defaults to the ID 'dot-widget'.
autoEmbedID: "dot-widget",
// runLink: String
// For advanced usage; most developers can ignore this.
// The URL that should be navigated to to run this
// application offline; this will be placed inside of a
// link that the user can drag to their desktop and double
// click. Note that this URL must exactly match the URL
// of the main page of our resource that is offline for
// it to be retrieved from the offline cache correctly.
// For example, if you have cached your main page as
// http://foobar.com/index.html, and you set this to
// http://www.foobar.com/index.html, the run link will
// not work. By default this value is automatically set to
// the URL of this page, so it does not need to be set
// manually unless you have unusual needs.
runLink: window.location.href,
// runLinkTitle: String
// For advanced usage; most developers can ignore this.
// The text that will be inside of the link that a user
// can drag to their desktop to run this application offline.
// By default this is automatically set to "Run " plus your
// application's name.
runLinkTitle: "Run Application",
// learnHowPath: String
// For advanced usage; most developers can ignore this.
// The path to a web page that has information on
// how to use this web app offline; defaults to
// src/off/ui-template/learnhow.html, relative to
// your Dojo installation. Make sure to set
// dojo.to.ui.customLearnHowPath to true if you want
// a custom Learn How page.
learnHowPath: dojo.moduleUrl("dojox", "off/resources/learnhow.html"),
// customLearnHowPath: boolean
// For advanced usage; most developers can ignore this.
// Whether the developer is using their own custom page
// for the Learn How instructional page; defaults to false.
// Use in conjunction with dojox.off.ui.learnHowPath.
customLearnHowPath: false,
htmlTemplatePath: dojo.moduleUrl("dojox", "off/resources/offline-widget.html").uri,
cssTemplatePath: dojo.moduleUrl("dojox", "off/resources/offline-widget.css").uri,
onlineImagePath: dojo.moduleUrl("dojox", "off/resources/greenball.png").uri,
offlineImagePath: dojo.moduleUrl("dojox", "off/resources/redball.png").uri,
rollerImagePath: dojo.moduleUrl("dojox", "off/resources/roller.gif").uri,
checkmarkImagePath: dojo.moduleUrl("dojox", "off/resources/checkmark.png").uri,
learnHowJSPath: dojo.moduleUrl("dojox", "off/resources/learnhow.js").uri,
_initialized: false,
onLoad: function(){
// summary:
// A function that should be connected to allow your
// application to know when Dojo Offline, the page, and
// the Offline Widget are all initialized and ready to be
// used:
//
// dojo.connect(dojox.off.ui, "onLoad", someFunc)
},
 
_initialize: function(){
//console.debug("dojox.off.ui._initialize");
// make sure our app name is correct
if(this._validateAppName(this.appName) == false){
alert("You must set dojox.off.ui.appName; it can only contain "
+ "letters, numbers, and spaces; right now it "
+ "is incorrectly set to '" + dojox.off.ui.appName + "'");
dojox.off.enabled = false;
return;
}
// set our run link text to its default
this.runLinkText = "Run " + this.appName;
// setup our event listeners for Dojo Offline events
// to update our UI
dojo.connect(dojox.off, "onNetwork", this, "_onNetwork");
dojo.connect(dojox.off.sync, "onSync", this, "_onSync");
// cache our default UI resources
dojox.off.files.cache([
this.htmlTemplatePath,
this.cssTemplatePath,
this.onlineImagePath,
this.offlineImagePath,
this.rollerImagePath,
this.checkmarkImagePath
]);
// embed the offline widget UI
if(this.autoEmbed){
this._doAutoEmbed();
}
},
_doAutoEmbed: function(){
// fetch our HTML for the offline widget
 
// dispatch the request
dojo.xhrGet({
url: this.htmlTemplatePath,
handleAs: "text",
error: function(err){
dojox.off.enabled = false;
err = err.message||err;
alert("Error loading the Dojo Offline Widget from "
+ this.htmlTemplatePath + ": " + err);
},
load: dojo.hitch(this, this._templateLoaded)
});
},
_templateLoaded: function(data){
//console.debug("dojox.off.ui._templateLoaded");
// inline our HTML
var container = dojo.byId(this.autoEmbedID);
if(container){ container.innerHTML = data; }
// fill out our image paths
this._initImages();
// update our network indicator status ball
this._updateNetIndicator();
// update our 'Learn How' text
this._initLearnHow();
this._initialized = true;
// check offline cache settings
if(!dojox.off.hasOfflineCache){
this._showNeedsOfflineCache();
return;
}
// check to see if we need a browser restart
// to be able to use this web app offline
if(dojox.off.hasOfflineCache && dojox.off.browserRestart){
this._needsBrowserRestart();
return;
}else{
var browserRestart = dojo.byId("dot-widget-browser-restart");
if(browserRestart){ browserRestart.style.display = "none"; }
}
// update our sync UI
this._updateSyncUI();
// register our event listeners for our main buttons
this._initMainEvtHandlers();
// if offline functionality is disabled, disable everything
this._setOfflineEnabled(dojox.off.enabled);
// update our UI based on the state of the network
this._onNetwork(dojox.off.isOnline ? "online" : "offline");
// try to go online
this._testNet();
},
_testNet: function(){
dojox.off.goOnline(dojo.hitch(this, function(isOnline){
//console.debug("testNet callback, isOnline="+isOnline);
// display our online/offline results
this._onNetwork(isOnline ? "online" : "offline");
// indicate that our default UI
// and Dojo Offline are now ready to
// be used
this.onLoad();
}));
},
_updateNetIndicator: function(){
var onlineImg = dojo.byId("dot-widget-network-indicator-online");
var offlineImg = dojo.byId("dot-widget-network-indicator-offline");
var titleText = dojo.byId("dot-widget-title-text");
if(onlineImg && offlineImg){
if(dojox.off.isOnline == true){
onlineImg.style.display = "inline";
offlineImg.style.display = "none";
}else{
onlineImg.style.display = "none";
offlineImg.style.display = "inline";
}
}
if(titleText){
if(dojox.off.isOnline){
titleText.innerHTML = "Online";
}else{
titleText.innerHTML = "Offline";
}
}
},
_initLearnHow: function(){
var learnHow = dojo.byId("dot-widget-learn-how-link");
if(!learnHow){ return; }
if(!this.customLearnHowPath){
// add parameters to URL so the Learn How page
// can customize itself and display itself
// correctly based on framework settings
var dojoPath = djConfig.baseRelativePath;
this.learnHowPath += "?appName=" + encodeURIComponent(this.appName)
+ "&hasOfflineCache=" + dojox.off.hasOfflineCache
+ "&runLink=" + encodeURIComponent(this.runLink)
+ "&runLinkText=" + encodeURIComponent(this.runLinkText)
+ "&baseRelativePath=" + encodeURIComponent(dojoPath);
// cache our Learn How JavaScript page and
// the HTML version with full query parameters
// so it is available offline without a cache miss
dojox.off.files.cache(this.learnHowJSPath);
dojox.off.files.cache(this.learnHowPath);
}
learnHow.setAttribute("href", this.learnHowPath);
var appName = dojo.byId("dot-widget-learn-how-app-name");
if(!appName){ return; }
appName.innerHTML = "";
appName.appendChild(document.createTextNode(this.appName));
},
_validateAppName: function(appName){
if(!appName){ return false; }
return (/^[a-z0-9 ]*$/i.test(appName));
},
_updateSyncUI: function(){
var roller = dojo.byId("dot-roller");
var checkmark = dojo.byId("dot-success-checkmark");
var syncMessages = dojo.byId("dot-sync-messages");
var details = dojo.byId("dot-sync-details");
var cancel = dojo.byId("dot-sync-cancel");
if(dojox.off.sync.isSyncing){
this._clearSyncMessage();
if(roller){ roller.style.display = "inline"; }
if(checkmark){ checkmark.style.display = "none"; }
if(syncMessages){
dojo.removeClass(syncMessages, "dot-sync-error");
}
if(details){ details.style.display = "none"; }
if(cancel){ cancel.style.display = "inline"; }
}else{
if(roller){ roller.style.display = "none"; }
if(cancel){ cancel.style.display = "none"; }
if(syncMessages){
dojo.removeClass(syncMessages, "dot-sync-error");
}
}
},
_setSyncMessage: function(message){
var syncMessage = dojo.byId("dot-sync-messages");
if(syncMessage){
// when used with Google Gears pre-release in Firefox/Mac OS X,
// the browser would crash when testing in Moxie
// if we set the message this way for some reason.
// Brad Neuberg, bkn3@columbia.edu
//syncMessage.innerHTML = message;
while(syncMessage.firstChild){
syncMessage.removeChild(syncMessage.firstChild);
}
syncMessage.appendChild(document.createTextNode(message));
}
},
_clearSyncMessage: function(){
this._setSyncMessage("");
},
_initImages: function(){
var onlineImg = dojo.byId("dot-widget-network-indicator-online");
if(onlineImg){
onlineImg.setAttribute("src", this.onlineImagePath);
}
var offlineImg = dojo.byId("dot-widget-network-indicator-offline");
if(offlineImg){
offlineImg.setAttribute("src", this.offlineImagePath);
}
var roller = dojo.byId("dot-roller");
if(roller){
roller.setAttribute("src", this.rollerImagePath);
}
var checkmark = dojo.byId("dot-success-checkmark");
if(checkmark){
checkmark.setAttribute("src", this.checkmarkImagePath);
}
},
_showDetails: function(evt){
// cancel the button's default behavior
evt.preventDefault();
evt.stopPropagation();
if(!dojox.off.sync.details.length){
return;
}
// determine our HTML message to display
var html = "";
html += "<html><head><title>Sync Details</title><head><body>";
html += "<h1>Sync Details</h1>\n";
html += "<ul>\n";
for(var i = 0; i < dojox.off.sync.details.length; i++){
html += "<li>";
html += dojox.off.sync.details[i];
html += "</li>";
}
html += "</ul>\n";
html += "<a href='javascript:window.close()' "
+ "style='text-align: right; padding-right: 2em;'>"
+ "Close Window"
+ "</a>\n";
html += "</body></html>";
// open a popup window with this message
var windowParams = "height=400,width=600,resizable=true,"
+ "scrollbars=true,toolbar=no,menubar=no,"
+ "location=no,directories=no,dependent=yes";
 
var popup = window.open("", "SyncDetails", windowParams);
if(!popup){ // aggressive popup blocker
alert("Please allow popup windows for this domain; can't display sync details window");
return;
}
popup.document.open();
popup.document.write(html);
popup.document.close();
// put the focus on the popup window
if(popup.focus){
popup.focus();
}
},
_cancel: function(evt){
// cancel the button's default behavior
evt.preventDefault();
evt.stopPropagation();
dojox.off.sync.cancel();
},
_needsBrowserRestart: function(){
var browserRestart = dojo.byId("dot-widget-browser-restart");
if(browserRestart){
dojo.addClass(browserRestart, "dot-needs-browser-restart");
}
var appName = dojo.byId("dot-widget-browser-restart-app-name");
if(appName){
appName.innerHTML = "";
appName.appendChild(document.createTextNode(this.appName));
}
var status = dojo.byId("dot-sync-status");
if(status){
status.style.display = "none";
}
},
_showNeedsOfflineCache: function(){
var widgetContainer = dojo.byId("dot-widget-container");
if(widgetContainer){
dojo.addClass(widgetContainer, "dot-needs-offline-cache");
}
},
_hideNeedsOfflineCache: function(){
var widgetContainer = dojo.byId("dot-widget-container");
if(widgetContainer){
dojo.removeClass(widgetContainer, "dot-needs-offline-cache");
}
},
_initMainEvtHandlers: function(){
var detailsButton = dojo.byId("dot-sync-details-button");
if(detailsButton){
dojo.connect(detailsButton, "onclick", this, this._showDetails);
}
var cancelButton = dojo.byId("dot-sync-cancel-button");
if(cancelButton){
dojo.connect(cancelButton, "onclick", this, this._cancel);
}
},
_setOfflineEnabled: function(enabled){
var elems = [];
elems.push(dojo.byId("dot-sync-status"));
for(var i = 0; i < elems.length; i++){
if(elems[i]){
elems[i].style.visibility =
(enabled ? "visible" : "hidden");
}
}
},
_syncFinished: function(){
this._updateSyncUI();
var checkmark = dojo.byId("dot-success-checkmark");
var details = dojo.byId("dot-sync-details");
if(dojox.off.sync.successful == true){
this._setSyncMessage("Sync Successful");
if(checkmark){ checkmark.style.display = "inline"; }
}else if(dojox.off.sync.cancelled == true){
this._setSyncMessage("Sync Cancelled");
if(checkmark){ checkmark.style.display = "none"; }
}else{
this._setSyncMessage("Sync Error");
var messages = dojo.byId("dot-sync-messages");
if(messages){
dojo.addClass(messages, "dot-sync-error");
}
if(checkmark){ checkmark.style.display = "none"; }
}
if(dojox.off.sync.details.length && details){
details.style.display = "inline";
}
},
_onFrameworkEvent: function(type, saveData){
if(type == "save"){
if(saveData.status == dojox.storage.FAILED && !saveData.isCoreSave){
alert("Please increase the amount of local storage available "
+ "to this application");
if(dojox.storage.hasSettingsUI()){
dojox.storage.showSettingsUI();
}
// FIXME: Be able to know if storage size has changed
// due to user configuration
}
}else if(type == "coreOperationFailed"){
console.log("Application does not have permission to use Dojo Offline");
if(!this._userInformed){
alert("This application will not work if Google Gears is not allowed to run");
this._userInformed = true;
}
}else if(type == "offlineCacheInstalled"){
// clear out the 'needs offline cache' info
this._hideNeedsOfflineCache();
// check to see if we need a browser restart
// to be able to use this web app offline
if(dojox.off.hasOfflineCache == true
&& dojox.off.browserRestart == true){
this._needsBrowserRestart();
return;
}else{
var browserRestart = dojo.byId("dot-widget-browser-restart");
if(browserRestart){
browserRestart.style.display = "none";
}
}
// update our sync UI
this._updateSyncUI();
// register our event listeners for our main buttons
this._initMainEvtHandlers();
// if offline is disabled, disable everything
this._setOfflineEnabled(dojox.off.enabled);
// try to go online
this._testNet();
}
},
_onSync: function(type){
//console.debug("ui, onSync="+type);
switch(type){
case "start":
this._updateSyncUI();
break;
case "refreshFiles":
this._setSyncMessage("Downloading UI...");
break;
case "upload":
this._setSyncMessage("Uploading new data...");
break;
case "download":
this._setSyncMessage("Downloading new data...");
break;
case "finished":
this._syncFinished();
break;
case "cancel":
this._setSyncMessage("Canceling Sync...");
break;
default:
dojo.warn("Programming error: "
+ "Unknown sync type in dojox.off.ui: " + type);
break;
}
},
_onNetwork: function(type){
// summary:
// Called when we go on- or off-line
// description:
// When we go online or offline, this method is called to update
// our UI. Default behavior is to update the Offline
// Widget UI and to attempt a synchronization.
// type: String
// "online" if we just moved online, and "offline" if we just
// moved offline.
if(!this._initialized){ return; }
// update UI
this._updateNetIndicator();
if(type == "offline"){
this._setSyncMessage("You are working offline");
// clear old details
var details = dojo.byId("dot-sync-details");
if(details){ details.style.display = "none"; }
// if we fell offline during a sync, hide
// the sync info
this._updateSyncUI();
}else{ // online
// synchronize, but pause for a few seconds
// so that the user can orient themselves
if(dojox.off.sync.autoSync){
window.setTimeout("dojox.off.sync.synchronize()", 1000);
}
}
}
});
 
// register ourselves for low-level framework events
dojo.connect(dojox.off, "onFrameworkEvent", dojox.off.ui, "_onFrameworkEvent");
 
// start our magic when the Dojo Offline framework is ready to go
dojo.connect(dojox.off, "onLoad", dojox.off.ui, dojox.off.ui._initialize);
 
}
 
if(!dojo._hasResource["dojox.off.offline"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.off.offline"] = true;
dojo.provide("dojox.off.offline");
 
 
 
 
 
 
 
}
 
/trunk/api/js/dojo1.0/dojox/off/_common.js
New file
0,0 → 1,559
if(!dojo._hasResource["dojox.off._common"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.off._common"] = true;
dojo.provide("dojox.off._common");
 
dojo.require("dojox.storage");
dojo.require("dojox.sql");
dojo.require("dojox.off.sync");
 
// Author: Brad Neuberg, bkn3@columbia.edu, http://codinginparadise.org
 
// summary:
// dojox.off is the main object for offline applications.
dojo.mixin(dojox.off, {
// isOnline: boolean
// true if we are online, false if not
isOnline: false,
// NET_CHECK: int
// For advanced usage; most developers can ignore this.
// Time in seconds on how often we should check the status of the
// network with an automatic background timer. The current default
// is 5 seconds.
NET_CHECK: 5,
// STORAGE_NAMESPACE: String
// For advanced usage; most developers can ignore this.
// The namespace we use to save core data into Dojo Storage.
STORAGE_NAMESPACE: "_dot",
// enabled: boolean
// For advanced usage; most developers can ignore this.
// Whether offline ability is enabled or not. Defaults to true.
enabled: true,
// availabilityURL: String
// For advanced usage; most developers can ignore this.
// The URL to check for site availability. We do a GET request on
// this URL to check for site availability. By default we check for a
// simple text file in src/off/network_check.txt that has one value
// it, the value '1'.
availabilityURL: dojo.moduleUrl("dojox", "off/network_check.txt"),
// goingOnline: boolean
// For advanced usage; most developers can ignore this.
// True if we are attempting to go online, false otherwise
goingOnline: false,
// coreOpFailed: boolean
// For advanced usage; most developers can ignore this.
// A flag set by the Dojo Offline framework that indicates that the
// user denied some operation that required the offline cache or an
// operation failed in some critical way that was unrecoverable. For
// example, if the offline cache is Google Gears and we try to get a
// Gears database, a popup window appears asking the user whether they
// will approve or deny this request. If the user denies the request,
// and we are doing some operation that is core to Dojo Offline, then
// we set this flag to 'true'. This flag causes a 'fail fast'
// condition, turning off offline ability.
coreOpFailed: false,
// doNetChecking: boolean
// For advanced usage; most developers can ignore this.
// Whether to have a timing interval in the background doing automatic
// network checks at regular intervals; the length of time between
// checks is controlled by dojox.off.NET_CHECK. Defaults to true.
doNetChecking: true,
// hasOfflineCache: boolean
// For advanced usage; most developers can ignore this.
// Determines if an offline cache is available or installed; an
// offline cache is a facility that can truely cache offline
// resources, such as JavaScript, HTML, etc. in such a way that they
// won't be removed from the cache inappropriately like a browser
// cache would. If this is false then an offline cache will be
// installed. Only Google Gears is currently supported as an offline
// cache. Future possible offline caches include Firefox 3.
hasOfflineCache: null,
// browserRestart: boolean
// For advanced usage; most developers can ignore this.
// If true, the browser must be restarted to register the existence of
// a new host added offline (from a call to addHostOffline); if false,
// then nothing is needed.
browserRestart: false,
_STORAGE_APP_NAME: window.location.href.replace(/[^0-9A-Za-z_]/g, "_"),
_initializeCalled: false,
_storageLoaded: false,
_pageLoaded: false,
onLoad: function(){
// summary:
// Called when Dojo Offline can be used.
// description:
// Do a dojo.connect to this to know when you can
// start using Dojo Offline:
// dojo.connect(dojox.off, "onLoad", myFunc);
},
onNetwork: function(type){
// summary:
// Called when our on- or offline- status changes.
// description:
// If we move online, then this method is called with the
// value "online". If we move offline, then this method is
// called with the value "offline". You can connect to this
// method to do add your own behavior:
//
// dojo.connect(dojox.off, "onNetwork", someFunc)
//
// Note that if you are using the default Dojo Offline UI
// widget that most of the on- and off-line notification
// and syncing is automatically handled and provided to the
// user.
// type: String
// Either "online" or "offline".
},
initialize: function(){ /* void */
// summary:
// Called when a Dojo Offline-enabled application is finished
// configuring Dojo Offline, and is ready for Dojo Offline to
// initialize itself.
// description:
// When an application has finished filling out the variables Dojo
// Offline needs to work, such as dojox.off.ui.appName, it must
// this method to tell Dojo Offline to initialize itself.
// Note:
// This method is needed for a rare edge case. In some conditions,
// especially if we are dealing with a compressed Dojo build, the
// entire Dojo Offline subsystem might initialize itself and be
// running even before the JavaScript for an application has had a
// chance to run and configure Dojo Offline, causing Dojo Offline
// to have incorrect initialization parameters for a given app,
// such as no value for dojox.off.ui.appName. This method is
// provided to prevent this scenario, to slightly 'slow down' Dojo
// Offline so it can be configured before running off and doing
// its thing.
 
//console.debug("dojox.off.initialize");
this._initializeCalled = true;
if(this._storageLoaded && this._pageLoaded){
this._onLoad();
}
},
goOffline: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Manually goes offline, away from the network.
if((dojox.off.sync.isSyncing)||(this.goingOnline)){ return; }
this.goingOnline = false;
this.isOnline = false;
},
goOnline: function(callback){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Attempts to go online.
// description:
// Attempts to go online, making sure this web application's web
// site is available. 'callback' is called asychronously with the
// result of whether we were able to go online or not.
// callback: Function
// An optional callback function that will receive one argument:
// whether the site is available or not and is boolean. If this
// function is not present we call dojo.xoff.onOnline instead if
// we are able to go online.
//console.debug("goOnline");
if(dojox.off.sync.isSyncing || dojox.off.goingOnline){
return;
}
this.goingOnline = true;
this.isOnline = false;
// see if can reach our web application's web site
this._isSiteAvailable(callback);
},
onFrameworkEvent: function(type /* String */, saveData /* Object? */){
// summary:
// For advanced usage; most developers can ignore this.
// A standard event handler that can be attached to to find out
// about low-level framework events. Most developers will not need to
// attach to this method; it is meant for low-level information
// that can be useful for updating offline user-interfaces in
// exceptional circumstances. The default Dojo Offline UI
// widget takes care of most of these situations.
// type: String
// The type of the event:
//
// * "offlineCacheInstalled"
// An event that is fired when a user
// has installed an offline cache after the page has been loaded.
// If a user didn't have an offline cache when the page loaded, a
// UI of some kind might have prompted them to download one. This
// method is called if they have downloaded and installed an
// offline cache so a UI can reinitialize itself to begin using
// this offline cache.
// * "coreOperationFailed"
// Fired when a core operation during interaction with the
// offline cache is denied by the user. Some offline caches, such
// as Google Gears, prompts the user to approve or deny caching
// files, using the database, and more. If the user denies a
// request that is core to Dojo Offline's operation, we set
// dojox.off.coreOpFailed to true and call this method for
// listeners that would like to respond some how to Dojo Offline
// 'failing fast'.
// * "save"
// Called whenever the framework saves data into persistent
// storage. This could be useful for providing save feedback
// or providing appropriate error feedback if saving fails
// due to a user not allowing the save to occur
// saveData: Object?
// If the type was 'save', then a saveData object is provided with
// further save information. This object has the following properties:
//
// * status - dojox.storage.SUCCESS, dojox.storage.PENDING, dojox.storage.FAILED
// Whether the save succeeded, whether it is pending based on a UI
// dialog asking the user for permission, or whether it failed.
//
// * isCoreSave - boolean
// If true, then this save was for a core piece of data necessary
// for the functioning of Dojo Offline. If false, then it is a
// piece of normal data being saved for offline access. Dojo
// Offline will 'fail fast' if some core piece of data could not
// be saved, automatically setting dojox.off.coreOpFailed to
// 'true' and dojox.off.enabled to 'false'.
//
// * key - String
// The key that we are attempting to persist
//
// * value - Object
// The object we are trying to persist
//
// * namespace - String
// The Dojo Storage namespace we are saving this key/value pair
// into, such as "default", "Documents", "Contacts", etc.
// Optional.
if(type == "save"){
if(saveData.isCoreSave && (saveData.status == dojox.storage.FAILED)){
dojox.off.coreOpFailed = true;
dojox.off.enabled = false;
// FIXME: Stop the background network thread
dojox.off.onFrameworkEvent("coreOperationFailed");
}
}else if(type == "coreOperationFailed"){
dojox.off.coreOpFailed = true;
dojox.off.enabled = false;
// FIXME: Stop the background network thread
}
},
_checkOfflineCacheAvailable: function(callback){
// is a true, offline cache running on this machine?
this.hasOfflineCache = dojo.isGears;
callback();
},
_onLoad: function(){
//console.debug("dojox.off._onLoad");
// both local storage and the page are finished loading
// cache the Dojo JavaScript -- just use the default dojo.js
// name for the most common scenario
// FIXME: TEST: Make sure syncing doesn't break if dojo.js
// can't be found, or report an error to developer
dojox.off.files.cache(dojo.moduleUrl("dojo", "dojo.js"));
// pull in the files needed by Dojo
this._cacheDojoResources();
// FIXME: need to pull in the firebug lite files here!
// workaround or else we will get an error on page load
// from Dojo that it can't find 'console.debug' for optimized builds
// dojox.off.files.cache(djConfig.baseRelativePath + "src/debug.js");
// make sure that resources needed by all of our underlying
// Dojo Storage storage providers will be available
// offline
dojox.off.files.cache(dojox.storage.manager.getResourceList());
// slurp the page if the end-developer wants that
dojox.off.files._slurp();
// see if we have an offline cache; when done, move
// on to the rest of our startup tasks
this._checkOfflineCacheAvailable(dojo.hitch(this, "_onOfflineCacheChecked"));
},
_onOfflineCacheChecked: function(){
// this method is part of our _onLoad series of startup tasks
// if we have an offline cache, see if we have been added to the
// list of available offline web apps yet
if(this.hasOfflineCache && this.enabled){
// load framework data; when we are finished, continue
// initializing ourselves
this._load(dojo.hitch(this, "_finishStartingUp"));
}else if(this.hasOfflineCache && !this.enabled){
// we have an offline cache, but it is disabled for some reason
// perhaps due to the user denying a core operation
this._finishStartingUp();
}else{
this._keepCheckingUntilInstalled();
}
},
_keepCheckingUntilInstalled: function(){
// this method is part of our _onLoad series of startup tasks
// kick off a background interval that keeps
// checking to see if an offline cache has been
// installed since this page loaded
// FIXME: Gears: See if we are installed somehow after the
// page has been loaded
// now continue starting up
this._finishStartingUp();
},
_finishStartingUp: function(){
//console.debug("dojox.off._finishStartingUp");
// this method is part of our _onLoad series of startup tasks
if(!this.hasOfflineCache){
this.onLoad();
}else if(this.enabled){
// kick off a thread to check network status on
// a regular basis
this._startNetworkThread();
 
// try to go online
this.goOnline(dojo.hitch(this, function(){
//console.debug("Finished trying to go online");
// indicate we are ready to be used
dojox.off.onLoad();
}));
}else{ // we are disabled or a core operation failed
if(this.coreOpFailed){
this.onFrameworkEvent("coreOperationFailed");
}else{
this.onLoad();
}
}
},
_onPageLoad: function(){
//console.debug("dojox.off._onPageLoad");
this._pageLoaded = true;
if(this._storageLoaded && this._initializeCalled){
this._onLoad();
}
},
_onStorageLoad: function(){
//console.debug("dojox.off._onStorageLoad");
this._storageLoaded = true;
// were we able to initialize storage? if
// not, then this is a core operation, and
// let's indicate we will need to fail fast
if(!dojox.storage.manager.isAvailable()
&& dojox.storage.manager.isInitialized()){
this.coreOpFailed = true;
this.enabled = false;
}
if(this._pageLoaded && this._initializeCalled){
this._onLoad();
}
},
_isSiteAvailable: function(callback){
// summary:
// Determines if our web application's website is available.
// description:
// This method will asychronously determine if our web
// application's web site is available, which is a good proxy for
// network availability. The URL dojox.off.availabilityURL is
// used, which defaults to this site's domain name (ex:
// foobar.com). We check for dojox.off.AVAILABILITY_TIMEOUT (in
// seconds) and abort after that
// callback: Function
// An optional callback function that will receive one argument:
// whether the site is available or not and is boolean. If this
// function is not present we call dojox.off.onNetwork instead if we
// are able to go online.
dojo.xhrGet({
url: this._getAvailabilityURL(),
handleAs: "text",
timeout: this.NET_CHECK * 1000,
error: dojo.hitch(this, function(err){
//console.debug("dojox.off._isSiteAvailable.error: " + err);
this.goingOnline = false;
this.isOnline = false;
if(callback){ callback(false); }
}),
load: dojo.hitch(this, function(data){
//console.debug("dojox.off._isSiteAvailable.load, data="+data);
this.goingOnline = false;
this.isOnline = true;
if(callback){ callback(true);
}else{ this.onNetwork("online"); }
})
});
},
_startNetworkThread: function(){
//console.debug("startNetworkThread");
// kick off a thread that does periodic
// checks on the status of the network
if(!this.doNetChecking){
return;
}
window.setInterval(dojo.hitch(this, function(){
var d = dojo.xhrGet({
url: this._getAvailabilityURL(),
handleAs: "text",
timeout: this.NET_CHECK * 1000,
error: dojo.hitch(this,
function(err){
if(this.isOnline){
this.isOnline = false;
// FIXME: xhrGet() is not
// correctly calling abort
// on the XHR object when
// it times out; fix inside
// there instead of externally
// here
try{
if(typeof d.ioArgs.xhr.abort == "function"){
d.ioArgs.xhr.abort();
}
}catch(e){}
// if things fell in the middle of syncing,
// stop syncing
dojox.off.sync.isSyncing = false;
this.onNetwork("offline");
}
}
),
load: dojo.hitch(this,
function(data){
if(!this.isOnline){
this.isOnline = true;
this.onNetwork("online");
}
}
)
});
 
}), this.NET_CHECK * 1000);
},
_getAvailabilityURL: function(){
var url = this.availabilityURL.toString();
// bust the browser's cache to make sure we are really talking to
// the server
if(url.indexOf("?") == -1){
url += "?";
}else{
url += "&";
}
url += "browserbust=" + new Date().getTime();
return url;
},
_onOfflineCacheInstalled: function(){
this.onFrameworkEvent("offlineCacheInstalled");
},
_cacheDojoResources: function(){
// if we are a non-optimized build, then the core Dojo bootstrap
// system was loaded as separate JavaScript files;
// add these to our offline cache list. these are
// loaded before the dojo.require() system exists
// FIXME: create a better mechanism in the Dojo core to
// expose whether you are dealing with an optimized build;
// right now we just scan the SCRIPT tags attached to this
// page and see if there is one for _base/_loader/bootstrap.js
var isOptimizedBuild = true;
dojo.forEach(dojo.query("script"), function(i){
var src = i.getAttribute("src");
if(!src){ return; }
if(src.indexOf("_base/_loader/bootstrap.js") != -1){
isOptimizedBuild = false;
}
});
if(!isOptimizedBuild){
dojox.off.files.cache(dojo.moduleUrl("dojo", "_base.js").uri);
dojox.off.files.cache(dojo.moduleUrl("dojo", "_base/_loader/loader.js").uri);
dojox.off.files.cache(dojo.moduleUrl("dojo", "_base/_loader/bootstrap.js").uri);
// FIXME: pull in the host environment file in a more generic way
// for other host environments
dojox.off.files.cache(dojo.moduleUrl("dojo", "_base/_loader/hostenv_browser.js").uri);
}
// add anything that was brought in with a
// dojo.require() that resulted in a JavaScript
// URL being fetched
// FIXME: modify dojo/_base/_loader/loader.js to
// expose a public API to get this information
for(var i = 0; i < dojo._loadedUrls.length; i++){
dojox.off.files.cache(dojo._loadedUrls[i]);
}
// FIXME: add the standard Dojo CSS file
},
_save: function(){
// summary:
// Causes the Dojo Offline framework to save its configuration
// data into local storage.
},
_load: function(callback){
// summary:
// Causes the Dojo Offline framework to load its configuration
// data from local storage
dojox.off.sync._load(callback);
}
});
 
 
// wait until the storage system is finished loading
dojox.storage.manager.addOnLoad(dojo.hitch(dojox.off, "_onStorageLoad"));
 
// wait until the page is finished loading
dojo.addOnLoad(dojox.off, "_onPageLoad");
 
}
/trunk/api/js/dojo1.0/dojox/off/network_check.txt
New file
0,0 → 1,0
1
/trunk/api/js/dojo1.0/dojox/off/sync.js
New file
0,0 → 1,690
if(!dojo._hasResource["dojox.off.sync"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.off.sync"] = true;
dojo.provide("dojox.off.sync");
 
dojo.require("dojox.storage.GearsStorageProvider");
dojo.require("dojox.off._common");
dojo.require("dojox.off.files");
 
// Author: Brad Neuberg, bkn3@columbia.edu, http://codinginparadise.org
 
// summary:
// Exposes syncing functionality to offline applications
dojo.mixin(dojox.off.sync, {
// isSyncing: boolean
// Whether we are in the middle of a syncing session.
isSyncing: false,
// cancelled: boolean
// Whether we were cancelled during our last sync request or not. If
// we are cancelled, then successful will be false.
cancelled: false,
// successful: boolean
// Whether the last sync was successful or not. If false, an error
// occurred.
successful: true,
// details: String[]
// Details on the sync. If the sync was successful, this will carry
// any conflict or merging messages that might be available; if the
// sync was unsuccessful, this will have an error message. For both
// of these, this should be an array of Strings, where each string
// carries details on the sync.
// Example:
// dojox.off.sync.details = ["The document 'foobar' had conflicts - yours one",
// "The document 'hello world' was automatically merged"];
details: [],
// error: boolean
// Whether an error occurred during the syncing process.
error: false,
// actions: dojox.off.sync.ActionLog
// Our ActionLog that we store offline actions into for later
// replaying when we go online
actions: null,
// autoSync: boolean
// For advanced usage; most developers can ignore this.
// Whether we do automatically sync on page load or when we go online.
// If true we do, if false syncing must be manually initiated.
// Defaults to true.
autoSync: true,
// summary:
// An event handler that is called during the syncing process with
// the state of syncing. It is important that you connect to this
// method and respond to certain sync events, especially the
// "download" event.
// description:
// This event handler is called during the syncing process. You can
// do a dojo.connect to receive sync feedback:
//
// dojo.connect(dojox.off.sync, "onSync", someFunc);
//
// You will receive one argument, which is the type of the event
// and which can have the following values.
//
// The most common two types that you need to care about are "download"
// and "finished", especially if you are using the default
// Dojo Offline UI widget that does the hard work of informing
// the user through the UI about what is occuring during syncing.
//
// If you receive the "download" event, you should make a network call
// to retrieve and store your data somehow for offline access. The
// "finished" event indicates that syncing is done. An example:
//
// dojo.connect(dojox.off.sync, "onSync", function(type){
// if(type == "download"){
// // make a network call to download some data
// // for use offline
// dojo.xhrGet({
// url: "downloadData.php",
// handleAs: "javascript",
// error: function(err){
// dojox.off.sync.finishedDownloading(false, "Can't download data");
// },
// load: function(data){
// // store our data
// dojox.storage.put("myData", data);
//
// // indicate we are finished downloading
// dojox.off.sync.finishedDownloading(true);
// }
// });
// }else if(type == "finished"){
// // update UI somehow to indicate we are finished,
// // such as using the download data to change the
// // available data
// }
// })
//
// Here is the full list of event types if you want to do deep
// customization, such as updating your UI to display the progress
// of syncing (note that the default Dojo Offline UI widget does
// this for you if you choose to pull that in). Most of these
// are only appropriate for advanced usage and can be safely
// ignored:
//
// * "start"
// syncing has started
// * "refreshFiles"
// syncing will begin refreshing
// our offline file cache
// * "upload"
// syncing will begin uploading
// any local data changes we have on the client.
// This event is fired before we fire
// the dojox.off.sync.actions.onReplay event for
// each action to replay; use it to completely
// over-ride the replaying behavior and prevent
// it entirely, perhaps rolling your own sync
// protocol if needed.
// * "download"
// syncing will begin downloading any new data that is
// needed into persistent storage. Applications are required to
// implement this themselves, storing the required data into
// persistent local storage using Dojo Storage.
// * "finished"
// syncing is finished; this
// will be called whether an error ocurred or not; check
// dojox.off.sync.successful and dojox.off.sync.error for sync details
// * "cancel"
// Fired when canceling has been initiated; canceling will be
// attempted, followed by the sync event "finished".
onSync: function(/* String */ type){},
synchronize: function(){ /* void */
// summary: Starts synchronizing
 
//dojo.debug("synchronize");
if(this.isSyncing || dojox.off.goingOnline || (!dojox.off.isOnline)){
return;
}
this.isSyncing = true;
this.successful = false;
this.details = [];
this.cancelled = false;
this.start();
},
cancel: function(){ /* void */
// summary:
// Attempts to cancel this sync session
if(!this.isSyncing){ return; }
this.cancelled = true;
if(dojox.off.files.refreshing){
dojox.off.files.abortRefresh();
}
this.onSync("cancel");
},
finishedDownloading: function(successful /* boolean? */,
errorMessage /* String? */){
// summary:
// Applications call this method from their
// after getting a "download" event in
// dojox.off.sync.onSync to signal that
// they are finished downloading any data
// that should be available offline
// successful: boolean?
// Whether our downloading was successful or not.
// If not present, defaults to true.
// errorMessage: String?
// If unsuccessful, a message explaining why
if(typeof successful == "undefined"){
successful = true;
}
if(!successful){
this.successful = false;
this.details.push(errorMessage);
this.error = true;
}
this.finished();
},
start: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Called at the start of the syncing process. Advanced
// developers can over-ride this method to use their
// own sync mechanism to start syncing.
if(this.cancelled){
this.finished();
return;
}
this.onSync("start");
this.refreshFiles();
},
refreshFiles: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Called when we are going to refresh our list
// of offline files during syncing. Advanced developers
// can over-ride this method to do some advanced magic related to
// refreshing files.
//dojo.debug("refreshFiles");
if(this.cancelled){
this.finished();
return;
}
this.onSync("refreshFiles");
dojox.off.files.refresh(dojo.hitch(this, function(error, errorMessages){
if(error){
this.error = true;
this.successful = false;
for(var i = 0; i < errorMessages.length; i++){
this.details.push(errorMessages[i]);
}
// even if we get an error while syncing files,
// keep syncing so we can upload and download
// data
}
this.upload();
}));
},
upload: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Called when syncing wants to upload data. Advanced
// developers can over-ride this method to completely
// throw away the Action Log and replaying system
// and roll their own advanced sync mechanism if needed.
if(this.cancelled){
this.finished();
return;
}
this.onSync("upload");
// when we are done uploading start downloading
dojo.connect(this.actions, "onReplayFinished", this, this.download);
// replay the actions log
this.actions.replay();
},
download: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Called when syncing wants to download data. Advanced
// developers can over-ride this method to use their
// own sync mechanism.
if(this.cancelled){
this.finished();
return;
}
// apps should respond to the "download"
// event to download their data; when done
// they must call dojox.off.sync.finishedDownloading()
this.onSync("download");
},
finished: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Called when syncing is finished. Advanced
// developers can over-ride this method to clean
// up after finishing their own sync
// mechanism they might have rolled.
this.isSyncing = false;
this.successful = (!this.cancelled && !this.error);
this.onSync("finished");
},
_save: function(callback){
this.actions._save(function(){
callback();
});
},
_load: function(callback){
this.actions._load(function(){
callback();
});
}
});
 
 
// summary:
// A class that records actions taken by a user when they are offline,
// suitable for replaying when the network reappears.
// description:
// The basic idea behind this method is to record user actions that would
// normally have to contact a server into an action log when we are
// offline, so that later when we are online we can simply replay this log
// in the order user actions happened so that they can be executed against
// the server, causing synchronization to happen.
//
// When we replay, for each of the actions that were added, we call a
// method named onReplay that applications should connect to and
// which will be called over and over for each of our actions --
// applications should take the offline action
// information and use it to talk to a server to have this action
// actually happen online, 'syncing' themselves with the server.
//
// For example, if the action was "update" with the item that was updated, we
// might call some RESTian server API that exists for updating an item in
// our application. The server could either then do sophisticated merging
// and conflict resolution on the server side, for example, allowing you
// to pop up a custom merge UI, or could do automatic merging or nothing
// of the sort. When you are finished with this particular action, your
// application is then required to call continueReplay() on the actionLog object
// passed to onReplay() to continue replaying the action log, or haltReplay()
// with the reason for halting to completely stop the syncing/replaying
// process.
//
// For example, imagine that we have a web application that allows us to add
// contacts. If we are offline, and we update a contact, we would add an action;
// imagine that the user has to click an Update button after changing the values
// for a given contact:
//
// dojox.off.whenOffline(dojo.byId("updateButton"), "onclick", function(evt){
// // get the updated customer values
// var customer = getCustomerValues();
//
// // we are offline -- just record this action
// var action = {name: "update", customer: customer};
// dojox.off.sync.actions.add(action)
//
// // persist this customer data into local storage as well
// dojox.storage.put(customer.name, customer);
// })
//
// Then, when we go back online, the dojox.off.sync.actions.onReplay event
// will fire over and over, once for each action that was recorded while offline:
//
// dojo.connect(dojox.off.sync.actions, "onReplay", function(action, actionLog){
// // called once for each action we added while offline, in the order
// // they were added
// if(action.name == "update"){
// var customer = action.customer;
//
// // call some network service to update this customer
// dojo.xhrPost({
// url: "updateCustomer.php",
// content: {customer: dojo.toJson(customer)},
// error: function(err){
// actionLog.haltReplay(err);
// },
// load: function(data){
// actionLog.continueReplay();
// }
// })
// }
// })
//
// Note that the actions log is always automatically persisted locally while using it, so
// that if the user closes the browser or it crashes the actions will safely be stored
// for later replaying.
dojo.declare("dojox.off.sync.ActionLog", null, {
// entries: Array
// An array of our action entries, where each one is simply a custom
// object literal that were passed to add() when this action entry
// was added.
entries: [],
// reasonHalted: String
// If we halted, the reason why
reasonHalted: null,
// isReplaying: boolean
// If true, we are in the middle of replaying a command log; if false,
// then we are not
isReplaying: false,
// autoSave: boolean
// Whether we automatically save the action log after each call to
// add(); defaults to true. For applications that are rapidly adding
// many action log entries in a short period of time, it can be
// useful to set this to false and simply call save() yourself when
// you are ready to persist your command log -- otherwise performance
// could be slow as the default action is to attempt to persist the
// actions log constantly with calls to add().
autoSave: true,
add: function(action /* Object */){ /* void */
// summary:
// Adds an action to our action log
// description:
// This method will add an action to our
// action log, later to be replayed when we
// go from offline to online. 'action'
// will be available when this action is
// replayed and will be passed to onReplay.
//
// Example usage:
//
// dojox.off.sync.log.add({actionName: "create", itemType: "document",
// {title: "Message", content: "Hello World"}});
//
// The object literal is simply a custom object appropriate
// for our application -- it can be anything that preserves the state
// of a user action that will be executed when we go back online
// and replay this log. In the above example,
// "create" is the name of this action; "documents" is the
// type of item this command is operating on, such as documents, contacts,
// tasks, etc.; and the final argument is the document that was created.
if(this.isReplaying){
throw "Programming error: you can not call "
+ "dojox.off.sync.actions.add() while "
+ "we are replaying an action log";
}
this.entries.push(action);
// save our updated state into persistent
// storage
if(this.autoSave){
this._save();
}
},
onReplay: function(action /* Object */,
actionLog /* dojox.off.sync.ActionLog */){ /* void */
// summary:
// Called when we replay our log, for each of our action
// entries.
// action: Object
// A custom object literal representing an action for this
// application, such as
// {actionName: "create", item: {title: "message", content: "hello world"}}
// actionLog: dojox.off.sync.ActionLog
// A reference to the dojox.off.sync.actions log so that developers
// can easily call actionLog.continueReplay() or actionLog.haltReplay().
// description:
// This callback should be connected to by applications so that
// they can sync themselves when we go back online:
//
// dojo.connect(dojox.off.sync.actions, "onReplay", function(action, actionLog){
// // do something
// })
//
// When we replay our action log, this callback is called for each
// of our action entries in the order they were added. The
// 'action' entry that was passed to add() for this action will
// also be passed in to onReplay, so that applications can use this information
// to do their syncing, such as contacting a server web-service
// to create a new item, for example.
//
// Inside the method you connected to onReplay, you should either call
// actionLog.haltReplay(reason) if an error occurred and you would like to halt
// action replaying or actionLog.continueReplay() to have the action log
// continue replaying its log and proceed to the next action;
// the reason you must call these is the action you execute inside of
// onAction will probably be asynchronous, since it will be talking on
// the network, and you should call one of these two methods based on
// the result of your network call.
},
length: function(){ /* Number */
// summary:
// Returns the length of this
// action log
return this.entries.length;
},
haltReplay: function(reason /* String */){ /* void */
// summary: Halts replaying this command log.
// reason: String
// The reason we halted.
// description:
// This method is called as we are replaying an action log; it
// can be called from dojox.off.sync.actions.onReplay, for
// example, for an application to indicate an error occurred
// while replaying this action, halting further processing of
// the action log. Note that any action log entries that
// were processed before have their effects retained (i.e.
// they are not rolled back), while the action entry that was
// halted stays in our list of actions to later be replayed.
if(!this.isReplaying){
return;
}
if(reason){
this.reasonHalted = reason.toString();
}
// save the state of our action log, then
// tell anyone who is interested that we are
// done when we are finished saving
if(this.autoSave){
var self = this;
this._save(function(){
self.isReplaying = false;
self.onReplayFinished();
});
}else{
this.isReplaying = false;
this.onReplayFinished();
}
},
continueReplay: function(){ /* void */
// summary:
// Indicates that we should continue processing out list of
// actions.
// description:
// This method is called by applications that have overridden
// dojox.off.sync.actions.onReplay() to continue replaying our
// action log after the application has finished handling the
// current action.
if(!this.isReplaying){
return;
}
// shift off the old action we just ran
this.entries.shift();
// are we done?
if(!this.entries.length){
// save the state of our action log, then
// tell anyone who is interested that we are
// done when we are finished saving
if(this.autoSave){
var self = this;
this._save(function(){
self.isReplaying = false;
self.onReplayFinished();
});
return;
}else{
this.isReplaying = false;
this.onReplayFinished();
return;
}
}
// get the next action
var nextAction = this.entries[0];
this.onReplay(nextAction, this);
},
clear: function(){ /* void */
// summary:
// Completely clears this action log of its entries
if(this.isReplaying){
return;
}
this.entries = [];
// save our updated state into persistent
// storage
if(this.autoSave){
this._save();
}
},
replay: function(){ /* void */
// summary:
// For advanced usage; most developers can ignore this.
// Replays all of the commands that have been
// cached in this command log when we go back online;
// onCommand will be called for each command we have
if(this.isReplaying){
return;
}
this.reasonHalted = null;
if(!this.entries.length){
this.onReplayFinished();
return;
}
this.isReplaying = true;
var nextAction = this.entries[0];
this.onReplay(nextAction, this);
},
// onReplayFinished: Function
// For advanced usage; most developers can ignore this.
// Called when we are finished replaying our commands;
// called if we have successfully exhausted all of our
// commands, or if an error occurred during replaying.
// The default implementation simply continues the
// synchronization process. Connect to this to register
// for the event:
//
// dojo.connect(dojox.off.sync.actions, "onReplayFinished",
// someFunc)
onReplayFinished: function(){
},
 
toString: function(){
var results = "";
results += "[";
for(var i = 0; i < this.entries.length; i++){
results += "{";
for(var j in this.entries[i]){
results += j + ": \"" + this.entries[i][j] + "\"";
results += ", ";
}
results += "}, ";
}
results += "]";
return results;
},
_save: function(callback){
if(!callback){
callback = function(){};
}
try{
var self = this;
var resultsHandler = function(status, key, message){
//console.debug("resultsHandler, status="+status+", key="+key+", message="+message);
if(status == dojox.storage.FAILED){
dojox.off.onFrameworkEvent("save",
{status: dojox.storage.FAILED,
isCoreSave: true,
key: key,
value: message,
namespace: dojox.off.STORAGE_NAMESPACE});
callback();
}else if(status == dojox.storage.SUCCESS){
callback();
}
};
dojox.storage.put("actionlog", this.entries, resultsHandler,
dojox.off.STORAGE_NAMESPACE);
}catch(exp){
console.debug("dojox.off.sync._save: " + exp.message||exp);
dojox.off.onFrameworkEvent("save",
{status: dojox.storage.FAILED,
isCoreSave: true,
key: "actionlog",
value: this.entries,
namespace: dojox.off.STORAGE_NAMESPACE});
callback();
}
},
_load: function(callback){
var entries = dojox.storage.get("actionlog", dojox.off.STORAGE_NAMESPACE);
if(!entries){
entries = [];
}
this.entries = entries;
callback();
}
}
);
 
dojox.off.sync.actions = new dojox.off.sync.ActionLog();
 
}
/trunk/api/js/dojo1.0/dojox/off/docs/bookmarklets.html
New file
0,0 → 1,10
<html>
<body>
<h1>Browser Bookmarklets</h1>
 
<p>Drag the following bookmarklets to your links toolbar and press to clear the Google Gears cache:</p>
 
<p>Firefox: <a title="Clear Gears Cache" href="javascript:(function(){new GearsFactory().create('beta.localserver', '1.0').removeStore('dot_store_'+window.location.href.replace(/[^0-9A-Za-z_]/g, '_'));dojox.storage.remove('oldVersion', '_dot');}())">Clear Gears Cache</a></p>
<p>Internet Explorer: <a title="Clear Gears Cache" href="javascript:(function(){new ActiveXObject('Gears.Factory').create('beta.localserver', '1.0').removeStore('dot_store_'+window.location.href.replace(/[^0-9A-Za-z_]/g, '_'));dojox.storage.remove('oldVersion', '_dot');}())">Clear Gears Cache</a></p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/off/ui.js
New file
0,0 → 1,618
if(!dojo._hasResource["dojox.off.ui"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.off.ui"] = true;
dojo.provide("dojox.off.ui");
 
dojo.require("dojox.storage.Provider");
dojo.require("dojox.storage.manager");
dojo.require("dojox.storage.GearsStorageProvider");
 
// Author: Brad Neuberg, bkn3@columbia.edu, http://codinginparadise.org
 
// summary:
// dojox.off.ui provides a standard,
// default user-interface for a
// Dojo Offline Widget that can easily
// be dropped into applications that would
// like to work offline.
dojo.mixin(dojox.off.ui, {
// appName: String
// This application's name, such as "Foobar". Note that
// this is a string, not HTML, so embedded markup will
// not work, including entities. Only the following
// characters are allowed: numbers, letters, and spaces.
// You must set this property.
appName: "setme",
// autoEmbed: boolean
// For advanced usage; most developers can ignore this.
// Whether to automatically auto-embed the default Dojo Offline
// widget into this page; default is true.
autoEmbed: true,
// autoEmbedID: String
// For advanced usage; most developers can ignore this.
// The ID of the DOM element that will contain our
// Dojo Offline widget; defaults to the ID 'dot-widget'.
autoEmbedID: "dot-widget",
// runLink: String
// For advanced usage; most developers can ignore this.
// The URL that should be navigated to to run this
// application offline; this will be placed inside of a
// link that the user can drag to their desktop and double
// click. Note that this URL must exactly match the URL
// of the main page of our resource that is offline for
// it to be retrieved from the offline cache correctly.
// For example, if you have cached your main page as
// http://foobar.com/index.html, and you set this to
// http://www.foobar.com/index.html, the run link will
// not work. By default this value is automatically set to
// the URL of this page, so it does not need to be set
// manually unless you have unusual needs.
runLink: window.location.href,
// runLinkTitle: String
// For advanced usage; most developers can ignore this.
// The text that will be inside of the link that a user
// can drag to their desktop to run this application offline.
// By default this is automatically set to "Run " plus your
// application's name.
runLinkTitle: "Run Application",
// learnHowPath: String
// For advanced usage; most developers can ignore this.
// The path to a web page that has information on
// how to use this web app offline; defaults to
// src/off/ui-template/learnhow.html, relative to
// your Dojo installation. Make sure to set
// dojo.to.ui.customLearnHowPath to true if you want
// a custom Learn How page.
learnHowPath: dojo.moduleUrl("dojox", "off/resources/learnhow.html"),
// customLearnHowPath: boolean
// For advanced usage; most developers can ignore this.
// Whether the developer is using their own custom page
// for the Learn How instructional page; defaults to false.
// Use in conjunction with dojox.off.ui.learnHowPath.
customLearnHowPath: false,
htmlTemplatePath: dojo.moduleUrl("dojox", "off/resources/offline-widget.html").uri,
cssTemplatePath: dojo.moduleUrl("dojox", "off/resources/offline-widget.css").uri,
onlineImagePath: dojo.moduleUrl("dojox", "off/resources/greenball.png").uri,
offlineImagePath: dojo.moduleUrl("dojox", "off/resources/redball.png").uri,
rollerImagePath: dojo.moduleUrl("dojox", "off/resources/roller.gif").uri,
checkmarkImagePath: dojo.moduleUrl("dojox", "off/resources/checkmark.png").uri,
learnHowJSPath: dojo.moduleUrl("dojox", "off/resources/learnhow.js").uri,
_initialized: false,
onLoad: function(){
// summary:
// A function that should be connected to allow your
// application to know when Dojo Offline, the page, and
// the Offline Widget are all initialized and ready to be
// used:
//
// dojo.connect(dojox.off.ui, "onLoad", someFunc)
},
 
_initialize: function(){
//console.debug("dojox.off.ui._initialize");
// make sure our app name is correct
if(this._validateAppName(this.appName) == false){
alert("You must set dojox.off.ui.appName; it can only contain "
+ "letters, numbers, and spaces; right now it "
+ "is incorrectly set to '" + dojox.off.ui.appName + "'");
dojox.off.enabled = false;
return;
}
// set our run link text to its default
this.runLinkText = "Run " + this.appName;
// setup our event listeners for Dojo Offline events
// to update our UI
dojo.connect(dojox.off, "onNetwork", this, "_onNetwork");
dojo.connect(dojox.off.sync, "onSync", this, "_onSync");
// cache our default UI resources
dojox.off.files.cache([
this.htmlTemplatePath,
this.cssTemplatePath,
this.onlineImagePath,
this.offlineImagePath,
this.rollerImagePath,
this.checkmarkImagePath
]);
// embed the offline widget UI
if(this.autoEmbed){
this._doAutoEmbed();
}
},
_doAutoEmbed: function(){
// fetch our HTML for the offline widget
 
// dispatch the request
dojo.xhrGet({
url: this.htmlTemplatePath,
handleAs: "text",
error: function(err){
dojox.off.enabled = false;
err = err.message||err;
alert("Error loading the Dojo Offline Widget from "
+ this.htmlTemplatePath + ": " + err);
},
load: dojo.hitch(this, this._templateLoaded)
});
},
_templateLoaded: function(data){
//console.debug("dojox.off.ui._templateLoaded");
// inline our HTML
var container = dojo.byId(this.autoEmbedID);
if(container){ container.innerHTML = data; }
// fill out our image paths
this._initImages();
// update our network indicator status ball
this._updateNetIndicator();
// update our 'Learn How' text
this._initLearnHow();
this._initialized = true;
// check offline cache settings
if(!dojox.off.hasOfflineCache){
this._showNeedsOfflineCache();
return;
}
// check to see if we need a browser restart
// to be able to use this web app offline
if(dojox.off.hasOfflineCache && dojox.off.browserRestart){
this._needsBrowserRestart();
return;
}else{
var browserRestart = dojo.byId("dot-widget-browser-restart");
if(browserRestart){ browserRestart.style.display = "none"; }
}
// update our sync UI
this._updateSyncUI();
// register our event listeners for our main buttons
this._initMainEvtHandlers();
// if offline functionality is disabled, disable everything
this._setOfflineEnabled(dojox.off.enabled);
// update our UI based on the state of the network
this._onNetwork(dojox.off.isOnline ? "online" : "offline");
// try to go online
this._testNet();
},
_testNet: function(){
dojox.off.goOnline(dojo.hitch(this, function(isOnline){
//console.debug("testNet callback, isOnline="+isOnline);
// display our online/offline results
this._onNetwork(isOnline ? "online" : "offline");
// indicate that our default UI
// and Dojo Offline are now ready to
// be used
this.onLoad();
}));
},
_updateNetIndicator: function(){
var onlineImg = dojo.byId("dot-widget-network-indicator-online");
var offlineImg = dojo.byId("dot-widget-network-indicator-offline");
var titleText = dojo.byId("dot-widget-title-text");
if(onlineImg && offlineImg){
if(dojox.off.isOnline == true){
onlineImg.style.display = "inline";
offlineImg.style.display = "none";
}else{
onlineImg.style.display = "none";
offlineImg.style.display = "inline";
}
}
if(titleText){
if(dojox.off.isOnline){
titleText.innerHTML = "Online";
}else{
titleText.innerHTML = "Offline";
}
}
},
_initLearnHow: function(){
var learnHow = dojo.byId("dot-widget-learn-how-link");
if(!learnHow){ return; }
if(!this.customLearnHowPath){
// add parameters to URL so the Learn How page
// can customize itself and display itself
// correctly based on framework settings
var dojoPath = djConfig.baseRelativePath;
this.learnHowPath += "?appName=" + encodeURIComponent(this.appName)
+ "&hasOfflineCache=" + dojox.off.hasOfflineCache
+ "&runLink=" + encodeURIComponent(this.runLink)
+ "&runLinkText=" + encodeURIComponent(this.runLinkText)
+ "&baseRelativePath=" + encodeURIComponent(dojoPath);
// cache our Learn How JavaScript page and
// the HTML version with full query parameters
// so it is available offline without a cache miss
dojox.off.files.cache(this.learnHowJSPath);
dojox.off.files.cache(this.learnHowPath);
}
learnHow.setAttribute("href", this.learnHowPath);
var appName = dojo.byId("dot-widget-learn-how-app-name");
if(!appName){ return; }
appName.innerHTML = "";
appName.appendChild(document.createTextNode(this.appName));
},
_validateAppName: function(appName){
if(!appName){ return false; }
return (/^[a-z0-9 ]*$/i.test(appName));
},
_updateSyncUI: function(){
var roller = dojo.byId("dot-roller");
var checkmark = dojo.byId("dot-success-checkmark");
var syncMessages = dojo.byId("dot-sync-messages");
var details = dojo.byId("dot-sync-details");
var cancel = dojo.byId("dot-sync-cancel");
if(dojox.off.sync.isSyncing){
this._clearSyncMessage();
if(roller){ roller.style.display = "inline"; }
if(checkmark){ checkmark.style.display = "none"; }
if(syncMessages){
dojo.removeClass(syncMessages, "dot-sync-error");
}
if(details){ details.style.display = "none"; }
if(cancel){ cancel.style.display = "inline"; }
}else{
if(roller){ roller.style.display = "none"; }
if(cancel){ cancel.style.display = "none"; }
if(syncMessages){
dojo.removeClass(syncMessages, "dot-sync-error");
}
}
},
_setSyncMessage: function(message){
var syncMessage = dojo.byId("dot-sync-messages");
if(syncMessage){
// when used with Google Gears pre-release in Firefox/Mac OS X,
// the browser would crash when testing in Moxie
// if we set the message this way for some reason.
// Brad Neuberg, bkn3@columbia.edu
//syncMessage.innerHTML = message;
while(syncMessage.firstChild){
syncMessage.removeChild(syncMessage.firstChild);
}
syncMessage.appendChild(document.createTextNode(message));
}
},
_clearSyncMessage: function(){
this._setSyncMessage("");
},
_initImages: function(){
var onlineImg = dojo.byId("dot-widget-network-indicator-online");
if(onlineImg){
onlineImg.setAttribute("src", this.onlineImagePath);
}
var offlineImg = dojo.byId("dot-widget-network-indicator-offline");
if(offlineImg){
offlineImg.setAttribute("src", this.offlineImagePath);
}
var roller = dojo.byId("dot-roller");
if(roller){
roller.setAttribute("src", this.rollerImagePath);
}
var checkmark = dojo.byId("dot-success-checkmark");
if(checkmark){
checkmark.setAttribute("src", this.checkmarkImagePath);
}
},
_showDetails: function(evt){
// cancel the button's default behavior
evt.preventDefault();
evt.stopPropagation();
if(!dojox.off.sync.details.length){
return;
}
// determine our HTML message to display
var html = "";
html += "<html><head><title>Sync Details</title><head><body>";
html += "<h1>Sync Details</h1>\n";
html += "<ul>\n";
for(var i = 0; i < dojox.off.sync.details.length; i++){
html += "<li>";
html += dojox.off.sync.details[i];
html += "</li>";
}
html += "</ul>\n";
html += "<a href='javascript:window.close()' "
+ "style='text-align: right; padding-right: 2em;'>"
+ "Close Window"
+ "</a>\n";
html += "</body></html>";
// open a popup window with this message
var windowParams = "height=400,width=600,resizable=true,"
+ "scrollbars=true,toolbar=no,menubar=no,"
+ "location=no,directories=no,dependent=yes";
 
var popup = window.open("", "SyncDetails", windowParams);
if(!popup){ // aggressive popup blocker
alert("Please allow popup windows for this domain; can't display sync details window");
return;
}
popup.document.open();
popup.document.write(html);
popup.document.close();
// put the focus on the popup window
if(popup.focus){
popup.focus();
}
},
_cancel: function(evt){
// cancel the button's default behavior
evt.preventDefault();
evt.stopPropagation();
dojox.off.sync.cancel();
},
_needsBrowserRestart: function(){
var browserRestart = dojo.byId("dot-widget-browser-restart");
if(browserRestart){
dojo.addClass(browserRestart, "dot-needs-browser-restart");
}
var appName = dojo.byId("dot-widget-browser-restart-app-name");
if(appName){
appName.innerHTML = "";
appName.appendChild(document.createTextNode(this.appName));
}
var status = dojo.byId("dot-sync-status");
if(status){
status.style.display = "none";
}
},
_showNeedsOfflineCache: function(){
var widgetContainer = dojo.byId("dot-widget-container");
if(widgetContainer){
dojo.addClass(widgetContainer, "dot-needs-offline-cache");
}
},
_hideNeedsOfflineCache: function(){
var widgetContainer = dojo.byId("dot-widget-container");
if(widgetContainer){
dojo.removeClass(widgetContainer, "dot-needs-offline-cache");
}
},
_initMainEvtHandlers: function(){
var detailsButton = dojo.byId("dot-sync-details-button");
if(detailsButton){
dojo.connect(detailsButton, "onclick", this, this._showDetails);
}
var cancelButton = dojo.byId("dot-sync-cancel-button");
if(cancelButton){
dojo.connect(cancelButton, "onclick", this, this._cancel);
}
},
_setOfflineEnabled: function(enabled){
var elems = [];
elems.push(dojo.byId("dot-sync-status"));
for(var i = 0; i < elems.length; i++){
if(elems[i]){
elems[i].style.visibility =
(enabled ? "visible" : "hidden");
}
}
},
_syncFinished: function(){
this._updateSyncUI();
var checkmark = dojo.byId("dot-success-checkmark");
var details = dojo.byId("dot-sync-details");
if(dojox.off.sync.successful == true){
this._setSyncMessage("Sync Successful");
if(checkmark){ checkmark.style.display = "inline"; }
}else if(dojox.off.sync.cancelled == true){
this._setSyncMessage("Sync Cancelled");
if(checkmark){ checkmark.style.display = "none"; }
}else{
this._setSyncMessage("Sync Error");
var messages = dojo.byId("dot-sync-messages");
if(messages){
dojo.addClass(messages, "dot-sync-error");
}
if(checkmark){ checkmark.style.display = "none"; }
}
if(dojox.off.sync.details.length && details){
details.style.display = "inline";
}
},
_onFrameworkEvent: function(type, saveData){
if(type == "save"){
if(saveData.status == dojox.storage.FAILED && !saveData.isCoreSave){
alert("Please increase the amount of local storage available "
+ "to this application");
if(dojox.storage.hasSettingsUI()){
dojox.storage.showSettingsUI();
}
// FIXME: Be able to know if storage size has changed
// due to user configuration
}
}else if(type == "coreOperationFailed"){
console.log("Application does not have permission to use Dojo Offline");
if(!this._userInformed){
alert("This application will not work if Google Gears is not allowed to run");
this._userInformed = true;
}
}else if(type == "offlineCacheInstalled"){
// clear out the 'needs offline cache' info
this._hideNeedsOfflineCache();
// check to see if we need a browser restart
// to be able to use this web app offline
if(dojox.off.hasOfflineCache == true
&& dojox.off.browserRestart == true){
this._needsBrowserRestart();
return;
}else{
var browserRestart = dojo.byId("dot-widget-browser-restart");
if(browserRestart){
browserRestart.style.display = "none";
}
}
// update our sync UI
this._updateSyncUI();
// register our event listeners for our main buttons
this._initMainEvtHandlers();
// if offline is disabled, disable everything
this._setOfflineEnabled(dojox.off.enabled);
// try to go online
this._testNet();
}
},
_onSync: function(type){
//console.debug("ui, onSync="+type);
switch(type){
case "start":
this._updateSyncUI();
break;
case "refreshFiles":
this._setSyncMessage("Downloading UI...");
break;
case "upload":
this._setSyncMessage("Uploading new data...");
break;
case "download":
this._setSyncMessage("Downloading new data...");
break;
case "finished":
this._syncFinished();
break;
case "cancel":
this._setSyncMessage("Canceling Sync...");
break;
default:
dojo.warn("Programming error: "
+ "Unknown sync type in dojox.off.ui: " + type);
break;
}
},
_onNetwork: function(type){
// summary:
// Called when we go on- or off-line
// description:
// When we go online or offline, this method is called to update
// our UI. Default behavior is to update the Offline
// Widget UI and to attempt a synchronization.
// type: String
// "online" if we just moved online, and "offline" if we just
// moved offline.
if(!this._initialized){ return; }
// update UI
this._updateNetIndicator();
if(type == "offline"){
this._setSyncMessage("You are working offline");
// clear old details
var details = dojo.byId("dot-sync-details");
if(details){ details.style.display = "none"; }
// if we fell offline during a sync, hide
// the sync info
this._updateSyncUI();
}else{ // online
// synchronize, but pause for a few seconds
// so that the user can orient themselves
if(dojox.off.sync.autoSync){
window.setTimeout("dojox.off.sync.synchronize()", 1000);
}
}
}
});
 
// register ourselves for low-level framework events
dojo.connect(dojox.off, "onFrameworkEvent", dojox.off.ui, "_onFrameworkEvent");
 
// start our magic when the Dojo Offline framework is ready to go
dojo.connect(dojox.off, "onLoad", dojox.off.ui, dojox.off.ui._initialize);
 
}
/trunk/api/js/dojo1.0/dojox/resources/README.template
New file
0,0 → 1,36
-------------------------------------------------------------------------------
Project Name
-------------------------------------------------------------------------------
Version X.XXX
Release date: MM/DD/YYYY
-------------------------------------------------------------------------------
Project state:
prototype | expermental | beta | stable | production
-------------------------------------------------------------------------------
Credits
Author one (author contact info)
Author two (author contact info)
-------------------------------------------------------------------------------
Project description
 
Describe the point of the project here.
-------------------------------------------------------------------------------
Dependencies:
 
List any dependencies here.
-------------------------------------------------------------------------------
Documentation
 
-------------------------------------------------------------------------------
Installation instructions
 
Use this to explain in detail what a person needs to do in order to use this
project. Include URLs for grabbing source, URLs for any dependencies, etc.
Also be sure to include any additional information, such as where to place
CSS files, images, other media, etc. The goal is that someone reading this
file can follow your instructions and be using this project within minutes.
-------------------------------------------------------------------------------
Additional Notes
 
Anything else you think is of interest (for example, object hierarchy) should
be placed here.
/trunk/api/js/dojo1.0/dojox/gfx3d/gradient.js
New file
0,0 → 1,41
if(!dojo._hasResource["dojox.gfx3d.gradient"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx3d.gradient"] = true;
dojo.provide("dojox.gfx3d.gradient");
 
dojo.require("dojox.gfx3d.vector");
dojo.require("dojox.gfx3d.matrix");
 
(function(){
var dist = function(a, b){ return Math.sqrt(Math.pow(b.x - a.x, 2) + Math.pow(b.y - a.y, 2)); };
var N = 32;
 
dojox.gfx3d.gradient = function(model, material, center, radius, from, to, matrix){
// summary: calculate a cylindrical gradient
// model: dojox.gfx3d.lighting.Model: color model
// material: Object: defines visual properties
// center: Object: center of the cylinder's bottom
// radius: Number: radius of the cylinder
// from: Number: from position in radians
// to: Number: from position in radians
// matrix: dojox.gfx3d.Matrix3D: the cumulative transformation matrix
// tolerance: Number: tolerable diffirence in colors between gradient steps
 
var m = dojox.gfx3d.matrix, v = dojox.gfx3d.vector, mx = m.normalize(matrix),
f = m.multiplyPoint(mx, radius * Math.cos(from) + center.x, radius * Math.sin(from) + center.y, center.z),
t = m.multiplyPoint(mx, radius * Math.cos(to) + center.x, radius * Math.sin(to) + center.y, center.z),
c = m.multiplyPoint(mx, center.x, center.y, center.z), step = (to - from) / N, r = dist(f, t) / 2,
mod = model[material.type], fin = material.finish, pmt = material.color,
colors = [{offset: 0, color: mod.call(model, v.substract(f, c), fin, pmt)}];
 
for(var a = from + step; a < to; a += step){
var p = m.multiplyPoint(mx, radius * Math.cos(a) + center.x, radius * Math.sin(a) + center.y, center.z),
df = dist(f, p), dt = dist(t, p);
colors.push({offset: df / (df + dt), color: mod.call(model, v.substract(p, c), fin, pmt)});
}
colors.push({offset: 1, color: mod.call(model, v.substract(t, c), fin, pmt)});
 
return {type: "linear", x1: 0, y1: -r, x2: 0, y2: r, colors: colors};
};
})();
 
}
/trunk/api/js/dojo1.0/dojox/gfx3d/scheduler.js
New file
0,0 → 1,126
if(!dojo._hasResource["dojox.gfx3d.scheduler"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx3d.scheduler"] = true;
dojo.provide("dojox.gfx3d.scheduler");
dojo.provide("dojox.gfx3d.drawer");
dojo.require("dojox.gfx3d.vector");
 
dojo.mixin(dojox.gfx3d.scheduler, {
zOrder: function(buffer, order){
order = order ? order : dojox.gfx3d.scheduler.order;
buffer.sort(function(a, b){
return order(b) - order(a);
});
return buffer;
},
 
bsp: function(buffer, outline){
console.debug("BSP scheduler");
outline = outline ? outline : dojox.gfx3d.scheduler.outline;
var p = new dojox.gfx3d.scheduler.BinarySearchTree(buffer[0], outline);
dojo.forEach(buffer.slice(1), function(item){ p.add(item, outline); });
return p.iterate(outline);
},
 
// default implementation
order: function(it){
return it.getZOrder();
},
 
outline: function(it){
return it.getOutline();
}
 
});
 
dojo.declare("dojox.gfx3d.scheduler.BinarySearchTree", null, {
constructor: function(obj, outline){
// summary: build the binary search tree, using binary space partition algorithm.
// The idea is for any polygon, for example, (a, b, c), the space is divided by
// the plane into two space: plus and minus.
//
// for any arbitary vertex p, if(p - a) dotProduct n = 0, p is inside the plane,
// > 0, p is in the plus space, vice versa for minus space.
// n is the normal vector that is perpendicular the plate, defined as:
// n = ( b - a) crossProduct ( c - a )
//
// in this implementation, n is declared as normal, ,a is declared as orient.
//
// obj: object: dojox.gfx3d.Object
this.plus = null;
this.minus = null;
this.object = obj;
 
var o = outline(obj);
this.orient = o[0];
this.normal = dojox.gfx3d.vector.normalize(o);
},
 
add: function(obj, outline){
var epsilon = 0.5, o = outline(obj), v = dojox.gfx3d.vector, n = this.normal, a = this.orient;
 
if(dojo.every(o, function(item){ return Math.floor(epsilon + v.dotProduct(n, v.substract(item, a))) <= 0; })){
if(this.minus){
this.minus.add(obj, outline);
} else {
this.minus = new dojox.gfx3d.scheduler.BinarySearchTree(obj, outline);
}
} else if(dojo.every(o, function(item){ return Math.floor(epsilon + v.dotProduct(n, v.substract(item, a))) >= 0; })){
if(this.plus){
this.plus.add(obj, outline);
} else {
this.plus = new dojox.gfx3d.scheduler.BinarySearchTree(obj, outline);
}
} else {
dojo.forEach(o, function(item){ console.debug(v.dotProduct(n, v.substract(item, a))); });
throw "The case: polygon cross siblings' plate is not implemneted yet";
}
},
 
iterate: function(outline){
var epsilon = 0.5;
var v = dojox.gfx3d.vector;
var sorted = [];
var subs = null;
// FIXME: using Infinity here?
var view = {x: 0, y: 0, z: -10000};
if(Math.floor( epsilon + v.dotProduct(this.normal, v.substract(view, this.orient))) <= 0){
subs = [this.plus, this.minus];
} else {
subs = [this.minus, this.plus];
}
 
if(subs[0]){
sorted = sorted.concat(subs[0].iterate());
}
sorted.push(this.object);
if(subs[1]){
sorted = sorted.concat(subs[1].iterate());
}
return sorted;
}
 
});
 
dojo.mixin(dojox.gfx3d.drawer, {
conservative: function(todos, objects, viewport){
console.debug('conservative draw');
dojo.forEach(this.objects, function(item){
item.destroy();
});
dojo.forEach(objects, function(item){
item.draw(viewport.lighting);
});
},
chart: function(todos, objects, viewport){
// NOTE: ondemand may require the todos' objects to use setShape
// to redraw themselves to maintain the z-order.
console.debug('chart draw');
dojo.forEach(this.todos, function(item){
item.draw(viewport.lighting);
});
}
// More aggrasive optimization may re-order the DOM nodes using the order
// of objects, and only elements of todos call setShape.
});
 
}
/trunk/api/js/dojo1.0/dojox/gfx3d/README
New file
0,0 → 1,36
-------------------------------------------------------------------------------
dojox.gfx3d
-------------------------------------------------------------------------------
Version 0.100
Release date: 10/31/2007
-------------------------------------------------------------------------------
Project state:
beta
-------------------------------------------------------------------------------
Credits
Kun Xi (bookstack@gmail.com)
Eugene Lazutkin (eugene.lazutkin@gmail.com)
-------------------------------------------------------------------------------
Project description
 
Implementation of simple portable 3D graphics library.
-------------------------------------------------------------------------------
Dependencies:
 
Dojo Core, dojox.gfx.
-------------------------------------------------------------------------------
Documentation
 
Not ready yet.
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/gfx3d.js
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/gfx3d/*
 
Install into the following directory structure:
/dojox/gfx3d/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
/trunk/api/js/dojo1.0/dojox/gfx3d/vector.js
New file
0,0 → 1,110
if(!dojo._hasResource["dojox.gfx3d.vector"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx3d.vector"] = true;
dojo.provide("dojox.gfx3d.vector");
 
dojo.mixin(dojox.gfx3d.vector, {
sum: function(){
// summary: sum of the vectors
var v = {x: 0, y: 0, z:0};
dojo.forEach(arguments, function(item){ v.x += item.x; v.y += item.y; v.z += item.z; });
return v;
},
 
center: function(){
// summary: center of the vectors
var l = arguments.length;
if(l == 0){
return {x: 0, y: 0, z: 0};
}
var v = dojox.gfx3d.vector.sum(arguments);
return {x: v.x/l, y: v.y/l, z: v.z/l};
},
 
substract: function(/* Pointer */a, /* Pointer */b){
return {x: a.x - b.x, y: a.y - b.y, z: a.z - b.z};
},
 
_crossProduct: function(x, y, z, u, v, w){
// summary: applies a cross product of two vectorss, (x, y, z) and (u, v, w)
// x: Number: an x coordinate of a point
// y: Number: a y coordinate of a point
// z: Number: a z coordinate of a point
// u: Number: an x coordinate of a point
// v: Number: a y coordinate of a point
// w: Number: a z coordinate of a point
return {x: y * w - z * v, y: z * u - x * w, z: x * v - y * u}; // Object
},
 
crossProduct: function(/* Number||Point */ a, /* Number||Point */ b, /* Number, optional */ c, /* Number, optional */ d, /* Number, optional */ e, /* Number, optional */ f){
// summary: applies a matrix to a point
// matrix: dojox.gfx3d.matrix.Matrix3D: a 3D matrix object to be applied
// a: Number: an x coordinate of a point
// b: Number: a y coordinate of a point
// c: Number: a z coordinate of a point
// d: Number: an x coordinate of a point
// e: Number: a y coordinate of a point
// f: Number: a z coordinate of a point
if(arguments.length == 6 && dojo.every(arguments, function(item){ return typeof item == "number"; })){
return dojox.gfx3d.vector._crossProduct(a, b, c, d, e, f); // Object
}
// branch
// a: Object: a point
// b: Object: a point
// c: null
// d: null
// e: null
// f: null
return dojox.gfx3d.vector._crossProduct(a.x, a.y, a.z, b.x, b.y, b.z); // Object
},
 
_dotProduct: function(x, y, z, u, v, w){
// summary: applies a cross product of two vectorss, (x, y, z) and (u, v, w)
// x: Number: an x coordinate of a point
// y: Number: a y coordinate of a point
// z: Number: a z coordinate of a point
// u: Number: an x coordinate of a point
// v: Number: a y coordinate of a point
// w: Number: a z coordinate of a point
return x * u + y * v + z * w; // Number
},
dotProduct: function(/* Number||Point */ a, /* Number||Point */ b, /* Number, optional */ c, /* Number, optional */ d, /* Number, optional */ e, /* Number, optional */ f){
// summary: applies a matrix to a point
// matrix: dojox.gfx3d.matrix.Matrix3D: a 3D matrix object to be applied
// a: Number: an x coordinate of a point
// b: Number: a y coordinate of a point
// c: Number: a z coordinate of a point
// d: Number: an x coordinate of a point
// e: Number: a y coordinate of a point
// f: Number: a z coordinate of a point
if(arguments.length == 6 && dojo.every(arguments, function(item){ return typeof item == "number"; })){
return dojox.gfx3d.vector._dotProduct(a, b, c, d, e, f); // Object
}
// branch
// a: Object: a point
// b: Object: a point
// c: null
// d: null
// e: null
// f: null
return dojox.gfx3d.vector._dotProduct(a.x, a.y, a.z, b.x, b.y, b.z); // Object
},
 
normalize: function(/* Point||Array*/ a, /* Point */ b, /* Point */ c){
// summary: find the normal of the implicit surface
// a: Object: a point
// b: Object: a point
// c: Object: a point
var l, m, n;
if(a instanceof Array){
l = a[0]; m = a[1]; n = a[2];
}else{
l = a; m = b; n = c;
}
 
var u = dojox.gfx3d.vector.substract(m, l);
var v = dojox.gfx3d.vector.substract(n, l);
return dojox.gfx3d.vector.crossProduct(u, v);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/gfx3d/matrix.js
New file
0,0 → 1,339
if(!dojo._hasResource["dojox.gfx3d.matrix"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx3d.matrix"] = true;
dojo.provide("dojox.gfx3d.matrix");
 
// candidates for dojox.math:
dojox.gfx3d.matrix._degToRad = function(degree){ return Math.PI * degree / 180; };
dojox.gfx3d.matrix._radToDeg = function(radian){ return radian / Math.PI * 180; };
 
dojox.gfx3d.matrix.Matrix3D = function(arg){
// summary: a 3D matrix object
// description: Normalizes a 3D matrix-like object. If arrays is passed,
// all objects of the array are normalized and multiplied sequentially.
// arg: Object
// a 3D matrix-like object, a number, or an array of such objects
if(arg){
if(typeof arg == "number"){
this.xx = this.yy = this.zz = arg;
}else if(arg instanceof Array){
if(arg.length > 0){
var m = dojox.gfx3d.matrix.normalize(arg[0]);
// combine matrices
for(var i = 1; i < arg.length; ++i){
var l = m;
var r = dojox.gfx3d.matrix.normalize(arg[i]);
m = new dojox.gfx3d.matrix.Matrix3D();
m.xx = l.xx * r.xx + l.xy * r.yx + l.xz * r.zx;
m.xy = l.xx * r.xy + l.xy * r.yy + l.xz * r.zy;
m.xz = l.xx * r.xz + l.xy * r.yz + l.xz * r.zz;
m.yx = l.yx * r.xx + l.yy * r.yx + l.yz * r.zx;
m.yy = l.yx * r.xy + l.yy * r.yy + l.yz * r.zy;
m.yz = l.yx * r.xz + l.yy * r.yz + l.yz * r.zz;
m.zx = l.zx * r.xx + l.zy * r.yx + l.zz * r.zx;
m.zy = l.zx * r.xy + l.zy * r.yy + l.zz * r.zy;
m.zz = l.zx * r.xz + l.zy * r.yz + l.zz * r.zz;
m.dx = l.xx * r.dx + l.xy * r.dy + l.xz * r.dz + l.dx;
m.dy = l.yx * r.dx + l.yy * r.dy + l.yz * r.dz + l.dy;
m.dz = l.zx * r.dx + l.zy * r.dy + l.zz * r.dz + l.dz;
}
dojo.mixin(this, m);
}
}else{
dojo.mixin(this, arg);
}
}
};
 
// the default (identity) matrix, which is used to fill in missing values
dojo.extend(dojox.gfx3d.matrix.Matrix3D, {xx: 1, xy: 0, xz: 0, yx: 0, yy: 1, yz: 0, zx: 0, zy: 0, zz: 1, dx: 0, dy: 0, dz: 0});
 
dojo.mixin(dojox.gfx3d.matrix, {
// summary: class constants, and methods of dojox.gfx3d.matrix
// matrix constants
// identity: dojox.gfx3d.matrix.Matrix3D
// an identity matrix constant: identity * (x, y, z) == (x, y, z)
identity: new dojox.gfx3d.matrix.Matrix3D(),
// matrix creators
translate: function(a, b, c){
// summary: forms a translation matrix
// description: The resulting matrix is used to translate (move) points by specified offsets.
// a: Number: an x coordinate value
// b: Number: a y coordinate value
// c: Number: a z coordinate value
if(arguments.length > 1){
return new dojox.gfx3d.matrix.Matrix3D({dx: a, dy: b, dz: c}); // dojox.gfx3d.matrix.Matrix3D
}
// branch
// a: Object: a point-like object, which specifies offsets for 3 dimensions
// b: null
return new dojox.gfx3d.matrix.Matrix3D({dx: a.x, dy: a.y, dz: a.z}); // dojox.gfx3d.matrix.Matrix3D
},
scale: function(a, b, c){
// summary: forms a scaling matrix
// description: The resulting matrix is used to scale (magnify) points by specified offsets.
// a: Number: a scaling factor used for the x coordinate
// b: Number: a scaling factor used for the y coordinate
// c: Number: a scaling factor used for the z coordinate
if(arguments.length > 1){
return new dojox.gfx3d.matrix.Matrix3D({xx: a, yy: b, zz: c}); // dojox.gfx3d.matrix.Matrix3D
}
if(typeof a == "number"){
// branch
// a: Number: a uniform scaling factor used for the all coordinates
// b: null
return new dojox.gfx3d.matrix.Matrix3D({xx: a, yy: a, zz: a}); // dojox.gfx3d.matrix.Matrix3D
}
// branch
// a: Object: a point-like object, which specifies scale factors for 3 dimensions
// b: null
return new dojox.gfx3d.matrix.Matrix3D({xx: a.x, yy: a.y, zz: a.z}); // dojox.gfx3d.matrix.Matrix3D
},
rotateX: function(angle){
// summary: forms a rotating matrix (about the x axis)
// 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)
var c = Math.cos(angle);
var s = Math.sin(angle);
return new dojox.gfx3d.matrix.Matrix3D({yy: c, yz: -s, zy: s, zz: c}); // dojox.gfx3d.matrix.Matrix3D
},
rotateXg: function(degree){
// summary: forms a rotating matrix (about the x axis)
// description: The resulting matrix is used to rotate points
// around the origin of coordinates (0, 0) by specified degree.
// See dojox.gfx3d.matrix.rotateX() for comparison.
// degree: Number: an angle of rotation in degrees (>0 for CW)
return dojox.gfx3d.matrix.rotateX(dojox.gfx3d.matrix._degToRad(degree)); // dojox.gfx3d.matrix.Matrix3D
},
rotateY: function(angle){
// summary: forms a rotating matrix (about the y axis)
// 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)
var c = Math.cos(angle);
var s = Math.sin(angle);
return new dojox.gfx3d.matrix.Matrix3D({xx: c, xz: s, zx: -s, zz: c}); // dojox.gfx3d.matrix.Matrix3D
},
rotateYg: function(degree){
// summary: forms a rotating matrix (about the y axis)
// description: The resulting matrix is used to rotate points
// around the origin of coordinates (0, 0) by specified degree.
// See dojox.gfx3d.matrix.rotateY() for comparison.
// degree: Number: an angle of rotation in degrees (>0 for CW)
return dojox.gfx3d.matrix.rotateY(dojox.gfx3d.matrix._degToRad(degree)); // dojox.gfx3d.matrix.Matrix3D
},
rotateZ: function(angle){
// summary: forms a rotating matrix (about the z axis)
// 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)
var c = Math.cos(angle);
var s = Math.sin(angle);
return new dojox.gfx3d.matrix.Matrix3D({xx: c, xy: -s, yx: s, yy: c}); // dojox.gfx3d.matrix.Matrix3D
},
rotateZg: function(degree){
// summary: forms a rotating matrix (about the z axis)
// description: The resulting matrix is used to rotate points
// around the origin of coordinates (0, 0) by specified degree.
// See dojox.gfx3d.matrix.rotateZ() for comparison.
// degree: Number: an angle of rotation in degrees (>0 for CW)
return dojox.gfx3d.matrix.rotateZ(dojox.gfx3d.matrix._degToRad(degree)); // dojox.gfx3d.matrix.Matrix3D
},
 
// camera transformation
cameraTranslate: function(a, b, c){
// summary: forms a translation matrix
// description: The resulting matrix is used to translate (move) points by specified offsets.
// a: Number: an x coordinate value
// b: Number: a y coordinate value
// c: Number: a z coordinate value
if(arguments.length > 1){
return new dojox.gfx3d.matrix.Matrix3D({dx: -a, dy: -b, dz: -c}); // dojox.gfx3d.matrix.Matrix3D
}
// branch
// a: Object: a point-like object, which specifies offsets for 3 dimensions
// b: null
return new dojox.gfx3d.matrix.Matrix3D({dx: -a.x, dy: -a.y, dz: -a.z}); // dojox.gfx3d.matrix.Matrix3D
},
cameraRotateX: function(angle){
// summary: forms a rotating matrix (about the x axis) in cameraTransform manner
// 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)
var c = Math.cos(-angle);
var s = Math.sin(-angle);
return new dojox.gfx3d.matrix.Matrix3D({yy: c, yz: -s, zy: s, zz: c}); // dojox.gfx3d.matrix.Matrix3D
},
cameraRotateXg: function(degree){
// summary: forms a rotating matrix (about the x axis)in cameraTransform manner
// description: The resulting matrix is used to rotate points
// around the origin of coordinates (0, 0) by specified degree.
// See dojox.gfx3d.matrix.rotateX() for comparison.
// degree: Number: an angle of rotation in degrees (>0 for CW)
return dojox.gfx3d.matrix.rotateX(dojox.gfx3d.matrix._degToRad(degree)); // dojox.gfx3d.matrix.Matrix3D
},
cameraRotateY: function(angle){
// summary: forms a rotating matrix (about the y axis) in cameraTransform manner
// 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)
var c = Math.cos(-angle);
var s = Math.sin(-angle);
return new dojox.gfx3d.matrix.Matrix3D({xx: c, xz: s, zx: -s, zz: c}); // dojox.gfx3d.matrix.Matrix3D
},
cameraRotateYg: function(degree){
// summary: forms a rotating matrix (about the y axis) in cameraTransform manner
// description: The resulting matrix is used to rotate points
// around the origin of coordinates (0, 0) by specified degree.
// See dojox.gfx3d.matrix.rotateY() for comparison.
// degree: Number: an angle of rotation in degrees (>0 for CW)
return dojox.gfx3d.matrix.rotateY(dojox.gfx3d.matrix._degToRad(degree)); // dojox.gfx3d.matrix.Matrix3D
},
cameraRotateZ: function(angle){
// summary: forms a rotating matrix (about the z axis) in cameraTransform manner
// 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)
var c = Math.cos(-angle);
var s = Math.sin(-angle);
return new dojox.gfx3d.matrix.Matrix3D({xx: c, xy: -s, yx: s, yy: c}); // dojox.gfx3d.matrix.Matrix3D
},
cameraRotateZg: function(degree){
// summary: forms a rotating matrix (about the z axis) in cameraTransform manner
// description: The resulting matrix is used to rotate points
// around the origin of coordinates (0, 0) by specified degree.
// See dojox.gfx3d.matrix.rotateZ() for comparison.
// degree: Number: an angle of rotation in degrees (>0 for CW)
return dojox.gfx3d.matrix.rotateZ(dojox.gfx3d.matrix._degToRad(degree)); // dojox.gfx3d.matrix.Matrix3D
},
 
// ensure matrix 3D conformance
normalize: function(matrix){
// summary: converts an object to a matrix, if necessary
// description: Converts any 3D matrix-like object or an array of
// such objects to a valid dojox.gfx3d.matrix.Matrix3D object.
// matrix: Object: an object, which is converted to a matrix, if necessary
return (matrix instanceof dojox.gfx3d.matrix.Matrix3D) ? matrix : new dojox.gfx3d.matrix.Matrix3D(matrix); // dojox.gfx3d.matrix.Matrix3D
},
// common operations
clone: function(matrix){
// summary: creates a copy of a 3D matrix
// matrix: dojox.gfx3d.matrix.Matrix3D: a 3D matrix-like object to be cloned
var obj = new dojox.gfx3d.matrix.Matrix3D();
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.gfx3d.matrix.Matrix3D
},
invert: function(matrix){
// summary: inverts a 2D matrix
// matrix: dojox.gfx.matrix.Matrix3D: a 2D matrix-like object to be inverted
var m = dojox.gfx3d.matrix.normalize(matrix);
var D = m.xx * m.yy * m.zz + m.xy * m.yz * m.zx + m.xz * m.yx * m.zy - m.xx * m.yz * m.zy - m.xy * m.yx * m.zz - m.xz * m.yy * m.zx;
var M = new dojox.gfx3d.matrix.Matrix3D({
xx: (m.yy * m.zz - m.yz * m.zy) / D,
xy: (m.xz * m.zy - m.xy * m.zz) / D,
xz: (m.xy * m.yz - m.xz * m.yy) / D,
yx: (m.yz * m.zx - m.yx * m.zz) / D,
yy: (m.xx * m.zz - m.xz * m.zx) / D,
yz: (m.xz * m.yx - m.xx * m.yz) / D,
zx: (m.yx * m.zy - m.yy * m.zx) / D,
zy: (m.xy * m.zx - m.xx * m.zy) / D,
zz: (m.xx * m.yy - m.xy * m.yx) / D,
dx: -1 * (m.xy * m.yz * m.dz + m.xz * m.dy * m.zy + m.dx * m.yy * m.zz - m.xy * m.dy * m.zz - m.xz * m.yy * m.dz - m.dx * m.yz * m.zy) / D,
dy: (m.xx * m.yz * m.dz + m.xz * m.dy * m.zx + m.dx * m.yx * m.zz - m.xx * m.dy * m.zz - m.xz * m.yx * m.dz - m.dx * m.yz * m.zx) / D,
dz: -1 * (m.xx * m.yy * m.dz + m.xy * m.dy * m.zx + m.dx * m.yx * m.zy - m.xx * m.dy * m.zy - m.xy * m.yx * m.dz - m.dx * m.yy * m.zx) / D
});
return M; // dojox.gfx3d.matrix.Matrix3D
},
_multiplyPoint: function(m, x, y, z){
// summary: applies a matrix to a point
// matrix: dojox.gfx3d.matrix.Matrix3D: a 3D matrix object to be applied
// x: Number: an x coordinate of a point
// y: Number: a y coordinate of a point
// z: Number: a z coordinate of a point
return {x: m.xx * x + m.xy * y + m.xz * z + m.dx, y: m.yx * x + m.yy * y + m.yz * z + m.dy, z: m.zx * x + m.zy * y + m.zz * z + m.dz}; // Object
},
multiplyPoint: function(matrix, /* Number||Point */ a, /* Number, optional */ b, /* Number, optional */ c){
// summary: applies a matrix to a point
// matrix: dojox.gfx3d.matrix.Matrix3D: a 3D matrix object to be applied
// a: Number: an x coordinate of a point
// b: Number: a y coordinate of a point
// c: Number: a z coordinate of a point
var m = dojox.gfx3d.matrix.normalize(matrix);
if(typeof a == "number" && typeof b == "number" && typeof c == "number"){
return dojox.gfx3d.matrix._multiplyPoint(m, a, b, c); // Object
}
// branch
// matrix: dojox.gfx3d.matrix.Matrix3D: a 3D matrix object to be applied
// a: Object: a point
// b: null
// c: null
return dojox.gfx3d.matrix._multiplyPoint(m, a.x, a.y, a.z); // Object
},
multiply: function(matrix){
// summary: combines matrices by multiplying them sequentially in the given order
// matrix: dojox.gfx3d.matrix.Matrix3D...: a 3D matrix-like object,
// all subsequent arguments are matrix-like objects too
var m = dojox.gfx3d.matrix.normalize(matrix);
// combine matrices
for(var i = 1; i < arguments.length; ++i){
var l = m;
var r = dojox.gfx3d.matrix.normalize(arguments[i]);
m = new dojox.gfx3d.matrix.Matrix3D();
m.xx = l.xx * r.xx + l.xy * r.yx + l.xz * r.zx;
m.xy = l.xx * r.xy + l.xy * r.yy + l.xz * r.zy;
m.xz = l.xx * r.xz + l.xy * r.yz + l.xz * r.zz;
m.yx = l.yx * r.xx + l.yy * r.yx + l.yz * r.zx;
m.yy = l.yx * r.xy + l.yy * r.yy + l.yz * r.zy;
m.yz = l.yx * r.xz + l.yy * r.yz + l.yz * r.zz;
m.zx = l.zx * r.xx + l.zy * r.yx + l.zz * r.zx;
m.zy = l.zx * r.xy + l.zy * r.yy + l.zz * r.zy;
m.zz = l.zx * r.xz + l.zy * r.yz + l.zz * r.zz;
m.dx = l.xx * r.dx + l.xy * r.dy + l.xz * r.dz + l.dx;
m.dy = l.yx * r.dx + l.yy * r.dy + l.yz * r.dz + l.dy;
m.dz = l.zx * r.dx + l.zy * r.dy + l.zz * r.dz + l.dz;
}
return m; // dojox.gfx3d.matrix.Matrix3D
},
 
_project: function(m, x, y, z){
// summary: applies a matrix to a point
// matrix: dojox.gfx3d.matrix.Matrix3D: a 3D matrix object to be applied
// x: Number: an x coordinate of a point
// y: Number: a y coordinate of a point
// z: Number: a z coordinate of a point
return { // Object
x: m.xx * x + m.xy * y + m.xz * z + m.dx,
y: m.yx * x + m.yy * y + m.yz * z + m.dy,
z: m.zx * x + m.zy * y + m.zz * z + m.dz};
},
project: function(matrix, /* Number||Point */ a, /* Number, optional */ b, /* Number, optional */ c){
// summary: applies a matrix to a point
// matrix: dojox.gfx3d.matrix.Matrix3D: a 3D matrix object to be applied
// a: Number: an x coordinate of a point
// b: Number: a y coordinate of a point
// c: Number: a z coordinate of a point
var m = dojox.gfx3d.matrix.normalize(matrix);
if(typeof a == "number" && typeof b == "number" && typeof c == "number"){
return dojox.gfx3d.matrix._project(m, a, b, c); // Object
}
// branch
// matrix: dojox.gfx3d.matrix.Matrix3D: a 3D matrix object to be applied
// a: Object: a point
// b: null
// c: null
return dojox.gfx3d.matrix._project(m, a.x, a.y, a.z); // Object
}
});
 
// propagate matrix up
dojox.gfx3d.Matrix3D = dojox.gfx3d.matrix.Matrix3D;
 
}
/trunk/api/js/dojo1.0/dojox/gfx3d/lighting.js
New file
0,0 → 1,241
if(!dojo._hasResource["dojox.gfx3d.lighting"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx3d.lighting"] = true;
dojo.provide("dojox.gfx3d.lighting");
dojo.require("dojox.gfx._base");
 
(function(){
var lite = dojox.gfx3d.lighting;
 
dojo.mixin(dojox.gfx3d.lighting, {
// color utilities
black: function(){
return {r: 0, g: 0, b: 0, a: 1};
},
white: function(){
return {r: 1, g: 1, b: 1, a: 1};
},
toStdColor: function(c){
c = dojox.gfx.normalizeColor(c);
return {r: c.r / 255, g: c.g / 255, b: c.b / 255, a: c.a};
},
fromStdColor: function(c){
return new dojo.Color([Math.round(255 * c.r), Math.round(255 * c.g), Math.round(255 * c.b), c.a]);
},
scaleColor: function(s, c){
return {r: s * c.r, g: s * c.g, b: s * c.b, a: s * c.a};
},
addColor: function(a, b){
return {r: a.r + b.r, g: a.g + b.g, b: a.b + b.b, a: a.a + b.a};
},
multiplyColor: function(a, b){
return {r: a.r * b.r, g: a.g * b.g, b: a.b * b.b, a: a.a * b.a};
},
saturateColor: function(c){
return {
r: c.r < 0 ? 0 : c.r > 1 ? 1 : c.r,
g: c.g < 0 ? 0 : c.g > 1 ? 1 : c.g,
b: c.b < 0 ? 0 : c.b > 1 ? 1 : c.b,
a: c.a < 0 ? 0 : c.a > 1 ? 1 : c.a
};
},
mixColor: function(c1, c2, s){
return lite.addColor(lite.scaleColor(s, c1), lite.scaleColor(1 - s, c2));
},
diff2Color: function(c1, c2){
var r = c1.r - c2.r;
var g = c1.g - c2.g;
var b = c1.b - c2.b;
var a = c1.a - c2.a;
return r * r + g * g + b * b + a * a;
},
length2Color: function(c){
return c.r * c.r + c.g * c.g + c.b * c.b + c.a * c.a;
},
// vector utilities
//TODO: move vector utilities from this file to vector.js
dot: function(a, b){
return a.x * b.x + a.y * b.y + a.z * b.z;
},
scale: function(s, v){
return {x: s * v.x, y: s * v.y, z: s * v.z};
},
add: function(a, b){
return {x: a.x + b.x, y: a.y + b.y, z: a.z + b.z};
},
saturate: function(v){
return Math.min(Math.max(v, 0), 1);
},
length: function(v){
return Math.sqrt(dojox.gfx3d.lighting.dot(v, v));
},
normalize: function(v){
return lite.scale(1 / lite.length(v), v);
},
faceforward: function(n, i){
var p = dojox.gfx3d.lighting;
var s = p.dot(i, n) < 0 ? 1 : -1;
return p.scale(s, n);
},
reflect: function(i, n){
var p = dojox.gfx3d.lighting;
return p.add(i, p.scale(-2 * p.dot(i, n), n));
},
// lighting utilities
diffuse: function(normal, lights){
var c = lite.black();
for(var i = 0; i < lights.length; ++i){
var l = lights[i],
d = lite.dot(lite.normalize(l.direction), normal);
c = lite.addColor(c, lite.scaleColor(d, l.color));
}
return lite.saturateColor(c);
},
specular: function(normal, v, roughness, lights){
var c = lite.black();
for(var i = 0; i < lights.length; ++i){
var l = lights[i],
h = lite.normalize(lite.add(lite.normalize(l.direction), v)),
s = Math.pow(Math.max(0, lite.dot(normal, h)), 1 / roughness);
c = lite.addColor(c, lite.scaleColor(s, l.color));
}
return lite.saturateColor(c);
},
phong: function(normal, v, size, lights){
normal = lite.normalize(normal);
var c = lite.black();
for(var i = 0; i < lights.length; ++i){
var l = lights[i],
r = lite.reflect(lite.scale(-1, lite.normalize(v)), normal),
s = Math.pow(Math.max(0, lite.dot(r, lite.normalize(l.direction))), size);
c = lite.addColor(c, lite.scaleColor(s, l.color));
}
return lite.saturateColor(c);
}
});
 
// this lighting model is derived from RenderMan Interface Specification Version 3.2
 
dojo.declare("dojox.gfx3d.lighting.Model", null, {
constructor: function(incident, lights, ambient, specular){
this.incident = lite.normalize(incident);
this.lights = [];
for(var i = 0; i < lights.length; ++i){
var l = lights[i];
this.lights.push({direction: lite.normalize(l.direction), color: lite.toStdColor(l.color)});
}
this.ambient = lite.toStdColor(ambient.color ? ambient.color : "white");
this.ambient = lite.scaleColor(ambient.intensity, this.ambient);
this.ambient = lite.scaleColor(this.ambient.a, this.ambient);
this.ambient.a = 1;
this.specular = lite.toStdColor(specular ? specular : "white");
this.specular = lite.scaleColor(this.specular.a, this.specular);
this.specular.a = 1;
this.npr_cool = {r: 0, g: 0, b: 0.4, a: 1};
this.npr_warm = {r: 0.4, g: 0.4, b: 0.2, a: 1};
this.npr_alpha = 0.2;
this.npr_beta = 0.6;
this.npr_scale = 0.6;
},
constant: function(normal, finish, pigment){
pigment = lite.toStdColor(pigment);
var alpha = pigment.a, color = lite.scaleColor(alpha, pigment);
color.a = alpha;
return lite.fromStdColor(lite.saturateColor(color));
},
matte: function(normal, finish, pigment){
if(typeof finish == "string"){ finish = lite.finish[finish]; }
pigment = lite.toStdColor(pigment);
normal = lite.faceforward(lite.normalize(normal), this.incident);
var ambient = lite.scaleColor(finish.Ka, this.ambient),
shadow = lite.saturate(-4 * lite.dot(normal, this.incident)),
diffuse = lite.scaleColor(shadow * finish.Kd, lite.diffuse(normal, this.lights)),
color = lite.scaleColor(pigment.a, lite.multiplyColor(pigment, lite.addColor(ambient, diffuse)));
color.a = pigment.a;
return lite.fromStdColor(lite.saturateColor(color));
},
metal: function(normal, finish, pigment){
if(typeof finish == "string"){ finish = lite.finish[finish]; }
pigment = lite.toStdColor(pigment);
normal = lite.faceforward(lite.normalize(normal), this.incident);
var v = lite.scale(-1, this.incident), specular, color,
ambient = lite.scaleColor(finish.Ka, this.ambient),
shadow = lite.saturate(-4 * lite.dot(normal, this.incident));
if("phong" in finish){
specular = lite.scaleColor(shadow * finish.Ks * finish.phong, lite.phong(normal, v, finish.phong_size, this.lights));
}else{
specular = lite.scaleColor(shadow * finish.Ks, lite.specular(normal, v, finish.roughness, this.lights));
}
color = lite.scaleColor(pigment.a, lite.addColor(lite.multiplyColor(pigment, ambient), lite.multiplyColor(this.specular, specular)));
color.a = pigment.a;
return lite.fromStdColor(lite.saturateColor(color));
},
plastic: function(normal, finish, pigment){
if(typeof finish == "string"){ finish = lite.finish[finish]; }
pigment = lite.toStdColor(pigment);
normal = lite.faceforward(lite.normalize(normal), this.incident);
var v = lite.scale(-1, this.incident), specular, color,
ambient = lite.scaleColor(finish.Ka, this.ambient),
shadow = lite.saturate(-4 * lite.dot(normal, this.incident)),
diffuse = lite.scaleColor(shadow * finish.Kd, lite.diffuse(normal, this.lights));
if("phong" in finish){
specular = lite.scaleColor(shadow * finish.Ks * finish.phong, lite.phong(normal, v, finish.phong_size, this.lights));
}else{
specular = lite.scaleColor(shadow * finish.Ks, lite.specular(normal, v, finish.roughness, this.lights));
}
color = lite.scaleColor(pigment.a, lite.addColor(lite.multiplyColor(pigment, lite.addColor(ambient, diffuse)), lite.multiplyColor(this.specular, specular)));
color.a = pigment.a;
return lite.fromStdColor(lite.saturateColor(color));
},
npr: function(normal, finish, pigment){
if(typeof finish == "string"){ finish = lite.finish[finish]; }
pigment = lite.toStdColor(pigment);
normal = lite.faceforward(lite.normalize(normal), this.incident);
var ambient = lite.scaleColor(finish.Ka, this.ambient),
shadow = lite.saturate(-4 * lite.dot(normal, this.incident)),
diffuse = lite.scaleColor(shadow * finish.Kd, lite.diffuse(normal, this.lights)),
color = lite.scaleColor(pigment.a, lite.multiplyColor(pigment, lite.addColor(ambient, diffuse))),
cool = lite.addColor(this.npr_cool, lite.scaleColor(this.npr_alpha, color)),
warm = lite.addColor(this.npr_warm, lite.scaleColor(this.npr_beta, color)),
d = (1 + lite.dot(this.incident, normal)) / 2,
color = lite.scaleColor(this.npr_scale, lite.addColor(color, lite.mixColor(cool, warm, d)));
color.a = pigment.a;
return lite.fromStdColor(lite.saturateColor(color));
}
});
})();
 
// POV-Ray basic finishes
 
dojox.gfx3d.lighting.finish = {
 
// Default
defaults: {Ka: 0.1, Kd: 0.6, Ks: 0.0, roughness: 0.05},
dull: {Ka: 0.1, Kd: 0.6, Ks: 0.5, roughness: 0.15},
shiny: {Ka: 0.1, Kd: 0.6, Ks: 1.0, roughness: 0.001},
glossy: {Ka: 0.1, Kd: 0.6, Ks: 1.0, roughness: 0.0001},
phong_dull: {Ka: 0.1, Kd: 0.6, Ks: 0.5, phong: 0.5, phong_size: 1},
phong_shiny: {Ka: 0.1, Kd: 0.6, Ks: 1.0, phong: 1.0, phong_size: 200},
phong_glossy: {Ka: 0.1, Kd: 0.6, Ks: 1.0, phong: 1.0, phong_size: 300},
 
luminous: {Ka: 1.0, Kd: 0.0, Ks: 0.0, roughness: 0.05},
 
// Metals
 
// very soft and dull
metalA: {Ka: 0.35, Kd: 0.3, Ks: 0.8, roughness: 1/20},
// fairly soft and dull
metalB: {Ka: 0.30, Kd: 0.4, Ks: 0.7, roughness: 1/60},
// medium reflectivity, holds color well
metalC: {Ka: 0.25, Kd: 0.5, Ks: 0.8, roughness: 1/80},
// highly hard and polished, high reflectivity
metalD: {Ka: 0.15, Kd: 0.6, Ks: 0.8, roughness: 1/100},
// very highly polished and reflective
metalE: {Ka: 0.10, Kd: 0.7, Ks: 0.8, roughness: 1/120}
};
 
}
/trunk/api/js/dojo1.0/dojox/gfx3d/object.js
New file
0,0 → 1,1088
if(!dojo._hasResource["dojox.gfx3d.object"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx3d.object"] = true;
dojo.provide("dojox.gfx3d.object");
 
dojo.require("dojox.gfx");
dojo.require("dojox.gfx3d.lighting");
dojo.require("dojox.gfx3d.scheduler");
dojo.require("dojox.gfx3d.vector");
dojo.require("dojox.gfx3d.gradient");
 
// FIXME: why the global "out" var here?
var out = function(o, x){
if(arguments.length > 1){
// console.debug("debug:", o);
o = x;
}
var e = {};
for(var i in o){
if(i in e){ continue; }
// console.debug("debug:", i, typeof o[i], o[i]);
}
};
 
dojo.declare("dojox.gfx3d.Object", null, {
constructor: function(){
// summary: a Object object, which knows how to map
// 3D objects to 2D shapes.
 
// object: Object: an abstract Object object
// (see dojox.gfx3d.defaultEdges,
// dojox.gfx3d.defaultTriangles,
// dojox.gfx3d.defaultQuads
// dojox.gfx3d.defaultOrbit
// dojox.gfx3d.defaultCube
// or dojox.gfx3d.defaultCylinder)
this.object = null;
 
// matrix: dojox.gfx3d.matrix: world transform
this.matrix = null;
// cache: buffer for intermediate result, used late for draw()
this.cache = null;
// renderer: a reference for the Viewport
this.renderer = null;
// parent: a reference for parent, Scene or Viewport object
this.parent = null;
 
// strokeStyle: Object: a stroke object
this.strokeStyle = null;
// fillStyle: Object: a fill object or texture object
this.fillStyle = null;
// shape: dojox.gfx.Shape: an underlying 2D shape
this.shape = null;
},
 
setObject: function(newObject){
// summary: sets a Object object
// object: Object: an abstract Object object
// (see dojox.gfx3d.defaultEdges,
// dojox.gfx3d.defaultTriangles,
// dojox.gfx3d.defaultQuads
// dojox.gfx3d.defaultOrbit
// dojox.gfx3d.defaultCube
// or dojox.gfx3d.defaultCylinder)
this.object = dojox.gfx.makeParameters(this.object, newObject);
return this;
},
 
setTransform: function(matrix){
// summary: sets a transformation matrix
// matrix: dojox.gfx3d.matrix.Matrix: a matrix or a matrix-like object
// (see an argument of dojox.gfx3d.matrix.Matrix
// constructor for a list of acceptable arguments)
this.matrix = dojox.gfx3d.matrix.clone(matrix ? dojox.gfx3d.matrix.normalize(matrix) : dojox.gfx3d.identity, true);
return this; // self
},
 
// apply left & right transformation
applyRightTransform: function(matrix){
// summary: multiplies the existing matrix with an argument on right side
// (this.matrix * matrix)
// matrix: dojox.gfx3d.matrix.Matrix: a matrix or a matrix-like object
// (see an argument of dojox.gfx.matrix.Matrix
// 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.gfx3d.matrix.Matrix: a matrix or a matrix-like object
// (see an argument of dojox.gfx.matrix.Matrix
// 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.applyRightTransform
// matrix: dojox.gfx3d.matrix.Matrix: a matrix or a matrix-like object
// (see an argument of dojox.gfx.matrix.Matrix
// constructor for a list of acceptable arguments)
return matrix ? this.setTransform([this.matrix, matrix]) : this; // self
},
setFill: function(fill){
// summary: sets a fill object
// (the default implementation is to delegate to
// the underlying 2D shape).
// fill: Object: a fill object
// (see dojox.gfx.defaultLinearGradient,
// dojox.gfx.defaultRadialGradient,
// dojox.gfx.defaultPattern,
// dojo.Color
// or dojox.gfx.MODEL)
this.fillStyle = fill;
return this;
},
 
setStroke: function(stroke){
// summary: sets a stroke object
// (the default implementation simply ignores it)
// stroke: Object: a stroke object
// (see dojox.gfx.defaultStroke)
this.strokeStyle = stroke;
return this;
},
 
toStdFill: function(lighting, normal){
return (this.fillStyle && typeof this.fillStyle['type'] != "undefined") ? lighting[this.fillStyle.type](normal, this.fillStyle.finish, this.fillStyle.color) : this.fillStyle;
},
 
invalidate: function(){
this.renderer.addTodo(this);
},
destroy: function(){
if(this.shape){
var p = this.shape.getParent();
if(p){
p.remove(this.shape);
}
this.shape = null;
}
},
 
// All the 3D objects need to override the following virtual functions:
// render, getZOrder, getOutline, draw, redraw if necessary.
 
render: function(camera){
throw "Pure virtual function, not implemented";
},
 
draw: function(lighting){
throw "Pure virtual function, not implemented";
},
 
getZOrder: function(){
return 0;
},
 
getOutline: function(){
return null;
}
 
});
 
dojo.declare("dojox.gfx3d.Scene", dojox.gfx3d.Object, {
// summary: the Scene is just a containter.
// note: we have the following assumption:
// all objects in the Scene are not overlapped with other objects
// outside of the scene.
constructor: function(){
// summary: a containter of other 3D objects
this.objects= [];
this.todos = [];
this.schedule = dojox.gfx3d.scheduler.zOrder;
this._draw = dojox.gfx3d.drawer.conservative;
},
 
setFill: function(fill){
this.fillStyle = fill;
dojo.forEach(this.objects, function(item){
item.setFill(fill);
});
return this;
},
 
setStroke: function(stroke){
this.strokeStyle = stroke;
dojo.forEach(this.objects, function(item){
item.setStroke(stroke);
});
return this;
},
 
render: function(camera, deep){
var m = dojox.gfx3d.matrix.multiply(camera, this.matrix);
if(deep){
this.todos = this.objects;
}
dojo.forEach(this.todos, function(item){ item.render(m, deep); });
},
 
draw: function(lighting){
this.objects = this.schedule(this.objects);
this._draw(this.todos, this.objects, this.renderer);
},
 
addTodo: function(newObject){
// FIXME: use indexOf?
if(dojo.every(this.todos, function(item){ return item != newObject; })){
this.todos.push(newObject);
this.invalidate();
}
},
 
invalidate: function(){
this.parent.addTodo(this);
},
 
getZOrder: function(){
var zOrder = 0;
dojo.forEach(this.objects, function(item){ zOrder += item.getZOrder(); });
return (this.objects.length > 1) ? zOrder / this.objects.length : 0;
}
});
 
 
dojo.declare("dojox.gfx3d.Edges", dojox.gfx3d.Object, {
constructor: function(){
// summary: a generic edge in 3D viewport
this.object = dojo.clone(dojox.gfx3d.defaultEdges);
},
 
setObject: function(newObject, /* String, optional */ style){
// summary: setup the object
// newObject: Array of points || Object
// style: String, optional
this.object = dojox.gfx.makeParameters(this.object, (newObject instanceof Array) ? { points: newObject, style: style } : newObject);
return this;
},
 
getZOrder: function(){
var zOrder = 0;
dojo.forEach(this.cache, function(item){ zOrder += item.z;} );
return (this.cache.length > 1) ? zOrder / this.cache.length : 0;
},
 
render: function(camera){
var m = dojox.gfx3d.matrix.multiply(camera, this.matrix);
this.cache = dojo.map(this.object.points, function(item){
return dojox.gfx3d.matrix.multiplyPoint(m, item);
});
},
 
draw: function(){
var c = this.cache;
if(this.shape){
this.shape.setShape("")
}else{
this.shape = this.renderer.createPath();
}
var p = this.shape.setAbsoluteMode("absolute");
 
if(this.object.style == "strip" || this.object.style == "loop"){
p.moveTo(c[0].x, c[0].y);
dojo.forEach(c.slice(1), function(item){
p.lineTo(item.x, item.y);
});
if(this.object.style == "loop"){
p.closePath();
}
}else{
for(var i = 0; i < this.cache.length; ){
p.moveTo(c[i].x, c[i].y);
i ++;
p.lineTo(c[i].x, c[i].y);
i ++;
}
}
// FIXME: doe setFill make sense here?
p.setStroke(this.strokeStyle);
}
});
 
dojo.declare("dojox.gfx3d.Orbit", dojox.gfx3d.Object, {
constructor: function(){
// summary: a generic edge in 3D viewport
this.object = dojo.clone(dojox.gfx3d.defaultOrbit);
},
 
render: function(camera){
var m = dojox.gfx3d.matrix.multiply(camera, this.matrix);
var angles = [0, Math.PI/4, Math.PI/3];
var center = dojox.gfx3d.matrix.multiplyPoint(m, this.object.center);
var marks = dojo.map(angles, function(item){
return {x: this.center.x + this.radius * Math.cos(item),
y: this.center.y + this.radius * Math.sin(item), z: this.center.z};
}, this.object);
 
marks = dojo.map(marks, function(item){
return dojox.gfx3d.matrix.multiplyPoint(m, item);
});
 
var normal = dojox.gfx3d.vector.normalize(marks);
 
marks = dojo.map(marks, function(item){
return dojox.gfx3d.vector.substract(item, center);
});
 
// Use the algorithm here:
// http://www.3dsoftware.com/Math/PlaneCurves/EllipseAlgebra/
// After we normalize the marks, the equation is:
// a x^2 + 2b xy + cy^2 + f = 0: let a = 1
// so the final equation is:
// [ xy, y^2, 1] * [2b, c, f]' = [ -x^2 ]'
 
var A = {
xx: marks[0].x * marks[0].y, xy: marks[0].y * marks[0].y, xz: 1,
yx: marks[1].x * marks[1].y, yy: marks[1].y * marks[1].y, yz: 1,
zx: marks[2].x * marks[2].y, zy: marks[2].y * marks[2].y, zz: 1,
dx: 0, dy: 0, dz: 0
};
var b = dojo.map(marks, function(item){
return -Math.pow(item.x, 2);
});
 
// X is 2b, c, f
var X = dojox.gfx3d.matrix.multiplyPoint(dojox.gfx3d.matrix.invert(A),b[0], b[1], b[2]);
var theta = Math.atan2(X.x, 1 - X.y) / 2;
 
// rotate the marks back to the canonical form
var probes = dojo.map(marks, function(item){
return dojox.gfx.matrix.multiplyPoint(dojox.gfx.matrix.rotate(-theta), item.x, item.y);
});
 
// we are solving the equation: Ax = b
// A = [x^2, y^2] X = [1/a^2, 1/b^2]', b = [1, 1]'
// so rx = Math.sqrt(1/ ( inv(A)[1:] * b ) );
// so ry = Math.sqrt(1/ ( inv(A)[2:] * b ) );
 
var a = Math.pow(probes[0].x, 2);
var b = Math.pow(probes[0].y, 2);
var c = Math.pow(probes[1].x, 2);
var d = Math.pow(probes[1].y, 2);
 
// the invert matrix is
// 1/(ad -bc) [ d, -b; -c, a];
var rx = Math.sqrt( (a*d - b*c)/ (d-b) );
var ry = Math.sqrt( (a*d - b*c)/ (a-c) );
 
this.cache = {cx: center.x, cy: center.y, rx: rx, ry: ry, theta: theta, normal: normal};
},
 
draw: function(lighting){
if(this.shape){
this.shape.setShape(this.cache);
} else {
this.shape = this.renderer.createEllipse(this.cache);
}
this.shape.applyTransform(dojox.gfx.matrix.rotateAt(this.cache.theta, this.cache.cx, this.cache.cy))
.setStroke(this.strokeStyle)
.setFill(this.toStdFill(lighting, this.cache.normal));
}
});
 
dojo.declare("dojox.gfx3d.Path3d", dojox.gfx3d.Object, {
// This object is still very immature !
constructor: function(){
// summary: a generic line
// (this is a helper object, which is defined for convenience)
this.object = dojo.clone(dojox.gfx3d.defaultPath3d);
this.segments = [];
this.absolute = true;
this.last = {};
this.path = "";
},
 
_collectArgs: function(array, args){
// summary: converts an array of arguments to plain numeric values
// array: Array: an output argument (array of numbers)
// args: Array: an input argument (can be values of Boolean, Number, dojox.gfx.Point, or an embedded array of them)
for(var i = 0; i < args.length; ++i){
var t = args[i];
if(typeof(t) == "boolean"){
array.push(t ? 1 : 0);
}else if(typeof(t) == "number"){
array.push(t);
}else if(t instanceof Array){
this._collectArgs(array, t);
}else if("x" in t && "y" in t){
array.push(t.x);
array.push(t.y);
}
}
},
 
// a dictionary, which maps segment type codes to a number of their argemnts
_validSegments: {m: 3, l: 3, z: 0},
 
_pushSegment: function(action, args){
// summary: adds a segment
// action: String: valid SVG code for a segment's type
// args: Array: a list of parameters for this segment
var group = this._validSegments[action.toLowerCase()];
if(typeof(group) == "number"){
if(group){
if(args.length >= group){
var segment = {action: action, args: args.slice(0, args.length - args.length % group)};
this.segments.push(segment);
}
}else{
var segment = {action: action, args: []};
this.segments.push(segment);
}
}
},
 
moveTo: function(){
// summary: formes a move segment
var args = [];
this._collectArgs(args, arguments);
this._pushSegment(this.absolute ? "M" : "m", args);
return this; // self
},
lineTo: function(){
// summary: formes a line segment
var args = [];
this._collectArgs(args, arguments);
this._pushSegment(this.absolute ? "L" : "l", args);
return this; // self
},
 
closePath: function(){
// summary: closes a path
this._pushSegment("Z", []);
return this; // self
},
 
render: function(camera){
// TODO: we need to get the ancestors' matrix
var m = dojox.gfx3d.matrix.multiply(camera, this.matrix);
// iterate all the segments and convert them to 2D canvas
// TODO consider the relative mode
var path = ""
var _validSegments = this._validSegments;
dojo.forEach(this.segments, function(item){
path += item.action;
for(var i = 0; i < item.args.length; i+= _validSegments[item.action.toLowerCase()] ){
var pt = dojox.gfx3d.matrix.multiplyPoint(m, item.args[i], item.args[i+1], item.args[i+2])
path += " " + pt.x + " " + pt.y;
}
});
 
this.cache = path;
},
 
_draw: function(){
return this.parent.createPath(this.cache);
}
});
 
dojo.declare("dojox.gfx3d.Triangles", dojox.gfx3d.Object, {
constructor: function(){
// summary: a generic triangle
// (this is a helper object, which is defined for convenience)
this.object = dojo.clone(dojox.gfx3d.defaultTriangles);
},
 
setObject: function(newObject, /* String, optional */ style){
// summary: setup the object
// newObject: Array of points || Object
// style: String, optional
if(newObject instanceof Array){
this.object = dojox.gfx.makeParameters(this.object, { points: newObject, style: style } );
} else {
this.object = dojox.gfx.makeParameters(this.object, newObject);
}
return this;
},
render: function(camera){
var m = dojox.gfx3d.matrix.multiply(camera, this.matrix);
var c = dojo.map(this.object.points, function(item){
return dojox.gfx3d.matrix.multiplyPoint(m, item);
});
this.cache = [];
var pool = c.slice(0, 2);
var center = c[0];
if(this.object.style == "strip"){
dojo.forEach(c.slice(2), function(item){
pool.push(item);
pool.push(pool[0]);
this.cache.push(pool);
pool = pool.slice(1, 3);
}, this);
} else if(this.object.style == "fan"){
dojo.forEach(c.slice(2), function(item){
pool.push(item);
pool.push(center);
this.cache.push(pool);
pool = [center, item];
}, this);
} else {
for(var i = 0; i < c.length; ){
this.cache.push( [ c[i], c[i+1], c[i+2], c[i] ]);
i += 3;
}
}
},
 
draw: function(lighting){
// use the BSP to schedule
this.cache = dojox.gfx3d.scheduler.bsp(this.cache, function(it){ return it; });
if(this.shape){
this.shape.clear();
} else {
this.shape = this.renderer.createGroup();
}
dojo.forEach(this.cache, function(item){
this.shape.createPolyline(item)
.setStroke(this.strokeStyle)
.setFill(this.toStdFill(lighting, dojox.gfx3d.vector.normalize(item)));
}, this);
},
 
getZOrder: function(){
var zOrder = 0;
dojo.forEach(this.cache, function(item){
zOrder += (item[0].z + item[1].z + item[2].z) / 3; });
return (this.cache.length > 1) ? zOrder / this.cache.length : 0;
}
});
 
dojo.declare("dojox.gfx3d.Quads", dojox.gfx3d.Object, {
constructor: function(){
// summary: a generic triangle
// (this is a helper object, which is defined for convenience)
this.object = dojo.clone(dojox.gfx3d.defaultQuads);
},
 
setObject: function(newObject, /* String, optional */ style){
// summary: setup the object
// newObject: Array of points || Object
// style: String, optional
this.object = dojox.gfx.makeParameters(this.object, (newObject instanceof Array) ? { points: newObject, style: style } : newObject );
return this;
},
render: function(camera){
var m = dojox.gfx3d.matrix.multiply(camera, this.matrix);
var c = dojo.map(this.object.points, function(item){
return dojox.gfx3d.matrix.multiplyPoint(m, item);
});
this.cache = [];
if(this.object.style == "strip"){
var pool = c.slice(0, 2);
for(var i = 2; i < c.length; ){
pool = pool.concat( [ c[i], c[i+1], pool[0] ] );
this.cache.push(pool);
pool = pool.slice(2,4);
i += 2;
}
}else{
for(var i = 0; i < c.length; ){
this.cache.push( [c[i], c[i+1], c[i+2], c[i+3], c[i] ] );
i += 4;
}
}
},
 
draw: function(lighting){
// use the BSP to schedule
this.cache = dojox.gfx3d.scheduler.bsp(this.cache, function(it){ return it; });
if(this.shape){
this.shape.clear();
}else{
this.shape = this.renderer.createGroup();
}
// using naive iteration to speed things up a bit by avoiding function call overhead
for(var x=0; x<this.cache.length; x++){
this.shape.createPolyline(this.cache[x])
.setStroke(this.strokeStyle)
.setFill(this.toStdFill(lighting, dojox.gfx3d.vector.normalize(this.cache[x])));
}
/*
dojo.forEach(this.cache, function(item){
this.shape.createPolyline(item)
.setStroke(this.strokeStyle)
.setFill(this.toStdFill(lighting, dojox.gfx3d.vector.normalize(item)));
}, this);
*/
},
 
getZOrder: function(){
var zOrder = 0;
// using naive iteration to speed things up a bit by avoiding function call overhead
for(var x=0; x<this.cache.length; x++){
var i = this.cache[x];
zOrder += (i[0].z + i[1].z + i[2].z + i[3].z) / 4;
}
/*
dojo.forEach(this.cache, function(item){
zOrder += (item[0].z + item[1].z + item[2].z + item[3].z) / 4; });
*/
return (this.cache.length > 1) ? zOrder / this.cache.length : 0;
}
});
 
dojo.declare("dojox.gfx3d.Polygon", dojox.gfx3d.Object, {
constructor: function(){
// summary: a generic triangle
// (this is a helper object, which is defined for convenience)
this.object = dojo.clone(dojox.gfx3d.defaultPolygon);
},
 
setObject: function(newObject){
// summary: setup the object
// newObject: Array of points || Object
this.object = dojox.gfx.makeParameters(this.object, (newObject instanceof Array) ? {path: newObject} : newObject)
return this;
},
 
render: function(camera){
var m = dojox.gfx3d.matrix.multiply(camera, this.matrix);
this.cache = dojo.map(this.object.path, function(item){
return dojox.gfx3d.matrix.multiplyPoint(m, item);
});
// add the first point to close the polyline
this.cache.push(this.cache[0]);
},
 
draw: function(lighting){
if(this.shape){
this.shape.setShape({points: this.cache});
}else{
this.shape = this.renderer.createPolyline({points: this.cache});
}
 
this.shape.setStroke(this.strokeStyle)
.setFill(this.toStdFill(lighting, dojox.gfx3d.matrix.normalize(this.cache)));
},
 
getZOrder: function(){
var zOrder = 0;
// using naive iteration to speed things up a bit by avoiding function call overhead
for(var x=0; x<this.cache.length; x++){
zOrder += this.cache[x].z;
}
return (this.cache.length > 1) ? zOrder / this.cache.length : 0;
},
 
getOutline: function(){
return this.cache.slice(0, 3);
}
});
 
dojo.declare("dojox.gfx3d.Cube", dojox.gfx3d.Object, {
constructor: function(){
// summary: a generic triangle
// (this is a helper object, which is defined for convenience)
this.object = dojo.clone(dojox.gfx3d.defaultCube);
this.polygons = [];
},
 
setObject: function(newObject){
// summary: setup the object
// newObject: Array of points || Object
this.object = dojox.gfx.makeParameters(this.object, newObject);
},
 
render: function(camera){
// parse the top, bottom to get 6 polygons:
var a = this.object.top;
var g = this.object.bottom;
var b = {x: g.x, y: a.y, z: a.z};
var c = {x: g.x, y: g.y, z: a.z};
var d = {x: a.x, y: g.y, z: a.z};
var e = {x: a.x, y: a.y, z: g.z};
var f = {x: g.x, y: a.y, z: g.z};
var h = {x: a.x, y: g.y, z: g.z};
var polygons = [a, b, c, d, e, f, g, h];
var m = dojox.gfx3d.matrix.multiply(camera, this.matrix);
var p = dojo.map(polygons, function(item){
return dojox.gfx3d.matrix.multiplyPoint(m, item);
});
a = p[0]; b = p[1]; c = p[2]; d = p[3]; e = p[4]; f = p[5]; g = p[6]; h = p[7];
this.cache = [[a, b, c, d, a], [e, f, g, h, e], [a, d, h, e, a], [d, c, g, h, d], [c, b, f, g, c], [b, a, e, f, b]];
},
 
draw: function(lighting){
// use bsp to sort.
this.cache = dojox.gfx3d.scheduler.bsp(this.cache, function(it){ return it; });
// only the last 3 polys are visible.
var cache = this.cache.slice(3);
 
if(this.shape){
this.shape.clear();
}else{
this.shape = this.renderer.createGroup();
}
for(var x=0; x<cache.length; x++){
this.shape.createPolyline(cache[x])
.setStroke(this.strokeStyle)
.setFill(this.toStdFill(lighting, dojox.gfx3d.vector.normalize(cache[x])));
}
/*
dojo.forEach(cache, function(item){
this.shape.createPolyline(item)
.setStroke(this.strokeStyle)
.setFill(this.toStdFill(lighting, dojox.gfx3d.vector.normalize(item)));
}, this);
*/
},
 
getZOrder: function(){
var top = this.cache[0][0];
var bottom = this.cache[1][2];
return (top.z + bottom.z) / 2;
}
});
 
 
dojo.declare("dojox.gfx3d.Cylinder", dojox.gfx3d.Object, {
constructor: function(){
this.object = dojo.clone(dojox.gfx3d.defaultCylinder);
},
 
render: function(camera){
// get the bottom surface first
var m = dojox.gfx3d.matrix.multiply(camera, this.matrix);
var angles = [0, Math.PI/4, Math.PI/3];
var center = dojox.gfx3d.matrix.multiplyPoint(m, this.object.center);
var marks = dojo.map(angles, function(item){
return {x: this.center.x + this.radius * Math.cos(item),
y: this.center.y + this.radius * Math.sin(item), z: this.center.z};
}, this.object);
 
marks = dojo.map(marks, function(item){
return dojox.gfx3d.vector.substract(dojox.gfx3d.matrix.multiplyPoint(m, item), center);
});
 
// Use the algorithm here:
// http://www.3dsoftware.com/Math/PlaneCurves/EllipseAlgebra/
// After we normalize the marks, the equation is:
// a x^2 + 2b xy + cy^2 + f = 0: let a = 1
// so the final equation is:
// [ xy, y^2, 1] * [2b, c, f]' = [ -x^2 ]'
 
var A = {
xx: marks[0].x * marks[0].y, xy: marks[0].y * marks[0].y, xz: 1,
yx: marks[1].x * marks[1].y, yy: marks[1].y * marks[1].y, yz: 1,
zx: marks[2].x * marks[2].y, zy: marks[2].y * marks[2].y, zz: 1,
dx: 0, dy: 0, dz: 0
};
var b = dojo.map(marks, function(item){
return -Math.pow(item.x, 2);
});
 
// X is 2b, c, f
var X = dojox.gfx3d.matrix.multiplyPoint(dojox.gfx3d.matrix.invert(A), b[0], b[1], b[2]);
var theta = Math.atan2(X.x, 1 - X.y) / 2;
 
// rotate the marks back to the canonical form
var probes = dojo.map(marks, function(item){
return dojox.gfx.matrix.multiplyPoint(dojox.gfx.matrix.rotate(-theta), item.x, item.y);
});
 
// we are solving the equation: Ax = b
// A = [x^2, y^2] X = [1/a^2, 1/b^2]', b = [1, 1]'
// so rx = Math.sqrt(1/ ( inv(A)[1:] * b ) );
// so ry = Math.sqrt(1/ ( inv(A)[2:] * b ) );
 
var a = Math.pow(probes[0].x, 2);
var b = Math.pow(probes[0].y, 2);
var c = Math.pow(probes[1].x, 2);
var d = Math.pow(probes[1].y, 2);
 
// the invert matrix is
// 1/(ad - bc) [ d, -b; -c, a];
var rx = Math.sqrt((a * d - b * c) / (d - b));
var ry = Math.sqrt((a * d - b * c) / (a - c));
if(rx < ry){
var t = rx;
rx = ry;
ry = t;
theta -= Math.PI/2;
}
 
var top = dojox.gfx3d.matrix.multiplyPoint(m,
dojox.gfx3d.vector.sum(this.object.center, {x: 0, y:0, z: this.object.height}));
 
var gradient = this.fillStyle.type == "constant" ? this.fillStyle.color
: dojox.gfx3d.gradient(this.renderer.lighting, this.fillStyle, this.object.center, this.object.radius, Math.PI, 2 * Math.PI, m);
if(isNaN(rx) || isNaN(ry) || isNaN(theta)){
// in case the cap is invisible (parallel to the incident vector)
rx = this.object.radius, ry = 0, theta = 0;
}
this.cache = {center: center, top: top, rx: rx, ry: ry, theta: theta, gradient: gradient};
},
 
draw: function(){
var c = this.cache, v = dojox.gfx3d.vector, m = dojox.gfx.matrix,
centers = [c.center, c.top], normal = v.substract(c.top, c.center);
if(v.dotProduct(normal, this.renderer.lighting.incident) > 0){
centers = [c.top, c.center];
normal = v.substract(c.center, c.top);
}
 
var color = this.renderer.lighting[this.fillStyle.type](normal, this.fillStyle.finish, this.fillStyle.color),
d = Math.sqrt( Math.pow(c.center.x - c.top.x, 2) + Math.pow(c.center.y - c.top.y, 2) );
 
if(this.shape){
this.shape.clear();
}else{
this.shape = this.renderer.createGroup();
}
this.shape.createPath("")
.moveTo(0, -c.rx)
.lineTo(d, -c.rx)
.lineTo(d, c.rx)
.lineTo(0, c.rx)
.arcTo(c.ry, c.rx, 0, true, true, 0, -c.rx)
.setFill(c.gradient).setStroke(this.strokeStyle)
.setTransform([m.translate(centers[0]),
m.rotate(Math.atan2(centers[1].y - centers[0].y, centers[1].x - centers[0].x))]);
 
if(c.rx > 0 && c.ry > 0){
this.shape.createEllipse({cx: centers[1].x, cy: centers[1].y, rx: c.rx, ry: c.ry})
.setFill(color).setStroke(this.strokeStyle)
.applyTransform(m.rotateAt(c.theta, centers[1]));
}
}
});
 
 
// the ultimate container of 3D world
dojo.declare("dojox.gfx3d.Viewport", dojox.gfx.Group, {
constructor: function(){
// summary: a viewport/container for 3D objects, which knows
// the camera and lightings
 
// matrix: dojox.gfx3d.matrix: world transform
// dimension: Object: the dimension of the canvas
this.dimension = null;
 
// objects: Array: all 3d Objects
this.objects = [];
// todos: Array: all 3d Objects that needs to redraw
this.todos = [];
 
// FIXME: memory leak?
this.renderer = this;
// Using zOrder as the default scheduler
this.schedule = dojox.gfx3d.scheduler.zOrder;
this.draw = dojox.gfx3d.drawer.conservative;
// deep: boolean, true means the whole viewport needs to re-render, redraw
this.deep = false;
 
// lights: Array: an array of light objects
this.lights = [];
this.lighting = null;
},
 
setCameraTransform: function(matrix){
// summary: sets a transformation matrix
// matrix: dojox.gfx3d.matrix.Matrix: a matrix or a matrix-like object
// (see an argument of dojox.gfx.matrix.Matrix
// constructor for a list of acceptable arguments)
this.camera = dojox.gfx3d.matrix.clone(matrix ? dojox.gfx3d.matrix.normalize(matrix) : dojox.gfx3d.identity, true);
this.invalidate();
return this; // self
},
 
applyCameraRightTransform: function(matrix){
// summary: multiplies the existing matrix with an argument on right side
// (this.matrix * matrix)
// matrix: dojox.gfx3d.matrix.Matrix: a matrix or a matrix-like object
// (see an argument of dojox.gfx3d.matrix.Matrix
// constructor for a list of acceptable arguments)
return matrix ? this.setCameraTransform([this.camera, matrix]) : this; // self
},
 
applyCameraLeftTransform: function(matrix){
// summary: multiplies the existing matrix with an argument on left side
// (matrix * this.matrix)
// matrix: dojox.gfx3d.matrix.Matrix: a matrix or a matrix-like object
// (see an argument of dojox.gfx3d.matrix.Matrix
// constructor for a list of acceptable arguments)
return matrix ? this.setCameraTransform([matrix, this.camera]) : this; // self
},
 
applyCameraTransform: function(matrix){
// summary: a shortcut for dojox.gfx3d.Object.applyRightTransform
// matrix: dojox.gfx3d.matrix.Matrix: a matrix or a matrix-like object
// (see an argument of dojox.gfx3d.matrix.Matrix
// constructor for a list of acceptable arguments)
return this.applyCameraRightTransform(matrix); // self
},
 
setLights: function(/* Array || Object */lights, /* Color, optional */ ambient,
/* Color, optional */ specular){
// summary: set the lights
// lights: Array: an array of light object
// or lights object
// ambient: Color: an ambient object
// specular: Color: an specular object
this.lights = (lights instanceof Array) ? {sources: lights, ambient: ambient, specular: specular} : lights;
var view = {x: 0, y: 0, z: 1};
 
this.lighting = new dojox.gfx3d.lighting.Model(view, this.lights.sources,
this.lights.ambient, this.lights.specular);
this.invalidate();
return this;
},
 
addLights: function(lights){
// summary: add new light/lights to the viewport.
// lights: Array || light object: light object(s)
return this.setLights(this.lights.sources.concat(lights));
},
 
addTodo: function(newObject){
// NOTE: Viewport implements almost the same addTodo,
// except calling invalidate, since invalidate is used as
// any modification needs to redraw the object itself, call invalidate.
// then call render.
if(dojo.every(this.todos, function(item){
return item != newObject; })){
this.todos.push(newObject);
}
},
 
invalidate: function(){
this.deep = true;
this.todos = this.objects;
},
 
setDimensions: function(dim){
if(dim){
this.dimension = {
width: typeof dim.width == "string" ? parseInt(dim.width) : dim.width,
height: typeof dim.height == "string" ? parseInt(dim.height) : dim.height
};
}else{
this.dimension = null;
}
},
 
render: function(){
// summary: iterate all children and call their render callback function.
if(this.todos.length == 0){ return; }
var m = dojox.gfx3d.matrix;
// Iterate the todos and call render to prepare the rendering:
for(var x=0; x<this.todos.length; x++){
this.todos[x].render(dojox.gfx3d.matrix.normalize([
m.cameraRotateXg(180),
m.cameraTranslate(0, this.dimension.height, 0),
this.camera,
]), this.deep);
}
 
this.objects = this.schedule(this.objects);
this.draw(this.todos, this.objects, this);
this.todos = [];
this.deep = false;
}
 
});
 
//FIXME: Viewport cannot masquerade as a Group
dojox.gfx3d.Viewport.nodeType = dojox.gfx.Group.nodeType;
 
dojox.gfx3d._creators = {
// summary: object creators
createEdges: function(edges, style){
// summary: creates an edge object
// line: Object: a edge object (see dojox.gfx3d.defaultPath)
return this.create3DObject(dojox.gfx3d.Edges, edges, style); // dojox.gfx3d.Edge
},
createTriangles: function(tris, style){
// summary: creates an edge object
// line: Object: a edge object (see dojox.gfx3d.defaultPath)
return this.create3DObject(dojox.gfx3d.Triangles, tris, style); // dojox.gfx3d.Edge
},
createQuads: function(quads, style){
// summary: creates an edge object
// line: Object: a edge object (see dojox.gfx3d.defaultPath)
return this.create3DObject(dojox.gfx3d.Quads, quads, style); // dojox.gfx3d.Edge
},
createPolygon: function(points){
// summary: creates an triangle object
// points: Array of points || Object
return this.create3DObject(dojox.gfx3d.Polygon, points); // dojox.gfx3d.Polygon
},
 
createOrbit: function(orbit){
// summary: creates an triangle object
// points: Array of points || Object
return this.create3DObject(dojox.gfx3d.Orbit, orbit); // dojox.gfx3d.Cube
},
 
createCube: function(cube){
// summary: creates an triangle object
// points: Array of points || Object
return this.create3DObject(dojox.gfx3d.Cube, cube); // dojox.gfx3d.Cube
},
 
createCylinder: function(cylinder){
// summary: creates an triangle object
// points: Array of points || Object
return this.create3DObject(dojox.gfx3d.Cylinder, cylinder); // dojox.gfx3d.Cube
},
 
createPath3d: function(path){
// summary: creates an edge object
// line: Object: a edge object (see dojox.gfx3d.defaultPath)
return this.create3DObject(dojox.gfx3d.Path3d, path); // dojox.gfx3d.Edge
},
createScene: function(){
// summary: creates an triangle object
// line: Object: a triangle object (see dojox.gfx3d.defaultPath)
return this.create3DObject(dojox.gfx3d.Scene); // dojox.gfx3d.Scene
},
 
create3DObject: function(objectType, rawObject, style){
// 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
var obj = new objectType();
this.adopt(obj);
if(rawObject){ obj.setObject(rawObject, style); }
return obj; // dojox.gfx3d.Object
},
// todo : override the add/remove if necessary
adopt: function(obj){
// summary: adds a shape to the list
// shape: dojox.gfx.Shape: a shape
obj.renderer = this.renderer; // obj._setParent(this, null); more TODOs HERER?
obj.parent = this;
this.objects.push(obj);
this.addTodo(obj);
return this;
},
abandon: function(obj, silently){
// summary: removes a shape from the list
// silently: Boolean?: if true, do not redraw a picture yet
for(var i = 0; i < this.objects.length; ++i){
if(this.objects[i] == obj){
this.objects.splice(i, 1);
}
}
// if(this.rawNode == shape.rawNode.parentNode){
// this.rawNode.removeChild(shape.rawNode);
// }
// obj._setParent(null, null);
obj.parent = null;
return this; // self
},
 
 
setScheduler: function(scheduler){
this.schedule = scheduler;
},
 
setDrawer: function(drawer){
this.draw = drawer;
}
};
 
dojo.extend(dojox.gfx3d.Viewport, dojox.gfx3d._creators);
dojo.extend(dojox.gfx3d.Scene, dojox.gfx3d._creators);
delete dojox.gfx3d._creators;
 
 
//FIXME: extending dojox.gfx.Surface and masquerading Viewport as Group is hacky!
 
// Add createViewport to dojox.gfx.Surface
dojo.extend(dojox.gfx.Surface, {
createViewport: function(){
//FIXME: createObject is non-public method!
var viewport = this.createObject(dojox.gfx3d.Viewport, null, true);
//FIXME: this may not work with dojox.gfx.Group !!
viewport.setDimensions(this.getDimensions());
return viewport;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_cube.html
New file
0,0 → 1,50
<html>
<head>
<title>Cube of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
dojo.require("dojox.gfx3d");
dojo.require("dojox.gfx.utils");
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
var view = surface.createViewport();
view.setLights([{direction: {x: -10, y: -5, z: 5}, color: "white"}],
{color:"white", intensity: 2}, "white");
var m = dojox.gfx3d.matrix;
var l = view.createCube({bottom: {x: 0, y: 0, z: 0}, top: {x: 100, y: 100, z: 100}})
.setFill({type: "plastic", finish: "dull", color: "lime"});
var camera = [m.cameraRotateXg(20), m.cameraRotateYg(20), m.cameraTranslate(-200, -200, 0)];
view.applyCameraTransform(camera);
view.render();
//dojo.byId("out1").value = dojo.byId("test").innerHTML;
//dojo.byId("out2").value = dojox.gfx.utils.toJson(surface, true);
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Cube Test</h1>
<div id="test" style="width: 500px; height: 500px;"></div>
<!--
<p><button onclick="makeObjects();">Go</button></p>
<p><textarea id="out1" cols="40" rows="5"></textarea></p>
<p><textarea id="out2" cols="40" rows="5"></textarea></p>
-->
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_rotate.html
New file
0,0 → 1,123
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Rotate test of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../../../dijit/themes/tundra/tundra.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
 
var angles = {x: 0, y: 0, z: 0};
var cube = null;
var view = null;
 
rotate = function(){
var m = dojox.gfx3d.matrix;
 
if(dojo.byId('rx').checked){
angles.x += 10;
}
if(dojo.byId('ry').checked){
angles.y += 10;
}
if(dojo.byId('rz').checked){
angles.z += 10;
}
var t = m.normalize([
m.cameraRotateXg(angles.x),
m.cameraRotateYg(angles.y),
m.cameraRotateZg(angles.z),
]);
cube.setTransform(t);
cube.invalidate();
view.render();
}
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
view = surface.createViewport();
var c = {bottom: {x: 0, y: 0, z: 0}, top: {x: 100, y: 100, z: 100}};
var xaxis = [
{x: 0, y: 0, z: 0},
{x: 200, y: 0, z: 0}
];
 
var yaxis = [
{x: 0, y: 0, z: 0},
{x: 0, y: 200, z: 0}
];
var zaxis = [
{x: 0, y: 0, z: 0},
{x: 0, y: 0, z: 200}
];
 
var m = dojox.gfx3d.matrix;
 
view.createEdges(xaxis).setStroke({color: "red", width: 1});
view.createEdges(yaxis).setStroke({color: "green", width: 1});
view.createEdges(zaxis).setStroke({color: "blue", width: 1});
 
cube = view.createCube(c).setStroke({color: "lime", width: 1});
 
var camera = dojox.gfx3d.matrix.normalize([
m.cameraRotateXg(20),
m.cameraRotateYg(30),
m.cameraTranslate(-100, -100, 0)
]);
 
view.applyCameraTransform(camera);
view.render();
window.setInterval(rotate, 200);
 
// add the click event handler
dojo.connect(dojo.byId("conservative"), "onclick", drawWithConservative);
dojo.connect(dojo.byId("chart"), "onclick", drawWithChart);
};
 
draw = function(title, drawer){
dojo.byId("drawer").innerHTML = title;
view.setDrawer(drawer);
};
 
drawWithConservative = function(){
draw("Conservative", dojox.gfx3d.drawer.conservative);
};
 
drawWithChart = function(){
draw("Chart", dojox.gfx3d.drawer.chart);
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body class="tundra">
<h1>Pilot Test</h1>
<p>There are two drawers(well, the name is quite misleading, it means draw-er) in dojox.gfx3d, conservative and chart:</p>
<ul>
<li><em>conservative</em> drawer is a pessimist, it assumes that the movement, transformation of objects would take a big fat impact to the viewport, so it not only render the modified objects, but also reorder all the underlying 2D shapes and redraw them.</li>
<li> <em>chart</em> drawer is an optimist, it assumes the change of the objects does not take effect on the z-order, this is most likely true in chart application. It only render and then draw the modified objects.</li>
</ul>
<p>The cube is in the center (0, 0, 0): The color of X, Y, Z axes are red, green, blue as the reference. The cube would rotate around X, Y, Z or their combination, it is up to you.</p>
<p>Current Drawer: <strong id="drawer">Conservative</strong></p>
<form>
<input id="conservative" type="button" value="Draw with conservative"/>
<input id="chart" type="button" value="Draw with chart"/><br />
<input id="rx" type="checkbox" name="rotateX" checked="true" value="on"/>
<label for="rx"> Rotate around X-axis</label> <br/>
<input id="ry" type="checkbox" name="rotateY" checked="false" value="off"/>
<label for="ry"> Rotate around Y-axis</label> <br/>
<input id="rz" type="checkbox" name="rotateZ" checked="false" value="off"/>
<label for="rz"> Rotate around Z-axis</label> <br/>
</form>
 
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_camerarotate_shaded.html
New file
0,0 → 1,97
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Camera rotate of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../../../dijit/themes/tundra/tundra.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: false"></script>
<script type="text/javascript" src="../object.js"></script>
<script type="text/javascript" src="../scheduler.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
 
var angles = {x: 30, y: 30, z: 0};
var cube = null;
var view = null;
 
rotate = function() {
var m = dojox.gfx3d.matrix;
 
if(dojo.byId('rx').checked){
angles.x += 1;
}
if(dojo.byId('ry').checked){
angles.y += 1;
}
if(dojo.byId('rz').checked){
angles.z += 1;
}
var t = m.normalize([
m.cameraTranslate(-300, -200, 0),
m.cameraRotateXg(angles.x),
m.cameraRotateYg(angles.y),
m.cameraRotateZg(angles.z)
]);
console.debug(t);
view.setCameraTransform(t);
view.render();
}
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
view = surface.createViewport();
 
view.setLights([{direction: {x: -10, y: -5, z: 5}, color: "white"}],
{color:"white", intensity: 2}, "white");
 
var c = {bottom: {x: 0, y: 0, z: 0}, top :{x: 100, y: 100, z: 100}};
var xaxis = [{x: 0, y: 0, z: 0}, {x: 200, y: 0, z: 0}];
var yaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 200, z: 0}];
var zaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 0, z: 200}];
 
var m = dojox.gfx3d.matrix;
 
view.createEdges(xaxis).setStroke({color: "red", width: 1});
view.createEdges(yaxis).setStroke({color: "green", width: 1});
view.createEdges(zaxis).setStroke({color: "blue", width: 1});
// setStroke({color: "lime", width: 1}).
cube = view.createCube(c).setFill({ type: "plastic", finish: "dull", color: "lime" });
 
var camera = dojox.gfx3d.matrix.normalize([
m.cameraTranslate(-300, -200, 0),
m.cameraRotateXg(angles.x),
m.cameraRotateYg(angles.y),
m.cameraRotateZg(angles.z),
]);
 
view.applyCameraTransform(camera);
view.render();
window.setInterval(rotate, 50);
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body class="tundra">
<h1>Camera rotate</h1>
<p>The cube is in the center (0, 0, 0): The color of X, Y, Z axes are red, green, blue. The view renders all the objects
in each frame, the <em>conservative</em> drawer is used.</p>
<form>
<input id="rx" type="checkbox" name="rotateX" checked="true" value="on"/>
<label for="rx"> Rotate around X-axis</label> <br/>
<input id="ry" type="checkbox" name="rotateY" checked="false" value="off"/>
<label for="ry"> Rotate around Y-axis</label> <br/>
<input id="rz" type="checkbox" name="rotateZ" checked="false" value="off"/>
<label for="rz"> Rotate around Z-axis</label> <br/>
</form>
 
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_orbit.html
New file
0,0 → 1,50
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Orbit test of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
var view = surface.createViewport();
var m = dojox.gfx3d.matrix;
 
view.createOrbit({center: {x: 0, y: 0, z: 0}, radius: 80})
.setStroke({color: "blue", width: 1});
 
var camera = dojox.gfx3d.matrix.normalize([
m.cameraRotateXg(60),
m.cameraRotateYg(30),
m.cameraRotateZg(0),
m.cameraTranslate(-300, -100, 0)
]);
 
view.applyCameraTransform(camera);
view.render();
};
 
mdebug = function(matrix){
var m = dojox.gfx3d.matrix.normalize(matrix);
console.debug("xx: " + m.xx + ", xy: " + m.xy + " | xz:" + m.xz + " | dx:" + m.dx);
console.debug("yx: " + m.yx + ", yy: " + m.yy + " | yz:" + m.yz + " | dy:" + m.dy);
console.debug("zx: " + m.zx + ", zy: " + m.zy + " | zz:" + m.zz + " | dz:" + m.dz);
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Orbit Test</h1>
<p>Test how orbit looks like in 3D</p>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_vector.html
New file
0,0 → 1,59
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Dojo 3D Vector</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d.vector");
 
pdebug = function(point){
console.debug("x: " + point.x + ", y: " + point.y + ", z: " + point.z);
};
 
dojo.addOnLoad(function(){
var m = dojox.gfx3d.vector;
console.debug("test crossProduct...");
c = m.crossProduct(1, 2, 3, 4, 5, 6);
pdebug(c);
a = {x: 1, y: 2, z: 3};
b = {x: 4, y: 5, z: 6};
c = m.crossProduct(a, b);
pdebug(c);
 
console.debug("test dotProduct...");
c = m.dotProduct(1, 2, 3, 4, 5, 6);
console.debug(c);
a = {x: 1, y: 2, z: 3};
b = {x: 4, y: 5, z: 6};
c = m.dotProduct(a, b);
console.debug(c);
 
console.debug("test sum/substract...");
a = {x: 10, y: 5, z: 8};
b = {x: 1, y: 15, z: 2};
console.debug(m.sum(a, b));
console.debug(m.substract(a, b));
 
console.debug("test normalize...");
c = {x: 0, y: 17, z: -2};
d = m.normalize(a, b, c);
e = m.normalize([a, b, c]);
console.debug(d);
console.debug( "expecting 0:", m.dotProduct(d, m.substract(b, a)));
console.debug(e);
console.debug( "expecting 0:", m.dotProduct(e, m.substract(b, a)));
 
});
 
</script>
</head>
<body>
<h1>dojox.gfx3d.vector test</h1>
<p>Please check the debug console for test results.</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_drawer.html
New file
0,0 → 1,92
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Pilot test of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../../../dijit/themes/tundra/tundra.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
 
var angles = {x: 0, y: 0, z: 0};
var view = null;
var cube = null;
 
function moveMe(){
var p = dojo.byId("action");
var m = dojox.gfx3d.matrix;
if(p.value == "Move to Back!"){
console.debug(p.value);
p.value = "Move to Front!";
cube.setTransform(m.translate(20, 0, -120))
}else{
p.value = "Move to Back!";
cube.setTransform(m.translate(50, 0, 150))
}
cube.invalidate();
view.render();
};
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
view = surface.createViewport();
var c = { bottom: {x: 0, y: 0, z: 0}, top :{x: 100, y: 100, z: 100} };
var xaxis = [{x: 0, y: 0, z: 0}, {x: 200, y: 0, z: 0}];
var yaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 200, z: 0}];
var zaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 0, z: 200}];
 
var m = dojox.gfx3d.matrix;
 
view.createEdges(xaxis).setStroke({color: "red", width: 1});
view.createEdges(yaxis).setStroke({color: "green", width: 1});
view.createEdges(zaxis).setStroke({color: "blue", width: 1});
 
view.createCube(c)
.setFill({type: "plastic", finish: dojox.gfx3d.lighting.finish.dull, color: "blue"})
.setStroke({color: "black", width: 1});
 
cube = view.createCube(c)
.setTransform(m.translate(50, 50, 150))
.setFill({type: "plastic", finish: dojox.gfx3d.lighting.finish.dull, color: "lime"})
.setStroke({color: "black", width: 1});
 
var camera = dojox.gfx3d.matrix.normalize([
m.cameraRotateXg(60),
m.cameraRotateYg(30),
m.cameraTranslate(-200, -300, 0)
]);
 
view.applyCameraTransform(camera);
view.setLights([{direction: {x: 10, y: 7, z: 5}, color: "white"}],
{color:"white", intensity: 2}, "white");
view.render();
 
// add the click event handler
dojo.connect(dojo.byId("action"), "onclick", moveMe);
};
 
mdebug = function(matrix){
var m = dojox.gfx3d.matrix.normalize(matrix);
console.debug("xx: " + m.xx + ", xy: " + m.xy + " | xz:" + m.xz + " | dx:" + m.dx);
console.debug("yx: " + m.yx + ", yy: " + m.yy + " | yz:" + m.yz + " | dy:" + m.dy);
console.debug("zx: " + m.zx + ", zy: " + m.zy + " | zz:" + m.zz + " | dz:" + m.dz);
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body class="tundra">
<h1>Pilot Test</h1>
<p> The color of X, Y, Z axes are red, green, blue. One cube is in the center (0, 0, 0), click the button to move the other one back
and forth, using this to test <em>dojox.gfx3d.drawer.conservative</em></p>
<input id="action" type="button" value="Move to Back!"/>
 
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_matrix.html
New file
0,0 → 1,89
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Dojo 3D Matrix</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
 
mdebug = function(matrix){
var m = dojox.gfx3d.matrix.normalize(matrix);
console.debug("xx: " + m.xx + ", xy: " + m.xy + " | xz:" + m.xz + " | dx:" + m.dx);
console.debug("yx: " + m.yx + ", yy: " + m.yy + " | yz:" + m.yz + " | dy:" + m.dy);
console.debug("zx: " + m.zx + ", zy: " + m.zy + " | zz:" + m.zz + " | dz:" + m.dz);
};
 
pdebug = function(point){
console.debug("x: " + point.x + ", y: " + point.y + ", z: " + point.z);
};
 
dojo.addOnLoad(function(){
var m = dojox.gfx3d.matrix;
var a = new m.Matrix3D();
console.debug("identity");
mdebug(a);
a = m.rotateXg(30);
console.debug("rotateXg(30);");
mdebug(a);
a = m.rotateYg(45);
console.debug("rotateYg(45);");
mdebug(a);
a = m.rotateZg(90);
console.debug("rotateZg(90);");
mdebug(a);
a = [new m.Matrix3D(), new m.Matrix3D(), new m.Matrix3D()];
console.debug("identity");
mdebug(a);
a = [m.rotateXg(30), m.rotateXg(-30)];
console.debug("identity");
mdebug(a);
var b = m.multiplyPoint(a, 10, 10, 10);
pdebug(b);
b = m.multiplyPoint(a, 10, 5, 10);
pdebug(b);
b = m.multiplyPoint(a, 10, 15, 5);
pdebug(b);
 
a = [m.scale(1,1,2), m.rotateXg(45)];
console.debug("a = [m.scale(1,1,2), m.rotateXg(45)];");
mdebug(a);
a = [m.rotateXg(45), m.scale(1,1,2)];
console.debug("a = [m.rotateXg(45), m.scale(1,1,2)];");
mdebug(a);
 
a = [m.scale(2,1,2), m.rotateYg(45)];
console.debug("a = [m.scale(2,1,2), m.rotateYg(45)];");
mdebug(a);
a = [m.rotateYg(45), m.scale(2,1,2)];
console.debug("a = [m.rotateYg(45), m.scale(2,1,2)];");
mdebug(a);
 
a = [m.scale(1,2,1), m.invert(m.rotateZg(45))];
console.debug("[m.scale(1,2,1), m.invert(m.rotateZg(45))];");
mdebug(a);
a = [m.invert(m.rotateZg(45)), m.scale(1,2,1)];
console.debug("a = [m.invert(m.rotateZg(45)), m.scale(1,2,1)];");
mdebug(a);
 
a = [a, m.invert(a)];
console.debug("identity");
mdebug(a);
 
a = 5;
mdebug(a);
a = [2, m.scale(2,1,3)];
mdebug(a);
});
 
</script>
</head>
<body>
<h1>dojox.gfx3d.matrix test</h1>
<p>Please check the debug console for test results.</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_camerarotate.html
New file
0,0 → 1,93
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Camera rotate of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../../../dijit/themes/tundra/tundra.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: false"></script>
<script type="text/javascript" src="../object.js"></script>
<script type="text/javascript" src="../scheduler.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
 
var angles = {x: 30, y: 30, z: 0};
var cube = null;
var view = null;
 
rotate = function() {
var m = dojox.gfx3d.matrix;
 
if(dojo.byId('rx').checked){
angles.x += 1;
}
if(dojo.byId('ry').checked){
angles.y += 1;
}
if(dojo.byId('rz').checked){
angles.z += 1;
}
var t = m.normalize([
m.cameraTranslate(-300, -200, 0),
m.cameraRotateXg(angles.x),
m.cameraRotateYg(angles.y),
m.cameraRotateZg(angles.z)
]);
console.debug(t);
view.setCameraTransform(t);
view.render();
}
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
view = surface.createViewport();
 
var c = {bottom: {x: 0, y: 0, z: 0}, top :{x: 100, y: 100, z: 100}};
var xaxis = [{x: 0, y: 0, z: 0}, {x: 200, y: 0, z: 0}];
var yaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 200, z: 0}];
var zaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 0, z: 200}];
 
var m = dojox.gfx3d.matrix;
 
view.createEdges(xaxis).setStroke({color: "red", width: 1});
view.createEdges(yaxis).setStroke({color: "green", width: 1});
view.createEdges(zaxis).setStroke({color: "blue", width: 1});
cube = view.createCube(c).setStroke({color: "lime", width: 1});
 
var camera = dojox.gfx3d.matrix.normalize([
m.cameraTranslate(-300, -200, 0),
m.cameraRotateXg(angles.x),
m.cameraRotateYg(angles.y),
m.cameraRotateZg(angles.z),
]);
 
view.applyCameraTransform(camera);
view.render();
window.setInterval(rotate, 50);
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body class="tundra">
<h1>Camera rotate</h1>
<p>The cube is in the center (0, 0, 0): The color of X, Y, Z axes are red, green, blue. The view renders all the objects
in each frame, the <em>conservative</em> drawer is used.</p>
<form>
<input id="rx" type="checkbox" name="rotateX" checked="true" value="on"/>
<label for="rx"> Rotate around X-axis</label> <br/>
<input id="ry" type="checkbox" name="rotateY" checked="false" value="off"/>
<label for="ry"> Rotate around Y-axis</label> <br/>
<input id="rz" type="checkbox" name="rotateZ" checked="false" value="off"/>
<label for="rz"> Rotate around Z-axis</label> <br/>
</form>
 
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_edges.html
New file
0,0 → 1,73
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Edges test of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
var view = surface.createViewport();
var lines = [
{x: 100, y: 10, z: 5},
{x: 80, y: 80, z: 55},
{x: 120, y: 80, z: 75},
{x: 250, y: 92, z: 15},
{x: 200, y: 25, z: 5},
{x: 156, y: 40, z: 45}
];
 
var m = dojox.gfx3d.matrix;
var loop = view.createEdges(lines, "loop")
.setStroke({color: "blue", width: 1})
.applyTransform(dojox.gfx3d.matrix.translate({x: 0, y: 0, z: 0}));
 
var strip = view.createEdges(lines, "strip")
.setStroke({color: "red", width: 1})
.applyTransform(dojox.gfx3d.matrix.translate({x: 0, y: 100, z: 0}));
 
var normal = view.createEdges(lines)
.setStroke({color: "lime", width: 1})
.applyTransform(dojox.gfx3d.matrix.translate({x: 0, y: 200, z: 0}));
 
var camera = dojox.gfx3d.matrix.normalize([
m.cameraRotateZg(20),
//m.cameraRotateYg(30),
//m.cameraRotateXg(50),
m.cameraTranslate(0, 0, 0)
]);
 
view.applyCameraTransform(camera);
view.render();
};
 
mdebug = function(matrix){
var m = dojox.gfx3d.matrix.normalize(matrix);
console.debug("xx: " + m.xx + ", xy: " + m.xy + " | xz:" + m.xz + " | dx:" + m.dx);
console.debug("yx: " + m.yx + ", yy: " + m.yy + " | yz:" + m.yz + " | dy:" + m.dy);
console.debug("zx: " + m.zx + ", zy: " + m.zy + " | zz:" + m.zz + " | dz:" + m.dz);
};
 
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Edges Test</h1>
<p> Test of the Edges, there are three modes</p>
<ul>
<li>none, any two vertice pair form one edge, lime</li>
<li>strip, vertices are connected by edges. red</li>
<li>loop, the same as strip, close the path, blue</li>
</ul>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_polygon.html
New file
0,0 → 1,44
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Polygon test of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
var view = surface.createViewport();
var poly = [{x: 0, y: 0, z: 0}, {x: 0, y: 100, z: 0}, {x: 100, y: 100, z: 0}, {x: 100, y: 0, z: 0}];
var m = dojox.gfx3d.matrix;
t = view.createPolygon(poly)
.setStroke({color: "blue", width: 1})
.setFill("#cc0");
var camera = dojox.gfx3d.matrix.normalize([
m.cameraRotateXg(30),
m.cameraRotateYg(30),
//m.cameraRotateZg(15),
m.cameraTranslate(-0, 0, 0)
]);
 
view.applyCameraTransform(camera);
view.render();
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Polygon Test</h1>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_overlap.html
New file
0,0 → 1,69
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Test of dojox.gfx3d.scheduler</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
var view = null;
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
view = surface.createViewport();
var tas = [
[{x: 100, y: 0, z: 0}, {x: 100, y: 100, z: 0}, {x: 50, y: 50, z: 50}],
[{x: 100, y: 0, z: 0}, {x: 100, y: 100, z: 0}, {x: 0, y: 70, z: 50}]
];
var fills = ["#0cc", "#c0c"];
 
var m = dojox.gfx3d.matrix;
for(var i = 0; i < tas.length; i++){
console.debug(fills[i]);
view.createPolygon(tas[i])
.setStroke({color: "blue", width: 1})
.setFill(fills[i]);
}
var camera = dojox.gfx3d.matrix.normalize([m.cameraTranslate(0, -300, 0)]);
 
view.applyCameraTransform(camera);
view.render();
// set up the click handlers.
dojo.connect(dojo.byId("bsp"), "onclick", renderWithBSP);
dojo.connect(dojo.byId("zorder"), "onclick", renderWithZOrder);
};
 
render = function(title, render){
dojo.byId("render").innerHTML = title;
view.setScheduler(render);
view.invalidate();
view.render();
};
 
renderWithBSP = function(){
render("BSP", dojox.gfx3d.scheduler.bsp);
};
 
renderWithZOrder = function(){
render("ZOrder", dojox.gfx3d.scheduler.zOrder);
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Scheduler Test</h1>
<p>There are two schedulers available in dojox.gfx3d, zOrder and BSP. zOrder is much simpler, and it performs quite well in most cases, it may fail in some rare cases, for example: two triangles share the same two vertice, and have the same Z value of the third vertex, in this case, they have the same z-order. They are rendered in arbitary order. In this case, BSP is the rescure.</p>
<p>Current render: <strong id="render">default</strong></p>
<p><button id="bsp">BSP</button>&nbsp;<button id="zorder">zOrder</button></p>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_triangles.html
New file
0,0 → 1,82
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Triangles test of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
var view = surface.createViewport();
var points = [
{x: 0, y: 0, z: 150},
{x: 50, y: 0, z: 0},
{x: 0, y: 50, z: 0},
{x: 0, y: 0, z: 150},
{x: 50, y: 0, z: 0},
{x: 0, y: -50, z: 0}
];
var fan = [
{x: 0, y: 0, z: 150},
{x: 50, y: 0, z: 0},
{x: 0, y: 50, z: 0},
{x: -50, y: 0, z: 0},
{x: 0, y: -50, z: 0}
];
var strip = [
{x: 0, y: -50, z: 0},
{x: 0, y: 0, z: 150},
{x: 50, y: 0, z: 0},
{x: 0, y: 50, z: 0}
];
 
var m = dojox.gfx3d.matrix;
var normal = view.createTriangles(points)
.setStroke({color: "blue", width: 1})
.setFill("#ccc")
.applyTransform(dojox.gfx3d.matrix.translate({x: 0, y: 0, z: 10}));
 
view.createTriangles(strip, "strip")
.setStroke({color: "red", width: 1})
.setFill("#ccc")
.applyTransform(dojox.gfx3d.matrix.translate({x: 150, y: 0, z: 10}));
 
view.createTriangles(fan, "fan")
.setStroke({color: "lime", width: 1})
.setFill("#ccc")
.applyTransform(dojox.gfx3d.matrix.translate({x: 300, y: 0, z: 10}));
 
var camera = dojox.gfx3d.matrix.normalize([
m.cameraRotateXg(-30),
m.cameraRotateYg(-10),
m.cameraTranslate(-50, -100, 0)
]);
 
view.applyCameraTransform(camera);
view.render();
};
 
mdebug = function(matrix){
var m = dojox.gfx3d.matrix.normalize(matrix);
console.debug("xx: " + m.xx + ", xy: " + m.xy + " | xz:" + m.xz + " | dx:" + m.dx);
console.debug("yx: " + m.yx + ", yy: " + m.yy + " | yz:" + m.yz + " | dy:" + m.dy);
console.debug("zx: " + m.zx + ", zy: " + m.zy + " | zz:" + m.zz + " | dz:" + m.dz);
};
 
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Path3d Test</h1>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_cylinder.html
New file
0,0 → 1,66
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Cylinder test of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../lighting.js"></script>
<script type="text/javascript" src="../gradient.js"></script>
<script type="text/javascript" src="../object.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 400);
var view = surface.createViewport();
view.setLights([
{direction: {x: 0, y: 0, z: -10}, color: "white"},
{direction: {x: 10, y: 0, z: -10}, color: "#444"}
], {color: "white", intensity: 2}, "white");
 
var m = dojox.gfx3d.matrix;
view.createCylinder({})
.setTransform([m.translate(150, 250, 0), m.rotateZg(60), m.rotateXg(-60)])
.setStroke("black")
.setFill({type: "plastic", finish: "glossy", color: "red"});
view.createCylinder({})
.setTransform([m.translate(150, 100, 0), m.rotateZg(45), m.rotateXg(-135)])
.setStroke("black")
.setFill({type: "plastic", finish: "shiny", color: "yellow"});
 
view.createCylinder({})
.setTransform([m.translate(250, 200, 0), m.rotateZg(-30), m.rotateXg(-30)])
.setStroke("black")
.setFill({type: "plastic", finish: "dull", color: "lime"});
 
//var camera = m.normalize([m.cameraRotateXg(15), m.cameraRotateYg(15), m.cameraTranslate(-200, -300, 0)]);
//var camera = m.normalize([m.cameraRotateXg(15), m.cameraRotateYg(15)]);
var camera = m.normalize({});
 
view.applyCameraTransform(camera);
view.render();
};
 
mdebug = function(matrix){
var m = dojox.gfx3d.matrix.normalize(matrix);
console.debug("xx: " + m.xx + ", xy: " + m.xy + " | xz:" + m.xz + " | dx:" + m.dx);
console.debug("yx: " + m.yx + ", yy: " + m.yy + " | yz:" + m.yz + " | dy:" + m.dy);
console.debug("zx: " + m.zx + ", zy: " + m.zy + " | zz:" + m.zz + " | dz:" + m.dz);
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Cylinder Test</h1>
<div id="test" style="width: 500px; height: 400px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_quads.html
New file
0,0 → 1,78
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Quads test of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
var view = surface.createViewport();
var strip = [
{x: 50, y: 0, z: 0},
{x: 70, y: 0, z: 60},
{x: 0, y: 70, z: 60},
{x: 0, y: 50, z: 0},
{x: -50, y: 0, z: 0},
{x: -70, y: 0, z: 60},
{x: 0, y: -70, z: 60},
{x: 0, y: -50, z: 0}
];
 
var normal = [
{x: 50, y: 0, z: 0},
{x: 70, y: 0, z: 60},
{x: 0, y: 70, z: 60},
{x: 0, y: 50, z: 0},
{x: 0, y: 70, z: 60},
{x: 0, y: 50, z: 0},
{x: -50, y: 0, z: 0},
{x: -70, y: 0, z: 60}
];
 
var m = dojox.gfx3d.matrix;
view.createQuads(normal)
.setStroke({color: "blue", width: 1})
.setFill("#f00")
.applyTransform(dojox.gfx3d.matrix.translate({x: 0, y: 500, z: 10}));
 
view.createQuads(strip, "strip")
.setStroke({color: "red", width: 1})
.setFill("#0f0")
.applyTransform(dojox.gfx3d.matrix.translate({x: 0, y: 200, z: 10}));
 
var camera = dojox.gfx3d.matrix.normalize([
m.cameraRotateXg(30),
m.cameraRotateYg(30),
m.cameraRotateXg(50),
m.cameraTranslate(-100, -100, 0)
]);
 
view.applyCameraTransform(camera);
view.render();
};
 
mdebug = function(matrix){
var m = dojox.gfx3d.matrix.normalize(matrix);
console.debug("xx: " + m.xx + ", xy: " + m.xy + " | xz:" + m.xz + " | dx:" + m.dx);
console.debug("yx: " + m.yx + ", yy: " + m.yy + " | yz:" + m.yz + " | dy:" + m.dy);
console.debug("zx: " + m.zx + ", zy: " + m.zy + " | zz:" + m.zz + " | dz:" + m.dz);
};
 
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Quads Test</h1>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/tests/test_scene.html
New file
0,0 → 1,66
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Scene test of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx3d");
 
var view = null;
 
makeObjects = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
view = surface.createViewport();
var c = {bottom: {x: 0, y: 0, z: 0}, top: {x: 100, y: 100, z: 100}};
var m = dojox.gfx3d.matrix;
 
var sc1 = view.createScene();
sc1.createCube(c).setStroke({color: "blue", width: 1});
 
var sc2 = view.createScene();
sc2.createCube(c).setStroke({color: "red", width: 1}).setFill("lime");
 
var poly = [{x: 0, y: 0, z: 0}, {x: 0, y: 100, z: 0}, {x: 100, y: 100, z: 0}, {x: 100, y: 0, z: 0}];
sc2.createPolygon(poly)
.setStroke({color: "blue", width: 1})
.setTransform(dojox.gfx3d.matrix.translate(50, 20, 30))
.setFill("yellow");
 
sc2.setTransform(dojox.gfx3d.matrix.translate(100, 200, 30))
var camera = dojox.gfx3d.matrix.normalize([
m.cameraRotateXg(30),
m.cameraRotateYg(60),
m.cameraTranslate(0, 0, 0)
]);
 
view.applyCameraTransform(camera);
view.render();
 
// set up the click handlers.
dojo.connect(dojo.byId("rotate"), "onclick", rotate);
};
 
rotate = function() {
view.applyCameraTransform(dojox.gfx3d.matrix.rotateXg(10));
view.invalidate();
view.render();
};
 
dojo.addOnLoad(makeObjects);
 
</script>
</head>
<body>
<h1>Scene Test</h1>
<p>Test the setTransform of the Scene. the lime cube and yellow polygon are grouped in one Scene, and they are moved in one shot.</p>
<p>Test Viewport.invalidate with Scene. <input id="rotate" type="button" value="Rotate around Z-Axis"/></p>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx3d/_base.js
New file
0,0 → 1,19
if(!dojo._hasResource["dojox.gfx3d._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx3d._base"] = true;
dojo.provide("dojox.gfx3d._base");
 
dojo.mixin(dojox.gfx3d, {
// summary: defines constants, prototypes, and utility functions
// default objects, which are used to fill in missing parameters
defaultEdges: {type: "edges", style: null, points: []},
defaultTriangles: {type: "triangles", style: null, points: []},
defaultQuads: {type: "quads", style: null, points: []},
defaultOrbit: {type: "orbit", center: {x: 0, y: 0, z: 0}, radius: 50},
defaultPath3d: {type: "path3d", path: []},
defaultPolygon: {type: "polygon", path: []},
defaultCube: {type: "cube", bottom: {x: 0, y: 0, z: 0}, top: {x: 100, y: 100, z: 100}},
defaultCylinder: {type: "cylinder", center: /* center of bottom */ {x: 0, y: 0, z: 0}, height: 100, radius: 50}
});
 
}
/trunk/api/js/dojo1.0/dojox/layout/RadioGroup.js
New file
0,0 → 1,233
if(!dojo._hasResource["dojox.layout.RadioGroup"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.layout.RadioGroup"] = true;
dojo.provide("dojox.layout.RadioGroup");
dojo.experimental("dojox.layout.RadioGroup");
//
// dojox.layout.RadioGroup - an experimental (probably poorly named) Layout widget extending StackContainer
// that accepts ContentPanes as children, and applies aesthetically pleasing responsive transition animations
// attached to :hover of the Buttons created.
//
// FIXME: take the Buttons out of the root template, and allow layoutAlign or similar attrib to use a different
// template, or build the template dynamically?
//
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dijit._Container");
dojo.require("dijit.layout.StackContainer");
dojo.require("dojox.fx.easing");
 
dojo.declare("dojox.layout.RadioGroup",
[dijit.layout.StackContainer,dijit._Templated],
{
// summary: A Container that turns its Layout Children into a single Pane and transitions between states
// onHover of the button
//
 
// duration: Int
// used for Fade and Slide RadioGroup's, the duration to run the transition animation. does not affect anything
// in default RadioGroup
duration: 750,
 
// hasButtons: Boolean
// toggles internal button making on or off
hasButtons: true,
 
// templateString: String
// the template for our container
templateString: '<div class="dojoxRadioGroup">'
+' <div dojoAttachPoint="buttonHolder" style="display:none;">'
+' <table class="dojoxRadioButtons"><tbody><tr class="dojoxRadioButtonRow" dojoAttachPoint="buttonNode"></tr></tbody></table>'
+' </div>'
+' <div class="dojoxRadioView" dojoAttachPoint="containerNode"></div>'
+'</div>',
 
startup: function(){
// summary: scan the container for children, and make "tab buttons" for them
this.inherited("startup",arguments);
this._children = this.getChildren();
this._buttons = this._children.length;
this._size = dojo.coords(this.containerNode);
if(this.hasButtons){
dojo.style(this.buttonHolder,"display","block");
dojo.forEach(this._children,this._makeButton,this);
}
},
 
// private:
_makeButton: function(/* DomNode */n){
// summary: creates a hover button for a child node of the RadioGroup
dojo.style(n.domNode,"position","absolute");
var tmp = document.createElement('td');
this.buttonNode.appendChild(tmp);
var tmpt = tmp.appendChild(document.createElement('div'));
var tmpw = new dojox.layout._RadioButton({
label: n.title,
page: n
},tmpt);
tmpw.startup();
},
 
// FIXME: shouldn't have to rewriting these, need to take styling out of _showChild and _hideChild
// and use classes on the domNode in _transition or something similar (in StackContainer)
_transition: function(/*Widget*/newWidget, /*Widget*/oldWidget){
// summary: called when StackContainer receives a selectChild call, used to transition the panes.
this._showChild(newWidget);
if(oldWidget){
this._hideChild(oldWidget);
}
// Size the new widget, in case this is the first time it's being shown,
// or I have been resized since the last time it was shown.
// page must be visible for resizing to work
if(this.doLayout && newWidget.resize){
newWidget.resize(this._containerContentBox || this._contentBox);
}
},
 
_showChild: function(/*Widget*/ page){
// summary: show the selected child widget
var children = this.getChildren();
page.isFirstChild = (page == children[0]);
page.isLastChild = (page == children[children.length-1]);
page.selected = true;
 
page.domNode.style.display="";
 
if(page._loadCheck){
page._loadCheck(); // trigger load in ContentPane
}
if(page.onShow){
page.onShow();
}
},
 
_hideChild: function(/*Widget*/ page){
// summary: hide the specified child widget
page.selected=false;
page.domNode.style.display="none";
if(page.onHide){
page.onHide();
}
}
 
});
 
dojo.declare("dojox.layout.RadioGroupFade",
dojox.layout.RadioGroup,
{
// summary: An extension on a stock RadioGroup, that fades the panes.
 
_hideChild: function(page){
// summary: hide the specified child widget
dojo.fadeOut({
node:page.domNode,
duration:this.duration,
onEnd: this.inherited("_hideChild",arguments)
}).play();
},
 
_showChild: function(page){
// summary: show the specified child widget
this.inherited("_showChild",arguments);
dojo.style(page.domNode,"opacity",0);
dojo.fadeIn({
node:page.domNode,
duration:this.duration
}).play();
}
});
 
dojo.declare("dojox.layout.RadioGroupSlide",
dojox.layout.RadioGroup,
{
// summary: A Sliding Radio Group
// description:
// An extension on a stock RadioGroup widget, sliding the pane
// into view from being hidden. The entry direction is randomized
// on each view
//
 
// easing: dojo._Animation.easing
// A hook to override the default easing of the pane slides.
easing: dojox.fx.easing.easeOut,
 
startup: function(){
// summary: on startup, set each of the panes off-screen (_showChild is called later)
this.inherited("startup",arguments);
dojo.forEach(this._children,this._positionChild,this);
},
 
_positionChild: function(page){
// summary: randomly set the child out of view
// description:
var rA = Math.round(Math.random());
var rB = Math.round(Math.random());
dojo.style(page.domNode, rA? "top" : "left", (rB ? "-" : "") + this._size[rA?"h":"w"]+"px");
},
 
_showChild: function(page){
// summary: Slide in the selected child widget
this.inherited("_showChild",arguments);
if(this._anim && this._anim.status()=="playing"){
this._anim.gotoPercent(100,true);
}
this._anim = dojo.animateProperty({
node:page.domNode,
properties: {
// take a performance hit determinging one of these doesn't get modified
// but it's better this way than an extra call to mixin in think?
left: { end:0, unit:"px" },
top: { end:0, unit:"px" }
},
duration:this.duration,
easing:this.easing
});
this._anim.play();
},
 
_hideChild: function(page){
// summary: reset the position of the hidden pane out of sight
this.inherited("_hideChild",arguments);
this._positionChild(page);
}
});
 
dojo.declare("dojox.layout._RadioButton",
[dijit._Widget,dijit._Templated,dijit._Contained],
{
// summary: The Buttons for a RadioGroup
//
// description: A private widget used to manipulate the StackContainer (RadioGroup*). Don't create directly.
//
// label: String
// the Text Label of the button
label: "",
 
// domNode to tell parent to select
page: null,
 
templateString: '<div dojoAttachPoint="focusNode" class="dojoxRadioButton"><span dojoAttachPoint="titleNode" class="dojoxRadioButtonLabel">${label}</span></div>',
startup: function(){
// summary: start listening to mouseOver
this.connect(this.domNode,"onmouseover","_onMouse");
},
_onMouse: function(/* Event */e){
// summary: set the selected child on hover, and set our hover state class
this.getParent().selectChild(this.page);
this._clearSelected();
dojo.addClass(this.domNode,"dojoxRadioButtonSelected");
},
 
_clearSelected: function(){
// summary: remove hover state class from sibling Buttons. This is easier (and more reliable)
// than setting up an additional connection to onMouseOut
// FIXME: this relies on the template being [div][span]node[/span][/div]
dojo.query(".dojoxRadioButtonSelected",this.domNode.parentNode.parentNode).forEach(function(n){
dojo.removeClass(n,"dojoxRadioButtonSelected");
});
}
});
 
}
/trunk/api/js/dojo1.0/dojox/layout/ResizeHandle.js
New file
0,0 → 1,239
if(!dojo._hasResource["dojox.layout.ResizeHandle"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.layout.ResizeHandle"] = true;
dojo.provide("dojox.layout.ResizeHandle");
dojo.experimental("dojox.layout.ResizeHandle");
 
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dojo.fx");
 
dojo.declare("dojox.layout.ResizeHandle", [dijit._Widget, dijit._Templated], {
// summary
// The handle on the bottom-right corner of FloatingPane or other widgets that allows
// the widget to be resized.
// Typically not used directly.
 
// targetId: String
// id of the Widget OR DomNode that I will size
targetId: '',
 
// targetContainer: DomNode
// over-ride targetId and attch this handle directly to a reference of a DomNode
targetContainer: null,
 
// resizeAxis: String
// one of: x|y|xy limit resizing to a single axis, default to xy ...
resizeAxis: "xy",
 
// activeResize: Boolean
// if true, node will size realtime with mouse movement,
// if false, node will create virtual node, and only resize target on mouseUp
activeResize: false,
// activeResizeClass: String
// css class applied to virtual resize node.
activeResizeClass: 'dojoxResizeHandleClone',
 
// animateSizing: Boolean
// only applicable if activeResize = false. onMouseup, animate the node to the
// new size
animateSizing: true,
// animateMethod: String
// one of "chain" or "combine" ... visual effect only. combine will "scale"
// node to size, "chain" will alter width, then height
animateMethod: 'chain',
 
// animateDuration: Integer
// time in MS to run sizing animation. if animateMethod="chain", total animation
// playtime is 2*animateDuration
animateDuration: 225,
 
// minHeight: Integer
// smallest height in px resized node can be
minHeight: 100,
 
// minWidth: Integer
// smallest width in px resize node can be
minWidth: 100,
 
// resize handle template, fairly easy to override:
templateString: '<div dojoAttachPoint="resizeHandle" class="dojoxResizeHandle"><div></div></div>',
 
// private propteries and holders
_isSizing: false,
_connects: [],
_activeResizeNode: null,
_activeResizeLastEvent: null,
// defaults to match default resizeAxis. set resizeAxis variable to modify.
_resizeX: true,
_resizeY: true,
 
 
postCreate: function(){
// summary: setup our one major listener upon creation
dojo.connect(this.resizeHandle, "onmousedown", this, "_beginSizing");
if(!this.activeResize){
this._activeResizeNode = document.createElement('div');
dojo.addClass(this._activeResizeNode,this.activeResizeClass);
}else{ this.animateSizing = false; }
 
if (!this.minSize) {
this.minSize = { w: this.minWidth, h: this.minHeight };
}
// should we modify the css for the cursor hover to n-resize nw-resize and w-resize?
this._resizeX = this._resizeY = false;
switch (this.resizeAxis.toLowerCase()) {
case "xy" :
this._resizeX = this._resizeY = true;
// FIXME: need logic to determine NW or NE class to see
// based on which [todo] corner is clicked
dojo.addClass(this.resizeHandle,"dojoxResizeNW");
break;
case "x" :
this._resizeX = true;
dojo.addClass(this.resizeHandle,"dojoxResizeW");
break;
case "y" :
this._resizeY = true;
dojo.addClass(this.resizeHandle,"dojoxResizeN");
break;
}
},
 
_beginSizing: function(/*Event*/ e){
// summary: setup movement listeners and calculate initial size
if (this._isSizing){ return false; }
 
this.targetWidget = dijit.byId(this.targetId);
 
// FIXME: resizing widgets does weird things, disable virtual resizing for now:
if (this.targetWidget) { this.activeResize = true; }
 
this.targetDomNode = this.targetWidget ? this.targetWidget.domNode : dojo.byId(this.targetId);
if (this.targetContainer) { this.targetDomNode = this.targetContainer; }
if (!this.targetDomNode){ return; }
 
if (!this.activeResize) {
this.targetDomNode.appendChild(this._activeResizeNode);
dojo.fadeIn({ node: this._activeResizeNode, duration:120,
beforeBegin: dojo.hitch(this,function(){
this._activeResizeNode.style.display='';
})
}).play();
}
 
this._isSizing = true;
this.startPoint = {'x':e.clientX, 'y':e.clientY};
 
// FIXME: this is funky: marginBox adds height, contentBox ignores padding (expected, but foo!)
var mb = (this.targetWidget) ? dojo.marginBox(this.targetDomNode) : dojo.contentBox(this.targetDomNode);
this.startSize = { 'w':mb.w, 'h':mb.h };
 
this._connects = [];
this._connects.push(dojo.connect(document,"onmousemove",this,"_updateSizing"));
this._connects.push(dojo.connect(document,"onmouseup", this, "_endSizing"));
 
e.preventDefault();
},
 
_updateSizing: function(/*Event*/ e){
// summary: called when moving the ResizeHandle ... determines
// new size based on settings/position and sets styles.
 
if(this.activeResize){
this._changeSizing(e);
}else{
var tmp = this._getNewCoords(e);
if(tmp === false){ return; }
dojo.style(this._activeResizeNode,"width",tmp.width+"px");
dojo.style(this._activeResizeNode,"height",tmp.height+"px");
this._activeResizeNode.style.display='';
}
},
 
_getNewCoords: function(/* Event */ e){
// On IE, if you move the mouse above/to the left of the object being resized,
// sometimes clientX/Y aren't set, apparently. Just ignore the event.
try{
if(!e.clientX || !e.clientY){ return false; }
}catch(e){
// sometimes you get an exception accessing above fields...
return false;
}
this._activeResizeLastEvent = e;
 
var dx = this.startPoint.x - e.clientX;
var dy = this.startPoint.y - e.clientY;
var newW = (this._resizeX) ? this.startSize.w - dx : this.startSize.w;
var newH = (this._resizeY) ? this.startSize.h - dy : this.startSize.h;
 
// minimum size check
if(this.minSize){
//var mb = dojo.marginBox(this.targetDomNode);
if(newW < this.minSize.w){
newW = this.minSize.w;
}
if(newH < this.minSize.h){
newH = this.minSize.h;
}
}
return {width:newW, height:newH}; // Object
},
_changeSizing: function(/*Event*/ e){
// summary: apply sizing information based on information in (e) to attached node
var tmp = this._getNewCoords(e);
if(tmp===false){ return; }
 
if(this.targetWidget && typeof this.targetWidget.resize == "function"){
this.targetWidget.resize({ w: tmp.width, h: tmp.height });
}else{
if(this.animateSizing){
var anim = dojo.fx[this.animateMethod]([
dojo.animateProperty({
node: this.targetDomNode,
properties: {
width: { start: this.startSize.w, end: tmp.width, unit:'px' }
},
duration: this.animateDuration
}),
dojo.animateProperty({
node: this.targetDomNode,
properties: {
height: { start: this.startSize.h, end: tmp.height, unit:'px' }
},
duration: this.animateDuration
})
]);
anim.play();
}else{
dojo.style(this.targetDomNode,"width",tmp.width+"px");
dojo.style(this.targetDomNode,"height",tmp.height+"px");
}
}
e.preventDefault();
},
 
_endSizing: function(/*Event*/ e){
// summary: disconnect listenrs and cleanup sizing
dojo.forEach(this._connects,function(c){
dojo.disconnect(c);
});
if(!this.activeResize){
dojo.fadeOut({ node:this._activeResizeNode, duration:250,
onEnd: dojo.hitch(this,function(){
this._activeResizeNode.style.display="none";
})
}).play();
this._changeSizing(e);
}
this._isSizing = false;
}
 
});
 
}
/trunk/api/js/dojo1.0/dojox/layout/ContentPane.js
New file
0,0 → 1,478
if(!dojo._hasResource["dojox.layout.ContentPane"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.layout.ContentPane"] = true;
dojo.provide("dojox.layout.ContentPane");
 
dojo.require("dijit.layout.ContentPane");
 
(function(){ // private scope, sort of a namespace
 
// TODO: should these methods be moved to dojox.html.cssPathAdjust or something?
 
// css at-rules must be set before any css declarations according to CSS spec
// match:
// @import 'http://dojotoolkit.org/dojo.css';
// @import 'you/never/thought/' print;
// @import url("it/would/work") tv, screen;
// @import url(/did/you/now.css);
// but not:
// @namespace dojo "http://dojotoolkit.org/dojo.css"; /* namespace URL should always be a absolute URI */
// @charset 'utf-8';
// @media print{ #menuRoot {display:none;} }
 
// we adjust all paths that dont start on '/' or contains ':'
//(?![a-z]+:|\/)
 
if(dojo.isIE){
var alphaImageLoader = /(AlphaImageLoader\([^)]*?src=(['"]))(?![a-z]+:|\/)([^\r\n;}]+?)(\2[^)]*\)\s*[;}]?)/g;
}
 
var cssPaths = /(?:(?:@import\s*(['"])(?![a-z]+:|\/)([^\r\n;{]+?)\1)|url\(\s*(['"]?)(?![a-z]+:|\/)([^\r\n;]+?)\3\s*\))([a-z, \s]*[;}]?)/g;
 
function adjustCssPaths(cssUrl, cssText){
// summary:
// adjusts relative paths in cssText to be relative to cssUrl
// a path is considered relative if it doesn't start with '/' and not contains ':'
// description:
// Say we fetch a HTML page from level1/page.html
// It has some inline CSS:
// @import "css/page.css" tv, screen;
// ...
// background-image: url(images/aplhaimage.png);
//
// as we fetched this HTML and therefore this CSS
// from level1/page.html, these paths needs to be adjusted to:
// @import 'level1/css/page.css' tv, screen;
// ...
// background-image: url(level1/images/alphaimage.png);
//
// In IE it will also adjust relative paths in AlphaImageLoader()
// filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/alphaimage.png');
// will be adjusted to:
// filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='level1/images/alphaimage.png');
//
// Please note that any relative paths in AlphaImageLoader in external css files wont work, as
// the paths in AlphaImageLoader is MUST be declared relative to the HTML page,
// not relative to the CSS file that declares it
 
if(!cssText || !cssUrl){ return; }
 
// support the ImageAlphaFilter if it exists, most people use it in IE 6 for transparent PNGs
// We are NOT going to kill it in IE 7 just because the PNGs work there. Somebody might have
// other uses for it.
// If user want to disable css filter in IE6 he/she should
// unset filter in a declaration that just IE 6 doesn't understands
// like * > .myselector { filter:none; }
if(alphaImageLoader){
cssText = cssText.replace(alphaImageLoader, function(ignore, pre, delim, url, post){
return pre + (new dojo._Url(cssUrl, './'+url).toString()) + post;
});
}
 
return cssText.replace(cssPaths, function(ignore, delimStr, strUrl, delimUrl, urlUrl, media){
if(strUrl){
return '@import "' + (new dojo._Url(cssUrl, './'+strUrl).toString()) + '"' + media;
}else{
return 'url(' + (new dojo._Url(cssUrl, './'+urlUrl).toString()) + ')' + media;
}
});
}
 
// attributepaths one tag can have multiple paths, example:
// <input src="..." style="url(..)"/> or <a style="url(..)" href="..">
// <img style='filter:progid...AlphaImageLoader(src="noticeTheSrcHereRunsThroughHtmlSrc")' src="img">
var htmlAttrPaths = /(<[a-z][a-z0-9]*\s[^>]*)(?:(href|src)=(['"]?)([^>]*?)\3|style=(['"]?)([^>]*?)\5)([^>]*>)/gi;
 
function adjustHtmlPaths(htmlUrl, cont){
var url = htmlUrl || "./";
 
return cont.replace(htmlAttrPaths,
function(tag, start, name, delim, relUrl, delim2, cssText, end){
return start + (name ?
(name + '=' + delim + (new dojo._Url(url, relUrl).toString()) + delim)
: ('style=' + delim2 + adjustCssPaths(url, cssText) + delim2)
) + end;
}
);
}
 
function secureForInnerHtml(cont){
/********* remove <!DOCTYPE.. and <title>..</title> tag **********/
// khtml is picky about dom faults, you can't attach a <style> or <title> node as child of body
// must go into head, so we need to cut out those tags
return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, "");
}
 
function snarfStyles(/*String*/cssUrl, /*String*/cont, /*Array*/styles){
/**************** cut out all <style> and <link rel="stylesheet" href=".."> **************/
// also return any attributes from this tag (might be a media attribute)
// if cssUrl is set it will adjust paths accordingly
styles.attributes = [];
 
return cont.replace(/(?:<style([^>]*)>([\s\S]*?)<\/style>|<link\s+(?=[^>]*rel=['"]?stylesheet)([^>]*?href=(['"])([^>]*?)\4[^>\/]*)\/?>)/gi,
function(ignore, styleAttr, cssText, linkAttr, delim, href){
// trim attribute
var i, attr = (styleAttr||linkAttr||"").replace(/^\s*([\s\S]*?)\s*$/i, "$1");
if(cssText){
i = styles.push(cssUrl ? adjustCssPaths(cssUrl, cssText) : cssText);
}else{
i = styles.push('@import "' + href + '";')
attr = attr.replace(/\s*(?:rel|href)=(['"])?[^\s]*\1\s*/gi, ""); // remove rel=... and href=...
}
if(attr){
attr = attr.split(/\s+/);// split on both "\n", "\t", " " etc
var atObj = {}, tmp;
for(var j = 0, e = attr.length; j < e; j++){
tmp = attr[j].split('=')// split name='value'
atObj[tmp[0]] = tmp[1].replace(/^\s*['"]?([\s\S]*?)['"]?\s*$/, "$1"); // trim and remove ''
}
styles.attributes[i - 1] = atObj;
}
return ""; // squelsh the <style> or <link>
}
);
}
 
function snarfScripts(cont, byRef){
// summary
// strips out script tags from cont
// invoke with
// byRef = {errBack:function(){/*add your download error code here*/, downloadRemote: true(default false)}}
// byRef will have {code: 'jscode'} when this scope leaves
byRef.code = "";
 
function download(src){
if(byRef.downloadRemote){
// console.debug('downloading',src);
dojo.xhrGet({
url: src,
sync: true,
load: function(code){
byRef.code += code+";";
},
error: byRef.errBack
});
}
}
// match <script>, <script type="text/..., but not <script type="dojo(/method)...
return cont.replace(/<script\s*(?![^>]*type=['"]?dojo)(?:[^>]*?(?:src=(['"]?)([^>]*?)\1[^>]*)?)*>([\s\S]*?)<\/script>/gi,
function(ignore, delim, src, code){
if(src){
download(src);
}else{
byRef.code += code;
}
return "";
}
);
}
 
function evalInGlobal(code, appendNode){
// we do our own eval here as dojo.eval doesn't eval in global crossbrowser
// This work X browser but but it relies on a DOM
// plus it doesn't return anything, thats unrelevant here but not for dojo core
appendNode = appendNode || dojo.doc.body;
var n = appendNode.ownerDocument.createElement('script');
n.type = "text/javascript";
appendNode.appendChild(n);
n.text = code; // DOM 1 says this should work
}
 
/*=====
dojox.layout.ContentPane.DeferredHandle = {
// cancel: Function
cancel: function(){
// summary: cancel a in flight download
},
 
addOnLoad: function(func){
// summary: add a callback to the onLoad chain
// func: Function
},
 
addOnUnload: function(func){
// summary: add a callback to the onUnload chain
// func: Function
}
}
=====*/
 
 
dojo.declare("dojox.layout.ContentPane", dijit.layout.ContentPane, {
// summary:
// An extended version of dijit.layout.ContentPane
// Supports infile scrips and external ones declared by <script src=''
// relative path adjustments (content fetched from a different folder)
// <style> and <link rel='stylesheet' href='..'> tags,
// css paths inside cssText is adjusted (if you set adjustPaths = true)
//
// NOTE that dojo.require in script in the fetched file isn't recommended
// Many widgets need to be required at page load to work properly
 
// adjustPaths: Boolean
// Adjust relative paths in html string content to point to this page
// Only usefull if you grab content from a another folder then the current one
adjustPaths: false,
 
// cleanContent: Boolean
// summary:
// cleans content to make it less likly to generate DOM/JS errors.
// description:
// usefull if you send contentpane a complete page, instead of a html fragment
// scans for
// style nodes, inserts in Document head
// title Node, remove
// DOCTYPE tag, remove
// <!-- *JS code here* -->
// <![CDATA[ *JS code here* ]]>
cleanContent: false,
 
// renderStyles: Boolean
// trigger/load styles in the content
renderStyles: false,
 
// executeScripts: Boolean
// Execute (eval) scripts that is found in the content
executeScripts: true,
 
// scriptHasHooks: Boolean
// replace keyword '_container_' in scripts with 'dijit.byId(this.id)'
// NOTE this name might change in the near future
scriptHasHooks: false,
 
/*======
// ioMethod: dojo.xhrGet|dojo.xhrPost
// reference to the method that should grab the content
ioMethod: dojo.xhrGet,
// ioArgs: Object
// makes it possible to add custom args to xhrGet, like ioArgs.headers['X-myHeader'] = 'true'
ioArgs: {},
 
// onLoadDeferred: dojo.Deferred
// callbackchain will start when onLoad occurs
onLoadDeferred: new dojo.Deferred(),
 
// onUnloadDeferred: dojo.Deferred
// callbackchain will start when onUnload occurs
onUnloadDeferred: new dojo.Deferred(),
 
setHref: function(url){
// summary: replace current content with url's content
return ;// dojox.layout.ContentPane.DeferredHandle
},
 
refresh: function(){
summary: force a re-download of content
return ;// dojox.layout.ContentPane.DeferredHandle
},
 
======*/
 
constructor: function(){
// init per instance properties, initializer doesn't work here because how things is hooked up in dijit._Widget
this.ioArgs = {};
this.ioMethod = dojo.xhrGet;
this.onLoadDeferred = new dojo.Deferred();
this.onUnloadDeferred = new dojo.Deferred();
},
 
postCreate: function(){
// override to support loadDeferred
this._setUpDeferreds();
 
dijit.layout.ContentPane.prototype.postCreate.apply(this, arguments);
},
 
onExecError: function(e){
// summary
// event callback, called on script error or on java handler error
// overide and return your own html string if you want a some text
// displayed within the ContentPane
},
 
setContent: function(data){
// summary: set data as new content, sort of like innerHTML
// data: String|DomNode|NodeList|dojo.NodeList
if(!this._isDownloaded){
var defObj = this._setUpDeferreds();
}
 
dijit.layout.ContentPane.prototype.setContent.apply(this, arguments);
return defObj; // dojox.layout.ContentPane.DeferredHandle
},
 
cancel: function(){
// summary: cancels a inflight download
if(this._xhrDfd && this._xhrDfd.fired == -1){
// we are still in flight, which means we should reset our DeferredHandle
// otherwise we will trigger onUnLoad chain of the canceled content,
// the canceled content have never gotten onLoad so it shouldn't get onUnload
this.onUnloadDeferred = null;
}
dijit.layout.ContentPane.prototype.cancel.apply(this, arguments);
},
 
_setUpDeferreds: function(){
var _t = this, cancel = function(){ _t.cancel(); }
var onLoad = (_t.onLoadDeferred = new dojo.Deferred());
var onUnload = (_t._nextUnloadDeferred = new dojo.Deferred());
return {
cancel: cancel,
addOnLoad: function(func){onLoad.addCallback(func);},
addOnUnload: function(func){onUnload.addCallback(func);}
};
},
 
_onLoadHandler: function(){
dijit.layout.ContentPane.prototype._onLoadHandler.apply(this, arguments);
if(this.onLoadDeferred){
this.onLoadDeferred.callback(true);
}
},
 
_onUnloadHandler: function(){
this.isLoaded = false;
this.cancel();// need to cancel so we don't get any inflight suprises
if(this.onUnloadDeferred){
this.onUnloadDeferred.callback(true);
}
 
dijit.layout.ContentPane.prototype._onUnloadHandler.apply(this, arguments);
 
if(this._nextUnloadDeferred){
this.onUnloadDeferred = this._nextUnloadDeferred;
}
},
 
_onError: function(type, err){
dijit.layout.ContentPane.prototype._onError.apply(this, arguments);
if(this.onLoadDeferred){
this.onLoadDeferred.errback(err);
}
},
 
_prepareLoad: function(forceLoad){
// sets up for a xhrLoad, load is deferred until widget is showing
var defObj = this._setUpDeferreds();
 
dijit.layout.ContentPane.prototype._prepareLoad.apply(this, arguments);
 
return defObj;
},
 
_setContent: function(cont){
// override dijit.layout.ContentPane._setContent, to enable path adjustments
var styles = [];// init vars
if(dojo.isString(cont)){
if(this.adjustPaths && this.href){
cont = adjustHtmlPaths(this.href, cont);
}
if(this.cleanContent){
cont = secureForInnerHtml(cont);
}
if(this.renderStyles || this.cleanContent){
cont = snarfStyles(this.href, cont, styles);
}
 
// because of a bug in IE, script tags that is first in html hierarchy doesnt make it into the DOM
// when content is innerHTML'ed, so we can't use dojo.query to retrieve scripts from DOM
if(this.executeScripts){
var _t = this, code, byRef = {
downloadRemote: true,
errBack:function(e){
_t._onError.call(_t, 'Exec', 'Error downloading remote script in "'+_t.id+'"', e);
}
};
cont = snarfScripts(cont, byRef);
code = byRef.code;
}
 
// rationale for this block:
// if containerNode/domNode is a table derivate tag, some browsers dont allow innerHTML on those
var node = (this.containerNode || this.domNode), pre = post = '', walk = 0;
switch(name = node.nodeName.toLowerCase()){
case 'tr':
pre = '<tr>'; post = '</tr>';
walk += 1;//fallthrough
case 'tbody': case 'thead':// children of THEAD is of same type as TBODY
pre = '<tbody>' + pre; post += '</tbody>';
walk += 1;// falltrough
case 'table':
pre = '<table>' + pre; post += '</table>';
walk += 1;
break;
}
if(walk){
var n = node.ownerDocument.createElement('div');
n.innerHTML = pre + cont + post;
do{
n = n.firstChild;
}while(--walk);
cont = n.childNodes;
}
}
 
// render the content
dijit.layout.ContentPane.prototype._setContent.call(this, cont);
 
// clear old stylenodes from the DOM
if(this._styleNodes && this._styleNodes.length){
while(this._styleNodes.length){
dojo._destroyElement(this._styleNodes.pop());
}
}
// render new style nodes
if(this.renderStyles && styles && styles.length){
this._renderStyles(styles);
}
 
if(this.executeScripts && code){
if(this.cleanContent){
// clean JS from html comments and other crap that browser
// parser takes care of in a normal page load
code = code.replace(/(<!--|(?:\/\/)?-->|<!\[CDATA\[|\]\]>)/g, '');
}
if(this.scriptHasHooks){
// replace _container_ with dijit.byId(this.id)
code = code.replace(/_container_(?!\s*=[^=])/g, "dijit.byId('"+this.id+"')");
}
try{
evalInGlobal(code, (this.containerNode || this.domNode));
}catch(e){
this._onError('Exec', 'Error eval script in '+this.id+', '+e.message, e);
}
}
},
 
_renderStyles: function(styles){
// insert css from content into document head
this._styleNodes = [];
var st, att, cssText, doc = this.domNode.ownerDocument;
var head = doc.getElementsByTagName('head')[0];
 
for(var i = 0, e = styles.length; i < e; i++){
cssText = styles[i]; att = styles.attributes[i];
st = doc.createElement('style');
st.setAttribute("type", "text/css"); // this is required in CSS spec!
 
for(var x in att){
st.setAttribute(x, att[x])
}
this._styleNodes.push(st);
head.appendChild(st); // must insert into DOM before setting cssText
 
if(st.styleSheet){ // IE
st.styleSheet.cssText = cssText;
}else{ // w3c
st.appendChild(doc.createTextNode(cssText));
}
}
}
});
 
})();
 
}
/trunk/api/js/dojo1.0/dojox/layout/resources/icons/resize.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/layout/resources/icons/resize.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/layout/resources/FloatingPane.css
New file
0,0 → 1,170
.dojoxFloatingPane {
background-color:#fff;
position:relative;
border: 1px solid #dedede;
overflow: hidden;
-webkit-box-shadow: 0px 5px 10px #adadad;
}
 
.dojoxFloatingPaneFg {
-webkit-box-shadow: 0px 8px 20px #525252;
}
 
/* titleNode */
.dojoxFloatingPaneTitle {
background: #cccccc;
background:#fafafa url("images/floatTitleBarBg.gif") repeat-x bottom left;
border:1px solid #bfbfbf;
padding:4px 4px 2px 4px;
cursor: pointer;
white-space: nowrap;
}
 
.soria .dojoxFloatingPaneTitle {
background:#4f8ced url("../../../dijit/themes/soria/images/gradientTopBg.png") repeat-x top left;
border:1px solid #6969FF;
background-position:0px -1px;
color:#fff; font-weight:bold;
}
.tundra .dojoxFloatingPaneTitle {
background:#fafafa url("../../../dijit/themes/tundra/images/titleBarBg.gif") repeat-x bottom left;
border:1px solid #bfbfbf;
color:#000;
}
 
 
/* Icons */
.dojoxFloatingCloseIcon {
background:url('icons/tabClose.png') no-repeat center center;
width:16px;
height:16px;
overflow:hidden;
float:right;
}
 
.dojoxFloatingMinimizeIcon {
background:url('../../../dijit/themes/tundra/images/arrowDown.png') no-repeat center center;
width:16px;
height:16px;
overflow:hidden;
float:right;
}
 
.floatingPaneMaximized .dojoxFloatingMaximizeIcon { display:none; }
.dojoxFloatingMaximizeIcon {
background:url('../../../dijit/themes/tundra/images/arrowUp.png') no-repeat center center;
width:16px;
height:16px;
overflow:hidden;
float:right;
}
 
.floatingPaneMaximized .dojoxFloatingRestoreIcon { display:inline; }
.dojoxFloatingRestoreIcon {
background:url('../../../dijit/themes/tundra/images/arrowDown.png') no-repeat center center;
width:16px; height:16px;
overflow:hidden;
float:right;
display:none;
}
 
.dojoxFloatingResizeHandle {
background:url('icons/resize.png') no-repeat bottom right;
position:absolute;
right:0;
bottom:0;
width:16px;
height:16px;
cursor:nw-resize;
}
 
.dojoxFloatingCloseIcon {
width:16px;
height:16px;
overflow:hidden;
float:right;
cursor:pointer;
}
.soria .dojoxFloatingCloseIcon {
background:url('../../../dijit/themes/soria/images/arrows.png') no-repeat center center;
background-position:-65px -1px;
}
.tundra .dojoxFloatingCloseIcon {
background:url('../../../dijit/themes/tundra/images/tabClose.png') no-repeat center center;
}
 
/* our un-used dock styles for now */
.dojoxFloatingDockDefault {
position:absolute;
bottom:0px;
left:0px;
overflow:hidden;
margin:0;
margin-bottom:3px;
padding:0px;
width:100%;
z-index:99; /* position the dock _just_ below the lowest pane */
 
background:transparent;
/* background-color:#fff;
border-top:1px solid #ccc;
*/
}
 
.dojoxDockList {
padding: 0px;
margin: 0px;
}
 
.dojoxDockRestoreButton {
background:url('../../../dijit/themes/tundra/images/arrowUp.png') no-repeat center center;
width:16px; height:16px;
overflow:hidden;
float:left;
margin-top:2px;
}
 
.dojoxDockTitleNode {
overflow:hidden;
}
 
/* Modifications */
 
.dojoxDock {
display: block;
border: 1px solid black;
position: absolute;
padding:0;
margin:0;
background:#fcfcfc;
}
 
.dojoxDockNode {
border: 1px solid #adadad;
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 3px;
cursor:pointer;
list-style: none;
padding: 2px;
margin: 0px;
height: 16px;
width: auto;
float: left;
background: #fafafa url("images/floatTitleBarBg.gif") repeat-x bottom left;
}
.soria .dojoxDockNode {
background:#b7cdee url("../../../dijit/themes/soria/images/gradientTopBg.png") repeat-x;
}
 
.dojoxFloatingPaneContent {
overflow: auto;
background-color: #fff;
height: 100%;
width: 100%;
}
 
.dojoxFloatingPaneCanvas {
background-color:#fff;
}
/trunk/api/js/dojo1.0/dojox/layout/resources/RadioGroup.css
New file
0,0 → 1,45
/* RadioGroup base Button styling: */
.dojoxRadioButtons {
margin:0; padding:4px;
width:100%;
outline:0;
}
 
.dojoxRadioButtons tbody {
margin:0; padding:0;
width:100%;
}
 
.dojoxRadioButton {
text-align:center;
cursor:pointer;
margin:0;
}
 
.dojoxRadioButtonSelected {
border:1px solid #ededed;
}
.tundra .dojoxRadioButtonSelected {
border:1px solid #a0a0a0;
background:#b7b7b7;
}
.soria .dojoxRadioButtonSelected {
background:#b7cdee url('../../../dijit/themes/soria/images/gradientTopBg.png') repeat-x top center;
}
 
.dojoxRadioButtonLabel {
padding:8px;
text-align:center;
display:block;
}
 
.dojoxRadioGroup {
overflow:hidden;
border:0;
margin:0; padding:0;
}
.dojoxRadioView {
position:relative;
overflow:hidden;
height:100%;
}
/trunk/api/js/dojo1.0/dojox/layout/resources/ResizeHandle.css
New file
0,0 → 1,32
.dojoxResizeHandle {
float: right;
position: absolute;
right: 2px;
bottom: 2px;
width: 13px;
height: 13px;
z-index: 20;
background-image: url('icons/resize.png');
line-height: 0px;
}
 
.dojoxResizeNW {
cursor: nw-resize;
}
 
.dojoxResizeNE {
cursor: ne-resize;
}
 
.dojoxResizeW {
cursor: w-resize;
}
 
.dojoxResizeN {
cursor: n-resize;
}
 
.dojoxResizeHandleClone {
position:absolute; top:0; left:0;
border:1px dashed #666;
}
/trunk/api/js/dojo1.0/dojox/layout/resources/FloatingPane.html
New file
0,0 → 1,14
<div class="dojoxFloatingPane" id="${id}">
<div tabindex="0" waiRole="button" class="dojoxFloatingPaneTitle" dojoAttachPoint="focusNode">
<span dojoAttachPoint="closeNode" dojoAttachEvent="onclick: close" class="dojoxFloatingCloseIcon"></span>
<span dojoAttachPoint="maxNode" dojoAttachEvent="onclick: maximize" class="dojoxFloatingMaximizeIcon"></span>
<span dojoAttachPoint="restoreNode" dojoAttachEvent="onclick: _restore" class="dojoxFloatingRestoreIcon"></span>
<span dojoAttachPoint="dockNode" dojoAttachEvent="onclick: minimize" class="dojoxFloatingMinimizeIcon"></span>
<span dojoAttachPoint="titleNode" class="dijitInline dijitTitleNode"></span>
</div>
<div dojoAttachPoint="canvas" class="dojoxFloatingPaneCanvas">
<div dojoAttachPoint="containerNode" waiRole="region" tabindex="-1" class="${contentClass}">
</div>
<span dojoAttachPoint="resizeHandle" class="dojoxFloatingResizeHandle"></span>
</div>
</div>
/trunk/api/js/dojo1.0/dojox/layout/BorderContainer.js
New file
0,0 → 1,119
if(!dojo._hasResource["dojox.layout.BorderContainer"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.layout.BorderContainer"] = true;
dojo.provide("dojox.layout.BorderContainer");
 
dojo.require("dijit.layout._LayoutWidget");
 
dojo.experimental("dojox.layout.BorderContainer");
 
dojo.declare(
"dojox.layout.BorderContainer",
// [dijit._Widget, dijit._Container, dijit._Contained],
dijit.layout._LayoutWidget,
{
// summary
// Provides layout in 5 regions, a center and borders along its 4 sides.
//
// details
// A BorderContainer is a box with a specified size (like style="width: 500px; height: 500px;"),
// that contains children widgets marked with "position" of "top", "bottom", "left", "right", "center".
// It takes it's children marked as top/bottom/left/right, and lays them out along the edges of the center box,
// with "top" and "bottom" extending the full width of the container.
//
// usage
// <style>
// html, body{ height: 100%; width: 100%; }
// </style>
// <div dojoType="BorderContainer" style="width: 100%; height: 100%">
// <div dojoType="ContentPane" position="top">header text</div>
// <div dojoType="ContentPane" position="right" style="width: 200px;">table of contents</div>
// <div dojoType="ContentPane" position="center">client area</div>
// </div>
top: {},
bottom: {},
left: {}, // inside?
right: {}, // outside?
center: {},
 
layout: function(){
this._layoutChildren(this.domNode, this._contentBox, this.getChildren());
},
 
addChild: function(/*Widget*/ child, /*Integer?*/ insertIndex){
dijit._Container.prototype.addChild.apply(this, arguments);
if(this._started){
this._layoutChildren(this.domNode, this._contentBox, this.getChildren());
}
},
 
removeChild: function(/*Widget*/ widget){
dijit._Container.prototype.removeChild.apply(this, arguments);
if(this._started){
this._layoutChildren(this.domNode, this._contentBox, this.getChildren());
}
},
 
_layoutChildren: function(/*DomNode*/ container, /*Object*/ dim, /*Object[]*/ children){
/**
* summary
* Layout a bunch of child dom nodes within a parent dom node
* container:
* parent node
* dim:
* {l, t, w, h} object specifying dimensions of container into which to place children
* children:
* an array like [ {domNode: foo, position: "bottom" }, {domNode: bar, position: "client"} ]
*/
 
//TODO: what is dim and why doesn't it look right?
// copy dim because we are going to modify it
// dim = dojo.mixin({}, dim);
 
this.domNode.style.position = "relative";
 
//FIXME: do this once? somewhere else?
dojo.addClass(container, "dijitBorderContainer");
dojo.forEach(children, function(child){
var style = child.domNode.style;
style.position = "absolute";
if(child.position){
this[child.position] = child.domNode;
}
}, this);
 
var topStyle = this.top.style;
var rightStyle = this.right.style;
var leftStyle = this.left.style;
var centerStyle = this.center.style;
var bottomStyle = this.bottom.style;
var rightCoords = dojo.coords(this.right);
var leftCoords = dojo.coords(this.left);
var centerCoords = dojo.coords(this.center);
var bottomCoords = dojo.coords(this.bottom);
var topCoords = dojo.coords(this.top);
rightStyle.top = leftStyle.top = centerStyle.top = topCoords.h + "px";
topStyle.top = topStyle.left = topStyle.right = "0px";
bottomStyle.left = bottomStyle.bottom = bottomStyle.right = "0px";
leftStyle.left = rightStyle.right = "0px";
centerStyle.left = leftCoords.w + "px";
centerStyle.right = rightCoords.w + "px";
rightStyle.bottom = leftStyle.bottom = centerStyle.bottom = bottomCoords.h + "px";
},
 
resize: function(args){
this.layout();
}
});
 
// This argument can be specified for the children of a BorderContainer.
// Since any widget can be specified as a LayoutContainer child, mix it
// into the base widget class. (This is a hack, but it's effective.)
dojo.extend(dijit._Widget, {
// position: String
// "top", "bottom", "left", "right", "center".
// See the BorderContainer description for details on this parameter.
position: 'none'
});
 
}
/trunk/api/js/dojo1.0/dojox/layout/README
New file
0,0 → 1,72
-------------------------------------------------------------------------------
dojox.layout
-------------------------------------------------------------------------------
Version 1.0
Release date: 10/31/2007
-------------------------------------------------------------------------------
Project state:
[expermental | beta]
-------------------------------------------------------------------------------
Credits
Pete Higgins (dante)
Fredrik Johansson (fj.mumme@gmail.com)
Adam Peller (peller)
Bill Keese (bill)
-------------------------------------------------------------------------------
Project description
 
placeholder for dijit.layout extensions. Currently only:
dojox.layout.FloatingPane - an extension on TitlePane for drag/drop
operation, "docking" [minimize/maximize], and [soon] resizing.
 
dojox.layout.ResizeHandle - resize handle to attach to a domNode.
works well on normal domNodes, but will require adding a resizeTo(w,h)
method to any widget you wish to use it on. [experimental]
 
dojox.layout.ContentPane - an extension on dijit ContentPane.
Supports inline scripts, inline styles, relative path adjustments
and having a table tag as domNode.
 
dojox.layout.BorderContainer - an experimental replacement for dijit.layout.BorderLayout
using CSS for layout. Incomplete. [experimental]
 
dojox.layout.RadioGroup - a stack container with sliding or fading transitions
(and an internal button set to mimic a tab container, but fires on hover)
 
-------------------------------------------------------------------------------
Dependencies
 
require Dojo Core, Dojo Base (fx), and Dijit
 
-------------------------------------------------------------------------------
Installation:
 
checkout:
 
http://svn.dojotoolkit.org/dojo/dojox/layout/*
http://svn.dojotoolkit.org/dojo/dijit/*
 
and require via:
dojo.require("dojox.layout.FloatingPane");
or:
dojo.require("dojox.layout.ContentPane");
etc ...
 
-------------------------------------------------------------------------------
Basic Usage:
 
<div dojoType="dojox.layout.FloatingPane" title="my title">
Content To be Floated
</div>
 
<div dojoType="dojox.layout.ContentPane"
adjustPaths="true"
renderStyles="true"
executeScripts="true"
href="my/page/containing/scripts/and/styles/in/a/sub/folder.html"
>
Initial content, will be replace by href.
paths in folder.html will be adjusted to match this page
</div>
 
/trunk/api/js/dojo1.0/dojox/layout/FloatingPane.js
New file
0,0 → 1,361
if(!dojo._hasResource["dojox.layout.FloatingPane"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.layout.FloatingPane"] = true;
dojo.provide("dojox.layout.FloatingPane");
dojo.experimental("dojox.layout.FloatingPane");
 
dojo.require("dojox.layout.ContentPane");
dojo.require("dijit._Templated");
dojo.require("dijit._Widget");
dojo.require("dojo.dnd.move");
dojo.require("dojox.layout.ResizeHandle");
 
dojo.declare("dojox.layout.FloatingPane",
[ dojox.layout.ContentPane, dijit._Templated ],
{
// summary:
//
// Makes a dijit.ContentPane float and draggable by it's title [similar to TitlePane]
// and over-rides onClick to onDblClick for wipeIn/Out of containerNode
// provides minimize(dock) / show() and hide() methods, and resize [almost]
 
// closable: Boolean
// allow closure of this Node
closable: true,
 
// dockable: Boolean
// allow minimizing of pane true/false
dockable: true,
 
// resizable: Boolean
// allow resizing of pane true/false
resizable: false,
 
// maxable: Boolean
// horrible param name for "Can you maximize this floating pane"
maxable: false,
 
// resizeAxis: String
// x | xy | y to limit pane's sizing direction
resizeAxis: "xy",
 
// title: String
// title to put in titlebar
title: "",
 
// dockTo: DomNode || null
// if null, will create private layout.Dock that scrolls with viewport
// on bottom span of viewport.
dockTo: null,
 
// duration: Integer
// time is MS to spend toggling in/out node
duration: 400,
 
// animation holders for toggle
_showAnim: null,
_hideAnim: null,
// node in the dock (if docked)
_dockNode: null,
 
// iconSrc: String
// [not implemented yet] will be either icon in titlepane to left
// of Title, and/or icon show when docked in a fisheye-like dock
// or maybe dockIcon would be better?
iconSrc: null,
 
contentClass: "dojoxFloatingPaneContent",
templateString: null,
templateString:"<div class=\"dojoxFloatingPane\" id=\"${id}\">\n\t<div tabindex=\"0\" waiRole=\"button\" class=\"dojoxFloatingPaneTitle\" dojoAttachPoint=\"focusNode\">\n\t\t<span dojoAttachPoint=\"closeNode\" dojoAttachEvent=\"onclick: close\" class=\"dojoxFloatingCloseIcon\"></span>\n\t\t<span dojoAttachPoint=\"maxNode\" dojoAttachEvent=\"onclick: maximize\" class=\"dojoxFloatingMaximizeIcon\"></span>\n\t\t<span dojoAttachPoint=\"restoreNode\" dojoAttachEvent=\"onclick: _restore\" class=\"dojoxFloatingRestoreIcon\"></span>\t\n\t\t<span dojoAttachPoint=\"dockNode\" dojoAttachEvent=\"onclick: minimize\" class=\"dojoxFloatingMinimizeIcon\"></span>\n\t\t<span dojoAttachPoint=\"titleNode\" class=\"dijitInline dijitTitleNode\"></span>\n\t</div>\n\t<div dojoAttachPoint=\"canvas\" class=\"dojoxFloatingPaneCanvas\">\n\t\t<div dojoAttachPoint=\"containerNode\" waiRole=\"region\" tabindex=\"-1\" class=\"${contentClass}\">\n\t\t</div>\n\t\t<span dojoAttachPoint=\"resizeHandle\" class=\"dojoxFloatingResizeHandle\"></span>\n\t</div>\n</div>\n",
 
_restoreState: {},
_allFPs: [],
 
postCreate: function(){
// summary:
this.setTitle(this.title);
this.inherited("postCreate",arguments);
var move = new dojo.dnd.Moveable(this.domNode,{ handle: this.focusNode });
//this._listener = dojo.subscribe("/dnd/move/start",this,"bringToTop");
 
if(!this.dockable){ this.dockNode.style.display = "none"; }
if(!this.closable){ this.closeNode.style.display = "none"; }
if(!this.maxable){
this.maxNode.style.display = "none";
this.restoreNode.style.display = "none";
}
if(!this.resizable){
this.resizeHandle.style.display = "none";
}else{
var foo = dojo.marginBox(this.domNode);
this.domNode.style.width = foo.w+"px";
}
this._allFPs.push(this);
},
startup: function(){
this.inherited("startup",arguments);
 
if(this.resizable){
if(dojo.isIE){
this.canvas.style.overflow = "auto";
} else {
this.containerNode.style.overflow = "auto";
}
var tmp = new dojox.layout.ResizeHandle({
//targetContainer: this.containerNode,
targetId: this.id,
resizeAxis: this.resizeAxis
},this.resizeHandle);
}
 
if(this.dockable){
// FIXME: argh.
tmpName = this.dockTo;
 
if(this.dockTo){
this.dockTo = dijit.byId(this.dockTo);
}else{
this.dockTo = dijit.byId('dojoxGlobalFloatingDock');
}
 
if(!this.dockTo){
// we need to make our dock node, and position it against
// .dojoxDockDefault .. this is a lot. either dockto="node"
// and fail if node doesn't exist or make the global one
// once, and use it on empty OR invalid dockTo="" node?
if(tmpName){
var tmpId = tmpName;
var tmpNode = dojo.byId(tmpName);
}else{
var tmpNode = document.createElement('div');
dojo.body().appendChild(tmpNode);
dojo.addClass(tmpNode,"dojoxFloatingDockDefault");
var tmpId = 'dojoxGlobalFloatingDock';
}
this.dockTo = new dojox.layout.Dock({ id: tmpId, autoPosition: "south" },tmpNode);
this.dockTo.startup();
}
if((this.domNode.style.display == "none")||(this.domNode.style.visibility == "hidden")){
// If the FP is created dockable and non-visible, start up docked.
this.minimize();
}
}
this.connect(this.focusNode,"onmousedown","bringToTop");
this.connect(this.domNode, "onmousedown","bringToTop");
},
 
setTitle: function(/* String */ title){
// summary: Update the string in the titleNode
this.titleNode.innerHTML = title;
},
close: function(){
// summary: close and destroy this widget
if(!this.closable){ return; }
dojo.unsubscribe(this._listener);
this.hide(dojo.hitch(this,"destroy"));
},
 
hide: function(/* Function? */ callback){
// summary: close but do not destroy this widget
dojo.fadeOut({
node:this.domNode,
duration:this.duration,
onEnd: dojo.hitch(this,function() {
this.domNode.style.display = "none";
this.domNode.style.visibility = "hidden";
if(this.dockTo){
this.dockTo._positionDock(null);
}
if(callback){
callback();
}
})
}).play();
},
 
show: function(/* Function? */callback){
// summary: show the FloatingPane
var anim = dojo.fadeIn({node:this.domNode, duration:this.duration,
beforeBegin: dojo.hitch(this,function(){
this.domNode.style.display = "";
this.domNode.style.visibility = "visible";
this.dockTo._positionDock(null);
if (this.dockTo) { this.dockTo._positionDock(null); }
if (typeof callback == "function") { callback(); }
this._isDocked = false;
if (this._dockNode) {
this._dockNode.destroy();
this._dockNode = null;
}
})
}).play();
this.resize(dojo.coords(this.domNode));
},
 
minimize: function(){
// summary: hide and dock the FloatingPane
if(!this._isDocked){
this.hide(dojo.hitch(this,"_dock"));
}
},
 
maximize: function(){
// summary: Make this floatingpane fullscreen (viewport)
if(this._maximized){ return; }
this._naturalState = dojo.coords(this.domNode);
if(this._isDocked){
this.show();
setTimeout(dojo.hitch(this,"maximize"),this.duration);
}
dojo.addClass(this.focusNode,"floatingPaneMaximized");
this.resize(dijit.getViewport());
this._maximized = true;
},
 
_restore: function(){
if(this._maximized){
this.resize(this._naturalState);
dojo.removeClass(this.focusNode,"floatingPaneMaximized");
this._maximized = false;
}
},
 
_dock: function(){
if(!this._isDocked){
this._dockNode = this.dockTo.addNode(this);
this._isDocked = true;
}
},
resize: function(/* Object */dim){
// summary: size the widget and place accordingly
this._currentState = dim;
var dns = this.domNode.style;
 
dns.top = dim.t+"px";
dns.left = dim.l+"px";
 
dns.width = dim.w+"px";
this.canvas.style.width = dim.w+"px";
 
dns.height = dim.h+"px";
this.canvas.style.height = (dim.h - this.focusNode.offsetHeight)+"px";
},
_startZ: 100,
bringToTop: function(){
// summary: bring this FloatingPane above all other panes
var windows = dojo.filter(
this._allFPs,
function(i){
return i !== this;
},
this);
windows.sort(function(a, b){
return a.domNode.style.zIndex - b.domNode.style.zIndex;
});
windows.push(this);
dojo.forEach(windows, function(w, x){
w.domNode.style.zIndex = (this._startZ + x * 2);
dojo.removeClass(w.domNode, "dojoxFloatingPaneFg");
}, this);
dojo.addClass(this.domNode, "dojoxFloatingPaneFg");
},
destroy: function(){
// summary: Destroy this FloatingPane completely
this._allFPs.splice(dojo.indexOf(this._allFPs, this), 1);
this.inherited("destroy", arguments);
}
});
 
 
dojo.declare("dojox.layout.Dock", [dijit._Widget,dijit._Templated], {
// summary:
// a widget that attaches to a node and keeps track of incoming / outgoing FloatingPanes
// and handles layout
 
templateString: '<div class="dojoxDock"><ul dojoAttachPoint="containerNode" class="dojoxDockList"></ul></div>',
 
// private _docked: array of panes currently in our dock
_docked: [],
_inPositioning: false,
autoPosition: false,
addNode: function(refNode){
// summary: instert a dockNode refernce into the dock
var div = document.createElement('li');
this.containerNode.appendChild(div);
var node = new dojox.layout._DockNode({ title: refNode.title, paneRef: refNode },div);
node.startup();
return node;
},
 
startup: function(){
// summary: attaches some event listeners
if (this.id == "dojoxGlobalFloatingDock" || this.isFixedDock) {
// attach window.onScroll, and a position like in presentation/dialog
dojo.connect(window,'onresize',this,"_positionDock");
dojo.connect(window,'onscroll',this,"_positionDock");
if(dojo.isIE){
dojo.connect(this.domNode,'onresize', this,"_positionDock");
}
}
this._positionDock(null);
this.inherited("startup",arguments);
},
_positionDock: function(/* Event? */e){
if(!this._inPositioning){
if(this.autoPosition == "south"){
// Give some time for scrollbars to appear/disappear
setTimeout(dojo.hitch(this, function() {
this._inPositiononing = true;
var viewport = dijit.getViewport();
var s = this.domNode.style;
s.left = viewport.l + "px";
s.width = (viewport.w-2) + "px";
s.top = (viewport.h + viewport.t) - this.domNode.offsetHeight + "px";
this._inPositioning = false;
}), 500);
}
}
}
 
 
});
 
dojo.declare("dojox.layout._DockNode", [dijit._Widget,dijit._Templated], {
// summary:
// dojox.layout._DockNode is a private widget used to keep track of
// which pane is docked.
 
// title: String
// shown in dock icon. should read parent iconSrc?
title: "",
 
// paneRef: Widget
// reference to the FloatingPane we reprasent in any given dock
paneRef: null,
 
templateString: '<li dojoAttachEvent="onclick: restore" class="dojoxDockNode">'+
'<span dojoAttachPoint="restoreNode" class="dojoxDockRestoreButton" dojoAttachEvent="onclick: restore"></span>'+
'<span class="dojoxDockTitleNode" dojoAttachPoint="titleNode">${title}</span>'+
'</li>',
 
restore: function(){
// summary: remove this dock item from parent dock, and call show() on reffed floatingpane
this.paneRef.show();
this.paneRef.bringToTop();
this.destroy();
}
 
});
 
}
/trunk/api/js/dojo1.0/dojox/layout/tests/remote/getResponse.php
New file
0,0 → 1,108
<?php
// this file is just a bouncer for ContentPane.html test
error_reporting(E_ALL ^ E_NOTICE);
if(isset($_GET['mode'])){
switch($_GET['mode']){
case 'htmlPaths':
echo "<img src='../images/testImage.gif' id='imgTest'/>
<div id='inlineStyleTest' style='width:188px;height:125px;background-image:url(../images/testImage.gif)'></div>
<style>@import 'getResponse.php?mode=importCss';</style>
<link type='text/css' rel='stylesheet' href='getResponse.php?mode=linkCss'/>
<div id='importCssTest'></div>
<div id='linkCssTest'></div>
<div id='importMediaTest'></div>
<div id='linkMediaTest'></div>
<!-- these may download but not render -->
<style media='print'>@import 'getResponse.php?mode=importMediaPrint';</style>
<link media='print' type='text/css' rel='stylesheet' href='getResponse.php?mode=linkMediaPrint'/>
";
break;
case 'importCss':
header('Content-type: text/css; charset=utf-8');
echo "#importMediaTest {
margin: 4px;
border: 1px dashed red;
width: 200px;
height: 200px;
}
#importCssTest {
margin: 4px;
border: 1px solid blue;
width: 100px;
height: 100px;
}";
break;
case 'linkCss':
header('Content-type: text/css; charset=utf-8');
echo "#linkMediaTest {
margin: 4px;
border: 2px dashed red;
width: 200px;
height: 200px;
}
#linkCssTest {
margin: 4px;
border: 2px dashed red;
width: 100px;
height: 100px;
}";
break;
 
case 'importMediaPrint': // may download but not render
header('Content-type: text/css; charset=utf-8');
echo "#importMediaTest {
margin: 10px;
border: 5px dashed gray;
width: 100px;
height: 100px;
}";
break;
 
case 'linkMediaPrint': // may download but not render
header('Content-type: text/css; charset=utf-8');
echo "#linkMediaTest {
margin: 10px;
border: 5px dashed gray;
width: 100px;
height: 100px;
}";
break;
case 'remoteJsTrue':
header('Content-type: text/javascript; charset=utf-8');
echo "unTypedVarInDocScope = true;";
break;
case 'remoteJsFalse':
header('Content-type: text/javascript; charset=utf-8');
echo "unTypedVarInDocScope = false;";
break;
case 'bounceInput':
echo file_get_contents("php://input");
break;
case 'bounceHeaders';
if(function_exists("apache_request_headers")){
$headers = apache_request_headers();
foreach($headers as $header => $vlu){
echo "$header=$vlu\n<br/>";
}
}else{
// IIS, php as CGI etc gets here, messes formating, suboptimal
$headers = preg_grep('/HTTP_/i', array_keys($_SERVER));
foreach($headers as $header){
$vlu = preg_replace(array('/^HTTP_/', '/_/'), array('', '-'), $header);
echo "$vlu={$_SERVER[$header]}\n<br/>";
}
}
break;
default:
echo "unkown mode {$_GET['mode']}";
}
}
?>
/trunk/api/js/dojo1.0/dojox/layout/tests/test_RadioGroup.html
New file
0,0 → 1,61
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
 
<title>RadioGroup Widget Test</title>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="parseOnLoad:true"></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
<script type="text/javascript" src="../RadioGroup.js"></script>
<script language="JavaScript" type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dijit.layout.ContentPane");
</script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../resources/RadioGroup.css";
body { background:#a0a0a0 !important; }
 
.dojoPane {
background:#eee url('../../../util/resources/logo/positive/dojo.logo.png') no-repeat center center !important;
}
.dojoxPane {
background:#ededed url('../../../util/resources/logo/positive/dojox.logo.png') no-repeat center center !important;
}
.dijitPane {
background:#fefefe url('../../../util/resources/logo/positive/dijit.logo.png') no-repeat center center !important;
}
 
</style>
 
</head>
<body class="tundra">
 
<h1 class="testTitle">dojox.layout.RadioGroup test</h1>
 
<div style="width:915px; margin:0 auto; height:300px;">
<div dojoType="dojox.layout.RadioGroup" style="width:300px; height:300px; float:left;">
<div dojoType="dijit.layout.ContentPane" title="Dojo" class="dojoPane" style="width:300px; height:300px; "></div>
<div dojoType="dijit.layout.ContentPane" title="Dijit" class="dijitPane" style="width:300px; height:300px; "></div>
<div dojoType="dijit.layout.ContentPane" title="Dojox" class="dojoxPane" style="width:300px; height:300px; "></div>
</div>
<div dojoType="dojox.layout.RadioGroupFade" style="width:300px; height:300px; float:left">
<div dojoType="dijit.layout.ContentPane" title="Dojo" class="dojoPane" style="width:300px; height:300px; "></div>
<div dojoType="dijit.layout.ContentPane" title="Dijit" class="dijitPane" style="width:300px; height:300px; "></div>
<div dojoType="dijit.layout.ContentPane" title="Dojox" class="dojoxPane" style="width:300px; height:300px; "></div>
</div>
<div dojoType="dojox.layout.RadioGroupSlide" style="width:300px; height:300px;">
<div dojoType="dijit.layout.ContentPane" title="Dojo" class="dojoPane" style="width:300px; height:300px; "></div>
<div dojoType="dijit.layout.ContentPane" title="Dijit" class="dijitPane" style="width:300px; height:300px; "></div>
<div dojoType="dijit.layout.ContentPane" title="Dojox" class="dojoxPane" style="width:300px; height:300px; "></div>
</div>
</div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/layout/tests/test_ResizeHandle.html
New file
0,0 → 1,120
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
 
<title>Resize Widget Test</title>
 
<script type="text/javascript">var djConfig = {isDebug: true, parseOnLoad: true };</script>
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
<script type="text/javascript" src="../ResizeHandle.js"></script>
<script language="JavaScript" type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dijit.layout.ContentPane");
// dojo.require("dojox.layout.ResizeHandle");
function makeNewSizer(){
var handle = document.createElement('div');
dojo.byId("programatic").appendChild(handle);
var resizer = new dojox.layout.ResizeHandle({
targetId: "programatic",
activeResize: true
},handle);
resizer.startup();
}
dojo.addOnLoad(makeNewSizer);
 
</script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../resources/ResizeHandle.css";
#programatic {
width:100px;
height:100px;
border:2px solid #333;
position:relative;
}
</style>
 
</head>
<body class="tundra">
 
<h1 class="testTitle">dojox.layout.ResizeHandle test</h1>
 
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam facilisis enim.
Pellentesque in elit et lacus euismod dignissim. Aliquam dolor pede, convallis eget,
dictum a, blandit ac, urna. Pellentesque sed nunc ut justo volutpat egestas. Class
aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos.
In erat. Suspendisse potenti. Fusce faucibus nibh sed nisi. Phasellus faucibus, dui
a cursus dapibus, mauris nulla euismod velit, a lobortis turpis arcu vel dui. Pellentesque
fermentum ultrices pede. Donec auctor lectus eu arcu. Curabitur non orci eget est porta gravida.
Aliquam pretium orci id nisi. Duis faucibus, mi non adipiscing venenatis, erat urna aliquet elit,
eu fringilla lacus tellus quis erat. Nam tempus ornare lorem. Nullam feugiat.</p>
 
<p>Sed congue. Aenean blandit sollicitudin mi. Maecenas pellentesque. Vivamus ac urna. Nunc consequat nisi vitae quam. Suspendisse sed nunc. Proin suscipit porta magna. Duis accumsan nunc in velit. Nam et nibh. Nulla facilisi. Cras venenatis urna et magna. Aenean magna mauris, bibendum sit amet, semper quis, aliquet nec, sapien. Aliquam aliquam odio quis erat. Etiam est nisi, condimentum non, lacinia ac, vehicula laoreet, elit. Sed interdum augue sit amet quam dapibus semper. Nulla facilisi. Pellentesque lobortis erat nec quam.</p>
 
<!-- TODO: figure out a way to attach to non-containers, or make ResizeContainter
<div style="position:relative; height:188px; width:125px; margin:0; padding:0; " id="logo"><img src="images/dojoLogo.png" style="width:100%; height:100%">
<div dojoType="dojox.layout.ResizeHandle" activeSizing="true" targetId="logo"></div>
</div>
-->
 
<div id="programatic"> This is text!</div>
<br><br>
<div dojoType="dijit.layout.ContentPane"
title="Test window"
style="width: 300px; height: 200px; padding:10px; border: 1px solid #dedede; position: relative; background: white;"
id="testWindow"
>
Content Pane w/a resize handle. activeResize'ing only on layout Widgets? FIXME: :)
<div dojoType="dojox.layout.ResizeHandle" targetId="testWindow"></div>
</div>
 
<br>
 
<div id="plainDiv"
style="width: 300px; padding:3px; height: 200px; border:1px solid #666; position: relative; background: white;"
>
Plain div w/a resize handle. All Default settings.
<div dojoType="dojox.layout.ResizeHandle" targetId="plainDiv"></div>
</div>
 
<br><br>
 
<div id="plainDiv3"
style="margin:8px; float:left; width: 300px; height: 200px; border: solid red 5px; position: relative; background: white;"
>
Plain div w/a resize handle but resizeAxis="y", and activeResize="true"
<div dojoType="dojox.layout.ResizeHandle" resizeAxis="y" activeResize="true" targetId="plainDiv3" style="bottom: 0; right: 0; position: absolute;"></div>
</div>
 
 
<div id="plainDiv2"
style="margin:8px; float:left; width: 300px; height: 200px; border: solid red 5px; position: relative; background: white;"
>
Plain div w/a resize handle but resizeAxis="x" with animated sizing.
<div dojoType="dojox.layout.ResizeHandle" resizeAxis="x" targetId="plainDiv2" style="bottom: 2px; right: 2px; position: absolute;"></div>
</div>
 
<br><br>
<div id="plainDiv22"
style="margin:8px; padding:15px; float:left; width: 300px; height: 200px; border: solid red 5px; position: relative; background: white;"
>
Plain div w/a resize handle but resizeAxis="xy" with animated sizing (combine).
<div dojoType="dojox.layout.ResizeHandle" resizeAxis="xy" animateMethod="combine" targetId="plainDiv22" style="bottom: 2px; right: 2px; position: absolute;"></div>
</div>
 
<br><br>
 
<p>Sed arcu magna, molestie at, fringilla in, sodales eu, elit. Curabitur mattis lorem et est. Quisque et tortor. Integer bibendum vulputate odio. Nam nec ipsum. Vestibulum mollis eros feugiat augue. Integer fermentum odio lobortis odio. Nullam mollis nisl non metus. Maecenas nec nunc eget pede ultrices blandit. Ut non purus ut elit convallis eleifend. Fusce tincidunt, justo quis tempus euismod, magna nulla viverra libero, sit amet lacinia odio diam id risus. Ut varius viverra turpis. Morbi urna elit, imperdiet eu, porta ac, pharetra sed, nisi. Etiam ante libero, ultrices ac, faucibus ac, cursus sodales, nisl. Praesent nisl sem, fermentum eu, consequat quis, varius interdum, nulla. Donec neque tortor, sollicitudin sed, consequat nec, facilisis sit amet, orci. Aenean ut eros sit amet ante pharetra interdum.</p>
 
<p>Fusce rutrum pede eget quam. Praesent purus. Aenean at elit in sem volutpat facilisis. Nunc est augue, commodo at, pretium a, fermentum at, quam. Nam sit amet enim. Suspendisse potenti. Cras hendrerit rhoncus justo. Integer libero. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam erat volutpat. Sed adipiscing mi vel ipsum.</p>
 
<p>Sed aliquam, quam consectetuer condimentum bibendum, neque libero commodo metus, non consectetuer magna risus vitae eros. Pellentesque mollis augue id libero. Morbi nonummy hendrerit dui. Morbi nisi felis, fringilla ac, euismod vitae, dictum mollis, pede. Integer suscipit, est sed posuere ullamcorper, ipsum lectus interdum nunc, quis blandit erat eros hendrerit pede. Vestibulum varius, elit id mattis mattis, nulla est feugiat ante, eget vestibulum augue eros ut odio. Maecenas euismod purus quis felis. Ut hendrerit tincidunt est. Fusce euismod, nunc eu tempus tempor, purus ligula volutpat tellus, nec lacinia sapien enim id risus. Aliquam orci turpis, condimentum sed, sollicitudin vel, placerat in, purus. Proin tortor nisl, blandit quis, imperdiet quis, scelerisque at, nisl. Maecenas suscipit fringilla erat. Curabitur consequat, dui blandit suscipit dictum, felis lectus imperdiet tellus, sit amet ornare risus mauris non ipsum. Fusce a purus. Vestibulum sodales. Sed porta ultrices nibh. Vestibulum metus.</p>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/layout/tests/ContentPane.html
New file
0,0 → 1,1059
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.layout.ContentPane test</title>
<script >
function fixPngIE6(){
if(this.complete && dojo.isIE < 7){
var r = this.runtimeStyle;
if(/.png$/i.test(this.src)){
r.height = this.height;
r.width = this.width;
r.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.src+"');";
this.src = this.currentStyle.backgroundImage.replace(/url\(\s*['"]?(.+?)['"]?\s*\)/, "$1");
}
this.className = this.className.replace('run_png_fix', "");
r.behaviour = 'none';
}
}
</script>
<style type='text/css'>
.run_png_fix {
background-image:url(images/blank.gif);
behaviour: expression(fixPngIE6.call(this));
}
</style>
<script src='../../../dojo/dojo.js' djConfig='isDebug:true, parseOnLoad:true'></script>
<script>
dojo.require('doh.runner');
dojo.require('dojox.layout.ContentPane');
dojo.require('dojo.parser');
dojo.require('dijit._Container');
dojo.require('dijit._Templated');
 
 
// create a do nothing, only for test widget
dojo.declare("dojox.TestWidget",
[dijit._Widget, dijit._Templated], {
templateString: "<span class='dojoxTestWidget'></span>"
});
 
// used to test if we fire scrips to document scope
function documentCallback(){
arguments.callee.reached = true;
//console.debug('reached');
}
var unTypedVarInDocScope; // a closure test to make sure we can reach this from evaled scripts
 
 
var pane1, pane2;
 
dojo.addOnLoad(function(){
 
pane1 = dijit.byId('parsedPane');
 
function ieTrimSpaceBetweenTags(str){
return str.replace(/(<[a-z]*[^>]*>)\s*/ig, "$1");
}
function testHandle(t, handle){
t.assertTrue(handle);
t.assertTrue(dojo.isFunction(handle.cancel));
t.assertTrue(dojo.isFunction(handle.addOnLoad));
t.assertTrue(dojo.isFunction(handle.addOnUnload));
}
 
 
doh.register("basicChecks", [
{
name: 'setContent',
runTest: function(t){
var msg = "Simple Test";
pane1.setContent(msg);
t.assertEqual(msg, pane1.domNode.innerHTML);
}
},
{
name: 'setHref',
timeout: 1800,
runTest: function(t){
var msg = "simple remote Test"
pane1.setHref(dojo.moduleUrl('dijit', 'tests/layout/getResponse.php?message='+encodeURI(msg)));
 
var d = new t.Deferred();
setTimeout(d.getTestCallback(function(){
t.assertEqual(msg, pane1.domNode.innerHTML)
}), 1500);
return d;
}
},
{
name: 'setContent_with_Widgets',
runTest: function(t){
var cont = "<div dojoType='dojox.TestWidget'>Test</div>";
pane1.setContent(cont);
t.assertFalse(cont.toLowerCase() == pane1.domNode.innerHTML.toLowerCase());
t.assertEqual(1, dijit._Container.prototype.getChildren.call(pane1).length);
}
},
{
name: 'changeContentTRHead',
runTest: function(t){
var trHead = dojo.query('table#tableTest > thead > tr')[0];
pane2 = new dojox.layout.ContentPane({} , trHead);
var html = "<td><div>This</div>Should<u>Work</u></td>";
pane2.setContent(html);
var res = ieTrimSpaceBetweenTags(pane2.domNode.innerHTML.toLowerCase());
t.assertEqual(html.toLowerCase(), res);
},
tearDown: function(){
pane2.destroy();
}
},
{
name: 'changeContentTHead',
runTest: function(t){
var tHead = dojo.query('table#tableTest > thead')[0];
pane2 = new dojox.layout.ContentPane({}, tHead);
var html = "<tr><td><div>This</div>Should<u>Work</u></td></tr>";
pane2.setContent(html);
var res = ieTrimSpaceBetweenTags(pane2.domNode.innerHTML.toLowerCase());
t.assertEqual(html.toLowerCase(), res);
},
tearDown: function(){
pane2.destroy();
}
},
{
name: 'changeContentTRBody',
runTest: function(t){
var trBody = dojo.query('table#tableTest > tbody > tr')[0];
pane2 = new dojox.layout.ContentPane({}, trBody);
var html = "<td><div>This</div>Should<u>Work</u></td>";
pane2.setContent(html);
var res = ieTrimSpaceBetweenTags(pane2.domNode.innerHTML.toLowerCase());
t.assertEqual(html.toLowerCase(), res);
},
tearDown: function(){
pane2.destroy();
}
},
{
name: 'changeContentTBody',
runTest: function(t){
var tBody = dojo.query('table#tableTest > tbody')[0];
pane2 = new dojox.layout.ContentPane({}, tBody);
var html = "<tr><td><div>This</div>Should<u>Work</u></td></tr>";
pane2.setContent(html);
var res = ieTrimSpaceBetweenTags(pane2.domNode.innerHTML.toLowerCase());
t.assertEqual(html.toLowerCase(), res);
},
tearDown: function(){
pane2.destroy();
}
},
{
name: 'changeContentTable',
runTest: function(t){
var table = dojo.query('table#tableTest')[0];
pane2 = new dojox.layout.ContentPane({}, table);
var html = "<tbody><tr><td><div>This</div>Should<u>Work</u></td></tr></tbody>";
pane2.setContent(html);
var res = ieTrimSpaceBetweenTags(pane2.domNode.innerHTML.toLowerCase());
t.assertEqual(html.toLowerCase(), res);
},
tearDown: function(){
pane2.destroy();
}
},
{
name: 'ioArgsSetSyncLoad',
timeout: 1500,
runTest: function(t){
pane1.ioArgs.sync = true;
pane1.setHref(dojo.moduleUrl('dijit', 'tests/layout/getResponse.php?delay=100&message=sync'));
 
// since it was a sync fetch it should be loaded here
t.assertEqual('sync', pane1.domNode.innerHTML);
},
tearDown: function(){
pane1.ioArgs = {}; // back to defaults
}
},
{
name: 'ioArgsSetsHeader',
timeout: 1800,
runTest: function(t){
// test if we can set a custom header on every request
pane1.ioArgs.headers = {'X-TestHeader': 'Testing'};
pane1.setHref('remote/getResponse.php?mode=bounceHeaders');
 
var d = new t.Deferred();
setTimeout(d.getTestCallback(function(){
var cont = pane1.domNode.innerHTML;
t.assertTrue(/X-TestHeader/i.test(cont));
t.assertTrue(/Testing/i.test(cont));
}), 1500);
 
return d;
},
tearDown: function(){
pane1.ioArgs = {}; // back to defaults
}
},
{
name: 'ioMethodPost',
timeout: 1800,
runTest: function(t){
// test to post some content on each request
pane1.ioMethod = dojo.xhrPost;
pane1.ioArgs.content = {test:'it should work'};
pane1.setHref('remote/getResponse.php?mode=bounceInput');
 
var d = new t.Deferred();
setTimeout(d.getTestCallback(function(){
t.assertEqual('test=it%20should%20work', pane1.domNode.innerHTML);
}), 1500);
return d;
},
tearDown: function(){
// back to defaults
pane1.ioMethod = dojo.xhrGet;
pane1.ioArgs = {};
}
},
{
name: 'handleFrom_setContent',
runTest: function(t){
var unLoadCalled, loadCalled;
var handle = pane1.setContent("test 'var handle = setContent()'");
testHandle(t, handle);
 
handle.addOnLoad(function(){
loadCalled = true;
});
 
t.assertTrue(loadCalled);
 
handle.addOnUnload(function(){
unLoadCalled = true;
});
 
// test unLoad callback above
handle = pane1.setContent("testing 'addOnUnload(callback)'");
t.assertTrue(unLoadCalled);
testHandle(t, handle);
}
},
{
name: 'handleFrom_setHref_and_refresh_and_cancelWorking',
timeout: 3400,
runTest: function(t){
var unloadCalled, loadCalled;
var r_unloadCalled, r_loadCalled;
var r_handle, href = dojo.moduleUrl('dijit', 'tests/layout/getResponse.php?delay=100&message=test');
 
var handle = pane1.setHref(href);
testHandle(t, handle);
handle.addOnLoad(function(){
loadCalled = 'loadCalled';
});
handle.addOnUnload(function(){
unloadCalled = 'unloadCalled';
});
 
handle.cancel();
 
setTimeout(function(){
pane1.href = href;
handle = pane1.refresh();
testHandle(t, handle); // might throw and kill rest of test, infact we rely on that
r_handle = 'refreshHandle ok';
handle.addOnLoad(function(){
r_loadCalled = 'refresh loadCalled';
pane1.setContent(); // trigger unload
});
handle.addOnUnload(function(){
r_unloadCalled = 'refresh unloadCalled';
});
}, 1500); // wait for page load in case cancel didn't work
 
var d = new t.Deferred();
 
setTimeout(d.getTestCallback(function(){
// load from the href (was canceled)
t.assertEqual(undefined, loadCalled);
t.assertEqual(undefined, unloadCalled);
 
// load from the refresh
t.assertEqual('refreshHandle ok', r_handle);
t.assertEqual('refresh loadCalled', r_loadCalled);
t.assertEqual('refresh unloadCalled', r_unloadCalled);
}), 3200);
 
return d;
}
},
{
name: 'onLoadDeferred|onUnloadDeferred_call_order',
timeout: 6200,
runTest: function(t){
pane1.preventCache = 1;
var count = {u: 0, l: 0}; // need a object for the ref in closures
var href = dojo.moduleUrl('dijit', 'tests/layout/getResponse.php?delay=100&message=test').toString();
 
function next(){
if(!isNaN(count.u) && !isNaN(count.l)){
if(count.u < 4 && count.l < 4){
pane1.setHref(href);
pane1.onLoadDeferred.addCallback(makeCallback('l', 'u', 1));
pane1.onUnloadDeferred.addCallback(makeCallback('u', 'l', 0));
}else{
pane1.setContent(); // unload to get even
}
}
}
 
function makeCallback(tryVar, compareVar, inc){
return function(){
//console.debug(tryVar, count[tryVar] + 1, count[compareVar] + inc)
if((++count[tryVar]) === (count[compareVar] + inc)){
count[tryVar];
if(tryVar == 'l'){
next(); // onload event, trigger new load
}
}else{
tryVar = 'failed '+(tryVar=='u'?'unload':'load')+' on '+count[tryVar]+' try';
}
}
}
next(); // starts the loop
var d = new t.Deferred();
setTimeout(d.getTestCallback(function(){
t.assertEqual(4, count.l);
t.assertEqual(4, count.u)
}), 6000); // 1.5 sec max on each load should be enough
return d;
},
tearDown: function(){
delete pane1.preventCache;
}
}
]
);
 
 
doh.register("pathAdjustments",
[
{
name: 'cssPathAdjustments',
runTest: function(t){
 
// we do this test as one big string to emulate as good as possible,
// but split it later to easily see where we failed
var cssText = ".easy{ background-image:url(images/image.png) }\n"
+".dontReplaceEasy{ background-image:url(images/images/image.png) }\n"
+".hardurl{background-image:url(\t \"../../source/~test/%20t'e(s)t.gif(\"1')?foo=bar11103&bar=baz-foo\" \t);}body{};\n"
+".file{background-image: url(file:///home/nobody/image.png);}\n"
+".http{background-image: url(http://dojotoolkit.org/image.png);}\n"
+".https{background-image: url(https://dojotoolkit.org/image.png);}\n"
+".nonRelative{background-image:url(/toplevelfolder/image.gif);}\n"
+'@import "css/main.css";' + "\n@import \t'css/Newbee Url.css'\t;\n"
+"@import 'http://dojotoolkit.org/dojo.css';\n"
+" @import 'you/never/thought/' print;\n"
+' @import url("it/would/work") tv, screen;'+"\n"
+' @import url(/did/you/now.css);'+"\n"
+' @import "yes.i.did";';
 
pane1.href = "deep/nested/file";
pane1.adjustPaths = 1;
pane1.renderStyles = 1;
var adjustedCss;
 
// hijack internals to snatch the styles before they are inserted to DOM (DOM messes formating)
var oldFunc = pane1._renderStyles;
return function(styles){
adjustedCss = styles.join();
}
pane1._setContent.call(pane1, '<style>'+cssText+'</style>');
pane1._renderStyles = oldFunc;
 
adjustedCss = adjustedCss.split("\n");
 
var expectedCss = (".easy{ background-image:url(deep/nested/images/image.png) }\n"
+".dontReplaceEasy{ background-image:url(deep/nested/images/images/image.png) }\n"
+".hardurl{background-image:url(source/~test/%20t'e(s)t.gif(\"1')?foo=bar11103&bar=baz-foo);}body{};\n"
+".file{background-image: url(file:///home/nobody/image.png);}\n"
+".http{background-image: url(http://dojotoolkit.org/image.png);}\n"
+".https{background-image: url(https://dojotoolkit.org/image.png);}\n"
+".nonRelative{background-image:url(/toplevelfolder/image.gif);}\n"
+"@import \"deep/nested/css/main.css\";\n@import \"deep/nested/css/Newbee Url.css\"\t;\n"
+"@import 'http://dojotoolkit.org/dojo.css';\n"
+" @import \"deep/nested/you/never/thought/\" print;\n"
+' @import url(deep/nested/it/would/work) tv, screen;'+"\n"
+' @import url(/did/you/now.css);'+"\n"
+' @import "deep/nested/yes.i.did";').split("\n");
 
// we split and loop to get a faster hint of where it failed
for(var i = 0; i < expectedCss.length; i++){
t.assertEqual(expectedCss[i], adjustedCss[i]);
}
},
tearDown: function(){
delete pane1.adjustPaths; // get back to defaults
delete pane1.renderStyles;
}
},
{
name: 'htmlPathAdjustments',
timeout: 1800,
runTest: function(t){
 
var d = new t.Deferred();
setTimeout(d.getTestCallback(
function(){
// check that images and styles have been applied
var cb = dojo.contentBox(dojo.byId('imgTest'));
//dojo.getComputedStyle(dojo.byId('imgTest'));
t.assertEqual(188, cb.w);
t.assertEqual(125, cb.h);
 
// make sure we didn't mess up the other inline styles
cb = dojo.contentBox(dojo.byId('inlineStyleTest'));
t.assertEqual(188, cb.w);
t.assertEqual(125, cb.h);
 
// make sure it is the correct image
var cs = dojo.getComputedStyle(dojo.byId('inlineStyleTest'));
var url = cs.backgroundImage;
//remove url(..)
url = url.replace(/^\s?url\(['"]?/, "").replace(/['"]?\);?\s?$/, "");
// compare image url to full path of this document
imageUrl = dojo.moduleUrl('dojox', 'layout/tests/images/testImage.gif');
t.assertEqual(new dojo._Url(document.location, imageUrl), url);
 
// make sure we loaded the <link rel='stylesheet' correctly
var mb = dojo.marginBox(dojo.byId('linkCssTest'));
t.assertEqual(112, mb.w); // 100px + 2px border + 4px margin = 112px
t.assertEqual(112, mb.h);
 
// make sure we loaded the <style>@import '...'; correctly
mb = dojo.marginBox(dojo.byId('importCssTest'));
t.assertEqual(110, mb.w); // 100px + 1px border + 4px margin = 110px
t.assertEqual(110, mb.h);
 
// make sure we didn't render the <link media='print' rel='stylesheet'
var mb = dojo.marginBox(dojo.byId('linkMediaTest'));
t.assertEqual(212, mb.w); // 100px + 2px border + 4px margin = 112px
t.assertEqual(212, mb.h);
 
// make sure we didn't render the <style media='print'>@import '...';
mb = dojo.marginBox(dojo.byId('importMediaTest'));
t.assertEqual(210, mb.w); // 100px + 1px border + 4px margin = 110px
t.assertEqual(210, mb.h);
}
), 1500);
 
pane1.adjustPaths = 1;pane1.renderStyles = 1;
pane1.setHref('remote/getResponse.php?mode=htmlPaths');
return d;
},
tearDown: function(){
delete pane1.adjustPaths; // get back to defaults
delete pane1.renderStyles;
}
},
{
name: 'renderStylesOfByDefaultAndOldDeleted',
timeout: 1800,
runTest: function(t){
var d = new t.Deferred();
 
setTimeout(d.getTestCallback(
function(){
// innerHTML'ing <link tags works in some browser (IE, moz), but not all
// we can't test if LINK was loaded this way
 
// make sure we didn't load the <link rel='stylesheet'
//var mb = dojo.marginBox(dojo.byId('linkCssTest'));
//t.assertFalse(112 == mb.w);
//t.assertFalse(112 == mb.h);
 
// make sure we didn't load the <style>@import '...';
var mb = dojo.marginBox(dojo.byId('importCssTest'));
t.assertFalse(110 == mb.w);
t.assertFalse(110 == mb.h);
}
), 1500);
pane1.adjustPaths = 1;
pane1.setHref('remote/getResponse.php?mode=htmlPaths');
return d;
},
tearDown: function(){
delete pane1.adjustPaths;
}
}
]
);
 
doh.register("scriptTests",
[
"t.assertTrue(pane1.executeScripts);",
{
name: 'leaveDojoMethodScriptsAsIs',
runTest: function(t){
pane1.setContent("<"
+"script type='dojo/method'>unTypedVarInDocScope = 'failure';<"
+"/script>");
 
var d = new t.Deferred();
// IE req to async this test
setTimeout(d.getTestCallback(function(){
t.assertEqual('undefined', typeof unTypedVarInDocScope);
t.assertFalse(unTypedVarInDocScope == 'failure');
}), 40);
 
return d;
}
},
{
name: 'scripts_evals_in_global_scope',
timeout: 1800, // grabing remote js, wait for that
runTest: function(t){
pane1.setContent("<"
+"script>function scriptsInGlobalClicked(){ documentCallback(); }<"
+"/script><"+"script src='remote/getResponse.php?mode=remoteJsTrue'></"
+"script>"+"<a href='javascript:scriptsInGlobalClicked()' "
+"onfocus='scriptsInGlobalClicked();' id='anchorTag'>test</a>");
 
var link = dojo.byId('anchorTag');
dojo.isFunction(link.click) ? /*others*/ link.click() : /*moz*/ link.focus();
var d = new t.Deferred();
setTimeout(d.getTestCallback(function(){
t.assertEqual('boolean', typeof documentCallback.reached);
t.assertTrue(documentCallback.reached);
t.assertTrue(unTypedVarInDocScope);
}), 40);
return d;
}
},
{
name:'scriptsEvalsInOrder',
timeout: 1800,// grabing remote js, wait for that
runTest: function(t){
pane1.setContent("<"
+"script src='remote/getResponse.php?mode=remoteJsFalse'><"
+"/script><"+"script>unTypedVarInDocScope = 1;<"
+"/script>"); // scripts only test
 
// we need to make this async because of IEs strange events loops
var d = new t.Deferred();
setTimeout(d.getTestCallback(function(){
t.assertEqual('number', typeof unTypedVarInDocScope);
t.assertEqual(1, unTypedVarInDocScope);
}), 40);
return d;
}
},
{
name: 'scriptsWithTypeTextJavascript',
runTest: function(t){
pane1.setContent("<"
+"script type='text/javascript'> unTypedVarInDocScope = 'text/javascript'; <"
+"/script>");
 
var d = new t.Deferred();
// IE needs async here
setTimeout(d.getTestCallback(function(){
t.assertEqual('text/javascript', unTypedVarInDocScope);
}), 40);
return d;
}
},
{
name:'scriptsWithHtmlComments',
runTest: function(t){
pane1.cleanContent = 1;
pane1.setContent("<"
+"script><!-- unTypedVarInDocScope = 2; --><"
+"/script>");
 
var d = new t.Deferred();
// IE need a async here
setTimeout(d.getTestCallback(function(){
t.assertEqual('number', typeof unTypedVarInDocScope);
t.assertEqual(2, unTypedVarInDocScope);
}), 40);
 
return d;
},
tearDown: function(){
delete pane1.cleanContent; // go back to default
}
},
{
name:'scriptsWithCData',
runTest: function(t){
pane1.cleanContent = 1;
pane1.setContent("<"
+"script><![CDATA[ unTypedVarInDocScope = 3; ]]><"
+"/script>");
 
var d = new t.Deferred();
// IE need a async here
setTimeout(d.getTestCallback(function(){
t.assertEqual('number', typeof unTypedVarInDocScope);
t.assertEqual(3, unTypedVarInDocScope);
}), 40);
 
return d;
},
tearDown: function(){
delete pane1.cleanContent; // go back to default
}
},
{
name: 'replace_container_with_dijit.byId()',
runTest: function(t){
unTypedVarInDocScope = 'failure';
pane1.scriptHasHooks = true;
pane1.setContent("<"
+"script>function testReplace(){"
+ "if(typeof _container_ != 'object'){return 'not replaced 1';}\n"
+ "if(_container_ != pane1){ return 'not replaced 2';}\n"
+ "if(!_container_ == pane1){ return 'not replaced 3';}\n"
+ "var tmp =_container_=dojo;\n"
+ "if(tmp != dojo){ return 'replaced when shouldnt 1';}\n"
+ "var tmp = _container_ \t \t = dojo;\n"
+ "if(tmp != dojo){ return 'replaced when shouldnt 2';}\n"
+ "return 'success';\n"
+"};\n"
+"unTypedVarInDocScope = testReplace();"
+"</"+"script>");
 
// let IE inhale here
var d = new t.Deferred();
setTimeout(d.getTestCallback(function(){
t.assertEqual('success', unTypedVarInDocScope);
}), 40);
return d;
},
tearDown: function(){
delete pane1.scriptHasHooks; // get back to default
}
},
{
name:'_container_onLoadDeferred|onUnloadDeferred',
runTest: function(t){
pane1.scriptHasHooks = true;
pane1.setContent("<"
+"script>"
+"var testConn;"
+"_container_.onLoadDeferred.addCallback(function(){"
+ "testConn = dojo.connect(dojo.byId('testForm'), 'onsubmit', null, function(){"
+ "unTypedVarInDocScope = dojo.byId('testInput').value;"
+ "});"
+ "dojo.byId('testButton').click();"
+"});"
+"_container_.onUnloadDeferred.addCallback(function(){"
+ "unTypedVarInDocScope = 'unloaded';"
+ "dojo.disconnect(testConn);"
+"});"
+"<"+"/script><form onsubmit='return false;' id='testForm'>"
+ "<input id='testInput' value='loaded'/>"
+ "<input type='submit' id='testButton'/>"
+"</form>");
 
var d = new t.Deferred();
// IE must breathe here
setTimeout(d.getTestCallback(function(){
t.assertEqual('loaded', unTypedVarInDocScope);
}), 40);
return d;
},
tearDown: function(){
delete pane1.scriptHasHooks; // get back to default
pane1.setContent();
}
},
"t.assertEqual('unloaded', unTypedVarInDocScope)"
]
);
 
 
doh.register('regexRegressionAndSpeedtest',[
{
name: 'cssPathAdjustments',
runTest: function(t){
// we do this test as one big string to emulate as good as possible,
// but split it later to easily see where we failed
var cssText = ".easy{ background-image:url(images/image.png) }\n"
+".dontReplaceEasy{ background-image:url(images/images/image.png) }\n"
+".hardurl{background-image:url(\t \"../../source/~test/%20t'e(s)t.gif(\"1')?foo=bar11103&bar=baz-foo\" \t);}body{};\n"
+".file{background-image: url(file:///home/nobody/image.png);}\n"
+".http{background-image: url(http://dojotoolkit.org/image.png);}\n"
+".https{background-image: url(https://dojotoolkit.org/image.png);}\n"
+".nonRelative{background-image:url(/toplevelfolder/image.gif);}\n"
+'@import "css/main.css";' + "\n@import \t'css/Newbee Url.css'\t;\n"
+"@import 'http://dojotoolkit.org/dojo.css';\n"
+" @import 'you/never/thought/' print;\n"
+' @import url("it/would/work") tv, screen;'+"\n"
+' @import url(/did/you/now.css);'+"\n"
+' @import "yes.i.did";';
 
var expectedCss = ".easy{ background-image:url(deep/nested/images/image.png) }\n"
+".dontReplaceEasy{ background-image:url(deep/nested/images/images/image.png) }\n"
+".hardurl{background-image:url(source/~test/%20t'e(s)t.gif(\"1')?foo=bar11103&bar=baz-foo);}body{};\n"
+".file{background-image: url(file:///home/nobody/image.png);}\n"
+".http{background-image: url(http://dojotoolkit.org/image.png);}\n"
+".https{background-image: url(https://dojotoolkit.org/image.png);}\n"
+".nonRelative{background-image:url(/toplevelfolder/image.gif);}\n"
+"@import \"deep/nested/css/main.css\";\n@import \"deep/nested/css/Newbee Url.css\"\t;\n"
+"@import 'http://dojotoolkit.org/dojo.css';\n"
+" @import \"deep/nested/you/never/thought/\" print;\n"
+' @import url(deep/nested/it/would/work) tv, screen;'+"\n"
+' @import url(/did/you/now.css);'+"\n"
+' @import "deep/nested/yes.i.did";';
 
for(var i = 0; i < 6; i++){
cssText += cssText;
expectedCss += expectedCss;
}
 
expectedCss = expectedCss.split("\n");
 
pane1.href = "deep/nested/file";
pane1.adjustPaths = 1;
pane1.renderStyles = 1;
var adjustedCss;
 
// hijack internals to snatch the styles before they are inserted to DOM (DOM messes formating)
var oldFunc = pane1._renderStyles;
pane1._renderStyles = function(styles){
adjustedCss = styles.join();
}
 
var start = new Date();
pane1._setContent.call(pane1, '<style>'+cssText+'</style>');
var end = new Date();
pane1._renderStyles = oldFunc;
 
adjustedCss = adjustedCss.split("\n");
console.info('Time used to regex scan css and adjust relative paths within css:'+
(end - start)+' ms on '+ cssText.split('\n').length
+' css rows, with '+ cssText.length+' characters (roughly '
+Math.round(cssText.length/1024)+ 'Kb) of infile css')
 
// we split and loop to get a faster hint of where it failed
for(var i = 0; i < expectedCss.length; i++){
t.assertEqual(expectedCss[i], adjustedCss[i]);
}
},
tearDown: function(){
delete pane1.adjustPaths; // get back to defaults
delete pane1.renderStyles;
pane1.href = "";
}
}
,
{
name:'htmlPathsSpeedTest',
runTest: function(t){
var htmlText = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n"
+"<title>should be removed</title>\n"
+"<img src=\"images/image.gif\"/>Testing\n"
+"<a href=\"../../topmost.html\">\n"
+" <img src=\"/siteroot/top.html\">\n"
+" <p style='background:url(\"images/back.png\")'>\n"
+" testing link\n"
+"</p></a>\n"
+"<style \ntype='text/css'>\n"
+" @import 'http://dojotoolkit.org/visible.css' tv, screen;\n"
+" @import \"./audio.css\" audio;\n"
+" @import url(/topsite/css/main.css);\n"
+" div.mywidget, #someId {\n"
+" background-color:url(../../css/main.css);"
+" display:none;\n"
+" background:url(../tmp/css)\n"
+" }\n"
+"</style>\n"
+"<link rel=\"stylesheet\" href=\"../../css/theme.css\" media=\"all\">\n"
+"<link media='print' type='text/css' rel='stylesheet' href='../../css/theme2.css'/>\n"
+"<a style='display:block; background:url(/topmost/css)' href='../above'>above</a>\n"
+"<sc"+"ript type=\"text/javascript\"\n src=\"..\\windows\\morons\"></scr"+"ipt>\n"
+"<scr"+"ipt type=\"dojo/method\" src=\"/dont/mess/with/this\"></scr"+"ipt>\n"
+"<scr"+"ipt src=\"/dont/mess/here/either\" type=\"dojo/method\"></scr"+"ipt>\n"
+"<scr"+"ipt event=\"/havent/you/listened\" type=\"dojo/method\"></scr"+"ipt>\n"
+"<scr"+"ipt>JS CODE</scr"+"ipt>\n"
+"<a href='javascript:void(0)'>void</a>";
 
 
pane1.href = 'deep/nested/file';
 
var expectedHtml = "\n\n<img src=\"deep/nested/images/image.gif\"/>Testing\n"
+"<a href=\"topmost.html\">\n"
+" <img src=\"/siteroot/top.html\">\n"
+" <p style='background:url(deep/nested/images/back.png)'>\n"
+" testing link\n"
+"</p></a>\n"
+"\n"
+"\n\n"
+"<a style='display:block; background:url(/topmost/css)' href='deep/above'>above</a>\n\n"
+"<scr"+"ipt type=\"dojo/method\" src=\"/dont/mess/with/this\"></scr"+"ipt>\n"
+"<scr"+"ipt src=\"/dont/mess/here/either\" type=\"dojo/method\"></scr"+"ipt>\n"
+"<scr"+"ipt event=\"/havent/you/listened\" type=\"dojo/method\"></scr"+"ipt>\n\n"
+"<a href='javascript:void(0)'>void</a>";
 
 
var expectedCss = [
"\n @import 'http://dojotoolkit.org/visible.css' tv, screen;\n"
+" @import \"deep/nested/audio.css\" audio;\n"
+" @import url(/topsite/css/main.css);\n"
+" div.mywidget, #someId {\n"
+" background-color:url(css/main.css);"
+" display:none;\n"
+" background:url(deep/tmp/css)\n"
+" }\n", "@import \"css/theme.css\";", "@import \"css/theme2.css\";"];
 
for(var i = 0; i < 6; i++){
htmlText += htmlText;
expectedHtml += expectedHtml;
expectedCss = expectedCss.concat(expectedCss);
}
 
 
pane1.href = "deep/nested/file";
pane1.adjustPaths = 1;
pane1.renderStyles = 1;
pane1.cleanContent = 1;
var adjustedCss, adjustedHtml;
 
// hijack internals to snatch the styles before they are inserted to DOM (DOM messes formating)
var oldFunc = pane1._renderStyles;
pane1._renderStyles = function(styles){
adjustedCss = styles;
pane1.executeScripts = 0;
}
 
var oldSetFunc = dijit.layout.ContentPane.prototype._setContent;
dijit.layout.ContentPane.prototype._setContent = function(html){
adjustedHtml = html;
}
 
var oldXhr = dojo.xhrGet;
dojo.xhrGet = function(){}; // kill script download
 
var start = new Date();
pane1._setContent.call(pane1, htmlText);
var end = new Date();
 
// reset back to the way it was
pane1._renderStyles = oldFunc;
dijit.layout.ContentPane.prototype._setContent = oldSetFunc;
dojo.xhrGet = oldXhr;
 
console.info('Time used to regex scan html/css and\n adjust relative paths (adjustPaths=true),\n copy scripts (executeScripts=true) and copy css innerText (renderStyles=true) and adjust paths in there \nTime:'+
(end - start)+' ms on '+ htmlText.split('\n').length
+' html rows, with '+ htmlText.length+' characters (roughly '
+Math.round(htmlText.length/1024)+ 'Kb)');
 
// we split and loop to get a faster hint of where it failed
adjustedHtml = adjustedHtml.split("\n");
expectedHtml = expectedHtml.split("\n");
 
for(var i = 0; i < expectedHtml.length; i++){
//console.debug(expectedHtml[i], i);
//console.debug(adjustedHtml[i], i);
t.assertEqual(expectedHtml[i], adjustedHtml[i]);
}
 
var exCssBlock, adjCssBlock;
for(var i = 0; i < expectedCss.length; i++){
t.assertEqual('string', typeof adjustedCss[i]);
 
exCssBlock = expectedCss[i].split('\n');
adjCssBlock = adjustedCss[i].split('\n');
 
for(var j = 0; j < exCssBlock.length;j++){
t.assertEqual(dojo.trim(exCssBlock[j]), dojo.trim(adjCssBlock[j]));
}
}
},
tearDown: function(){
delete pane1.cleanContent;
delete pane1.adjustPaths;
delete pane1.renderStyles;
delete pane1.executeScripts;
}
}
,
{
name:'IE_AlphaImageLoader_PathAdjustments',
runTest: function(t){
if(!dojo.isIE){
console.info('aborting test IE_AlphaImageLoader_PathAdjustments, you dont use IE');
return;
}
 
pane1.adjustPaths = 1;
pane1.renderStyles = 1;
 
pane1.href = "deep/";
 
var html = "<div style='width:10px;height:10px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=\"scale\", src=\"images/alpha(1).png\", nextProperty=\"useless\");'><!-- \n"
+" alpha png in IE 6 --></div>\n"
+"<style>\n"
+" .ie_menu_png {"
+" filter: \t progid:\n"
+" DXImageTransform.Microsoft.AlphaImageLoader(\n"
+" src='../midlevel/alpha(2).png')\n"
+" }\n"
+" #my_transparent_png {filter: progid:DXImageTransform.Microsoft.AlphaImageLoader( src='/images/alpha(3).png') }\n"
+" #my_transparent_png1 {filter: progid:DXImageTransform.Microsoft.AlhaImageLoader(src='http://no.se/images/alpha(4).png')}\n"
+"</style>\n";
 
 
var expectedHtml = "<div style='width:10px;height:10px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=\"scale\", src=\"deep/images/alpha(1).png\", nextProperty=\"useless\");'><!-- \n"
+" alpha png in IE 6 --></div>\n\n";
 
var expectedCss = "\n"
+" .ie_menu_png {"
+" filter: \t progid:\n"
+" DXImageTransform.Microsoft.AlphaImageLoader(\n"
+" src='midlevel/alpha(2).png')\n"
+" }\n"
+" #my_transparent_png {filter: progid:DXImageTransform.Microsoft.AlphaImageLoader( src='/images/alpha(3).png') }\n"
+" #my_transparent_png1 {filter: progid:DXImageTransform.Microsoft.AlhaImageLoader(src='http://no.se/images/alpha(4).png')}\n";
 
 
for(var i = 0; i < 7; i++){
html += html;
expectedHtml += expectedHtml;
expectedCss += expectedCss;
}
 
var adjustedHtml, adjustedCss;
 
// hijack internals to snatch the content
var oldRenderStyles = pane1._renderStyles;
var oldSetContent = dijit.layout.ContentPane.prototype._setContent;
pane1._renderStyles = function(styles){ adjustedCss = styles.join(''); };
dijit.layout.ContentPane.prototype._setContent = function(cont){ adjustedHtml = cont; }
 
var start = new Date();
pane1._setContent.call(pane1, html);
var end = new Date();
 
console.info('Time used to replace AlphaImageLoader(src="...") '
+(end - start) + "ms in HTML with "+html.length
+' characters (roughly '+(Math.round(html.length/1024))+'Kb)');
 
// reset hijacked
pane1._renderStyles = oldRenderStyles;
dijit.layout.ContentPane.prototype._setContent = oldSetContent;
 
 
// split on newline and run a check on each row to help debugging
expectedHtml = expectedHtml.split("\n");
adjustedHtml = adjustedHtml.split("\n");
for(var i = 0; i < expectedHtml.length; i++){
t.assertEqual(expectedHtml[i], adjustedHtml[i]);
}
 
expectedCss = expectedCss.split("\n");
adjustedCss = adjustedCss.split("\n");
for(var i = 0; i < expectedCss.length; i++){
t.assertEqual(expectedCss[i], adjustedCss[i]);
}
},
tearDown: function(){
delete pane1.renderStyles;
delete pane1.adjustPaths;
}
}
]);
 
doh.register("A_AlphaImageLoader_inAction", [{
name:"AlphaLoaderShowHow",
runTest:function(t){
// IE filter alphaimageloader paths must be relative to the page
// not to the cssFile that declares it
 
// demo a much better way of "Fixing" alpha png in IE6 than inlining in html
var html = "<img src='images/dojoLogo.png' class='run_png_fix'/>"
 
var showHowHtml = "<pre >\nCode used in IE transparent png example\n"
+"code (declared in main page, not through ContentPane)\n"
+"&lt;script type='text/javascript'&gt;\n"
+fixPngIE6.toString().replace(/\n\t?/g, "\n")
+"\n&lt;/script&gt;\n"
+"&lt;style type='text/css'&gt;\n"
+" .run_png_fix {\n"
+" background-image:url(images/blank.gif);\n"
+" behaviour: expression(fixPngIE6.call(this));\n"
+" }\n"
+"&lt;/style&gt;\n\n...\n\nHtml feeded to ContentPane (or your main page):\n"
+"&lt;img src='images/dojoLogo.png' class='run_png_fix'/&gt;\n</pre>";
 
pane1.executeScripts = 1;
pane1.renderStyles = 1;
pane1.setContent(html+showHowHtml);
 
}
}]);
 
doh.run();
});
</script>
<style>
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
 
.box {
border: 1px solid black;
height: 190px;
width: 80%;
overflow: auto;
}
 
.red {
color: red;
}
 
.dojoxTestWidget {
border: 1px dashed red;
background-color: #C0E209 ;
}
</style>
</head>
<body class='tundra'>
<h1>dojox.layout.ContentPane</h1>
<h3>As dojox ContentPane is derived from dijit ContentPane, make sure that the dijit test passes before running this test</h3>
<h3 class='red'>Test relies on a php page as backend, so you need php installed on your server</h3>
 
<div class='box' dojoType="dojox.layout.ContentPane" id='parsedPane'>
Initial value
</div>
 
<table id='tableTest' class='box'>
<thead>
<tr>
<td></td>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
<tbody>
</table>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/layout/tests/test_BorderContainer.html
New file
0,0 → 1,54
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.layout.BorderContainer Test</title>
 
 
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
 
<script type="text/javascript">
dojo.require("dojox.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
</script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../css/dijitTests.css";
</style>
</head>
<body>
<h2>dojox.layout.BorderContainer tests</h2>
<p>Basic layout</p>
 
<div dojoType="dojox.layout.BorderContainer"
style="border: 2px solid black; width: 90%; height: 300px; padding: 10px;"
>
<div dojoType="dijit.layout.ContentPane" position="left" style="background-color: #acb386; width: 100px;">
left
</div>
<div dojoType="dijit.layout.ContentPane" position="right" style="background-color: #acb386; width: 100px;">
right
</div>
<div dojoType="dijit.layout.ContentPane" position="top" style="background-color: #b39b86; height: 100px;">
top bar
</div>
<div dojoType="dijit.layout.ContentPane" position="bottom" style="background-color: #b39b86; height: 100px;">
bottom bar
</div>
<div dojoType="dijit.layout.ContentPane" position="center" style="background-color: #f5ffbf; padding: 10px;">
main panel with <a href="http://www.dojotoolkit.org/">a link</a>.<br />
(to check we're copying children around properly).<br />
<select dojoType="dijit.form.FilteringSelect">
<option value="1">foo</option>
<option value="2">bar</option>
<option value="3">baz</option>
</select>
Here's some text that comes AFTER the combo box.
</div>
</div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/layout/tests/images/blank.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/layout/tests/images/blank.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/layout/tests/images/gridUnderlay.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/layout/tests/images/gridUnderlay.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/layout/tests/images/dojoLogo.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/layout/tests/images/dojoLogo.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/layout/tests/images/testImage.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/layout/tests/images/testImage.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/layout/tests/_script.html
New file
0,0 → 1,9
<script type="text/javascript">
console.log('foo - whenever');
dojo.addOnLoad(function(){
console.warn('foo - onload');
});
</script>
<p>
bar baz
</p>
/trunk/api/js/dojo1.0/dojox/layout/tests/test_FloatingPane.html
New file
0,0 → 1,144
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.layout.FloatPane - simplest extension on TitlePane ... ever.</title>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true" ></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
<script type="text/javascript" src="../FloatingPane.js"></script>
<script type="text/javascript">
// dojo.require("dojox.layout.FloatingPane");
dojo.require("dijit.form.ComboBox");
dojo.require("dijit.form.Button");
dojo.require("dojo.parser"); // scan page for widgets
</script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../resources/FloatingPane.css";
@import "../resources/ResizeHandle.css";
 
/* body { background:url('gridUnderlay.png') top left; } */
 
.alternateDock {
position:absolute;
background-color:#ededed;
right:0px; top:0px;
border-left:1px solid #ccc;
height:100%;
}
#alternateDock ul.dojoxDockList { display:block; }
.testFixedSize {
width:300px;
height:200px;
padding:7px;
}
</style>
<script type="text/javascript">
 
function makeFloater() {
// programatically created FloatingPane with srcNode ref
var tmp = new dojox.layout.FloatingPane({
title: "dynamically created ...",
id:"floater3",
closeable:true,
resizable:true,
dockable: false
},"nonFloater");
tmp.startup();
}
 
var mi = 1;
function brandNewFloater(){
var node = document.createElement('div');
node.innerHTML = dojo.byId('contentHolder').innerHTML;
dojo.body().appendChild(node);
dojo.addClass(node,"testFixedSize");
var tmp = new dojox.layout.FloatingPane({
title:" New Floater #"+(mi++),
dockable: false,
maxable: true,
closable: true,
resizable: false
},node);
tmp.startup();
tmp.resize({ w:300, h:175 });
}
 
var vpx, vpy = null;
dojo.addOnLoad(makeFloater);
 
</script>
 
</head>
<body>
 
 
<a href="javascript:dijit.byId('floater1').hide()">hide first pane</a> |
<a href="javascript:dijit.byId('floater1').show()">show first pane</a> |
<a href="javascript:dijit.byId('floater1').minimize()">minimize 'uncloseable, dockable' pane pane</a> |
<a href="javascript:brandNewFloater()">new floater</a>
 
<div dojoType="dojox.layout.FloatingPane" title="Floater test ... " resizable="true" id="floater1" style="width:200px;" duration="300">
<p style="margin:0; padding:10px;">I am the content to be floated around</p>
</div>
 
<div dojoType="dojox.layout.FloatingPane" title="un-closable, dockable" style="width:200px; position:absolute; " closable="false" id="floater2">
<p style="padding:8px; margin:0;">
I am dockable, though I have no dockTo="" attribute. I will create or use an existing dock
on the bottom of the screen.
<br><br>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In porta. Etiam mattis libero nec ante. Nam
porta lacus eu ligula. Cras mauris. Suspendisse vel augue. Vivamus aliquam orci ut eros. Nunc
eleifend sagittis turpis. purus purus in nibh. Phasellus in nunc.
</p>
</div>
<div id="nonFloater" style="width:200px;" duration="750" >
<p style="padding:8x; margin:2px;">
I am made into a FloatingPane in dojo.addOnLoad();<br><br>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In porta. Etiam mattis libero nec ante. Nam
porta lacus eu ligula. Cras mauris. Suspendisse vel augue. Vivamus aliquam orci ut eros. Nunc eleifend
sagittis turpis. purus purus in nibh. Phasellus in nunc.
</p>
</div>
 
<div title="Alt Dock 1" style="width:100px; height:100px; float:left;"
dojoType="dojox.layout.FloatingPane" duration="350" resizable="true"
dockTo="alternateDock" executeScripts="true" href="_script.html">
</div>
<div title="Alt Dock 2" dojoType="dojox.layout.FloatingPane" resizable="true" style="width:200px; float:left;" duration="350" dockTo="alternateDock">
<p style="color:#666; padding:8px; margin:0;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In porta. Etiam mattis libero nec ante. Nam
porta lacus eu ligula. Cras mauris. Suspendisse vel augue. Vivamus aliquam orci ut eros. Nunc eleifend
sagittis turpis. purus purus in nibh. Phasellus in nunc.
</p>
</div>
 
<div dojoType="dojox.layout.FloatingPane"
resizeable="false" style="width:200px; margin:0; background:#ccc; " title="foobar"
closable="false" dockable="false"><p style="padding:12px;">
This is just a pane. You cannot close me, you cannot resize me, you cannot minimize me.
</p>
</div>
 
<div dojoType="dojox.layout.FloatingPane"
title="remote pane" href="../../../dijit/tests/layout/doc0.html"
style="width:250px; height:250px; background:#fff; margin:0; "
></div>
 
<div dojoType="dojox.layout.Dock" id="alternateDock" class="alternateDock"></div>
 
<div style="display:none;" id="contentHolder"><p style="padding:13px; margin:0;">
I am content. I am hidden right now. This content is used to populate the newly created
node being attached to the DOM to insert a new FloatingPane without a srcNodeRef. This
node is not being manipulated, just having it's innerHTML read. For demonstration purposes.
</p>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/layout/tests/test_SizingPane.html
New file
0,0 → 1,170
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.layout.SizingPane</title>
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("dijit.dijit");
dojo.require("dojo.fx");
</script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
 
body { background:#ededed; color:#666; }
 
#nav {
position:absolute;
top:100px;
left:10px;
width:200px;
-moz-border-radius:8pt 8pt;
background:#fff;
border:2px solid #ccc;
}
 
#box1 {
overflow:hidden;
position:absolute;
display:block;
width:25px;
height:25px;
-moz-border-radius:8pt 8pt;
radius:8pt;
-webkit-border-radius:8pt 8pt;
background:#fff;
border:2px solid #ccc;
padding:7px;
}
 
</style>
<script>
var animationMethod = "chain"; // || combine
var _showing = false;
var animG, offsetW, offsetH = null;
var box1 = null;
var boxMixin = {
startWidth: 25,
startHeight: 25,
endWidth: 320,
endHeight: 320,
duration: 300
};
 
dojo.addOnLoad(function() {
box1 = dojo.byId('box1');
centerNode(box1);
dojo.connect(box1,"onmouseover",null,"show");
dojo.connect(box1,"onmouseout",null,"hideCheck");
//dojo.connect(box1,"onmouseout",null,"hideCheck");
//dojo.connect(but1,"onclick",null,"show");
});
 
function hideCheck(node) {
if (_showing) {
setTimeout("hide('box1')",125);
}
}
 
function centerNode(node) {
var viewport = dijit.getViewport();
var mb = dojo.marginBox(node);
var style = node.style;
offsetW = mb.w - style.width;
offsetH = mb.h - style.height;
style.left = (viewport.l + (viewport.w - mb.w)/2) + "px";
style.top = (viewport.t + (viewport.h - mb.h)/2) + "px";
}
 
function doUnderlay() {
console.debug('make underlay');
 
}
 
function show() {
if (_showing) { return; }
if (animG && animG.status == "playing") { animG.stop(); }
_showing = true;
var viewport = dijit.getViewport();
 
var newLeft = (viewport.l + (viewport.w - boxMixin.endWidth)/2);
var newTop = (viewport.t + (viewport.h - boxMixin.endHeight)/2);
 
var style = box1.style;
var anim1 = dojo.animateProperty({
node: box1,
duration: boxMixin.duration/2,
properties: {
width: { /* start: boxMixin.startWidth, */ end: boxMixin.endWidth, unit:"px" },
left: { end: newLeft, unit:"px" }
},
beforeBegin: doUnderlay()
});
var anim2 = dojo.animateProperty({
node: box1,
duration: boxMixin.duration/2,
properties: {
height: { /*start: boxMixin.startHeight, */ end: boxMixin.endHeight, unit:"px" },
top: { end: newTop, unit: "px" }
},
onEnd: function() { _showing = true; }
 
});
animG = dojo.fx[animationMethod]([anim1,anim2]).play();
// chain:
// animate width / left position
// animate height / top position
// onend: fadeIn content?
}
 
function hide(node) {
if (!_showing) return;
if (animG && animG.status() == "playing") { animG.stop(); }
var viewport = dijit.getViewport();
var newLeft = (viewport.l + (viewport.w - boxMixin.startWidth)/2);
var newTop = (viewport.t + (viewport.h - boxMixin.startHeight)/2);
 
var style = node.style;
var anim1 = dojo.animateProperty({
node: box1,
duration: boxMixin.duration/2,
properties: {
width: { end: boxMixin.startWidth, unit:"px" },
left: { end: newLeft, unit:"px" }
}
});
var anim2 = dojo.animateProperty({
node: box1,
duration: boxMixin.duration/2,
properties: {
height: { end: boxMixin.startHeight, unit:"px" },
top: { end: newTop, unit: "px" }
},
onEnd: function() { _showing = false; }
});
// if we chain, do anim2 first [because height/top is how anim2 in show() ends]
animG = dojo.fx[animationMethod]([anim2,anim1]).play();
}
</script>
 
</head>
<body class="tundra">
 
<h1 class="testTitle">dojox.layout.SizingPane</h1>
 
<p>This is simply a test / example. There is no <i>real</i> dojox.layout.SizingPane, but this code
should/might become part of a dojox.fx.toggle class ... it's just "neat", isn't it?</p>
 
<div id="box1">
lorem. lorem. lorem.
</div>
 
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/fx/style.js
New file
0,0 → 1,221
if(!dojo._hasResource["dojox.fx.style"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.fx.style"] = true;
dojo.provide("dojox.fx.style");
dojo.experimental("dojox.fx.style");
//
// summary: dojox.fx CSS Class _Animations:
//
// description: a set of functions to animate properties based on
// normalized CSS class definitions.
//
// provides: addClass, removeClass, and toggleClass
//
dojo.require("dojox.fx._base");
 
// FIXME: should the call signatures match dojo.addClass/removeClass/toggleClass and extend
// by having a third (or fourth) param to mix in additional _Animation args for advanced
// usage (delay: curve: repeat: easing: etc ... )
 
dojox.fx.addClass = function(/*dojox.fx._arg.StyleArgs*/ args){
// summary: Animate the effects of adding a class to a node
// description:
// Creates an animation that will animate
// the properties of a node to the properties
// defined in a standard CSS .class definition.
// (calculating the differences itself)
//
// example:
//
// .bar { line-height: 12px; }
// .foo { line-height: 40px; }
// <div class="bar" id="test">
// Multi<br>line<br>text
// </div>
//
// // animate to line-height:40px
// dojo.fx.addClass({ node:"test", cssClass:"foo" }).play();
//
var node = (args.node = dojo.byId(args.node));
 
var pushClass = (function(){
// summary: onEnd we want to add the class to the node
// (as dojo.addClass naturally would) in case our
// class parsing misses anything the browser would
// otherwise interpret. this may cause some flicker,
// and will only apply the class so children can inherit
// after the animation is done (potentially more flicker)
var innerNode = node; // FIXME: why do we do this like this?
return function(){
dojo.addClass(innerNode, args.cssClass);
innerNode.style.cssText = _beforeStyle;
}
})();
 
// _getCalculatedStleChanges is the core of our style/class animations
var mixedProperties = dojox.fx._getCalculatedStyleChanges(args,true);
var _beforeStyle = node.style.cssText;
var _anim = dojo.animateProperty(dojo.mixin({
properties: mixedProperties
},args));
dojo.connect(_anim,"onEnd",_anim,pushClass);
return _anim; // dojo._Animation
};
 
dojox.fx.removeClass = function(/*dojox.fx._arg.StyleArgs*/ args){
// summary: Animate the effects of removing a class from a node
// description:
// Creates an animation that will animate the properties of a
// node (args.node) to the properties calculated after removing
// a standard CSS className from a that node.
//
// calls dojo.removeClass(args.cssClass) onEnd of animation
//
// standard dojo._Animation object rules apply.
//
// example:
// | // animate the removal of "foo" from a node with id="bar"
// | dojox.fx.removeClass({
// | node: "bar",
// | cssClass: "foo"
// | }).play();
 
var node = (args.node = dojo.byId(args.node));
 
var pullClass = (function(){
// summary: onEnd we want to remove the class from the node
// (as dojo.removeClass naturally would) in case our class
// parsing misses anything the browser would otherwise
// interpret. this may cause some flicker, and will only
// apply the class so children can inherit after the
// animation is done (potentially more flicker)
//
var innerNode = node;
return function(){
dojo.removeClass(innerNode, args.cssClass);
innerNode.style.cssText = _beforeStyle;
}
})();
 
var mixedProperties = dojox.fx._getCalculatedStyleChanges(args,false);
var _beforeStyle = node.style.cssText;
var _anim = dojo.animateProperty(dojo.mixin({
properties: mixedProperties
},args));
dojo.connect(_anim,"onEnd",_anim,pullClass);
return _anim; // dojo._Animation
};
 
dojox.fx.toggleClass = function(/*DomNode|String*/node, /*String*/cssClass, /*Boolean?*/condition){
// summary:
// Animate the effects of Toggling a class on a Node
//
// description:
// creates an animation that will animate the effect of
// toggling a class on or off of a node.
// Adds a class to node if not present, or removes if present.
// Pass a boolean condition if you want to explicitly add or remove.
// node:
// The domNode (or string of the id) to toggle
// cssClass:
// String of the classname to add to the node
// condition:
// If passed, true means to add the class, false means to remove.
//
// example:
// | // add the class "sampleClass" to a node id="theNode"
// | dojox.fx.toggleClass("theNode","sampleClass",true).play();
// example:
// | // toggle the class "sampleClass" on the node id="theNode"
// | dojox.fx.toggleClass("theNode","sampleClass").play();
if(typeof condition == "undefined"){
condition = !dojo.hasClass(node, cssClass);
}
return dojox.fx[(condition ? "addClass" : "removeClass")]({ node: node, cssClass:cssClass }); // dojo._Animation
// TODO: support 4th param animMixin to allow passing of easing and duration and other _Animtion options
};
 
dojox.fx._allowedProperties = [
// summary:
// this is our pseudo map of properties we will check for.
// it should be much more intuitive. a way to normalize and
// "predict" intent, or even something more clever ...
// open to suggestions.
 
// no-brainers:
"width",
"height",
// only if position = absolute || relative?
"left", "top", "right", "bottom",
// these need to be filtered through dojo.colors?
// "background", // normalize to:
/* "backgroundImage", */
// "backgroundPosition", // FIXME: to be effective, this needs "#px #px"?
"backgroundColor",
 
"color",
 
// "border",
"borderBottomColor", "borderBottomWidth",
"borderTopColor","borderTopWidth",
"borderLeftColor","borderLeftWidth",
"borderRightColor","borderRightWidth",
 
// "padding", // normalize to:
"paddingLeft", "paddingRight", "paddingTop", "paddingBottom",
// "margin", // normalize to:
"marginLeft", "marginTop", "marginRight", "marginBottom",
 
// unit import/delicate?:
"lineHeight",
"letterSpacing",
"fontSize"
];
 
dojox.fx._getStyleSnapshot = function(/* Object */cache){
// summary:
// uses a dojo.getComputedStyle(node) cache reference and
// iterates through the 'documented/supported animate-able'
// properties.
//
// returns: Array
// an array of raw, calculcated values (no keys), to be normalized/compared
// elsewhere
return dojo.map(dojox.fx._allowedProperties,function(style){
return cache[style]; // String
}); // Array
};
 
dojox.fx._getCalculatedStyleChanges = function(/*dojox.fx._arg.StyleArgs*/ args, /*Boolean*/addClass){
// summary: calclate the difference in style properties between two states
// description:
// calculate and normalize(?) the differences between two states
// of a node (args.node) by quickly adding or removing a class, and
// iterateing over the results of dojox.fx._getStyleSnapshot()
//
// addClass:
// true to calculate what adding a class would do,
// false to calculate what removing the class would do
 
var node = (args.node = dojo.byId(args.node));
var compute = dojo.getComputedStyle(node);
 
// take our snapShots
var _before = dojox.fx._getStyleSnapshot(compute);
dojo[(addClass ? "addClass" : "removeClass")](node,args.cssClass);
var _after = dojox.fx._getStyleSnapshot(compute);
dojo[(addClass ? "removeClass" : "addClass")](node,args.cssClass);
 
var calculated = {};
var i = 0;
dojo.forEach(dojox.fx._allowedProperties,function(prop){
if(_before[i] != _after[i]){
// FIXME: the static unit: px is not good, either. need to parse unit from computed style?
calculated[prop] = { end: parseInt(_after[i]) /* start: parseInt(_before[i]), unit: 'px' */ };
}
i++;
});
return calculated;
};
 
}
/trunk/api/js/dojo1.0/dojox/fx/README
New file
0,0 → 1,69
-------------------------------------------------------------------------------
dojox.fx
-------------------------------------------------------------------------------
Version 1.0.0
Release date: 10/31/2007
-------------------------------------------------------------------------------
Project state:
prototype / expermental
-------------------------------------------------------------------------------
Credits
Peter Higgins (dante)
Jonathan Bond-Caron (jbondc@gmail.com)
Shane O'Sullivan (shaneosullivan1@gmail.com)
-------------------------------------------------------------------------------
Project description
 
dojox.fx provides a class of animation effects to use, and
other animation addons to dojo base.
 
-------------------------------------------------------------------------------
Dependencies:
 
dojox.fx requires dojo (core) and the dojo.fx package
dojox.fx.easing requires only dojo core.
-------------------------------------------------------------------------------
Documentation
 
existing API surface:
 
dojox.fx._base:
- dojox.fx.crossFade - crossfade two nodes easily
- dojox.fx.sizeTo - size a node about it's center to a new width/height
- dojox.fx.slideBy - slide a node by a t,l offset
- dojox.fx.highlight - animates the background color of a node, and returns
it to the color it was.
 
(all use standard _Animation properties, like duration, easing, node, etc)
 
dojox.fx._core:
- dojox.fx._Line - a 2-d _Line implementation, backwards compatible with
dojo._Line ... you might could safely do something akin to
dojo._Line.prototype = dojox.fx._Line.prototype;
and enable this for all dojo _Animations?
 
dojox.fx.style: - experimental CSS animation via class definitions
- dojox.fx.addClass - animate the effects of applying a class to a node
- dojox.fx.removeClass - " " " " removing a class from a node
- dojox.fx.toggleClass - wrapper for addClass/removeClass
 
dojox.fx.easing: - a collection of easing functions to use
this is a "stand alone" class, and can be used via:
dojo.require("dojox.fx.easing");
and provides:
dojo.fx.easing.easeIn/easeOut/easeInOut
to use in an _Animation easing: property
 
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/dojo/dojox/trunk/fx.js
http://svn.dojotoolkit.org/dojo/dojox/trunk/fx/*
 
Install into the following directory structure:
/dojox/fx/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
/trunk/api/js/dojo1.0/dojox/fx/easing.js
New file
0,0 → 1,42
if(!dojo._hasResource["dojox.fx.easing"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.fx.easing"] = true;
dojo.provide("dojox.fx.easing");
/*
dojox.fx.easing is in this little file so you don't need dojox.fx to utilize this.
dojox.fx has a lot of fun animations, but this module is optimized for size ...
 
*/
dojox.fx.easing = {
// summary: Collection of easing functions to use beyond the default dojo._defaultEasing
//
// description:
// Easing functions are used to manipulate the iteration through
// an _Animation's _Line. _Line being the properties of an Animation,
// and the easing function progresses through that Line determing
// how quickly (or slowly) it should go.
//
// example:
// dojo.require("dojox.fx.easing");
// var anim = dojo.fadeOut({
// node: 'node',
// duration: 2000,
// easing: dojox.fx.easing.easeIn
// }).play();
//
easeIn: function(/* Decimal? */n){
// summary: an easing function that speeds an _Animation up closer to end
return Math.pow(n, 3);
},
 
easeOut: function(/* Decimal? */n){
// summary: an easing function that slows an _Animation down towards end
return (1 - Math.pow(1-n,3));
},
 
easeInOut: function(/* Decimal? */n){
// summary: an easing function that "humps" in the middle of an _Animation?
return ((3 * Math.pow(n, 2)) - (2 * Math.pow(n, 3)))
}
};
 
}
/trunk/api/js/dojo1.0/dojox/fx/_core.js
New file
0,0 → 1,60
if(!dojo._hasResource["dojox.fx._core"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.fx._core"] = true;
dojo.provide("dojox.fx._core");
 
dojox.fx._Line = function(start, end){
// summary: a custom _Line to accomodate multi-dimensional values
//
// description:
// a normal dojo._Line is the curve, and does Line(start,end)
// for propertyAnimation. as we make more complicatied animations, we realize
// some properties can have 2, or 4 values relevant (x,y) or (t,l,r,b) for example
//
// this function provides support for those Lines, and is ported directly from 0.4
// this is a lot of extra code for something so seldom used, so we'll put it here as
// and optional core addition. you can create a new line, and use it during onAnimate
// as you see fit.
//
// start: Integer|Array
// An Integer (or an Array of integers) to use as a starting point
// end: Integer|Array
// An Integer (or an Array of integers) to use as an ending point
//
// example: see dojox.fx.smoothScroll
//
// example:
// | // this is 10 .. 100 and 50 .. 500
// | var curve = new dojox.fx._Line([10,50],[100,500]);
// | // dojo._Animation.onAnimate is called at every step of the animation
// | // to define current values. this _Line returns an array
// | // at each step. arguments[0] and [1] in this example.
//
this.start = start;
this.end = end;
if(dojo.isArray(start)){
// multi-dimensional branch
var diff = [];
dojo.forEach(this.start, function(s,i){
diff[i] = this.end[i] - s;
}, this);
this.getValue = function(/*float*/ n){
var res = [];
dojo.forEach(this.start, function(s, i){
res[i] = (diff[i] * n) + s;
}, this);
return res; // Array
}
}else{
// single value branch, document here for both branches:
var diff = end - start;
this.getValue = function(/*float*/ n){
// summary: Returns the point on the line, or an array of points
// n: a floating point number greater than 0 and less than 1
// returns: Mixed
return (diff * n) + this.start; // Decimal
}
}
};
 
}
/trunk/api/js/dojo1.0/dojox/fx/tests/test_easing.html
New file
0,0 → 1,107
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.fx.easing functions:</title>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true" ></script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
 
.block {
width:200px;
height:100px;
background:#666;
border:1px solid #ccc;
display:block;
color:#fff;
text-align:center;
}
</style>
<script type="text/javascript">
dojo.require("dojo.fx"); // chain and combine should be in core :) (when they work)
dojo.require("dojox.fx.easing");
 
 
var allAnim = null;
dojo.addOnLoad(function(){
 
var easeInAnim = dojo.fx.chain([
dojo.fadeOut({
node: 'easeIn',
duration:2000,
easing: dojox.fx.easing.easeIn
}),
dojo.fadeIn({
node: 'easeIn',
duration:2000,
easing: dojox.fx.easing.easeIn
})
]);
 
 
var easeOutAnim = dojo.fx.chain([
dojo.fadeOut({
node: 'easeOut',
duration:2000,
easing: dojox.fx.easing.easeOut
}),
dojo.fadeIn({
node: 'easeOut',
duration:2000,
easing: dojox.fx.easing.easeOut
})
]);
 
var easeInOutAnim = dojo.fx.chain([
dojo.fadeOut({
node: 'easeInOut',
duration:2000,
easing: dojox.fx.easing.easeInOut
}),
dojo.fadeIn({
node: 'easeInOut',
duration:2000,
easing: dojox.fx.easing.easeInOut
})
]);
 
dojo.connect(dojo.byId('easeIn'),"onclick",easeInAnim,"play");
dojo.connect(dojo.byId('easeOut'),"onclick",easeOutAnim,"play");
dojo.connect(dojo.byId('easeInOut'),"onclick",easeInOutAnim,"play");
 
// argh! FIXME: combine and chain are destructive to the animations. :(
// allAnim = dojo.fx.combine([easeInAnim,easeOutAnim,easeInOutAnim]);
allAnim = { play: function(){
console.log("can't do this via fx.combine - destructive");
easeInAnim.play();
easeOutAnim.play();
easeInOutAnim.play();
}
};
 
}); // dojo.addOnLoad
</script>
</head>
<body class="tundra">
 
<h1 class="testTitle">dojox.fx.easing function tests:</h1>
 
(click block to play animation, or <a href="#" onclick="allAnim.play()">here to do all three</a>)
 
<div id="easeIn" class="block">dojox.fx.easing.easeIn</div>
<br><br>
<div id="easeOut" class="block">dojox.fx.easing.easeOut</div>
<br><br>
<div id="easeInOut" class="block">dojox.fx.easing.easeInOut</div>
<p>
dojox.fx.easing is stand-alone, and does not require the dojox.fx base files.
</p>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/fx/tests/test_highlight.html
New file
0,0 → 1,41
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.fx.highlight</title>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true"></script>
<script type="text/javascript">
dojo.require("dojox.fx");
</script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
</head>
<body class="tundra">
 
<h1 class="testTitle">dojox.fx.highlight tests</h1>
 
<div id="attention" style="position:absolute; left:300px; top:200px; padding:10px;" >
<h3>This is the default highlight</h3>
</div>
 
<div id="attention2" style="position:absolute; left:300px; top:80px; padding:10px;" >
<h3>BRING ATTENTION HERE!</h3>
</div>
 
<div id="attention3" style="position:absolute; left:350px; top:150px; padding:10px; background-color:#CCCCCC" >
<h3>Highlight me</h3>
</div>
 
<a href="javascript:void(0)" onClick="dojox.fx.highlight({node:'attention'}).play()">test #1 (default)</a>
<br>
<a href="javascript:void(0)" onClick="dojox.fx.highlight({node:'attention', repeat:1}).play()">test #2 (default - play twice)</a>
<br>
<a href="javascript:void(0)" onClick="dojox.fx.highlight({node:'attention2', color:'#0066FF', duration:800}).play()">test #3</a>
<br>
<a href="javascript:void(0)" onClick="dojox.fx.highlight({node:'attention3', color:'#0066FF', duration:800}).play()">test #4</a>
 
</body></html>
/trunk/api/js/dojo1.0/dojox/fx/tests/test_crossFade.html
New file
0,0 → 1,145
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.fx - animation sets to use!</title>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true" ></script>
<script type="text/javascript" src="../_base.js"></script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
#crossfade {
position:absolute;
top:0;
left:300px;
border:2px solid #ededed;
width:50px; height:50px;
background:#fff;
text-align:center;
}
table tr { padding:5px; margin:5px; border:1px solid #ccc; }
 
.box {
width:75px; height:75px; float:left;
border:1px solid #ededed;
padding:20px;
background-color:#fee;
}
.two { background-color:#c7bedd; }
.nopad { padding:0 !important;
width:100px; height:100px; border:0;
}
.hidden {
opacity:0;
}
</style>
<script type="text/javascript">
dojo.require("dijit.form.Button");
dojo.require("dijit.TitlePane");
function basicXfade(){
dojox.fx.crossFade({
nodes: [dojo.byId('node1'),dojo.byId('node2')],
duration: 1000
}).play();
};
 
function absoluteXfade(){
dojox.fx.crossFade({
nodes: ["node3","node4"],
duration:1000
}).play();
};
 
var _anim;
function simpleLoop(){
dojo.byId('button').disabled = "disabled";
_anim = dojox.fx.crossFade({
nodes: ["node5","node6"],
duration:1000
});
dojo.connect(_anim,"onEnd","simpleLoop");
_anim.play(500);
};
function stopLoop(){ _anim.stop(); }
 
function buttonExample(){
dojox.fx.crossFade({
nodes: [
// FIXME: fails in ie6?!?
dijit.byId('node7').domNode,
dijit.byId('node8').domNode
],
duration: 350
}).play();
}
 
dojo.addOnLoad(function(){
// this is a hack to make nodes with class="hidden" hidden
// because ie6 is a horrible wretched beast
dojo.query(".hidden").forEach(function(node){
dojo.style(node,"opacity","0");
});
 
 
});
 
</script>
</head>
<body class="tundra">
<h1 class="testTitle">dojox.fx.crossFade test</h1>
 
<h3>a simple demonstration of two nodes fading simultaneously</h3>
<div>
<input type="button" onclick="basicXfade()" value="run" />
<div style="padding:20px">
<div id="node1" style="display:inline;" class="box hidden">box1</div>
<div id="node2" class="box">box2</div>
</div>
<br style="clear:both">
</div>
 
<h3>two nodes with position:relative in a container with position:absolute, crossfading together.</h3>
<input type="button" onclick="absoluteXfade()" value="run" />
<div>
<div style="width:100px; height:100px; position:relative; border:1px solid #666; ">
<div id="node3" style="position:absolute; top:0; left:0;" class="box nopad hidden">box one</div>
<div id="node4" style="position:absolute; top:0; left:0;" class="box two nopad">box two</div>
</div>
<br style="clear:both">
</div>
 
<h3>simple looping crossfade</h3>
<input type="button" onclick="simpleLoop()" value="run" id="button" />
<div>
<div style="padding:20px;">
<div id="node5" class="box nopad">box one</div>
<div id="node6" class="box two nopad hidden">box two</div>
</div>
<br style="clear:both">
</div>
 
<!-- FIXME: acting oddly, only in IE though
<h3>An example of cross-fading a dijit.form.Button</h3>
<input type="button" onclick="buttonExample()" value="run" id="button" />
<div>
<div style="position:relative;">
<div dojoType="dijit.TitlePane" id="node7"
style="position:absolute; top:0; left:0;">Lorem content two</div>
<div dojoTYpe="dijit.TitlePane" id="node8" class="hidden"
style="position:absolute; top:0; left:0;">Lorem content one</div>
</div>
<br style="clear:both;">
</div>
-->
 
<h3>that's all, folks...</h3>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/fx/tests/test_slideBy.html
New file
0,0 → 1,58
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.fx - animation sets to use!</title>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true" ></script>
<script type="text/javascript" src="../_base.js"></script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
 
#sizeToTest {
position:absolute;
top:0;
left:300px;
border:2px solid #ededed;
width:50px; height:50px;
background:#fff;
text-align:center;
}
 
</style>
<script type="text/javascript">
function chainTest(){
// FIXME: not recalculating mixin in init? or not re-mixing, rather.
// happens to a lot of propertyAnimations, actually when chaining, with a
// fixed 'start' property in the mixin. see _base/fx.js:slideBy()
dojo.fx.chain([
dojox.fx.slideBy({ node: 'sizeToTest', top:50, left:50, duration:400 }),
dojox.fx.slideBy({ node: 'sizeToTest', top:25, left:-25, duration:400 })
]).play();
}
</script>
</head>
<body class="tundra">
<h1 class="testTitle">dojox.fx.slideBy test</h1>
 
<a href="#" onclick="javascript:dojox.fx.slideBy({node:'sizeToTest', top:50, left:50, duration:200 }).play()">top: 50, left:50</a>
<a href="#" onclick="javascript:dojox.fx.slideBy({node:'sizeToTest', top:-50, left:50, duration:400 }).play()">top:-50, left:50</a>
<a href="#" onclick="javascript:dojox.fx.slideBy({node:'sizeToTest', top:-50, left:-50, duration:400 }).play()">top:-50, left:-50</a>
<a href="#" onclick="javascript:dojox.fx.slideBy({node:'sizeToTest', top:50, left:-50, duration:400 }).play()">top:50, left:-50</a>
<a href="#" onclick="javascript:chainTest()">chainTest</a>
 
<div id="sizeToTest">
lorem. ipsum.
</div>
HTML AFTER
<br>
 
 
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/fx/tests/test_sizeTo.html
New file
0,0 → 1,140
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.fx.sizeTo | experimental fx add-ons for the Dojo Toolkit</title>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true" ></script>
<script type="text/javascript" src="../_base.js"></script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
.testBox {
position:absolute;
top:0; left:0;
width:50px;
height:50px;
background:#ededed;
border:1px solid #b7b7b7;
-moz-border-radius:6pt;
-webkit-border-radius:5pt;
overflow:hidden;
}
</style>
<script type="text/javascript">
var test1 = function(e){
// this is our click test,
dojox.fx.sizeTo({
node: e.target,
width: 120,
height:120,
duration:250
}).play(5);
};
var testundo = function(e){
dojox.fx.sizeTo({
node: e.target,
width:50,
height:50,
duration:320
}).play(5);
};
var test2 = function(e){
dojox.fx.sizeTo({
node: e.target,
width: 120,
height:120,
duration:120,
method:"combine"
}).play(5);
};
 
var noIdTest = function(){
var myNode = dojo.query(".noIdHere")[0]; // first one wins
if(myNode){
// mmm, fake events (all we're using is the target anyway ... )
(!dojo.hasClass(myNode,"testRun") ? test2 : testundo)({ target: myNode });
dojo.toggleClass(myNode,"testRun");
}
};
var init = function(){
// lets setup out connections, etc ...
dojo.connect(dojo.byId("sizer1"),"onmousedown","test1");
dojo.connect(dojo.byId("sizer1"),"onmouseup","testundo"); // generic resest
// did you know dojo normalizes onmouseenter onmouseleave!?!? neat. ie got _one_ thing right.
dojo.connect(dojo.byId("sizer2"),"onmouseenter","test2");
dojo.connect(dojo.byId("sizer2"),"onmouseout","testundo");
// example using dojo.query to get a couple of nodes and roll into one anim
var hasRun = false;
dojo.connect(dojo.byId("sizer3"),"onclick",function(e){
var _anims = [];
dojo.query(".testBox").forEach(function(n){
_anims.push(
dojox.fx.sizeTo({ node: n,
width: ( hasRun ? "50" : "150"),
height: ( hasRun ? "50" : "150"),
method:"chain",
duration:720
})
);
});
hasRun=!hasRun;
var anim = dojo.fx.combine(_anims);
anim.play();
});
};
dojo.addOnLoad(init);
</script>
</head>
<body class="tundra">
<h1 class="testTitle">dojox.fx.sizeTo test</h1>
<p>quick sizeTo API overview:</p>
 
<pre>
dojox.fx.sizeTo({
// basic requirements:
node: "aDomNodeId", // or a domNode reference
width: 200, // measured in px
height: 200, // measured in px
method: "chain" // is default, or "combine"
});
</pre>
<p>
little test blocks (works in Opera, FF/win/mac:
</p>
 
<div style="position:relative; height:60px; width:600px; margin:0 auto;">
<div id="sizer1" class="testBox">
mouse down / mouse up
</div>
<div id="sizer2" class="testBox" style="left:60px;" >
hover / exit
</div>
<div class="testBox noIdHere" style="left:120px; ">
<a href="javascript:noIdTest()">noIdTest()</a>
</div>
<div class="testBox" id="sizer3" style="left:180px;">
all of em'
</div>
</div>
<br style="clear:both;">
(click the box labeled "all of em'" again to reset all nodes)
HTML AFTER
<br>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/fx/tests/test_scroll.html
New file
0,0 → 1,93
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.fx.scroll</title>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true"></script>
<!-- <script type="text/javascript" src="../scroll.js"></script> -->
<script type="text/javascript">
dojo.require("dojox.fx.easing");
dojo.require("dojox.fx.scroll");
 
function gotoName(name){
// summary; searches for a <a name=""></a> attrib, and scrolls to it
dojo.query('a[name="'+name+'"]').forEach(function(node){
// first one wins
var anim = dojox.fx.smoothScroll({
node: node,
win:window,
duration:300,
easing:dojox.fx.easing.easeOut
}).play();
return;
});
}
 
dojo.addOnLoad(function(){
/*dojo.connect(dojo.byId("goToHeader0"), "onclick", function (e) {
var h2s = dojo.html.iframeContentDocument(dojo.byId("embed0")).getElementsByTagName('h2');
var h2 = h2s[h2s.length-1];
var anm = new dojo.lfx.smoothScroll(h2,dojo.html.iframeContentWindow(dojo.byId("embed0")),null,500);
anm.play();
});
*/
 
dojo.connect(dojo.byId("goToHeader"), "onclick", function (e) {
var node = dojo.byId('targetHeader3');
var anim0 = dojox.fx.smoothScroll({ node: node, win: window, duration:500, easing:dojox.fx.easing.easeOut });
anim0.play();
});
 
dojo.connect(dojo.byId("goToHeader1"), "onclick", function(/* Event */e){
var node = dojo.byId('targetHeader1');
var anim0 = dojox.fx.smoothScroll({ node: node, win: window, duration:1000, easing:dojox.fx.easing.easeOut });
anim0.play();
});
});
</script>
</head>
<body class="tundra">
 
<a name="top"></a>
<h1 class="testTitle">dojox.fx.scroll tests</h1>
 
<div id="targetHeader3" style="position:absolute; left:0px; top:3000px; padding:100px;" ><h3>YOU FOUND ME!</h3>
<p>neat.</p>
</div>
 
<p>dojox.fx.scroll provides:</p>
<ul>
<li>dojox.fx.smoothScroll()</li>
</ul>
which will create and return a dojo._Animation to scroll
a window to a desired offset.
<p></p>
<h2><code>getScroll</code></h2>
<p>
Scroll top: <span id="scrollTop">0</span><br>
Scroll left: <span id="scrollLeft">0</span>
</p>
 
<table style="position:fixed;top:20px;right:20px;">
<tr><td>
<!-- <input type="button" id="goToHeader0" value="scroll only the iframe (to a node in iframe)"><br> -->
<input type="button" id="goToHeader" value="scroll to to far node"><br>
<input type="button" id="goToHeader1" value="scroll to a node in top window">
</td></tr>
</table>
 
<p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p><p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p><p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p><p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p><p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p>
 
 
<h2 id='targetHeader1'><code>getElementsByClass</code></h2>
 
<p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p><p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p><p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p><p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p><p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p>
 
<h3 id='targetHeader2'>ContainsAny</h3>
<input type="button" onclick="gotoName('top');" value="back to top">
<p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p><p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p><p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p><p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p><p style="font:10pt Arial,sans-serif; color:#666;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitaerisus.</p>
 
 
</body></html>
/trunk/api/js/dojo1.0/dojox/fx/tests/_animation.css
New file
0,0 → 1,113
.testBox {
border:1px solid #333;
width:75px;
height:75px;
}
.absolutely { position:absolute;
top:0; left:0;
}
.floating {
float:left;
}
.wide {
width:200px;
}
.tall {
height:200px;
}
.tiny {
width:3px;
height:3px;
}
 
 
.black {
color:#fff;
background-color:#000;
}
 
.white {
color:#666;
background-color:#fff;
}
 
.green {
color:#000;
background-color:#eef;
}
.red {
color:#fff;
background-color:#ffe;
}
.blue {
color:#000;
background-color:#fef !important;
}
 
/* font sizes */
.baseFont {
line-height:14px;
font:12px Arial,sans-serif;
letter-spacing:0.1em;
}
 
.spacedVertical {
line-height:42px;
}
.spacedHorizontal {
letter-spacing:0.42em;
}
.fontSizeTest {
font:20px Arial,sans-serif;
}
 
/* margins */
.bigMargin {
margin:30px;
}
.noMargin {
margin:0;
}
.mediumMargin {
margin:15px;
}
.bigMarginLeft {
margin-left:150px;
}
 
/* padding */
.padded {
padding:3px;
}
.noPadding {
padding:0;
}
.topPadding {
padding-top:50px;
}
.bigPadding {
padding:30px;
}
 
/* positioning */
 
.offsetSome {
top:50px;
left:75px;
}
 
.topLeft {
top:0;
left:0;
}
.bottomRight {
bottom:0;
right:0;
}
 
.bothAxis {
top:10px;
left:10px;
right:10px;
bottom:10px;
}
/trunk/api/js/dojo1.0/dojox/fx/tests/example_Line.html
New file
0,0 → 1,82
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojoClass detail information</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
#node {
position:absolute;
top:100px; left:100px;
width:400px;
height:400px;
padding:12px;
-moz-border-radius:5pt;
overflow:hidden;
border:1px solid #333;
}
</style>
<script type="text/javascript"
djConfig="parseOnLoad: true"
src="../../../dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojox.fx.easing");
dojo.require("dojox.gfx");
 
var surface, shape, line, node;
dojo.addOnLoad(function(){
// dojo._Line is just a simple class to hold some numbers, and return a given point
// on the line as a percentage, essentially
var _line = new dojo._Line(20,75); // a holder for the numbers 100..300
console.log(_line,_line.getValue(0.5 /* Float: 0..1 */)); // should return 200
 
node = dojo.byId('node');
 
surface = dojox.gfx.createSurface(node,400,400);
shape = surface.createCircle({ cx: 200, cy: 200, r: 20 })
.setFill([0,0,255])
.setStroke({ color:[128,128,128], width: 1});
// so we just make a raw _Animation
var _anim = new dojo._Animation({
// the id of the shape
node: node,
// some easing options
easing: dojox.fx.easing.easeInOut,
// our radius start and end values
curve:_line,
// call transform on the shape with the values
onAnimate: function(){
shape.setShape({ r: arguments[0] });
},
duration:1200 // ms
// rate:100 // ms, so duration/rate iterations
});
 
 
dojo.connect(_anim,"onEnd",function(){
dojo.animateProperty({
node: node,
duration:1000,
properties: {
left: { end: 300, unit:"px" }
},
onEnd: function(){
dojo.fadeOut({ node: node, duration:3000 }).play();
}
}).play(500);
});
_anim.play(2000);
});
</script>
</head>
<body class="tundra">
<h1>animateProperty for dojox.gfx</h1>
<div id="node"></div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/fx/tests/test_animateClass.html
New file
0,0 → 1,222
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.fx.style - animatated CSS functions | The Dojo Toolkit</title>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true" ></script>
<script type="text/javascript" src="../style.js"></script><!-- debugging -->
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "_animation.css"; /* external stylesheets to enhance readability in this test */
</style>
<script type="text/javascript">
dojo.require("dojox.fx.style");
dojo.require("dijit.form.Button");
</script>
</head>
<body class="tundra">
 
<h1 class="testTitle">dojox.fx.style tests</h1>
 
<p id="fontTest">
dojox.fx.style provides a few methods to animate the changes that would occur
when adding or removing a class from a domNode.
</p>
<ul class="testUl" id="test1">
<li class="baseFont">dojox.fx.addClass(/* Object */)args); // Returns dojo._Animation</li>
<li class="baseFont">dojox.fx.removeClass(/* Object */args); // Returns dojo._Animation</li>
<li class="baseFont">dojox.fx.toggleClass(/* DomNode */node, /* String */cssClass,/* Boolean */force)</li>
</ul>
 
<button dojoType="dijit.form.Button">
spacing test
<script type="dojo/method" event="onClick">
var _anims = [];
// until dojox.fx.NodeList-fx is ready:
dojo.query("li.baseFont").forEach(function(node){
_anims.push(dojox.fx.toggleClass(node,"spacedHorizontal"));
})
dojo.fx.combine(_anims).play(5);
</script>
</button>
 
<button dojoType="dijit.form.Button">
line-height test
<script type="dojo/method" event="onClick">
var _anims = [];
// until dojox.fx.NodeList-fx is ready:
dojo.query("li.baseFont").forEach(function(node){
_anims.push(dojox.fx.toggleClass(node,"spacedVertical"));
})
dojo.fx.combine(_anims).play(5);
</script>
</button>
 
<button dojoType="dijit.form.Button">
font-size test
<script type="dojo/method" event="onClick">
var _anims = [];
// until dojox.fx.NodeList-fx is ready:
dojo.query("li.baseFont").forEach(function(node){
_anims.push(dojox.fx.toggleClass(node,"fontSizeTest"));
})
dojo.fx.combine(_anims).play(5);
</script>
</button>
 
<h2>testing sizes</h2>
 
<button dojoType="dijit.form.Button" id="addTall">
add .tall
<script type="dojo/method" event="onClick">
var delay = 500;
var _anims = [];
dojo.query("#colorTest > .testBox").forEach(function(n){
_anims.push(dojox.fx.addClass({
node:n,
cssClass:"tall",
delay: delay
}));
delay+=200;
});
this.setDisabled(true);
dijit.byId('removeTall').setDisabled(false);
dojo.fx.combine(_anims).play();
</script>
</button>
<button dojoType="dijit.form.Button" id="removeTall" disabled="true">
remove .tall
<script type="dojo/method" event="onClick">
var delay = 500;
var _anims = [];
dojo.query("#colorTest > .testBox").forEach(function(n){
_anims.push(dojox.fx.removeClass({
node:n,
cssClass:"tall",
delay: delay
}));
delay+=200;
});
this.setDisabled(true);
dijit.byId('addTall').setDisabled(false);
dojo.fx.combine(_anims).play();
</script>
</button>
<button dojoType="dijit.form.Button" id="addWide">
add .wide
<script type="dojo/method" event="onClick">
var delay = 500;
var _anims = [];
dojo.query("#colorTest > .testBox").forEach(function(n){
_anims.push(dojox.fx.addClass({
node:n,
cssClass:"wide",
delay: delay
}));
delay+=200;
});
this.setDisabled(true);
dijit.byId('removeWide').setDisabled(false);
dojo.fx.combine(_anims).play();
</script>
</button>
<button dojoType="dijit.form.Button" id="removeWide" disabled="true">
remove .wide
<script type="dojo/method" event="onClick">
var delay = 500;
var _anims = [];
dojo.query("#colorTest > .testBox").forEach(function(n){
_anims.push(dojox.fx.removeClass({
node:n,
cssClass:"wide",
delay: delay
}));
delay+=200;
});
this.setDisabled(true);
dijit.byId('addWide').setDisabled(false);
dojo.fx.combine(_anims).play();
</script>
</button>
<button dojoType="dijit.form.Button">
toggle .tiny
<script type="dojo/method" event="onClick">
var _anims = [];
// until dojox.fx.NodeList-fx is ready:
dojo.query("#colorTest > .testBox").forEach(function(node){
_anims.push(dojox.fx.toggleClass(node,"tiny"));
})
dojo.fx.combine(_anims).play(5);
</script>
</button>
<div id="colorTest">
<div id="colorTest1" class="floating testBox white"></div>
<div id="colorTest2" class="floating testBox black"></div>
<div id="colorTest3" class="floating testBox green"></div>
</div>
 
<br style="clear:both">
<h2>testing position</h2>
<p>This is a div position:relative with a position:absolute div inside. testing various t/l/b/r combos.
normal css inheritance rules apply, so setting .foo .bar if .foo was defined last in the css text, .bar
will take precedent. the below position test shows the results of this:
</p>
<button dojoType="dijit.form.Button">
.offsetSome
<script type="dojo/method" event="onClick">
dojox.fx.toggleClass("positionTest","offsetSome").play();
</script>
</button>
<button dojoType="dijit.form.Button">
.topLeft
<script type="dojo/method" event="onClick">
dojox.fx.toggleClass("positionTest","topLeft").play();
</script>
</button>
<button dojoType="dijit.form.Button">
.bottomRight
<script type="dojo/method" event="onClick">
dojox.fx.toggleClass("positionTest","bottomRight").play();
</script>
</button>
<div style="position:relative; height:175px; width:500px; border:1px solid #666;" id="positionBlock">
<div class="testBox absolutely" id="positionTest"></div>
</div>
<button dojoType="dijit.form.Button">
toggle .green
<script type="dojo/method" event="onClick">
dojox.fx.toggleClass("positionTest","green").play();
</script>
</button>
<button dojoType="dijit.form.Button">
toggle .black
<script type="dojo/method" event="onClick">
dojox.fx.toggleClass("positionTest","black").play();
</script>
</button>
<button dojoType="dijit.form.Button">
toggle .blue
<script type="dojo/method" event="onClick">
dojox.fx.toggleClass("positionTest","blue").play();
</script>
</button>
 
<p>Some properties
cannot be modified (fontFace, and so on), so to ensure the results at the end
of the animation are applied correctly and fully, the class name is set on the node
via dojo.add/removeClass().
</p>
 
</body>
</html>
 
/trunk/api/js/dojo1.0/dojox/fx/_arg.js
New file
0,0 → 1,27
if(!dojo._hasResource["dojox.fx._arg"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.fx._arg"] = true;
dojo.provide("dojox.fx._arg");
 
dojox.fx._arg.StyleArgs = function(/*Object*/ args){
// summary:
// The node and CSS class to use for style manipulations.
// node: DOMNode
// The node to manipulate
// cssClass: String
// The class to use during the manipulation
this.node = args.node;
this.cssClass = args.cssClass;
}
 
dojox.fx._arg.ShadowResizeArgs = function(/*Object*/ args){
// summary:
// The odd way to document object parameters.
// x: Integer
// the width to set
// y: Integer
// the height to set
this.x = args.x;
this.y = args.y;
}
 
}
/trunk/api/js/dojo1.0/dojox/fx/_base.js
New file
0,0 → 1,195
if(!dojo._hasResource["dojox.fx._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.fx._base"] = true;
dojo.provide("dojox.fx._base");
// summary: add-on Animations to dojo.fx
 
dojo.require("dojo.fx");
 
// convenience functions:
dojox.fx.chain = dojo.fx.chain;
dojox.fx.combine = dojo.fx.combine;
dojox.fx.wipeIn = dojo.fx.wipeIn;
dojox.fx.wipeOut = dojo.fx.wipeOut;
dojox.fx.slideTo = dojo.fx.slideTo;
 
dojox.fx.sizeTo = function(/* Object */args){
// summary: Create an animation that will size a node
// description:
// Returns an animation that will size "node"
// defined in args Object about it's center to
// a width and height defined by (args.width, args.height),
// supporting an optional method: chain||combine mixin
// (defaults to chain).
//
// - works best on absolutely or relatively positioned elements?
//
// example:
// | // size #myNode to 400px x 200px over 1 second
// | dojo.fx.sizeTo({ node:'myNode',
// | duration: 1000,
// | width: 400,
// | height: 200,
// | method: "chain"
// | }).play();
//
var node = (args.node = dojo.byId(args.node));
var compute = dojo.getComputedStyle;
 
var method = args.method || "chain";
if (method=="chain"){ args.duration = Math.floor(args.duration/2); }
var top, newTop, left, newLeft, width, height = null;
 
var init = (function(){
var innerNode = node;
return function(){
var pos = compute(innerNode).position;
top = (pos == 'absolute' ? node.offsetTop : parseInt(compute(node).top) || 0);
left = (pos == 'absolute' ? node.offsetLeft : parseInt(compute(node).left) || 0);
width = parseInt(dojo.style(node,'width'));
height = parseInt(dojo.style(node,'height'));
 
newLeft = left - Math.floor((args.width - width)/2);
newTop = top - Math.floor((args.height - height)/2);
 
if(pos != 'absolute' && pos != 'relative'){
var ret = dojo.coords(innerNode, true);
top = ret.y;
left = ret.x;
innerNode.style.position="absolute";
innerNode.style.top=top+"px";
innerNode.style.left=left+"px";
}
}
})();
init(); // hmmm, do we need to init() or just the once beforeBegin?
 
var anim1 = dojo.animateProperty(dojo.mixin({
properties: {
height: { start: height, end: args.height || 0, unit:"px" },
top: { start: top, end: newTop }
}
}, args));
var anim2 = dojo.animateProperty(dojo.mixin({
properties: {
width: { start: width, end: args.width || 0, unit:"px" },
left: { start: left, end: newLeft }
}
}, args));
 
var anim = dojo.fx[((args.method == "combine") ? "combine" : "chain")]([anim1,anim2]);
dojo.connect(anim, "beforeBegin", anim, init);
return anim; // dojo._Animation
};
 
dojox.fx.slideBy = function(/* Object */args){
// summary: Returns an animation to slide a node by a defined offset.
//
// description:
// Returns an animation that will slide a node (args.node) from it's
// current position to it's current posision plus the numbers defined
// in args.top and args.left. standard dojo.fx mixin's apply.
//
// example:
// | // slide domNode 50px down, and 22px left
// | dojox.fx.slideBy({
// | node: domNode, duration:400,
// | top: 50, left: -22
// | }).play();
 
var node = (args.node = dojo.byId(args.node));
var compute = dojo.getComputedStyle;
var top = null; var left = null;
var init = (function(){
var innerNode = node;
return function(){
var pos = compute(innerNode,'position');
top = (pos == 'absolute' ? node.offsetTop : parseInt(compute(node, 'top')) || 0);
left = (pos == 'absolute' ? node.offsetLeft : parseInt(compute(node, 'left')) || 0);
if(pos != 'absolute' && pos != 'relative'){
var ret = dojo.coords(innerNode, true);
top = ret.y;
left = ret.x;
innerNode.style.position="absolute";
innerNode.style.top=top+"px";
innerNode.style.left=left+"px";
}
}
})();
init();
var _anim = dojo.animateProperty(dojo.mixin({
properties: {
// FIXME: is there a way to update the _Line after creation?
// null start values allow chaining to work, animateProperty will
// determine them for us (except in ie6? -- ugh)
top: { /* start: top, */end: top+(args.top||0) },
left: { /* start: left, */end: left+(args.left||0) }
}
}, args));
dojo.connect(_anim,"beforeBegin",_anim,init);
return _anim; // dojo._Animation
};
 
dojox.fx.crossFade = function(/* Object */args){
// summary: Returns an animation cross fading two element simultaneously
//
// args:
// args.nodes: Array - two element array of domNodes, or id's
//
// all other standard animation args mixins apply. args.node ignored.
//
if(dojo.isArray(args.nodes)){
// simple check for which node is visible, maybe too simple?
var node1 = args.nodes[0] = dojo.byId(args.nodes[0]);
var op1 = dojo.style(node1,"opacity");
var node2 = args.nodes[1] = dojo.byId(args.nodes[1]);
var op2 = dojo.style(node2, "opacity");
 
var _anim = dojo.fx.combine([
dojo[((op1==0)?"fadeIn":"fadeOut")](dojo.mixin({
node: node1
},args)),
dojo[((op1==0)?"fadeOut":"fadeIn")](dojo.mixin({
node: node2
},args))
]);
return _anim; // dojo._Animation
}else{
// improper syntax in args, needs Array
return false; // Boolean
}
};
 
dojox.fx.highlight = function(/*Object*/ args){
// summary: Highlight a node
// description:
// Returns an animation that sets the node background to args.color
// then gradually fades back the original node background color
//
// example:
// dojox.fx.highlight({ node:"foo" }).play();
 
var node = (args.node = dojo.byId(args.node));
 
args.duration = args.duration || 400;
// Assign default color light yellow
var startColor = args.color || '#ffff99';
var endColor = dojo.style(node, "backgroundColor");
var wasTransparent = (endColor == "transparent" || endColor == "rgba(0, 0, 0, 0)");
 
var anim = dojo.animateProperty(dojo.mixin({
properties: {
backgroundColor: { start: startColor, end: endColor }
}
}, args));
 
dojo.connect(anim, "onEnd", anim, function(){
if(wasTransparent){
node.style.backgroundColor = "transparent";
}
});
 
return anim; // dojo._Animation
};
 
}
/trunk/api/js/dojo1.0/dojox/fx/scroll.js
New file
0,0 → 1,40
if(!dojo._hasResource["dojox.fx.scroll"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.fx.scroll"] = true;
dojo.provide("dojox.fx.scroll");
dojo.experimental("dojox.fx.scroll");
 
dojo.require("dojox.fx._core");
 
dojox.fx.smoothScroll = function(/* Object */args){
// summary: Returns an animation that will smooth-scroll to a node (specified in etup())
// description: This implementation support either horizental or vertical scroll, as well as
// both. In addition, element in iframe can be scrolled to correctly.
// offset: {x: int, y: int} this will be added to the target position
// duration: Duration of the animation in milliseconds.
// win: a node or window object to scroll
if(!args.target){ args.target = dojo.coords(args.node,true); }
 
var isWindow = dojo[(dojo.isIE ? "isObject" : "isFunction")](args["win"].scrollTo);
 
var _anim = (isWindow) ?
(function(val){
args.win.scrollTo(val[0],val[1]);
}) :
(function(val){
args.win.scrollLeft = val[0];
args.win.scrollTop = val[1];
});
 
var anim = new dojo._Animation(dojo.mixin({
beforeBegin: function(){
if(this.curve){ delete this.curve; }
var current = isWindow ? dojo._docScroll() : {x: args.win.scrollLeft, y: args.win.scrollTop};
anim.curve = new dojox.fx._Line([current.x,current.y],[args.target.x,args.target.y]);
},
onAnimate: _anim
},args));
return anim; // dojo._Animation
};
 
}
/trunk/api/js/dojo1.0/dojox/date/README
New file
0,0 → 1,36
-------------------------------------------------------------------------------
DojoX Date
-------------------------------------------------------------------------------
Version 0.9
Release date: 5/17/2007
-------------------------------------------------------------------------------
Project state:
expermental
-------------------------------------------------------------------------------
Credits
Adam Peller (dojox.date.posix)
Neil Roberts (dojox.date.php)
-------------------------------------------------------------------------------
Project description
 
Placeholder for any kind of date operations, including formatters that are
common to other languages (posix and php).
-------------------------------------------------------------------------------
Dependencies:
 
Depends only on the Dojo Core.
-------------------------------------------------------------------------------
Documentation
 
See the API documentation for details.
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/date/*
 
Install into the following directory structure:
/dojox/date/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
/trunk/api/js/dojo1.0/dojox/date/posix.js
New file
0,0 → 1,293
if(!dojo._hasResource["dojox.date.posix"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.date.posix"] = true;
dojo.provide("dojox.date.posix");
 
dojo.require("dojo.date");
dojo.require("dojo.date.locale");
dojo.require("dojo.string");
 
dojox.date.posix.strftime = function(/*Date*/dateObject, /*String*/format, /*String?*/locale){
//
// summary:
// Formats the date object using the specifications of the POSIX strftime function
//
// description:
// see <http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html>
 
// zero pad
var padChar = null;
var _ = function(s, n){
return dojo.string.pad(s, n || 2, padChar || "0");
};
 
var bundle = dojo.date.locale._getGregorianBundle(locale);
 
var $ = function(property){
switch(property){
case "a": // abbreviated weekday name according to the current locale
return dojo.date.locale.getNames('days', 'abbr', 'format', locale)[dateObject.getDay()];
 
case "A": // full weekday name according to the current locale
return dojo.date.locale.getNames('days', 'wide', 'format', locale)[dateObject.getDay()];
 
case "b":
case "h": // abbreviated month name according to the current locale
return dojo.date.locale.getNames('months', 'abbr', 'format', locale)[dateObject.getMonth()];
case "B": // full month name according to the current locale
return dojo.date.locale.getNames('months', 'wide', 'format', locale)[dateObject.getMonth()];
case "c": // preferred date and time representation for the current
// locale
return dojo.date.locale.format(dateObject, {formatLength: 'full', locale: locale});
 
case "C": // century number (the year divided by 100 and truncated
// to an integer, range 00 to 99)
return _(Math.floor(dateObject.getFullYear()/100));
case "d": // day of the month as a decimal number (range 01 to 31)
return _(dateObject.getDate());
case "D": // same as %m/%d/%y
return $("m") + "/" + $("d") + "/" + $("y");
case "e": // day of the month as a decimal number, a single digit is
// preceded by a space (range ' 1' to '31')
if(padChar == null){ padChar = " "; }
return _(dateObject.getDate());
case "f": // month as a decimal number, a single digit is
// preceded by a space (range ' 1' to '12')
if(padChar == null){ padChar = " "; }
return _(dateObject.getMonth()+1);
case "g": // like %G, but without the century.
break;
case "G": // The 4-digit year corresponding to the ISO week number
// (see %V). This has the same format and value as %Y,
// except that if the ISO week number belongs to the
// previous or next year, that year is used instead.
dojo.unimplemented("unimplemented modifier 'G'");
break;
case "F": // same as %Y-%m-%d
return $("Y") + "-" + $("m") + "-" + $("d");
case "H": // hour as a decimal number using a 24-hour clock (range
// 00 to 23)
return _(dateObject.getHours());
case "I": // hour as a decimal number using a 12-hour clock (range
// 01 to 12)
return _(dateObject.getHours() % 12 || 12);
 
case "j": // day of the year as a decimal number (range 001 to 366)
return _(dojo.date.locale._getDayOfYear(dateObject), 3);
 
case "k": // Hour as a decimal number using a 24-hour clock (range
// 0 to 23 (space-padded))
if(padChar == null){ padChar = " "; }
return _(dateObject.getHours());
 
case "l": // Hour as a decimal number using a 12-hour clock (range
// 1 to 12 (space-padded))
if(padChar == null){ padChar = " "; }
return _(dateObject.getHours() % 12 || 12);
 
case "m": // month as a decimal number (range 01 to 12)
return _(dateObject.getMonth() + 1);
 
case "M": // minute as a decimal number
return _(dateObject.getMinutes());
 
case "n":
return "\n";
 
case "p": // either `am' or `pm' according to the given time value,
// or the corresponding strings for the current locale
return bundle[dateObject.getHours() < 12 ? "am" : "pm"];
case "r": // time in a.m. and p.m. notation
return $("I") + ":" + $("M") + ":" + $("S") + " " + $("p");
case "R": // time in 24 hour notation
return $("H") + ":" + $("M");
case "S": // second as a decimal number
return _(dateObject.getSeconds());
 
case "t":
return "\t";
 
case "T": // current time, equal to %H:%M:%S
return $("H") + ":" + $("M") + ":" + $("S");
case "u": // weekday as a decimal number [1,7], with 1 representing
// Monday
return String(dateObject.getDay() || 7);
case "U": // week number of the current year as a decimal number,
// starting with the first Sunday as the first day of the
// first week
return _(dojo.date.locale._getWeekOfYear(dateObject));
 
case "V": // week number of the year (Monday as the first day of the
// week) as a decimal number [01,53]. If the week containing
// 1 January has four or more days in the new year, then it
// is considered week 1. Otherwise, it is the last week of
// the previous year, and the next week is week 1.
return _(dojox.date.posix.getIsoWeekOfYear(dateObject));
case "W": // week number of the current year as a decimal number,
// starting with the first Monday as the first day of the
// first week
return _(dojo.date.locale._getWeekOfYear(dateObject, 1));
case "w": // day of the week as a decimal, Sunday being 0
return String(dateObject.getDay());
 
case "x": // preferred date representation for the current locale
// without the time
return dojo.date.locale.format(dateObject, {selector:'date', formatLength: 'full', locale:locale});
 
case "X": // preferred time representation for the current locale
// without the date
return dojo.date.locale.format(dateObject, {selector:'time', formatLength: 'full', locale:locale});
 
case "y": // year as a decimal number without a century (range 00 to
// 99)
return _(dateObject.getFullYear()%100);
case "Y": // year as a decimal number including the century
return String(dateObject.getFullYear());
case "z": // time zone or name or abbreviation
var timezoneOffset = dateObject.getTimezoneOffset();
return (timezoneOffset > 0 ? "-" : "+") +
_(Math.floor(Math.abs(timezoneOffset)/60)) + ":" +
_(Math.abs(timezoneOffset)%60);
 
case "Z": // time zone or name or abbreviation
return dojo.date.getTimezoneName(dateObject);
case "%":
return "%";
}
};
 
// parse the formatting string and construct the resulting string
var string = "";
var i = 0;
var index = 0;
var switchCase = null;
while ((index = format.indexOf("%", i)) != -1){
string += format.substring(i, index++);
// inspect modifier flag
switch (format.charAt(index++)) {
case "_": // Pad a numeric result string with spaces.
padChar = " "; break;
case "-": // Do not pad a numeric result string.
padChar = ""; break;
case "0": // Pad a numeric result string with zeros.
padChar = "0"; break;
case "^": // Convert characters in result string to uppercase.
switchCase = "upper"; break;
case "*": // Convert characters in result string to lowercase
switchCase = "lower"; break;
case "#": // Swap the case of the result string.
switchCase = "swap"; break;
default: // no modifier flag so decrement the index
padChar = null; index--; break;
}
 
// toggle case if a flag is set
var property = $(format.charAt(index++));
switch (switchCase){
case "upper":
property = property.toUpperCase();
break;
case "lower":
property = property.toLowerCase();
break;
case "swap": // Upper to lower, and versey-vicea
var compareString = property.toLowerCase();
var swapString = '';
var ch = '';
for (var j = 0; j < property.length; j++){
ch = property.charAt(j);
swapString += (ch == compareString.charAt(j)) ?
ch.toUpperCase() : ch.toLowerCase();
}
property = swapString;
break;
default:
break;
}
switchCase = null;
string += property;
i = index;
}
string += format.substring(i);
return string; // String
};
 
dojox.date.posix.getStartOfWeek = function(/*Date*/dateObject, /*Number*/firstDay){
// summary: Return a date object representing the first day of the given
// date's week.
if(isNaN(firstDay)){
firstDay = dojo.cldr.supplemental.getFirstDayOfWeek ? dojo.cldr.supplemental.getFirstDayOfWeek() : 0;
}
var offset = firstDay;
if(dateObject.getDay() >= firstDay){
offset -= dateObject.getDay();
}else{
offset -= (7 - dateObject.getDay());
}
var date = new Date(dateObject);
date.setHours(0, 0, 0, 0);
return dojo.date.add(date, "day", offset); // Date
}
 
dojox.date.posix.setIsoWeekOfYear = function(/*Date*/dateObject, /*Number*/week){
// summary: Set the ISO8601 week number of the given date.
// The week containing January 4th is the first week of the year.
// week:
// can be positive or negative: -1 is the year's last week.
if(!week){ return dateObject; }
var currentWeek = dojox.date.posix.getIsoWeekOfYear(dateObject);
var offset = week - currentWeek;
if(week < 0){
var weeks = dojox.date.posix.getIsoWeeksInYear(dateObject);
offset = (weeks + week + 1) - currentWeek;
}
return dojo.date.add(dateObject, "week", offset); // Date
}
 
dojox.date.posix.getIsoWeekOfYear = function(/*Date*/dateObject){
// summary: Get the ISO8601 week number of the given date.
// The week containing January 4th is the first week of the year.
// See http://en.wikipedia.org/wiki/ISO_week_date
var weekStart = dojox.date.posix.getStartOfWeek(dateObject, 1);
var yearStart = new Date(dateObject.getFullYear(), 0, 4); // January 4th
yearStart = dojox.date.posix.getStartOfWeek(yearStart, 1);
var diff = weekStart.getTime() - yearStart.getTime();
if(diff < 0){ return dojox.date.posix.getIsoWeeksInYear(weekStart); } // Integer
return Math.ceil(diff / 604800000) + 1; // Integer
}
 
dojox.date.posix.getIsoWeeksInYear = function(/*Date*/dateObject) {
// summary: Determine the number of ISO8601 weeks in the year of the given
// date. Most years have 52 but some have 53.
// See http://www.phys.uu.nl/~vgent/calendar/isocalendar_text3.htm
function p(y) {
return y + Math.floor(y/4) - Math.floor(y/100) + Math.floor(y/400);
}
var y = dateObject.getFullYear();
return ( p(y) % 7 == 4 || p(y-1) % 7 == 3 ) ? 53 : 52; // Integer
}
 
}
/trunk/api/js/dojo1.0/dojox/date/php.js
New file
0,0 → 1,296
if(!dojo._hasResource["dojox.date.php"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.date.php"] = true;
dojo.provide("dojox.date.php");
dojo.require("dojo.date");
 
dojox.date.php.format = function(/*Date*/ date, /*String*/ format, /*Object?*/ overrides){
// summary: Get a formatted string for a given date object
var df = new dojox.date.php.DateFormat(date);
return df.format(format, overrides);
}
 
dojox.date.php.DateFormat = function(/*Date*/ date){
this.date = date;
}
dojo.extend(dojox.date.php.DateFormat, {
weekdays: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
weekdays_3: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
months_3: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
monthdays: [31,28,31,30,31,30,31,31,30,31,30,31],
 
format: function(/*String*/ format, /*Object?*/ overrides){
// summary: Format the internal date object
var parts = [];
for(var i = 0; i < format.length; i++){
var chr = format.charAt(i);
if(overrides && typeof overrides[chr] == "function"){
parts.push(overrides[chr].call(this));
}else if(typeof this[chr] == "function"){
parts.push(this[chr]());
}else{
parts.push(chr);
}
}
return parts.join("");
},
 
// Day
 
d: function(){
// summary: Day of the month, 2 digits with leading zeros
var j = this.j();
return (j.length == 1) ? "0" + j : j;
},
 
D: function(){
// summary: A textual representation of a day, three letters
return this.weekdays_3[this.date.getDay()];
},
 
j: function(){
// summary: Day of the month without leading zeros
return this.date.getDate() + "";
},
 
l: function(){
// summary: A full textual representation of the day of the week
return this.weekdays[this.date.getDay()];
},
N: function(){
// summary: ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0)
var w = this.w();
return (!w) ? 7 : w;
},
 
S: function(){
// summary: English ordinal suffix for the day of the month, 2 characters
switch(this.date.getDate()){
case 11: case 12: case 13: return "th";
case 1: case 21: case 31: return "st";
case 2: case 22: return "nd";
case 3: case 23: return "rd";
default: return "th";
}
},
 
w: function(){
// summary: Numeric representation of the day of the week
return this.date.getDay() + "";
},
 
z: function(){
// summary: The day of the year (starting from 0)
var millis = this.date.getTime() - new Date(this.date.getFullYear(), 0, 1).getTime();
return Math.floor(millis/86400000) + "";
},
 
// Week
 
W: function(){
// summary: ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0)
var week;
var jan1_w = new Date(this.date.getFullYear(), 0, 1).getDay() + 1;
var w = this.date.getDay() + 1;
var z = parseInt(this.z());
 
if(z <= (8 - jan1_w) && jan1_w > 4){
var last_year = new Date(this.date.getFullYear() - 1, this.date.getMonth(), this.date.getDate());
if(jan1_w == 5 || (jan1_w == 6 && dojo.date.isLeapYear(last_year))){
week = 53;
}else{
week = 52;
}
}else{
var i;
if(Boolean(this.L())){
i = 366;
}else{
i = 365;
}
if((i - z) < (4 - w)){
week = 1;
}else{
var j = z + (7 - w) + (jan1_w - 1);
week = Math.ceil(j / 7);
if(jan1_w > 4){
--week;
}
}
}
return week;
},
 
// Month
 
F: function(){
// summary: A full textual representation of a month, such as January or March
return this.months[this.date.getMonth()];
},
 
m: function(){
// summary: Numeric representation of a month, with leading zeros
var n = this.n();
return (n.length == 1) ? "0" + n : n;
},
 
M: function(){
// summary: A short textual representation of a month, three letters
return months_3[this.date.getMonth()];
},
 
n: function(){
// summary: Numeric representation of a month, without leading zeros
return this.date.getMonth() + 1 + "";
},
 
t: function(){
// summary: Number of days in the given month
return (Boolean(this.L()) && this.date.getMonth() == 1) ? 29 : this.monthdays[this.getMonth()];
},
 
// Year
 
L: function(){
// summary: Whether it's a leap year
return (dojo.date.isLeapYear(this.date)) ? "1" : "0";
},
 
o: function(){
// summary:
// ISO-8601 year number. This has the same value as Y, except that if
// the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0)
// TODO: Figure out what this means
},
 
Y: function(){
// summary: A full numeric representation of a year, 4 digits
return this.date.getFullYear() + "";
},
 
y: function(){
// summary: A two digit representation of a year
return this.date.getFullYear.substsring(2, 4);
},
 
// Time
 
a: function(){
// summary: Lowercase Ante meridiem and Post meridiem
return this.date.getHours() >= 12 ? "pm" : "am";
},
 
b: function(){
// summary: Uppercase Ante meridiem and Post meridiem
return this.a().toUpperCase();
},
 
B: function(){
// summary:
// Swatch Internet time
// A day is 1,000 beats. All time is measured from GMT + 1
var off = this.date.getTimezoneOffset() + 60;
var secs = (this.date.getHours() * 3600) + (this.date.getMinutes() * 60) + this.getSeconds() + (off * 60);
var beat = Math.abs(Math.floor(secs / 86.4) % 1000) + "";
while(beat.length < 2) beat = "0" + beat;
return beat;
},
 
g: function(){
// summary: 12-hour format of an hour without leading zeros
return (this.date.getHours() > 12) ? this.date.getHours() - 12 + "" : this.date.getHours() + "";
},
 
G: function(){
// summary: 24-hour format of an hour without leading zeros
return this.date.getHours() + "";
},
 
h: function(){
// summary: 12-hour format of an hour with leading zeros
var g = this.g();
return (g.length == 1) ? "0" + g : g;
},
 
H: function(){
// summary: 24-hour format of an hour with leading zeros
var G = this.G();
return (G.length == 1) ? "0" + G : G;
},
 
i: function(){
// summary: Minutes with leading zeros
var mins = this.date.getMinutes() + "";
return (mins.length == 1) ? "0" + mins : mins;
},
 
s: function(){
// summary: Seconds, with leading zeros
var secs = this.date.getSeconds() + "";
return (secs.length == 1) ? "0" + secs : secs;
},
 
// Timezone
 
e: function(){
// summary: Timezone identifier (added in PHP 5.1.0)
return dojo.date.getTimezoneName(this.date);
},
 
I: function(){
// summary: Whether or not the date is in daylight saving time
// TODO: Can dojo.date do this?
},
 
O: function(){
// summary: Difference to Greenwich time (GMT) in hours
var off = Math.abs(this.date.getTimezoneOffset());
var hours = Math.floor(off / 60) + "";
var mins = (off % 60) + "";
if(hours.length == 1) hours = "0" + hours;
if(mins.length == 1) hours = "0" + mins;
return ((this.date.getTimezoneOffset() < 0) ? "+" : "-") + hours + mins;
},
 
P: function(){
// summary: Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3)
var O = this.O();
return O.substring(0, 2) + ":" + O.substring(2, 4);
},
 
T: function(){
// summary: Timezone abbreviation
 
// Guess...
return this.e().substring(0, 3);
},
 
Z: function(){
// summary:
// Timezone offset in seconds. The offset for timezones west of UTC is always negative,
// and for those east of UTC is always positive.
return this.date.getTimezoneOffset() * -60;
},
 
// Full Date/Time
 
c: function(){
// summary: ISO 8601 date (added in PHP 5)
return this.Y() + "-" + this.m() + "-" + this.d() + "T" + this.h() + ":" + this.i() + ":" + this.s() + this.P();
},
 
r: function(){
// summary: RFC 2822 formatted date
return this.D() + ", " + this.d() + " " + this.M() + " " + this.Y() + " " + this.H() + ":" + this.i() + ":" + this.s() + " " + this.O();
},
 
U: function(){
// summary: Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
return Math.floor(this.date.getTime() / 1000);
}
 
});
 
}
/trunk/api/js/dojo1.0/dojox/date/tests/runTests.html
New file
0,0 → 1,9
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dojox Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.date.tests.module"></HEAD>
<BODY>
Redirecting to D.O.H runner.
</BODY>
</HTML>
/trunk/api/js/dojo1.0/dojox/date/tests/posix.js
New file
0,0 → 1,236
if(!dojo._hasResource["dojox.date.tests.posix"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.date.tests.posix"] = true;
dojo.provide("dojox.date.tests.posix");
dojo.require("dojox.date.posix");
 
tests.register("dojox.date.tests.posix",
[
//FIXME: set up by loading 'en' resources
function test_date_strftime(t){
var date = new Date(2006, 7, 11, 0, 55, 12, 3456);
t.is("06/08/11", dojox.date.posix.strftime(date, "%y/%m/%d"));
 
var dt = null; // Date to test
var fmt = ''; // Format to test
var res = ''; // Expected result
dt = new Date(2006, 0, 1, 18, 23);
fmt = '%a';
res = 'Sun';
t.is(res, dojox.date.posix.strftime(dt, fmt, 'en'));
fmt = '%A';
res = 'Sunday';
t.is(res, dojox.date.posix.strftime(dt, fmt, 'en'));
fmt = '%b';
res = 'Jan';
t.is(res, dojox.date.posix.strftime(dt, fmt, 'en'));
fmt = '%B';
res = 'January';
t.is(res, dojox.date.posix.strftime(dt, fmt, 'en'));
 
fmt = '%c';
res = 'Sunday, January 1, 2006 6:23:00 PM';
t.is(res, dojox.date.posix.strftime(dt, fmt).substring(0, res.length));
fmt = '%C';
res = '20';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%d';
res = '01';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%D';
res = '01/01/06';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%e';
res = ' 1';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%h';
res = 'Jan';
t.is(res, dojox.date.posix.strftime(dt, fmt, 'en'));
fmt = '%H';
res = '18';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%I';
res = '06';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%j';
res = '001';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%k';
res = '18';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%l';
res = ' 6';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%m';
res = '01';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%M';
res = '23';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%p';
res = 'PM';
t.is(res, dojox.date.posix.strftime(dt, fmt, 'en'));
fmt = '%r';
res = '06:23:00 PM';
t.is(res, dojox.date.posix.strftime(dt, fmt, 'en'));
fmt = '%R';
res = '18:23';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%S';
res = '00';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%T';
res = '18:23:00';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%u';
res = '7';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%w';
res = '0';
t.is(res, dojox.date.posix.strftime(dt, fmt));
 
fmt = '%x';
res = 'Sunday, January 1, 2006';
t.is(res, dojox.date.posix.strftime(dt, fmt, 'en'));
 
fmt = '%X';
res = '6:23:00 PM';
t.is(res, dojox.date.posix.strftime(dt, fmt, 'en').substring(0,res.length));
fmt = '%y';
res = '06';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%Y';
res = '2006';
t.is(res, dojox.date.posix.strftime(dt, fmt));
fmt = '%%';
res = '%';
t.is(res, dojox.date.posix.strftime(dt, fmt));
},
function test_date_getStartOfWeek(t){
var weekStart;
// Monday
var date = new Date(2007, 0, 1);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 1), 1);
t.is(date, weekStart);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 2), 1);
t.is(date, weekStart);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 3), 1);
t.is(date, weekStart);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 4), 1);
t.is(date, weekStart);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 5), 1);
t.is(date, weekStart);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 6), 1);
t.is(date, weekStart);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 7), 1);
t.is(date, weekStart);
 
// Sunday
date = new Date(2007, 0, 7);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 7), 0);
t.is(date, weekStart);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 8), 0);
t.is(date, weekStart);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 9), 0);
t.is(date, weekStart);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 10), 0);
t.is(date, weekStart);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 11), 0);
t.is(date, weekStart);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 12), 0);
t.is(date, weekStart);
weekStart = dojox.date.posix.getStartOfWeek(new Date(2007, 0, 13), 0);
t.is(date, weekStart);
},
 
function test_date_setIsoWeekOfYear(t){
var date = new Date(2006,10,10);
var result = dojox.date.posix.setIsoWeekOfYear(date, 1);
t.is(new Date(2006,0,6), result);
result = dojox.date.posix.setIsoWeekOfYear(date, 10);
result = dojox.date.posix.setIsoWeekOfYear(date, 2);
t.is(new Date(2006,0,13), result);
result = dojox.date.posix.setIsoWeekOfYear(date, 10);
t.is(new Date(2006,2,10), result);
result = dojox.date.posix.setIsoWeekOfYear(date, 52);
t.is(new Date(2006,11,29), result);
var result = dojox.date.posix.setIsoWeekOfYear(date, -1);
t.is(new Date(2006,11,29), result);
var result = dojox.date.posix.setIsoWeekOfYear(date, -2);
t.is(new Date(2006,11,22), result);
var result = dojox.date.posix.setIsoWeekOfYear(date, -10);
t.is(new Date(2006,9,27), result);
date = new Date(2004,10,10);
result = dojox.date.posix.setIsoWeekOfYear(date, 1);
t.is(new Date(2003,11,31), result);
result = dojox.date.posix.setIsoWeekOfYear(date, 2);
t.is(new Date(2004,0,7), result);
result = dojox.date.posix.setIsoWeekOfYear(date, -1);
t.is(new Date(2004,11,29), result);
},
 
function test_date_getIsoWeekOfYear(t){
var week = dojox.date.posix.getIsoWeekOfYear(new Date(2006,0,1));
t.is(52, week);
week = dojox.date.posix.getIsoWeekOfYear(new Date(2006,0,4));
t.is(1, week);
week = dojox.date.posix.getIsoWeekOfYear(new Date(2006,11,31));
t.is(52, week);
week = dojox.date.posix.getIsoWeekOfYear(new Date(2007,0,1));
t.is(1, week);
week = dojox.date.posix.getIsoWeekOfYear(new Date(2007,11,31));
t.is(53, week);
week = dojox.date.posix.getIsoWeekOfYear(new Date(2008,0,1));
t.is(1, week);
week = dojox.date.posix.getIsoWeekOfYear(new Date(2007,11,31));
t.is(53, week);
},
 
function test_date_getIsoWeeksInYear(t){
// 44 long years in a 400 year cycle.
var longYears = [4, 9, 15, 20, 26, 32, 37, 43, 48, 54, 60, 65, 71, 76, 82,
88, 93, 99, 105, 111, 116, 122, 128, 133, 139, 144, 150, 156, 161, 167,
172, 178, 184, 189, 195, 201, 207, 212, 218, 224, 229, 235, 240, 246,
252, 257, 263, 268, 274, 280, 285, 291, 296, 303, 308, 314, 320, 325,
331, 336, 342, 348, 353, 359, 364, 370, 376, 381, 387, 392, 398];
 
var i, j, weeks, result;
for(i=0; i < 400; i++) {
weeks = 52;
if(i == longYears[0]) { weeks = 53; longYears.shift(); }
result = dojox.date.posix.getIsoWeeksInYear(new Date(2000 + i, 0, 1));
t.is(/*weeks +" weeks in "+ (2000+i), */weeks, result);
}
}
]
);
 
}
/trunk/api/js/dojo1.0/dojox/date/tests/module.js
New file
0,0 → 1,12
if(!dojo._hasResource["dojox.date.tests.module"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.date.tests.module"] = true;
dojo.provide("dojox.date.tests.module");
 
try{
dojo.require("dojox.date.tests.posix");
}catch(e){
doh.debug(e);
}
 
 
}
/trunk/api/js/dojo1.0/dojox/collections/SortedList.js
New file
0,0 → 1,198
if(!dojo._hasResource["dojox.collections.SortedList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.SortedList"] = true;
dojo.provide("dojox.collections.SortedList");
dojo.require("dojox.collections._base");
 
dojox.collections.SortedList=function(/* object? */ dictionary){
// summary
// creates a collection that acts like a dictionary but is also internally sorted.
// Note that the act of adding any elements forces an internal resort, making this object potentially slow.
var _this=this;
var items={};
var q=[];
var sorter=function(a,b){
if (a.key > b.key) return 1;
if (a.key < b.key) return -1;
return 0;
};
var build=function(){
q=[];
var e=_this.getIterator();
while (!e.atEnd()){
q.push(e.get());
}
q.sort(sorter);
};
var testObject={};
 
this.count=q.length;
this.add=function(/* string */ k,/* object */v){
// summary
// add the passed value to the dictionary at location k
if (!items[k]) {
items[k]=new dojox.collections.DictionaryEntry(k,v);
this.count=q.push(items[k]);
q.sort(sorter);
}
};
this.clear=function(){
// summary
// clear the internal collections
items={};
q=[];
this.count=q.length;
};
this.clone=function(){
// summary
// create a clone of this sorted list
return new dojox.collections.SortedList(this); // dojox.collections.SortedList
};
this.contains=this.containsKey=function(/* string */ k){
// summary
// Check to see if the list has a location k
if(testObject[k]){
return false; // bool
}
return (items[k]!=null); // bool
};
this.containsValue=function(/* object */ o){
// summary
// Check to see if this list contains the passed object
var e=this.getIterator();
while (!e.atEnd()){
var item=e.get();
if(item.value==o){
return true; // bool
}
}
return false; // bool
};
this.copyTo=function(/* array */ arr, /* int */ i){
// summary
// copy the contents of the list into array arr at index i
var e=this.getIterator();
var idx=i;
while(!e.atEnd()){
arr.splice(idx,0,e.get());
idx++;
}
};
this.entry=function(/* string */ k){
// summary
// return the object at location k
return items[k]; // dojox.collections.DictionaryEntry
};
this.forEach=function(/* function */ fn, /* object? */ scope){
// summary
// functional iterator, following the mozilla spec.
dojo.forEach(q, fn, scope);
};
this.getByIndex=function(/* int */ i){
// summary
// return the item at index i
return q[i].valueOf(); // object
};
this.getIterator=function(){
// summary
// get an iterator for this object
return new dojox.collections.DictionaryIterator(items); // dojox.collections.DictionaryIterator
};
this.getKey=function(/* int */ i){
// summary
// return the key of the item at index i
return q[i].key;
};
this.getKeyList=function(){
// summary
// return an array of the keys set in this list
var arr=[];
var e=this.getIterator();
while (!e.atEnd()){
arr.push(e.get().key);
}
return arr; // array
};
this.getValueList=function(){
// summary
// return an array of values in this list
var arr=[];
var e=this.getIterator();
while (!e.atEnd()){
arr.push(e.get().value);
}
return arr; // array
};
this.indexOfKey=function(/* string */ k){
// summary
// return the index of the passed key.
for (var i=0; i<q.length; i++){
if (q[i].key==k){
return i; // int
}
}
return -1; // int
};
this.indexOfValue=function(/* object */ o){
// summary
// return the first index of object o
for (var i=0; i<q.length; i++){
if (q[i].value==o){
return i; // int
}
}
return -1; // int
};
this.item=function(/* string */ k){
// summary
// return the value of the object at location k.
if(k in items && !testObject[k]){
return items[k].valueOf(); // object
}
return undefined; // object
};
this.remove=function(/* string */k){
// summary
// remove the item at location k and rebuild the internal collections.
delete items[k];
build();
this.count=q.length;
};
this.removeAt=function(/* int */ i){
// summary
// remove the item at index i, and rebuild the internal collections.
delete items[q[i].key];
build();
this.count=q.length;
};
this.replace=function(/* string */ k, /* object */ v){
// summary
// Replace an existing item if it's there, and add a new one if not.
if (!items[k]){
// we're adding a new object, return false
this.add(k,v);
return false; // bool
}else{
// we're replacing an object, return true
items[k]=new dojox.collections.DictionaryEntry(k,v);
build();
return true; // bool
}
};
this.setByIndex=function(/* int */ i, /* object */ o){
// summary
// set an item by index
items[q[i].key].value=o;
build();
this.count=q.length;
};
if (dictionary){
var e=dictionary.getIterator();
while (!e.atEnd()){
var item=e.get();
q[q.length]=items[item.key]=new dojox.collections.DictionaryEntry(item.key,item.value);
}
q.sort(sorter);
}
}
 
}
/trunk/api/js/dojo1.0/dojox/collections/README
New file
0,0 → 1,39
-------------------------------------------------------------------------------
DojoX Collections
-------------------------------------------------------------------------------
Version 0.9
Release date: 05/27/2007
-------------------------------------------------------------------------------
Project state: stable
-------------------------------------------------------------------------------
Project authors
Tom Trenka (ttrenka@gmail.com)
-------------------------------------------------------------------------------
Project description
 
DojoX Collections is the port of the original Dojo 0.4.x collection classes.
It is intended for use by people who are looking for a little bit more
functionality out of common collections, like ArrayLists or Dictionaries.
 
Included are the Iterator and DictionaryIterator classes, both of which can
operate on standard arrays and objects (respectively).
-------------------------------------------------------------------------------
Dependencies:
 
DojoX Collections has no dependencies, outside of Dojo Core.
-------------------------------------------------------------------------------
Documentation
 
See the API documentation for Dojo (http://dojotoolkit.org/api).
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/collections.js
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/collections/*
 
Install into the following directory structure:
/dojox/collections/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
/trunk/api/js/dojo1.0/dojox/collections/BinaryTree.js
New file
0,0 → 1,211
if(!dojo._hasResource["dojox.collections.BinaryTree"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.BinaryTree"] = true;
dojo.provide("dojox.collections.BinaryTree");
dojo.require("dojox.collections._base");
 
dojox.collections.BinaryTree=function(data){
function node(data, rnode, lnode){
this.value=data||null;
this.right=rnode||null;
this.left=lnode||null;
this.clone=function(){
var c=new node();
if(this.value.value){
c.value=this.value.clone();
}else{
c.value=this.value;
}
if(this.left!=null){
c.left=this.left.clone();
}
if(this.right!=null){
c.right=this.right.clone();
}
return c;
}
this.compare=function(n){
if(this.value>n.value){ return 1; }
if(this.value<n.value){ return -1; }
return 0;
}
this.compareData=function(d){
if(this.value>d){ return 1; }
if(this.value<d){ return -1; }
return 0;
}
}
 
function inorderTraversalBuildup(current, a){
if(current){
inorderTraversalBuildup(current.left, a);
a.push(current.value);
inorderTraversalBuildup(current.right, a);
}
}
 
function preorderTraversal(current, sep){
var s="";
if (current){
s=current.value.toString() + sep;
s+=preorderTraversal(current.left, sep);
s+=preorderTraversal(current.right, sep);
}
return s;
}
function inorderTraversal(current, sep){
var s="";
if (current){
s=inorderTraversal(current.left, sep);
s+=current.value.toString() + sep;
s+=inorderTraversal(current.right, sep);
}
return s;
}
function postorderTraversal(current, sep){
var s="";
if (current){
s=postorderTraversal(current.left, sep);
s+=postorderTraversal(current.right, sep);
s+=current.value.toString() + sep;
}
return s;
}
function searchHelper(current, data){
if(!current){ return null; }
var i=current.compareData(data);
if(i==0){ return current; }
if(i>0){ return searchHelper(current.left, data); }
else{ return searchHelper(current.right, data); }
}
 
this.add=function(data){
var n=new node(data);
var i;
var current=root;
var parent=null;
while(current){
i=current.compare(n);
if(i==0){ return; }
parent=current;
if(i>0){ current=current.left; }
else{ current=current.right; }
}
this.count++;
if(!parent){
root=n;
}else{
i=parent.compare(n);
if(i>0){
parent.left=n;
}else{
parent.right=n;
}
}
};
this.clear=function(){
root=null;
this.count=0;
};
this.clone=function(){
var c=new dojox.collections.BinaryTree();
var itr=this.getIterator();
while(!itr.atEnd()){
c.add(itr.get());
}
return c;
};
this.contains=function(data){
return this.search(data) != null;
};
this.deleteData=function(data){
var current=root;
var parent=null;
var i=current.compareData(data);
while(i!=0&&current!=null){
if(i>0){
parent=current;
current=current.left;
}else if(i<0){
parent=current;
current=current.right;
}
i=current.compareData(data);
}
if(!current){ return; }
this.count--;
if(!current.right){
if(!parent){
root=current.left;
}else{
i=parent.compare(current);
if(i>0){ parent.left=current.left; }
else if(i<0){ parent.right=current.left; }
}
}
else if(!current.right.left){
if(!parent){
root=current.right;
}else{
i=parent.compare(current);
if(i>0){ parent.left=current.right; }
else if(i<0){ parent.right=current.right; }
}
}
else{
var leftmost=current.right.left;
var lmParent=current.right;
while(leftmost.left!=null){
lmParent=leftmost;
leftmost=leftmost.left;
}
lmParent.left=leftmost.right;
leftmost.left=current.left;
leftmost.right=current.right;
if(!parent){
root=leftmost;
}else{
i=parent.compare(current);
if(i>0){ parent.left=leftmost; }
else if(i<0){ parent.right=leftmost; }
}
}
};
this.getIterator=function(){
var a=[];
inorderTraversalBuildup(root, a);
return new dojox.collections.Iterator(a);
};
this.search=function(data){
return searchHelper(root, data);
};
this.toString=function(order, sep){
if(!order){ order=dojox.collections.BinaryTree.TraversalMethods.Inorder; }
if(!sep){ sep=","; }
var s="";
switch(order){
case dojox.collections.BinaryTree.TraversalMethods.Preorder:
s=preorderTraversal(root, sep);
break;
case dojox.collections.BinaryTree.TraversalMethods.Inorder:
s=inorderTraversal(root, sep);
break;
case dojox.collections.BinaryTree.TraversalMethods.Postorder:
s=postorderTraversal(root, sep);
break;
};
if(s.length==0){ return ""; }
else{ return s.substring(0, s.length - sep.length); }
};
 
this.count=0;
var root=this.root=null;
if(data){
this.add(data);
}
}
dojox.collections.BinaryTree.TraversalMethods={
Preorder: 1, Inorder: 2, Postorder: 3
};
 
}
/trunk/api/js/dojo1.0/dojox/collections/Queue.js
New file
0,0 → 1,74
if(!dojo._hasResource["dojox.collections.Queue"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.Queue"] = true;
dojo.provide("dojox.collections.Queue");
dojo.require("dojox.collections._base");
 
dojox.collections.Queue=function(/* array? */arr){
// summary
// return an object of type dojox.collections.Queue
var q=[];
if (arr){
q=q.concat(arr);
}
this.count=q.length;
this.clear=function(){
// summary
// clears the internal collection
q=[];
this.count=q.length;
};
this.clone=function(){
// summary
// creates a new Queue based on this one
return new dojox.collections.Queue(q); // dojox.collections.Queue
};
this.contains=function(/* object */ o){
// summary
// Check to see if the passed object is an element in this queue
for(var i=0; i<q.length; i++){
if (q[i]==o){
return true; // bool
}
}
return false; // bool
};
this.copyTo=function(/* array */ arr, /* int */ i){
// summary
// Copy the contents of this queue into the passed array at index i.
arr.splice(i,0,q);
};
this.dequeue=function(){
// summary
// shift the first element off the queue and return it
var r=q.shift();
this.count=q.length;
return r; // object
};
this.enqueue=function(/* object */ o){
// summary
// put the passed object at the end of the queue
this.count=q.push(o);
};
this.forEach=function(/* function */ fn, /* object? */ scope){
// summary
// functional iterator, following the mozilla spec.
dojo.forEach(q, fn, scope);
};
this.getIterator=function(){
// summary
// get an Iterator based on this queue.
return new dojox.collections.Iterator(q); // dojox.collections.Iterator
};
this.peek=function(){
// summary
// get the next element in the queue without altering the queue.
return q[0];
};
this.toArray=function(){
// summary
// return an array based on the internal array of the queue.
return [].concat(q);
};
};
 
}
/trunk/api/js/dojo1.0/dojox/collections/Dictionary.js
New file
0,0 → 1,116
if(!dojo._hasResource["dojox.collections.Dictionary"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.Dictionary"] = true;
dojo.provide("dojox.collections.Dictionary");
dojo.require("dojox.collections._base");
 
dojox.collections.Dictionary=function(/* dojox.collections.Dictionary? */dictionary){
// summary
// Returns an object of type dojox.collections.Dictionary
var items={};
this.count=0;
 
// comparator for property addition and access.
var testObject={};
 
this.add=function(/* string */k, /* object */v){
// summary
// Add a new item to the Dictionary.
var b=(k in items);
items[k]=new dojox.collections.DictionaryEntry(k,v);
if(!b){
this.count++;
}
};
this.clear=function(){
// summary
// Clears the internal dictionary.
items={};
this.count=0;
};
this.clone=function(){
// summary
// Returns a new instance of dojox.collections.Dictionary; note the the dictionary is a clone but items might not be.
return new dojox.collections.Dictionary(this); // dojox.collections.Dictionary
};
this.contains=this.containsKey=function(/* string */k){
// summary
// Check to see if the dictionary has an entry at key "k".
if(testObject[k]){
return false; // bool
}
return (items[k]!=null); // bool
};
this.containsValue=function(/* object */v){
// summary
// Check to see if the dictionary has an entry with value "v".
var e=this.getIterator();
while(e.get()){
if(e.element.value==v){
return true; // bool
}
}
return false; // bool
};
this.entry=function(/* string */k){
// summary
// Accessor method; similar to dojox.collections.Dictionary.item but returns the actual Entry object.
return items[k]; // dojox.collections.DictionaryEntry
};
this.forEach=function(/* function */ fn, /* object? */ scope){
// summary
// functional iterator, following the mozilla spec.
var a=[]; // Create an indexing array
for(var p in items) {
if(!testObject[p]){
a.push(items[p]); // fill it up
}
}
dojo.forEach(a, fn, scope);
};
this.getKeyList=function(){
// summary
// Returns an array of the keys in the dictionary.
return (this.getIterator()).map(function(entry){
return entry.key;
}); // array
};
this.getValueList=function(){
// summary
// Returns an array of the values in the dictionary.
return (this.getIterator()).map(function(entry){
return entry.value;
}); // array
};
this.item=function(/* string */k){
// summary
// Accessor method.
if(k in items){
return items[k].valueOf(); // object
}
return undefined; // object
};
this.getIterator=function(){
// summary
// Gets a dojox.collections.DictionaryIterator for iteration purposes.
return new dojox.collections.DictionaryIterator(items); // dojox.collections.DictionaryIterator
};
this.remove=function(/* string */k){
// summary
// Removes the item at k from the internal collection.
if(k in items && !testObject[k]){
delete items[k];
this.count--;
return true; // bool
}
return false; // bool
};
 
if (dictionary){
var e=dictionary.getIterator();
while(e.get()) {
this.add(e.element.key, e.element.value);
}
}
};
 
}
/trunk/api/js/dojo1.0/dojox/collections/Stack.js
New file
0,0 → 1,72
if(!dojo._hasResource["dojox.collections.Stack"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.Stack"] = true;
dojo.provide("dojox.collections.Stack");
dojo.require("dojox.collections._base");
 
dojox.collections.Stack=function(/* array? */arr){
// summary
// returns an object of type dojox.collections.Stack
var q=[];
if (arr) q=q.concat(arr);
this.count=q.length;
this.clear=function(){
// summary
// Clear the internal array and reset the count
q=[];
this.count=q.length;
};
this.clone=function(){
// summary
// Create and return a clone of this Stack
return new dojox.collections.Stack(q);
};
this.contains=function(/* object */o){
// summary
// check to see if the stack contains object o
for (var i=0; i<q.length; i++){
if (q[i] == o){
return true; // bool
}
}
return false; // bool
};
this.copyTo=function(/* array */ arr, /* int */ i){
// summary
// copy the stack into array arr at index i
arr.splice(i,0,q);
};
this.forEach=function(/* function */ fn, /* object? */ scope){
// summary
// functional iterator, following the mozilla spec.
dojo.forEach(q, fn, scope);
};
this.getIterator=function(){
// summary
// get an iterator for this collection
return new dojox.collections.Iterator(q); // dojox.collections.Iterator
};
this.peek=function(){
// summary
// Return the next item without altering the stack itself.
return q[(q.length-1)]; // object
};
this.pop=function(){
// summary
// pop and return the next item on the stack
var r=q.pop();
this.count=q.length;
return r; // object
};
this.push=function(/* object */ o){
// summary
// Push object o onto the stack
this.count=q.push(o);
};
this.toArray=function(){
// summary
// create and return an array based on the internal collection
return [].concat(q); // array
};
}
 
}
/trunk/api/js/dojo1.0/dojox/collections/tests/_base.js
New file
0,0 → 1,84
if(!dojo._hasResource["dojox.collections.tests._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.tests._base"] = true;
dojo.provide("dojox.collections.tests._base");
dojo.require("dojox.collections");
 
tests.register("dojox.collections.tests._base", [
function testDictionaryEntry(t){
var d=new dojox.collections.DictionaryEntry("foo","bar");
t.assertEqual("bar", d.valueOf());
t.assertEqual("bar", d.toString());
},
 
function testIterator(t){
var itr=new dojox.collections.Iterator(["foo","bar","baz","zoo"]);
t.assertEqual("foo", itr.element); // test initialization
t.assertTrue(!itr.atEnd());
t.assertEqual("foo", itr.get()); // make sure the first get doesn't advance.
t.assertEqual("bar", itr.get());
t.assertEqual("baz", itr.get());
t.assertEqual("zoo", itr.get());
t.assertTrue(itr.atEnd());
t.assertEqual(null, itr.get());
 
itr.reset();
t.assertTrue(!itr.atEnd());
t.assertEqual("foo", itr.element);
 
// test map
var a=itr.map(function(elm){
return elm+"-mapped";
});
itr=new dojox.collections.Iterator(a);
t.assertEqual("foo-mapped", itr.element); // test initialization
t.assertTrue(!itr.atEnd());
t.assertEqual("foo-mapped", itr.get()); // make sure the first get doesn't advance.
t.assertEqual("bar-mapped", itr.get());
t.assertEqual("baz-mapped", itr.get());
t.assertEqual("zoo-mapped", itr.get());
t.assertTrue(itr.atEnd());
t.assertEqual(null, itr.get());
},
 
function testDictionaryIterator(t){
/*
in the context of any of the Dictionary-based collections, the
element would normally return a DictionaryEntry. However, since
the DictionaryIterator is really an iterator of pure objects,
we will just test with an object here. This means all property
names are lost in the translation, but...that's why there's a
DictionaryEntry object :)
*/
var itr=new dojox.collections.DictionaryIterator({
first:"foo", second:"bar", third:"baz", fourth:"zoo"
});
t.assertEqual("foo", itr.element); // test initialization
t.assertTrue(!itr.atEnd());
t.assertEqual("foo", itr.get()); // make sure the first get doesn't advance.
t.assertEqual("bar", itr.get());
t.assertEqual("baz", itr.get());
t.assertEqual("zoo", itr.get());
t.assertTrue(itr.atEnd());
t.assertEqual(null, itr.get());
 
itr.reset();
t.assertTrue(!itr.atEnd());
t.assertEqual("foo", itr.element);
 
// test map
var a=itr.map(function(elm){
return elm+"-mapped";
});
itr=new dojox.collections.Iterator(a);
t.assertEqual("foo-mapped", itr.element); // test initialization
t.assertTrue(!itr.atEnd());
t.assertEqual("foo-mapped", itr.get()); // make sure the first get doesn't advance.
t.assertEqual("bar-mapped", itr.get());
t.assertEqual("baz-mapped", itr.get());
t.assertEqual("zoo-mapped", itr.get());
t.assertTrue(itr.atEnd());
t.assertEqual(null, itr.get());
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/collections/tests/ArrayList.js
New file
0,0 → 1,83
if(!dojo._hasResource["dojox.collections.tests.ArrayList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.tests.ArrayList"] = true;
dojo.provide("dojox.collections.tests.ArrayList");
dojo.require("dojox.collections.ArrayList");
 
tests.register("dojox.collections.tests.ArrayList", [
function testCtor(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
t.assertEqual(4, al.count);
},
function testAdd(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
al.add("carp");
t.assertEqual("foo,bar,test,bull,carp", al.toString());
al.addRange(["oof","rab"]);
t.assertEqual("foo,bar,test,bull,carp,oof,rab", al.toString());
},
function testClear(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
al.clear();
t.assertEqual(0, al.count);
},
function testClone(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
var cloned=al.clone();
t.assertEqual(al.toString(), cloned.toString());
},
function testContains(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
t.assertTrue(al.contains("bar"));
t.assertFalse(al.contains("faz"));
},
function testGetIterator(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
var itr=al.getIterator();
while(!itr.atEnd()){
itr.get();
}
t.assertEqual("bull", itr.element);
},
function testIndexOf(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
t.assertEqual(1, al.indexOf("bar"));
},
function testInsert(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
al.insert(2, "baz");
t.assertEqual(2, al.indexOf("baz"));
},
function testItem(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
t.assertEqual("test", al.item(2));
},
function testRemove(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
al.remove("bar");
t.assertEqual("foo,test,bull", al.toString());
t.assertEqual(3, al.count);
},
function testRemoveAt(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
al.removeAt(3);
t.assertEqual("foo,bar,test", al.toString());
t.assertEqual(3, al.count);
},
function testReverse(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
al.reverse();
t.assertEqual("bull,test,bar,foo", al.toString());
},
function testSort(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
al.sort();
t.assertEqual("bar,bull,foo,test", al.toString());
},
function testToArray(t){
var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
var a=al.toArray();
t.assertEqual(a.join(","), al.toString());
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/collections/tests/Set.js
New file
0,0 → 1,35
if(!dojo._hasResource["dojox.collections.tests.Set"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.tests.Set"] = true;
dojo.provide("dojox.collections.tests.Set");
dojo.require("dojox.collections.Set");
 
(function(){
var dxcs=dojox.collections.Set;
var a = ["apple","bear","candy","donut","epiphite","frank"];
var b = ["bear","epiphite","google","happy","joy"];
tests.register("dojox.collections.tests.Set", [
function testUnion(t){
var union=dxcs.union(a,b);
t.assertEqual("apple,bear,candy,donut,epiphite,frank,google,happy,joy", union.toArray().join(','));
},
function testIntersection(t){
var itsn=dxcs.intersection(a,b);
t.assertEqual("bear,epiphite", itsn.toArray().join(","));
t.assertEqual("bear", dxcs.intersection(["bear","apple"], ["bear"]));
},
function testDifference(t){
var d=dxcs.difference(a,b);
t.assertEqual("apple,candy,donut,frank",d.toArray().join(','));
},
function testIsSubSet(t){
t.assertFalse(dxcs.isSubSet(a,["bear","candy"]));
t.assertTrue(dxcs.isSubSet(["bear","candy"],a));
},
function testIsSuperSet(t){
t.assertTrue(dxcs.isSuperSet(a,["bear","candy"]));
t.assertFalse(dxcs.isSuperSet(["bear","candy"],a));
}
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/collections/tests/SortedList.js
New file
0,0 → 1,168
if(!dojo._hasResource["dojox.collections.tests.SortedList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.tests.SortedList"] = true;
dojo.provide("dojox.collections.tests.SortedList");
dojo.require("dojox.collections.SortedList");
 
tests.register("dojox.collections.tests.SortedList", [
function testCtor(t){
var sl=new dojox.collections.SortedList();
t.assertTrue(sl instanceof dojox.collections.SortedList);
},
function testAdd(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
t.assertEqual("bar", sl.item("foo").valueOf());
},
function testClear(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.clear();
t.assertEqual(0, sl.count);
},
function testClone(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
var sl2=sl.clone();
t.assertTrue(sl2.contains("baz"));
},
function testContains(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
t.assertTrue(sl.contains("baz"));
t.assertFalse(sl.contains("faz"));
},
function testContainsKey(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
t.assertTrue(sl.containsKey("buck"));
t.assertFalse(sl.containsKey("faz"));
},
function testContainsValue(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
t.assertTrue(sl.containsValue("shot"));
t.assertFalse(sl.containsValue("faz"));
},
function testGetKeyList(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
t.assertEqual("foo,baz,buck,apple",sl.getKeyList().join(','));
},
function testGetValueList(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
t.assertEqual("bar,fab,shot,orange",sl.getValueList().join(','));
},
function testCopyTo(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
var arr=["bek"];
sl.copyTo(arr,0);
t.assertEqual("bar,fab,shot,orange,bek", arr.join(','));
},
function testGetByIndex(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
t.assertEqual("shot", sl.getByIndex(2));
},
function testGetKey(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
t.assertEqual("apple", sl.getKey(0));
},
function testIndexOfKey(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
t.assertEqual(0, sl.indexOfKey("apple"));
},
function testIndexOfValue(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
t.assertEqual(3, sl.indexOfValue("bar"));
},
function testRemove(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
sl.remove("baz");
t.assertEqual(3, sl.count);
t.assertEqual(undefined, sl.item("baz"));
},
function testRemoveAt(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
sl.removeAt(2);
t.assertEqual(undefined, sl.item("buck"));
},
function testReplace(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
sl.replace("buck","dollar");
t.assertEqual(sl.item("buck").valueOf(), "dollar");
},
function testSetByIndex(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
sl.setByIndex(0, "bar");
t.assertEqual("bar", sl.getByIndex(0));
},
function testSorting(t){
var sl=new dojox.collections.SortedList();
sl.add("foo","bar");
sl.add("baz","fab");
sl.add("buck","shot");
sl.add("apple","orange");
 
var a=[];
sl.forEach(function(item){
a.push(item);
});
t.assertEqual("orange,fab,shot,bar", a.join());
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/collections/tests/collections.js
New file
0,0 → 1,19
if(!dojo._hasResource["dojox.collections.tests.collections"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.tests.collections"] = true;
dojo.provide("dojox.collections.tests.collections");
dojo.require("dojox.collections");
 
try{
dojo.require("dojox.collections.tests._base");
dojo.require("dojox.collections.tests.ArrayList");
dojo.require("dojox.collections.tests.BinaryTree");
dojo.require("dojox.collections.tests.Dictionary");
dojo.require("dojox.collections.tests.Queue");
dojo.require("dojox.collections.tests.Set");
dojo.require("dojox.collections.tests.SortedList");
dojo.require("dojox.collections.tests.Stack");
}catch(e){
doh.debug(e);
}
 
}
/trunk/api/js/dojo1.0/dojox/collections/tests/runTests.html
New file
0,0 → 1,9
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dojox.wire Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.collections.tests.collections"></HEAD>
<BODY>
Redirecting to D.O.H runner.
</BODY>
</HTML>
/trunk/api/js/dojo1.0/dojox/collections/tests/BinaryTree.js
New file
0,0 → 1,83
if(!dojo._hasResource["dojox.collections.tests.BinaryTree"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.tests.BinaryTree"] = true;
dojo.provide("dojox.collections.tests.BinaryTree");
dojo.require("dojox.collections.BinaryTree");
 
tests.register("dojox.collections.tests.BinaryTree", [
function testCtor(t){
var bt=new dojox.collections.BinaryTree("foo");
t.assertTrue(bt instanceof dojox.collections.BinaryTree);
},
function testAdd(t){
var bt=new dojox.collections.BinaryTree("foo");
bt.add("bar");
bt.add("baz");
bt.add("buck");
bt.add("shot");
bt.add("apple");
t.assertEqual("apple,bar,baz,buck,foo,shot",bt.toString());
},
function testClear(t){
var bt=new dojox.collections.BinaryTree("foo");
bt.add("bar");
bt.add("baz");
bt.add("buck");
bt.add("shot");
bt.add("apple");
bt.clear();
t.assertEqual(bt.count, 0);
},
function testClone(t){
var bt=new dojox.collections.BinaryTree("foo");
bt.add("bar");
bt.add("baz");
bt.add("buck");
bt.add("shot");
bt.add("apple");
var bt2=bt.clone();
t.assertEqual(bt2.count, 6);
t.assertEqual(bt.toString(), bt2.toString());
},
function testContains(t){
var bt=new dojox.collections.BinaryTree("foo");
bt.add("bar");
bt.add("baz");
bt.add("buck");
bt.add("shot");
bt.add("apple");
t.assertTrue(bt.contains("buck"));
t.assertFalse(bt.contains("duck"));
},
function testDeleteData(t){
var bt=new dojox.collections.BinaryTree("foo");
bt.add("bar");
bt.add("baz");
bt.add("buck");
bt.add("shot");
bt.add("apple");
bt.deleteData("buck");
t.assertEqual("apple,bar,baz,foo,shot",bt.toString());
},
function testGetIterator(t){
var bt=new dojox.collections.BinaryTree("foo");
bt.add("bar");
bt.add("baz");
bt.add("buck");
bt.add("shot");
bt.add("apple");
var itr=bt.getIterator();
while(!itr.atEnd()){ itr.get(); }
t.assertEqual("shot", itr.element);
},
function testSearch(t){
var bt=new dojox.collections.BinaryTree("foo");
bt.add("bar");
bt.add("baz");
bt.add("buck");
bt.add("shot");
bt.add("apple");
t.assertEqual("buck", bt.search("buck").value);
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/collections/tests/Queue.js
New file
0,0 → 1,49
if(!dojo._hasResource["dojox.collections.tests.Queue"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.tests.Queue"] = true;
dojo.provide("dojox.collections.tests.Queue");
dojo.require("dojox.collections.Queue");
 
tests.register("dojox.collections.tests.Queue", [
function testCtor(t){
var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
t.assertEqual(4, q.count);
},
function testClear(t){
var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
q.clear();
t.assertEqual(0, q.count);
},
function testClone(t){
var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
var cloned=q.clone();
t.assertEqual(q.count, cloned.count);
t.assertEqual(q.toArray().join(), cloned.toArray().join());
},
function testContains(t){
var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
t.assertTrue(q.contains("bar"));
t.assertFalse(q.contains("faz"));
},
function testGetIterator(t){
var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
var itr=q.getIterator();
while(!itr.atEnd()){ itr.get(); }
t.assertEqual("bull", itr.element);
},
function testPeek(t){
var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
t.assertEqual("foo", q.peek());
},
function testDequeue(t){
var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
t.assertEqual("foo", q.dequeue());
t.assertEqual("bar,test,bull", q.toArray().join(","));
},
function testEnqueue(t){
var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
q.enqueue("bull");
t.assertEqual("bull", q.toArray().pop());
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/collections/tests/Dictionary.js
New file
0,0 → 1,82
if(!dojo._hasResource["dojox.collections.tests.Dictionary"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.tests.Dictionary"] = true;
dojo.provide("dojox.collections.tests.Dictionary");
dojo.require("dojox.collections.Dictionary");
 
tests.register("dojox.collections.tests.Dictionary", [
function testCtor(t){
var d=new dojox.collections.Dictionary();
t.assertTrue(d instanceof dojox.collections.Dictionary);
},
function testAdd(t){
var d=new dojox.collections.Dictionary();
d.add("foo","bar");
t.assertEqual("bar", d.item("foo").valueOf());
},
function testClear(t){
var d=new dojox.collections.Dictionary();
d.add("foo","bar");
d.clear()
t.assertEqual(0, d.count);
},
function testClone(t){
var d=new dojox.collections.Dictionary();
d.add("baz","fab");
d.add("buck","shot");
d.add("apple","orange");
var d2 = d.clone();
t.assertTrue(d2.contains("baz"));
},
function testContains(t){
var d=new dojox.collections.Dictionary();
d.add("foo","bar");
d.add("baz","fab");
d.add("buck","shot");
d.add("apple","orange");
t.assertTrue(d.contains("baz"));
},
function testContainsKey(t){
var d=new dojox.collections.Dictionary();
d.add("foo","bar");
d.add("baz","fab");
d.add("buck","shot");
d.add("apple","orange");
t.assertTrue(d.containsKey("buck"));
},
function testContainsValue(t){
var d=new dojox.collections.Dictionary();
d.add("foo","bar");
d.add("baz","fab");
d.add("buck","shot");
d.add("apple","orange");
t.assertTrue(d.containsValue("shot"));
},
function testGetKeyList(t){
var d=new dojox.collections.Dictionary();
d.add("foo","bar");
d.add("baz","fab");
d.add("buck","shot");
d.add("apple","orange");
t.assertEqual("foo,baz,buck,apple", d.getKeyList().join(","));
},
function testGetValueList(t){
var d=new dojox.collections.Dictionary();
d.add("foo","bar");
d.add("baz","fab");
d.add("buck","shot");
d.add("apple","orange");
t.assertEqual("bar,fab,shot,orange", d.getValueList().join(","));
},
function testRemove(t){
var d=new dojox.collections.Dictionary();
d.add("foo","bar");
d.add("baz","fab");
d.add("buck","shot");
d.add("apple","orange");
d.remove("baz");
t.assertEqual(3, d.count);
t.assertEqual(undefined, d.item("baz"));
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/collections/tests/Stack.js
New file
0,0 → 1,49
if(!dojo._hasResource["dojox.collections.tests.Stack"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.tests.Stack"] = true;
dojo.provide("dojox.collections.tests.Stack");
dojo.require("dojox.collections.Stack");
 
tests.register("dojox.collections.tests.Stack", [
function testCtor(t){
var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
t.assertEqual(4, s.count);
},
function testClear(t){
var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
s.clear();
t.assertEqual(0, s.count);
},
function testClone(t){
var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
var cloned=s.clone();
t.assertEqual(s.count, cloned.count);
t.assertEqual(s.toArray().join(), cloned.toArray().join());
},
function testContains(t){
var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
t.assertTrue(s.contains("bar"));
t.assertFalse(s.contains("faz"));
},
function testGetIterator(t){
var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
var itr=s.getIterator();
while(!itr.atEnd()){ itr.get(); }
t.assertEqual("bull", itr.element);
},
function testPeek(t){
var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
t.assertEqual("bull", s.peek());
},
function testPop(t){
var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
t.assertEqual("bull", s.pop());
t.assertEqual("test", s.pop());
},
function testPush(t){
var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
s.push("bug");
t.assertEqual("bug", s.peek());
}
]);
 
}
/trunk/api/js/dojo1.0/dojox/collections/_base.js
New file
0,0 → 1,100
if(!dojo._hasResource["dojox.collections._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections._base"] = true;
dojo.provide("dojox.collections._base");
 
dojox.collections.DictionaryEntry=function(/* string */k, /* object */v){
// summary
// return an object of type dojox.collections.DictionaryEntry
this.key=k;
this.value=v;
this.valueOf=function(){
return this.value; // object
};
this.toString=function(){
return String(this.value); // string
};
}
 
/* Iterators
* The collections.Iterators (Iterator and DictionaryIterator) are built to
* work with the Collections included in this module. However, they *can*
* be used with arrays and objects, respectively, should one choose to do so.
*/
dojox.collections.Iterator=function(/* array */arr){
// summary
// return an object of type dojox.collections.Iterator
var a=arr;
var position=0;
this.element=a[position]||null;
this.atEnd=function(){
// summary
// Test to see if the internal cursor has reached the end of the internal collection.
return (position>=a.length); // bool
};
this.get=function(){
// summary
// Get the next member in the collection.
if(this.atEnd()){
return null; // object
}
this.element=a[position++];
return this.element; // object
};
this.map=function(/* function */fn, /* object? */scope){
// summary
// Functional iteration with optional scope.
return dojo.map(a, fn, scope);
};
this.reset=function(){
// summary
// reset the internal cursor.
position=0;
this.element=a[position];
};
}
 
/* Notes:
* The DictionaryIterator no longer supports a key and value property;
* the reality is that you can use this to iterate over a JS object
* being used as a hashtable.
*/
dojox.collections.DictionaryIterator=function(/* object */obj){
// summary
// return an object of type dojox.collections.DictionaryIterator
var a=[]; // Create an indexing array
var testObject={};
for(var p in obj){
if(!testObject[p]){
a.push(obj[p]); // fill it up
}
}
var position=0;
this.element=a[position]||null;
this.atEnd=function(){
// summary
// Test to see if the internal cursor has reached the end of the internal collection.
return (position>=a.length); // bool
};
this.get=function(){
// summary
// Get the next member in the collection.
if(this.atEnd()){
return null; // object
}
this.element=a[position++];
return this.element; // object
};
this.map=function(/* function */fn, /* object? */scope){
// summary
// Functional iteration with optional scope.
return dojo.map(a, fn, scope);
};
this.reset=function() {
// summary
// reset the internal cursor.
position=0;
this.element=a[position];
};
};
 
}
/trunk/api/js/dojo1.0/dojox/collections/ArrayList.js
New file
0,0 → 1,133
if(!dojo._hasResource["dojox.collections.ArrayList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.ArrayList"] = true;
dojo.provide("dojox.collections.ArrayList");
dojo.require("dojox.collections._base");
 
dojox.collections.ArrayList=function(/* array? */arr){
// summary
// Returns a new object of type dojox.collections.ArrayList
var items=[];
if(arr) items=items.concat(arr);
this.count=items.length;
this.add=function(/* object */obj){
// summary
// Add an element to the collection.
items.push(obj);
this.count=items.length;
};
this.addRange=function(/* array */a){
// summary
// Add a range of objects to the ArrayList
if(a.getIterator){
var e=a.getIterator();
while(!e.atEnd()){
this.add(e.get());
}
this.count=items.length;
}else{
for(var i=0; i<a.length; i++){
items.push(a[i]);
}
this.count=items.length;
}
};
this.clear=function(){
// summary
// Clear all elements out of the collection, and reset the count.
items.splice(0, items.length);
this.count=0;
};
this.clone=function(){
// summary
// Clone the array list
return new dojox.collections.ArrayList(items); // dojox.collections.ArrayList
};
this.contains=function(/* object */obj){
// summary
// Check to see if the passed object is a member in the ArrayList
for(var i=0; i < items.length; i++){
if(items[i] == obj) {
return true; // bool
}
}
return false; // bool
};
this.forEach=function(/* function */ fn, /* object? */ scope){
// summary
// functional iterator, following the mozilla spec.
dojo.forEach(items, fn, scope);
};
this.getIterator=function(){
// summary
// Get an Iterator for this object
return new dojox.collections.Iterator(items); // dojox.collections.Iterator
};
this.indexOf=function(/* object */obj){
// summary
// Return the numeric index of the passed object; will return -1 if not found.
for(var i=0; i < items.length; i++){
if(items[i] == obj) {
return i; // int
}
}
return -1; // int
};
this.insert=function(/* int */ i, /* object */ obj){
// summary
// Insert the passed object at index i
items.splice(i,0,obj);
this.count=items.length;
};
this.item=function(/* int */ i){
// summary
// return the element at index i
return items[i]; // object
};
this.remove=function(/* object */obj){
// summary
// Look for the passed object, and if found, remove it from the internal array.
var i=this.indexOf(obj);
if(i >=0) {
items.splice(i,1);
}
this.count=items.length;
};
this.removeAt=function(/* int */ i){
// summary
// return an array with function applied to all elements
items.splice(i,1);
this.count=items.length;
};
this.reverse=function(){
// summary
// Reverse the internal array
items.reverse();
};
this.sort=function(/* function? */ fn){
// summary
// sort the internal array
if(fn){
items.sort(fn);
}else{
items.sort();
}
};
this.setByIndex=function(/* int */ i, /* object */ obj){
// summary
// Set an element in the array by the passed index.
items[i]=obj;
this.count=items.length;
};
this.toArray=function(){
// summary
// Return a new array with all of the items of the internal array concatenated.
return [].concat(items);
}
this.toString=function(/* string */ delim){
// summary
// implementation of toString, follows [].toString();
return items.join((delim||","));
};
};
 
}
/trunk/api/js/dojo1.0/dojox/collections/Set.js
New file
0,0 → 1,89
if(!dojo._hasResource["dojox.collections.Set"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.Set"] = true;
dojo.provide("dojox.collections.Set");
dojo.require("dojox.collections.ArrayList");
 
(function(){
var dxc=dojox.collections;
dxc.Set=new (function(){
function conv(arr){
if(arr.constructor==Array){
return new dojox.collections.ArrayList(arr); // dojox.collections.ArrayList
}
return arr; // dojox.collections.ArrayList
}
this.union = function(/* array */setA, /* array */setB){
// summary
// Return the union of the two passed sets.
setA=conv(setA);
setB=conv(setB);
var result = new dojox.collections.ArrayList(setA.toArray());
var e = setB.getIterator();
while(!e.atEnd()){
var item=e.get();
if(!result.contains(item)){
result.add(item);
}
}
return result; // dojox.collections.ArrayList
};
this.intersection = function(/* array */setA, /* array */setB){
// summary
// Return the intersection of the two passed sets.
setA=conv(setA);
setB=conv(setB);
var result = new dojox.collections.ArrayList();
var e = setB.getIterator();
while(!e.atEnd()){
var item=e.get();
if(setA.contains(item)){
result.add(item);
}
}
return result; // dojox.collections.ArrayList
};
this.difference = function(/* array */setA, /* array */setB){
// summary
// Returns everything in setA that is not in setB.
setA=conv(setA);
setB=conv(setB);
var result = new dojox.collections.ArrayList();
var e=setA.getIterator();
while(!e.atEnd()){
var item=e.get();
if(!setB.contains(item)){
result.add(item);
}
}
return result; // dojox.collections.ArrayList
};
this.isSubSet = function(/* array */setA, /* array */setB) {
// summary
// Returns if set B is a subset of set A.
setA=conv(setA);
setB=conv(setB);
var e = setA.getIterator();
while(!e.atEnd()){
if(!setB.contains(e.get())){
return false; // boolean
}
}
return true; // boolean
};
this.isSuperSet = function(/* array */setA, /* array */setB){
// summary
// Returns if set B is a superset of set A.
setA=conv(setA);
setB=conv(setB);
var e = setB.getIterator();
while(!e.atEnd()){
if(!setA.contains(e.get())){
return false; // boolean
}
}
return true; // boolean
};
})();
})();
 
}
/trunk/api/js/dojo1.0/dojox/crypto/MD5.js
New file
0,0 → 1,204
if(!dojo._hasResource["dojox.crypto.MD5"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.crypto.MD5"] = true;
dojo.provide("dojox.crypto.MD5");
 
dojo.require("dojox.crypto._base");
 
/* Return to a port of Paul Johnstone's MD5 implementation
* http://pajhome.org.uk/crypt/md5/index.html
*
* Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
*
* Dojo port by Tom Trenka
*
* 2005-12-7
* All conversions are internalized (no dependencies)
* implemented getHMAC for message digest auth.
*/
dojox.crypto.MD5 = new function(){
// summary
// object for creating digests using the MD5 algorithm
var chrsz=8;
var mask=(1<<chrsz)-1;
function toWord(s) {
var wa=[];
for(var i=0; i<s.length*chrsz; i+=chrsz)
wa[i>>5]|=(s.charCodeAt(i/chrsz)&mask)<<(i%32);
return wa;
}
function toString(wa){
var s=[];
for(var i=0; i<wa.length*32; i+=chrsz)
s.push(String.fromCharCode((wa[i>>5]>>>(i%32))&mask));
return s.join("");
}
function toHex(wa) {
var h="0123456789abcdef";
var s=[];
for(var i=0; i<wa.length*4; i++){
s.push(h.charAt((wa[i>>2]>>((i%4)*8+4))&0xF)+h.charAt((wa[i>>2]>>((i%4)*8))&0xF));
}
return s.join("");
}
function toBase64(wa){
var p="=";
var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var s=[];
for(var i=0; i<wa.length*4; i+=3){
var t=(((wa[i>>2]>>8*(i%4))&0xFF)<<16)|(((wa[i+1>>2]>>8*((i+1)%4))&0xFF)<<8)|((wa[i+2>>2]>>8*((i+2)%4))&0xFF);
for(var j=0; j<4; j++){
if(i*8+j*6>wa.length*32) s.push(p);
else s.push(tab.charAt((t>>6*(3-j))&0x3F));
}
}
return s.join("");
}
function add(x,y) {
var l=(x&0xFFFF)+(y&0xFFFF);
var m=(x>>16)+(y>>16)+(l>>16);
return (m<<16)|(l&0xFFFF);
}
function R(n,c){ return (n<<c)|(n>>>(32-c)); }
function C(q,a,b,x,s,t){ return add(R(add(add(a,q),add(x,t)),s),b); }
function FF(a,b,c,d,x,s,t){ return C((b&c)|((~b)&d),a,b,x,s,t); }
function GG(a,b,c,d,x,s,t){ return C((b&d)|(c&(~d)),a,b,x,s,t); }
function HH(a,b,c,d,x,s,t){ return C(b^c^d,a,b,x,s,t); }
function II(a,b,c,d,x,s,t){ return C(c^(b|(~d)),a,b,x,s,t); }
function core(x,len){
x[len>>5]|=0x80<<((len)%32);
x[(((len+64)>>>9)<<4)+14]=len;
var a= 1732584193;
var b=-271733879;
var c=-1732584194;
var d= 271733878;
for(var i=0; i<x.length; i+=16){
var olda=a;
var oldb=b;
var oldc=c;
var oldd=d;
 
a=FF(a,b,c,d,x[i+ 0],7 ,-680876936);
d=FF(d,a,b,c,x[i+ 1],12,-389564586);
c=FF(c,d,a,b,x[i+ 2],17, 606105819);
b=FF(b,c,d,a,x[i+ 3],22,-1044525330);
a=FF(a,b,c,d,x[i+ 4],7 ,-176418897);
d=FF(d,a,b,c,x[i+ 5],12, 1200080426);
c=FF(c,d,a,b,x[i+ 6],17,-1473231341);
b=FF(b,c,d,a,x[i+ 7],22,-45705983);
a=FF(a,b,c,d,x[i+ 8],7 , 1770035416);
d=FF(d,a,b,c,x[i+ 9],12,-1958414417);
c=FF(c,d,a,b,x[i+10],17,-42063);
b=FF(b,c,d,a,x[i+11],22,-1990404162);
a=FF(a,b,c,d,x[i+12],7 , 1804603682);
d=FF(d,a,b,c,x[i+13],12,-40341101);
c=FF(c,d,a,b,x[i+14],17,-1502002290);
b=FF(b,c,d,a,x[i+15],22, 1236535329);
 
a=GG(a,b,c,d,x[i+ 1],5 ,-165796510);
d=GG(d,a,b,c,x[i+ 6],9 ,-1069501632);
c=GG(c,d,a,b,x[i+11],14, 643717713);
b=GG(b,c,d,a,x[i+ 0],20,-373897302);
a=GG(a,b,c,d,x[i+ 5],5 ,-701558691);
d=GG(d,a,b,c,x[i+10],9 , 38016083);
c=GG(c,d,a,b,x[i+15],14,-660478335);
b=GG(b,c,d,a,x[i+ 4],20,-405537848);
a=GG(a,b,c,d,x[i+ 9],5 , 568446438);
d=GG(d,a,b,c,x[i+14],9 ,-1019803690);
c=GG(c,d,a,b,x[i+ 3],14,-187363961);
b=GG(b,c,d,a,x[i+ 8],20, 1163531501);
a=GG(a,b,c,d,x[i+13],5 ,-1444681467);
d=GG(d,a,b,c,x[i+ 2],9 ,-51403784);
c=GG(c,d,a,b,x[i+ 7],14, 1735328473);
b=GG(b,c,d,a,x[i+12],20,-1926607734);
 
a=HH(a,b,c,d,x[i+ 5],4 ,-378558);
d=HH(d,a,b,c,x[i+ 8],11,-2022574463);
c=HH(c,d,a,b,x[i+11],16, 1839030562);
b=HH(b,c,d,a,x[i+14],23,-35309556);
a=HH(a,b,c,d,x[i+ 1],4 ,-1530992060);
d=HH(d,a,b,c,x[i+ 4],11, 1272893353);
c=HH(c,d,a,b,x[i+ 7],16,-155497632);
b=HH(b,c,d,a,x[i+10],23,-1094730640);
a=HH(a,b,c,d,x[i+13],4 , 681279174);
d=HH(d,a,b,c,x[i+ 0],11,-358537222);
c=HH(c,d,a,b,x[i+ 3],16,-722521979);
b=HH(b,c,d,a,x[i+ 6],23, 76029189);
a=HH(a,b,c,d,x[i+ 9],4 ,-640364487);
d=HH(d,a,b,c,x[i+12],11,-421815835);
c=HH(c,d,a,b,x[i+15],16, 530742520);
b=HH(b,c,d,a,x[i+ 2],23,-995338651);
 
a=II(a,b,c,d,x[i+ 0],6 ,-198630844);
d=II(d,a,b,c,x[i+ 7],10, 1126891415);
c=II(c,d,a,b,x[i+14],15,-1416354905);
b=II(b,c,d,a,x[i+ 5],21,-57434055);
a=II(a,b,c,d,x[i+12],6 , 1700485571);
d=II(d,a,b,c,x[i+ 3],10,-1894986606);
c=II(c,d,a,b,x[i+10],15,-1051523);
b=II(b,c,d,a,x[i+ 1],21,-2054922799);
a=II(a,b,c,d,x[i+ 8],6 , 1873313359);
d=II(d,a,b,c,x[i+15],10,-30611744);
c=II(c,d,a,b,x[i+ 6],15,-1560198380);
b=II(b,c,d,a,x[i+13],21, 1309151649);
a=II(a,b,c,d,x[i+ 4],6 ,-145523070);
d=II(d,a,b,c,x[i+11],10,-1120210379);
c=II(c,d,a,b,x[i+ 2],15, 718787259);
b=II(b,c,d,a,x[i+ 9],21,-343485551);
 
a = add(a,olda);
b = add(b,oldb);
c = add(c,oldc);
d = add(d,oldd);
}
return [a,b,c,d];
}
function hmac(data,key){
var wa=toWord(key);
if(wa.length>16) wa=core(wa,key.length*chrsz);
var l=[], r=[];
for(var i=0; i<16; i++){
l[i]=wa[i]^0x36363636;
r[i]=wa[i]^0x5c5c5c5c;
}
var h=core(l.concat(toWord(data)),512+data.length*chrsz);
return core(r.concat(h),640);
}
 
// Public functions
this.compute=function(/* string */data, /* dojox.crypto.outputTypes */outputType){
// summary
// computes the digest of data, and returns the result as a string of type outputType
var out=outputType||dojox.crypto.outputTypes.Base64;
switch(out){
case dojox.crypto.outputTypes.Hex:{
return toHex(core(toWord(data),data.length*chrsz)); // string
}
case dojox.crypto.outputTypes.String:{
return toString(core(toWord(data),data.length*chrsz)); // string
}
default:{
return toBase64(core(toWord(data),data.length*chrsz)); // string
}
}
};
this.getHMAC=function(/* string */data, /* string */key, /* dojox.crypto.outputTypes */outputType){
// summary
// computes a digest of data using key, and returns the result as a string of outputType
var out=outputType||dojox.crypto.outputTypes.Base64;
switch(out){
case dojox.crypto.outputTypes.Hex:{
return toHex(hmac(data,key)); // string
}
case dojox.crypto.outputTypes.String:{
return toString(hmac(data,key)); // string
}
default:{
return toBase64(hmac(data,key)); // string
}
}
};
}();
 
}
/trunk/api/js/dojo1.0/dojox/crypto/LICENSE
New file
0,0 → 1,9
License Disclaimer:
 
All contents of this directory are Copyright (c) the Dojo Foundation, with the
following exceptions:
-------------------------------------------------------------------------------
 
MD5.js, SHA1.js:
* Copyright 1998-2005, Paul Johnstone
Distributed under the terms of the BSD License
/trunk/api/js/dojo1.0/dojox/crypto/tests/MD5.js
New file
0,0 → 1,26
if(!dojo._hasResource["dojox.crypto.tests.MD5"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.crypto.tests.MD5"] = true;
dojo.provide("dojox.crypto.tests.MD5");
dojo.require("dojox.crypto.MD5");
 
(function(){
var message="The rain in Spain falls mainly on the plain.";
var base64="OUhxbVZ1Mtmu4zx9LzS5cA==";
var hex="3948716d567532d9aee33c7d2f34b970";
var s="9HqmVu2\xD9\xAE\xE3<}/4\xB9p";
var dxc=dojox.crypto;
 
tests.register("dojox.crypto.tests.MD5", [
function testBase64Compute(t){
t.assertEqual(base64, dxc.MD5.compute(message));
},
function testHexCompute(t){
t.assertEqual(hex, dxc.MD5.compute(message, dxc.outputTypes.Hex));
},
function testStringCompute(t){
t.assertEqual(s, dxc.MD5.compute(message, dxc.outputTypes.String));
}
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/crypto/tests/Blowfish.js
New file
0,0 → 1,29
if(!dojo._hasResource["dojox.crypto.tests.Blowfish"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.crypto.tests.Blowfish"] = true;
dojo.provide("dojox.crypto.tests.Blowfish");
dojo.require("dojox.crypto.Blowfish");
 
(function(){
var message="The rain in Spain falls mainly on the plain.";
var key="foobar";
var base64Encrypted="WI5J5BPPVBuiTniVcl7KlIyNMmCosmKTU6a/ueyQuoUXyC5dERzwwdzfFsiU4vBw";
var dxc=dojox.crypto;
 
tests.register("dojox.crypto.tests.Blowfish", [
function testEncrypt(t){
t.assertEqual(base64Encrypted, dxc.Blowfish.encrypt(message, key));
},
function testDecrypt(t){
t.assertEqual(message, dxc.Blowfish.decrypt(base64Encrypted, key));
},
function testShortMessage(t){
var msg="pass";
var pwd="foobar";
var enc=dxc.Blowfish.encrypt(msg, pwd);
var dec=dxc.Blowfish.decrypt(enc, pwd);
t.assertEqual(dec, msg);
}
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/crypto/tests/runTests.html
New file
0,0 → 1,9
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dojox.wire Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.crypto.tests.crypto"></HEAD>
<BODY>
Redirecting to D.O.H runner.
</BODY>
</HTML>
/trunk/api/js/dojo1.0/dojox/crypto/tests/crypto.js
New file
0,0 → 1,13
if(!dojo._hasResource["dojox.crypto.tests.crypto"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.crypto.tests.crypto"] = true;
dojo.provide("dojox.crypto.tests.crypto");
dojo.require("dojox.crypto");
 
try{
dojo.require("dojox.crypto.tests.MD5");
dojo.require("dojox.crypto.tests.Blowfish");
}catch(e){
doh.debug(e);
}
 
}
/trunk/api/js/dojo1.0/dojox/crypto/_base.js
New file
0,0 → 1,19
if(!dojo._hasResource["dojox.crypto._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.crypto._base"] = true;
dojo.provide("dojox.crypto._base");
 
(function(){
var dxc=dojox.crypto;
dxc.cipherModes={
// summary
// Enumeration for various cipher modes.
ECB:0, CBC:1, PCBC:2, CFB:3, OFB:4, CTR:5
};
dxc.outputTypes={
// summary
// Enumeration for input and output encodings.
Base64:0, Hex:1, String:2, Raw:3
};
})();
 
}
/trunk/api/js/dojo1.0/dojox/crypto/Blowfish.js
New file
0,0 → 1,576
if(!dojo._hasResource["dojox.crypto.Blowfish"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.crypto.Blowfish"] = true;
dojo.provide("dojox.crypto.Blowfish");
 
dojo.require("dojox.crypto._base");
 
/* Blowfish
* Created based on the C# implementation by Marcus Hahn (http://www.hotpixel.net/)
* Unsigned math functions derived from Joe Gregorio's SecureSyndication GM script
* http://bitworking.org/projects/securesyndication/
* (Note that this is *not* an adaption of the above script)
*
* version 1.0
* TRT
* 2005-12-08
*/
dojox.crypto.Blowfish = new function(){
// summary
// Object for doing Blowfish encryption/decryption.
var POW2=Math.pow(2,2);
var POW3=Math.pow(2,3);
var POW4=Math.pow(2,4);
var POW8=Math.pow(2,8);
var POW16=Math.pow(2,16);
var POW24=Math.pow(2,24);
var iv=null; // CBC mode initialization vector
var boxes={
p:[
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
0x9216d5d9, 0x8979fb1b
],
s0:[
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a
],
s1:[
0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7
],
s2:[
0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0
],
s3:[
0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
]
}
////////////////////////////////////////////////////////////////////////////
function add(x,y){
var sum=(x+y)&0xffffffff;
if (sum<0){
sum=-sum;
return (0x10000*((sum>>16)^0xffff))+(((sum&0xffff)^0xffff)+1);
}
return sum;
}
function split(x){
var r=x&0xffffffff;
if(r<0) {
r=-r;
return [((r&0xffff)^0xffff)+1,(r>>16)^0xffff];
}
return [r&0xffff,(r>>16)];
}
function xor(x,y){
var xs=split(x);
var ys=split(y);
return (0x10000*(xs[1]^ys[1]))+(xs[0]^ys[0]);
}
function $(v, box){
var d=v&0xff; v>>=8;
var c=v&0xff; v>>=8;
var b=v&0xff; v>>=8;
var a=v&0xff;
var r=add(box.s0[a],box.s1[b]);
r=xor(r,box.s2[c]);
return add(r,box.s3[d]);
}
////////////////////////////////////////////////////////////////////////////
function eb(o, box){
var l=o.left;
var r=o.right;
l=xor(l,box.p[0]);
r=xor(r,xor($(l,box),box.p[1]));
l=xor(l,xor($(r,box),box.p[2]));
r=xor(r,xor($(l,box),box.p[3]));
l=xor(l,xor($(r,box),box.p[4]));
r=xor(r,xor($(l,box),box.p[5]));
l=xor(l,xor($(r,box),box.p[6]));
r=xor(r,xor($(l,box),box.p[7]));
l=xor(l,xor($(r,box),box.p[8]));
r=xor(r,xor($(l,box),box.p[9]));
l=xor(l,xor($(r,box),box.p[10]));
r=xor(r,xor($(l,box),box.p[11]));
l=xor(l,xor($(r,box),box.p[12]));
r=xor(r,xor($(l,box),box.p[13]));
l=xor(l,xor($(r,box),box.p[14]));
r=xor(r,xor($(l,box),box.p[15]));
l=xor(l,xor($(r,box),box.p[16]));
o.right=l;
o.left=xor(r,box.p[17]);
}
 
function db(o, box){
var l=o.left;
var r=o.right;
l=xor(l,box.p[17]);
r=xor(r,xor($(l,box),box.p[16]));
l=xor(l,xor($(r,box),box.p[15]));
r=xor(r,xor($(l,box),box.p[14]));
l=xor(l,xor($(r,box),box.p[13]));
r=xor(r,xor($(l,box),box.p[12]));
l=xor(l,xor($(r,box),box.p[11]));
r=xor(r,xor($(l,box),box.p[10]));
l=xor(l,xor($(r,box),box.p[9]));
r=xor(r,xor($(l,box),box.p[8]));
l=xor(l,xor($(r,box),box.p[7]));
r=xor(r,xor($(l,box),box.p[6]));
l=xor(l,xor($(r,box),box.p[5]));
r=xor(r,xor($(l,box),box.p[4]));
l=xor(l,xor($(r,box),box.p[3]));
r=xor(r,xor($(l,box),box.p[2]));
l=xor(l,xor($(r,box),box.p[1]));
o.right=l;
o.left=xor(r,box.p[0]);
}
 
// Note that we aren't caching contexts here; it might take a little longer
// but we should be more secure this way.
function init(key){
var k=key;
if (typeof(k)=="string"){
var a=[];
for(var i=0; i<k.length; i++)
a.push(k.charCodeAt(i)&0xff);
k=a;
}
// init the boxes
var box = { p:[], s0:[], s1:[], s2:[], s3:[] };
for(var i=0; i<boxes.p.length; i++) box.p.push(boxes.p[i]);
for(var i=0; i<boxes.s0.length; i++) box.s0.push(boxes.s0[i]);
for(var i=0; i<boxes.s1.length; i++) box.s1.push(boxes.s1[i]);
for(var i=0; i<boxes.s2.length; i++) box.s2.push(boxes.s2[i]);
for(var i=0; i<boxes.s3.length; i++) box.s3.push(boxes.s3[i]);
 
// init p with the key
var pos=0;
var data=0;
for(var i=0; i < box.p.length; i++){
for (var j=0; j<4; j++){
data = (data*POW8) | k[pos];
if(++pos==k.length) pos=0;
}
box.p[i] = xor(box.p[i], data);
}
 
// encrypt p and the s boxes
var res={ left:0, right:0 };
for(var i=0; i<box.p.length;){
eb(res, box);
box.p[i++]=res.left;
box.p[i++]=res.right;
}
for (var i=0; i<4; i++){
for(var j=0; j<box["s"+i].length;){
eb(res, box);
box["s"+i][j++]=res.left;
box["s"+i][j++]=res.right;
}
}
return box;
}
 
////////////////////////////////////////////////////////////////////////////
// CONVERSION FUNCTIONS
////////////////////////////////////////////////////////////////////////////
// these operate on byte arrays, NOT word arrays.
function toBase64(ba){
var p="=";
var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var s=[];
var l=ba.length;
var rm=l%3;
var x=l-rm;
for (var i=0; i<x;){
var t=ba[i++]<<16|ba[i++]<<8|ba[i++];
s.push(tab.charAt((t>>>18)&0x3f));
s.push(tab.charAt((t>>>12)&0x3f));
s.push(tab.charAt((t>>>6)&0x3f));
s.push(tab.charAt(t&0x3f));
}
// deal with trailers, based on patch from Peter Wood.
switch(rm){
case 2:{
var t=ba[i++]<<16|ba[i++]<<8;
s.push(tab.charAt((t>>>18)&0x3f));
s.push(tab.charAt((t>>>12)&0x3f));
s.push(tab.charAt((t>>>6)&0x3f));
s.push(p);
break;
}
case 1:{
var t=ba[i++]<<16;
s.push(tab.charAt((t>>>18)&0x3f));
s.push(tab.charAt((t>>>12)&0x3f));
s.push(p);
s.push(p);
break;
}
}
return s.join("");
}
function fromBase64(str){
var s=str.split("");
var p="=";
var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var out=[];
var l=s.length;
while(s[--l]==p){ }
for (var i=0; i<l;){
var t=tab.indexOf(s[i++])<<18;
if(i<=l){ t|=tab.indexOf(s[i++])<<12 };
if(i<=l){ t|=tab.indexOf(s[i++])<<6 };
if(i<=l){ t|=tab.indexOf(s[i++]) };
out.push((t>>>16)&0xff);
out.push((t>>>8)&0xff);
out.push(t&0xff);
}
// strip off any null bytes
while(out[out.length-1]==0){ out.pop(); }
return out;
}
////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS
// 0.2: Only supporting ECB mode for now.
////////////////////////////////////////////////////////////////////////////
this.getIV=function(/* dojox.crypto.outputTypes? */ outputType){
// summary
// returns the initialization vector in the output format specified by outputType
var out=outputType||dojox.crypto.outputTypes.Base64;
switch(out){
case dojox.crypto.outputTypes.Hex:{
var s=[];
for(var i=0; i<iv.length; i++)
s.push((iv[i]).toString(16));
return s.join(""); // string
}
case dojox.crypto.outputTypes.String:{
return iv.join(""); // string
}
case dojox.crypto.outputTypes.Raw:{
return iv; // array
}
default:{
return toBase64(iv); // string
}
}
};
this.setIV=function(/* string */data, /* dojox.crypto.outputTypes? */inputType){
// summary
// sets the initialization vector to data (as interpreted as inputType)
var ip=inputType||dojox.crypto.outputTypes.Base64;
var ba=null;
switch(ip){
case dojox.crypto.outputTypes.String:{
ba=[];
for (var i=0; i<data.length; i++){
ba.push(data.charCodeAt(i));
}
break;
}
case dojox.crypto.outputTypes.Hex:{
ba=[];
var i=0;
while (i+1<data.length){
ba.push(parseInt(data.substr(i,2),16));
i+=2;
}
break;
}
case dojox.crypto.outputTypes.Raw:{
ba=data;
break;
}
default:{
ba=fromBase64(data);
break;
}
}
// make it a pair of words now
iv={};
iv.left=ba[0]*POW24|ba[1]*POW16|ba[2]*POW8|ba[3];
iv.right=ba[4]*POW24|ba[5]*POW16|ba[6]*POW8|ba[7];
}
this.encrypt = function(/* string */plaintext, /* string */key, /* object? */ao){
// summary
// encrypts plaintext using key; allows user to specify output type and cipher mode via keyword object "ao"
var out=dojox.crypto.outputTypes.Base64;
var mode=dojox.crypto.cipherModes.EBC;
if (ao){
if (ao.outputType) out=ao.outputType;
if (ao.cipherMode) mode=ao.cipherMode;
}
 
var bx = init(key);
var padding = 8-(plaintext.length&7);
for (var i=0; i<padding; i++) plaintext+=String.fromCharCode(padding);
var cipher=[];
var count=plaintext.length >> 3;
var pos=0;
var o={};
var isCBC=(mode==dojox.crypto.cipherModes.CBC);
var vector={left:iv.left||null, right:iv.right||null};
for(var i=0; i<count; i++){
o.left=plaintext.charCodeAt(pos)*POW24
|plaintext.charCodeAt(pos+1)*POW16
|plaintext.charCodeAt(pos+2)*POW8
|plaintext.charCodeAt(pos+3);
o.right=plaintext.charCodeAt(pos+4)*POW24
|plaintext.charCodeAt(pos+5)*POW16
|plaintext.charCodeAt(pos+6)*POW8
|plaintext.charCodeAt(pos+7);
 
if(isCBC){
o.left=xor(o.left, vector.left);
o.right=xor(o.right, vector.right);
}
 
eb(o, bx); // encrypt the block
 
if(isCBC){
vector.left=o.left;
vector.right=o.right;dojox.crypto.outputTypes.Hex
}
 
cipher.push((o.left>>24)&0xff);
cipher.push((o.left>>16)&0xff);
cipher.push((o.left>>8)&0xff);
cipher.push(o.left&0xff);
cipher.push((o.right>>24)&0xff);
cipher.push((o.right>>16)&0xff);
cipher.push((o.right>>8)&0xff);
cipher.push(o.right&0xff);
pos+=8;
}
switch(out){
case dojox.crypto.outputTypes.Hex:{
var s=[];
for(var i=0; i<cipher.length; i++)
s.push((cipher[i]).toString(16));
return s.join(""); // string
}
case dojox.crypto.outputTypes.String:{
return cipher.join(""); // string
}
case dojox.crypto.outputTypes.Raw:{
return cipher; // array
}
default:{
return toBase64(cipher); // string
}
}
};
 
this.decrypt = function(/* string */ciphertext, /* string */key, /* object? */ao){
// summary
// decrypts ciphertext using key; allows specification of how ciphertext is encoded via ao.
var ip=dojox.crypto.outputTypes.Base64;
var mode=dojox.crypto.cipherModes.EBC;
if (ao){
if (ao.outputType) ip=ao.outputType;
if (ao.cipherMode) mode=ao.cipherMode;
}
var bx = init(key);
var pt=[];
var c=null;
switch(ip){
case dojox.crypto.outputTypes.Hex:{
c=[];
var i=0;
while (i+1<ciphertext.length){
c.push(parseInt(ciphertext.substr(i,2),16));
i+=2;
}
break;
}
case dojox.crypto.outputTypes.String:{
c=[];
for (var i=0; i<ciphertext.length; i++){
c.push(ciphertext.charCodeAt(i));
}
break;
}
case dojox.crypto.outputTypes.Raw:{
c=ciphertext; // should be a byte array
break;
}
default:{
c=fromBase64(ciphertext);
break;
}
}
 
var count=c.length >> 3;
var pos=0;
var o={};
var isCBC=(mode==dojox.crypto.cipherModes.CBC);
var vector={left:iv.left||null, right:iv.right||null};
for(var i=0; i<count; i++){
o.left=c[pos]*POW24|c[pos+1]*POW16|c[pos+2]*POW8|c[pos+3];
o.right=c[pos+4]*POW24|c[pos+5]*POW16|c[pos+6]*POW8|c[pos+7];
 
if(isCBC){
var left=o.left;
var right=o.right;
}
 
db(o, bx); // decrypt the block
 
if(isCBC){
o.left=xor(o.left, vector.left);
o.right=xor(o.right, vector.right);
vector.left=left;
vector.right=right;
}
 
pt.push((o.left>>24)&0xff);
pt.push((o.left>>16)&0xff);
pt.push((o.left>>8)&0xff);
pt.push(o.left&0xff);
pt.push((o.right>>24)&0xff);
pt.push((o.right>>16)&0xff);
pt.push((o.right>>8)&0xff);
pt.push(o.right&0xff);
pos+=8;
}
 
// check for padding, and remove.
if(pt[pt.length-1]==pt[pt.length-2]||pt[pt.length-1]==0x01){
var n=pt[pt.length-1];
pt.splice(pt.length-n, n);
}
 
// convert to string
for(var i=0; i<pt.length; i++)
pt[i]=String.fromCharCode(pt[i]);
return pt.join(""); // string
};
 
this.setIV("0000000000000000", dojox.crypto.outputTypes.Hex);
}();
 
}
/trunk/api/js/dojo1.0/dojox/crypto/README
New file
0,0 → 1,41
-------------------------------------------------------------------------------
DojoX Cryptography
-------------------------------------------------------------------------------
Version 0.9
Release date: 05/27/2007
-------------------------------------------------------------------------------
Project state: beta
-------------------------------------------------------------------------------
Project authors
Tom Trenka (ttrenka@gmail.com)
-------------------------------------------------------------------------------
Project description
 
The DojoX Cryptography project is a set of implementations of public crypto
algorithms. At the time of writing, only MD5 and Blowfish are complete; others
will follow.
 
DojoX Cryptography is comprised of both symmetric (Blowfish) and asymmetric
(MD5) algorithms. Symmetric algs always implement encrypt() and decrypt()
methods; asymmetric algs implement compute().
-------------------------------------------------------------------------------
Dependencies:
 
DojoX Cryptography has no dependencies, outside of the Dojo package system
and DOH.
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/crypto.js
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/crypto/*
 
Install into the following directory structure:
/dojox/crypto/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
Documentation
 
See the Dojo API tool (http://dojotoolkit.org/api)
-------------------------------------------------------------------------------
/trunk/api/js/dojo1.0/dojox/lang/utils.js
New file
0,0 → 1,54
if(!dojo._hasResource["dojox.lang.utils"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.lang.utils"] = true;
dojo.provide("dojox.lang.utils");
 
(function(){
var empty = {}, du = dojox.lang.utils;
dojo.mixin(dojox.lang.utils, {
coerceType: function(target, source){
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.updateObject(t, source[x]);
}else{
target[x] = conv ? du.coerceType(t, source[x]) : dojo.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: Array: an array of properties to be copied
// 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]) : dojo.clone(source[x]);
}
}
return target; // Object
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/lang/README
New file
0,0 → 1,37
-------------------------------------------------------------------------------
dojox.lang
-------------------------------------------------------------------------------
Version 0.990
Release date: 07/30/2007
-------------------------------------------------------------------------------
Project state:
[beta]
-------------------------------------------------------------------------------
Credits
Eugene Lazutkin (eugene.lazutkin@gmail.com)
-------------------------------------------------------------------------------
Project description
 
Implementation of common functional operations, and provisions.
Later we can add other JS language-related helpers.
-------------------------------------------------------------------------------
Dependencies:
 
None.
-------------------------------------------------------------------------------
Documentation
 
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/lang/*
 
Install into the following directory structure:
/dojox/lang/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
Additional Notes
 
See tests and the source for more details.
/trunk/api/js/dojo1.0/dojox/lang/functional.js
New file
0,0 → 1,462
if(!dojo._hasResource["dojox.lang.functional"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.lang.functional"] = true;
dojo.provide("dojox.lang.functional");
 
// This module adds high-level functions and related constructs:
// - list comprehensions similar to JavaScript 1.7
// - anonymous functions built from the string
// - zip combiners
// - "reduce" family of functions
// - currying and partial functions
// - argument pre-processing: mixer and flip
// - miscellaneous useful functions
 
// Acknoledgements:
// - parts of this module (most notably lambda, constFun, invoke, pluck, and partial)
// are based on work by Oliver Steele (http://osteele.com/sources/javascript/functional/functional.js)
// which was published under MIT License
// - Simple "maybe" monad was donated by Alex Russell.
 
// Notes:
// - Dojo provides following high-level functions in dojo/_base/array.js:
// forEach, map, filter, every, some
// - These functions implemented with optional lambda expression as a parameter.
// - missing high-level functions are provided with the compatible API:
// foldl, foldl1, scanl, scanl1, foldr, foldr1, scanr, scanr1,
// reduce, reduceRight
// - lambda() and listcomp() produce functions, which after the compilation step are
// as fast as regular JS functions (at least theoretically).
 
(function(){
var d = dojo, df = dojox.lang.functional, g_re = /\bfor\b|\bif\b/gm, empty = {};
// 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 + "){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 {
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|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, "").
match(/([a-z_$][a-z_$\d]*)/gi) || [];
var t = {};
d.forEach(vars, function(v){
if(!(v in t)){
args.push(v);
t[v] = 1;
}
});
}
}
return {args: args, body: "return (" + s + ");"}; // Object
};
var listcomp = function(/*String*/ s){
var frag = s.split(g_re), act = s.match(g_re),
head = ["var r = [];"], tail = [];
for(var i = 0; i < act.length;){
var a = act[i], f = frag[++i];
if(a == "for" && !/^\s*\(\s*(;|var)/.test(f)){
f = f.replace(/^\s*\(/, "(var ");
}
head.push(a, f, "{");
tail.push("}");
}
return head.join("") + "r.push(" + frag[0] + ");" + tail.join("") + "return r;"; // String
};
var currying = function(/*Object*/ info){
return function(){ // Function
if(arguments.length + info.args.length < info.arity){
return currying({func: info.func, arity: info.arity,
args: Array.prototype.concat.apply(info.args, arguments)});
}
return info.func.apply(this, Array.prototype.concat.apply(info.args, arguments));
};
};
var identity = function(x){ return x; };
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;
};
d.mixin(df, {
// lambda
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.
s = lambda(s);
return "function(" + s.args.join(",") + "){" + s.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); }
s = lambda(s);
return new Function(s.args, s.body); // Function
},
// sequence generators
repeat: function(/*Number*/ n, /*Function|String|Array*/ f, /*Object*/ z, /*Object?*/ o){
// summary: builds an array by repeatedly applying a unary function N times
// with a seed value Z.
o = o || d.global; f = df.lambda(f);
var t = new Array(n);
t[0] = z;
for(var i = 1; i < n; t[i] = z = f.call(o, z), ++i);
return t; // Array
},
until: function(/*Function|String|Array*/ pr, /*Function|String|Array*/ f, /*Object*/ z, /*Object?*/ o){
// summary: builds an array by repeatedly applying a unary function with
// a seed value Z until the predicate is satisfied.
o = o || d.global; f = df.lambda(f); pr = df.lambda(pr);
var t = [];
for(; !pr.call(o, z); t.push(z), z = f.call(o, z));
return t; // Array
},
buildListcomp: function(/*String*/ s){
// summary: builds a function from a text snippet, which represents a valid
// JS 1.7 list comprehension, returns a string, which represents the function.
// description: This method returns a textual representation of a function
// built from the list comprehension text snippet (conformant to JS 1.7).
// It is meant to be evaled in the proper context, so local variable can be
// pulled from the environment.
return "function(){" + listcomp(s) + "}"; // String
},
compileListcomp: function(/*String*/ s){
// summary: builds a function from a text snippet, which represents a valid
// JS 1.7 list comprehension, returns a function object.
// description: This method returns a function built from the list
// comprehension text snippet (conformant to JS 1.7). It is meant to be
// reused several times.
return new Function([], listcomp(s)); // Function
},
listcomp: function(/*String*/ s){
// summary: executes the list comprehension building an array.
return (new Function([], listcomp(s)))(); // Array
},
// classic reduce-class functions
foldl: function(/*Array*/ 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.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
for(var i = 0; i < a.length; z = f.call(o, z, a[i], i, a), ++i);
return z; // Object
},
foldl1: function(/*Array*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary: repeatedly applies a binary function to an array from left
// to right; returns the final value.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
var z = a[0];
for(var i = 1; i < a.length; z = f.call(o, z, a[i], i, a), ++i);
return z; // Object
},
scanl: function(/*Array*/ a, /*Function|String|Array*/ 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 an array
// of values produced by foldl() at that point.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
var n = a.length, t = new Array(n + 1);
t[0] = z;
for(var i = 0; i < n; z = f.call(o, z, a[i], i, a), t[++i] = z);
return t; // Array
},
scanl1: function(/*Array*/ a, /*Function|String|Array*/ f, /*Object*/ z, /*Object?*/ o){
// summary: repeatedly applies a binary function to an array from left
// to right; returns an array of values produced by foldl1() at that
// point.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
var n = a.length, t = new Array(n), z = a[0];
t[0] = z;
for(var i = 1; i < n; z = f.call(o, z, a[i], i, a), t[i++] = z);
return t; // Array
},
foldr: function(/*Array*/ 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.
a = typeof a == "string" ? a.split("") : a; o = o || d.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*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary: repeatedly applies a binary function to an array from right
// to left; returns the final value.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
var n = a.length, z = a[n - 1];
for(var i = n - 1; i > 0; --i, z = f.call(o, z, a[i], i, a));
return z; // Object
},
scanr: function(/*Array*/ 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 an array
// of values produced by foldr() at that point.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
var n = a.length, t = new Array(n + 1);
t[n] = z;
for(var i = n; i > 0; --i, z = f.call(o, z, a[i], i, a), t[i] = z);
return t; // Array
},
scanr1: function(/*Array*/ a, /*Function|String|Array*/ f, /*Object*/ z, /*Object?*/ o){
// summary: repeatedly applies a binary function to an array from right
// to left; returns an array of values produced by foldr1() at that
// point.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
var n = a.length, t = new Array(n), z = a[n - 1];
t[n - 1] = z;
for(var i = n - 1; i > 0; --i, z = f.call(o, z, a[i], i, a), t[i] = z);
return t; // Array
},
// 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*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary: creates a new array with all elements that pass the test
// implemented by the provided function.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
var n = a.length, t = [], v;
for(var i = 0; i < n; ++i){
v = a[i];
if(f.call(o, v, i, a)){ t.push(v); }
}
return t; // Array
},
forEach: function(/*Array*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary: executes a provided function once per array element.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
var n = a.length;
for(var i = 0; i < n; f.call(o, a[i], i, a), ++i);
},
map: function(/*Array*/ 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.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
var n = a.length, t = new Array(n);
for(var i = 0; i < n; t[i] = f.call(o, a[i], i, a), ++i);
return t; // Array
},
every: function(/*Array*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary: tests whether all elements in the array pass the test
// implemented by the provided function.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
var n = a.length;
for(var i = 0; i < n; ++i){
if(!f.call(o, a[i], i, a)){
return false; // Boolean
}
}
return true; // Boolean
},
some: function(/*Array*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary: tests whether some element in the array passes the test
// implemented by the provided function.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
var n = a.length;
for(var i = 0; i < n; ++i){
if(f.call(o, a[i], i, a)){
return true; // Boolean
}
}
return false; // Boolean
},
// JS 1.8 standard array functions, which can take a lambda as a parameter.
reduce: function(/*Array*/ a, /*Function*/ 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*/ a, /*Function*/ 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
},
// currying and partial functions
curry: function(/*Function|String|Array*/ f, /*Number?*/ arity){
// summary: curries a function until the arity is satisfied, at
// which point it returns the calculated value.
f = df.lambda(f);
arity = typeof arity == "number" ? arity : f.length;
return currying({func: f, arity: arity, args: []}); // Function
},
arg: {}, // marker for missing arguments
partial: function(/*Function|String|Array*/ f){
// summary: creates a function where some arguments are bound, and
// some arguments (marked as dojox.lang.functional.arg) are will be
// accepted by the final function in the order they are encountered.
// description: This method is used to produce partially bound
// functions. If you want to change the order of arguments, use
// dojox.lang.functional.mixer() or dojox.lang.functional.flip().
var a = arguments, args = new Array(a.length - 1), p = [];
f = df.lambda(f);
for(var i = 1; i < a.length; ++i){
var t = a[i];
args[i - 1] = t;
if(t == df.arg){
p.push(i - 1);
}
}
return function(){ // Function
var t = Array.prototype.slice.call(args, 0); // clone the array
for(var i = 0; i < p.length; ++i){
t[p[i]] = arguments[i];
}
return f.apply(this, t);
};
},
// argument pre-processing
mixer: function(/*Function|String|Array*/ f, /*Array*/ mix){
// summary: changes the order of arguments using an array of
// numbers mix --- i-th argument comes from mix[i]-th place
// of supplied arguments.
f = df.lambda(f);
return function(){ // Function
var t = new Array(mix.length);
for(var i = 0; i < mix.length; ++i){
t[i] = arguments[mix[i]];
}
return f.apply(this, t);
};
},
flip: function(/*Function|String|Array*/ f){
// summary: changes the order of arguments by reversing their
// order.
f = df.lambda(f);
return function(){ // Function
// reverse arguments
var a = arguments, l = a.length - 1, t = new Array(l + 1), i;
for(i = 0; i <= l; ++i){
t[l - i] = a[i];
}
return f.apply(this, t);
};
},
// combiners
zip: function(){
// summary: returns an array of arrays, where the i-th array
// contains the i-th element from each of the argument arrays.
// description: This is the venerable zip combiner (for example,
// see Python documentation for general details). The returned
// array is truncated to match the length of the shortest input
// array.
var n = arguments[0].length, m = arguments.length, i;
for(i = 1; i < m; n = Math.min(n, arguments[i++].length));
var t = new Array(n), j;
for(i = 0; i < n; ++i){
var p = new Array(m);
for(j = 0; j < m; p[j] = arguments[j][i], ++j);
t[i] = p;
}
return t; // Array
},
unzip: function(/*Array*/ a){
// summary: similar to dojox.lang.functional.zip(), but takes
// a single array of arrays as the input.
// description: This function is similar to dojox.lang.functional.zip()
// and can be used to unzip objects packed by
// dojox.lang.functional.zip(). It is here mostly to provide
// a short-cut for the different method signature.
return df.zip.apply(null, a); // Array
},
// miscelaneous functional adapters
constFun: function(/*Object*/ x){
// summary: returns a function, which produces a constant value
// regardless of supplied parameters.
return function(){ return x; }; // Function
},
invoke: function(/*String*/ m){
// summary: returns a function, which invokes a method on supplied
// object using optional parameters.
return function(/*Object*/ o){ // Function
return o[m].apply(o, Array.prototype.slice.call(arguments, 1));
};
},
pluck: function(/*String*/ m){
// summary: returns a function, which returns a named object member.
return function(/*Object*/ o){ // Function
return o[m];
};
},
// object helpers
forIn: function(/*Object*/ obj, /*Function|String|Array*/ f, /*Object?*/ o){
// summary: iterates over all object members skipping members, which
// are present in the empty object (IE and/or 3rd-party libraries).
o = o || d.global; f = df.lambda(f);
for(var i in obj){
if(i in empty){ continue; }
f.call(o, obj[i], i, obj);
}
},
forEachReversed: function(/*Array*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
// summary: executes a provided function once per array element.
a = typeof a == "string" ? a.split("") : a; o = o || d.global; f = df.lambda(f);
for(var i = a.length - 1; i >= 0; f.call(o, a[i], i, a), --i);
}
});
 
// monads
dojo.declare("dojox.lang.functional.MaybeMonad", null, {
constructor: function(/*Object*/ value){
// summary: constructs a monad optionally initializing all additional members
if(arguments.length){
this.value = value;
}
},
bind: function(/*dojox.lang.functional.Monad*/ monad, /*Function|String|Array*/ f, /*Object?*/ o){
// summary: this is the classic bind method, which applies a function to a monad,
// and returns a result as a monad; it is meant to be overwritten to incorporate
// side effects
if(!("value" in monad)){
return new this.constructor(); // dojox.lang.functional.MaybeMonad
}
// => possible side-effects go here
o = o || d.global; f = df.lambda(f);
return f.call(o, monad.value); // dojox.lang.functional.Monad
},
// class-specific methods
isNothing: function(){
// summary: check if there is no bound value.
return !("value" in this); // Boolean
}
});
df.MaybeMonad.returnMonad = function(/*Object*/ value){
// summary: puts a valye in the Maybe monad.
return new df.MaybeMonad(value); // dojox.lang.functional.MaybeMonad
};
df.MaybeMonad.zero = new df.MaybeMonad();
})();
 
}
/trunk/api/js/dojo1.0/dojox/lang/LICENSE
New file
0,0 → 1,21
The MIT License
 
Copyright (c) 2007 Oliver Steele
 
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
 
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
/trunk/api/js/dojo1.0/dojox/lang/tests/listcomp.js
New file
0,0 → 1,26
if(!dojo._hasResource["dojox.lang.tests.listcomp"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.lang.tests.listcomp"] = true;
dojo.provide("dojox.lang.tests.listcomp");
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional;
tests.register("dojox.lang.tests.listcomp", [
function testIterator1(t){ t.assertEqual(df.repeat(3, function(n){ return n + 1; }, 0), [0, 1, 2]); },
function testIterator2(t){ t.assertEqual(df.repeat(3, function(n){ return n * 3; }, 1), [1, 3, 9]); },
function testIterator3(t){ t.assertEqual(df.until(function(n){ return n > 10; }, function(n){ return n * 3; }, 1), [1, 3, 9]); },
function testListcomp1(t){ t.assertEqual(df.listcomp("i for(var i=0; i<3; ++i)"), [0, 1, 2]); },
function testListcomp2(t){ t.assertEqual(df.listcomp("i*j for(var i=0; i<3; ++i) for(var j=0; j<3; ++j)"), [0, 0, 0, 0, 1, 2, 0, 2, 4]); },
function testListcomp3(t){ t.assertEqual(df.listcomp("i*j for(var i=0; i<3; ++i) if(i%2==1) for(var j=0; j<3; ++j)"), [0, 1, 2]); },
function testListcomp4(t){ t.assertEqual(df.listcomp("i+j for(var i=0; i<3; ++i) for(var j=0; j<3; ++j)"), [0, 1, 2, 1, 2, 3, 2, 3, 4]); },
function testListcomp5(t){ t.assertEqual(df.listcomp("i+j for(var i=0; i<3; ++i) if(i%2==1) for(var j=0; j<3; ++j)"), [1, 2, 3]); },
function testListcomp6(t){ t.assertEqual(df.listcomp("i for(i=0; i<3; ++i)"), [0, 1, 2]); },
function testListcomp7(t){ t.assertEqual(df.listcomp("i*j for(i=0; i<3; ++i) for(j=0; j<3; ++j)"), [0, 0, 0, 0, 1, 2, 0, 2, 4]); },
function testListcomp8(t){ t.assertEqual(df.listcomp("i*j for(i=0; i<3; ++i) if(i%2==1) for(j=0; j<3; ++j)"), [0, 1, 2]); },
function testListcomp9(t){ t.assertEqual(df.listcomp("i+j for(i=0; i<3; ++i) for(j=0; j<3; ++j)"), [0, 1, 2, 1, 2, 3, 2, 3, 4]); },
function testListcomp10(t){ t.assertEqual(df.listcomp("i+j for(i=0; i<3; ++i) if(i%2==1) for(j=0; j<3; ++j)"), [1, 2, 3]); }
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/lang/tests/std.js
New file
0,0 → 1,31
if(!dojo._hasResource["dojox.lang.tests.std"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.lang.tests.std"] = true;
dojo.provide("dojox.lang.tests.std");
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, v, isOdd = "%2";
tests.register("dojox.lang.tests.std", [
function testFilter1(t){ t.assertEqual(df.filter([1, 2, 3], isOdd), [1, 3]); },
function testFilter2(t){ t.assertEqual(df.filter([1, 2, 3], "%2==0"), [2]); },
function testForEach(t){ t.assertEqual(
(v = [], df.forEach([1, 2, 3], function(x){ v.push(x); }), v), [1, 2, 3]); },
function testMap(t){ t.assertEqual(df.map([1, 2, 3], "+3"), [4, 5, 6]); },
function testEvery1(t){ t.assertFalse(df.every([1, 2, 3], isOdd)); },
function testEvery2(t){ t.assertTrue(df.every([1, 3, 5], isOdd)); },
 
function testSome1(t){ t.assertFalse(df.some([2, 4, 6], isOdd)); },
function testSome2(t){ t.assertTrue(df.some([1, 2, 3], isOdd)); },
 
function testReduce1(t){ t.assertEqual(df.reduce([4, 2, 1], "x-y"), 1); },
function testReduce2(t){ t.assertEqual(df.reduce([4, 2, 1], "x-y", 8), 1); },
function testReduceRight1(t){ t.assertEqual(df.reduceRight([4, 2, 1], "x-y"), -5); },
function testReduceRight2(t){ t.assertEqual(df.reduceRight([4, 2, 1], "x-y", 8), 1); }
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/lang/tests/misc.js
New file
0,0 → 1,36
if(!dojo._hasResource["dojox.lang.tests.misc"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.lang.tests.misc"] = true;
dojo.provide("dojox.lang.tests.misc");
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, fun = df.lambda("100*a + 10*b + c"), result = [];
df.forIn({a: 1, b: 2}, function(v, i){ result.push("[" + i + "] = " + v); });
tests.register("dojox.lang.tests.misc", [
function testZip1(t){ t.assertEqual(df.zip([1, 2, 3], [4, 5, 6]), [[1, 4], [2, 5], [3, 6]]); },
function testZip2(t){ t.assertEqual(df.zip([1, 2], [3, 4], [5, 6]), [[1, 3, 5], [2, 4, 6]]); },
function testUnzip1(t){ t.assertEqual(df.unzip([[1, 4], [2, 5], [3, 6]]), [[1, 2, 3], [4, 5, 6]]); },
function testUnzip2(t){ t.assertEqual(df.unzip([[1, 3, 5], [2, 4, 6]]), [[1, 2], [3, 4], [5, 6]]); },
function testConst1(t){ t.assertEqual(df.constFun(5)(), 5); },
function testConst2(t){ t.assertEqual(df.constFun(8)(), 8); },
function testInvoke1(t){ t.assertEqual(df.invoke("max")(Math, 1, 2), 2); },
function testInvoke2(t){ t.assertEqual(df.invoke("min")(Math, 1, 2), 1); },
function testPluck1(t){ t.assertEqual(df.pluck("PI")(Math), Math.PI); },
function testPluck2(t){ t.assertEqual(df.pluck("E")(Math), Math.E); },
function testMixer(t){ t.assertEqual(df.mixer(fun, [1, 2, 0])(3, 1, 2), 123); },
function testFlip(t){ t.assertEqual(df.flip(fun)(3, 2, 1), 123); },
function testCompose1(t){ t.assertEqual(df.lambda(["+5", "*3"])(8), 8 * 3 + 5); },
function testCompose2(t){ t.assertEqual(df.lambda(["+5", "*3"].reverse())(8), (8 + 5) * 3); },
function testForIn(t){ t.assertEqual(result.sort().join(", "), "[a] = 1, [b] = 2"); }
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/lang/tests/fun_perf.html
New file
0,0 → 1,61
<html>
<head>
<title>clocking fun</title>
<style type="text/css">
@import "../resources/dojo.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true"></script>
<script type="text/javascript" src="../functional.js"></script>
<script type="text/javascript">
dojo.addOnLoad(function(){
var LEN = 1000, ITER = 100, SUM = (LEN - 1) * LEN / 2;
var foldl_1 = function(/*Array*/ a, /*Function*/ f, /*Object*/ z){
for(var i = 0; i < a.length; z = f.call(dojo.global, z, a[i++]));
return z;
};
var foldl_2 = function(/*Array*/ a, /*Function*/ f, /*Object*/ z){
dojo.forEach(a, function(x){ z = f.call(dojo.global, z, x); });
return z;
};
var foldl_3 = function(/*Array*/ a, /*Function*/ f, /*Object*/ z){
a.forEach(function(x){ z = f.call(dojo.global, z, x); });
return z;
};
var sample = dojox.lang.functional.repeat(LEN, function(x){ return x + 1; }, 0);
console.profile("dojox.lang.functional.foldl");
for(var i = 0; i < ITER; ++i){
var t = dojox.lang.functional.foldl(sample, function(a, b){ return a + b; }, 0);
console.assert(t == SUM);
}
console.profileEnd("dojox.lang.functional.foldl");
console.profile("dojox.lang.functional.reduce");
for(var i = 0; i < ITER; ++i){
var t = dojox.lang.functional.reduce(sample, function(a, b){ return a + b; });
console.assert(t == SUM);
}
console.profileEnd("dojox.lang.functional.reduce");
console.profile("raw loop");
for(var i = 0; i < ITER; ++i){
var t = foldl_1(sample, function(a, b){ return a + b; }, 0);
console.assert(t == SUM);
}
console.profileEnd("raw loop");
console.profile("dojo.forEach");
for(var i = 0; i < ITER; ++i){
var t = foldl_2(sample, function(a, b){ return a + b; }, 0);
console.assert(t == SUM);
}
console.profileEnd("dojo.forEach");
console.profile("Array.forEach");
for(var i = 0; i < ITER; ++i){
var t = foldl_3(sample, function(a, b){ return a + b; }, 0);
console.assert(t == SUM);
}
console.profileEnd("Array.forEach");
});
</script>
</head>
<body>
<p>This test is meant to run on Firefox with Firebug installed.</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/lang/tests/runTests.html
New file
0,0 → 1,9
<html>
<head>
<title>DojoX Functional Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.lang.tests.main" />
</head>
<body>
<p>Redirecting to D.O.H runner.</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/lang/tests/lambda.js
New file
0,0 → 1,22
if(!dojo._hasResource["dojox.lang.tests.lambda"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.lang.tests.lambda"] = true;
dojo.provide("dojox.lang.tests.lambda");
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional;
tests.register("dojox.lang.tests.lambda", [
function testLambda1(t){ t.assertEqual(df.repeat(3, "3*", 1), [1, 3, 9]); },
function testLambda2(t){ t.assertEqual(df.repeat(3, "*3", 1), [1, 3, 9]); },
function testLambda3(t){ t.assertEqual(df.repeat(3, "_*3", 1), [1, 3, 9]); },
function testLambda4(t){ t.assertEqual(df.repeat(3, "3*_", 1), [1, 3, 9]); },
function testLambda5(t){ t.assertEqual(df.repeat(3, "n->n*3", 1), [1, 3, 9]); },
function testLambda6(t){ t.assertEqual(df.repeat(3, "n*3", 1), [1, 3, 9]); },
function testLambda7(t){ t.assertEqual(df.repeat(3, "3*m", 1), [1, 3, 9]); },
function testLambda8(t){ t.assertEqual(df.repeat(3, "->1", 1), [1, 1, 1]); },
function testLambda9(t){ t.assertEqual(df.repeat(3, function(n){ return n * 3; }, 1), [1, 3, 9]); },
function testLambda10(t){ t.assertEqual(df.repeat(3, ["_-1", ["*3"]], 1), [1, 2, 5]); }
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/lang/tests/curry.js
New file
0,0 → 1,30
if(!dojo._hasResource["dojox.lang.tests.curry"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.lang.tests.curry"] = true;
dojo.provide("dojox.lang.tests.curry");
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, add5 = df.curry("+")(5), sub3 = df.curry("_-3"), fun = df.lambda("100*a + 10*b + c");
tests.register("dojox.lang.tests.curry", [
function testCurry1(t){ t.assertEqual(df.curry("+")(1, 2), 3); },
function testCurry2(t){ t.assertEqual(df.curry("+")(1)(2), 3); },
function testCurry3(t){ t.assertEqual(df.curry("+")(1, 2, 3), 3); },
function testCurry4(t){ t.assertEqual(add5(1), 6); },
function testCurry5(t){ t.assertEqual(add5(3), 8); },
function testCurry6(t){ t.assertEqual(add5(5), 10); },
function testCurry7(t){ t.assertEqual(sub3(1), -2); },
function testCurry8(t){ t.assertEqual(sub3(3), 0); },
function testCurry9(t){ t.assertEqual(sub3(5), 2); },
function testPartial1(t){ t.assertEqual(df.partial(fun, 1, 2, 3)(), 123); },
function testPartial2(t){ t.assertEqual(df.partial(fun, 1, 2, df.arg)(3), 123); },
function testPartial3(t){ t.assertEqual(df.partial(fun, 1, df.arg, 3)(2), 123); },
function testPartial4(t){ t.assertEqual(df.partial(fun, 1, df.arg, df.arg)(2, 3), 123); },
function testPartial5(t){ t.assertEqual(df.partial(fun, df.arg, 2, 3)(1), 123); },
function testPartial6(t){ t.assertEqual(df.partial(fun, df.arg, 2, df.arg)(1, 3), 123); },
function testPartial7(t){ t.assertEqual(df.partial(fun, df.arg, df.arg, 3)(1, 2), 123); },
function testPartial8(t){ t.assertEqual(df.partial(fun, df.arg, df.arg, df.arg)(1, 2, 3), 123); }
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/lang/tests/fold.js
New file
0,0 → 1,33
if(!dojo._hasResource["dojox.lang.tests.fold"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.lang.tests.fold"] = true;
dojo.provide("dojox.lang.tests.fold");
dojo.require("dojox.lang.functional");
 
(function(){
var df = dojox.lang.functional, a = df.arg;
tests.register("dojox.lang.tests.fold", [
function testFoldl1(t){ t.assertEqual(df.foldl([1, 2, 3], "+", 0), 6); },
function testFoldl2(t){ t.assertEqual(df.foldl1([1, 2, 3], "*"), 6); },
function testFoldl3(t){ t.assertEqual(df.foldl1([1, 2, 3], "/"), 1/6); },
function testFoldl4(t){ t.assertEqual(df.foldl1([1, 2, 3], df.partial(Math.max, a, a)), 3); },
function testFoldl5(t){ t.assertEqual(df.foldl1([1, 2, 3], df.partial(Math.min, a, a)), 1); },
function testFoldr1(t){ t.assertEqual(df.foldr([1, 2, 3], "+", 0), 6); },
function testFoldr2(t){ t.assertEqual(df.foldr1([1, 2, 3], "*"), 6); },
function testFoldr3(t){ t.assertEqual(df.foldr1([1, 2, 3], "/"), 3/2); },
function testFoldr4(t){ t.assertEqual(df.foldr1([1, 2, 3], df.partial(Math.max, a, a)), 3); },
function testFoldr5(t){ t.assertEqual(df.foldr1([1, 2, 3], df.partial(Math.min, a, a)), 1); },
function testScanl1(t){ t.assertEqual(df.scanl([1, 2, 3], "+", 0), [0, 1, 3, 6]); },
function testScanl2(t){ t.assertEqual(df.scanl1([1, 2, 3], "*"), [1, 2, 6]); },
function testScanl3(t){ t.assertEqual(df.scanl1([1, 2, 3], df.partial(Math.max, a, a)), [1, 2, 3]); },
function testScanl4(t){ t.assertEqual(df.scanl1([1, 2, 3], df.partial(Math.min, a, a)), [1, 1, 1]); },
function testScanr1(t){ t.assertEqual(df.scanr([1, 2, 3], "+", 0), [6, 5, 3, 0]); },
function testScanr2(t){ t.assertEqual(df.scanr1([1, 2, 3], "*"), [6, 6, 3]); },
function testScanr3(t){ t.assertEqual(df.scanr1([1, 2, 3], df.partial(Math.max, a, a)), [3, 3, 3]); },
function testScanr4(t){ t.assertEqual(df.scanr1([1, 2, 3], df.partial(Math.min, a, a)), [1, 2, 3]); }
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/lang/tests/main.js
New file
0,0 → 1,16
if(!dojo._hasResource["dojox.lang.tests.test_fun"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.lang.tests.test_fun"] = true;
dojo.provide("dojox.lang.tests.test_fun");
 
try{
dojo.require("dojox.lang.tests.listcomp");
dojo.require("dojox.lang.tests.lambda");
dojo.require("dojox.lang.tests.fold");
dojo.require("dojox.lang.tests.curry");
dojo.require("dojox.lang.tests.misc");
dojo.require("dojox.lang.tests.std");
}catch(e){
doh.debug(e);
}
 
}
/trunk/api/js/dojo1.0/dojox/wire.js
New file
0,0 → 1,7
if(!dojo._hasResource["dojox.wire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.wire"] = true;
dojo.provide("dojox.wire");
dojo.require("dojox.wire._base");
 
 
}
/trunk/api/js/dojo1.0/dojox/image/Gallery.js
New file
0,0 → 1,181
if(!dojo._hasResource["dojox.image.Gallery"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.image.Gallery"] = true;
dojo.provide("dojox.image.Gallery");
dojo.experimental("dojox.image.Gallery");
//
// dojox.image.Gallery courtesy Shane O Sullivan, licensed under a Dojo CLA
// @author Copyright 2007 Shane O Sullivan (shaneosullivan1@gmail.com)
//
// For a sample usage, see http://www.skynet.ie/~sos/photos.php
//
// TODO: Make public, document params and privitize non-API conformant methods.
// document topics.
 
dojo.require("dojo.fx");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dojox.image.ThumbnailPicker");
dojo.require("dojox.image.SlideShow");
 
dojo.declare("dojox.image.Gallery",
[dijit._Widget, dijit._Templated],
{
// summary:
// Gallery widget that wraps a dojox.image.ThumbnailPicker and dojox.image.SlideShow widget
// imageHeight: Number
// Maximum height of an image in the SlideShow widget
imageHeight: 375,
// imageWidth: Number
// Maximum width of an image in the SlideShow widget
imageWidth: 500,
// pageSize: Number
// The number of records to retrieve from the data store per request.
pageSize: dojox.image.SlideShow.prototype.pageSize,
// autoLoad: Boolean
// If true, images are loaded before the user views them. If false, an
// image is loaded when the user displays it.
autoLoad: true,
// linkAttr: String
// Defines the name of the attribute to request from the store to retrieve the
// URL to link to from an image, if any.
linkAttr: "link",
// imageThumbAttr: String
// Defines the name of the attribute to request from the store to retrieve the
// URL to the thumbnail image.
imageThumbAttr: "imageUrlThumb",
// imageLargeAttr: String
// Defines the name of the attribute to request from the store to retrieve the
// URL to the image.
imageLargeAttr: "imageUrl",
// titleAttr: String
// Defines the name of the attribute to request from the store to retrieve the
// title of the picture, if any.
titleAttr: "title",
// slideshowInterval: Integer
// time in seconds, between image changes in the slide show.
slideshowInterval: 3,
templateString:"<div dojoAttachPoint=\"outerNode\" class=\"imageGalleryWrapper\">\n\t<div dojoAttachPoint=\"thumbPickerNode\"></div>\n\t<div dojoAttachPoint=\"slideShowNode\"></div>\n</div>\n",
 
postCreate: function(){
// summary: Initializes the widget, creates the ThumbnailPicker and SlideShow widgets
this.widgetid = this.id;
this.inherited("postCreate",arguments)
this.thumbPicker = new dojox.image.ThumbnailPicker({
linkAttr: this.linkAttr,
imageLargeAttr: this.imageLargeAttr,
titleAttr: this.titleAttr,
useLoadNotifier: true
}, this.thumbPickerNode);
this.slideShow = new dojox.image.SlideShow({
imageHeight: this.imageHeight,
imageWidth: this.imageWidth,
autoLoad: this.autoLoad,
linkAttr: this.linkAttr,
imageLargeAttr: this.imageLargeAttr,
titleAttr: this.titleAttr,
slideshowInterval: this.slideshowInterval,
pageSize: this.pageSize
}, this.slideShowNode);
var _this = this;
//When an image is shown in the Slideshow, make sure it is visible
//in the ThumbnailPicker
dojo.subscribe(this.slideShow.getShowTopicName(), function(packet){
//if(packet.index < _this.thumbPicker._thumbIndex
// || packet.index > _this.thumbPicker._thumbIndex + _this.thumbPicker.numberThumbs -1){
//if(!_this.thumbPicker.isVisible(packet.index)){
//var index = packet.index - (packet.index % _this.thumbPicker.numberThumbs);
_this.thumbPicker._showThumbs(packet.index);
//}
});
//When the user clicks a thumbnail, show that image
dojo.subscribe(this.thumbPicker.getClickTopicName(), function(evt){
_this.slideShow.showImage(evt.index);
});
//When the ThumbnailPicker moves to show a new set of pictures,
//make the Slideshow start loading those pictures first.
dojo.subscribe(this.thumbPicker.getShowTopicName(), function(evt){
_this.slideShow.moveImageLoadingPointer(evt.index);
});
//When an image finished loading in the slideshow, update the loading
//notification in the ThumbnailPicker
dojo.subscribe(this.slideShow.getLoadTopicName(), function(index){
_this.thumbPicker.markImageLoaded(index);
});
this._centerChildren();
},
setDataStore: function(dataStore, request, /*optional*/paramNames){
// summary: Sets the data store and request objects to read data from.
// dataStore:
// An implementation of the dojo.data.api.Read API. This accesses the image
// data.
// request:
// An implementation of the dojo.data.api.Request API. This specifies the
// query and paging information to be used by the data store
// paramNames:
// An object defining the names of the item attributes to fetch from the
// data store. The four attributes allowed are 'linkAttr', 'imageLargeAttr',
// 'imageThumbAttr' and 'titleAttr'
this.thumbPicker.setDataStore(dataStore, request, paramNames);
this.slideShow.setDataStore(dataStore, request, paramNames);
},
reset: function(){
// summary: Resets the widget to its initial state
this.slideShow.reset();
this.thumbPicker.reset();
},
showNextImage: function(inTimer){
// summary: Changes the image being displayed in the SlideShow to the next
// image in the data store
// inTimer: Boolean
// If true, a slideshow is active, otherwise the slideshow is inactive.
this.slideShow.showNextImage();
},
 
toggleSlideshow: function(){
// summary: Switches the slideshow mode on and off.
this.slideShow.toggleSlideshow();
},
 
showImage: function(index, /*optional*/callback){
// summary: Shows the image at index 'idx'.
// idx: Number
// The position of the image in the data store to display
// callback: Function
// Optional callback function to call when the image has finished displaying.
this.slideShow.showImage(index, callback);
},
_centerChildren: function() {
// summary: Ensures that the ThumbnailPicker and the SlideShow widgets
// are centered.
var thumbSize = dojo.marginBox(this.thumbPicker.outerNode);
var slideSize = dojo.marginBox(this.slideShow.outerNode);
var diff = (thumbSize.w - slideSize.w) / 2;
if(diff > 0) {
dojo.style(this.slideShow.outerNode, "marginLeft", diff + "px");
} else if(diff < 0) {
dojo.style(this.thumbPicker.outerNode, "marginLeft", (diff * -1) + "px");
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/image/resources/image.css
New file
0,0 → 1,337
/*
This is the master CSS file for the dojox.image project, and provides all
needed definitions for:
dojox.image.Lightbox
dojox.image.Gallery [which is a combination of:]
dojox.image.SlideShow
dojox.image.ThumbNailPicker
 
*/
 
 
/* dojox.image.Lightbox:base */
/* FIXME: should be be doing this? I want a black underlay, but this sets ALL dialogs to black,
but because it's decendant of body, i can't set this color any other way ... */
.dijitDialogUnderlay {
background-color:#000;
}
 
.dojoxLightbox {
position:absolute;
z-index:999;
overflow:hidden;
width:100px;
height:100px;
border:11px solid #fff;
background:#fff url('images/loading.gif') no-repeat center center;
 
/* special safari + FF specific rounding + shadows */
-webkit-box-shadow: 0px 6px 10px #636363; /* #adadad; */
-webkit-border-radius: 3px;
-moz-border-radius:4px;
}
 
.dojoxLightboxContainer {
position:absolute;
top:0; left:0;
}
 
.dojoxLightboxFooter {
height:50px;
position:relative;
bottom:0;
left:0;
margin-top:8px;
color:#333;
z-index:1000;
font-size:10pt;
}
 
.dojoxLightboxGroupText {
color:#666;
font-size:8pt;
}
 
.LightboxNext,
.LightboxPrev,
.LightboxClose {
float:right;
width:16px;
height:16px;
cursor:pointer;
}
 
/* dojox.image.Lightbox:tundra */
.tundra .LightboxClose {
background:url('../../../dijit/themes/tundra/images/tabClose.png') no-repeat center center;
}
.tundra .LightboxNext {
background:url('../../../dijit/themes/tundra/images/arrowRight.png') no-repeat center center;
}
.tundra .LightboxPrev {
background:url('../../../dijit/themes/tundra/images/arrowLeft.png') no-repeat center center;
}
 
/* dojox.image.Lightbox:soria */
.soria .LightboxNext,
.soria .LightboxPrev,
.soria .LightboxClose {
background:url('../../../dijit/themes/soria/images/arrows.png') no-repeat center center;
background-position:-65px 0;
}
.soria .LightboxNext {
background-position:-48px 0;
}
.soria .LightboxPrev {
background-position:-16px 0;
}
 
/* dojox.image.SlideShow */
 
.slideShowWrapper {
position:relative;
background:#fff;
padding:8px;
border:1px solid #333;
padding-bottom:20px;
overflow:hidden;
text-align: center;
-moz-border-radius:3pt;
-webkit-border-radius:4pt;
-webkit-drop-shadow:#ccc 4pt;
}
.slideShowNav {
position:absolute;
bottom:-18px;
left:0px;
padding:0px 3px 2px 0px;
background-color:#fff;
width:100%;
}
.slideShowNavWrapper { float:right; }
.slideShowTitle {
float:left;
color:#333;
font-size:10pt;
}
.slideShowTitle .slideShowCounterText {
font-size:6pt; color:#666;
}
.slideShowHidden {
position:absolute;
display: none;
height: 1px;
width: 1px;
}
.slideShowImageWrapper {
position:relative;
text-align: center;
margin-top: -42px;
float: left;
width: 100%;
}
.slideShowImageWrapper img {
border: 0px none;
}
.slideShowNotifier {
background-color: red;
width: 100px;
height: 5px;
font-size: 1%;/*IE hack to get around the Empty-Div bug*/
}
.slideShowSlideShow {
position:absolute;
top:30px;
padding: 0 5px;
border: 0px;
text-decoration: none;
color: #2e6ab1;
}
.slideShowLoading { background-color: #fad66a; }
.slideShowLoaded { background-color: transparent; }
/*
.sprite-arrowbottom { background-position: 0 -30px; }
.sprite-arrowtop { background-position: 0 -430px; }
*/
.slideShowCtrlPrev {
background-position: -96px 0px;
float: left;
}
.slideShowCtrlNext {
background-position: -144px 0px;
float: right;
}
.slideShowCtrlPlay {
background-position: -190px 0px;
position: absolute;
}
.slideShowPaused .slideShowCtrlPlay {
background-position: -236px 0px;
position: absolute;
}
.slideShowCtrl span.slideShowCtrlHide {
background-image: url("images/1pixel.gif");
cursor: auto;
}
 
.slideShowCtrl {
height: 50px;
width: 100%;
position: relative;
z-index:999;
float: left;
}
.slideShowCtrl span {
width: 50px;
height: 100%;
background-image: url("images/buttons.png");
cursor: pointer;
}
.dj_ie6 .slideShowCtrl span {
background-image: url("images/buttons.gif");
}
 
.dj_ie6 .slideShowPager li.currentpage,
.dj_ie6 .pagination li.disablepage{
/*IE 6 and below. Adjust non linked LIs slightly to account for bugs*/
margin-right: 5px;
padding-right: 0;
}
 
/* dojox.image.ThumbnailPicker */
 
.thumbWrapper .thumbNav {
background-repeat: no-repeat;
background-position: center;
padding-top: 1px;
width: 30px;
height: 100%;
}
 
.thumbOuter {
padding-bottom: 2px;
}
 
.thumbOuter.thumbHoriz {
width: 500px;
height: 85px;
}
 
.thumbOuter.thumbVert {
width: 100px;
height: 400px;
}
 
.thumbOuter .enabled {
background: transparent url("images/buttons.png") no-repeat center center;
}
.dj_ie6 .thumbOuter .enabled { background-image: url("images/buttons.gif"); }
 
.thumbOuter .thumbNav img {
width: 48px;
height: 75px;
}
.thumbOuter .thumbClickable div {
cursor: pointer;
}
.thumbOuter .prevHoriz {
background-position: -96px 12px;
position: relative;
float: left;
height: 100%;
}
 
.thumbOuter .nextHoriz {
background-position: -144px 12px;
position: relative;
float: right;
height: 100%;
/* margin-top: -85px;*/
}
.thumbOuter .prevVert {
background-position: 0px 0px;
height: 48px;
width:48px;
margin-left:24px;
}
 
.thumbOuter .nextVert {
background-position: -48px 0px;
height: 48px;
width:48px;
margin-left:24px;
}
 
.thumbWrapper img {
height: 75px;
max-width: 100px;
width: expression(this.width > 100 ? 100: true);/*IE Hack*/
}
 
.thumbWrapper .thumbNav .imageGalleryThumb {
height: 50px;
}
 
.thumbWrapper .thumbNotifier {
background-color: red;
width: 0px;
margin-left: 2px;
height: 5px;
font-size: 1%;/*IE hack to get around the Empty-Div bug*/
}
 
.thumbWrapper .thumbLoaded {
background-color: transparent;
}
 
.thumbScroller {
overflow-x: hidden;
overflow-y: hidden;
white-space: nowrap;
text-align: center;
}
 
.thumbHoriz .thumbScroller {
width: 500px;
height: 85px;
float: left;
}
 
.thumbVert .thumbScroller {
height: 500px;
width: 100px;
}
 
.thumbWrapper {
float: left;
}
 
.thumbVert .thumbWrapper {
width: 100px;
height: 10px;
}
.thumbHoriz .thumbWapper {
height:85px;
width: 10px;
}
 
.thumbWrapper.thumbHoriz div {
float: left;
padding-right: 2px;
}
 
.thumbWrapper.thumbVert {
width: 100px;
}
 
.thumbWrapper.thumbVert div {
padding-bottom: 2px;
}
 
/* dojox.image.Gallery */
 
.imageGalleryWrapper {
padding-bottom: 20px;
text-align: center;
}
/trunk/api/js/dojo1.0/dojox/image/resources/Gallery.html
New file
0,0 → 1,4
<div dojoAttachPoint="outerNode" class="imageGalleryWrapper">
<div dojoAttachPoint="thumbPickerNode"></div>
<div dojoAttachPoint="slideShowNode"></div>
</div>
/trunk/api/js/dojo1.0/dojox/image/resources/Lightbox.html
New file
0,0 → 1,15
<div class="dojoxLightbox" dojoAttachPoint="containerNode">
<div style="position:relative">
<div dojoAttachPoint="imageContainer" class="dojoxLightboxContainer">
<img dojoAttachPoint="imgNode" src="${imgUrl}" class="dojoxLightboxImage" alt="${title}">
<div class="dojoxLightboxFooter" dojoAttachPoint="titleNode">
<div class="dijitInline LightboxClose" dojoAttachPoint="closeNode"></div>
<div class="dijitInline LightboxNext" dojoAttachPoint="nextNode"></div>
<div class="dijitInline LightboxPrev" dojoAttachPoint="prevNode"></div>
 
<div class="dojoxLightboxText"><span dojoAttachPoint="textNode">${title}</span><span dojoAttachPoint="groupCount" class="dojoxLightboxGroupText"></span></div>
</div>
</div>
</div>
</div>
/trunk/api/js/dojo1.0/dojox/image/resources/SlideShow.html
New file
0,0 → 1,14
<div dojoAttachPoint="outerNode" class="slideShowWrapper">
<div style="position:relative;" dojoAttachPoint="innerWrapper">
<div class="slideShowNav" dojoAttachEvent="onclick: _handleClick">
<div class="dijitInline slideShowTitle" dojoAttachPoint="titleNode">${title}</div>
</div>
<div dojoAttachPoint="navNode" class="slideShowCtrl" dojoAttachEvent="onclick: _handleClick">
<span dojoAttachPoint="navPrev" class="slideShowCtrlPrev"></span>
<span dojoAttachPoint="navPlay" class="slideShowCtrlPlay"></span>
<span dojoAttachPoint="navNext" class="slideShowCtrlNext"></span>
</div>
<div dojoAttachPoint="largeNode" class="slideShowImageWrapper"></div>
<div dojoAttachPoint="hiddenNode" class="slideShowHidden"></div>
</div>
</div>
/trunk/api/js/dojo1.0/dojox/image/resources/ThumbnailPicker.html
New file
0,0 → 1,11
<div dojoAttachPoint="outerNode" class="thumbOuter">
<div dojoAttachPoint="navPrev" class="thumbNav thumbClickable">
<img src="" dojoAttachPoint="navPrevImg"/>
</div>
<div dojoAttachPoint="thumbScroller" class="thumbScroller">
<div dojoAttachPoint="thumbsNode" class="thumbWrapper"></div>
</div>
<div dojoAttachPoint="navNext" class="thumbNav thumbClickable">
<img src="" dojoAttachPoint="navNextImg"/>
</div>
</div>
/trunk/api/js/dojo1.0/dojox/image/resources/images/buttons.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/image/resources/images/buttons.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/image/resources/images/loading.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/image/resources/images/loading.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/image/resources/images/buttons.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/image/resources/images/buttons.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/image/resources/images/1pixel.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/image/resources/images/1pixel.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/image/Lightbox.js
New file
0,0 → 1,312
if(!dojo._hasResource["dojox.image.Lightbox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.image.Lightbox"] = true;
dojo.provide("dojox.image.Lightbox");
dojo.experimental("dojox.image.Lightbox");
 
dojo.require("dijit.Dialog");
dojo.require("dojox.fx");
 
dojo.declare("dojox.image.Lightbox",
dijit._Widget,{
// summary:
// a dojo-based Lightbox implementation.
//
// description:
// an Elegant, keyboard accessible, markup and store capable Lightbox widget to show images
// in a modal dialog-esque format. Can show individual images as Modal dialog, or can group
// images with multiple entry points, all using a single "master" Dialog for visualization
//
// examples:
//
// <a href="image1.jpg" dojoType="dojox.image.Lightbox">show lightbox</a>
// <a href="image2.jpg" dojoType="dojox.image.Lightbox" group="one">show group lightbox</a>
// <a href="image3.jpg" dojoType="dojox.image.Lightbox" group="one">show group lightbox</a>
//
// FIXME: not implemented fully yet, though works with basic datastore access. need to manually call
// widget._attachedDialog.addImage(item,"fromStore") for each item in a store result set.
// <div dojoType="dojox.image.Lightbox" group="fromStore" store="storeName"></div>
 
// group: String
// grouping images in a page with similar tags will provide a 'slideshow' like grouping of images
group: "",
 
// title: String
// A string of text to be shown in the Lightbox beneath the image (empty if using a store)
title: "",
 
// href; String
// link to image to use for this Lightbox node (empty if using a store).
href: "",
 
// duration: Integer
// generic time in MS to adjust the feel of widget. could possibly add various
// durations for the various actions (dialog fadein, sizeing, img fadein ...)
duration: 500,
 
// _allowPassthru: Boolean
// privately set this to disable/enable natural link of anchor tags
_allowPassthru: false,
_attachedDialog: null, // try to share a single underlay per page?
 
startup: function(){
this.inherited("startup", arguments);
// setup an attachment to the masterDialog (or create the masterDialog)
var tmp = dijit.byId('dojoxLightboxDialog');
if(tmp){
this._attachedDialog = tmp;
}else{
// this is the first instance to start, so we make the masterDialog
this._attachedDialog = new dojox.image._LightboxDialog({ id: "dojoxLightboxDialog" });
this._attachedDialog.startup();
}
if(!this.store){
// FIXME: full store support lacking, have to manually call this._attachedDialog.addImage(imgage,group) as it stands
this._addSelf();
this.connect(this.domNode, "onclick", "_handleClick");
}
},
 
_addSelf: function(){
this._attachedDialog.addImage({
href: this.href,
title: this.title
},this.group||null);
},
 
_handleClick: function(/* Event */e){
// summary: handle the click on the link
if(!this._allowPassthru){ e.preventDefault(); }
else{ return; }
this.show();
},
 
show: function(){
this._attachedDialog.show(this);
},
 
disable: function(){
// summary, disables event clobbering and dialog, and follows natural link
this._allowPassthru = true;
},
 
enable: function(){
// summary: enables the dialog (prevents default link)
this._allowPassthru = false;
}
 
});
 
dojo.declare("dojox.image._LightboxDialog",
dijit.Dialog,{
//
// Description:
//
// a widget that intercepts anchor links (typically around images)
// and displays a modal Dialog. this is the actual Popup, and should
// not be created directly.
//
// there will only be one of these on a page, so all dojox.image.Lightbox's will us it
// (the first instance of a Lightbox to be show()'n will create me If i do not exist)
//
// note: the could be the ImagePane i was talking about?
 
// title: String
// the current title
title: "",
 
// FIXME: implement titleTemplate
 
// inGroup: Array
// Array of objects. this is populated by from the JSON object _groups, and
// should not be populate manually. it is a placeholder for the currently
// showing group of images in this master dialog
inGroup: null,
 
// imgUrl: String
// the src="" attrib of our imageNode (can be null at statup)
imgUrl: "",
 
// an array of objects, each object being a unique 'group'
_groups: { XnoGroupX: [] },
_imageReady: false,
 
templateString:"<div class=\"dojoxLightbox\" dojoAttachPoint=\"containerNode\">\n\t<div style=\"position:relative\">\n\t\t<div dojoAttachPoint=\"imageContainer\" class=\"dojoxLightboxContainer\">\n\t\t\t<img dojoAttachPoint=\"imgNode\" src=\"${imgUrl}\" class=\"dojoxLightboxImage\" alt=\"${title}\">\n\t\t\t<div class=\"dojoxLightboxFooter\" dojoAttachPoint=\"titleNode\">\n\t\t\t\t<div class=\"dijitInline LightboxClose\" dojoAttachPoint=\"closeNode\"></div>\n\t\t\t\t<div class=\"dijitInline LightboxNext\" dojoAttachPoint=\"nextNode\"></div>\t\n\t\t\t\t<div class=\"dijitInline LightboxPrev\" dojoAttachPoint=\"prevNode\"></div>\n\n\t\t\t\t<div class=\"dojoxLightboxText\"><span dojoAttachPoint=\"textNode\">${title}</span><span dojoAttachPoint=\"groupCount\" class=\"dojoxLightboxGroupText\"></span></div>\n\t\t\t</div>\n\t\t</div>\t\n\t\t\n\t</div>\n</div>\n",
 
startup: function(){
// summary: add some extra event handlers, and startup our superclass.
this.inherited("startup", arguments);
 
// FIXME: these are supposed to be available in dijit.Dialog already,
// but aren't making it over.
dojo.connect(document.documentElement,"onkeypress",this,"_handleKey");
this.connect(window,"onresize","_position");
 
this.connect(this.nextNode, "onclick", "_nextImage");
this.connect(this.prevNode, "onclick", "_prevImage");
this.connect(this.closeNode, "onclick", "hide");
},
 
show: function(/* Object */groupData){
// summary: starts the chain of events to show an image in the dialog, including showing the dialog
// if it is not already visible
 
dojo.style(this.imgNode,"opacity","0");
dojo.style(this.titleNode,"opacity","0");
 
// we only need to call dijit.Dialog.show() if we're not already open.
if(!this.open){ this.inherited("show", arguments); }
this._imageReady = false;
this.imgNode.src = groupData.href;
if((groupData.group && !(groupData == "XnoGroupX")) || this.inGroup){
if(!this.inGroup){
this.inGroup = this._groups[(groupData.group)];
var i = 0;
// determine where we were or are in the show
dojo.forEach(this.inGroup,function(g){
if (g.href == groupData.href){
this._positionIndex = i;
}
i++;
},this);
}
if(!this._positionIndex){ this._positionIndex=0; this.imgNode.src = this.inGroup[this._positionIndex].href; }
this.groupCount.innerHTML = " (" +(this._positionIndex+1) +" of "+this.inGroup.length+")";
this.prevNode.style.visibility = "visible";
this.nextNode.style.visibility = "visible";
}else{
this.groupCount.innerHTML = "";
this.prevNode.style.visibility = "hidden";
this.nextNode.style.visibility = "hidden";
}
this.textNode.innerHTML = groupData.title;
if(!this._imageReady || this.imgNode.complete === true){
this._imgConnect = dojo.connect(this.imgNode,"onload", this, function(){
this._imageReady = true;
this.resizeTo({ w: this.imgNode.width, h:this.imgNode.height, duration:this.duration });
dojo.disconnect(this._imgConnect);
});
// onload doesn't fire in IE if you connect before you set the src.
// hack to re-set the src after onload connection made:
if(dojo.isIE){ this.imgNode.src = this.imgNode.src; }
}else{
// do it quickly. kind of a hack, but image is ready now
this.resizeTo({ w: this.imgNode.width, h:this.imgNode.height, duration:1 });
}
},
 
_nextImage: function(){
// summary: load next image in group
if(this._positionIndex+1<this.inGroup.length){
this._positionIndex++;
}else{
this._positionIndex = 0;
}
this._loadImage();
},
 
_prevImage: function(){
// summary: load previous image in group
if(this._positionIndex==0){
this._positionIndex = this.inGroup.length-1;
}else{
this._positionIndex--;
}
this._loadImage();
},
 
_loadImage: function(){
// summary: do the prep work before we can show another image
var _loading = dojo.fx.combine([
dojo.fadeOut({ node:this.imgNode, duration:(this.duration/2) }),
dojo.fadeOut({ node:this.titleNode, duration:(this.duration/2) })
]);
this.connect(_loading,"onEnd","_prepNodes");
_loading.play(10);
},
 
_prepNodes: function(){
// summary: a localized hook to accompany _loadImage
this._imageReady = false;
this.show({
href: this.inGroup[this._positionIndex].href,
title: this.inGroup[this._positionIndex].title
});
},
 
resizeTo: function(/* Object */size){
// summary: resize our dialog container, and fire _showImage
var _sizeAnim = dojox.fx.sizeTo({
node: this.containerNode,
duration:size.duration||this.duration,
width: size.w,
height:size.h+30
});
this.connect(_sizeAnim,"onEnd","_showImage");
_sizeAnim.play(this.duration);
},
 
_showImage: function(){
// summary: fade in the image, and fire showNav
dojo.fadeIn({ node: this.imgNode, duration:this.duration,
onEnd: dojo.hitch(this,"_showNav")
}).play(75);
},
 
_showNav: function(){
// summary: fade in the footer, and setup our connections.
dojo.fadeIn({ node: this.titleNode, duration:200 }).play(25);
},
 
hide: function(){
// summary: close the Lightbox
dojo.fadeOut({node:this.titleNode, duration:200 }).play(25);
this.inherited("hide", arguments);
this.inGroup = null;
this._positionIndex = null;
},
 
addImage: function(/* object */child,/* String? */group){
// summary: add an image to this master dialog
//
// child.href: String - link to image (required)
// child.title: String - title to display
//
// group: String - attach to group of similar tag
// or null for individual image instance
 
var g = group;
if(!child.href){ return; }
if(g){
if(this._groups[(g)]){
this._groups[(g)].push(child);
}else{
this._groups[(g)] = [(child)];
}
}else{ this._groups["XnoGroupX"].push(child); }
},
 
_handleKey: function(/* Event */e){
// summary: handle keyboard navigation
if(!this.open){ return; }
var key = (e.charCode == dojo.keys.SPACE ? dojo.keys.SPACE : e.keyCode);
switch(key){
case dojo.keys.ESCAPE: this.hide(); break;
 
case dojo.keys.DOWN_ARROW:
case dojo.keys.RIGHT_ARROW:
case 78: // key "n"
this._nextImage(); break;
 
case dojo.keys.UP_ARROW:
case dojo.keys.LEFT_ARROW:
case 80: // key "p"
this._prevImage(); break;
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/image/SlideShow.js
New file
0,0 → 1,590
if(!dojo._hasResource["dojox.image.SlideShow"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.image.SlideShow"] = true;
dojo.provide("dojox.image.SlideShow");
//
// dojox.image.SlideShow courtesy Shane O Sullivan, licensed under a Dojo CLA
// For a sample usage, see http://www.skynet.ie/~sos/photos.php
//
// @author Copyright 2007 Shane O Sullivan (shaneosullivan1@gmail.com)
// @license Licensed under the Academic Free License 3.0 http://www.opensource.org/licenses/afl-3.0.php
//
// TODO: more cleanups
//
dojo.require("dojo.fx");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
 
dojo.declare("dojox.image.SlideShow",
[dijit._Widget, dijit._Templated],
{
// imageHeight: Number
// The maximum height of an image
imageHeight: 375,
// imageWidth: Number
// The maximum width of an image.
imageWidth: 500,
 
// title: String
// the initial title of the SlideShow
title: "",
 
// titleTemplate: String
// a way to customize the wording in the title. supported tags to be populated are:
// @title = the passed title of the image
// @current = the current index of the image
// @total = the total number of images in the SlideShow
//
// should add more?
titleTemplate: '@title <span class="slideShowCounterText">(@current of @total)</span>',
 
// noLink: Boolean
// Prevents the slideshow from putting an anchor link around the displayed image
// enables if true, though still will not link in absence of a url to link to
noLink: false,
 
// loop: Boolean
// true/false - make the slideshow loop
loop: true,
 
// hasNav: Boolean
// toggle to enable/disable the visual navigation controls
hasNav: true,
 
// images: Array
// Contains the DOM nodes that individual images are stored in when loaded or loading.
images: [],
// pageSize: Number
// The number of images to request each time.
pageSize: 20,
// autoLoad: Boolean
// If true, then images are preloaded, before the user navigates to view them.
// If false, an image is not loaded until the user views it.
autoLoad: true,
// fixedHeight: Boolean
// If true, the widget does not resize itself to fix the displayed image.
fixedHeight: false,
 
// imageStore: Object
// Implementation of the dojo.data.api.Read API, which provides data on the images
// to be displayed.
imageStore: null,
// linkAttr: String
// Defines the name of the attribute to request from the store to retrieve the
// URL to link to from an image, if any.
linkAttr: "link",
// imageLargeAttr: String
// Defines the name of the attribute to request from the store to retrieve the
// URL to the image.
imageLargeAttr: "imageUrl",
// titleAttr: String
// Defines the name of the attribute to request from the store to retrieve the
// title of the picture, if any.
titleAttr: "title",
 
// slideshowInterval: Number
// Time, in seconds, between image transitions during a slideshow.
slideshowInterval: 3,
templateString:"<div dojoAttachPoint=\"outerNode\" class=\"slideShowWrapper\">\n\t<div style=\"position:relative;\" dojoAttachPoint=\"innerWrapper\">\n\t\t<div class=\"slideShowNav\" dojoAttachEvent=\"onclick: _handleClick\">\n\t\t\t<div class=\"dijitInline slideShowTitle\" dojoAttachPoint=\"titleNode\">${title}</div>\n\t\t</div>\n\t\t<div dojoAttachPoint=\"navNode\" class=\"slideShowCtrl\" dojoAttachEvent=\"onclick: _handleClick\">\n\t\t\t<span dojoAttachPoint=\"navPrev\" class=\"slideShowCtrlPrev\"></span>\n\t\t\t<span dojoAttachPoint=\"navPlay\" class=\"slideShowCtrlPlay\"></span>\n\t\t\t<span dojoAttachPoint=\"navNext\" class=\"slideShowCtrlNext\"></span>\n\t\t</div>\n\t\t<div dojoAttachPoint=\"largeNode\" class=\"slideShowImageWrapper\"></div>\t\t\n\t\t<div dojoAttachPoint=\"hiddenNode\" class=\"slideShowHidden\"></div>\n\t</div>\n</div>\n",
// _tempImgPath: URL
// URL to the image to display when an image is not yet fully loaded.
_tempImgPath: dojo.moduleUrl("dojox.image", "resources/images/1pixel.gif"),
 
// _imageCounter: Number
// A counter to keep track of which index image is to be loaded next
_imageCounter: 0,
// _tmpImage: DomNode
// The temporary image to show when a picture is loading.
_tmpImage: null,
// _request: Object
// Implementation of the dojo.data.api.Request API, which defines the query
// parameters for accessing the store.
_request: null,
 
postCreate: function(){
// summary: Initilizes the widget, sets up listeners and shows the first image
this.inherited("postCreate",arguments);
var img = document.createElement("img");
 
// FIXME: should API be to normalize an image to fit in the specified height/width?
img.setAttribute("width", this.imageWidth);
img.setAttribute("height", this.imageHeight);
 
if(this.hasNav){
dojo.connect(this.outerNode, "onmouseover", function(evt){
try{_this._showNav();}
catch(e){}
});
dojo.connect(this.outerNode, "onmouseout", function(evt){
try{_this._hideNav(evt);}
catch(e){}
});
}
this.outerNode.style.width = this.imageWidth + "px";
 
img.setAttribute("src", this._tempImgPath);
var _this = this;
this.largeNode.appendChild(img);
this._tmpImage = img;
this._currentImage = img;
this._fitSize(true);
this._loadImage(0, function(){
_this.showImage(0);
});
this._calcNavDimensions();
},
 
setDataStore: function(dataStore, request, /*optional*/paramNames){
// summary: Sets the data store and request objects to read data from.
// dataStore:
// An implementation of the dojo.data.api.Read API. This accesses the image
// data.
// request:
// An implementation of the dojo.data.api.Request API. This specifies the
// query and paging information to be used by the data store
// paramNames:
// An object defining the names of the item attributes to fetch from the
// data store. The three attributes allowed are 'linkAttr', 'imageLargeAttr' and 'titleAttr'
this.reset();
var _this = this;
this._request = {
query: {},
start: ((request.start) ? request.start : 0),
count: ((request.count) ? request.count : this.pageSize),
onBegin: function(count, request){
_this.maxPhotos = count;
}
};
if(request.query){ dojo.mixin(this._request.query, request.query); }
if(paramNames && paramNames.imageLargeAttr){
this.imageLargeAttr = paramNames.imageLargeAttr;
}
var _this = this;
var _complete = function(items){
_this.showImage(0);
_this._request.onComplete = null;
};
this.imageStore = dataStore;
this._request.onComplete = _complete;
this._request.start = 0;
this.imageStore.fetch(this._request);
},
 
reset: function(){
// summary: Resets the widget to its initial state
// description: Removes all previously loaded images, and clears all caches.
while(this.largeNode.firstChild){
this.largeNode.removeChild(this.largeNode.firstChild);
}
this.largeNode.appendChild(this._tmpImage);
while(this.hiddenNode.firstChild){
this.hiddenNode.removeChild(this.hiddenNode.firstChild);
}
var img;
for(var pos = 0; pos < this.images.length; pos++){
img = this.images[pos];
if(img && img.parentNode){ img.parentNode.removeChild(img); }
}
this.images = [];
this.isInitialized = false;
this._imageCounter = 0;
},
 
isImageLoaded: function(idx){
// summary: Returns true if image at the specified index is loaded, false otherwise.
// idx:
// The number index in the data store to check if it is loaded.
return this.images && this.images.length > index && this.images[idx];
},
 
moveImageLoadingPointer: function(idx){
// summary: If 'autoload' is true, this tells the widget to start loading
// images from the specified pointer.
// idx:
// The number index in the data store to start loading images from.
this._imageCounter = idx;
},
destroy: function(){
// summary: Cleans up the widget when it is being destroyed
if(this._slideId) { this._stop(); }
this.inherited("destroy",arguments);
},
 
showNextImage: function(inTimer, forceLoop){
// summary: Changes the image being displayed to the next image in the data store
// inTimer: Boolean
// If true, a slideshow is active, otherwise the slideshow is inactive.
if(inTimer && this._timerCancelled){return false;}
if(this.imageIndex + 1 >= this.maxPhotos){
if(inTimer && (this.loop || forceLoop)){ this.imageIndex = -1; }
else{
if(this._slideId){ this._stop(); }
return false;
}
}
var _this = this;
this.showImage(this.imageIndex + 1, function(){
if(inTimer){ _this._startTimer(); }
});
return true;
},
 
toggleSlideShow: function(){
// summary: Switches the slideshow mode on and off.
if(this._slideId){
this._stop();
}else{
dojo.toggleClass(this.domNode,"slideShowPaused");
this._timerCancelled = false;
var success = this.showNextImage(true, true);
if(!success){
this._stop();
}
}
},
 
getShowTopicName: function(){
// summary: Returns the topic id published to when an image is shown
// description:
// The information published is: index, title and url
return (this.widgetId ? this.widgetId : this.id) + "/imageShow";
},
 
getLoadTopicName: function(){
// summary: Returns the topic id published to when an image finishes loading.
// description:
// The information published is the index position of the image loaded.
return (this.widgetId ? this.widgetId : this.id) + "/imageLoad";
},
 
showImage: function(idx, /* Function? */callback){
// summary: Shows the image at index 'idx'.
// idx: Number
// The position of the image in the data store to display
// callback: Function
// Optional callback function to call when the image has finished displaying.
if(!callback && this._slideId){ this.toggleSlideShow(); }
var _this = this;
var current = this.largeNode.getElementsByTagName("div");
this.imageIndex = idx;
 
var showOrLoadIt = function() {
//If the image is already loaded, then show it.
if(_this.images[idx]){
while(_this.largeNode.firstChild){
_this.largeNode.removeChild(_this.largeNode.firstChild);
}
_this.images[idx].style.opacity = 0;
_this.largeNode.appendChild(_this.images[idx]);
_this._currentImage = _this.images[idx]._img;
_this._fitSize();
var onEnd = function(a,b,c) {
var img = _this.images[idx].firstChild;
if(img.tagName.toLowerCase() != "img"){img = img.firstChild;}
title = img.getAttribute("title");
if(_this._navShowing){
_this._showNav(true);
}
dojo.publish(_this.getShowTopicName(), [{
index: idx,
title: title,
url: img.getAttribute("src")
}]);
if(callback) { callback(a,b,c); }
_this._setTitle(title);
};
dojo.fadeIn({
node: _this.images[idx],
duration: 300,
onEnd: onEnd
}).play();
}else{
//If the image is not loaded yet, load it first, then show it.
_this._loadImage(idx, function(){
dojo.publish(_this.getLoadTopicName(), [idx]);
_this.showImage(idx, callback);
});
}
};
 
//If an image is currently showing, fade it out, then show
//the new image. Otherwise, just show the new image.
if(current && current.length > 0){
dojo.fadeOut({
node: current[0],
duration: 300,
onEnd: function(){
_this.hiddenNode.appendChild(current[0]);
showOrLoadIt();
}
}).play();
}else{
showOrLoadIt();
}
},
_fitSize: function(force){
// summary: Fits the widget size to the size of the image being shown,
// or centers the image, depending on the value of 'fixedHeight'
// force: Boolean
// If true, the widget is always resized, regardless of the value of 'fixedHeight'
if(!this.fixedHeight || force){
var height = (this._currentImage.height + (this.hasNav ? 20:0));
dojo.style(this.innerWrapper, "height", height + "px");
return;
}
dojo.style(this.largeNode, "paddingTop", this._getTopPadding() + "px");
},
_getTopPadding: function(){
if(!this.fixedHeight){return 0;}
// summary: Returns the padding to place at the top of the image to center it vertically.
return (this.imageHeight - this._currentImage.height)/2;
},
_loadNextImage: function(){
//summary: Load the next unloaded image.
if(!this.autoLoad){ return; }
while(this.images.length >= this._imageCounter && this.images[this._imageCounter]){
this._imageCounter++;
}
this._loadImage(this._imageCounter);
},
_loadImage: function(idx, callbackFn){
// summary: Load image at specified index
// description:
// This function loads the image at position 'idx' into the
// internal cache of images. This does not cause the image to be displayed.
// idx:
// The position in the data store to load an image from.
// callbackFn:
// An optional function to execute when the image has finished loading.
if(this.images[idx] || !this._request) { return; }
var pageStart = idx - (idx % this.pageSize);
 
this._request.start = pageStart;
 
this._request.onComplete = function(items){
var diff = idx - pageStart;
if(items && items.length > diff){
loadIt(items[diff]);
}else{ /* Squelch - console.log("Got an empty set of items"); */ }
}
 
var _this = this;
var loadIt = function(item){
var url = _this.imageStore.getValue(item, _this.imageLargeAttr);
var img = document.createElement("img");
var div = document.createElement("div");
div._img = img;
 
var link = _this.imageStore.getValue(item,_this.linkAttr);
if(!link || _this.noLink){ div.appendChild(img);
}else{
var a = document.createElement("a");
a.setAttribute("href", link);
a.setAttribute("target","_blank");
div.appendChild(a);
a.appendChild(img);
}
 
div.setAttribute("id",_this.id + "_imageDiv" + idx);
dojo.connect(img, "onload", function(){
_this._fitImage(img);
div.setAttribute("width",_this.imageWidth);
div.setAttribute("height",_this.imageHeight);
dojo.publish(_this.getLoadTopicName(), [idx]);
_this._loadNextImage();
if(callbackFn){ callbackFn(); }
});
_this.hiddenNode.appendChild(div);
 
var titleDiv = document.createElement("div");
dojo.addClass(titleDiv, "slideShowTitle");
div.appendChild(titleDiv);
_this.images[idx] = div;
img.setAttribute("src", url);
var title = _this.imageStore.getValue(item,_this.titleAttr);
if(title){ img.setAttribute("title",title); }
}
this.imageStore.fetch(this._request);
},
 
_stop: function(){
// summary: Stops a running slide show.
if(this._slideId) { clearTimeout(this._slideId); }
this._slideId = null;
this._timerCancelled = true;
dojo.removeClass(this.domNode,"slideShowPaused");
},
 
_prev: function(){
// summary: Show the previous image.
// FIXME: either pull code from showNext/prev, or call it here
if(this.imageIndex < 1) { return;}
this.showImage(this.imageIndex - 1);
},
 
_next: function(){
// summary: Show the next image
this.showNextImage();
},
 
_startTimer: function(){
// summary: Starts a timeout to show the next image when a slide show is active
this._slideId = setTimeout("dijit.byId('"+this.id +"').showNextImage(true);", this.slideshowInterval * 1000);
},
_calcNavDimensions: function() {
// summary:
// Calculates the dimensions of the navigation controls
dojo.style(this.navNode, "position", "absolute");
//Place the navigation controls far off screen
dojo.style(this.navNode, "left", "-10000px");
//Make the navigation controls visible
dojo._setOpacity(this.navNode, 99);
this.navPlay._size = dojo.marginBox(this.navPlay);
this.navPrev._size = dojo.marginBox(this.navPrev);
this.navNext._size = dojo.marginBox(this.navNext);
dojo._setOpacity(this.navNode, 0);
dojo.style(this.navNode, "position", "");
dojo.style(this.navNode, "left", "");
},
 
_setTitle: function(title){
// summary: Sets the title of the image to be displayed
// title: String
// The String title of the image
this.titleNode.innerHTML = this.titleTemplate.replace('@title',title)
.replace('@current', String(Number(this.imageIndex) + 1))
.replace('@total',String(this.maxPhotos));
},
_fitImage: function(img) {
// summary: Ensures that the image width and height do not exceed the maximum.
// img: Node
// The image DOM node to optionally resize
var width = img.width
var height = img.height;
if(width > this.imageWidth){
height = Math.floor(height * (this.imageWidth / width));
img.setAttribute("height", height + "px");
img.setAttribute("width", this.imageWidth + "px");
}
if(height > this.imageHeight){
width = Math.floor(width * (this.imageHeight / height));
img.setAttribute("height", this.imageHeight + "px");
img.setAttribute("width", width + "px");
}
},
_handleClick: function(/* Event */e){
// summary: Performs navigation on the images based on users mouse clicks
// e:
// An Event object
switch(e.target){
case this.navNext:this._next(); break;
case this.navPrev:this._prev(); break;
case this.navPlay:this.toggleSlideShow(); break;
}
},
_showNav: function(force){
// summary:
// Shows the navigation controls
// force: Boolean
// If true, the navigation controls are repositioned even if they are
// currently visible.
if(this._navShowing && !force){return;}
dojo.style(this.navNode, "marginTop", "0px");
dojo.style(this.navPlay, "marginLeft", "0px");
var wrapperSize = dojo.marginBox(this.outerNode);
var margin = this._currentImage.height - this.navPlay._size.h - 10 + this._getTopPadding();
if(margin > this._currentImage.height){margin += 10;}
dojo[this.imageIndex < 1 ? "addClass":"removeClass"](this.navPrev, "slideShowCtrlHide");
dojo[this.imageIndex + 1 >= this.maxPhotos ? "addClass":"removeClass"](this.navNext, "slideShowCtrlHide");
var _this = this;
if(this._navAnim) {
this._navAnim.stop();
}
if(this._navShowing){return;}
this._navAnim = dojo.fadeIn({node: this.navNode, duration: 300,
onEnd: function(){_this._navAnim=null;}});
this._navAnim.play();
this._navShowing = true;
},
_hideNav: function(/* Event */e){
// summary: Hides the navigation controls
// e: Event
// The DOM Event that triggered this function
if(!e || !this._overElement(this.outerNode, e)) {
var _this = this;
if(this._navAnim) {
this._navAnim.stop();
}
this._navAnim = dojo.fadeOut({node: this.navNode,duration:300,
onEnd: function(){_this._navAnim=null;}});
this._navAnim.play();
this._navShowing = false;
}
},
_overElement: function(/*DomNode*/element, /*Event*/e){
// summary:
// Returns whether the mouse is over the passed element.
// Element must be display:block (ie, not a <span>)
//When the page is unloading, if this method runs it will throw an
//exception.
if(typeof(dojo)=="undefined"){return false;}
element = dojo.byId(element);
var m = {x: e.pageX, y: e.pageY};
var bb = dojo._getBorderBox(element);
var absl = dojo.coords(element, true);
var left = absl.x;
 
return (m.x >= left
&& m.x <= (left + bb.w)
&& m.y >= absl.y
&& m.y <= (top + bb.h)
); // boolean
}
});
 
}
/trunk/api/js/dojo1.0/dojox/image/ThumbnailPicker.js
New file
0,0 → 1,538
if(!dojo._hasResource["dojox.image.ThumbnailPicker"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.image.ThumbnailPicker"] = true;
dojo.provide("dojox.image.ThumbnailPicker");
dojo.experimental("dojox.image.ThumbnailPicker");
//
// dojox.image.ThumbnailPicker courtesy Shane O Sullivan, licensed under a Dojo CLA
// @author Copyright 2007 Shane O Sullivan (shaneosullivan1@gmail.com)
//
// For a sample usage, see http://www.skynet.ie/~sos/photos.php
//
// document topics.
 
dojo.require("dojo.fx");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
 
dojo.declare("dojox.image.ThumbnailPicker",
[dijit._Widget, dijit._Templated],
{
// summary: A scrolling Thumbnail Picker widget
//
// imageStore: Object
// A data store that implements the dojo.data Read API.
imageStore: null,
 
// request: Object
// A dojo.data Read API Request object.
request: null,
 
// size: Number
// Width or height in pixels, depending if horizontal or vertical.
size: 500,
 
// thumbHeight: Number
// Default height of a thumbnail image
thumbHeight: 75,
 
// thumbWidth: Number
// Default width of an image
thumbWidth: 100,
 
// useLoadNotifier: Boolean
// Setting useLoadNotifier to true makes a colored DIV appear under each
// thumbnail image, which is used to display the loading status of each
// image in the data store.
useLoadNotifier: false,
 
// useHyperlink: boolean
// Setting useHyperlink to true causes a click on a thumbnail to open a link.
useHyperlink: false,
 
// hyperlinkTarget: String
// If hyperlinkTarget is set to "new", clicking on a thumb will open a new window
// If it is set to anything else, clicking a thumbnail will open the url in the
// current window.
hyperlinkTarget: "new",
 
// isClickable: Boolean
// When set to true, the cursor over a thumbnail changes.
isClickable: true,
 
// isScrollable: Boolean
// When true, uses smoothScroll to move between pages
isScrollable: true,
 
// isHorizontal: Boolean
// If true, the thumbnails are displayed horizontally. Otherwise they are displayed
// vertically
isHorizontal: true,
 
//autoLoad: Boolean
autoLoad: true,
 
// linkAttr: String
// The attribute name for accessing the url from the data store
linkAttr: "link",
// imageThumbAttr: String
// The attribute name for accessing the thumbnail image url from the data store
imageThumbAttr: "imageUrlThumb",
// imageLargeAttr: String
// The attribute name for accessing the large image url from the data store
imageLargeAttr: "imageUrl",
// pageSize: Number
// The number of images to request each time.
pageSize: 20,
// titleAttr: String
// The attribute name for accessing the title from the data store
titleAttr: "title",
templateString:"<div dojoAttachPoint=\"outerNode\" class=\"thumbOuter\">\n\t<div dojoAttachPoint=\"navPrev\" class=\"thumbNav thumbClickable\">\n\t <img src=\"\" dojoAttachPoint=\"navPrevImg\"/> \n\t</div>\n\t<div dojoAttachPoint=\"thumbScroller\" class=\"thumbScroller\">\n\t <div dojoAttachPoint=\"thumbsNode\" class=\"thumbWrapper\"></div>\n\t</div>\n\t<div dojoAttachPoint=\"navNext\" class=\"thumbNav thumbClickable\">\n\t <img src=\"\" dojoAttachPoint=\"navNextImg\"/> \n\t</div>\n</div>\n",
tempImgPath: dojo.moduleUrl("dojox.image", "resources/images/1pixel.gif"),
// thumbs: Array
// Stores the image nodes for the thumbnails.
_thumbs: [],
// _thumbIndex: Number
// The index of the first thumbnail shown
_thumbIndex: 0,
// _maxPhotos: Number
// The total number of photos in the image store
_maxPhotos: 0,
// _loadedImages: Object
// Stores the indices of images that have been marked as loaded using the
// markImageLoaded function.
_loadedImages: {},
 
postCreate: function(){
// summary: Initializes styles and listeners
this.widgetid = this.id;
this.inherited("postCreate",arguments);
this.pageSize = Number(this.pageSize);
 
this._scrollerSize = this.size - (51 * 2);
var sizeProp = this._sizeProperty = this.isHorizontal ? "width" : "height";
// FIXME: do this via css? calculate the correct width for the widget
dojo.style(this.outerNode, "textAlign","center");
dojo.style(this.outerNode, sizeProp, this.size+"px");
dojo.style(this.thumbScroller, sizeProp, this._scrollerSize + "px");
//If useHyperlink is true, then listen for a click on a thumbnail, and
//open the link
if(this.useHyperlink){
dojo.subscribe(this.getClickTopicName(), this, function(packet){
var index = packet.index;
var url = this.imageStore.getValue(packet.data,this.linkAttr);
//If the data item doesn't contain a URL, do nothing
if(!url){return;}
if(this.hyperlinkTarget == "new"){
window.open(url);
}else{
window.location = url;
}
});
}
if(this.isScrollable) {
dojo.require("dojox.fx.scroll");
dojo.require("dojox.fx.easing");
}
if(this.isClickable){
dojo.addClass(this.thumbsNode, "thumbClickable");
}
this._totalSize = 0;
this.init();
},
init: function(){
// summary: Creates DOM nodes for thumbnail images and initializes their listeners
if(this.isInitialized) {return false;}
var classExt = this.isHorizontal ? "Horiz" : "Vert";
// FIXME: can we setup a listener around the whole element and determine based on e.target?
dojo.addClass(this.navPrev, "prev" + classExt);
dojo.addClass(this.navNext, "next" + classExt);
dojo.addClass(this.thumbsNode, "thumb"+classExt);
dojo.addClass(this.outerNode, "thumb"+classExt);
this.navNextImg.setAttribute("src", this.tempImgPath);
this.navPrevImg.setAttribute("src", this.tempImgPath);
dojo.connect(this.navPrev, "onclick", this, "_prev");
dojo.connect(this.navNext, "onclick", this, "_next");
this.isInitialized = true;
if(this.isHorizontal){
this._offsetAttr = "offsetLeft";
this._sizeAttr = "offsetWidth";
this._scrollAttr = "scrollLeft";
}else{
this._offsetAttr = "offsetTop";
this._sizeAttr = "offsetHeight";
this._scrollAttr = "scrollTop";
}
this._updateNavControls();
if(this.imageStore && this.request){this._loadNextPage();}
return true;
},
 
getClickTopicName: function(){
// summary: Returns the name of the dojo topic that can be
// subscribed to in order to receive notifications on
// which thumbnail was selected.
return (this.widgetId ? this.widgetId : this.id) + "/select"; // String
},
 
getShowTopicName: function(){
// summary: Returns the name of the dojo topic that can be
// subscribed to in order to receive notifications on
// which thumbnail is now visible
return (this.widgetId ? this.widgetId : this.id) + "/show"; // String
},
 
setDataStore: function(dataStore, request, /*optional*/paramNames){
// summary: Sets the data store and request objects to read data from.
// dataStore:
// An implementation of the dojo.data.api.Read API. This accesses the image
// data.
// request:
// An implementation of the dojo.data.api.Request API. This specifies the
// query and paging information to be used by the data store
// paramNames:
// An object defining the names of the item attributes to fetch from the
// data store. The four attributes allowed are 'linkAttr', 'imageLargeAttr',
// 'imageThumbAttr' and 'titleAttr'
this.reset();
this.request = {
query: {},
start: request.start ? request.start : 0,
count: request.count ? request.count : 10,
onBegin: dojo.hitch(this, function(total){
this._maxPhotos = total;
})
};
if(request.query){ dojo.mixin(this.request.query, request.query);}
if(paramNames && paramNames.imageThumbAttr){
var attrNames = ["imageThumbAttr", "imageLargeAttr", "linkAttr", "titleAttr"];
for(var i = 0; i< attrNames.length; i++){
if(paramNames[attrNames[i]]){this[attrNames[i]] = paramNames[attrNames[i]];}
}
}
this.request.start = 0;
this.request.count = this.pageSize;
this.imageStore = dataStore;
if(!this.init()){this._loadNextPage();}
},
 
reset: function(){
// summary: Resets the widget back to its original state.
this._loadedImages = {};
var img;
for(var pos = 0; pos < this._thumbs.length; pos++){
img = this._thumbs[pos];
if(img){
// dojo.event.browser.clean(img);
if(img.parentNode){
img.parentNode.removeChild(img);
}
}
}
this._thumbs = [];
this.isInitialized = false;
this._noImages = true;
},
isVisible: function(idx) {
// summary: Returns true if the image at the specified index is currently visible. False otherwise.
var img = this._thumbs[idx];;
if(!img){return false;}
var pos = this.isHorizontal ? "offsetLeft" : "offsetTop";
var size = this.isHorizontal ? "offsetWidth" : "offsetHeight";
var scrollAttr = this.isHorizontal ? "scrollLeft" : "scrollTop";
var offset = img[pos] - this.thumbsNode[pos];
return (offset >= this.thumbScroller[scrollAttr]
&& offset + img[size] <= this.thumbScroller[scrollAttr] + this._scrollerSize);
},
_next: function() {
// summary: Displays the next page of images
var pos = this.isHorizontal ? "offsetLeft" : "offsetTop";
var size = this.isHorizontal ? "offsetWidth" : "offsetHeight";
var baseOffset = this.thumbsNode[pos];
var firstThumb = this._thumbs[this._thumbIndex];
var origOffset = firstThumb[pos] - baseOffset;
var idx = -1, img;
for(var i = this._thumbIndex + 1; i < this._thumbs.length; i++){
img = this._thumbs[i];
if(img[pos] - baseOffset + img[size] - origOffset > this._scrollerSize){
this._showThumbs(i);
return;
}
}
},
 
_prev: function(){
// summary: Displays the next page of images
if(this.thumbScroller[this.isHorizontal ? "scrollLeft" : "scrollTop"] == 0){return;}
var pos = this.isHorizontal ? "offsetLeft" : "offsetTop";
var size = this.isHorizontal ? "offsetWidth" : "offsetHeight";
var firstThumb = this._thumbs[this._thumbIndex];
var origOffset = firstThumb[pos] - this.thumbsNode[pos];
var idx = -1, img;
for(var i = this._thumbIndex - 1; i > -1; i--) {
img = this._thumbs[i];
if(origOffset - img[pos] > this._scrollerSize){
this._showThumbs(i + 1);
return;
}
}
this._showThumbs(0);
},
 
_checkLoad: function(img, idx){
dojo.publish(this.getShowTopicName(), [{index:idx}]);
this._updateNavControls();
this._loadingImages = {};
this._thumbIndex = idx;
//If we have not already requested the data from the store, do so.
if(this.thumbsNode.offsetWidth - img.offsetLeft < (this._scrollerSize * 2)){
this._loadNextPage();
}
},
 
_showThumbs: function(idx){
// summary: Displays thumbnail images, starting at position 'idx'
// idx: Number
// The index of the first thumbnail
var _this = this;
var idx = arguments.length == 0 ? this._thumbIndex : arguments[0];
idx = Math.min(Math.max(idx, 0), this._maxPhotos);
if(idx >= this._maxPhotos){ return; }
var img = this._thumbs[idx];
if(!img){ return; }
var left = img.offsetLeft - this.thumbsNode.offsetLeft;
var top = img.offsetTop - this.thumbsNode.offsetTop;
var offset = this.isHorizontal ? left : top;
if( (offset >= this.thumbScroller[this._scrollAttr]) &&
(offset + img[this._sizeAttr] <= this.thumbScroller[this._scrollAttr] + this._scrollerSize)
){
// FIXME: WTF is this checking for?
return;
}
if(this.isScrollable){
var target = this.isHorizontal ? {x: left, y: 0} : { x:0, y:top};
dojox.fx.smoothScroll({
target: target,
win: this.thumbScroller,
duration:300,
easing:dojox.fx.easing.easeOut,
onEnd: dojo.hitch(this, "_checkLoad", img, idx)
}).play(10);
}else{
if(this.isHorizontal){
this.thumbScroller.scrollLeft = left;
}else{
this.thumbScroller.scrollTop = top;
}
this._checkLoad(img, idx);
}
},
markImageLoaded: function(index){
// summary: Changes a visual cue to show the image is loaded
// description: If 'useLoadNotifier' is set to true, then a visual cue is
// given to state whether the image is loaded or not. Calling this function
// marks an image as loaded.
var thumbNotifier = dojo.byId("loadingDiv_"+this.widgetid+"_"+index);
if(thumbNotifier){this._setThumbClass(thumbNotifier, "thumbLoaded");}
this._loadedImages[index] = true;
},
 
_setThumbClass: function(thumb, className){
// summary: Adds a CSS class to a thumbnail, only if 'autoLoad' is true
// thumb: DomNode
// The thumbnail DOM node to set the class on
// className: String
// The CSS class to add to the DOM node.
if(!this.autoLoad){ return; }
dojo.addClass(thumb, className);
},
_loadNextPage: function(){
// summary: Loads the next page of thumbnail images
if(this._loadInProgress){return;}
this._loadInProgress = true;
var start = this.request.start + (this._noImages == true ? 0 : this.pageSize);
var pos = start;
while(pos < this._thumbs.length && this._thumbs[pos]){pos ++;}
var _this = this;
//Define the function to call when the items have been
//returned from the data store.
var complete = function(items, request){
if(items && items.length) {
var itemCounter = 0;
var loadNext = function(){
if(itemCounter >= items.length){
_this._loadInProgress = false;
return;
}
var counter = itemCounter++;
_this._loadImage(items[counter], pos + counter, loadNext);
}
loadNext();
//Show or hide the navigation arrows on the thumbnails,
//depending on whether or not the widget is at the start,
//end, or middle of the list of images.
_this._updateNavControls();
}else{
_this._loadInProgress = false;
}
};
//Define the function to call if the store reports an error.
var error = function(){
_this._loadInProgress = false;
console.debug("Error getting items");
};
this.request.onComplete = complete;
this.request.onError = error;
//Increment the start parameter. This is the dojo.data API's
//version of paging.
this.request.start = start;
this._noImages = false;
//Execute the request for data.
this.imageStore.fetch(this.request);
},
 
_loadImage: function(data, index, callback){
var url = this.imageStore.getValue(data,this.imageThumbAttr);
var img = document.createElement("img");
var imgContainer = document.createElement("div");
imgContainer.setAttribute("id","img_" + this.widgetid+"_"+index);
imgContainer.appendChild(img);
img._index = index;
img._data = data;
this._thumbs[index] = imgContainer;
var loadingDiv;
if(this.useLoadNotifier){
loadingDiv = document.createElement("div");
loadingDiv.setAttribute("id","loadingDiv_" + this.widgetid+"_"+index);
//If this widget was previously told that the main image for this
//thumb has been loaded, make the loading indicator transparent.
this._setThumbClass(loadingDiv,
this._loadedImages[index] ? "thumbLoaded":"thumbNotifier");
imgContainer.appendChild(loadingDiv);
}
var size = dojo.marginBox(this.thumbsNode);
var defaultSize;
var sizeParam;
if(this.isHorizontal){
defaultSize = this.thumbWidth;
sizeParam = 'w';
} else{
defaultSize = this.thumbHeight;
sizeParam = 'h';
}
size = size[sizeParam];
var sl = this.thumbScroller.scrollLeft, st = this.thumbScroller.scrollTop;
dojo.style(this.thumbsNode, this._sizeProperty, (size + defaultSize + 20) + "px");
//Remember the scroll values, as changing the size can alter them
this.thumbScroller.scrollLeft = sl;
this.thumbScroller.scrollTop = st;
this.thumbsNode.appendChild(imgContainer);
dojo.connect(img, "onload", this, function(){
var realSize = dojo.marginBox(img)[sizeParam];
this._totalSize += (Number(realSize) + 4);
dojo.style(this.thumbsNode, this._sizeProperty, this._totalSize + "px");
if(this.useLoadNotifier){dojo.style(loadingDiv, "width", (img.width - 4) + "px"); }
callback();
return false;
});
dojo.connect(img, "onclick", this, function(evt){
dojo.publish(this.getClickTopicName(), [{
index: evt.target._index,
data: evt.target._data,
url: img.getAttribute("src"),
largeUrl: this.imageStore.getValue(data,this.imageLargeAttr),
title: this.imageStore.getValue(data,this.titleAttr),
link: this.imageStore.getValue(data,this.linkAttr)
}]);
return false;
});
dojo.addClass(img, "imageGalleryThumb");
img.setAttribute("src", url);
var title = this.imageStore.getValue(data, this.titleAttr);
if(title){ img.setAttribute("title",title); }
this._updateNavControls();
},
 
_updateNavControls: function(){
// summary: Updates the navigation controls to hide/show them when at
// the first or last images.
var cells = [];
var change = function(node, add){
var fn = add ? "addClass" : "removeClass";
dojo[fn](node,"enabled");
dojo[fn](node,"thumbClickable");
};
var pos = this.isHorizontal ? "scrollLeft" : "scrollTop";
var size = this.isHorizontal ? "offsetWidth" : "offsetHeight";
change(this.navPrev, (this.thumbScroller[pos] > 0));
var last = this._thumbs[this._thumbs.length - 1];
var addClass = (this.thumbScroller[pos] + this._scrollerSize < this.thumbsNode[size]);
change(this.navNext, addClass);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/image/README
New file
0,0 → 1,60
-------------------------------------------------------------------------------
dojox.image
-------------------------------------------------------------------------------
Version 1.0
Release date: 10/31/07
-------------------------------------------------------------------------------
Project state:
prototype | expermental
-------------------------------------------------------------------------------
Credits
Peter Higgins (dante)
Shane O'Sullivan (shaneosullivan1@gmail.com)
-------------------------------------------------------------------------------
Project description
 
A class to provide a common API for images, and home for image
related Widgets.
-------------------------------------------------------------------------------
Dependencies:
 
LightBox: dojo core, dojox.fx and optionally dojox.data. uses
either tundra or soria theme, no standalone icons.
 
SlideShow: dojo core, dojo.fx, and dojo.data (optional
dojox.data store implementations apply)
 
ThumbNailPicker: dojo core, dojo.fx and dojo.data. Combined
with a SlideShow, creates a sample Gallery app.
 
Gallery: core, dojox.image.SlideShow, dojox.image.ThumbNailPicker
 
-------------------------------------------------------------------------------
Documentation
 
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/dojo/dojox/trunk/image/*
 
Install into the following directory structure:
/dojox/image/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
Additional Notes
 
LightBox: currently works as individual items, and grouped items,
but usage of dojo.data is broken (atm). the API is subject to
change, and is marked accordingly.
 
Hoping to implement: Carossel, and Reflect using
a common API provided by dojox.image.Pane (?)
 
SlideShow: Shows an image, one by one, from a datastore. Acts
as standing ImagePane implementation,
 
Gallery: A combination Thumbnail view and SlideShow, using
a datastore, and providing navigation, and common API.
/trunk/api/js/dojo1.0/dojox/image/tests/images/extraWide.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/image/tests/images/extraWide.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/image/tests/images/imageHoriz.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/image/tests/images/imageHoriz.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/image/tests/images/imageHoriz2.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/image/tests/images/imageHoriz2.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/image/tests/images/square.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/image/tests/images/square.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/image/tests/images/imageVert.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/image/tests/images/imageVert.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/image/tests/images.json
New file
0,0 → 1,32
{ items: [
{
"thumb":"images/extraWide.jpg",
"large":"images/extraWide.jpg",
"title":"I'm wide, me",
"link":"http://www.flickr.com/photos/44153025@N00/748348847"
},
{
"thumb":"images/imageHoriz.jpg",
"large":"images/imageHoriz.jpg",
"title":"I'm a horizontal picture",
"link":"http://www.flickr.com/photos/44153025@N00/735656038"
},
{
"thumb":"images/imageHoriz2.jpg",
"large":"images/imageHoriz2.jpg",
"title":"I'm another horizontal picture",
"link":"http://www.flickr.com/photos/44153025@N00/714540483"
},
{
"thumb":"images/imageVert.jpg",
"large":"images/imageVert.jpg",
"title":"I'm a vertical picture",
"link":"http://www.flickr.com/photos/44153025@N00/715392758"
},
{
"large":"images/square.jpg",
"thumb":"images/square.jpg",
"link" :"images/square.jpg",
"title":"1:1 aspect ratio"
}
]}
/trunk/api/js/dojo1.0/dojox/image/tests/test_Gallery.html
New file
0,0 → 1,67
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Testing the Image Gallery</title>
 
<style type="text/css">
@import "../../../dijit/tests/css/dijitTests.css";
@import "../resources/image.css";
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djconfig="parseOnLoad:true, isDebug: true, defaultTestTheme:'soria'"></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
<script type="text/javascript" src="../ThumbnailPicker.js"></script>
<script type="text/javascript" src="../SlideShow.js"></script>
<script type="text/javascript" src="../Gallery.js"></script>
<script type="text/javascript" src="../../../dojo/data/util/simpleFetch.js"></script>
<script type="text/javascript" src="../../data/FlickrStore.js"></script>
<script type="text/javascript" src="../../data/FlickrRestStore.js"></script>
<script type="text/javascript" src="../../../dojo/data/ItemFileReadStore.js"></script>
<script type="text/javascript">
// dojo.require("dojox.image.Gallery");
dojo.require("dojox.data.FlickrRestStore");
dojo.require("dojo.parser"); // find widgets
dojo.addOnLoad(function(){
var flickrRestStore = new dojox.data.FlickrRestStore();
var req = {
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627",
sort: [
{
attribute: "interestingness",
descending: true
}
],
// tags: ["superhorse", "redbones", "beachvolleyball"],
tag_mode: "any"
},
count: 20
};
dijit.byId('gallery1').setDataStore(flickrRestStore, req);
/*
dijit.byId('gallery2').setDataStore(imageItemStore,{ count:20 },{
imageThumbAttr: "thumb",
imageLargeAttr: "large"
});
*/
});
</script>
</head>
<body>
<h1 class="testTitle">dojox.image.Gallery</h1>
 
<h2>From FlickrRestStore:</h2>
<div id="gallery1" dojoType="dojox.image.Gallery" numberThumbs="4"></div>
 
<!--
<h2>From ItemFileReadStore:</h2>
<div id="gallery2" dojoType="dojox.image.Gallery"></div>
-->
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/image/tests/test_Lightbox.html
New file
0,0 → 1,101
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Dojo Lightbox Tests</title>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
<script type="text/javascript" src="../Lightbox.js"></script>
<script type="text/javascript">
// dojo.require("dojox.image.Lightbox"); // un-comment when not debugging
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
dojo.require("dojox.data.FlickrStore");
</script>
 
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/tests/css/dijitTests.css";
 
/* you need this file */
@import "../resources/image.css";
 
body, html { width:100%; height:100%; margin:0; padding:0; }
 
</style>
 
<script type="text/javascript">
// programatic flickrstore implementation [basic]
function onComplete(items,request){
if (items.length>0){
dojo.forEach(items,function(item){
var part = {
title: flickrStore.getValue(item,"title"),
href: flickrStore.getValue(item,"imageUrl")
};
// FIXME: make addImage more accessible, or do this internally
dijit.byId('fromStore')._attachedDialog.addImage(part,"flickrStore");
});
dojo.byId('flickrButton').disabled = false;
}
}
 
function onError(error,request){
console.warn(error,request);
}
 
function init(){
var flickrRequest = {
query: {},
onComplete: onComplete,
onError: onError,
userid: "jetstreet",
tags: "jetstreet",
count: 10
};
flickrStore.fetch(flickrRequest);
}
dojo.addOnLoad(init);
</script>
 
 
</head>
<body class="tundra">
 
<div style="padding:20px;">
<h1 class="testTitle">Dojo-base Lightbox implementation</h1>
 
<h3>Individual</h3>
<p>
<a href="images/imageVert.jpg" dojoType="dojox.image.Lightbox" title="More Guatemala...">tall</a>
<a href="images/imageHoriz.jpg" dojoType="dojox.image.Lightbox" title="Antigua, Guatemala">4:3 image</a>
</p>
 
<h3>Grouped:</h3>
<p>
<a href="images/imageHoriz2.jpg" dojoType="dojox.image.Lightbox" group="group1" title="Amterdamn Train Depot">wide image</a>
<a href="images/square.jpg" dojoType="dojox.image.Lightbox" group="group1" title="1:1 aspect">square</a>
<a href="images/extraWide.jpg" dojoType="dojox.image.Lightbox" group="group1" title="Greeneville, TN">wide image</a>
</p>
 
<h3>Alternate Group:</h3>
<p>
<a href="images/imageHoriz2.jpg" dojoType="dojox.image.Lightbox" group="group2" title="Amterdamn Train Depot">wide image</a>
<a href="images/square.jpg" dojoType="dojox.image.Lightbox" group="group2" title="1:1 aspect">square</a>
<a href="images/imageHoriz.jpg" dojoType="dojox.image.Lightbox" group="group2" title="Antigua, Guatemala">4:3 image</a>
<a href="images/imageVert.jpg" dojoType="dojox.image.Lightbox" group="group2" title="More Guatemala...">tall</a>
</p>
 
<h3>From dojox.data.FlickrStore (?)</h3>
 
<div dojoType="dojox.data.FlickrStore" jsId="flickrStore" label="title"></div>
<div id="fromStore" dojoType="dojox.image.Lightbox" store="flickrStore" group="flickrStore"></div>
 
<input id="flickrButton" type="button" onclick="dijit.byId('fromStore').show()" value="show flickr lightbox" disabled="disabled">
</div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/image/tests/test_SlideShow.html
New file
0,0 → 1,68
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Testing dojox.image.SlideShow</title>
 
<style type="text/css">
@import "../../../dijit/tests/css/dijitTests.css";
@import "../resources/image.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djconfig="parseOnLoad:false, isDebug: true, defaultTestTheme: 'soria'"></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
<script type="text/javascript" src="../SlideShow.js"></script>
<script type="text/javascript" src="../../../dojo/data/ItemFileReadStore.js"></script>
<script type="text/javascript" src="../../data/FlickrRestStore.js"></script>
 
<script type="text/javascript">
// dojo.require("dojox.image.SlideShow");
// dojo.require("dojox.data.FlickrRestStore");
// dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojo.parser"); // find widgets
dojo.addOnLoad(function(){
//Initialize the first SlideShow with an ItemFileReadStore
dojo.parser.parse(dojo.body());
dijit.byId('slideshow1').setDataStore(imageItemStore,
{ query: {}, count:20 },
{
imageThumbAttr: "thumb",
imageLargeAttr: "large"
}
);
//INitialize the second store with a FlickrRestStore
var flickrRestStore = new dojox.data.FlickrRestStore();
var req = {
query: {
userid: "44153025@N00",
apikey: "8c6803164dbc395fb7131c9d54843627"
},
count: 20
};
dijit.byId('slideshow2').setDataStore(flickrRestStore, req);
});
</script>
</head>
<body>
<h1 class="testTitle">dojox.image.SlideShow</h1>
 
<h2>from dojo.data.ItemFileReadStore</h2>
<div jsId="imageItemStore" dojoType="dojo.data.ItemFileReadStore" url="images.json"></div>
 
This SlideShow should display five photos, and loop. It should also
open a URL when the image is clicked. The widget should also resize to
fit the image.
<div id="slideshow1" dojoType="dojox.image.SlideShow"></div>
 
<h2>from dojox.data.FlickrRestStore</h2>
This SlideShow should display five photos, and not loop. It should also not
open a URL when the image is clicked. AutoLoading of images is also disabled.
The time between images in a SlideShow is 1 second. The widget should not resize to fit the image
<div id="slideshow2" dojoType="dojox.image.SlideShow" noLink="true" loop="false" autoLoad="false"
slideshowInterval="1" fixedHeight="true"></div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/image/tests/test_ThumbnailPicker.html
New file
0,0 → 1,134
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Testing the ThumbnailPicker</title>
 
<style type="text/css">
@import "../../../dijit/tests/css/dijitTests.css";
@import "../resources/image.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djconfig="parseOnLoad:true, isDebug: true, defaultTestTheme:'soria'"></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
<script type="text/javascript" src="../ThumbnailPicker.js"></script>
<script type="text/javascript">
// dojo.require("dojox.image.Gallery");
dojo.require("dojox.data.FlickrRestStore");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojo.parser"); // find widgets
/*
Initializes the ThumbnailPicker with a data store that
reads from the Flickr REST APIs.
*/
function initFlickrGallery() {
var flickrRestStore = new dojox.data.FlickrRestStore();
var req = {
query: {
userid: "44153025@N00",//The Flickr user id to use
apikey: "8c6803164dbc395fb7131c9d54843627",//An API key is required.
sort: [
{
descending: true //Use descending sort order, ascending is default.
}
],
tags: ["superhorse", "redbones", "beachvolleyball","dublin","croatia"],
tag_mode: "any" //Match any of the tags
},
count: 20
};
//Set the flickr data store on two of the dojox.image.ThumbnailPicker widgets
dijit.byId('thumbPicker1').setDataStore(flickrRestStore, req);
dijit.byId('thumbPicker3').setDataStore(flickrRestStore, req);
}
/*
Initializes the second ThumbnailPicker widget with a data store that
reads information from a JSON URL. This also tells the ThumbnailPicker
the name of the JSON attributes to read from each data item retrieved
from the JSON URL.
*/
function initItemStoreGallery(){
var itemRequest = {
query: {},
count: 20
};
var itemNameMap = {
imageThumbAttr: "thumb",
imageLargeAttr: "large"
};
//Set the dojo.data.ItemFileReadStore on two of the dojox.image.ThumbnailPicker widgets
//Note the use of the 'itemNameMap', which tells the widget what attributes to
//read from the store. Look in the 'images.json' file in the same folder as this
//file to see the data being read by the widget.
dijit.byId('thumbPicker2').setDataStore(imageItemStore, itemRequest, itemNameMap);
dijit.byId('thumbPicker4').setDataStore(imageItemStore, itemRequest, itemNameMap);
}
//Subscribe to clicks on the thumbnails, and print out the information provided
function doSubscribe(){
function updateDiv(packet){
dojo.byId('PublishedData').innerHTML = "You selected the thumbnail:"
+ "<br/><b>Index:</b> " + packet.index
+ "<br/><b>Url:</b> " + packet.url
+ "<br/><b>Large Url:</b> " + packet.largeUrl
+ "<br/><b>Title:</b> " + packet.title
+ "<br/><b>Link:</b> " + packet.link
;
};
//When an image in the ThumbnailPicker is clicked on, it publishes
//information on the image to a topic, whose name is found by calling
//the 'getTopicName' function on the widget.
dojo.subscribe(dijit.byId('thumbPicker1').getClickTopicName(), updateDiv);
dojo.subscribe(dijit.byId('thumbPicker2').getClickTopicName(), updateDiv);
}
dojo.addOnLoad(initFlickrGallery);
dojo.addOnLoad(initItemStoreGallery);
dojo.addOnLoad(doSubscribe);
</script>
</head>
<body>
<h1 class="testTitle">dojox.image.ThumbnailPicker</h1>
 
<div id="PublishedData" style="background-color:light-grey">
When you click on a thumbnail image, it's information is placed here
</div>
 
<h2>From FlickrRestStore:</h2>
This ThumbnailPicker should have 8 thumbnails, with each of them linking
to a URL when clicked on. The cursor should also change when over an image.
<div id="thumbPicker1" dojoType="dojox.image.ThumbnailPicker" size="500"
useHyperlink="true" ></div>
 
<h2>From ItemFileReadStore:</h2>
This ThumbnailPicker should have 5 thumbnails. Clicking on a thumbnail should NOT
open a URL, and the cursor should not change when over an image that is not an arrow.
<div id="thumbPicker2" dojoType="dojox.image.ThumbnailPicker" size="400"
isClickable="false"></div>
<div jsId="imageItemStore" dojoType="dojo.data.ItemFileReadStore" url="images.json"></div>
<h2>From FlickrRestStore:</h2>
This ThumbnailPicker should have 6 thumbnails, with each of them linking
to a URL when clicked on. The cursor should also change when over an image.
Unlike the ThumbnailPicker above, when these links are clicked on, this page
changes, instead of a popup window.
<div id="thumbPicker3" dojoType="dojox.image.ThumbnailPicker" size="600"
useHyperLink="true" hyperlinkTarget="this"></div>
 
<h2>From ItemFileReadStore, and vertical:</h2>
This ThumbnailPicker should have 5 thumbnails. Clicking on a thumbnail should NOT
open a URL, and the cursor should not change when over an image that is not an arrow.
The thumbnails should also be aligned vertically.
<div id="thumbPicker4" dojoType="dojox.image.ThumbnailPicker" size="300"
isClickable="false" isHorizontal="false"></div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/dtl/tag/logic.js
New file
0,0 → 1,164
if(!dojo._hasResource["dojox.dtl.tag.logic"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.tag.logic"] = true;
dojo.provide("dojox.dtl.tag.logic");
 
dojo.require("dojox.dtl._base");
 
dojox.dtl.tag.logic.IfNode = function(bools, trues, falses, type){
this.bools = bools;
this.trues = trues;
this.falses = falses;
this.type = type;
}
dojo.extend(dojox.dtl.tag.logic.IfNode, {
render: function(context, buffer){
if(this.type == "or"){
for(var i = 0, bool; bool = this.bools[i]; i++){
var ifnot = bool[0];
var filter = bool[1];
var value = filter.resolve(context);
if((value && !ifnot) || (ifnot && !value)){
if(this.falses){
buffer = this.falses.unrender(context, buffer);
}
return this.trues.render(context, buffer, this);
}
buffer = this.trues.unrender(context, buffer);
if(this.falses) return this.falses.render(context, buffer, this);
}
}else{
for(var i = 0, bool; bool = this.bools[i]; i++){
var ifnot = bool[0];
var filter = bool[1];
var value = filter.resolve(context);
if(!((value && !ifnot) || (ifnot && !value))){
if(this.trues){
buffer = this.trues.unrender(context, buffer);
}
return this.falses.render(context, buffer, this);
}
buffer = this.falses.unrender(context, buffer);
if(this.falses) return this.trues.render(context, buffer, this);
}
}
return buffer;
},
unrender: function(context, buffer){
if(this.trues) buffer = this.trues.unrender(context, buffer);
if(this.falses) buffer = this.falses.unrender(context, buffer);
return buffer;
},
clone: function(buffer){
var trues = this.trues;
var falses = this.falses;
if(trues){
trues = trues.clone(buffer);
}
if(falses){
falses = falses.clone(buffer);
}
return new this.constructor(this.bools, trues, falses, this.type);
},
toString: function(){ return "dojox.dtl.tag.logic.IfNode"; }
});
 
dojox.dtl.tag.logic.ForNode = function(assign, loop, reversed, nodelist){
this.assign = assign;
this.loop = loop;
this.reversed = reversed;
this.nodelist = nodelist;
this.pool = [];
}
dojo.extend(dojox.dtl.tag.logic.ForNode, {
render: function(context, buffer){
var parentloop = {};
if(context.forloop){
parentloop = context.forloop;
}
var items = dojox.dtl.resolveVariable(this.loop, context);
context.push();
for(var i = items.length; i < this.pool.length; i++){
this.pool[i].unrender(context, buffer);
}
if(this.reversed){
items = items.reversed();
}
var j = 0;
for(var i in items){
var item = items[i];
context.forloop = {
key: i,
counter0: j,
counter: j + 1,
revcounter0: items.length - j - 1,
revcounter: items.length - j,
first: j == 0,
parentloop: parentloop
};
context[this.assign] = item;
if(j + 1 > this.pool.length){
this.pool.push(this.nodelist.clone(buffer));
}
buffer = this.pool[j].render(context, buffer, this);
++j;
}
context.pop();
return buffer;
},
unrender: function(context, buffer){
for(var i = 0, pool; pool = this.pool[i]; i++){
buffer = pool.unrender(context, buffer);
}
return buffer;
},
clone: function(buffer){
return new this.constructor(this.assign, this.loop, this.reversed, this.nodelist.clone(buffer));
},
toString: function(){ return "dojox.dtl.tag.logic.ForNode"; }
});
 
dojox.dtl.tag.logic.if_ = function(parser, text){
var parts = text.split(/\s+/g);
var type;
var bools = [];
parts.shift();
text = parts.join(" ");
parts = text.split(" and ");
if(parts.length == 1){
type = "or";
parts = text.split(" or ");
}else{
type = "and";
for(var i = 0; i < parts.length; i++){
if(parts[i] == "or"){
throw new Error("'if' tags can't mix 'and' and 'or'");
}
}
}
for(var i = 0, part; part = parts[i]; i++){
var not = false;
if(part.indexOf("not ") == 0){
part = part.substring(4);
not = true;
}
bools.push([not, new dojox.dtl.Filter(part)]);
}
var trues = parser.parse(["else", "endif"]);
var falses = false;
var token = parser.next();
if(token.text == "else"){
var falses = parser.parse(["endif"]);
parser.next();
}
return new dojox.dtl.tag.logic.IfNode(bools, trues, falses, type);
}
 
dojox.dtl.tag.logic.for_ = function(parser, text){
var parts = text.split(/\s+/g);
var reversed = parts.length == 5;
var nodelist = parser.parse(["endfor"]);
parser.next();
return new dojox.dtl.tag.logic.ForNode(parts[1], parts[3], reversed, nodelist);
}
 
}
/trunk/api/js/dojo1.0/dojox/dtl/tag/event.js
New file
0,0 → 1,42
if(!dojo._hasResource["dojox.dtl.tag.event"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.tag.event"] = true;
dojo.provide("dojox.dtl.tag.event");
 
dojo.require("dojox.dtl._base");
 
dojox.dtl.tag.event.EventNode = function(type, fn){
this._type = type;
this.contents = fn;
}
dojo.extend(dojox.dtl.tag.event.EventNode, {
render: function(context, buffer){
if(!this._clear){
buffer.getParent()[this._type] = null;
this._clear = true;
}
if(this.contents && !this._rendered){
if(!context.getThis()) throw new Error("You must use Context.setObject(instance)");
this._rendered = dojo.connect(buffer.getParent(), this._type, context.getThis(), this.contents);
}
return buffer;
},
unrender: function(context, buffer){
if(this._rendered){
dojo.disconnect(this._rendered);
this._rendered = false;
}
return buffer;
},
clone: function(){
return new dojox.dtl.tag.event.EventNode(this._type, this.contents);
},
toString: function(){ return "dojox.dtl.tag.event." + this._type; }
});
 
dojox.dtl.tag.event.on = function(parser, text){
// summary: Associates an event type to a function (on the current widget) by name
var parts = text.split(" ");
return new dojox.dtl.tag.event.EventNode(parts[0], parts[1]);
}
 
}
/trunk/api/js/dojo1.0/dojox/dtl/tag/html.js
New file
0,0 → 1,136
if(!dojo._hasResource["dojox.dtl.tag.html"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.tag.html"] = true;
dojo.provide("dojox.dtl.tag.html");
 
dojo.require("dojox.dtl._base");
 
dojox.dtl.tag.html.HtmlNode = function(name){
this.contents = new dojox.dtl.Filter(name);
this._div = document.createElement("div");
this._lasts = [];
}
dojo.extend(dojox.dtl.tag.html.HtmlNode, {
render: function(context, buffer){
var text = this.contents.resolve(context);
text = text.replace(/<(\/?script)/ig, '&lt;$1').replace(/\bon[a-z]+\s*=/ig, '');
if(this._rendered && this._last != text){
buffer = this.unrender(context, buffer);
}
this._last = text;
 
// This can get reset in the above tag
if(!this._rendered){
this._rendered = true;
var div = this._div;
div.innerHTML = text;
var children = div.childNodes;
while(children.length){
var removed = div.removeChild(children[0]);
this._lasts.push(removed);
buffer = buffer.concat(removed);
}
}
 
return buffer;
},
unrender: function(context, buffer){
if(this._rendered){
this._rendered = false;
this._last = "";
for(var i = 0, node; node = this._lasts[i++];){
buffer = buffer.remove(node);
dojo._destroyElement(node);
}
this._lasts = [];
}
return buffer;
},
clone: function(buffer){
return new dojox.dtl.tag.html.HtmlNode(this.contents.contents);
},
toString: function(){ return "dojox.dtl.tag.html.HtmlNode"; }
});
 
dojox.dtl.tag.html.StyleNode = function(styles){
this.contents = {};
this._styles = styles;
for(var key in styles){
this.contents[key] = new dojox.dtl.Template(styles[key]);
}
}
dojo.extend(dojox.dtl.tag.html.StyleNode, {
render: function(context, buffer){
for(var key in this.contents){
dojo.style(buffer.getParent(), key, this.contents[key].render(context));
}
return buffer;
},
unrender: function(context, buffer){
return buffer;
},
clone: function(buffer){
return new dojox.dtl.tag.html.HtmlNode(this._styles);
},
toString: function(){ return "dojox.dtl.tag.html.StyleNode"; }
});
 
dojox.dtl.tag.html.AttachNode = function(key){
this.contents = key;
}
dojo.extend(dojox.dtl.tag.html.AttachNode, {
render: function(context, buffer){
if(!this._rendered){
this._rendered = true;
context.getThis()[this.contents] = buffer.getParent();
}
return buffer;
},
unrender: function(context, buffer){
if(this._rendered){
this._rendered = false;
if(context.getThis()[this.contents] === buffer.getParent()){
delete context.getThis()[this.contents];
}
}
return buffer;
},
clone: function(buffer){
return new dojox.dtl.tag.html.HtmlNode(this._styles);
},
toString: function(){ return "dojox.dtl.tag.html.AttachNode"; }
});
 
dojox.dtl.tag.html.html = function(parser, text){
var parts = text.split(" ", 2);
return new dojox.dtl.tag.html.HtmlNode(parts[1]);
}
 
dojox.dtl.tag.html.tstyle = function(parser, text){
var styles = {};
text = text.replace(dojox.dtl.tag.html.tstyle._re, "");
var rules = text.split(dojox.dtl.tag.html.tstyle._re1);
for(var i = 0, rule; rule = rules[i]; i++){
var parts = rule.split(dojox.dtl.tag.html.tstyle._re2);
var key = parts[0];
var value = parts[1];
if(value.indexOf("{{") == 0){
styles[key] = value;
}
}
return new dojox.dtl.tag.html.StyleNode(styles);
}
dojo.mixin(dojox.dtl.tag.html.tstyle, {
_re: /^tstyle\s+/,
_re1: /\s*;\s*/g,
_re2: /\s*:\s*/g
});
 
dojox.dtl.tag.html.attach = function(parser, text){
var parts = text.split(dojox.dtl.tag.html.attach._re);
return new dojox.dtl.tag.html.AttachNode(parts[1]);
}
dojo.mixin(dojox.dtl.tag.html.attach, {
_re: /\s+/g
})
 
}
/trunk/api/js/dojo1.0/dojox/dtl/tag/loader.js
New file
0,0 → 1,146
if(!dojo._hasResource["dojox.dtl.tag.loader"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.tag.loader"] = true;
dojo.provide("dojox.dtl.tag.loader");
 
dojo.require("dojox.dtl._base");
 
dojox.dtl.tag.loader.BlockNode = function(name, nodelist){
this.name = name;
this.nodelist = nodelist; // Can be overridden
}
dojo.extend(dojox.dtl.tag.loader.BlockNode, {
render: function(context, buffer){
if(this.override){
buffer = this.override.render(context, buffer, this);
this.rendered = this.override;
}else{
buffer = this.nodelist.render(context, buffer, this);
this.rendered = this.nodelist;
}
this.override = null;
return buffer;
},
unrender: function(context, buffer){
return this.rendered.unrender(context, buffer);
},
setOverride: function(nodelist){
// summary: In a shared parent, we override, not overwrite
if(!this.override){
this.override = nodelist;
}
},
toString: function(){ return "dojox.dtl.tag.loader.BlockNode"; }
});
dojox.dtl.tag.loader.block = function(parser, text){
var parts = text.split(" ");
var name = parts[1];
parser._blocks = parser._blocks || {};
parser._blocks[name] = parser._blocks[name] || [];
parser._blocks[name].push(name);
var nodelist = parser.parse(["endblock", "endblock " + name]);
parser.next();
return new dojox.dtl.tag.loader.BlockNode(name, nodelist);
}
 
dojox.dtl.tag.loader.ExtendsNode = function(getTemplate, nodelist, shared, parent, key){
this.getTemplate = getTemplate;
this.nodelist = nodelist;
this.shared = shared;
this.parent = parent;
this.key = key;
}
dojo.extend(dojox.dtl.tag.loader.ExtendsNode, {
parents: {},
getParent: function(context){
if(!this.parent){
this.parent = context.get(this.key, false);
if(!this.parent){
throw new Error("extends tag used a variable that did not resolve");
}
if(typeof this.parent == "object"){
if(this.parent.url){
if(this.parent.shared){
this.shared = true;
}
this.parent = this.parent.url.toString();
}else{
this.parent = this.parent.toString();
}
}
if(this.parent && this.parent.indexOf("shared:") == 0){
this.shared = true;
this.parent = this.parent.substring(7, parent.length);
}
}
var parent = this.parent;
if(!parent){
throw new Error("Invalid template name in 'extends' tag.");
}
if(parent.render){
return parent;
}
if(this.parents[parent]){
return this.parents[parent];
}
this.parent = this.getTemplate(dojox.dtl.text.getTemplateString(parent));
if(this.shared){
this.parents[parent] = this.parent;
}
return this.parent;
},
render: function(context, buffer){
var st = dojox.dtl;
var stbl = dojox.dtl.tag.loader;
var parent = this.getParent(context);
var isChild = parent.nodelist[0] instanceof this.constructor;
var parentBlocks = {};
for(var i = 0, node; node = parent.nodelist.contents[i]; i++){
if(node instanceof stbl.BlockNode){
parentBlocks[node.name] = node;
}
}
for(var i = 0, node; node = this.nodelist.contents[i]; i++){
if(node instanceof stbl.BlockNode){
var block = parentBlocks[node.name];
if(!block){
if(isChild){
parent.nodelist[0].nodelist.append(node);
}
}else{
if(this.shared){
block.setOverride(node.nodelist);
}else{
block.nodelist = node.nodelist;
}
}
}
}
this.rendered = parent;
return parent.render(context, buffer, this);
},
unrender: function(context, buffer){
return this.rendered.unrender(context, buffer, this);
},
toString: function(){ return "dojox.dtl.block.ExtendsNode"; }
});
dojox.dtl.tag.loader.extends_ = function(parser, text){
var parts = text.split(" ");
var shared = false;
var parent = null;
var key = null;
if(parts[1].charAt(0) == '"' || parts[1].charAt(0) == "'"){
parent = parts[1].substring(1, parts[1].length - 1);
}else{
key = parts[1];
}
if(parent && parent.indexOf("shared:") == 0){
shared = true;
parent = parent.substring(7, parent.length);
}
var nodelist = parser.parse();
return new dojox.dtl.tag.loader.ExtendsNode(parser.getTemplate, nodelist, shared, parent, key);
}
 
}
/trunk/api/js/dojo1.0/dojox/dtl/tag/loop.js
New file
0,0 → 1,89
if(!dojo._hasResource["dojox.dtl.tag.loop"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.tag.loop"] = true;
dojo.provide("dojox.dtl.tag.loop");
 
dojo.require("dojox.dtl._base");
 
dojox.dtl.tag.loop.CycleNode = function(cyclevars, name, VarNode){
this._cyclevars = cyclevars;
this._counter = -1
this._name = name;
this._map = {};
this._VarNode = VarNode;
}
dojo.extend(dojox.dtl.tag.loop.CycleNode, {
render: function(context, buffer){
if(context.forloop && !context.forloop.counter0){
this._counter = -1;
}
 
++this._counter;
var value = this._cyclevars[this._counter % this._cyclevars.length];
if(this._name){
context[this._name] = value;
}
if(!this._map[value]){
this._map[value] = {};
}
var node = this._map[value][this._counter] = new this._VarNode(value);
 
return node.render(context, buffer, this);
},
unrender: function(context, buffer){
return buffer;
},
clone: function(){
return new this.constructor(this._cyclevars, this._name);
},
_onEnd: function(){
this._counter = -1;
},
toString: function(){ return "dojox.dtl.tag.loop.CycleNode"; }
});
 
dojox.dtl.tag.loop.cycle = function(parser, text){
// summary: Cycle among the given strings each time this tag is encountered
var args = text.split(" ");
 
if(args.length < 2){
throw new Error("'cycle' tag requires at least two arguments");
}
 
if(args[1].indexOf(",") != -1){
var vars = args[1].split(",");
args = [args[0]];
for(var i = 0; i < vars.length; i++){
args.push('"' + vars[i] + '"');
}
}
 
if(args.length == 2){
var name = args[args.length - 1];
 
if(!parser._namedCycleNodes){
throw new Error("No named cycles in template: '" + name + "' is not defined");
}
if(!parser._namedCycleNodes[name]){
throw new Error("Named cycle '" + name + "' does not exist");
}
 
return parser._namedCycleNodes[name];
}
 
if(args.length > 4 && args[args.length - 2] == "as"){
var name = args[args.length - 1];
 
var node = new dojox.dtl.tag.loop.CycleNode(args.slice(1, args.length - 2), name, parser.getVarNode());
 
if(!parser._namedCycleNodes){
parser._namedCycleNodes = {};
}
parser._namedCycleNodes[name] = node;
}else{
node = new dojox.dtl.tag.loop.CycleNode(args.slice(1), null, parser.getVarNode());
}
 
return node;
}
 
}
/trunk/api/js/dojo1.0/dojox/dtl/tag/misc.js
New file
0,0 → 1,76
if(!dojo._hasResource["dojox.dtl.tag.misc"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.tag.misc"] = true;
dojo.provide("dojox.dtl.tag.misc");
 
dojo.require("dojox.dtl._base");
 
dojox.dtl.tag.misc.commentNode = new function(){
this.render = this.unrender = function(context, buffer){ return buffer; };
this.clone = function(){ return this; };
this.toString = function(){ return "dojox.dtl.tag.misc.CommentNode"; };
}
 
dojox.dtl.tag.misc.DebugNode = function(TextNode){
this._TextNode = TextNode;
}
dojo.extend(dojox.dtl.tag.misc.DebugNode, {
render: function(context, buffer){
var keys = context.getKeys();
var debug = "";
for(var i = 0, key; key = keys[i]; i++){
console.debug("DEBUG", key, ":", context[key]);
debug += key + ": " + dojo.toJson(context[key]) + "\n\n";
}
return new this._TextNode(debug).render(context, buffer, this);
},
unrender: function(context, buffer){
return buffer;
},
clone: function(buffer){
return new this.constructor(this._TextNode);
},
toString: function(){ return "dojox.dtl.tag.misc.DebugNode"; }
});
 
dojox.dtl.tag.misc.FilterNode = function(varnode, nodelist){
this._varnode = varnode;
this._nodelist = nodelist;
}
dojo.extend(dojox.dtl.tag.misc.FilterNode, {
render: function(context, buffer){
// Doing this in HTML requires a different buffer with a fake root node
var output = this._nodelist.render(context, new dojox.string.Builder());
context.update({ "var": output.toString() });
var filtered = this._varnode.render(context, buffer);
context.pop();
return buffer;
},
unrender: function(context, buffer){
return buffer;
},
clone: function(buffer){
return new this.constructor(this._expression, this._nodelist.clone(buffer));
}
});
 
dojox.dtl.tag.misc.comment = function(parser, text){
// summary: Ignore everything between {% comment %} and {% endcomment %}
parser.skipPast("endcomment");
return dojox.dtl.tag.misc.commentNode;
}
 
dojox.dtl.tag.misc.debug = function(parser, text){
// summary: Output the current context, maybe add more stuff later.
return new dojox.dtl.tag.misc.DebugNode(parser.getTextNode());
}
 
dojox.dtl.tag.misc.filter = function(parser, text){
// summary: Filter the contents of the blog through variable filters.
var parts = text.split(" ", 2);
var varnode = new (parser.getVarNode())("var|" + parts[1]);
var nodelist = parser.parse(["endfilter"]);
parser.next();
return new dojox.dtl.tag.misc.FilterNode(varnode, nodelist);
}
 
}
/trunk/api/js/dojo1.0/dojox/dtl/README
New file
0,0 → 1,203
-------------------------------------------------------------------------------
DojoX Django Template Language
-------------------------------------------------------------------------------
Version 0.0
Release date: 09/20/2007
-------------------------------------------------------------------------------
Project state: experimental/feature incomplete
-------------------------------------------------------------------------------
Project authors
Neil Roberts (pottedmeat@dojotoolkit.org)
-------------------------------------------------------------------------------
Project description
 
The Django Template language uses a system of templates that can be compiled
once and rendered indefinitely afterwards. It uses a simple system of tags
and filters.
 
This aims to be a 1:1 match with the Django Template Language as outlined in
http://www.djangoproject.com/documentation/templates/. Many common tags and
filters have been implemented (see below), along with new filters and tags as
necessary (see below).
 
The Django Template Language is intended within Django to only handle text.
Our implementation is able to handle HTML in addition to text. Actually, the
text and HTML portions of dojox.dtl are two separate layers, the HTML layer
sits on top of the text layer (base). It's also been implemented in such a way
that you have little to fear when moving your code from Django to dojox.dtl.
Your existing templates should work, and will benefit from the massive
performance gain of being able to manipulate nodes, rather than having to do
clunky innerHTML swaps you would have to do with a text-only system. It also
allows for new HTML-centric abilities, outlined below.
 
Despite having two levels of complexity, if you write your tags correctly, they
will work in both environments.
-------------------------------------------------------------------------------
Dependencies
 
Base:
dojox.string.Builder
 
Date filters and tags:
dojox.date.php
 
Widget:
dijit._Widget
dijit._Container
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/dtl.js
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/dtl/*
 
Install into the following directory structure:
/dojox/dtl/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
What's Been Done
 
| Implemented | Tag | Text Unit Test | HTML Unit Test |
| X | block | X | |
| X | comment | X | |
| X | cycle | X | |
| X | debug | X | |
| X | extends | X | |
| X | filter | X | |
| | firstof | | |
| X | for | | |
| X | if | | |
| | ifchanged | | |
| | ifequal | | |
| | ifnotequal | | |
| | include | | |
| | load | | |
| | now | | |
| | regroup | | |
| | spaceless | | |
| | ssi | | |
| | templatetag | | |
| | url | | |
| | widthratio | | |
| | with | | |
 
| Implemented | Filter | Text Unit Test | HTML Unit Test |
| X | add | X | |
| X | addslashes | X | |
| X | capfirst | X | |
| X | center | X | |
| X | cut | X | |
| X | date | X | |
| X | default | X | |
| X | default_if_none | X | |
| X | dictsort | X | |
| X | dictsort_reversed | X | |
| X | divisibleby | X | |
| X | escape | X | |
| X | filesizeformat | X | |
| X | first | X | |
| X | fix_ampersands | X | |
| X | floatformat | X | |
| X | get_digit | X | |
| X | iriencode | X | |
| X | join | X | |
| X | length | X | |
| X | length_is | X | |
| X | linebreaks | X | |
| X | linebreaksbr | X | |
| X | linenumbers | X | |
| X | ljust | X | |
| X | lower | X | |
| X | make_list | X | |
| X | phone2numeric | X | |
| X | pluralize | X | |
| X | pprint | X | |
| X | random | X | |
| X | removetags | X | |
| X | rjust | X | |
| X | slice | X | |
| X | slugify | X | |
| X | stringformat | X | |
| X | striptags | X | |
| X | time | X | |
| X | timesince | X | |
| X | timeuntil | X | |
| X | title | X | |
| X | truncatewords | X | |
| X | truncatewords_html | X | |
| X | unordered_list | X | |
| X | upper | X | |
| X | urlencode | X | |
| X | urlize | X | |
| X | urlizetrunc | X | |
| X | wordcount | X | |
| X | wordwrap | X | |
| X | yesno | X | |
-------------------------------------------------------------------------------
HTML-Specific Additions
-------------------------------------------------------------------------------
{%extends "shared:templates/template.html" %}
 
When using the {% extends %} tag, we don't always want to replace the parent
node in DOM. For example, if we have a list view and a detail view, but both
share the same base template, we want it to share the parent template. This
basically means that the same nodes will be used in the parent for both views.
 
To use this, simply add "shared:" to the beginning of the specified template.
-------------------------------------------------------------------------------
<!--{% commented markup %}-->
 
Some browsers treat comment nodes as full fledged nodes. If performance is
important to you, you can wrap your markup in comments. The comments will be
automatically stripped for browsers that cannot support this.
-------------------------------------------------------------------------------
Attribute Tags
 
If a tag name begins with "attr:" then it will be able to inject an object
into the parsed template. (See dojox.dtl.tag.event.EventNode)
 
onclick/onmouseover/etc attributes work by attaching to the rendering object.
 
tstyle attribute allows for styles to be changed dynamically. Use them just
like a "style" attribute.
 
attach attribute attaches the node to the rendering object.
-------------------------------------------------------------------------------
New Context Functions
 
setThis() and getThis() returns the object "in charge" of the current rendering.
This is used so that we can attach events.
 
mixin() and filter() clone the current context, and either add to or reduce
the keys in the context.
-------------------------------------------------------------------------------
Buffers
 
Both the base and HTML versions of dojox.dtl use buffers. The base version uses
dojox.string.Builder and the HTML version uses dojox.dtl.HtmlBuffer.
 
The HTML buffer has several calls important to rendering:
 
setParent/getParent/concat/remove:
 
setParent and concat are used in order to render our HTML. As we move through
the parsed template, different nodes change the parent or add on to the
current parent. getParent is useful in things like the attribute tags, since
they can use getParent to find the node that they're an attribute on. remove is
used during unrendering.
 
setAttribute:
 
Sets an attribute on the current parent
-------------------------------------------------------------------------------
Tags Need clone/unrender Functions.
 
One of the biggest challenges of getting dojox.dtl to work in an HTML
environment was logic blocks. Nodes and objects inside a for loop need to be
cloned, they can't simply be re-rendered, especially if they involve a Node.
Also, in the case of an if/else block, we need to be able to not just render
one of the blocks, but also unrender the second.
 
This is really simple code, a good example is the dojox.dtl.HtmlNode
object. Each function in this object is only one line long.
/trunk/api/js/dojo1.0/dojox/dtl/widget.js
New file
0,0 → 1,48
if(!dojo._hasResource["dojox.dtl.widget"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.widget"] = true;
dojo.provide("dojox.dtl.widget");
 
dojo.require("dijit._Widget");
dojo.require("dijit._Container")
dojo.require("dojox.dtl.html");
dojo.require("dojox.dtl.render.html");
 
dojo.declare("dojox.dtl._Widget", [dijit._Widget, dijit._Contained],
{
buffer: 0,
buildRendering: function(){
this.domNode = this.srcNodeRef;
 
if(this.domNode){
var parent = this.getParent();
if(parent){
this.setAttachPoint(parent);
}
}
},
setAttachPoint: function(/*dojox.dtl.AttachPoint*/ attach){
this._attach = attach;
},
render: function(/*dojox.dtl.HtmlTemplate*/ tpl, /*dojox.dtl.Context*/ context){
if(!this._attach){
throw new Error("You must use an attach point with dojox.dtl.TemplatedWidget");
}
 
context.setThis(this);
this._attach.render(tpl, context);
}
}
);
 
dojo.declare("dojox.dtl.AttachPoint", [dijit._Widget, dijit._Container],
{
constructor: function(props, node){
this._render = new dojox.dtl.render.html.Render(node);
},
render: function(/*dojox.dtl.HtmlTemplate*/ tpl, /*dojox.dtl.Context*/ context){
this._render.render(tpl, context);
}
}
);
 
}
/trunk/api/js/dojo1.0/dojox/dtl/html.js
New file
0,0 → 1,658
if(!dojo._hasResource["dojox.dtl.html"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.html"] = true;
dojo.provide("dojox.dtl.html");
 
dojo.require("dojox.dtl._base");
 
dojox.dtl.ObjectMap = function(){
this.contents = [];
}
dojo.extend(dojox.dtl.ObjectMap, {
get: function(key){
var contents = this.contents;
for(var i = 0, content; content = contents[i]; i++){
if(content[0] === key){
return content[1];
}
}
},
put: function(key, value){
var contents = this.contents;
for(var i = 0, content; content = contents[i]; i++){
if(content[0] === key){
if(arguments.length == 1){
contents.splice(i, 1);
return;
}
content[1] = value;
return;
}
}
contents.push([key, value]);
},
toString: function(){ return "dojox.dtl.ObjectMap"; }
});
 
dojox.dtl.html = {
types: dojo.mixin({change: -11, attr: -12, elem: 1, text: 3}, dojox.dtl.text.types),
_attributes: {},
_re: /(^\s+|\s+$)/g,
_re2: /\b([a-zA-Z]+)="/g,
_re3: /<!--({({|%).*?(%|})})-->/g,
_re4: /^function anonymous\(\)\s*{\s*(.*)\s*}$/,
_trim: function(/*String*/ str){
return str.replace(this._re, "");
},
getTemplate: function(text){
if(typeof this._commentable == "undefined"){
// Check to see if the browser can handle comments
this._commentable = false;
var div = document.createElement("div");
div.innerHTML = "<!--Test comment handling, and long comments, using comments whenever possible.-->";
if(div.childNodes.length && div.childNodes[0].nodeType == 8 && div.childNodes[0].data == "comment"){
this._commentable = true;
}
}
 
if(!this._commentable){
// Strip comments
text = text.replace(this._re3, "$1");
}
 
var match;
while(match = this._re2.exec(text)){
this._attributes[match[1]] = true;
}
var div = document.createElement("div");
div.innerHTML = text;
var output = { pres: [], posts: []}
while(div.childNodes.length){
if(!output.node && div.childNodes[0].nodeType == 1){
output.node = div.removeChild(div.childNodes[0]);
}else if(!output.node){
output.pres.push(div.removeChild(div.childNodes[0]));
}else{
output.posts.push(div.removeChild(div.childNodes[0]));
}
}
 
if(!output.node){
throw new Error("Template did not provide any content");
}
 
return output;
},
tokenize: function(/*Node*/ node, /*Array?*/ tokens, /*Array?*/ preNodes, /*Array?*/ postNodes){
tokens = tokens || [];
var first = !tokens.length;
var types = this.types;
 
var children = [];
for(var i = 0, child; child = node.childNodes[i]; i++){
children.push(child);
}
 
if(preNodes){
for(var i = 0, child; child = preNodes[i]; i++){
this._tokenize(node, child, tokens);
}
}
 
tokens.push([types.elem, node]);
tokens.push([types.change, node]);
 
for(var key in this._attributes){
var value = "";
if(key == "class"){
value = node.className || value;
}else if(key == "for"){
value = node.htmlFor || value;
}else if(node.getAttribute){
value = node.getAttribute(key, 2) || value;
if(key == "href" || key == "src"){
if(dojo.isIE){
var hash = location.href.lastIndexOf(location.hash);
var href = location.href.substring(0, hash).split("/");
href.pop();
href = href.join("/") + "/";
if(value.indexOf(href) == 0){
value = value.replace(href, "");
}
value = value.replace(/%20/g, " ").replace(/%7B/g, "{").replace(/%7D/g, "}").replace(/%25/g, "%");
}
if(value.indexOf("{%") != -1 || value.indexOf("{{") != -1){
node.setAttribute(key, "");
}
}
}
if(typeof value == "function"){
value = value.toString().replace(this._re4, "$1");
}
if(typeof value == "string" && (value.indexOf("{%") != -1 || value.indexOf("{{") != -1 || (value && dojox.dtl.text.getTag("attr:" + key, true)))){
tokens.push([types.attr, node, key, value]);
}
}
 
if(!children.length){
tokens.push([types.change, node.parentNode, true]);
if(postNodes){
for(var i = 0, child; child = postNodes[i]; i++){
this._tokenize(node, child, tokens);
}
}
return tokens;
}
 
for(var i = 0, child; child = children[i]; i++){
this._tokenize(node, child, tokens);
}
 
if(node.parentNode && node.parentNode.tagName){
tokens.push([types.change, node.parentNode, true]);
node.parentNode.removeChild(node);
}
if(postNodes){
for(var i = 0, child; child = postNodes[i]; i++){
this._tokenize(node, child, tokens);
}
}
 
if(first){
tokens.push([types.change, node, true]);
}
 
return tokens;
},
_tokenize: function(parent, child, tokens){
var types = this.types;
var data = child.data;
switch(child.nodeType){
case 1:
this.tokenize(child, tokens);
break;
case 3:
if(data.match(/[^\s\n]/)){
if(data.indexOf("{{") != -1 || data.indexOf("{%") != -1){
var texts = dojox.dtl.text.tokenize(data);
for(var j = 0, text; text = texts[j]; j++){
if(typeof text == "string"){
tokens.push([types.text, text]);
}else{
tokens.push(text);
}
}
}else{
tokens.push([child.nodeType, child]);
}
}
if(child.parentNode) child.parentNode.removeChild(child);
break;
case 8:
if(data.indexOf("{%") == 0){
tokens.push([types.tag, this._trim(data.substring(2, data.length - 3))]);
}
if(data.indexOf("{{") == 0){
tokens.push([types.varr, this._trim(data.substring(2, data.length - 3))]);
}
if(child.parentNode) child.parentNode.removeChild(child);
break;
}
}
}
 
dojox.dtl.HtmlTemplate = function(/*String|dojo._Url*/ obj){
// summary: Use this object for HTML templating
var dd = dojox.dtl;
var ddh = dd.html;
 
if(!obj.node){
if(typeof obj == "object"){
obj = dojox.dtl.text.getTemplateString(obj);
}
obj = ddh.getTemplate(obj);
}
 
var tokens = ddh.tokenize(obj.node, [], obj.pres, obj.posts);
var parser = new dd.HtmlParser(tokens);
this.nodelist = parser.parse();
}
dojo.extend(dojox.dtl.HtmlTemplate, {
_count: 0,
_re: /\bdojo:([a-zA-Z0-9_]+)\b/g,
setClass: function(str){
this.getRootNode().className = str;
},
getRootNode: function(){
return this.rootNode;
},
getBuffer: function(){
return new dojox.dtl.HtmlBuffer();
},
render: function(context, buffer){
buffer = buffer || this.getBuffer();
this.rootNode = null;
var onSetParent = dojo.connect(buffer, "onSetParent", this, function(node){
if(!this.rootNode){
this.rootNode = node || true;
}
});
var output = this.nodelist.render(context || new dojox.dtl.Context({}), buffer);
dojo.disconnect(onSetParent);
buffer._flushCache();
return output;
},
unrender: function(context, buffer){
return this.nodelist.unrender(context, buffer);
},
toString: function(){ return "dojox.dtl.HtmlTemplate"; }
});
 
dojox.dtl.HtmlBuffer = function(/*Node*/ parent){
// summary: Allows the manipulation of DOM
// description:
// Use this to append a child, change the parent, or
// change the attribute of the current node.
this._parent = parent;
this._cache = [];
}
dojo.extend(dojox.dtl.HtmlBuffer, {
concat: function(/*DOMNode*/ node){
if(!this._parent) return this;
if(node.nodeType){
var caches = this._getCache(this._parent);
if(node.parentNode === this._parent){
// If we reach a node that already existed, fill in the cache for this same parent
var i = 0;
for(var i = 0, cache; cache = caches[i]; i++){
this.onAddNode(node);
this._parent.insertBefore(cache, node);
}
caches.length = 0;
}
if(!node.parentNode || !node.parentNode.tagName){
if(!this._parent.childNodes.length){
this.onAddNode(node);
this._parent.appendChild(node);
}else{
caches.push(node);
}
}
}
return this;
},
remove: function(obj){
if(typeof obj == "string"){
this._parent.removeAttribute(obj);
}else{
if(obj.parentNode === this._parent){
this.onRemoveNode();
this._parent.removeChild(obj);
}
}
return this;
},
setAttribute: function(key, value){
if(key == "class"){
this._parent.className = value;
}else if(key == "for"){
this._parent.htmlFor = value;
}else if(this._parent.setAttribute){
this._parent.setAttribute(key, value);
}
return this;
},
setParent: function(node, /*Boolean?*/ up){
if(!this._parent) this._parent = node;
var caches = this._getCache(this._parent);
if(caches && caches.length && up){
for(var i = 0, cache; cache = caches[i]; i++){
if(cache !== this._parent && (!cache.parentNode || !cache.parentNode.tagName)){
this.onAddNode(cache);
this._parent.appendChild(cache);
}
}
caches.length = 0;
}
 
this.onSetParent(node, up);
this._parent = node;
return this;
},
getParent: function(){
return this._parent;
},
onSetParent: function(){
// summary: Stub called when setParent is used.
},
onAddNode: function(){
// summary: Stub called when new nodes are added
},
onRemoveNode: function(){
// summary: Stub called when nodes are removed
},
_getCache: function(node){
for(var i = 0, cache; cache = this._cache[i]; i++){
if(cache[0] === node){
return cache[1];
}
}
var arr = [];
this._cache.push([node, arr]);
return arr;
},
_flushCache: function(node){
for(var i = 0, cache; cache = this._cache[i]; i++){
if(!cache[1].length){
this._cache.splice(i--, 1);
}
}
},
toString: function(){ return "dojox.dtl.HtmlBuffer"; }
});
 
dojox.dtl.HtmlNode = function(node){
// summary: Places a node into DOM
this.contents = node;
}
dojo.extend(dojox.dtl.HtmlNode, {
render: function(context, buffer){
return buffer.concat(this.contents);
},
unrender: function(context, buffer){
return buffer.remove(this.contents);
},
clone: function(buffer){
return new dojox.dtl.HtmlNode(this.contents);
},
toString: function(){ return "dojox.dtl.HtmlNode"; }
});
 
dojox.dtl.HtmlNodeList = function(/*Node[]*/ nodes){
// summary: A list of any HTML-specific node object
// description:
// Any object that's used in the constructor or added
// through the push function much implement the
// render, unrender, and clone functions.
this.contents = nodes || [];
}
dojo.extend(dojox.dtl.HtmlNodeList, {
parents: new dojox.dtl.ObjectMap(),
push: function(node){
this.contents.push(node);
},
unshift: function(node){
this.contents.unshift(node);
},
render: function(context, buffer, /*Node*/ instance){
if(instance){
var parent = buffer.getParent();
}
for(var i = 0; i < this.contents.length; i++){
buffer = this.contents[i].render(context, buffer);
if(!buffer) throw new Error("Template node render functions must return their buffer");
}
if(parent){
buffer.setParent(parent, true);
}
return buffer;
},
unrender: function(context, buffer){
for(var i = 0; i < this.contents.length; i++){
buffer = this.contents[i].unrender(context, buffer);
if(!buffer) throw new Error("Template node render functions must return their buffer");
}
return buffer;
},
clone: function(buffer){
// summary:
// Used to create an identical copy of a NodeList, useful for things like the for tag.
var dd = dojox.dtl;
var ddh = dd.html;
var parent = buffer.getParent();
var contents = this.contents;
var nodelist = new dd.HtmlNodeList();
var cloned = [];
for(var i = 0; i < contents.length; i++){
var clone = contents[i].clone(buffer);
if(clone instanceof dd.ChangeNode || clone instanceof dd.HtmlNode){
var item = this.parents.get(clone.contents);
if(item){
clone.contents = item;
}else if(parent !== clone.contents && clone instanceof dd.HtmlNode){
var node = clone.contents;
clone.contents = clone.contents.cloneNode(false);
cloned.push(node);
this.parents.put(node, clone.contents);
}
}
nodelist.push(clone);
}
 
for(var i = 0, clone; clone = cloned[i]; i++){
this.parents.put(clone);
}
 
return nodelist;
},
toString: function(){ return "dojox.dtl.HtmlNodeList"; }
});
 
dojox.dtl.HtmlVarNode = function(str){
// summary: A node to be processed as a variable
// description:
// Will render an object that supports the render function
// and the getRootNode function
this.contents = new dojox.dtl.Filter(str);
this._lists = {};
}
dojo.extend(dojox.dtl.HtmlVarNode, {
render: function(context, buffer){
this._rendered = true;
var dd = dojox.dtl;
var ddh = dd.html;
var str = this.contents.resolve(context);
if(str && str.render && str.getRootNode){
var root = this._curr = str.getRootNode();
var lists = this._lists;
var list = lists[root];
if(!list){
list = lists[root] = new dd.HtmlNodeList();
list.push(new dd.ChangeNode(buffer.getParent()));
list.push(new dd.HtmlNode(root));
list.push(str);
list.push(new dd.ChangeNode(buffer.getParent(), true));
}
return list.render(context, buffer);
}else{
if(!this._txt) this._txt = document.createTextNode(str);
if(this._txt.data != str) this._txt.data = str;
return buffer.concat(this._txt);
}
return buffer;
},
unrender: function(context, buffer){
if(this._rendered){
this._rendered = false;
if(this._curr){
return this._lists[this._curr].unrender(context, buffer);
}else if(this._txt){
return buffer.remove(this._txt);
}
}
return buffer;
},
clone: function(){
return new dojox.dtl.HtmlVarNode(this.contents.contents);
},
toString: function(){ return "dojox.dtl.HtmlVarNode"; }
});
 
dojox.dtl.ChangeNode = function(node, /*Boolean?*/ up){
// summary: Changes the parent during render/unrender
this.contents = node;
this._up = up;
}
dojo.extend(dojox.dtl.ChangeNode, {
render: function(context, buffer){
return buffer.setParent(this.contents, this._up);
},
unrender: function(context, buffer){
return buffer.setParent(this.contents);
},
clone: function(buffer){
return new dojox.dtl.ChangeNode(this.contents, this._up);
},
toString: function(){ return "dojox.dtl.ChangeNode"; }
});
 
dojox.dtl.AttributeNode = function(key, value){
// summary: Works on attributes
this._key = key;
this._value = value;
this._tpl = new dojox.dtl.Template(value);
this.contents = "";
}
dojo.extend(dojox.dtl.AttributeNode, {
render: function(context, buffer){
var key = this._key;
var value = this._tpl.render(context);
if(this._rendered){
if(value != this.contents){
this.contents = value;
return buffer.setAttribute(key, value);
}
}else{
this._rendered = true;
this.contents = value;
return buffer.setAttribute(key, value);
}
return buffer;
},
unrender: function(context, buffer){
if(this._rendered){
this._rendered = false;
this.contents = "";
return buffer.remove(this.contents);
}
return buffer;
},
clone: function(){
return new dojox.dtl.AttributeNode(this._key, this._value);
},
toString: function(){ return "dojox.dtl.AttributeNode"; }
});
 
dojox.dtl.HtmlTextNode = function(str){
// summary: Adds a straight text node without any processing
this.contents = document.createTextNode(str);
}
dojo.extend(dojox.dtl.HtmlTextNode, {
render: function(context, buffer){
return buffer.concat(this.contents);
},
unrender: function(context, buffer){
return buffer.remove(this.contents);
},
clone: function(){
return new dojox.dtl.HtmlTextNode(this.contents.data);
},
toString: function(){ return "dojox.dtl.HtmlTextNode"; }
});
 
dojox.dtl.HtmlParser = function(tokens){
// summary: Turn a simple array into a set of objects
// description:
// This is also used by all tags to move through
// the list of nodes.
this.contents = tokens;
}
dojo.extend(dojox.dtl.HtmlParser, {
parse: function(/*Array?*/ stop_at){
var dd = dojox.dtl;
var ddh = dd.html;
var types = ddh.types;
var terminators = {};
var tokens = this.contents;
if(!stop_at){
stop_at = [];
}
for(var i = 0; i < stop_at.length; i++){
terminators[stop_at[i]] = true;
}
var nodelist = new dd.HtmlNodeList();
while(tokens.length){
var token = tokens.shift();
var type = token[0];
var value = token[1];
if(type == types.change){
nodelist.push(new dd.ChangeNode(value, token[2]));
}else if(type == types.attr){
var fn = dojox.dtl.text.getTag("attr:" + token[2], true);
if(fn){
nodelist.push(fn(null, token[2] + " " + token[3]));
}else{
nodelist.push(new dd.AttributeNode(token[2], token[3]));
}
}else if(type == types.elem){
var fn = dojox.dtl.text.getTag("node:" + value.tagName.toLowerCase(), true);
if(fn){
// TODO: We need to move this to tokenization so that it's before the
// node and the parser can be passed here instead of null
nodelist.push(fn(null, value, value.tagName.toLowerCase()));
}
nodelist.push(new dd.HtmlNode(value));
}else if(type == types.varr){
nodelist.push(new dd.HtmlVarNode(value));
}else if(type == types.text){
nodelist.push(new dd.HtmlTextNode(value.data || value));
}else if(type == types.tag){
if(terminators[value]){
tokens.unshift(token);
return nodelist;
}
var cmd = value.split(/\s+/g);
if(cmd.length){
cmd = cmd[0];
var fn = dojox.dtl.text.getTag(cmd);
if(typeof fn != "function"){
throw new Error("Function not found for ", cmd);
}
var tpl = fn(this, value);
if(tpl){
nodelist.push(tpl);
}
}
}
}
 
if(stop_at.length){
throw new Error("Could not find closing tag(s): " + stop_at.toString());
}
 
return nodelist;
},
next: function(){
// summary: Used by tags to discover what token was found
var token = this.contents.shift();
return {type: token[0], text: token[1]};
},
skipPast: function(endtag){
return dojox.dtl.Parser.prototype.skipPast.call(this, endtag);
},
getVarNode: function(){
return dojox.dtl.HtmlVarNode;
},
getTextNode: function(){
return dojox.dtl.HtmlTextNode;
},
getTemplate: function(/*String*/ loc){
return new dojox.dtl.HtmlTemplate(dojox.dtl.html.getTemplate(loc));
},
toString: function(){ return "dojox.dtl.HtmlParser"; }
});
 
dojox.dtl.register.tag("dojox.dtl.tag.event", "dojox.dtl.tag.event", [[/(attr:)?on(click|key(up))/i, "on"]]);
dojox.dtl.register.tag("dojox.dtl.tag.html", "dojox.dtl.tag.html", ["html", "attr:attach", "attr:tstyle"]);
 
}
/trunk/api/js/dojo1.0/dojox/dtl/render/html.js
New file
0,0 → 1,70
if(!dojo._hasResource["dojox.dtl.render.html"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.render.html"] = true;
dojo.provide("dojox.dtl.render.html");
 
dojox.dtl.render.html.sensitivity = {
// summary:
// Set conditions under which to buffer changes
// description:
// Necessary if you make a lot of changes to your template.
// What happens is that the entire node, from the attached DOM Node
// down gets swapped with a clone, and until the entire rendering
// is complete, we don't replace the clone again. In this way, renders are
// "batched".
//
// But, if we're only changing a small number of nodes, we might no want to buffer at all.
// The higher numbers mean that even small changes will result in buffering.
// Each higher level includes the lower levels.
NODE: 1, // If a node changes, implement buffering
ATTRIBUTE: 2, // If an attribute or node changes, implement buffering
TEXT: 3 // If any text at all changes, implement buffering
}
dojox.dtl.render.html.Render = function(/*DOMNode?*/ attachPoint, /*dojox.dtl.HtmlTemplate?*/ tpl){
this._tpl = tpl;
this._node = attachPoint;
this._swap = dojo.hitch(this, function(){
// summary: Swaps the node out the first time the DOM is changed
// description: Gets swapped back it at end of render
if(this._node === this._tpl.getRootNode()){
var frag = this._node;
this._node = this._node.cloneNode(true);
frag.parentNode.replaceChild(this._node, frag);
}
});
}
dojo.extend(dojox.dtl.render.html.Render, {
sensitivity: dojox.dtl.render.html.sensitivity,
setAttachPoint: function(/*Node*/ node){
this._node = node;
},
render: function(/*dojox.dtl.HtmlTemplate*/ tpl, /*Object*/ context, /*dojox.dtl.HtmlBuffer?*/ buffer){
if(!this._node){
throw new Error("You cannot use the Render object without specifying where you want to render it");
}
 
buffer = buffer || tpl.getBuffer();
 
if(context.getThis() && context.getThis().buffer == this.sensitivity.NODE){
var onAddNode = dojo.connect(buffer, "onAddNode", this, "_swap");
var onRemoveNode = dojo.connect(buffer, "onRemoveNode", this, "_swap");
}
 
if(this._tpl && this._tpl !== tpl){
this._tpl.unrender(context, buffer);
}
this._tpl = tpl;
 
var frag = tpl.render(context, buffer).getParent();
 
dojo.disconnect(onAddNode);
dojo.disconnect(onRemoveNode);
 
if(this._node !== frag){
this._node.parentNode.replaceChild(frag, this._node);
dojo._destroyElement(this._node);
this._node = frag;
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/dtl/utils/date.js
New file
0,0 → 1,67
if(!dojo._hasResource["dojox.dtl.utils.date"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.utils.date"] = true;
dojo.provide("dojox.dtl.utils.date");
 
dojo.require("dojox.date.php");
 
dojo.mixin(dojox.dtl.utils.date, {
format: function(/*Date*/ date, /*String*/ format){
return dojox.date.php.format(date, format, dojox.dtl.utils.date._overrides);
},
timesince: function(d, now){
// summary:
// Takes two datetime objects and returns the time between then and now
// as a nicely formatted string, e.g "10 minutes"
// description:
// Adapted from http://blog.natbat.co.uk/archive/2003/Jun/14/time_since
if(!(d instanceof Date)){
d = new Date(d.year, d.month, d.day);
}
if(!now){
now = new Date();
}
 
var delta = Math.abs(now.getTime() - d.getTime());
for(var i = 0, chunk; chunk = dojox.dtl.utils.date._chunks[i]; i++){
var count = Math.floor(delta / chunk[0]);
if(count) break;
}
return count + " " + chunk[1](count);
},
_chunks: [
[60 * 60 * 24 * 365 * 1000, function(n){ return (n == 1) ? 'year' : 'years'; }],
[60 * 60 * 24 * 30 * 1000, function(n){ return (n == 1) ? 'month' : 'months'; }],
[60 * 60 * 24 * 7 * 1000, function(n){ return (n == 1) ? 'week' : 'weeks'; }],
[60 * 60 * 24 * 1000, function(n){ return (n == 1) ? 'day' : 'days'; }],
[60 * 60 * 1000, function(n){ return (n == 1) ? 'hour' : 'hours'; }],
[60 * 1000, function(n){ return (n == 1) ? 'minute' : 'minutes'; }]
],
_months_ap: ["Jan.", "Feb.", "March", "April", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."],
_overrides: {
f: function(){
// summary:
// Time, in 12-hour hours and minutes, with minutes left off if they're zero.
// description:
// Examples: '1', '1:30', '2:05', '2'
// Proprietary extension.
if(!this.date.getMinutes()) return this.g();
},
N: function(){
// summary: Month abbreviation in Associated Press style. Proprietary extension.
return dojox.dtl.utils.date._months_ap[this.date.getMonth()];
},
P: function(){
// summary:
// Time, in 12-hour hours, minutes and 'a.m.'/'p.m.', with minutes left off
// if they're zero and the strings 'midnight' and 'noon' if appropriate.
// description:
// Examples: '1 a.m.', '1:30 p.m.', 'midnight', 'noon', '12:30 p.m.'
// Proprietary extension.
if(!this.date.getMinutes() && !this.date.getHours()) return 'midnight';
if(!this.date.getMinutes() && this.date.getHours() == 12) return 'noon';
return self.f() + " " + self.a();
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/dtl/tests/text/templates/pocket.html
New file
0,0 → 1,0
{% block pocket %}Hot{% endblock %} Pocket
/trunk/api/js/dojo1.0/dojox/dtl/tests/text/filter.js
New file
0,0 → 1,717
if(!dojo._hasResource["dojox.dtl.tests.text.filter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.tests.text.filter"] = true;
dojo.provide("dojox.dtl.tests.text.filter");
 
dojo.require("dojox.dtl");
dojo.require("dojox.date.php");
dojo.require("dojox.string.sprintf");
 
doh.register("dojox.dtl.text.filter",
[
function test_filter_add(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ four: 4 });
tpl = new dd.Template('{{ four|add:"6" }}');
t.is("10", tpl.render(context));
context.four = "4";
t.is("10", tpl.render(context));
tpl = new dd.Template('{{ four|add:"six" }}');
t.is("4", tpl.render(context));
tpl = new dd.Template('{{ four|add:"6.6" }}');
t.is("10", tpl.render(context));
},
function test_filter_addslashes(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ unslashed: "Test back slashes \\, double quotes \" and single quotes '" })
var tpl = new dd.Template('{{ unslashed|addslashes }}');
t.is("Test back slashes \\\\, double quotes \\\" and single quotes \\'", tpl.render(context));
},
function test_filter_capfirst(t){
var dd = dojox.dtl;
 
var tpl = new dd.Template('{{ uncapped|capfirst }}');
t.is("Cap", tpl.render(new dd.Context({ uncapped: "cap" })));
},
function test_filter_center(t){
var dd = dojox.dtl;
 
var context = new dd.Context();
var tpl = new dd.Template('{{ narrow|center }}');
context.narrow = "even";
t.is("even", tpl.render(context));
context.narrow = "odd";
t.is("odd", tpl.render(context));
tpl = new dd.Template('{{ narrow|center:"5" }}');
context.narrow = "even";
t.is("even ", tpl.render(context));
context.narrow = "odd";
t.is(" odd ", tpl.render(context));
tpl = new dd.Template('{{ narrow|center:"6" }}');
context.narrow = "even";
t.is(" even ", tpl.render(context));
context.narrow = "odd";
t.is(" odd ", tpl.render(context));
tpl = new dd.Template('{{ narrow|center:"12" }}');
context.narrow = "even";
t.is(" even ", tpl.render(context));
context.narrow = "odd";
t.is(" odd ", tpl.render(context));
},
function test_filter_cut(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ uncut: "Apples and oranges" });
var tpl = new dd.Template('{{ uncut|cut }}');
t.is("Apples and oranges", tpl.render(context));
tpl = new dd.Template('{{ uncut|cut:"A" }}');
t.is("pples and oranges", tpl.render(context));
tpl = new dd.Template('{{ uncut|cut:" " }}');
t.is("Applesandoranges", tpl.render(context));
tpl = new dd.Template('{{ uncut|cut:"e" }}');
t.is("Appls and orangs", tpl.render(context));
},
function test_filter_date(t){
var dd = dojox.dtl;
var context = new dd.Context({ now: new Date(2007, 0, 1), then: new Date(2007, 1, 1) });
 
var tpl = new dd.Template('{{ now|date }}');
t.is(dojox.date.php.format(context.now, "N j, Y", dd.utils.date._overrides), tpl.render(context));
 
context.then = new Date(2007, 0, 1);
tpl = new dd.Template('{{ now|date:"d" }}');
t.is("01", tpl.render(context));
 
tpl = new dd.Template('{{ now|date:"D" }}');
t.is("Mon", tpl.render(context));
 
tpl = new dd.Template('{{ now|date:"j" }}');
t.is("1", tpl.render(context));
 
tpl = new dd.Template('{{ now|date:"l" }}');
t.is("Monday", tpl.render(context));
 
tpl = new dd.Template('{{ now|date:"N" }}');
t.is("Jan.", tpl.render(context));
 
tpl = new dd.Template('{{ now|date:"S" }}');
t.is("st", tpl.render(context));
context.now.setDate(2);
t.is("nd", tpl.render(context));
context.now.setDate(3);
t.is("rd", tpl.render(context));
context.now.setDate(4);
t.is("th", tpl.render(context));
context.now.setDate(5);
t.is("th", tpl.render(context));
context.now.setDate(6);
t.is("th", tpl.render(context));
context.now.setDate(7);
t.is("th", tpl.render(context));
context.now.setDate(8);
t.is("th", tpl.render(context));
context.now.setDate(9);
t.is("th", tpl.render(context));
context.now.setDate(10);
t.is("th", tpl.render(context));
context.now.setDate(11);
t.is("th", tpl.render(context));
context.now.setDate(12);
t.is("th", tpl.render(context));
context.now.setDate(13);
t.is("th", tpl.render(context));
context.now.setDate(14);
t.is("th", tpl.render(context));
context.now.setDate(15);
t.is("th", tpl.render(context));
context.now.setDate(16);
t.is("th", tpl.render(context));
context.now.setDate(17);
t.is("th", tpl.render(context));
context.now.setDate(18);
t.is("th", tpl.render(context));
context.now.setDate(19);
t.is("th", tpl.render(context));
context.now.setDate(20);
t.is("th", tpl.render(context));
context.now.setDate(21);
t.is("st", tpl.render(context));
context.now.setDate(22);
t.is("nd", tpl.render(context));
context.now.setDate(23);
t.is("rd", tpl.render(context));
context.now.setDate(24);
t.is("th", tpl.render(context));
context.now.setDate(25);
t.is("th", tpl.render(context));
context.now.setDate(26);
t.is("th", tpl.render(context));
context.now.setDate(27);
t.is("th", tpl.render(context));
context.now.setDate(28);
t.is("th", tpl.render(context));
context.now.setDate(29);
t.is("th", tpl.render(context));
context.now.setDate(30);
t.is("th", tpl.render(context));
context.now.setDate(31);
t.is("st", tpl.render(context));
context.now.setDate(1);
 
tpl = new dd.Template('{{ now|date:"w" }}');
t.is("1", tpl.render(context));
 
tpl = new dd.Template('{{ now|date:"z" }}');
t.is("0", tpl.render(context));
tpl = new dd.Template('{{ now|date:"W" }}');
t.is("1", tpl.render(context));
},
function test_filter_default(t){
var dd = dojox.dtl;
 
var context = new dd.Context();
tpl = new dd.Template('{{ empty|default }}');
t.is("", tpl.render(context));
tpl = new dd.Template('{{ empty|default:"full" }}');
t.is("full", tpl.render(context));
context.empty = "not empty";
t.is("not empty", tpl.render(context));
},
function test_filter_default_if_none(t){
var dd = dojox.dtl;
 
var context = new dd.Context();
tpl = new dd.Template('{{ empty|default_if_none }}');
t.is("", tpl.render(context));
tpl = new dd.Template('{{ empty|default_if_none:"full" }}');
t.is("", tpl.render(context));
context.empty = null;
t.is("full", tpl.render(context));
context.empty = "not empty";
t.is("not empty", tpl.render(context));
},
function test_filter_dictsort(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
fruit: [
{ name: "lemons", toString: function(){ return this.name; } },
{ name: "apples", toString: function(){ return this.name; } },
{ name: "grapes", toString: function(){ return this.name; } }
]
});
tpl = new dd.Template('{{ fruit|dictsort|join:"|" }}');
t.is("lemons|apples|grapes", tpl.render(context));
tpl = new dd.Template('{{ fruit|dictsort:"name"|join:"|" }}');
t.is("apples|grapes|lemons", tpl.render(context));
},
function test_filter_dictsort_reversed(t){
var dd = dojox.dtl;
 
context = new dd.Context({
fruit: [
{ name: "lemons", toString: function(){ return this.name; } },
{ name: "apples", toString: function(){ return this.name; } },
{ name: "grapes", toString: function(){ return this.name; } }
]
});
tpl = new dd.Template('{{ fruit|dictsortreversed:"name"|join:"|" }}');
t.is("lemons|grapes|apples", tpl.render(context));
},
function test_filter_divisibleby(t){
var dd = dojox.dtl;
 
context = new dd.Context();
tpl = new dd.Template('{{ 4|divisibleby:"2" }}');
t.is("true", tpl.render(context));
context = new dd.Context({ number: 4 });
tpl = new dd.Template('{{ number|divisibleby:3 }}');
t.is("false", tpl.render(context));
},
function test_filter_escape(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ unescaped: "Try & cover <all> the \"major\" 'situations' at once" });
tpl = new dd.Template('{{ unescaped|escape }}');
t.is("Try &amp; cover &lt;all&gt; the &quot;major&quot; &#39;situations&#39; at once", tpl.render(context));
},
function test_filter_filesizeformat(t){
var dd = dojox.dtl;
 
var tpl = new dd.Template('{{ 1|filesizeformat }}');
t.is("1 byte", tpl.render());
tpl = new dd.Template('{{ 512|filesizeformat }}');
t.is("512 bytes", tpl.render());
tpl = new dd.Template('{{ 1024|filesizeformat }}');
t.is("1.0 KB", tpl.render());
tpl = new dd.Template('{{ 2048|filesizeformat }}');
t.is("2.0 KB", tpl.render());
tpl = new dd.Template('{{ 1048576|filesizeformat }}');
t.is("1.0 MB", tpl.render());
tpl = new dd.Template('{{ 1073741824|filesizeformat }}');
t.is("1.0 GB", tpl.render());
},
function test_filter_first(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
fruit: [
{ name: "lemons", toString: function(){ return this.name; } },
{ name: "apples", toString: function(){ return this.name; } },
{ name: "grapes", toString: function(){ return this.name; } }
]
});
tpl = new dd.Template('{{ fruit|first }}');
t.is("lemons", tpl.render(context));
},
function test_filter_fix_ampersands(t){
var dd = dojox.dtl;
 
var tpl = new dd.Template('{{ "One & Two"|fix_ampersands }}');
t.is("One &amp; Two", tpl.render());
},
function test_filter_floatformat(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ num1: 34.23234, num2: 34.00000 });
var tpl = new dd.Template('{{ num1|floatformat }}');
t.is("34.2", tpl.render(context));
tpl = new dd.Template('{{ num2|floatformat }}');
t.is("34", tpl.render(context));
tpl = new dd.Template('{{ num1|floatformat:3 }}');
t.is("34.232", tpl.render(context));
tpl = new dd.Template('{{ num2|floatformat:3 }}');
t.is("34.000", tpl.render(context));
tpl = new dd.Template('{{ num1|floatformat:-3 }}');
t.is("34.2", tpl.render(context));
tpl = new dd.Template('{{ num2|floatformat:-3 }}');
t.is("34", tpl.render(context));
},
function test_filter_get_digit(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ pi: 314159265 });
var tpl = new dd.Template('{{ pi|get_digit:1 }}');
t.is("3", tpl.render(context));
tpl = new dd.Template('{{ pi|get_digit:"2" }}');
t.is("1", tpl.render(context));
tpl = new dd.Template('{{ pi|get_digit:0 }}');
t.is("314159265", tpl.render(context));
tpl = new dd.Template('{{ "nada"|get_digit:1 }}');
t.is("0", tpl.render(context));
},
function test_filter_iriencode(t){
var dd = dojox.dtl;
 
var tpl = new dd.Template('{{ "http://homepage.com/~user"|urlencode|iriencode }}');
t.is("http%3A//homepage.com/%7Euser", tpl.render());
tpl = new dd.Template('{{ "pottedmeat@dojotoolkit.org"|iriencode }}');
t.is("pottedmeat%40dojotoolkit.org", tpl.render());
},
function test_filter_join(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ items: ["foo", "bar", "baz" ]});
var tpl = new dd.Template("{{ items|join }}");
t.is("foo,bar,baz", tpl.render(context));
 
tpl = new dd.Template('{{ items|join:"mustard" }}');
t.is("foomustardbarmustardbaz", tpl.render(context));
},
function test_filter_length(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
fruit: [
{ name: "lemons", toString: function(){ return this.name; } },
{ name: "apples", toString: function(){ return this.name; } },
{ name: "grapes", toString: function(){ return this.name; } }
]
});
tpl = new dd.Template('{{ fruit|length }}');
t.is("3", tpl.render(context));
tpl = new dd.Template('{{ fruit|first|length }}');
t.is("6", tpl.render(context));
},
function test_filter_length_is(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
fruit: [
{ name: "lemons", toString: function(){ return this.name; } },
{ name: "apples", toString: function(){ return this.name; } },
{ name: "grapes", toString: function(){ return this.name; } }
]
});
tpl = new dd.Template('{{ fruit|length_is:"3" }}');
t.is("true", tpl.render(context));
tpl = new dd.Template('{{ fruit|length_is:"4" }}');
t.is("false", tpl.render(context));
},
function test_filter_linebreaks(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ unbroken: "This is just\r\n\n\ra bunch\nof text\n\n\nand such" });
tpl = new dd.Template('{{ unbroken|linebreaks }}');
t.is("<p>This is just</p>\n\n<p>a bunch<br />of text</p>\n\n<p>and such</p>", tpl.render(context));
},
function test_filter_linebreaksbr(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ unbroken: "This is just\r\n\n\ra bunch\nof text\n\n\nand such" });
tpl = new dd.Template('{{ unbroken|linebreaksbr }}');
t.is("This is just<br /><br />a bunch<br />of text<br /><br /><br />and such", tpl.render(context));
},
function test_filter_linenumbers(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ lines: "One\nTwo\nThree\nFour\n" });
var tpl = new dd.Template('{{ lines|linenumbers }}');
t.is("1. One\n2. Two\n3. Three\n4. Four\n5. ", tpl.render(context));
},
function test_filter_ljust(t){
var dd = dojox.dtl;
 
var context = new dd.Context();
var tpl = new dd.Template('{{ narrow|ljust }}');
context.narrow = "even";
t.is("even", tpl.render(context));
context.narrow = "odd";
t.is("odd", tpl.render(context));
tpl = new dd.Template('{{ narrow|ljust:"5" }}');
context.narrow = "even";
t.is("even ", tpl.render(context));
context.narrow = "odd";
t.is("odd ", tpl.render(context));
tpl = new dd.Template('{{ narrow|ljust:"6" }}');
context.narrow = "even";
t.is("even ", tpl.render(context));
context.narrow = "odd";
t.is("odd ", tpl.render(context));
tpl = new dd.Template('{{ narrow|ljust:"12" }}');
context.narrow = "even";
t.is("even ", tpl.render(context));
context.narrow = "odd";
t.is("odd ", tpl.render(context));
},
function test_filter_lower(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ mixed: "MiXeD" });
var tpl = new dd.Template('{{ mixed|lower }}');
t.is("mixed", tpl.render(context));
},
function test_filter_make_list(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ word: "foo", number: 314159265, arr: ["first", "second"], obj: {first: "first", second: "second"} });
var tpl = new dd.Template('{{ word|make_list|join:"|" }} {{ number|make_list|join:"|" }} {{ arr|make_list|join:"|" }} {{ obj|make_list|join:"|" }}');
t.is("f|o|o 3|1|4|1|5|9|2|6|5 first|second first|second", tpl.render(context));
},
function test_filter_phone2numeric(t){
var dd = dojox.dtl;
 
tpl = new dd.Template('{{ "1-800-pottedmeat"|phone2numeric }}');
t.is("1-800-7688336328", tpl.render());
},
function test_filter_pluralize(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ animals: ["bear", "cougar", "aardvark"] });
var tpl = new dd.Template('{{ animals|length }} animal{{ animals|length|pluralize }}');
t.is("3 animals", tpl.render(context));
context.animals = ["bear"];
t.is("1 animal", tpl.render(context));
context = new dd.Context({ fairies: ["tinkerbell", "Andy Dick" ]});
tpl = new dd.Template('{{ fairies|length }} fair{{ fairies|length|pluralize:"y,ies" }}');
t.is("2 fairies", tpl.render(context));
context.fairies.pop();
t.is("1 fairy", tpl.render(context));
},
function test_filter_pprint(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ animals: ["bear", "cougar", "aardvark"] });
tpl = new dd.Template("{{ animals|pprint }}");
t.is('["bear", "cougar", "aardvark"]', tpl.render(context));
},
function test_filter_random(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
fruit: [
{ name: "lemons", toString: function(){ return this.name; } },
{ name: "apples", toString: function(){ return this.name; } },
{ name: "grapes", toString: function(){ return this.name; } }
]
});
tpl = new dd.Template('{{ fruit|random }}');
result = tpl.render(context);
t.t(result == "lemons" || result == "apples" || result == "grapes");
var different = false;
for(var i = 0; i < 10; i++){
// Check to see if it changes
if(result != tpl.render(context) && result == "lemons" || result == "apples" || result == "grapes"){
different = true;
break;
}
}
t.t(different);
},
function test_filter_removetags(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ tagged: "I'm gonna do something <script>evil</script> with the <html>filter" });
tpl = new dd.Template('{{ tagged|removetags:"script <html>" }}');
t.is("I'm gonna do something evil with the filter", tpl.render(context));
},
function test_filter_rjust(t){
var dd = dojox.dtl;
 
var context = new dd.Context();
var tpl = new dd.Template('{{ narrow|rjust }}');
context.narrow = "even";
t.is("even", tpl.render(context));
context.narrow = "odd";
t.is("odd", tpl.render(context));
tpl = new dd.Template('{{ narrow|rjust:"5" }}');
context.narrow = "even";
t.is(" even", tpl.render(context));
context.narrow = "odd";
t.is(" odd", tpl.render(context));
tpl = new dd.Template('{{ narrow|rjust:"6" }}');
context.narrow = "even";
t.is(" even", tpl.render(context));
context.narrow = "odd";
t.is(" odd", tpl.render(context));
tpl = new dd.Template('{{ narrow|rjust:"12" }}');
context.narrow = "even";
t.is(" even", tpl.render(context));
context.narrow = "odd";
t.is(" odd", tpl.render(context));
},
function test_filter_slice(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
fruit: [
{ name: "lemons", toString: function(){ return this.name; } },
{ name: "apples", toString: function(){ return this.name; } },
{ name: "grapes", toString: function(){ return this.name; } }
]
});
tpl = new dd.Template('{{ fruit|slice:":1"|join:"|" }}');
t.is("lemons", tpl.render(context));
tpl = new dd.Template('{{ fruit|slice:"1"|join:"|" }}');
t.is("apples|grapes", tpl.render(context));
tpl = new dd.Template('{{ fruit|slice:"1:3"|join:"|" }}');
t.is("apples|grapes", tpl.render(context));
tpl = new dd.Template('{{ fruit|slice:""|join:"|" }}');
t.is("lemons|apples|grapes", tpl.render(context));
tpl = new dd.Template('{{ fruit|slice:"-1"|join:"|" }}');
t.is("grapes", tpl.render(context));
tpl = new dd.Template('{{ fruit|slice:":-1"|join:"|" }}');
t.is("lemons|apples", tpl.render(context));
tpl = new dd.Template('{{ fruit|slice:"-2:-1"|join:"|" }}');
t.is("apples", tpl.render(context));
},
function test_filter_slugify(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ unslugged: "Apples and oranges()"});
tpl = new dd.Template('{{ unslugged|slugify }}');
t.is("apples-and-oranges", tpl.render(context));
},
function test_filter_stringformat(t){
var dd = dojox.dtl;
 
var tpl = new dd.Template('{{ 42|stringformat:"7.3f" }}');
t.is(" 42.000", tpl.render());
},
function test_filter_striptags(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ tagged: "I'm gonna do something <script>evil</script> with the <html>filter" });
tpl = new dd.Template('{{ tagged|striptags }}');
t.is("I'm gonna do something evil with the filter", tpl.render(context));
},
function test_filter_time(t){
var dd = dojox.dtl;
var context = new dd.Context({ now: new Date(2007, 0, 1) });
 
tpl = new dd.Template('{{ now|time }}');
t.is(dojox.date.php.format(context.now, "P", dd.utils.date._overrides), tpl.render(context));
},
function test_filter_timesince(t){
var dd = dojox.dtl;
var context = new dd.Context({ now: new Date(2007, 0, 1), then: new Date(2007, 1, 1) });
 
tpl = new dd.Template('{{ now|timesince:then }}');
t.is("1 month", tpl.render(context));
context.then = new Date(2007, 0, 5);
t.is("4 days", tpl.render(context));
context.then = new Date(2007, 0, 17);
t.is("2 weeks", tpl.render(context));
context.then = new Date(2008, 1, 1);
t.is("1 year", tpl.render(context));
},
function test_filter_timeuntil(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ now: new Date(2007, 0, 1), then: new Date(2007, 1, 1) });
var tpl = new dd.Template('{{ now|timeuntil:then }}');
t.is("1 month", tpl.render(context));
context.then = new Date(2007, 0, 5);
t.is("4 days", tpl.render(context));
context.then = new Date(2007, 0, 17);
t.is("2 weeks", tpl.render(context));
context.then = new Date(2008, 1, 1);
t.is("1 year", tpl.render(context));
},
function test_filter_title(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ name: "potted meat" });
var tpl = new dd.Template("{{ name|title }}");
t.is("Potted Meat", tpl.render(context));
 
context.name = "What's going on?";
t.is("What's Going On?", tpl.render(context));
 
context.name = "use\nline\nbREAKs\tand tabs";
t.is("Use\nLine\nBreaks\tAnd Tabs", tpl.render(context));
},
function test_filter_truncatewords(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ word: "potted meat writes a lot of tests" });
var tpl = new dd.Template("{{ word|truncatewords }}");
t.is(context.word, tpl.render(context));
 
tpl = new dd.Template('{{ word|truncatewords:"1" }}');
t.is("potted", tpl.render(context));
 
tpl = new dd.Template('{{ word|truncatewords:"2" }}');
t.is("potted meat", tpl.render(context));
 
tpl = new dd.Template('{{ word|truncatewords:20" }}');
t.is(context.word, tpl.render(context));
 
context.word = "potted \nmeat \nwrites a lot of tests";
tpl = new dd.Template('{{ word|truncatewords:"3" }}');
t.is("potted \nmeat \nwrites", tpl.render(context));
},
function test_filter_truncatewords_html(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
body: "Test a string <em>that ends <i>inside a</i> tag</em> with different args",
size: 2
})
var tpl = new dd.Template('{{ body|truncatewords_html:size }}');
t.is("Test a ...", tpl.render(context));
context.size = 4;
t.is("Test a string <em>that ...</em>", tpl.render(context));
context.size = 6;
t.is("Test a string <em>that ends <i>inside ...</i></em>", tpl.render(context));
},
function test_filter_unordered_list(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ states: ["States", [["Kansas", [["Lawrence", []], ["Topeka", []]]], ["Illinois", []]]] });
tpl = new dd.Template('{{ states|unordered_list }}');
t.is("\t<li>States\n\t<ul>\n\t\t<li>Kansas\n\t\t<ul>\n\t\t\t<li>Lawrence</li>\n\t\t\t<li>Topeka</li>\n\t\t</ul>\n\t\t</li>\n\t\t<li>Illinois</li>\n\t</ul>\n\t</li>", tpl.render(context));
},
function test_filter_upper(t){
var dd = dojox.dtl;
 
var context = new dd.Context({ mixed: "MiXeD" });
var tpl = new dd.Template('{{ mixed|upper }}');
t.is("MIXED", tpl.render(context));
},
function test_filter_urlencode(t){
var dd = dojox.dtl;
 
var tpl = new dd.Template('{{ "http://homepage.com/~user"|urlencode }}');
t.is("http%3A//homepage.com/%7Euser", tpl.render());
},
function test_filter_urlize(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
body: "My favorite websites are www.televisionwithoutpity.com, http://daringfireball.net and you can email me at pottedmeat@sitepen.com"
});
var tpl = new dd.Template("{{ body|urlize }}");
t.is('My favorite websites are <a href="http://www.televisionwithoutpity.com" rel="nofollow">www.televisionwithoutpity.com</a> <a href="http://daringfireball.net" rel="nofollow">http://daringfireball.net</a> and you can email me at <a href="mailto:pottedmeat@sitepen.com">pottedmeat@sitepen.com</a>', tpl.render(context));
},
function test_filter_urlizetrunc(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
body: "My favorite websites are www.televisionwithoutpity.com, http://daringfireball.net and you can email me at pottedmeat@sitepen.com"
});
var tpl = new dd.Template("{{ body|urlizetrunc }}");
t.is('My favorite websites are <a href="http://www.televisionwithoutpity.com" rel="nofollow">www.televisionwithoutpity.com</a> <a href="http://daringfireball.net" rel="nofollow">http://daringfireball.net</a> and you can email me at <a href="mailto:pottedmeat@sitepen.com">pottedmeat@sitepen.com</a>', tpl.render(context));
tpl = new dd.Template('{{ body|urlizetrunc:"2" }}');
t.is('My favorite websites are <a href="http://www.televisionwithoutpity.com" rel="nofollow">www.televisionwithoutpity.com</a> <a href="http://daringfireball.net" rel="nofollow">http://daringfireball.net</a> and you can email me at <a href="mailto:pottedmeat@sitepen.com">pottedmeat@sitepen.com</a>', tpl.render(context));
tpl = new dd.Template('{{ body|urlizetrunc:"10" }}');
t.is('My favorite websites are <a href="http://www.televisionwithoutpity.com" rel="nofollow">www.tel...</a> <a href="http://daringfireball.net" rel="nofollow">http://...</a> and you can email me at <a href="mailto:pottedmeat@sitepen.com">pottedmeat@sitepen.com</a>', tpl.render(context));
},
function test_filter_wordcount(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
food: "Hot Pocket"
});
var tpl = new dd.Template("{{ food|wordcount }}");
t.is("2", tpl.render(context));
context.food = "";
t.is("0", tpl.render(context));
context.food = "A nice barbecue, maybe a little grilled veggies, some cole slaw.";
t.is("11", tpl.render(context));
},
function test_filter_wordwrap(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
body: "shrimp gumbo, shrimp pie, shrimp scampi, shrimp stew, fried shrimp, baked shrimp, shrimp o grotten, grilled shrimp, shrimp on a stick, shrimp salad, shrimp pop overs, shrimp cake, shrimp legs, shrimp stuffed eggs, shrimp cre oll, shrimp soup, creamed shrimp on toast, shrimp crapes, shrimply good crescent rolls, shrimp pizza, scalloped shrimp, boiled shrimp, shrimp cocktail"
});
var tpl = new dd.Template("{{ body|wordwrap }}");
t.is(context.body, tpl.render(context));
tpl = new dd.Template("{{ body|wordwrap:width }}");
context.width = 10;
t.is("shrimp\ngumbo,\nshrimp\npie,\nshrimp\nscampi,\nshrimp\nstew,\nfried\nshrimp,\nbaked\nshrimp,\nshrimp o\ngrotten,\ngrilled\nshrimp,\nshrimp on\na stick,\nshrimp\nsalad,\nshrimp pop\novers,\nshrimp\ncake,\nshrimp\nlegs,\nshrimp\nstuffed\neggs,\nshrimp cre\noll,\nshrimp\nsoup,\ncreamed\nshrimp on\ntoast,\nshrimp\ncrapes,\nshrimply\ngood\ncrescent\nrolls,\nshrimp\npizza,\nscalloped\nshrimp,\nboiled\nshrimp,\nshrimp\ncocktail", tpl.render(context));
tpl = new dd.Template('{{ body|wordwrap:"80" }}');
t.is("shrimp gumbo, shrimp pie, shrimp scampi, shrimp stew, fried shrimp, baked\nshrimp, shrimp o grotten, grilled shrimp, shrimp on a stick, shrimp salad,\nshrimp pop overs, shrimp cake, shrimp legs, shrimp stuffed eggs, shrimp cre oll,\nshrimp soup, creamed shrimp on toast, shrimp crapes, shrimply good crescent\nrolls, shrimp pizza, scalloped shrimp, boiled shrimp, shrimp cocktail", tpl.render(context));
},
function test_filter_yesno(t){
var dd = dojox.dtl;
 
var context = new dd.Context();
tpl = new dd.Template('{{ true|yesno }}');
t.is("yes", tpl.render(context));
context = new dd.Context({ test: "value" });
tpl = new dd.Template('{{ test|yesno }}');
t.is("yes", tpl.render(context));
tpl = new dd.Template('{{ false|yesno }}');
t.is("no", tpl.render(context));
tpl = new dd.Template('{{ null|yesno }}');
t.is("maybe", tpl.render(context));
tpl = new dd.Template('{{ true|yesno:"bling,whack,soso" }}');
t.is("bling", tpl.render(context));
context = new dd.Context({ test: "value" });
tpl = new dd.Template('{{ test|yesno:"bling,whack,soso" }}');
t.is("bling", tpl.render(context));
tpl = new dd.Template('{{ false|yesno:"bling,whack,soso" }}');
t.is("whack", tpl.render(context));
tpl = new dd.Template('{{ null|yesno:"bling,whack,soso" }}');
t.is("soso", tpl.render(context));
tpl = new dd.Template('{{ null|yesno:"bling,whack" }}');
t.is("whack", tpl.render(context));
}
]
);
 
}
/trunk/api/js/dojo1.0/dojox/dtl/tests/text/tag.js
New file
0,0 → 1,164
if(!dojo._hasResource["dojox.dtl.tests.text.tag"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.tests.text.tag"] = true;
dojo.provide("dojox.dtl.tests.text.tag");
 
dojo.require("dojox.dtl");
 
doh.register("dojox.dtl.text.tag",
[
function test_tag_block_and_extends(t){
var dd = dojox.dtl;
 
// Simple (messy) string-based extension
var template = new dd.Template('{% extends "../../dojox/dtl/tests/text/templates/pocket.html" %}{% block pocket %}Simple{% endblock %}');
t.is("Simple Pocket", template.render());
 
// Variable replacement
var context = new dd.Context({
parent: "../../dojox/dtl/tests/text/templates/pocket.html"
})
template = new dd.Template('{% extends parent %}{% block pocket %}Variabled{% endblock %}');
t.is("Variabled Pocket", template.render(context));
 
// Nicer dojo.moduleUrl and variable based extension
context.parent = dojo.moduleUrl("dojox.dtl.tests.text.templates", "pocket.html");
template = new dd.Template('{% extends parent %}{% block pocket %}Slightly More Advanced{% endblock %}');
t.is("Slightly More Advanced Pocket", template.render(context));
 
// dojo.moduleUrl with support for more variables.
// This is important for HTML templates where the "shared" flag will be important.
context.parent = {
url: dojo.moduleUrl("dojox.dtl.tests.text.templates", "pocket.html")
}
template = new dd.Template('{% extends parent %}{% block pocket %}Super{% endblock %}');
t.is("Super Pocket", template.render(context));
},
function test_tag_comment(t){
var dd = dojox.dtl;
 
var template = new dd.Template('Hot{% comment %}<strong>Make me disappear</strong>{% endcomment %} Pocket');
t.is("Hot Pocket", template.render());
 
var found = false;
try {
template = new dd.Template('Hot{% comment %}<strong>Make me disappear</strong> Pocket');
}catch(e){
t.is("Unclosed tag found when looking for endcomment", e.message);
found = true;
}
t.t(found);
},
function test_tag_cycle(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
items: ["apple", "banana", "lemon"],
unplugged: "Torrey"
});
var template = new dd.Template("{% for item in items %}{% cycle 'Hot' 'Diarrhea' unplugged 'Extra' %} Pocket. {% endfor %}");
t.is("Hot Pocket. Diarrhea Pocket. Torrey Pocket. ", template.render(context));
// Make sure that it doesn't break on re-render
t.is("Hot Pocket. Diarrhea Pocket. Torrey Pocket. ", template.render(context));
 
// Test repeating the loop
context.items.push("guava", "mango", "pineapple");
t.is("Hot Pocket. Diarrhea Pocket. Torrey Pocket. Extra Pocket. Hot Pocket. Diarrhea Pocket. ", template.render(context));
 
// Repeat the above tests for the old style
// ========================================
context.items = context.items.slice(0, 3);
template = new dd.Template("{% for item in items %}{% cycle Hot,Diarrhea,Torrey,Extra %} Pocket. {% endfor %}");
t.is("Hot Pocket. Diarrhea Pocket. Torrey Pocket. ", template.render(context));
// Make sure that it doesn't break on re-render
t.is("Hot Pocket. Diarrhea Pocket. Torrey Pocket. ", template.render(context));
 
// Test repeating the loop
context.items.push("guava", "mango", "pineapple");
t.is("Hot Pocket. Diarrhea Pocket. Torrey Pocket. Extra Pocket. Hot Pocket. Diarrhea Pocket. ", template.render(context));
 
// Now test outside of the for loop
// ================================
context = new dojox.dtl.Context({ unplugged: "Torrey" });
template = new dd.Template("{% cycle 'Hot' 'Diarrhea' unplugged 'Extra' as steakum %} Pocket. {% cycle steakum %} Pocket. {% cycle steakum %} Pocket.");
t.is("Hot Pocket. Diarrhea Pocket. Torrey Pocket.", template.render(context));
 
template = new dd.Template("{% cycle 'Hot' 'Diarrhea' unplugged 'Extra' as steakum %} Pocket. {% cycle steakum %} Pocket. {% cycle steakum %} Pocket. {% cycle steakum %} Pocket. {% cycle steakum %} Pocket. {% cycle steakum %} Pocket.");
t.is("Hot Pocket. Diarrhea Pocket. Torrey Pocket. Extra Pocket. Hot Pocket. Diarrhea Pocket.", template.render(context));
 
// Test for nested objects
context.items = {
list: ["apple", "banana", "lemon"]
};
template = new dd.Template("{% for item in items.list %}{% cycle 'Hot' 'Diarrhea' unplugged 'Extra' %} Pocket. {% endfor %}");
t.is("Hot Pocket. Diarrhea Pocket. Torrey Pocket. ", template.render(context));
// Make sure that it doesn't break on re-render
t.is("Hot Pocket. Diarrhea Pocket. Torrey Pocket. ", template.render(context));
},
function test_tag_debug(t){
var dd = dojox.dtl;
 
var context = new dd.Context({
items: ["apple", "banana", "lemon"],
unplugged: "Torrey"
});
var template = new dd.Template("{% debug %}");
t.is('items: ["apple", "banana", "lemon"]\n\nunplugged: "Torrey"\n\n', template.render(context));
},
function test_tag_filter(t){
var dd = dojox.dtl;
 
var template = new dd.Template('{% filter lower|center:"15" %}Hot Pocket{% endfilter %}');
t.is(" hot pocket ", template.render());
},
function test_tag_firstof(t){
t.t(false);
},
function test_tag_for(t){
t.t(false);
},
function test_tag_if(t){
t.t(false);
},
function test_tag_ifchanged(t){
t.t(false);
},
function test_tag_ifequal(t){
t.t(false);
},
function test_tag_ifnotequal(t){
t.t(false);
},
function test_tag_include(t){
t.t(false);
},
function test_tag_load(t){
t.t(false);
},
function test_tag_now(t){
t.t(false);
},
function test_tag_regroup(t){
t.t(false);
},
function test_tag_spaceless(t){
t.t(false);
},
function test_tag_ssi(t){
t.t(false);
},
function test_tag_templatetag(t){
t.t(false);
},
function test_tag_url(t){
t.t(false);
},
function test_tag_widthratio(t){
t.t(false);
},
function test_tag_with(t){
t.t(false);
}
]
);
 
}
/trunk/api/js/dojo1.0/dojox/dtl/tests/runTests.html
New file
0,0 → 1,9
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dojox Djanto Template Language D.O.H. Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.dtl.tests.module"></HEAD>
<BODY>
Redirecting to D.O.H runner.
</BODY>
</HTML>
/trunk/api/js/dojo1.0/dojox/dtl/tests/context.js
New file
0,0 → 1,78
if(!dojo._hasResource["dojox.dtl.tests.context"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.tests.context"] = true;
dojo.provide("dojox.dtl.tests.context");
 
dojo.require("dojox.dtl");
 
doh.register("dojox.dtl.context",
[
function test_context_creation(t){
var context = new dojox.dtl.Context({ foo: "foo", bar: "bar" });
t.is("foo", context.foo);
t.is("bar", context.bar);
},
function test_context_push(t){
var context = new dojox.dtl.Context({ foo: "foo", bar: "bar" });
context.push();
for(var key in context._dicts[0]){
t.t(key == "foo" || key == "bar");
}
},
function test_context_pop(t){
var context = new dojox.dtl.Context({ foo: "foo", bar: "bar" });
context.push();
t.is("undefined", typeof context.foo);
t.is("undefined", typeof context.bar);
context.pop();
t.is("foo", context.foo);
t.is("bar", context.bar);
},
function test_context_overpop(t){
var context = new dojox.dtl.Context();
try{
context.pop();
t.t(false);
}catch(e){
t.is("pop() has been called more times than push() on the Context", e.message);
}
},
function test_context_filter(t){
var context = new dojox.dtl.Context({ foo: "one", bar: "two", baz: "three" });
var filtered = context.filter("foo", "bar");
t.is(filtered.foo, "one");
t.is(filtered.bar, "two");
t.f(filtered.baz);
 
filtered = context.filter({ bar: true, baz: true });
t.f(filtered.foo);
t.is(filtered.bar, "two");
t.is(filtered.baz, "three");
 
filtered = context.filter(new dojox.dtl.Context({ foo: true, baz: true }));
t.is(filtered.foo, "one");
t.f(filtered.bar);
t.is(filtered.baz, "three");
},
function test_context_extend(t){
var context = new dojox.dtl.Context({ foo: "one" });
var extended = context.extend({ bar: "two", baz: "three" });
t.is(extended.foo, "one");
t.is(extended.bar, "two");
t.is(extended.baz, "three");
 
extended = context.extend({ barr: "two", bazz: "three" });
t.is(extended.foo, "one");
t.f(extended.bar);
t.f(extended.baz);
t.is(extended.barr, "two");
t.is(extended.bazz, "three");
 
t.f(context.bar)
t.f(context.baz);
t.f(context.barr);
t.f(context.bazz);
}
]
);
 
}
/trunk/api/js/dojo1.0/dojox/dtl/tests/module.js
New file
0,0 → 1,13
if(!dojo._hasResource["dojox.dtl.tests.module"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.tests.module"] = true;
dojo.provide("dojox.dtl.tests.module");
 
try{
dojo.require("dojox.dtl.tests.text.filter");
dojo.require("dojox.dtl.tests.text.tag");
dojo.require("dojox.dtl.tests.context");
}catch(e){
doh.debug(e);
}
 
}
/trunk/api/js/dojo1.0/dojox/dtl/_base.js
New file
0,0 → 1,632
if(!dojo._hasResource["dojox.dtl._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl._base"] = true;
dojo.provide("dojox.dtl._base");
 
dojo.require("dojox.string.Builder");
dojo.require("dojox.string.tokenize");
 
dojox.dtl.Context = function(dict){
dojo.mixin(this, dict || {});
this._dicts = [];
this._this = {};
}
dojo.extend(dojox.dtl.Context, {
_dicts: [],
_this: {},
extend: function(/*dojox.dtl.Context|Object*/ obj){
// summary: Returns a clone of this context object, with the items from the
// passed objecct mixed in.
var context = new dojox.dtl.Context();
var keys = this.getKeys();
for(var i = 0, key; key = keys[i]; i++){
if(typeof obj[key] != "undefined"){
context[key] = obj[key];
}else{
context[key] = this[key];
}
}
 
if(obj instanceof dojox.dtl.Context){
keys = obj.getKeys();
}else if(typeof obj == "object"){
keys = [];
for(var key in obj){
keys.push(key);
}
}
 
for(var i = 0, key; key = keys[i]; i++){
context[key] = obj[key];
}
 
return context;
},
filter: function(/*dojox.dtl.Context|Object|String...*/ filter){
// summary: Returns a clone of this context, only containing the items
// defined in the filter.
var context = new dojox.dtl.Context();
var keys = [];
if(filter instanceof dojox.dtl.Context){
keys = filter.getKeys();
}else if(typeof filter == "object"){
for(var key in filter){
keys.push(key);
}
}else{
for(var i = 0, arg; arg = arguments[i]; i++){
if(typeof arg == "string"){
keys.push(arg);
}
}
}
 
for(var i = 0, key; key = keys[i]; i++){
context[key] = this[key];
}
 
return context;
},
setThis: function(/*Object*/ _this){
this._this = _this;
},
getThis: function(){
return this._this;
},
push: function(){
var dict = {};
var keys = this.getKeys();
for(var i = 0, key; key = keys[i]; i++){
dict[key] = this[key];
delete this[key];
}
this._dicts.unshift(dict);
},
pop: function(){
if(!this._dicts.length){
throw new Error("pop() has been called more times than push() on the Context");
}
var dict = this._dicts.shift();
dojo.mixin(this, dict);
},
hasKey: function(key){
if(typeof this[key] != "undefined"){
return true;
}
 
for(var i = 0, dict; dict = this._dicts[i]; i++){
if(typeof dict[key] != "undefined"){
return true;
}
}
 
return false;
},
getKeys: function(){
var keys = [];
for(var key in this){
if(isNaN(key)){
var found = false;
for(var protoKey in dojox.dtl.Context.prototype){
if(key == protoKey){
found = true;
break;
}
}
if(!found){
keys.push(key);
}
}
}
return keys;
},
get: function(key, otherwise){
if(typeof this[key] != "undefined"){
return this[key];
}
 
for(var i = 0, dict; dict = this._dicts[i]; i++){
if(typeof dict[key] != "undefined"){
return dict[key];
}
}
 
return otherwise;
},
update: function(dict){
this.push();
if(dict){
dojo.mixin(this, dict);
}
},
toString: function(){ return "dojox.dtl.Context"; }
});
 
dojox.dtl.text = {
types: {tag: -1, varr: -2, text: 3},
pySplit: function(str){
// summary: Split a string according to Python's split function
str = str.replace(/^\s+|\s+$/, "");
if(!str.length){
return [];
}
return str.split(/\s+/g);
},
urlquote: function(/*String*/ url, /*String?*/ safe){
if(!safe){
safe = "/";
}
return dojox.string.tokenize(url, /([^\w-_.])/g, function(token){
if(safe.indexOf(token) == -1){
if(token == " "){
return "+";
}else{
return "%" + token.charCodeAt(0).toString(16).toUpperCase();
}
}
return token;
}).join("");
},
_get: function(module, name, errorless){
// summary: Used to find both tags and filters
var params = dojox.dtl.register.get(module, name, errorless);
if(!params) return;
 
var require = params.getRequire();
var obj = params.getObj();
var fn = params.getFn();
 
if(fn.indexOf(":") != -1){
var parts = fn.split(":");
fn = parts.pop();
}
 
dojo.requireIf(true, require);
 
var parent = window;
var parts = obj.split(".");
for(var i = 0, part; part = parts[i]; i++){
if(!parent[part]) return;
parent = parent[part];
}
return parent[fn || name] || parent[name + "_"];
},
getTag: function(name, errorless){
return dojox.dtl.text._get("tag", name, errorless);
},
getFilter: function(name, errorless){
return dojox.dtl.text._get("filter", name, errorless);
},
getTemplate: function(file){
return new dojox.dtl.Template(dojox.dtl.getTemplateString(file));
},
getTemplateString: function(file){
return dojo._getText(file.toString()) || "";
},
_re: /(?:\{\{\s*(.+?)\s*\}\}|\{%\s*(.+?)\s*%\})/g,
tokenize: function(str){
return dojox.string.tokenize(str, dojox.dtl.text._re, dojox.dtl.text._parseDelims);
},
_parseDelims: function(varr, tag){
var types = dojox.dtl.text.types;
if(varr){
return [types.varr, varr];
}else{
return [types.tag, tag];
}
}
}
 
dojox.dtl.Template = function(str){
var st = dojox.dtl;
var tokens = st.text.tokenize(str);
var parser = new st.Parser(tokens);
this.nodelist = parser.parse();
}
dojo.extend(dojox.dtl.Template, {
render: function(context, /*concatenatable?*/ buffer){
context = context || new dojox.dtl.Context({});
if(!buffer){
dojo.require("dojox.string.Builder");
buffer = new dojox.string.Builder();
}
return this.nodelist.render(context, buffer) + "";
},
toString: function(){ return "dojox.dtl.Template"; }
});
 
dojox.dtl.Filter = function(token){
// summary: Uses a string to find (and manipulate) a variable
if(!token) throw new Error("Filter must be called with variable name");
this.contents = token;
var key = null;
var re = this._re;
var matches, filter, arg, fn;
var filters = [];
while(matches = re.exec(token)){
if(key === null){
if(this._exists(matches, 3)){
// variable
key = matches[3];
}else if(this._exists(matches, 1)){
// _("text")
key = '"' + matches[1] + '"';
}else if(this._exists(matches, 2)){
// "text"
key = '"' + matches[2] + '"';
}else if(this._exists(matches, 9)){
// 'text'
key = '"' + matches[9] + '"';
}
}else{
if(this._exists(matches, 7)){
// :variable
arg = [true, matches[7]];
}else if(this._exists(matches, 5)){
// :_("text")
arg = [false, dojox.dtl.replace(matches[5], '\\"', '"')];
}else if(this._exists(matches, 6)){
// :"text"
arg = [false, dojox.dtl.replace(matches[6], '\\"', '"')];
}else if(this._exists(matches, 8)){
// :"text"
arg = [false, dojox.dtl.replace(matches[8], "\\'", "'")];
}
// Get a named filter
fn = dojox.dtl.text.getFilter(matches[4]);
if(typeof fn != "function") throw new Error(matches[4] + " is not registered as a filter");
filters.push([fn, arg]);
}
}
 
this.key = key;
this.filters = filters;
}
dojo.extend(dojox.dtl.Filter, {
_re: /(?:^_\("([^\\"]*(?:\\.[^\\"])*)"\)|^"([^\\"]*(?:\\.[^\\"]*)*)"|^([a-zA-Z0-9_.]+)|\|(\w+)(?::(?:_\("([^\\"]*(?:\\.[^\\"])*)"\)|"([^\\"]*(?:\\.[^\\"]*)*)"|([a-zA-Z0-9_.]+)|'([^\\']*(?:\\.[^\\']*)*)'))?|^'([^\\']*(?:\\.[^\\']*)*)')/g,
_exists: function(arr, index){
if(typeof arr[index] != "undefined" && arr[index] !== ""){
return true;
}
return false;
},
resolve: function(context){
var str = this.resolvePath(this.key, context);
for(var i = 0, filter; filter = this.filters[i]; i++){
// Each filter has the function in [0], a boolean in [1][0] of whether it's a variable or a string
// and [1][1] is either the variable name of the string content.
if(filter[1]){
if(filter[1][0]){
str = filter[0](str, this.resolvePath(filter[1][1], context));
}else{
str = filter[0](str, filter[1][1]);
}
}else{
str = filter[0](str);
}
}
return str;
},
resolvePath: function(path, context){
var current, parts;
var first = path.charAt(0);
var last = path.charAt(path.length - 1);
if(!isNaN(parseInt(first))){
current = (path.indexOf(".") == -1) ? parseInt(path) : parseFloat(path);
}else if(first == '"' && first == last){
current = path.substring(1, path.length - 1);
}else{;
if(path == "true") return true;
if(path == "false") return false;
if(path == "null" || path == "None") return null;
parts = path.split(".");
current = context.get(parts.shift());
while(parts.length){
if(current && typeof current[parts[0]] != "undefined"){
current = current[parts[0]];
if(typeof current == "function"){
if(current.alters_data){
current = "";
}else{
current = current();
}
}
}else{
return "";
}
parts.shift();
}
}
return current;
},
toString: function(){ return "dojox.dtl.Filter"; }
});
 
dojox.dtl.Node = function(/*Object*/ obj){
// summary: Basic catch-all node
this.contents = obj;
}
dojo.extend(dojox.dtl.Node, {
render: function(context, buffer){
// summary: Adds content onto the buffer
return buffer.concat(this.contents);
},
toString: function(){ return "dojox.dtl.Node"; }
});
 
dojox.dtl.NodeList = function(/*Node[]*/ nodes){
// summary: Allows us to render a group of nodes
this.contents = nodes || [];
}
dojo.extend(dojox.dtl.NodeList, {
push: function(node){
// summary: Add a new node to the list
this.contents.push(node);
},
render: function(context, buffer){
// summary: Adds all content onto the buffer
for(var i = 0; i < this.contents.length; i++){
buffer = this.contents[i].render(context, buffer);
if(!buffer) throw new Error("Template node render functions must return their buffer");
}
return buffer;
},
unrender: function(context, buffer){ return buffer; },
clone: function(){ return this; },
toString: function(){ return "dojox.dtl.NodeList"; }
});
 
dojox.dtl.TextNode = dojox.dtl.Node;
 
dojox.dtl.VarNode = function(str){
// summary: A node to be processed as a variable
this.contents = new dojox.dtl.Filter(str);
}
dojo.extend(dojox.dtl.VarNode, {
render: function(context, buffer){
var str = this.contents.resolve(context);
return buffer.concat(str);
},
toString: function(){ return "dojox.dtl.VarNode"; }
});
 
dojox.dtl.Parser = function(tokens){
// summary: Parser used during initialization and for tag groups.
this.contents = tokens;
}
dojo.extend(dojox.dtl.Parser, {
parse: function(/*Array?*/ stop_at){
// summary: Turns tokens into nodes
// description: Steps into tags are they're found. Blocks use the parse object
// to find their closing tag (the stop_at array). stop_at is inclusive, it
// returns the node that matched.
var st = dojox.dtl;
var types = st.text.types;
var terminators = {};
var tokens = this.contents;
stop_at = stop_at || [];
for(var i = 0; i < stop_at.length; i++){
terminators[stop_at[i]] = true;
}
 
var nodelist = new st.NodeList();
while(tokens.length){
token = tokens.shift();
if(typeof token == "string"){
nodelist.push(new st.TextNode(token));
}else{
var type = token[0];
var text = token[1];
if(type == types.varr){
nodelist.push(new st.VarNode(text));
}else if(type == types.tag){
if(terminators[text]){
tokens.unshift(token);
return nodelist;
}
var cmd = text.split(/\s+/g);
if(cmd.length){
cmd = cmd[0];
var fn = dojox.dtl.text.getTag(cmd);
if(fn){
nodelist.push(fn(this, text));
}
}
}
}
}
 
if(stop_at.length){
throw new Error("Could not find closing tag(s): " + stop_at.toString());
}
 
return nodelist;
},
next: function(){
// summary: Returns the next token in the list.
var token = this.contents.shift();
return {type: token[0], text: token[1]};
},
skipPast: function(endtag){
var types = dojox.dtl.text.types;
while(this.contents.length){
var token = this.contents.shift();
if(token[0] == types.tag && token[1] == endtag){
return;
}
}
throw new Error("Unclosed tag found when looking for " + endtag);
},
getVarNode: function(){
return dojox.dtl.VarNode;
},
getTextNode: function(){
return dojox.dtl.TextNode;
},
getTemplate: function(file){
return new dojox.dtl.Template(file);
},
toString: function(){ return "dojox.dtl.Parser"; }
});
 
dojox.dtl.register = function(module, cols, args, /*Function*/ normalize){
// summary: Used to create dojox.dtl.register[module] function, and as a namespace
// expand: Used if the call structure is reformatted for a more compact view.
// Should return an array of normalized arguments.
// description: The function produced will accept a "name"
// as the first parameter and all other parameters will
// be associated with the parameter names listed in cols.
var ddr = dojox.dtl.register;
var registry = ddr._mod[module] = {
params: [],
Getter: function(params){
ddr._params = params || {};
}
};
 
cols.unshift("name");
for(var i = 0, col; col = cols[i]; i++){
registry.Getter.prototype["get" + col.substring(0, 1).toUpperCase() + col.substring(1, col.length)] = ddr._ret(i);
}
 
ddr[module] = function(/*String*/ name, /*mixed...*/ parameters){
if(normalize){
var normalized = normalize(arguments);
}else{
var normalized = [arguments];
}
 
for(var i = 0, args; args = normalized[i]; i++){
var params = [];
for(var j = 0; j < cols.length; j++){
params.push(args[j] || null);
}
if(typeof args[0] == "string"){
// Strings before regexes for speed
registry.params.unshift(params);
}else{
// break
// module RegExp
registry.params.push(params);
}
}
}
 
ddr[module].apply(null, args);
}
dojo.mixin(dojox.dtl.register, {
_mod: {},
_ret: function(i){
// summary: Just lets use i and _params within a closure
return function(){
return dojox.dtl.register._params[i] || "";
}
},
get: function(/*String*/ module, /*String*/ name, /*Boolean*/ errorless){
// summary: Returns a "Getter", based on the registry
// description: The getter functions correspond with the registered cols
// used in dojo.register
var registry = this._mod[module] || {};
if(registry.params){
for(var i = 0, param; param = registry.params[i]; i++){
var search = param[0];
if(typeof search == "string"){
if(search == name){
return new registry.Getter(param);
}
}else if(name.match(search)){
var matches = search.exec(name);
var mixin = [];
dojo.mixin(mixin, param);
mixin[0] = matches[1];
return new registry.Getter(param);
}
}
}
if(!errorless) throw new Error("'" + module + "' of name '" + name + "' does not exist");
},
_normalize: function(args){
// summary:
// Translates to the signature (/*String*/ name, /*String*/ require, /*String*/ obj, /*String*/ fn)
var items = args[2];
var output = [];
for(var i = 0, item; item = items[i]; i++){
if(typeof item == "string"){
output.push([item, args[0], args[1], item]);
}else{
output.push([item[0], args[0], args[1], item[1]]);
}
}
return output;
},
tag: function(/*String*/ require, /*String*/ obj, /*String[]|[RegExp, String][]*/ fns){
// summary:
// Specify the location of a given tag function.
// require:
// The file this function is in
// obj:
// The base object to use for lookups
// fn:
// List of functions within obj to use
// description:
// When we are looking up a tag as specified in a template, we either use a
// string in the fns array, or the RegExp item of the [RegExp, String] pair.
// When that string is found, it requires the file specified in the require
// parameter, uses the base object as a starting point and checks for obj.fn
// or obj.fn_ in case fn is a reserved word.
this("tag", ["require", "obj", "fn"], arguments, this._normalize);
},
filter: function(/*String*/ require, /*String*/ obj, /*String[]|[RegExp, String][]*/ fns){
// summary:
// Specify the location of a given filter function.
// require:
// The file this function is in
// obj:
// The base object to use for lookups
// fn:
// List of functions within obj to use
// description:
// When we are looking up a tag as specified in a template, we either use a
// string in the fns array, or the RegExp item of the [RegExp, String] pair.
// When that string is found, it requires the file specified in the require
// parameter, uses the base object as a starting point and checks for obj.fn
// or obj.fn_ in case fn is a reserved word.
this("filter", ["require", "obj", "fn"], arguments, this._normalize);
}
});
 
(function(){
var register = dojox.dtl.register;
var dtt = "dojox.dtl.tag";
register.tag(dtt + ".logic", dtt + ".logic", ["if", "for"]);
register.tag(dtt + ".loader", dtt + ".loader", ["extends", "block"]);
register.tag(dtt + ".misc", dtt + ".misc", ["comment", "debug", "filter"]);
register.tag(dtt + ".loop", dtt + ".loop", ["cycle"]);
 
var dtf = "dojox.dtl.filter";
register.filter(dtf + ".dates", dtf + ".dates", ["date", "time", "timesince", "timeuntil"]);
register.filter(dtf + ".htmlstrings", dtf + ".htmlstrings", ["escape", "linebreaks", "linebreaksbr", "removetags", "striptags"]);
register.filter(dtf + ".integers", dtf + ".integers", ["add", "get_digit"]);
register.filter(dtf + ".lists", dtf + ".lists", ["dictsort", "dictsortreversed", "first", "join", "length", "length_is", "random", "slice", "unordered_list"]);
register.filter(dtf + ".logic", dtf + ".logic", ["default", "default_if_none", "divisibleby", "yesno"]);
register.filter(dtf + ".misc", dtf + ".misc", ["filesizeformat", "pluralize", "phone2numeric", "pprint"]);
register.filter(dtf + ".strings", dtf + ".strings", ["addslashes", "capfirst", "center", "cut", "fix_ampersands", "floatformat", "iriencode", "linenumbers", "ljust", "lower", "make_list", "rjust", "slugify", "stringformat", "title", "truncatewords", "truncatewords_html", "upper", "urlencode", "urlize", "urlizetrunc", "wordcount", "wordwrap"]);
})();
 
dojox.dtl.replace = function(str, token, repl){
repl = repl || "";
var pos, len = token.length;
while(1){
pos = str.indexOf(token);
if(pos == -1) break;
str = str.substring(0, pos) + repl + str.substring(pos + len);
}
return str;
}
 
dojox.dtl.resolveVariable = function(token, context){
// summary: Quickly resolve a variables
var filter = new dojox.dtl.Filter(token);
return filter.resolve(context);
}
 
}
/trunk/api/js/dojo1.0/dojox/dtl/filter/dates.js
New file
0,0 → 1,36
if(!dojo._hasResource["dojox.dtl.filter.dates"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.filter.dates"] = true;
dojo.provide("dojox.dtl.filter.dates");
 
dojo.require("dojox.dtl.utils.date");
 
dojo.mixin(dojox.dtl.filter.dates, {
date: function(value, arg){
// summary: Formats a date according to the given format
if(!value || !(value instanceof Date)) return "";
arg = arg || "N j, Y";
return dojox.dtl.utils.date.format(value, arg);
},
time: function(value, arg){
// summary: Formats a time according to the given format
if(!value || !(value instanceof Date)) return "";
arg = arg || "P";
return dojox.dtl.utils.date.format(value, arg);
},
timesince: function(value, arg){
// summary: Formats a date as the time since that date (i.e. "4 days, 6 hours")
var timesince = dojox.dtl.utils.date.timesince;
if(!value) return "";
if(arg) return timesince(arg, value);
return timesince(value);
},
timeuntil: function(value, arg){
// summary: Formats a date as the time until that date (i.e. "4 days, 6 hours")
var timesince = dojox.dtl.utils.date.timesince;
if(!value) return "";
if(arg) return timesince(arg, value);
return timesince(new Date(), value);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/dtl/filter/integers.js
New file
0,0 → 1,32
if(!dojo._hasResource["dojox.dtl.filter.integers"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.filter.integers"] = true;
dojo.provide("dojox.dtl.filter.integers");
 
dojo.mixin(dojox.dtl.filter.integers, {
add: function(value, arg){
value = parseInt(value);
arg = parseInt(arg);
return isNaN(arg) ? value : value + arg;
},
get_digit: function(value, arg){
// summary:
// Given a whole number, returns the 1-based requested digit of it
// desciprtion:
// 1 is the right-most digit, 2 is the second-right-most digit, etc. Returns the
// original value for invalid input (if input or argument is not an integer,
// or if argument is less than 1). Otherwise, output is always an integer.
value = parseInt(value);
arg = parseInt(arg) - 1;
if(arg >= 0){
value += "";
if(arg < value.length){
value = parseInt(value.charAt(arg));
}else{
value = 0;
}
}
return (isNaN(value) ? 0 : value);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/dtl/filter/strings.js
New file
0,0 → 1,312
if(!dojo._hasResource["dojox.dtl.filter.strings"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.filter.strings"] = true;
dojo.provide("dojox.dtl.filter.strings");
 
dojo.require("dojox.dtl.filter.htmlstrings");
dojo.require("dojox.string.sprintf");
dojo.require("dojox.string.tokenize");
 
dojo.mixin(dojox.dtl.filter.strings, {
addslashes: function(value){
// summary: Adds slashes - useful for passing strings to JavaScript, for example.
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/'/g, "\\'");
},
capfirst: function(value){
// summary: Capitalizes the first character of the value
value = "" + value;
return value.charAt(0).toUpperCase() + value.substring(1);
},
center: function(value, arg){
// summary: Centers the value in a field of a given width
arg = arg || value.length;
value = value + "";
var diff = arg - value.length;
if(diff % 2){
value = value + " ";
diff -= 1;
}
for(var i = 0; i < diff; i += 2){
value = " " + value + " ";
}
return value;
},
cut: function(value, arg){
// summary: Removes all values of arg from the given string
arg = arg + "" || "";
value = value + "";
return value.replace(new RegExp(arg, "g"), "");
},
_fix_ampersands: /&(?!(\w+|#\d+);)/g,
fix_ampersands: function(value){
// summary: Replaces ampersands with ``&amp;`` entities
return value.replace(dojox.dtl.filter.strings._fix_ampersands, "&amp;");
},
floatformat: function(value, arg){
// summary: Format a number according to arg
// description:
// If called without an argument, displays a floating point
// number as 34.2 -- but only if there's a point to be displayed.
// With a positive numeric argument, it displays that many decimal places
// always.
// With a negative numeric argument, it will display that many decimal
// places -- but only if there's places to be displayed.
arg = parseInt(arg || -1);
value = parseFloat(value);
var m = value - value.toFixed(0);
if(!m && arg < 0){
return value.toFixed();
}
value = value.toFixed(Math.abs(arg));
return (arg < 0) ? parseFloat(value) + "" : value;
},
iriencode: function(value){
return dojox.dtl.text.urlquote(value, "/#%[]=:;$&()+,!");
},
linenumbers: function(value){
// summary: Displays text with line numbers
var df = dojox.dtl.filter;
var lines = value.split("\n");
var output = [];
var width = (lines.length + "").length;
for(var i = 0, line; i < lines.length; i++){
line = lines[i];
output.push(df.strings.ljust(i + 1, width) + ". " + df.htmlstrings.escape(line));
}
return output.join("\n");
},
ljust: function(value, arg){
value = value + "";
arg = parseInt(arg);
while(value.length < arg){
value = value + " ";
}
return value;
},
lower: function(value){
// summary: Converts a string into all lowercase
return (value + "").toLowerCase();
},
make_list: function(value){
// summary:
// Returns the value turned into a list. For an integer, it's a list of
// digits. For a string, it's a list of characters.
var output = [];
if(typeof value == "number"){
value = value + "";
}
if(value.charAt){
for(var i = 0; i < value.length; i++){
output.push(value.charAt(i));
}
return output;
}
if(typeof value == "object"){
for(var key in value){
output.push(value[key]);
}
return output;
}
return [];
},
rjust: function(value, arg){
value = value + "";
arg = parseInt(arg);
while(value.length < arg){
value = " " + value;
}
return value;
},
slugify: function(value){
// summary: Converts to lowercase, removes
// non-alpha chars and converts spaces to hyphens
value = value.replace(/[^\w\s-]/g, "").toLowerCase();
return value.replace(/[\-\s]+/g, "-");
},
_strings: {},
stringformat: function(value, arg){
// summary:
// Formats the variable according to the argument, a string formatting specifier.
// This specifier uses Python string formating syntax, with the exception that
// the leading "%" is dropped.
arg = "" + arg;
var strings = dojox.dtl.filter.strings._strings;
if(!strings[arg]){
strings[arg] = new dojox.string.sprintf.Formatter("%" + arg);
}
return strings[arg].format(value);
},
title: function(value){
// summary: Converts a string into titlecase
var last, title = "";
for(var i = 0, current; i < value.length; i++){
current = value.charAt(i);
if(last == " " || last == "\n" || last == "\t" || !last){
title += current.toUpperCase();
}else{
title += current.toLowerCase();
}
last = current;
}
return title;
},
_truncatewords: /[ \n\r\t]/,
truncatewords: function(value, arg){
// summary: Truncates a string after a certain number of words
// arg: Integer
// Number of words to truncate after
arg = parseInt(arg);
if(!arg){
return value;
}
 
for(var i = 0, j = value.length, count = 0, current, last; i < value.length; i++){
current = value.charAt(i);
if(dojox.dtl.filter.strings._truncatewords.test(last)){
if(!dojox.dtl.filter.strings._truncatewords.test(current)){
++count;
if(count == arg){
return value.substring(0, j + 1);
}
}
}else if(!dojox.dtl.filter.strings._truncatewords.test(current)){
j = i;
}
last = current;
}
return value;
},
_truncate_words: /(&.*?;|<.*?>|(\w[\w-]*))/g,
_truncate_tag: /<(\/)?([^ ]+?)(?: (\/)| .*?)?>/,
_truncate_singlets: { br: true, col: true, link: true, base: true, img: true, param: true, area: true, hr: true, input: true },
truncatewords_html: function(value, arg){
arg = parseInt(arg);
 
if(arg <= 0){
return "";
}
 
var strings = dojox.dtl.filter.strings;
var words = 0;
var open = [];
 
var output = dojox.string.tokenize(value, strings._truncate_words, function(all, word){
if(word){
// It's an actual non-HTML word
++words;
if(words < arg){
return word;
}else if(words == arg){
return word + " ...";
}
}
// Check for tag
var tag = all.match(strings._truncate_tag);
if(!tag || words >= arg){
// Don't worry about non tags or tags after our truncate point
return;
}
var closing = tag[1];
var tagname = tag[2].toLowerCase();
var selfclosing = tag[3];
if(closing || strings._truncate_singlets[tagname]){
}else if(closing){
var i = dojo.indexOf(open, tagname);
if(i != -1){
open = open.slice(i + 1);
}
}else{
open.unshift(tagname);
}
return all;
}).join("");
 
output = output.replace(/\s+$/g, "");
 
for(var i = 0, tag; tag = open[i]; i++){
output += "</" + tag + ">";
}
 
return output;
},
upper: function(value){
return value.toUpperCase();
},
urlencode: function(value){
return dojox.dtl.text.urlquote(value);
},
_urlize: /^((?:[(>]|&lt;)*)(.*?)((?:[.,)>\n]|&gt;)*)$/,
_urlize2: /^\S+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$/,
urlize: function(value){
return dojox.dtl.filter.strings.urlizetrunc(value);
},
urlizetrunc: function(value, arg){
arg = parseInt(arg);
return dojox.string.tokenize(value, /(\S+)/g, function(word){
var matches = dojox.dtl.filter.strings._urlize.exec(word);
if(!matches){
return word;
}
var lead = matches[1];
var middle = matches[2];
var trail = matches[3];
 
var startsWww = middle.indexOf("www.") == 0;
var hasAt = middle.indexOf("@") != -1;
var hasColon = middle.indexOf(":") != -1;
var startsHttp = middle.indexOf("http://") == 0;
var startsHttps = middle.indexOf("https://") == 0;
var firstAlpha = /[a-zA-Z0-9]/.test(middle.charAt(0));
var last4 = middle.substring(middle.length - 4);
 
var trimmed = middle;
if(arg > 3){
trimmed = trimmed.substring(0, arg - 3) + "...";
}
 
if(startsWww || (!hasAt && !startsHttp && middle.length && firstAlpha && (last4 == ".org" || last4 == ".net" || last4 == ".com"))){
return '<a href="http://' + middle + '" rel="nofollow">' + trimmed + '</a>';
}else if(startsHttp || startsHttps){
return '<a href="' + middle + '" rel="nofollow">' + trimmed + '</a>';
}else if(hasAt && !startsWww && !hasColon && dojox.dtl.filter.strings._urlize2.test(middle)){
return '<a href="mailto:' + middle + '">' + middle + '</a>';
}
return word;
}).join("");
},
wordcount: function(value){
return dojox.dtl.text.pySplit(value).length;
},
wordwrap: function(value, arg){
arg = parseInt(arg);
// summary: Wraps words at specified line length
var output = [];
var parts = value.split(/ /g);
if(parts.length){
var word = parts.shift();
output.push(word);
var pos = word.length - word.lastIndexOf("\n") - 1;
for(var i = 0; i < parts.length; i++){
word = parts[i];
if(word.indexOf("\n") != -1){
var lines = word.split(/\n/g);
}else{
var lines = [word];
}
pos += lines[0].length + 1;
if(arg && pos > arg){
output.push("\n");
pos = lines[lines.length - 1].length;
}else{
output.push(" ");
if(lines.length > 1){
pos = lines[lines.length - 1].length;
}
}
output.push(word);
}
}
return output.join("");
}
});
 
}
/trunk/api/js/dojo1.0/dojox/dtl/filter/misc.js
New file
0,0 → 1,59
if(!dojo._hasResource["dojox.dtl.filter.misc"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.filter.misc"] = true;
dojo.provide("dojox.dtl.filter.misc");
 
dojo.mixin(dojox.dtl.filter.misc, {
filesizeformat: function(value){
// summary: Format the value like a 'human-readable' file size (i.e. 13 KB, 4.1 MB, 102bytes, etc).
value = parseFloat(value);
if(value < 1024){
return (value == 1) ? value + " byte" : value + " bytes";
}else if(value < 1024 * 1024){
return (value / 1024).toFixed(1) + " KB";
}else if(value < 1024 * 1024 * 1024){
return (value / 1024 / 1024).toFixed(1) + " MB";
}
return (value / 1024 / 1024 / 1024).toFixed(1) + " GB";
},
pluralize: function(value, arg){
// summary:
// Returns a plural suffix if the value is not 1, for '1 vote' vs. '2 votes'
// description:
// By default, 's' is used as a suffix; if an argument is provided, that string
// is used instead. If the provided argument contains a comma, the text before
// the comma is used for the singular case.
arg = arg || 's';
if(arg.indexOf(",") == -1){
arg = "," + arg;
}
var parts = arg.split(",");
if(parts.length > 2){
return "";
}
var singular = parts[0];
var plural = parts[1];
 
if(parseInt(value) != 1){
return plural;
}
return singular;
},
_phone2numeric: { a: 2, b: 2, c: 2, d: 3, e: 3, f: 3, g: 4, h: 4, i: 4, j: 5, k: 5, l: 5, m: 6, n: 6, o: 6, p: 7, r: 7, s: 7, t: 8, u: 8, v: 8, w: 9, x: 9, y: 9 },
phone2numeric: function(value){
// summary: Takes a phone number and converts it in to its numerical equivalent
var dm = dojox.dtl.filter.misc;
value = value + "";
var output = "";
for(var i = 0; i < value.length; i++){
var chr = value.charAt(i).toLowerCase();
(dm._phone2numeric[chr]) ? output += dm._phone2numeric[chr] : output += value.charAt(i);
}
return output;
},
pprint: function(value){
// summary: A wrapper around toJson unless something better comes along
return dojo.toJson(value);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/dtl/filter/logic.js
New file
0,0 → 1,34
if(!dojo._hasResource["dojox.dtl.filter.logic"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.filter.logic"] = true;
dojo.provide("dojox.dtl.filter.logic");
 
dojo.mixin(dojox.dtl.filter.logic, {
default_: function(value, arg){
// summary: If value is unavailable, use given default
return value || arg || "";
},
default_if_none: function(value, arg){
// summary: If value is null, use given default
return (value === null) ? arg || "" : value || "";
},
divisibleby: function(value, arg){
// summary: Returns true if the value is devisible by the argument"
return (parseInt(value) % parseInt(arg)) == 0;
},
_yesno: /\s*,\s*/g,
yesno: function(value, arg){
// summary:
// arg being a comma-delimited string, value of true/false/none
// chooses the appropriate item from the string
if(!arg) arg = 'yes,no,maybe';
var parts = arg.split(dojox.dtl.filter.logic._yesno);
if(parts.length < 2){
return value;
}
if(value) return parts[0];
if((!value && value !== null) || parts.length < 3) return parts[1];
return parts[2];
}
});
 
}
/trunk/api/js/dojo1.0/dojox/dtl/filter/htmlstrings.js
New file
0,0 → 1,59
if(!dojo._hasResource["dojox.dtl.filter.htmlstrings"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.filter.htmlstrings"] = true;
dojo.provide("dojox.dtl.filter.htmlstrings");
 
dojo.require("dojox.dtl._base");
 
dojo.mixin(dojox.dtl.filter.htmlstrings, {
_escapeamp: /&/g,
_escapelt: /</g,
_escapegt: />/g,
_escapeqt: /'/g,
_escapedblqt: /"/g,
_linebreaksrn: /(\r\n|\n\r)/g,
_linebreaksn: /\n{2,}/g,
_linebreakss: /(^\s+|\s+$)/g,
_linebreaksbr: /\n/g,
_removetagsfind: /[a-z0-9]+/g,
_striptags: /<[^>]*?>/g,
escape: function(value){
// summary: Escapes a string's HTML
var dh = dojox.dtl.filter.htmlstrings;
return value.replace(dh._escapeamp, '&amp;').replace(dh._escapelt, '&lt;').replace(dh._escapegt, '&gt;').replace(dh._escapedblqt, '&quot;').replace(dh._escapeqt, '&#39;');
},
linebreaks: function(value){
// summary: Converts newlines into <p> and <br />s
var output = [];
var dh = dojox.dtl.filter.htmlstrings;
value = value.replace(dh._linebreaksrn, "\n");
var parts = value.split(dh._linebreaksn);
for(var i = 0; i < parts.length; i++){
var part = parts[i].replace(dh._linebreakss, "").replace(dh._linebreaksbr, "<br />")
output.push("<p>" + part + "</p>");
}
 
return output.join("\n\n");
},
linebreaksbr: function(value){
// summary: Converts newlines into <br />s
var dh = dojox.dtl.filter.htmlstrings;
return value.replace(dh._linebreaksrn, "\n").replace(dh._linebreaksbr, "<br />");
},
removetags: function(value, arg){
// summary: Removes a space separated list of [X]HTML tags from the output"
var dh = dojox.dtl.filter.htmlstrings;
var tags = [];
var group;
while(group = dh._removetagsfind.exec(arg)){
tags.push(group[0]);
}
tags = "(" + tags.join("|") + ")";
return value.replace(new RegExp("</?\s*" + tags + "\s*[^>]*>", "gi"), "");
},
striptags: function(value){
// summary: Strips all [X]HTML tags
return value.replace(dojox.dtl.filter.htmlstrings._striptags, "");
}
});
 
}
/trunk/api/js/dojo1.0/dojox/dtl/filter/lists.js
New file
0,0 → 1,131
if(!dojo._hasResource["dojox.dtl.filter.lists"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.filter.lists"] = true;
dojo.provide("dojox.dtl.filter.lists")
 
dojo.require("dojox.dtl._base");
 
dojo.mixin(dojox.dtl.filter.lists, {
_dictsort: function(a, b){
if(a[0] == b[0]) return 0;
return (a[0] < b[0]) ? -1 : 1;
},
dictsort: function(value, arg){
// summary: Takes a list of dicts, returns that list sorted by the property given in the argument.
if(!arg) return value;
 
var items = [];
for(var key in value){
items.push([dojox.dtl.resolveVariable('var.' + arg, new dojox.dtl.Context({ 'var' : value[key]})), value[key]]);
}
items.sort(dojox.dtl.filter.lists._dictsort);
var output = [];
for(var i = 0, item; item = items[i]; i++){
output.push(item[1]);
}
return output;
},
dictsortreversed: function(value, arg){
// summary: Takes a list of dicts, returns that list sorted in reverse order by the property given in the argument.
if(!arg) return value;
 
var dictsort = dojox.dtl.filter.lists.dictsort(value, arg);
return dictsort.reverse();
},
first: function(value){
// summary: Returns the first item in a list
return (value.length) ? value[0] : "";
},
join: function(value, arg){
// summary: Joins a list with a string, like Python's ``str.join(list)``
// description:
// Django throws a compile error, but JS can't do arg checks
// so we're left with run time errors, which aren't wise for something
// as trivial here as an empty arg.
return value.join(arg || ",");
},
length: function(value){
// summary: Returns the length of the value - useful for lists
return (isNaN(value.length)) ? (value + "").length : value.length;
},
length_is: function(value, arg){
// summary: Returns a boolean of whether the value's length is the argument
return value.length == parseInt(arg);
},
random: function(value){
// summary: Returns a random item from the list
return value[Math.floor(Math.random() * value.length)];
},
slice: function(value, arg){
// summary: Returns a slice of the list.
// description:
// Uses the same syntax as Python's list slicing; see
// http://diveintopython.org/native_data_types/lists.html#odbchelper.list.slice
// for an introduction.
// Also uses the optional third value to denote every X item.
arg = arg || "";
var parts = arg.split(":");
var bits = [];
for(var i = 0; i < parts.length; i++){
if(!parts[i].length){
bits.push(null);
}else{
bits.push(parseInt(parts[i]));
}
}
 
if(bits[0] === null){
bits[0] = 0;
}
if(bits[0] < 0){
bits[0] = value.length + bits[0];
}
if(bits.length < 2 || bits[1] === null){
bits[1] = value.length;
}
if(bits[1] < 0){
bits[1] = value.length + bits[1];
}
return value.slice(bits[0], bits[1]);
},
_unordered_list: function(value, tabs){
var ddl = dojox.dtl.filter.lists;
var indent = "";
for(var i = 0; i < tabs; i++){
indent += "\t";
}
if(value[1] && value[1].length){
var recurse = [];
for(var i = 0; i < value[1].length; i++){
recurse.push(ddl._unordered_list(value[1][i], tabs + 1))
}
return indent + "<li>" + value[0] + "\n" + indent + "<ul>\n" + recurse.join("\n") + "\n" + indent + "</ul>\n" + indent + "</li>";
}else{
return indent + "<li>" + value[0] + "</li>";
}
},
unordered_list: function(value){
// summary:
// Recursively takes a self-nested list and returns an HTML unordered list --
// WITHOUT opening and closing <ul> tags.
// description:
// The list is assumed to be in the proper format. For example, if ``var`` contains
// ``['States', [['Kansas', [['Lawrence', []], ['Topeka', []]]], ['Illinois', []]]]``,
// then ``{{ var|unordered_list }}`` would return::
//
// <li>States
// <ul>
// <li>Kansas
// <ul>
// <li>Lawrence</li>
// <li>Topeka</li>
// </ul>
// </li>
// <li>Illinois</li>
// </ul>
// </li>
return dojox.dtl.filter.lists._unordered_list(value, 1);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/dtl/demos/demo_Animation.html
New file
0,0 → 1,47
<html>
<head>
<title>Testing dojox.dtl using animation to change attributes</title>
<script src="../../../dojo/dojo.js" djConfig="parseOnLoad: true, usePlainJson: true"></script>
<script>
dojo.require("dojox.dtl.widget");
 
dojo.provide("demo");
 
dojo.declare("demo.Animation", dojox.dtl._Widget,
{
buffer: 0, // Note: Sensitivity is 0 by default, but this is to emphasize we're not doing any buffering
constructor: function(props, node){
this.context = new dojox.dtl.Context({ x: 0, y: 0 });
this.template = new dojox.dtl.HtmlTemplate(dojo.moduleUrl("dojox.dtl.demos.templates", "animation.html"));
},
postCreate: function(){
this.render(this.template, this.context);
var anim = new dojo._Animation({
curve: [0, 300],
rate: 10,
duration: 5000,
easing: dojo._defaultEasing
});
dojo.connect(anim, "onAnimate", this, "_reDraw");
anim.play();
},
_reDraw: function(obj){
this.context.x = obj;
this.context.y = Math.sqrt(obj) * 10;
 
dojo.style(this.blue, "left", this.context.x);
dojo.style(this.blue, "top", this.context.y + 10);
 
this.render(this.template, this.context);
}
});
 
dojo.require("dojo.parser");
</script>
</head>
<body>
<div dojoType="dojox.dtl.AttachPoint">
<div dojoType="demo.Animation" />
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/dtl/demos/json/blog/get_blog_list.json
New file
0,0 → 1,0
{"blog_list":{"3":{"title":"My Trip to the Beach"},"1":{"title":"If I Were a Robot"}}}
/trunk/api/js/dojo1.0/dojox/dtl/demos/json/blog/get_blog_1.json
New file
0,0 → 1,0
{"teaser":"I'd be able to write a lot faster.","body":"I think I wouldn't be able to think.","date":1189125242601,"author":"jim"}
/trunk/api/js/dojo1.0/dojox/dtl/demos/json/blog/get_blog_3.json
New file
0,0 → 1,0
{"teaser":"There was SO much sand","body":"I tried to walk so fast that I wouldn't leave foot prints.","date":1190245842601,"author":"jim"}
/trunk/api/js/dojo1.0/dojox/dtl/demos/json/blog/get_page_about.json
New file
0,0 → 1,0
{"title":"About Jim","body":"<p>Jim is an avid golfer, enjoys long walks on the beach, and eating hot pockets</p><p>When he's not scalding his mouth, you'll find him throwing rocks at pigeons.</p>"}
/trunk/api/js/dojo1.0/dojox/dtl/demos/demo_Blog.html
New file
0,0 → 1,114
<html>
<head>
<title>Testing dojox.dtl using a blog example</title>
<script src="../../../dojo/dojo.js" djConfig="parseOnLoad: true, usePlainJson: true"></script>
<script>
dojo.require("dojox.dtl.widget");
 
dojo.provide("demo");
 
dojo.declare("demo.Blog", dojox.dtl._Widget,
{
buffer: dojox.dtl.render.html.sensitivity.NODE,
constructor: function(props, node){
this.contexts = {
list: false,
blogs: {},
pages: {}
}
this.templates = {
list: new dojox.dtl.HtmlTemplate(dojo.moduleUrl("dojox.dtl.demos.templates", "blog_list.html")),
detail: new dojox.dtl.HtmlTemplate(dojo.moduleUrl("dojox.dtl.demos.templates", "blog_detail.html")),
page: new dojox.dtl.HtmlTemplate(dojo.moduleUrl("dojox.dtl.demos.templates", "blog_page.html"))
}
},
postCreate: function(){
if(this.contexts.list){
this.render(this.templates.list, this.contexts.list);
}else{
dojo.xhrGet({
url: dojo.moduleUrl("dojox.dtl.demos.json.blog", "get_blog_list.json"),
handleAs: "json"
}).addCallback(this, "_loadList");
}
},
_showList: function(obj){
this.render(this.templates.list, this.contexts.list);
},
_showDetail: function(obj){
var key = obj.target.className.substring(5);
 
if(this.contexts.blogs[key]){
this.render(this.templates.detail, this.contexts.blogs[key]);
}else{
dojo.xhrGet({
url: dojo.moduleUrl("dojox.dtl.demos.json.blog", "get_blog_" + key + ".json"),
handleAs: "json",
load: function(data){
data.key = key;
return data;
}
}).addCallback(this, "_loadDetail");
}
},
_showPage: function(obj){
var key = obj.target.className.substring(5);
 
if(this.contexts.pages[key]){
this.render(this.templates.page, this.contexts.pages[key]);
}else{
dojo.xhrGet({
url: dojo.moduleUrl("dojox.dtl.demos.json.blog", "get_page_" + key + ".json"),
handleAs: "json",
load: function(data){
data.key = key;
return data;
}
}).addCallback(this, "_loadPage");
}
},
_loadList: function(data){
this.contexts.list = new dojox.dtl.Context(data).extend({
title: "Blog Posts",
base: {
url: dojo.moduleUrl("dojox.dtl.demos.templates", "blog_base.html"),
shared: true
}
});
this.render(this.templates.list, this.contexts.list);
},
_loadDetail: function(data){
var context = {
title: "Blog Post",
blog: data
}
context.blog.date = new Date(context.blog.date);
context.blog.title = this.contexts.list.get("blog_list", {})[data.key].title;
this.contexts.blogs[data.key] = new dojox.dtl.Context(context).extend({
base: {
url: dojo.moduleUrl("dojox.dtl.demos.templates", "blog_base.html"),
shared: true
}
});
this.render(this.templates.detail, this.contexts.blogs[data.key]);
},
_loadPage: function(data){
this.contexts.pages[data.key] = new dojox.dtl.Context(data).extend({
base: {
url: dojo.moduleUrl("dojox.dtl.demos.templates", "blog_base.html"),
shared: true
}
});
this.render(this.templates.page, this.contexts.pages[data.key]);
}
});
 
dojo.require("dojo.parser");
</script>
</head>
<body>
<div dojoType="dojox.dtl.AttachPoint">
<div dojoType="demo.Blog" />
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/dtl/demos/templates/blog_detail.html
New file
0,0 → 1,10
<!--{% extends base %}-->
 
<!--{% block body %}-->
<div>
<h3><!--{{ blog.title }}--></h3>
<div><small>posted on <!--{{ blog.date|date }}--> by <!--{{ blog.author }}--></small></div>
<p><!--{{ blog.teaser }}--></p>
<p><!--{{ blog.body }}--></p>
</div>
<!--{% endblock %}-->
/trunk/api/js/dojo1.0/dojox/dtl/demos/templates/blog_base.html
New file
0,0 → 1,8
<div>
<h1><!--{{ title }}--></h1>
<ul style="float: left; width: 100px; height: 300px; margin-right: 20px; border: 1px solid #666;">
<li><a onclick="_showList" style="cursor: pointer;">Home</a></li>
<li><a onclick="_showPage" style="cursor: pointer;" class="page-about">About Jim</a></li>
</ul>
<!--{% block body %}--><!--{% endblock %}-->
</div>
/trunk/api/js/dojo1.0/dojox/dtl/demos/templates/blog_list.html
New file
0,0 → 1,8
<!--{% extends base %}-->
<!--{% block body %}-->
<ul>
<!--{% for blog in blog_list %}-->
<li onclick="_showDetail" class="blog-{{ forloop.key }}" style="cursor: pointer;">{{ blog.title }}</li>
<!--{% endfor %}-->
</ul>
<!--{% endblock %}-->
/trunk/api/js/dojo1.0/dojox/dtl/demos/templates/animation.html
New file
0,0 → 1,4
<div>
<div tstyle="top: {{ y }}px; left: {{ x }}px;" style="width: 10px; height: 10px; background: red; position: absolute;">&nbsp;</div>
<div attach="blue" style="top: 10px; left: 0; width: 10px; height: 10px; background: blue; position: absolute;">&nbsp;</div>
</div>
/trunk/api/js/dojo1.0/dojox/dtl/demos/templates/blog_page.html
New file
0,0 → 1,7
<!--{% extends "shared:templates/blog_base.html" %}-->
 
<!--{% block body %}-->
<div>
<!--{% html body %}-->
</div>
<!--{% endblock %}-->
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_group.html
New file
0,0 → 1,73
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Dojo Unified 2D Graphics</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<!--<script type="text/javascript" src="../matrix.js"></script>-->
<!--<script type="text/javascript" src="../util.js"></script>-->
<!--<script type="text/javascript" src="../shape.js"></script>-->
<!--<script type="text/javascript" src="../path.js"></script>-->
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
var surface = null;
var g1 = null;
var g2 = null;
var r1 = null;
 
makeShapes = function(){
surface = dojox.gfx.createSurface(document.getElementById("test"), 500, 500);
// make a checkerboard
for(var i = 0; i < 500; i += 100){
for(var j = 0; j < 500; j += 100){
if(i % 200 == j % 200) {
surface.createRect({ x: i, y: j }).setFill([255, 0, 0, 0.1]);
}
}
}
// create groups and shapes
g1 = surface.createGroup();
g2 = surface.createGroup();
r1 = surface.createRect({x: 200, y: 200}).setFill("green").setStroke({});
g1.setTransform({dy: -100});
//g2.setTransform(dojox.gfx.matrix.rotateAt(-45, 250, 250));
g2.setTransform({dx: 100, dy: -100});
};
 
switchRect = function(){
var radio = document.getElementsByName("switch");
if(radio[0].checked){
surface.add(r1);
}else if(radio[1].checked){
g1.add(r1);
}else if(radio[2].checked){
g2.add(r1);
}
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>dojox.gfx Group tests</h1>
<p>
<input type="radio" name="switch" id="r1_s" checked="checked" onclick="switchRect()" /><label for="r1_s">Rectangle belongs to the surface</label><br />
<input type="radio" name="switch" id="r1_g1" onclick="switchRect()" /><label for="r1_g1">Rectangle belongs to the group #1</label><br />
<input type="radio" name="switch" id="r1_g2" onclick="switchRect()" /><label for="r1_g2">Rectangle belongs to the group #2</label>
</p>
<div id="test"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_gradient.html
New file
0,0 → 1,70
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Dojo Unified 2D Graphics</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
dojo.require("dojo.colors"); // pull in CSS3 color names
 
makeShapes = function(){
var SIDE = 10;
var fillObj = {
colors: [
{ offset: 0, color: [255, 255, 0, 0] },
{ offset: 0.5, color: "orange" },
{ offset: 1, color: [255, 255, 0, 0] }
]
};
var surface = dojox.gfx.createSurface(dojo.byId("grad"), 300, 300);
// create a background
for(var i = 0; i < 300; i += SIDE){
for(var j = 0; j < 300; j += SIDE){
surface.
createRect({x: j, y: i, width: 10, height: 10}).
setFill((Math.floor(i / SIDE) + Math.floor(j / SIDE)) % 2 ? "lightgrey" : "white");
}
}
// create a rect
surface.createRect({
width: 300,
height: 100
}).setFill(dojo.mixin({
type: "linear",
x1: 0, y1: 0,
x2: 300, y2: 0
}, fillObj));
// create a circle
surface.createEllipse({
cx: 150,
cy: 200,
rx: 100,
ry: 100
}).setFill(dojo.mixin({
type: "radial",
cx: 150,
cy: 200
}, fillObj));
};
dojo.addOnLoad(makeShapes);
</script>
<style type="text/css">
#grad { width: 300px; height: 300px; }
</style>
</head>
<body>
<h1>dojox.gfx Alpha gradient test</h1>
<div id="grad"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/module.js
New file
0,0 → 1,13
if(!dojo._hasResource["dojox.gfx.tests.module"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.tests.module"] = true;
dojo.provide("dojox.gfx.tests.module");
 
try{
dojo.require("dojox.gfx.tests.matrix");
dojo.require("dojox.gfx.tests.decompose");
}catch(e){
doh.debug(e);
}
 
 
}
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_textpath.html
New file
0,0 → 1,76
<html>
<head>
<title>Testing textpath</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<!--
<script type="text/javascript" src="../common.js"></script>
<script type="text/javascript" src="../shape.js"></script>
<script type="text/javascript" src="../path.js"></script>
-->
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
var CPD = 30;
 
var surface = null;
 
var makeText = function(surface, text, font, fill, stroke){
var t = surface.createText(text);
if(font) t.setFont(font);
if(fill) t.setFill(fill);
if(stroke) t.setStroke(stroke);
placeAnchor(surface, text.x, text.y);
return t;
};
 
makeShapes = function(){
surface = dojox.gfx.createSurface("test", 500, 500);
var p = surface.createPath({})
.setStroke("green")
.moveTo(0, 100)
.setAbsoluteMode(false)
.curveTo(CPD, 0, 100 - CPD, 300, 100, 300)
.curveTo(CPD, 0, 100 - CPD, -300, 100, -300)
.curveTo(CPD, 0, 100 - CPD, 300, 100, 300)
.curveTo(CPD, 0, 100 - CPD, -300, 100, -300)
.curveTo(CPD, 0, 100 - CPD, 300, 100, 300)
;
console.debug(p);
var t = surface.createTextPath({
text: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent erat. " +
"In malesuada ultricies velit. Vestibulum tempor odio vitae diam. " +
"Morbi arcu lectus, laoreet eget, nonummy at, elementum a, quam."
, align: "middle"
//, rotated: true
})
//.setShape(p.shape)
.moveTo(0, 100)
.setAbsoluteMode(false)
.curveTo(CPD, 0, 100 - CPD, 300, 100, 300)
.curveTo(CPD, 0, 100 - CPD, -300, 100, -300)
.curveTo(CPD, 0, 100 - CPD, 300, 100, 300)
.curveTo(CPD, 0, 100 - CPD, -300, 100, -300)
.curveTo(CPD, 0, 100 - CPD, 300, 100, 300)
.setFont({family: "times", size: "12pt"})
.setFill("blue")
;
console.debug(t);
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>dojox.gfx Text on a Path test</h1>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_resize.html
New file
0,0 → 1,61
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Testing surface resizing</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../_base.js"></script>
<script type="text/javascript" src="../shape.js"></script>
<script type="text/javascript" src="../path.js"></script>
<script type="text/javascript" src="../arc.js"></script>
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../canvas.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
var surface;
 
makeShapes = function(){
surface = dojox.gfx.createSurface("test", 500, 500);
surface.createRect({width: 300, height: 300}).setFill([255, 0, 0, 0.3]).setStroke("red");
surface.createRect({x: 200, y: 200, width: 300, height: 300}).setFill([0, 0, 255, 0.3]).setStroke("green");
};
 
getDim = function(){
var t = surface.getDimensions();
alert("dimensions: " + t.width + " by " + t.height);
};
 
make500x500 = function(){ surface.setDimensions(500, 500); };
make400x400 = function(){ surface.setDimensions(400, 400); };
make300x300 = function(){ surface.setDimensions(300, 300); };
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>Testing surface resizing</h1>
<!--<p><button onclick="makeShapes();">Go</button></p>-->
<p>
<button onclick="getDim();">getDimensions</button>
&nbsp;
<button onclick="make300x300();">Make 300x300</button>
&nbsp;
<button onclick="make400x400();">Make 400x400</button>
&nbsp;
<button onclick="make500x500();">Make 500x500</button>
</p>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_image1.html
New file
0,0 → 1,74
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Testing image</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
var image = null;
var grid_size = 500;
var grid_step = 50;
 
makeShapes = function(){
var surface = dojox.gfx.createSurface("test", 800, 600);
for(var i = 0; i <= grid_size; i += grid_step){
surface.createLine({x1: 0, x2: grid_size, y1: i, y2: i}).setStroke("black");
surface.createLine({y1: 0, y2: grid_size, x1: i, x2: i}).setStroke("black");
}
image = surface.createImage({width: 157, height: 53, src: "http://archive.dojotoolkit.org/nightly/checkout/util/resources/dojotoolkit.org/mini-dtk/images/logo.png"});
//dojo.connect(image.getEventSource(), "onclick", function(){ alert("You didn't expect a download, did you?"); });
image.connect("onclick", function(){ alert("You didn't expect a download, did you?"); });
};
 
transformImage = function(){
var radio = document.getElementsByName("switch");
if(radio[0].checked){
image.setTransform({});
}else if(radio[1].checked){
image.setTransform(dojox.gfx.matrix.translate(100,100));
}else if(radio[2].checked){
image.setTransform([dojox.gfx.matrix.translate(100,0), dojox.gfx.matrix.rotateg(45)]);
}else if(radio[3].checked){
image.setTransform([dojox.gfx.matrix.translate(70,90), dojox.gfx.matrix.scale({x:1.5, y:0.5})]);
}else if(radio[4].checked){
image.setTransform([dojox.gfx.matrix.rotateg(15), dojox.gfx.matrix.skewXg(-30)]);
}
var cb = document.getElementById("r2");
if(cb.checked && !image.getShape().x){
image.setShape({x: 100, y: 50});
}else if(!cb.checked && image.getShape().x){
image.setShape({x: 0, y: 0});
}
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>dojox.gfx Image tests</h1>
<p>Note: Silverlight doesn't allow downloading images when run from a file system. This demo should be run from a server.</p>
<p>
<input type="radio" name="switch" id="r1_reset" checked onclick="transformImage()" /><label for="r1_reset">Reset Image</label><br />
<input type="radio" name="switch" id="r1_move" onclick="transformImage()" /><label for="r1_move">Move Image</label><br />
<input type="radio" name="switch" id="r1_rotate" onclick="transformImage()" /><label for="r1_rotate">Rotate Image</label><br />
<input type="radio" name="switch" id="r1_scale" onclick="transformImage()" /><label for="r1_scale">Scale Image</label><br />
<input type="radio" name="switch" id="r1_skew" onclick="transformImage()" /><label for="r1_skew">Skew Image</label><br />
</p>
<p><input type="checkbox" id="r2" onclick="transformImage()" /><label for="r2">Offset image by (100, 50)</label></p>
<div id="test"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_image2.html
New file
0,0 → 1,50
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Testing image</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
var grid_size = 500, grid_step = 50;
var main = null, g = null, image = null, rect = null;
 
makeShapes = function(){
var s = dojox.gfx.createSurface("test", 800, 600);
for(var i = 0; i <= grid_size; i += grid_step){
s.createLine({x1: 0, x2: grid_size, y1: i, y2: i}).setStroke("black");
s.createLine({y1: 0, y2: grid_size, x1: i, x2: i}).setStroke("black");
}
 
main = s.createGroup();
//rect = main.createRect({x: 0, y: 0, width: 100, height: 100}).setStroke("black").setFill(new dojo.Color([255, 0, 255, 0.5]));
image = main.createImage({width: 157, height: 53, src: "http://archive.dojotoolkit.org/nightly/checkout/util/resources/dojotoolkit.org/mini-dtk/images/logo.png"});
// comment out the next string to see the problem
rect = main.createRect({x: 0, y: 0, width: 100, height: 100}).setStroke("black").setFill(new dojo.Color([255, 0, 255, 0.5]));
//g = main.createGroup();
//g.createRect({x: 0, y: 0, width: 100, height: 100}).setStroke("black").setFill(new dojo.Color([255, 255, 0, 0.5]));
};
 
trans = function(){
var x = 1;
main.setTransform([dojox.gfx.matrix.rotategAt(45, 200, 200), {dx: 200, dy: 200}]);
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<p>Testing image:<br /><button onclick="trans();">Trans</button></p>
<p>Note: Silverlight doesn't allow downloading images when run from a file system. This demo should be run from a server.</p>
<div id="test"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_arc.html
New file
0,0 → 1,71
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Testing arc</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../_base.js"></script>
<script type="text/javascript" src="../shape.js"></script>
<script type="text/javascript" src="../path.js"></script>
<script type="text/javascript" src="../arc.js"></script>
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../canvas.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
makeShapes = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
var m = dojox.gfx.matrix;
var g1 = surface.createGroup();
var g2 = g1.createGroup();
 
var rx = 100, ry = 60, xRotg = -30;
var startPoint = m.multiplyPoint(m.rotateg(xRotg), {x: -rx, y: 0 });
var endPoint = m.multiplyPoint(m.rotateg(xRotg), {x: 0, y: -ry});
var re1 = g1.createPath()
.moveTo(startPoint)
.arcTo(rx, ry, xRotg, true, false, endPoint)
.setStroke({color: "red", width: 3})
;
var ge1 = g1.createPath()
.moveTo(re1.getLastPosition())
.arcTo(rx, ry, xRotg, false, false, startPoint)
.setStroke({color: "black"})
;
var re2 = g2.createPath()
.moveTo(startPoint)
.arcTo(rx, ry, xRotg, false, true, endPoint)
.setStroke({color: "green", width: 3})
;
var ge2 = g2.createPath()
.moveTo(re2.getLastPosition())
.arcTo(rx, ry, xRotg, true, true, startPoint)
.setStroke({color: "black"})
;
g1.setTransform({dx: 200, dy: 200});
g2.setTransform({dx: 10, dy: 10});
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>Testing arc</h1>
<!--<p><button onclick="makeShapes();">Go</button></p>-->
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_setPath.html
New file
0,0 → 1,76
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Testing setPath and curves</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<!--<script type="text/javascript" src="../path.js"></script>-->
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
makeShapes = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
// relative path with cubic beziers
surface
.createPath("m100 100 100 0 0 100c0 50-50 50-100 0s-50-100 0-100z")
.setStroke({color: "blue"})
.setFill("#ddd")
.setTransform({dx: -50, dy: -50})
;
// absolute path with cubic bezier
surface
.createPath("M100 100 200 100 200 200C200 250 150 250 100 200S50 100 100 100z")
.setStroke({color: "blue"})
.setFill("#ddd")
.setTransform({dx: 100, dy: -50})
;
// relative path with horizontal and vertical lines, and cubic beziers
surface
.createPath("m100 100h100v100c0 50-50 50-100 0s-50-100 0-100z")
.setStroke({color: "blue"})
.setFill("#ddd")
.setTransform({dx: 250, dy: -50})
;
// relative path with quadratic beziers
surface
.createPath("m100 100 100 0 0 100q0 50-75-25t-25-75z")
.setStroke({color: "blue"})
.setFill("#ddd")
.setTransform({dx: -50, dy: 150})
;
// absolute path with quadratic bezier
surface
.createPath("M100 100 200 100 200 200Q200 250 125 175T100 100z")
.setStroke({color: "blue"})
.setFill("#ddd")
.setTransform({dx: 100, dy: 150})
;
// relative path with horizontal and vertical lines, and quadratic beziers
surface
.createPath("m100 100h100v100q0 50-75-25t-25-75z")
.setStroke({color: "blue"})
.setFill("#ddd")
.setTransform({dx: 250, dy: 150})
;
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>dojox.gfx setPath and curve test</h1>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_linestyle.html
New file
0,0 → 1,45
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Dojo Unified 2D Graphics</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<!--<script type="text/javascript" src="../_base.js"></script>-->
<!--<script type="text/javascript" src="../shape.js"></script>-->
<!--<script type="text/javascript" src="../path.js"></script>-->
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
makeShapes = function(){
var surface = dojox.gfx.createSurface(document.getElementById("test"), 500, 500);
var styles = ["none", "Solid", "ShortDash", "ShortDot", "ShortDashDot", "ShortDashDotDot",
"Dot", "Dash", "LongDash", "DashDot", "LongDashDot", "LongDashDotDot"];
var font = "normal normal normal 10pt Arial"; // CSS font style
var y_offset = dojox.gfx.normalizedLength("4pt");
for(var i = 0; i < styles.length; ++i){
var y = 20 + i * 20;
surface.createText({x: 140, y: y + y_offset, text: styles[i], align: "end"}).setFont(font).setFill("black");
surface.createLine({x1: 150, y1: y, x2: 490, y2: y}).setStroke({style: styles[i], width: 3, cap: "round"});
}
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>dojox.gfx: Line style test</h1>
<div id="test"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_transform.html
New file
0,0 → 1,98
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Dojo Unified 2D Graphics</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
makeShapes = function(){
var surface = dojox.gfx.createSurface(document.getElementById("test"), 500, 500);
var g1 = surface.createGroup();
// make a checkerboard
for(var i = 0; i < 500; i += 100){
for(var j = 0; j < 500; j += 100){
if(i % 200 == j % 200) {
surface.createRect({x: i, y: j}).setFill([255, 0, 0, 0.1]);
}
}
}
var r1 = g1.createShape({type: "rect", x: 200, y: 200})
.setFill("green")
.setStroke({})
//.setTransform(dojox.gfx.matrix.rotategAt(-45, 250, 250))
;
var r2 = surface.createShape({type: "rect"}).setStroke({})
.setFill({type: "linear", to: {x: 50, y: 100},
colors: [{offset: 0, color: "green"}, {offset: 0.5, color: "red"}, {offset: 1, color: "blue"}] })
.setTransform({dx: 100, dy: 100})
;
var r3 = surface.createRect().setStroke({})
.setFill({ type: "linear" })
//.setTransform(dojox.gfx.matrix.rotategAt(-45, 250, 250))
;
var r4 = g1.createShape({type: "rect"})
.setFill("blue")
//.setStroke({})
//.setTransform(dojox.gfx.matrix.rotategAt(-45, 350, 250))
.setTransform([dojox.gfx.matrix.rotategAt(-30, 350, 250), { dx: 300, dy: 200 }])
;
var p1 = g1.createShape({type: "path"})
.setStroke({})
.moveTo(300, 100)
.lineTo(400, 200)
.lineTo(400, 300)
.lineTo(300, 400)
.curveTo(400, 300, 400, 200, 300, 100)
//.setTransform(dojox.gfx.matrix.rotategAt(-45, 250, 250))
.setTransform({})
;
var p2 = g1.createShape(p1.getShape())
.setStroke({color: "red", width: 2})
//.moveTo( 300, 100 )
//.lineTo( 400, 200 )
//.lineTo( 400, 300 )
//.lineTo( 300, 400 )
//.curveTo( 400, 300, 400, 200, 300, 100 )
//.setTransform(dojox.gfx.matrix.rotategAt(180, 250, 250))
.setTransform({dx: 100})
;
var p3 = g1.createShape({type: "path"})
.setStroke({color: "blue", width: 2})
.moveTo(300, 100)
.setAbsoluteMode(false)
.lineTo ( 100, 100)
.lineTo ( 0, 100)
.lineTo (-100, 100)
.curveTo( 100, -100, 100, -200, 0, -300)
//.setTransform(dojox.gfx.matrix.rotategAt(135, 250, 250))
.setTransform(dojox.gfx.matrix.rotategAt(180, 250, 250))
;
//g1.setTransform({dx: 100});
g1.moveToFront();
g1.setTransform(dojox.gfx.matrix.rotategAt(-15, 250, 250));
//g1.setTransform([dojox.gfx.matrix.rotategAt(-45, 250, 250), dojox.gfx.matrix.scaleAt(0.5, 250, 250)]);
//g1.setTransform([dojox.gfx.matrix.scaleAt(2, 1, 250, 250), dojox.gfx.matrix.rotategAt(-45, 250, 250)]);
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>dojox.gfx Transform test</h1>
<div id="test"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_pattern.html
New file
0,0 → 1,44
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Testing pattern</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<!--<script type="text/javascript" src="../matrix.js"></script>-->
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<!--<script type="text/javascript" src="../canvas.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
makeShapes = function(){
var pattern = {
type: "pattern",
x: 0, y: 0, width: 333, height: 80,
src: "http://dojotoolkit.org/files/downloadButton.gif"
};
var ellipse = {cx: 400, cy: 200, rx: 350, ry: 150};
var surface = dojox.gfx.createSurface("test", 800, 600);
surface.createEllipse(ellipse)
.setStroke({color: "blue", width: 1 })
.setFill(pattern);
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>dojox.gfx Pattern test</h1>
<div id="test"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/matrix.js
New file
0,0 → 1,228
if(!dojo._hasResource["dojox.gfx.tests.matrix"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.tests.matrix"] = true;
dojo.provide("dojox.gfx.tests.matrix");
dojo.require("dojox.gfx.matrix");
 
(function(){
var m = dojox.gfx.matrix;
var eq = function(t, a, b){ t.t(2 * Math.abs(a - b) / ((a < 1 && b < 1) ? 1 : a + b) < 1e-6); };
tests.register("dojox.gfx.tests.matrix", [
function IdentityTest(t){
var a = new m.Matrix2D();
eq(t, a.xx, 1);
eq(t, a.yy, 1);
eq(t, a.xy, 0);
eq(t, a.yx, 0);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
},
function Rot30gTest(t){
var a = m.rotateg(30);
eq(t, a.xx, a.yy);
eq(t, a.xy, -a.yx);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
eq(t, a.yx, 0.5);
t.t(a.xy < 0);
t.t(a.yx > 0);
},
function Rot45gTest(t){
var a = m.rotateg(45);
eq(t, a.xx, a.yy);
eq(t, a.xy, -a.yx);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
eq(t, a.xx, a.yx);
eq(t, a.yy, -a.xy);
},
function Rot90gTest(t){
var a = m.rotateg(90);
eq(t, a.xx, a.yy);
eq(t, a.xy, -a.yx);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
eq(t, a.xx, 0);
eq(t, a.yx, 1);
},
function CombineIdentitiesTest(t){
var a = m.normalize([new m.Matrix2D(), new m.Matrix2D(), new m.Matrix2D()]);
eq(t, a.xx, 1);
eq(t, a.yy, 1);
eq(t, a.xy, 0);
eq(t, a.yx, 0);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
},
function CombineExclusiveTest(t){
var a = m.normalize([m.rotateg(30), m.rotateg(-30)]);
eq(t, a.xx, 1);
eq(t, a.yy, 1);
eq(t, a.xy, 0);
eq(t, a.yx, 0);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
},
function CombineInvertedTest(t){
var a = m.normalize([m.rotateg(30), m.invert(m.rotateg(30))]);
eq(t, a.xx, 1);
eq(t, a.yy, 1);
eq(t, a.xy, 0);
eq(t, a.yx, 0);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
},
function Rot90gAtTest(t){
var a = m.rotategAt(90, 10, 10);
eq(t, a.xx, a.yy);
eq(t, a.xy, -a.yx);
eq(t, a.dx, 20);
eq(t, a.dy, 0);
eq(t, a.xx, 0);
eq(t, a.yx, 1);
},
function MultPointTest1(t){
var b = m.multiplyPoint(m.rotategAt(90, 10, 10), 10, 10);
eq(t, b.x, 10);
eq(t, b.y, 10);
},
function MultPointTest2(t){
var b = m.multiplyPoint(m.rotategAt(90, 10, 10), {x: 10, y: 5});
eq(t, b.x, 15);
eq(t, b.y, 10);
},
function MultPointTest3(t){
var b = m.multiplyPoint(m.rotategAt(90, 10, 10), 10, 15);
eq(t, b.x, 5);
eq(t, b.y, 10);
},
function ScaleTest1(t){
var a = m.normalize([m.scale(2, 1), m.invert(m.rotateg(45))]);
eq(t, a.xx, 2 * a.yy);
eq(t, a.xy, -2 * a.yx);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
eq(t, a.xx, a.xy);
eq(t, a.yy, -a.yx);
},
function ScaleTest2(t){
var a = m.normalize([m.scale(1, 2), m.invert(m.rotateg(45))]);
eq(t, 2 * a.xx, a.yy);
eq(t, 2 * a.xy, -a.yx);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
eq(t, a.xx, a.xy);
eq(t, a.yy, -a.yx);
},
function ScaleTest3(t){
var a = m.normalize([m.rotateg(45), m.scale(2, 1)]);
eq(t, a.xx, 2 * a.yy);
eq(t, a.yx, -2 * a.xy);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
eq(t, a.xx, a.yx);
eq(t, a.yy, -a.xy);
},
function ScaleTest4(t){
var a = m.normalize([m.rotateg(45), m.scale(1, 2)]);
eq(t, 2 * a.xx, a.yy);
eq(t, 2 * a.yx, -a.xy);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
eq(t, a.xx, a.yx);
eq(t, a.yy, -a.xy);
},
function ScaleTest5(t){
var a = m.normalize([m.rotategAt(45, 100, 100), m.scale(2)]);
eq(t, a.xx, a.yy);
eq(t, a.xy, -a.yx);
eq(t, a.xx, a.yx);
eq(t, a.yy, -a.xy);
eq(t, a.dx, 100);
t.t(a.dy < 0);
var b = m.normalize([m.scale(2), m.rotategAt(45, 100, 100)]);
eq(t, b.xx, b.yy);
eq(t, b.xy, -b.yx);
eq(t, b.xx, b.yx);
eq(t, b.yy, -b.xy);
eq(t, b.dx, 200);
t.t(b.dy < 0);
eq(t, a.xx, b.xx);
eq(t, a.xy, b.xy);
eq(t, a.yx, b.yx);
eq(t, a.yy, b.yy);
eq(t, 2 * a.dx, b.dx);
eq(t, 2 * a.dy, b.dy);
var c = m.normalize([m.rotateg(45), m.scale(2)]);
eq(t, c.xx, c.yy);
eq(t, c.xy, -c.yx);
eq(t, c.xx, c.yx);
eq(t, c.yy, -c.xy);
eq(t, c.dx, 0);
eq(t, c.dy, 0);
var d = m.normalize([m.scale(2), m.rotateg(45)]);
eq(t, d.xx, d.yy);
eq(t, d.xy, -d.yx);
eq(t, d.xx, d.yx);
eq(t, d.yy, -d.xy);
eq(t, d.dx, 0);
eq(t, d.dy, 0);
eq(t, a.xx, c.xx);
eq(t, a.xy, c.xy);
eq(t, a.yx, c.yx);
eq(t, a.yy, c.yy);
eq(t, a.xx, d.xx);
eq(t, a.xy, d.xy);
eq(t, a.yx, d.yx);
eq(t, a.yy, d.yy);
},
function ScaleTest6(t){
var a = m.normalize(6);
eq(t, a.xx, 6);
eq(t, a.yy, 6);
eq(t, a.xy, 0);
eq(t, a.yx, 0);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
},
function ScaleTest7(t){
var a = m.normalize([2, m.scale(2, 1)]);
eq(t, a.xx, 4);
eq(t, a.yy, 2);
eq(t, a.xy, 0);
eq(t, a.yx, 0);
eq(t, a.dx, 0);
eq(t, a.dy, 0);
},
function TranslateTest(t){
var a = m.normalize({dx: 100, dy: 200});
eq(t, a.xx, 1);
eq(t, a.yy, 1);
eq(t, a.xy, 0);
eq(t, a.yx, 0);
eq(t, a.dx, 100);
eq(t, a.dy, 200);
},
function ReflectTest1(t){
var b = m.multiplyPoint(m.reflect(1, 1), 1, 0);
eq(t, b.x, 0);
eq(t, b.y, 1);
},
function ReflectTest2(t){
var b = m.multiplyPoint(m.reflect(1, 1), 0, 1);
eq(t, b.x, 1);
eq(t, b.y, 0);
},
function ProjectTest1(t){
var b = m.multiplyPoint(m.project(1, 1), 1, 0);
eq(t, b.x, 0.5);
eq(t, b.y, 0.5);
},
function ProjectTest2(t){
var b = m.multiplyPoint(m.project(1, 1), 0, 1);
eq(t, b.x, 0.5);
eq(t, b.y, 0.5);
}
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_decompose.html
New file
0,0 → 1,54
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Testing decompose</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../matrix.js"></script>
<script type="text/javascript" src="../decompose.js"></script>
<script type="text/javascript">
dojo.require("dojox.gfx.decompose");
 
var m = dojox.gfx.matrix;
 
var eq = function(a, b){
return Math.abs((a - b) / (a + b)) < 1e-6;
};
 
var calc = function(){
var matrix1 = eval("(m.normalize([" + dojo.byId("input").value + "]))");
dojo.byId("matrix1").value = dojo.toJson(matrix1, true);
var result = dojox.gfx.decompose(matrix1);
dojo.byId("result").innerHTML = "Result: " + dojo.toJson(result);
var matrix2 = m.normalize([
m.translate(result.dx, result.dy),
m.rotate(result.angle2),
m.scale(result.sx, result.sy),
m.rotate(result.angle1)
]);
dojo.byId("matrix2").value = dojo.toJson(matrix2, true);
};
 
</script>
</head>
<body>
<h1>Testing decompose</h1>
<p>
<span style="font-size: 8pt;">Example: m.rotategAt(30, 100, 100), m.scaleAt(2, 3, 5, 5), m.rotate(45)</span><br />
<input id="input" type="text" size="50" maxlength="200" /><button onclick="calc();">Calc</button>
</p>
<p id="result">Result:</p>
<p>
<span style="font-size: 8pt;">Original matrix</span><br />
<textarea id="matrix1" cols="50" rows="8" readonly="readonly"></textarea>
</p>
<p>
<span style="font-size: 8pt;">Decomposed matrix</span><br />
<textarea id="matrix2" cols="50" rows="8" readonly="readonly"></textarea>
</p>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_tbbox.html
New file
0,0 → 1,117
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Dojo Unified 2D Graphics</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../_base.js"></script>
<script type="text/javascript" src="../shape.js"></script>
<script type="text/javascript" src="../path.js"></script>
<script type="text/javascript" src="../arc.js"></script>
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../canvas.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
makeShapes = function(){
var surface = dojox.gfx.createSurface(document.getElementById("test"), 500, 500);
var g1 = surface.createGroup();
// make a checkerboard
for(var i = 0; i < 500; i += 100){
for(var j = 0; j < 500; j += 100){
if(i % 200 == j % 200) {
surface.createRect({ x: i, y: j }).setFill([255, 0, 0, 0.1]);
}
}
}
var r1 = g1.createRect({ x: 200, y: 200 })
.setFill("green")
.setStroke({})
//.setTransform(dojox.gfx.matrix.rotategAt(45, 250, 250))
;
var r2 = surface.createRect().setStroke({})
.setFill({ type: "linear", to: { x: 50, y: 100 },
colors: [{ offset: 0, color: "green" }, { offset: 0.5, color: "red" }, { offset: 1, color: "blue" }] })
.setTransform({dx: 100, dy: 100})
;
var r3 = surface.createRect().setStroke({})
.setFill({ type: "linear" })
//.setTransform(dojox.gfx.matrix.rotategAt(-45, 250, 250))
;
var r4 = g1.createRect({})
.setFill("blue")
//.setStroke({})
//.setTransform(dojox.gfx.matrix.rotategAt(-45, 350, 250))
.setTransform([dojox.gfx.matrix.rotategAt(-30, 350, 250), { dx: 300, dy: 200 }])
;
var p1 = g1.createPath()
.setStroke({})
.moveTo( 300, 100 )
.lineTo( 400, 200 )
.lineTo( 400, 300 )
.lineTo( 300, 400 )
.curveTo( 400, 300, 400, 200, 300, 100 )
//.setTransform(dojox.gfx.matrix.rotategAt(-45, 250, 250))
.setTransform({})
;
var p2 = g1.createPath(p1.getShape())
.setStroke({ color: "red", width: 2 })
//.moveTo( 300, 100 )
//.lineTo( 400, 200 )
//.lineTo( 400, 300 )
//.lineTo( 300, 400 )
//.curveTo( 400, 300, 400, 200, 300, 100 )
//.setTransform(dojox.gfx.matrix.rotategAt(180, 250, 250))
.setTransform({ dx: 100 })
;
var p3 = g1.createPath()
.setStroke({ color: "blue", width: 2 })
.moveTo( 300, 100 )
.setAbsoluteMode(false)
.lineTo ( 100, 100 )
.lineTo ( 0, 100 )
.lineTo ( -100, 100 )
.curveTo( 100, -100, 100, -200, 0, -300 )
//.setTransform(dojox.gfx.matrix.rotategAt(135, 250, 250))
.setTransform(dojox.gfx.matrix.rotategAt(180, 250, 250))
;
//g1.setTransform({ dx: 100 });
g1.moveToFront();
g1.setTransform(dojox.gfx.matrix.rotategAt(-15, 250, 250));
//g1.setTransform([dojox.gfx.matrix.rotategAt(-45, 250, 250), dojox.gfx.matrix.scaleAt(0.5, 250, 250)]);
//g1.setTransform([dojox.gfx.matrix.scaleAt(2, 1, 250, 250), dojox.gfx.matrix.rotategAt(-45, 250, 250)]);
var a = p1.getTransformedBoundingBox();
a.push(a[0]);
surface.createPolyline(a).setStroke("green");
a = p2.getTransformedBoundingBox();
a.push(a[0]);
surface.createPolyline(a).setStroke("green");
a = p3.getTransformedBoundingBox();
a.push(a[0]);
surface.createPolyline(a).setStroke("green");
};
 
dojo.addOnLoad(makeShapes);
 
</script>
<!--
<style>
v:group { text-align: left; }
</style>
-->
</head>
<body>
<h1>dojox.gfx Transformation test</h1>
<div id="test"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_bezier.html
New file
0,0 → 1,85
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Approximation of an arc with bezier</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../_base.js"></script>
<script type="text/javascript" src="../shape.js"></script>
<script type="text/javascript" src="../path.js"></script>
<script type="text/javascript" src="../arc.js"></script>
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../canvas.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
makeShapes = function(){
var surface = dojox.gfx.createSurface("test", 500, 300);
var g = surface.createGroup();
// create a reference ellipse
var rx = 200;
var ry = 100;
var startAngle = -30;
var arcAngle = -90;
var axisAngle = -30;
var e = g.createEllipse({rx: rx, ry: ry}).setStroke({});
// calculate a bezier
var alpha = dojox.gfx.matrix._degToRad(arcAngle) / 2; // half of our angle
var cosa = Math.cos(alpha);
var sina = Math.sin(alpha);
// start point
var p1 = {x: cosa, y: sina};
// 1st control point
var p2 = {x: cosa + (4 / 3) * (1 - cosa), y: sina - (4 / 3) * cosa * (1 - cosa) / sina};
// 2nd control point (symmetric to the 1st one)
var p3 = {x: p2.x, y: -p2.y};
// end point (symmetric to the start point)
var p4 = {x: p1.x, y: -p1.y};
// rotate and scale poins as appropriate
var s = dojox.gfx.matrix.normalize([dojox.gfx.matrix.scale(e.shape.rx, e.shape.ry), dojox.gfx.matrix.rotateg(startAngle + arcAngle / 2)]);
p1 = dojox.gfx.matrix.multiplyPoint(s, p1);
p2 = dojox.gfx.matrix.multiplyPoint(s, p2);
p3 = dojox.gfx.matrix.multiplyPoint(s, p3);
p4 = dojox.gfx.matrix.multiplyPoint(s, p4);
// draw control trapezoid
var t = g.createPath().setStroke({color: "blue"});
t.moveTo(p1.x, p1.y);
t.lineTo(p2.x, p2.y);
t.lineTo(p3.x, p3.y);
t.lineTo(p4.x, p4.y);
t.lineTo(p1.x, p1.y);
t.moveTo((p1.x + p4.x) / 2, (p1.y + p4.y) / 2);
t.lineTo((p2.x + p3.x) / 2, (p2.y + p3.y) / 2);
t.moveTo((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
t.lineTo((p3.x + p4.x) / 2, (p3.y + p4.y) / 2);
// draw a bezier
var b = g.createPath().setStroke({color: "red"});
b.moveTo(p1.x, p1.y);
b.curveTo(p2.x, p2.y, p3.x, p3.y, p4.x, p4.y);
// move everything in a middle
g.setTransform([dojox.gfx.matrix.translate(250, 150), dojox.gfx.matrix.rotateg(axisAngle)]);
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>Approximation of an arc with bezier</h1>
<!--<p><button onclick="makeShapes();">Make</button></p>-->
<div id="test" style="width: 500px; height: 300px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_poly.html
New file
0,0 → 1,53
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Testing polyline and line transforms</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../_base.js"></script>
<script type="text/javascript" src="../shape.js"></script>
<script type="text/javascript" src="../path.js"></script>
<script type="text/javascript" src="../arc.js"></script>
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../canvas.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
makeShapes = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
var line = surface.createLine({x1: 250, y1: 50, x2: 250, y2: 250})
.setStroke({color: "blue"})
;
var poly = surface.createPolyline([{x: 250, y: 250}, {x: 300, y: 300}, {x: 250, y: 350}, {x: 200, y: 300}, {x: 250, y: 250}])
.setStroke({color: "blue"})
;
var rotate = dojox.gfx.matrix.rotategAt(5, 250, 250);
//var rotate = dojox.gfx.matrix.rotategAt(0.4, 250, 250);
window.setInterval(function() {
line.applyTransform(rotate);
poly.applyTransform(rotate);
},
100
);
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>dojox.gfx Polyline test</h1>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_text.html
New file
0,0 → 1,88
<html>
<head>
<title>Testing text</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<!--
<script type="text/javascript" src="../common.js"></script>
<script type="text/javascript" src="../shape.js"></script>
-->
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
var ROTATION = 30;
 
var surface = null, t1, t2, t3, t4, t5;
 
var placeAnchor = function(surface, x, y){
surface.createLine({x1: x - 2, y1: y, x2: x + 2, y2: y}).setStroke("blue");
surface.createLine({x1: x, y1: y - 2, x2: x, y2: y + 2}).setStroke("blue");
};
 
var makeText = function(surface, text, font, fill, stroke){
var t = surface.createText(text);
if(font) t.setFont(font);
if(fill) t.setFill(fill);
if(stroke) t.setStroke(stroke);
placeAnchor(surface, text.x, text.y);
return t;
};
 
makeShapes = function(){
surface = dojox.gfx.createSurface("test", 500, 500);
var m = dojox.gfx.matrix;
surface.createLine({x1: 250, y1: 0, x2: 250, y2: 500}).setStroke("green");
t1 = makeText(surface, {x: 250, y: 50, text: "Start", align: "start"},
{family: "Times", size: "36pt", weight: "bold"}, "black", "red")
.setTransform(m.rotategAt(ROTATION, 250, 50))
;
t2 = makeText(surface, {x: 250, y: 100, text: "Middle", align: "middle"},
{family: "Symbol", size: "24pt"}, "red", "black")
.setTransform(m.rotategAt(ROTATION, 250, 100))
;
t3 = makeText(surface, {x: 250, y: 150, text: "End", align: "end"},
{family: "Helvetica", style: "italic", size: "18pt", rotated: true}, "#FF8000")
.setTransform(m.rotategAt(ROTATION, 250, 150))
;
t4 = makeText(surface, {x: 250, y: 200, text: "Define Shuffle Tiff", align: "middle", kerning: true},
{family: "serif", size: "36pt"}, "black")
.setTransform(m.rotategAt(0, 250, 200))
;
t5 = makeText(surface, {x: 250, y: 250, text: "Define Shuffle Tiff", align: "middle", kerning: false},
{family: "serif", size: "36pt"}, "black")
.setTransform(m.rotategAt(0, 250, 250))
;
};
 
getSizes = function(){
var t = [];
dojo.forEach(["t1", "t2", "t3", "t4", "t5"], function(name){
var node = eval("(" + name + ")");
t.push(node.getShape().text + " = " + node.getTextWidth());
});
dojo.byId("sizes").innerHTML = t.join("<br/>");
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>dojox.gfx Text test</h1>
<div id="test" style="width: 500px; height: 500px;"></div>
<div><button onclick="surface.clear();">Clear</button>&nbsp;<button onclick="getSizes();">Get sizes</button></div>
<p id="sizes">&nbsp;</p>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_gfx.html
New file
0,0 → 1,489
<html>
<head>
<title>Dojo Unified 2D Graphics</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, gfxRenderer: 'svg,silverlight,vml'"></script>
<!--<script type="text/javascript" src="../_base.js"></script>-->
<!--<script type="text/javascript" src="../path.js"></script>-->
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
 
dojo.require("dojox.gfx");
 
var gTestContainer = null;
var gTests = {};
 
function isEqual(foo, bar, prefix)
{
var flag = true;
if( foo != bar ) {
console.debug(prefix+":"+foo + "!=" + bar + " try dig into it" );
if( foo instanceof Array ) {
for( var i = 0; i< foo.length; i++ ) {
flag = isEqual(foo[i], bar[i], prefix+"["+i+"]") && flag;
}
flag = false;
} else {
for(var x in foo) {
if(bar[x] != undefined ) {
flag = isEqual(foo[x], bar[x], prefix+"."+x) && flag;
} else {
console.debug(prefix+":"+ x + " is undefined in bar" );
flag = false;
}
}
}
}
return flag;
}
 
 
function getTestSurface(testName, testDescription, width, height)
{
width = width ? width : 300;
height = height ? height : 300;
 
// Create a DOM node for the surface
var testRow = document.createElement('tr');
var testCell = document.createElement('td');
var testHolder = document.createElement('div');
testHolder.id = testName + '_holder';
testHolder.style.width = width;
testHolder.style.height = height;
 
testCell.appendChild(testHolder);
testRow.appendChild(testCell);
gTestContainer.appendChild(testRow);
 
var descRow = document.createElement('tr');
var desc = document.createElement('td');
desc.innerHTML = testDescription;
descRow.appendChild(desc);
gTestContainer.appendChild(descRow);
 
return dojox.gfx.createSurface(testHolder, width, height);
}
 
function addTest(testName, fn)
{
gTests[testName] = fn;
}
 
function runTest_nodebug(testName)
{
try {
var t = gTests[testName];
if (!t) {
return 'no test named ' + t;
}
t(testName);
return null; // the success condition
} catch (e) {
return e.message;
}
}
 
function runTest_debug(testName)
{
var t = gTests[testName];
if (!t) {
return 'no test named ' + t;
}
t(testName);
return null; // the success condition
}
 
var runTest = djConfig.isDebug ? runTest_debug : runTest_nodebug;
 
dojo.addOnLoad(function()
{
gTestContainer = dojo.byId('testcontainer');
var rect = { x: 0, y: 0, width: 100, height: 100 };
 
addTest('rect', function(testName){
var surface = getTestSurface(testName, 'translucent rect with rounded stroke');
var red_rect = surface.createRect(rect);
red_rect.setFill([255, 0, 0, 0.5]);
red_rect.setStroke({color: "blue", width: 10, join: "round" });
red_rect.setTransform({dx: 100, dy: 100});
//dojo.connect(red_rect.getNode(), "onclick", function(){ alert("red"); });
red_rect.connect("onclick", function(){ alert("red"); });
});
 
addTest('straight_rect', function(testName){
var surface = getTestSurface(testName, 'translucent rect with no stroke');
var blue_rect = surface.createRect(rect).setFill([0, 255, 0, 0.5]).setTransform({ dx: 100, dy: 100 });
//dojo.connect( blue_rect.getNode(), "onclick", function(){ blue_rect.setShape({width: blue_rect.getShape().width + 20}); });
blue_rect.connect("onclick", function(){ blue_rect.setShape({width: blue_rect.getShape().width + 20}); });
});
 
addTest('rotated_rect', function(testName){
var surface = getTestSurface(testName, '30g CCW blue translucent rounded rect');
console.debug('rotated_rect');
// anonymous 30 degree CCW rotated green rectangle
surface.createRect({r: 20})
.setFill([0, 0, 255, 0.5])
// rotate it around its center and move to (100, 100)
.setTransform([dojox.gfx.matrix.translate(100, 100), dojox.gfx.matrix.rotategAt(-30, 0, 0)])
;
});
 
addTest('skew_rect', function(testName){
var surface = getTestSurface(testName, 'skewed rects' );
// anonymous red rectangle
surface.createRect(rect).setFill(new dojo.Color([255, 0, 0, 0.5]))
// skew it around LB point -30d, rotate it around LB point 30d, and move it to (100, 100)
.setTransform([dojox.gfx.matrix.translate(100, 100), dojox.gfx.matrix.rotategAt(-30, 0, 100), dojox.gfx.matrix.skewXgAt(30, 0, 100)]);
// anonymous blue rectangle
surface.createRect(rect).setFill(new dojo.Color([0, 0, 255, 0.5]))
// skew it around LB point -30d, and move it to (100, 100)
.setTransform([dojox.gfx.matrix.translate(100, 100), dojox.gfx.matrix.skewXgAt(30, 0, 100)]);
// anonymous yellow rectangle
surface.createRect(rect).setFill(new dojo.Color([255, 255, 0, 0.25]))
// move it to (100, 100)
.setTransform(dojox.gfx.matrix.translate(100, 100));
});
 
addTest('matrix_rect', function(testName){
var surface = getTestSurface(testName, 'all matrix operations, check debug output for more details');
 
var group = surface.createGroup();
var blue_rect = group.createRect(rect).setFill([0, 0, 255, 0.5]).applyTransform(dojox.gfx.matrix.identity);
console.debug( "blue_rect: rect with identity" );
 
group.createRect(rect).setFill([0, 255, 0, 0.5]).applyTransform(dojox.gfx.matrix.translate(30, 40));
console.debug( "lime_rect: translate(30,40) " );
group.createRect(rect).setFill([255, 0, 0, 0.5]).applyTransform(dojox.gfx.matrix.rotateg(-30));
console.debug( "red_rect: rotate 30 degree counterclockwise " );
 
group.createRect(rect).setFill([0, 255, 255, 0.5])
.applyTransform(dojox.gfx.matrix.scale({x:1.5, y:0.5}))
.applyTransform(dojox.gfx.matrix.translate(-40, 220))
;
console.debug( "lightblue_rect: scale(1.5, 0.5)" );
 
group.createRect(rect).setFill([0, 0, 255, 0.5]).setFill([255, 0, 255, 0.5]).applyTransform(dojox.gfx.matrix.flipX);
console.debug( "pink_rect: flipX" );
 
group.createRect(rect).setFill([0, 0, 255, 0.5]).setFill([255, 255, 0, 0.5]).applyTransform(dojox.gfx.matrix.flipY);
console.debug( "yellow_rect: flipY" );
 
group.createRect(rect).setFill([0, 0, 255, 0.5]).setFill([128, 0, 128, 0.5]).applyTransform(dojox.gfx.matrix.flipXY);
console.debug( "purple_rect: flipXY" );
 
group.createRect(rect).setFill([0, 0, 255, 0.5]).setFill([255, 128, 0, 0.5]).applyTransform(dojox.gfx.matrix.skewXg(-15));
console.debug( "purple_rect: skewXg 15 degree" );
 
group.createRect(rect).setFill([0, 0, 255, 0.5]).setFill([0, 0, 0, 0.5]).applyTransform(dojox.gfx.matrix.skewYg(-50));
console.debug( "black_rect: skewXg 50 degree" );
 
// move
group
.setTransform({ xx: 1.5, yy: 0.5, dx: 100, dy: 100 })
.applyTransform(dojox.gfx.matrix.rotateg(-30))
;
});
 
addTest('attach', function(testName){
var surface = getTestSurface(testName, 'Attach to existed shape');
var red_rect = surface.createRect(rect)
.setShape({ width: 75 })
.setFill([255, 0, 0, 0.5])
.setStroke({ color: "blue", width: 1 })
.setTransform({ dx: 50, dy: 50, xx: 1, xy: 0.5, yx: 0.7, yy: 1.1 })
;
 
console.debug("attaching !");
// now attach it!
var ar = dojox.gfx.attachNode(red_rect.rawNode);
console.assert( ar.rawNode == red_rect.rawNode );
 
// FIXME: more generic method to compare two dictionary?
console.debug("attach shape: ");
isEqual(ar.shape, red_rect.shape, "rect.shape");
console.debug("attach matrix: ");
isEqual(ar.matrix, red_rect.matrix, "rect.matrix");
console.debug("attach strokeStyle: ");
isEqual(ar.strokeStyle, red_rect.strokeStyle, "rect.strokeStyle");
console.debug("attach fillStyle: ");
isEqual(ar.fillStyle, red_rect.fillStyle, "rect.fillStyle");
});
// test circle
addTest('circle', function(testName){
var surface = getTestSurface(testName, 'translucent green circle');
var circle = { cx: 130, cy: 130, r: 50 };
surface.createCircle(circle).setFill([0, 255, 0, 0.5]).setTransform({ dx: 20, dy: 20 });
});
 
// test line
addTest('line', function(testName){
var surface = getTestSurface(testName, 'straight red line');
var line = { x1: 20, y1: 20, x2: 100, y2: 120 };
surface.createLine(line).setFill([255, 0, 0, 0.5]).setStroke({color: "red", width: 1}).setTransform({ dx:70, dy: 100 });
});
 
// test ellipse
addTest('ellipse', function(testName){
var surface = getTestSurface(testName, 'translucent cyan ellipse');
var ellipse = { cx: 50, cy: 80, rx: 50, ry: 80 };
surface.createEllipse(ellipse).setFill([0, 255, 255, 0.5]).setTransform({ dx: 30, dy: 70 });
});
 
// test polyline
addTest('polyline', function(testName){
var surface = getTestSurface(testName, 'unfilled open polyline');
var points = [ {x: 10, y: 20}, {x: 40, y: 70}, {x: 120, y: 50}, {x: 90, y: 90} ];
surface.createPolyline(points).setFill(null).setStroke({ color: "blue", width: 1 }).setTransform({ dx: 15, dy: 0 });
});
 
// test polygon
addTest('polygon', function(testName){
var surface = getTestSurface(testName, 'filled polygon');
var points2 = [{x: 100, y: 0}, {x: 200, y: 40}, {x: 180, y: 150}, {x: 60, y: 170}, {x: 20, y: 100}];
surface.createPolyline(points2).setFill([0, 128, 255, 0.6]).setTransform({dx:30, dy: 20});
});
 
// test path: lineTo, moveTo, closePath
addTest('lineTo', function(testName){
var surface = getTestSurface(testName, 'lineTo, moveTo, closePath');
surface.createPath()
.moveTo(10, 20).lineTo(80, 150)
.setAbsoluteMode(false).lineTo(40, 0)
.setAbsoluteMode(true).lineTo(180, 100)
.setAbsoluteMode(false).lineTo(0, -30).lineTo(-30, -50)
.closePath()
.setStroke({ color: "red", width: 1 })
.setFill(null)
.setTransform({ dx: 10, dy: 18 })
;
});
 
addTest('setPath', function(testName){
var surface = getTestSurface(testName, 'setPath example with lineTo moveTo');
surface.createPath()
.moveTo(10, 20).lineTo(80, 150)
.setAbsoluteMode(false).lineTo(40,0)
.setAbsoluteMode(true).lineTo(180, 100)
.setAbsoluteMode(false).lineTo(0, -30).lineTo(-30, -50)
.curveTo(10, -80, -150, -10, -90, -10)
.closePath()
.setStroke({ color: "red", width: 1 })
.setFill(null)
.setTransform({ dx: 10, dy: 58 })
;
 
surface.createPath({ path: "M10,20 L80,150 l40,0 L180,100 l0,-30 l-30,-50 c10,-80 -150,-10 -90,-10 z" })
.setFill(null)
.setStroke({ color: "blue", width: 1 })
.setTransform({ dx: 50, dy: 78 })
;
});
 
// test arcTo
addTest('arcTo', function(testName){
var surface = getTestSurface(testName, 'arcTo: from 0 to 360 degree, w/ 30 degree of x axis rotation, rendered with different color');
 
var m = dojox.gfx.matrix;
var g1 = surface.createGroup();
var g2 = g1.createGroup();
 
var rx = 100, ry = 60, xRotg = 30;
var startPoint = m.multiplyPoint(m.rotateg(xRotg), {x: -rx, y: 0 });
var endPoint = m.multiplyPoint(m.rotateg(xRotg), {x: 0, y: -ry});
var re1 = g1.createPath()
.moveTo(startPoint)
.arcTo(rx, ry, xRotg, true, false, endPoint)
.setStroke({color: "red"})
;
var ge1 = g1.createPath()
.moveTo(re1.getLastPosition())
.arcTo(rx, ry, xRotg, false, false, startPoint)
.setStroke({color: "blue"})
;
var re2 = g2.createPath()
.moveTo(startPoint)
.arcTo(rx, ry, xRotg, false, true, endPoint)
.setStroke({color: "red"})
;
var ge2 = g2.createPath()
.moveTo(re2.getLastPosition())
.arcTo(rx, ry, xRotg, true, true, startPoint)
.setStroke({color: "blue"})
;
g1.setTransform({dx: 150, dy: 150});
g2.setTransform({dx: 10, dy: 10});
});
 
// test path: curveTo, smoothCurveTo
addTest('curveTo', function(testName) {
var surface = getTestSurface(testName, 'curveTo, smoothCurveTo');
surface.createPath()
.moveTo(10, 20).curveTo(50, 50, 50, 100, 150, 100).smoothCurveTo(300, 300, 200, 200)
.setStroke({ color: "green", width: 1 }).setFill(null).setTransform({ dx: 10, dy: 30 })
;
});
 
// test path: curveTo, smoothCurveTo with relative.
addTest('curveTo2', function(testName) {
var surface = getTestSurface(testName, 'curveTo, smoothCurveTo with relative coordination');
surface.createPath()
.moveTo(10, 20).curveTo(50, 50, 50, 100, 150, 100)
.setAbsoluteMode(false).smoothCurveTo(150, 200, 50, 100)
.setAbsoluteMode(true).smoothCurveTo(50, 100, 10, 230)
.setStroke({ color: "green", width: 1 }).setFill(null).setTransform({ dx: 10, dy: 30 })
;
});
 
// test path: curveTo, smoothCurveTo with relative.
addTest('qCurveTo', function(testName) {
var surface = getTestSurface(testName, 'qCurveTo, qSmoothCurveTo' );
surface.createPath()
.moveTo(10, 15).qCurveTo(50, 50, 100, 100).qSmoothCurveTo(150, 20)
.setStroke({ color: "green", width: 1 }).setFill(null).setTransform({ dx: 10, dy: 30 })
;
});
 
addTest('qCurveTo2', function(testName) {
var surface = getTestSurface(testName, 'qCurveTo, qSmoothCurveTo with relative' );
surface.createPath()
.moveTo(10, 20).qCurveTo(50, 50, 100, 100)
.setAbsoluteMode(false).qSmoothCurveTo(50, -80)
.setAbsoluteMode(true).qSmoothCurveTo(200, 80)
.setStroke({ color: "green", width: 1 }).setFill(null).setTransform({ dx: 10, dy: 30 })
;
});
 
// test defines, linearGradient
addTest('linearGradient', function(testName) {
var surface = getTestSurface(testName, 'linear gradient fill');
// this is an example to split the linearGradient from setFill:
var lg = {
type: "linear",
x1: 0, y1: 0, x2: 75, y2: 50,
colors: [
{ offset: 0, color: "#F60" },
{ offset: 1, color: "#FF6" }
]
};
surface.createRect(rect).setFill(lg).setTransform({ dx: 40, dy: 100 });
});
 
// TODO: test radialGradient
addTest('radialGradient', function(testName) {
var surface = getTestSurface(testName, 'radial gradient fill');
// this is a total inline implementation compared with previous one.
var rg = {
type: "radial",
cx: 100, cy: 100, r: 100,
colors: [
{ offset: 0, color: "red" },
{ offset: 0.5, color: "green" },
{ offset: 1, color: "blue" }
]
};
surface.createCircle({cx: 100, cy: 100, r: 100})
.setStroke({})
.setFill(rg)
.setTransform({dx: 40, dy: 30})
;
// surface.createRect(rect)
// .setShape({width: 200})
// .setStroke({})
// .setFill(rg)
// .setTransform({dx: 40, dy: 30})
// ;
});
 
addTest('attach_gradient', function(testName) {
var surface = getTestSurface(testName, 'attach gradient fill');
// this is an example to split the linearGradient from setFill:
var lg = {
type: "linear",
x1: 0, y1: 0, x2: 75, y2: 50,
colors: [
{ offset: 0, color: "#F60" },
{ offset: 0.5, color: "#FAF" },
{ offset: 1, color: "#FF6" }
]
};
 
var lgr = surface.createRect(rect).setFill(lg).setTransform({ dx: 40, dy: 100 });
 
var ar = dojox.gfx.attachNode(lgr.rawNode);
// FIXME: more generic method to compare two dictionary?
console.debug("attach_gradient!");
 
console.debug("attach shape: ");
isEqual(lgr.shape, ar.shape, "rect.shape");
console.debug("attach matrix: ");
isEqual(lgr.matrix, ar.matrix, "rect.matrix");
console.debug("attach strokeStyle: ");
isEqual(lgr.strokeStyle, ar.strokeStyle, "rect.strokeStyle");
console.debug("attach fillStyle: ");
isEqual(lgr.fillStyle.gradient, ar.fillStyle.gradient, "rect.fillStyle.gradient");
//isEqual(lgr.fillStyle.id, ar.fillStyle.id, "rect.fillStyle.id");
});
 
var gTestsToRun = [
'rect',
'straight_rect',
'rotated_rect',
'skew_rect',
'matrix_rect',
//'attach',
//'attach_gradient',
'circle',
'arcTo',
'line',
'ellipse',
'polyline',
'polygon',
'lineTo',
'setPath',
'curveTo',
'curveTo2',
'qCurveTo',
'qCurveTo2',
'linearGradient',
'radialGradient'
];
 
for (var i = 0; i < gTestsToRun.length; ++i) {
var testName = gTestsToRun[i];
var err = runTest(testName);
if (err) {
getTestSurface(testName, testName + ' FAILED (' + err + ')');
}
}
 
}); // end onload
</script>
<style>
td { border: 1px solid black; text-align: left; vertical-align: top; }
v:group { text-align: left; }
</style>
</head>
<body>
<h1>dojox.gfx tests</h1>
<table>
<tbody id="testcontainer">
</tbody>
</table>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_fill.html
New file
0,0 → 1,47
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Testing fill rule</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<!--<script type="text/javascript" src="../_base.js"></script>-->
<!--<script type="text/javascript" src="../shape.js"></script>-->
<!--<script type="text/javascript" src="../path.js"></script>-->
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
 
makeShapes = function(){
var surface = dojox.gfx.createSurface("test", 500, 500);
var path = surface.createPath("");
// form concentric circles
var center = {x: 250, y: 250};
for(var r = 200; r > 0; r -= 30){
// make two 180 degree arcs to form a circle
var start = {x: center.x, y: center.y - r};
var end = {x: center.x, y: center.y + r};
path.moveTo(start).arcTo(r, r, 0, true, true, end).arcTo(r, r, 0, true, true, start).closePath();
}
// set visual attributes
path.setFill("red").setStroke("black");
};
 
dojo.addOnLoad(makeShapes);
 
</script>
</head>
<body>
<h1>Testing fill rule</h1>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/tests/decompose.js
New file
0,0 → 1,114
if(!dojo._hasResource["dojox.gfx.tests.decompose"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.tests.decompose"] = true;
dojo.provide("dojox.gfx.tests.decompose");
dojo.require("dojox.gfx.decompose");
 
(function(){
var m = dojox.gfx.matrix;
var eq = function(t, a, b){ t.t(2 * Math.abs(a - b) / ((a < 1 && b < 1) ? 1 : a + b) < 1e-6); };
var eqM = function(t, a, b){
eq(t, a.xx, b.xx);
eq(t, a.yy, b.yy);
eq(t, a.xy, b.xy);
eq(t, a.yx, b.yx);
eq(t, a.dx, b.dx);
eq(t, a.dy, b.dy);
};
var compose = function(r){
return m.normalize([
m.translate(r.dx, r.dy),
m.rotate(r.angle2),
m.scale(r.sx, r.sy),
m.rotate(r.angle1)
]);
};
var reconstruct = function(a){
return compose(dojox.gfx.decompose(a));
};
var compare = function(t, a){
var A = m.normalize(a);
eqM(t, A, reconstruct(A));
};
tests.register("dojox.gfx.tests.decompose", [
function IdentityTest(t){
compare(t, m.identity);
},
function FlipXTest(t){
compare(t, m.flipX);
},
function FlipYTest(t){
compare(t, m.flipY);
},
function FlipXYTest(t){
compare(t, m.flipXY);
},
function TranslationTest(t){
compare(t, m.translate(45, -15));
},
function RotationTest(t){
compare(t, m.rotateg(35));
},
function SkewXTest(t){
compare(t, m.skewXg(35));
},
function SkewYTest(t){
compare(t, m.skewYg(35));
},
function ReflectTest(t){
compare(t, m.reflect(13, 27));
},
function ProjectTest(t){
compare(t, m.project(13, 27));
},
function ScaleTest1(t){
compare(t, m.scale(3));
},
function ScaleTest2(t){
compare(t, m.scale(3, -1));
},
function ScaleTest3(t){
compare(t, m.scale(-3, 1));
},
function ScaleTest4(t){
compare(t, m.scale(-3, -1));
},
function ScaleRotateTest1(t){
compare(t, [m.scale(3), m.rotateAt(35, 13, 27)]);
},
function ScaleRotateTest2(t){
compare(t, [m.scale(3, -1), m.rotateAt(35, 13, 27)]);
},
function ScaleRotateTest3(t){
compare(t, [m.scale(-3, 1), m.rotateAt(35, 13, 27)]);
},
function ScaleRotateTest4(t){
compare(t, [m.scale(-3, -1), m.rotateAt(35, 13, 27)]);
},
function RotateScaleTest1(t){
compare(t, [m.rotateAt(35, 13, 27), m.scale(3)]);
},
function RotateScaleTest2(t){
compare(t, [m.rotateAt(35, 13, 27), m.scale(3, -1)]);
},
function RotateScaleTest3(t){
compare(t, [m.rotateAt(35, 13, 27), m.scale(-3, 1)]);
},
function RotateScaleTest4(t){
compare(t, [m.rotateAt(35, 13, 27), m.scale(-3, -1)]);
},
function RotateScaleRotateTest1(t){
compare(t, [m.rotateAt(35, 13, 27), m.scale(3), m.rotateAt(-15, 163, -287)]);
},
function RotateScaleRotateTest2(t){
compare(t, [m.rotateAt(35, 13, 27), m.scale(3, -1), m.rotateAt(-15, 163, -287)]);
},
function RotateScaleRotateTest3(t){
compare(t, [m.rotateAt(35, 13, 27), m.scale(-3, 1), m.rotateAt(-15, 163, -287)]);
},
function RotateScaleRotateTest4(t){
compare(t, [m.rotateAt(35, 13, 27), m.scale(-3, -1), m.rotateAt(-15, 163, -287)]);
}
]);
})();
 
}
/trunk/api/js/dojo1.0/dojox/gfx/tests/runTests.html
New file
0,0 → 1,9
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dojox Unit Test Runner</title>
<meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.gfx.tests.module"></HEAD>
<BODY>
Redirecting to D.O.H runner.
</BODY>
</HTML>
/trunk/api/js/dojo1.0/dojox/gfx/tests/test_linearGradient.html
New file
0,0 → 1,80
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Dojo Unified 2D Graphics</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../../../dojo/_base/Color.js"></script>
<script type="text/javascript" src="../_base.js"></script>
<script type="text/javascript" src="../shape.js"></script>
<script type="text/javascript" src="../path.js"></script>
<script type="text/javascript" src="../arc.js"></script>
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../canvas.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
dojo.require("dojox.gfx");
dojo.require("dojo.colors");
 
makeShapes = function(){
var lg1 = {
type: "linear",
x1: 0, y1: 0,
x2: 300, y2: 0,
colors: [
{ offset: 0, color: [0, 0, 0, 0] },
{ offset: 0.1, color: "#000000" },
{ offset: 0.2, color: "red" },
{ offset: 0.3, color: "rgb(0,255,0)" },
{ offset: 0.4, color: "blue" },
{ offset: 0.5, color: "#ff0" },
{ offset: 0.6, color: [128] },
{ offset: 0.7, color: [128, 128, 64] },
{ offset: 1, color: [0, 255, 0, 0] }
]
};
var lg2 = {
type: "linear",
x1: 0, y1: 0,
x2: 300, y2: 0,
colors: [
{ offset: 0.2, color: "red" },
{ offset: 0.3, color: "yellow" }
]
};
var surface = dojox.gfx.createSurface(dojo.byId("grad"), 300, 300);
var group = surface.createGroup();
var rect1 = surface.createRect({
width: 300,
height: 100
});
rect1.setFill(lg1);
var rect2 = surface.createRect({
y: 150,
width: 300,
height: 100
});
rect2.setFill(lg2);
group.add(rect1);
group.add(rect2);
};
dojo.addOnLoad(makeShapes);
</script>
<style>
v:group { text-align: left; }
#grad { width: 300px; height: 300px; }
</style>
</head>
<body>
<h1>dojox.gfx Linear Gradient test</h1>
<div id="grad"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/demos/tiger.html
New file
0,0 → 1,566
<html>
<head>
<title>dojox.gfx: Tiger</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="parseOnLoad: true"></script>
<script type="text/javascript">
 
dojo.require("dijit.form.Slider");
dojo.require("dojo.parser"); // scan page for widgets
 
dojo.require("dojox.gfx");
 
var rotation = 0, scaling = 1;
var surface, g, m = dojox.gfx.matrix;
var initial_matrix = m.translate(250, 250);
 
var updateMatrix = function(){
if(g){ g.setTransform([m.rotategAt(rotation, 350, 350), m.scaleAt(scaling, 350, 350), initial_matrix]); }
};
 
var rotatingEvent = function(value){
rotation = value;
dojo.byId("rotationValue").innerHTML = rotation;
updateMatrix();
};
 
var scalingEvent = function(value){
scaling = Math.exp(Math.LN10 * (value - 1));
dojo.byId("scaleValue").innerHTML = scaling.toFixed(3);
updateMatrix();
};
 
makeShapes = function(){
surface = dojox.gfx.createSurface(dojo.byId("gfx_holder"), 700, 700);
surface.createRect({x: 0, y: 0, width: 700, height: 700}).setFill("#eee");
g = surface.createGroup().setTransform(initial_matrix);
var f, s = {color: "black", width: 1};
f = "#ffffff"; s = {color: "#000000", width: 0.172};
g.createPath("M-122.304 84.285C-122.304 84.285 -122.203 86.179 -123.027 86.16C-123.851 86.141 -140.305 38.066 -160.833 40.309C-160.833 40.309 -143.05 32.956 -122.304 84.285z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.172};
g.createPath("M-118.774 81.262C-118.774 81.262 -119.323 83.078 -120.092 82.779C-120.86 82.481 -119.977 31.675 -140.043 26.801C-140.043 26.801 -120.82 25.937 -118.774 81.262z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.172};
g.createPath("M-91.284 123.59C-91.284 123.59 -89.648 124.55 -90.118 125.227C-90.589 125.904 -139.763 113.102 -149.218 131.459C-149.218 131.459 -145.539 112.572 -91.284 123.59z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.172};
g.createPath("M-94.093 133.801C-94.093 133.801 -92.237 134.197 -92.471 134.988C-92.704 135.779 -143.407 139.121 -146.597 159.522C-146.597 159.522 -149.055 140.437 -94.093 133.801z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.172};
g.createPath("M-98.304 128.276C-98.304 128.276 -96.526 128.939 -96.872 129.687C-97.218 130.435 -147.866 126.346 -153.998 146.064C-153.998 146.064 -153.646 126.825 -98.304 128.276z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.172};
g.createPath("M-109.009 110.072C-109.009 110.072 -107.701 111.446 -108.34 111.967C-108.979 112.488 -152.722 86.634 -166.869 101.676C-166.869 101.676 -158.128 84.533 -109.009 110.072z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.172};
g.createPath("M-116.554 114.263C-116.554 114.263 -115.098 115.48 -115.674 116.071C-116.25 116.661 -162.638 95.922 -174.992 112.469C-174.992 112.469 -168.247 94.447 -116.554 114.263z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.172};
g.createPath("M-119.154 118.335C-119.154 118.335 -117.546 119.343 -118.036 120.006C-118.526 120.669 -167.308 106.446 -177.291 124.522C-177.291 124.522 -173.066 105.749 -119.154 118.335z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.172};
g.createPath("M-108.42 118.949C-108.42 118.949 -107.298 120.48 -107.999 120.915C-108.7 121.35 -148.769 90.102 -164.727 103.207C-164.727 103.207 -153.862 87.326 -108.42 118.949z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.172};
g.createPath("M-128.2 90C-128.2 90 -127.6 91.8 -128.4 92C-129.2 92.2 -157.8 50.2 -177.001 57.8C-177.001 57.8 -161.8 46 -128.2 90z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.172};
g.createPath("M-127.505 96.979C-127.505 96.979 -126.53 98.608 -127.269 98.975C-128.007 99.343 -164.992 64.499 -182.101 76.061C-182.101 76.061 -169.804 61.261 -127.505 96.979z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.172};
g.createPath("M-127.62 101.349C-127.62 101.349 -126.498 102.88 -127.199 103.315C-127.9 103.749 -167.969 72.502 -183.927 85.607C-183.927 85.607 -173.062 69.726 -127.62 101.349z").setFill(f).setStroke(s);
f = "#ffffff"; s = "#000000";
g.createPath("M-129.83 103.065C-129.327 109.113 -128.339 115.682 -126.6 118.801C-126.6 118.801 -130.2 131.201 -121.4 144.401C-121.4 144.401 -121.8 151.601 -120.2 154.801C-120.2 154.801 -116.2 163.201 -111.4 164.001C-107.516 164.648 -98.793 167.717 -88.932 169.121C-88.932 169.121 -71.8 183.201 -75 196.001C-75 196.001 -75.4 212.401 -79 214.001C-79 214.001 -67.4 202.801 -77 219.601L-81.4 238.401C-81.4 238.401 -55.8 216.801 -71.4 235.201L-81.4 261.201C-81.4 261.201 -61.8 242.801 -69 251.201L-72.2 260.001C-72.2 260.001 -29 232.801 -59.8 262.401C-59.8 262.401 -51.8 258.801 -47.4 261.601C-47.4 261.601 -40.6 260.401 -41.4 262.001C-41.4 262.001 -62.2 272.401 -65.8 290.801C-65.8 290.801 -57.4 280.801 -60.6 291.601L-60.2 303.201C-60.2 303.201 -56.2 281.601 -56.6 319.201C-56.6 319.201 -37.4 301.201 -49 322.001L-49 338.801C-49 338.801 -33.8 322.401 -40.2 335.201C-40.2 335.201 -30.2 326.401 -34.2 341.601C-34.2 341.601 -35 352.001 -30.6 340.801C-30.6 340.801 -14.6 310.201 -20.6 336.401C-20.6 336.401 -21.4 355.601 -16.6 340.801C-16.6 340.801 -16.2 351.201 -7 358.401C-7 358.401 -8.2 307.601 4.6 343.601L8.6 360.001C8.6 360.001 11.4 350.801 11 345.601C11 345.601 25.8 329.201 19 353.601C19 353.601 34.2 330.801 31 344.001C31 344.001 23.4 360.001 25 364.801C25 364.801 41.8 330.001 43 328.401C43 328.401 41 370.802 51.8 334.801C51.8 334.801 57.4 346.801 54.6 351.201C54.6 351.201 62.6 343.201 61.8 340.001C61.8 340.001 66.4 331.801 69.2 345.401C69.2 345.401 71 354.801 72.6 351.601C72.6 351.601 76.6 375.602 77.8 352.801C77.8 352.801 79.4 339.201 72.2 327.601C72.2 327.601 73 324.401 70.2 320.401C70.2 320.401 83.8 342.001 76.6 313.201C76.6 313.201 87.801 321.201 89.001 321.201C89.001 321.201 75.4 298.001 84.2 302.801C84.2 302.801 79 292.401 97.001 304.401C97.001 304.401 81 288.401 98.601 298.001C98.601 298.001 106.601 304.401 99.001 294.401C99.001 294.401 84.6 278.401 106.601 296.401C106.601 296.401 118.201 312.801 119.001 315.601C119.001 315.601 109.001 286.401 104.601 283.601C104.601 283.601 113.001 247.201 154.201 262.801C154.201 262.801 161.001 280.001 165.401 261.601C165.401 261.601 178.201 255.201 189.401 282.801C189.401 282.801 193.401 269.201 192.601 266.401C192.601 266.401 199.401 267.601 198.601 266.401C198.601 266.401 211.801 270.801 213.001 270.001C213.001 270.001 219.801 276.801 220.201 273.201C220.201 273.201 229.401 276.001 227.401 272.401C227.401 272.401 236.201 288.001 236.601 291.601L239.001 277.601L241.001 280.401C241.001 280.401 242.601 272.801 241.801 271.601C241.001 270.401 261.801 278.401 266.601 299.201L268.601 307.601C268.601 307.601 274.601 292.801 273.001 288.801C273.001 288.801 278.201 289.601 278.601 294.001C278.601 294.001 282.601 270.801 277.801 264.801C277.801 264.801 282.201 264.001 283.401 267.601L283.401 260.401C283.401 260.401 290.601 261.201 290.601 258.801C290.601 258.801 295.001 254.801 297.001 259.601C297.001 259.601 284.601 224.401 303.001 243.601C303.001 243.601 310.201 254.401 306.601 235.601C303.001 216.801 299.001 215.201 303.801 214.801C303.801 214.801 304.601 211.201 302.601 209.601C300.601 208.001 303.801 209.601 303.801 209.601C303.801 209.601 308.601 213.601 303.401 191.601C303.401 191.601 309.801 193.201 297.801 164.001C297.801 164.001 300.601 161.601 296.601 153.201C296.601 153.201 304.601 157.601 307.401 156.001C307.401 156.001 307.001 154.401 303.801 150.401C303.801 150.401 282.201 95.6 302.601 117.601C302.601 117.601 314.451 131.151 308.051 108.351C308.051 108.351 298.94 84.341 299.717 80.045L-129.83 103.065z").setFill(f).setStroke(s);
f = "#cc7226"; s = "#000000";
g.createPath("M299.717 80.245C300.345 80.426 302.551 81.55 303.801 83.2C303.801 83.2 310.601 94 305.401 75.6C305.401 75.6 296.201 46.8 305.001 58C305.001 58 311.001 65.2 307.801 51.6C303.936 35.173 301.401 28.8 301.401 28.8C301.401 28.8 313.001 33.6 286.201 -6L295.001 -2.4C295.001 -2.4 275.401 -42 253.801 -47.2L245.801 -53.2C245.801 -53.2 284.201 -91.2 271.401 -128C271.401 -128 264.601 -133.2 255.001 -124C255.001 -124 248.601 -119.2 242.601 -120.8C242.601 -120.8 211.801 -119.6 209.801 -119.6C207.801 -119.6 173.001 -156.8 107.401 -139.2C107.401 -139.2 102.201 -137.2 97.801 -138.4C97.801 -138.4 79.4 -154.4 30.6 -131.6C30.6 -131.6 20.6 -129.6 19 -129.6C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 -103.2 -25 -102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 -51.4 -72.8 -52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 -42 -69.4 -39.2C-69.4 -39.2 -77 -25.2 -75.8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 -11.2C-87.4 -11.2 -90.2 -10 -87.8 -6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 -99.8 25.6 -97.8 30.8C-97.8 30.8 -97.4 35.6 -100.2 37.2C-100.2 37.2 -103.8 36.8 -95.4 48.8C-95.4 48.8 -94.6 50 -97.8 52.4C-97.8 52.4 -115 56 -117.4 72.4C-117.4 72.4 -131 87.2 -131 92.4C-131 94.705 -130.729 97.852 -130.03 102.465C-130.03 102.465 -130.6 110.801 -103 111.601C-75.4 112.401 299.717 80.245 299.717 80.245z").setFill(f).setStroke(s);
f = "#cc7226"; s = null;
g.createPath("M-115.6 102.6C-140.6 63.2 -126.2 119.601 -126.2 119.601C-117.4 154.001 12.2 116.401 12.2 116.401C12.2 116.401 181.001 86 192.201 82C203.401 78 298.601 84.4 298.601 84.4L293.001 67.6C228.201 21.2 209.001 44.4 195.401 40.4C181.801 36.4 184.201 46 181.001 46.8C177.801 47.6 138.601 22.8 132.201 23.6C125.801 24.4 100.459 0.649 115.401 32.4C131.401 66.4 57 71.6 40.2 60.4C23.4 49.2 47.4 78.8 47.4 78.8C65.8 98.8 31.4 82 31.4 82C-3 69.2 -27 94.8 -30.2 95.6C-33.4 96.4 -38.2 99.6 -39 93.2C-39.8 86.8 -47.31 70.099 -79 96.4C-99 113.001 -112.8 91 -112.8 91L-115.6 102.6z").setFill(f).setStroke(s);
f = "#e87f3a";
g.createPath("M133.51 25.346C127.11 26.146 101.743 2.407 116.71 34.146C133.31 69.346 58.31 73.346 41.51 62.146C24.709 50.946 48.71 80.546 48.71 80.546C67.11 100.546 32.709 83.746 32.709 83.746C-1.691 70.946 -25.691 96.546 -28.891 97.346C-32.091 98.146 -36.891 101.346 -37.691 94.946C-38.491 88.546 -45.87 72.012 -77.691 98.146C-98.927 115.492 -112.418 94.037 -112.418 94.037L-115.618 104.146C-140.618 64.346 -125.546 122.655 -125.546 122.655C-116.745 157.056 13.509 118.146 13.509 118.146C13.509 118.146 182.31 87.746 193.51 83.746C204.71 79.746 299.038 86.073 299.038 86.073L293.51 68.764C228.71 22.364 210.31 46.146 196.71 42.146C183.11 38.146 185.51 47.746 182.31 48.546C179.11 49.346 139.91 24.546 133.51 25.346z").setFill(f).setStroke(s);
f = "#ea8c4d";
g.createPath("M134.819 27.091C128.419 27.891 103.685 3.862 118.019 35.891C134.219 72.092 59.619 75.092 42.819 63.892C26.019 52.692 50.019 82.292 50.019 82.292C68.419 102.292 34.019 85.492 34.019 85.492C-0.381 72.692 -24.382 98.292 -27.582 99.092C-30.782 99.892 -35.582 103.092 -36.382 96.692C-37.182 90.292 -44.43 73.925 -76.382 99.892C-98.855 117.983 -112.036 97.074 -112.036 97.074L-115.636 105.692C-139.436 66.692 -124.891 125.71 -124.891 125.71C-116.091 160.11 14.819 119.892 14.819 119.892C14.819 119.892 183.619 89.492 194.819 85.492C206.019 81.492 299.474 87.746 299.474 87.746L294.02 69.928C229.219 23.528 211.619 47.891 198.019 43.891C184.419 39.891 186.819 49.491 183.619 50.292C180.419 51.092 141.219 26.291 134.819 27.091z").setFill(f).setStroke(s);
f = "#ec9961";
g.createPath("M136.128 28.837C129.728 29.637 104.999 5.605 119.328 37.637C136.128 75.193 60.394 76.482 44.128 65.637C27.328 54.437 51.328 84.037 51.328 84.037C69.728 104.037 35.328 87.237 35.328 87.237C0.928 74.437 -23.072 100.037 -26.272 100.837C-29.472 101.637 -34.272 104.837 -35.072 98.437C-35.872 92.037 -42.989 75.839 -75.073 101.637C-98.782 120.474 -111.655 100.11 -111.655 100.11L-115.655 107.237C-137.455 70.437 -124.236 128.765 -124.236 128.765C-115.436 163.165 16.128 121.637 16.128 121.637C16.128 121.637 184.928 91.237 196.129 87.237C207.329 83.237 299.911 89.419 299.911 89.419L294.529 71.092C229.729 24.691 212.929 49.637 199.329 45.637C185.728 41.637 188.128 51.237 184.928 52.037C181.728 52.837 142.528 28.037 136.128 28.837z").setFill(f).setStroke(s);
f = "#eea575";
g.createPath("M137.438 30.583C131.037 31.383 106.814 7.129 120.637 39.383C137.438 78.583 62.237 78.583 45.437 67.383C28.637 56.183 52.637 85.783 52.637 85.783C71.037 105.783 36.637 88.983 36.637 88.983C2.237 76.183 -21.763 101.783 -24.963 102.583C-28.163 103.383 -32.963 106.583 -33.763 100.183C-34.563 93.783 -41.548 77.752 -73.763 103.383C-98.709 122.965 -111.273 103.146 -111.273 103.146L-115.673 108.783C-135.473 73.982 -123.582 131.819 -123.582 131.819C-114.782 166.22 17.437 123.383 17.437 123.383C17.437 123.383 186.238 92.983 197.438 88.983C208.638 84.983 300.347 91.092 300.347 91.092L295.038 72.255C230.238 25.855 214.238 51.383 200.638 47.383C187.038 43.383 189.438 52.983 186.238 53.783C183.038 54.583 143.838 29.783 137.438 30.583z").setFill(f).setStroke(s);
f = "#f1b288";
g.createPath("M138.747 32.328C132.347 33.128 106.383 9.677 121.947 41.128C141.147 79.928 63.546 80.328 46.746 69.128C29.946 57.928 53.946 87.528 53.946 87.528C72.346 107.528 37.946 90.728 37.946 90.728C3.546 77.928 -20.454 103.528 -23.654 104.328C-26.854 105.128 -31.654 108.328 -32.454 101.928C-33.254 95.528 -40.108 79.665 -72.454 105.128C-98.636 125.456 -110.891 106.183 -110.891 106.183L-115.691 110.328C-133.691 77.128 -122.927 134.874 -122.927 134.874C-114.127 169.274 18.746 125.128 18.746 125.128C18.746 125.128 187.547 94.728 198.747 90.728C209.947 86.728 300.783 92.764 300.783 92.764L295.547 73.419C230.747 27.019 215.547 53.128 201.947 49.128C188.347 45.128 190.747 54.728 187.547 55.528C184.347 56.328 145.147 31.528 138.747 32.328z").setFill(f).setStroke(s);
f = "#f3bf9c";
g.createPath("M140.056 34.073C133.655 34.873 107.313 11.613 123.255 42.873C143.656 82.874 64.855 82.074 48.055 70.874C31.255 59.674 55.255 89.274 55.255 89.274C73.655 109.274 39.255 92.474 39.255 92.474C4.855 79.674 -19.145 105.274 -22.345 106.074C-25.545 106.874 -30.345 110.074 -31.145 103.674C-31.945 97.274 -38.668 81.578 -71.145 106.874C-98.564 127.947 -110.509 109.219 -110.509 109.219L-115.709 111.874C-131.709 81.674 -122.273 137.929 -122.273 137.929C-113.473 172.329 20.055 126.874 20.055 126.874C20.055 126.874 188.856 96.474 200.056 92.474C211.256 88.474 301.22 94.437 301.22 94.437L296.056 74.583C231.256 28.183 216.856 54.874 203.256 50.874C189.656 46.873 192.056 56.474 188.856 57.274C185.656 58.074 146.456 33.273 140.056 34.073z").setFill(f).setStroke(s);
f = "#f5ccb0";
g.createPath("M141.365 35.819C134.965 36.619 107.523 13.944 124.565 44.619C146.565 84.219 66.164 83.819 49.364 72.619C32.564 61.419 56.564 91.019 56.564 91.019C74.964 111.019 40.564 94.219 40.564 94.219C6.164 81.419 -17.836 107.019 -21.036 107.819C-24.236 108.619 -29.036 111.819 -29.836 105.419C-30.636 99.019 -37.227 83.492 -69.836 108.619C-98.491 130.438 -110.127 112.256 -110.127 112.256L-115.727 113.419C-130.128 85.019 -121.618 140.983 -121.618 140.983C-112.818 175.384 21.364 128.619 21.364 128.619C21.364 128.619 190.165 98.219 201.365 94.219C212.565 90.219 301.656 96.11 301.656 96.11L296.565 75.746C231.765 29.346 218.165 56.619 204.565 52.619C190.965 48.619 193.365 58.219 190.165 59.019C186.965 59.819 147.765 35.019 141.365 35.819z").setFill(f).setStroke(s);
f = "#f8d8c4";
g.createPath("M142.674 37.565C136.274 38.365 108.832 15.689 125.874 46.365C147.874 85.965 67.474 85.565 50.674 74.365C33.874 63.165 57.874 92.765 57.874 92.765C76.274 112.765 41.874 95.965 41.874 95.965C7.473 83.165 -16.527 108.765 -19.727 109.565C-22.927 110.365 -27.727 113.565 -28.527 107.165C-29.327 100.765 -35.786 85.405 -68.527 110.365C-98.418 132.929 -109.745 115.293 -109.745 115.293L-115.745 114.965C-129.346 88.564 -120.963 144.038 -120.963 144.038C-112.163 178.438 22.673 130.365 22.673 130.365C22.673 130.365 191.474 99.965 202.674 95.965C213.874 91.965 302.093 97.783 302.093 97.783L297.075 76.91C232.274 30.51 219.474 58.365 205.874 54.365C192.274 50.365 194.674 59.965 191.474 60.765C188.274 61.565 149.074 36.765 142.674 37.565z").setFill(f).setStroke(s);
f = "#fae5d7";
g.createPath("M143.983 39.31C137.583 40.11 110.529 17.223 127.183 48.11C149.183 88.91 68.783 87.31 51.983 76.11C35.183 64.91 59.183 94.51 59.183 94.51C77.583 114.51 43.183 97.71 43.183 97.71C8.783 84.91 -15.217 110.51 -18.417 111.31C-21.618 112.11 -26.418 115.31 -27.218 108.91C-28.018 102.51 -34.346 87.318 -67.218 112.11C-98.345 135.42 -109.363 118.329 -109.363 118.329L-115.764 116.51C-128.764 92.51 -120.309 147.093 -120.309 147.093C-111.509 181.493 23.983 132.11 23.983 132.11C23.983 132.11 192.783 101.71 203.983 97.71C215.183 93.71 302.529 99.456 302.529 99.456L297.583 78.074C232.783 31.673 220.783 60.11 207.183 56.11C193.583 52.11 195.983 61.71 192.783 62.51C189.583 63.31 150.383 38.51 143.983 39.31z").setFill(f).setStroke(s);
f = "#fcf2eb";
g.createPath("M145.292 41.055C138.892 41.855 112.917 18.411 128.492 49.855C149.692 92.656 70.092 89.056 53.292 77.856C36.492 66.656 60.492 96.256 60.492 96.256C78.892 116.256 44.492 99.456 44.492 99.456C10.092 86.656 -13.908 112.256 -17.108 113.056C-20.308 113.856 -25.108 117.056 -25.908 110.656C-26.708 104.256 -32.905 89.232 -65.908 113.856C-98.273 137.911 -108.982 121.365 -108.982 121.365L-115.782 118.056C-128.582 94.856 -119.654 150.147 -119.654 150.147C-110.854 184.547 25.292 133.856 25.292 133.856C25.292 133.856 194.093 103.456 205.293 99.456C216.493 95.456 302.965 101.128 302.965 101.128L298.093 79.237C233.292 32.837 222.093 61.856 208.493 57.856C194.893 53.855 197.293 63.456 194.093 64.256C190.892 65.056 151.692 40.255 145.292 41.055z").setFill(f).setStroke(s);
f = "#ffffff";
g.createPath("M-115.8 119.601C-128.6 97.6 -119 153.201 -119 153.201C-110.2 187.601 26.6 135.601 26.6 135.601C26.6 135.601 195.401 105.2 206.601 101.2C217.801 97.2 303.401 102.8 303.401 102.8L298.601 80.4C233.801 34 223.401 63.6 209.801 59.6C196.201 55.6 198.601 65.2 195.401 66C192.201 66.8 153.001 42 146.601 42.8C140.201 43.6 114.981 19.793 129.801 51.6C152.028 99.307 69.041 89.227 54.6 79.6C37.8 68.4 61.8 98 61.8 98C80.2 118.001 45.8 101.2 45.8 101.2C11.4 88.4 -12.6 114.001 -15.8 114.801C-19 115.601 -23.8 118.801 -24.6 112.401C-25.4 106 -31.465 91.144 -64.6 115.601C-98.2 140.401 -108.6 124.401 -108.6 124.401L-115.8 119.601z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-74.2 149.601C-74.2 149.601 -81.4 161.201 -60.6 174.401C-60.6 174.401 -59.2 175.801 -77.2 171.601C-77.2 171.601 -83.4 169.601 -85 159.201C-85 159.201 -89.8 154.801 -94.6 149.201C-99.4 143.601 -74.2 149.601 -74.2 149.601z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M65.8 102C65.8 102 83.498 128.821 82.9 133.601C81.6 144.001 81.4 153.601 84.6 157.601C87.801 161.601 96.601 194.801 96.601 194.801C96.601 194.801 96.201 196.001 108.601 158.001C108.601 158.001 120.201 142.001 100.201 123.601C100.201 123.601 65 94.8 65.8 102z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-54.2 176.401C-54.2 176.401 -43 183.601 -57.4 214.801L-51 212.401C-51 212.401 -51.8 223.601 -55 226.001L-47.8 222.801C-47.8 222.801 -43 230.801 -47 235.601C-47 235.601 -30.2 243.601 -31 250.001C-31 250.001 -24.6 242.001 -28.6 235.601C-32.6 229.201 -39.8 233.201 -39 214.801L-47.8 218.001C-47.8 218.001 -42.2 209.201 -42.2 202.801L-50.2 205.201C-50.2 205.201 -34.731 178.623 -45.4 177.201C-51.4 176.401 -54.2 176.401 -54.2 176.401z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-21.8 193.201C-21.8 193.201 -19 188.801 -21.8 189.601C-24.6 190.401 -55.8 205.201 -61.8 214.801C-61.8 214.801 -27.4 190.401 -21.8 193.201z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-11.4 201.201C-11.4 201.201 -8.6 196.801 -11.4 197.601C-14.2 198.401 -45.4 213.201 -51.4 222.801C-51.4 222.801 -17 198.401 -11.4 201.201z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M1.8 186.001C1.8 186.001 4.6 181.601 1.8 182.401C-1 183.201 -32.2 198.001 -38.2 207.601C-38.2 207.601 -3.8 183.201 1.8 186.001z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-21.4 229.601C-21.4 229.601 -21.4 223.601 -24.2 224.401C-27 225.201 -63 242.801 -69 252.401C-69 252.401 -27 226.801 -21.4 229.601z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-20.2 218.801C-20.2 218.801 -19 214.001 -21.8 214.801C-23.8 214.801 -50.2 226.401 -56.2 236.001C-56.2 236.001 -26.6 214.401 -20.2 218.801z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-34.6 266.401L-44.6 274.001C-44.6 274.001 -34.2 266.401 -30.6 267.601C-30.6 267.601 -37.4 278.801 -38.2 284.001C-38.2 284.001 -27.8 271.201 -22.2 271.601C-22.2 271.601 -14.6 272.001 -14.6 282.801C-14.6 282.801 -9 272.401 -5.8 272.801C-5.8 272.801 -4.6 279.201 -5.8 286.001C-5.8 286.001 -1.8 278.401 2.2 280.001C2.2 280.001 8.6 278.001 7.8 289.601C7.8 289.601 7.8 300.001 7 302.801C7 302.801 12.6 276.401 15 276.001C15 276.001 23 274.801 27.8 283.601C27.8 283.601 23.8 276.001 28.6 278.001C28.6 278.001 39.4 279.601 42.6 286.401C42.6 286.401 35.8 274.401 41.4 277.601C41.4 277.601 48.2 277.601 49.4 284.001C49.4 284.001 57.8 305.201 59.8 306.801C59.8 306.801 52.2 285.201 53.8 285.201C53.8 285.201 51.8 273.201 57 288.001C57 288.001 53.8 274.001 59.4 274.801C65 275.601 69.4 285.601 77.8 283.201C77.8 283.201 87.401 288.801 89.401 219.601L-34.6 266.401z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-29.8 173.601C-29.8 173.601 -15 167.601 25 173.601C25 173.601 32.2 174.001 39 165.201C45.8 156.401 72.6 149.201 79 151.201L88.601 157.601L89.401 158.801C89.401 158.801 101.801 169.201 102.201 176.801C102.601 184.401 87.801 232.401 78.2 248.401C68.6 264.401 59 276.801 39.8 274.401C39.8 274.401 19 270.401 -6.6 274.401C-6.6 274.401 -35.8 272.801 -38.6 264.801C-41.4 256.801 -27.4 241.601 -27.4 241.601C-27.4 241.601 -23 233.201 -24.2 218.801C-25.4 204.401 -25 176.401 -29.8 173.601z").setFill(f).setStroke(s);
f = "#e5668c";
g.createPath("M-7.8 175.601C0.6 194.001 -29 259.201 -29 259.201C-31 260.801 -16.34 266.846 -6.2 264.401C4.746 261.763 45 266.001 45 266.001C68.6 250.401 81.4 206.001 81.4 206.001C81.4 206.001 91.801 182.001 74.2 178.801C56.6 175.601 -7.8 175.601 -7.8 175.601z").setFill(f).setStroke(s);
f = "#b23259";
g.createPath("M-9.831 206.497C-6.505 193.707 -4.921 181.906 -7.8 175.601C-7.8 175.601 54.6 182.001 65.8 161.201C70.041 153.326 84.801 184.001 84.4 193.601C84.4 193.601 21.4 208.001 6.6 196.801L-9.831 206.497z").setFill(f).setStroke(s);
f = "#a5264c";
g.createPath("M-5.4 222.801C-5.4 222.801 -3.4 230.001 -5.8 234.001C-5.8 234.001 -7.4 234.801 -8.6 235.201C-8.6 235.201 -7.4 238.801 -1.4 240.401C-1.4 240.401 0.6 244.801 3 245.201C5.4 245.601 10.2 251.201 14.2 250.001C18.2 248.801 29.4 244.801 29.4 244.801C29.4 244.801 35 241.601 43.8 245.201C43.8 245.201 46.175 244.399 46.6 240.401C47.1 235.701 50.2 232.001 52.2 230.001C54.2 228.001 63.8 215.201 62.6 214.801C61.4 214.401 -5.4 222.801 -5.4 222.801z").setFill(f).setStroke(s);
f = "#ff727f"; s = "#000000";
g.createPath("M-9.8 174.401C-9.8 174.401 -12.6 196.801 -9.4 205.201C-6.2 213.601 -7 215.601 -7.8 219.601C-8.6 223.601 -4.2 233.601 1.4 239.601L13.4 241.201C13.4 241.201 28.6 237.601 37.8 240.401C37.8 240.401 46.794 241.744 50.2 226.801C50.2 226.801 55 220.401 62.2 217.601C69.4 214.801 76.6 173.201 72.6 165.201C68.6 157.201 54.2 152.801 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-8.2 249.201C-8.2 249.201 -9 247.201 -13.4 246.801C-13.4 246.801 -35.8 243.201 -44.2 230.801C-44.2 230.801 -51 225.201 -46.6 236.801C-46.6 236.801 -36.2 257.201 -29.4 260.001C-29.4 260.001 -13 264.001 -8.2 249.201z").setFill(f).setStroke(s);
f = "#cc3f4c"; s = null;
g.createPath("M71.742 185.229C72.401 177.323 74.354 168.709 72.6 165.201C66.154 152.307 49.181 157.695 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401C-9.8 174.401 -11.545 188.364 -10.705 198.376C-10.705 198.376 26.6 186.801 27.4 192.401C27.4 192.401 29 189.201 38.2 189.201C47.4 189.201 70.142 188.029 71.742 185.229z").setFill(f).setStroke(s);
s = {color: "#a51926", width: 2}; f = null;
g.createPath("M28.6 175.201C28.6 175.201 33.4 180.001 29.8 189.601C29.8 189.601 15.4 205.601 17.4 219.601").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-19.4 260.001C-19.4 260.001 -23.8 247.201 -15 254.001C-15 254.001 -10.2 256.001 -11.4 257.601C-12.6 259.201 -18.2 263.201 -19.4 260.001z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-14.36 261.201C-14.36 261.201 -17.88 250.961 -10.84 256.401C-10.84 256.401 -6.419 258.849 -7.96 259.281C-12.52 260.561 -7.96 263.121 -14.36 261.201z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-9.56 261.201C-9.56 261.201 -13.08 250.961 -6.04 256.401C-6.04 256.401 -1.665 258.711 -3.16 259.281C-6.52 260.561 -3.16 263.121 -9.56 261.201z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-2.96 261.401C-2.96 261.401 -6.48 251.161 0.56 256.601C0.56 256.601 4.943 258.933 3.441 259.481C0.48 260.561 3.441 263.321 -2.96 261.401z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M3.52 261.321C3.52 261.321 0 251.081 7.041 256.521C7.041 256.521 10.881 258.121 9.921 259.401C8.961 260.681 9.921 263.241 3.52 261.321z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M10.2 262.001C10.2 262.001 5.4 249.601 14.6 256.001C14.6 256.001 19.4 258.001 18.2 259.601C17 261.201 18.2 264.401 10.2 262.001z").setFill(f).setStroke(s);
s = {color: "#a5264c", width: 2}; f = null;
g.createPath("M-18.2 244.801C-18.2 244.801 -5 242.001 1 245.201C1 245.201 7 246.401 8.2 246.001C9.4 245.601 12.6 245.201 12.6 245.201").setFill(f).setStroke(s);
s = {color: "#a5264c", width: 2};
g.createPath("M15.8 253.601C15.8 253.601 27.8 240.001 39.8 244.401C46.816 246.974 45.8 243.601 46.6 240.801C47.4 238.001 47.6 233.801 52.6 230.801").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M33 237.601C33 237.601 29 226.801 26.2 239.601C23.4 252.401 20.2 256.001 18.6 258.801C18.6 258.801 18.6 264.001 27 263.601C27 263.601 37.8 263.201 38.2 260.401C38.6 257.601 37 246.001 33 237.601z").setFill(f).setStroke(s);
s = {color: "#a5264c", width: 2}; f = null;
g.createPath("M47 244.801C47 244.801 50.6 242.401 53 243.601").setFill(f).setStroke(s);
s = {color: "#a5264c", width: 2};
g.createPath("M53.5 228.401C53.5 228.401 56.4 223.501 61.2 222.701").setFill(f).setStroke(s);
f = "#b2b2b2"; s = null;
g.createPath("M-25.8 265.201C-25.8 265.201 -7.8 268.401 -3.4 266.801C-3.4 266.801 5.4 266.801 -3 268.801C-3 268.801 -15.8 268.801 -23.8 267.601C-23.8 267.601 -35.4 262.001 -25.8 265.201z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-11.8 172.001C-11.8 172.001 5.8 172.001 7.8 172.801C7.8 172.801 15 203.601 11.4 211.201C11.4 211.201 10.2 214.001 7.4 208.401C7.4 208.401 -11 175.601 -14.2 173.601C-17.4 171.601 -13 172.001 -11.8 172.001z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-88.9 169.301C-88.9 169.301 -80 171.001 -67.4 173.601C-67.4 173.601 -62.6 196.001 -59.4 200.801C-56.2 205.601 -59.8 205.601 -63.4 202.801C-67 200.001 -81.8 186.001 -83.8 181.601C-85.8 177.201 -88.9 169.301 -88.9 169.301z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-67.039 173.818C-67.039 173.818 -61.239 175.366 -60.23 177.581C-59.222 179.795 -61.432 183.092 -61.432 183.092C-61.432 183.092 -62.432 186.397 -63.634 184.235C-64.836 182.072 -67.708 174.412 -67.039 173.818z").setFill(f).setStroke(s);
f = "#000000"; s = null;
g.createPath("M-67 173.601C-67 173.601 -63.4 178.801 -59.8 178.801C-56.2 178.801 -55.818 178.388 -53 179.001C-48.4 180.001 -48.8 178.001 -42.2 179.201C-39.56 179.681 -37 178.801 -34.2 180.001C-31.4 181.201 -28.2 180.401 -27 178.401C-25.8 176.401 -21 172.201 -21 172.201C-21 172.201 -33.8 174.001 -36.6 174.801C-36.6 174.801 -59 176.001 -67 173.601z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-22.4 173.801C-22.4 173.801 -28.85 177.301 -29.25 179.701C-29.65 182.101 -24 185.801 -24 185.801C-24 185.801 -21.25 190.401 -20.65 188.001C-20.05 185.601 -21.6 174.201 -22.4 173.801z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-59.885 179.265C-59.885 179.265 -52.878 190.453 -52.661 179.242C-52.661 179.242 -52.104 177.984 -53.864 177.962C-59.939 177.886 -58.418 173.784 -59.885 179.265z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-52.707 179.514C-52.707 179.514 -44.786 190.701 -45.422 179.421C-45.422 179.421 -45.415 179.089 -47.168 178.936C-51.915 178.522 -51.57 174.004 -52.707 179.514z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-45.494 179.522C-45.494 179.522 -37.534 190.15 -38.203 180.484C-38.203 180.484 -38.084 179.251 -39.738 178.95C-43.63 178.244 -43.841 174.995 -45.494 179.522z").setFill(f).setStroke(s);
f = "#ffffcc"; s = {color: "#000000", width: 0.5};
g.createPath("M-38.618 179.602C-38.618 179.602 -30.718 191.163 -30.37 181.382C-30.37 181.382 -28.726 180.004 -30.472 179.782C-36.29 179.042 -35.492 174.588 -38.618 179.602z").setFill(f).setStroke(s);
f = "#e5e5b2"; s = null;
g.createPath("M-74.792 183.132L-82.45 181.601C-85.05 176.601 -87.15 170.451 -87.15 170.451C-87.15 170.451 -80.8 171.451 -68.3 174.251C-68.3 174.251 -67.424 177.569 -65.952 183.364L-74.792 183.132z").setFill(f).setStroke(s);
f = "#e5e5b2";
g.createPath("M-9.724 178.47C-11.39 175.964 -12.707 174.206 -13.357 173.8C-16.37 171.917 -12.227 172.294 -11.098 172.294C-11.098 172.294 5.473 172.294 7.356 173.047C7.356 173.047 7.88 175.289 8.564 178.68C8.564 178.68 -1.524 176.67 -9.724 178.47z").setFill(f).setStroke(s);
f = "#cc7226";
g.createPath("M43.88 40.321C71.601 44.281 97.121 8.641 98.881 -1.04C100.641 -10.72 90.521 -22.6 90.521 -22.6C91.841 -25.68 87.001 -39.76 81.721 -49C76.441 -58.24 60.54 -57.266 43 -58.24C27.16 -59.12 8.68 -35.8 7.36 -34.04C6.04 -32.28 12.2 6.001 13.52 11.721C14.84 17.441 12.2 43.841 12.2 43.841C46.44 34.741 16.16 36.361 43.88 40.321z").setFill(f).setStroke(s);
f = "#ea8e51";
g.createPath("M8.088 -33.392C6.792 -31.664 12.84 5.921 14.136 11.537C15.432 17.153 12.84 43.073 12.84 43.073C45.512 34.193 16.728 35.729 43.944 39.617C71.161 43.505 96.217 8.513 97.945 -0.992C99.673 -10.496 89.737 -22.16 89.737 -22.16C91.033 -25.184 86.281 -39.008 81.097 -48.08C75.913 -57.152 60.302 -56.195 43.08 -57.152C27.528 -58.016 9.384 -35.12 8.088 -33.392z").setFill(f).setStroke(s);
f = "#efaa7c";
g.createPath("M8.816 -32.744C7.544 -31.048 13.48 5.841 14.752 11.353C16.024 16.865 13.48 42.305 13.48 42.305C44.884 33.145 17.296 35.097 44.008 38.913C70.721 42.729 95.313 8.385 97.009 -0.944C98.705 -10.272 88.953 -21.72 88.953 -21.72C90.225 -24.688 85.561 -38.256 80.473 -47.16C75.385 -56.064 60.063 -55.125 43.16 -56.064C27.896 -56.912 10.088 -34.44 8.816 -32.744z").setFill(f).setStroke(s);
f = "#f4c6a8";
g.createPath("M9.544 -32.096C8.296 -30.432 14.12 5.761 15.368 11.169C16.616 16.577 14.12 41.537 14.12 41.537C43.556 32.497 17.864 34.465 44.072 38.209C70.281 41.953 94.409 8.257 96.073 -0.895C97.737 -10.048 88.169 -21.28 88.169 -21.28C89.417 -24.192 84.841 -37.504 79.849 -46.24C74.857 -54.976 59.824 -54.055 43.24 -54.976C28.264 -55.808 10.792 -33.76 9.544 -32.096z").setFill(f).setStroke(s);
f = "#f9e2d3";
g.createPath("M10.272 -31.448C9.048 -29.816 14.76 5.681 15.984 10.985C17.208 16.289 14.76 40.769 14.76 40.769C42.628 31.849 18.432 33.833 44.136 37.505C69.841 41.177 93.505 8.129 95.137 -0.848C96.769 -9.824 87.385 -20.84 87.385 -20.84C88.609 -23.696 84.121 -36.752 79.225 -45.32C74.329 -53.888 59.585 -52.985 43.32 -53.888C28.632 -54.704 11.496 -33.08 10.272 -31.448z").setFill(f).setStroke(s);
f = "#ffffff";
g.createPath("M44.2 36.8C69.4 40.4 92.601 8 94.201 -0.8C95.801 -9.6 86.601 -20.4 86.601 -20.4C87.801 -23.2 83.4 -36 78.6 -44.4C73.8 -52.8 59.346 -51.914 43.4 -52.8C29 -53.6 12.2 -32.4 11 -30.8C9.8 -29.2 15.4 5.6 16.6 10.8C17.8 16 15.4 40 15.4 40C40.9 31.4 19 33.2 44.2 36.8z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M90.601 2.8C90.601 2.8 62.8 10.4 51.2 8.8C51.2 8.8 35.4 2.2 26.6 24C26.6 24 23 31.2 21 33.2C19 35.2 90.601 2.8 90.601 2.8z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M94.401 0.6C94.401 0.6 65.4 12.8 55.4 12.4C55.4 12.4 39 7.8 30.6 22.4C30.6 22.4 22.2 31.6 19 33.2C19 33.2 18.6 34.8 25 30.8L35.4 36C35.4 36 50.2 45.6 59.8 29.6C59.8 29.6 63.8 18.4 63.8 16.4C63.8 14.4 85 8.8 86.601 8.4C88.201 8 94.801 3.8 94.401 0.6z").setFill(f).setStroke(s);
f = "#99cc32";
g.createPath("M47 36.514C40.128 36.514 31.755 32.649 31.755 26.4C31.755 20.152 40.128 13.887 47 13.887C53.874 13.887 59.446 18.952 59.446 25.2C59.446 31.449 53.874 36.514 47 36.514z").setFill(f).setStroke(s);
f = "#659900";
g.createPath("M43.377 19.83C38.531 20.552 33.442 22.055 33.514 21.839C35.054 17.22 41.415 13.887 47 13.887C51.296 13.887 55.084 15.865 57.32 18.875C57.32 18.875 52.004 18.545 43.377 19.83z").setFill(f).setStroke(s);
f = "#ffffff";
g.createPath("M55.4 19.6C55.4 19.6 51 16.4 51 18.6C51 18.6 54.6 23 55.4 19.6z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M45.4 27.726C42.901 27.726 40.875 25.7 40.875 23.2C40.875 20.701 42.901 18.675 45.4 18.675C47.9 18.675 49.926 20.701 49.926 23.2C49.926 25.7 47.9 27.726 45.4 27.726z").setFill(f).setStroke(s);
f = "#cc7226";
g.createPath("M-58.6 14.4C-58.6 14.4 -61.8 -6.8 -59.4 -11.2C-59.4 -11.2 -48.6 -21.2 -49 -24.8C-49 -24.8 -49.4 -42.8 -50.6 -43.6C-51.8 -44.4 -59.4 -50.4 -65.4 -44C-65.4 -44 -75.8 -26 -75 -19.6L-75 -17.6C-75 -17.6 -82.6 -18 -84.2 -16C-84.2 -16 -85.4 -10.8 -86.6 -10.4C-86.6 -10.4 -89.4 -8 -87.4 -5.2C-87.4 -5.2 -89.4 -2.8 -89 1.2L-81.4 5.2C-81.4 5.2 -79.4 19.6 -68.6 24.8C-63.764 27.129 -60.6 20.4 -58.6 14.4z").setFill(f).setStroke(s);
f = "#ffffff";
g.createPath("M-59.6 12.56C-59.6 12.56 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.48 -40.36 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.96 -59.6 12.56z").setFill(f).setStroke(s);
f = "#eb955c";
g.createPath("M-51.05 -42.61C-52.14 -43.47 -59.63 -49.24 -65.48 -43C-65.48 -43 -75.62 -25.45 -74.84 -19.21L-74.84 -17.26C-74.84 -17.26 -82.25 -17.65 -83.81 -15.7C-83.81 -15.7 -84.98 -10.63 -86.15 -10.24C-86.15 -10.24 -88.88 -7.9 -86.93 -5.17C-86.93 -5.17 -88.88 -2.83 -88.49 1.07L-81.08 4.97C-81.08 4.97 -79.13 19.01 -68.6 24.08C-63.886 26.35 -60.8 19.79 -58.85 13.94C-58.85 13.94 -61.97 -6.73 -59.63 -11.02C-59.63 -11.02 -49.1 -20.77 -49.49 -24.28C-49.49 -24.28 -49.88 -41.83 -51.05 -42.61z").setFill(f).setStroke(s);
f = "#f2b892";
g.createPath("M-51.5 -41.62C-52.48 -42.54 -59.86 -48.08 -65.56 -42C-65.56 -42 -75.44 -24.9 -74.68 -18.82L-74.68 -16.92C-74.68 -16.92 -81.9 -17.3 -83.42 -15.4C-83.42 -15.4 -84.56 -10.46 -85.7 -10.08C-85.7 -10.08 -88.36 -7.8 -86.46 -5.14C-86.46 -5.14 -88.36 -2.86 -87.98 0.94L-80.76 4.74C-80.76 4.74 -78.86 18.42 -68.6 23.36C-64.006 25.572 -61 19.18 -59.1 13.48C-59.1 13.48 -62.14 -6.66 -59.86 -10.84C-59.86 -10.84 -49.6 -20.34 -49.98 -23.76C-49.98 -23.76 -50.36 -40.86 -51.5 -41.62z").setFill(f).setStroke(s);
f = "#f8dcc8";
g.createPath("M-51.95 -40.63C-52.82 -41.61 -60.09 -46.92 -65.64 -41C-65.64 -41 -75.26 -24.35 -74.52 -18.43L-74.52 -16.58C-74.52 -16.58 -81.55 -16.95 -83.03 -15.1C-83.03 -15.1 -84.14 -10.29 -85.25 -9.92C-85.25 -9.92 -87.84 -7.7 -85.99 -5.11C-85.99 -5.11 -87.84 -2.89 -87.47 0.81L-80.44 4.51C-80.44 4.51 -78.59 17.83 -68.6 22.64C-64.127 24.794 -61.2 18.57 -59.35 13.02C-59.35 13.02 -62.31 -6.59 -60.09 -10.66C-60.09 -10.66 -50.1 -19.91 -50.47 -23.24C-50.47 -23.24 -50.84 -39.89 -51.95 -40.63z").setFill(f).setStroke(s);
f = "#ffffff";
g.createPath("M-59.6 12.46C-59.6 12.46 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.16 -40.68 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.86 -59.6 12.46z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-62.7 6.2C-62.7 6.2 -84.3 -4 -85.2 -4.8C-85.2 -4.8 -76.1 3.4 -75.3 3.4C-74.5 3.4 -62.7 6.2 -62.7 6.2z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-79.8 0C-79.8 0 -61.4 3.6 -61.4 8C-61.4 10.912 -61.643 24.331 -67 22.8C-75.4 20.4 -71.8 6 -79.8 0z").setFill(f).setStroke(s);
f = "#99cc32";
g.createPath("M-71.4 3.8C-71.4 3.8 -62.422 5.274 -61.4 8C-60.8 9.6 -60.137 17.908 -65.6 19C-70.152 19.911 -72.382 9.69 -71.4 3.8z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M14.595 46.349C14.098 44.607 15.409 44.738 17.2 44.2C19.2 43.6 31.4 39.8 32.2 37.2C33 34.6 46.2 39 46.2 39C48 39.8 52.4 42.4 52.4 42.4C57.2 43.6 63.8 44 63.8 44C66.2 45 69.6 47.8 69.6 47.8C84.2 58 96.601 50.8 96.601 50.8C116.601 44.2 110.601 27 110.601 27C107.601 18 110.801 14.6 110.801 14.6C111.001 10.8 118.201 17.2 118.201 17.2C120.801 21.4 121.601 26.4 121.601 26.4C129.601 37.6 126.201 19.8 126.201 19.8C126.401 18.8 123.601 15.2 123.601 14C123.601 12.8 121.801 9.4 121.801 9.4C118.801 6 121.201 -1 121.201 -1C123.001 -14.8 120.801 -13 120.801 -13C119.601 -14.8 110.401 -4.8 110.401 -4.8C108.201 -1.4 102.201 0.2 102.201 0.2C99.401 2 96.001 0.6 96.001 0.6C93.401 0.2 87.801 7.2 87.801 7.2C90.601 7 93.001 11.4 95.401 11.6C97.801 11.8 99.601 9.2 101.201 8.6C102.801 8 105.601 13.8 105.601 13.8C106.001 16.4 100.401 21.2 100.401 21.2C100.001 25.8 98.401 24.2 98.401 24.2C95.401 23.6 94.201 27.4 93.201 32C92.201 36.6 88.001 37 88.001 37C86.401 44.4 85.2 41.4 85.2 41.4C85 35.8 79 41.6 79 41.6C77.8 43.6 73.2 41.4 73.2 41.4C66.4 39.4 68.8 37.4 68.8 37.4C70.6 35.2 81.8 37.4 81.8 37.4C84 35.8 76 31.8 76 31.8C75.4 30 76.4 25.6 76.4 25.6C77.6 22.4 84.4 16.8 84.4 16.8C93.801 15.6 91.001 14 91.001 14C84.801 8.8 79 16.4 79 16.4C76.8 22.6 59.4 37.6 59.4 37.6C54.6 41 57.2 34.2 53.2 37.6C49.2 41 28.6 32 28.6 32C17.038 30.807 14.306 46.549 10.777 43.429C10.777 43.429 16.195 51.949 14.595 46.349z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M209.401 -120C209.401 -120 183.801 -112 181.001 -93.2C181.001 -93.2 178.601 -70.4 199.001 -52.8C199.001 -52.8 199.401 -46.4 201.401 -43.2C201.401 -43.2 199.801 -38.4 218.601 -46L245.801 -54.4C245.801 -54.4 252.201 -56.8 257.401 -65.6C262.601 -74.4 277.801 -93.2 274.201 -118.4C274.201 -118.4 275.401 -129.6 269.401 -130C269.401 -130 261.001 -131.6 253.801 -124C253.801 -124 247.001 -120.8 244.601 -121.2L209.401 -120z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M264.022 -120.99C264.022 -120.99 266.122 -129.92 261.282 -125.08C261.282 -125.08 254.242 -119.36 246.761 -119.36C246.761 -119.36 232.241 -117.16 227.841 -103.96C227.841 -103.96 223.881 -77.12 231.801 -71.4C231.801 -71.4 236.641 -63.92 243.681 -70.52C250.722 -77.12 266.222 -107.35 264.022 -120.99z").setFill(f).setStroke(s);
f = "#323232";
g.createPath("M263.648 -120.632C263.648 -120.632 265.738 -129.376 260.986 -124.624C260.986 -124.624 254.074 -119.008 246.729 -119.008C246.729 -119.008 232.473 -116.848 228.153 -103.888C228.153 -103.888 224.265 -77.536 232.041 -71.92C232.041 -71.92 236.793 -64.576 243.705 -71.056C250.618 -77.536 265.808 -107.24 263.648 -120.632z").setFill(f).setStroke(s);
f = "#666666";
g.createPath("M263.274 -120.274C263.274 -120.274 265.354 -128.832 260.69 -124.168C260.69 -124.168 253.906 -118.656 246.697 -118.656C246.697 -118.656 232.705 -116.536 228.465 -103.816C228.465 -103.816 224.649 -77.952 232.281 -72.44C232.281 -72.44 236.945 -65.232 243.729 -71.592C250.514 -77.952 265.394 -107.13 263.274 -120.274z").setFill(f).setStroke(s);
f = "#999999";
g.createPath("M262.9 -119.916C262.9 -119.916 264.97 -128.288 260.394 -123.712C260.394 -123.712 253.738 -118.304 246.665 -118.304C246.665 -118.304 232.937 -116.224 228.777 -103.744C228.777 -103.744 225.033 -78.368 232.521 -72.96C232.521 -72.96 237.097 -65.888 243.753 -72.128C250.41 -78.368 264.98 -107.02 262.9 -119.916z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M262.526 -119.558C262.526 -119.558 264.586 -127.744 260.098 -123.256C260.098 -123.256 253.569 -117.952 246.633 -117.952C246.633 -117.952 233.169 -115.912 229.089 -103.672C229.089 -103.672 225.417 -78.784 232.761 -73.48C232.761 -73.48 237.249 -66.544 243.777 -72.664C250.305 -78.784 264.566 -106.91 262.526 -119.558z").setFill(f).setStroke(s);
f = "#ffffff";
g.createPath("M262.151 -119.2C262.151 -119.2 264.201 -127.2 259.801 -122.8C259.801 -122.8 253.401 -117.6 246.601 -117.6C246.601 -117.6 233.401 -115.6 229.401 -103.6C229.401 -103.6 225.801 -79.2 233.001 -74C233.001 -74 237.401 -67.2 243.801 -73.2C250.201 -79.2 264.151 -106.8 262.151 -119.2z").setFill(f).setStroke(s);
f = "#992600";
g.createPath("M50.6 84C50.6 84 30.2 64.8 22.2 64C22.2 64 -12.2 60 -27 78C-27 78 -9.4 57.6 18.2 63.2C18.2 63.2 -3.4 58.8 -15.8 62C-15.8 62 -32.6 62 -42.2 76L-45 80.8C-45 80.8 -41 66 -22.6 60C-22.6 60 0.2 55.2 11 60C11 60 -10.6 53.2 -20.6 55.2C-20.6 55.2 -51 52.8 -63.8 79.2C-63.8 79.2 -59.8 64.8 -45 57.6C-45 57.6 -31.4 48.8 -11 51.6C-11 51.6 3.4 54.8 8.6 57.2C13.8 59.6 12.6 56.8 4.2 52C4.2 52 -1.4 42 -15.4 42.4C-15.4 42.4 -58.2 46 -68.6 58C-68.6 58 -55 46.8 -44.6 44C-44.6 44 -22.2 36 -13.8 36.8C-13.8 36.8 11 37.8 18.6 33.8C18.6 33.8 7.4 38.8 10.6 42C13.8 45.2 20.6 52.8 20.6 54C20.6 55.2 44.8 77.3 48.4 81.7L50.6 84z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M189 278C189 278 173.5 241.5 161 232C161 232 187 248 190.5 266C190.5 266 190.5 276 189 278z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M236 285.5C236 285.5 209.5 230.5 191 206.5C191 206.5 234.5 244 239.5 270.5L240 276L237 273.5C237 273.5 236.5 282.5 236 285.5z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M292.5 237C292.5 237 230 177.5 228.5 175C228.5 175 289 241 292 248.5C292 248.5 290 239.5 292.5 237z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M104 280.5C104 280.5 123.5 228.5 142.5 251C142.5 251 157.5 261 157 264C157 264 153 257.5 135 258C135 258 116 255 104 280.5z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M294.5 153C294.5 153 249.5 124.5 242 123C230.193 120.639 291.5 152 296.5 162.5C296.5 162.5 298.5 160 294.5 153z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M143.801 259.601C143.801 259.601 164.201 257.601 171.001 250.801L175.401 254.401L193.001 216.001L196.601 221.201C196.601 221.201 211.001 206.401 210.201 198.401C209.401 190.401 223.001 204.401 223.001 204.401C223.001 204.401 222.201 192.801 229.401 199.601C229.401 199.601 227.001 184.001 235.401 192.001C235.401 192.001 224.864 161.844 247.401 187.601C253.001 194.001 248.601 187.201 248.601 187.201C248.601 187.201 222.601 139.201 244.201 153.601C244.201 153.601 246.201 130.801 245.001 126.401C243.801 122.001 241.801 99.6 237.001 94.4C232.201 89.2 237.401 87.6 243.001 92.8C243.001 92.8 231.801 68.8 245.001 80.8C245.001 80.8 241.401 65.6 237.001 62.8C237.001 62.8 231.401 45.6 246.601 56.4C246.601 56.4 242.201 44 239.001 40.8C239.001 40.8 227.401 13.2 234.601 18L239.001 21.6C239.001 21.6 232.201 7.6 238.601 12C245.001 16.4 245.001 16 245.001 16C245.001 16 223.801 -17.2 244.201 0.4C244.201 0.4 236.042 -13.518 232.601 -20.4C232.601 -20.4 213.801 -40.8 228.201 -34.4L233.001 -32.8C233.001 -32.8 224.201 -42.8 216.201 -44.4C208.201 -46 218.601 -52.4 225.001 -50.4C231.401 -48.4 247.001 -40.8 247.001 -40.8C247.001 -40.8 259.801 -22 263.801 -21.6C263.801 -21.6 243.801 -29.2 249.801 -21.2C249.801 -21.2 264.201 -7.2 257.001 -7.6C257.001 -7.6 251.001 -0.4 255.801 8.4C255.801 8.4 237.342 -9.991 252.201 15.6L259.001 32C259.001 32 234.601 7.2 245.801 29.2C245.801 29.2 263.001 52.8 265.001 53.2C267.001 53.6 271.401 62.4 271.401 62.4L267.001 60.4L272.201 69.2C272.201 69.2 261.001 57.2 267.001 70.4L272.601 84.8C272.601 84.8 252.201 62.8 265.801 92.4C265.801 92.4 249.401 87.2 258.201 104.4C258.201 104.4 256.601 120.401 257.001 125.601C257.401 130.801 258.601 159.201 254.201 167.201C249.801 175.201 260.201 194.401 262.201 198.401C264.201 202.401 267.801 213.201 259.001 204.001C250.201 194.801 254.601 200.401 256.601 209.201C258.601 218.001 264.601 233.601 263.801 239.201C263.801 239.201 262.601 240.401 259.401 236.801C259.401 236.801 244.601 214.001 246.201 228.401C246.201 228.401 245.001 236.401 241.801 245.201C241.801 245.201 238.601 256.001 238.601 247.201C238.601 247.201 235.401 230.401 232.601 238.001C229.801 245.601 226.201 251.601 223.401 254.001C220.601 256.401 215.401 233.601 214.201 244.001C214.201 244.001 202.201 231.601 197.401 248.001L185.801 264.401C185.801 264.401 185.401 252.001 184.201 258.001C184.201 258.001 154.201 264.001 143.801 259.601z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M109.401 -97.2C109.401 -97.2 97.801 -105.2 93.801 -104.8C89.801 -104.4 121.401 -113.6 162.601 -86C162.601 -86 167.401 -83.2 171.001 -83.6C171.001 -83.6 174.201 -81.2 171.401 -77.6C171.401 -77.6 162.601 -68 173.801 -56.8C173.801 -56.8 192.201 -50 186.601 -58.8C186.601 -58.8 197.401 -54.8 199.801 -50.8C202.201 -46.8 201.001 -50.8 201.001 -50.8C201.001 -50.8 194.601 -58 188.601 -63.2C188.601 -63.2 183.401 -65.2 180.601 -73.6C177.801 -82 175.401 -92 179.801 -95.2C179.801 -95.2 175.801 -90.8 176.601 -94.8C177.401 -98.8 181.001 -102.4 182.601 -102.8C184.201 -103.2 200.601 -119 207.401 -119.4C207.401 -119.4 198.201 -118 195.201 -119C192.201 -120 165.601 -131.4 159.601 -132.6C159.601 -132.6 142.801 -139.2 154.801 -137.2C154.801 -137.2 190.601 -133.4 208.801 -120.2C208.801 -120.2 201.601 -128.6 183.201 -135.6C183.201 -135.6 161.001 -148.2 125.801 -143.2C125.801 -143.2 108.001 -140 100.201 -138.2C100.201 -138.2 97.601 -138.8 97.001 -139.2C96.401 -139.6 84.6 -148.6 57 -141.6C57 -141.6 40 -137 31.4 -132.2C31.4 -132.2 16.2 -131 12.6 -127.8C12.6 -127.8 -6 -113.2 -8 -112.4C-10 -111.6 -21.4 -104 -22.2 -103.6C-22.2 -103.6 2.4 -110.2 4.8 -112.6C7.2 -115 24.6 -117.6 27 -116.2C29.4 -114.8 37.8 -115.4 28.2 -114.8C28.2 -114.8 103.801 -100 104.601 -98C105.401 -96 109.401 -97.2 109.401 -97.2z").setFill(f).setStroke(s);
f = "#cc7226";
g.createPath("M180.801 -106.4C180.801 -106.4 170.601 -113.8 168.601 -113.8C166.601 -113.8 154.201 -124 150.001 -123.6C145.801 -123.2 133.601 -133.2 106.201 -125C106.201 -125 105.601 -127 109.201 -127.8C109.201 -127.8 115.601 -130 116.001 -130.6C116.001 -130.6 136.201 -134.8 143.401 -131.2C143.401 -131.2 152.601 -128.6 158.801 -122.4C158.801 -122.4 170.001 -119.2 173.201 -120.2C173.201 -120.2 182.001 -118 182.401 -116.2C182.401 -116.2 188.201 -113.2 186.401 -110.6C186.401 -110.6 186.801 -109 180.801 -106.4z").setFill(f).setStroke(s);
f = "#cc7226";
g.createPath("M168.33 -108.509C169.137 -107.877 170.156 -107.779 170.761 -106.97C170.995 -106.656 170.706 -106.33 170.391 -106.233C169.348 -105.916 168.292 -106.486 167.15 -105.898C166.748 -105.691 166.106 -105.873 165.553 -106.022C163.921 -106.463 162.092 -106.488 160.401 -105.8C158.416 -106.929 156.056 -106.345 153.975 -107.346C153.917 -107.373 153.695 -107.027 153.621 -107.054C150.575 -108.199 146.832 -107.916 144.401 -110.2C141.973 -110.612 139.616 -111.074 137.188 -111.754C135.37 -112.263 133.961 -113.252 132.341 -114.084C130.964 -114.792 129.507 -115.314 127.973 -115.686C126.11 -116.138 124.279 -116.026 122.386 -116.546C122.293 -116.571 122.101 -116.227 122.019 -116.254C121.695 -116.362 121.405 -116.945 121.234 -116.892C119.553 -116.37 118.065 -117.342 116.401 -117C115.223 -118.224 113.495 -117.979 111.949 -118.421C108.985 -119.269 105.831 -117.999 102.801 -119C106.914 -120.842 111.601 -119.61 115.663 -121.679C117.991 -122.865 120.653 -121.763 123.223 -122.523C123.71 -122.667 124.401 -122.869 124.801 -122.2C124.935 -122.335 125.117 -122.574 125.175 -122.546C127.625 -121.389 129.94 -120.115 132.422 -119.049C132.763 -118.903 133.295 -119.135 133.547 -118.933C135.067 -117.717 137.01 -117.82 138.401 -116.6C140.099 -117.102 141.892 -116.722 143.621 -117.346C143.698 -117.373 143.932 -117.032 143.965 -117.054C145.095 -117.802 146.25 -117.531 147.142 -117.227C147.48 -117.112 148.143 -116.865 148.448 -116.791C149.574 -116.515 150.43 -116.035 151.609 -115.852C151.723 -115.834 151.908 -116.174 151.98 -116.146C153.103 -115.708 154.145 -115.764 154.801 -114.6C154.936 -114.735 155.101 -114.973 155.183 -114.946C156.21 -114.608 156.859 -113.853 157.96 -113.612C158.445 -113.506 159.057 -112.88 159.633 -112.704C162.025 -111.973 163.868 -110.444 166.062 -109.549C166.821 -109.239 167.697 -109.005 168.33 -108.509z").setFill(f).setStroke(s);
f = "#cc7226";
g.createPath("M91.696 -122.739C89.178 -124.464 86.81 -125.57 84.368 -127.356C84.187 -127.489 83.827 -127.319 83.625 -127.441C82.618 -128.05 81.73 -128.631 80.748 -129.327C80.209 -129.709 79.388 -129.698 78.88 -129.956C76.336 -131.248 73.707 -131.806 71.2 -133C71.882 -133.638 73.004 -133.394 73.6 -134.2C73.795 -133.92 74.033 -133.636 74.386 -133.827C76.064 -134.731 77.914 -134.884 79.59 -134.794C81.294 -134.702 83.014 -134.397 84.789 -134.125C85.096 -134.078 85.295 -133.555 85.618 -133.458C87.846 -132.795 90.235 -133.32 92.354 -132.482C93.945 -131.853 95.515 -131.03 96.754 -129.755C97.006 -129.495 96.681 -129.194 96.401 -129C96.789 -129.109 97.062 -128.903 97.173 -128.59C97.257 -128.351 97.257 -128.049 97.173 -127.81C97.061 -127.498 96.782 -127.397 96.408 -127.346C95.001 -127.156 96.773 -128.536 96.073 -128.088C94.8 -127.274 95.546 -125.868 94.801 -124.6C94.521 -124.794 94.291 -125.012 94.401 -125.4C94.635 -124.878 94.033 -124.588 93.865 -124.272C93.48 -123.547 92.581 -122.132 91.696 -122.739z").setFill(f).setStroke(s);
f = "#cc7226";
g.createPath("M59.198 -115.391C56.044 -116.185 52.994 -116.07 49.978 -117.346C49.911 -117.374 49.688 -117.027 49.624 -117.054C48.258 -117.648 47.34 -118.614 46.264 -119.66C45.351 -120.548 43.693 -120.161 42.419 -120.648C42.095 -120.772 41.892 -121.284 41.591 -121.323C40.372 -121.48 39.445 -122.429 38.4 -123C40.736 -123.795 43.147 -123.764 45.609 -124.148C45.722 -124.166 45.867 -123.845 46 -123.845C46.136 -123.845 46.266 -124.066 46.4 -124.2C46.595 -123.92 46.897 -123.594 47.154 -123.848C47.702 -124.388 48.258 -124.198 48.798 -124.158C48.942 -124.148 49.067 -123.845 49.2 -123.845C49.336 -123.845 49.467 -124.156 49.6 -124.156C49.736 -124.155 49.867 -123.845 50 -123.845C50.136 -123.845 50.266 -124.066 50.4 -124.2C51.092 -123.418 51.977 -123.972 52.799 -123.793C53.837 -123.566 54.104 -122.418 55.178 -122.12C59.893 -120.816 64.03 -118.671 68.393 -116.584C68.7 -116.437 68.91 -116.189 68.8 -115.8C69.067 -115.8 69.38 -115.888 69.57 -115.756C70.628 -115.024 71.669 -114.476 72.366 -113.378C72.582 -113.039 72.253 -112.632 72.02 -112.684C67.591 -113.679 63.585 -114.287 59.198 -115.391z").setFill(f).setStroke(s);
f = "#cc7226";
g.createPath("M45.338 -71.179C43.746 -72.398 43.162 -74.429 42.034 -76.221C41.82 -76.561 42.094 -76.875 42.411 -76.964C42.971 -77.123 43.514 -76.645 43.923 -76.443C45.668 -75.581 47.203 -74.339 49.2 -74.2C51.19 -71.966 55.45 -71.581 55.457 -68.2C55.458 -67.341 54.03 -68.259 53.6 -67.4C51.149 -68.403 48.76 -68.3 46.38 -69.767C45.763 -70.148 46.093 -70.601 45.338 -71.179z").setFill(f).setStroke(s);
f = "#cc7226";
g.createPath("M17.8 -123.756C17.935 -123.755 24.966 -123.522 24.949 -123.408C24.904 -123.099 17.174 -122.05 16.81 -122.22C16.646 -122.296 9.134 -119.866 9 -120C9.268 -120.135 17.534 -123.756 17.8 -123.756z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M33.2 -114C33.2 -114 18.4 -112.2 14 -111C9.6 -109.8 -9 -102.2 -12 -100.2C-12 -100.2 -25.4 -94.8 -42.4 -74.8C-42.4 -74.8 -34.8 -78.2 -32.6 -81C-32.6 -81 -19 -93.6 -19.2 -91C-19.2 -91 -7 -99.6 -7.6 -97.4C-7.6 -97.4 16.8 -108.6 14.8 -105.4C14.8 -105.4 36.4 -110 35.4 -108C35.4 -108 54.2 -103.6 51.4 -103.4C51.4 -103.4 45.6 -102.2 52 -98.6C52 -98.6 48.6 -94.2 43.2 -98.2C37.8 -102.2 40.8 -100 35.8 -99C35.8 -99 33.2 -98.2 28.6 -102.2C28.6 -102.2 23 -106.8 14.2 -103.2C14.2 -103.2 -16.4 -90.6 -18.4 -90C-18.4 -90 -22 -87.2 -24.4 -83.6C-24.4 -83.6 -30.2 -79.2 -33.2 -77.8C-33.2 -77.8 -46 -66.2 -47.2 -64.8C-47.2 -64.8 -50.6 -59.6 -51.4 -59.2C-51.4 -59.2 -45 -63 -43 -65C-43 -65 -29 -75 -23.6 -75.8C-23.6 -75.8 -19.2 -78.8 -18.4 -80.2C-18.4 -80.2 -4 -89.4 0.2 -89.4C0.2 -89.4 9.4 -84.2 11.8 -91.2C11.8 -91.2 17.6 -93 23.2 -91.8C23.2 -91.8 26.4 -94.4 25.6 -96.6C25.6 -96.6 27.2 -98.4 28.2 -94.6C28.2 -94.6 31.6 -91 36.4 -93C36.4 -93 40.4 -93.2 38.4 -90.8C38.4 -90.8 34 -87 22.2 -86.8C22.2 -86.8 9.8 -86.2 -6.6 -78.6C-6.6 -78.6 -36.4 -68.2 -45.6 -57.8C-45.6 -57.8 -52 -49 -57.4 -47.8C-57.4 -47.8 -63.2 -47 -69.2 -39.6C-69.2 -39.6 -59.4 -45.4 -50.4 -45.4C-50.4 -45.4 -46.4 -47.8 -50.2 -44.2C-50.2 -44.2 -53.8 -36.6 -52.2 -31.2C-52.2 -31.2 -52.8 -26 -53.6 -24.4C-53.6 -24.4 -61.4 -11.6 -61.4 -9.2C-61.4 -6.8 -60.2 3 -59.8 3.6C-59.4 4.2 -60.8 2 -57 4.4C-53.2 6.8 -50.4 8.4 -49.6 11.2C-48.8 14 -51.6 5.8 -51.8 4C-52 2.2 -56.2 -5 -55.4 -7.4C-55.4 -7.4 -54.4 -6.4 -53.6 -5C-53.6 -5 -54.2 -5.6 -53.6 -9.2C-53.6 -9.2 -52.8 -14.4 -51.4 -17.6C-50 -20.8 -48 -24.6 -47.6 -25.4C-47.2 -26.2 -47.2 -32 -45.8 -29.4L-42.4 -26.8C-42.4 -26.8 -45.2 -29.4 -43 -31.6C-43 -31.6 -44 -37.2 -42.2 -39.8C-42.2 -39.8 -35.2 -48.2 -33.6 -49.2C-32 -50.2 -33.4 -49.8 -33.4 -49.8C-33.4 -49.8 -27.4 -54 -33.2 -52.4C-33.2 -52.4 -37.2 -50.8 -40.2 -50.8C-40.2 -50.8 -47.8 -48.8 -43.8 -53C-39.8 -57.2 -29.8 -62.6 -26 -62.4L-25.2 -60.8L-14 -63.2L-15.2 -62.4C-15.2 -62.4 -15.4 -62.6 -11.2 -63C-7 -63.4 -1.2 -62 0.2 -63.8C1.6 -65.6 5 -66.6 4.6 -65.2C4.2 -63.8 4 -61.8 4 -61.8C4 -61.8 9 -67.6 8.4 -65.4C7.8 -63.2 -0.4 -58 -1.8 -51.8L8.6 -60L12.2 -63C12.2 -63 15.8 -60.8 16 -62.4C16.2 -64 20.8 -69.8 22 -69.6C23.2 -69.4 25.2 -72.2 25 -69.6C24.8 -67 32.4 -61.6 32.4 -61.6C32.4 -61.6 35.6 -63.4 37 -62C38.4 -60.6 42.6 -81.8 42.6 -81.8L67.6 -92.4L111.201 -95.8L94.201 -102.6L33.2 -114z").setFill(f).setStroke(s);
s = {color: "#4c0000", width: 2}; f = null;
g.createPath("M51.4 85C51.4 85 36.4 68.2 28 65.6C28 65.6 14.6 58.8 -10 66.6").setFill(f).setStroke(s);
s = {color: "#4c0000", width: 2};
g.createPath("M24.8 64.2C24.8 64.2 -0.4 56.2 -15.8 60.4C-15.8 60.4 -34.2 62.4 -42.6 76.2").setFill(f).setStroke(s);
s = {color: "#4c0000", width: 2};
g.createPath("M21.2 63C21.2 63 4.2 55.8 -10.6 53.6C-10.6 53.6 -27.2 51 -43.8 58.2C-43.8 58.2 -56 64.2 -61.4 74.4").setFill(f).setStroke(s);
s = {color: "#4c0000", width: 2};
g.createPath("M22.2 63.4C22.2 63.4 6.8 52.4 5.8 51C5.8 51 -1.2 40 -14.2 39.6C-14.2 39.6 -35.6 40.4 -52.8 48.4").setFill(f).setStroke(s);
f = "#000000"; s = null;
g.createPath("M20.895 54.407C22.437 55.87 49.4 84.8 49.4 84.8C84.6 121.401 56.6 87.2 56.6 87.2C49 82.4 39.8 63.6 39.8 63.6C38.6 60.8 53.8 70.8 53.8 70.8C57.8 71.6 71.4 90.8 71.4 90.8C64.6 88.4 69.4 95.6 69.4 95.6C72.2 97.6 92.601 113.201 92.601 113.201C96.201 117.201 100.201 118.801 100.201 118.801C114.201 113.601 107.801 126.801 107.801 126.801C110.201 133.601 115.801 122.001 115.801 122.001C127.001 105.2 110.601 107.601 110.601 107.601C80.6 110.401 73.8 94.4 73.8 94.4C71.4 92 80.2 94.4 80.2 94.4C88.601 96.4 73 82 73 82C75.4 82 84.6 88.8 84.6 88.8C95.001 98 97.001 96 97.001 96C115.001 87.2 125.401 94.8 125.401 94.8C127.401 96.4 121.801 103.2 123.401 108.401C125.001 113.601 129.801 126.001 129.801 126.001C127.401 127.601 127.801 138.401 127.801 138.401C144.601 161.601 135.001 159.601 135.001 159.601C119.401 159.201 134.201 166.801 134.201 166.801C137.401 168.801 146.201 176.001 146.201 176.001C143.401 174.801 141.801 180.001 141.801 180.001C146.601 184.001 143.801 188.801 143.801 188.801C137.801 190.001 136.601 194.001 136.601 194.001C143.401 202.001 133.401 202.401 133.401 202.401C137.001 206.801 132.201 218.801 132.201 218.801C127.401 218.801 121.001 224.401 121.001 224.401C123.401 229.201 113.001 234.801 113.001 234.801C104.601 236.401 107.401 243.201 107.401 243.201C99.401 249.201 97.001 265.201 97.001 265.201C96.201 275.601 93.801 278.801 99.001 276.801C104.201 274.801 103.401 262.401 103.401 262.401C98.601 246.801 141.401 230.801 141.401 230.801C145.401 229.201 146.201 224.001 146.201 224.001C148.201 224.401 157.001 232.001 157.001 232.001C164.601 243.201 165.001 234.001 165.001 234.001C166.201 230.401 164.601 224.401 164.601 224.401C170.601 202.801 156.601 196.401 156.601 196.401C146.601 162.801 160.601 171.201 160.601 171.201C163.401 176.801 174.201 182.001 174.201 182.001L177.801 179.601C176.201 174.801 184.601 168.801 184.601 168.801C187.401 175.201 193.401 167.201 193.401 167.201C197.001 142.801 209.401 157.201 209.401 157.201C213.401 158.401 214.601 151.601 214.601 151.601C218.201 141.201 214.601 127.601 214.601 127.601C218.201 127.201 227.801 133.201 227.801 133.201C230.601 129.601 221.401 112.801 225.401 115.201C229.401 117.601 233.801 119.201 233.801 119.201C234.601 117.201 224.601 104.801 224.601 104.801C220.201 102 215.001 81.6 215.001 81.6C222.201 85.2 212.201 70 212.201 70C212.201 66.8 218.201 55.6 218.201 55.6C217.401 48.8 218.201 49.2 218.201 49.2C221.001 50.4 229.001 52 222.201 45.6C215.401 39.2 223.001 34.4 223.001 34.4C227.401 31.6 213.801 32 213.801 32C208.601 27.6 209.001 23.6 209.001 23.6C217.001 25.6 202.601 11.2 200.201 7.6C197.801 4 207.401 -1.2 207.401 -1.2C220.601 -4.8 209.001 -8 209.001 -8C189.401 -7.6 200.201 -18.4 200.201 -18.4C206.201 -18 204.601 -20.4 204.601 -20.4C199.401 -21.6 189.801 -28 189.801 -28C185.801 -31.6 189.401 -30.8 189.401 -30.8C206.201 -29.6 177.401 -40.8 177.401 -40.8C185.401 -40.8 167.401 -51.2 167.401 -51.2C165.401 -52.8 162.201 -60.4 162.201 -60.4C156.201 -65.6 151.401 -72.4 151.401 -72.4C151.001 -76.8 146.201 -81.6 146.201 -81.6C134.601 -95.2 129.001 -94.8 129.001 -94.8C114.201 -98.4 109.001 -97.6 109.001 -97.6L56.2 -93.2C29.8 -80.4 37.6 -59.4 37.6 -59.4C44 -51 53.2 -54.8 53.2 -54.8C57.8 -61 69.4 -58.8 69.4 -58.8C89.801 -55.6 87.201 -59.2 87.201 -59.2C84.801 -63.8 68.6 -70 68.4 -70.6C68.2 -71.2 59.4 -74.6 59.4 -74.6C56.4 -75.8 52 -85 52 -85C48.8 -88.4 64.6 -82.6 64.6 -82.6C63.4 -81.6 70.8 -77.6 70.8 -77.6C88.201 -78.6 98.801 -67.8 98.801 -67.8C109.601 -51.2 109.801 -59.4 109.801 -59.4C112.601 -68.8 100.801 -90 100.801 -90C101.201 -92 109.401 -85.4 109.401 -85.4C110.801 -87.4 111.601 -81.6 111.601 -81.6C111.801 -79.2 115.601 -71.2 115.601 -71.2C118.401 -58.2 122.001 -65.6 122.001 -65.6L126.601 -56.2C128.001 -53.6 122.001 -46 122.001 -46C121.801 -43.2 122.601 -43.4 117.001 -35.8C111.401 -28.2 114.801 -23.8 114.801 -23.8C113.401 -17.2 122.201 -17.6 122.201 -17.6C124.801 -15.4 128.201 -15.4 128.201 -15.4C130.001 -13.4 132.401 -14 132.401 -14C134.001 -17.8 140.201 -15.8 140.201 -15.8C141.601 -18.2 149.801 -18.6 149.801 -18.6C150.801 -21.2 151.201 -22.8 154.601 -23.4C158.001 -24 133.401 -67 133.401 -67C139.801 -67.8 131.601 -80.2 131.601 -80.2C129.401 -86.8 140.801 -72.2 143.001 -70.8C145.201 -69.4 146.201 -67.2 144.601 -67.4C143.001 -67.6 141.201 -65.4 142.601 -65.2C144.001 -65 157.001 -50 160.401 -39.8C163.801 -29.6 169.801 -25.6 176.001 -19.6C182.201 -13.6 181.401 10.6 181.401 10.6C181.001 19.4 187.001 30 187.001 30C189.001 33.8 184.801 52 184.801 52C182.801 54.2 184.201 55 184.201 55C185.201 56.2 192.001 69.4 192.001 69.4C190.201 69.2 193.801 72.8 193.801 72.8C199.001 78.8 192.601 75.8 192.601 75.8C186.601 74.2 193.601 84 193.601 84C194.801 85.8 185.801 81.2 185.801 81.2C176.601 80.6 188.201 87.8 188.201 87.8C196.801 95 185.401 90.6 185.401 90.6C180.801 88.8 184.001 95.6 184.001 95.6C187.201 97.2 204.401 104.2 204.401 104.2C204.801 108.001 201.801 113.001 201.801 113.001C202.201 117.001 200.001 120.401 200.001 120.401C198.801 128.601 198.201 129.401 198.201 129.401C194.001 129.601 186.601 143.401 186.601 143.401C184.801 146.001 174.601 158.001 174.601 158.001C172.601 165.001 154.601 157.801 154.601 157.801C148.001 161.201 150.001 157.801 150.001 157.801C149.601 155.601 154.401 149.601 154.401 149.601C161.401 147.001 158.801 136.201 158.801 136.201C162.801 134.801 151.601 132.001 151.801 130.801C152.001 129.601 157.801 128.201 157.801 128.201C165.801 126.201 161.401 123.801 161.401 123.801C160.801 119.801 163.801 114.201 163.801 114.201C175.401 113.401 163.801 97.2 163.801 97.2C153.001 89.6 152.001 83.8 152.001 83.8C164.601 75.6 156.401 63.2 156.601 59.6C156.801 56 158.001 34.4 158.001 34.4C156.001 28.2 153.001 14.6 153.001 14.6C155.201 9.4 162.601 -3.2 162.601 -3.2C165.401 -7.4 174.201 -12.2 172.001 -15.2C169.801 -18.2 162.001 -16.4 162.001 -16.4C154.201 -17.8 154.801 -12.6 154.801 -12.6C153.201 -11.6 152.401 -6.6 152.401 -6.6C151.68 1.333 142.801 7.6 142.801 7.6C131.601 13.8 140.801 17.8 140.801 17.8C146.801 24.4 137.001 24.6 137.001 24.6C126.001 22.8 134.201 33 134.201 33C145.001 45.8 142.001 48.6 142.001 48.6C131.801 49.6 144.401 58.8 144.401 58.8C144.401 58.8 143.601 56.8 143.801 58.6C144.001 60.4 147.001 64.6 147.801 66.6C148.601 68.6 144.601 68.8 144.601 68.8C145.201 78.4 129.801 74.2 129.801 74.2C129.801 74.2 129.801 74.2 128.201 74.4C126.601 74.6 115.401 73.8 109.601 71.6C103.801 69.4 97.001 69.4 97.001 69.4C97.001 69.4 93.001 71.2 85.4 71C77.8 70.8 69.8 73.6 69.8 73.6C65.4 73.2 74 68.8 74.2 69C74.4 69.2 80 63.6 72 64.2C50.203 65.835 39.4 55.6 39.4 55.6C37.4 54.2 34.8 51.4 34.8 51.4C24.8 49.4 36.2 63.8 36.2 63.8C37.4 65.2 36 66.2 36 66.2C35.2 64.6 27.4 59.2 27.4 59.2C24.589 58.227 23.226 56.893 20.895 54.407z").setFill(f).setStroke(s);
f = "#4c0000";
g.createPath("M-3 42.8C-3 42.8 8.6 48.4 11.2 51.2C13.8 54 27.8 65.4 27.8 65.4C27.8 65.4 22.4 63.4 19.8 61.6C17.2 59.8 6.4 51.6 6.4 51.6C6.4 51.6 2.6 45.6 -3 42.8z").setFill(f).setStroke(s);
f = "#99cc32";
g.createPath("M-61.009 11.603C-60.672 11.455 -61.196 8.743 -61.4 8.2C-62.422 5.474 -71.4 4 -71.4 4C-71.627 5.365 -71.682 6.961 -71.576 8.599C-71.576 8.599 -66.708 14.118 -61.009 11.603z").setFill(f).setStroke(s);
f = "#659900";
g.createPath("M-61.009 11.403C-61.458 11.561 -61.024 8.669 -61.2 8.2C-62.222 5.474 -71.4 3.9 -71.4 3.9C-71.627 5.265 -71.682 6.861 -71.576 8.499C-71.576 8.499 -67.308 13.618 -61.009 11.403z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-65.4 11.546C-66.025 11.546 -66.531 10.406 -66.531 9C-66.531 7.595 -66.025 6.455 -65.4 6.455C-64.775 6.455 -64.268 7.595 -64.268 9C-64.268 10.406 -64.775 11.546 -65.4 11.546z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-65.4 9z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-111 109.601C-111 109.601 -116.6 119.601 -91.8 113.601C-91.8 113.601 -77.8 112.401 -75.4 110.001C-74.2 110.801 -65.834 113.734 -63 114.401C-56.2 116.001 -47.8 106 -47.8 106C-47.8 106 -43.2 95.5 -40.4 95.5C-37.6 95.5 -40.8 97.1 -40.8 97.1C-40.8 97.1 -47.4 107.201 -47 108.801C-47 108.801 -52.2 128.801 -68.2 129.601C-68.2 129.601 -84.35 130.551 -83 136.401C-83 136.401 -74.2 134.001 -71.8 136.401C-71.8 136.401 -61 136.001 -69 142.401L-75.8 154.001C-75.8 154.001 -75.66 157.919 -85.8 154.401C-95.6 151.001 -105.9 138.101 -105.9 138.101C-105.9 138.101 -121.85 123.551 -111 109.601z").setFill(f).setStroke(s);
f = "#e59999";
g.createPath("M-112.2 113.601C-112.2 113.601 -114.2 123.201 -77.4 112.801C-77.4 112.801 -73 112.801 -70.6 113.601C-68.2 114.401 -56.2 117.201 -54.2 116.001C-54.2 116.001 -61.4 129.601 -73 128.001C-73 128.001 -86.2 129.601 -85.8 134.401C-85.8 134.401 -81.8 141.601 -77 144.001C-77 144.001 -74.2 146.401 -74.6 149.601C-75 152.801 -77.8 154.401 -79.8 155.201C-81.8 156.001 -85 152.801 -86.6 152.801C-88.2 152.801 -96.6 146.401 -101 141.601C-105.4 136.801 -113.8 124.801 -113.4 122.001C-113 119.201 -112.2 113.601 -112.2 113.601z").setFill(f).setStroke(s);
f = "#b26565";
g.createPath("M-109 131.051C-106.4 135.001 -103.2 139.201 -101 141.601C-96.6 146.401 -88.2 152.801 -86.6 152.801C-85 152.801 -81.8 156.001 -79.8 155.201C-77.8 154.401 -75 152.801 -74.6 149.601C-74.2 146.401 -77 144.001 -77 144.001C-80.066 142.468 -82.806 138.976 -84.385 136.653C-84.385 136.653 -84.2 139.201 -89.4 138.401C-94.6 137.601 -99.8 134.801 -101.4 131.601C-103 128.401 -105.4 126.001 -103.8 129.601C-102.2 133.201 -99.8 136.801 -98.2 137.201C-96.6 137.601 -97 138.801 -99.4 138.401C-101.8 138.001 -104.6 137.601 -109 132.401z").setFill(f).setStroke(s);
f = "#992600";
g.createPath("M-111.6 110.001C-111.6 110.001 -109.8 96.4 -108.6 92.4C-108.6 92.4 -109.4 85.6 -107 81.4C-104.6 77.2 -102.6 71 -99.6 65.6C-96.6 60.2 -96.4 56.2 -92.4 54.6C-88.4 53 -82.4 44.4 -79.6 43.4C-76.8 42.4 -77 43.2 -77 43.2C-77 43.2 -70.2 28.4 -56.6 32.4C-56.6 32.4 -72.8 29.6 -57 20.2C-57 20.2 -61.8 21.3 -58.5 14.3C-56.299 9.632 -56.8 16.4 -67.8 28.2C-67.8 28.2 -72.8 36.8 -78 39.8C-83.2 42.8 -95.2 49.8 -96.4 53.6C-97.6 57.4 -100.8 63.2 -102.8 64.8C-104.8 66.4 -107.6 70.6 -108 74C-108 74 -109.2 78 -110.6 79.2C-112 80.4 -112.2 83.6 -112.2 85.6C-112.2 87.6 -114.2 90.4 -114 92.8C-114 92.8 -113.2 111.801 -113.6 113.801L-111.6 110.001z").setFill(f).setStroke(s);
f = "#ffffff";
g.createPath("M-120.2 114.601C-120.2 114.601 -122.2 113.201 -126.6 119.201C-126.6 119.201 -119.3 152.201 -119.3 153.601C-119.3 153.601 -118.2 151.501 -119.5 144.301C-120.8 137.101 -121.7 124.401 -121.7 124.401L-120.2 114.601z").setFill(f).setStroke(s);
f = "#992600";
g.createPath("M-98.6 54C-98.6 54 -116.2 57.2 -115.8 86.4L-116.6 111.201C-116.6 111.201 -117.8 85.6 -119 84C-120.2 82.4 -116.2 71.2 -119.4 77.2C-119.4 77.2 -133.4 91.2 -125.4 112.401C-125.4 112.401 -123.9 115.701 -126.9 111.101C-126.9 111.101 -131.5 98.5 -130.4 92.1C-130.4 92.1 -130.2 89.9 -128.3 87.1C-128.3 87.1 -119.7 75.4 -117 73.1C-117 73.1 -115.2 58.7 -99.8 53.5C-99.8 53.5 -94.1 51.2 -98.6 54z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M40.8 -12.2C41.46 -12.554 41.451 -13.524 42.031 -13.697C43.18 -14.041 43.344 -15.108 43.862 -15.892C44.735 -17.211 44.928 -18.744 45.51 -20.235C45.782 -20.935 45.809 -21.89 45.496 -22.55C44.322 -25.031 43.62 -27.48 42.178 -29.906C41.91 -30.356 41.648 -31.15 41.447 -31.748C40.984 -33.132 39.727 -34.123 38.867 -35.443C38.579 -35.884 39.104 -36.809 38.388 -36.893C37.491 -36.998 36.042 -37.578 35.809 -36.552C35.221 -33.965 36.232 -31.442 37.2 -29C36.418 -28.308 36.752 -27.387 36.904 -26.62C37.614 -23.014 36.416 -19.662 35.655 -16.188C35.632 -16.084 35.974 -15.886 35.946 -15.824C34.724 -13.138 33.272 -10.693 31.453 -8.312C30.695 -7.32 29.823 -6.404 29.326 -5.341C28.958 -4.554 28.55 -3.588 28.8 -2.6C25.365 0.18 23.115 4.025 20.504 7.871C20.042 8.551 20.333 9.76 20.884 10.029C21.697 10.427 22.653 9.403 23.123 8.557C23.512 7.859 23.865 7.209 24.356 6.566C24.489 6.391 24.31 5.972 24.445 5.851C27.078 3.504 28.747 0.568 31.2 -1.8C33.15 -2.129 34.687 -3.127 36.435 -4.14C36.743 -4.319 37.267 -4.07 37.557 -4.265C39.31 -5.442 39.308 -7.478 39.414 -9.388C39.464 -10.272 39.66 -11.589 40.8 -12.2z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M31.959 -16.666C32.083 -16.743 31.928 -17.166 32.037 -17.382C32.199 -17.706 32.602 -17.894 32.764 -18.218C32.873 -18.434 32.71 -18.814 32.846 -18.956C35.179 -21.403 35.436 -24.427 34.4 -27.4C35.424 -28.02 35.485 -29.282 35.06 -30.129C34.207 -31.829 34.014 -33.755 33.039 -35.298C32.237 -36.567 30.659 -37.811 29.288 -36.508C28.867 -36.108 28.546 -35.321 28.824 -34.609C28.888 -34.446 29.173 -34.3 29.146 -34.218C29.039 -33.894 28.493 -33.67 28.487 -33.398C28.457 -31.902 27.503 -30.391 28.133 -29.062C28.905 -27.433 29.724 -25.576 30.4 -23.8C29.166 -21.684 30.199 -19.235 28.446 -17.358C28.31 -17.212 28.319 -16.826 28.441 -16.624C28.733 -16.138 29.139 -15.732 29.625 -15.44C29.827 -15.319 30.175 -15.317 30.375 -15.441C30.953 -15.803 31.351 -16.29 31.959 -16.666z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M94.771 -26.977C96.16 -25.185 96.45 -22.39 94.401 -21C94.951 -17.691 98.302 -19.67 100.401 -20.2C100.292 -20.588 100.519 -20.932 100.802 -20.937C101.859 -20.952 102.539 -21.984 103.601 -21.8C104.035 -23.357 105.673 -24.059 106.317 -25.439C108.043 -29.134 107.452 -33.407 104.868 -36.653C104.666 -36.907 104.883 -37.424 104.759 -37.786C104.003 -39.997 101.935 -40.312 100.001 -41C98.824 -44.875 98.163 -48.906 96.401 -52.6C94.787 -52.85 94.089 -54.589 92.752 -55.309C91.419 -56.028 90.851 -54.449 90.892 -53.403C90.899 -53.198 91.351 -52.974 91.181 -52.609C91.105 -52.445 90.845 -52.334 90.845 -52.2C90.846 -52.065 91.067 -51.934 91.201 -51.8C90.283 -50.98 88.86 -50.503 88.565 -49.358C87.611 -45.648 90.184 -42.523 91.852 -39.322C92.443 -38.187 91.707 -36.916 90.947 -35.708C90.509 -35.013 90.617 -33.886 90.893 -33.03C91.645 -30.699 93.236 -28.96 94.771 -26.977z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M57.611 -8.591C56.124 -6.74 52.712 -4.171 55.629 -2.243C55.823 -2.114 56.193 -2.11 56.366 -2.244C58.387 -3.809 60.39 -4.712 62.826 -5.294C62.95 -5.323 63.224 -4.856 63.593 -5.017C65.206 -5.72 67.216 -5.662 68.4 -7C72.167 -6.776 75.732 -7.892 79.123 -9.2C80.284 -9.648 81.554 -10.207 82.755 -10.709C84.131 -11.285 85.335 -12.213 86.447 -13.354C86.58 -13.49 86.934 -13.4 87.201 -13.4C87.161 -14.263 88.123 -14.39 88.37 -15.012C88.462 -15.244 88.312 -15.64 88.445 -15.742C90.583 -17.372 91.503 -19.39 90.334 -21.767C90.049 -22.345 89.8 -22.963 89.234 -23.439C88.149 -24.35 87.047 -23.496 86 -23.8C85.841 -23.172 85.112 -23.344 84.726 -23.146C83.867 -22.707 82.534 -23.292 81.675 -22.854C80.313 -22.159 79.072 -21.99 77.65 -21.613C77.338 -21.531 76.56 -21.627 76.4 -21C76.266 -21.134 76.118 -21.368 76.012 -21.346C74.104 -20.95 72.844 -20.736 71.543 -19.044C71.44 -18.911 70.998 -19.09 70.839 -18.955C69.882 -18.147 69.477 -16.913 68.376 -16.241C68.175 -16.118 67.823 -16.286 67.629 -16.157C66.983 -15.726 66.616 -15.085 65.974 -14.638C65.645 -14.409 65.245 -14.734 65.277 -14.99C65.522 -16.937 66.175 -18.724 65.6 -20.6C67.677 -23.12 70.194 -25.069 72 -27.8C72.015 -29.966 72.707 -32.112 72.594 -34.189C72.584 -34.382 72.296 -35.115 72.17 -35.462C71.858 -36.316 72.764 -37.382 71.92 -38.106C70.516 -39.309 69.224 -38.433 68.4 -37C66.562 -36.61 64.496 -35.917 62.918 -37.151C61.911 -37.938 61.333 -38.844 60.534 -39.9C59.549 -41.202 59.884 -42.638 59.954 -44.202C59.96 -44.33 59.645 -44.466 59.645 -44.6C59.646 -44.735 59.866 -44.866 60 -45C59.294 -45.626 59.019 -46.684 58 -47C58.305 -48.092 57.629 -48.976 56.758 -49.278C54.763 -49.969 53.086 -48.057 51.194 -47.984C50.68 -47.965 50.213 -49.003 49.564 -49.328C49.132 -49.544 48.428 -49.577 48.066 -49.311C47.378 -48.807 46.789 -48.693 46.031 -48.488C44.414 -48.052 43.136 -46.958 41.656 -46.103C40.171 -45.246 39.216 -43.809 38.136 -42.489C37.195 -41.337 37.059 -38.923 38.479 -38.423C40.322 -37.773 41.626 -40.476 43.592 -40.15C43.904 -40.099 44.11 -39.788 44 -39.4C44.389 -39.291 44.607 -39.52 44.8 -39.8C45.658 -38.781 46.822 -38.444 47.76 -37.571C48.73 -36.667 50.476 -37.085 51.491 -36.088C53.02 -34.586 52.461 -31.905 54.4 -30.6C53.814 -29.287 53.207 -28.01 52.872 -26.583C52.59 -25.377 53.584 -24.18 54.795 -24.271C56.053 -24.365 56.315 -25.124 56.8 -26.2C57.067 -25.933 57.536 -25.636 57.495 -25.42C57.038 -23.033 56.011 -21.04 55.553 -18.609C55.494 -18.292 55.189 -18.09 54.8 -18.2C54.332 -14.051 50.28 -11.657 47.735 -8.492C47.332 -7.99 47.328 -6.741 47.737 -6.338C49.14 -4.951 51.1 -6.497 52.8 -7C53.013 -8.206 53.872 -9.148 55.204 -9.092C55.46 -9.082 55.695 -9.624 56.019 -9.754C56.367 -9.892 56.869 -9.668 57.155 -9.866C58.884 -11.061 60.292 -12.167 62.03 -13.356C62.222 -13.487 62.566 -13.328 62.782 -13.436C63.107 -13.598 63.294 -13.985 63.617 -14.17C63.965 -14.37 64.207 -14.08 64.4 -13.8C63.754 -13.451 63.75 -12.494 63.168 -12.292C62.393 -12.024 61.832 -11.511 61.158 -11.064C60.866 -10.871 60.207 -11.119 60.103 -10.94C59.505 -9.912 58.321 -9.474 57.611 -8.591z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M2.2 -58C2.2 -58 -7.038 -60.872 -18.2 -35.2C-18.2 -35.2 -20.6 -30 -23 -28C-25.4 -26 -36.6 -22.4 -38.6 -18.4L-49 -2.4C-49 -2.4 -34.2 -18.4 -31 -20.8C-31 -20.8 -23 -29.2 -26.2 -22.4C-26.2 -22.4 -40.2 -11.6 -39 -2.4C-39 -2.4 -44.6 12 -45.4 14C-45.4 14 -29.4 -18 -27 -19.2C-24.6 -20.4 -23.4 -20.4 -24.6 -16.8C-25.8 -13.2 -26.2 3.2 -29 5.2C-29 5.2 -21 -15.2 -21.8 -18.4C-21.8 -18.4 -18.6 -22 -16.2 -16.8L-17.4 -0.8L-13 11.2C-13 11.2 -15.4 0 -13.8 -15.6C-13.8 -15.6 -15.8 -26 -11.8 -20.4C-7.8 -14.8 1.8 -8.8 1.8 -4C1.8 -4 -3.4 -21.6 -12.6 -26.4L-16.6 -20.4L-17.8 -22.4C-17.8 -22.4 -21.4 -23.2 -17 -30C-12.6 -36.8 -13 -37.6 -13 -37.6C-13 -37.6 -6.6 -30.4 -5 -30.4C-5 -30.4 8.2 -38 9.4 -13.6C9.4 -13.6 16.2 -28 7 -34.8C7 -34.8 -7.8 -36.8 -6.6 -42L0.6 -54.4C4.2 -59.6 2.6 -56.8 2.6 -56.8z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-17.8 -41.6C-17.8 -41.6 -30.6 -41.6 -33.8 -36.4L-41 -26.8C-41 -26.8 -23.8 -36.8 -19.8 -38C-15.8 -39.2 -17.8 -41.6 -17.8 -41.6z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-57.8 -35.2C-57.8 -35.2 -59.8 -34 -60.2 -31.2C-60.6 -28.4 -63 -28 -62.2 -25.2C-61.4 -22.4 -59.4 -20 -59.4 -24C-59.4 -28 -57.8 -30 -57 -31.2C-56.2 -32.4 -54.6 -36.8 -57.8 -35.2z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-66.6 26C-66.6 26 -75 22 -78.2 18.4C-81.4 14.8 -80.948 19.966 -85.8 19.6C-91.647 19.159 -90.6 3.2 -90.6 3.2L-94.6 10.8C-94.6 10.8 -95.8 25.2 -87.8 22.8C-83.893 21.628 -82.6 23.2 -84.2 24C-85.8 24.8 -78.6 25.2 -81.4 26.8C-84.2 28.4 -69.8 23.2 -72.2 33.6L-66.6 26z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-79.2 40.4C-79.2 40.4 -94.6 44.8 -98.2 35.2C-98.2 35.2 -103 37.6 -100.8 40.6C-98.6 43.6 -97.4 44 -97.4 44C-97.4 44 -92 45.2 -92.6 46C-93.2 46.8 -95.6 50.2 -95.6 50.2C-95.6 50.2 -85.4 44.2 -79.2 40.4z").setFill(f).setStroke(s);
f = "#ffffff";
g.createPath("M149.201 118.601C148.774 120.735 147.103 121.536 145.201 122.201C143.284 121.243 140.686 118.137 138.801 120.201C138.327 119.721 137.548 119.661 137.204 118.999C136.739 118.101 137.011 117.055 136.669 116.257C136.124 114.985 135.415 113.619 135.601 112.201C137.407 111.489 138.002 109.583 137.528 107.82C137.459 107.563 137.03 107.366 137.23 107.017C137.416 106.694 137.734 106.467 138.001 106.2C137.866 106.335 137.721 106.568 137.61 106.548C137 106.442 137.124 105.805 137.254 105.418C137.839 103.672 139.853 103.408 141.201 104.6C141.457 104.035 141.966 104.229 142.401 104.2C142.351 103.621 142.759 103.094 142.957 102.674C143.475 101.576 145.104 102.682 145.901 102.07C146.977 101.245 148.04 100.546 149.118 101.149C150.927 102.162 152.636 103.374 153.835 105.115C154.41 105.949 154.65 107.23 154.592 108.188C154.554 108.835 153.173 108.483 152.83 109.412C152.185 111.16 154.016 111.679 154.772 113.017C154.97 113.366 154.706 113.67 154.391 113.768C153.98 113.896 153.196 113.707 153.334 114.16C154.306 117.353 151.55 118.031 149.201 118.601z").setFill(f).setStroke(s);
f = "#ffffff";
g.createPath("M139.6 138.201C139.593 136.463 137.992 134.707 139.201 133.001C139.336 133.135 139.467 133.356 139.601 133.356C139.736 133.356 139.867 133.135 140.001 133.001C141.496 135.217 145.148 136.145 145.006 138.991C144.984 139.438 143.897 140.356 144.801 141.001C142.988 142.349 142.933 144.719 142.001 146.601C140.763 146.315 139.551 145.952 138.401 145.401C138.753 143.915 138.636 142.231 139.456 140.911C139.89 140.213 139.603 139.134 139.6 138.201z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-26.6 129.201C-26.6 129.201 -43.458 139.337 -29.4 124.001C-20.6 114.401 -10.6 108.801 -10.6 108.801C-10.6 108.801 -0.2 104.4 3.4 103.2C7 102 22.2 96.8 25.4 96.4C28.6 96 38.2 92 45 96C51.8 100 59.8 104.4 59.8 104.4C59.8 104.4 43.4 96 39.8 98.4C36.2 100.8 29 100.4 23 103.6C23 103.6 8.2 108.001 5 110.001C1.8 112.001 -8.6 123.601 -10.2 122.801C-11.8 122.001 -9.8 121.601 -8.6 118.801C-7.4 116.001 -9.4 114.401 -17.4 120.801C-25.4 127.201 -26.6 129.201 -26.6 129.201z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-19.195 123.234C-19.195 123.234 -17.785 110.194 -9.307 111.859C-9.307 111.859 -1.081 107.689 1.641 105.721C1.641 105.721 9.78 104.019 11.09 103.402C29.569 94.702 44.288 99.221 44.835 98.101C45.381 96.982 65.006 104.099 68.615 108.185C69.006 108.628 58.384 102.588 48.686 100.697C40.413 99.083 18.811 100.944 7.905 106.48C4.932 107.989 -4.013 113.773 -6.544 113.662C-9.075 113.55 -19.195 123.234 -19.195 123.234z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-23 148.801C-23 148.801 -38.2 146.401 -21.4 144.801C-21.4 144.801 -3.4 142.801 0.6 137.601C0.6 137.601 14.2 128.401 17 128.001C19.8 127.601 49.8 120.401 50.2 118.001C50.6 115.601 56.2 115.601 57.8 116.401C59.4 117.201 58.6 118.401 55.8 119.201C53 120.001 21.8 136.401 15.4 137.601C9 138.801 -2.6 146.401 -7.4 147.601C-12.2 148.801 -23 148.801 -23 148.801z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-3.48 141.403C-3.48 141.403 -12.062 140.574 -3.461 139.755C-3.461 139.755 5.355 136.331 7.403 133.668C7.403 133.668 14.367 128.957 15.8 128.753C17.234 128.548 31.194 124.861 31.399 123.633C31.604 122.404 65.67 109.823 70.09 113.013C73.001 115.114 63.1 113.437 53.466 117.847C52.111 118.467 18.258 133.054 14.981 133.668C11.704 134.283 5.765 138.174 3.307 138.788C0.85 139.403 -3.48 141.403 -3.48 141.403z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-11.4 143.601C-11.4 143.601 -6.2 143.201 -7.4 144.801C-8.6 146.401 -11 145.601 -11 145.601L-11.4 143.601z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-18.6 145.201C-18.6 145.201 -13.4 144.801 -14.6 146.401C-15.8 148.001 -18.2 147.201 -18.2 147.201L-18.6 145.201z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-29 146.801C-29 146.801 -23.8 146.401 -25 148.001C-26.2 149.601 -28.6 148.801 -28.6 148.801L-29 146.801z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-36.6 147.601C-36.6 147.601 -31.4 147.201 -32.6 148.801C-33.8 150.401 -36.2 149.601 -36.2 149.601L-36.6 147.601z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M1.8 108.001C1.8 108.001 6.2 108.001 5 109.601C3.8 111.201 0.6 110.801 0.6 110.801L1.8 108.001z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-8.2 113.601C-8.2 113.601 -1.694 111.46 -4.2 114.801C-5.4 116.401 -7.8 115.601 -7.8 115.601L-8.2 113.601z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-19.4 118.401C-19.4 118.401 -14.2 118.001 -15.4 119.601C-16.6 121.201 -19 120.401 -19 120.401L-19.4 118.401z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-27 124.401C-27 124.401 -21.8 124.001 -23 125.601C-24.2 127.201 -26.6 126.401 -26.6 126.401L-27 124.401z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-33.8 129.201C-33.8 129.201 -28.6 128.801 -29.8 130.401C-31 132.001 -33.4 131.201 -33.4 131.201L-33.8 129.201z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M5.282 135.598C5.282 135.598 12.203 135.066 10.606 137.195C9.009 139.325 5.814 138.26 5.814 138.26L5.282 135.598z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M15.682 130.798C15.682 130.798 22.603 130.266 21.006 132.395C19.409 134.525 16.214 133.46 16.214 133.46L15.682 130.798z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M26.482 126.398C26.482 126.398 33.403 125.866 31.806 127.995C30.209 130.125 27.014 129.06 27.014 129.06L26.482 126.398z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M36.882 121.598C36.882 121.598 43.803 121.066 42.206 123.195C40.609 125.325 37.414 124.26 37.414 124.26L36.882 121.598z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M9.282 103.598C9.282 103.598 16.203 103.066 14.606 105.195C13.009 107.325 9.014 107.06 9.014 107.06L9.282 103.598z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M19.282 100.398C19.282 100.398 26.203 99.866 24.606 101.995C23.009 104.125 18.614 103.86 18.614 103.86L19.282 100.398z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-3.4 140.401C-3.4 140.401 1.8 140.001 0.6 141.601C-0.6 143.201 -3 142.401 -3 142.401L-3.4 140.401z").setFill(f).setStroke(s);
f = "#992600";
g.createPath("M-76.6 41.2C-76.6 41.2 -81 50 -81.4 53.2C-81.4 53.2 -80.6 44.4 -79.4 42.4C-78.2 40.4 -76.6 41.2 -76.6 41.2z").setFill(f).setStroke(s);
f = "#992600";
g.createPath("M-95 55.2C-95 55.2 -98.2 69.6 -97.8 72.4C-97.8 72.4 -99 60.8 -98.6 59.6C-98.2 58.4 -95 55.2 -95 55.2z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-74.2 -19.4L-74.4 -16.2L-76.6 -16C-76.6 -16 -62.4 -3.4 -61.8 4.2C-61.8 4.2 -61 -4 -74.2 -19.4z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-70.216 -18.135C-70.647 -18.551 -70.428 -19.296 -70.836 -19.556C-71.645 -20.072 -69.538 -20.129 -69.766 -20.845C-70.149 -22.051 -69.962 -22.072 -70.084 -23.348C-70.141 -23.946 -69.553 -25.486 -69.168 -25.926C-67.722 -27.578 -69.046 -30.51 -67.406 -32.061C-67.102 -32.35 -66.726 -32.902 -66.441 -33.32C-65.782 -34.283 -64.598 -34.771 -63.648 -35.599C-63.33 -35.875 -63.531 -36.702 -62.962 -36.61C-62.248 -36.495 -61.007 -36.625 -61.052 -35.784C-61.165 -33.664 -62.494 -31.944 -63.774 -30.276C-63.323 -29.572 -63.781 -28.937 -64.065 -28.38C-65.4 -25.76 -65.211 -22.919 -65.385 -20.079C-65.39 -19.994 -65.697 -19.916 -65.689 -19.863C-65.336 -17.528 -64.752 -15.329 -63.873 -13.1C-63.507 -12.17 -63.036 -11.275 -62.886 -10.348C-62.775 -9.662 -62.672 -8.829 -63.08 -8.124C-61.045 -5.234 -62.354 -2.583 -61.185 0.948C-60.978 1.573 -59.286 3.487 -59.749 3.326C-62.262 2.455 -62.374 2.057 -62.551 1.304C-62.697 0.681 -63.027 -0.696 -63.264 -1.298C-63.328 -1.462 -63.499 -3.346 -63.577 -3.468C-65.09 -5.85 -63.732 -5.674 -65.102 -8.032C-66.53 -8.712 -67.496 -9.816 -68.619 -10.978C-68.817 -11.182 -67.674 -11.906 -67.855 -12.119C-68.947 -13.408 -70.1 -14.175 -69.764 -15.668C-69.609 -16.358 -69.472 -17.415 -70.216 -18.135z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-73.8 -16.4C-73.8 -16.4 -73.4 -9.6 -71 -8C-68.6 -6.4 -69.8 -7.2 -73 -8.4C-76.2 -9.6 -75 -10.4 -75 -10.4C-75 -10.4 -77.8 -10 -75.4 -8C-73 -6 -69.4 -3.6 -71 -3.6C-72.6 -3.6 -80.2 -7.6 -80.2 -10.4C-80.2 -13.2 -81.2 -17.3 -81.2 -17.3C-81.2 -17.3 -80.1 -18.1 -75.3 -18C-75.3 -18 -73.9 -17.3 -73.8 -16.4z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-74.6 2.2C-74.6 2.2 -83.12 -0.591 -101.6 2.8C-101.6 2.8 -92.569 0.722 -73.8 3C-63.5 4.25 -74.6 2.2 -74.6 2.2z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-72.502 2.129C-72.502 2.129 -80.748 -1.389 -99.453 0.392C-99.453 0.392 -90.275 -0.897 -71.774 2.995C-61.62 5.131 -72.502 2.129 -72.502 2.129z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-70.714 2.222C-70.714 2.222 -78.676 -1.899 -97.461 -1.514C-97.461 -1.514 -88.213 -2.118 -70.052 3.14C-60.086 6.025 -70.714 2.222 -70.714 2.222z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-69.444 2.445C-69.444 2.445 -76.268 -1.862 -93.142 -2.96C-93.142 -2.96 -84.803 -2.79 -68.922 3.319C-60.206 6.672 -69.444 2.445 -69.444 2.445z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M45.84 12.961C45.84 12.961 44.91 13.605 45.124 12.424C45.339 11.243 73.547 -1.927 77.161 -1.677C77.161 -1.677 46.913 11.529 45.84 12.961z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M42.446 13.6C42.446 13.6 41.57 14.315 41.691 13.121C41.812 11.927 68.899 -3.418 72.521 -3.452C72.521 -3.452 43.404 12.089 42.446 13.6z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M39.16 14.975C39.16 14.975 38.332 15.747 38.374 14.547C38.416 13.348 58.233 -2.149 68.045 -4.023C68.045 -4.023 50.015 4.104 39.16 14.975z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M36.284 16.838C36.284 16.838 35.539 17.532 35.577 16.453C35.615 15.373 53.449 1.426 62.28 -0.26C62.28 -0.26 46.054 7.054 36.284 16.838z").setFill(f).setStroke(s);
f = "#cccccc"; s = null;
g.createPath("M4.6 164.801C4.6 164.801 -10.6 162.401 6.2 160.801C6.2 160.801 24.2 158.801 28.2 153.601C28.2 153.601 41.8 144.401 44.6 144.001C47.4 143.601 63.8 140.001 64.2 137.601C64.6 135.201 70.6 132.801 72.2 133.601C73.8 134.401 73.8 143.601 71 144.401C68.2 145.201 49.4 152.401 43 153.601C36.6 154.801 25 162.401 20.2 163.601C15.4 164.801 4.6 164.801 4.6 164.801z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M77.6 127.401C77.6 127.401 74.6 129.001 73.4 131.601C73.4 131.601 67 142.201 52.8 145.401C52.8 145.401 29.8 154.401 22 156.401C22 156.401 8.6 161.401 1.2 160.601C1.2 160.601 -5.8 160.801 0.4 162.401C0.4 162.401 20.6 160.401 24 158.601C24 158.601 39.6 153.401 42.6 150.801C45.6 148.201 63.8 143.201 66 141.201C68.2 139.201 78 130.801 77.6 127.401z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M18.882 158.911C18.882 158.911 24.111 158.685 22.958 160.234C21.805 161.784 19.357 160.91 19.357 160.91L18.882 158.911z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M11.68 160.263C11.68 160.263 16.908 160.037 15.756 161.586C14.603 163.136 12.155 162.263 12.155 162.263L11.68 160.263z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M1.251 161.511C1.251 161.511 6.48 161.284 5.327 162.834C4.174 164.383 1.726 163.51 1.726 163.51L1.251 161.511z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-6.383 162.055C-6.383 162.055 -1.154 161.829 -2.307 163.378C-3.46 164.928 -5.908 164.054 -5.908 164.054L-6.383 162.055z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M35.415 151.513C35.415 151.513 42.375 151.212 40.84 153.274C39.306 155.336 36.047 154.174 36.047 154.174L35.415 151.513z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M45.73 147.088C45.73 147.088 51.689 143.787 51.155 148.849C50.885 151.405 46.362 149.749 46.362 149.749L45.73 147.088z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M54.862 144.274C54.862 144.274 62.021 140.573 60.287 146.035C59.509 148.485 55.493 146.935 55.493 146.935L54.862 144.274z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M64.376 139.449C64.376 139.449 68.735 134.548 69.801 141.21C70.207 143.748 65.008 142.11 65.008 142.11L64.376 139.449z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M26.834 155.997C26.834 155.997 32.062 155.77 30.91 157.32C29.757 158.869 27.308 157.996 27.308 157.996L26.834 155.997z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M62.434 34.603C62.434 34.603 61.708 35.268 61.707 34.197C61.707 33.127 79.191 19.863 88.034 18.479C88.034 18.479 71.935 25.208 62.434 34.603z").setFill(f).setStroke(s);
f = "#000000"; s = null;
g.createPath("M65.4 98.4C65.4 98.4 87.401 120.801 96.601 124.401C96.601 124.401 105.801 135.601 101.801 161.601C101.801 161.601 98.601 169.201 95.401 148.401C95.401 148.401 98.601 123.201 87.401 139.201C87.401 139.201 79 129.301 85.4 129.601C85.4 129.601 88.601 131.601 89.001 130.001C89.401 128.401 81.4 114.801 64.2 100.4C47 86 65.4 98.4 65.4 98.4z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M7 137.201C7 137.201 6.8 135.401 8.6 136.201C10.4 137.001 104.601 143.201 136.201 167.201C136.201 167.201 91.001 144.001 7 137.201z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M17.4 132.801C17.4 132.801 17.2 131.001 19 131.801C20.8 132.601 157.401 131.601 181.001 164.001C181.001 164.001 159.001 138.801 17.4 132.801z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M29 128.801C29 128.801 28.8 127.001 30.6 127.801C32.4 128.601 205.801 115.601 229.401 148.001C229.401 148.001 219.801 122.401 29 128.801z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M39 124.001C39 124.001 38.8 122.201 40.6 123.001C42.4 123.801 164.601 85.2 188.201 117.601C188.201 117.601 174.801 93 39 124.001z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-19 146.801C-19 146.801 -19.2 145.001 -17.4 145.801C-15.6 146.601 2.2 148.801 4.2 187.601C4.2 187.601 -3 145.601 -19 146.801z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-27.8 148.401C-27.8 148.401 -28 146.601 -26.2 147.401C-24.4 148.201 -10.2 143.601 -13 182.401C-13 182.401 -11.8 147.201 -27.8 148.401z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-35.8 148.801C-35.8 148.801 -36 147.001 -34.2 147.801C-32.4 148.601 -17 149.201 -29.4 171.601C-29.4 171.601 -19.8 147.601 -35.8 148.801z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M11.526 104.465C11.526 104.465 11.082 106.464 12.631 105.247C28.699 92.622 61.141 33.72 116.826 28.086C116.826 28.086 78.518 15.976 11.526 104.465z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M22.726 102.665C22.726 102.665 21.363 101.472 23.231 100.847C25.099 100.222 137.541 27.72 176.826 35.686C176.826 35.686 149.719 28.176 22.726 102.665z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M1.885 108.767C1.885 108.767 1.376 110.366 3.087 109.39C12.062 104.27 15.677 47.059 59.254 45.804C59.254 45.804 26.843 31.09 1.885 108.767z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-18.038 119.793C-18.038 119.793 -19.115 121.079 -17.162 120.825C-6.916 119.493 14.489 78.222 58.928 83.301C58.928 83.301 26.962 68.955 -18.038 119.793z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-6.8 113.667C-6.8 113.667 -7.611 115.136 -5.742 114.511C4.057 111.237 17.141 66.625 61.729 63.078C61.729 63.078 27.603 55.135 -6.8 113.667z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-25.078 124.912C-25.078 124.912 -25.951 125.954 -24.369 125.748C-16.07 124.669 1.268 91.24 37.264 95.354C37.264 95.354 11.371 83.734 -25.078 124.912z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-32.677 130.821C-32.677 130.821 -33.682 131.866 -32.091 131.748C-27.923 131.439 2.715 98.36 21.183 113.862C21.183 113.862 9.168 95.139 -32.677 130.821z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M36.855 98.898C36.855 98.898 35.654 97.543 37.586 97.158C39.518 96.774 160.221 39.061 198.184 51.927C198.184 51.927 172.243 41.053 36.855 98.898z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M3.4 163.201C3.4 163.201 3.2 161.401 5 162.201C6.8 163.001 22.2 163.601 9.8 186.001C9.8 186.001 19.4 162.001 3.4 163.201z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M13.8 161.601C13.8 161.601 13.6 159.801 15.4 160.601C17.2 161.401 35 163.601 37 202.401C37 202.401 29.8 160.401 13.8 161.601z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M20.6 160.001C20.6 160.001 20.4 158.201 22.2 159.001C24 159.801 48.6 163.201 72.2 195.601C72.2 195.601 36.6 158.801 20.6 160.001z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M28.225 157.972C28.225 157.972 27.788 156.214 29.678 156.768C31.568 157.322 52.002 155.423 90.099 189.599C90.099 189.599 43.924 154.656 28.225 157.972z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M38.625 153.572C38.625 153.572 38.188 151.814 40.078 152.368C41.968 152.922 76.802 157.423 128.499 192.399C128.499 192.399 54.324 150.256 38.625 153.572z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-1.8 142.001C-1.8 142.001 -2 140.201 -0.2 141.001C1.6 141.801 55 144.401 85.4 171.201C85.4 171.201 50.499 146.426 -1.8 142.001z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M-11.8 146.001C-11.8 146.001 -12 144.201 -10.2 145.001C-8.4 145.801 16.2 149.201 39.8 181.601C39.8 181.601 4.2 144.801 -11.8 146.001z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M49.503 148.962C49.503 148.962 48.938 147.241 50.864 147.655C52.79 148.068 87.86 150.004 141.981 181.098C141.981 181.098 64.317 146.704 49.503 148.962z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M57.903 146.562C57.903 146.562 57.338 144.841 59.264 145.255C61.19 145.668 96.26 147.604 150.381 178.698C150.381 178.698 73.317 143.904 57.903 146.562z").setFill(f).setStroke(s);
f = "#ffffff"; s = {color: "#000000", width: 0.1};
g.createPath("M67.503 141.562C67.503 141.562 66.938 139.841 68.864 140.255C70.79 140.668 113.86 145.004 203.582 179.298C203.582 179.298 82.917 138.904 67.503 141.562z").setFill(f).setStroke(s);
f = "#000000"; s = null;
g.createPath("M-43.8 148.401C-43.8 148.401 -38.6 148.001 -39.8 149.601C-41 151.201 -43.4 150.401 -43.4 150.401L-43.8 148.401z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-13 162.401C-13 162.401 -7.8 162.001 -9 163.601C-10.2 165.201 -12.6 164.401 -12.6 164.401L-13 162.401z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-21.8 162.001C-21.8 162.001 -16.6 161.601 -17.8 163.201C-19 164.801 -21.4 164.001 -21.4 164.001L-21.8 162.001z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-117.169 150.182C-117.169 150.182 -112.124 151.505 -113.782 152.624C-115.439 153.744 -117.446 152.202 -117.446 152.202L-117.169 150.182z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-115.169 140.582C-115.169 140.582 -110.124 141.905 -111.782 143.024C-113.439 144.144 -115.446 142.602 -115.446 142.602L-115.169 140.582z").setFill(f).setStroke(s);
f = "#000000";
g.createPath("M-122.369 136.182C-122.369 136.182 -117.324 137.505 -118.982 138.624C-120.639 139.744 -122.646 138.202 -122.646 138.202L-122.369 136.182z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-42.6 211.201C-42.6 211.201 -44.2 211.201 -48.2 213.201C-50.2 213.201 -61.4 216.801 -67 226.801C-67 226.801 -54.6 217.201 -42.6 211.201z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M45.116 303.847C45.257 304.105 45.312 304.525 45.604 304.542C46.262 304.582 47.495 304.883 47.37 304.247C46.522 299.941 45.648 295.004 41.515 293.197C40.876 292.918 39.434 293.331 39.36 294.215C39.233 295.739 39.116 297.088 39.425 298.554C39.725 299.975 41.883 299.985 42.8 298.601C43.736 300.273 44.168 302.116 45.116 303.847z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M34.038 308.581C34.786 309.994 34.659 311.853 36.074 312.416C36.814 312.71 38.664 311.735 38.246 310.661C37.444 308.6 37.056 306.361 35.667 304.55C35.467 304.288 35.707 303.755 35.547 303.427C34.953 302.207 33.808 301.472 32.4 301.801C31.285 304.004 32.433 306.133 33.955 307.842C34.091 307.994 33.925 308.37 34.038 308.581z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-5.564 303.391C-5.672 303.014 -5.71 302.551 -5.545 302.23C-5.014 301.197 -4.221 300.075 -4.558 299.053C-4.906 297.997 -6.022 298.179 -6.672 298.748C-7.807 299.742 -7.856 301.568 -8.547 302.927C-8.743 303.313 -8.692 303.886 -9.133 304.277C-9.607 304.698 -10.047 306.222 -9.951 306.793C-9.898 307.106 -10.081 317.014 -9.859 316.751C-9.24 316.018 -6.19 306.284 -6.121 305.392C-6.064 304.661 -5.332 304.196 -5.564 303.391z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-31.202 296.599C-28.568 294.1 -25.778 291.139 -26.22 287.427C-26.336 286.451 -28.111 286.978 -28.298 287.824C-29.1 291.449 -31.139 294.11 -33.707 296.502C-35.903 298.549 -37.765 304.893 -38 305.401C-34.303 300.145 -32.046 297.399 -31.202 296.599z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-44.776 290.635C-44.253 290.265 -44.555 289.774 -44.338 289.442C-43.385 287.984 -42.084 286.738 -42.066 285C-42.063 284.723 -42.441 284.414 -42.776 284.638C-43.053 284.822 -43.395 284.952 -43.503 285.082C-45.533 287.531 -46.933 290.202 -48.376 293.014C-48.559 293.371 -49.703 297.862 -49.39 297.973C-49.151 298.058 -47.431 293.877 -47.221 293.763C-45.958 293.077 -45.946 291.462 -44.776 290.635z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-28.043 310.179C-27.599 309.31 -26.023 308.108 -26.136 307.219C-26.254 306.291 -25.786 304.848 -26.698 305.536C-27.955 306.484 -31.404 307.833 -31.674 313.641C-31.7 314.212 -28.726 311.519 -28.043 310.179z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-13.6 293.001C-13.2 292.333 -12.492 292.806 -12.033 292.543C-11.385 292.171 -10.774 291.613 -10.482 290.964C-9.512 288.815 -7.743 286.995 -7.6 284.601C-9.091 283.196 -9.77 285.236 -10.4 286.201C-11.723 284.554 -12.722 286.428 -14.022 286.947C-14.092 286.975 -14.305 286.628 -14.38 286.655C-15.557 287.095 -16.237 288.176 -17.235 288.957C-17.406 289.091 -17.811 288.911 -17.958 289.047C-18.61 289.65 -19.583 289.975 -19.863 290.657C-20.973 293.364 -24.113 295.459 -26 303.001C-25.619 303.91 -21.488 296.359 -21.001 295.661C-20.165 294.465 -20.047 297.322 -18.771 296.656C-18.72 296.629 -18.534 296.867 -18.4 297.001C-18.206 296.721 -17.988 296.492 -17.6 296.601C-17.6 296.201 -17.734 295.645 -17.533 295.486C-16.296 294.509 -16.38 293.441 -15.6 292.201C-15.142 292.99 -14.081 292.271 -13.6 293.001z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M46.2 347.401C46.2 347.401 53.6 327.001 49.2 315.801C49.2 315.801 60.6 337.401 56 348.601C56 348.601 55.6 338.201 51.6 333.201C51.6 333.201 47.6 346.001 46.2 347.401z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M31.4 344.801C31.4 344.801 36.8 336.001 28.8 317.601C28.8 317.601 28 338.001 21.2 349.001C21.2 349.001 35.4 328.801 31.4 344.801z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M21.4 342.801C21.4 342.801 21.2 322.801 21.6 319.801C21.6 319.801 17.8 336.401 7.6 346.001C7.6 346.001 22 334.001 21.4 342.801z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M11.8 310.801C11.8 310.801 17.8 324.401 7.8 342.801C7.8 342.801 14.2 330.601 9.4 323.601C9.4 323.601 12 320.201 11.8 310.801z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-7.4 342.401C-7.4 342.401 -8.4 326.801 -6.6 324.601C-6.6 324.601 -6.4 318.201 -6.8 317.201C-6.8 317.201 -2.8 311.001 -2.6 318.401C-2.6 318.401 -1.2 326.201 1.6 330.801C1.6 330.801 5.2 336.201 5 342.601C5 342.601 -5 312.401 -7.4 342.401z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-11 314.801C-11 314.801 -17.6 325.601 -19.4 344.601C-19.4 344.601 -20.8 338.401 -17 324.001C-17 324.001 -12.8 308.601 -11 314.801z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-32.8 334.601C-32.8 334.601 -27.8 329.201 -26.4 324.201C-26.4 324.201 -22.8 308.401 -29.2 317.001C-29.2 317.001 -29 325.001 -37.2 332.401C-37.2 332.401 -32.4 330.001 -32.8 334.601z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-38.6 329.601C-38.6 329.601 -35.2 312.201 -34.4 311.401C-34.4 311.401 -32.6 308.001 -35.4 311.201C-35.4 311.201 -44.2 330.401 -48.2 337.001C-48.2 337.001 -40.2 327.801 -38.6 329.601z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-44.4 313.001C-44.4 313.001 -32.8 290.601 -54.6 316.401C-54.6 316.401 -43.6 306.601 -44.4 313.001z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M-59.8 298.401C-59.8 298.401 -55 279.601 -52.4 279.801C-52.4 279.801 -44.2 270.801 -50.8 281.401C-50.8 281.401 -56.8 291.001 -56.2 300.801C-56.2 300.801 -56.8 291.201 -59.8 298.401z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 287z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M276 265C276 265 255 250 251.5 242.5C251.5 242.5 278 272 278 276.5C278 276.5 278.5 267.5 276 265z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M293 111C293 111 281 103 279.5 105C279.5 105 290 111.5 292.5 120C292.5 120 291 111 293 111z").setFill(f).setStroke(s);
f = "#cccccc";
g.createPath("M301.5 191.5L284 179.5C284 179.5 303 196.5 303.5 200.5L301.5 191.5z").setFill(f).setStroke(s);
s = "#000000"; f = null;
g.createPath("M-89.25 169L-67.25 173.75").setFill(f).setStroke(s);
s = "#000000";
g.createPath("M-39 331C-39 331 -39.5 327.5 -48.5 338").setFill(f).setStroke(s);
s = "#000000";
g.createPath("M-33.5 336C-33.5 336 -31.5 329.5 -38 334").setFill(f).setStroke(s);
s = "#000000";
g.createPath("M20.5 344.5C20.5 344.5 22 333.5 10.5 346.5").setFill(f).setStroke(s);
//surface.createLine({x1: 0, y1: 350, x2: 700, y2: 350}).setStroke("green");
//surface.createLine({y1: 0, x1: 350, y2: 700, x2: 350}).setStroke("green");
dojo.connect(dijit.byId("rotatingSlider"), "onChange", rotatingEvent);
dojo.connect(dijit.byId("scalingSlider"), "onChange", scalingEvent);
};
 
dojo.addOnLoad(makeShapes);
 
</script>
<style type="text/css">
td.pad { padding: 0px 5px 0px 5px; }
</style>
</head>
<body class="tundra">
<h1>dojox.gfx: Tiger</h1>
<p>This example was directly converted from SVG file.</p>
<table>
<tr><td align="center" class="pad">Rotation (<span id="rotationValue">0</span>)</td></tr>
<tr><td>
<div id="rotatingSlider" dojoType="dijit.form.HorizontalSlider"
value="0" minimum="-180" maximum="180" discreteValues="72" showButtons="false" intermediateChanges="true"
style="width: 600px;">
<div dojoType="dijit.form.HorizontalRule" container="topDecoration" count="73" style="height:5px;"></div>
<div dojoType="dijit.form.HorizontalRule" container="bottomDecoration" count="9" style="height:5px;"></div>
<div dojoType="dijit.form.HorizontalRuleLabels" container="bottomDecoration" labels="-180,-135,-90,-45,0,45,90,135,180" style="height:1.2em;font-size:75%;color:gray;"></div>
</div>
</td></tr>
<tr><td align="center" class="pad">Scaling (<span id="scaleValue">1.000</span>)</td></tr>
<tr><td>
<div id="scalingSlider" dojoType="dijit.form.HorizontalSlider"
value="1" minimum="0" maximum="1" showButtons="false" intermediateChanges="true"
style="width: 600px;">
<div dojoType="dijit.form.HorizontalRule" container="bottomDecoration" count="5" style="height:5px;"></div>
<div dojoType="dijit.form.HorizontalRuleLabels" container="bottomDecoration" labels="10%,18%,32%,56%,100%" style="height:1.2em;font-size:75%;color:gray;"></div>
</div>
</td></tr>
</table>
<div id="gfx_holder" style="width: 700px; height: 700px;"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/demos/clock.html
New file
0,0 → 1,253
<html>
<head>
<title>dojox.gfx: interactive analog clock</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverlight.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx");
dojo.require("dojo.date.locale");
 
var current_time = new Date();
 
var hour_hand = null;
var minute_hand = null;
var second_hand = null;
 
var hour_shadow = null;
var minute_shadow = null;
var second_shadow = null;
 
var center = {x: 385 / 2, y: 385 / 2};
 
var hour_shadow_shift = {dx: 2, dy: 2};
var minute_shadow_shift = {dx: 3, dy: 3};
var second_shadow_shift = {dx: 4, dy: 4};
 
var selected_hand = null;
var container = null;
var container_position = null;
var text_time = null;
var diff_time = new Date();
 
placeHand = function(shape, angle, shift){
var move = {dx: center.x + (shift ? shift.dx : 0), dy: center.y + (shift ? shift.dy : 0)};
return shape.setTransform([move, dojox.gfx.matrix.rotateg(angle)]);
};
 
placeHourHand = function(h, m, s){
var angle = 30 * (h % 12 + m / 60 + s / 3600);
placeHand(hour_hand, angle);
placeHand(hour_shadow, angle, hour_shadow_shift);
};
 
placeMinuteHand = function(m, s){
var angle = 6 * (m + s / 60);
placeHand(minute_hand, angle);
placeHand(minute_shadow, angle, minute_shadow_shift);
};
 
placeSecondHand = function(s){
var angle = 6 * s;
placeHand(second_hand, angle);
placeHand(second_shadow, angle, second_shadow_shift);
};
 
reflectTime = function(time, hold_second_hand, hold_minute_hand, hold_hour_hand){
if(!time) time = current_time;
var h = time.getHours();
var m = time.getMinutes();
var s = time.getSeconds();
if(!hold_hour_hand) placeHourHand(h, m, s);
if(!hold_minute_hand) placeMinuteHand(m, s);
if(!hold_second_hand) placeSecondHand(s);
text_time.innerHTML = dojo.date.locale.format(
time, {selector: "time", timePattern: "h:mm:ss a"});
};
 
resetTime = function(){
current_time = new Date();
reflectTime();
};
 
tick = function(){
current_time.setSeconds(current_time.getSeconds() + 1);
reflectTime();
};
 
advanceTime = function(){
if(!selected_hand) {
tick();
}
};
 
normalizeAngle = function(angle){
if(angle > Math.PI) {
angle -= 2 * Math.PI;
} else if(angle < -Math.PI) {
angle += 2 * Math.PI;
}
return angle;
};
 
calculateAngle = function(x, y, handAngle){
try {
return normalizeAngle(Math.atan2(y - center.y, x - center.x) - handAngle);
} catch(e) {
// supress
}
return 0;
};
 
getSecondAngle = function(time){
if(!time) time = current_time;
return (6 * time.getSeconds() - 90) / 180 * Math.PI;
};
 
getMinuteAngle = function(time){
if(!time) time = current_time;
return (6 * (time.getMinutes() + time.getSeconds() / 60) - 90) / 180 * Math.PI;
};
 
getHourAngle = function(time){
if(!time) time = current_time;
return (30 * (time.getHours() + (time.getMinutes() + time.getSeconds() / 60) / 60) - 90) / 180 * Math.PI;
};
 
onMouseDown = function(evt){
selected_hand = evt.target;
diff_time.setTime(current_time.getTime());
dojo.stopEvent(evt);
};
 
onMouseMove = function(evt){
if(!selected_hand) return;
if(evt.target == second_hand.getEventSource() ||
evt.target == minute_hand.getEventSource() ||
evt.target == hour_hand.getEventSource()){
dojo.stopEvent(evt);
return;
}
if(dojox.gfx.equalSources(selected_hand, second_hand.getEventSource())){
var angle = calculateAngle(
evt.clientX - container_position.x,
evt.clientY - container_position.y,
normalizeAngle(getSecondAngle())
);
var diff = Math.round(angle / Math.PI * 180 / 6); // in whole seconds
current_time.setSeconds(current_time.getSeconds() + Math.round(diff));
reflectTime();
}else if(dojox.gfx.equalSources(selected_hand, minute_hand.getEventSource())){
var angle = calculateAngle(
evt.clientX - container_position.x,
evt.clientY - container_position.y,
normalizeAngle(getMinuteAngle(diff_time))
);
var diff = Math.round(angle / Math.PI * 180 / 6 * 60); // in whole seconds
diff_time.setTime(diff_time.getTime() + 1000 * diff);
reflectTime(diff_time, true);
}else if(dojox.gfx.equalSources(selected_hand, hour_hand.getEventSource())){
var angle = calculateAngle(
evt.clientX - container_position.x,
evt.clientY - container_position.y,
normalizeAngle(getHourAngle(diff_time))
);
var diff = Math.round(angle / Math.PI * 180 / 30 * 60 * 60); // in whole seconds
diff_time.setTime(diff_time.getTime() + 1000 * diff);
reflectTime(diff_time, true, true);
}else{
return;
}
dojo.stopEvent(evt);
};
 
onMouseUp = function(evt){
if(selected_hand && !dojox.gfx.equalSources(selected_hand, second_hand.getEventSource())){
current_time.setTime(diff_time.getTime());
reflectTime();
}
selected_hand = null;
dojo.stopEvent(evt);
};
 
makeShapes = function(){
// prerequisites
container = dojo.byId("gfx_holder");
container_position = dojo.coords(container, true);
text_time = dojo.byId("time");
var surface = dojox.gfx.createSurface(container, 385, 385);
surface.createImage({width: 385, height: 385, src: "images/clock_face.jpg"});
// hand shapes
var hour_hand_points = [{x: -7, y: 15}, {x: 7, y: 15}, {x: 0, y: -60}, {x: -7, y: 15}];
var minute_hand_points = [{x: -5, y: 15}, {x: 5, y: 15}, {x: 0, y: -100}, {x: -5, y: 15}];
var second_hand_points = [{x: -2, y: 15}, {x: 2, y: 15}, {x: 2, y: -105}, {x: 6, y: -105}, {x: 0, y: -116}, {x: -6, y: -105}, {x: -2, y: -105}, {x: -2, y: 15}];
// create shapes
hour_shadow = surface.createPolyline(hour_hand_points)
.setFill([0, 0, 0, 0.1])
;
hour_hand = surface.createPolyline(hour_hand_points)
.setStroke({color: "black", width: 2})
.setFill("#889")
;
minute_shadow = surface.createPolyline(minute_hand_points)
.setFill([0, 0, 0, 0.1])
;
minute_hand = surface.createPolyline(minute_hand_points)
.setStroke({color: "black", width: 2})
.setFill("#ccd")
;
second_shadow = surface.createPolyline(second_hand_points)
.setFill([0, 0, 0, 0.1])
;
second_hand = surface.createPolyline(second_hand_points)
.setStroke({color: "#800", width: 1})
.setFill("#d00")
;
 
// next 3 lines kill Silverlight because its nodes do not support CSS
//dojox.gfx._addClass(hour_hand .getEventSource(), "movable");
//dojox.gfx._addClass(minute_hand.getEventSource(), "movable");
//dojox.gfx._addClass(second_hand.getEventSource(), "movable");
surface.createCircle({r: 1}).setFill("black").setTransform({dx: 192.5, dy: 192.5});
// attach events
hour_hand .connect("onmousedown", onMouseDown);
minute_hand.connect("onmousedown", onMouseDown);
second_hand.connect("onmousedown", onMouseDown);
dojo.connect(container, "onmousemove", onMouseMove);
dojo.connect(container, "onmouseup", onMouseUp);
dojo.connect(dojo.byId("reset"), "onclick", resetTime);
 
// start the clock
resetTime();
window.setInterval(advanceTime, 1000);
};
 
dojo.addOnLoad(makeShapes);
 
</script>
<style type="text/css">
.movable { cursor: hand; }
</style>
</head>
<body>
<h1>dojox.gfx: interactive analog clock</h1>
<p>Grab hands and set your own time.</p>
<p>Warning: Canvas renderer doesn't implement event handling.</p>
<div id="gfx_holder" style="width: 385px; height: 385px;"></div>
<p>Current time: <span id="time"></span>.</p>
<p><button id="reset">Reset</button></p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/demos/creator.html
New file
0,0 → 1,123
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title>Create DojoX GFX JSON</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
td.cell { padding: 1em 1em 0em 0em; }
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("dojox.gfx");
dojo.require("dojox.gfx.utils");
 
surface = null;
grid_size = 500;
grid_step = 50;
 
init = function(){
// initialize graphics
var container = dojo.byId("gfx");
surface = dojox.gfx.createSurface(container, 500, 500);
// create a picture
 
// make a grid
var grid = surface.createGroup();
for(var i = 0; i <= grid_size; i += grid_step){
grid.createLine({x1: 0, x2: grid_size, y1: i, y2: i}).setStroke("black");
grid.createLine({y1: 0, y2: grid_size, x1: i, x2: i}).setStroke("black");
}
// make a checkerboard
var board = surface.createGroup(), gs2 = grid_step * 2;
for(var i = 0; i < grid_size; i += grid_step){
for(var j = 0; j < grid_size; j += grid_step){
if(i % gs2 == j % gs2) {
board.createRect({x: i, y: j, width: grid_step, height: grid_step}).setFill([255, 0, 0, 0.1]);
}
}
}
// draw test_transform shapes
var g1 = surface.createGroup();
var r1 = g1.createShape({type: "rect", x: 200, y: 200})
.setFill("green")
.setStroke({})
;
var r2 = surface.createShape({type: "rect"}).setStroke({})
.setFill({type: "linear", to: {x: 50, y: 100},
colors: [{offset: 0, color: "green"}, {offset: 0.5, color: "red"}, {offset: 1, color: "blue"}] })
.setTransform({dx: 100, dy: 100})
;
var r3 = surface.createRect().setStroke({})
.setFill({ type: "linear" })
;
var r4 = g1.createShape({type: "rect"})
.setFill("blue")
.setTransform([dojox.gfx.matrix.rotategAt(-30, 350, 250), { dx: 300, dy: 200 }])
;
var p1 = g1.createShape({type: "path"})
.setStroke({})
.moveTo(300, 100)
.lineTo(400, 200)
.lineTo(400, 300)
.lineTo(300, 400)
.curveTo(400, 300, 400, 200, 300, 100)
.setTransform({})
;
var p2 = g1.createShape(p1.getShape())
.setStroke({color: "red", width: 2})
.setTransform({dx: 100})
;
var p3 = g1.createShape({type: "path"})
.setStroke({color: "blue", width: 2})
.moveTo(300, 100)
.setAbsoluteMode(false)
.lineTo ( 100, 100)
.lineTo ( 0, 100)
.lineTo (-100, 100)
.curveTo( 100, -100, 100, -200, 0, -300)
//.setTransform(dojox.gfx.matrix.rotategAt(135, 250, 250))
.setTransform(dojox.gfx.matrix.rotategAt(180, 250, 250))
;
g1.moveToFront();
g1.setTransform(dojox.gfx.matrix.rotategAt(-15, 250, 250));
// dump everything
dump();
};
 
dump = function(){
var objects = dojox.gfx.utils.serialize(surface);
// name top-level objects
for(var i = 0; i < objects.length; ++i){
objects[i].name = "shape" + i;
}
// format and show
dojo.byId("io").value = dojo.toJson(objects, dojo.byId("pprint").checked);
};
 
dojo.addOnLoad(init);
</script>
</head>
<body>
<h1>Create DojoX GFX JSON</h1>
<p>This is a helper file, which serves as a template to generate static pictures.</p>
<table>
<tr>
<td align="left" valign="top" class="cell">
<div id="gfx" style="width: 500px; height: 500px; border: solid 1px black;">
</div>
</td>
</tr>
</table>
<p><textarea id="io" cols="80" rows="10" wrap="off"></textarea></p>
<p><button onclick="dump()">Dump!</button>
&nbsp;&nbsp;&nbsp;<input type="checkbox" id="pprint" checked="checked" />&nbsp;<label for="pprint">Pretty-print JSON</label></p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/demos/butterfly.html
New file
0,0 → 1,88
<html>
<head>
<title>dojox.gfx: Butterfly</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="parseOnLoad: true"></script>
<script type="text/javascript">
 
dojo.require("dijit.form.Slider");
dojo.require("dojo.parser"); // scan page for widgets
 
dojo.require("dojox.gfx");
 
var rotation = 0, scaling = 1;
var surface, g, m = dojox.gfx.matrix;
var initial_matrix = m.translate(140, 180);
 
var updateMatrix = function(){
if(g){ g.setTransform([m.rotategAt(rotation, 350, 350), m.scaleAt(scaling, 350, 350), initial_matrix]); }
};
 
var rotatingEvent = function(value){
rotation = value;
dojo.byId("rotationValue").innerHTML = rotation;
updateMatrix();
};
 
var scalingEvent = function(value){
scaling = Math.exp(Math.LN10 * (value - 1));
dojo.byId("scaleValue").innerHTML = scaling.toFixed(3);
updateMatrix();
};
 
var makeShapes = function(){
surface = dojox.gfx.createSurface(dojo.byId("gfx_holder"), 700, 700);
surface.createRect({x: 0, y: 0, width: 700, height: 700}).setFill("#eee");
g = surface.createGroup().setTransform(initial_matrix);
g.createPath("M204.33 139.83 C196.33 133.33 206.68 132.82 206.58 132.58 C192.33 97.08 169.35 81.41 167.58 80.58 C162.12 78.02 159.48 78.26 160.45 76.97 C161.41 75.68 167.72 79.72 168.58 80.33 C193.83 98.33 207.58 132.33 207.58 132.33 C207.58 132.33 209.33 133.33 209.58 132.58 C219.58 103.08 239.58 87.58 246.33 81.33 C253.08 75.08 256.63 74.47 247.33 81.58 C218.58 103.58 210.34 132.23 210.83 132.33 C222.33 134.83 211.33 140.33 211.83 139.83 C214.85 136.81 214.83 145.83 214.83 145.83 C214.83 145.83 231.83 110.83 298.33 66.33 C302.43 63.59 445.83 -14.67 395.83 80.83 C393.24 85.79 375.83 105.83 375.83 105.83 C375.83 105.83 377.33 114.33 371.33 121.33 C370.3 122.53 367.83 134.33 361.83 140.83 C360.14 142.67 361.81 139.25 361.83 140.83 C362.33 170.83 337.76 170.17 339.33 170.33 C348.83 171.33 350.19 183.66 350.33 183.83 C355.83 190.33 353.83 191.83 355.83 194.83 C366.63 211.02 355.24 210.05 356.83 212.83 C360.83 219.83 355.99 222.72 357.33 224.83 C360.83 230.33 354.75 233.84 354.83 235.33 C355.33 243.83 349.67 240.73 349.83 244.33 C350.33 255.33 346.33 250.83 343.83 254.83 C336.33 266.83 333.46 262.38 332.83 263.83 C329.83 270.83 325.81 269.15 324.33 270.83 C320.83 274.83 317.33 274.83 315.83 276.33 C308.83 283.33 304.86 278.39 303.83 278.83 C287.83 285.83 280.33 280.17 277.83 280.33 C270.33 280.83 271.48 279.67 269.33 277.83 C237.83 250.83 219.33 211.83 215.83 206.83 C214.4 204.79 211.35 193.12 212.33 195.83 C214.33 201.33 213.33 250.33 207.83 250.33 C202.33 250.33 201.83 204.33 205.33 195.83 C206.43 193.16 204.4 203.72 201.79 206.83 C196.33 213.33 179.5 250.83 147.59 277.83 C145.42 279.67 146.58 280.83 138.98 280.33 C136.46 280.17 128.85 285.83 112.65 278.83 C111.61 278.39 107.58 283.33 100.49 276.33 C98.97 274.83 95.43 274.83 91.88 270.83 C90.39 269.15 86.31 270.83 83.27 263.83 C82.64 262.38 79.73 266.83 72.13 254.83 C69.6 250.83 65.54 255.33 66.05 244.33 C66.22 240.73 60.48 243.83 60.99 235.33 C61.08 233.84 54.91 230.33 58.45 224.83 C59.81 222.72 54.91 219.83 58.96 212.83 C60.57 210.05 49.04 211.02 59.97 194.83 C62 191.83 59.97 190.33 65.54 183.83 C65.69 183.66 67.06 171.33 76.69 170.33 C78.28 170.17 53.39 170.83 53.9 140.83 C53.92 139.25 55.61 142.67 53.9 140.83 C47.82 134.33 45.32 122.53 44.27 121.33 C38.19 114.33 39.71 105.83 39.71 105.83 C39.71 105.83 22.08 85.79 19.46 80.83 C-31.19 -14.67 114.07 63.59 118.22 66.33 C185.58 110.83 202 145.83 202 145.83 C202 145.83 202.36 143.28 203 141.83 C203.64 140.39 204.56 140.02 204.33 139.83 z").setFill("rgb(246,127,0)");
g.createPath("M203.62 139.62 C195.62 133.12 205.96 132.6 205.87 132.37 C191.62 96.87 168.64 81.2 166.87 80.37 C161.41 77.81 158.77 78.05 159.73 76.76 C160.69 75.47 167.01 79.51 167.87 80.12 C193.12 98.12 206.87 132.12 206.87 132.12 C206.87 132.12 208.62 133.12 208.87 132.37 C218.87 102.87 238.87 87.37 245.62 81.12 C252.37 74.87 255.92 74.26 246.62 81.37 C217.87 103.37 209.63 132.01 210.12 132.12 C221.62 134.62 210.62 140.12 211.12 139.62 C214.14 136.6 214.12 145.62 214.12 145.62 C214.12 145.62 231.12 110.62 297.62 66.12 C301.71 63.38 445.12 -14.88 395.12 80.62 C392.53 85.57 375.12 105.62 375.12 105.62 C375.12 105.62 376.62 114.12 370.62 121.12 C369.59 122.32 367.12 134.12 361.12 140.62 C359.43 142.46 361.09 139.04 361.12 140.62 C361.62 170.62 337.05 169.96 338.62 170.12 C348.12 171.12 349.47 183.45 349.62 183.62 C355.12 190.12 353.12 191.62 355.12 194.62 C365.91 210.81 354.53 209.84 356.12 212.62 C360.12 219.62 355.28 222.51 356.62 224.62 C360.12 230.12 354.03 233.62 354.12 235.12 C354.62 243.62 348.96 240.52 349.12 244.12 C349.62 255.12 345.62 250.62 343.12 254.62 C335.62 266.62 332.74 262.17 332.12 263.62 C329.12 270.62 325.09 268.94 323.62 270.62 C320.12 274.62 316.62 274.62 315.12 276.12 C308.12 283.12 304.15 278.17 303.12 278.62 C287.12 285.62 279.62 279.95 277.12 280.12 C269.62 280.62 270.77 279.46 268.62 277.62 C237.12 250.62 218.62 211.62 215.12 206.62 C213.69 204.57 210.63 192.91 211.62 195.62 C213.62 201.12 212.62 250.12 207.12 250.12 C201.62 250.12 201.12 204.12 204.62 195.62 C205.72 192.95 203.69 203.5 201.08 206.62 C195.62 213.12 178.79 250.62 146.88 277.62 C144.71 279.46 145.87 280.62 138.27 280.12 C135.75 279.95 128.14 285.62 111.94 278.62 C110.9 278.17 106.87 283.12 99.78 276.12 C98.26 274.62 94.72 274.62 91.17 270.62 C89.68 268.94 85.6 270.62 82.56 263.62 C81.93 262.17 79.01 266.62 71.42 254.62 C68.88 250.62 64.83 255.12 65.34 244.12 C65.51 240.52 59.77 243.62 60.27 235.12 C60.36 233.62 54.2 230.12 57.74 224.62 C59.1 222.51 54.2 219.62 58.25 212.62 C59.86 209.84 48.33 210.81 59.26 194.62 C61.29 191.62 59.26 190.12 64.83 183.62 C64.98 183.45 66.35 171.12 75.98 170.12 C77.57 169.96 52.68 170.62 53.18 140.62 C53.21 139.04 54.9 142.46 53.18 140.62 C47.11 134.12 44.6 122.32 43.56 121.12 C37.48 114.12 39 105.62 39 105.62 C39 105.62 21.37 85.57 18.74 80.62 C-31.9 -14.88 113.36 63.38 117.51 66.12 C184.87 110.62 201.29 145.62 201.29 145.62 C201.29 145.62 201.65 143.07 202.29 141.62 C202.93 140.18 203.85 139.81 203.62 139.62 zM242.12 153.12 C245.16 153.02 251.35 156.17 255.12 155.12 C280.55 148.06 328.44 154.56 331.62 155.62 C343.62 159.62 351.62 131.12 326.12 131.12 C294.59 131.12 301.12 129.12 280.12 126.12 C278.34 125.87 252.6 135.42 228.62 149.12 C225.12 151.12 227.12 153.62 242.12 153.12 zM223.12 148.12 C225.66 148.4 238.12 139.62 277.12 124.12 C279.49 123.18 279.62 118.12 300.62 108.62 C301.99 108 300.12 104.62 314.62 92.62 C321.79 86.69 297.12 87.62 291.62 88.62 C286.12 89.62 272.62 100.62 272.62 100.62 C272.62 100.62 287.8 88.55 282.62 90.12 C271.12 93.62 241.12 126.62 231.12 140.62 C221.12 154.62 247.62 116.62 254.12 110.62 C260.62 104.62 204.62 146.12 223.12 148.12 zM335.62 128.62 C350.14 131.53 348.62 110.12 341.12 109.12 C329.55 107.58 307.51 108.3 301.12 110.62 C284.62 116.62 280.29 122.65 281.62 123.12 C310.12 133.12 330.62 127.62 335.62 128.62 zM335.12 106.62 C341.04 107.36 351.12 109.62 351.62 101.62 C351.87 97.6 365.62 104.62 368.62 105.12 C371.1 105.53 358.12 100.33 353.62 97.12 C350.12 94.62 349.51 91.76 349.12 91.62 C317.12 80.12 303.62 107.12 303.62 107.12 C303.62 107.12 331.12 106.12 335.12 106.62 zM400.62 62.62 C395.62 54.62 386.66 57.08 383.62 53.62 C369.12 37.12 335.54 58.28 363.12 56.12 C395.12 53.62 401.21 63.57 400.62 62.62 zM376.62 66.62 C390.13 66.62 396.12 72.62 395.12 71.62 C388.12 64.62 382.12 66.12 380.62 64.12 C371.7 52.23 345.12 64.62 347.12 67.62 C349.12 70.62 373.12 66.62 376.62 66.62 zM330.12 76.12 C309.12 81.12 318.12 88.62 320.62 88.12 C340.05 84.24 334.5 75.08 330.12 76.12 zM340.62 52.12 C331.12 53.12 330.48 70.43 335.12 67.12 C342.12 62.12 350.12 51.12 340.62 52.12 zM315.62 75.62 C329.62 70.12 319.12 67.62 314.62 68.12 C310.12 68.62 306.79 75.45 308.12 78.12 C311.12 84.12 312.91 76.69 315.62 75.62 zM359.62 121.12 C364.12 118.62 358.62 112.62 354.62 115.12 C350.62 117.62 355.12 123.62 359.62 121.12 zM350.12 78.62 C361.89 90.39 366.62 84.12 369.12 83.12 C377.24 79.87 386.12 88.62 384.62 87.12 C377.34 79.84 372.62 81.12 371.62 79.62 C364.01 68.2 352.66 75.44 350.12 75.62 C343.12 76.12 334.43 81.03 337.62 80.12 C341.12 79.12 348.62 77.12 350.12 78.62 zM383.62 44.12 C390.62 39.12 381.4 37.85 379.62 38.12 C373.12 39.12 376.62 49.12 383.62 44.12 zM224.62 181.12 C230.12 187.62 291.62 285.12 282.12 252.62 C280.83 248.2 285.62 266.12 291.12 256.12 C292.66 253.32 301.27 253.03 274.62 208.62 C273.12 206.12 252.62 198.12 232.12 175.62 C229.02 172.21 220.05 175.72 224.62 181.12 zM280.12 215.62 C284.62 222.62 295.81 246.07 296.62 249.62 C299.12 260.62 306.12 248.12 307.62 248.62 C320.78 253.01 311.12 241.12 310.12 238.12 C300.95 210.62 279.62 213.12 279.62 213.12 C279.62 213.12 275.62 208.62 280.12 215.62 zM253.62 256.12 C266.26 274.09 271.12 267.12 273.62 265.12 C281.32 258.96 232.34 196.14 229.12 192.12 C225.12 187.12 225.12 215.62 253.62 256.12 zM300.12 219.12 C306.62 224.12 313.86 245.19 317.62 244.62 C327.62 243.12 321.62 234.62 324.12 236.12 C326.62 237.62 331.62 234.95 330.12 232.12 C317.62 208.62 298.12 216.12 298.12 216.12 C298.12 216.12 293.62 214.12 300.12 219.12 zM235.62 168.62 C216.12 168.62 282.12 222.62 301.12 212.12 C305.06 209.94 296.12 208.62 297.62 197.12 C297.9 195.02 284.12 191.12 284.12 178.12 C284.12 173.88 276.2 172.12 251.12 172.12 C246.62 172.12 256.03 168.62 235.62 168.62 zM307.62 213.62 C325.89 215.65 330.23 229.8 332.62 228.12 C361.12 208.12 309.89 199.96 300.62 201.12 C296.62 201.62 303.12 213.12 307.62 213.62 zM238.62 164.12 C242.12 166.62 254.12 176.62 292.62 168.12 C294.09 167.8 263.62 167.62 259.62 166.62 C255.62 165.62 236.25 162.43 238.62 164.12 zM305.12 198.62 C342.62 207.62 332.72 201.36 334.12 200.62 C342.62 196.12 333.33 195.23 334.62 193.62 C338.83 188.36 327.62 185.12 304.12 182.62 C298.56 182.03 287.54 179.27 287.12 180.12 C283.62 187.12 300.33 197.47 305.12 198.62 zM311.12 182.12 C343.62 187.62 323.23 177.43 323.62 177.12 C335.12 168.12 297.12 168.12 297.12 168.12 C297.12 168.12 280.79 172 281.12 172.62 C285.62 181.12 307.15 181.45 311.12 182.12 zM249.62 253.62 C249.62 253.62 220.62 207.12 226.62 188.12 C227.83 184.31 213.62 165.62 220.12 197.12 C220.22 197.61 218.89 190.43 216.62 187.12 C214.35 183.81 211.18 184.9 213.12 194.62 C218.01 219.05 249.62 253.62 249.62 253.62 zM289.12 83.62 C296.62 81.62 293.12 79.12 288.62 78.12 C284.12 77.12 281.62 85.62 289.12 83.62 zM187.4 149.12 C163.12 135.42 137.04 125.87 135.23 126.12 C113.96 129.12 120.58 131.12 88.64 131.12 C62.81 131.12 70.91 159.62 83.07 155.62 C86.29 154.56 134.8 148.06 160.56 155.12 C164.37 156.17 170.65 153.02 173.73 153.12 C188.92 153.62 190.95 151.12 187.4 149.12 zM161.57 110.62 C168.15 116.62 195 154.62 184.87 140.62 C174.74 126.62 144.35 93.62 132.7 90.12 C127.46 88.55 142.83 100.62 142.83 100.62 C142.83 100.62 129.16 89.62 123.58 88.62 C118.01 87.62 93.03 86.69 100.29 92.62 C114.97 104.62 113.08 108 114.47 108.62 C135.74 118.12 135.87 123.18 138.27 124.12 C177.78 139.62 190.4 148.4 192.97 148.12 C211.71 146.12 154.99 104.62 161.57 110.62 zM133.71 123.12 C135.07 122.65 130.68 116.62 113.96 110.62 C107.49 108.3 85.16 107.58 73.44 109.12 C65.85 110.12 64.31 131.53 79.01 128.62 C84.08 127.62 104.84 133.12 133.71 123.12 zM111.43 107.12 C111.43 107.12 97.75 80.12 65.34 91.62 C64.95 91.76 64.33 94.62 60.78 97.12 C56.23 100.33 43.08 105.53 45.59 105.12 C48.63 104.62 62.55 97.6 62.81 101.62 C63.31 109.62 73.53 107.36 79.52 106.62 C83.57 106.12 111.43 107.12 111.43 107.12 zM51.16 56.12 C79.09 58.28 45.08 37.12 30.39 53.62 C27.31 57.08 18.24 54.62 13.17 62.62 C12.57 63.57 18.74 53.62 51.16 56.12 zM67.37 67.62 C69.39 64.62 42.47 52.23 33.43 64.12 C31.91 66.12 25.83 64.62 18.74 71.62 C17.73 72.62 23.8 66.62 37.48 66.62 C41.03 66.62 65.34 70.62 67.37 67.62 zM84.59 76.12 C105.86 81.12 96.74 88.62 94.21 88.12 C74.53 84.24 80.15 75.08 84.59 76.12 zM79.52 67.12 C84.22 70.43 83.57 53.12 73.95 52.12 C64.33 51.12 72.43 62.12 79.52 67.12 zM106.87 78.12 C108.22 75.45 104.84 68.62 100.29 68.12 C95.73 67.62 85.09 70.12 99.27 75.62 C102.02 76.69 103.83 84.12 106.87 78.12 zM59.77 115.12 C55.72 112.62 50.14 118.62 54.7 121.12 C59.26 123.62 63.82 117.62 59.77 115.12 zM76.99 80.12 C80.22 81.03 71.42 76.12 64.33 75.62 C61.75 75.44 50.26 68.2 42.55 79.62 C41.53 81.12 36.75 79.84 29.38 87.12 C27.86 88.62 36.85 79.87 45.08 83.12 C47.61 84.12 52.41 90.39 64.33 78.62 C65.85 77.12 73.44 79.12 76.99 80.12 zM34.44 38.12 C32.64 37.85 23.3 39.12 30.39 44.12 C37.48 49.12 41.03 39.12 34.44 38.12 zM183.86 175.62 C163.09 198.12 142.32 206.12 140.8 208.62 C113.81 253.03 122.53 253.32 124.09 256.12 C129.66 266.12 134.52 248.2 133.21 252.62 C123.58 285.12 185.88 187.62 191.45 181.12 C196.08 175.72 187 172.21 183.86 175.62 zM135.74 213.12 C135.74 213.12 114.13 210.62 104.84 238.12 C103.83 241.12 94.05 253.01 107.38 248.62 C108.9 248.12 115.99 260.62 118.52 249.62 C119.34 246.07 130.68 222.62 135.23 215.62 C139.79 208.62 135.74 213.12 135.74 213.12 zM186.89 192.12 C183.64 196.14 134.02 258.96 141.82 265.12 C144.35 267.12 149.27 274.09 162.08 256.12 C190.95 215.62 190.95 187.12 186.89 192.12 zM117 216.12 C117 216.12 97.25 208.62 84.59 232.12 C83.06 234.95 88.13 237.62 90.66 236.12 C93.2 234.62 87.12 243.12 97.25 244.62 C101.06 245.19 108.39 224.12 114.97 219.12 C121.56 214.12 117 216.12 117 216.12 zM164.61 172.12 C139.2 172.12 131.18 173.88 131.18 178.12 C131.18 191.12 117.23 195.02 117.51 197.12 C119.03 208.62 109.97 209.94 113.96 212.12 C133.21 222.62 200.06 168.62 180.31 168.62 C159.64 168.62 169.17 172.12 164.61 172.12 zM114.47 201.12 C105.08 199.96 53.18 208.12 82.05 228.12 C84.47 229.8 88.87 215.65 107.38 213.62 C111.94 213.12 118.52 201.62 114.47 201.12 zM156 166.62 C151.95 167.62 121.09 167.8 122.57 168.12 C161.57 176.62 173.73 166.62 177.27 164.12 C179.67 162.43 160.05 165.62 156 166.62 zM128.14 180.12 C127.71 179.27 116.55 182.03 110.92 182.62 C87.12 185.12 75.76 188.36 80.03 193.62 C81.33 195.23 71.92 196.12 80.53 200.62 C81.95 201.36 71.92 207.62 109.91 198.62 C114.76 197.47 131.69 187.12 128.14 180.12 zM134.22 172.62 C134.56 172 118.01 168.12 118.01 168.12 C118.01 168.12 79.52 168.12 91.17 177.12 C91.57 177.43 70.91 187.62 103.83 182.12 C107.86 181.45 129.66 181.12 134.22 172.62 zM203.1 194.62 C205.07 184.9 201.85 183.81 199.56 187.12 C197.26 190.43 195.91 197.61 196.01 197.12 C202.6 165.62 188.21 184.31 189.43 188.12 C195.5 207.12 166.13 253.62 166.13 253.62 C166.13 253.62 198.15 219.05 203.1 194.62 zM126.62 78.12 C122.06 79.12 118.52 81.62 126.12 83.62 C133.71 85.62 131.18 77.12 126.62 78.12 z").setFill("black");
g.createPath("M363.73 85.73 C359.27 86.29 355.23 86.73 354.23 81.23 C353.23 75.73 355.73 73.73 363.23 75.73 C370.73 77.73 375.73 84.23 363.73 85.73 zM327.23 89.23 C327.23 89.23 308.51 93.65 325.73 80.73 C333.73 74.73 334.23 79.73 334.73 82.73 C335.48 87.2 327.23 89.23 327.23 89.23 zM384.23 48.73 C375.88 47.06 376.23 42.23 385.23 40.23 C386.7 39.91 389.23 49.73 384.23 48.73 zM389.23 48.73 C391.73 48.23 395.73 49.23 396.23 52.73 C396.73 56.23 392.73 58.23 390.23 56.23 C387.73 54.23 386.73 49.23 389.23 48.73 zM383.23 59.73 C385.73 58.73 393.23 60.23 392.73 63.23 C392.23 66.23 386.23 66.73 383.73 65.23 C381.23 63.73 380.73 60.73 383.23 59.73 zM384.23 77.23 C387.23 74.73 390.73 77.23 391.73 78.73 C392.73 80.23 387.73 82.23 386.23 82.73 C384.73 83.23 381.23 79.73 384.23 77.23 zM395.73 40.23 C395.73 40.23 399.73 40.23 398.73 41.73 C397.73 43.23 394.73 43.23 394.73 43.23 zM401.73 49.23 C401.73 49.23 405.73 49.23 404.73 50.73 C403.73 52.23 400.73 52.23 400.73 52.23 zM369.23 97.23 C369.23 97.23 374.23 99.23 373.23 100.73 C372.23 102.23 370.73 104.73 367.23 101.23 C363.73 97.73 369.23 97.23 369.23 97.23 zM355.73 116.73 C358.73 114.23 362.23 116.73 363.23 118.23 C364.23 119.73 359.23 121.73 357.73 122.23 C356.23 122.73 352.73 119.23 355.73 116.73 zM357.73 106.73 C360.73 104.23 363.23 107.73 364.23 109.23 C365.23 110.73 361.23 111.73 359.73 112.23 C358.23 112.73 354.73 109.23 357.73 106.73 zM340.73 73.23 C337.16 73.43 331.23 71.73 340.23 65.73 C348.55 60.19 348.23 61.73 348.73 64.73 C349.48 69.2 344.3 73.04 340.73 73.23 zM310.23 82.23 C310.23 82.23 306.73 79.23 313.73 73.23 C321.33 66.73 320.23 69.23 320.73 72.23 C321.48 76.7 310.23 82.23 310.23 82.23 zM341.23 55.73 C341.23 55.73 347.23 54.73 346.23 56.23 C345.23 57.73 342.73 63.23 339.23 59.73 C335.73 56.23 341.23 55.73 341.23 55.73 zM374.73 86.23 C376.11 86.23 377.23 87.36 377.23 88.73 C377.23 90.11 376.11 91.23 374.73 91.23 C373.36 91.23 372.23 90.11 372.23 88.73 C372.23 87.36 373.36 86.23 374.73 86.23 zM369.73 110.73 C371.11 110.73 372.23 111.86 372.23 113.23 C372.23 114.61 371.11 115.73 369.73 115.73 C368.36 115.73 367.23 114.61 367.23 113.23 C367.23 111.86 368.36 110.73 369.73 110.73 zM365.73 120.73 C367.11 120.73 368.23 121.86 368.23 123.23 C368.23 124.61 367.11 125.73 365.73 125.73 C364.36 125.73 363.23 124.61 363.23 123.23 C363.23 121.86 364.36 120.73 365.73 120.73 zM349.73 127.23 C351.11 127.23 352.23 128.36 352.23 129.73 C352.23 131.11 351.11 132.23 349.73 132.23 C348.36 132.23 347.23 131.11 347.23 129.73 C347.23 128.36 348.36 127.23 349.73 127.23 zM358.23 128.73 C359.61 128.73 362.23 130.86 362.23 132.23 C362.23 133.61 359.61 133.73 358.23 133.73 C356.86 133.73 355.73 132.61 355.73 131.23 C355.73 129.86 356.86 128.73 358.23 128.73 zM382.23 89.73 C383.61 89.73 384.73 90.86 384.73 92.23 C384.73 93.61 383.61 94.73 382.23 94.73 C380.86 94.73 379.73 93.61 379.73 92.23 C379.73 90.86 380.86 89.73 382.23 89.73 zM395.73 66.23 C397.11 66.23 398.23 67.36 398.23 68.73 C398.23 70.11 397.11 71.23 395.73 71.23 C394.36 71.23 393.23 70.11 393.23 68.73 C393.23 67.36 394.36 66.23 395.73 66.23 zM300.73 74.23 C303.05 75.16 314.23 67.73 310.73 66.73 C307.23 65.73 298.23 73.23 300.73 74.23 zM319.73 61.23 C322.23 61.73 329.73 58.73 326.23 57.73 C322.73 56.73 317.09 60.71 319.73 61.23 zM271.73 91.73 C277.23 88.73 292.73 81.23 285.23 82.23 C277.73 83.23 267.01 94.31 271.73 91.73 zM364.23 42.23 C366.73 42.73 374.23 39.73 370.73 38.73 C367.23 37.73 361.59 41.71 364.23 42.23 zM292.23 78.73 C294.73 79.23 299.73 76.73 296.23 75.73 C292.73 74.73 289.59 78.21 292.23 78.73 zM355.23 141.23 C356.61 141.23 357.73 142.86 357.73 144.23 C357.73 145.61 357.11 145.73 355.73 145.73 C354.36 145.73 353.23 144.61 353.23 143.23 C353.23 141.86 353.86 141.23 355.23 141.23 zM347.73 140.73 C349.11 140.73 351.23 141.36 351.23 142.73 C351.23 144.11 348.61 143.73 347.23 143.73 C345.86 143.73 344.73 142.61 344.73 141.23 C344.73 139.86 346.36 140.73 347.73 140.73 zM349.73 155.23 C351.11 155.23 353.73 157.36 353.73 158.73 C353.73 160.11 351.11 160.23 349.73 160.23 C348.36 160.23 347.23 159.11 347.23 157.73 C347.23 156.36 348.36 155.23 349.73 155.23 zM337.73 175.73 C341.73 174.73 341.73 176.73 342.73 180.23 C343.73 183.73 350.8 195.11 339.23 181.23 C336.73 178.23 333.73 176.73 337.73 175.73 zM349.73 187.73 C351.11 187.73 352.23 188.86 352.23 190.23 C352.23 191.61 351.11 192.73 349.73 192.73 C348.36 192.73 347.23 191.61 347.23 190.23 C347.23 188.86 348.36 187.73 349.73 187.73 zM352.23 196.73 C353.61 196.73 354.73 197.86 354.73 199.23 C354.73 200.61 353.61 201.73 352.23 201.73 C350.86 201.73 349.73 200.61 349.73 199.23 C349.73 197.86 350.86 196.73 352.23 196.73 zM352.4 205.73 C353.77 205.73 355.73 208.86 355.73 210.23 C355.73 211.61 354.61 212.73 353.23 212.73 C351.86 212.73 349.07 211.11 349.07 209.73 C349.07 208.36 351.02 205.73 352.4 205.73 zM353.73 221.73 C355.11 221.73 354.73 221.86 354.73 223.23 C354.73 224.61 354.61 223.73 353.23 223.73 C351.86 223.73 352.23 224.61 352.23 223.23 C352.23 221.86 352.36 221.73 353.73 221.73 zM340.23 188.73 C341.61 188.73 341.23 188.86 341.23 190.23 C341.23 191.61 341.11 190.73 339.73 190.73 C338.36 190.73 338.73 191.61 338.73 190.23 C338.73 188.86 338.86 188.73 340.23 188.73 zM343.23 201.23 C344.61 201.23 344.23 201.36 344.23 202.73 C344.23 204.11 344.44 207.73 343.07 207.73 C341.69 207.73 341.73 204.11 341.73 202.73 C341.73 201.36 341.86 201.23 343.23 201.23 zM346.73 215.23 C348.11 215.23 347.73 215.36 347.73 216.73 C347.73 218.11 347.61 217.23 346.23 217.23 C344.86 217.23 345.23 218.11 345.23 216.73 C345.23 215.36 345.36 215.23 346.73 215.23 zM340.57 228.73 C341.94 228.73 341.73 228.86 341.73 230.23 C341.73 231.61 341.44 230.73 340.07 230.73 C338.69 230.73 339.23 231.61 339.23 230.23 C339.23 228.86 339.19 228.73 340.57 228.73 zM349.4 232.07 C350.77 232.07 352.07 234.02 352.07 235.4 C352.07 236.77 349.11 239.23 347.73 239.23 C346.36 239.23 346.73 240.11 346.73 238.73 C346.73 237.36 348.02 232.07 349.4 232.07 zM343.73 246.4 C345.11 246.4 347.4 246.02 347.4 247.4 C347.4 248.77 344.11 251.23 342.73 251.23 C341.36 251.23 341.73 252.11 341.73 250.73 C341.73 249.36 342.36 246.4 343.73 246.4 zM335.23 239.23 C336.61 239.23 336.23 239.36 336.23 240.73 C336.23 242.11 336.11 241.23 334.73 241.23 C333.36 241.23 333.73 242.11 333.73 240.73 C333.73 239.36 333.86 239.23 335.23 239.23 zM332.73 258.4 C334.11 258.4 335.4 260.02 335.4 261.4 C335.4 262.77 333.11 262.23 331.73 262.23 C330.36 262.23 330.73 263.11 330.73 261.73 C330.73 260.36 331.36 258.4 332.73 258.4 zM324.4 263.73 C325.77 263.73 325.07 265.36 325.07 266.73 C325.07 268.11 320.11 271.23 318.73 271.23 C317.36 271.23 317.73 272.11 317.73 270.73 C317.73 269.36 323.02 263.73 324.4 263.73 zM325.23 247.73 C326.61 247.73 326.23 247.86 326.23 249.23 C326.23 250.61 326.11 249.73 324.73 249.73 C323.36 249.73 323.73 250.61 323.73 249.23 C323.73 247.86 323.86 247.73 325.23 247.73 zM313.23 256.23 C314.61 256.23 319.07 258.02 319.07 259.4 C319.07 260.77 313.44 263.07 312.07 263.07 C310.69 263.07 309.73 260.77 309.73 259.4 C309.73 258.02 311.86 256.23 313.23 256.23 zM300.23 260.73 C301.61 260.73 301.23 260.86 301.23 262.23 C301.23 263.61 301.11 262.73 299.73 262.73 C298.36 262.73 298.73 263.61 298.73 262.23 C298.73 260.86 298.86 260.73 300.23 260.73 zM308.23 272.73 C309.61 272.73 309.23 272.86 309.23 274.23 C309.23 275.61 309.11 274.73 307.73 274.73 C306.36 274.73 306.73 275.61 306.73 274.23 C306.73 272.86 306.86 272.73 308.23 272.73 zM305.23 273.73 C306.61 273.73 306.23 273.86 306.23 275.23 C306.23 276.61 306.11 275.73 304.73 275.73 C303.36 275.73 303.73 276.61 303.73 275.23 C303.73 273.86 303.86 273.73 305.23 273.73 zM293.73 274.07 C294.65 274.07 295.73 275.48 295.73 276.4 C295.73 277.32 295.65 276.73 294.73 276.73 C293.82 276.73 291.4 277.98 291.4 277.07 C291.4 276.15 292.82 274.07 293.73 274.07 zM296.73 276.73 C297.65 276.73 297.4 276.82 297.4 277.73 C297.4 278.65 297.32 278.07 296.4 278.07 C295.48 278.07 295.73 278.65 295.73 277.73 C295.73 276.82 295.82 276.73 296.73 276.73 zM291.4 263.73 C292.32 263.73 293.73 267.15 293.73 268.07 C293.73 268.98 290.65 268.73 289.73 268.73 C288.82 268.73 287.4 265.98 287.4 265.07 C287.4 264.15 290.48 263.73 291.4 263.73 zM280.07 274.73 C281.44 274.73 281.23 274.86 281.23 276.23 C281.23 277.61 280.94 276.73 279.57 276.73 C278.19 276.73 278.73 277.61 278.73 276.23 C278.73 274.86 278.69 274.73 280.07 274.73 zM277.07 267.73 C278.44 267.73 276.4 271.02 276.4 272.4 C276.4 273.77 271.94 274.23 270.57 274.23 C269.19 274.23 271.73 272.44 271.73 271.07 C271.73 269.69 275.69 267.73 277.07 267.73 zM52.23 84.9 C56.7 85.46 60.73 85.9 61.73 80.4 C62.73 74.9 60.23 72.9 52.73 74.9 C45.23 76.9 40.23 83.4 52.23 84.9 zM88.73 88.4 C88.73 88.4 107.45 92.81 90.23 79.9 C82.23 73.9 81.73 78.9 81.23 81.9 C80.49 86.37 88.73 88.4 88.73 88.4 zM31.73 47.9 C40.08 46.23 39.73 41.4 30.73 39.4 C29.27 39.07 26.73 48.9 31.73 47.9 zM26.73 47.9 C24.23 47.4 20.23 48.4 19.73 51.9 C19.23 55.4 23.23 57.4 25.73 55.4 C28.23 53.4 29.23 48.4 26.73 47.9 zM32.73 58.9 C30.23 57.9 22.73 59.4 23.23 62.4 C23.73 65.4 29.73 65.9 32.23 64.4 C34.73 62.9 35.23 59.9 32.73 58.9 zM31.73 76.4 C28.73 73.9 25.23 76.4 24.23 77.9 C23.23 79.4 28.23 81.4 29.73 81.9 C31.23 82.4 34.73 78.9 31.73 76.4 zM20.23 39.4 C20.23 39.4 16.23 39.4 17.23 40.9 C18.23 42.4 21.23 42.4 21.23 42.4 zM14.23 48.4 C14.23 48.4 10.23 48.4 11.23 49.9 C12.23 51.4 15.23 51.4 15.23 51.4 zM46.73 96.4 C46.73 96.4 41.73 98.4 42.73 99.9 C43.73 101.4 45.23 103.9 48.73 100.4 C52.23 96.9 46.73 96.4 46.73 96.4 zM60.23 115.9 C57.23 113.4 53.73 115.9 52.73 117.4 C51.73 118.9 56.73 120.9 58.23 121.4 C59.73 121.9 63.23 118.4 60.23 115.9 zM58.23 105.9 C55.23 103.4 52.73 106.9 51.73 108.4 C50.73 109.9 54.73 110.9 56.23 111.4 C57.73 111.9 61.23 108.4 58.23 105.9 zM75.23 72.4 C78.8 72.6 84.73 70.9 75.73 64.9 C67.41 59.35 67.73 60.9 67.23 63.9 C66.49 68.37 71.66 72.2 75.23 72.4 zM105.73 81.4 C105.73 81.4 109.23 78.4 102.23 72.4 C94.64 65.89 95.73 68.4 95.23 71.4 C94.49 75.87 105.73 81.4 105.73 81.4 zM74.73 54.9 C74.73 54.9 68.73 53.9 69.73 55.4 C70.73 56.9 73.23 62.4 76.73 58.9 C80.23 55.4 74.73 54.9 74.73 54.9 zM41.23 85.4 C39.86 85.4 38.73 86.53 38.73 87.9 C38.73 89.28 39.86 90.4 41.23 90.4 C42.61 90.4 43.73 89.28 43.73 87.9 C43.73 86.53 42.61 85.4 41.23 85.4 zM46.23 109.9 C44.86 109.9 43.73 111.03 43.73 112.4 C43.73 113.78 44.86 114.9 46.23 114.9 C47.61 114.9 48.73 113.78 48.73 112.4 C48.73 111.03 47.61 109.9 46.23 109.9 zM50.23 119.9 C48.86 119.9 47.73 121.03 47.73 122.4 C47.73 123.78 48.86 124.9 50.23 124.9 C51.61 124.9 52.73 123.78 52.73 122.4 C52.73 121.03 51.61 119.9 50.23 119.9 zM66.23 126.4 C64.86 126.4 63.73 127.53 63.73 128.9 C63.73 130.28 64.86 131.4 66.23 131.4 C67.61 131.4 68.73 130.28 68.73 128.9 C68.73 127.53 67.61 126.4 66.23 126.4 zM57.73 127.9 C56.36 127.9 53.73 130.03 53.73 131.4 C53.73 132.78 56.36 132.9 57.73 132.9 C59.11 132.9 60.23 131.78 60.23 130.4 C60.23 129.03 59.11 127.9 57.73 127.9 zM33.73 88.9 C32.36 88.9 31.23 90.03 31.23 91.4 C31.23 92.78 32.36 93.9 33.73 93.9 C35.11 93.9 36.23 92.78 36.23 91.4 C36.23 90.03 35.11 88.9 33.73 88.9 zM20.23 65.4 C18.86 65.4 17.73 66.53 17.73 67.9 C17.73 69.28 18.86 70.4 20.23 70.4 C21.61 70.4 22.73 69.28 22.73 67.9 C22.73 66.53 21.61 65.4 20.23 65.4 zM115.23 73.4 C112.91 74.33 101.73 66.9 105.23 65.9 C108.73 64.9 117.73 72.4 115.23 73.4 zM96.23 60.4 C93.73 60.9 86.23 57.9 89.73 56.9 C93.23 55.9 98.87 59.87 96.23 60.4 zM144.23 90.9 C138.73 87.9 123.23 80.4 130.73 81.4 C138.23 82.4 148.96 93.48 144.23 90.9 zM51.73 41.4 C49.23 41.9 41.73 38.9 45.23 37.9 C48.73 36.9 54.37 40.87 51.73 41.4 zM123.73 77.9 C121.23 78.4 116.23 75.9 119.73 74.9 C123.23 73.9 126.37 77.37 123.73 77.9 zM60.73 140.4 C59.36 140.4 58.23 142.03 58.23 143.4 C58.23 144.78 58.86 144.9 60.23 144.9 C61.61 144.9 62.73 143.78 62.73 142.4 C62.73 141.03 62.11 140.4 60.73 140.4 zM68.23 139.9 C66.86 139.9 64.73 140.53 64.73 141.9 C64.73 143.28 67.36 142.9 68.73 142.9 C70.11 142.9 71.23 141.78 71.23 140.4 C71.23 139.03 69.61 139.9 68.23 139.9 zM66.23 154.4 C64.86 154.4 62.23 156.53 62.23 157.9 C62.23 159.28 64.86 159.4 66.23 159.4 C67.61 159.4 68.73 158.28 68.73 156.9 C68.73 155.53 67.61 154.4 66.23 154.4 zM78.23 174.9 C74.23 173.9 74.23 175.9 73.23 179.4 C72.23 182.9 65.17 194.28 76.73 180.4 C79.23 177.4 82.23 175.9 78.23 174.9 zM66.23 186.9 C64.86 186.9 63.73 188.02 63.73 189.4 C63.73 190.77 64.86 191.9 66.23 191.9 C67.61 191.9 68.73 190.77 68.73 189.4 C68.73 188.02 67.61 186.9 66.23 186.9 zM63.73 195.9 C62.36 195.9 61.23 197.02 61.23 198.4 C61.23 199.77 62.36 200.9 63.73 200.9 C65.11 200.9 66.23 199.77 66.23 198.4 C66.23 197.02 65.11 195.9 63.73 195.9 zM63.57 204.9 C62.19 204.9 60.23 208.02 60.23 209.4 C60.23 210.77 61.36 211.9 62.73 211.9 C64.11 211.9 66.9 210.27 66.9 208.9 C66.9 207.52 64.94 204.9 63.57 204.9 zM62.23 220.9 C60.86 220.9 61.23 221.02 61.23 222.4 C61.23 223.77 61.36 222.9 62.73 222.9 C64.11 222.9 63.73 223.77 63.73 222.4 C63.73 221.02 63.61 220.9 62.23 220.9 zM75.73 187.9 C74.36 187.9 74.73 188.02 74.73 189.4 C74.73 190.77 74.86 189.9 76.23 189.9 C77.61 189.9 77.23 190.77 77.23 189.4 C77.23 188.02 77.11 187.9 75.73 187.9 zM72.73 200.4 C71.36 200.4 71.73 200.52 71.73 201.9 C71.73 203.27 71.53 206.9 72.9 206.9 C74.28 206.9 74.23 203.27 74.23 201.9 C74.23 200.52 74.11 200.4 72.73 200.4 zM69.23 214.4 C67.86 214.4 68.23 214.52 68.23 215.9 C68.23 217.27 68.36 216.4 69.73 216.4 C71.11 216.4 70.73 217.27 70.73 215.9 C70.73 214.52 70.61 214.4 69.23 214.4 zM75.4 227.9 C74.03 227.9 74.23 228.02 74.23 229.4 C74.23 230.77 74.53 229.9 75.9 229.9 C77.28 229.9 76.73 230.77 76.73 229.4 C76.73 228.02 76.78 227.9 75.4 227.9 zM66.57 231.23 C65.19 231.23 63.9 233.19 63.9 234.57 C63.9 235.94 66.86 238.4 68.23 238.4 C69.61 238.4 69.23 239.27 69.23 237.9 C69.23 236.52 67.94 231.23 66.57 231.23 zM72.23 245.57 C70.86 245.57 68.57 245.19 68.57 246.57 C68.57 247.94 71.86 250.4 73.23 250.4 C74.61 250.4 74.23 251.27 74.23 249.9 C74.23 248.52 73.61 245.57 72.23 245.57 zM80.73 238.4 C79.36 238.4 79.73 238.52 79.73 239.9 C79.73 241.27 79.86 240.4 81.23 240.4 C82.61 240.4 82.23 241.27 82.23 239.9 C82.23 238.52 82.11 238.4 80.73 238.4 zM83.23 257.57 C81.86 257.57 80.57 259.19 80.57 260.57 C80.57 261.94 82.86 261.4 84.23 261.4 C85.61 261.4 85.23 262.27 85.23 260.9 C85.23 259.52 84.61 257.57 83.23 257.57 zM91.57 262.9 C90.19 262.9 90.9 264.52 90.9 265.9 C90.9 267.27 95.86 270.4 97.23 270.4 C98.61 270.4 98.23 271.27 98.23 269.9 C98.23 268.52 92.94 262.9 91.57 262.9 zM90.73 246.9 C89.36 246.9 89.73 247.02 89.73 248.4 C89.73 249.77 89.86 248.9 91.23 248.9 C92.61 248.9 92.23 249.77 92.23 248.4 C92.23 247.02 92.11 246.9 90.73 246.9 zM102.73 255.4 C101.36 255.4 96.9 257.19 96.9 258.57 C96.9 259.94 102.53 262.23 103.9 262.23 C105.28 262.23 106.23 259.94 106.23 258.57 C106.23 257.19 104.11 255.4 102.73 255.4 zM115.73 259.9 C114.36 259.9 114.73 260.02 114.73 261.4 C114.73 262.77 114.86 261.9 116.23 261.9 C117.61 261.9 117.23 262.77 117.23 261.4 C117.23 260.02 117.11 259.9 115.73 259.9 zM107.73 271.9 C106.36 271.9 106.73 272.02 106.73 273.4 C106.73 274.77 106.86 273.9 108.23 273.9 C109.61 273.9 109.23 274.77 109.23 273.4 C109.23 272.02 109.11 271.9 107.73 271.9 zM110.73 272.9 C109.36 272.9 109.73 273.02 109.73 274.4 C109.73 275.77 109.86 274.9 111.23 274.9 C112.61 274.9 112.23 275.77 112.23 274.4 C112.23 273.02 112.11 272.9 110.73 272.9 zM122.23 273.23 C121.32 273.23 120.23 274.65 120.23 275.57 C120.23 276.48 120.32 275.9 121.23 275.9 C122.15 275.9 124.57 277.15 124.57 276.23 C124.57 275.32 123.15 273.23 122.23 273.23 zM119.23 275.9 C118.32 275.9 118.57 275.98 118.57 276.9 C118.57 277.82 118.65 277.23 119.57 277.23 C120.48 277.23 120.23 277.82 120.23 276.9 C120.23 275.98 120.15 275.9 119.23 275.9 zM124.57 262.9 C123.65 262.9 122.23 266.32 122.23 267.23 C122.23 268.15 125.32 267.9 126.23 267.9 C127.15 267.9 128.57 265.15 128.57 264.23 C128.57 263.32 125.48 262.9 124.57 262.9 zM135.9 273.9 C134.53 273.9 134.73 274.02 134.73 275.4 C134.73 276.77 135.03 275.9 136.4 275.9 C137.78 275.9 137.23 276.77 137.23 275.4 C137.23 274.02 137.28 273.9 135.9 273.9 zM138.9 266.9 C137.53 266.9 139.57 270.19 139.57 271.57 C139.57 272.94 144.03 273.4 145.4 273.4 C146.78 273.4 144.23 271.61 144.23 270.23 C144.23 268.86 140.28 266.9 138.9 266.9 zM211 134.8 C209.63 134.8 209.83 134.93 209.83 136.3 C209.83 137.68 210.13 136.8 211.5 136.8 C212.88 136.8 212.33 137.68 212.33 136.3 C212.33 134.93 212.38 134.8 211 134.8 zM205.5 134.8 C204.13 134.8 204.33 134.93 204.33 136.3 C204.33 137.68 204.63 136.8 206 136.8 C207.38 136.8 206.83 137.68 206.83 136.3 C206.83 134.93 206.88 134.8 205.5 134.8 zM211 143.8 C209.63 143.8 209.83 143.93 209.83 145.3 C209.83 146.68 210.13 145.8 211.5 145.8 C212.88 145.8 212.33 146.68 212.33 145.3 C212.33 143.93 212.38 143.8 211 143.8 zM204.9 143.7 C203.53 143.7 203.73 143.83 203.73 145.2 C203.73 146.58 204.03 145.7 205.4 145.7 C206.78 145.7 206.23 146.58 206.23 145.2 C206.23 143.83 206.28 143.7 204.9 143.7 zM213 154.3 C211.63 154.3 212 155.43 212 156.8 C212 158.18 212.42 161.3 213.8 161.3 C215.17 161.3 214.33 157.18 214.33 155.8 C214.33 154.43 214.38 154.3 213 154.3 zM204 154.3 C202.63 154.3 202.6 155.53 202.6 156.9 C202.6 158.28 201.63 161.5 203 161.5 C204.38 161.5 204.8 157.68 204.8 156.3 C204.8 154.93 205.38 154.3 204 154.3 z").setFill("rgb(255,246,227)");
//surface.createLine({x1: 0, y1: 350, x2: 700, y2: 350}).setStroke("green");
//surface.createLine({y1: 0, x1: 350, y2: 700, x2: 350}).setStroke("green");
dojo.connect(dijit.byId("rotatingSlider"), "onChange", rotatingEvent);
dojo.connect(dijit.byId("scalingSlider"), "onChange", scalingEvent);
};
 
dojo.addOnLoad(makeShapes);
 
</script>
<style type="text/css">
td.pad { padding: 0px 5px 0px 5px; }
</style>
</head>
<body class="tundra">
<h1>dojox.gfx: Butterfly</h1>
<p>This example was directly converted from SVG file.</p>
<p>This is a slightly modified version of a sample that shipped with JASC's WebDraw (www.jasc.com). Generated by Jasc WebDraw PR4(tm) on 06/07/01 12:18:39.</p>
<table>
<tr><td align="center" class="pad">Rotation (<span id="rotationValue">0</span>)</td></tr>
<tr><td>
<div id="rotatingSlider" dojoType="dijit.form.HorizontalSlider"
value="0" minimum="-180" maximum="180" discreteValues="72" showButtons="false" intermediateChanges="true"
style="width: 600px;">
<div dojoType="dijit.form.HorizontalRule" container="topDecoration" count="73" style="height:5px;"></div>
<div dojoType="dijit.form.HorizontalRule" container="bottomDecoration" count="9" style="height:5px;"></div>
<div dojoType="dijit.form.HorizontalRuleLabels" container="bottomDecoration" labels="-180,-135,-90,-45,0,45,90,135,180" style="height:1.2em;font-size:75%;color:gray;"></div>
</div>
</td></tr>
<tr><td align="center" class="pad">Scaling (<span id="scaleValue">1.000</span>)</td></tr>
<tr><td>
<div id="scalingSlider" dojoType="dijit.form.HorizontalSlider" intermediateChanges="true"
value="1" minimum="0" maximum="1" showButtons="false" style="width: 600px;">
<div dojoType="dijit.form.HorizontalRule" container="bottomDecoration" count="5" style="height:5px;"></div>
<div dojoType="dijit.form.HorizontalRuleLabels" container="bottomDecoration" labels="10%,18%,32%,56%,100%" style="height:1.2em;font-size:75%;color:gray;"></div>
</div>
</td></tr>
</table>
<div id="gfx_holder" style="width: 700px; height: 700px;"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/demos/lion.html
New file
0,0 → 1,235
<html>
<head>
<title>dojox.gfx: Lion</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="parseOnLoad: true"></script>
<!--
<script type="text/javascript" src="../_base.js"></script>
<script type="text/javascript" src="../shape.js"></script>
<script type="text/javascript" src="../path.js"></script>
<script type="text/javascript" src="../arc.js"></script>
-->
<!--<script type="text/javascript" src="../vml.js"></script>-->
<!--<script type="text/javascript" src="../svg.js"></script>-->
<!--<script type="text/javascript" src="../canvas.js"></script>-->
<!--<script type="text/javascript" src="../silverlight.js"></script>-->
<script type="text/javascript">
 
dojo.require("dijit.form.Slider");
dojo.require("dojo.parser"); // scan page for widgets
 
dojo.require("dojox.gfx");
 
var rotation = 0, scaling = 1;
var surface, g, m = dojox.gfx.matrix;
var initial_matrix = m.normalize([m.rotateg(10), m.translate(300, 100)]);
 
var updateMatrix = function(){
if(g){ g.setTransform([m.rotategAt(rotation, 350, 350), m.scaleAt(scaling, 350, 350), initial_matrix]); }
};
 
var rotatingEvent = function(value){
rotation = value;
dojo.byId("rotationValue").innerHTML = rotation;
updateMatrix();
};
 
var scalingEvent = function(value){
scaling = Math.exp(Math.LN10 * (value - 1));
dojo.byId("scaleValue").innerHTML = scaling.toFixed(3);
updateMatrix();
};
 
makeShapes = function(){
surface = dojox.gfx.createSurface(dojo.byId("gfx_holder"), 700, 700);
surface.createRect({x: 0, y: 0, width: 700, height: 700}).setFill("#eee");
g = surface.createGroup().setTransform(initial_matrix);
g.createPolyline([69,18,82,8,99,3,118,5,135,12,149,21,156,13,165,9,177,13,183,28,180,50,164,91,155,107,154,114,151,121,141,127,139,136,155,206,157,251,126,342,133,357,128,376,83,376,75,368,67,350,61,350,53,369,4,369,2,361,5,354,12,342,16,321,4,257,4,244,7,218,9,179,26,127,43,93,32,77,30,70,24,67,16,49,17,35,18,23,30,12,40,7,53,7,62,12]).setFill("#f2cc99");
g.createPolyline([142,79,136,74,138,82,133,78,133,84,127,78,128,85,124,80,125,87,119,82,119,90,125,99,125,96,128,100,128,94,131,98,132,93,135,97,136,93,138,97,139,94,141,98,143,94,144,85]).setFill("#e5b27f");
g.createPolyline([127,101,132,100,137,99,144,101,143,105,135,110]).setFill("#eb8080");
g.createPolyline([178,229,157,248,139,296,126,349,137,356,158,357,183,342,212,332,235,288,235,261,228,252,212,250,188,251]).setFill("#f2cc99");
var c = new dojo.Color("#9c826b");
g.createPolyline([56,229,48,241,48,250,57,281,63,325,71,338,81,315,76,321,79,311,83,301,75,308,80,298,73,303,76,296,71,298,74,292,69,293,74,284,78,278,71,278,74,274,68,273,70,268,66,267,68,261,60,266,62,259,65,253,57,258,59,251,55,254,55,248,60,237,54,240,58,234,54,236]).setFill(c);
g.createPolyline([74,363,79,368,81,368,85,362,89,363,92,370,96,373,101,372,108,361,110,371,113,373,116,371,120,358,122,363,123,371,126,371,129,367,132,357,135,361,130,376,127,377,94,378,84,376,76,371]).setFill(c);
g.createPolyline([212,250,219,251,228,258,236,270,235,287,225,304,205,332,177,343,171,352,158,357,166,352,168,346,168,339,165,333,155,327,155,323,161,320,165,316,169,316,167,312,171,313,168,308,173,309,170,306,177,306,175,308,177,311,174,311,176,316,171,315,174,319,168,320,168,323,175,327,179,332,183,326,184,332,189,323,190,328,194,320,194,325,199,316,201,320,204,313,206,316,208,310,211,305,219,298,226,288,229,279,228,266,224,259,217,253]).setFill(c);
g.createPolyline([151,205,151,238,149,252,141,268,128,282,121,301,130,300,126,313,118,324,116,337,120,346,133,352,133,340,137,333,145,329,156,327,153,319,153,291,157,271,170,259,178,277,193,250,174,216]).setFill(c);
g.createPolyline([78,127,90,142,95,155,108,164,125,167,139,175,150,206,152,191,141,140,121,148,100,136]).setFill(c);
g.createPolyline([21,58,35,63,38,68,32,69,42,74,40,79,47,80,54,83,45,94,34,81,32,73,24,66]).setFill(c);
g.createPolyline([71,34,67,34,66,27,59,24,54,17,48,17,39,22,30,26,28,31,31,39,38,46,29,45,36,54,41,61,41,70,50,69,54,71,55,58,67,52,76,43,76,39,68,44]).setFill(c);
g.createPolyline([139,74,141,83,143,89,144,104,148,104,155,106,154,86,157,77,155,72,150,77,144,77]).setFill(c);
g.createPolyline([105,44,102,53,108,58,111,62,112,55]).setFill(c);
g.createPolyline([141,48,141,54,144,58,139,62,137,66,136,59,137,52]).setFill(c);
g.createPolyline([98,135,104,130,105,134,108,132,108,135,112,134,113,137,116,136,116,139,119,139,124,141,128,140,133,138,140,133,139,140,126,146,104,144]).setFill(c);
g.createPolyline([97,116,103,119,103,116,111,118,116,117,122,114,127,107,135,111,142,107,141,114,145,118,149,121,145,125,140,124,127,121,113,125,100,124]).setFill(c);
g.createPolyline([147,33,152,35,157,34,153,31,160,31,156,28,161,28,159,24,163,25,163,21,165,22,170,23,167,17,172,21,174,18,175,23,176,22,177,28,177,33,174,37,176,39,174,44,171,49,168,53,164,57,159,68,156,70,154,60,150,51,146,43,144,35]).setFill(c);
g.createPolyline([85,72,89,74,93,75,100,76,105,75,102,79,94,79,88,76]).setFill(c);
g.createPolyline([86,214,79,221,76,232,82,225,78,239,82,234,78,245,81,243,79,255,84,250,84,267,87,254,90,271,90,257,95,271,93,256,95,249,92,252,93,243,89,253,89,241,86,250,87,236,83,245,87,231,82,231,90,219,84,221]).setFill(c);
c = new dojo.Color("#ffcc7f");
g.createPolyline([93,68,96,72,100,73,106,72,108,66,105,63,100,62]).setFill(c);
g.createPolyline([144,64,142,68,142,73,146,74,150,73,154,64,149,62]).setFill(c);
c = new dojo.Color("#9c826b");
g.createPolyline([57,91,42,111,52,105,41,117,53,112,46,120,53,116,50,124,57,119,55,127,61,122,60,130,67,126,66,134,71,129,72,136,77,130,76,137,80,133,82,138,86,135,96,135,94,129,86,124,83,117,77,123,79,117,73,120,75,112,68,116,71,111,65,114,69,107,63,110,68,102,61,107,66,98,61,103,63,97,57,99]).setFill(c);
g.createPolyline([83,79,76,79,67,82,75,83,65,88,76,87,65,92,76,91,68,96,77,95,70,99,80,98,72,104,80,102,76,108,85,103,92,101,87,98,93,96,86,94,91,93,85,91,93,89,99,89,105,93,107,85,102,82,92,80]).setFill(c);
g.createPolyline([109,77,111,83,109,89,113,94,117,90,117,81,114,78]).setFill(c);
g.createPolyline([122,128,127,126,134,127,136,129,134,130,130,128,124,129]).setFill(c);
g.createPolyline([78,27,82,32,80,33,82,36,78,37,82,40,78,42,81,46,76,47,78,49,74,50,82,52,87,50,83,48,91,46,86,45,91,42,88,40,92,37,86,34,90,31,86,29,89,26]).setFill(c);
g.createPolyline([82,17,92,20,79,21,90,25,81,25,94,28,93,26,101,30,101,26,107,33,108,28,111,40,113,34,115,45,117,39,119,54,121,46,124,58,126,47,129,59,130,49,134,58,133,44,137,48,133,37,137,40,133,32,126,20,135,26,132,19,138,23,135,17,142,18,132,11,116,6,94,6,78,11,92,12,80,14,90,16]).setFill(c);
g.createPolyline([142,234,132,227,124,223,115,220,110,225,118,224,127,229,135,236,122,234,115,237,113,242,121,238,139,243,121,245,111,254,95,254,102,244,104,235,110,229,100,231,104,224,113,216,122,215,132,217,141,224,145,230,149,240]).setFill(c);
g.createPolyline([115,252,125,248,137,249,143,258,134,255,125,254]).setFill(c);
g.createPolyline([114,212,130,213,140,219,147,225,144,214,137,209,128,207]).setFill(c);
g.createPolyline([102,263,108,258,117,257,131,258,116,260,109,265]).setFill(c);
g.createPolyline([51,241,35,224,40,238,23,224,31,242,19,239,28,247,17,246,25,250,37,254,39,263,44,271,47,294,48,317,51,328,60,351,60,323,53,262,47,246]).setFill(c);
g.createPolyline([2,364,9,367,14,366,18,355,20,364,26,366,31,357,35,364,39,364,42,357,47,363,53,360,59,357,54,369,7,373]).setFill(c);
g.createPolyline([7,349,19,345,25,339,18,341,23,333,28,326,23,326,27,320,23,316,25,311,20,298,15,277,12,264,9,249,10,223,3,248,5,261,15,307,17,326,11,343]).setFill(c);
g.createPolyline([11,226,15,231,25,236,18,227]).setFill(c);
g.createPolyline([13,214,19,217,32,227,23,214,16,208,15,190,24,148,31,121,24,137,14,170,8,189]).setFill(c);
g.createPolyline([202,254,195,258,199,260,193,263,197,263,190,268,196,268,191,273,188,282,200,272,194,272,201,266,197,265,204,262,200,258,204,256]).setFill(c);
c = new dojo.Color("#845433");
g.createPolyline([151,213,165,212,179,225,189,246,187,262,179,275,176,263,177,247,171,233,163,230,165,251,157,264,146,298,145,321,133,326,143,285,154,260,153,240]).setFill(c);
g.createPolyline([91,132,95,145,97,154,104,148,107,155,109,150,111,158,115,152,118,159,120,153,125,161,126,155,133,164,132,154,137,163,137,152,142,163,147,186,152,192,148,167,141,143,124,145,105,143]).setFill(c);
c = new dojo.Color("#9c826b");
g.createPolyline([31,57,23,52,26,51,20,44,23,42,21,36,22,29,25,23,24,32,30,43,26,41,30,50,26,48]).setFill(c);
g.createPolyline([147,21,149,28,155,21,161,16,167,14,175,15,173,11,161,9]).setFill(c);
g.createPolyline([181,39,175,51,169,57,171,65,165,68,165,75,160,76,162,91,171,71,180,51]).setFill(c);
g.createPolyline([132,346,139,348,141,346,142,341,147,342,143,355,133,350]).setFill(c);
g.createPolyline([146,355,151,352,155,348,157,343,160,349,151,356,147,357]).setFill(c);
g.createPolyline([99,266,100,281,94,305,86,322,78,332,72,346,73,331,91,291]).setFill(c);
g.createPolyline([20,347,32,342,45,340,54,345,45,350,42,353,38,350,31,353,29,356,23,350,19,353,15,349]).setFill(c);
g.createPolyline([78,344,86,344,92,349,88,358,84,352]).setFill(c);
g.createPolyline([93,347,104,344,117,345,124,354,121,357,116,351,112,351,108,355,102,351]).setFill(c);
c = new dojo.Color("black");
g.createPolyline([105,12,111,18,113,24,113,29,119,34,116,23,112,16]).setFill(c);
g.createPolyline([122,27,125,34,127,43,128,34,125,29]).setFill(c);
g.createPolyline([115,13,122,19,122,15,113,10]).setFill(c);
c = new dojo.Color("#ffe5b2");
g.createPolyline([116,172,107,182,98,193,98,183,90,199,89,189,84,207,88,206,87,215,95,206,93,219,91,230,98,216,97,226,104,214,112,209,104,208,113,202,126,200,139,207,132,198,142,203,134,192,142,195,134,187,140,185,130,181,136,177,126,177,125,171,116,180]).setFill(c);
g.createPolyline([74,220,67,230,67,221,59,235,63,233,60,248,70,232,65,249,71,243,67,256,73,250,69,262,73,259,71,267,76,262,72,271,78,270,76,275,82,274,78,290,86,279,86,289,92,274,88,275,87,264,82,270,82,258,77,257,78,247,73,246,77,233,72,236]).setFill(c);
g.createPolyline([133,230,147,242,148,250,145,254,138,247,129,246,142,245,138,241,128,237,137,238]).setFill(c);
g.createPolyline([133,261,125,261,116,263,111,267,125,265]).setFill(c);
g.createPolyline([121,271,109,273,103,279,99,305,92,316,85,327,83,335,89,340,97,341,94,336,101,336,96,331,103,330,97,327,108,325,99,322,109,321,100,318,110,317,105,314,110,312,107,310,113,308,105,306,114,303,105,301,115,298,107,295,115,294,108,293,117,291,109,289,117,286,109,286,118,283,112,281,118,279,114,278,119,276,115,274]).setFill(c);
g.createPolyline([79,364,74,359,74,353,76,347,80,351,83,356,82,360]).setFill(c);
g.createPolyline([91,363,93,356,97,353,103,355,105,360,103,366,99,371,94,368]).setFill(c);
g.createPolyline([110,355,114,353,118,357,117,363,113,369,111,362]).setFill(c);
g.createPolyline([126,354,123,358,124,367,126,369,129,361,129,357]).setFill(c);
g.createPolyline([30,154,24,166,20,182,23,194,29,208,37,218,41,210,41,223,46,214,46,227,52,216,52,227,61,216,59,225,68,213,73,219,70,207,77,212,69,200,77,202,70,194,78,197,68,187,76,182,64,182,58,175,58,185,53,177,50,186,46,171,44,182,39,167,36,172,36,162,30,166]).setFill(c);
g.createPolyline([44,130,41,137,45,136,43,150,48,142,48,157,53,150,52,164,60,156,61,169,64,165,66,175,70,167,74,176,77,168,80,183,85,172,90,182,93,174,98,181,99,173,104,175,105,169,114,168,102,163,95,157,94,166,90,154,87,162,82,149,75,159,72,148,68,155,67,143,62,148,62,138,58,145,56,133,52,142,52,128,49,134,47,125]).setFill(c);
g.createPolyline([13,216,19,219,36,231,22,223,16,222,22,227,12,224,13,220,16,220]).setFill(c);
g.createPolyline([10,231,14,236,25,239,27,237,19,234]).setFill(c);
g.createPolyline([9,245,14,242,25,245,13,245]).setFill(c);
g.createPolyline([33,255,26,253,18,254,25,256,18,258,27,260,18,263,27,265,19,267,29,270,21,272,29,276,21,278,30,281,22,283,31,287,24,288,32,292,23,293,34,298,26,299,37,303,32,305,39,309,33,309,39,314,34,314,40,318,34,317,40,321,34,321,41,326,33,326,40,330,33,332,39,333,33,337,42,337,54,341,49,337,52,335,47,330,50,330,45,325,49,325,45,321,48,321,45,316,46,306,45,286,43,274,36,261]).setFill(c);
g.createPolyline([7,358,9,351,14,351,17,359,11,364]).setFill(c);
g.createPolyline([44,354,49,351,52,355,49,361]).setFill(c);
g.createPolyline([32,357,37,353,40,358,36,361]).setFill(c);
g.createPolyline([139,334,145,330,154,330,158,334,154,341,152,348,145,350,149,340,147,336,141,339,139,345,136,342,136,339]).setFill(c);
g.createPolyline([208,259,215,259,212,255,220,259,224,263,225,274,224,283,220,292,208,300,206,308,203,304,199,315,197,309,195,318,193,313,190,322,190,316,185,325,182,318,180,325,172,321,178,320,176,313,186,312,180,307,188,307,184,303,191,302,186,299,195,294,187,290,197,288,192,286,201,283,194,280,203,277,198,275,207,271,200,269,209,265,204,265,212,262]).setFill(c);
g.createPolyline([106,126,106,131,109,132,111,134,115,132,115,135,119,133,118,137,123,137,128,137,133,134,136,130,136,127,132,124,118,128,112,128,106,126,106,126,106,126]).setFill(c);
g.createPolyline([107,114,101,110,98,102,105,97,111,98,119,102,121,108,118,112,113,115]).setFill(c);
g.createPolyline([148,106,145,110,146,116,150,118,152,111,151,107]).setFill(c);
g.createPolyline([80,55,70,52,75,58,63,57,72,61,57,61,67,66,57,67,62,69,54,71,61,73,54,77,63,78,53,85,60,84,56,90,69,84,63,82,75,76,70,75,77,72,72,71,78,69,72,66,81,67,78,64,82,63,80,60,86,62]).setFill(c);
g.createPolyline([87,56,91,52,96,50,102,56,98,56,92,60]).setFill(c);
g.createPolyline([85,68,89,73,98,76,106,74,96,73,91,70]).setFill(c);
g.createPolyline([115,57,114,64,111,64,115,75,122,81,122,74,126,79,126,74,131,78,130,72,133,77,131,68,126,61,119,57]).setFill(c);
g.createPolyline([145,48,143,53,147,59,151,59,150,55]).setFill(c);
g.createPolyline([26,22,34,15,43,10,52,10,59,16,47,15,32,22]).setFill(c);
g.createPolyline([160,19,152,26,149,34,154,33,152,30,157,30,155,26,158,27,157,23,161,23]).setFill(c);
c = new dojo.Color("black");
g.createPolyline([98,117,105,122,109,122,105,117,113,120,121,120,130,112,128,108,123,103,123,99,128,101,132,106,135,109,142,105,142,101,145,101,145,91,148,101,145,105,136,112,135,116,143,124,148,120,150,122,142,128,133,122,121,125,112,126,103,125,100,129,96,124]).setFill(c);
g.createPolyline([146,118,152,118,152,115,149,115]).setFill(c);
g.createPolyline([148,112,154,111,154,109,149,109]).setFill(c);
g.createPolyline([106,112,108,115,114,116,118,114]).setFill(c);
g.createPolyline([108,108,111,110,116,110,119,108]).setFill(c);
g.createPolyline([106,104,109,105,117,106,115,104]).setFill(c);
g.createPolyline([50,25,41,26,34,33,39,43,49,58,36,51,47,68,55,69,54,59,61,57,74,46,60,52,67,42,57,48,61,40,54,45,60,36,59,29,48,38,52,30,47,32]).setFill(c);
g.createPolyline([147,34,152,41,155,49,161,53,157,47,164,47,158,43,168,44,159,40,164,37,169,37,164,33,169,34,165,28,170,30,170,25,173,29,175,27,176,32,173,36,175,39,172,42,172,46,168,49,170,55,162,57,158,63,155,58,153,50,149,46]).setFill(c);
g.createPolyline([155,71,159,80,157,93,157,102,155,108,150,101,149,93,154,101,152,91,151,83,155,79]).setFill(c);
g.createPolyline([112,78,115,81,114,91,112,87,113,82]).setFill(c);
g.createPolyline([78,28,64,17,58,11,47,9,36,10,28,16,21,26,18,41,20,51,23,61,33,65,28,68,37,74,36,81,43,87,48,90,43,100,40,98,39,90,31,80,30,72,22,71,17,61,14,46,16,28,23,17,33,9,45,6,54,6,65,12]).setFill(c);
g.createPolyline([67,18,76,9,87,5,101,2,118,3,135,8,149,20,149,26,144,19,132,12,121,9,105,7,89,8,76,14,70,20]).setFill(c);
g.createPolyline([56,98,48,106,56,103,47,112,56,110,52,115,57,113,52,121,62,115,58,123,65,119,63,125,69,121,68,127,74,125,74,129,79,128,83,132,94,135,93,129,85,127,81,122,76,126,75,121,71,124,71,117,66,121,66,117,62,117,64,112,60,113,60,110,57,111,61,105,57,107,60,101,55,102]).setFill(c);
g.createPolyline([101,132,103,138,106,134,106,139,112,136,111,142,115,139,114,143,119,142,125,145,131,142,135,138,140,134,140,129,143,135,145,149,150,171,149,184,145,165,141,150,136,147,132,151,131,149,126,152,125,150,121,152,117,148,111,152,110,148,105,149,104,145,98,150,96,138,94,132,94,130,98,132]).setFill(c);
g.createPolyline([41,94,32,110,23,132,12,163,6,190,7,217,5,236,3,247,9,230,12,211,12,185,18,160,26,134,35,110,43,99]).setFill(c);
g.createPolyline([32,246,41,250,50,257,52,267,53,295,53,323,59,350,54,363,51,365,44,366,42,360,40,372,54,372,59,366,62,353,71,352,75,335,73,330,66,318,68,302,64,294,67,288,63,286,63,279,59,275,58,267,56,262,50,247,42,235,44,246,32,236,35,244]).setFill(c);
g.createPolyline([134,324,146,320,159,322,173,327,179,337,179,349,172,355,158,357,170,350,174,343,170,333,163,328,152,326,134,329]).setFill(c);
g.createPolyline([173,339,183,334,184,338,191,329,194,332,199,323,202,325,206,318,209,320,213,309,221,303,228,296,232,289,234,279,233,269,230,262,225,256,219,253,208,252,198,252,210,249,223,250,232,257,237,265,238,277,238,291,232,305,221,323,218,335,212,342,200,349,178,348]).setFill(c);
g.createPolyline([165,296,158,301,156,310,156,323,162,324,159,318,162,308,162,304]).setFill(c);
g.createPolyline([99,252,105,244,107,234,115,228,121,228,131,235,122,233,113,235,109,246,121,239,133,243,121,243,110,251]).setFill(c);
g.createPolyline([117,252,124,247,134,249,136,253,126,252]).setFill(c);
g.createPolyline([117,218,132,224,144,233,140,225,132,219,117,218,117,218,117,218]).setFill(c);
g.createPolyline([122,212,134,214,143,221,141,213,132,210]).setFill(c);
g.createPolyline([69,352,70,363,76,373,86,378,97,379,108,379,120,377,128,378,132,373,135,361,133,358,132,366,127,375,121,374,121,362,119,367,117,374,110,376,110,362,107,357,106,371,104,375,97,376,90,375,90,368,86,362,83,364,86,369,85,373,78,370,73,362,71,351]).setFill(c);
g.createPolyline([100,360,96,363,99,369,102,364]).setFill(c);
g.createPolyline([115,360,112,363,114,369,117,364]).setFill(c);
g.createPolyline([127,362,125,364,126,369,128,365]).setFill(c);
g.createPolyline([5,255,7,276,11,304,15,320,13,334,6,348,2,353,0,363,5,372,12,374,25,372,38,372,44,369,42,367,36,368,31,369,30,360,27,368,20,370,16,361,15,368,10,369,3,366,3,359,6,352,11,348,17,331,19,316,12,291,9,274]).setFill(c);
g.createPolyline([10,358,7,362,10,366,11,362]).setFill(c);
g.createPolyline([25,357,22,360,24,366,27,360]).setFill(c);
g.createPolyline([37,357,34,361,36,365,38,361]).setFill(c);
g.createPolyline([49,356,46,359,47,364,50,360]).setFill(c);
g.createPolyline([130,101,132,102,135,101,139,102,143,103,142,101,137,100,133,100]).setFill(c);
g.createPolyline([106,48,105,52,108,56,109,52]).setFill(c);
g.createPolyline([139,52,139,56,140,60,142,58,141,56]).setFill(c);
g.createPolyline([25,349,29,351,30,355,33,350,37,348,42,351,45,347,49,345,44,343,36,345]).setFill(c);
g.createPolyline([98,347,105,351,107,354,109,349,115,349,120,353,118,349,113,346,104,346]).setFill(c);
g.createPolyline([83,348,87,352,87,357,89,351,87,348]).setFill(c);
g.createPolyline([155,107,163,107,170,107,186,108,175,109,155,109]).setFill(c);
g.createPolyline([153,114,162,113,175,112,192,114,173,114,154,115]).setFill(c);
g.createPolyline([152,118,164,120,180,123,197,129,169,123,151,120]).setFill(c);
g.createPolyline([68,109,87,106,107,106,106,108,88,108]).setFill(c);
g.createPolyline([105,111,95,112,79,114,71,116,85,115,102,113]).setFill(c);
g.createPolyline([108,101,98,99,87,99,78,99,93,100,105,102]).setFill(c);
g.createPolyline([85,63,91,63,97,60,104,60,108,62,111,69,112,75,110,74,108,71,103,73,106,69,105,65,103,64,103,67,102,70,99,70,97,66,94,67,97,72,88,67,84,66]).setFill(c);
g.createPolyline([140,74,141,66,144,61,150,61,156,62,153,70,150,73,152,65,150,65,151,68,149,71,146,71,144,66,143,70,143,74]).setFill(c);
g.createPolyline([146,20,156,11,163,9,172,9,178,14,182,18,184,32,182,42,182,52,177,58,176,67,171,76,165,90,157,105,160,92,164,85,168,78,167,73,173,66,172,62,175,59,174,55,177,53,180,46,181,29,179,21,173,13,166,11,159,13,153,18,148,23]).setFill(c);
g.createPolyline([150,187,148,211,150,233,153,247,148,267,135,283,125,299,136,292,131,313,122,328,122,345,129,352,133,359,133,367,137,359,148,356,140,350,131,347,129,340,132,332,140,328,137,322,140,304,154,265,157,244,155,223,161,220,175,229,186,247,185,260,176,275,178,287,185,277,188,261,196,253,189,236,174,213]).setFill(c);
g.createPolyline([147,338,142,341,143,345,141,354,147,343]).setFill(c);
g.createPolyline([157,342,156,349,150,356,157,353,163,346,162,342]).setFill(c);
g.createPolyline([99,265,96,284,92,299,73,339,73,333,87,300]).setFill(c);
//surface.createLine({x1: 0, y1: 350, x2: 700, y2: 350}).setStroke("green");
//surface.createLine({y1: 0, x1: 350, y2: 700, x2: 350}).setStroke("green");
dojo.connect(dijit.byId("rotatingSlider"), "onChange", rotatingEvent);
dojo.connect(dijit.byId("scalingSlider"), "onChange", scalingEvent);
};
 
dojo.addOnLoad(makeShapes);
 
</script>
<style type="text/css">
td.pad { padding: 0px 5px 0px 5px; }
</style>
</head>
<body class="tundra">
<h1>dojox.gfx: Lion</h1>
<p>This example was directly converted from SVG file.</p>
<table>
<tr><td align="center" class="pad">Rotation (<span id="rotationValue">0</span>)</td></tr>
<tr><td>
<div id="rotatingSlider" dojoType="dijit.form.HorizontalSlider"
value="0" minimum="-180" maximum="180" discreteValues="72" showButtons="false" intermediateChanges="true"
style="width: 600px;">
<div dojoType="dijit.form.HorizontalRule" container="topDecoration" count="73" style="height:5px;"></div>
<div dojoType="dijit.form.HorizontalRule" container="bottomDecoration" count="9" style="height:5px;"></div>
<div dojoType="dijit.form.HorizontalRuleLabels" container="bottomDecoration" labels="-180,-135,-90,-45,0,45,90,135,180" style="height:1.2em;font-size:75%;color:gray;"></div>
</div>
</td></tr>
<tr><td align="center" class="pad">Scaling (<span id="scaleValue">1.000</span>)</td></tr>
<tr><td>
<div id="scalingSlider" dojoType="dijit.form.HorizontalSlider"
value="1" minimum="0" maximum="1" showButtons="false" intermediateChanges="true"
style="width: 600px;">
<div dojoType="dijit.form.HorizontalRule" container="bottomDecoration" count="5" style="height:5px;"></div>
<div dojoType="dijit.form.HorizontalRuleLabels" container="bottomDecoration" labels="10%,18%,32%,56%,100%" style="height:1.2em;font-size:75%;color:gray;"></div>
</div>
</td></tr>
</table>
<div id="gfx_holder" style="width: 700px; height: 700px;"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/demos/images/clock_face_black.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/images/clock_face_black.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/images/clock_face.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/images/clock_face.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/circles.html
New file
0,0 → 1,92
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title>dojox.gfx: 100 draggable circles</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx");
dojo.require("dojox.gfx.move");
 
var container = null;
var container_position = null;
var surface = null;
var surface_size = null;
 
function getRand(from, to){
return Math.random() * (to - from) + from;
}
 
var skew_stat_factor = 15;
 
function getRandSkewed(from, to){
// let skew stats to smaller values
var seed = 0;
for(var i = 0; i < skew_stat_factor; ++i){
seed += Math.random();
}
seed = 2 * Math.abs(seed / skew_stat_factor - 0.5);
return seed * (to - from) + from;
}
 
function randColor(alpha){
var red = Math.floor(getRand(0, 255));
var green = Math.floor(getRand(0, 255));
var blue = Math.floor(getRand(0, 255));
var opacity = alpha ? getRand(0.1, 1) : 1;
return [red, green, blue, opacity];
}
 
var gShapes = {}
var gShapeCounter = 0;
 
function makeCircleGrid(itemCount){
var minR = 10, maxR = surface_size.width / 3;
for(var j = 0; j < itemCount; ++j){
var r = getRandSkewed(minR, maxR);
var cx = getRand(r, surface_size.width - r);
var cy = getRand(r, surface_size.height - r);
var shape = surface.createCircle({cx: cx, cy: cy, r: r})
.setFill(randColor(true))
.setStroke({color: randColor(true), width: getRand(0, 3)})
;
new dojox.gfx.Moveable(shape);
}
}
 
function initGfx(){
container = dojo.byId("gfx_holder");
container_position = dojo.coords(container, true);
surface = dojox.gfx.createSurface(container, 500, 500);
surface_size = {width: 500, height: 500};
 
makeCircleGrid(100);
 
// cancel text selection and text dragging
dojo.connect(container, "ondragstart", dojo, "stopEvent");
dojo.connect(container, "onselectstart", dojo, "stopEvent");
}
 
dojo.addOnLoad(initGfx);
 
</script>
 
<style type="text/css">
.movable { cursor: pointer; }
</style>
 
</head>
<body>
<h1>dojox.gfx: 100 draggable circles</h1>
<p>Warning: Canvas renderer doesn't implement event handling.</p>
<div id="gfx_holder" style="width: 500px; height: 500px;"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/svg2gfx.xsl
New file
0,0 → 1,72
<?xml version="1.0" encoding="UTF-8"?>
<!-- Super simple XSLT to convert Nils.svg and Lars.svg to our format -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="text" version="1.0" encoding="UTF-8"/>
<xsl:template name="fill">
<xsl:param name="node"/>
<xsl:if test="count($node/@fill) &gt; 0">
<xsl:text>fill: "</xsl:text>
<xsl:value-of select="$node/@fill"/>
<xsl:text>",</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="stroke">
<xsl:param name="node"/>
<xsl:text>stroke: {</xsl:text>
<xsl:if test="count($node/@stroke) &gt; 0">
<xsl:text>color: "</xsl:text>
<xsl:value-of select="$node/@stroke"/>
<xsl:text>",</xsl:text>
</xsl:if>
<xsl:if test="count($node/@stroke-width) &gt; 0">
<xsl:text>width: "</xsl:text>
<xsl:value-of select="$node/@stroke-width"/>
<xsl:text>",</xsl:text>
</xsl:if>
<xsl:if test="count($node/@stroke-linecap) &gt; 0">
<xsl:text>cap: "</xsl:text>
<xsl:value-of select="$node/@stroke-linecap"/>
<xsl:text>",</xsl:text>
</xsl:if>
<xsl:if test="count($node/@stroke-linejoin) &gt; 0">
<xsl:text>join: "</xsl:text>
<xsl:value-of select="$node/@stroke-linejoin"/>
<xsl:text>",</xsl:text>
</xsl:if>
<xsl:text>},</xsl:text>
</xsl:template>
<xsl:template match="g">
<xsl:text>{</xsl:text>
<xsl:if test="count(@id) &gt; 0">
<xsl:text>name: "</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>",</xsl:text>
</xsl:if>
<xsl:text>children: [</xsl:text>
<xsl:apply-templates select="g|path"/>
<xsl:text>]},</xsl:text>
</xsl:template>
<xsl:template match="path">
<xsl:text>{</xsl:text>
<xsl:if test="count(@id) &gt; 0">
<xsl:text>name: "</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>",</xsl:text>
</xsl:if>
<xsl:text>shape: {type: "path", path: "</xsl:text>
<xsl:value-of select="@d"/>
<xsl:text>"},</xsl:text>
<xsl:call-template name="fill">
<xsl:with-param name="node" select="."/>
</xsl:call-template>
<xsl:call-template name="stroke">
<xsl:with-param name="node" select="."/>
</xsl:call-template>
<xsl:text>},</xsl:text>
</xsl:template>
<xsl:template match="svg">
<xsl:text>[</xsl:text>
<xsl:apply-templates select="g|path"/>
<xsl:text>]</xsl:text>
</xsl:template>
</xsl:stylesheet>
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino.json
New file
0,0 → 1,12
[
{name: "bg", shape: {type: "image", width: 321, height: 355, src: "data/buratino-bg.png"}},
{name: "left-arm", shape: {type: "image", width: 111, height: 40, src: "data/buratino-left-arm.png"}},
{name: "right-arm", shape: {type: "image", width: 59, height: 130, src: "data/buratino-right-arm.png"}},
{name: "left-leg", shape: {type: "image", width: 152, height: 99, src: "data/buratino-left-leg.png"}},
{name: "right-leg", shape: {type: "image", width: 104, height: 158, src: "data/buratino-right-leg.png"}},
{name: "torso", shape: {type: "image", width: 90, height: 130, src: "data/buratino-torso.png"}},
{name: "head", shape: {type: "image", width: 116, height: 139, src: "data/buratino-head.png"}},
{name: "nose-medium", shape: {type: "image", width: 50, height: 43, src: "data/buratino-nose-medium.png"}},
{name: "nose-large", shape: {type: "image", width: 70, height: 66, src: "data/buratino-nose-large.png"}},
{name: "lollipop", shape: {type: "image", width: 82, height: 144, src: "data/buratino-lollipop.png"}}
]
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-bg.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-bg.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-lollipop.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-lollipop.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-right-arm.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-right-arm.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/Lars.svg
New file
0,0 → 1,531
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/">
<g id="torso" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#000000000000">
<path id="leftArm" i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M156.007,292.674c2.737,1.779,5.563,3.322,8.752,3.947c7.098,1.39,19.25-5.666,23.136-11.699
c1.572-2.441,8.077-21.031,11.177-14.271c1.224,2.67-1.59,4-1.399,6.462c3.108-1.425,5.48-5.242,8.918-2.182
c0.672,4.019-4.472,4.343-3.918,7.669c1.376,0.218,5.394-1.595,6.285-0.535c1.707,2.027-2.933,3.561-4.072,4.018
c-1.852,0.741-4.294,1.233-5.988,2.369c-2.636,1.768-4.766,5.143-7.034,7.4c-11.657,11.604-26.183,10.553-40.646,5.515
c-4.713-1.642-17.399-4.472-18.655-9.427c-1.647-6.502,5.523-7.999,10.184-6.74C147.658,286.528,151.725,289.891,156.007,292.674z
"/>
<path id="leftArmThumb" i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M188.257,284.902c-1.932-1.391-3.314-4.206-3.506-6.494c-0.149-1.786,0.59-6.522,3.199-3.95c0.792,0.78,0.083,2.155,0.558,2.943
c0.885,1.47,1.071,0.493,2.748,1.002c1.406,0.426,3.827,2.05,4.251,3.499"/>
<path id="rightArm" i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M57.05,283.306c-5.502,5.354-13.185,8.541-18.249,14.221c-4.303,4.827-7.721,11.575-11.138,17.112
c-6.752,10.939-10.794,26.076-19.912,35.185c-3.869,3.866-7.637,5.721-7.251,12.032c0.932,0.372,1.548,0.589,2.418,0.683
c0.605-2.746,2.569-4.199,5.362-3.799c-0.14,3.365-3.512,5.941-3.228,9.235c0.364,4.223,3.983,5.968,7.181,2.662
c2.61-2.699,0.192-7.848,3.338-10.179c5.535-4.103,2.889,2.998,4.13,5.514c5.19,10.519,8.634-1.859,7.35-7.996
c-2.336-11.159-3.003-15.126,3.267-24.416c6.358-9.419,12.194-18.708,19.399-27.588c1.116-1.375,2.08-2.728,3.333-4"/>
<g id="shirt" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F008000FFFF">
<path id="tShirt" i:knockout="Off" fill="#4459A5" stroke="#000000" stroke-linecap="round" d="M96.509,268.264
c-2.301,0.323-4.69,0.205-6.945,0.72c-2.234,0.509-4.5,0.8-6.749,1.249c-4.369,0.872-8.206,3.265-12.3,5.024
c-3.259,1.401-6.644,2.571-9.763,4.26c-1.923,1.041-3.688,2.616-5.487,3.97c-1.543,1.16-3.495,2.11-4.854,3.562
c-2.205,2.354,0.896,7.408,1.854,9.873c0.92,2.368,2.149,4.82,2.749,7.29c0.228,0.937,0.235,2.058,0.875,2.873
c0.644,0.821,0.64,0.735,1.822,0.048c1.513-0.878,2.873-1.993,4.329-2.993c2.431-1.67,5.462-2.848,7.434-5.111
c-3.335,1.652-5.335,4.679-6.931,8.012c-1.398,2.92-4.482,35.854-5.389,38.947c-0.195,0.003-0.775,0.003-0.749,0.013
c20.561,0,41.123-0.07,61.684,0c2.1,0.007,3.607-0.497,5.529-1.252c0.715-0.281,2.257-0.356,2.807-0.745
c1.412-0.998-0.094-3.916-0.646-5.302c-1.425-3.579-2.111-37.767-4.726-40.543c1.842,0.057,4.127,1.311,5.937,1.95
c1.351,0.478,2.633,1.092,3.956,1.66c1.39,0.597,3.667,1.927,5.168,1.858c0.296-1.873,1.045-3.286,1.839-5.02
c0.943-2.061,1.155-4.214,1.528-6.415c0.351-2.07,0.898-3.787,1.939-5.635c0.531-0.942,1.356-1.73,1.693-2.768
c-0.443-0.402-1.043-0.907-1.603-1.125c-0.56-0.219-1.292-0.111-1.908-0.33c-1.237-0.438-2.44-1.089-3.669-1.576
c-3.773-1.499-7.519-2.983-11.319-4.466c-3.575-1.396-6.977-3.239-10.784-3.872c-1.735-0.289-3.467-0.529-5.073-0.906"/>
<path id="shirtNeck" i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" d="M99.759,268.889
c-0.984,0.152-1.746-0.549-2.75-0.5c-1.369,0.066-1.649,0.872-2.153,2c-1.037,2.325-2.442,4.974,0.064,6.946
c2.53,1.991,6.964,1.717,9.829,0.803c1.616-0.516,3.045-1.24,3.825-2.867c0.508-1.061,0.935-2.771,0.149-3.598
c-0.231-0.243-0.562-0.376-0.84-0.534"/>
<g id="shirtLogo" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F008000FFFF">
<g i:knockout="Off">
<path i:knockout="Off" d="M104.864,296.92c-0.151-0.003,7.101,0.41,7.052,0.404c0.132,0.028-0.172,0.633-0.021,0.632
c-0.226,0.028-7.244-0.454-7.28-0.464C104.657,297.518,104.776,296.904,104.864,296.92z"/>
</g>
<g i:knockout="Off">
<path i:knockout="Off" d="M90.071,295.919c-0.199,0.004,6.792,0.43,6.79,0.446c0.153,0.005-0.031,0.663,0.012,0.665
c0.272,0.015-6.79-0.471-6.875-0.459C89.881,296.56,89.796,295.899,90.071,295.919z"/>
</g>
<path i:isolated="yes" i:knockout="Off" enable-background="new " d="M84.407,306.476c0.2-0.159,0.322-1.04,0.254,0.057
c-0.542-0.356-2.02,2.083-4.215,2.001c-1.887-1.706-4.559-3.384-4.302-7.092c0.652-2.599,3.082-4.084,5.213-3.942
c1.889,0.377,2.899,0.716,4,1.318c-0.497,0.957-0.175,0.866-0.459,0.703c0.456-2.398,0.598-5.75,0.312-7.855
c0.594-0.554,0.714,0.125,1.249,0.941c0.502-0.727,0.509-1.425,0.875-0.571c-0.207,1.328-0.809,7.186-0.711,10.174
c-0.126,2.797-0.375,4.354-0.051,4.985c-0.718,0.613-0.667,1.006-0.981,1.381c-0.72-1.33-1.056-0.132-1.339-0.157
C84.632,308.442,84.493,305.791,84.407,306.476z M81.186,307.176c2.403,0.206,3.734-2.164,3.841-4.222
c0.269-2.72-0.896-5.104-3.198-5.04c-1.972,0.437-3.46,2.188-3.331,4.638C78.171,306.265,79.847,306.961,81.186,307.176z"/>
<path i:isolated="yes" i:knockout="Off" enable-background="new " d="M93.321,297.766c2.592,0.148,5.688,2.315,5.696,5.627
c-0.611,4.576-3.69,5.316-6.158,5.581c-2.68-0.76-5.708-1.872-5.413-6.472C88.086,299.394,90.653,297.875,93.321,297.766z
M92.939,307.46c2.531,0.735,3.706-1.297,3.666-3.935c0.114-2.219-0.641-4.584-3.389-4.896c-2.29-0.552-3.366,2.188-3.661,4.688
C89.339,305.264,89.934,307.95,92.939,307.46z"/>
<path i:isolated="yes" i:knockout="Off" enable-background="new " d="M99.688,303.916c0.03-1.511,0.055-4.731,0.022-4.646
c0.481-1.355,0.658-0.556,1.034-1.297c0.263,1.473,0.653,0.326,1.186,0.066c-0.386,2.517-0.513,3.347-0.574,4.949
c-0.068-0.47-0.128,2.28-0.238,2.188c-0.055,1.935-0.036,2.201-0.047,4.219c-0.079,0.914-0.28,2.412-1.126,3.831
c-0.61,1.212-1.73,1.146-3.24,1.651c0.073-0.945-0.065-1.242-0.096-1.822c0.098,0.138,0.213,0.604,0.225,0.398
c1.892,0.228,2.209-1.896,2.362-3.366c0.042,0.304,0.512-6.933,0.415-7.061C99.73,302.636,99.75,303.178,99.688,303.916z
M100.978,295.564c0.717,0.14,1.11,0.61,1.099,1.156c0.052,0.552-0.595,0.993-1.286,1.015c-0.541-0.074-1.025-0.548-1.022-1.054
C99.813,296.084,100.292,295.643,100.978,295.564z"/>
<path i:isolated="yes" i:knockout="Off" enable-background="new " d="M108.115,298.791c3.028-0.067,5.283,1.359,5.256,5.757
c-0.264,3.479-3.366,4.63-5.883,5.12c-2.429-0.034-5.619-2.241-5.16-5.811C102.322,300.085,105.715,298.845,108.115,298.791z
M107.351,309.232c2.675-0.132,3.839-2.333,3.841-4.497c0.246-2.344-0.263-4.833-2.923-5.396
c-2.844,0.299-3.974,1.917-4.053,4.48C104.136,306.655,104.854,308.372,107.351,309.232z"/>
</g>
</g>
</g>
<g id="heads" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F004F00FFFF">
<g id="head1" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFFFFFF4F00">
<g id="leftEart" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFFFFFF4F00">
<path i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M201.557,195.474
c7.734-4.547,16.591-5.012,18.405,4.443c2.43,12.659-3.317,13.328-14.598,13.328"/>
<path i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M211.711,203.09
c0.523,0.004,0.946-0.208,1.27-0.635"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M211.076,197.377
c3.062,3.013,5.489,5.624,4.443,10.155"/>
</g>
<path id="bgHairTop" i:knockout="Off" fill="#FFF471" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M54.384,199.306c-5.253-4.402-7.511-11.061-15.779-10.632c3.449-1.277,7.116-2.397,10.911-2.666
c-2.873-1.397-5.865-2.575-8.231-4.718c3.986-1.119,11.47-1.817,14.864,0.75c-5.183-2.758-8.397-7.816-13.062-10.598
c6.014-0.643,12.377,0.978,18.022,2.265c-2.547-4.486-6.682-10.83-10.523-14.297c5.033,1.052,10.647,4.518,15.062,7.177
c-1.614-4.176-5.634-8.406-7.859-12.513c10.312-1.125,12.522,4.919,19.7,9.932c-0.412-0.127-1.114-0.113-1.527,0.015
c0.875-7.261,3.058-12.8,8.258-18.566c6.771-7.507,17.812-9.131,24.095-15.381c-4.699,1.821-4.518,23.765-4.875,28.955"/>
<path id="bgHairLeft" i:knockout="Off" fill="#FFF471" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M92.384,243.972c-6.334,7.929-12.601,12.241-22.465,15.362c3.65-1.263,7.735-5.86,7.695-9.928
c-2.208,0.218-4.49,0.605-6.498,1.097c1.244-1.097,2.087-3.239,3.198-4.396c-5.77,0.001-12.131,1.133-18.396,1.23
c5.013-2.809,10.665-3.25,12.398-9.246c-3.59,0.313-7.233,1.606-11.033,1.097c1.731-2.022,3.953-3.995,5.049-6.447
c-3.781,0.056-6.665,3.098-10.547,2.465c0.962-2.863,3.187-5.208,4.531-7.766c-5.59-0.273-11.658,2.45-17.732,2.564
c5.494-2.857,8.967-7.819,12.3-12.718c5.233-7.693,10.625-9.96,20.349-9.981c11.059-0.024,15.558,6.714,20.984,16
c2.786,4.767,7.249,14.375,0.832,18"/>
<path id="bgHair" i:knockout="Off" fill="#FFF471" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M142.384,255.306c2.984,6.076,3.567,11.856,10.531,14.6c-0.134-3.114-0.094-6.664,1.619-9.033
c1.605,1.968,3.122,4.211,5.048,5.698c-0.29-1.769,0.412-4.024,0.233-5.828c3.445,0.26,4.979,3.965,8.468,4.479
c0.066-2.78,0.427-5.151,0.868-7.813c2.687,0.2,4.768,1.565,7.132,2.997c0.452-4.921-0.409-10.579-0.667-15.666
c-5.795-0.756-12.291,2.827-17.899,3.899c-4.414,0.844-14.136,0.524-15.333,6"/>
<path id="neck" i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M106.989,254.499c-2.932,6.063-4.613,11.997-8.947,17.137c7.288,10.195,16.311-10.9,15.183-17.026
c-1.926-1.138-3.928-1.589-6.236-1.38"/>
<path id="headShape" i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M210.941,207.665c-0.843,3.985-2.081,7.982-3.769,11.783c-3.374,7.604-8.543,14.427-16.052,18.899
c-2.94,2.13-5.983,4.167-9.109,6.085c-25.013,15.342-55.353,23.08-82.254,10.57c-3.433-1.557-6.785-3.431-10.053-5.66
c-1.821-1.184-3.592-2.46-5.308-3.832c-1.715-1.373-3.375-2.842-4.972-4.412c-2.352-2.148-4.576-4.425-6.631-6.814
c-6.168-7.169-10.823-15.358-12.87-24.185c-0.649-3.284-0.84-6.634-0.5-9.975c4.48-13.743,14.22-24.364,26.109-32.149
c2.973-1.946,6.079-3.715,9.271-5.309c30.581-15.027,69.581-10.027,95.851,12.209c2.564,2.254,4.988,4.651,7.244,7.178
c4.513,5.054,8.354,10.626,11.312,16.64C210.178,201.505,210.798,204.496,210.941,207.665z"/>
<g id="rightEar" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFFFFFF4F00">
<path i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M64.857,195.606
c-6.59-7.181-15.047-10.664-19.467,3.676c-1.235,4.007-1.87,14.468,1.29,17.786c4.223,4.435,13.591,0.529,19.055-0.015"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M52.407,196.743
c-1.702,3.613-1.257,7.505-1.27,11.424"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M51.772,209.437
c-3.39-4.661,0.922-5.769,5.078-6.347"/>
</g>
<path id="fgHair" i:knockout="Off" fill="#FFF471" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M90.384,154.639c8.453-11.353,15.678-13.458,28.581-15.915c-1.382,3.376-3.89,7.352-5.179,11.16
c5.01-1.816,9.571-6.545,15.218-8.413c11.355-3.755,23.852-1.903,35.671-2.213c-3.004,3.712-4.912,7.88-2.026,11.447
c5.856-2.212,13.37-6.871,19.635-6.646c0.263,4.561-0.024,9.278,0.201,13.841c3.509-1.201,6.015-3.04,8.277-5.148
s3.761-4.049,4.942-5.2c1.063,2.408,2.134,5.334,2.24,8.494c-0.182,3.462-0.866,6.794-2.66,9.291
c3.663,0.65,6.098-2.021,8.35-4.479c-0.655,4.349-3.164,8.604-3.851,13.013c2.178-0.072,4.382,0.216,6.367-0.48
c-1.389,3.093-3.069,7.287-6.616,8.414c-4.475,1.423-4.354-0.992-7.315-4.332c-4.892-5.518-9.774-6.791-15.872-9.464
c-6.585-2.887-10.983-6.47-17.963-8.219c-8.994-2.255-19.864-3.867-28.093-5.196c2.466,1.967,1.138,5.594,0.659,8.625
c-2.729-0.645-4.41-3.813-6.301-5.158c0.953,3.195,0.983,6.953-2.134,8.491c-6.145-5.226-9.199-9.721-17.527-11.647
c1,1.83,1.728,4.208,1.396,6.402c-0.751,4.971-0.289,3.134-3.836,2.466c-5.192-0.977-9.953-3.677-15.815-4.496
c3.292,2.002,5.469,5.017,7.418,8.21c-2.651,0.404-6.238,0.257-8.382,1.671c2.456,0.38,3.44,2.166,3.197,4.714
c-7.45,0.386-13.623,0.731-19.915,5.434"/>
</g>
</g>
<g id="eyes" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFF4F00FFFF">
<g id="eyes1" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#4F00FFFFFFFF" display="none">
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M123.163,176.668
c-5.066,1.17-9.01,7.888-13.666,10.335c-4.238,2.227-8.648,6.636-7.009,12.332c1.971,6.848,12.042,3.991,16.261,1.165
c5.282-3.539,9.59-8.517,12.006-14.524c1.523-3.787,2.568-7.272-1.509-9.391c-2.905-1.51-8.174-1.386-11.417-0.583"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" stroke-linecap="round" d="M182.545,179.865
c-3.533,0.169-4.854-1.166-8.408-0.001c-3,0.983-6.24,1.936-8.852,3.743c-3.938,2.725-7.46,5.555-4.73,13.592
c1.973,5.811,8.791,7.571,14.656,6.667c5.537-0.854,9.078-4.977,11.408-10.007c3.666-7.918,0.943-11.639-6.742-13.659"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M108.829,183.668c-1.308-1.03-4.557,0.011-5.6-1.733
c-1.056-1.765,1.735-5.409,2.984-6.192c5.684-3.562,15.946-0.39,19.95-6.742"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M163.877,167.198c2.369,1.282,6.539,0.307,9.408,0.815
c3.449,0.612,7.066,2.657,10.592,2.851"/>
<path i:knockout="Off" display="inline" stroke="#000000" d="M127.496,192.002c-4.917-2.12-9.188-1.708-8.608,4.942
c3.132,1.734,5.428-2.82,7.275-4.942"/>
<path i:knockout="Off" display="inline" stroke="#000000" d="M174.852,203.143c-0.293,0.12-0.307,0.577-0.943,0.282
c-1.605-3.188-0.404-6.507,2.676-8.192c2.15-1.176,5.67-1.759,7.471,0.359c0.199,0.234,0.412,0.521,0.514,0.813
c0.229,0.649-0.285,0.95-0.285,0.95s-3.988,6.009-3.285,1.934c0.438,1.743-5.537,5.743-2.287,1.653
c-1.955,2.583-2.525,1.977-3.859,2.868"/>
</g>
<g id="eyes2" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#800080008000" display="none">
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M98.668,186.108c0.668-8.915,15.545-13.749,22.667-15"
/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M169.667,178.108
c5.307,3.436,16.928,5.632,19.668,12.333"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M105.334,197.775c8.085-4.283,17.059-2.8,25-6.333"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M164.001,198.775c4.656-0.417,9.664,1.805,14.334,2.017
c3.951,0.18,5.773,0.189,9,2.316"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M124.001,188.108c3.039-0.258,4.594,2.571,5.301,4.983
c-1.096,1.242-2.065,2.646-2.968,4.017"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M168.335,194.108c-1.77,2.293-4.869,3.271-6.299,5.91
c1.377,0.991,3.02,2.122,3.965,3.424"/>
</g>
</g>
<g id="beard" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFF4F00">
<path i:knockout="Off" fill="#AFA8A5" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M96.05,213.639
c-0.366,0.21-0.783,0.389-1.167,0.5"/>
<path i:knockout="Off" fill="#AFA8A5" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M102.55,211.972
c0.314-0.01,0.554-0.198,0.667-0.5"/>
<path i:knockout="Off" fill="#AFA8A5" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M105.717,208.805
c0.164-0.109,0.336-0.224,0.5-0.333"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M111.05,207.972
c-0.651-1.81,0.859-2.262,2.333-1.5"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M117.717,209.805
c1.738,0,3.653,0.369,5.333,0.167"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M132.717,214.472
c0.104-0.21,0.162-0.435,0.167-0.667"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M139.551,216.972
c0.215-0.175,0.465-0.426,0.666-0.667"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M144.551,213.305
c0.277-0.056,0.556-0.111,0.833-0.167"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M147.884,216.639
c0.195,0.045,0.369-0.013,0.5-0.167"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M148.384,214.139
c0.112-0.168,0.222-0.332,0.333-0.5"/>
<path i:knockout="Off" display="none" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M98.217,219.305c1.697-1.772,4.233-2.109,5.967-4.046c1.519-1.696,3.812-3.001,4.2-5.454"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M152.717,216.139
c0.611,0,1.223,0,1.834,0"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M160.384,217.472
c0.333,0,0.667,0,1,0"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M163.217,215.972
c0.321-0.042,0.658-0.175,0.834-0.333"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M164.217,218.805
c0.167,0,0.333,0,0.5,0"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M168.384,217.972
c0.056-0.056,0.111-0.111,0.167-0.167"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M169.884,225.805
c0.491-0.397,0.882-0.926,1.167-1.5"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M172.717,221.972
c0.056,0,0.111,0,0.167,0"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M171.717,229.805
c0.334,0.075,0.659,0.025,0.834-0.167"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M190.051,227.805
c0.163-0.242,0.398-0.423,0.666-0.5"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M197.384,221.472
c0.258-0.007,0.485-0.125,0.667-0.333"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M199.384,214.972
c-0.04-0.333,0.075-0.609,0.333-0.833"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M117.884,257.305
c0.056,0,0.111,0,0.167,0"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M142.717,252.472
c0.358,0.069,0.71,0.016,1-0.167"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M137.884,256.472
c0.277,0,0.556,0,0.833,0"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M160.884,252.972
c0.366-0.138,0.765-0.402,1-0.667"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M171.384,250.139
c0.235-0.263,0.475-0.561,0.667-0.834"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M89.384,243.972
c0.537,0.378,1.329,0.876,1.833,1.333"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M79.05,225.472
c0.087,0.272,0.143,0.55,0.167,0.833"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M73.884,222.639
c0,0.167,0,0.333,0,0.5"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M72.55,219.805c0.466-0.325,0.875-0.797,1.167-1.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M71.717,211.972c0.422-0.553,0.776-1.305,1-2"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M78.55,214.472c0-0.111,0-0.222,0-0.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M79.384,218.805c-0.001-0.137,0.055-0.248,0.167-0.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M80.217,221.139c0.111,0,0.222,0,0.333,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M75.55,226.472c0.103-0.5,0.156-0.977,0.167-1.5"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M78.55,230.139c0.111,0,0.222,0,0.333,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M83.384,227.639c0.118-0.059,0.215-0.107,0.333-0.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M81.55,237.139c0.056,0,0.111,0,0.167,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M86.217,233.805c0.056,0,0.111,0,0.167,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M87.884,230.472c0.595-0.181,1.219-0.527,1.833-0.667"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M88.717,222.139
c-0.929,2.359-1.615,4.865-2.667,7.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M89.05,216.139
c0.784-0.736,1.709-1.565,2.833-1.5"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M94.217,210.139
c1.599-0.089,3.199-0.167,4.833-0.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M94.884,224.639
c0.052-0.588-0.004-1.155-0.167-1.667"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M92.384,228.305
c0.585-0.062,1.244-0.132,1.667-0.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M88.717,240.139
c0.111,0,0.222,0,0.333,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M95.884,243.305
c0.526,0.1,1.017-0.015,1.333-0.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M98.55,248.305
c0.069-0.24,0.265-0.926,0.333-1.166"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M96.55,249.805
c0.125,0.014,0.18-0.042,0.167-0.166"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M104.55,250.139
c0.01-0.238,0.126-0.428,0.333-0.5"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M106.884,251.972
c0.195,0.045,0.37-0.013,0.5-0.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M113.884,254.805
c0.758-0.586,1.595-1.171,2.382-1.774c0.072,0.376,0.418,0.685,0.48,1.079c0.833,0.265,1.624-0.021,1.638-0.971"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M122.217,254.639
c0.063-0.165,0.179-0.288,0.333-0.334"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M125.884,255.805
c1.13-0.745,2.783-0.962,3.667-2"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M132.217,255.972
c0.638-0.492,1.104-1.173,1.141-1.975c-1.11,0.062-1.449-0.888-1.475-1.858"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M129.717,249.305
c-0.045,0.154-0.168,0.271-0.333,0.334"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M136.551,252.305
c0.222,0,0.444,0,0.666,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M110.217,251.305
c0.056-0.056,0.111-0.11,0.167-0.166"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M140.717,251.805
c0.111,0,0.223,0,0.334,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M150.051,249.472
c0.111,0,0.222,0,0.333,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M143.217,255.472
c1.022-0.313,1.724-1.175,2.646-1.654c0.203,0.321,0.44,0.626,0.521,0.987"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M152.217,253.472
c0.165-0.063,0.288-0.179,0.334-0.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M155.051,254.639
c0.222,0,0.444,0,0.666,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M157.717,256.472
c0.326-0.027,0.546-0.073,0.834-0.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M163.217,252.639
c0.552-0.891,2.082-1.512,2.341-2.334c0.37-1.177-1.156-3.069-1.007-4.5"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M167.384,235.972
c0.118-0.54,0.353-1.064,0.667-1.5"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M170.717,242.805
c0-0.333,0-0.667,0-1"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M170.217,236.972
c0-0.333,0-0.667,0-1"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M179.051,235.805
c0.378-0.101,0.738-0.35,1-0.667"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M185.051,232.805
c0.379-0.319,0.656-0.702,0.833-1.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M188.051,231.139
c0.063-0.39,0.178-0.792,0.333-1.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M197.884,223.305
c-0.166,0.277-0.334,0.556-0.5,0.833"/>
</g>
<g id="mouths" i:isolated="yes" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFF4F004F00" enable-background="new ">
<g id="mouth1" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#4F00FFFF4F00" display="none">
<path i:knockout="Off" display="inline" stroke="#000000" d="M177.122,216.821c-0.515,2.282-5.213,3.21-7.433,3.854
c-3.254,0.945-6.596,1.345-9.895,1.851c-3.26,0.5-6.665,0.671-10.107,0.671c-3.596,0-6.645,0.559-10.107,0.671
c-3.105,0.1-6.898-0.474-9.694-1.3c-3.527-1.043-6.672-1.666-10.096-3.062c-2.823-1.152-5.746-1.876-8.462-3.143
c-2.594-1.209-6.084-1.994-8.221-3.552c-1.068,1.834-5.867,3.748-8.1,4.546c-2.444,0.874-8.881,2.725-7.817,5.512
c0.457,1.195,1.948,2.273,2.63,3.385c0.774,1.261,1.139,2.601,2.057,3.859c1.83,2.5,4.506,4.773,6,7.34
c1.308,2.249,2.096,4.74,4.01,6.67c2.214,2.233,5.792,2.634,9.231,2.399c7.028-0.479,13.982-2.129,20.481-3.983
c3.295-0.941,6.699-1.536,10.087-2.686c3.272-1.111,6.641-3,9.402-4.777c5.248-3.377,10.278-6.409,14.283-10.705
c1.479-1.587,3.429-2.503,5.15-3.859"/>
<path i:knockout="Off" display="inline" fill="#FFC0C0" stroke="#000000" d="M135.25,241.319
c0.723-4.757-10.487-8.47-14.898-9.526c-3.09-0.74-6.68-1.17-9.858-1.712c-2.758-0.47-6.865-0.836-9.437,0.369
c-1.385,0.649-2.843,1.724-4.141,2.513c2.156,3.964,4.728,8.861,9.468,11.506c3.229,1.801,5.511,0.777,8.859,0.373
c3.045-0.369,6.046-0.703,9.029-1.72c3.479-1.186,7.228-2.385,10.978-2.475"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M148.656,225.547c1.267,0.697,1.301,2.838,0.671,3.9
c-0.702,1.182-2.063,1.4-3.306,2.01c-2.271,1.116-4.581,2.624-7.482,2.638c-4.619,0.023-2.143-4.067-0.253-5.869
c2.405-2.292,5.057-2.72,8.72-2.512c0.588,0.034,1.095,0.041,1.65,0.168"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M130.299,223.365
c2.687,0.437,5.619,4.384,3.727,6.422c-1.234,1.33-7.94,1.391-9.915,1.296c-4.896-0.233-2.502-2.445-0.613-4.525
c1.604-1.767,5.088-3.249,7.833-3.36"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M113.178,217.157
c2.56,0.958,4.922,5.057,5.352,7.215c0.377,1.885-0.324,2.106-2.526,2.643c-1.366,0.333-3.636,0.723-5.105,0.385
c-2.506-0.577-5.883-5.051-4.909-7.223c1.03-2.298,5.944-2.923,8.427-2.852"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M99.359,217.661
c2.038,0.432,4.015,4.279,2.468,5.625c-1.083,0.943-5.221,1.795-6.799,1.589c-4.032-0.526-2.265-4.102-0.866-5.872
c0.706-0.894,1.049-1.976,2.514-2.186c1.627-0.233,2.501,0.99,3.921,1.346"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M181.815,222.895c-3.101-2.75-4.764-8.777-9.282-10.403
"/>
</g>
<g id="mouth2" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#4F00FFFF4F00" display="none">
<path i:knockout="Off" display="inline" stroke="#000000" stroke-width="3" stroke-linecap="round" stroke-linejoin="bevel" d="
M87.57,221.951c5.563-1.759,11.066-1.32,16.694-1.782c2.93-0.24,5.228-1.14,8.309-0.927c3.142,0.217,6.085-0.235,9.289,0.176
c7.136,0.914,13.96,0.598,21.112,1.506c3.654,0.464,7.218,0.609,10.81,0.869c4.017,0.291,7.646,1.582,11.433,2.623
c2.948,0.812,6.347,1.618,9.011,2.99c2.521,1.298,6.354,2.856,8.3,4.72c-2.775,0.027-5.601,2.603-8.021,3.769
c-2.93,1.412-5.741,2.949-8.656,4.432c-5.599,2.849-11.885,5.468-18.104,6.53c-6.793,1.161-13.195,2.107-20.067,2.197
c-7.699,0.102-14.313-4.705-20.735-8.396c-2.071-1.19-4.69-2.182-6.504-3.666c-1.792-1.466-3.469-3.386-5.154-4.984
c-2.703-2.564-7.519-5.649-8.13-9.438"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" stroke-width="2" d="M87.785,228.193
c-5.907-3.235-0.344-9.531,3.971-11.424"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M184.679,227.228c-1.534,2.583-2.548,5.334-4.025,7.889"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M106.862,219.528
c-3.071-0.74-5.608,2.166-6.318,4.738c-0.379,1.375-0.494,2.55,0.748,3.337c1.519,0.962,2.905-0.052,4.418-0.332
c2.518-0.467,7.293,0.053,6.461-4.248c-0.568-2.938-3.743-3.682-6.338-3.335c-0.451,0.06-0.758,0.212-1.205,0.229"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M119.764,218.479
c-2.648,1.243-4.657,3.518-5.346,6.377c-0.866,3.594,3.9,3.711,6.356,2.865c2.64-0.91,4.77-3.351,3.299-6.133
c-1.01-1.91-3.979-2.548-6.026-2.823"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M130.388,219.492
c-1.753,1.382-4.069,4.525-4.835,6.61c-1.159,3.156,2.296,3.371,4.868,3.348c3.061-0.028,6.6-1.148,5.022-4.78
c-1.168-2.691-2.552-4.85-5.551-5.241"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M142.954,221.087
c-1.502,0.337-5.418,3.249-5.638,4.997c-0.292,2.311,4.856,4.536,6.854,4.234c2.503-0.377,4.384-3.175,3.167-5.65
c-0.92-1.873-3.36-2.252-4.508-3.932"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M155.354,222.663
c-2.039,0.426-4.212,2.287-4.766,4.444c-0.723,2.821,3.225,3.383,5.458,3.331c2.541-0.059,5.126-1.752,3.249-4.32
c-1.394-1.908-3.707-3.189-5.304-4.636"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M168.367,237.924
c-1.554-1.217-3.302-2.557-5.203-2.976c-2.973-0.654-3.537,2.131-3.377,4.406c0.205,2.913,1.032,3.883,3.901,2.344
c1.988-1.066,4.272-1.997,4.599-4.456"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M151.524,246.202
c-1.912-0.166-4.003-4.491-2.91-6.25c0.771-1.239,5.456-1.688,6.858-1.292c0.271,0.917,0.979,1.841,0.829,2.771
c-0.088,0.54-0.994,1.645-1.296,2.188c-1.08,1.951-2.133,1.866-3.998,2.684"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M145.911,241.457
c-0.209,1.649-0.215,2.702-1.528,3.801c-0.885,0.739-1.773,1.19-2.54,2.1c-0.786,0.933-1.226,2.38-2.792,1.812
c-1.042-0.377-1.959-2.318-2.138-3.311c-0.299-1.676-1.003-5.228,0.783-6.158c1.155-0.603,7.067-0.18,7.43,1.32"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M133.12,238.991
c-1.495-0.087-2.253-1.33-3.918-0.964c-1.42,0.311-2.489,1.354-2.54,2.836c-0.052,1.527,0.99,5.581,1.852,6.956
c2.363,3.771,4.329-1.535,5.516-3.159c1.117-1.526,2.643-2.053,2.271-3.958c-0.318-1.632-1.118-2.047-2.766-2.329
c-0.382-0.065-0.773-0.095-1.158-0.147"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M116.853,237.429
c-1.049,2.211-0.173,5.147,0.047,7.566c0.357,3.929,3.827,2.028,5.831,0.067c1.575-1.541,4.599-4.86,2.209-6.484
c-1.881-1.279-5.727-2.458-7.756-1.107"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M107.455,233.38
c-0.813,2.487-1.704,5.049,0.073,7.364c1.91,2.486,4.009,1.229,5.537-0.939c1.056-1.5,3.316-4.481,1.563-6.017
c-1.347-1.179-6.468-1.518-7.854-0.325"/>
</g>
<g id="mouth3" i:isolated="yes" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFF4F00" enable-background="new ">
<path i:knockout="Off" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M99.05,218.972
c1.691-0.875,3.313-2.39,4.833-3.537c1.231-0.928,2.782-1.671,3.5-3.072c1.846,3.486,7.661,4.669,11.003,6.067
c3.553,1.486,7.174,3.066,10.784,4.166c4.271,1.301,9.277,1.67,13.721,2.343c4.155,0.629,9.979,1.365,14.162,0.496
c1.181-0.245,2.343-1.024,3.462-1.446c0.162,1.905-3.637,3.023-4.933,3.487c-2.435,0.871-4.18,2.541-6.362,3.871
c-1.623,0.989-2.974,1.669-4.755,2.117c-1.77,0.445-3.353,0.806-4.825,1.878c-5.915,4.311-15.264,3.247-22.424,3.13
c-5.384-0.088-6.719-5.372-9.337-9c-1.437-1.991-2.843-3.854-3.796-6.138c-0.871-2.086-1.119-4.582-2.033-6.528"/>
<path i:knockout="Off" fill="#F4BDBD" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M107.217,227.972
c1.182-2.033,4.375-2.176,6.5-1.963c2.879,0.289,4.124,1.217,6.168,3.167c1.834,1.749,5.906,5.509,5.64,8.271
c-2.808,0.89-7.847,0.402-10.346-1.104c-1.334-0.804-1.151-2.256-2.246-3.588c-0.712-0.866-1.836-2.673-2.855-3.311
c-0.209-0.94-2.106-1.499-3.028-1.805"/>
</g>
</g>
<g id="personalProps" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F004F00FFFF">
<g id="hat" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#FFFFFFFF4F00" display="none">
<g display="inline">
<g i:knockout="Off">
<path i:knockout="Off" fill="#FF0000" d="M88.374,173.144c0.474-0.074,16.606,2.725,18.01,5.879
c1.145,2.572,28.184,4.568,28.184,4.568l35.971-5.618l5.025,1.132l7.211,0.315l9.295,0.851l10.188,3.248l5.75,2.935
l1.615-1.832l-0.264-5.27l-3.967-7.087c0,0-22.045-13.031-23.273-13.703c-1.229-0.669-4.941-2.294-6.484-4.542
c-8.584-12.528-8.404-18.05-3.371-6.461c0,0,2.662-7.592,2.52-8.575c-0.143-0.982,0.355-5.031,0.355-5.031l2.396-6.832
c0,0-1.379-5.341-2.738-7.19c-1.357-1.844-15.793-4.078-18.162-4.011c-24.933,0.706-3.783,0.071-25.567,0.724
c-24.317,0.728-0.882-2.591-24.068,3.551c-24.228,6.418-5.35-1.298-23.187,6.142c-18.301,7.633-16.67,7.186-16.704,10.685
c-0.034,3.499-3.057-4.884-0.034,3.499c3.023,8.381,3.037-3.871,3.023,8.381c-0.015,12.252,6.696,4.557,1.678,12.373
c-5.017,7.813-3.831,7.91-0.179,8.543c17.017,2.953,4.157,4.378,17.427,3.175"/>
<path i:knockout="Off" d="M156.605,114.92l-13.936,0.381l-11.633,0.343c-10.646,0.319-11.973-0.155-12.021-0.175l-0.599-0.238
l-0.577,0.514l0.049-0.047c-0.118,0.09-1.43,0.957-11.145,3.53c-9.989,2.646-12.812,2.931-13.421,2.704
c-0.822-0.306-0.821-0.306-7.791,2.604l-2.104,0.878c-16.037,6.689-17.342,7.324-17.342,10.316c0,0.019,0.001,0.041,0.001,0.06
c-0.224-0.108-0.459-0.199-0.787-0.04c-0.357,0.173-0.565,0.275-0.565,0.672c0,0.557,0.411,1.697,1.399,4.438
c0.924,2.561,1.71,3.671,2.714,3.833c0.083,0.014,0.164,0.02,0.241,0.02c0.007,0.584,0.01,1.339,0.01,2.313
c0,0.561-0.001,1.902-0.001,1.916c0,6.908,2.176,8.105,3.347,8.749c0,0,0.075,0.045,0.151,0.09
c-0.095,0.332-0.47,1.1-1.661,2.955c-2.509,3.908-3.516,5.931-3.516,7.303c0,0.358,0.068,0.671,0.196,0.962
c0.544,1.237,1.926,1.477,3.677,1.78l0.135,0.023c8.138,1.412,9.14,2.422,9.568,2.854c0.923,0.931,1.511,0.928,7.224,0.413
c0.06,0.014,0.102,0.068,0.165,0.071c2.167,0.105,16.131,3.138,17.087,5.288c1.147,2.578,16.416,4.228,29.023,5.159
l0.115,0.009c0,0,35.523-5.548,35.896-5.606c0.345,0.078,4.927,1.11,4.927,1.11l7.3,0.319c0,0,8.927,0.818,9.139,0.837
c0.202,0.064,9.854,3.142,10.006,3.19c0.143,0.073,6.368,3.251,6.368,3.251l2.398-2.719l-0.296-5.911l-4.213-7.526
l-0.232-0.137c-0.9-0.532-22.073-13.047-23.303-13.72c-0.001,0-0.735-0.38-0.735-0.38c-1.48-0.752-4.238-2.151-5.404-3.85
c-1.357-1.982-2.451-3.729-3.355-5.268c0.022-0.064,0.104-0.296,0.104-0.296c1.193-3.402,2.576-7.619,2.576-8.885
c0-0.063-0.004-0.118-0.011-0.165c-0.012-0.083-0.017-0.204-0.017-0.356c0-0.909,0.194-2.911,0.363-4.307
c0.072-0.205,2.46-7.013,2.46-7.013l-0.076-0.294c-0.146-0.566-1.468-5.584-2.9-7.532
C173.721,116.784,158.242,114.874,156.605,114.92z M131.097,117.643l11.614-0.342l13.951-0.382
c2.575-0.073,16.104,2.238,17.336,3.614c0.956,1.3,2.058,4.938,2.49,6.549c-0.188,0.536-2.33,6.642-2.33,6.642l-0.013,0.107
c-0.073,0.592-0.387,3.224-0.387,4.658c0,0.258,0.011,0.477,0.034,0.639c-0.006,0.493-0.768,3.026-1.659,5.709
c-2.14-4.566-2.792-4.606-3.242-4.629l-0.62-0.031l-0.354,0.571c-0.069,0.124-0.102,0.29-0.102,0.492
c0,2.273,4.134,9.172,6.993,13.346c1.456,2.12,4.509,3.669,6.149,4.501l0.682,0.353c1.138,0.622,20.813,12.25,23.011,13.549
c0.239,0.427,3.513,6.275,3.721,6.647c0.02,0.393,0.199,3.971,0.231,4.629c-0.23,0.262-0.472,0.535-0.832,0.944
c-1.07-0.546-5.132-2.619-5.132-2.619l-10.369-3.306l-9.404-0.86c0,0-6.995-0.307-7.169-0.315
c-0.168-0.038-5.124-1.155-5.124-1.155s-35.814,5.594-36.044,5.63c-12.419-0.922-25.993-2.687-27.285-4.058
c-1.366-3.097-13.245-5.574-17.517-6.211c-0.203-0.212-0.479-0.346-0.793-0.318c-3.083,0.28-5.996,0.544-6.4,0.369
c0-0.003-0.12-0.117-0.12-0.117c-0.703-0.708-1.879-1.895-10.646-3.416l-0.135-0.023c-0.827-0.143-2.075-0.359-2.188-0.614
c-0.021-0.048-0.033-0.111-0.033-0.193c0-0.592,0.632-2.179,3.205-6.187c1.488-2.318,2.024-3.388,2.024-4.188
c0-0.15-0.019-0.291-0.054-0.428c-0.181-0.712-0.758-1.03-1.179-1.261c-0.865-0.476-2.311-1.271-2.311-6.993
c0-0.014,0.001-1.098,0.001-1.56c0-4.969-0.065-4.992-0.833-5.258c-0.424-0.146-0.816,0.001-1.178,0.377
c-0.208-0.289-0.558-0.898-1.073-2.324c-0.205-0.568-0.385-1.068-0.542-1.506c0.587-0.423,0.632-1.277,0.636-1.644
l-0.014-0.825c-0.004-0.119-0.007-0.231-0.007-0.338c0-1.702,0.899-2.264,16.109-8.608l2.105-0.878
c4.165-1.739,5.948-2.482,6.375-2.562c0.817,0.296,2.292,0.597,14.579-2.658c8.169-2.164,10.697-3.187,11.58-3.704
C120.451,117.773,124.529,117.84,131.097,117.643z"/>
</g>
<g i:knockout="Off">
<path i:knockout="Off" fill="#FFFFFF" d="M155.146,147.929c4.879-9.398-5.344-20.199-12.65-21.176
c-12.05-1.61-13.404,10.426-13.684,21.258c3.73,2.016,8.915,3.425,11.721,6.534"/>
<path i:knockout="Off" d="M133.446,127.979c-4.599,3.921-5.426,11.933-5.635,20.006l-0.017,0.654l4.415,2.067
c2.849,1.244,5.793,2.529,7.581,4.509c0.371,0.41,1.004,0.442,1.412,0.072c0.219-0.197,0.33-0.469,0.33-0.743
c0-0.239-0.084-0.479-0.258-0.67c-2.076-2.299-5.222-3.673-8.266-5.001c0,0-2.377-1.112-3.174-1.486
c0.223-7.385,1.021-14.572,4.909-17.887c1.892-1.614,4.386-2.189,7.621-1.757c4.143,0.554,9.086,4.472,11.5,9.113
c1.348,2.591,2.51,6.535,0.395,10.611c-0.254,0.49-0.064,1.093,0.426,1.348c0.49,0.254,1.094,0.063,1.35-0.427
c1.959-3.775,1.818-8.199-0.395-12.456c-2.732-5.251-8.203-9.53-13.012-10.172C138.853,125.257,135.763,126,133.446,127.979z"
/>
</g>
<g i:knockout="Off">
<path i:knockout="Off" d="M154.077,146.278c-2.156,1.18-4.24,2.619-6.256,4.01c-3.635,2.509-7.068,4.878-10.941,5.924
c-2.991,0.808-6.055,1.058-9.3,1.324c-3.222,0.263-6.553,0.536-9.783,1.406c-2.027,0.546-4.117,1.397-6.137,2.221
c-3.491,1.423-7.102,2.895-10.528,2.866c-0.552-0.005-1.004,0.439-1.009,0.991s0.439,1.004,0.991,1.009
c3.828,0.033,7.627-1.516,11.301-3.014c2.054-0.837,3.994-1.628,5.902-2.142c3.054-0.823,6.292-1.088,9.425-1.344
c3.191-0.261,6.492-0.531,9.659-1.386c4.205-1.135,7.941-3.714,11.557-6.208c1.973-1.362,4.014-2.771,6.08-3.901
c0.484-0.265,0.662-0.873,0.396-1.357S154.562,146.013,154.077,146.278z"/>
</g>
<g i:knockout="Off">
<path i:knockout="Off" d="M156.458,153.549c-2.619,0.064-5.709,0.812-8.98,1.604c-4.279,1.035-8.701,2.104-11.902,1.536
c-0.543-0.096-1.063,0.267-1.159,0.81c-0.097,0.544,0.267,1.063,0.81,1.16c3.613,0.641,8.24-0.481,12.72-1.562
c3.166-0.766,6.154-1.489,8.561-1.548c5.664-0.141,7.961,0.698,13.508,2.724c0.518,0.189,1.094-0.077,1.281-0.596
c0.189-0.519-0.076-1.091-0.596-1.282C165.069,154.337,162.501,153.399,156.458,153.549z"/>
</g>
</g>
</g>
<g id="textSurface" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFFFFFF4F00">
<g id="spokenBubble" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFF4F00FFFF">
<path id="textContainer" i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M225.719,45.306c0-6.627,5.373-12,12-12h181.333
c6.627,0,12,5.373,12,12V150.64c0,6.627-5.373,12-12,12H237.719c-6.627,0-12-5.373-12-12V45.306z"/>
<path id="textArrowBelow" i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M249.052,160.639
c-0.775,14.251-1.676,18.525-9.1,30.565c9.705-0.79,21.952-21.605,25.1-30.045"/>
</g>
<g id="thoughtBubble" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#FFFF4F00FFFF" display="none">
<path id="textContainer_1_" i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M202.698,21.089
c19.686-26.45,59.686-24.45,79.747-0.084c2.697,1.349,5.571,1.709,7.472,0.781c15.28-13.888,33.272-14.043,49.893-7.839
c2.771,1.034,5.478,2.219,8.031,3.421c28.543-21.729,75.543-10.729,83.166,27.658c0,0-1.324,3.889,1.165,6.603
c18.212,11.011,26.212,32.011,22.212,53.011c-1,5.333-3.223,9.667-6.037,13.52c-2.814,3.854-1.381,0-2.613-0.591
c-1.35-0.929-3.35-0.929-4.35-1.929c16,7,27,22,30,39c2,21-8,41-27,50c-16,7.5-32.5,5.5-45.745-2.556
c-2.532-1.384-4.229-1.856-5.336-1.551c-1.919,0.107-3.919,2.107-5.919,2.107c4-1,6-5,10-6c-15,11-35,12-52,3c-13-7-20-20-24-34
c1,5,3,9,3.299,13.505c-0.397,0.708-3.423,2.219-6.655,3.466c-22.627,8.729-49.423,1.729-65.241-19.971
c-3.453,0-6.263,0.589-8.723,0.879c-17.3,3.2-32.381-7.709-40.771-22.689c-1.678-2.996-3.089-6.153-4.195-9.396
c-15.714-7.795-29.714-18.795-33.714-37.795c-5-25,11-45,29.842-57.667c0.719-2.335,1.697-4.636,3.006-6.896
C201.159,23.306,202.698,21.089,202.698,21.089z"/>
<g i:knockout="Off" display="inline">
<path i:knockout="Off" fill="#FFFFFF" d="M269.719,186.306c0,4.602-4.179,8.333-9.333,8.333c-5.155,0-9.334-3.731-9.334-8.333
c0-4.603,4.179-8.333,9.334-8.333C265.54,177.973,269.719,181.704,269.719,186.306z"/>
<g>
<path i:knockout="Off" fill="none" d="M269.719,186.306c0,4.602-4.179,8.333-9.333,8.333c-5.155,0-9.334-3.731-9.334-8.333
c0-4.603,4.179-8.333,9.334-8.333C265.54,177.973,269.719,181.704,269.719,186.306z"/>
<path i:knockout="Off" fill="#FFFFFF" d="M268.225,186.165c-0.564,8.736-13.982,9.286-15.633,0.853
c-1.785-9.125,15.017-10.254,15.649-0.451c0.125,1.929,3.078,1.388,2.955-0.521c-0.814-12.597-20.828-12.412-21.639,0.119
c-0.827,12.813,20.831,13.028,21.655,0.283C271.337,184.518,268.35,184.235,268.225,186.165z"/>
</g>
</g>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M260.386,188.306c0,3.498-2.985,6.333-6.667,6.333
s-6.667-2.835-6.667-6.333c0-3.498,2.985-6.333,6.667-6.333S260.386,184.808,260.386,188.306z"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M238.386,196.973c0,1.289-1.045,2.333-2.334,2.333
c-1.288,0-2.333-1.045-2.333-2.333s1.045-2.333,2.333-2.333C237.341,194.639,238.386,195.684,238.386,196.973z"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M285.719,179.973c0,4.602-4.253,8.333-9.5,8.333
s-9.5-3.731-9.5-8.333c0-4.603,4.253-8.333,9.5-8.333S285.719,175.371,285.719,179.973z"/>
</g>
<g id="yellBubble" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#FFFF4F00FFFF" display="none">
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M251.156,176.051
l40.228-15.992"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M280.932,149.385
l-40.667,36.42"/>
<path id="textContainer_2_" i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M217.778,34.643
c8.609,6.684,9.952,3.684,7.987-5.785c6.308,5.125,9.308,3.782,10.188-4.309c2.433,8.091,5.266,8.091,9.12-1.703
c6.063,9.793,13.146,9.793,24.043,3.878c6.103,5.915,16.02,5.915,20.094-4.64c17.178,10.555,28.511,10.555,45.233-5.505
c5.941,16.06,17.273,16.06,18.835,1.458c19.688,14.603,29.605,14.603,46.749-17.802c-0.144,32.405,6.939,32.405,29.26,16.182
c-12.403,16.223-9.57,16.223,4.813,6.576c-11.07,9.646-8.07,10.99,4.333,9.089c-8.061,6.244-6.717,9.244,2.533,11.068
c-9.25,1.489-9.25,5.703-0.315,13.07c-8.935,6.115-8.935,15.385,7.513,10.932c-16.447,24.677-16.447,35.631,14.938,36.553
c-31.385,19.303-31.385,28.571-4.39,40.526c-26.995,1.528-26.995,5.741-5.942,17.857c-21.053-8.801-22.396-5.802-9.526,11.916
c-17.213-13.374-20.213-12.03-12.048,8.029c-11.479-20.06-14.312-20.06-10.553,3.532c-13.676-23.591-20.759-23.591-29.814-2.664
c-7.944-20.927-17.861-20.927-27.072,12.467c-12.039-33.395-23.373-33.395-23.148-1.581
c-22.89-31.814-34.224-31.814-61.517-8.479c6.042-23.335-3.874-23.335-11.9-9.703c-8.975-13.632-16.058-13.632-23.926,4.361
c-2.049-17.993-4.882-17.993-10.51-1.486c2.314-16.508-0.686-17.851-12.385-5.019c7.356-17.175,6.013-20.176-10.27-7.879
c16.283-15.61,16.283-19.824-9.255-12.972c25.538-20.334,25.538-29.603,1.919-46.578c23.619-3.249,23.619-14.204-0.313-25.522
c23.933-8.905,23.933-18.175,7.798-37.429C226.385,48.854,226.385,44.64,217.778,34.643z"/>
</g>
</g>
</g>
</svg>
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-nose-large.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-nose-large.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-left-leg.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-left-leg.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/Nils.svg
New file
0,0 → 1,188
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/">
<g id="nils_1_" i:isolated="yes" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFF4F004F00" enable-background="new ">
<g id="lowerBody" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFFFFFF4F00">
<g id="leftShoe" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFF4F00FFFF">
<path i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M44.787,442.042c13.536-0.097,28.515-2.647,40.667-8.815
c13.064-6.631,3.188-24.604,0.553-34.404c-5.771-1.73-10.549-4.837-16.568-0.148c-4.371,3.405-6.025,11.462-2.07,15.501
c-3.212,7.339-17.804,1.912-23.732,6.7c-5.825,4.706-7.32,17.966,0.484,21.167"/>
<path i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M133.453,425.375c0.901-2.979,2.793-5.781,4.667-8"/>
<path i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M56.787,426.708c-2.551-2.07-3.97-5.252-5.333-8"/>
</g>
<g id="rightShoe" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFFFFFF">
<path i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M111.453,402.042c-2.005-0.426-3.947-0.363-5.899-0.566
c-0.104,2.376,0.438,5.478,0.048,7.751c-0.4,2.327-1.597,4.06-2.146,6.817c-0.975,4.9,0.412,10.561,3.813,13.517
c3.718,3.23,8.442,2.56,12.87,3.797c4.256,1.189,7.959,3.502,12.5,4.849c9.169,2.717,20.433,7.657,25.649-4.685
c2.797-6.618-0.894-5.624-6.331-7.982c-4.049-1.757-6.774-4.353-10.32-7.014c-4.123-3.095-8.203-5.957-13.415-6.584
c-0.11-3.353,1.616-5.692,1.132-9.117c-5.299-2.318-13.883-3.984-19.233-0.116"/>
<path i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M62.787,424.708c-1.417-2.271-3.012-5.388-2.667-8.666"/>
<path i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M141.453,428.042c2.076-1.991,4.274-3.745,6-6"/>
</g>
<path id="leftLeft" i:knockout="Off" fill="#FFF0A9" stroke="#000000" d="M111.687,360.891c0.036,4.747,1.844,9.223,1.56,14.078
c-0.24,4.099-1.372,8.075-1.553,12.199c-0.2,4.558-1.141,9.069-1.142,13.648c0,3.48-0.275,5.533,3.084,7.379
c2.301,1.264,4.909,1.163,7.094-0.113c2.993-1.748,2.841-3.747,2.868-6.904c0.025-2.952,0.712-5.943,1.162-8.841
c0.446-2.868,0.401-5.667,0.398-8.578c-0.004-3.788,0.138-7.556,0.003-11.357c-0.118-3.318-1.49-6.782-1.279-10.093"/>
<path id="rightLeg" i:knockout="Off" fill="#FFF0A9" stroke="#000000" d="M74.107,353.8c-0.57,1.485-0.055,3.729-0.142,5.357
c-0.076,1.44-0.315,2.774-0.571,4.184c-0.786,4.316-1,8.786-1.732,13.181c-1.158,6.942-0.906,14.193-1.777,21.167
c-0.456,3.648,0.862,8.169,5.499,7.139c2.579-0.572,4.859-3.016,5.846-5.361c2.937-6.981-0.974-13.832-0.457-21.057
c0.331-4.619,2.141-8.637,3.402-13.056c0.769-2.694,1.709-5.131,1.703-7.972c-0.004-1.809,0-3.616,0-5.425"/>
<g id="pants" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFF4F00">
<path id="pants_1_" i:knockout="Off" fill="#ADA274" stroke="#000000" d="M72.453,299.375
c1.947,19.47-1.848,38.143-0.849,57.849c3.905,0.681,11.166,0.417,14.849-0.849c7.135-2.453,6.497-2.631,7-11
c0.81-13.479-2.849-20.278,12.845-17.853c-1.125,13.305-9.43,25.115-3.42,38.649c8.404-0.38,20.265,0.661,28.427-1.944
c0.505-10.198-1.523-17.622-2.853-26.853c-1.398-9.708,3.313-18.866-1.174-27.826c-9.218,0.693-18.358,2.747-27.722,0.798
c-9.863-2.054-18.89-8.623-29.104-8.972"/>
</g>
</g>
<g id="leftArm_1_" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFFFFFF">
<path id="leftArm" i:knockout="Off" fill="#FFF0A9" stroke="#000000" d="M161.453,199.375c-6.73,0.606-12.711,7.192-9.248,13.248
c3.358,5.87,13.618,5.538,19.021,6.979c4,1.066,16.837,3.192,19.52,5.703c3.974,3.72,5.243,15.844,5.854,20.924
c13.641,4.354,26.949-0.671,33.102-13.826c5.331-11.398-5.783-19.505-17.098-22.174c1.771-8.465,14.167-32.061-0.128-36.899
c-4.761-1.611-15.726,3.346-17.801,7.272c-3.095,5.855-0.055,15.902-0.374,22.623c-13.399,0.68-27.351-3.555-39.849-1.849"/>
<path i:knockout="Off" fill="#FFF0A9" stroke="#000000" d="M221.453,220.375c-4.604-1.889-17.369-6.456-21.801-1.801
c-4.797,5.039,1.256,14.077,6.027,16.578c4.118,2.159,20.628,4.348,24.575,1c4.999-4.241,2.906-14.993-2.801-17.777"/>
<path i:knockout="Off" fill="#FFF0A9" stroke="#000000" d="M214.453,253.375c-1.006,3.482-0.767,9-3.174,12.826
c-15.878,0.834-16.244-5.43-25.674-14.571c10.53-5.253,19.583,4.754,29.849,2.745"/>
<path i:knockout="Off" fill="#FFF0A9" stroke="#000000" d="M226.453,239.375c0.54,16.962-8.377,15.391-21.023,12.023
c-17.34-4.617-11.577-7.176,3.023-13.023"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M208.453,188.375c-4.474,0.83-8.972-0.434-11-4"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M203.453,221.375c6.112-0.45,18.967,6.649,8,10"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M195.453,258.375c3.441-0.666,5.408-2.2,4-5"/>
</g>
<g id="rightArm" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFF4F00">
<path i:knockout="Off" fill="#FFF0A9" stroke="#000000" d="M39.453,187.375c-3.104,7.216-3.137,14.998-7.278,21.997
c-5.137,8.684-9.794,6.9-17.5,12.281c-8.803,6.146-12.141,29.697-14.095,40.548c20.2,3.536,18.779-23.776,21.649-34.524
c0.975,13.012-0.289,26.468,0.374,39.546c2.257,0.582,6.44,0.582,8.697,0c2.04-10.494-3.53-22.034-0.852-33.546
c0.009,7.58-2.598,32.2,10.852,28.546c0.514-10.124-1.899-18.938-4.868-25.972c2.181,8.766,4.798,18.48,15.845,15.949
c6.407-12.781-3.909-15.105-8.048-25.604c-2.531-6.422,0.527-25.44,6.223-31.223"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M6.453,248.042c2.111,0,6.324-0.997,6.667,1.666"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M22.453,255.375c2.85-0.37,4.155,0.539,4.999,3.001
c1.085,3.168-0.233,4.173-2.999,5.332"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M31.787,255.042c3.675-0.503,7.077,4.971,3,6"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M48.453,235.708c-5.387-0.935-3.676,10.551,3.667,8.667"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M207.453,241.375c2.63,1.686,2.368,4.909,1.884,7.884
c-0.744,0.175-1.23,0.456-1.884,0.783"/>
</g>
<g id="shirt" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFFFFFF4F00">
<path id="mainShirt" i:knockout="Off" fill="#4867FF" stroke="#000000" stroke-width="2" d="M39.453,189.375
c0.777-3.467,1.211-7.217,1.151-10.849c14.871-1.403,32.372-7.656,46.875-11.125c9.423-2.254,31.959-20.14,39.244-11.079
c3.778,4.7,2.066,16.102,5.456,22.08c2.827,4.986,9.093,12.445,13.003,16.217c5.193,5.009,15.695-3.271,18.271,2.754
c3.024,7.075-0.511,20.739-10.02,18.016c-5.084-1.456-12.238-5.093-15.228-9.769c-4.055-6.341-8.831-13.012-10.53-19.167
c-0.713,10.697,1.173,22.369,2.726,32.92c1.637,11.128,1.886,22.261,3.052,34c2.02,20.336,6.915,42.053,10.845,61.855
c-14.599,4.091-47.868-3.832-47.868-3.832s-14.457-3.595-21.2-5.801c-8.131-2.661-21.777-11.223-13.777-11.223
s-3.063-9.756,2.468-40.878s14.003-39.61,19.806-56.122c1.387-3.946,2.399-8.004,4.375-11.845
c-17.565,1.273-26.117,7.964-40.475,16.742c-2.413-9.11-9.707-14.336-17.174-18.897"/>
<path id="highlight" i:knockout="Off" fill="#4867FF" stroke="#000000" stroke-width="2" d="M99.453,179.375
c-5.364,2.937-10.603,8.065-17,8"/>
<g id="logo" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFF4F00FFFF">
</g>
</g>
<g id="heads" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFF4F004F00">
<g id="head1" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFF4F00">
<path id="hair_1_" i:knockout="Off" fill="#605542" stroke="#000000" d="M60.453,97.375c-3.965-0.012-7.98,0.045-11.897-0.147
c2.645-5.735,10.791-8.417,14.794-13.65c-2.384,0.19-5.083-0.61-7.543-0.154c2.395-1.359,4.008-3.487,6.347-4.846
c-2.993-0.207-6.326-0.467-9.399-0.18c2.893-0.874,5.243-2.063,7.821-3.05c-0.92-0.166-4.625-2.732-6.772-4.221
c5.187-4.255,12.317-5.834,17.573-8.534c-2.844-0.13-5.037-1.713-7.75-2.393c-0.424-7.244-1.302-14.461-1.223-21.475
c2.166,2.761,3.541,5.976,4.849,8.546c-0.996-11.489,4.773-13.594,13.025-18.797c0.403,1.91,1.943,3.845,2.229,5.546
c1.27-13.312,22.924-28.644,34.016-33.272c0.039,6.247-2.955,11.957-5.365,17.475c-0.365,0.375-0.375,0.366-0.028-0.028
c5.849-6.92,14-8.882,22.143-10.721c-1.215,5.635-5.28,10.684-6.698,16.602c6.258-10.069,20.421-4.135,27.949-11.351
c-1.011,3.251-2.028,6.254-3.143,9.276c7.035-8.774,15.902-11.37,25.894-14.499c-0.668,7.995-10.243,18.061-0.822,20.872
c8.889,2.653,17.435-7.31,26.698-6.075c-2.976,1.954-5.822,4.12-8.614,6.345c7.596,2.01,18.243,0.852,26.614,0.658
c-4.125,3.304-9.116,7.352-9.593,12.943c3.896-0.826,8.6-1.318,12.741-0.725c-1.013,1.726-1.479,5.845-2.718,7.678
c3.136-0.265,6.17,1.053,8.519,1.452c-3.019,0.804-5.247,3.16-7.566,4.52c3.765,0.755,7.282,2.001,10.844,3.398
c-3.322,1.78-5.724,5.475-4.776,9.657c0.798,0.374,2.536,0.977,2.995,1.147c-6.481,3.645-21.331-1.522-28.945-2.752
c-13.967-2.257-27.844-4.641-41.913-6.244c-17.039-1.941-37.716-3.446-54.359,1.025C83.983,67.42,68.871,76.651,58.453,98.375"
/>
<path id="neck" i:knockout="Off" fill="#FFF0A9" stroke="#000000" d="M108.453,132.375c0.902,8.412-0.835,20.235-3.849,27.797
c4.164,2.769,15.721,4.339,19.868,0c3.538-3.701,1.964-17.522,1.98-22.797"/>
<g id="leftEar_1_" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFFFFFF">
<path id="leftEar" i:knockout="Off" fill="#FFF0A9" stroke="#000000" d="M232.453,76.375c10.186-6.915,21.465,6.994,19.052,17
c-2.781,11.53-20.253,15.518-27.052,5"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M245.453,91.375c-0.398-2.267-1.99-4.77-3.171-6.829
c-2.738-0.936-5.713-1.545-8.829-1.171"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M238.453,90.375c1.863-0.367,3.589-1.433,5-3"/>
</g>
<path id="headShape" i:knockout="Off" fill="#FFF0A9" stroke="#000000" d="M116.453,35.375
c-13.417,2.219-31.83,24.639-39.777,35.055c-8.128,10.652-24.737,25.747-20.219,39.945
c5.161,16.221,22.089,14.526,34.025,19.972c15.448,7.047,30.645,11.875,46.749,14.251c18.146,2.676,27.633,0.161,44.223-7.972
c15.701-7.697,29.862-9.589,41.801-24.303c8.182-10.084,15.033-28.733,8.174-38.923c-6.159-9.151-21.79-19.289-31.201-25.75
c-12.144-8.339-26.876-10.032-41-11.274c-15.007-1.32-33.207-3.056-47.774,1"/>
<g id="rightEar_1_" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFF4F00FFFF">
<path id="rightEar" i:knockout="Off" fill="#FFF0A9" stroke="#000000" d="M66.453,94.375
c-10.188-4.124-23.701-5.729-27.774,7.226c-4.779,15.198,14.506,23.077,25.774,15.774"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M42.453,106.375c4.149-4.954,11.06-7.737,16-10"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M48.453,100.375c1.337,3.541,2.787,6.955,5,10"/>
</g>
<path id="adamsApple" i:knockout="Off" fill="none" stroke="#000000" d="M113.453,152.375c-0.526-2.327,1.546-3.837,5-4"/>
</g>
</g>
<g id="expressions" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#800080008000">
<g id="confused" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#000000000000">
<g id="mouth_1_" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F008000FFFF">
<path id="mouth" i:knockout="Off" fill="none" stroke="#000000" d="M102.148,120.014c13.398-6.9,33.568-7.688,49-10.026
c12.555-1.903,36.519-2.575,44,9.026"/>
<path id="tooth_1_" i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M178.148,109.014
c-0.563-2.655-0.017-6.196,0.151-8.849c4.788-0.944,9.637,0.768,13.675,3.022c0.664,3.187,0.065,6.267-1.826,8.826"/>
<path id="tooth" i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M168.148,108.014c-2.021-7.958,5.04-7.752,10.826-6.826
c1.286,2.446,1.752,5.863,1.022,8.675c-3.801,0.292-8.049,0.308-10.849-0.849"/>
</g>
<g id="eyes" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F008000FFFF">
<path id="rightEye" i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M121.148,52.014
c-6.562,8.145-20.057,16.28-21.023,26.977c-1.104,12.227,10.759,15.164,21.02,11.798c18.8-6.168,24.482-40.499,0.004-39.774"/>
<path id="pupilRight" i:knockout="Off" stroke="#000000" d="M112.148,61.014c-7.625,3.067-4.047,12.428,3.826,10.826
C118.354,67.432,118.046,61.261,112.148,61.014"/>
<path id="leftEye" i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M184.148,55.014c-13.391-8.758-17.664,28.504,5,25.996
c10.862-1.201,14.124-12.581,8.004-19.996c-6.121-7.415-14.988-4.947-22.004-8"/>
<path id="pupilLeft" i:knockout="Off" stroke="#000000" d="M176.148,54.014c-2.04,2.896-2.657,6.347-1.849,9.849
C184.707,66.621,182.108,56.322,176.148,54.014"/>
</g>
</g>
<g id="confused2" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#000000000000" display="none">
<path id="rightEye_1_" i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M121.148,52.014
c-6.562,8.145-20.057,16.28-21.023,26.977c-1.104,12.227,10.759,15.164,21.02,11.798c18.8-6.168,24.482-40.499,0.004-39.774"/>
<path id="pupilRight_1_" i:knockout="Off" display="inline" stroke="#000000" d="M112.148,61.014
c-7.625,3.067-4.047,12.428,3.826,10.826C118.354,67.432,118.046,61.261,112.148,61.014"/>
<path id="leftEye_1_" i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M184.148,55.014
c-13.391-8.758-17.664,28.504,5,25.996c10.862-1.201,14.124-12.581,8.004-19.996c-6.121-7.415-14.988-4.947-22.004-8"/>
<path id="pupilLeft_1_" i:knockout="Off" display="inline" stroke="#000000" d="M176.148,54.014
c-2.04,2.896-2.657,6.347-1.849,9.849C184.707,66.621,182.108,56.322,176.148,54.014"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M114.934,118.74
c18.933-4.896,31.704-2.456,49.826,1.171c6.734,1.348,17.654,7.566,23.408,0.323c5.436-6.841-0.011-16.179-7.237-17.994"/>
</g>
<g id="talking" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#000000000000" display="none">
<path i:knockout="Off" display="inline" stroke="#000000" d="M150.536,116.479c0.413,18.115,48.746,18.222,37.276-7.278
c-10.396-1.757-28.836,2.451-38.776,5.778"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M103.453,104.875c-2.277,2.169-1.729,7.324-4.849,8
c8.889,3.074,18.975,7.877,28.849,6.998c6.759-0.602,18.439-1.511,23.5-5.998"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M104.453,64.875
c-6.218-0.224-17.093,9.247-13.875,15.887c2.822,5.825,15.087,4.174,20.375,3.113c4.505-0.904,7.783-1.37,9.889-6.123
c1.107-2.499,2.855-9.088,1.623-11.889c-2.859-6.496-15.374-3.248-19.512,0.012"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M176.953,59.875
c-4.742,8.403,0.46,13.596,6.486,18.376c4.779,3.791,15.903,8.529,19.512,0.622c8.012-17.554-22.026-19.554-32.498-17.887
c-0.345,0.055-1.151,0.291-1.5,0.389"/>
<path i:knockout="Off" display="inline" stroke="#000000" d="M98.953,66.875c-6.969-2.545-10.165,5.418-3.002,8.05
c2.178-2.129,5.596-6.88,2.502-9.05"/>
<path i:knockout="Off" display="inline" stroke="#000000" d="M178.453,60.875c-5.534,0.708-5.259,9.173,0.5,7.387
c6.145-1.906,5.217-9.047-1.5-8.387"/>
</g>
<g id="talking2" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#000000000000" display="none">
<path i:knockout="Off" display="inline" stroke="#000000" d="M102.87,94.503c-2.279,15.037-5.934,27.828,15.027,23.027
c15.334-3.512,25.379-13.239,28.973-28.027"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M92.87,104.503
c4.248-16.004,34.717-10.765,47.052-11.948c8.414-0.807,15.879-1.97,24.948-1.055c8.295,0.837,19.3,2.941,27-0.997"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M84.87,73.503c2.341-8.752,12.467-12.772,19-18"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M181.87,59.503c8.968-3.27,16.681,2.245,25,3"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M98.87,68.503
c-7.218,11.165,3.031,17.234,13.003,17.997c13.201,1.009,21.125-8.677,18.845-21.842c-11.637-0.604-21.219,1.818-31.849,2.845"
/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M178.87,67.503
c-9.045,2.007-6.264,11.616-1.249,15.249c3.778,2.737,13.479,4.477,18.249,2.528C210.946,79.123,185.327,71.038,178.87,67.503"
/>
<path i:knockout="Off" display="inline" stroke="#000000" d="M115.87,85.503c2.365-1.63,3.646-3.553,2.826-6.826
c-16.491-8.159-17.436,11.182-1.826,8.826"/>
<path i:knockout="Off" display="inline" stroke="#000000" d="M174.87,80.503c-0.492-1.165-0.677-2.687-0.872-3.826
c3.483-0.285,7.207-0.292,10.698-0.023c3.568,7.301-6.079,7.593-10.826,5.849"/>
</g>
</g>
</g>
</svg>
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-head.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-head.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/LarsDreaming.svg
New file
0,0 → 1,536
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/">
<g id="torso" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F008000FFFF">
<path id="leftArm" i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M156.007,292.675c2.737,1.778,5.563,3.321,8.752,3.946c7.099,1.391,19.25-5.666,23.136-11.698
c1.572-2.441,8.077-21.031,11.178-14.271c1.224,2.67-1.59,4-1.399,6.462c3.108-1.425,5.48-5.242,8.918-2.182
c0.672,4.019-4.472,4.343-3.918,7.669c1.376,0.218,5.395-1.595,6.285-0.535c1.707,2.027-2.933,3.561-4.072,4.018
c-1.852,0.741-4.294,1.233-5.988,2.369c-2.636,1.769-4.766,5.144-7.033,7.4c-11.657,11.604-26.184,10.553-40.646,5.515
c-4.713-1.642-17.399-4.472-18.655-9.427c-1.647-6.502,5.523-7.999,10.184-6.74C147.658,286.528,151.725,289.892,156.007,292.675z
"/>
<path id="leftArmThumb" i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M188.257,284.902c-1.932-1.391-3.313-4.206-3.506-6.494c-0.149-1.786,0.59-6.521,3.199-3.95c0.792,0.78,0.083,2.155,0.558,2.943
c0.885,1.47,1.071,0.493,2.748,1.002c1.406,0.426,3.827,2.05,4.251,3.499"/>
<path id="rightArm" i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M57.05,283.307c-5.502,5.354-13.185,8.541-18.249,14.221c-4.303,4.827-7.721,11.575-11.138,17.112
c-6.752,10.938-10.794,26.076-19.912,35.185c-3.869,3.866-7.637,5.722-7.251,12.032c0.932,0.372,1.548,0.589,2.418,0.683
c0.605-2.745,2.569-4.198,5.362-3.799c-0.14,3.365-3.512,5.941-3.228,9.235c0.364,4.223,3.983,5.968,7.181,2.662
c2.61-2.699,0.192-7.849,3.338-10.18c5.535-4.103,2.889,2.998,4.13,5.515c5.19,10.519,8.634-1.859,7.35-7.996
c-2.336-11.159-3.003-15.126,3.267-24.416c6.358-9.419,12.194-18.708,19.399-27.588c1.116-1.375,2.08-2.729,3.333-4"/>
<g id="shirt" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFF4F00">
<path id="tShirt" i:knockout="Off" fill="#4459A5" stroke="#000000" stroke-linecap="round" d="M96.509,268.265
c-2.301,0.323-4.69,0.205-6.945,0.72c-2.234,0.509-4.5,0.8-6.749,1.249c-4.369,0.872-8.206,3.265-12.3,5.024
c-3.259,1.4-6.644,2.57-9.763,4.26c-1.923,1.041-3.688,2.616-5.487,3.97c-1.543,1.16-3.495,2.11-4.854,3.563
c-2.205,2.354,0.896,7.407,1.854,9.873c0.92,2.367,2.149,4.819,2.749,7.29c0.228,0.937,0.235,2.058,0.875,2.872
c0.644,0.821,0.64,0.735,1.822,0.049c1.513-0.878,2.873-1.993,4.329-2.993c2.431-1.67,5.462-2.849,7.434-5.111
c-3.335,1.652-5.335,4.679-6.931,8.012c-1.398,2.921-4.482,35.854-5.389,38.947c-0.195,0.003-0.775,0.003-0.749,0.013
c20.561,0,41.123-0.069,61.684,0c2.1,0.008,3.607-0.496,5.529-1.252c0.715-0.28,2.257-0.355,2.807-0.744
c1.412-0.998-0.094-3.916-0.646-5.303c-1.425-3.579-2.111-37.767-4.726-40.543c1.842,0.058,4.127,1.312,5.938,1.95
c1.351,0.478,2.633,1.092,3.956,1.66c1.39,0.597,3.667,1.927,5.168,1.857c0.296-1.872,1.045-3.285,1.839-5.02
c0.942-2.061,1.155-4.214,1.528-6.415c0.351-2.07,0.897-3.787,1.938-5.635c0.531-0.942,1.356-1.73,1.693-2.769
c-0.443-0.401-1.043-0.906-1.604-1.125c-0.56-0.219-1.292-0.11-1.908-0.33c-1.236-0.438-2.439-1.089-3.668-1.575
c-3.773-1.499-7.519-2.983-11.319-4.467c-3.575-1.396-6.977-3.238-10.784-3.871c-1.735-0.289-3.467-0.529-5.073-0.906"/>
<path id="shirtNeck" i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" d="M99.759,268.89
c-0.984,0.151-1.746-0.549-2.75-0.5c-1.369,0.065-1.649,0.872-2.153,2c-1.037,2.325-2.442,4.974,0.064,6.945
c2.53,1.991,6.964,1.718,9.829,0.804c1.616-0.517,3.045-1.24,3.825-2.867c0.508-1.062,0.935-2.771,0.149-3.598
c-0.231-0.243-0.562-0.376-0.84-0.534"/>
<g id="shirtLogo" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F004F00FFFF">
<g i:knockout="Off">
<path i:knockout="Off" d="M104.864,296.921c-0.151-0.004,7.101,0.409,7.052,0.403c0.132,0.028-0.172,0.633-0.021,0.632
c-0.226,0.028-7.244-0.454-7.28-0.464C104.657,297.519,104.776,296.904,104.864,296.921z"/>
</g>
<g i:knockout="Off">
<path i:knockout="Off" d="M90.071,295.919c-0.199,0.005,6.792,0.431,6.79,0.446c0.153,0.005-0.031,0.663,0.012,0.665
c0.272,0.016-6.79-0.471-6.875-0.459C89.881,296.561,89.796,295.899,90.071,295.919z"/>
</g>
<path i:knockout="Off" d="M84.407,306.477c0.2-0.159,0.322-1.04,0.254,0.057c-0.542-0.355-2.02,2.083-4.215,2.001
c-1.887-1.706-4.559-3.384-4.302-7.092c0.652-2.599,3.082-4.084,5.213-3.942c1.889,0.378,2.899,0.717,4,1.318
c-0.497,0.957-0.175,0.866-0.459,0.703c0.456-2.398,0.598-5.75,0.312-7.855c0.594-0.554,0.714,0.125,1.249,0.941
c0.502-0.727,0.509-1.425,0.875-0.571c-0.207,1.328-0.809,7.187-0.711,10.174c-0.126,2.798-0.375,4.354-0.051,4.985
c-0.718,0.613-0.667,1.006-0.981,1.381c-0.72-1.33-1.056-0.132-1.339-0.157C84.632,308.442,84.493,305.791,84.407,306.477z
M81.186,307.177c2.403,0.206,3.734-2.164,3.841-4.223c0.269-2.72-0.896-5.104-3.198-5.04c-1.972,0.438-3.46,2.188-3.331,4.639
C78.171,306.266,79.847,306.962,81.186,307.177z"/>
<path i:knockout="Off" d="M93.321,297.767c2.592,0.147,5.688,2.314,5.696,5.627c-0.611,4.576-3.69,5.316-6.158,5.581
c-2.68-0.76-5.708-1.872-5.413-6.472C88.086,299.395,90.653,297.875,93.321,297.767z M92.939,307.46
c2.531,0.735,3.706-1.297,3.666-3.935c0.114-2.219-0.641-4.584-3.389-4.896c-2.29-0.553-3.366,2.188-3.661,4.688
C89.339,305.265,89.934,307.95,92.939,307.46z"/>
<path i:knockout="Off" d="M99.688,303.916c0.03-1.511,0.055-4.73,0.022-4.646c0.481-1.355,0.658-0.556,1.034-1.297
c0.263,1.473,0.653,0.326,1.186,0.065c-0.386,2.518-0.513,3.348-0.574,4.949c-0.068-0.47-0.128,2.28-0.238,2.188
c-0.055,1.935-0.036,2.201-0.047,4.219c-0.079,0.914-0.28,2.412-1.126,3.831c-0.61,1.212-1.73,1.146-3.24,1.651
c0.073-0.945-0.065-1.242-0.096-1.822c0.098,0.138,0.213,0.604,0.225,0.397c1.892,0.229,2.209-1.896,2.362-3.365
c0.042,0.304,0.512-6.934,0.415-7.062C99.73,302.637,99.75,303.179,99.688,303.916z M100.978,295.564
c0.717,0.14,1.11,0.61,1.099,1.156c0.052,0.552-0.595,0.993-1.286,1.015c-0.541-0.074-1.025-0.548-1.022-1.054
C99.813,296.084,100.292,295.644,100.978,295.564z"/>
<path i:knockout="Off" d="M108.115,298.791c3.028-0.066,5.283,1.359,5.256,5.758c-0.264,3.479-3.366,4.63-5.883,5.119
c-2.429-0.033-5.619-2.24-5.16-5.811C102.322,300.085,105.715,298.846,108.115,298.791z M107.351,309.232
c2.675-0.132,3.839-2.333,3.841-4.497c0.246-2.344-0.263-4.833-2.923-5.396c-2.844,0.299-3.974,1.917-4.053,4.479
C104.136,306.655,104.854,308.372,107.351,309.232z"/>
</g>
</g>
</g>
<g id="heads" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFFFFFF4F00">
<g id="head1" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFF4F00FFFF">
<g id="leftEart" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFFFFFF">
<path i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M201.557,195.475
c7.734-4.547,16.592-5.012,18.405,4.443c2.43,12.659-3.317,13.328-14.598,13.328"/>
<path i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M211.711,203.09
c0.523,0.004,0.946-0.208,1.271-0.635"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M211.076,197.377
c3.062,3.013,5.489,5.624,4.442,10.155"/>
</g>
<path id="bgHairTop" i:knockout="Off" fill="#FFF471" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M54.384,199.307c-5.253-4.402-7.511-11.061-15.779-10.632c3.449-1.277,7.116-2.397,10.911-2.666
c-2.873-1.397-5.865-2.575-8.231-4.718c3.986-1.119,11.47-1.817,14.864,0.75c-5.183-2.758-8.397-7.816-13.062-10.598
c6.014-0.643,12.377,0.978,18.022,2.265c-2.547-4.486-6.682-10.83-10.523-14.297c5.033,1.052,10.647,4.518,15.062,7.177
c-1.614-4.176-5.634-8.406-7.859-12.513c10.312-1.125,12.522,4.919,19.7,9.932c-0.412-0.127-1.114-0.113-1.527,0.015
c0.875-7.261,3.058-12.8,8.258-18.566c6.771-7.507,17.813-9.131,24.095-15.381c-4.699,1.821-4.518,23.765-4.875,28.955"/>
<path id="bgHairLeft" i:knockout="Off" fill="#FFF471" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M92.384,243.973c-6.334,7.929-12.601,12.241-22.465,15.361c3.65-1.263,7.735-5.859,7.695-9.928
c-2.208,0.218-4.49,0.605-6.498,1.098c1.244-1.098,2.087-3.239,3.198-4.396c-5.77,0.001-12.131,1.133-18.396,1.23
c5.013-2.81,10.665-3.25,12.398-9.247c-3.59,0.313-7.233,1.606-11.033,1.097c1.731-2.022,3.953-3.995,5.049-6.447
c-3.781,0.056-6.665,3.098-10.547,2.465c0.962-2.863,3.187-5.208,4.531-7.766c-5.59-0.273-11.658,2.45-17.732,2.564
c5.494-2.857,8.967-7.819,12.3-12.718c5.233-7.693,10.625-9.96,20.349-9.981c11.059-0.024,15.558,6.714,20.984,16
c2.786,4.767,7.249,14.375,0.832,18"/>
<path id="bgHair" i:knockout="Off" fill="#FFF471" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M142.384,255.307c2.984,6.076,3.567,11.855,10.531,14.6c-0.134-3.114-0.094-6.664,1.619-9.033
c1.604,1.969,3.122,4.211,5.048,5.698c-0.29-1.769,0.412-4.023,0.233-5.828c3.444,0.261,4.979,3.965,8.468,4.479
c0.065-2.78,0.427-5.151,0.868-7.813c2.687,0.2,4.768,1.565,7.132,2.997c0.452-4.921-0.409-10.579-0.667-15.666
c-5.795-0.756-12.291,2.827-17.899,3.899c-4.414,0.844-14.136,0.523-15.333,6"/>
<path id="neck" i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M106.989,254.499c-2.932,6.063-4.613,11.997-8.947,17.138c7.288,10.194,16.311-10.9,15.183-17.026
c-1.926-1.138-3.928-1.589-6.236-1.38"/>
<path id="headShape" i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M210.941,207.666c-0.844,3.985-2.081,7.982-3.77,11.783c-3.374,7.604-8.543,14.427-16.052,18.899
c-2.94,2.13-5.983,4.167-9.109,6.085c-25.013,15.342-55.353,23.08-82.254,10.57c-3.433-1.558-6.785-3.432-10.053-5.66
c-1.821-1.185-3.592-2.46-5.308-3.832c-1.715-1.373-3.375-2.842-4.972-4.412c-2.352-2.148-4.576-4.425-6.631-6.814
c-6.168-7.169-10.823-15.358-12.87-24.185c-0.649-3.284-0.84-6.634-0.5-9.975c4.48-13.743,14.22-24.364,26.109-32.149
c2.973-1.946,6.079-3.715,9.271-5.309c30.581-15.027,69.581-10.027,95.852,12.209c2.563,2.254,4.987,4.651,7.244,7.178
c4.513,5.054,8.354,10.626,11.312,16.64C210.178,201.505,210.798,204.497,210.941,207.666z"/>
<g id="rightEar" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#800080008000">
<path i:knockout="Off" fill="#FFE8B0" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M64.857,195.606
c-6.59-7.181-15.047-10.664-19.467,3.676c-1.235,4.007-1.87,14.468,1.29,17.786c4.223,4.435,13.591,0.529,19.055-0.015"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M52.407,196.744
c-1.702,3.613-1.257,7.505-1.27,11.424"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M51.772,209.438
c-3.39-4.661,0.922-5.769,5.078-6.347"/>
</g>
<path id="fgHair" i:knockout="Off" fill="#FFF471" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M90.384,154.64c8.453-11.353,15.678-13.458,28.581-15.915c-1.382,3.376-3.89,7.352-5.179,11.16
c5.01-1.816,9.571-6.545,15.218-8.413c11.355-3.755,23.853-1.903,35.671-2.213c-3.004,3.712-4.912,7.88-2.025,11.447
c5.855-2.212,13.369-6.871,19.635-6.646c0.263,4.561-0.024,9.278,0.201,13.841c3.509-1.201,6.015-3.04,8.276-5.148
c2.263-2.108,3.761-4.049,4.942-5.2c1.063,2.408,2.134,5.334,2.24,8.494c-0.183,3.462-0.866,6.794-2.66,9.291
c3.663,0.65,6.098-2.021,8.35-4.479c-0.655,4.349-3.164,8.604-3.851,13.013c2.178-0.072,4.382,0.216,6.367-0.48
c-1.39,3.093-3.069,7.287-6.616,8.414c-4.476,1.423-4.354-0.992-7.315-4.332c-4.892-5.518-9.773-6.791-15.872-9.464
c-6.585-2.887-10.982-6.47-17.963-8.219c-8.994-2.255-19.864-3.867-28.093-5.196c2.466,1.967,1.138,5.594,0.659,8.625
c-2.729-0.646-4.41-3.813-6.301-5.158c0.953,3.195,0.983,6.953-2.134,8.491c-6.145-5.226-9.199-9.721-17.527-11.647
c1,1.83,1.728,4.208,1.396,6.402c-0.751,4.971-0.289,3.134-3.836,2.466c-5.192-0.977-9.953-3.677-15.815-4.496
c3.292,2.002,5.469,5.017,7.418,8.21c-2.651,0.404-6.238,0.257-8.382,1.671c2.456,0.38,3.44,2.166,3.197,4.714
c-7.45,0.386-13.623,0.731-19.915,5.434"/>
</g>
</g>
<g id="eyes" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#000000000000">
<g id="eyes1" i:knockout="Off" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#4F008000FFFF" display="none">
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M123.163,176.668
c-5.066,1.17-9.01,7.888-13.666,10.335c-4.238,2.227-8.648,6.636-7.009,12.332c1.971,6.848,12.042,3.991,16.261,1.165
c5.282-3.539,9.59-8.517,12.006-14.524c1.523-3.787,2.568-7.272-1.509-9.391c-2.905-1.51-8.174-1.386-11.417-0.583"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" stroke-linecap="round" d="M182.545,179.865
c-3.533,0.169-4.854-1.166-8.408-0.001c-3,0.983-6.239,1.936-8.852,3.743c-3.938,2.725-7.46,5.555-4.73,13.592
c1.974,5.811,8.791,7.571,14.656,6.667c5.537-0.854,9.078-4.977,11.408-10.007c3.666-7.918,0.942-11.639-6.742-13.659"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M108.829,183.668c-1.308-1.03-4.557,0.011-5.6-1.733
c-1.056-1.765,1.735-5.409,2.984-6.192c5.684-3.562,15.946-0.39,19.95-6.742"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M163.877,167.198c2.369,1.282,6.539,0.307,9.408,0.815
c3.449,0.612,7.065,2.657,10.592,2.851"/>
<path i:knockout="Off" display="inline" stroke="#000000" d="M127.496,192.002c-4.917-2.12-9.188-1.708-8.608,4.942
c3.132,1.734,5.428-2.82,7.275-4.942"/>
<path i:knockout="Off" display="inline" stroke="#000000" d="M174.852,203.144c-0.293,0.12-0.307,0.577-0.942,0.282
c-1.605-3.188-0.404-6.507,2.676-8.192c2.15-1.176,5.67-1.759,7.471,0.359c0.199,0.234,0.412,0.521,0.515,0.813
c0.229,0.649-0.285,0.95-0.285,0.95s-3.988,6.009-3.285,1.934c0.438,1.743-5.537,5.743-2.287,1.653
c-1.955,2.583-2.524,1.977-3.859,2.868"/>
</g>
<g id="eyes2" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#FFFF4F004F00">
<path i:knockout="Off" fill="none" stroke="#000000" d="M98.668,186.108c0.668-8.915,15.545-13.749,22.667-15"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M169.667,178.108c5.307,3.436,16.928,5.632,19.668,12.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M105.334,197.775c8.085-4.283,17.059-2.8,25-6.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M164.001,198.775c4.656-0.417,9.664,1.805,14.334,2.017
c3.951,0.18,5.773,0.189,9,2.316"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M124.001,188.108c3.039-0.258,4.594,2.571,5.301,4.983
c-1.096,1.242-2.065,2.646-2.968,4.017"/>
<path i:knockout="Off" fill="none" stroke="#000000" d="M168.335,194.108c-1.77,2.293-4.869,3.271-6.299,5.91
c1.377,0.991,3.02,2.122,3.965,3.424"/>
</g>
</g>
<g id="beard" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFF4F00">
<path i:knockout="Off" fill="#AFA8A5" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M96.05,213.64
c-0.366,0.21-0.783,0.389-1.167,0.5"/>
<path i:knockout="Off" fill="#AFA8A5" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M102.55,211.973
c0.314-0.01,0.554-0.198,0.667-0.5"/>
<path i:knockout="Off" fill="#AFA8A5" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M105.717,208.806
c0.164-0.109,0.336-0.224,0.5-0.333"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M111.05,207.973
c-0.651-1.81,0.859-2.262,2.333-1.5"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M117.717,209.806
c1.738,0,3.653,0.369,5.333,0.167"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M132.717,214.473
c0.104-0.21,0.162-0.435,0.167-0.667"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M139.551,216.973
c0.215-0.175,0.465-0.426,0.666-0.667"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M144.551,213.306
c0.277-0.056,0.557-0.111,0.833-0.167"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M147.884,216.64
c0.195,0.045,0.369-0.013,0.5-0.167"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M148.384,214.14
c0.112-0.168,0.223-0.332,0.333-0.5"/>
<path i:knockout="Off" display="none" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M98.217,219.306c1.697-1.772,4.233-2.109,5.967-4.046c1.519-1.696,3.812-3.001,4.2-5.454"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M152.717,216.14
c0.611,0,1.224,0,1.834,0"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M160.384,217.473
c0.333,0,0.667,0,1,0"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M163.217,215.973
c0.321-0.042,0.658-0.175,0.834-0.333"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M164.217,218.806
c0.167,0,0.333,0,0.5,0"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M168.384,217.973
c0.057-0.056,0.111-0.111,0.167-0.167"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M169.884,225.806
c0.491-0.397,0.882-0.926,1.167-1.5"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M172.717,221.973
c0.057,0,0.111,0,0.167,0"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M171.717,229.806
c0.334,0.075,0.659,0.025,0.834-0.167"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M190.051,227.806
c0.163-0.242,0.398-0.423,0.666-0.5"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M197.384,221.473
c0.258-0.007,0.485-0.125,0.667-0.333"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M199.384,214.973
c-0.04-0.333,0.075-0.609,0.333-0.833"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M117.884,257.306
c0.056,0,0.111,0,0.167,0"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M142.717,252.473
c0.358,0.068,0.71,0.016,1-0.167"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M137.884,256.473
c0.277,0,0.557,0,0.833,0"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M160.884,252.973
c0.366-0.139,0.766-0.402,1-0.667"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M171.384,250.14
c0.235-0.264,0.476-0.562,0.667-0.834"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M89.384,243.973
c0.537,0.378,1.329,0.876,1.833,1.333"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M79.05,225.473
c0.087,0.272,0.143,0.55,0.167,0.833"/>
<path i:knockout="Off" fill="none" stroke="#AAAAAA" stroke-linecap="round" stroke-linejoin="bevel" d="M73.884,222.64
c0,0.167,0,0.333,0,0.5"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M72.55,219.806c0.466-0.325,0.875-0.797,1.167-1.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M71.717,211.973c0.422-0.553,0.776-1.305,1-2"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M78.55,214.473c0-0.111,0-0.222,0-0.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M79.384,218.806c-0.001-0.137,0.055-0.248,0.167-0.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M80.217,221.14c0.111,0,0.222,0,0.333,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M75.55,226.473c0.103-0.5,0.156-0.977,0.167-1.5"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M78.55,230.14c0.111,0,0.222,0,0.333,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M83.384,227.64c0.118-0.059,0.215-0.107,0.333-0.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M81.55,237.14c0.056,0,0.111,0,0.167,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M86.217,233.806c0.056,0,0.111,0,0.167,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M87.884,230.473c0.595-0.181,1.219-0.527,1.833-0.667"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M88.717,222.14
c-0.929,2.359-1.615,4.865-2.667,7.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M89.05,216.14
c0.784-0.736,1.709-1.565,2.833-1.5"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M94.217,210.14
c1.599-0.089,3.199-0.167,4.833-0.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M94.884,224.64
c0.052-0.588-0.004-1.155-0.167-1.667"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M92.384,228.306
c0.585-0.062,1.244-0.132,1.667-0.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M88.717,240.14
c0.111,0,0.222,0,0.333,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M95.884,243.306
c0.526,0.1,1.017-0.016,1.333-0.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M98.55,248.306
c0.069-0.24,0.265-0.926,0.333-1.166"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M96.55,249.806
c0.125,0.014,0.18-0.042,0.167-0.166"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M104.55,250.14
c0.01-0.238,0.126-0.428,0.333-0.5"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M106.884,251.973
c0.195,0.045,0.37-0.014,0.5-0.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M113.884,254.806
c0.758-0.586,1.595-1.171,2.382-1.774c0.072,0.376,0.418,0.686,0.48,1.079c0.833,0.265,1.624-0.021,1.638-0.971"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M122.217,254.64
c0.063-0.165,0.179-0.288,0.333-0.334"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M125.884,255.806
c1.13-0.745,2.783-0.962,3.667-2"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M132.217,255.973
c0.638-0.492,1.104-1.173,1.141-1.976c-1.11,0.063-1.449-0.888-1.475-1.857"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M129.717,249.306
c-0.045,0.153-0.168,0.271-0.333,0.334"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M136.551,252.306
c0.223,0,0.444,0,0.666,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M110.217,251.306
c0.056-0.057,0.111-0.11,0.167-0.166"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M140.717,251.806
c0.111,0,0.224,0,0.334,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M150.051,249.473
c0.111,0,0.223,0,0.333,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M143.217,255.473
c1.022-0.313,1.725-1.175,2.646-1.654c0.203,0.321,0.439,0.626,0.521,0.987"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M152.217,253.473
c0.165-0.063,0.288-0.179,0.334-0.333"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M155.051,254.64
c0.223,0,0.444,0,0.666,0"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M157.717,256.473
c0.326-0.027,0.546-0.073,0.834-0.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M163.217,252.64
c0.552-0.892,2.082-1.512,2.341-2.334c0.37-1.178-1.155-3.069-1.007-4.5"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M167.384,235.973
c0.118-0.54,0.354-1.064,0.667-1.5"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M170.717,242.806
c0-0.333,0-0.667,0-1"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M170.217,236.973
c0-0.333,0-0.667,0-1"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M179.051,235.806
c0.378-0.101,0.738-0.35,1-0.667"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M185.051,232.806
c0.379-0.319,0.656-0.702,0.833-1.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M188.051,231.14
c0.063-0.39,0.178-0.792,0.333-1.167"/>
<path i:knockout="Off" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="M197.884,223.306
c-0.166,0.277-0.334,0.556-0.5,0.833"/>
</g>
<g id="mouths" i:isolated="yes" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F004F00FFFF" enable-background="new ">
<g id="mouth1" i:knockout="Off" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#FFFFFFFF4F00" display="none">
<path i:knockout="Off" display="inline" stroke="#000000" d="M177.122,216.821c-0.515,2.282-5.213,3.21-7.434,3.854
c-3.254,0.945-6.596,1.345-9.895,1.851c-3.26,0.5-6.665,0.671-10.107,0.671c-3.596,0-6.645,0.559-10.106,0.671
c-3.105,0.1-6.898-0.474-9.694-1.3c-3.527-1.043-6.672-1.666-10.096-3.062c-2.823-1.152-5.746-1.876-8.462-3.143
c-2.594-1.209-6.084-1.994-8.221-3.552c-1.068,1.834-5.867,3.748-8.1,4.546c-2.444,0.874-8.881,2.725-7.817,5.512
c0.457,1.195,1.948,2.273,2.63,3.385c0.774,1.261,1.139,2.601,2.057,3.859c1.83,2.5,4.506,4.773,6,7.34
c1.308,2.249,2.096,4.74,4.01,6.669c2.214,2.233,5.792,2.635,9.231,2.399c7.028-0.479,13.982-2.129,20.481-3.983
c3.295-0.941,6.699-1.536,10.086-2.686c3.272-1.111,6.642-3,9.402-4.777c5.248-3.377,10.278-6.409,14.283-10.705
c1.479-1.587,3.429-2.503,5.149-3.859"/>
<path i:knockout="Off" display="inline" fill="#FFC0C0" stroke="#000000" d="M135.25,241.319
c0.723-4.757-10.487-8.47-14.898-9.526c-3.09-0.74-6.68-1.17-9.858-1.712c-2.758-0.47-6.865-0.836-9.437,0.369
c-1.385,0.649-2.843,1.724-4.141,2.513c2.156,3.964,4.728,8.861,9.468,11.506c3.229,1.801,5.511,0.776,8.859,0.373
c3.045-0.369,6.046-0.703,9.029-1.721c3.479-1.186,7.228-2.385,10.978-2.475"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M148.656,225.547c1.267,0.697,1.301,2.838,0.671,3.9
c-0.702,1.182-2.063,1.4-3.307,2.01c-2.271,1.116-4.58,2.624-7.481,2.638c-4.619,0.023-2.144-4.067-0.253-5.869
c2.405-2.292,5.057-2.72,8.72-2.512c0.588,0.034,1.095,0.041,1.65,0.168"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M130.299,223.365
c2.687,0.437,5.619,4.384,3.727,6.422c-1.234,1.33-7.94,1.391-9.915,1.296c-4.896-0.233-2.502-2.445-0.613-4.525
c1.604-1.767,5.088-3.249,7.833-3.36"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M113.178,217.157
c2.56,0.958,4.922,5.057,5.352,7.215c0.377,1.885-0.324,2.106-2.526,2.643c-1.366,0.333-3.636,0.723-5.105,0.385
c-2.506-0.577-5.883-5.051-4.909-7.223c1.03-2.298,5.944-2.923,8.427-2.852"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M99.359,217.662
c2.038,0.432,4.015,4.279,2.468,5.625c-1.083,0.943-5.221,1.795-6.799,1.589c-4.032-0.526-2.265-4.102-0.866-5.872
c0.706-0.894,1.049-1.976,2.514-2.186c1.627-0.233,2.501,0.99,3.921,1.346"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" d="M181.815,222.896c-3.102-2.75-4.765-8.777-9.282-10.403
"/>
</g>
<g id="mouth2" i:knockout="Off" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#FFFF4F00FFFF" display="none">
<path i:knockout="Off" display="inline" stroke="#000000" stroke-width="3" stroke-linecap="round" stroke-linejoin="bevel" d="
M87.57,221.951c5.563-1.759,11.066-1.32,16.694-1.782c2.93-0.24,5.228-1.14,8.309-0.927c3.142,0.217,6.085-0.235,9.289,0.176
c7.136,0.914,13.96,0.598,21.112,1.506c3.654,0.464,7.219,0.609,10.811,0.869c4.017,0.291,7.646,1.582,11.433,2.623
c2.948,0.812,6.347,1.618,9.011,2.99c2.521,1.298,6.354,2.856,8.301,4.72c-2.775,0.027-5.602,2.603-8.021,3.769
c-2.93,1.412-5.741,2.949-8.656,4.432c-5.599,2.849-11.885,5.468-18.104,6.53c-6.793,1.161-13.195,2.107-20.067,2.197
c-7.699,0.102-14.313-4.705-20.735-8.396c-2.071-1.19-4.69-2.182-6.504-3.666c-1.792-1.466-3.469-3.386-5.154-4.984
c-2.703-2.564-7.519-5.649-8.13-9.438"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" stroke-width="2" d="M87.785,228.193
c-5.907-3.235-0.344-9.531,3.971-11.424"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="bevel" d="
M184.679,227.229c-1.534,2.583-2.548,5.334-4.024,7.889"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M106.862,219.528
c-3.071-0.74-5.608,2.166-6.318,4.738c-0.379,1.375-0.494,2.55,0.748,3.337c1.519,0.962,2.905-0.052,4.418-0.332
c2.518-0.467,7.293,0.053,6.461-4.248c-0.568-2.938-3.743-3.682-6.338-3.335c-0.451,0.06-0.758,0.212-1.205,0.229"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M119.764,218.479
c-2.648,1.243-4.657,3.518-5.346,6.377c-0.866,3.594,3.9,3.711,6.356,2.865c2.64-0.91,4.77-3.351,3.299-6.133
c-1.01-1.91-3.979-2.548-6.026-2.823"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M130.388,219.492
c-1.753,1.382-4.069,4.525-4.835,6.61c-1.159,3.156,2.296,3.371,4.868,3.348c3.061-0.028,6.6-1.148,5.022-4.78
c-1.168-2.691-2.552-4.85-5.551-5.241"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M142.954,221.087
c-1.502,0.337-5.418,3.249-5.638,4.997c-0.292,2.311,4.855,4.536,6.854,4.234c2.503-0.377,4.384-3.175,3.167-5.65
c-0.92-1.873-3.36-2.252-4.508-3.932"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M155.354,222.664
c-2.038,0.426-4.212,2.287-4.766,4.444c-0.723,2.821,3.226,3.383,5.458,3.331c2.541-0.059,5.126-1.752,3.249-4.32
c-1.394-1.908-3.707-3.189-5.304-4.636"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M168.367,237.924
c-1.554-1.217-3.302-2.557-5.203-2.976c-2.973-0.654-3.537,2.131-3.377,4.406c0.205,2.913,1.032,3.883,3.901,2.344
c1.987-1.066,4.271-1.997,4.599-4.456"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M151.524,246.202
c-1.912-0.166-4.004-4.491-2.91-6.25c0.771-1.239,5.456-1.688,6.857-1.292c0.271,0.917,0.979,1.841,0.829,2.771
c-0.088,0.54-0.994,1.645-1.296,2.188c-1.08,1.951-2.133,1.866-3.998,2.685"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M145.911,241.458
c-0.209,1.649-0.215,2.702-1.528,3.801c-0.885,0.738-1.772,1.189-2.54,2.1c-0.786,0.933-1.226,2.38-2.792,1.813
c-1.042-0.377-1.959-2.318-2.138-3.312c-0.299-1.676-1.003-5.228,0.783-6.158c1.154-0.603,7.066-0.18,7.43,1.32"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M133.12,238.991
c-1.495-0.087-2.253-1.33-3.918-0.964c-1.42,0.311-2.489,1.354-2.54,2.836c-0.052,1.527,0.99,5.581,1.852,6.956
c2.363,3.771,4.329-1.535,5.516-3.159c1.117-1.525,2.643-2.053,2.271-3.958c-0.318-1.632-1.118-2.047-2.766-2.329
c-0.382-0.065-0.773-0.095-1.158-0.147"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M116.853,237.43
c-1.049,2.211-0.173,5.147,0.047,7.565c0.357,3.93,3.827,2.028,5.831,0.067c1.575-1.541,4.599-4.86,2.209-6.484
c-1.881-1.279-5.727-2.458-7.756-1.107"/>
<path i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M107.455,233.38
c-0.813,2.487-1.704,5.049,0.073,7.364c1.91,2.486,4.009,1.229,5.537-0.939c1.056-1.5,3.316-4.481,1.563-6.017
c-1.347-1.179-6.468-1.518-7.854-0.325"/>
</g>
<g id="mouth3" i:isolated="yes" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFFFFFF" enable-background="new ">
<path i:isolated="yes" i:knockout="Off" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" enable-background="new " d="
M99.05,218.973c1.691-0.875,3.313-2.39,4.833-3.537c1.231-0.928,2.782-1.671,3.5-3.072c1.846,3.486,7.661,4.669,11.003,6.067
c3.553,1.486,7.174,3.066,10.784,4.166c4.271,1.301,9.277,1.67,13.721,2.343c4.155,0.629,9.979,1.365,14.162,0.496
c1.182-0.245,2.343-1.024,3.462-1.446c0.162,1.905-3.637,3.023-4.933,3.487c-2.435,0.871-4.18,2.541-6.362,3.871
c-1.623,0.989-2.974,1.669-4.755,2.117c-1.77,0.445-3.353,0.806-4.825,1.878c-5.915,4.311-15.264,3.247-22.424,3.13
c-5.384-0.088-6.719-5.372-9.337-9c-1.437-1.991-2.843-3.854-3.796-6.138c-0.871-2.086-1.119-4.582-2.033-6.528"/>
<path i:isolated="yes" i:knockout="Off" fill="#F4BDBD" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" enable-background="new " d="
M107.217,227.973c1.182-2.033,4.375-2.176,6.5-1.963c2.879,0.289,4.124,1.217,6.168,3.167c1.834,1.749,5.906,5.509,5.64,8.271
c-2.808,0.89-7.847,0.402-10.346-1.104c-1.334-0.804-1.151-2.256-2.246-3.588c-0.712-0.866-1.836-2.673-2.855-3.311
c-0.209-0.94-2.106-1.499-3.028-1.805"/>
</g>
</g>
<g id="personalProps" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#800080008000">
<g id="hat" i:knockout="Off" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#000000000000" display="none">
<g i:knockout="Off" display="inline">
<g i:knockout="Off">
<path i:knockout="Off" fill="#FF0000" d="M88.374,173.145c0.474-0.074,16.606,2.725,18.01,5.879
c1.145,2.572,28.184,4.568,28.184,4.568l35.971-5.618l5.024,1.132l7.212,0.315l9.295,0.851l10.188,3.248l5.75,2.935
l1.615-1.832l-0.264-5.27l-3.968-7.087c0,0-22.045-13.031-23.272-13.703c-1.229-0.669-4.941-2.294-6.484-4.542
c-8.584-12.528-8.403-18.05-3.371-6.461c0,0,2.662-7.592,2.521-8.575c-0.144-0.982,0.354-5.031,0.354-5.031l2.396-6.832
c0,0-1.379-5.341-2.738-7.19c-1.356-1.844-15.793-4.078-18.162-4.011c-24.933,0.706-3.783,0.071-25.567,0.724
c-24.317,0.728-0.882-2.591-24.068,3.551c-24.228,6.418-5.35-1.298-23.187,6.142c-18.301,7.633-16.67,7.186-16.704,10.685
c-0.034,3.499-3.057-4.884-0.034,3.499c3.023,8.381,3.037-3.871,3.023,8.381c-0.015,12.252,6.696,4.557,1.678,12.373
c-5.017,7.813-3.831,7.91-0.179,8.543c17.017,2.953,4.157,4.378,17.427,3.175"/>
<path i:knockout="Off" d="M156.604,114.92l-13.936,0.381l-11.633,0.343c-10.646,0.319-11.973-0.155-12.021-0.175l-0.599-0.238
l-0.577,0.514l0.049-0.047c-0.118,0.09-1.43,0.957-11.145,3.53c-9.989,2.646-12.812,2.931-13.421,2.704
c-0.822-0.306-0.821-0.306-7.791,2.604l-2.104,0.878c-16.037,6.689-17.342,7.324-17.342,10.316c0,0.019,0.001,0.041,0.001,0.06
c-0.224-0.108-0.459-0.199-0.787-0.04c-0.357,0.173-0.565,0.275-0.565,0.672c0,0.557,0.411,1.697,1.399,4.438
c0.924,2.561,1.71,3.671,2.714,3.833c0.083,0.014,0.164,0.02,0.241,0.02c0.007,0.584,0.01,1.339,0.01,2.313
c0,0.561-0.001,1.902-0.001,1.916c0,6.908,2.176,8.105,3.347,8.749c0,0,0.075,0.045,0.151,0.09
c-0.095,0.332-0.47,1.1-1.661,2.955c-2.509,3.908-3.516,5.931-3.516,7.303c0,0.358,0.068,0.671,0.196,0.962
c0.544,1.237,1.926,1.477,3.677,1.78l0.135,0.023c8.138,1.412,9.14,2.422,9.568,2.854c0.923,0.931,1.511,0.928,7.224,0.413
c0.06,0.014,0.102,0.068,0.165,0.071c2.167,0.105,16.131,3.138,17.087,5.288c1.147,2.578,16.416,4.228,29.023,5.159
l0.115,0.009c0,0,35.523-5.548,35.896-5.606c0.345,0.078,4.927,1.11,4.927,1.11l7.301,0.319c0,0,8.927,0.818,9.139,0.837
c0.202,0.064,9.854,3.142,10.006,3.19c0.143,0.073,6.368,3.251,6.368,3.251l2.397-2.719l-0.296-5.911l-4.213-7.526
l-0.231-0.137c-0.9-0.532-22.073-13.047-23.304-13.72c-0.001,0-0.734-0.38-0.734-0.38c-1.48-0.752-4.238-2.151-5.404-3.85
c-1.357-1.982-2.451-3.729-3.354-5.268c0.021-0.064,0.104-0.296,0.104-0.296c1.193-3.402,2.576-7.619,2.576-8.885
c0-0.063-0.004-0.118-0.011-0.165c-0.013-0.083-0.018-0.204-0.018-0.356c0-0.909,0.194-2.911,0.363-4.307
c0.072-0.205,2.46-7.013,2.46-7.013l-0.076-0.294c-0.146-0.566-1.468-5.584-2.9-7.532
C173.721,116.784,158.242,114.875,156.604,114.92z M131.097,117.644l11.614-0.342l13.951-0.382
c2.575-0.073,16.104,2.238,17.336,3.614c0.956,1.3,2.058,4.938,2.49,6.549c-0.188,0.536-2.33,6.642-2.33,6.642l-0.014,0.107
c-0.072,0.592-0.387,3.224-0.387,4.658c0,0.258,0.011,0.477,0.034,0.639c-0.006,0.493-0.768,3.026-1.659,5.709
c-2.14-4.566-2.792-4.606-3.242-4.629l-0.62-0.031l-0.354,0.571c-0.069,0.124-0.102,0.29-0.102,0.492
c0,2.273,4.134,9.172,6.992,13.346c1.456,2.12,4.51,3.669,6.149,4.501l0.682,0.353c1.139,0.622,20.813,12.25,23.012,13.549
c0.238,0.427,3.513,6.275,3.721,6.647c0.02,0.393,0.199,3.971,0.23,4.629c-0.229,0.262-0.472,0.535-0.832,0.944
c-1.069-0.546-5.132-2.619-5.132-2.619l-10.369-3.306l-9.403-0.86c0,0-6.995-0.307-7.169-0.315
c-0.168-0.038-5.124-1.155-5.124-1.155s-35.814,5.594-36.044,5.63c-12.419-0.922-25.993-2.687-27.285-4.058
c-1.366-3.097-13.245-5.574-17.517-6.211c-0.203-0.212-0.479-0.346-0.793-0.318c-3.083,0.28-5.996,0.544-6.4,0.369
c0-0.003-0.12-0.117-0.12-0.117c-0.703-0.708-1.879-1.895-10.646-3.416l-0.135-0.023c-0.827-0.143-2.075-0.359-2.188-0.614
c-0.021-0.048-0.033-0.111-0.033-0.193c0-0.592,0.632-2.179,3.205-6.187c1.488-2.318,2.024-3.388,2.024-4.188
c0-0.15-0.019-0.291-0.054-0.428c-0.181-0.712-0.758-1.03-1.179-1.261c-0.865-0.476-2.311-1.271-2.311-6.993
c0-0.014,0.001-1.098,0.001-1.56c0-4.969-0.065-4.992-0.833-5.258c-0.424-0.146-0.816,0.001-1.178,0.377
c-0.208-0.289-0.558-0.898-1.073-2.324c-0.205-0.568-0.385-1.068-0.542-1.506c0.587-0.423,0.632-1.277,0.636-1.644
l-0.014-0.825c-0.004-0.119-0.007-0.231-0.007-0.338c0-1.702,0.899-2.264,16.109-8.608l2.105-0.878
c4.165-1.739,5.948-2.482,6.375-2.562c0.817,0.296,2.292,0.597,14.579-2.658c8.169-2.164,10.697-3.187,11.58-3.704
C120.451,117.773,124.529,117.84,131.097,117.644z"/>
</g>
<g i:knockout="Off">
<path i:knockout="Off" fill="#FFFFFF" d="M155.146,147.93c4.88-9.398-5.344-20.199-12.649-21.176
c-12.05-1.61-13.404,10.426-13.684,21.258c3.73,2.016,8.915,3.425,11.721,6.534"/>
<path i:knockout="Off" d="M133.446,127.979c-4.599,3.921-5.426,11.933-5.635,20.006l-0.017,0.654l4.415,2.067
c2.849,1.244,5.793,2.529,7.581,4.509c0.371,0.41,1.004,0.442,1.412,0.072c0.219-0.197,0.33-0.469,0.33-0.743
c0-0.239-0.084-0.479-0.258-0.67c-2.076-2.299-5.223-3.673-8.267-5.001c0,0-2.377-1.112-3.174-1.486
c0.223-7.385,1.021-14.572,4.909-17.887c1.892-1.614,4.386-2.189,7.621-1.757c4.143,0.554,9.086,4.472,11.5,9.113
c1.348,2.591,2.51,6.535,0.395,10.611c-0.254,0.49-0.063,1.093,0.426,1.348c0.49,0.254,1.095,0.063,1.351-0.427
c1.959-3.775,1.817-8.199-0.396-12.456c-2.731-5.251-8.203-9.53-13.012-10.172C138.853,125.257,135.763,126,133.446,127.979z"
/>
</g>
<g i:knockout="Off">
<path i:knockout="Off" d="M154.077,146.278c-2.156,1.18-4.24,2.619-6.256,4.01c-3.636,2.509-7.068,4.878-10.941,5.924
c-2.991,0.808-6.055,1.058-9.3,1.324c-3.222,0.263-6.553,0.536-9.783,1.406c-2.027,0.546-4.117,1.397-6.137,2.221
c-3.491,1.423-7.102,2.895-10.528,2.866c-0.552-0.005-1.004,0.439-1.009,0.991c-0.005,0.552,0.439,1.004,0.991,1.009
c3.828,0.033,7.627-1.516,11.301-3.014c2.054-0.837,3.994-1.628,5.902-2.142c3.054-0.823,6.292-1.088,9.425-1.344
c3.191-0.261,6.492-0.531,9.659-1.386c4.205-1.135,7.94-3.714,11.557-6.208c1.973-1.362,4.014-2.771,6.08-3.901
c0.484-0.265,0.662-0.873,0.396-1.357C155.168,146.193,154.562,146.014,154.077,146.278z"/>
</g>
<g i:knockout="Off">
<path i:knockout="Off" d="M156.458,153.549c-2.619,0.064-5.709,0.812-8.98,1.604c-4.278,1.035-8.7,2.104-11.901,1.536
c-0.543-0.096-1.063,0.267-1.159,0.81c-0.097,0.544,0.267,1.063,0.81,1.16c3.613,0.641,8.24-0.481,12.72-1.562
c3.166-0.766,6.153-1.489,8.561-1.548c5.664-0.141,7.961,0.698,13.508,2.724c0.519,0.189,1.095-0.077,1.281-0.596
c0.189-0.519-0.076-1.091-0.596-1.282C165.069,154.337,162.501,153.399,156.458,153.549z"/>
</g>
</g>
</g>
<g id="textSurface" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F008000FFFF">
<g id="spokenBubble" i:knockout="Off" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#FFFF4F004F00" display="none">
<path id="textContainer" i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M225.719,45.307
c0-6.627,5.373-12,12-12h181.333c6.627,0,12,5.373,12,12v105.334c0,6.627-5.373,12-12,12H237.719c-6.627,0-12-5.373-12-12
V45.307z"/>
<path id="textArrowBelow" i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M249.052,160.64
c-0.774,14.251-1.676,18.525-9.1,30.565c9.705-0.79,21.952-21.605,25.1-30.045"/>
</g>
<g id="thoughtBubble" i:knockout="Off" i:layer="yes" i:dimmedPercent="50" i:rgbTrio="#4F00FFFF4F00">
<path id="textContainer_1_" i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M202.698,21.089
c19.686-26.45,59.686-24.45,79.747-0.084c2.696,1.349,5.57,1.709,7.472,0.781c15.28-13.888,33.271-14.043,49.893-7.839
c2.771,1.034,5.479,2.219,8.031,3.421C376.384-4.36,423.384,6.64,431.007,45.026c0,0-1.324,3.889,1.165,6.603
c18.212,11.011,26.212,32.011,22.212,53.011c-1,5.333-3.223,9.667-6.037,13.52c-2.813,3.854-1.381,0-2.612-0.591
c-1.351-0.929-3.351-0.929-4.351-1.929c16,7,27,22,30,39c2,21-8,41-27,50c-16,7.5-32.5,5.5-45.745-2.556
c-2.531-1.384-4.229-1.856-5.336-1.551c-1.919,0.107-3.919,2.107-5.919,2.107c4-1,6-5,10-6c-15,11-35,12-52,3c-13-7-20-20-24-34
c1,5,3,9,3.299,13.505c-0.396,0.708-3.423,2.219-6.654,3.466c-22.627,8.729-49.423,1.729-65.241-19.971
c-3.453,0-6.263,0.589-8.723,0.879c-17.301,3.2-32.382-7.709-40.771-22.689c-1.678-2.996-3.089-6.153-4.195-9.396
c-15.714-7.795-29.714-18.795-33.714-37.795c-5-25,11-45,29.842-57.667c0.72-2.335,1.697-4.636,3.007-6.896
C201.159,23.307,202.698,21.089,202.698,21.089z"/>
<g i:knockout="Off">
<path i:knockout="Off" fill="#FFFFFF" d="M269.719,186.307c0,4.602-4.179,8.333-9.333,8.333s-9.334-3.731-9.334-8.333
c0-4.603,4.18-8.333,9.334-8.333S269.719,181.705,269.719,186.307z"/>
<g i:knockout="Off">
<path i:knockout="Off" fill="none" d="M269.719,186.307c0,4.602-4.179,8.333-9.333,8.333s-9.334-3.731-9.334-8.333
c0-4.603,4.18-8.333,9.334-8.333S269.719,181.705,269.719,186.307z"/>
<path i:knockout="Off" fill="#FFFFFF" d="M268.225,186.166c-0.563,8.736-13.981,9.286-15.633,0.853
c-1.785-9.125,15.018-10.254,15.649-0.451c0.125,1.929,3.078,1.388,2.955-0.521c-0.814-12.597-20.828-12.412-21.64,0.119
c-0.827,12.813,20.831,13.028,21.655,0.283C271.337,184.519,268.35,184.235,268.225,186.166z"/>
</g>
</g>
<path i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M260.386,188.307c0,3.498-2.984,6.333-6.667,6.333
c-3.682,0-6.667-2.835-6.667-6.333s2.985-6.333,6.667-6.333C257.401,181.974,260.386,184.809,260.386,188.307z"/>
<path i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M238.386,196.974c0,1.289-1.045,2.333-2.334,2.333
c-1.288,0-2.333-1.045-2.333-2.333c0-1.288,1.045-2.333,2.333-2.333C237.341,194.64,238.386,195.685,238.386,196.974z"/>
<path i:knockout="Off" fill="#FFFFFF" stroke="#000000" d="M285.719,179.974c0,4.602-4.253,8.333-9.5,8.333
s-9.5-3.731-9.5-8.333c0-4.603,4.253-8.333,9.5-8.333S285.719,175.372,285.719,179.974z"/>
</g>
<g id="yellBubble" i:knockout="Off" i:layer="yes" i:visible="no" i:dimmedPercent="50" i:rgbTrio="#4F004F00FFFF" display="none">
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M251.156,176.051l40.228-15.992"/>
<path i:knockout="Off" display="inline" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="bevel" d="
M280.932,149.385l-40.667,36.42"/>
<path id="textContainer_2_" i:knockout="Off" display="inline" fill="#FFFFFF" stroke="#000000" d="M217.778,34.644
c8.608,6.684,9.951,3.684,7.986-5.785c6.309,5.125,9.309,3.782,10.188-4.309c2.433,8.091,5.266,8.091,9.12-1.703
c6.063,9.793,13.146,9.793,24.043,3.878c6.103,5.915,16.02,5.915,20.094-4.64c17.178,10.555,28.511,10.555,45.233-5.505
c5.94,16.06,17.272,16.06,18.835,1.458c19.688,14.603,29.604,14.603,46.749-17.802c-0.145,32.405,6.938,32.405,29.26,16.182
c-12.403,16.223-9.57,16.223,4.813,6.576c-11.069,9.646-8.069,10.99,4.333,9.089c-8.061,6.244-6.717,9.244,2.533,11.068
c-9.25,1.489-9.25,5.703-0.314,13.07c-8.936,6.115-8.936,15.385,7.513,10.932c-16.447,24.677-16.447,35.631,14.938,36.553
c-31.385,19.303-31.385,28.571-4.39,40.526c-26.995,1.528-26.995,5.741-5.942,17.857c-21.053-8.801-22.396-5.802-9.525,11.916
c-17.213-13.374-20.213-12.03-12.048,8.029c-11.479-20.06-14.313-20.06-10.554,3.532c-13.676-23.591-20.759-23.591-29.813-2.664
c-7.944-20.927-17.861-20.927-27.072,12.467c-12.039-33.395-23.373-33.395-23.147-1.581
c-22.891-31.814-34.225-31.814-61.518-8.479c6.042-23.335-3.874-23.335-11.899-9.703c-8.976-13.632-16.059-13.632-23.927,4.361
c-2.049-17.993-4.882-17.993-10.51-1.486c2.314-16.508-0.686-17.851-12.385-5.019c7.355-17.175,6.013-20.176-10.271-7.879
c16.283-15.61,16.283-19.824-9.255-12.972c25.538-20.334,25.538-29.603,1.919-46.578c23.619-3.249,23.619-14.204-0.313-25.522
c23.933-8.905,23.933-18.175,7.798-37.429C226.385,48.854,226.385,44.641,217.778,34.644z"/>
</g>
</g>
</g>
</svg>
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/Lars.json
New file
0,0 → 1,1823
[
{
"name": "torso",
"children": [
{
"name": "leftArm",
"shape": {
"type": "path",
"path": "M156.007,292.674c2.737,1.779,5.563,3.322,8.752,3.947c7.098,1.39,19.25-5.666,23.136-11.699 c1.572-2.441,8.077-21.031,11.177-14.271c1.224,2.67-1.59,4-1.399,6.462c3.108-1.425,5.48-5.242,8.918-2.182 c0.672,4.019-4.472,4.343-3.918,7.669c1.376,0.218,5.394-1.595,6.285-0.535c1.707,2.027-2.933,3.561-4.072,4.018 c-1.852,0.741-4.294,1.233-5.988,2.369c-2.636,1.768-4.766,5.143-7.034,7.4c-11.657,11.604-26.183,10.553-40.646,5.515 c-4.713-1.642-17.399-4.472-18.655-9.427c-1.647-6.502,5.523-7.999,10.184-6.74C147.658,286.528,151.725,289.891,156.007,292.674z"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "leftArmThumb",
"shape": {
"type": "path",
"path": "M188.257,284.902c-1.932-1.391-3.314-4.206-3.506-6.494c-0.149-1.786,0.59-6.522,3.199-3.95c0.792,0.78,0.083,2.155,0.558,2.943 c0.885,1.47,1.071,0.493,2.748,1.002c1.406,0.426,3.827,2.05,4.251,3.499"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "rightArm",
"shape": {
"type": "path",
"path": "M57.05,283.306c-5.502,5.354-13.185,8.541-18.249,14.221c-4.303,4.827-7.721,11.575-11.138,17.112 c-6.752,10.939-10.794,26.076-19.912,35.185c-3.869,3.866-7.637,5.721-7.251,12.032c0.932,0.372,1.548,0.589,2.418,0.683 c0.605-2.746,2.569-4.199,5.362-3.799c-0.14,3.365-3.512,5.941-3.228,9.235c0.364,4.223,3.983,5.968,7.181,2.662 c2.61-2.699,0.192-7.848,3.338-10.179c5.535-4.103,2.889,2.998,4.13,5.514c5.19,10.519,8.634-1.859,7.35-7.996 c-2.336-11.159-3.003-15.126,3.267-24.416c6.358-9.419,12.194-18.708,19.399-27.588c1.116-1.375,2.08-2.728,3.333-4"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "shirt",
"children": [
{
"name": "tShirt",
"shape": {
"type": "path",
"path": "M96.509,268.264 c-2.301,0.323-4.69,0.205-6.945,0.72c-2.234,0.509-4.5,0.8-6.749,1.249c-4.369,0.872-8.206,3.265-12.3,5.024 c-3.259,1.401-6.644,2.571-9.763,4.26c-1.923,1.041-3.688,2.616-5.487,3.97c-1.543,1.16-3.495,2.11-4.854,3.562 c-2.205,2.354,0.896,7.408,1.854,9.873c0.92,2.368,2.149,4.82,2.749,7.29c0.228,0.937,0.235,2.058,0.875,2.873 c0.644,0.821,0.64,0.735,1.822,0.048c1.513-0.878,2.873-1.993,4.329-2.993c2.431-1.67,5.462-2.848,7.434-5.111 c-3.335,1.652-5.335,4.679-6.931,8.012c-1.398,2.92-4.482,35.854-5.389,38.947c-0.195,0.003-0.775,0.003-0.749,0.013 c20.561,0,41.123-0.07,61.684,0c2.1,0.007,3.607-0.497,5.529-1.252c0.715-0.281,2.257-0.356,2.807-0.745 c1.412-0.998-0.094-3.916-0.646-5.302c-1.425-3.579-2.111-37.767-4.726-40.543c1.842,0.057,4.127,1.311,5.937,1.95 c1.351,0.478,2.633,1.092,3.956,1.66c1.39,0.597,3.667,1.927,5.168,1.858c0.296-1.873,1.045-3.286,1.839-5.02 c0.943-2.061,1.155-4.214,1.528-6.415c0.351-2.07,0.898-3.787,1.939-5.635c0.531-0.942,1.356-1.73,1.693-2.768 c-0.443-0.402-1.043-0.907-1.603-1.125c-0.56-0.219-1.292-0.111-1.908-0.33c-1.237-0.438-2.44-1.089-3.669-1.576 c-3.773-1.499-7.519-2.983-11.319-4.466c-3.575-1.396-6.977-3.239-10.784-3.872c-1.735-0.289-3.467-0.529-5.073-0.906"
},
"fill": "#4459A5",
"stroke": {
"color": "#000000",
"cap": "round"
}
},
{
"name": "shirtNeck",
"shape": {
"type": "path",
"path": "M99.759,268.889 c-0.984,0.152-1.746-0.549-2.75-0.5c-1.369,0.066-1.649,0.872-2.153,2c-1.037,2.325-2.442,4.974,0.064,6.946 c2.53,1.991,6.964,1.717,9.829,0.803c1.616-0.516,3.045-1.24,3.825-2.867c0.508-1.061,0.935-2.771,0.149-3.598 c-0.231-0.243-0.562-0.376-0.84-0.534"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round"
}
},
{
"name": "shirtLogo",
"children": [
{
"children": [
{
"shape": {
"type": "path",
"path": "M104.864,296.92c-0.151-0.003,7.101,0.41,7.052,0.404c0.132,0.028-0.172,0.633-0.021,0.632 c-0.226,0.028-7.244-0.454-7.28-0.464C104.657,297.518,104.776,296.904,104.864,296.92z"
},
"stroke": {
}
}
]
},
{
"children": [
{
"shape": {
"type": "path",
"path": "M90.071,295.919c-0.199,0.004,6.792,0.43,6.79,0.446c0.153,0.005-0.031,0.663,0.012,0.665 c0.272,0.015-6.79-0.471-6.875-0.459C89.881,296.56,89.796,295.899,90.071,295.919z"
},
"stroke": {
}
}
]
},
{
"shape": {
"type": "path",
"path": "M84.407,306.476c0.2-0.159,0.322-1.04,0.254,0.057 c-0.542-0.356-2.02,2.083-4.215,2.001c-1.887-1.706-4.559-3.384-4.302-7.092c0.652-2.599,3.082-4.084,5.213-3.942 c1.889,0.377,2.899,0.716,4,1.318c-0.497,0.957-0.175,0.866-0.459,0.703c0.456-2.398,0.598-5.75,0.312-7.855 c0.594-0.554,0.714,0.125,1.249,0.941c0.502-0.727,0.509-1.425,0.875-0.571c-0.207,1.328-0.809,7.186-0.711,10.174 c-0.126,2.797-0.375,4.354-0.051,4.985c-0.718,0.613-0.667,1.006-0.981,1.381c-0.72-1.33-1.056-0.132-1.339-0.157 C84.632,308.442,84.493,305.791,84.407,306.476z M81.186,307.176c2.403,0.206,3.734-2.164,3.841-4.222 c0.269-2.72-0.896-5.104-3.198-5.04c-1.972,0.437-3.46,2.188-3.331,4.638C78.171,306.265,79.847,306.961,81.186,307.176z"
},
"stroke": {
}
},
{
"shape": {
"type": "path",
"path": "M93.321,297.766c2.592,0.148,5.688,2.315,5.696,5.627 c-0.611,4.576-3.69,5.316-6.158,5.581c-2.68-0.76-5.708-1.872-5.413-6.472C88.086,299.394,90.653,297.875,93.321,297.766z M92.939,307.46c2.531,0.735,3.706-1.297,3.666-3.935c0.114-2.219-0.641-4.584-3.389-4.896c-2.29-0.552-3.366,2.188-3.661,4.688 C89.339,305.264,89.934,307.95,92.939,307.46z"
},
"stroke": {
}
},
{
"shape": {
"type": "path",
"path": "M99.688,303.916c0.03-1.511,0.055-4.731,0.022-4.646 c0.481-1.355,0.658-0.556,1.034-1.297c0.263,1.473,0.653,0.326,1.186,0.066c-0.386,2.517-0.513,3.347-0.574,4.949 c-0.068-0.47-0.128,2.28-0.238,2.188c-0.055,1.935-0.036,2.201-0.047,4.219c-0.079,0.914-0.28,2.412-1.126,3.831 c-0.61,1.212-1.73,1.146-3.24,1.651c0.073-0.945-0.065-1.242-0.096-1.822c0.098,0.138,0.213,0.604,0.225,0.398 c1.892,0.228,2.209-1.896,2.362-3.366c0.042,0.304,0.512-6.933,0.415-7.061C99.73,302.636,99.75,303.178,99.688,303.916z M100.978,295.564c0.717,0.14,1.11,0.61,1.099,1.156c0.052,0.552-0.595,0.993-1.286,1.015c-0.541-0.074-1.025-0.548-1.022-1.054 C99.813,296.084,100.292,295.643,100.978,295.564z"
},
"stroke": {
}
},
{
"shape": {
"type": "path",
"path": "M108.115,298.791c3.028-0.067,5.283,1.359,5.256,5.757 c-0.264,3.479-3.366,4.63-5.883,5.12c-2.429-0.034-5.619-2.241-5.16-5.811C102.322,300.085,105.715,298.845,108.115,298.791z M107.351,309.232c2.675-0.132,3.839-2.333,3.841-4.497c0.246-2.344-0.263-4.833-2.923-5.396 c-2.844,0.299-3.974,1.917-4.053,4.48C104.136,306.655,104.854,308.372,107.351,309.232z"
},
"stroke": {
}
}
]
}
]
}
]
},
{
"name": "heads",
"children": [
{
"name": "head1",
"children": [
{
"name": "leftEart",
"children": [
{
"shape": {
"type": "path",
"path": "M201.557,195.474 c7.734-4.547,16.591-5.012,18.405,4.443c2.43,12.659-3.317,13.328-14.598,13.328"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M211.711,203.09 c0.523,0.004,0.946-0.208,1.27-0.635"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M211.076,197.377 c3.062,3.013,5.489,5.624,4.443,10.155"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
}
]
},
{
"name": "bgHairTop",
"shape": {
"type": "path",
"path": "M54.384,199.306c-5.253-4.402-7.511-11.061-15.779-10.632c3.449-1.277,7.116-2.397,10.911-2.666 c-2.873-1.397-5.865-2.575-8.231-4.718c3.986-1.119,11.47-1.817,14.864,0.75c-5.183-2.758-8.397-7.816-13.062-10.598 c6.014-0.643,12.377,0.978,18.022,2.265c-2.547-4.486-6.682-10.83-10.523-14.297c5.033,1.052,10.647,4.518,15.062,7.177 c-1.614-4.176-5.634-8.406-7.859-12.513c10.312-1.125,12.522,4.919,19.7,9.932c-0.412-0.127-1.114-0.113-1.527,0.015 c0.875-7.261,3.058-12.8,8.258-18.566c6.771-7.507,17.812-9.131,24.095-15.381c-4.699,1.821-4.518,23.765-4.875,28.955"
},
"fill": "#FFF471",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "bgHairLeft",
"shape": {
"type": "path",
"path": "M92.384,243.972c-6.334,7.929-12.601,12.241-22.465,15.362c3.65-1.263,7.735-5.86,7.695-9.928 c-2.208,0.218-4.49,0.605-6.498,1.097c1.244-1.097,2.087-3.239,3.198-4.396c-5.77,0.001-12.131,1.133-18.396,1.23 c5.013-2.809,10.665-3.25,12.398-9.246c-3.59,0.313-7.233,1.606-11.033,1.097c1.731-2.022,3.953-3.995,5.049-6.447 c-3.781,0.056-6.665,3.098-10.547,2.465c0.962-2.863,3.187-5.208,4.531-7.766c-5.59-0.273-11.658,2.45-17.732,2.564 c5.494-2.857,8.967-7.819,12.3-12.718c5.233-7.693,10.625-9.96,20.349-9.981c11.059-0.024,15.558,6.714,20.984,16 c2.786,4.767,7.249,14.375,0.832,18"
},
"fill": "#FFF471",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "bgHair",
"shape": {
"type": "path",
"path": "M142.384,255.306c2.984,6.076,3.567,11.856,10.531,14.6c-0.134-3.114-0.094-6.664,1.619-9.033 c1.605,1.968,3.122,4.211,5.048,5.698c-0.29-1.769,0.412-4.024,0.233-5.828c3.445,0.26,4.979,3.965,8.468,4.479 c0.066-2.78,0.427-5.151,0.868-7.813c2.687,0.2,4.768,1.565,7.132,2.997c0.452-4.921-0.409-10.579-0.667-15.666 c-5.795-0.756-12.291,2.827-17.899,3.899c-4.414,0.844-14.136,0.524-15.333,6"
},
"fill": "#FFF471",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "neck",
"shape": {
"type": "path",
"path": "M106.989,254.499c-2.932,6.063-4.613,11.997-8.947,17.137c7.288,10.195,16.311-10.9,15.183-17.026 c-1.926-1.138-3.928-1.589-6.236-1.38"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "headShape",
"shape": {
"type": "path",
"path": "M210.941,207.665c-0.843,3.985-2.081,7.982-3.769,11.783c-3.374,7.604-8.543,14.427-16.052,18.899 c-2.94,2.13-5.983,4.167-9.109,6.085c-25.013,15.342-55.353,23.08-82.254,10.57c-3.433-1.557-6.785-3.431-10.053-5.66 c-1.821-1.184-3.592-2.46-5.308-3.832c-1.715-1.373-3.375-2.842-4.972-4.412c-2.352-2.148-4.576-4.425-6.631-6.814 c-6.168-7.169-10.823-15.358-12.87-24.185c-0.649-3.284-0.84-6.634-0.5-9.975c4.48-13.743,14.22-24.364,26.109-32.149 c2.973-1.946,6.079-3.715,9.271-5.309c30.581-15.027,69.581-10.027,95.851,12.209c2.564,2.254,4.988,4.651,7.244,7.178 c4.513,5.054,8.354,10.626,11.312,16.64C210.178,201.505,210.798,204.496,210.941,207.665z"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "rightEar",
"children": [
{
"shape": {
"type": "path",
"path": "M64.857,195.606 c-6.59-7.181-15.047-10.664-19.467,3.676c-1.235,4.007-1.87,14.468,1.29,17.786c4.223,4.435,13.591,0.529,19.055-0.015"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M52.407,196.743 c-1.702,3.613-1.257,7.505-1.27,11.424"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M51.772,209.437 c-3.39-4.661,0.922-5.769,5.078-6.347"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
}
]
},
{
"name": "fgHair",
"shape": {
"type": "path",
"path": "M90.384,154.639c8.453-11.353,15.678-13.458,28.581-15.915c-1.382,3.376-3.89,7.352-5.179,11.16 c5.01-1.816,9.571-6.545,15.218-8.413c11.355-3.755,23.852-1.903,35.671-2.213c-3.004,3.712-4.912,7.88-2.026,11.447 c5.856-2.212,13.37-6.871,19.635-6.646c0.263,4.561-0.024,9.278,0.201,13.841c3.509-1.201,6.015-3.04,8.277-5.148 s3.761-4.049,4.942-5.2c1.063,2.408,2.134,5.334,2.24,8.494c-0.182,3.462-0.866,6.794-2.66,9.291 c3.663,0.65,6.098-2.021,8.35-4.479c-0.655,4.349-3.164,8.604-3.851,13.013c2.178-0.072,4.382,0.216,6.367-0.48 c-1.389,3.093-3.069,7.287-6.616,8.414c-4.475,1.423-4.354-0.992-7.315-4.332c-4.892-5.518-9.774-6.791-15.872-9.464 c-6.585-2.887-10.983-6.47-17.963-8.219c-8.994-2.255-19.864-3.867-28.093-5.196c2.466,1.967,1.138,5.594,0.659,8.625 c-2.729-0.645-4.41-3.813-6.301-5.158c0.953,3.195,0.983,6.953-2.134,8.491c-6.145-5.226-9.199-9.721-17.527-11.647 c1,1.83,1.728,4.208,1.396,6.402c-0.751,4.971-0.289,3.134-3.836,2.466c-5.192-0.977-9.953-3.677-15.815-4.496 c3.292,2.002,5.469,5.017,7.418,8.21c-2.651,0.404-6.238,0.257-8.382,1.671c2.456,0.38,3.44,2.166,3.197,4.714 c-7.45,0.386-13.623,0.731-19.915,5.434"
},
"fill": "#FFF471",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
}
]
}
]
},
{
"name": "eyes",
"children": [
{
"name": "eyes1",
"children": [
{
"shape": {
"type": "path",
"path": "M123.163,176.668 c-5.066,1.17-9.01,7.888-13.666,10.335c-4.238,2.227-8.648,6.636-7.009,12.332c1.971,6.848,12.042,3.991,16.261,1.165 c5.282-3.539,9.59-8.517,12.006-14.524c1.523-3.787,2.568-7.272-1.509-9.391c-2.905-1.51-8.174-1.386-11.417-0.583"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M182.545,179.865 c-3.533,0.169-4.854-1.166-8.408-0.001c-3,0.983-6.24,1.936-8.852,3.743c-3.938,2.725-7.46,5.555-4.73,13.592 c1.973,5.811,8.791,7.571,14.656,6.667c5.537-0.854,9.078-4.977,11.408-10.007c3.666-7.918,0.943-11.639-6.742-13.659"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000",
"cap": "round"
}
},
{
"shape": {
"type": "path",
"path": "M108.829,183.668c-1.308-1.03-4.557,0.011-5.6-1.733 c-1.056-1.765,1.735-5.409,2.984-6.192c5.684-3.562,15.946-0.39,19.95-6.742"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M163.877,167.198c2.369,1.282,6.539,0.307,9.408,0.815 c3.449,0.612,7.066,2.657,10.592,2.851"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M127.496,192.002c-4.917-2.12-9.188-1.708-8.608,4.942 c3.132,1.734,5.428-2.82,7.275-4.942"
},
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M174.852,203.143c-0.293,0.12-0.307,0.577-0.943,0.282 c-1.605-3.188-0.404-6.507,2.676-8.192c2.15-1.176,5.67-1.759,7.471,0.359c0.199,0.234,0.412,0.521,0.514,0.813 c0.229,0.649-0.285,0.95-0.285,0.95s-3.988,6.009-3.285,1.934c0.438,1.743-5.537,5.743-2.287,1.653 c-1.955,2.583-2.525,1.977-3.859,2.868"
},
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "eyes2",
"children": [
{
"shape": {
"type": "path",
"path": "M98.668,186.108c0.668-8.915,15.545-13.749,22.667-15"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M169.667,178.108 c5.307,3.436,16.928,5.632,19.668,12.333"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M105.334,197.775c8.085-4.283,17.059-2.8,25-6.333"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M164.001,198.775c4.656-0.417,9.664,1.805,14.334,2.017 c3.951,0.18,5.773,0.189,9,2.316"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M124.001,188.108c3.039-0.258,4.594,2.571,5.301,4.983 c-1.096,1.242-2.065,2.646-2.968,4.017"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M168.335,194.108c-1.77,2.293-4.869,3.271-6.299,5.91 c1.377,0.991,3.02,2.122,3.965,3.424"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
}
]
}
]
},
{
"name": "beard",
"children": [
{
"shape": {
"type": "path",
"path": "M96.05,213.639 c-0.366,0.21-0.783,0.389-1.167,0.5"
},
"fill": "#AFA8A5",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M102.55,211.972 c0.314-0.01,0.554-0.198,0.667-0.5"
},
"fill": "#AFA8A5",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M105.717,208.805 c0.164-0.109,0.336-0.224,0.5-0.333"
},
"fill": "#AFA8A5",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M111.05,207.972 c-0.651-1.81,0.859-2.262,2.333-1.5"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M117.717,209.805 c1.738,0,3.653,0.369,5.333,0.167"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M132.717,214.472 c0.104-0.21,0.162-0.435,0.167-0.667"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M139.551,216.972 c0.215-0.175,0.465-0.426,0.666-0.667"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M144.551,213.305 c0.277-0.056,0.556-0.111,0.833-0.167"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M147.884,216.639 c0.195,0.045,0.369-0.013,0.5-0.167"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M148.384,214.139 c0.112-0.168,0.222-0.332,0.333-0.5"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M98.217,219.305c1.697-1.772,4.233-2.109,5.967-4.046c1.519-1.696,3.812-3.001,4.2-5.454"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M152.717,216.139 c0.611,0,1.223,0,1.834,0"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M160.384,217.472 c0.333,0,0.667,0,1,0"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M163.217,215.972 c0.321-0.042,0.658-0.175,0.834-0.333"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M164.217,218.805 c0.167,0,0.333,0,0.5,0"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M168.384,217.972 c0.056-0.056,0.111-0.111,0.167-0.167"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M169.884,225.805 c0.491-0.397,0.882-0.926,1.167-1.5"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M172.717,221.972 c0.056,0,0.111,0,0.167,0"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M171.717,229.805 c0.334,0.075,0.659,0.025,0.834-0.167"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M190.051,227.805 c0.163-0.242,0.398-0.423,0.666-0.5"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M197.384,221.472 c0.258-0.007,0.485-0.125,0.667-0.333"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M199.384,214.972 c-0.04-0.333,0.075-0.609,0.333-0.833"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M117.884,257.305 c0.056,0,0.111,0,0.167,0"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M142.717,252.472 c0.358,0.069,0.71,0.016,1-0.167"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M137.884,256.472 c0.277,0,0.556,0,0.833,0"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M160.884,252.972 c0.366-0.138,0.765-0.402,1-0.667"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M171.384,250.139 c0.235-0.263,0.475-0.561,0.667-0.834"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M89.384,243.972 c0.537,0.378,1.329,0.876,1.833,1.333"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M79.05,225.472 c0.087,0.272,0.143,0.55,0.167,0.833"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M73.884,222.639 c0,0.167,0,0.333,0,0.5"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M72.55,219.805c0.466-0.325,0.875-0.797,1.167-1.333"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M71.717,211.972c0.422-0.553,0.776-1.305,1-2"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M78.55,214.472c0-0.111,0-0.222,0-0.333"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M79.384,218.805c-0.001-0.137,0.055-0.248,0.167-0.333"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M80.217,221.139c0.111,0,0.222,0,0.333,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M75.55,226.472c0.103-0.5,0.156-0.977,0.167-1.5"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M78.55,230.139c0.111,0,0.222,0,0.333,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M83.384,227.639c0.118-0.059,0.215-0.107,0.333-0.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M81.55,237.139c0.056,0,0.111,0,0.167,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M86.217,233.805c0.056,0,0.111,0,0.167,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M87.884,230.472c0.595-0.181,1.219-0.527,1.833-0.667"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M88.717,222.139 c-0.929,2.359-1.615,4.865-2.667,7.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M89.05,216.139 c0.784-0.736,1.709-1.565,2.833-1.5"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M94.217,210.139 c1.599-0.089,3.199-0.167,4.833-0.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M94.884,224.639 c0.052-0.588-0.004-1.155-0.167-1.667"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M92.384,228.305 c0.585-0.062,1.244-0.132,1.667-0.333"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M88.717,240.139 c0.111,0,0.222,0,0.333,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M95.884,243.305 c0.526,0.1,1.017-0.015,1.333-0.333"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M98.55,248.305 c0.069-0.24,0.265-0.926,0.333-1.166"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M96.55,249.805 c0.125,0.014,0.18-0.042,0.167-0.166"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M104.55,250.139 c0.01-0.238,0.126-0.428,0.333-0.5"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M106.884,251.972 c0.195,0.045,0.37-0.013,0.5-0.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M113.884,254.805 c0.758-0.586,1.595-1.171,2.382-1.774c0.072,0.376,0.418,0.685,0.48,1.079c0.833,0.265,1.624-0.021,1.638-0.971"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M122.217,254.639 c0.063-0.165,0.179-0.288,0.333-0.334"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M125.884,255.805 c1.13-0.745,2.783-0.962,3.667-2"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M132.217,255.972 c0.638-0.492,1.104-1.173,1.141-1.975c-1.11,0.062-1.449-0.888-1.475-1.858"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M129.717,249.305 c-0.045,0.154-0.168,0.271-0.333,0.334"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M136.551,252.305 c0.222,0,0.444,0,0.666,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M110.217,251.305 c0.056-0.056,0.111-0.11,0.167-0.166"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M140.717,251.805 c0.111,0,0.223,0,0.334,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M150.051,249.472 c0.111,0,0.222,0,0.333,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M143.217,255.472 c1.022-0.313,1.724-1.175,2.646-1.654c0.203,0.321,0.44,0.626,0.521,0.987"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M152.217,253.472 c0.165-0.063,0.288-0.179,0.334-0.333"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M155.051,254.639 c0.222,0,0.444,0,0.666,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M157.717,256.472 c0.326-0.027,0.546-0.073,0.834-0.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M163.217,252.639 c0.552-0.891,2.082-1.512,2.341-2.334c0.37-1.177-1.156-3.069-1.007-4.5"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M167.384,235.972 c0.118-0.54,0.353-1.064,0.667-1.5"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M170.717,242.805 c0-0.333,0-0.667,0-1"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M170.217,236.972 c0-0.333,0-0.667,0-1"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M179.051,235.805 c0.378-0.101,0.738-0.35,1-0.667"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M185.051,232.805 c0.379-0.319,0.656-0.702,0.833-1.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M188.051,231.139 c0.063-0.39,0.178-0.792,0.333-1.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M197.884,223.305 c-0.166,0.277-0.334,0.556-0.5,0.833"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
}
]
},
{
"name": "mouths",
"children": [
{
"name": "mouth1",
"children": [
{
"shape": {
"type": "path",
"path": "M177.122,216.821c-0.515,2.282-5.213,3.21-7.433,3.854 c-3.254,0.945-6.596,1.345-9.895,1.851c-3.26,0.5-6.665,0.671-10.107,0.671c-3.596,0-6.645,0.559-10.107,0.671 c-3.105,0.1-6.898-0.474-9.694-1.3c-3.527-1.043-6.672-1.666-10.096-3.062c-2.823-1.152-5.746-1.876-8.462-3.143 c-2.594-1.209-6.084-1.994-8.221-3.552c-1.068,1.834-5.867,3.748-8.1,4.546c-2.444,0.874-8.881,2.725-7.817,5.512 c0.457,1.195,1.948,2.273,2.63,3.385c0.774,1.261,1.139,2.601,2.057,3.859c1.83,2.5,4.506,4.773,6,7.34 c1.308,2.249,2.096,4.74,4.01,6.67c2.214,2.233,5.792,2.634,9.231,2.399c7.028-0.479,13.982-2.129,20.481-3.983 c3.295-0.941,6.699-1.536,10.087-2.686c3.272-1.111,6.641-3,9.402-4.777c5.248-3.377,10.278-6.409,14.283-10.705 c1.479-1.587,3.429-2.503,5.15-3.859"
},
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M135.25,241.319 c0.723-4.757-10.487-8.47-14.898-9.526c-3.09-0.74-6.68-1.17-9.858-1.712c-2.758-0.47-6.865-0.836-9.437,0.369 c-1.385,0.649-2.843,1.724-4.141,2.513c2.156,3.964,4.728,8.861,9.468,11.506c3.229,1.801,5.511,0.777,8.859,0.373 c3.045-0.369,6.046-0.703,9.029-1.72c3.479-1.186,7.228-2.385,10.978-2.475"
},
"fill": "#FFC0C0",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M148.656,225.547c1.267,0.697,1.301,2.838,0.671,3.9 c-0.702,1.182-2.063,1.4-3.306,2.01c-2.271,1.116-4.581,2.624-7.482,2.638c-4.619,0.023-2.143-4.067-0.253-5.869 c2.405-2.292,5.057-2.72,8.72-2.512c0.588,0.034,1.095,0.041,1.65,0.168"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M130.299,223.365 c2.687,0.437,5.619,4.384,3.727,6.422c-1.234,1.33-7.94,1.391-9.915,1.296c-4.896-0.233-2.502-2.445-0.613-4.525 c1.604-1.767,5.088-3.249,7.833-3.36"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M113.178,217.157 c2.56,0.958,4.922,5.057,5.352,7.215c0.377,1.885-0.324,2.106-2.526,2.643c-1.366,0.333-3.636,0.723-5.105,0.385 c-2.506-0.577-5.883-5.051-4.909-7.223c1.03-2.298,5.944-2.923,8.427-2.852"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M99.359,217.661 c2.038,0.432,4.015,4.279,2.468,5.625c-1.083,0.943-5.221,1.795-6.799,1.589c-4.032-0.526-2.265-4.102-0.866-5.872 c0.706-0.894,1.049-1.976,2.514-2.186c1.627-0.233,2.501,0.99,3.921,1.346"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M181.815,222.895c-3.101-2.75-4.764-8.777-9.282-10.403"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "mouth2",
"children": [
{
"shape": {
"type": "path",
"path": "M87.57,221.951c5.563-1.759,11.066-1.32,16.694-1.782c2.93-0.24,5.228-1.14,8.309-0.927c3.142,0.217,6.085-0.235,9.289,0.176 c7.136,0.914,13.96,0.598,21.112,1.506c3.654,0.464,7.218,0.609,10.81,0.869c4.017,0.291,7.646,1.582,11.433,2.623 c2.948,0.812,6.347,1.618,9.011,2.99c2.521,1.298,6.354,2.856,8.3,4.72c-2.775,0.027-5.601,2.603-8.021,3.769 c-2.93,1.412-5.741,2.949-8.656,4.432c-5.599,2.849-11.885,5.468-18.104,6.53c-6.793,1.161-13.195,2.107-20.067,2.197 c-7.699,0.102-14.313-4.705-20.735-8.396c-2.071-1.19-4.69-2.182-6.504-3.666c-1.792-1.466-3.469-3.386-5.154-4.984 c-2.703-2.564-7.519-5.649-8.13-9.438"
},
"stroke": {
"color": "#000000",
"width": "3",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M87.785,228.193 c-5.907-3.235-0.344-9.531,3.971-11.424"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2"
}
},
{
"shape": {
"type": "path",
"path": "M184.679,227.228c-1.534,2.583-2.548,5.334-4.025,7.889"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M106.862,219.528 c-3.071-0.74-5.608,2.166-6.318,4.738c-0.379,1.375-0.494,2.55,0.748,3.337c1.519,0.962,2.905-0.052,4.418-0.332 c2.518-0.467,7.293,0.053,6.461-4.248c-0.568-2.938-3.743-3.682-6.338-3.335c-0.451,0.06-0.758,0.212-1.205,0.229"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M119.764,218.479 c-2.648,1.243-4.657,3.518-5.346,6.377c-0.866,3.594,3.9,3.711,6.356,2.865c2.64-0.91,4.77-3.351,3.299-6.133 c-1.01-1.91-3.979-2.548-6.026-2.823"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M130.388,219.492 c-1.753,1.382-4.069,4.525-4.835,6.61c-1.159,3.156,2.296,3.371,4.868,3.348c3.061-0.028,6.6-1.148,5.022-4.78 c-1.168-2.691-2.552-4.85-5.551-5.241"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M142.954,221.087 c-1.502,0.337-5.418,3.249-5.638,4.997c-0.292,2.311,4.856,4.536,6.854,4.234c2.503-0.377,4.384-3.175,3.167-5.65 c-0.92-1.873-3.36-2.252-4.508-3.932"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M155.354,222.663 c-2.039,0.426-4.212,2.287-4.766,4.444c-0.723,2.821,3.225,3.383,5.458,3.331c2.541-0.059,5.126-1.752,3.249-4.32 c-1.394-1.908-3.707-3.189-5.304-4.636"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M168.367,237.924 c-1.554-1.217-3.302-2.557-5.203-2.976c-2.973-0.654-3.537,2.131-3.377,4.406c0.205,2.913,1.032,3.883,3.901,2.344 c1.988-1.066,4.272-1.997,4.599-4.456"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M151.524,246.202 c-1.912-0.166-4.003-4.491-2.91-6.25c0.771-1.239,5.456-1.688,6.858-1.292c0.271,0.917,0.979,1.841,0.829,2.771 c-0.088,0.54-0.994,1.645-1.296,2.188c-1.08,1.951-2.133,1.866-3.998,2.684"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M145.911,241.457 c-0.209,1.649-0.215,2.702-1.528,3.801c-0.885,0.739-1.773,1.19-2.54,2.1c-0.786,0.933-1.226,2.38-2.792,1.812 c-1.042-0.377-1.959-2.318-2.138-3.311c-0.299-1.676-1.003-5.228,0.783-6.158c1.155-0.603,7.067-0.18,7.43,1.32"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M133.12,238.991 c-1.495-0.087-2.253-1.33-3.918-0.964c-1.42,0.311-2.489,1.354-2.54,2.836c-0.052,1.527,0.99,5.581,1.852,6.956 c2.363,3.771,4.329-1.535,5.516-3.159c1.117-1.526,2.643-2.053,2.271-3.958c-0.318-1.632-1.118-2.047-2.766-2.329 c-0.382-0.065-0.773-0.095-1.158-0.147"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M116.853,237.429 c-1.049,2.211-0.173,5.147,0.047,7.566c0.357,3.929,3.827,2.028,5.831,0.067c1.575-1.541,4.599-4.86,2.209-6.484 c-1.881-1.279-5.727-2.458-7.756-1.107"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M107.455,233.38 c-0.813,2.487-1.704,5.049,0.073,7.364c1.91,2.486,4.009,1.229,5.537-0.939c1.056-1.5,3.316-4.481,1.563-6.017 c-1.347-1.179-6.468-1.518-7.854-0.325"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "mouth3",
"children": [
{
"shape": {
"type": "path",
"path": "M99.05,218.972 c1.691-0.875,3.313-2.39,4.833-3.537c1.231-0.928,2.782-1.671,3.5-3.072c1.846,3.486,7.661,4.669,11.003,6.067 c3.553,1.486,7.174,3.066,10.784,4.166c4.271,1.301,9.277,1.67,13.721,2.343c4.155,0.629,9.979,1.365,14.162,0.496 c1.181-0.245,2.343-1.024,3.462-1.446c0.162,1.905-3.637,3.023-4.933,3.487c-2.435,0.871-4.18,2.541-6.362,3.871 c-1.623,0.989-2.974,1.669-4.755,2.117c-1.77,0.445-3.353,0.806-4.825,1.878c-5.915,4.311-15.264,3.247-22.424,3.13 c-5.384-0.088-6.719-5.372-9.337-9c-1.437-1.991-2.843-3.854-3.796-6.138c-0.871-2.086-1.119-4.582-2.033-6.528"
},
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M107.217,227.972 c1.182-2.033,4.375-2.176,6.5-1.963c2.879,0.289,4.124,1.217,6.168,3.167c1.834,1.749,5.906,5.509,5.64,8.271 c-2.808,0.89-7.847,0.402-10.346-1.104c-1.334-0.804-1.151-2.256-2.246-3.588c-0.712-0.866-1.836-2.673-2.855-3.311 c-0.209-0.94-2.106-1.499-3.028-1.805"
},
"fill": "#F4BDBD",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
}
]
}
]
},
{
"name": "personalProps",
"children": [
{
"name": "hat",
"children": [
{
"children": [
{
"children": [
{
"shape": {
"type": "path",
"path": "M88.374,173.144c0.474-0.074,16.606,2.725,18.01,5.879 c1.145,2.572,28.184,4.568,28.184,4.568l35.971-5.618l5.025,1.132l7.211,0.315l9.295,0.851l10.188,3.248l5.75,2.935 l1.615-1.832l-0.264-5.27l-3.967-7.087c0,0-22.045-13.031-23.273-13.703c-1.229-0.669-4.941-2.294-6.484-4.542 c-8.584-12.528-8.404-18.05-3.371-6.461c0,0,2.662-7.592,2.52-8.575c-0.143-0.982,0.355-5.031,0.355-5.031l2.396-6.832 c0,0-1.379-5.341-2.738-7.19c-1.357-1.844-15.793-4.078-18.162-4.011c-24.933,0.706-3.783,0.071-25.567,0.724 c-24.317,0.728-0.882-2.591-24.068,3.551c-24.228,6.418-5.35-1.298-23.187,6.142c-18.301,7.633-16.67,7.186-16.704,10.685 c-0.034,3.499-3.057-4.884-0.034,3.499c3.023,8.381,3.037-3.871,3.023,8.381c-0.015,12.252,6.696,4.557,1.678,12.373 c-5.017,7.813-3.831,7.91-0.179,8.543c17.017,2.953,4.157,4.378,17.427,3.175"
},
"fill": "#FF0000",
"stroke": {
}
},
{
"shape": {
"type": "path",
"path": "M156.605,114.92l-13.936,0.381l-11.633,0.343c-10.646,0.319-11.973-0.155-12.021-0.175l-0.599-0.238 l-0.577,0.514l0.049-0.047c-0.118,0.09-1.43,0.957-11.145,3.53c-9.989,2.646-12.812,2.931-13.421,2.704 c-0.822-0.306-0.821-0.306-7.791,2.604l-2.104,0.878c-16.037,6.689-17.342,7.324-17.342,10.316c0,0.019,0.001,0.041,0.001,0.06 c-0.224-0.108-0.459-0.199-0.787-0.04c-0.357,0.173-0.565,0.275-0.565,0.672c0,0.557,0.411,1.697,1.399,4.438 c0.924,2.561,1.71,3.671,2.714,3.833c0.083,0.014,0.164,0.02,0.241,0.02c0.007,0.584,0.01,1.339,0.01,2.313 c0,0.561-0.001,1.902-0.001,1.916c0,6.908,2.176,8.105,3.347,8.749c0,0,0.075,0.045,0.151,0.09 c-0.095,0.332-0.47,1.1-1.661,2.955c-2.509,3.908-3.516,5.931-3.516,7.303c0,0.358,0.068,0.671,0.196,0.962 c0.544,1.237,1.926,1.477,3.677,1.78l0.135,0.023c8.138,1.412,9.14,2.422,9.568,2.854c0.923,0.931,1.511,0.928,7.224,0.413 c0.06,0.014,0.102,0.068,0.165,0.071c2.167,0.105,16.131,3.138,17.087,5.288c1.147,2.578,16.416,4.228,29.023,5.159 l0.115,0.009c0,0,35.523-5.548,35.896-5.606c0.345,0.078,4.927,1.11,4.927,1.11l7.3,0.319c0,0,8.927,0.818,9.139,0.837 c0.202,0.064,9.854,3.142,10.006,3.19c0.143,0.073,6.368,3.251,6.368,3.251l2.398-2.719l-0.296-5.911l-4.213-7.526 l-0.232-0.137c-0.9-0.532-22.073-13.047-23.303-13.72c-0.001,0-0.735-0.38-0.735-0.38c-1.48-0.752-4.238-2.151-5.404-3.85 c-1.357-1.982-2.451-3.729-3.355-5.268c0.022-0.064,0.104-0.296,0.104-0.296c1.193-3.402,2.576-7.619,2.576-8.885 c0-0.063-0.004-0.118-0.011-0.165c-0.012-0.083-0.017-0.204-0.017-0.356c0-0.909,0.194-2.911,0.363-4.307 c0.072-0.205,2.46-7.013,2.46-7.013l-0.076-0.294c-0.146-0.566-1.468-5.584-2.9-7.532 C173.721,116.784,158.242,114.874,156.605,114.92z M131.097,117.643l11.614-0.342l13.951-0.382 c2.575-0.073,16.104,2.238,17.336,3.614c0.956,1.3,2.058,4.938,2.49,6.549c-0.188,0.536-2.33,6.642-2.33,6.642l-0.013,0.107 c-0.073,0.592-0.387,3.224-0.387,4.658c0,0.258,0.011,0.477,0.034,0.639c-0.006,0.493-0.768,3.026-1.659,5.709 c-2.14-4.566-2.792-4.606-3.242-4.629l-0.62-0.031l-0.354,0.571c-0.069,0.124-0.102,0.29-0.102,0.492 c0,2.273,4.134,9.172,6.993,13.346c1.456,2.12,4.509,3.669,6.149,4.501l0.682,0.353c1.138,0.622,20.813,12.25,23.011,13.549 c0.239,0.427,3.513,6.275,3.721,6.647c0.02,0.393,0.199,3.971,0.231,4.629c-0.23,0.262-0.472,0.535-0.832,0.944 c-1.07-0.546-5.132-2.619-5.132-2.619l-10.369-3.306l-9.404-0.86c0,0-6.995-0.307-7.169-0.315 c-0.168-0.038-5.124-1.155-5.124-1.155s-35.814,5.594-36.044,5.63c-12.419-0.922-25.993-2.687-27.285-4.058 c-1.366-3.097-13.245-5.574-17.517-6.211c-0.203-0.212-0.479-0.346-0.793-0.318c-3.083,0.28-5.996,0.544-6.4,0.369 c0-0.003-0.12-0.117-0.12-0.117c-0.703-0.708-1.879-1.895-10.646-3.416l-0.135-0.023c-0.827-0.143-2.075-0.359-2.188-0.614 c-0.021-0.048-0.033-0.111-0.033-0.193c0-0.592,0.632-2.179,3.205-6.187c1.488-2.318,2.024-3.388,2.024-4.188 c0-0.15-0.019-0.291-0.054-0.428c-0.181-0.712-0.758-1.03-1.179-1.261c-0.865-0.476-2.311-1.271-2.311-6.993 c0-0.014,0.001-1.098,0.001-1.56c0-4.969-0.065-4.992-0.833-5.258c-0.424-0.146-0.816,0.001-1.178,0.377 c-0.208-0.289-0.558-0.898-1.073-2.324c-0.205-0.568-0.385-1.068-0.542-1.506c0.587-0.423,0.632-1.277,0.636-1.644 l-0.014-0.825c-0.004-0.119-0.007-0.231-0.007-0.338c0-1.702,0.899-2.264,16.109-8.608l2.105-0.878 c4.165-1.739,5.948-2.482,6.375-2.562c0.817,0.296,2.292,0.597,14.579-2.658c8.169-2.164,10.697-3.187,11.58-3.704 C120.451,117.773,124.529,117.84,131.097,117.643z"
},
"stroke": {
}
}
]
},
{
"children": [
{
"shape": {
"type": "path",
"path": "M155.146,147.929c4.879-9.398-5.344-20.199-12.65-21.176 c-12.05-1.61-13.404,10.426-13.684,21.258c3.73,2.016,8.915,3.425,11.721,6.534"
},
"fill": "#FFFFFF",
"stroke": {
}
},
{
"shape": {
"type": "path",
"path": "M133.446,127.979c-4.599,3.921-5.426,11.933-5.635,20.006l-0.017,0.654l4.415,2.067 c2.849,1.244,5.793,2.529,7.581,4.509c0.371,0.41,1.004,0.442,1.412,0.072c0.219-0.197,0.33-0.469,0.33-0.743 c0-0.239-0.084-0.479-0.258-0.67c-2.076-2.299-5.222-3.673-8.266-5.001c0,0-2.377-1.112-3.174-1.486 c0.223-7.385,1.021-14.572,4.909-17.887c1.892-1.614,4.386-2.189,7.621-1.757c4.143,0.554,9.086,4.472,11.5,9.113 c1.348,2.591,2.51,6.535,0.395,10.611c-0.254,0.49-0.064,1.093,0.426,1.348c0.49,0.254,1.094,0.063,1.35-0.427 c1.959-3.775,1.818-8.199-0.395-12.456c-2.732-5.251-8.203-9.53-13.012-10.172C138.853,125.257,135.763,126,133.446,127.979z"
},
"stroke": {
}
}
]
},
{
"children": [
{
"shape": {
"type": "path",
"path": "M154.077,146.278c-2.156,1.18-4.24,2.619-6.256,4.01c-3.635,2.509-7.068,4.878-10.941,5.924 c-2.991,0.808-6.055,1.058-9.3,1.324c-3.222,0.263-6.553,0.536-9.783,1.406c-2.027,0.546-4.117,1.397-6.137,2.221 c-3.491,1.423-7.102,2.895-10.528,2.866c-0.552-0.005-1.004,0.439-1.009,0.991s0.439,1.004,0.991,1.009 c3.828,0.033,7.627-1.516,11.301-3.014c2.054-0.837,3.994-1.628,5.902-2.142c3.054-0.823,6.292-1.088,9.425-1.344 c3.191-0.261,6.492-0.531,9.659-1.386c4.205-1.135,7.941-3.714,11.557-6.208c1.973-1.362,4.014-2.771,6.08-3.901 c0.484-0.265,0.662-0.873,0.396-1.357S154.562,146.013,154.077,146.278z"
},
"stroke": {
}
}
]
},
{
"children": [
{
"shape": {
"type": "path",
"path": "M156.458,153.549c-2.619,0.064-5.709,0.812-8.98,1.604c-4.279,1.035-8.701,2.104-11.902,1.536 c-0.543-0.096-1.063,0.267-1.159,0.81c-0.097,0.544,0.267,1.063,0.81,1.16c3.613,0.641,8.24-0.481,12.72-1.562 c3.166-0.766,6.154-1.489,8.561-1.548c5.664-0.141,7.961,0.698,13.508,2.724c0.518,0.189,1.094-0.077,1.281-0.596 c0.189-0.519-0.076-1.091-0.596-1.282C165.069,154.337,162.501,153.399,156.458,153.549z"
},
"stroke": {
}
}
]
}
]
}
]
},
{
"name": "textSurface",
"children": [
{
"name": "spokenBubble",
"children": [
{
"name": "textContainer",
"shape": {
"type": "path",
"path": "M225.719,45.306c0-6.627,5.373-12,12-12h181.333 c6.627,0,12,5.373,12,12V150.64c0,6.627-5.373,12-12,12H237.719c-6.627,0-12-5.373-12-12V45.306z"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"name": "textArrowBelow",
"shape": {
"type": "path",
"path": "M249.052,160.639 c-0.775,14.251-1.676,18.525-9.1,30.565c9.705-0.79,21.952-21.605,25.1-30.045"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "thoughtBubble",
"children": [
{
"name": "textContainer_1_",
"shape": {
"type": "path",
"path": "M202.698,21.089 c19.686-26.45,59.686-24.45,79.747-0.084c2.697,1.349,5.571,1.709,7.472,0.781c15.28-13.888,33.272-14.043,49.893-7.839 c2.771,1.034,5.478,2.219,8.031,3.421c28.543-21.729,75.543-10.729,83.166,27.658c0,0-1.324,3.889,1.165,6.603 c18.212,11.011,26.212,32.011,22.212,53.011c-1,5.333-3.223,9.667-6.037,13.52c-2.814,3.854-1.381,0-2.613-0.591 c-1.35-0.929-3.35-0.929-4.35-1.929c16,7,27,22,30,39c2,21-8,41-27,50c-16,7.5-32.5,5.5-45.745-2.556 c-2.532-1.384-4.229-1.856-5.336-1.551c-1.919,0.107-3.919,2.107-5.919,2.107c4-1,6-5,10-6c-15,11-35,12-52,3c-13-7-20-20-24-34 c1,5,3,9,3.299,13.505c-0.397,0.708-3.423,2.219-6.655,3.466c-22.627,8.729-49.423,1.729-65.241-19.971 c-3.453,0-6.263,0.589-8.723,0.879c-17.3,3.2-32.381-7.709-40.771-22.689c-1.678-2.996-3.089-6.153-4.195-9.396 c-15.714-7.795-29.714-18.795-33.714-37.795c-5-25,11-45,29.842-57.667c0.719-2.335,1.697-4.636,3.006-6.896 C201.159,23.306,202.698,21.089,202.698,21.089z"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"children": [
{
"shape": {
"type": "path",
"path": "M269.719,186.306c0,4.602-4.179,8.333-9.333,8.333c-5.155,0-9.334-3.731-9.334-8.333 c0-4.603,4.179-8.333,9.334-8.333C265.54,177.973,269.719,181.704,269.719,186.306z"
},
"fill": "#FFFFFF",
"stroke": {
}
},
{
"children": [
{
"shape": {
"type": "path",
"path": "M269.719,186.306c0,4.602-4.179,8.333-9.333,8.333c-5.155,0-9.334-3.731-9.334-8.333 c0-4.603,4.179-8.333,9.334-8.333C265.54,177.973,269.719,181.704,269.719,186.306z"
},
"fill": "none",
"stroke": {
}
},
{
"shape": {
"type": "path",
"path": "M268.225,186.165c-0.564,8.736-13.982,9.286-15.633,0.853 c-1.785-9.125,15.017-10.254,15.649-0.451c0.125,1.929,3.078,1.388,2.955-0.521c-0.814-12.597-20.828-12.412-21.639,0.119 c-0.827,12.813,20.831,13.028,21.655,0.283C271.337,184.518,268.35,184.235,268.225,186.165z"
},
"fill": "#FFFFFF",
"stroke": {
}
}
]
}
]
},
{
"shape": {
"type": "path",
"path": "M260.386,188.306c0,3.498-2.985,6.333-6.667,6.333 s-6.667-2.835-6.667-6.333c0-3.498,2.985-6.333,6.667-6.333S260.386,184.808,260.386,188.306z"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M238.386,196.973c0,1.289-1.045,2.333-2.334,2.333 c-1.288,0-2.333-1.045-2.333-2.333s1.045-2.333,2.333-2.333C237.341,194.639,238.386,195.684,238.386,196.973z"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M285.719,179.973c0,4.602-4.253,8.333-9.5,8.333 s-9.5-3.731-9.5-8.333c0-4.603,4.253-8.333,9.5-8.333S285.719,175.371,285.719,179.973z"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "yellBubble",
"children": [
{
"shape": {
"type": "path",
"path": "M251.156,176.051 l40.228-15.992"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M280.932,149.385 l-40.667,36.42"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "textContainer_2_",
"shape": {
"type": "path",
"path": "M217.778,34.643 c8.609,6.684,9.952,3.684,7.987-5.785c6.308,5.125,9.308,3.782,10.188-4.309c2.433,8.091,5.266,8.091,9.12-1.703 c6.063,9.793,13.146,9.793,24.043,3.878c6.103,5.915,16.02,5.915,20.094-4.64c17.178,10.555,28.511,10.555,45.233-5.505 c5.941,16.06,17.273,16.06,18.835,1.458c19.688,14.603,29.605,14.603,46.749-17.802c-0.144,32.405,6.939,32.405,29.26,16.182 c-12.403,16.223-9.57,16.223,4.813,6.576c-11.07,9.646-8.07,10.99,4.333,9.089c-8.061,6.244-6.717,9.244,2.533,11.068 c-9.25,1.489-9.25,5.703-0.315,13.07c-8.935,6.115-8.935,15.385,7.513,10.932c-16.447,24.677-16.447,35.631,14.938,36.553 c-31.385,19.303-31.385,28.571-4.39,40.526c-26.995,1.528-26.995,5.741-5.942,17.857c-21.053-8.801-22.396-5.802-9.526,11.916 c-17.213-13.374-20.213-12.03-12.048,8.029c-11.479-20.06-14.312-20.06-10.553,3.532c-13.676-23.591-20.759-23.591-29.814-2.664 c-7.944-20.927-17.861-20.927-27.072,12.467c-12.039-33.395-23.373-33.395-23.148-1.581 c-22.89-31.814-34.224-31.814-61.517-8.479c6.042-23.335-3.874-23.335-11.9-9.703c-8.975-13.632-16.058-13.632-23.926,4.361 c-2.049-17.993-4.882-17.993-10.51-1.486c2.314-16.508-0.686-17.851-12.385-5.019c7.356-17.175,6.013-20.176-10.27-7.879 c16.283-15.61,16.283-19.824-9.255-12.972c25.538-20.334,25.538-29.603,1.919-46.578c23.619-3.249,23.619-14.204-0.313-25.522 c23.933-8.905,23.933-18.175,7.798-37.429C226.385,48.854,226.385,44.64,217.778,34.643z"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
}
]
}
]
}
]
}
]
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-torso.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-torso.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-left-arm.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-left-arm.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/Nils.json
New file
0,0 → 1,717
[
{
"name": "nils_1_",
"children": [
{
"name": "lowerBody",
"children": [
{
"name": "leftShoe",
"children": [
{
"shape": {
"type": "path",
"path": "M44.787,442.042c13.536-0.097,28.515-2.647,40.667-8.815 c13.064-6.631,3.188-24.604,0.553-34.404c-5.771-1.73-10.549-4.837-16.568-0.148c-4.371,3.405-6.025,11.462-2.07,15.501 c-3.212,7.339-17.804,1.912-23.732,6.7c-5.825,4.706-7.32,17.966,0.484,21.167"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M133.453,425.375c0.901-2.979,2.793-5.781,4.667-8"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M56.787,426.708c-2.551-2.07-3.97-5.252-5.333-8"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "rightShoe",
"children": [
{
"shape": {
"type": "path",
"path": "M111.453,402.042c-2.005-0.426-3.947-0.363-5.899-0.566 c-0.104,2.376,0.438,5.478,0.048,7.751c-0.4,2.327-1.597,4.06-2.146,6.817c-0.975,4.9,0.412,10.561,3.813,13.517 c3.718,3.23,8.442,2.56,12.87,3.797c4.256,1.189,7.959,3.502,12.5,4.849c9.169,2.717,20.433,7.657,25.649-4.685 c2.797-6.618-0.894-5.624-6.331-7.982c-4.049-1.757-6.774-4.353-10.32-7.014c-4.123-3.095-8.203-5.957-13.415-6.584 c-0.11-3.353,1.616-5.692,1.132-9.117c-5.299-2.318-13.883-3.984-19.233-0.116"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M62.787,424.708c-1.417-2.271-3.012-5.388-2.667-8.666"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M141.453,428.042c2.076-1.991,4.274-3.745,6-6"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "leftLeft",
"shape": {
"type": "path",
"path": "M111.687,360.891c0.036,4.747,1.844,9.223,1.56,14.078 c-0.24,4.099-1.372,8.075-1.553,12.199c-0.2,4.558-1.141,9.069-1.142,13.648c0,3.48-0.275,5.533,3.084,7.379 c2.301,1.264,4.909,1.163,7.094-0.113c2.993-1.748,2.841-3.747,2.868-6.904c0.025-2.952,0.712-5.943,1.162-8.841 c0.446-2.868,0.401-5.667,0.398-8.578c-0.004-3.788,0.138-7.556,0.003-11.357c-0.118-3.318-1.49-6.782-1.279-10.093"
},
"fill": "#FFF0A9",
"stroke": {
"color": "#000000"
}
},
{
"name": "rightLeg",
"shape": {
"type": "path",
"path": "M74.107,353.8c-0.57,1.485-0.055,3.729-0.142,5.357 c-0.076,1.44-0.315,2.774-0.571,4.184c-0.786,4.316-1,8.786-1.732,13.181c-1.158,6.942-0.906,14.193-1.777,21.167 c-0.456,3.648,0.862,8.169,5.499,7.139c2.579-0.572,4.859-3.016,5.846-5.361c2.937-6.981-0.974-13.832-0.457-21.057 c0.331-4.619,2.141-8.637,3.402-13.056c0.769-2.694,1.709-5.131,1.703-7.972c-0.004-1.809,0-3.616,0-5.425"
},
"fill": "#FFF0A9",
"stroke": {
"color": "#000000"
}
},
{
"name": "pants",
"children": [
{
"name": "pants_1_",
"shape": {
"type": "path",
"path": "M72.453,299.375 c1.947,19.47-1.848,38.143-0.849,57.849c3.905,0.681,11.166,0.417,14.849-0.849c7.135-2.453,6.497-2.631,7-11 c0.81-13.479-2.849-20.278,12.845-17.853c-1.125,13.305-9.43,25.115-3.42,38.649c8.404-0.38,20.265,0.661,28.427-1.944 c0.505-10.198-1.523-17.622-2.853-26.853c-1.398-9.708,3.313-18.866-1.174-27.826c-9.218,0.693-18.358,2.747-27.722,0.798 c-9.863-2.054-18.89-8.623-29.104-8.972"
},
"fill": "#ADA274",
"stroke": {
"color": "#000000"
}
}
]
}
]
},
{
"name": "leftArm_1_",
"children": [
{
"name": "leftArm",
"shape": {
"type": "path",
"path": "M161.453,199.375c-6.73,0.606-12.711,7.192-9.248,13.248 c3.358,5.87,13.618,5.538,19.021,6.979c4,1.066,16.837,3.192,19.52,5.703c3.974,3.72,5.243,15.844,5.854,20.924 c13.641,4.354,26.949-0.671,33.102-13.826c5.331-11.398-5.783-19.505-17.098-22.174c1.771-8.465,14.167-32.061-0.128-36.899 c-4.761-1.611-15.726,3.346-17.801,7.272c-3.095,5.855-0.055,15.902-0.374,22.623c-13.399,0.68-27.351-3.555-39.849-1.849"
},
"fill": "#FFF0A9",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M221.453,220.375c-4.604-1.889-17.369-6.456-21.801-1.801 c-4.797,5.039,1.256,14.077,6.027,16.578c4.118,2.159,20.628,4.348,24.575,1c4.999-4.241,2.906-14.993-2.801-17.777"
},
"fill": "#FFF0A9",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M214.453,253.375c-1.006,3.482-0.767,9-3.174,12.826 c-15.878,0.834-16.244-5.43-25.674-14.571c10.53-5.253,19.583,4.754,29.849,2.745"
},
"fill": "#FFF0A9",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M226.453,239.375c0.54,16.962-8.377,15.391-21.023,12.023 c-17.34-4.617-11.577-7.176,3.023-13.023"
},
"fill": "#FFF0A9",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M208.453,188.375c-4.474,0.83-8.972-0.434-11-4"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M203.453,221.375c6.112-0.45,18.967,6.649,8,10"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M195.453,258.375c3.441-0.666,5.408-2.2,4-5"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "rightArm",
"children": [
{
"shape": {
"type": "path",
"path": "M39.453,187.375c-3.104,7.216-3.137,14.998-7.278,21.997 c-5.137,8.684-9.794,6.9-17.5,12.281c-8.803,6.146-12.141,29.697-14.095,40.548c20.2,3.536,18.779-23.776,21.649-34.524 c0.975,13.012-0.289,26.468,0.374,39.546c2.257,0.582,6.44,0.582,8.697,0c2.04-10.494-3.53-22.034-0.852-33.546 c0.009,7.58-2.598,32.2,10.852,28.546c0.514-10.124-1.899-18.938-4.868-25.972c2.181,8.766,4.798,18.48,15.845,15.949 c6.407-12.781-3.909-15.105-8.048-25.604c-2.531-6.422,0.527-25.44,6.223-31.223"
},
"fill": "#FFF0A9",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M6.453,248.042c2.111,0,6.324-0.997,6.667,1.666"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M22.453,255.375c2.85-0.37,4.155,0.539,4.999,3.001 c1.085,3.168-0.233,4.173-2.999,5.332"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M31.787,255.042c3.675-0.503,7.077,4.971,3,6"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M48.453,235.708c-5.387-0.935-3.676,10.551,3.667,8.667"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M207.453,241.375c2.63,1.686,2.368,4.909,1.884,7.884 c-0.744,0.175-1.23,0.456-1.884,0.783"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "shirt",
"children": [
{
"name": "mainShirt",
"shape": {
"type": "path",
"path": "M39.453,189.375 c0.777-3.467,1.211-7.217,1.151-10.849c14.871-1.403,32.372-7.656,46.875-11.125c9.423-2.254,31.959-20.14,39.244-11.079 c3.778,4.7,2.066,16.102,5.456,22.08c2.827,4.986,9.093,12.445,13.003,16.217c5.193,5.009,15.695-3.271,18.271,2.754 c3.024,7.075-0.511,20.739-10.02,18.016c-5.084-1.456-12.238-5.093-15.228-9.769c-4.055-6.341-8.831-13.012-10.53-19.167 c-0.713,10.697,1.173,22.369,2.726,32.92c1.637,11.128,1.886,22.261,3.052,34c2.02,20.336,6.915,42.053,10.845,61.855 c-14.599,4.091-47.868-3.832-47.868-3.832s-14.457-3.595-21.2-5.801c-8.131-2.661-21.777-11.223-13.777-11.223 s-3.063-9.756,2.468-40.878s14.003-39.61,19.806-56.122c1.387-3.946,2.399-8.004,4.375-11.845 c-17.565,1.273-26.117,7.964-40.475,16.742c-2.413-9.11-9.707-14.336-17.174-18.897"
},
"fill": "#4867FF",
"stroke": {
"color": "#000000",
"width": "2"
}
},
{
"name": "highlight",
"shape": {
"type": "path",
"path": "M99.453,179.375 c-5.364,2.937-10.603,8.065-17,8"
},
"fill": "#4867FF",
"stroke": {
"color": "#000000",
"width": "2"
}
},
{
"name": "logo",
"children": [
]
}
]
},
{
"name": "heads",
"children": [
{
"name": "head1",
"children": [
{
"name": "hair_1_",
"shape": {
"type": "path",
"path": "M60.453,97.375c-3.965-0.012-7.98,0.045-11.897-0.147 c2.645-5.735,10.791-8.417,14.794-13.65c-2.384,0.19-5.083-0.61-7.543-0.154c2.395-1.359,4.008-3.487,6.347-4.846 c-2.993-0.207-6.326-0.467-9.399-0.18c2.893-0.874,5.243-2.063,7.821-3.05c-0.92-0.166-4.625-2.732-6.772-4.221 c5.187-4.255,12.317-5.834,17.573-8.534c-2.844-0.13-5.037-1.713-7.75-2.393c-0.424-7.244-1.302-14.461-1.223-21.475 c2.166,2.761,3.541,5.976,4.849,8.546c-0.996-11.489,4.773-13.594,13.025-18.797c0.403,1.91,1.943,3.845,2.229,5.546 c1.27-13.312,22.924-28.644,34.016-33.272c0.039,6.247-2.955,11.957-5.365,17.475c-0.365,0.375-0.375,0.366-0.028-0.028 c5.849-6.92,14-8.882,22.143-10.721c-1.215,5.635-5.28,10.684-6.698,16.602c6.258-10.069,20.421-4.135,27.949-11.351 c-1.011,3.251-2.028,6.254-3.143,9.276c7.035-8.774,15.902-11.37,25.894-14.499c-0.668,7.995-10.243,18.061-0.822,20.872 c8.889,2.653,17.435-7.31,26.698-6.075c-2.976,1.954-5.822,4.12-8.614,6.345c7.596,2.01,18.243,0.852,26.614,0.658 c-4.125,3.304-9.116,7.352-9.593,12.943c3.896-0.826,8.6-1.318,12.741-0.725c-1.013,1.726-1.479,5.845-2.718,7.678 c3.136-0.265,6.17,1.053,8.519,1.452c-3.019,0.804-5.247,3.16-7.566,4.52c3.765,0.755,7.282,2.001,10.844,3.398 c-3.322,1.78-5.724,5.475-4.776,9.657c0.798,0.374,2.536,0.977,2.995,1.147c-6.481,3.645-21.331-1.522-28.945-2.752 c-13.967-2.257-27.844-4.641-41.913-6.244c-17.039-1.941-37.716-3.446-54.359,1.025C83.983,67.42,68.871,76.651,58.453,98.375"
},
"fill": "#605542",
"stroke": {
"color": "#000000"
}
},
{
"name": "neck",
"shape": {
"type": "path",
"path": "M108.453,132.375c0.902,8.412-0.835,20.235-3.849,27.797 c4.164,2.769,15.721,4.339,19.868,0c3.538-3.701,1.964-17.522,1.98-22.797"
},
"fill": "#FFF0A9",
"stroke": {
"color": "#000000"
}
},
{
"name": "leftEar_1_",
"children": [
{
"name": "leftEar",
"shape": {
"type": "path",
"path": "M232.453,76.375c10.186-6.915,21.465,6.994,19.052,17 c-2.781,11.53-20.253,15.518-27.052,5"
},
"fill": "#FFF0A9",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M245.453,91.375c-0.398-2.267-1.99-4.77-3.171-6.829 c-2.738-0.936-5.713-1.545-8.829-1.171"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M238.453,90.375c1.863-0.367,3.589-1.433,5-3"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "headShape",
"shape": {
"type": "path",
"path": "M116.453,35.375 c-13.417,2.219-31.83,24.639-39.777,35.055c-8.128,10.652-24.737,25.747-20.219,39.945 c5.161,16.221,22.089,14.526,34.025,19.972c15.448,7.047,30.645,11.875,46.749,14.251c18.146,2.676,27.633,0.161,44.223-7.972 c15.701-7.697,29.862-9.589,41.801-24.303c8.182-10.084,15.033-28.733,8.174-38.923c-6.159-9.151-21.79-19.289-31.201-25.75 c-12.144-8.339-26.876-10.032-41-11.274c-15.007-1.32-33.207-3.056-47.774,1"
},
"fill": "#FFF0A9",
"stroke": {
"color": "#000000"
}
},
{
"name": "rightEar_1_",
"children": [
{
"name": "rightEar",
"shape": {
"type": "path",
"path": "M66.453,94.375 c-10.188-4.124-23.701-5.729-27.774,7.226c-4.779,15.198,14.506,23.077,25.774,15.774"
},
"fill": "#FFF0A9",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M42.453,106.375c4.149-4.954,11.06-7.737,16-10"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M48.453,100.375c1.337,3.541,2.787,6.955,5,10"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "adamsApple",
"shape": {
"type": "path",
"path": "M113.453,152.375c-0.526-2.327,1.546-3.837,5-4"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
}
]
}
]
},
{
"name": "expressions",
"children": [
{
"name": "confused",
"children": [
{
"name": "mouth_1_",
"children": [
{
"name": "mouth",
"shape": {
"type": "path",
"path": "M102.148,120.014c13.398-6.9,33.568-7.688,49-10.026 c12.555-1.903,36.519-2.575,44,9.026"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"name": "tooth_1_",
"shape": {
"type": "path",
"path": "M178.148,109.014 c-0.563-2.655-0.017-6.196,0.151-8.849c4.788-0.944,9.637,0.768,13.675,3.022c0.664,3.187,0.065,6.267-1.826,8.826"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"name": "tooth",
"shape": {
"type": "path",
"path": "M168.148,108.014c-2.021-7.958,5.04-7.752,10.826-6.826 c1.286,2.446,1.752,5.863,1.022,8.675c-3.801,0.292-8.049,0.308-10.849-0.849"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "eyes",
"children": [
{
"name": "rightEye",
"shape": {
"type": "path",
"path": "M121.148,52.014 c-6.562,8.145-20.057,16.28-21.023,26.977c-1.104,12.227,10.759,15.164,21.02,11.798c18.8-6.168,24.482-40.499,0.004-39.774"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"name": "pupilRight",
"shape": {
"type": "path",
"path": "M112.148,61.014c-7.625,3.067-4.047,12.428,3.826,10.826 C118.354,67.432,118.046,61.261,112.148,61.014"
},
"stroke": {
"color": "#000000"
}
},
{
"name": "leftEye",
"shape": {
"type": "path",
"path": "M184.148,55.014c-13.391-8.758-17.664,28.504,5,25.996 c10.862-1.201,14.124-12.581,8.004-19.996c-6.121-7.415-14.988-4.947-22.004-8"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"name": "pupilLeft",
"shape": {
"type": "path",
"path": "M176.148,54.014c-2.04,2.896-2.657,6.347-1.849,9.849 C184.707,66.621,182.108,56.322,176.148,54.014"
},
"stroke": {
"color": "#000000"
}
}
]
}
]
},
{
"name": "confused2",
"children": [
{
"name": "rightEye_1_",
"shape": {
"type": "path",
"path": "M121.148,52.014 c-6.562,8.145-20.057,16.28-21.023,26.977c-1.104,12.227,10.759,15.164,21.02,11.798c18.8-6.168,24.482-40.499,0.004-39.774"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"name": "pupilRight_1_",
"shape": {
"type": "path",
"path": "M112.148,61.014 c-7.625,3.067-4.047,12.428,3.826,10.826C118.354,67.432,118.046,61.261,112.148,61.014"
},
"stroke": {
"color": "#000000"
}
},
{
"name": "leftEye_1_",
"shape": {
"type": "path",
"path": "M184.148,55.014 c-13.391-8.758-17.664,28.504,5,25.996c10.862-1.201,14.124-12.581,8.004-19.996c-6.121-7.415-14.988-4.947-22.004-8"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"name": "pupilLeft_1_",
"shape": {
"type": "path",
"path": "M176.148,54.014 c-2.04,2.896-2.657,6.347-1.849,9.849C184.707,66.621,182.108,56.322,176.148,54.014"
},
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M114.934,118.74 c18.933-4.896,31.704-2.456,49.826,1.171c6.734,1.348,17.654,7.566,23.408,0.323c5.436-6.841-0.011-16.179-7.237-17.994"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "talking",
"children": [
{
"shape": {
"type": "path",
"path": "M150.536,116.479c0.413,18.115,48.746,18.222,37.276-7.278 c-10.396-1.757-28.836,2.451-38.776,5.778"
},
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M103.453,104.875c-2.277,2.169-1.729,7.324-4.849,8 c8.889,3.074,18.975,7.877,28.849,6.998c6.759-0.602,18.439-1.511,23.5-5.998"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M104.453,64.875 c-6.218-0.224-17.093,9.247-13.875,15.887c2.822,5.825,15.087,4.174,20.375,3.113c4.505-0.904,7.783-1.37,9.889-6.123 c1.107-2.499,2.855-9.088,1.623-11.889c-2.859-6.496-15.374-3.248-19.512,0.012"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M176.953,59.875 c-4.742,8.403,0.46,13.596,6.486,18.376c4.779,3.791,15.903,8.529,19.512,0.622c8.012-17.554-22.026-19.554-32.498-17.887 c-0.345,0.055-1.151,0.291-1.5,0.389"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M98.953,66.875c-6.969-2.545-10.165,5.418-3.002,8.05 c2.178-2.129,5.596-6.88,2.502-9.05"
},
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M178.453,60.875c-5.534,0.708-5.259,9.173,0.5,7.387 c6.145-1.906,5.217-9.047-1.5-8.387"
},
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "talking2",
"children": [
{
"shape": {
"type": "path",
"path": "M102.87,94.503c-2.279,15.037-5.934,27.828,15.027,23.027 c15.334-3.512,25.379-13.239,28.973-28.027"
},
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M92.87,104.503 c4.248-16.004,34.717-10.765,47.052-11.948c8.414-0.807,15.879-1.97,24.948-1.055c8.295,0.837,19.3,2.941,27-0.997"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M84.87,73.503c2.341-8.752,12.467-12.772,19-18"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M181.87,59.503c8.968-3.27,16.681,2.245,25,3"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M98.87,68.503 c-7.218,11.165,3.031,17.234,13.003,17.997c13.201,1.009,21.125-8.677,18.845-21.842c-11.637-0.604-21.219,1.818-31.849,2.845"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M178.87,67.503 c-9.045,2.007-6.264,11.616-1.249,15.249c3.778,2.737,13.479,4.477,18.249,2.528C210.946,79.123,185.327,71.038,178.87,67.503"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M115.87,85.503c2.365-1.63,3.646-3.553,2.826-6.826 c-16.491-8.159-17.436,11.182-1.826,8.826"
},
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M174.87,80.503c-0.492-1.165-0.677-2.687-0.872-3.826 c3.483-0.285,7.207-0.292,10.698-0.023c3.568,7.301-6.079,7.593-10.826,5.849"
},
"stroke": {
"color": "#000000"
}
}
]
}
]
}
]
}
]
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/LarsDreaming.json
New file
0,0 → 1,1823
[
{
"name": "torso",
"children": [
{
"name": "leftArm",
"shape": {
"type": "path",
"path": "M156.007,292.675c2.737,1.778,5.563,3.321,8.752,3.946c7.099,1.391,19.25-5.666,23.136-11.698 c1.572-2.441,8.077-21.031,11.178-14.271c1.224,2.67-1.59,4-1.399,6.462c3.108-1.425,5.48-5.242,8.918-2.182 c0.672,4.019-4.472,4.343-3.918,7.669c1.376,0.218,5.395-1.595,6.285-0.535c1.707,2.027-2.933,3.561-4.072,4.018 c-1.852,0.741-4.294,1.233-5.988,2.369c-2.636,1.769-4.766,5.144-7.033,7.4c-11.657,11.604-26.184,10.553-40.646,5.515 c-4.713-1.642-17.399-4.472-18.655-9.427c-1.647-6.502,5.523-7.999,10.184-6.74C147.658,286.528,151.725,289.892,156.007,292.675z"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "leftArmThumb",
"shape": {
"type": "path",
"path": "M188.257,284.902c-1.932-1.391-3.313-4.206-3.506-6.494c-0.149-1.786,0.59-6.521,3.199-3.95c0.792,0.78,0.083,2.155,0.558,2.943 c0.885,1.47,1.071,0.493,2.748,1.002c1.406,0.426,3.827,2.05,4.251,3.499"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "rightArm",
"shape": {
"type": "path",
"path": "M57.05,283.307c-5.502,5.354-13.185,8.541-18.249,14.221c-4.303,4.827-7.721,11.575-11.138,17.112 c-6.752,10.938-10.794,26.076-19.912,35.185c-3.869,3.866-7.637,5.722-7.251,12.032c0.932,0.372,1.548,0.589,2.418,0.683 c0.605-2.745,2.569-4.198,5.362-3.799c-0.14,3.365-3.512,5.941-3.228,9.235c0.364,4.223,3.983,5.968,7.181,2.662 c2.61-2.699,0.192-7.849,3.338-10.18c5.535-4.103,2.889,2.998,4.13,5.515c5.19,10.519,8.634-1.859,7.35-7.996 c-2.336-11.159-3.003-15.126,3.267-24.416c6.358-9.419,12.194-18.708,19.399-27.588c1.116-1.375,2.08-2.729,3.333-4"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "shirt",
"children": [
{
"name": "tShirt",
"shape": {
"type": "path",
"path": "M96.509,268.265 c-2.301,0.323-4.69,0.205-6.945,0.72c-2.234,0.509-4.5,0.8-6.749,1.249c-4.369,0.872-8.206,3.265-12.3,5.024 c-3.259,1.4-6.644,2.57-9.763,4.26c-1.923,1.041-3.688,2.616-5.487,3.97c-1.543,1.16-3.495,2.11-4.854,3.563 c-2.205,2.354,0.896,7.407,1.854,9.873c0.92,2.367,2.149,4.819,2.749,7.29c0.228,0.937,0.235,2.058,0.875,2.872 c0.644,0.821,0.64,0.735,1.822,0.049c1.513-0.878,2.873-1.993,4.329-2.993c2.431-1.67,5.462-2.849,7.434-5.111 c-3.335,1.652-5.335,4.679-6.931,8.012c-1.398,2.921-4.482,35.854-5.389,38.947c-0.195,0.003-0.775,0.003-0.749,0.013 c20.561,0,41.123-0.069,61.684,0c2.1,0.008,3.607-0.496,5.529-1.252c0.715-0.28,2.257-0.355,2.807-0.744 c1.412-0.998-0.094-3.916-0.646-5.303c-1.425-3.579-2.111-37.767-4.726-40.543c1.842,0.058,4.127,1.312,5.938,1.95 c1.351,0.478,2.633,1.092,3.956,1.66c1.39,0.597,3.667,1.927,5.168,1.857c0.296-1.872,1.045-3.285,1.839-5.02 c0.942-2.061,1.155-4.214,1.528-6.415c0.351-2.07,0.897-3.787,1.938-5.635c0.531-0.942,1.356-1.73,1.693-2.769 c-0.443-0.401-1.043-0.906-1.604-1.125c-0.56-0.219-1.292-0.11-1.908-0.33c-1.236-0.438-2.439-1.089-3.668-1.575 c-3.773-1.499-7.519-2.983-11.319-4.467c-3.575-1.396-6.977-3.238-10.784-3.871c-1.735-0.289-3.467-0.529-5.073-0.906"
},
"fill": "#4459A5",
"stroke": {
"color": "#000000",
"cap": "round"
}
},
{
"name": "shirtNeck",
"shape": {
"type": "path",
"path": "M99.759,268.89 c-0.984,0.151-1.746-0.549-2.75-0.5c-1.369,0.065-1.649,0.872-2.153,2c-1.037,2.325-2.442,4.974,0.064,6.945 c2.53,1.991,6.964,1.718,9.829,0.804c1.616-0.517,3.045-1.24,3.825-2.867c0.508-1.062,0.935-2.771,0.149-3.598 c-0.231-0.243-0.562-0.376-0.84-0.534"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round"
}
},
{
"name": "shirtLogo",
"children": [
{
"children": [
{
"shape": {
"type": "path",
"path": "M104.864,296.921c-0.151-0.004,7.101,0.409,7.052,0.403c0.132,0.028-0.172,0.633-0.021,0.632 c-0.226,0.028-7.244-0.454-7.28-0.464C104.657,297.519,104.776,296.904,104.864,296.921z"
},
"stroke": {
}
}
]
},
{
"children": [
{
"shape": {
"type": "path",
"path": "M90.071,295.919c-0.199,0.005,6.792,0.431,6.79,0.446c0.153,0.005-0.031,0.663,0.012,0.665 c0.272,0.016-6.79-0.471-6.875-0.459C89.881,296.561,89.796,295.899,90.071,295.919z"
},
"stroke": {
}
}
]
},
{
"shape": {
"type": "path",
"path": "M84.407,306.477c0.2-0.159,0.322-1.04,0.254,0.057c-0.542-0.355-2.02,2.083-4.215,2.001 c-1.887-1.706-4.559-3.384-4.302-7.092c0.652-2.599,3.082-4.084,5.213-3.942c1.889,0.378,2.899,0.717,4,1.318 c-0.497,0.957-0.175,0.866-0.459,0.703c0.456-2.398,0.598-5.75,0.312-7.855c0.594-0.554,0.714,0.125,1.249,0.941 c0.502-0.727,0.509-1.425,0.875-0.571c-0.207,1.328-0.809,7.187-0.711,10.174c-0.126,2.798-0.375,4.354-0.051,4.985 c-0.718,0.613-0.667,1.006-0.981,1.381c-0.72-1.33-1.056-0.132-1.339-0.157C84.632,308.442,84.493,305.791,84.407,306.477z M81.186,307.177c2.403,0.206,3.734-2.164,3.841-4.223c0.269-2.72-0.896-5.104-3.198-5.04c-1.972,0.438-3.46,2.188-3.331,4.639 C78.171,306.266,79.847,306.962,81.186,307.177z"
},
"stroke": {
}
},
{
"shape": {
"type": "path",
"path": "M93.321,297.767c2.592,0.147,5.688,2.314,5.696,5.627c-0.611,4.576-3.69,5.316-6.158,5.581 c-2.68-0.76-5.708-1.872-5.413-6.472C88.086,299.395,90.653,297.875,93.321,297.767z M92.939,307.46 c2.531,0.735,3.706-1.297,3.666-3.935c0.114-2.219-0.641-4.584-3.389-4.896c-2.29-0.553-3.366,2.188-3.661,4.688 C89.339,305.265,89.934,307.95,92.939,307.46z"
},
"stroke": {
}
},
{
"shape": {
"type": "path",
"path": "M99.688,303.916c0.03-1.511,0.055-4.73,0.022-4.646c0.481-1.355,0.658-0.556,1.034-1.297 c0.263,1.473,0.653,0.326,1.186,0.065c-0.386,2.518-0.513,3.348-0.574,4.949c-0.068-0.47-0.128,2.28-0.238,2.188 c-0.055,1.935-0.036,2.201-0.047,4.219c-0.079,0.914-0.28,2.412-1.126,3.831c-0.61,1.212-1.73,1.146-3.24,1.651 c0.073-0.945-0.065-1.242-0.096-1.822c0.098,0.138,0.213,0.604,0.225,0.397c1.892,0.229,2.209-1.896,2.362-3.365 c0.042,0.304,0.512-6.934,0.415-7.062C99.73,302.637,99.75,303.179,99.688,303.916z M100.978,295.564 c0.717,0.14,1.11,0.61,1.099,1.156c0.052,0.552-0.595,0.993-1.286,1.015c-0.541-0.074-1.025-0.548-1.022-1.054 C99.813,296.084,100.292,295.644,100.978,295.564z"
},
"stroke": {
}
},
{
"shape": {
"type": "path",
"path": "M108.115,298.791c3.028-0.066,5.283,1.359,5.256,5.758c-0.264,3.479-3.366,4.63-5.883,5.119 c-2.429-0.033-5.619-2.24-5.16-5.811C102.322,300.085,105.715,298.846,108.115,298.791z M107.351,309.232 c2.675-0.132,3.839-2.333,3.841-4.497c0.246-2.344-0.263-4.833-2.923-5.396c-2.844,0.299-3.974,1.917-4.053,4.479 C104.136,306.655,104.854,308.372,107.351,309.232z"
},
"stroke": {
}
}
]
}
]
}
]
},
{
"name": "heads",
"children": [
{
"name": "head1",
"children": [
{
"name": "leftEart",
"children": [
{
"shape": {
"type": "path",
"path": "M201.557,195.475 c7.734-4.547,16.592-5.012,18.405,4.443c2.43,12.659-3.317,13.328-14.598,13.328"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M211.711,203.09 c0.523,0.004,0.946-0.208,1.271-0.635"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M211.076,197.377 c3.062,3.013,5.489,5.624,4.442,10.155"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
}
]
},
{
"name": "bgHairTop",
"shape": {
"type": "path",
"path": "M54.384,199.307c-5.253-4.402-7.511-11.061-15.779-10.632c3.449-1.277,7.116-2.397,10.911-2.666 c-2.873-1.397-5.865-2.575-8.231-4.718c3.986-1.119,11.47-1.817,14.864,0.75c-5.183-2.758-8.397-7.816-13.062-10.598 c6.014-0.643,12.377,0.978,18.022,2.265c-2.547-4.486-6.682-10.83-10.523-14.297c5.033,1.052,10.647,4.518,15.062,7.177 c-1.614-4.176-5.634-8.406-7.859-12.513c10.312-1.125,12.522,4.919,19.7,9.932c-0.412-0.127-1.114-0.113-1.527,0.015 c0.875-7.261,3.058-12.8,8.258-18.566c6.771-7.507,17.813-9.131,24.095-15.381c-4.699,1.821-4.518,23.765-4.875,28.955"
},
"fill": "#FFF471",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "bgHairLeft",
"shape": {
"type": "path",
"path": "M92.384,243.973c-6.334,7.929-12.601,12.241-22.465,15.361c3.65-1.263,7.735-5.859,7.695-9.928 c-2.208,0.218-4.49,0.605-6.498,1.098c1.244-1.098,2.087-3.239,3.198-4.396c-5.77,0.001-12.131,1.133-18.396,1.23 c5.013-2.81,10.665-3.25,12.398-9.247c-3.59,0.313-7.233,1.606-11.033,1.097c1.731-2.022,3.953-3.995,5.049-6.447 c-3.781,0.056-6.665,3.098-10.547,2.465c0.962-2.863,3.187-5.208,4.531-7.766c-5.59-0.273-11.658,2.45-17.732,2.564 c5.494-2.857,8.967-7.819,12.3-12.718c5.233-7.693,10.625-9.96,20.349-9.981c11.059-0.024,15.558,6.714,20.984,16 c2.786,4.767,7.249,14.375,0.832,18"
},
"fill": "#FFF471",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "bgHair",
"shape": {
"type": "path",
"path": "M142.384,255.307c2.984,6.076,3.567,11.855,10.531,14.6c-0.134-3.114-0.094-6.664,1.619-9.033 c1.604,1.969,3.122,4.211,5.048,5.698c-0.29-1.769,0.412-4.023,0.233-5.828c3.444,0.261,4.979,3.965,8.468,4.479 c0.065-2.78,0.427-5.151,0.868-7.813c2.687,0.2,4.768,1.565,7.132,2.997c0.452-4.921-0.409-10.579-0.667-15.666 c-5.795-0.756-12.291,2.827-17.899,3.899c-4.414,0.844-14.136,0.523-15.333,6"
},
"fill": "#FFF471",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "neck",
"shape": {
"type": "path",
"path": "M106.989,254.499c-2.932,6.063-4.613,11.997-8.947,17.138c7.288,10.194,16.311-10.9,15.183-17.026 c-1.926-1.138-3.928-1.589-6.236-1.38"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "headShape",
"shape": {
"type": "path",
"path": "M210.941,207.666c-0.844,3.985-2.081,7.982-3.77,11.783c-3.374,7.604-8.543,14.427-16.052,18.899 c-2.94,2.13-5.983,4.167-9.109,6.085c-25.013,15.342-55.353,23.08-82.254,10.57c-3.433-1.558-6.785-3.432-10.053-5.66 c-1.821-1.185-3.592-2.46-5.308-3.832c-1.715-1.373-3.375-2.842-4.972-4.412c-2.352-2.148-4.576-4.425-6.631-6.814 c-6.168-7.169-10.823-15.358-12.87-24.185c-0.649-3.284-0.84-6.634-0.5-9.975c4.48-13.743,14.22-24.364,26.109-32.149 c2.973-1.946,6.079-3.715,9.271-5.309c30.581-15.027,69.581-10.027,95.852,12.209c2.563,2.254,4.987,4.651,7.244,7.178 c4.513,5.054,8.354,10.626,11.312,16.64C210.178,201.505,210.798,204.497,210.941,207.666z"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "rightEar",
"children": [
{
"shape": {
"type": "path",
"path": "M64.857,195.606 c-6.59-7.181-15.047-10.664-19.467,3.676c-1.235,4.007-1.87,14.468,1.29,17.786c4.223,4.435,13.591,0.529,19.055-0.015"
},
"fill": "#FFE8B0",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M52.407,196.744 c-1.702,3.613-1.257,7.505-1.27,11.424"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M51.772,209.438 c-3.39-4.661,0.922-5.769,5.078-6.347"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
}
]
},
{
"name": "fgHair",
"shape": {
"type": "path",
"path": "M90.384,154.64c8.453-11.353,15.678-13.458,28.581-15.915c-1.382,3.376-3.89,7.352-5.179,11.16 c5.01-1.816,9.571-6.545,15.218-8.413c11.355-3.755,23.853-1.903,35.671-2.213c-3.004,3.712-4.912,7.88-2.025,11.447 c5.855-2.212,13.369-6.871,19.635-6.646c0.263,4.561-0.024,9.278,0.201,13.841c3.509-1.201,6.015-3.04,8.276-5.148 c2.263-2.108,3.761-4.049,4.942-5.2c1.063,2.408,2.134,5.334,2.24,8.494c-0.183,3.462-0.866,6.794-2.66,9.291 c3.663,0.65,6.098-2.021,8.35-4.479c-0.655,4.349-3.164,8.604-3.851,13.013c2.178-0.072,4.382,0.216,6.367-0.48 c-1.39,3.093-3.069,7.287-6.616,8.414c-4.476,1.423-4.354-0.992-7.315-4.332c-4.892-5.518-9.773-6.791-15.872-9.464 c-6.585-2.887-10.982-6.47-17.963-8.219c-8.994-2.255-19.864-3.867-28.093-5.196c2.466,1.967,1.138,5.594,0.659,8.625 c-2.729-0.646-4.41-3.813-6.301-5.158c0.953,3.195,0.983,6.953-2.134,8.491c-6.145-5.226-9.199-9.721-17.527-11.647 c1,1.83,1.728,4.208,1.396,6.402c-0.751,4.971-0.289,3.134-3.836,2.466c-5.192-0.977-9.953-3.677-15.815-4.496 c3.292,2.002,5.469,5.017,7.418,8.21c-2.651,0.404-6.238,0.257-8.382,1.671c2.456,0.38,3.44,2.166,3.197,4.714 c-7.45,0.386-13.623,0.731-19.915,5.434"
},
"fill": "#FFF471",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
}
]
}
]
},
{
"name": "eyes",
"children": [
{
"name": "eyes1",
"children": [
{
"shape": {
"type": "path",
"path": "M123.163,176.668 c-5.066,1.17-9.01,7.888-13.666,10.335c-4.238,2.227-8.648,6.636-7.009,12.332c1.971,6.848,12.042,3.991,16.261,1.165 c5.282-3.539,9.59-8.517,12.006-14.524c1.523-3.787,2.568-7.272-1.509-9.391c-2.905-1.51-8.174-1.386-11.417-0.583"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M182.545,179.865 c-3.533,0.169-4.854-1.166-8.408-0.001c-3,0.983-6.239,1.936-8.852,3.743c-3.938,2.725-7.46,5.555-4.73,13.592 c1.974,5.811,8.791,7.571,14.656,6.667c5.537-0.854,9.078-4.977,11.408-10.007c3.666-7.918,0.942-11.639-6.742-13.659"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000",
"cap": "round"
}
},
{
"shape": {
"type": "path",
"path": "M108.829,183.668c-1.308-1.03-4.557,0.011-5.6-1.733 c-1.056-1.765,1.735-5.409,2.984-6.192c5.684-3.562,15.946-0.39,19.95-6.742"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M163.877,167.198c2.369,1.282,6.539,0.307,9.408,0.815 c3.449,0.612,7.065,2.657,10.592,2.851"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M127.496,192.002c-4.917-2.12-9.188-1.708-8.608,4.942 c3.132,1.734,5.428-2.82,7.275-4.942"
},
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M174.852,203.144c-0.293,0.12-0.307,0.577-0.942,0.282 c-1.605-3.188-0.404-6.507,2.676-8.192c2.15-1.176,5.67-1.759,7.471,0.359c0.199,0.234,0.412,0.521,0.515,0.813 c0.229,0.649-0.285,0.95-0.285,0.95s-3.988,6.009-3.285,1.934c0.438,1.743-5.537,5.743-2.287,1.653 c-1.955,2.583-2.524,1.977-3.859,2.868"
},
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "eyes2",
"children": [
{
"shape": {
"type": "path",
"path": "M98.668,186.108c0.668-8.915,15.545-13.749,22.667-15"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M169.667,178.108c5.307,3.436,16.928,5.632,19.668,12.333"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M105.334,197.775c8.085-4.283,17.059-2.8,25-6.333"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M164.001,198.775c4.656-0.417,9.664,1.805,14.334,2.017 c3.951,0.18,5.773,0.189,9,2.316"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M124.001,188.108c3.039-0.258,4.594,2.571,5.301,4.983 c-1.096,1.242-2.065,2.646-2.968,4.017"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M168.335,194.108c-1.77,2.293-4.869,3.271-6.299,5.91 c1.377,0.991,3.02,2.122,3.965,3.424"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
}
]
}
]
},
{
"name": "beard",
"children": [
{
"shape": {
"type": "path",
"path": "M96.05,213.64 c-0.366,0.21-0.783,0.389-1.167,0.5"
},
"fill": "#AFA8A5",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M102.55,211.973 c0.314-0.01,0.554-0.198,0.667-0.5"
},
"fill": "#AFA8A5",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M105.717,208.806 c0.164-0.109,0.336-0.224,0.5-0.333"
},
"fill": "#AFA8A5",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M111.05,207.973 c-0.651-1.81,0.859-2.262,2.333-1.5"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M117.717,209.806 c1.738,0,3.653,0.369,5.333,0.167"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M132.717,214.473 c0.104-0.21,0.162-0.435,0.167-0.667"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M139.551,216.973 c0.215-0.175,0.465-0.426,0.666-0.667"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M144.551,213.306 c0.277-0.056,0.557-0.111,0.833-0.167"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M147.884,216.64 c0.195,0.045,0.369-0.013,0.5-0.167"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M148.384,214.14 c0.112-0.168,0.223-0.332,0.333-0.5"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M98.217,219.306c1.697-1.772,4.233-2.109,5.967-4.046c1.519-1.696,3.812-3.001,4.2-5.454"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M152.717,216.14 c0.611,0,1.224,0,1.834,0"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M160.384,217.473 c0.333,0,0.667,0,1,0"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M163.217,215.973 c0.321-0.042,0.658-0.175,0.834-0.333"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M164.217,218.806 c0.167,0,0.333,0,0.5,0"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M168.384,217.973 c0.057-0.056,0.111-0.111,0.167-0.167"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M169.884,225.806 c0.491-0.397,0.882-0.926,1.167-1.5"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M172.717,221.973 c0.057,0,0.111,0,0.167,0"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M171.717,229.806 c0.334,0.075,0.659,0.025,0.834-0.167"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M190.051,227.806 c0.163-0.242,0.398-0.423,0.666-0.5"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M197.384,221.473 c0.258-0.007,0.485-0.125,0.667-0.333"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M199.384,214.973 c-0.04-0.333,0.075-0.609,0.333-0.833"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M117.884,257.306 c0.056,0,0.111,0,0.167,0"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M142.717,252.473 c0.358,0.068,0.71,0.016,1-0.167"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M137.884,256.473 c0.277,0,0.557,0,0.833,0"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M160.884,252.973 c0.366-0.139,0.766-0.402,1-0.667"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M171.384,250.14 c0.235-0.264,0.476-0.562,0.667-0.834"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M89.384,243.973 c0.537,0.378,1.329,0.876,1.833,1.333"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M79.05,225.473 c0.087,0.272,0.143,0.55,0.167,0.833"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M73.884,222.64 c0,0.167,0,0.333,0,0.5"
},
"fill": "none",
"stroke": {
"color": "#AAAAAA",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M72.55,219.806c0.466-0.325,0.875-0.797,1.167-1.333"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M71.717,211.973c0.422-0.553,0.776-1.305,1-2"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M78.55,214.473c0-0.111,0-0.222,0-0.333"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M79.384,218.806c-0.001-0.137,0.055-0.248,0.167-0.333"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M80.217,221.14c0.111,0,0.222,0,0.333,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M75.55,226.473c0.103-0.5,0.156-0.977,0.167-1.5"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M78.55,230.14c0.111,0,0.222,0,0.333,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M83.384,227.64c0.118-0.059,0.215-0.107,0.333-0.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M81.55,237.14c0.056,0,0.111,0,0.167,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M86.217,233.806c0.056,0,0.111,0,0.167,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M87.884,230.473c0.595-0.181,1.219-0.527,1.833-0.667"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M88.717,222.14 c-0.929,2.359-1.615,4.865-2.667,7.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M89.05,216.14 c0.784-0.736,1.709-1.565,2.833-1.5"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M94.217,210.14 c1.599-0.089,3.199-0.167,4.833-0.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M94.884,224.64 c0.052-0.588-0.004-1.155-0.167-1.667"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M92.384,228.306 c0.585-0.062,1.244-0.132,1.667-0.333"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M88.717,240.14 c0.111,0,0.222,0,0.333,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M95.884,243.306 c0.526,0.1,1.017-0.016,1.333-0.333"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M98.55,248.306 c0.069-0.24,0.265-0.926,0.333-1.166"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M96.55,249.806 c0.125,0.014,0.18-0.042,0.167-0.166"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M104.55,250.14 c0.01-0.238,0.126-0.428,0.333-0.5"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M106.884,251.973 c0.195,0.045,0.37-0.014,0.5-0.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M113.884,254.806 c0.758-0.586,1.595-1.171,2.382-1.774c0.072,0.376,0.418,0.686,0.48,1.079c0.833,0.265,1.624-0.021,1.638-0.971"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M122.217,254.64 c0.063-0.165,0.179-0.288,0.333-0.334"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M125.884,255.806 c1.13-0.745,2.783-0.962,3.667-2"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M132.217,255.973 c0.638-0.492,1.104-1.173,1.141-1.976c-1.11,0.063-1.449-0.888-1.475-1.857"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M129.717,249.306 c-0.045,0.153-0.168,0.271-0.333,0.334"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M136.551,252.306 c0.223,0,0.444,0,0.666,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M110.217,251.306 c0.056-0.057,0.111-0.11,0.167-0.166"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M140.717,251.806 c0.111,0,0.224,0,0.334,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M150.051,249.473 c0.111,0,0.223,0,0.333,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M143.217,255.473 c1.022-0.313,1.725-1.175,2.646-1.654c0.203,0.321,0.439,0.626,0.521,0.987"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M152.217,253.473 c0.165-0.063,0.288-0.179,0.334-0.333"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M155.051,254.64 c0.223,0,0.444,0,0.666,0"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M157.717,256.473 c0.326-0.027,0.546-0.073,0.834-0.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M163.217,252.64 c0.552-0.892,2.082-1.512,2.341-2.334c0.37-1.178-1.155-3.069-1.007-4.5"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M167.384,235.973 c0.118-0.54,0.354-1.064,0.667-1.5"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M170.717,242.806 c0-0.333,0-0.667,0-1"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M170.217,236.973 c0-0.333,0-0.667,0-1"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M179.051,235.806 c0.378-0.101,0.738-0.35,1-0.667"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M185.051,232.806 c0.379-0.319,0.656-0.702,0.833-1.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M188.051,231.14 c0.063-0.39,0.178-0.792,0.333-1.167"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M197.884,223.306 c-0.166,0.277-0.334,0.556-0.5,0.833"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
}
]
},
{
"name": "mouths",
"children": [
{
"name": "mouth1",
"children": [
{
"shape": {
"type": "path",
"path": "M177.122,216.821c-0.515,2.282-5.213,3.21-7.434,3.854 c-3.254,0.945-6.596,1.345-9.895,1.851c-3.26,0.5-6.665,0.671-10.107,0.671c-3.596,0-6.645,0.559-10.106,0.671 c-3.105,0.1-6.898-0.474-9.694-1.3c-3.527-1.043-6.672-1.666-10.096-3.062c-2.823-1.152-5.746-1.876-8.462-3.143 c-2.594-1.209-6.084-1.994-8.221-3.552c-1.068,1.834-5.867,3.748-8.1,4.546c-2.444,0.874-8.881,2.725-7.817,5.512 c0.457,1.195,1.948,2.273,2.63,3.385c0.774,1.261,1.139,2.601,2.057,3.859c1.83,2.5,4.506,4.773,6,7.34 c1.308,2.249,2.096,4.74,4.01,6.669c2.214,2.233,5.792,2.635,9.231,2.399c7.028-0.479,13.982-2.129,20.481-3.983 c3.295-0.941,6.699-1.536,10.086-2.686c3.272-1.111,6.642-3,9.402-4.777c5.248-3.377,10.278-6.409,14.283-10.705 c1.479-1.587,3.429-2.503,5.149-3.859"
},
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M135.25,241.319 c0.723-4.757-10.487-8.47-14.898-9.526c-3.09-0.74-6.68-1.17-9.858-1.712c-2.758-0.47-6.865-0.836-9.437,0.369 c-1.385,0.649-2.843,1.724-4.141,2.513c2.156,3.964,4.728,8.861,9.468,11.506c3.229,1.801,5.511,0.776,8.859,0.373 c3.045-0.369,6.046-0.703,9.029-1.721c3.479-1.186,7.228-2.385,10.978-2.475"
},
"fill": "#FFC0C0",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M148.656,225.547c1.267,0.697,1.301,2.838,0.671,3.9 c-0.702,1.182-2.063,1.4-3.307,2.01c-2.271,1.116-4.58,2.624-7.481,2.638c-4.619,0.023-2.144-4.067-0.253-5.869 c2.405-2.292,5.057-2.72,8.72-2.512c0.588,0.034,1.095,0.041,1.65,0.168"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M130.299,223.365 c2.687,0.437,5.619,4.384,3.727,6.422c-1.234,1.33-7.94,1.391-9.915,1.296c-4.896-0.233-2.502-2.445-0.613-4.525 c1.604-1.767,5.088-3.249,7.833-3.36"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M113.178,217.157 c2.56,0.958,4.922,5.057,5.352,7.215c0.377,1.885-0.324,2.106-2.526,2.643c-1.366,0.333-3.636,0.723-5.105,0.385 c-2.506-0.577-5.883-5.051-4.909-7.223c1.03-2.298,5.944-2.923,8.427-2.852"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M99.359,217.662 c2.038,0.432,4.015,4.279,2.468,5.625c-1.083,0.943-5.221,1.795-6.799,1.589c-4.032-0.526-2.265-4.102-0.866-5.872 c0.706-0.894,1.049-1.976,2.514-2.186c1.627-0.233,2.501,0.99,3.921,1.346"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M181.815,222.896c-3.102-2.75-4.765-8.777-9.282-10.403"
},
"fill": "none",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "mouth2",
"children": [
{
"shape": {
"type": "path",
"path": "M87.57,221.951c5.563-1.759,11.066-1.32,16.694-1.782c2.93-0.24,5.228-1.14,8.309-0.927c3.142,0.217,6.085-0.235,9.289,0.176 c7.136,0.914,13.96,0.598,21.112,1.506c3.654,0.464,7.219,0.609,10.811,0.869c4.017,0.291,7.646,1.582,11.433,2.623 c2.948,0.812,6.347,1.618,9.011,2.99c2.521,1.298,6.354,2.856,8.301,4.72c-2.775,0.027-5.602,2.603-8.021,3.769 c-2.93,1.412-5.741,2.949-8.656,4.432c-5.599,2.849-11.885,5.468-18.104,6.53c-6.793,1.161-13.195,2.107-20.067,2.197 c-7.699,0.102-14.313-4.705-20.735-8.396c-2.071-1.19-4.69-2.182-6.504-3.666c-1.792-1.466-3.469-3.386-5.154-4.984 c-2.703-2.564-7.519-5.649-8.13-9.438"
},
"stroke": {
"color": "#000000",
"width": "3",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M87.785,228.193 c-5.907-3.235-0.344-9.531,3.971-11.424"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2"
}
},
{
"shape": {
"type": "path",
"path": "M184.679,227.229c-1.534,2.583-2.548,5.334-4.024,7.889"
},
"fill": "none",
"stroke": {
"color": "#000000",
"width": "2",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M106.862,219.528 c-3.071-0.74-5.608,2.166-6.318,4.738c-0.379,1.375-0.494,2.55,0.748,3.337c1.519,0.962,2.905-0.052,4.418-0.332 c2.518-0.467,7.293,0.053,6.461-4.248c-0.568-2.938-3.743-3.682-6.338-3.335c-0.451,0.06-0.758,0.212-1.205,0.229"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M119.764,218.479 c-2.648,1.243-4.657,3.518-5.346,6.377c-0.866,3.594,3.9,3.711,6.356,2.865c2.64-0.91,4.77-3.351,3.299-6.133 c-1.01-1.91-3.979-2.548-6.026-2.823"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M130.388,219.492 c-1.753,1.382-4.069,4.525-4.835,6.61c-1.159,3.156,2.296,3.371,4.868,3.348c3.061-0.028,6.6-1.148,5.022-4.78 c-1.168-2.691-2.552-4.85-5.551-5.241"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M142.954,221.087 c-1.502,0.337-5.418,3.249-5.638,4.997c-0.292,2.311,4.855,4.536,6.854,4.234c2.503-0.377,4.384-3.175,3.167-5.65 c-0.92-1.873-3.36-2.252-4.508-3.932"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M155.354,222.664 c-2.038,0.426-4.212,2.287-4.766,4.444c-0.723,2.821,3.226,3.383,5.458,3.331c2.541-0.059,5.126-1.752,3.249-4.32 c-1.394-1.908-3.707-3.189-5.304-4.636"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M168.367,237.924 c-1.554-1.217-3.302-2.557-5.203-2.976c-2.973-0.654-3.537,2.131-3.377,4.406c0.205,2.913,1.032,3.883,3.901,2.344 c1.987-1.066,4.271-1.997,4.599-4.456"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M151.524,246.202 c-1.912-0.166-4.004-4.491-2.91-6.25c0.771-1.239,5.456-1.688,6.857-1.292c0.271,0.917,0.979,1.841,0.829,2.771 c-0.088,0.54-0.994,1.645-1.296,2.188c-1.08,1.951-2.133,1.866-3.998,2.685"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M145.911,241.458 c-0.209,1.649-0.215,2.702-1.528,3.801c-0.885,0.738-1.772,1.189-2.54,2.1c-0.786,0.933-1.226,2.38-2.792,1.813 c-1.042-0.377-1.959-2.318-2.138-3.312c-0.299-1.676-1.003-5.228,0.783-6.158c1.154-0.603,7.066-0.18,7.43,1.32"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M133.12,238.991 c-1.495-0.087-2.253-1.33-3.918-0.964c-1.42,0.311-2.489,1.354-2.54,2.836c-0.052,1.527,0.99,5.581,1.852,6.956 c2.363,3.771,4.329-1.535,5.516-3.159c1.117-1.525,2.643-2.053,2.271-3.958c-0.318-1.632-1.118-2.047-2.766-2.329 c-0.382-0.065-0.773-0.095-1.158-0.147"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M116.853,237.43 c-1.049,2.211-0.173,5.147,0.047,7.565c0.357,3.93,3.827,2.028,5.831,0.067c1.575-1.541,4.599-4.86,2.209-6.484 c-1.881-1.279-5.727-2.458-7.756-1.107"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M107.455,233.38 c-0.813,2.487-1.704,5.049,0.073,7.364c1.91,2.486,4.009,1.229,5.537-0.939c1.056-1.5,3.316-4.481,1.563-6.017 c-1.347-1.179-6.468-1.518-7.854-0.325"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "mouth3",
"children": [
{
"shape": {
"type": "path",
"path": "M99.05,218.973c1.691-0.875,3.313-2.39,4.833-3.537c1.231-0.928,2.782-1.671,3.5-3.072c1.846,3.486,7.661,4.669,11.003,6.067 c3.553,1.486,7.174,3.066,10.784,4.166c4.271,1.301,9.277,1.67,13.721,2.343c4.155,0.629,9.979,1.365,14.162,0.496 c1.182-0.245,2.343-1.024,3.462-1.446c0.162,1.905-3.637,3.023-4.933,3.487c-2.435,0.871-4.18,2.541-6.362,3.871 c-1.623,0.989-2.974,1.669-4.755,2.117c-1.77,0.445-3.353,0.806-4.825,1.878c-5.915,4.311-15.264,3.247-22.424,3.13 c-5.384-0.088-6.719-5.372-9.337-9c-1.437-1.991-2.843-3.854-3.796-6.138c-0.871-2.086-1.119-4.582-2.033-6.528"
},
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M107.217,227.973c1.182-2.033,4.375-2.176,6.5-1.963c2.879,0.289,4.124,1.217,6.168,3.167c1.834,1.749,5.906,5.509,5.64,8.271 c-2.808,0.89-7.847,0.402-10.346-1.104c-1.334-0.804-1.151-2.256-2.246-3.588c-0.712-0.866-1.836-2.673-2.855-3.311 c-0.209-0.94-2.106-1.499-3.028-1.805"
},
"fill": "#F4BDBD",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
}
]
}
]
},
{
"name": "personalProps",
"children": [
{
"name": "hat",
"children": [
{
"children": [
{
"children": [
{
"shape": {
"type": "path",
"path": "M88.374,173.145c0.474-0.074,16.606,2.725,18.01,5.879 c1.145,2.572,28.184,4.568,28.184,4.568l35.971-5.618l5.024,1.132l7.212,0.315l9.295,0.851l10.188,3.248l5.75,2.935 l1.615-1.832l-0.264-5.27l-3.968-7.087c0,0-22.045-13.031-23.272-13.703c-1.229-0.669-4.941-2.294-6.484-4.542 c-8.584-12.528-8.403-18.05-3.371-6.461c0,0,2.662-7.592,2.521-8.575c-0.144-0.982,0.354-5.031,0.354-5.031l2.396-6.832 c0,0-1.379-5.341-2.738-7.19c-1.356-1.844-15.793-4.078-18.162-4.011c-24.933,0.706-3.783,0.071-25.567,0.724 c-24.317,0.728-0.882-2.591-24.068,3.551c-24.228,6.418-5.35-1.298-23.187,6.142c-18.301,7.633-16.67,7.186-16.704,10.685 c-0.034,3.499-3.057-4.884-0.034,3.499c3.023,8.381,3.037-3.871,3.023,8.381c-0.015,12.252,6.696,4.557,1.678,12.373 c-5.017,7.813-3.831,7.91-0.179,8.543c17.017,2.953,4.157,4.378,17.427,3.175"
},
"fill": "#FF0000",
"stroke": {
}
},
{
"shape": {
"type": "path",
"path": "M156.604,114.92l-13.936,0.381l-11.633,0.343c-10.646,0.319-11.973-0.155-12.021-0.175l-0.599-0.238 l-0.577,0.514l0.049-0.047c-0.118,0.09-1.43,0.957-11.145,3.53c-9.989,2.646-12.812,2.931-13.421,2.704 c-0.822-0.306-0.821-0.306-7.791,2.604l-2.104,0.878c-16.037,6.689-17.342,7.324-17.342,10.316c0,0.019,0.001,0.041,0.001,0.06 c-0.224-0.108-0.459-0.199-0.787-0.04c-0.357,0.173-0.565,0.275-0.565,0.672c0,0.557,0.411,1.697,1.399,4.438 c0.924,2.561,1.71,3.671,2.714,3.833c0.083,0.014,0.164,0.02,0.241,0.02c0.007,0.584,0.01,1.339,0.01,2.313 c0,0.561-0.001,1.902-0.001,1.916c0,6.908,2.176,8.105,3.347,8.749c0,0,0.075,0.045,0.151,0.09 c-0.095,0.332-0.47,1.1-1.661,2.955c-2.509,3.908-3.516,5.931-3.516,7.303c0,0.358,0.068,0.671,0.196,0.962 c0.544,1.237,1.926,1.477,3.677,1.78l0.135,0.023c8.138,1.412,9.14,2.422,9.568,2.854c0.923,0.931,1.511,0.928,7.224,0.413 c0.06,0.014,0.102,0.068,0.165,0.071c2.167,0.105,16.131,3.138,17.087,5.288c1.147,2.578,16.416,4.228,29.023,5.159 l0.115,0.009c0,0,35.523-5.548,35.896-5.606c0.345,0.078,4.927,1.11,4.927,1.11l7.301,0.319c0,0,8.927,0.818,9.139,0.837 c0.202,0.064,9.854,3.142,10.006,3.19c0.143,0.073,6.368,3.251,6.368,3.251l2.397-2.719l-0.296-5.911l-4.213-7.526 l-0.231-0.137c-0.9-0.532-22.073-13.047-23.304-13.72c-0.001,0-0.734-0.38-0.734-0.38c-1.48-0.752-4.238-2.151-5.404-3.85 c-1.357-1.982-2.451-3.729-3.354-5.268c0.021-0.064,0.104-0.296,0.104-0.296c1.193-3.402,2.576-7.619,2.576-8.885 c0-0.063-0.004-0.118-0.011-0.165c-0.013-0.083-0.018-0.204-0.018-0.356c0-0.909,0.194-2.911,0.363-4.307 c0.072-0.205,2.46-7.013,2.46-7.013l-0.076-0.294c-0.146-0.566-1.468-5.584-2.9-7.532 C173.721,116.784,158.242,114.875,156.604,114.92z M131.097,117.644l11.614-0.342l13.951-0.382 c2.575-0.073,16.104,2.238,17.336,3.614c0.956,1.3,2.058,4.938,2.49,6.549c-0.188,0.536-2.33,6.642-2.33,6.642l-0.014,0.107 c-0.072,0.592-0.387,3.224-0.387,4.658c0,0.258,0.011,0.477,0.034,0.639c-0.006,0.493-0.768,3.026-1.659,5.709 c-2.14-4.566-2.792-4.606-3.242-4.629l-0.62-0.031l-0.354,0.571c-0.069,0.124-0.102,0.29-0.102,0.492 c0,2.273,4.134,9.172,6.992,13.346c1.456,2.12,4.51,3.669,6.149,4.501l0.682,0.353c1.139,0.622,20.813,12.25,23.012,13.549 c0.238,0.427,3.513,6.275,3.721,6.647c0.02,0.393,0.199,3.971,0.23,4.629c-0.229,0.262-0.472,0.535-0.832,0.944 c-1.069-0.546-5.132-2.619-5.132-2.619l-10.369-3.306l-9.403-0.86c0,0-6.995-0.307-7.169-0.315 c-0.168-0.038-5.124-1.155-5.124-1.155s-35.814,5.594-36.044,5.63c-12.419-0.922-25.993-2.687-27.285-4.058 c-1.366-3.097-13.245-5.574-17.517-6.211c-0.203-0.212-0.479-0.346-0.793-0.318c-3.083,0.28-5.996,0.544-6.4,0.369 c0-0.003-0.12-0.117-0.12-0.117c-0.703-0.708-1.879-1.895-10.646-3.416l-0.135-0.023c-0.827-0.143-2.075-0.359-2.188-0.614 c-0.021-0.048-0.033-0.111-0.033-0.193c0-0.592,0.632-2.179,3.205-6.187c1.488-2.318,2.024-3.388,2.024-4.188 c0-0.15-0.019-0.291-0.054-0.428c-0.181-0.712-0.758-1.03-1.179-1.261c-0.865-0.476-2.311-1.271-2.311-6.993 c0-0.014,0.001-1.098,0.001-1.56c0-4.969-0.065-4.992-0.833-5.258c-0.424-0.146-0.816,0.001-1.178,0.377 c-0.208-0.289-0.558-0.898-1.073-2.324c-0.205-0.568-0.385-1.068-0.542-1.506c0.587-0.423,0.632-1.277,0.636-1.644 l-0.014-0.825c-0.004-0.119-0.007-0.231-0.007-0.338c0-1.702,0.899-2.264,16.109-8.608l2.105-0.878 c4.165-1.739,5.948-2.482,6.375-2.562c0.817,0.296,2.292,0.597,14.579-2.658c8.169-2.164,10.697-3.187,11.58-3.704 C120.451,117.773,124.529,117.84,131.097,117.644z"
},
"stroke": {
}
}
]
},
{
"children": [
{
"shape": {
"type": "path",
"path": "M155.146,147.93c4.88-9.398-5.344-20.199-12.649-21.176 c-12.05-1.61-13.404,10.426-13.684,21.258c3.73,2.016,8.915,3.425,11.721,6.534"
},
"fill": "#FFFFFF",
"stroke": {
}
},
{
"shape": {
"type": "path",
"path": "M133.446,127.979c-4.599,3.921-5.426,11.933-5.635,20.006l-0.017,0.654l4.415,2.067 c2.849,1.244,5.793,2.529,7.581,4.509c0.371,0.41,1.004,0.442,1.412,0.072c0.219-0.197,0.33-0.469,0.33-0.743 c0-0.239-0.084-0.479-0.258-0.67c-2.076-2.299-5.223-3.673-8.267-5.001c0,0-2.377-1.112-3.174-1.486 c0.223-7.385,1.021-14.572,4.909-17.887c1.892-1.614,4.386-2.189,7.621-1.757c4.143,0.554,9.086,4.472,11.5,9.113 c1.348,2.591,2.51,6.535,0.395,10.611c-0.254,0.49-0.063,1.093,0.426,1.348c0.49,0.254,1.095,0.063,1.351-0.427 c1.959-3.775,1.817-8.199-0.396-12.456c-2.731-5.251-8.203-9.53-13.012-10.172C138.853,125.257,135.763,126,133.446,127.979z"
},
"stroke": {
}
}
]
},
{
"children": [
{
"shape": {
"type": "path",
"path": "M154.077,146.278c-2.156,1.18-4.24,2.619-6.256,4.01c-3.636,2.509-7.068,4.878-10.941,5.924 c-2.991,0.808-6.055,1.058-9.3,1.324c-3.222,0.263-6.553,0.536-9.783,1.406c-2.027,0.546-4.117,1.397-6.137,2.221 c-3.491,1.423-7.102,2.895-10.528,2.866c-0.552-0.005-1.004,0.439-1.009,0.991c-0.005,0.552,0.439,1.004,0.991,1.009 c3.828,0.033,7.627-1.516,11.301-3.014c2.054-0.837,3.994-1.628,5.902-2.142c3.054-0.823,6.292-1.088,9.425-1.344 c3.191-0.261,6.492-0.531,9.659-1.386c4.205-1.135,7.94-3.714,11.557-6.208c1.973-1.362,4.014-2.771,6.08-3.901 c0.484-0.265,0.662-0.873,0.396-1.357C155.168,146.193,154.562,146.014,154.077,146.278z"
},
"stroke": {
}
}
]
},
{
"children": [
{
"shape": {
"type": "path",
"path": "M156.458,153.549c-2.619,0.064-5.709,0.812-8.98,1.604c-4.278,1.035-8.7,2.104-11.901,1.536 c-0.543-0.096-1.063,0.267-1.159,0.81c-0.097,0.544,0.267,1.063,0.81,1.16c3.613,0.641,8.24-0.481,12.72-1.562 c3.166-0.766,6.153-1.489,8.561-1.548c5.664-0.141,7.961,0.698,13.508,2.724c0.519,0.189,1.095-0.077,1.281-0.596 c0.189-0.519-0.076-1.091-0.596-1.282C165.069,154.337,162.501,153.399,156.458,153.549z"
},
"stroke": {
}
}
]
}
]
}
]
},
{
"name": "textSurface",
"children": [
{
"name": "spokenBubble",
"children": [
{
"name": "textContainer",
"shape": {
"type": "path",
"path": "M225.719,45.307 c0-6.627,5.373-12,12-12h181.333c6.627,0,12,5.373,12,12v105.334c0,6.627-5.373,12-12,12H237.719c-6.627,0-12-5.373-12-12 V45.307z"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"name": "textArrowBelow",
"shape": {
"type": "path",
"path": "M249.052,160.64 c-0.774,14.251-1.676,18.525-9.1,30.565c9.705-0.79,21.952-21.605,25.1-30.045"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "thoughtBubble",
"children": [
{
"name": "textContainer_1_",
"shape": {
"type": "path",
"path": "M202.698,21.089 c19.686-26.45,59.686-24.45,79.747-0.084c2.696,1.349,5.57,1.709,7.472,0.781c15.28-13.888,33.271-14.043,49.893-7.839 c2.771,1.034,5.479,2.219,8.031,3.421C376.384-4.36,423.384,6.64,431.007,45.026c0,0-1.324,3.889,1.165,6.603 c18.212,11.011,26.212,32.011,22.212,53.011c-1,5.333-3.223,9.667-6.037,13.52c-2.813,3.854-1.381,0-2.612-0.591 c-1.351-0.929-3.351-0.929-4.351-1.929c16,7,27,22,30,39c2,21-8,41-27,50c-16,7.5-32.5,5.5-45.745-2.556 c-2.531-1.384-4.229-1.856-5.336-1.551c-1.919,0.107-3.919,2.107-5.919,2.107c4-1,6-5,10-6c-15,11-35,12-52,3c-13-7-20-20-24-34 c1,5,3,9,3.299,13.505c-0.396,0.708-3.423,2.219-6.654,3.466c-22.627,8.729-49.423,1.729-65.241-19.971 c-3.453,0-6.263,0.589-8.723,0.879c-17.301,3.2-32.382-7.709-40.771-22.689c-1.678-2.996-3.089-6.153-4.195-9.396 c-15.714-7.795-29.714-18.795-33.714-37.795c-5-25,11-45,29.842-57.667c0.72-2.335,1.697-4.636,3.007-6.896 C201.159,23.307,202.698,21.089,202.698,21.089z"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"children": [
{
"shape": {
"type": "path",
"path": "M269.719,186.307c0,4.602-4.179,8.333-9.333,8.333s-9.334-3.731-9.334-8.333 c0-4.603,4.18-8.333,9.334-8.333S269.719,181.705,269.719,186.307z"
},
"fill": "#FFFFFF",
"stroke": {
}
},
{
"children": [
{
"shape": {
"type": "path",
"path": "M269.719,186.307c0,4.602-4.179,8.333-9.333,8.333s-9.334-3.731-9.334-8.333 c0-4.603,4.18-8.333,9.334-8.333S269.719,181.705,269.719,186.307z"
},
"fill": "none",
"stroke": {
}
},
{
"shape": {
"type": "path",
"path": "M268.225,186.166c-0.563,8.736-13.981,9.286-15.633,0.853 c-1.785-9.125,15.018-10.254,15.649-0.451c0.125,1.929,3.078,1.388,2.955-0.521c-0.814-12.597-20.828-12.412-21.64,0.119 c-0.827,12.813,20.831,13.028,21.655,0.283C271.337,184.519,268.35,184.235,268.225,186.166z"
},
"fill": "#FFFFFF",
"stroke": {
}
}
]
}
]
},
{
"shape": {
"type": "path",
"path": "M260.386,188.307c0,3.498-2.984,6.333-6.667,6.333 c-3.682,0-6.667-2.835-6.667-6.333s2.985-6.333,6.667-6.333C257.401,181.974,260.386,184.809,260.386,188.307z"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M238.386,196.974c0,1.289-1.045,2.333-2.334,2.333 c-1.288,0-2.333-1.045-2.333-2.333c0-1.288,1.045-2.333,2.333-2.333C237.341,194.64,238.386,195.685,238.386,196.974z"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
},
{
"shape": {
"type": "path",
"path": "M285.719,179.974c0,4.602-4.253,8.333-9.5,8.333 s-9.5-3.731-9.5-8.333c0-4.603,4.253-8.333,9.5-8.333S285.719,175.372,285.719,179.974z"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
}
]
},
{
"name": "yellBubble",
"children": [
{
"shape": {
"type": "path",
"path": "M251.156,176.051l40.228-15.992"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"shape": {
"type": "path",
"path": "M280.932,149.385l-40.667,36.42"
},
"fill": "none",
"stroke": {
"color": "#000000",
"cap": "round",
"join": "bevel"
}
},
{
"name": "textContainer_2_",
"shape": {
"type": "path",
"path": "M217.778,34.644 c8.608,6.684,9.951,3.684,7.986-5.785c6.309,5.125,9.309,3.782,10.188-4.309c2.433,8.091,5.266,8.091,9.12-1.703 c6.063,9.793,13.146,9.793,24.043,3.878c6.103,5.915,16.02,5.915,20.094-4.64c17.178,10.555,28.511,10.555,45.233-5.505 c5.94,16.06,17.272,16.06,18.835,1.458c19.688,14.603,29.604,14.603,46.749-17.802c-0.145,32.405,6.938,32.405,29.26,16.182 c-12.403,16.223-9.57,16.223,4.813,6.576c-11.069,9.646-8.069,10.99,4.333,9.089c-8.061,6.244-6.717,9.244,2.533,11.068 c-9.25,1.489-9.25,5.703-0.314,13.07c-8.936,6.115-8.936,15.385,7.513,10.932c-16.447,24.677-16.447,35.631,14.938,36.553 c-31.385,19.303-31.385,28.571-4.39,40.526c-26.995,1.528-26.995,5.741-5.942,17.857c-21.053-8.801-22.396-5.802-9.525,11.916 c-17.213-13.374-20.213-12.03-12.048,8.029c-11.479-20.06-14.313-20.06-10.554,3.532c-13.676-23.591-20.759-23.591-29.813-2.664 c-7.944-20.927-17.861-20.927-27.072,12.467c-12.039-33.395-23.373-33.395-23.147-1.581 c-22.891-31.814-34.225-31.814-61.518-8.479c6.042-23.335-3.874-23.335-11.899-9.703c-8.976-13.632-16.059-13.632-23.927,4.361 c-2.049-17.993-4.882-17.993-10.51-1.486c2.314-16.508-0.686-17.851-12.385-5.019c7.355-17.175,6.013-20.176-10.271-7.879 c16.283-15.61,16.283-19.824-9.255-12.972c25.538-20.334,25.538-29.603,1.919-46.578c23.619-3.249,23.619-14.204-0.313-25.522 c23.933-8.905,23.933-18.175,7.798-37.429C226.385,48.854,226.385,44.641,217.778,34.644z"
},
"fill": "#FFFFFF",
"stroke": {
"color": "#000000"
}
}
]
}
]
}
]
}
]
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/transform.json
New file
0,0 → 1,1567
[
{
"children": [
{
"shape": {
"type": "line",
"x1": 0,
"y1": 0,
"x2": 500,
"y2": 0
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 0,
"y1": 0,
"x2": 0,
"y2": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 0,
"y1": 50,
"x2": 500,
"y2": 50
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 50,
"y1": 0,
"x2": 50,
"y2": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 0,
"y1": 100,
"x2": 500,
"y2": 100
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 100,
"y1": 0,
"x2": 100,
"y2": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 0,
"y1": 150,
"x2": 500,
"y2": 150
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 150,
"y1": 0,
"x2": 150,
"y2": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 0,
"y1": 200,
"x2": 500,
"y2": 200
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 200,
"y1": 0,
"x2": 200,
"y2": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 0,
"y1": 250,
"x2": 500,
"y2": 250
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 250,
"y1": 0,
"x2": 250,
"y2": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 0,
"y1": 300,
"x2": 500,
"y2": 300
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 300,
"y1": 0,
"x2": 300,
"y2": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 0,
"y1": 350,
"x2": 500,
"y2": 350
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 350,
"y1": 0,
"x2": 350,
"y2": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 0,
"y1": 400,
"x2": 500,
"y2": 400
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 400,
"y1": 0,
"x2": 400,
"y2": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 0,
"y1": 450,
"x2": 500,
"y2": 450
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 450,
"y1": 0,
"x2": 450,
"y2": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 0,
"y1": 500,
"x2": 500,
"y2": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
},
{
"shape": {
"type": "line",
"x1": 500,
"y1": 0,
"x2": 500,
"y2": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
}
}
],
"name": "grid"
},
{
"children": [
{
"shape": {
"type": "rect",
"x": 0,
"y": 0,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 0,
"y": 100,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 0,
"y": 200,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 0,
"y": 300,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 0,
"y": 400,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 50,
"y": 50,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 50,
"y": 150,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 50,
"y": 250,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 50,
"y": 350,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 50,
"y": 450,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 100,
"y": 0,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 100,
"y": 100,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 100,
"y": 200,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 100,
"y": 300,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 100,
"y": 400,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 150,
"y": 50,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 150,
"y": 150,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 150,
"y": 250,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 150,
"y": 350,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 150,
"y": 450,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 200,
"y": 0,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 200,
"y": 100,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 200,
"y": 200,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 200,
"y": 300,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 200,
"y": 400,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 250,
"y": 50,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 250,
"y": 150,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 250,
"y": 250,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 250,
"y": 350,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 250,
"y": 450,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 300,
"y": 0,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 300,
"y": 100,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 300,
"y": 200,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 300,
"y": 300,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 300,
"y": 400,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 350,
"y": 50,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 350,
"y": 150,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 350,
"y": 250,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 350,
"y": 350,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 350,
"y": 450,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 400,
"y": 0,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 400,
"y": 100,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 400,
"y": 200,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 400,
"y": 300,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 400,
"y": 400,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 450,
"y": 50,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 450,
"y": 150,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 450,
"y": 250,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 450,
"y": 350,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
},
{
"shape": {
"type": "rect",
"x": 450,
"y": 450,
"width": 50,
"height": 50,
"r": 0
},
"fill": {
"g": 0,
"b": 0,
"a": 0.1,
"r": 255
}
}
],
"name": "checkerboard"
},
{
"shape": {
"type": "rect",
"x": 0,
"y": 0,
"width": 100,
"height": 100,
"r": 0
},
"transform": {
"dx": 100,
"dy": 100,
"xx": 1,
"xy": 0,
"yx": 0,
"yy": 1
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
},
"fill": {
"type": "linear",
"x1": 0,
"y1": 0,
"x2": 100,
"y2": 100,
"colors": [
{
"offset": 0,
"color": {
"r": 0,
"g": 128,
"b": 0,
"a": 1
}
},
{
"offset": 0.5,
"color": {
"g": 0,
"b": 0,
"r": 255,
"a": 1
}
},
{
"offset": 1,
"color": {
"r": 0,
"g": 0,
"b": 255,
"a": 1
}
}
]
},
"name": "rect with color gradient"
},
{
"shape": {
"type": "rect",
"x": 0,
"y": 0,
"width": 100,
"height": 100,
"r": 0
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
},
"fill": {
"type": "linear",
"x1": 0,
"y1": 0,
"x2": 100,
"y2": 100,
"colors": [
{
"offset": 0,
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
}
},
{
"offset": 1,
"color": {
"r": 255,
"g": 255,
"b": 255,
"a": 1
}
}
]
},
"name": "rect with gray gradient"
},
{
"children": [
{
"shape": {
"type": "rect",
"x": 200,
"y": 200,
"width": 100,
"height": 100,
"r": 0
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
},
"fill": {
"r": 0,
"g": 128,
"b": 0,
"a": 1
},
name: "green rect"
},
{
"shape": {
"type": "rect",
"x": 0,
"y": 0,
"width": 100,
"height": 100,
"r": 0
},
"transform": {
"xx": 0.8660254037844387,
"xy": 0.49999999999999994,
"yx": -0.49999999999999994,
"yy": 0.8660254037844387,
"dx": 281.69872981077805,
"dy": 231.69872981077808
},
"fill": {
"r": 0,
"g": 0,
"b": 255,
"a": 1
},
name: "blue rect"
},
{
"shape": {
"type": "path",
"path": "M 300 100L 400 200L 400 300L 300 400C 400 300 400 200 300 100"
},
"transform": {
"xx": 1,
"xy": 0,
"yx": 0,
"yy": 1,
"dx": 0,
"dy": 0
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 0,
"a": 1
},
"style": "solid",
"width": 1,
"cap": "butt",
"join": 4
},
name: "black path"
},
{
"shape": {
"type": "path",
"path": "M 300 100L 400 200L 400 300L 300 400C 400 300 400 200 300 100"
},
"transform": {
"dx": 100,
"xx": 1,
"xy": 0,
"yx": 0,
"yy": 1,
"dy": 0
},
"stroke": {
"type": "stroke",
"color": {
"g": 0,
"b": 0,
"r": 255,
"a": 1
},
"style": "solid",
"width": 2,
"cap": "butt",
"join": 4
},
name: "red path"
},
{
"shape": {
"type": "path",
"path": "M 300 100l 100 100l 0 100l-100 100c 100-100 100-200 0-300"
},
"transform": {
"xx": -1,
"xy": -1.2246063538223773e-16,
"yx": 1.2246063538223773e-16,
"yy": -1,
"dx": 500,
"dy": 500
},
"stroke": {
"type": "stroke",
"color": {
"r": 0,
"g": 0,
"b": 255,
"a": 1
},
"style": "solid",
"width": 2,
"cap": "butt",
"join": 4
},
name: "blue path"
}
],
"transform": {
"xx": 0.9659258262890683,
"xy": 0.25881904510252074,
"yx": -0.25881904510252074,
"yy": 0.9659258262890683,
"dx": -56.1862178478973,
"dy": 73.22330470336311
},
"name": "rotated group"
}
]
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-nose-medium.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-nose-medium.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-right-leg.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/gfx/demos/data/buratino-right-leg.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/gfx/demos/inspector.html
New file
0,0 → 1,165
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Inspect DojoX GFX JSON</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
td.cell { padding: 1em 1em 0em 0em; }
td.note { font-size: 80%; }
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("dojox.gfx");
dojo.require("dojox.gfx.move");
dojo.require("dojox.gfx.utils");
 
surface = null;
container_pos = null;
mover = null;
 
init = function(){
// initialize graphics
var container = dojo.byId("gfx");
surface = dojox.gfx.createSurface(container, 500, 500);
container_pos = dojo.coords(container, true);
// wire UI
dojo.connect(dojo.byId("load"), "onclick", onLoad);
dojo.connect(dojo.byId("add"), "onclick", onAdd);
// handle moves
dojo.subscribe("/gfx/move/start", function(m){ mover = m; });
dojo.subscribe("/gfx/move/stop", function(){ mover = null; });
// handle shape operations
dojo.connect(document, "onkeydown", onKeyDown);
// cancel text selection and text dragging
dojo.connect(container, "ondragstart", dojo, "stopEvent");
dojo.connect(container, "onselectstart", dojo, "stopEvent");
};
 
onLoad = function(){
var s = dojo.byId("source");
if(!s.value){
alert("Name of the file is required.");
return;
}
dojo.xhrGet({
url: s.value,
preventCache: true,
handleAs: "json",
load: loadObjects,
error: function(r){ alert("Error: " + r); }
});
};
 
mainObject = null;
names = [];
 
loadObjects = function(r){
if(!r){
alert("Wrong JSON object. Did you type the file name correctly?");
return;
}
mainObject = r;
// clear old object names
names = [];
var s = dojo.byId("names"), ni = dojo.byId("names_info");
ni.innerHTML = "";
while(s.childNodes.length){ s.removeChild(s.lastChild); }
// find new names
findNames(s, dojo.byId("named").checked, "", mainObject);
ni.innerHTML = " (" + names.length + ")";
};
 
findNames = function(selector, named_only, prefix, o){
if(o instanceof Array){
for(var i = 0; i < o.length; ++i){
findNames(selector, named_only, prefix, o[i]);
}
return;
}
if(named_only && !("name" in o)) return;
var name = ("name" in o) ? o.name : "*",
full = prefix ? prefix + "/" + name : name,
opt = document.createElement("option");
opt.value = names.length;
opt.innerHTML = full;
names.push(o);
selector.appendChild(opt);
if("children" in o){
findNames(selector, named_only, full, o.children);
}
};
 
onAdd = function(){
var s = dojo.byId("names");
for(var i = 0; i < s.options.length; ++i){
var opt = s.options[i];
if(!opt.selected) continue;
var object = names[Number(opt.value)];
var group = surface.createGroup();
dojox.gfx.utils.deserialize(group, object);
new dojox.gfx.Moveable(group); // make it moveable as whole
}
};
 
// event handling
 
onKeyDown = function(e){
if(!mover) return;
switch(e.keyCode){
case "f".charCodeAt(0): case "F".charCodeAt(0):
mover.shape.moveToFront();
break;
case "b".charCodeAt(0): case "B".charCodeAt(0):
mover.shape.moveToBack();
break;
case "q".charCodeAt(0): case "Q".charCodeAt(0):
mover.shape.applyLeftTransform(dojox.gfx.matrix.rotategAt(-15, mover.lastX - container_pos.x, mover.lastY - container_pos.y));
break;
case "w".charCodeAt(0): case "W".charCodeAt(0):
mover.shape.applyLeftTransform(dojox.gfx.matrix.rotategAt(15, mover.lastX - container_pos.x, mover.lastY - container_pos.y));
break;
case "d".charCodeAt(0): case "D".charCodeAt(0):
mover.shape.parent.remove(mover.shape);
mover.shape.rawNode = null;
mover.destroy();
break;
}
dojo.stopEvent(e);
};
 
dojo.addOnLoad(init);
</script>
</head>
<body>
<h1>Inspect DojoX GFX JSON</h1>
<p>Help: load a file, select an object, and add it, move it around, or apply operations to selected items:<br />
F &mdash; bring to front, B &mdash; bring to back, Q &mdash; rotate CCW, W &mdash; rotate CW, D &mdash; delete.<br />
(all operations work on currently dragged item).</p>
<p><strong>VML note:</strong> VML doesn't process PNG images with opacity correctly.</p>
<table><tr>
<td align="left" valign="top" class="cell"><div id="gfx" style="width: 500px; height: 500px; border: solid 1px black;"></div></td>
<td align="left" valign="top" class="cell"><table>
<tr><td>Source:</td></tr>
<tr><td><input type="text" id="source" value="data/Lars.json" size="30" />&nbsp;<button id="load">Load</button><br />
<input type="checkbox" id="named" checked="checked" />&nbsp;<label for="named">Load only named objects</label></td></tr>
<tr><td class="note"><em>Available sources:</em></td></tr>
<tr><td class="note"><em>data/Lars.json &mdash; vectors from SVG</em></td></tr>
<tr><td class="note"><em>data/Nils.json &mdash; vectors from SVG</em></td></tr>
<tr><td class="note"><em>data/LarsDreaming.json &mdash; vectors from SVG</em></td></tr>
<tr><td class="note"><em>data/buratino.json &mdash; images</em></td></tr>
<tr><td class="note"><em>data/transform.json &mdash; from dojox.gfx</em></td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>Objects<span id="names_info"></span>:</td></tr>
<tr><td><select id="names" multiple="multiple" size="10" style="width: 300px;"></select></td></tr>
<tr><td><button id="add">Add Selected</button></td></tr>
<tr><td class="note"><div style="width: 300px;">Object names are hierarchical and separated by "/". Adding a selected object creates a group for this object.
A higher-level object (a group) always includes lower-level objects as children.</div></td></tr>
</table></td>
</tr></table>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/demos/clock_black.html
New file
0,0 → 1,253
<html>
<head>
<title>dojox.gfx: interactive analog clock</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverlight.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
<script type="text/javascript">
 
dojo.require("dojox.gfx");
dojo.require("dojo.date.locale");
 
var current_time = new Date();
 
var hour_hand = null;
var minute_hand = null;
var second_hand = null;
 
var hour_shadow = null;
var minute_shadow = null;
var second_shadow = null;
 
var center = {x: 385 / 2, y: 385 / 2};
 
var hour_shadow_shift = {dx: 2, dy: 2};
var minute_shadow_shift = {dx: 3, dy: 3};
var second_shadow_shift = {dx: 4, dy: 4};
 
var selected_hand = null;
var container = null;
var container_position = null;
var text_time = null;
var diff_time = new Date();
 
placeHand = function(shape, angle, shift){
var move = {dx: center.x + (shift ? shift.dx : 0), dy: center.y + (shift ? shift.dy : 0)};
return shape.setTransform([move, dojox.gfx.matrix.rotateg(angle)]);
};
 
placeHourHand = function(h, m, s){
var angle = 30 * (h % 12 + m / 60 + s / 3600);
placeHand(hour_hand, angle);
placeHand(hour_shadow, angle, hour_shadow_shift);
};
 
placeMinuteHand = function(m, s){
var angle = 6 * (m + s / 60);
placeHand(minute_hand, angle);
placeHand(minute_shadow, angle, minute_shadow_shift);
};
 
placeSecondHand = function(s){
var angle = 6 * s;
placeHand(second_hand, angle);
placeHand(second_shadow, angle, second_shadow_shift);
};
 
reflectTime = function(time, hold_second_hand, hold_minute_hand, hold_hour_hand){
if(!time) time = current_time;
var h = time.getHours();
var m = time.getMinutes();
var s = time.getSeconds();
if(!hold_hour_hand) placeHourHand(h, m, s);
if(!hold_minute_hand) placeMinuteHand(m, s);
if(!hold_second_hand) placeSecondHand(s);
text_time.innerHTML = dojo.date.locale.format(
time, {selector: "time", timePattern: "h:mm:ss a"});
};
 
resetTime = function(){
current_time = new Date();
reflectTime();
};
 
tick = function(){
current_time.setSeconds(current_time.getSeconds() + 1);
reflectTime();
};
 
advanceTime = function(){
if(!selected_hand) {
tick();
}
};
 
normalizeAngle = function(angle){
if(angle > Math.PI) {
angle -= 2 * Math.PI;
} else if(angle < -Math.PI) {
angle += 2 * Math.PI;
}
return angle;
};
 
calculateAngle = function(x, y, handAngle){
try {
return normalizeAngle(Math.atan2(y - center.y, x - center.x) - handAngle);
} catch(e) {
// supress
}
return 0;
};
 
getSecondAngle = function(time){
if(!time) time = current_time;
return (6 * time.getSeconds() - 90) / 180 * Math.PI;
};
 
getMinuteAngle = function(time){
if(!time) time = current_time;
return (6 * (time.getMinutes() + time.getSeconds() / 60) - 90) / 180 * Math.PI;
};
 
getHourAngle = function(time){
if(!time) time = current_time;
return (30 * (time.getHours() + (time.getMinutes() + time.getSeconds() / 60) / 60) - 90) / 180 * Math.PI;
};
 
onMouseDown = function(evt){
selected_hand = evt.target;
diff_time.setTime(current_time.getTime());
dojo.stopEvent(evt);
};
 
onMouseMove = function(evt){
if(!selected_hand) return;
if(evt.target == second_hand.getEventSource() ||
evt.target == minute_hand.getEventSource() ||
evt.target == hour_hand.getEventSource()){
dojo.stopEvent(evt);
return;
}
if(dojox.gfx.equalSources(selected_hand, second_hand.getEventSource())){
var angle = calculateAngle(
evt.clientX - container_position.x,
evt.clientY - container_position.y,
normalizeAngle(getSecondAngle())
);
var diff = Math.round(angle / Math.PI * 180 / 6); // in whole seconds
current_time.setSeconds(current_time.getSeconds() + Math.round(diff));
reflectTime();
}else if(dojox.gfx.equalSources(selected_hand, minute_hand.getEventSource())){
var angle = calculateAngle(
evt.clientX - container_position.x,
evt.clientY - container_position.y,
normalizeAngle(getMinuteAngle(diff_time))
);
var diff = Math.round(angle / Math.PI * 180 / 6 * 60); // in whole seconds
diff_time.setTime(diff_time.getTime() + 1000 * diff);
reflectTime(diff_time, true);
}else if(dojox.gfx.equalSources(selected_hand, hour_hand.getEventSource())){
var angle = calculateAngle(
evt.clientX - container_position.x,
evt.clientY - container_position.y,
normalizeAngle(getHourAngle(diff_time))
);
var diff = Math.round(angle / Math.PI * 180 / 30 * 60 * 60); // in whole seconds
diff_time.setTime(diff_time.getTime() + 1000 * diff);
reflectTime(diff_time, true, true);
}else{
return;
}
dojo.stopEvent(evt);
};
 
onMouseUp = function(evt){
if(selected_hand && !dojox.gfx.equalSources(selected_hand, second_hand.getEventSource())){
current_time.setTime(diff_time.getTime());
reflectTime();
}
selected_hand = null;
dojo.stopEvent(evt);
};
 
makeShapes = function(){
// prerequisites
container = dojo.byId("gfx_holder");
container_position = dojo.coords(container, true);
text_time = dojo.byId("time");
var surface = dojox.gfx.createSurface(container, 385, 385);
surface.createImage({width: 385, height: 385, src: "images/clock_face_black.jpg"});
// hand shapes
var hour_hand_points = [{x: -7, y: 15}, {x: 7, y: 15}, {x: 0, y: -60}, {x: -7, y: 15}];
var minute_hand_points = [{x: -5, y: 15}, {x: 5, y: 15}, {x: 0, y: -100}, {x: -5, y: 15}];
var second_hand_points = [{x: -2, y: 15}, {x: 2, y: 15}, {x: 2, y: -105}, {x: 6, y: -105}, {x: 0, y: -116}, {x: -6, y: -105}, {x: -2, y: -105}, {x: -2, y: 15}];
// create shapes
hour_shadow = surface.createPolyline(hour_hand_points)
.setFill([0, 0, 0, 0.1])
;
hour_hand = surface.createPolyline(hour_hand_points)
.setStroke({color: "black", width: 2})
.setFill("#889")
;
minute_shadow = surface.createPolyline(minute_hand_points)
.setFill([0, 0, 0, 0.1])
;
minute_hand = surface.createPolyline(minute_hand_points)
.setStroke({color: "black", width: 2})
.setFill("#ccd")
;
second_shadow = surface.createPolyline(second_hand_points)
.setFill([0, 0, 0, 0.1])
;
second_hand = surface.createPolyline(second_hand_points)
.setStroke({color: "#800", width: 1})
.setFill("#d00")
;
 
// next 3 lines kill Silverlight because its nodes do not support CSS
//dojox.gfx._addClass(hour_hand .getEventSource(), "movable");
//dojox.gfx._addClass(minute_hand.getEventSource(), "movable");
//dojox.gfx._addClass(second_hand.getEventSource(), "movable");
surface.createCircle({r: 1}).setFill("black").setTransform({dx: 192.5, dy: 192.5});
// attach events
hour_hand .connect("onmousedown", onMouseDown);
minute_hand.connect("onmousedown", onMouseDown);
second_hand.connect("onmousedown", onMouseDown);
dojo.connect(container, "onmousemove", onMouseMove);
dojo.connect(container, "onmouseup", onMouseUp);
dojo.connect(dojo.byId("reset"), "onclick", resetTime);
 
// start the clock
resetTime();
window.setInterval(advanceTime, 1000);
};
 
dojo.addOnLoad(makeShapes);
 
</script>
<style type="text/css">
.movable { cursor: hand; }
</style>
</head>
<body>
<h1>dojox.gfx: interactive analog clock</h1>
<p>Grab hands and set your own time.</p>
<p>Warning: Canvas renderer doesn't implement event handling.</p>
<div id="gfx_holder" style="width: 385px; height: 385px;"></div>
<p>Current time: <span id="time"></span>.</p>
<p><button id="reset">Reset</button></p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/demos/beautify.html
New file
0,0 → 1,48
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Beautify JSON</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
 
trimPath = function(o){
if(o instanceof Array){
for(var i = 0; i < o.length; ++i){
trimPath(o[i]);
}
return;
}
if(("shape" in o) && ("path" in o.shape)){
o.shape.path = dojo.trim(o.shape.path.replace(/\s\s+/g, " "));
}
if("children" in o){
trimPath(o.children);
}
};
 
beautify = function(){
var t = dojo.byId("io");
var v = dojo.fromJson(t.value);
if(dojo.byId("path").checked){
trimPath(v);
}
t.value = dojo.toJson(v, dojo.byId("pprint").checked);
};
 
</script>
</head>
<body>
<h1>Beautify JSON</h1>
<p>Paste valid JSON in this textarea and receive a pretty-printed version of it. Use Firefox, if you want to be able to read comma-ended sequences (Python style).
Additionally it knows how to remove extra spaces from path elements.</p>
<p><textarea id="io" cols="80" rows="10" wrap="off"></textarea></p>
<p><button onclick="beautify()">Beautify!</button>
&nbsp;&nbsp;&nbsp;<input type="checkbox" id="path" checked="checked" />&nbsp;Process "path" elements
&nbsp;&nbsp;&nbsp;<input type="checkbox" id="pprint" checked="checked" />&nbsp;Pretty-print JSON</p>
<p><em>This program is a companion for inspector.html.</em></p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/gfx/path.js
New file
0,0 → 1,353
if(!dojo._hasResource["dojox.gfx.path"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.path"] = true;
dojo.provide("dojox.gfx.path");
 
dojo.require("dojox.gfx.shape");
 
dojo.declare("dojox.gfx.path.Path", dojox.gfx.Shape, {
// summary: a generalized path shape
constructor: function(rawNode){
// summary: a path constructor
// rawNode: Node: a DOM node to be used by this path object
this.shape = dojo.clone(dojox.gfx.defaultPath);
this.segments = [];
this.absolute = true;
this.last = {};
this.rawNode = rawNode;
},
// mode manipulations
setAbsoluteMode: function(mode){
// summary: sets an absolute or relative mode for path points
// mode: Boolean: true/false or "absolute"/"relative" to specify the mode
this.absolute = typeof mode == "string" ? (mode == "absolute") : mode;
return this; // self
},
getAbsoluteMode: function(){
// summary: returns a current value of the absolute mode
return this.absolute; // Boolean
},
getBoundingBox: function(){
// summary: returns the bounding box {x, y, width, height} or null
return (this.bbox && ("l" in this.bbox)) ? {x: this.bbox.l, y: this.bbox.t, width: this.bbox.r - this.bbox.l, height: this.bbox.b - this.bbox.t} : null; // dojox.gfx.Rectangle
},
getLastPosition: function(){
// summary: returns the last point in the path, or null
return "x" in this.last ? this.last : null; // Object
},
// segment interpretation
_updateBBox: function(x, y){
// summary: updates the bounding box of path with new point
// x: Number: an x coordinate
// y: Number: a y coordinate
// we use {l, b, r, t} representation of a bbox
if(this.bbox && ("l" in this.bbox)){
if(this.bbox.l > x) this.bbox.l = x;
if(this.bbox.r < x) this.bbox.r = x;
if(this.bbox.t > y) this.bbox.t = y;
if(this.bbox.b < y) this.bbox.b = y;
}else{
this.bbox = {l: x, b: y, r: x, t: y};
}
},
_updateWithSegment: function(segment){
// summary: updates the bounding box of path with new segment
// segment: Object: a segment
var n = segment.args, l = n.length;
// update internal variables: bbox, absolute, last
switch(segment.action){
case "M":
case "L":
case "C":
case "S":
case "Q":
case "T":
for(var i = 0; i < l; i += 2){
this._updateBBox(n[i], n[i + 1]);
}
this.last.x = n[l - 2];
this.last.y = n[l - 1];
this.absolute = true;
break;
case "H":
for(var i = 0; i < l; ++i){
this._updateBBox(n[i], this.last.y);
}
this.last.x = n[l - 1];
this.absolute = true;
break;
case "V":
for(var i = 0; i < l; ++i){
this._updateBBox(this.last.x, n[i]);
}
this.last.y = n[l - 1];
this.absolute = true;
break;
case "m":
var start = 0;
if(!("x" in this.last)){
this._updateBBox(this.last.x = n[0], this.last.y = n[1]);
start = 2;
}
for(var i = start; i < l; i += 2){
this._updateBBox(this.last.x += n[i], this.last.y += n[i + 1]);
}
this.absolute = false;
break;
case "l":
case "t":
for(var i = 0; i < l; i += 2){
this._updateBBox(this.last.x += n[i], this.last.y += n[i + 1]);
}
this.absolute = false;
break;
case "h":
for(var i = 0; i < l; ++i){
this._updateBBox(this.last.x += n[i], this.last.y);
}
this.absolute = false;
break;
case "v":
for(var i = 0; i < l; ++i){
this._updateBBox(this.last.x, this.last.y += n[i]);
}
this.absolute = false;
break;
case "c":
for(var i = 0; i < l; i += 6){
this._updateBBox(this.last.x + n[i], this.last.y + n[i + 1]);
this._updateBBox(this.last.x + n[i + 2], this.last.y + n[i + 3]);
this._updateBBox(this.last.x += n[i + 4], this.last.y += n[i + 5]);
}
this.absolute = false;
break;
case "s":
case "q":
for(var i = 0; i < l; i += 4){
this._updateBBox(this.last.x + n[i], this.last.y + n[i + 1]);
this._updateBBox(this.last.x += n[i + 2], this.last.y += n[i + 3]);
}
this.absolute = false;
break;
case "A":
for(var i = 0; i < l; i += 7){
this._updateBBox(n[i + 5], n[i + 6]);
}
this.last.x = n[l - 2];
this.last.y = n[l - 1];
this.absolute = true;
break;
case "a":
for(var i = 0; i < l; i += 7){
this._updateBBox(this.last.x += n[i + 5], this.last.y += n[i + 6]);
}
this.absolute = false;
break;
}
// add an SVG path segment
var path = [segment.action];
for(var i = 0; i < l; ++i){
path.push(dojox.gfx.formatNumber(n[i], true));
}
if(typeof this.shape.path == "string"){
this.shape.path += path.join("");
}else{
var l = path.length, a = this.shape.path;
for(var i = 0; i < l; ++i){
a.push(path[i]);
}
}
},
// a dictionary, which maps segment type codes to a number of their argemnts
_validSegments: {m: 2, l: 2, h: 1, v: 1, c: 6, s: 4, q: 4, t: 2, a: 7, z: 0},
_pushSegment: function(action, args){
// summary: adds a segment
// action: String: valid SVG code for a segment's type
// args: Array: a list of parameters for this segment
var group = this._validSegments[action.toLowerCase()];
if(typeof group == "number"){
if(group){
if(args.length >= group){
var segment = {action: action, args: args.slice(0, args.length - args.length % group)};
this.segments.push(segment);
this._updateWithSegment(segment);
}
}else{
var segment = {action: action, args: []};
this.segments.push(segment);
this._updateWithSegment(segment);
}
}
},
_collectArgs: function(array, args){
// summary: converts an array of arguments to plain numeric values
// array: Array: an output argument (array of numbers)
// args: Array: an input argument (can be values of Boolean, Number, dojox.gfx.Point, or an embedded array of them)
for(var i = 0; i < args.length; ++i){
var t = args[i];
if(typeof t == "boolean"){
array.push(t ? 1 : 0);
}else if(typeof t == "number"){
array.push(t);
}else if(t instanceof Array){
this._collectArgs(array, t);
}else if("x" in t && "y" in t){
array.push(t.x, t.y);
}
}
},
 
// segments
moveTo: function(){
// summary: formes a move segment
var args = [];
this._collectArgs(args, arguments);
this._pushSegment(this.absolute ? "M" : "m", args);
return this; // self
},
lineTo: function(){
// summary: formes a line segment
var args = [];
this._collectArgs(args, arguments);
this._pushSegment(this.absolute ? "L" : "l", args);
return this; // self
},
hLineTo: function(){
// summary: formes a horizontal line segment
var args = [];
this._collectArgs(args, arguments);
this._pushSegment(this.absolute ? "H" : "h", args);
return this; // self
},
vLineTo: function(){
// summary: formes a vertical line segment
var args = [];
this._collectArgs(args, arguments);
this._pushSegment(this.absolute ? "V" : "v", args);
return this; // self
},
curveTo: function(){
// summary: formes a curve segment
var args = [];
this._collectArgs(args, arguments);
this._pushSegment(this.absolute ? "C" : "c", args);
return this; // self
},
smoothCurveTo: function(){
// summary: formes a smooth curve segment
var args = [];
this._collectArgs(args, arguments);
this._pushSegment(this.absolute ? "S" : "s", args);
return this; // self
},
qCurveTo: function(){
// summary: formes a quadratic curve segment
var args = [];
this._collectArgs(args, arguments);
this._pushSegment(this.absolute ? "Q" : "q", args);
return this; // self
},
qSmoothCurveTo: function(){
// summary: formes a quadratic smooth curve segment
var args = [];
this._collectArgs(args, arguments);
this._pushSegment(this.absolute ? "T" : "t", args);
return this; // self
},
arcTo: function(){
// summary: formes an elliptic arc segment
var args = [];
this._collectArgs(args, arguments);
this._pushSegment(this.absolute ? "A" : "a", args);
return this; // self
},
closePath: function(){
// summary: closes a path
this._pushSegment("Z", []);
return this; // self
},
// setShape
_setPath: function(path){
// summary: forms a path using an SVG path string
// path: String: an SVG path string
var p = dojo.isArray(path) ? path : path.match(dojox.gfx.pathSvgRegExp);
this.segments = [];
this.absolute = true;
this.bbox = {};
this.last = {};
if(!p) return;
// create segments
var action = "", // current action
args = [], // current arguments
l = p.length;
for(var i = 0; i < l; ++i){
var t = p[i], x = parseFloat(t);
if(isNaN(x)){
if(action){
this._pushSegment(action, args);
}
args = [];
action = t;
}else{
args.push(x);
}
}
this._pushSegment(action, args);
},
setShape: function(newShape){
// summary: forms a path using a shape
// newShape: Object: an SVG path string or a path object (see dojox.gfx.defaultPath)
dojox.gfx.Shape.prototype.setShape.call(this, typeof newShape == "string" ? {path: newShape} : newShape);
var path = this.shape.path;
// switch to non-updating version of path building
this.shape.path = [];
this._setPath(path);
// switch back to the string path
this.shape.path = this.shape.path.join("");
return this; // self
},
// useful constant for descendants
_2PI: Math.PI * 2
});
 
dojo.declare("dojox.gfx.path.TextPath", dojox.gfx.path.Path, {
// summary: a generalized TextPath shape
 
constructor: function(rawNode){
// summary: a TextPath shape constructor
// rawNode: Node: a DOM node to be used by this TextPath object
if(!("text" in this)){
this.text = dojo.clone(dojox.gfx.defaultTextPath);
}
if(!("fontStyle" in this)){
this.fontStyle = dojo.clone(dojox.gfx.defaultFont);
}
},
setText: function(newText){
// summary: sets a text to be drawn along the path
this.text = dojox.gfx.makeParameters(this.text,
typeof newText == "string" ? {text: newText} : newText);
this._setText();
return this; // self
},
setFont: function(newFont){
// summary: sets a font for text
this.fontStyle = typeof newFont == "string" ?
dojox.gfx.splitFontString(newFont) :
dojox.gfx.makeParameters(dojox.gfx.defaultFont, newFont);
this._setFont();
return this; // self
}
});
 
}
/trunk/api/js/dojo1.0/dojox/gfx/silverlight.js
New file
0,0 → 1,693
if(!dojo._hasResource["dojox.gfx.silverlight"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.silverlight"] = true;
dojo.provide("dojox.gfx.silverlight");
 
dojo.require("dojox.gfx._base");
dojo.require("dojox.gfx.shape");
dojo.require("dojox.gfx.path");
 
dojo.experimental("dojox.gfx.silverlight");
 
dojox.gfx.silverlight.dasharray = {
solid: "none",
shortdash: [4, 1],
shortdot: [1, 1],
shortdashdot: [4, 1, 1, 1],
shortdashdotdot: [4, 1, 1, 1, 1, 1],
dot: [1, 3],
dash: [4, 3],
longdash: [8, 3],
dashdot: [4, 3, 1, 3],
longdashdot: [8, 3, 1, 3],
longdashdotdot: [8, 3, 1, 3, 1, 3]
};
 
dojox.gfx.silverlight.fontweight = {
normal: 400,
bold: 700
};
 
dojox.gfx.silverlight.caps = {butt: "Flat", round: "Round", square: "Square"};
dojox.gfx.silverlight.joins = {bevel: "Bevel", round: "Round"};
 
dojox.gfx.silverlight.fonts = {
serif: "Times New Roman",
times: "Times New Roman",
"sans-serif": "Arial",
helvetica: "Arial",
monotone: "Courier New",
courier: "Courier New"
};
 
dojox.gfx.silverlight.hexColor = function(/*String|Array|dojo.Color*/ color){
// summary: converts a color object to a Silverlight hex color string (#aarrggbb)
var c = dojox.gfx.normalizeColor(color),
t = c.toHex(), a = Math.round(c.a * 255);
a = (a < 0 ? 0 : a > 255 ? 255 : a).toString(16);
return "#" + (a.length < 2 ? "0" + a : a) + t.slice(1); // String
};
 
dojo.extend(dojox.gfx.Shape, {
// summary: Silverlight-specific implementation of dojox.gfx.Shape methods
setFill: function(fill){
// summary: sets a fill object (Silverlight)
// fill: Object: a fill object
// (see dojox.gfx.defaultLinearGradient,
// dojox.gfx.defaultRadialGradient,
// dojox.gfx.defaultPattern,
// or dojo.Color)
 
var p = this.rawNode.getHost().content, r = this.rawNode, f;
if(!fill){
// don't fill
this.fillStyle = null;
this._setFillAttr(null);
return this; // self
}
if(typeof(fill) == "object" && "type" in fill){
// gradient
switch(fill.type){
case "linear":
this.fillStyle = f = dojox.gfx.makeParameters(dojox.gfx.defaultLinearGradient, fill);
var lgb = p.createFromXaml("<LinearGradientBrush/>");
lgb.mappingMode = "Absolute";
lgb.startPoint = f.x1 + "," + f.y1;
lgb.endPoint = f.x2 + "," + f.y2;
dojo.forEach(f.colors, function(c){
var t = p.createFromXaml("<GradientStop/>");
t.offset = c.offset;
t.color = dojox.gfx.silverlight.hexColor(c.color);
lgb.gradientStops.add(t);
});
this._setFillAttr(lgb);
break;
case "radial":
this.fillStyle = f = dojox.gfx.makeParameters(dojox.gfx.defaultRadialGradient, fill);
var rgb = p.createFromXaml("<RadialGradientBrush/>"), w = r.width, h = r.height,
l = this.rawNode["Canvas.Left"], t = this.rawNode["Canvas.Top"];
rgb.center = (f.cx - l) / w + "," + (f.cy - t) / h;
rgb.radiusX = f.r / w;
rgb.radiusY = f.r / h;
dojo.forEach(f.colors, function(c){
var t = p.createFromXaml("<GradientStop/>");
t.offset = c.offset;
t.color = dojox.gfx.silverlight.hexColor(c.color);
rgb.gradientStops.add(t);
});
this._setFillAttr(rgb);
break;
case "pattern":
// don't fill: Silverlight doesn't define TileBrush for some reason
this.fillStyle = null;
this._setFillAttr(null);
break;
}
return this; // self
}
// color object
this.fillStyle = f = dojox.gfx.normalizeColor(fill);
var scb = p.createFromXaml("<SolidColorBrush/>");
scb.color = f.toHex();
scb.opacity = f.a;
this._setFillAttr(scb);
return this; // self
},
_setFillAttr: function(f){
this.rawNode.fill = f;
},
 
setStroke: function(stroke){
// summary: sets a stroke object (Silverlight)
// stroke: Object: a stroke object
// (see dojox.gfx.defaultStroke)
var p = this.rawNode.getHost().content, r = this.rawNode;
if(!stroke){
// don't stroke
this.strokeStyle = null;
r.stroke = null;
return this;
}
// normalize the stroke
if(typeof stroke == "string"){
stroke = {color: stroke};
}
var s = this.strokeStyle = dojox.gfx.makeParameters(dojox.gfx.defaultStroke, stroke);
s.color = dojox.gfx.normalizeColor(s.color);
// generate attributes
if(s){
var scb = p.createFromXaml("<SolidColorBrush/>");
scb.color = s.color.toHex();
scb.opacity = s.color.a;
r.stroke = scb;
r.strokeThickness = s.width;
r.strokeStartLineCap = r.strokeEndLineCap = r.strokeDashCap =
dojox.gfx.silverlight.caps[s.cap];
if(typeof s.join == "number"){
r.strokeLineJoin = "Miter";
r.strokeMiterLimit = s.join;
}else{
r.strokeLineJoin = dojox.gfx.silverlight.joins[s.join];
}
var da = s.style.toLowerCase();
if(da in dojox.gfx.silverlight.dasharray){ da = dojox.gfx.silverlight.dasharray[da]; }
if(da instanceof Array){
da = dojo.clone(da);
/*
for(var i = 0; i < da.length; ++i){
da[i] *= s.width;
}
*/
if(s.cap != "butt"){
for(var i = 0; i < da.length; i += 2){
//da[i] -= s.width;
--da[i]
if(da[i] < 1){ da[i] = 1; }
}
for(var i = 1; i < da.length; i += 2){
//da[i] += s.width;
++da[i];
}
}
r.strokeDashArray = da.join(",");
}else{
r.strokeDashArray = null;
}
}
return this; // self
},
_getParentSurface: function(){
var surface = this.parent;
for(; surface && !(surface instanceof dojox.gfx.Surface); surface = surface.parent);
return surface;
},
_applyTransform: function() {
var tm = this.matrix, r = this.rawNode;
if(tm){
var p = this.rawNode.getHost().content,
m = p.createFromXaml("<MatrixTransform/>"),
mm = p.createFromXaml("<Matrix/>");
mm.m11 = tm.xx;
mm.m21 = tm.xy;
mm.m12 = tm.yx;
mm.m22 = tm.yy;
mm.offsetX = tm.dx;
mm.offsetY = tm.dy;
m.matrix = mm;
r.renderTransform = m;
}else{
r.renderTransform = null;
}
return this;
},
 
setRawNode: function(rawNode){
// summary:
// assigns and clears the underlying node that will represent this
// shape. Once set, transforms, gradients, etc, can be applied.
// (no fill & stroke by default)
rawNode.fill = null;
rawNode.stroke = null;
this.rawNode = rawNode;
},
// move family
 
_moveToFront: function(){
// summary: moves a shape to front of its parent's list of shapes (Silverlight)
var c = this.parent.rawNode.children, r = this.rawNode;
c.remove(r);
c.add(r);
return this; // self
},
_moveToBack: function(){
// summary: moves a shape to back of its parent's list of shapes (Silverlight)
var c = this.parent.rawNode.children, r = this.rawNode;
c.remove(r);
c.insert(0, r);
return this; // self
}
});
 
dojo.declare("dojox.gfx.Group", dojox.gfx.Shape, {
// summary: a group shape (Silverlight), which can be used
// to logically group shapes (e.g, to propagate matricies)
constructor: function(){
dojox.gfx.silverlight.Container._init.call(this);
},
setRawNode: function(rawNode){
// summary: sets a raw Silverlight node to be used by this shape
// rawNode: Node: an Silverlight node
this.rawNode = rawNode;
}
});
dojox.gfx.Group.nodeType = "Canvas";
 
dojo.declare("dojox.gfx.Rect", dojox.gfx.shape.Rect, {
// summary: a rectangle shape (Silverlight)
setShape: function(newShape){
// summary: sets a rectangle shape object (Silverlight)
// newShape: Object: a rectangle shape object
this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var r = this.rawNode, n = this.shape;
r["Canvas.Left"] = n.x;
r["Canvas.Top"] = n.y;
r.width = n.width;
r.height = n.height;
r.radiusX = r.radiusY = n.r;
return this; // self
}
});
dojox.gfx.Rect.nodeType = "Rectangle";
 
dojo.declare("dojox.gfx.Ellipse", dojox.gfx.shape.Ellipse, {
// summary: an ellipse shape (Silverlight)
setShape: function(newShape){
// summary: sets an ellipse shape object (Silverlight)
// newShape: Object: an ellipse shape object
this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var r = this.rawNode, n = this.shape;
r["Canvas.Left"] = n.cx - n.rx;
r["Canvas.Top"] = n.cy - n.ry;
r.width = 2 * n.rx;
r.height = 2 * n.ry;
return this; // self
}
});
dojox.gfx.Ellipse.nodeType = "Ellipse";
 
dojo.declare("dojox.gfx.Circle", dojox.gfx.shape.Circle, {
// summary: a circle shape (Silverlight)
setShape: function(newShape){
// summary: sets a circle shape object (Silverlight)
// newShape: Object: a circle shape object
this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var r = this.rawNode, n = this.shape;
r["Canvas.Left"] = n.cx - n.r;
r["Canvas.Top"] = n.cy - n.r;
r.width = r.height = 2 * n.r;
return this; // self
}
});
dojox.gfx.Circle.nodeType = "Ellipse";
 
dojo.declare("dojox.gfx.Line", dojox.gfx.shape.Line, {
// summary: a line shape (Silverlight)
setShape: function(newShape){
// summary: sets a line shape object (Silverlight)
// newShape: Object: a line shape object
this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var r = this.rawNode, n = this.shape;
r.x1 = n.x1; r.y1 = n.y1; r.x2 = n.x2; r.y2 = n.y2;
return this; // self
}
});
dojox.gfx.Line.nodeType = "Line";
 
dojo.declare("dojox.gfx.Polyline", dojox.gfx.shape.Polyline, {
// summary: a polyline/polygon shape (Silverlight)
setShape: function(points, closed){
// summary: sets a polyline/polygon shape object (Silverlight)
// points: Object: a polyline/polygon shape object
if(points && points instanceof Array){
// branch
// points: Array: an array of points
this.shape = dojox.gfx.makeParameters(this.shape, {points: points});
if(closed && this.shape.points.length){
this.shape.points.push(this.shape.points[0]);
}
}else{
this.shape = dojox.gfx.makeParameters(this.shape, points);
}
this.box = null;
var p = this.shape.points, rp = [];
for(var i = 0; i < p.length; ++i){
if(typeof p[i] == "number"){
rp.push(p[i], p[++i]);
}else{
rp.push(p[i].x, p[i].y);
}
}
this.rawNode.points = rp.join(",");
return this; // self
}
});
dojox.gfx.Polyline.nodeType = "Polyline";
 
dojo.declare("dojox.gfx.Image", dojox.gfx.shape.Image, {
// summary: an image (Silverlight)
setShape: function(newShape){
// summary: sets an image shape object (Silverlight)
// newShape: Object: an image shape object
this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var r = this.rawNode, n = this.shape;
r["Canvas.Left"] = n.x;
r["Canvas.Top"] = n.y;
r.width = n.width;
r.height = n.height;
r.source = n.src;
return this; // self
},
setRawNode: function(rawNode){
// summary:
// assigns and clears the underlying node that will represent this
// shape. Once set, transforms, gradients, etc, can be applied.
// (no fill & stroke by default)
this.rawNode = rawNode;
}
});
dojox.gfx.Image.nodeType = "Image";
 
dojo.declare("dojox.gfx.Text", dojox.gfx.shape.Text, {
// summary: an anchored text (Silverlight)
setShape: function(newShape){
// summary: sets a text shape object (Silverlight)
// newShape: Object: a text shape object
this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var r = this.rawNode, s = this.shape;
r.text = s.text;
r.textDecorations = s.decoration == "underline" ? "Underline" : "None";
r["Canvas.Left"] = -10000;
r["Canvas.Top"] = -10000;
window.setTimeout(dojo.hitch(this, "_delayAlignment"), 0);
return this; // self
},
_delayAlignment: function(){
// handle alignment
var r = this.rawNode, s = this.shape,
w = r.actualWidth, h = r.actualHeight, x = s.x, y = s.y - h * 0.75;
switch(s.align){
case "middle":
x -= w / 2;
break;
case "end":
x -= w;
break;
}
var a = this.matrix ? dojox.gfx.matrix.multiplyPoint(this.matrix, x, y) : {x: x, y: y};
r["Canvas.Left"] = a.x;
r["Canvas.Top"] = a.y;
},
setStroke: function(){
// summary: ignore setting a stroke style
return this; // self
},
_setFillAttr: function(f){
this.rawNode.foreground = f;
},
setRawNode: function(rawNode){
// summary:
// assigns and clears the underlying node that will represent this
// shape. Once set, transforms, gradients, etc, can be applied.
// (no fill & stroke by default)
this.rawNode = rawNode;
},
_applyTransform: function() {
var tm = this.matrix, r = this.rawNode;
if(tm){
// the next line is pure magic :-(
tm = dojox.gfx.matrix.normalize([1/100, tm, 100]);
var p = this.rawNode.getHost().content,
m = p.createFromXaml("<MatrixTransform/>"),
mm = p.createFromXaml("<Matrix/>");
mm.m11 = tm.xx;
mm.m21 = tm.xy;
mm.m12 = tm.yx;
mm.m22 = tm.yy;
mm.offsetX = tm.dx;
mm.offsetY = tm.dy;
m.matrix = mm;
r.renderTransform = m;
}else{
r.renderTransform = null;
}
return this;
},
getTextWidth: function(){
// summary: get the text width in pixels
return this.rawNode.actualWidth;
}
});
dojox.gfx.Text.nodeType = "TextBlock";
 
dojo.declare("dojox.gfx.Path", dojox.gfx.path.Path, {
// summary: a path shape (Silverlight)
_updateWithSegment: function(segment){
// summary: updates the bounding box of path with new segment
// segment: Object: a segment
dojox.gfx.Path.superclass._updateWithSegment.apply(this, arguments);
var p = this.shape.path;
if(typeof(p) == "string"){
this.rawNode.data = p ? p : null;
}
},
setShape: function(newShape){
// summary: forms a path using a shape (Silverlight)
// newShape: Object: an SVG path string or a path object (see dojox.gfx.defaultPath)
dojox.gfx.Path.superclass.setShape.apply(this, arguments);
var p = this.shape.path;
this.rawNode.data = p ? p : null;
return this; // self
}
});
dojox.gfx.Path.nodeType = "Path";
 
dojo.declare("dojox.gfx.TextPath", dojox.gfx.path.TextPath, {
// summary: a textpath shape (Silverlight)
_updateWithSegment: function(segment){
// summary: updates the bounding box of path with new segment
// segment: Object: a segment
},
setShape: function(newShape){
// summary: forms a path using a shape (Silverlight)
// newShape: Object: an SVG path string or a path object (see dojox.gfx.defaultPath)
},
_setText: function(){
}
});
dojox.gfx.TextPath.nodeType = "text";
 
dojo.declare("dojox.gfx.Surface", dojox.gfx.shape.Surface, {
// summary: a surface object to be used for drawings (Silverlight)
constructor: function(){
dojox.gfx.silverlight.Container._init.call(this);
},
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"
this.width = dojox.gfx.normalizedLength(width); // in pixels
this.height = dojox.gfx.normalizedLength(height); // in pixels
var p = this.rawNode && this.rawNode.getHost();
if(p){
p.width = width;
p.height = height;
}
return this; // self
},
getDimensions: function(){
// summary: returns an object with properties "width" and "height"
var p = this.rawNode && this.rawNode.getHost();
var t = p ? {width: p.content.actualWidth, height: p.content.actualHeight} : null;
if(t.width <= 0){ t.width = this.width; }
if(t.height <= 0){ t.height = this.height; }
return t; // Object
}
});
 
dojox.gfx.silverlight.surfaces = {};
 
dojox.gfx.createSurface = function(parentNode, width, height){
// summary: creates a surface (Silverlight)
// parentNode: Node: a parent node
// width: String: width of surface, e.g., "100px"
// height: String: height of surface, e.g., "100px"
 
var s = new dojox.gfx.Surface();
parentNode = dojo.byId(parentNode);
// create an empty canvas
var t = parentNode.ownerDocument.createElement("script");
t.type = "text/xaml";
t.id = dojox.gfx._base._getUniqueId();
t.text = "<Canvas xmlns='http://schemas.microsoft.com/client/2007' Name='" + dojox.gfx._base._getUniqueId() + "'/>";
document.body.appendChild(t);
// create a plugin
var pluginName = dojox.gfx._base._getUniqueId();
Silverlight.createObject(
"#" + t.id, // none
parentNode,
pluginName,
{ // Plugin properties.
width: String(width), // Width of rectangular region of plugin in pixels.
height: String(height), // Height of rectangular region of plugin in pixels.
inplaceInstallPrompt: "false", // Determines whether to display in-place install prompt if invalid version detected.
//background: "white", // Background color of plugin.
//isWindowless: "false", // Determines whether to display plugin in Windowless mode.
background: "transparent", // Background color of plugin.
isWindowless: "true", // Determines whether to display plugin in Windowless mode.
framerate: "24", // MaxFrameRate property value.
version: "1.0" // Silverlight version.
},
{},
null,
null
);
s.rawNode = dojo.byId(pluginName).content.root;
// register the plugin with its parent node
dojox.gfx.silverlight.surfaces[s.rawNode.name] = parentNode;
s.width = dojox.gfx.normalizedLength(width); // in pixels
s.height = dojox.gfx.normalizedLength(height); // in pixels
return s; // dojox.gfx.Surface
};
 
// Extenders
 
dojox.gfx.silverlight.Font = {
_setFont: function(){
// summary: sets a font object (Silverlight)
var f = this.fontStyle, r = this.rawNode,
fw = dojox.gfx.silverlight.fontweight,
fo = dojox.gfx.silverlight.fonts, t = f.family.toLowerCase();
r.fontStyle = f.style == "italic" ? "Italic" : "Normal";
r.fontWeight = f.weight in fw ? fw[f.weight] : f.weight;
r.fontSize = dojox.gfx.normalizedLength(f.size);
r.fontFamily = t in fo ? fo[t] : f.family;
}
};
 
dojox.gfx.silverlight.Container = {
_init: function(){
dojox.gfx.shape.Container._init.call(this);
},
add: function(shape){
// summary: adds a shape to a group/surface
// shape: dojox.gfx.Shape: an VML shape object
if(this != shape.getParent()){
//dojox.gfx.Group.superclass.add.apply(this, arguments);
//this.inherited(arguments);
dojox.gfx.shape.Container.add.apply(this, arguments);
this.rawNode.children.add(shape.rawNode);
}
return this; // self
},
remove: function(shape, silently){
// summary: remove a shape from a group/surface
// shape: dojox.gfx.Shape: an VML shape object
// silently: Boolean?: if true, regenerate a picture
if(this == shape.getParent()){
var parent = shape.rawNode.getParent();
if(parent){
parent.children.remove(shape.rawNode);
}
//dojox.gfx.Group.superclass.remove.apply(this, arguments);
//this.inherited(arguments);
dojox.gfx.shape.Container.remove.apply(this, arguments);
}
return this; // self
},
clear: function(){
// summary: removes all shapes from a group/surface
this.rawNode.children.clear();
//return this.inherited(arguments); // self
return dojox.gfx.shape.Container.clear.apply(this, arguments);
},
_moveChildToFront: dojox.gfx.shape.Container._moveChildToFront,
_moveChildToBack: dojox.gfx.shape.Container._moveChildToBack
};
 
dojo.mixin(dojox.gfx.shape.Creator, {
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
if(!this.rawNode){ return null; }
var shape = new shapeType();
var node = this.rawNode.getHost().content.createFromXaml("<" + shapeType.nodeType + "/>");
shape.setRawNode(node);
shape.setShape(rawShape);
this.add(shape);
return shape; // dojox.gfx.Shape
}
});
 
dojo.extend(dojox.gfx.Text, dojox.gfx.silverlight.Font);
//dojo.extend(dojox.gfx.TextPath, dojox.gfx.silverlight.Font);
 
dojo.extend(dojox.gfx.Group, dojox.gfx.silverlight.Container);
dojo.extend(dojox.gfx.Group, dojox.gfx.shape.Creator);
 
dojo.extend(dojox.gfx.Surface, dojox.gfx.silverlight.Container);
dojo.extend(dojox.gfx.Surface, dojox.gfx.shape.Creator);
 
(function(){
var surfaces = dojox.gfx.silverlight.surfaces;
var mouseFix = function(s, a){
var ev = {target: s, currentTarget: s,
preventDefault: function(){}, stopPropagation: function(){}};
if(a){
ev.ctrlKey = a.ctrl;
ev.shiftKey = a.shift;
var p = a.getPosition(null);
ev.x = ev.offsetX = ev.layerX = p.x;
ev.y = ev.offsetY = ev.layerY = p.y;
// calculate clientX and clientY
var parent = surfaces[s.getHost().content.root.name];
var t = dojo._abs(parent);
ev.clientX = t.x + p.x;
ev.clientY = t.y + p.y;
}
return ev;
};
var keyFix = function(s, a){
var ev = {
keyCode: a.platformKeyCode,
ctrlKey: a.ctrl,
shiftKey: a.shift
};
return ev;
};
var eventNames = {
onclick: {name: "MouseLeftButtonUp", fix: mouseFix},
onmouseenter: {name: "MouseEnter", fix: mouseFix},
onmouseleave: {name: "MouseLeave", fix: mouseFix},
onmousedown: {name: "MouseLeftButtonDown", fix: mouseFix},
onmouseup: {name: "MouseLeftButtonUp", fix: mouseFix},
onmousemove: {name: "MouseMove", fix: mouseFix},
onkeydown: {name: "KeyDown", fix: keyFix},
onkeyup: {name: "KeyUp", fix: keyFix}
};
var eventsProcessing = {
connect: function(name, object, method){
var token, n = name in eventNames ? eventNames[name] :
{name: name, fix: function(){ return {}; }};
if(arguments.length > 2){
token = this.getEventSource().addEventListener(n.name,
function(s, a){ dojo.hitch(object, method)(n.fix(s, a)); });
}else{
token = this.getEventSource().addEventListener(n.name,
function(s, a){ object(n.fix(s, a)); });
}
return {name: n.name, token: token};
},
disconnect: function(token){
this.getEventSource().removeEventListener(token.name, token.token);
}
};
dojo.extend(dojox.gfx.Shape, eventsProcessing);
dojo.extend(dojox.gfx.Surface, eventsProcessing);
dojox.gfx.equalSources = function(a, b){
return a && b && a.equals(b);
}
 
})();
 
}
/trunk/api/js/dojo1.0/dojox/gfx/vml.js
New file
0,0 → 1,1128
if(!dojo._hasResource["dojox.gfx.vml"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.vml"] = true;
dojo.provide("dojox.gfx.vml");
 
dojo.require("dojox.gfx._base");
dojo.require("dojox.gfx.shape");
dojo.require("dojox.gfx.path");
dojo.require("dojox.gfx.arc");
 
// dojox.gfx.vml.xmlns: String: a VML's namespace
dojox.gfx.vml.xmlns = "urn:schemas-microsoft-com:vml";
 
// dojox.gfx.vml.text_alignment: Object: mapping from SVG alignment to VML alignment
dojox.gfx.vml.text_alignment = {start: "left", middle: "center", end: "right"};
 
dojox.gfx.vml._parseFloat = function(str) {
// summary: a helper function to parse VML-specific floating-point values
// str: String: a representation of a floating-point number
return str.match(/^\d+f$/i) ? parseInt(str) / 65536 : parseFloat(str); // Number
};
 
dojox.gfx.vml._bool = {"t": 1, "true": 1};
 
dojo.extend(dojox.gfx.Shape, {
// summary: VML-specific implementation of dojox.gfx.Shape methods
 
setFill: function(fill){
// summary: sets a fill object (VML)
// fill: Object: a fill object
// (see dojox.gfx.defaultLinearGradient,
// dojox.gfx.defaultRadialGradient,
// dojox.gfx.defaultPattern,
// or dojo.Color)
 
if(!fill){
// don't fill
this.fillStyle = null;
this.rawNode.filled = "f";
return this;
}
if(typeof fill == "object" && "type" in fill){
// gradient
switch(fill.type){
case "linear":
var f = dojox.gfx.makeParameters(dojox.gfx.defaultLinearGradient, fill),
s = [], a = f.colors, matrix = this._getRealMatrix(), m = dojox.gfx.matrix;
this.fillStyle = f;
dojo.forEach(a, function(v, i, a){
a[i].color = dojox.gfx.normalizeColor(v.color);
});
if(a[0].offset > 0){
s.push("0 " + a[0].color.toHex());
}
for(var i = 0; i < a.length; ++i){
s.push(a[i].offset.toFixed(8) + " " + a[i].color.toHex());
}
var i = a.length - 1;
if(a[i].offset < 1){
s.push("1 " + a[i].color.toHex());
}
var fo = this.rawNode.fill;
fo.colors.value = s.join(";");
fo.method = "sigma";
fo.type = "gradient";
var fc1 = matrix ? m.multiplyPoint(matrix, f.x1, f.y1) : {x: f.x1, y: f.y1},
fc2 = matrix ? m.multiplyPoint(matrix, f.x2, f.y2) : {x: f.x2, y: f.y2};
fo.angle = (m._radToDeg(Math.atan2(fc2.x - fc1.x, fc2.y - fc1.y)) + 180) % 360;
fo.on = true;
break;
case "radial":
var f = dojox.gfx.makeParameters(dojox.gfx.defaultRadialGradient, fill);
this.fillStyle = f;
var l = parseFloat(this.rawNode.style.left),
t = parseFloat(this.rawNode.style.top),
w = parseFloat(this.rawNode.style.width),
h = parseFloat(this.rawNode.style.height),
c = isNaN(w) ? 1 : 2 * f.r / w,
a = new Array(f.colors.length);
// massage colors
dojo.forEach(f.colors, function(v, i){
a[i] = {offset: 1 - v.offset * c, color: dojox.gfx.normalizeColor(v.color)};
});
var i = a.length - 1;
while(i >= 0 && a[i].offset < 0){ --i; }
if(i < a.length - 1){
// correct excessive colors
var q = a[i], p = a[i + 1];
p.color = dojo.blendColors(q.color, p.color, q.offset / (q.offset - p.offset));
p.offset = 0;
while(a.length - i > 2) a.pop();
}
// set colors
var i = a.length - 1, s = [];
if(a[i].offset > 0){
s.push("0 " + a[i].color.toHex());
}
for(; i >= 0; --i){
s.push(a[i].offset.toFixed(8) + " " + a[i].color.toHex());
}
if(a[0].offset < 1){
s.push("1 " + a[0].color.toHex());
}
var fo = this.rawNode.fill;
fo.colors.value = s.join(";");
fo.method = "sigma";
fo.type = "gradientradial";
if(isNaN(w) || isNaN(h) || isNaN(l) || isNaN(t)){
fo.focusposition = "0.5 0.5";
}else{
fo.focusposition = ((f.cx - l) / w).toFixed(8) + " " + ((f.cy - t) / h).toFixed(8);
}
fo.focussize = "0 0";
fo.on = true;
break;
case "pattern":
var f = dojox.gfx.makeParameters(dojox.gfx.defaultPattern, fill);
this.fillStyle = f;
var fo = this.rawNode.fill;
fo.type = "tile";
fo.src = f.src;
if(f.width && f.height){
// in points
fo.size.x = dojox.gfx.px2pt(f.width);
fo.size.y = dojox.gfx.px2pt(f.height);
}
fo.alignShape = "f";
fo.position.x = 0;
fo.position.y = 0;
fo.origin.x = f.width ? f.x / f.width : 0;
fo.origin.y = f.height ? f.y / f.height : 0;
fo.on = true;
break;
}
this.rawNode.fill.opacity = 1;
return this;
}
// color object
this.fillStyle = dojox.gfx.normalizeColor(fill);
this.rawNode.fillcolor = this.fillStyle.toHex();
this.rawNode.fill.opacity = this.fillStyle.a;
this.rawNode.filled = true;
return this; // self
},
 
setStroke: function(stroke){
// summary: sets a stroke object (VML)
// stroke: Object: a stroke object
// (see dojox.gfx.defaultStroke)
if(!stroke){
// don't stroke
this.strokeStyle = null;
this.rawNode.stroked = "f";
return this;
}
// normalize the stroke
if(typeof stroke == "string"){
stroke = {color: stroke};
}
var s = this.strokeStyle = dojox.gfx.makeParameters(dojox.gfx.defaultStroke, stroke);
s.color = dojox.gfx.normalizeColor(s.color);
// generate attributes
var rn = this.rawNode;
rn.stroked = true;
rn.strokecolor = s.color.toCss();
rn.strokeweight = s.width + "px"; // TODO: should we assume that the width is always in pixels?
if(rn.stroke) {
rn.stroke.opacity = s.color.a;
rn.stroke.endcap = this._translate(this._capMap, s.cap);
if(typeof s.join == "number") {
rn.stroke.joinstyle = "miter";
rn.stroke.miterlimit = s.join;
}else{
rn.stroke.joinstyle = s.join;
// rn.stroke.miterlimit = s.width;
}
rn.stroke.dashstyle = s.style == "none" ? "Solid" : s.style;
}
return this; // self
},
_capMap: { butt: 'flat' },
_capMapReversed: { flat: 'butt' },
_translate: function(dict, value) {
return (value in dict) ? dict[value] : value;
},
_applyTransform: function() {
if(this.fillStyle && this.fillStyle.type == "linear"){
this.setFill(this.fillStyle);
}
var matrix = this._getRealMatrix();
if(!matrix) return this;
var skew = this.rawNode.skew;
if(typeof skew == "undefined"){
for(var i = 0; i < this.rawNode.childNodes.length; ++i){
if(this.rawNode.childNodes[i].tagName == "skew"){
skew = this.rawNode.childNodes[i];
break;
}
}
}
if(skew){
skew.on = "f";
var mt = matrix.xx.toFixed(8) + " " + matrix.xy.toFixed(8) + " " +
matrix.yx.toFixed(8) + " " + matrix.yy.toFixed(8) + " 0 0",
offset = Math.floor(matrix.dx).toFixed() + "px " + Math.floor(matrix.dy).toFixed() + "px",
s = this.rawNode.style,
l = parseFloat(s.left),
t = parseFloat(s.top),
w = parseFloat(s.width),
h = parseFloat(s.height);
if(isNaN(l)) l = 0;
if(isNaN(t)) t = 0;
if(isNaN(w)) w = 1;
if(isNaN(h)) h = 1;
var origin = (-l / w - 0.5).toFixed(8) + " " + (-t / h - 0.5).toFixed(8);
skew.matrix = mt;
skew.origin = origin;
skew.offset = offset;
skew.on = true;
}
return this;
},
 
setRawNode: function(rawNode){
// summary:
// assigns and clears the underlying node that will represent this
// shape. Once set, transforms, gradients, etc, can be applied.
// (no fill & stroke by default)
rawNode.stroked = "f";
rawNode.filled = "f";
this.rawNode = rawNode;
},
// move family
 
_moveToFront: function(){
// summary: moves a shape to front of its parent's list of shapes (VML)
this.rawNode.parentNode.appendChild(this.rawNode);
return this;
},
_moveToBack: function(){
// summary: moves a shape to back of its parent's list of shapes (VML)
var r = this.rawNode, p = r.parentNode, n = p.firstChild;
p.insertBefore(r, n);
if(n.tagName == "rect"){
// surface has a background rectangle, which position should be preserved
n.swapNode(r);
}
return this;
},
 
_getRealMatrix: function(){
// summary: returns the cumulative ("real") transformation matrix
// by combining the shape's matrix with its parent's matrix
return this.parentMatrix ? new dojox.gfx.Matrix2D([this.parentMatrix, this.matrix]) : this.matrix; // dojox.gfx.Matrix2D
}
});
 
dojo.declare("dojox.gfx.Group", dojox.gfx.Shape, {
// summary: a group shape (VML), which can be used
// to logically group shapes (e.g, to propagate matricies)
constructor: function(){
dojox.gfx.vml.Container._init.call(this);
},
// apply transformation
_applyTransform: function(){
// summary: applies a transformation matrix to a group
var matrix = this._getRealMatrix();
for(var i = 0; i < this.children.length; ++i){
this.children[i]._updateParentMatrix(matrix);
}
return this; // self
}
});
dojox.gfx.Group.nodeType = "group";
 
dojo.declare("dojox.gfx.Rect", dojox.gfx.shape.Rect, {
// summary: a rectangle shape (VML)
setShape: function(newShape){
// summary: sets a rectangle shape object (VML)
// newShape: Object: a rectangle shape object
var shape = this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var style = this.rawNode.style;
style.left = shape.x.toFixed();
style.top = shape.y.toFixed();
style.width = (typeof shape.width == "string" && shape.width.indexOf("%") >= 0) ? shape.width : shape.width.toFixed();
style.height = (typeof shape.width == "string" && shape.height.indexOf("%") >= 0) ? shape.height : shape.height.toFixed();
var r = Math.min(1, (shape.r / Math.min(parseFloat(shape.width), parseFloat(shape.height)))).toFixed(8);
// a workaround for the VML's arcsize bug: cannot read arcsize of an instantiated node
var parent = this.rawNode.parentNode, before = null;
if(parent){
if(parent.lastChild != this.rawNode){
for(var i = 0; i < parent.childNodes.length; ++i){
if(parent.childNodes[i] == this.rawNode){
before = parent.childNodes[i+1];
break;
}
}
}
parent.removeChild(this.rawNode);
}
this.rawNode.arcsize = r;
if(parent){
if(before){
parent.insertBefore(this.rawNode, before);
}else{
parent.appendChild(this.rawNode);
}
}
// set all necessary styles, which are lost by VML (yes, it's a VML's bug)
return this.setTransform(this.matrix).setFill(this.fillStyle).setStroke(this.strokeStyle); // self
}
});
dojox.gfx.Rect.nodeType = "roundrect"; // use a roundrect so the stroke join type is respected
 
dojo.declare("dojox.gfx.Ellipse", dojox.gfx.shape.Ellipse, {
// summary: an ellipse shape (VML)
setShape: function(newShape){
// summary: sets an ellipse shape object (VML)
// newShape: Object: an ellipse shape object
var shape = this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var style = this.rawNode.style;
style.left = (shape.cx - shape.rx).toFixed();
style.top = (shape.cy - shape.ry).toFixed();
style.width = (shape.rx * 2).toFixed();
style.height = (shape.ry * 2).toFixed();
return this.setTransform(this.matrix); // self
}
});
dojox.gfx.Ellipse.nodeType = "oval";
 
dojo.declare("dojox.gfx.Circle", dojox.gfx.shape.Circle, {
// summary: a circle shape (VML)
setShape: function(newShape){
// summary: sets a circle shape object (VML)
// newShape: Object: a circle shape object
var shape = this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var style = this.rawNode.style;
style.left = (shape.cx - shape.r).toFixed();
style.top = (shape.cy - shape.r).toFixed();
style.width = (shape.r * 2).toFixed();
style.height = (shape.r * 2).toFixed();
return this; // self
}
});
dojox.gfx.Circle.nodeType = "oval";
 
dojo.declare("dojox.gfx.Line", dojox.gfx.shape.Line, {
// summary: a line shape (VML)
constructor: function(rawNode){
if(rawNode) rawNode.setAttribute("dojoGfxType", "line");
},
setShape: function(newShape){
// summary: sets a line shape object (VML)
// newShape: Object: a line shape object
var shape = this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
this.rawNode.path.v = "m" + shape.x1.toFixed() + " " + shape.y1.toFixed() +
"l" + shape.x2.toFixed() + " " + shape.y2.toFixed() + "e";
return this.setTransform(this.matrix); // self
}
});
dojox.gfx.Line.nodeType = "shape";
 
dojo.declare("dojox.gfx.Polyline", dojox.gfx.shape.Polyline, {
// summary: a polyline/polygon shape (VML)
constructor: function(rawNode){
if(rawNode) rawNode.setAttribute("dojoGfxType", "polyline");
},
setShape: function(points, closed){
// summary: sets a polyline/polygon shape object (VML)
// points: Object: a polyline/polygon shape object
// closed: Boolean?: if true, close the polyline explicitely
if(points && points instanceof Array){
// branch
// points: Array: an array of points
this.shape = dojox.gfx.makeParameters(this.shape, { points: points });
if(closed && this.shape.points.length) this.shape.points.push(this.shape.points[0]);
}else{
this.shape = dojox.gfx.makeParameters(this.shape, points);
}
this.bbox = null;
var attr = [], p = this.shape.points;
if(p.length > 0){
attr.push("m");
var k = 1;
if(typeof p[0] == "number"){
attr.push(p[0].toFixed());
attr.push(p[1].toFixed());
k = 2;
}else{
attr.push(p[0].x.toFixed());
attr.push(p[0].y.toFixed());
}
if(p.length > k){
attr.push("l");
for(var i = k; i < p.length; ++i){
if(typeof p[i] == "number"){
attr.push(p[i].toFixed());
}else{
attr.push(p[i].x.toFixed());
attr.push(p[i].y.toFixed());
}
}
}
}
attr.push("e");
this.rawNode.path.v = attr.join(" ");
return this.setTransform(this.matrix); // self
}
});
dojox.gfx.Polyline.nodeType = "shape";
 
dojo.declare("dojox.gfx.Image", dojox.gfx.shape.Image, {
// summary: an image (VML)
constructor: function(rawNode){
if(rawNode) rawNode.setAttribute("dojoGfxType", "image");
},
getEventSource: function() {
// summary: returns a Node, which is used as
// a source of events for this shape
return this.rawNode ? this.rawNode.firstChild : null; // Node
},
setShape: function(newShape){
// summary: sets an image shape object (VML)
// newShape: Object: an image shape object
var shape = this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var firstChild = this.rawNode.firstChild;
firstChild.src = shape.src;
if(shape.width || shape.height){
firstChild.style.width = shape.width;
firstChild.style.height = shape.height;
}
return this.setTransform(this.matrix); // self
},
_applyTransform: function() {
var matrix = this._getRealMatrix();
if(!matrix) return this;
matrix = dojox.gfx.matrix.multiply(matrix, {dx: this.shape.x, dy: this.shape.y});
var f = this.rawNode.filters["DXImageTransform.Microsoft.Matrix"];
f.M11 = matrix.xx;
f.M12 = matrix.xy;
f.M21 = matrix.yx;
f.M22 = matrix.yy;
f.Dx = matrix.dx;
f.Dy = matrix.dy;
return this;
}
});
dojox.gfx.Image.nodeType = "div";
 
dojo.declare("dojox.gfx.Text", dojox.gfx.shape.Text, {
// summary: an anchored text (VML)
constructor: function(rawNode){
if(rawNode){rawNode.setAttribute("dojoGfxType", "text");}
this.fontStyle = null;
},
_alignment: {start: "left", middle: "center", end: "right"},
setShape: function(newShape){
// summary: sets a text shape object (VML)
// newShape: Object: a text shape object
this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var r = this.rawNode, s = this.shape, x = s.x, y = s.y.toFixed();
switch(s.align){
case "middle":
x -= 5;
break;
case "end":
x -= 10;
break;
}
this.rawNode.path.v = "m" + x.toFixed() + "," + y +
"l" + (x + 10).toFixed() + "," + y + "e";
// find path and text path
var p = null, t = null, c = r.childNodes;
for(var i = 0; i < c.length; ++i){
var tag = c[i].tagName;
if(tag == "path"){
p = c[i];
if(t) break;
}else if(tag == "textpath"){
t = c[i];
if(p) break;
}
}
if(!p){
p = this.rawNode.ownerDocument.createElement("v:path");
r.appendChild(p);
}
if(!t){
t = this.rawNode.ownerDocument.createElement("v:textpath");
r.appendChild(t);
}
p.textPathOk = true;
t.on = true;
var a = dojox.gfx.vml.text_alignment[s.align];
t.style["v-text-align"] = a ? a : "left";
t.style["text-decoration"] = s.decoration;
t.style["v-rotate-letters"] = s.rotated;
t.style["v-text-kern"] = s.kerning;
t.string = s.text;
return this.setTransform(this.matrix); // self
},
_setFont: function(){
// summary: sets a font object (VML)
var f = this.fontStyle, c = this.rawNode.childNodes;
for(var i = 0; i < c.length; ++i){
if(c[i].tagName == "textpath"){
c[i].style.font = dojox.gfx.makeFontString(f);
break;
}
}
this.setTransform(this.matrix);
},
_getRealMatrix: function(){
// summary: returns the cumulative ("real") transformation matrix
// by combining the shape's matrix with its parent's matrix;
// it makes a correction for a font size
var matrix = dojox.gfx.Shape.prototype._getRealMatrix.call(this);
// It appears that text is always aligned vertically at a middle of x-height (???).
// It is impossible to obtain these metrics from VML => I try to approximate it with
// more-or-less util value of 0.7 * FontSize, which is typical for European fonts.
if(matrix){
matrix = dojox.gfx.matrix.multiply(matrix,
{dy: -dojox.gfx.normalizedLength(this.fontStyle ? this.fontStyle.size : "10pt") * 0.35});
}
return matrix; // dojox.gfx.Matrix2D
},
getTextWidth: function(){
// summary: get the text width, in px
var rawNode = this.rawNode, _display = rawNode.style.display;
rawNode.style.display = "inline";
var _width = dojox.gfx.pt2px(parseFloat(rawNode.currentStyle.width));
rawNode.style.display = _display;
return _width;
}
});
dojox.gfx.Text.nodeType = "shape";
 
dojox.gfx.path._calcArc = function(alpha){
// return a start point, 1st and 2nd control points, and an end point
var cosa = Math.cos(alpha), sina = Math.sin(alpha),
p2 = {x: cosa + (4 / 3) * (1 - cosa), y: sina - (4 / 3) * cosa * (1 - cosa) / sina};
return {
s: {x: cosa, y: -sina},
c1: {x: p2.x, y: -p2.y},
c2: p2,
e: {x: cosa, y: sina}
};
};
 
dojo.declare("dojox.gfx.Path", dojox.gfx.path.Path, {
// summary: a path shape (VML)
constructor: function(rawNode){
if(rawNode && !rawNode.getAttribute("dojoGfxType")){
rawNode.setAttribute("dojoGfxType", "path");
}
this.vmlPath = "";
this.lastControl = {};
},
_updateWithSegment: function(segment){
// summary: updates the bounding box of path with new segment
// segment: Object: a segment
var last = dojo.clone(this.last);
dojox.gfx.Path.superclass._updateWithSegment.apply(this, arguments);
// add a VML path segment
var path = this[this.renderers[segment.action]](segment, last);
if(typeof this.vmlPath == "string"){
this.vmlPath += path.join("");
this.rawNode.path.v = this.vmlPath + " r0,0 e";
}else{
this.vmlPath = this.vmlPath.concat(path);
}
},
setShape: function(newShape){
// summary: forms a path using a shape (VML)
// newShape: Object: an VML path string or a path object (see dojox.gfx.defaultPath)
this.vmlPath = [];
this.lastControl = {};
dojox.gfx.Path.superclass.setShape.apply(this, arguments);
this.vmlPath = this.vmlPath.join("");
this.rawNode.path.v = this.vmlPath + " r0,0 e";
return this;
},
_pathVmlToSvgMap: {m: "M", l: "L", t: "m", r: "l", c: "C", v: "c", qb: "Q", x: "z", e: ""},
// VML-specific segment renderers
renderers: {
M: "_moveToA", m: "_moveToR",
L: "_lineToA", l: "_lineToR",
H: "_hLineToA", h: "_hLineToR",
V: "_vLineToA", v: "_vLineToR",
C: "_curveToA", c: "_curveToR",
S: "_smoothCurveToA", s: "_smoothCurveToR",
Q: "_qCurveToA", q: "_qCurveToR",
T: "_qSmoothCurveToA", t: "_qSmoothCurveToR",
A: "_arcTo", a: "_arcTo",
Z: "_closePath", z: "_closePath"
},
_addArgs: function(path, args, from, upto){
if(typeof upto == "undefined"){
upto = args.length;
}
if(typeof from == "undefined"){
from = 0;
}
for(var i = from; i < upto; ++i){
path.push(" ");
path.push(args[i].toFixed());
}
},
_addArgsAdjusted: function(path, last, args, from, upto){
if(typeof upto == "undefined"){
upto = args.length;
}
if(typeof from == "undefined"){
from = 0;
}
for(var i = from; i < upto; i += 2){
path.push(" ");
path.push((last.x + args[i]).toFixed());
path.push(" ");
path.push((last.y + args[i + 1]).toFixed());
}
},
_moveToA: function(segment){
var p = [" m"], n = segment.args, l = n.length;
if(l == 2){
this._addArgs(p, n);
}else{
this._addArgs(p, n, 0, 2);
p.push(" l");
this._addArgs(p, n, 2);
}
this.lastControl = {};
return p;
},
_moveToR: function(segment, last){
var p = ["x" in last ? " t" : " m"], n = segment.args, l = n.length;
if(l == 2){
this._addArgs(p, n);
}else{
this._addArgs(p, n, 0, 2);
p.push(" r");
this._addArgs(p, n, 2);
}
this.lastControl = {};
return p;
},
_lineToA: function(segment){
var p = [" l"];
this._addArgs(p, segment.args);
this.lastControl = {};
return p;
},
_lineToR: function(segment){
var p = [" r"];
this._addArgs(p, segment.args);
this.lastControl = {};
return p;
},
_hLineToA: function(segment, last){
var p = [" l"], n = segment.args, l = n.length, y = " " + last.y.toFixed();
for(var i = 0; i < l; ++i){
p.push(" ");
p.push(n[i].toFixed());
p.push(y);
}
this.lastControl = {};
return p;
},
_hLineToR: function(segment){
var p = [" r"], n = segment.args, l = n.length;
for(var i = 0; i < l; ++i){
p.push(" ");
p.push(n[i].toFixed());
p.push(" 0");
}
this.lastControl = {};
return p;
},
_vLineToA: function(segment, last){
var p = [" l"], n = segment.args, l = n.length, x = " " + last.x.toFixed();
for(var i = 0; i < l; ++i){
p.push(x);
p.push(" ");
p.push(n[i].toFixed());
}
this.lastControl = {};
return p;
},
_vLineToR: function(segment){
var p = [" r"], n = segment.args, l = n.length;
for(var i = 0; i < l; ++i){
p.push(" 0 ");
p.push(n[i].toFixed());
}
this.lastControl = {};
return p;
},
_curveToA: function(segment){
var p = [], n = segment.args, l = n.length;
for(var i = 0; i < l; i += 6){
p.push(" c");
this._addArgs(p, n, i, i + 6);
}
this.lastControl = {x: n[l - 4], y: n[l - 3], type: "C"};
return p;
},
_curveToR: function(segment, last){
var p = [], n = segment.args, l = n.length;
for(var i = 0; i < l; i += 6){
p.push(" v");
this._addArgs(p, n, i, i + 6);
this.lastControl = {x: last.x + n[i + 2], y: last.y + n[i + 3]};
last.x += n[i + 4];
last.y += n[i + 5];
}
this.lastControl.type = "C";
return p;
},
_smoothCurveToA: function(segment, last){
var p = [], n = segment.args, l = n.length;
for(var i = 0; i < l; i += 4){
p.push(" c");
if(this.lastControl.type == "C"){
this._addArgs(p, [
2 * last.x - this.lastControl.x,
2 * last.y - this.lastControl.y
]);
}else{
this._addArgs(p, [last.x, last.y]);
}
this._addArgs(p, n, i, i + 4);
}
this.lastControl = {x: n[l - 4], y: n[l - 3], type: "C"};
return p;
},
_smoothCurveToR: function(segment, last){
var p = [], n = segment.args, l = n.length;
for(var i = 0; i < l; i += 4){
p.push(" v");
if(this.lastControl.type == "C"){
this._addArgs(p, [
last.x - this.lastControl.x,
last.y - this.lastControl.y
]);
}else{
this._addArgs(p, [0, 0]);
}
this._addArgs(p, n, i, i + 4);
this.lastControl = {x: last.x + n[i], y: last.y + n[i + 1]};
last.x += n[i + 2];
last.y += n[i + 3];
}
this.lastControl.type = "C";
return p;
},
_qCurveToA: function(segment){
var p = [], n = segment.args, l = n.length;
for(var i = 0; i < l; i += 4){
p.push(" qb");
this._addArgs(p, n, i, i + 4);
}
this.lastControl = {x: n[l - 4], y: n[l - 3], type: "Q"};
return p;
},
_qCurveToR: function(segment, last){
var p = [], n = segment.args, l = n.length;
for(var i = 0; i < l; i += 4){
p.push(" qb");
this._addArgsAdjusted(p, last, n, i, i + 4);
this.lastControl = {x: last.x + n[i], y: last.y + n[i + 1]};
last.x += n[i + 2];
last.y += n[i + 3];
}
this.lastControl.type = "Q";
return p;
},
_qSmoothCurveToA: function(segment, last){
var p = [], n = segment.args, l = n.length;
for(var i = 0; i < l; i += 2){
p.push(" qb");
if(this.lastControl.type == "Q"){
this._addArgs(p, [
this.lastControl.x = 2 * last.x - this.lastControl.x,
this.lastControl.y = 2 * last.y - this.lastControl.y
]);
}else{
this._addArgs(p, [
this.lastControl.x = last.x,
this.lastControl.y = last.y
]);
}
this._addArgs(p, n, i, i + 2);
}
this.lastControl.type = "Q";
return p;
},
_qSmoothCurveToR: function(segment, last){
var p = [], n = segment.args, l = n.length;
for(var i = 0; i < l; i += 2){
p.push(" qb");
if(this.lastControl.type == "Q"){
this._addArgs(p, [
this.lastControl.x = 2 * last.x - this.lastControl.x,
this.lastControl.y = 2 * last.y - this.lastControl.y
]);
}else{
this._addArgs(p, [
this.lastControl.x = last.x,
this.lastControl.y = last.y
]);
}
this._addArgsAdjusted(p, last, n, i, i + 2);
}
this.lastControl.type = "Q";
return p;
},
_arcTo: function(segment, last){
var p = [], n = segment.args, l = n.length, relative = segment.action == "a";
for(var i = 0; i < l; i += 7){
var x1 = n[i + 5], y1 = n[i + 6];
if(relative){
x1 += last.x;
y1 += last.y;
}
var result = dojox.gfx.arc.arcAsBezier(
last, n[i], n[i + 1], n[i + 2],
n[i + 3] ? 1 : 0, n[i + 4] ? 1 : 0,
x1, y1
);
for(var j = 0; j < result.length; ++j){
p.push(" c");
this._addArgs(p, result[j]);
}
last = {x: x1, y: y1};
}
this.lastControl = {};
return p;
},
_closePath: function(){
this.lastControl = {};
return ["x"];
}
});
dojox.gfx.Path.nodeType = "shape";
 
dojo.declare("dojox.gfx.TextPath", dojox.gfx.Path, {
// summary: a textpath shape (VML)
constructor: function(rawNode){
if(rawNode){rawNode.setAttribute("dojoGfxType", "textpath");}
this.fontStyle = null;
if(!("text" in this)){
this.text = dojo.clone(dojox.gfx.defaultTextPath);
}
if(!("fontStyle" in this)){
this.fontStyle = dojo.clone(dojox.gfx.defaultFont);
}
},
setText: function(newText){
// summary: sets a text to be drawn along the path
this.text = dojox.gfx.makeParameters(this.text,
typeof newText == "string" ? {text: newText} : newText);
this._setText();
return this; // self
},
setFont: function(newFont){
// summary: sets a font for text
this.fontStyle = typeof newFont == "string" ?
dojox.gfx.splitFontString(newFont) :
dojox.gfx.makeParameters(dojox.gfx.defaultFont, newFont);
this._setFont();
return this; // self
},
 
_setText: function(){
// summary: sets a text shape object (VML)
this.bbox = null;
var r = this.rawNode, s = this.text,
// find path and text path
p = null, t = null, c = r.childNodes;
for(var i = 0; i < c.length; ++i){
var tag = c[i].tagName;
if(tag == "path"){
p = c[i];
if(t) break;
}else if(tag == "textpath"){
t = c[i];
if(p) break;
}
}
if(!p){
p = this.rawNode.ownerDocument.createElement("v:path");
r.appendChild(p);
}
if(!t){
t = this.rawNode.ownerDocument.createElement("v:textpath");
r.appendChild(t);
}
p.textPathOk = true;
t.on = true;
var a = dojox.gfx.vml.text_alignment[s.align];
t.style["v-text-align"] = a ? a : "left";
t.style["text-decoration"] = s.decoration;
t.style["v-rotate-letters"] = s.rotated;
t.style["v-text-kern"] = s.kerning;
t.string = s.text;
},
_setFont: function(){
// summary: sets a font object (VML)
var f = this.fontStyle, c = this.rawNode.childNodes;
for(var i = 0; i < c.length; ++i){
if(c[i].tagName == "textpath"){
c[i].style.font = dojox.gfx.makeFontString(f);
break;
}
}
}
});
dojox.gfx.TextPath.nodeType = "shape";
 
dojo.declare("dojox.gfx.Surface", dojox.gfx.shape.Surface, {
// summary: a surface object to be used for drawings (VML)
constructor: function(){
dojox.gfx.vml.Container._init.call(this);
},
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"
this.width = dojox.gfx.normalizedLength(width); // in pixels
this.height = dojox.gfx.normalizedLength(height); // in pixels
if(!this.rawNode) return this;
var cs = this.clipNode.style,
r = this.rawNode, rs = r.style,
bs = this.bgNode.style;
cs.width = width;
cs.height = height;
cs.clip = "rect(0 " + width + " " + height + " 0)";
rs.width = width;
rs.height = height;
r.coordsize = width + " " + height;
bs.width = width;
bs.height = height;
return this; // self
},
getDimensions: function(){
// summary: returns an object with properties "width" and "height"
var t = this.rawNode ? {
width: dojox.gfx.normalizedLength(this.rawNode.style.width),
height: dojox.gfx.normalizedLength(this.rawNode.style.height)} : null;
if(t.width <= 0){ t.width = this.width; }
if(t.height <= 0){ t.height = this.height; }
return t; // Object
}
});
 
dojox.gfx.createSurface = function(parentNode, width, height){
// summary: creates a surface (VML)
// parentNode: Node: a parent node
// width: String: width of surface, e.g., "100px"
// height: String: height of surface, e.g., "100px"
 
if(!width){ width = "100%"; }
if(!height){ height = "100%"; }
var s = new dojox.gfx.Surface(), p = dojo.byId(parentNode),
c = s.clipNode = p.ownerDocument.createElement("div"),
r = s.rawNode = p.ownerDocument.createElement("v:group"),
cs = c.style, rs = r.style;
p.style.width = width;
p.style.height = height;
cs.width = width;
cs.height = height;
cs.clip = "rect(0 " + width + " " + height + " 0)";
cs.position = "absolute";
rs.width = width;
rs.height = height;
r.coordsize = (width == "100%" ? width : parseFloat(width)) + " " +
(height == "100%" ? height : parseFloat(height));
r.coordorigin = "0 0";
// create a background rectangle, which is required to show all other shapes
var b = s.bgNode = r.ownerDocument.createElement("v:rect"), bs = b.style;
bs.left = bs.top = 0;
bs.width = rs.width;
bs.height = rs.height;
b.filled = b.stroked = "f";
 
r.appendChild(b);
c.appendChild(r);
p.appendChild(c);
s.width = dojox.gfx.normalizedLength(width); // in pixels
s.height = dojox.gfx.normalizedLength(height); // in pixels
 
return s; // dojox.gfx.Surface
};
 
// Extenders
 
dojox.gfx.vml.Container = {
_init: function(){
dojox.gfx.shape.Container._init.call(this);
},
add: function(shape){
// summary: adds a shape to a group/surface
// shape: dojox.gfx.Shape: an VML shape object
if(this != shape.getParent()){
this.rawNode.appendChild(shape.rawNode);
//dojox.gfx.Group.superclass.add.apply(this, arguments);
//this.inherited(arguments);
dojox.gfx.shape.Container.add.apply(this, arguments);
}
return this; // self
},
remove: function(shape, silently){
// summary: remove a shape from a group/surface
// shape: dojox.gfx.Shape: an VML shape object
// silently: Boolean?: if true, regenerate a picture
if(this == shape.getParent()){
if(this.rawNode == shape.rawNode.parentNode){
this.rawNode.removeChild(shape.rawNode);
}
//dojox.gfx.Group.superclass.remove.apply(this, arguments);
//this.inherited(arguments);
dojox.gfx.shape.Container.remove.apply(this, arguments);
}
return this; // self
},
clear: function(){
// summary: removes all shapes from a group/surface
var r = this.rawNode;
while(r.firstChild != r.lastChild){
if(r.firstChild != this.bgNode){
r.removeChild(r.firstChild);
}
if(r.lastChild != this.bgNode){
r.removeChild(r.lastChild);
}
}
//return this.inherited(arguments); // self
return dojox.gfx.shape.Container.clear.apply(this, arguments);
},
_moveChildToFront: dojox.gfx.shape.Container._moveChildToFront,
_moveChildToBack: dojox.gfx.shape.Container._moveChildToBack
};
 
dojo.mixin(dojox.gfx.shape.Creator, {
// summary: VML shape creators
createGroup: function(){
// summary: creates a VML group shape
var g = this.createObject(dojox.gfx.Group, null); // dojox.gfx.Group
// create a background rectangle, which is required to show all other shapes
var r = g.rawNode.ownerDocument.createElement("v:rect");
r.style.left = r.style.top = 0;
r.style.width = g.rawNode.style.width;
r.style.height = g.rawNode.style.height;
r.filled = r.stroked = "f";
g.rawNode.appendChild(r);
g.bgNode = r;
return g; // dojox.gfx.Group
},
createImage: function(image){
// summary: creates a VML image shape
// image: Object: an image object (see dojox.gfx.defaultImage)
if(!this.rawNode) return null;
var shape = new dojox.gfx.Image(), node = this.rawNode.ownerDocument.createElement('div');
node.style.position = "absolute";
node.style.width = this.rawNode.style.width;
node.style.height = this.rawNode.style.height;
node.style.filter = "progid:DXImageTransform.Microsoft.Matrix(M11=1, M12=0, M21=0, M22=1, Dx=0, Dy=0)";
var img = this.rawNode.ownerDocument.createElement('img');
node.appendChild(img);
shape.setRawNode(node);
this.rawNode.appendChild(node);
shape.setShape(image);
this.add(shape);
return shape; // dojox.gfx.Image
},
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
// overrideSize: Boolean: set the size explicitly, if true
if(!this.rawNode) return null;
var shape = new shapeType(),
node = this.rawNode.ownerDocument.createElement('v:' + shapeType.nodeType);
shape.setRawNode(node);
this.rawNode.appendChild(node);
switch(shapeType){
case dojox.gfx.Group:
case dojox.gfx.Line:
case dojox.gfx.Polyline:
case dojox.gfx.Text:
case dojox.gfx.Path:
case dojox.gfx.TextPath:
this._overrideSize(node);
}
shape.setShape(rawShape);
this.add(shape);
return shape; // dojox.gfx.Shape
},
_overrideSize: function(node){
var p = this;
for(; p && !(p instanceof dojox.gfx.Surface); p = p.parent);
node.style.width = p.width;
node.style.height = p.height;
node.coordsize = p.width + " " + p.height;
}
});
 
dojo.extend(dojox.gfx.Group, dojox.gfx.vml.Container);
dojo.extend(dojox.gfx.Group, dojox.gfx.shape.Creator);
 
dojo.extend(dojox.gfx.Surface, dojox.gfx.vml.Container);
dojo.extend(dojox.gfx.Surface, dojox.gfx.shape.Creator);
 
}
/trunk/api/js/dojo1.0/dojox/gfx/canvas_attach.js
New file
0,0 → 1,8
dojo.require("dojox.gfx.canvas");
 
dojo.experimental("dojox.gfx.canvas_attach");
 
// not implemented
dojox.gfx.attachNode = function(){
return null; // for now
};
/trunk/api/js/dojo1.0/dojox/gfx/svg.js
New file
0,0 → 1,634
if(!dojo._hasResource["dojox.gfx.svg"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.svg"] = true;
dojo.provide("dojox.gfx.svg");
 
dojo.require("dojox.gfx._base");
dojo.require("dojox.gfx.shape");
dojo.require("dojox.gfx.path");
 
dojox.gfx.svg.xmlns = {
xlink: "http://www.w3.org/1999/xlink",
svg: "http://www.w3.org/2000/svg"
};
 
dojox.gfx.svg.getRef = function(name){
// summary: returns a DOM Node specified by the name argument or null
// name: String: an SVG external reference
if(!name || name == "none") return null;
if(name.match(/^url\(#.+\)$/)){
return dojo.byId(name.slice(5, -1)); // Node
}
// alternative representation of a reference
if(name.match(/^#dojoUnique\d+$/)){
// we assume here that a reference was generated by dojox.gfx
return dojo.byId(name.slice(1)); // Node
}
return null; // Node
};
 
dojox.gfx.svg.dasharray = {
solid: "none",
shortdash: [4, 1],
shortdot: [1, 1],
shortdashdot: [4, 1, 1, 1],
shortdashdotdot: [4, 1, 1, 1, 1, 1],
dot: [1, 3],
dash: [4, 3],
longdash: [8, 3],
dashdot: [4, 3, 1, 3],
longdashdot: [8, 3, 1, 3],
longdashdotdot: [8, 3, 1, 3, 1, 3]
};
 
dojo.extend(dojox.gfx.Shape, {
// summary: SVG-specific implementation of dojox.gfx.Shape methods
setFill: function(fill){
// summary: sets a fill object (SVG)
// fill: Object: a fill object
// (see dojox.gfx.defaultLinearGradient,
// dojox.gfx.defaultRadialGradient,
// dojox.gfx.defaultPattern,
// or dojo.Color)
 
if(!fill){
// don't fill
this.fillStyle = null;
this.rawNode.setAttribute("fill", "none");
this.rawNode.setAttribute("fill-opacity", 0);
return this;
}
var f;
// FIXME: slightly magical. We're using the outer scope's "f", but setting it later
var setter = function(x){
// we assume that we're executing in the scope of the node to mutate
this.setAttribute(x, f[x].toFixed(8));
};
if(typeof(fill) == "object" && "type" in fill){
// gradient
switch(fill.type){
case "linear":
f = dojox.gfx.makeParameters(dojox.gfx.defaultLinearGradient, fill);
var gradient = this._setFillObject(f, "linearGradient");
dojo.forEach(["x1", "y1", "x2", "y2"], setter, gradient);
break;
case "radial":
f = dojox.gfx.makeParameters(dojox.gfx.defaultRadialGradient, fill);
var gradient = this._setFillObject(f, "radialGradient");
dojo.forEach(["cx", "cy", "r"], setter, gradient);
break;
case "pattern":
f = dojox.gfx.makeParameters(dojox.gfx.defaultPattern, fill);
var pattern = this._setFillObject(f, "pattern");
dojo.forEach(["x", "y", "width", "height"], setter, pattern);
break;
}
this.fillStyle = f;
return this;
}
// color object
var f = dojox.gfx.normalizeColor(fill);
this.fillStyle = f;
this.rawNode.setAttribute("fill", f.toCss());
this.rawNode.setAttribute("fill-opacity", f.a);
this.rawNode.setAttribute("fill-rule", "evenodd");
return this; // self
},
 
setStroke: function(stroke){
// summary: sets a stroke object (SVG)
// stroke: Object: a stroke object
// (see dojox.gfx.defaultStroke)
if(!stroke){
// don't stroke
this.strokeStyle = null;
this.rawNode.setAttribute("stroke", "none");
this.rawNode.setAttribute("stroke-opacity", 0);
return this;
}
// normalize the stroke
if(typeof stroke == "string"){
stroke = {color: stroke};
}
var s = this.strokeStyle = dojox.gfx.makeParameters(dojox.gfx.defaultStroke, stroke);
s.color = dojox.gfx.normalizeColor(s.color);
// generate attributes
var rn = this.rawNode;
if(s){
rn.setAttribute("stroke", s.color.toCss());
rn.setAttribute("stroke-opacity", s.color.a);
rn.setAttribute("stroke-width", s.width);
rn.setAttribute("stroke-linecap", s.cap);
if(typeof s.join == "number"){
rn.setAttribute("stroke-linejoin", "miter");
rn.setAttribute("stroke-miterlimit", s.join);
}else{
rn.setAttribute("stroke-linejoin", s.join);
}
var da = s.style.toLowerCase();
if(da in dojox.gfx.svg.dasharray){ da = dojox.gfx.svg.dasharray[da]; }
if(da instanceof Array){
da = dojo.clone(da);
for(var i = 0; i < da.length; ++i){
da[i] *= s.width;
}
if(s.cap != "butt"){
for(var i = 0; i < da.length; i += 2){
da[i] -= s.width;
if(da[i] < 1){ da[i] = 1; }
}
for(var i = 1; i < da.length; i += 2){
da[i] += s.width;
}
}
da = da.join(",");
}
rn.setAttribute("stroke-dasharray", da);
rn.setAttribute("dojoGfxStrokeStyle", s.style);
}
return this; // self
},
_getParentSurface: function(){
var surface = this.parent;
for(; surface && !(surface instanceof dojox.gfx.Surface); surface = surface.parent);
return surface;
},
 
_setFillObject: function(f, nodeType){
var svgns = dojox.gfx.svg.xmlns.svg;
this.fillStyle = f;
var surface = this._getParentSurface();
var defs = surface.defNode;
var fill = this.rawNode.getAttribute("fill");
var ref = dojox.gfx.svg.getRef(fill);
if(ref){
fill = ref;
if(fill.tagName.toLowerCase() != nodeType.toLowerCase()){
var id = fill.id;
fill.parentNode.removeChild(fill);
fill = document.createElementNS(svgns, nodeType);
fill.setAttribute("id", id);
defs.appendChild(fill);
}else{
while(fill.childNodes.length){
fill.removeChild(fill.lastChild);
}
}
}else{
fill = document.createElementNS(svgns, nodeType);
fill.setAttribute("id", dojox.gfx._base._getUniqueId());
defs.appendChild(fill);
}
if(nodeType == "pattern"){
if(dojo.isSafari){
fill.setAttributeNS(null, "patternUnits", "userSpaceOnUse");
}else{
fill.setAttribute("patternUnits", "userSpaceOnUse");
}
var img = document.createElementNS(svgns, "image");
img.setAttribute("x", 0);
img.setAttribute("y", 0);
img.setAttribute("width", f.width .toFixed(8));
img.setAttribute("height", f.height.toFixed(8));
img.setAttributeNS(dojox.gfx.svg.xmlns.xlink, "href", f.src);
fill.appendChild(img);
}else{
if(dojo.isSafari){
fill.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
}else{
fill.setAttribute("gradientUnits", "userSpaceOnUse");
}
for(var i = 0; i < f.colors.length; ++i){
var c = f.colors[i], t = document.createElementNS(svgns, "stop"),
cc = c.color = dojox.gfx.normalizeColor(c.color);
t.setAttribute("offset", c.offset.toFixed(8));
t.setAttribute("stop-color", cc.toCss());
t.setAttribute("stop-opacity", cc.a);
fill.appendChild(t);
}
}
this.rawNode.setAttribute("fill", "url(#" + fill.getAttribute("id") +")");
this.rawNode.removeAttribute("fill-opacity");
this.rawNode.setAttribute("fill-rule", "evenodd");
return fill;
},
_applyTransform: function() {
var matrix = this.matrix;
if(matrix){
var tm = this.matrix;
this.rawNode.setAttribute("transform", "matrix(" +
tm.xx.toFixed(8) + "," + tm.yx.toFixed(8) + "," +
tm.xy.toFixed(8) + "," + tm.yy.toFixed(8) + "," +
tm.dx.toFixed(8) + "," + tm.dy.toFixed(8) + ")");
}else{
this.rawNode.removeAttribute("transform");
}
return this;
},
 
setRawNode: function(rawNode){
// summary:
// assigns and clears the underlying node that will represent this
// shape. Once set, transforms, gradients, etc, can be applied.
// (no fill & stroke by default)
var r = this.rawNode = rawNode;
r.setAttribute("fill", "none");
r.setAttribute("fill-opacity", 0);
r.setAttribute("stroke", "none");
r.setAttribute("stroke-opacity", 0);
r.setAttribute("stroke-width", 1);
r.setAttribute("stroke-linecap", "butt");
r.setAttribute("stroke-linejoin", "miter");
r.setAttribute("stroke-miterlimit", 4);
},
setShape: function(newShape){
// summary: sets a shape object (SVG)
// newShape: 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)
this.shape = dojox.gfx.makeParameters(this.shape, newShape);
for(var i in this.shape){
if(i != "type"){ this.rawNode.setAttribute(i, this.shape[i]); }
}
return this; // self
},
 
// move family
 
_moveToFront: function(){
// summary: moves a shape to front of its parent's list of shapes (SVG)
this.rawNode.parentNode.appendChild(this.rawNode);
return this; // self
},
_moveToBack: function(){
// summary: moves a shape to back of its parent's list of shapes (SVG)
this.rawNode.parentNode.insertBefore(this.rawNode, this.rawNode.parentNode.firstChild);
return this; // self
}
});
 
dojo.declare("dojox.gfx.Group", dojox.gfx.Shape, {
// summary: a group shape (SVG), which can be used
// to logically group shapes (e.g, to propagate matricies)
constructor: function(){
dojox.gfx.svg.Container._init.call(this);
},
setRawNode: function(rawNode){
// summary: sets a raw SVG node to be used by this shape
// rawNode: Node: an SVG node
this.rawNode = rawNode;
}
});
dojox.gfx.Group.nodeType = "g";
 
dojo.declare("dojox.gfx.Rect", dojox.gfx.shape.Rect, {
// summary: a rectangle shape (SVG)
setShape: function(newShape){
// summary: sets a rectangle shape object (SVG)
// newShape: Object: a rectangle shape object
this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
for(var i in this.shape){
if(i != "type" && i != "r"){ this.rawNode.setAttribute(i, this.shape[i]); }
}
if(this.shape.r){
this.rawNode.setAttribute("ry", this.shape.r);
this.rawNode.setAttribute("rx", this.shape.r);
}
return this; // self
}
});
dojox.gfx.Rect.nodeType = "rect";
 
dojox.gfx.Ellipse = dojox.gfx.shape.Ellipse;
dojox.gfx.Ellipse.nodeType = "ellipse";
 
dojox.gfx.Circle = dojox.gfx.shape.Circle;
dojox.gfx.Circle.nodeType = "circle";
 
dojox.gfx.Line = dojox.gfx.shape.Line;
dojox.gfx.Line.nodeType = "line";
 
dojo.declare("dojox.gfx.Polyline", dojox.gfx.shape.Polyline, {
// summary: a polyline/polygon shape (SVG)
setShape: function(points, closed){
// summary: sets a polyline/polygon shape object (SVG)
// points: Object: a polyline/polygon shape object
if(points && points instanceof Array){
// branch
// points: Array: an array of points
this.shape = dojox.gfx.makeParameters(this.shape, { points: points });
if(closed && this.shape.points.length){
this.shape.points.push(this.shape.points[0]);
}
}else{
this.shape = dojox.gfx.makeParameters(this.shape, points);
}
this.box = null;
var attr = [];
var p = this.shape.points;
for(var i = 0; i < p.length; ++i){
if(typeof p[i] == "number"){
attr.push(p[i].toFixed(8));
}else{
attr.push(p[i].x.toFixed(8));
attr.push(p[i].y.toFixed(8));
}
}
this.rawNode.setAttribute("points", attr.join(" "));
return this; // self
}
});
dojox.gfx.Polyline.nodeType = "polyline";
 
dojo.declare("dojox.gfx.Image", dojox.gfx.shape.Image, {
// summary: an image (SVG)
setShape: function(newShape){
// summary: sets an image shape object (SVG)
// newShape: Object: an image shape object
this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var rawNode = this.rawNode;
for(var i in this.shape){
if(i != "type" && i != "src"){ rawNode.setAttribute(i, this.shape[i]); }
}
rawNode.setAttributeNS(dojox.gfx.svg.xmlns.xlink, "href", this.shape.src);
return this; // self
}
});
dojox.gfx.Image.nodeType = "image";
 
dojo.declare("dojox.gfx.Text", dojox.gfx.shape.Text, {
// summary: an anchored text (SVG)
setShape: function(newShape){
// summary: sets a text shape object (SVG)
// newShape: Object: a text shape object
this.shape = dojox.gfx.makeParameters(this.shape, newShape);
this.bbox = null;
var r = this.rawNode;
var s = this.shape;
r.setAttribute("x", s.x);
r.setAttribute("y", s.y);
r.setAttribute("text-anchor", s.align);
r.setAttribute("text-decoration", s.decoration);
r.setAttribute("rotate", s.rotated ? 90 : 0);
r.setAttribute("kerning", s.kerning ? "auto" : 0);
r.setAttribute("text-rendering", "optimizeLegibility");
r.textContent = s.text;
return this; // self
},
getTextWidth: function(){
// summary: get the text width in pixels
var rawNode = this.rawNode;
var oldParent = rawNode.parentNode;
var _measurementNode = rawNode.cloneNode(true);
_measurementNode.style.visibility = "hidden";
 
// solution to the "orphan issue" in FF
var _width = 0;
var _text = _measurementNode.firstChild.nodeValue;
oldParent.appendChild(_measurementNode);
 
// solution to the "orphan issue" in Opera
// (nodeValue == "" hangs firefox)
if(_text!=""){
while(!_width){
_width = parseInt(_measurementNode.getBBox().width);
}
}
oldParent.removeChild(_measurementNode);
return _width;
}
});
dojox.gfx.Text.nodeType = "text";
 
dojo.declare("dojox.gfx.Path", dojox.gfx.path.Path, {
// summary: a path shape (SVG)
_updateWithSegment: function(segment){
// summary: updates the bounding box of path with new segment
// segment: Object: a segment
dojox.gfx.Path.superclass._updateWithSegment.apply(this, arguments);
if(typeof(this.shape.path) == "string"){
this.rawNode.setAttribute("d", this.shape.path);
}
},
setShape: function(newShape){
// summary: forms a path using a shape (SVG)
// newShape: Object: an SVG path string or a path object (see dojox.gfx.defaultPath)
dojox.gfx.Path.superclass.setShape.apply(this, arguments);
this.rawNode.setAttribute("d", this.shape.path);
return this; // self
}
});
dojox.gfx.Path.nodeType = "path";
 
dojo.declare("dojox.gfx.TextPath", dojox.gfx.path.TextPath, {
// summary: a textpath shape (SVG)
_updateWithSegment: function(segment){
// summary: updates the bounding box of path with new segment
// segment: Object: a segment
dojox.gfx.Path.superclass._updateWithSegment.apply(this, arguments);
this._setTextPath();
},
setShape: function(newShape){
// summary: forms a path using a shape (SVG)
// newShape: Object: an SVG path string or a path object (see dojox.gfx.defaultPath)
dojox.gfx.Path.superclass.setShape.apply(this, arguments);
this._setTextPath();
return this; // self
},
_setTextPath: function(){
if(typeof this.shape.path != "string"){ return; }
var r = this.rawNode;
if(!r.firstChild){
var tp = document.createElementNS(dojox.gfx.svg.xmlns.svg, "textPath");
var tx = document.createTextNode("");
tp.appendChild(tx);
r.appendChild(tp);
}
var ref = r.firstChild.getAttributeNS(dojox.gfx.svg.xmlns.xlink, "href");
var path = ref && dojox.gfx.svg.getRef(ref);
if(!path){
var surface = this._getParentSurface();
if(surface){
var defs = surface.defNode;
path = document.createElementNS(dojox.gfx.svg.xmlns.svg, "path");
var id = dojox.gfx._base._getUniqueId();
path.setAttribute("id", id);
defs.appendChild(path);
r.firstChild.setAttributeNS(dojox.gfx.svg.xmlns.xlink, "href", "#" + id);
}
}
if(path){
path.setAttribute("d", this.shape.path);
}
},
_setText: function(){
var r = this.rawNode;
if(!r.firstChild){
var tp = document.createElementNS(dojox.gfx.svg.xmlns.svg, "textPath");
var tx = document.createTextNode("");
tp.appendChild(tx);
r.appendChild(tp);
}
r = r.firstChild;
var t = this.text;
r.setAttribute("alignment-baseline", "middle");
switch(t.align){
case "middle":
r.setAttribute("text-anchor", "middle");
r.setAttribute("startOffset", "50%");
break;
case "end":
r.setAttribute("text-anchor", "end");
r.setAttribute("startOffset", "100%");
break;
default:
r.setAttribute("text-anchor", "start");
r.setAttribute("startOffset", "0%");
break;
}
//r.parentNode.setAttribute("alignment-baseline", "central");
//r.setAttribute("dominant-baseline", "central");
r.setAttribute("baseline-shift", "0.5ex");
r.setAttribute("text-decoration", t.decoration);
r.setAttribute("rotate", t.rotated ? 90 : 0);
r.setAttribute("kerning", t.kerning ? "auto" : 0);
r.firstChild.data = t.text;
}
});
dojox.gfx.TextPath.nodeType = "text";
 
dojo.declare("dojox.gfx.Surface", dojox.gfx.shape.Surface, {
// summary: a surface object to be used for drawings (SVG)
constructor: function(){
dojox.gfx.svg.Container._init.call(this);
},
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"
if(!this.rawNode){ return this; }
this.rawNode.setAttribute("width", width);
this.rawNode.setAttribute("height", height);
return this; // self
},
getDimensions: function(){
// summary: returns an object with properties "width" and "height"
return this.rawNode ? {width: this.rawNode.getAttribute("width"), height: this.rawNode.getAttribute("height")} : null; // Object
}
});
 
dojox.gfx.createSurface = function(parentNode, width, height){
// summary: creates a surface (SVG)
// parentNode: Node: a parent node
// width: String: width of surface, e.g., "100px"
// height: String: height of surface, e.g., "100px"
 
var s = new dojox.gfx.Surface();
s.rawNode = document.createElementNS(dojox.gfx.svg.xmlns.svg, "svg");
s.rawNode.setAttribute("width", width);
s.rawNode.setAttribute("height", height);
 
var node = document.createElementNS(dojox.gfx.svg.xmlns.svg, "defs");
s.rawNode.appendChild(node);
s.defNode = node;
dojo.byId(parentNode).appendChild(s.rawNode);
return s; // dojox.gfx.Surface
};
 
// Extenders
 
dojox.gfx.svg.Font = {
_setFont: function(){
// summary: sets a font object (SVG)
var f = this.fontStyle;
// next line doesn't work in Firefox 2 or Opera 9
//this.rawNode.setAttribute("font", dojox.gfx.makeFontString(this.fontStyle));
this.rawNode.setAttribute("font-style", f.style);
this.rawNode.setAttribute("font-variant", f.variant);
this.rawNode.setAttribute("font-weight", f.weight);
this.rawNode.setAttribute("font-size", f.size);
this.rawNode.setAttribute("font-family", f.family);
}
};
 
dojox.gfx.svg.Container = {
_init: function(){
dojox.gfx.shape.Container._init.call(this);
},
add: function(shape){
// summary: adds a shape to a group/surface
// shape: dojox.gfx.Shape: an VML shape object
if(this != shape.getParent()){
this.rawNode.appendChild(shape.rawNode);
//dojox.gfx.Group.superclass.add.apply(this, arguments);
//this.inherited(arguments);
dojox.gfx.shape.Container.add.apply(this, arguments);
}
return this; // self
},
remove: function(shape, silently){
// summary: remove a shape from a group/surface
// shape: dojox.gfx.Shape: an VML shape object
// silently: Boolean?: if true, regenerate a picture
if(this == shape.getParent()){
if(this.rawNode == shape.rawNode.parentNode){
this.rawNode.removeChild(shape.rawNode);
}
//dojox.gfx.Group.superclass.remove.apply(this, arguments);
//this.inherited(arguments);
dojox.gfx.shape.Container.remove.apply(this, arguments);
}
return this; // self
},
clear: function(){
// summary: removes all shapes from a group/surface
var r = this.rawNode;
while(r.lastChild){
r.removeChild(r.lastChild);
}
//return this.inherited(arguments); // self
return dojox.gfx.shape.Container.clear.apply(this, arguments);
},
_moveChildToFront: dojox.gfx.shape.Container._moveChildToFront,
_moveChildToBack: dojox.gfx.shape.Container._moveChildToBack
};
 
dojo.mixin(dojox.gfx.shape.Creator, {
// summary: SVG shape creators
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
if(!this.rawNode){ return null; }
var shape = new shapeType();
var node = document.createElementNS(dojox.gfx.svg.xmlns.svg, shapeType.nodeType);
shape.setRawNode(node);
this.rawNode.appendChild(node);
shape.setShape(rawShape);
this.add(shape);
return shape; // dojox.gfx.Shape
}
});
 
dojo.extend(dojox.gfx.Text, dojox.gfx.svg.Font);
dojo.extend(dojox.gfx.TextPath, dojox.gfx.svg.Font);
 
dojo.extend(dojox.gfx.Group, dojox.gfx.svg.Container);
dojo.extend(dojox.gfx.Group, dojox.gfx.shape.Creator);
 
dojo.extend(dojox.gfx.Surface, dojox.gfx.svg.Container);
dojo.extend(dojox.gfx.Surface, dojox.gfx.shape.Creator);
 
}
/trunk/api/js/dojo1.0/dojox/gfx/utils.js
New file
0,0 → 1,87
if(!dojo._hasResource["dojox.gfx.utils"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.utils"] = true;
dojo.provide("dojox.gfx.utils");
 
dojo.require("dojox.gfx");
 
dojox.gfx.utils.serialize = function(
/* dojox.gfx.Surface || dojox.gfx.Shape */ object
){
var t = {}, v, isSurface = object instanceof dojox.gfx.Surface;
if(isSurface || object instanceof dojox.gfx.Group){
t.children = [];
for(var i = 0; i < object.children.length; ++i){
t.children.push(dojox.gfx.utils.serialize(object.children[i]));
}
if(isSurface){
return t.children; // Array
}
}else{
t.shape = object.getShape();
}
if(object.getTransform){
v = object.getTransform();
if(v){ t.transform = v; }
}
if(object.getStroke){
v = object.getStroke();
if(v){ t.stroke = v; }
}
if(object.getFill){
v = object.getFill();
if(v){ t.fill = v; }
}
if(object.getFont){
v = object.getFont();
if(v){ t.font = v; }
}
return t; // Object
};
 
dojox.gfx.utils.toJson = function(
/* dojox.gfx.Surface || dojox.gfx.Shape */ object,
/* Boolean? */ prettyPrint
){
return dojo.toJson(dojox.gfx.utils.serialize(object), prettyPrint); // String
};
 
dojox.gfx.utils.deserialize = function(
/* dojox.gfx.Surface || dojox.gfx.Shape */ parent,
/* dojox.gfx.Shape || Array */ object
){
if(object instanceof Array){
var t = [];
for(var i = 0; i < object.length; ++i){
t.push(dojox.gfx.utils.deserialize(parent, object[i]));
}
return t; // Array
}
var shape = ("shape" in object) ? parent.createShape(object.shape) : parent.createGroup();
if("transform" in object){
shape.setTransform(object.transform);
}
if("stroke" in object){
shape.setStroke(object.stroke);
}
if("fill" in object){
shape.setFill(object.fill);
}
if("font" in object){
shape.setFont(object.font);
}
if("children" in object){
for(var i = 0; i < object.children.length; ++i){
dojox.gfx.utils.deserialize(shape, object.children[i]);
}
}
return shape; // dojox.gfx.Shape
};
 
dojox.gfx.utils.fromJson = function(
/* dojox.gfx.Surface || dojox.gfx.Shape */ parent,
/* String */ json
){
return dojox.gfx.utils.deserialize(parent, dojo.fromJson(json)); // Array || dojox.gfx.Shape
};
 
}
/trunk/api/js/dojo1.0/dojox/gfx/shape.js
New file
0,0 → 1,687
if(!dojo._hasResource["dojox.gfx.shape"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.shape"] = true;
dojo.provide("dojox.gfx.shape");
 
dojo.require("dojox.gfx._base");
 
dojo.declare("dojox.gfx.Shape", null, {
// summary: a Shape object, which knows how to apply
// graphical attributes and transformations
constructor: function(){
// rawNode: Node: underlying node
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.Matrix2D: a transformation matrix
this.matrix = null;
// fillStyle: Object: a fill object
// (see dojox.gfx.defaultLinearGradient,
// dojox.gfx.defaultRadialGradient,
// dojox.gfx.defaultPattern,
// or dojo.Color)
this.fillStyle = null;
// strokeStyle: Object: 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.Surface,
// dojox.gfx.shape.VirtualGroup,
// or dojox.gfx.Group)
this.parent = null;
// parentMatrix: dojox.gfx.Matrix2D
// a transformation matrix inherited from the parent
this.parentMatrix = null;
},
// trivial getters
getNode: function(){
// summary: returns the current DOM Node or null
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 or null
return this.matrix; // dojox.gfx.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 or null
// (see dojox.gfx.Surface,
// dojox.gfx.shape.VirtualGroup,
// or dojox.gfx.Group)
return this.parent; // Object
},
getBoundingBox: function(){
// summary: returns the bounding box or null
// (see dojox.gfx.defaultRect)
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();
var r = [];
var g = dojox.gfx.matrix;
r.push(g.multiplyPoint(m, b.x, b.y));
r.push(g.multiplyPoint(m, b.x + b.width, b.y));
r.push(g.multiplyPoint(m, b.x + b.width, b.y + b.height));
r.push(g.multiplyPoint(m, b.x, b.y + b.height));
return r; // Array
},
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
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 = dojox.gfx.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.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 = dojox.gfx.makeParameters(dojox.gfx.defaultLinearGradient, fill);
break;
case "radial":
f = dojox.gfx.makeParameters(dojox.gfx.defaultRadialGradient, fill);
break;
case "pattern":
f = dojox.gfx.makeParameters(dojox.gfx.defaultPattern, fill);
break;
}
}else{
// color object
f = dojox.gfx.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"){
stroke = {color: stroke};
}
var s = this.strokeStyle = dojox.gfx.makeParameters(dojox.gfx.defaultStroke, stroke);
s.color = dojox.gfx.normalizeColor(s.color);
return this; // self
},
setTransform: function(matrix){
// summary: sets a transformation matrix
// matrix: dojox.gfx.Matrix2D: a matrix or a matrix-like object
// (see an argument of dojox.gfx.Matrix2D
// constructor for a list of acceptable arguments)
 
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
 
this.matrix = dojox.gfx.matrix.clone(matrix ? dojox.gfx.matrix.normalize(matrix) : dojox.gfx.matrix.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.Matrix2D: a matrix or a matrix-like object
// (see an argument of dojox.gfx.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.Matrix2D: a matrix or a matrix-like object
// (see an argument of dojox.gfx.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.applyRightTransform
// matrix: dojox.gfx.Matrix2D: a matrix or a matrix-like object
// (see an argument of dojox.gfx.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.Surface,
// dojox.gfx.shape.VirtualGroup,
// or dojox.gfx.Group)
// matrix: dojox.gfx.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 ? dojox.gfx.matrix.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 = dojox.gfx.matrix.multiply(p.matrix, m);
}
p = p.parent;
}
return m; // dojox.gfx.Matrix2D
}
});
 
dojox.gfx.shape._eventsProcessing = {
connect: function(name, object, method){
// summary: connects a handler to an event on this shape
 
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
 
return arguments.length > 2 ? // Object
dojo.connect(this.getEventSource(), name, object, method) :
dojo.connect(this.getEventSource(), name, object);
},
disconnect: function(token){
// summary: connects a handler by token from an event on this shape
 
// COULD BE RE-IMPLEMENTED BY THE RENDERER!
 
dojo.disconnect(token);
}
};
 
dojo.extend(dojox.gfx.Shape, dojox.gfx.shape._eventsProcessing);
 
dojox.gfx.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 = [];
},
// group management
add: function(shape){
// summary: adds a shape to the list
// shape: dojox.gfx.Shape: a shape
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
// 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._setParent(null, null);
}
this.children.splice(i, 1);
break;
}
}
return this; // self
},
clear: function(){
// summary: removes all shapes from a group/surface
this.children = [];
return this; // self
},
// moving child nodes
_moveChildToFront: function(shape){
// summary: moves a shape to front of the list of shapes
for(var i = 0; i < this.children.length; ++i){
if(this.children[i] == shape){
this.children.splice(i, 1);
this.children.push(shape);
break;
}
}
return this; // self
},
_moveChildToBack: function(shape){
// summary: moves a shape to back of the list of shapes
for(var i = 0; i < this.children.length; ++i){
if(this.children[i] == shape){
this.children.splice(i, 1);
this.children.unshift(shape);
break;
}
}
return this; // self
}
};
 
dojo.declare("dojox.gfx.shape.Surface", null, {
// summary: a surface object to be used for drawings
constructor: function(){
// underlying node
this.rawNode = 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
}
});
 
dojo.extend(dojox.gfx.shape.Surface, dojox.gfx.shape._eventsProcessing);
 
dojo.declare("dojox.gfx.Point", null, {
// summary: a hypothetical 2D point to be used for drawings - {x, y}
// description: This object is defined for documentation purposes.
// You should use the naked object instead: {x: 1, y: 2}.
});
 
dojo.declare("dojox.gfx.Rectangle", null, {
// summary: a hypothetical rectangle - {x, y, width, height}
// description: This object is defined for documentation purposes.
// You should use the naked object instead: {x: 1, y: 2, width: 100, height: 200}.
});
 
dojo.declare("dojox.gfx.shape.Rect", dojox.gfx.Shape, {
// summary: a generic rectangle
constructor: function(rawNode) {
// rawNode: Node: a DOM Node
this.shape = dojo.clone(dojox.gfx.defaultRect);
this.rawNode = rawNode;
},
getBoundingBox: function(){
// summary: returns the bounding box (its shape in this case)
return this.shape; // dojox.gfx.Rectangle
}
});
 
dojo.declare("dojox.gfx.shape.Ellipse", dojox.gfx.Shape, {
// summary: a generic ellipse
constructor: function(rawNode) {
// rawNode: Node: a DOM Node
this.shape = dojo.clone(dojox.gfx.defaultEllipse);
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
}
});
 
dojo.declare("dojox.gfx.shape.Circle", dojox.gfx.Shape, {
// summary: a generic circle
// (this is a helper object, which is defined for convenience)
constructor: function(rawNode) {
// rawNode: Node: a DOM Node
this.shape = dojo.clone(dojox.gfx.defaultCircle);
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
}
});
 
dojo.declare("dojox.gfx.shape.Line", dojox.gfx.Shape, {
// summary: a generic line
// (this is a helper object, which is defined for convenience)
constructor: function(rawNode) {
// rawNode: Node: a DOM Node
this.shape = dojo.clone(dojox.gfx.defaultLine);
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
}
});
 
dojo.declare("dojox.gfx.shape.Polyline", dojox.gfx.Shape, {
// summary: a generic polyline/polygon
// (this is a helper object, which is defined for convenience)
constructor: function(rawNode) {
// rawNode: Node: a DOM Node
this.shape = dojo.clone(dojox.gfx.defaultPolyline);
this.rawNode = rawNode;
},
setShape: function(points, closed){
// summary: sets a polyline/polygon shape object
// points: Object: a polyline/polygon shape object
// closed: Boolean: close the polyline to make a polygon
if(points && points instanceof Array){
// points: Array: an array of points
dojox.gfx.Shape.prototype.setShape.call(this, {points: points});
if(closed && this.shape.points.length){
this.shape.points.push(this.shape.points[0]);
}
}else{
dojox.gfx.Shape.prototype.setShape.call(this, points);
}
return this; // self
},
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
}
});
 
dojo.declare("dojox.gfx.shape.Image", dojox.gfx.Shape, {
// summary: a generic image
// (this is a helper object, which is defined for convenience)
constructor: function(rawNode) {
// rawNode: Node: a DOM Node
this.shape = dojo.clone(dojox.gfx.defaultImage);
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
}
});
 
dojo.declare("dojox.gfx.shape.Text", dojox.gfx.Shape, {
// summary: a generic text
constructor: function(rawNode) {
// rawNode: Node: a DOM Node
this.fontStyle = null;
this.shape = dojo.clone(dojox.gfx.defaultText);
this.rawNode = rawNode;
},
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" ? dojox.gfx.splitFontString(newFont) :
dojox.gfx.makeParameters(dojox.gfx.defaultFont, newFont);
this._setFont();
return this; // self
}
});
 
dojox.gfx.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
switch(shape.type){
case dojox.gfx.defaultPath.type: return this.createPath(shape);
case dojox.gfx.defaultRect.type: return this.createRect(shape);
case dojox.gfx.defaultCircle.type: return this.createCircle(shape);
case dojox.gfx.defaultEllipse.type: return this.createEllipse(shape);
case dojox.gfx.defaultLine.type: return this.createLine(shape);
case dojox.gfx.defaultPolyline.type: return this.createPolyline(shape);
case dojox.gfx.defaultImage.type: return this.createImage(shape);
case dojox.gfx.defaultText.type: return this.createText(shape);
case dojox.gfx.defaultTextPath.type: return this.createTextPath(shape);
}
return null;
},
createGroup: function(){
// summary: creates an SVG group shape
return this.createObject(dojox.gfx.Group); // dojox.gfx.Group
},
createRect: function(rect){
// summary: creates an SVG rectangle shape
// rect: Object: a path object (see dojox.gfx.defaultRect)
return this.createObject(dojox.gfx.Rect, rect); // dojox.gfx.Rect
},
createEllipse: function(ellipse){
// summary: creates an SVG ellipse shape
// ellipse: Object: an ellipse object (see dojox.gfx.defaultEllipse)
return this.createObject(dojox.gfx.Ellipse, ellipse); // dojox.gfx.Ellipse
},
createCircle: function(circle){
// summary: creates an SVG circle shape
// circle: Object: a circle object (see dojox.gfx.defaultCircle)
return this.createObject(dojox.gfx.Circle, circle); // dojox.gfx.Circle
},
createLine: function(line){
// summary: creates an SVG line shape
// line: Object: a line object (see dojox.gfx.defaultLine)
return this.createObject(dojox.gfx.Line, line); // dojox.gfx.Line
},
createPolyline: function(points){
// summary: creates an SVG polyline/polygon shape
// points: Object: a points object (see dojox.gfx.defaultPolyline)
// or an Array of points
return this.createObject(dojox.gfx.Polyline, points); // dojox.gfx.Polyline
},
createImage: function(image){
// summary: creates an SVG image shape
// image: Object: an image object (see dojox.gfx.defaultImage)
return this.createObject(dojox.gfx.Image, image); // dojox.gfx.Image
},
createText: function(text){
// summary: creates an SVG text shape
// text: Object: a text object (see dojox.gfx.defaultText)
return this.createObject(dojox.gfx.Text, text); // dojox.gfx.Text
},
createPath: function(path){
// summary: creates an SVG path shape
// path: Object: a path object (see dojox.gfx.defaultPath)
return this.createObject(dojox.gfx.Path, path); // dojox.gfx.Path
},
createTextPath: function(text){
// summary: creates an SVG text shape
// text: Object: a textpath object (see dojox.gfx.defaultTextPath)
return this.createObject(dojox.gfx.TextPath, {}).setText(text); // dojox.gfx.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
}
};
 
}
/trunk/api/js/dojo1.0/dojox/gfx/matrix.js
New file
0,0 → 1,444
if(!dojo._hasResource["dojox.gfx.matrix"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.matrix"] = true;
dojo.provide("dojox.gfx.matrix");
 
(function(){
var m = dojox.gfx.matrix;
// candidates for dojox.math:
m._degToRad = function(degree){ return 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 = dojox.gfx.matrix.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;
}
dojo.mixin(this, matrix);
}
}else{
dojo.mixin(this, arg);
}
}
};
 
// the default (identity) matrix, which is used to fill in missing values
dojo.extend(m.Matrix2D, {xx: 1, xy: 0, yx: 0, yy: 1, dx: 0, dy: 0});
 
dojo.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: an x coordinate value
// b: Number: a y coordinate value
if(arguments.length > 1){
return new m.Matrix2D({dx: a, dy: b}); // dojox.gfx.matrix.Matrix2D
}
// branch
// a: dojox.gfx.Point: a point-like object, which specifies offsets for both dimensions
// b: null
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: a scaling factor used for the x coordinate
// b: Number: a scaling factor used for the y coordinate
if(arguments.length > 1){
return new m.Matrix2D({xx: a, yy: b}); // dojox.gfx.matrix.Matrix2D
}
if(typeof a == "number"){
// branch
// a: Number: a uniform scaling factor used for the both coordinates
// b: null
return new m.Matrix2D({xx: a, yy: a}); // dojox.gfx.matrix.Matrix2D
}
// branch
// a: dojox.gfx.Point: a point-like object, which specifies scale factors for both dimensions
// b: null
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)
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)
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: an skewing angle in radians
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: an skewing angle in degrees
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: an skewing angle in radians
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: an skewing angle in degrees
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: a point-like object, which specifies a vector of reflection
// b: null
if(arguments.length == 1){
b = a.y;
a = a.x;
}
// branch
// a: Number: an x coordinate value
// b: Number: a y coordinate value
// 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: a point-like object, which specifies a vector of projection
// b: null
if(arguments.length == 1){
b = a.y;
a = a.x;
}
// branch
// a: Number: an x coordinate value
// b: Number: a y coordinate value
// 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
return (matrix instanceof m.Matrix2D) ? matrix : new m.Matrix2D(matrix); // dojox.gfx.matrix.Matrix2D
},
// common operations
clone: function(matrix){
// summary: creates a copy of a 2D matrix
// matrix: dojox.gfx.matrix.Matrix2D: a 2D matrix-like object to be cloned
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
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
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, optional */ b){
// summary: applies a matrix to a point
// matrix: dojox.gfx.matrix.Matrix2D: a 2D matrix object to be applied
// a: Number: an x coordinate of a point
// b: Number: a y coordinate of a point
var M = m.normalize(matrix);
if(typeof a == "number" && typeof b == "number"){
return m._multiplyPoint(M, a, b); // dojox.gfx.Point
}
// branch
// matrix: dojox.gfx.matrix.Matrix2D: a 2D matrix object to be applied
// a: dojox.gfx.Point: a point
// b: null
return m._multiplyPoint(M, a.x, a.y); // dojox.gfx.Point
},
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 centrtal 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
// b: Number: a scaling factor used for the y coordinate
// c: Number: an x component of a central point
// d: Number: a y component of a central point
// accepts several signatures:
// 1) uniform scale factor, Point
// 2) uniform scale factor, x, y
// 3) x scale, y scale, Point
// 4) x scale, y scale, x, y
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"){
// branch
// a: Number: a uniform scaling factor used for both coordinates
// b: Number: an x component of a central point
// c: Number: a y component of a central point
// d: null
return m._sandwich(m.scale(a), b, c); // dojox.gfx.matrix.Matrix2D
}
// branch
// a: Number: a scaling factor used for the x coordinate
// b: Number: a scaling factor used for the y coordinate
// c: dojox.gfx.Point: a central point
// d: null
return m._sandwich(m.scale(a, b), c.x, c.y); // dojox.gfx.matrix.Matrix2D
}
// branch
// a: Number: a uniform scaling factor used for both coordinates
// b: dojox.gfx.Point: a central point
// c: null
// d: null
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: an x component of a central point
// b: Number: a y component of a central point
// accepts several signatures:
// 1) rotation angle in radians, Point
// 2) rotation angle in radians, x, y
if(arguments.length > 2){
return m._sandwich(m.rotate(angle), a, b); // dojox.gfx.matrix.Matrix2D
}
// branch
// angle: Number: an angle of rotation in radians (>0 for CCW)
// a: dojox.gfx.Point: a central point
// b: null
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: an x component of a central point
// b: Number: a y component of a central point
// accepts several signatures:
// 1) rotation angle in degrees, Point
// 2) rotation angle in degrees, x, y
if(arguments.length > 2){
return m._sandwich(m.rotateg(degree), a, b); // dojox.gfx.matrix.Matrix2D
}
 
// branch
// degree: Number: an angle of rotation in degrees (>0 for CCW)
// a: dojox.gfx.Point: a central point
// b: null
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: an skewing angle in radians
// a: Number: an x component of a central point
// b: Number: a y component of a central point
// accepts several signatures:
// 1) skew angle in radians, Point
// 2) skew angle in radians, x, y
if(arguments.length > 2){
return m._sandwich(m.skewX(angle), a, b); // dojox.gfx.matrix.Matrix2D
}
 
// branch
// angle: Number: an skewing angle in radians
// a: dojox.gfx.Point: a central point
// b: null
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: an skewing angle in degrees
// a: Number: an x component of a central point
// b: Number: a y component of a central point
// accepts several signatures:
// 1) skew angle in degrees, Point
// 2) skew angle in degrees, x, y
 
if(arguments.length > 2){
return m._sandwich(m.skewXg(degree), a, b); // dojox.gfx.matrix.Matrix2D
}
 
// branch
// degree: Number: an skewing angle in degrees
// a: dojox.gfx.Point: a central point
// b: null
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: an skewing angle in radians
// a: Number: an x component of a central point
// b: Number: a y component of a central point
// accepts several signatures:
// 1) skew angle in radians, Point
// 2) skew angle in radians, x, y
if(arguments.length > 2){
return m._sandwich(m.skewY(angle), a, b); // dojox.gfx.matrix.Matrix2D
}
 
// branch
// angle: Number: an skewing angle in radians
// a: dojox.gfx.Point: a central point
// b: null
return m._sandwich(m.skewY(angle), a.x, a.y); // dojox.gfx.matrix.Matrix2D
},
skewYgAt: function(/* Number */ degree, /* Number||Point */ a, /* Number, optional */ 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: an skewing angle in degrees
// a: Number: an x component of a central point
// b: Number: a y component of a central point
// accepts several signatures:
// 1) skew angle in degrees, Point
// 2) skew angle in degrees, x, y
 
if(arguments.length > 2){
return m._sandwich(m.skewYg(degree), a, b); // dojox.gfx.matrix.Matrix2D
}
 
// branch
// degree: Number: an skewing angle in degrees
// a: dojox.gfx.Point: a central point
// b: null
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
dojox.gfx.Matrix2D = dojox.gfx.matrix.Matrix2D;
 
}
/trunk/api/js/dojo1.0/dojox/gfx/attach.js
New file
0,0 → 1,7
dojo.require("dojox.gfx");
 
// include an attacher conditionally
dojo.requireIf(dojox.gfx.renderer == "svg", "dojox.gfx.svg_attach");
dojo.requireIf(dojox.gfx.renderer == "vml", "dojox.gfx.vml_attach");
dojo.requireIf(dojox.gfx.renderer == "silverlight", "dojox.gfx.silverlight_attach");
dojo.requireIf(dojox.gfx.renderer == "canvas", "dojox.gfx.canvas_attach");
/trunk/api/js/dojo1.0/dojox/gfx/arc.js
New file
0,0 → 1,122
if(!dojo._hasResource["dojox.gfx.arc"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.arc"] = true;
dojo.provide("dojox.gfx.arc");
 
dojo.require("dojox.gfx.matrix");
 
(function(){
var m = dojox.gfx.matrix,
unitArcAsBezier = function(alpha){
// summary: return a start point, 1st and 2nd control points, and an end point of
// a an arc, which is reflected on the x axis
// alpha: Number: angle in radians, the arc will be 2 * angle size
var cosa = Math.cos(alpha), sina = Math.sin(alpha),
p2 = {x: cosa + (4 / 3) * (1 - cosa), y: sina - (4 / 3) * cosa * (1 - cosa) / sina};
return { // Object
s: {x: cosa, y: -sina},
c1: {x: p2.x, y: -p2.y},
c2: p2,
e: {x: cosa, y: sina}
};
},
twoPI = 2 * Math.PI, pi4 = Math.PI / 4, pi8 = Math.PI / 8,
pi48 = pi4 + pi8, curvePI4 = unitArcAsBezier(pi8);
 
dojo.mixin(dojox.gfx.arc, {
unitArcAsBezier: unitArcAsBezier,
curvePI4: curvePI4,
arcAsBezier: function(last, rx, ry, xRotg, large, sweep, x, y){
// summary: calculates an arc as a series of Bezier curves
// given the last point and a standard set of SVG arc parameters,
// it returns an array of arrays of parameters to form a series of
// absolute Bezier curves.
// last: Object: a point-like object as a start of the arc
// rx: Number: a horizontal radius for the virtual ellipse
// ry: Number: a vertical radius for the virtual ellipse
// xRotg: Number: a rotation of an x axis of the virtual ellipse in degrees
// large: Boolean: which part of the ellipse will be used (the larger arc if true)
// sweep: Boolean: direction of the arc (CW if true)
// x: Number: the x coordinate of the end point of the arc
// y: Number: the y coordinate of the end point of the arc
// calculate parameters
large = Boolean(large);
sweep = Boolean(sweep);
var xRot = m._degToRad(xRotg),
rx2 = rx * rx, ry2 = ry * ry,
pa = m.multiplyPoint(
m.rotate(-xRot),
{x: (last.x - x) / 2, y: (last.y - y) / 2}
),
pax2 = pa.x * pa.x, pay2 = pa.y * pa.y,
c1 = Math.sqrt((rx2 * ry2 - rx2 * pay2 - ry2 * pax2) / (rx2 * pay2 + ry2 * pax2));
if(isNaN(c1)){ c1 = 0; }
var ca = {
x: c1 * rx * pa.y / ry,
y: -c1 * ry * pa.x / rx
};
if(large == sweep){
ca = {x: -ca.x, y: -ca.y};
}
// the center
var c = m.multiplyPoint(
[
m.translate(
(last.x + x) / 2,
(last.y + y) / 2
),
m.rotate(xRot)
],
ca
);
// calculate the elliptic transformation
var elliptic_transform = m.normalize([
m.translate(c.x, c.y),
m.rotate(xRot),
m.scale(rx, ry)
]);
// start, end, and size of our arc
var inversed = m.invert(elliptic_transform),
sp = m.multiplyPoint(inversed, last),
ep = m.multiplyPoint(inversed, x, y),
startAngle = Math.atan2(sp.y, sp.x),
endAngle = Math.atan2(ep.y, ep.x),
theta = startAngle - endAngle; // size of our arc in radians
if(sweep){ theta = -theta; }
if(theta < 0){
theta += twoPI;
}else if(theta > twoPI){
theta -= twoPI;
}
// draw curve chunks
var alpha = pi8, curve = curvePI4, step = sweep ? alpha : -alpha,
result = [];
for(var angle = theta; angle > 0; angle -= pi4){
if(angle < pi48){
alpha = angle / 2;
curve = unitArcAsBezier(alpha);
step = sweep ? alpha : -alpha;
angle = 0; // stop the loop
}
var c1, c2, e,
M = m.normalize([elliptic_transform, m.rotate(startAngle + step)]);
if(sweep){
c1 = m.multiplyPoint(M, curve.c1);
c2 = m.multiplyPoint(M, curve.c2);
e = m.multiplyPoint(M, curve.e );
}else{
c1 = m.multiplyPoint(M, curve.c2);
c2 = m.multiplyPoint(M, curve.c1);
e = m.multiplyPoint(M, curve.s );
}
// draw the curve
result.push([c1.x, c1.y, c2.x, c2.y, e.x, e.y]);
startAngle += 2 * step;
}
return result; // Object
}
});
})();
 
}
/trunk/api/js/dojo1.0/dojox/gfx/move.js
New file
0,0 → 1,114
if(!dojo._hasResource["dojox.gfx.move"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.move"] = true;
dojo.provide("dojox.gfx.move");
dojo.experimental("dojox.gfx.move");
 
dojox.gfx.Mover = function(shape, e){
// summary: an object, which makes a shape follow the mouse,
// used as a default mover, and as a base class for custom movers
// shape: dojox.gfx.Shape: a shape object to be moved
// e: Event: a mouse event, which started the move;
// only clientX and clientY properties are used
this.shape = shape;
this.lastX = e.clientX
this.lastY = e.clientY;
var d = document, firstEvent = dojo.connect(d, "onmousemove", this, "onFirstMove");
this.events = [
dojo.connect(d, "onmousemove", this, "onMouseMove"),
dojo.connect(d, "onmouseup", this, "destroy"),
// cancel text selection and text dragging
dojo.connect(d, "ondragstart", dojo, "stopEvent"),
dojo.connect(d, "onselectstart", dojo, "stopEvent"),
firstEvent
];
// set globals to indicate that move has started
dojo.publish("/gfx/move/start", [this]);
dojo.addClass(dojo.body(), "dojoMove");
};
 
dojo.extend(dojox.gfx.Mover, {
// mouse event processors
onMouseMove: function(e){
// summary: event processor for onmousemove
// e: Event: mouse event
var x = e.clientX;
var y = e.clientY;
this.shape.applyLeftTransform({dx: x - this.lastX, dy: y - this.lastY});
this.lastX = x;
this.lastY = y;
dojo.stopEvent(e);
},
// utilities
onFirstMove: function(){
// summary: it is meant to be called only once
dojo.disconnect(this.events.pop());
},
destroy: function(){
// summary: stops the move, deletes all references, so the object can be garbage-collected
dojo.forEach(this.events, dojo.disconnect);
// undo global settings
dojo.publish("/gfx/move/stop", [this]);
dojo.removeClass(dojo.body(), "dojoMove");
// destroy objects
this.events = this.shape = null;
}
});
 
dojox.gfx.Moveable = function(shape, params){
// summary: an object, which makes a shape moveable
// shape: dojox.gfx.Shape: a shape object to be moved
// params: Object: an optional object with additional parameters;
// following parameters are recognized:
// delay: Number: delay move by this number of pixels
// mover: Object: a constructor of custom Mover
this.shape = shape;
this.delay = (params && params.delay > 0) ? params.delay : 0;
this.mover = (params && params.mover) ? params.mover : dojox.gfx.Mover;
this.events = [
this.shape.connect("onmousedown", this, "onMouseDown"),
// cancel text selection and text dragging
//dojo.connect(this.handle, "ondragstart", dojo, "stopEvent"),
//dojo.connect(this.handle, "onselectstart", dojo, "stopEvent")
];
};
 
dojo.extend(dojox.gfx.Moveable, {
// methods
destroy: function(){
// summary: stops watching for possible move, deletes all references, so the object can be garbage-collected
dojo.forEach(this.events, "disconnect", this.shape);
this.events = this.shape = null;
},
// mouse event processors
onMouseDown: function(e){
// summary: event processor for onmousedown, creates a Mover for the shape
// e: Event: mouse event
if(this.delay){
this.events.push(this.shape.connect("onmousemove", this, "onMouseMove"));
this.events.push(this.shape.connect("onmouseup", this, "onMouseUp"));
this._lastX = e.clientX;
this._lastY = e.clientY;
}else{
new this.mover(this.shape, e);
}
dojo.stopEvent(e);
},
onMouseMove: function(e){
// summary: event processor for onmousemove, used only for delayed drags
// e: Event: mouse event
if(Math.abs(e.clientX - this._lastX) > this.delay || Math.abs(e.clientY - this._lastY) > this.delay){
this.onMouseUp(e);
new this.mover(this.shape, e);
}
dojo.stopEvent(e);
},
onMouseUp: function(e){
// summary: event processor for onmouseup, used only for delayed delayed drags
// e: Event: mouse event
this.shape.disconnect(this.events.pop());
this.shape.disconnect(this.events.pop());
}
});
 
}
/trunk/api/js/dojo1.0/dojox/gfx/_base.js
New file
0,0 → 1,250
if(!dojo._hasResource["dojox.gfx._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx._base"] = true;
dojo.provide("dojox.gfx._base");
 
// candidates for dojox.style (work on VML and SVG nodes)
dojox.gfx._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
return ((" "+node.getAttribute("className")+" ").indexOf(" "+classStr+" ") >= 0); // Boolean
}
 
dojox.gfx._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+" ").indexOf(" "+classStr+" ") < 0){
node.setAttribute("className", cls + (cls ? ' ' : '') + classStr);
}
}
 
dojox.gfx._removeClass = function(/*DomNode*/node, /*String*/classStr){
// summary: Removes classes from node.
node.setAttribute("className", node.getAttribute("className").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
dojox.gfx._base._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
};
 
if(dojo.isIE){
// 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.
dojo.doc.documentElement.style.fontSize="100%";
}
 
// set up the measuring node.
var div=dojo.doc.createElement("div");
div.style.position="absolute";
div.style.left="-100px";
div.style.top="0";
div.style.width="30px";
div.style.height="1000em";
div.style.border="0";
div.style.margin="0";
div.style.padding="0";
div.style.outline="0";
div.style.lineHeight="1";
div.style.overflow="hidden";
dojo.body().appendChild(div);
 
// do the measurements.
for(var p in heights){
div.style.fontSize = p;
heights[p] = Math.round(div.offsetHeight * 12/16) * 16/12 / 1000;
}
dojo.body().removeChild(div);
div = null;
return heights; // object
};
 
dojox.gfx._base._fontMeasurements = null;
 
dojox.gfx._base._getCachedFontMeasurements = function(recalculate){
if(recalculate || !dojox.gfx._base._fontMeasurements){
dojox.gfx._base._fontMeasurements = dojox.gfx._base._getFontMeasurements();
}
return dojox.gfx._base._fontMeasurements;
};
 
// candidate for dojo.dom
 
dojox.gfx._base._uniqueId = 0;
dojox.gfx._base._getUniqueId = function(){
// summary: returns a unique string for use with any DOM element
var id;
do{
id = "dojoUnique" + (++dojox.gfx._base._uniqueId);
}while(dojo.byId(id));
return id;
};
 
dojo.mixin(dojox.gfx, {
// summary: defines constants, prototypes, and utility functions
// default shapes, which are used to fill in missing parameters
defaultPath: {type: "path", path: ""},
defaultPolyline: {type: "polyline", points: []},
defaultRect: {type: "rect", x: 0, y: 0, width: 100, height: 100, r: 0},
defaultEllipse: {type: "ellipse", cx: 0, cy: 0, rx: 200, ry: 100},
defaultCircle: {type: "circle", cx: 0, cy: 0, r: 100},
defaultLine: {type: "line", x1: 0, y1: 0, x2: 100, y2: 100},
defaultImage: {type: "image", x: 0, y: 0, width: 0, height: 0, src: ""},
defaultText: {type: "text", x: 0, y: 0, text: "",
align: "start", decoration: "none", rotated: false, kerning: true },
defaultTextPath: {type: "textpath", text: "",
align: "start", decoration: "none", rotated: false, kerning: true },
 
// default geometric attributes
defaultStroke: {type: "stroke", color: "black", style: "solid", width: 1, cap: "butt", join: 4},
defaultLinearGradient: {type: "linear", x1: 0, y1: 0, x2: 100, y2: 100,
colors: [{offset: 0, color: "black"}, {offset: 1, color: "white"}]},
defaultRadialGradient: {type: "radial", cx: 0, cy: 0, r: 100,
colors: [{offset: 0, color: "black"}, {offset: 1, color: "white"}]},
defaultPattern: {type: "pattern", x: 0, y: 0, width: 0, height: 0, src: ""},
defaultFont: {type: "font", style: "normal", variant: "normal", weight: "normal",
size: "10pt", family: "serif"},
 
normalizeColor: function(/*Color*/ color){
// summary: converts any legal color representation to normalized dojo.Color object
return (color instanceof dojo.Color) ? color : new dojo.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
if(update){
var empty = {};
for(var 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
if(!update) return dojo.clone(defaults);
var result = {};
for(var i in defaults){
if(!(i in result)){
result[i] = dojo.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?: if it is true, add a space before a positive number
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
// str: String: a CSS font string
var font = dojo.clone(dojox.gfx.defaultFont);
var t = str.split(/\s+/);
do{
if(t.length < 5){ break; }
font.style = t[0];
font.varian = 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;
break;
}
if(t[4].substr(0, 1) == "/"){
j = 5;
break;
}
}
if(j + 3 > t.length){ break; }
font.size = t[j];
font.family = t[j + 1];
}while(false);
return font; // Object
},
// length operations
cm_in_pt: 72 / 2.54, // Number: centimeters per inch
mm_in_pt: 7.2 / 2.54, // Number: millimeters per inch
px_in_pt: function(){
// summary: returns a number of pixels per point
return dojox.gfx._base._getCachedFontMeasurements()["12pt"] / 12; // Number
},
pt2px: function(len){
// summary: converts points to pixels
// len: Number: a value in points
return len * dojox.gfx.px_in_pt(); // Number
},
px2pt: function(len){
// summary: converts pixels to points
// len: Number: a value in pixels
return len / dojox.gfx.px_in_pt(); // Number
},
normalizedLength: function(len) {
// summary: converts any length value to pixels
// len: String: a length, e.g., "12pc"
if(len.length == 0) return 0;
if(len.length > 2){
var px_in_pt = dojox.gfx.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 / dojox.gfx.mm_in_pt * px_in_pt;
case "cm": return val / dojox.gfx.cm_in_pt * px_in_pt;
}
}
return parseFloat(len); // Number
},
// a constant used to split a SVG/VML path into primitive components
pathVmlRegExp: /([A-Za-z]+)|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g,
pathSvgRegExp: /([A-Za-z])|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g,
equalSources: function(a, b){
// summary: compares event sources, returns true if they are equal
return a && b && a == b;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/gfx/canvas.js
New file
0,0 → 1,682
if(!dojo._hasResource["dojox.gfx.canvas"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.canvas"] = true;
dojo.provide("dojox.gfx.canvas");
 
dojo.require("dojox.gfx._base");
dojo.require("dojox.gfx.shape");
dojo.require("dojox.gfx.path");
dojo.require("dojox.gfx.arc");
dojo.require("dojox.gfx.decompose");
 
dojo.experimental("dojox.gfx.canvas");
 
(function(){
var g = dojox.gfx, gs = g.shape, ga = g.arc,
m = g.matrix, mp = m.multiplyPoint, twoPI = 2 * Math.PI;
dojo.extend(g.Shape, {
render: function(/* Object */ ctx){
// summary: render the shape
ctx.save();
this._renderTransform(ctx);
this._renderShape(ctx);
this._renderFill(ctx, true);
this._renderStroke(ctx, true);
ctx.restore();
},
_renderTransform: function(/* Object */ ctx){
if("canvasTransform" in this){
var t = this.canvasTransform;
ctx.translate(t.dx, t.dy);
ctx.rotate(t.angle2);
ctx.scale(t.sx, t.sy);
ctx.rotate(t.angle1);
// The future implementation when vendors catch up with the spec:
// var t = this.matrix;
// ctx.transform(t.xx, t.yx, t.xy, t.yy, t.dx, t.dy);
}
},
_renderShape: function(/* Object */ ctx){
// nothing
},
_renderFill: function(/* Object */ ctx, /* Boolean */ apply){
if("canvasFill" in this){
if("canvasFillImage" in this){
this.canvasFill = ctx.createPattern(this.canvasFillImage, "repeat");
delete this.canvasFillImage;
}
ctx.fillStyle = this.canvasFill;
if(apply){ ctx.fill(); }
}else{
ctx.fillStyle = "rgba(0,0,0,0.0)";
}
},
_renderStroke: function(/* Object */ ctx, /* Boolean */ apply){
var s = this.strokeStyle;
if(s){
ctx.strokeStyle = s.color.toString();
ctx.lineWidth = s.width;
ctx.lineCap = s.cap;
if(typeof s.join == "number"){
ctx.lineJoin = "miter";
ctx.miterLimit = s.join;
}else{
ctx.lineJoin = s.join;
}
if(apply){ ctx.stroke(); }
}else if(!apply){
ctx.strokeStyle = "rgba(0,0,0,0.0)";
}
},
// events are not implemented
getEventSource: function(){ return null; },
connect: function(){},
disconnect: function(){}
});
var modifyMethod = function(shape, method, extra){
var old = shape.prototype[method];
shape.prototype[method] = extra ?
function(){
this.surface.makeDirty();
old.apply(this, arguments);
extra.call(this);
return this;
} :
function(){
this.surface.makeDirty();
return old.apply(this, arguments);
};
};
 
modifyMethod(g.Shape, "setTransform",
function(){
// prepare Canvas-specific structures
if(this.matrix){
this.canvasTransform = g.decompose(this.matrix);
}else{
delete this.canvasTransform;
}
});
 
modifyMethod(g.Shape, "setFill",
function(){
// prepare Canvas-specific structures
var fs = this.fillStyle, f;
if(fs){
if(typeof(fs) == "object" && "type" in fs){
var ctx = this.surface.rawNode.getContext("2d");
switch(fs.type){
case "linear":
case "radial":
f = fs.type == "linear" ?
ctx.createLinearGradient(fs.x1, fs.y1, fs.x2, fs.y2) :
ctx.createRadialGradient(fs.cx, fs.cy, 0, fs.cx, fs.cy, fs.r);
dojo.forEach(fs.colors, function(step){
f.addColorStop(step.offset, g.normalizeColor(step.color).toString());
});
break;
case "pattern":
var img = new Image(fs.width, fs.height);
this.surface.downloadImage(img, fs.src);
this.canvasFillImage = img;
}
}else{
// Set fill color using CSS RGBA func style
f = fs.toString();
}
this.canvasFill = f;
}else{
delete this.canvasFill;
}
});
modifyMethod(g.Shape, "setStroke");
modifyMethod(g.Shape, "setShape");
dojo.declare("dojox.gfx.Group", g.Shape, {
// summary: a group shape (Canvas), which can be used
// to logically group shapes (e.g, to propagate matricies)
constructor: function(){
gs.Container._init.call(this);
},
render: function(/* Object */ ctx){
// summary: render the group
ctx.save();
this._renderTransform(ctx);
this._renderFill(ctx);
this._renderStroke(ctx);
for(var i = 0; i < this.children.length; ++i){
this.children[i].render(ctx);
}
ctx.restore();
}
});
 
dojo.declare("dojox.gfx.Rect", gs.Rect, {
// summary: a rectangle shape (Canvas)
_renderShape: function(/* Object */ ctx){
var s = this.shape, r = Math.min(s.r, s.height / 2, s.width / 2),
xl = s.x, xr = xl + s.width, yt = s.y, yb = yt + s.height,
xl2 = xl + r, xr2 = xr - r, yt2 = yt + r, yb2 = yb - r;
ctx.beginPath();
ctx.moveTo(xl2, yt);
ctx.lineTo(xr2, yt);
if(r){ ctx.arcTo(xr, yt, xr, yt2, r); }
ctx.lineTo(xr, yb2);
if(r){ ctx.arcTo(xr, yb, xr2, yb, r); }
ctx.lineTo(xl2, yb);
if(r){ ctx.arcTo(xl, yb, xl, yb2, r); }
ctx.lineTo(xl, yt2);
if(r){ ctx.arcTo(xl, yt, xl2, yt, r); }
ctx.closePath();
}
});
var bezierCircle = [];
(function(){
var u = ga.curvePI4;
bezierCircle.push(u.s, u.c1, u.c2, u.e);
for(var a = 45; a < 360; a += 45){
var r = m.rotateg(a);
bezierCircle.push(mp(r, u.c1), mp(r, u.c2), mp(r, u.e));
}
})();
dojo.declare("dojox.gfx.Ellipse", gs.Ellipse, {
// summary: an ellipse shape (Canvas)
setShape: function(){
g.Ellipse.superclass.setShape.apply(this, arguments);
// prepare Canvas-specific structures
var s = this.shape, t, c1, c2, r = [],
M = m.normalize([m.translate(s.cx, s.cy), m.scale(s.rx, s.ry)]);
t = mp(M, bezierCircle[0]);
r.push([t.x, t.y]);
for(var i = 1; i < bezierCircle.length; i += 3){
c1 = mp(M, bezierCircle[i]);
c2 = mp(M, bezierCircle[i + 1]);
t = mp(M, bezierCircle[i + 2]);
r.push([c1.x, c1.y, c2.x, c2.y, t.x, t.y]);
}
this.canvasEllipse = r;
return this;
},
_renderShape: function(/* Object */ ctx){
var r = this.canvasEllipse;
ctx.beginPath();
ctx.moveTo.apply(ctx, r[0]);
for(var i = 1; i < r.length; ++i){
ctx.bezierCurveTo.apply(ctx, r[i]);
}
ctx.closePath();
}
});
 
dojo.declare("dojox.gfx.Circle", gs.Circle, {
// summary: a circle shape (Canvas)
_renderShape: function(/* Object */ ctx){
var s = this.shape;
ctx.beginPath();
ctx.arc(s.cx, s.cy, s.r, 0, twoPI, 1);
}
});
 
dojo.declare("dojox.gfx.Line", gs.Line, {
// summary: a line shape (Canvas)
_renderShape: function(/* Object */ ctx){
var s = this.shape;
ctx.beginPath();
ctx.moveTo(s.x1, s.y1);
ctx.lineTo(s.x2, s.y2);
}
});
 
dojo.declare("dojox.gfx.Polyline", gs.Polyline, {
// summary: a polyline/polygon shape (Canvas)
setShape: function(){
g.Polyline.superclass.setShape.apply(this, arguments);
// prepare Canvas-specific structures
var p = this.shape.points, f = p[0], r = [], c, i;
if(p.length){
if(typeof f == "number"){
r.push(f, p[1]);
i = 2;
}else{
r.push(f.x, f.y);
i = 1;
}
for(; i < p.length; ++i){
c = p[i];
if(typeof c == "number"){
r.push(c, p[++i]);
}else{
r.push(c.x, c.y);
}
}
}
this.canvasPolyline = r;
return this;
},
_renderShape: function(/* Object */ ctx){
var p = this.canvasPolyline;
if(p.length){
ctx.beginPath();
ctx.moveTo(p[0], p[1]);
for(var i = 2; i < p.length; i += 2){
ctx.lineTo(p[i], p[i + 1]);
}
}
}
});
dojo.declare("dojox.gfx.Image", gs.Image, {
// summary: an image shape (Canvas)
setShape: function(){
g.Image.superclass.setShape.apply(this, arguments);
// prepare Canvas-specific structures
var img = new Image();
this.surface.downloadImage(img, this.shape.src);
this.canvasImage = img;
return this;
},
_renderShape: function(/* Object */ ctx){
var s = this.shape;
ctx.drawImage(this.canvasImage, s.x, s.y, s.width, s.height);
}
});
dojo.declare("dojox.gfx.Text", gs.Text, {
// summary: a text shape (Canvas)
_renderShape: function(/* Object */ ctx){
var s = this.shape;
// nothing for the moment
}
});
modifyMethod(g.Text, "setFont");
var pathRenderers = {
M: "_moveToA", m: "_moveToR",
L: "_lineToA", l: "_lineToR",
H: "_hLineToA", h: "_hLineToR",
V: "_vLineToA", v: "_vLineToR",
C: "_curveToA", c: "_curveToR",
S: "_smoothCurveToA", s: "_smoothCurveToR",
Q: "_qCurveToA", q: "_qCurveToR",
T: "_qSmoothCurveToA", t: "_qSmoothCurveToR",
A: "_arcTo", a: "_arcTo",
Z: "_closePath", z: "_closePath"
};
dojo.declare("dojox.gfx.Path", g.path.Path, {
// summary: a path shape (Canvas)
constructor: function(){
this.last = {};
this.lastControl = {};
},
setShape: function(){
this.canvasPath = [];
return g.Path.superclass.setShape.apply(this, arguments);
},
_updateWithSegment: function(segment){
var last = dojo.clone(this.last);
this[pathRenderers[segment.action]](this.canvasPath, segment.action, segment.args);
this.last = last;
g.Path.superclass._updateWithSegment.apply(this, arguments);
},
_renderShape: function(/* Object */ ctx){
var r = this.canvasPath;
ctx.beginPath();
for(var i = 0; i < r.length; i += 2){
ctx[r[i]].apply(ctx, r[i + 1]);
}
},
_moveToA: function(result, action, args){
result.push("moveTo", [args[0], args[1]]);
for(var i = 2; i < args.length; i += 2){
result.push("lineTo", [args[i], args[i + 1]]);
}
this.last.x = args[args.length - 2];
this.last.y = args[args.length - 1];
this.lastControl = {};
},
_moveToR: function(result, action, args){
if("x" in this.last){
result.push("moveTo", [this.last.x += args[0], this.last.y += args[1]]);
}else{
result.push("moveTo", [this.last.x = args[0], this.last.y = args[1]]);
}
for(var i = 2; i < args.length; i += 2){
result.push("lineTo", [this.last.x += args[i], this.last.y += args[i + 1]]);
}
this.lastControl = {};
},
_lineToA: function(result, action, args){
for(var i = 0; i < args.length; i += 2){
result.push("lineTo", [args[i], args[i + 1]]);
}
this.last.x = args[args.length - 2];
this.last.y = args[args.length - 1];
this.lastControl = {};
},
_lineToR: function(result, action, args){
for(var i = 0; i < args.length; i += 2){
result.push("lineTo", [this.last.x += args[i], this.last.y += args[i + 1]]);
}
this.lastControl = {};
},
_hLineToA: function(result, action, args){
for(var i = 0; i < args.length; ++i){
result.push("lineTo", [args[i], this.last.y]);
}
this.last.x = args[args.length - 1];
this.lastControl = {};
},
_hLineToR: function(result, action, args){
for(var i = 0; i < args.length; ++i){
result.push("lineTo", [this.last.x += args[i], this.last.y]);
}
this.lastControl = {};
},
_vLineToA: function(result, action, args){
for(var i = 0; i < args.length; ++i){
result.push("lineTo", [this.last.x, args[i]]);
}
this.last.y = args[args.length - 1];
this.lastControl = {};
},
_vLineToR: function(result, action, args){
for(var i = 0; i < args.length; ++i){
result.push("lineTo", [this.last.x, this.last.y += args[i]]);
}
this.lastControl = {};
},
_curveToA: function(result, action, args){
for(var i = 0; i < args.length; i += 6){
result.push("bezierCurveTo", args.slice(i, i + 6));
}
this.last.x = args[args.length - 2];
this.last.y = args[args.length - 1];
this.lastControl.x = args[args.length - 4];
this.lastControl.y = args[args.length - 3];
this.lastControl.type = "C";
},
_curveToR: function(result, action, args){
for(var i = 0; i < args.length; i += 6){
result.push("bezierCurveTo", [
this.last.x + args[i],
this.last.y + args[i + 1],
this.lastControl.x = this.last.x + args[i + 2],
this.lastControl.y = this.last.y + args[i + 3],
this.last.x + args[i + 4],
this.last.y + args[i + 5]
]);
this.last.x += args[i + 4];
this.last.y += args[i + 5];
}
this.lastControl.type = "C";
},
_smoothCurveToA: function(result, action, args){
for(var i = 0; i < args.length; i += 4){
var valid = this.lastControl.type == "C";
result.push("bezierCurveTo", [
valid ? 2 * this.last.x - this.lastControl.x : this.last.x,
valid ? 2 * this.last.y - this.lastControl.y : this.last.y,
args[i],
args[i + 1],
args[i + 2],
args[i + 3]
]);
this.lastControl.x = args[i];
this.lastControl.y = args[i + 1];
this.lastControl.type = "C";
}
this.last.x = args[args.length - 2];
this.last.y = args[args.length - 1];
},
_smoothCurveToR: function(result, action, args){
for(var i = 0; i < args.length; i += 4){
var valid = this.lastControl.type == "C";
result.push("bezierCurveTo", [
valid ? 2 * this.last.x - this.lastControl.x : this.last.x,
valid ? 2 * this.last.y - this.lastControl.y : this.last.y,
this.last.x + args[i],
this.last.y + args[i + 1],
this.last.x + args[i + 2],
this.last.y + args[i + 3]
]);
this.lastControl.x = this.last.x + args[i];
this.lastControl.y = this.last.y + args[i + 1];
this.lastControl.type = "C";
this.last.x += args[i + 2];
this.last.y += args[i + 3];
}
},
_qCurveToA: function(result, action, args){
for(var i = 0; i < args.length; i += 4){
result.push("quadraticCurveTo", args.slice(i, i + 4));
}
this.last.x = args[args.length - 2];
this.last.y = args[args.length - 1];
this.lastControl.x = args[args.length - 4];
this.lastControl.y = args[args.length - 3];
this.lastControl.type = "Q";
},
_qCurveToR: function(result, action, args){
for(var i = 0; i < args.length; i += 4){
result.push("quadraticCurveTo", [
this.lastControl.x = this.last.x + args[i],
this.lastControl.y = this.last.y + args[i + 1],
this.last.x + args[i + 2],
this.last.y + args[i + 3]
]);
this.last.x += args[i + 2];
this.last.y += args[i + 3];
}
this.lastControl.type = "Q";
},
_qSmoothCurveToA: function(result, action, args){
for(var i = 0; i < args.length; i += 2){
var valid = this.lastControl.type == "Q";
result.push("quadraticCurveTo", [
this.lastControl.x = valid ? 2 * this.last.x - this.lastControl.x : this.last.x,
this.lastControl.y = valid ? 2 * this.last.y - this.lastControl.y : this.last.y,
args[i],
args[i + 1]
]);
this.lastControl.type = "Q";
}
this.last.x = args[args.length - 2];
this.last.y = args[args.length - 1];
},
_qSmoothCurveToR: function(result, action, args){
for(var i = 0; i < args.length; i += 2){
var valid = this.lastControl.type == "Q";
result.push("quadraticCurveTo", [
this.lastControl.x = valid ? 2 * this.last.x - this.lastControl.x : this.last.x,
this.lastControl.y = valid ? 2 * this.last.y - this.lastControl.y : this.last.y,
this.last.x + args[i],
this.last.y + args[i + 1]
]);
this.lastControl.type = "Q";
this.last.x += args[i];
this.last.y += args[i + 1];
}
},
_arcTo: function(result, action, args){
var relative = action == "a";
for(var i = 0; i < args.length; i += 7){
var x1 = args[i + 5], y1 = args[i + 6];
if(relative){
x1 += this.last.x;
y1 += this.last.y;
}
var arcs = ga.arcAsBezier(
this.last, args[i], args[i + 1], args[i + 2],
args[i + 3] ? 1 : 0, args[i + 4] ? 1 : 0,
x1, y1
);
dojo.forEach(arcs, function(p){
result.push("bezierCurveTo", p);
});
this.last.x = x1;
this.last.y = y1;
}
this.lastControl = {};
},
_closePath: function(result, action, args){
result.push("closePath", []);
this.lastControl = {};
}
});
dojo.forEach(["moveTo", "lineTo", "hLineTo", "vLineTo", "curveTo",
"smoothCurveTo", "qCurveTo", "qSmoothCurveTo", "arcTo", "closePath"],
function(method){ modifyMethod(g.Path, method); }
);
 
dojo.declare("dojox.gfx.TextPath", g.path.TextPath, {
// summary: a text shape (Canvas)
_renderShape: function(/* Object */ ctx){
var s = this.shape;
// nothing for the moment
}
});
dojo.declare("dojox.gfx.Surface", gs.Surface, {
// summary: a surface object to be used for drawings (Canvas)
constructor: function(){
gs.Container._init.call(this);
this.pendingImageCount = 0;
this.makeDirty();
},
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"
this.width = g.normalizedLength(width); // in pixels
this.height = g.normalizedLength(height); // in pixels
if(!this.rawNode) return this;
this.rawNode.width = width;
this.rawNode.height = height;
this.makeDirty();
return this; // self
},
getDimensions: function(){
// summary: returns an object with properties "width" and "height"
return this.rawNode ? {width: this.rawNode.width, height: this.rawNode.height} : null; // Object
},
render: function(){
// summary: render the all shapes
if(this.pendingImageCount){ return; }
var ctx = this.rawNode.getContext("2d");
ctx.save();
ctx.clearRect(0, 0, this.rawNode.width, this.rawNode.height);
for(var i = 0; i < this.children.length; ++i){
this.children[i].render(ctx);
}
ctx.restore();
if("pendingRender" in this){
clearTimeout(this.pendingRender);
delete this.pendingRender;
}
},
makeDirty: function(){
// summary: internal method, which is called when we may need to redraw
if(!this.pendingImagesCount && !("pendingRender" in this)){
this.pendingRender = setTimeout(dojo.hitch(this, this.render), 0);
}
},
downloadImage: function(img, url){
// summary:
// internal method, which starts an image download and renders, when it is ready
// img: Image:
// the image object
// url: String:
// the url of the image
var handler = dojo.hitch(this, this.onImageLoad);
if(!this.pendingImageCount++ && "pendingRender" in this){
clearTimeout(this.pendingRender);
delete this.pendingRender;
}
img.onload = handler;
img.onerror = handler;
img.onabort = handler;
img.src = url;
},
onImageLoad: function(){
if(!--this.pendingImageCount){ this.render(); }
},
 
// events are not implemented
getEventSource: function(){ return null; },
connect: function(){},
disconnect: function(){}
});
 
g.createSurface = function(parentNode, width, height){
// summary: creates a surface (Canvas)
// parentNode: Node: a parent node
// width: String: width of surface, e.g., "100px"
// height: String: height of surface, e.g., "100px"
 
if(!width){ width = "100%"; }
if(!height){ height = "100%"; }
var s = new g.Surface(),
p = dojo.byId(parentNode),
c = p.ownerDocument.createElement("canvas");
c.width = width;
c.height = height;
p.appendChild(c);
s.rawNode = c;
s.surface = s;
return s; // dojox.gfx.Surface
};
// Extenders
var C = gs.Container, Container = {
add: function(shape){
this.surface.makeDirty();
return C.add.apply(this, arguments);
},
remove: function(shape, silently){
this.surface.makeDirty();
return C.remove.apply(this, arguments);
},
clear: function(){
this.surface.makeDirty();
return C.clear.apply(this, arguments);
},
_moveChildToFront: function(shape){
this.surface.makeDirty();
return C._moveChildToFront.apply(this, arguments);
},
_moveChildToBack: function(shape){
this.surface.makeDirty();
return C._moveChildToBack.apply(this, arguments);
}
};
 
dojo.mixin(gs.Creator, {
// summary: Canvas shape creators
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
// overrideSize: Boolean: set the size explicitly, if true
var shape = new shapeType();
shape.surface = this.surface;
shape.setShape(rawShape);
this.add(shape);
return shape; // dojox.gfx.Shape
}
});
 
dojo.extend(g.Group, Container);
dojo.extend(g.Group, gs.Creator);
 
dojo.extend(g.Surface, Container);
dojo.extend(g.Surface, gs.Creator);
})();
 
}
/trunk/api/js/dojo1.0/dojox/gfx/decompose.js
New file
0,0 → 1,139
if(!dojo._hasResource["dojox.gfx.decompose"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.gfx.decompose"] = true;
dojo.provide("dojox.gfx.decompose");
 
dojo.require("dojox.gfx.matrix");
 
(function(){
var m = dojox.gfx.matrix;
 
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 calcFromValues = function(/* Number */ r1, /* Number */ m1, /* Number */ r2, /* Number */ m2){
// summary: uses two close FP ration and their original magnitudes to approximate the result
if(!isFinite(r1)){
return r2; // Number
}else if(!isFinite(r2)){
return r1; // Number
}
m1 = Math.abs(m1), m2 = Math.abs(m2);
return (m1 * r1 + m2 * r2) / (m1 + m2); // Number
};
var transpose = function(/* dojox.gfx.matrix.Matrix2D */ matrix){
// matrix: dojox.gfx.matrix.Matrix2D: a 2D matrix-like object
var M = new m.Matrix2D(matrix);
return dojo.mixin(M, {dx: 0, dy: 0, xy: M.yx, yx: M.xy}); // dojox.gfx.matrix.Matrix2D
};
var scaleSign = function(/* dojox.gfx.matrix.Matrix2D */ matrix){
return (matrix.xx * matrix.yy < 0 || matrix.xy * matrix.yx > 0) ? -1 : 1; // Number
};
var eigenvalueDecomposition = function(/* dojox.gfx.matrix.Matrix2D */ matrix){
// matrix: dojox.gfx.matrix.Matrix2D: a 2D matrix-like object
var M = m.normalize(matrix),
b = -M.xx - M.yy,
c = M.xx * M.yy - M.xy * M.yx,
d = Math.sqrt(b * b - 4 * c),
l1 = -(b + (b < 0 ? -d : d)) / 2,
l2 = c / l1,
vx1 = M.xy / (l1 - M.xx), vy1 = 1,
vx2 = M.xy / (l2 - M.xx), vy2 = 1;
if(eq(l1, l2)){
vx1 = 1, vy1 = 0, vx2 = 0, vy2 = 1;
}
if(!isFinite(vx1)){
vx1 = 1, vy1 = (l1 - M.xx) / M.xy;
if(!isFinite(vy1)){
vx1 = (l1 - M.yy) / M.yx, vy1 = 1;
if(!isFinite(vx1)){
vx1 = 1, vy1 = M.yx / (l1 - M.yy);
}
}
}
if(!isFinite(vx2)){
vx2 = 1, vy2 = (l2 - M.xx) / M.xy;
if(!isFinite(vy2)){
vx2 = (l2 - M.yy) / M.yx, vy2 = 1;
if(!isFinite(vx2)){
vx2 = 1, vy2 = M.yx / (l2 - M.yy);
}
}
}
var d1 = Math.sqrt(vx1 * vx1 + vy1 * vy1),
d2 = Math.sqrt(vx2 * vx2 + vy2 * vy2);
if(!isFinite(vx1 /= d1)){ vx1 = 0; }
if(!isFinite(vy1 /= d1)){ vy1 = 0; }
if(!isFinite(vx2 /= d2)){ vx2 = 0; }
if(!isFinite(vy2 /= d2)){ vy2 = 0; }
return { // Object
value1: l1,
value2: l2,
vector1: {x: vx1, y: vy1},
vector2: {x: vx2, y: vy2}
};
};
var decomposeSR = function(/* dojox.gfx.matrix.Matrix2D */ M, /* Object */ result){
// summary: decomposes a matrix into [scale, rotate]; no checks are done.
var sign = scaleSign(M),
a = result.angle1 = (Math.atan2(M.yx, M.yy) + Math.atan2(-sign * M.xy, sign * M.xx)) / 2,
cos = Math.cos(a), sin = Math.sin(a);
result.sx = calcFromValues(M.xx / cos, cos, -M.xy / sin, sin);
result.sy = calcFromValues(M.yy / cos, cos, M.yx / sin, sin);
return result; // Object
};
var decomposeRS = function(/* dojox.gfx.matrix.Matrix2D */ M, /* Object */ result){
// summary: decomposes a matrix into [rotate, scale]; no checks are done
var sign = scaleSign(M),
a = result.angle2 = (Math.atan2(sign * M.yx, sign * M.xx) + Math.atan2(-M.xy, M.yy)) / 2,
cos = Math.cos(a), sin = Math.sin(a);
result.sx = calcFromValues(M.xx / cos, cos, M.yx / sin, sin);
result.sy = calcFromValues(M.yy / cos, cos, -M.xy / sin, sin);
return result; // Object
};
dojox.gfx.decompose = function(matrix){
// summary: decompose a 2D matrix into translation, scaling, and rotation components
// description: this function decompose a matrix into four logical components:
// translation, rotation, scaling, and one more rotation using SVD.
// The components should be applied in following order:
// | [translate, rotate(angle2), scale, rotate(angle1)]
// matrix: dojox.gfx.matrix.Matrix2D: a 2D matrix-like object
var M = m.normalize(matrix),
result = {dx: M.dx, dy: M.dy, sx: 1, sy: 1, angle1: 0, angle2: 0};
// detect case: [scale]
if(eq(M.xy, 0) && eq(M.yx, 0)){
return dojo.mixin(result, {sx: M.xx, sy: M.yy}); // Object
}
// detect case: [scale, rotate]
if(eq(M.xx * M.yx, -M.xy * M.yy)){
return decomposeSR(M, result); // Object
}
// detect case: [rotate, scale]
if(eq(M.xx * M.xy, -M.yx * M.yy)){
return decomposeRS(M, result); // Object
}
// do SVD
var MT = transpose(M),
u = eigenvalueDecomposition([M, MT]),
v = eigenvalueDecomposition([MT, M]),
U = new m.Matrix2D({xx: u.vector1.x, xy: u.vector2.x, yx: u.vector1.y, yy: u.vector2.y}),
VT = new m.Matrix2D({xx: v.vector1.x, xy: v.vector1.y, yx: v.vector2.x, yy: v.vector2.y}),
S = new m.Matrix2D([m.invert(U), M, m.invert(VT)]);
decomposeSR(VT, result);
S.xx *= result.sx;
S.yy *= result.sy;
decomposeRS(U, result);
S.xx *= result.sx;
S.yy *= result.sy;
return dojo.mixin(result, {sx: S.xx, sy: S.yy}); // Object
};
})();
 
}
/trunk/api/js/dojo1.0/dojox/gfx/silverlight_attach.js
New file
0,0 → 1,87
dojo.require("dojox.gfx.silverlight");
 
dojo.experimental("dojox.gfx.silverlight_attach");
 
(function(){
dojox.gfx.attachNode = function(node){
// summary: creates a shape from a Node
// node: Node: an Silverlight node
return null; // for now
if(!node) return null;
var s = null;
switch(node.tagName.toLowerCase()){
case dojox.gfx.Rect.nodeType:
s = new dojox.gfx.Rect(node);
break;
case dojox.gfx.Ellipse.nodeType:
if(node.width == node.height){
s = new dojox.gfx.Circle(node);
}else{
s = new dojox.gfx.Ellipse(node);
}
break;
case dojox.gfx.Polyline.nodeType:
s = new dojox.gfx.Polyline(node);
break;
case dojox.gfx.Path.nodeType:
s = new dojox.gfx.Path(node);
break;
case dojox.gfx.Line.nodeType:
s = new dojox.gfx.Line(node);
break;
case dojox.gfx.Image.nodeType:
s = new dojox.gfx.Image(node);
break;
case dojox.gfx.Text.nodeType:
s = new dojox.gfx.Text(node);
attachFont(s);
break;
default:
//console.debug("FATAL ERROR! tagName = " + node.tagName);
return null;
}
attachShape(s);
if(!(s instanceof dojox.gfx.Image)){
attachFill(s);
attachStroke(s);
}
attachTransform(s);
return s; // dojox.gfx.Shape
};
 
dojox.gfx.attachSurface = function(node){
// summary: creates a surface from a Node
// node: Node: an Silverlight node
return null; // dojox.gfx.Surface
};
 
var attachFill = function(rawNode){
// summary: deduces a fill style from a Node.
// rawNode: Node: an Silverlight node
return null; // Object
};
var attachStroke = function(rawNode){
// summary: deduces a stroke style from a Node.
// rawNode: Node: an SVG node
return null; // Object
};
 
var attachTransform = function(rawNode){
// summary: deduces a transformation matrix from a Node.
// rawNode: Node: an Silverlight node
return null; // dojox.gfx.matrix.Matrix
};
var attachFont = function(rawNode){
// summary: deduces a font style from a Node.
// rawNode: Node: an Silverlight node
return null; // Object
};
var attachShape = function(rawNode){
// summary: builds a shape from a Node.
// rawNode: Node: an Silverlight node
return null; // dojox.gfx.Shape
};
})();
/trunk/api/js/dojo1.0/dojox/gfx/vml_attach.js
New file
0,0 → 1,362
dojo.require("dojox.gfx.vml");
 
dojo.experimental("dojox.gfx.vml_attach");
 
(function(){
dojox.gfx.attachNode = function(node){
// summary: creates a shape from a Node
// node: Node: an VML node
if(!node) return null;
var s = null;
switch(node.tagName.toLowerCase()){
case dojox.gfx.Rect.nodeType:
s = new dojox.gfx.Rect(node);
attachRect(s);
break;
case dojox.gfx.Ellipse.nodeType:
if(node.style.width == node.style.height){
s = new dojox.gfx.Circle(node);
attachCircle(s);
}else{
s = new dojox.gfx.Ellipse(node);
attachEllipse(s);
}
break;
case dojox.gfx.Path.nodeType:
switch(node.getAttribute("dojoGfxType")){
case "line":
s = new dojox.gfx.Line(node);
attachLine(s);
break;
case "polyline":
s = new dojox.gfx.Polyline(node);
attachPolyline(s);
break;
case "path":
s = new dojox.gfx.Path(node);
attachPath(s);
break;
case "text":
s = new dojox.gfx.Text(node);
attachText(s);
attachFont(s);
attachTextTransform(s);
break;
case "textpath":
s = new dojox.gfx.TextPath(node);
attachPath(s);
attachText(s);
attachFont(s);
break;
}
break;
case dojox.gfx.Image.nodeType:
switch(node.getAttribute("dojoGfxType")){
case "image":
s = new dojox.gfx.Image(node);
attachImage(s);
attachImageTransform(s);
break;
}
break;
default:
//console.debug("FATAL ERROR! tagName = " + node.tagName);
return null;
}
if(!(s instanceof dojox.gfx.Image)){
attachFill(s);
attachStroke(s);
if(!(s instanceof dojox.gfx.Text)){
attachTransform(s);
}
}
return s; // dojox.gfx.Shape
};
 
dojox.gfx.attachSurface = function(node){
// summary: creates a surface from a Node
// node: Node: an VML node
var s = new dojox.gfx.Surface();
s.clipNode = node;
var r = s.rawNode = node.firstChild;
var b = r.firstChild;
if(!b || b.tagName != "rect"){
return null; // dojox.gfx.Surface
}
s.bgNode = r;
return s; // dojox.gfx.Surface
};
 
var attachFill = function(object){
// summary: deduces a fill style from a node.
// object: dojox.gfx.Shape: an VML shape
var fillStyle = null, r = object.rawNode, fo = r.fill;
if(fo.on && fo.type == "gradient"){
var fillStyle = dojo.clone(dojox.gfx.defaultLinearGradient),
rad = dojox.gfx.matrix._degToRad(fo.angle);
fillStyle.x2 = Math.cos(rad);
fillStyle.y2 = Math.sin(rad);
fillStyle.colors = [];
var stops = fo.colors.value.split(";");
for(var i = 0; i < stops.length; ++i){
var t = stops[i].match(/\S+/g);
if(!t || t.length != 2){ continue; }
fillStyle.colors.push({offset: dojox.gfx.vml._parseFloat(t[0]), color: new dojo.Color(t[1])});
}
}else if(fo.on && fo.type == "gradientradial"){
var fillStyle = dojo.clone(dojox.gfx.defaultRadialGradient),
w = parseFloat(r.style.width), h = parseFloat(r.style.height);
fillStyle.cx = isNaN(w) ? 0 : fo.focusposition.x * w;
fillStyle.cy = isNaN(h) ? 0 : fo.focusposition.y * h;
fillStyle.r = isNaN(w) ? 1 : w / 2;
fillStyle.colors = [];
var stops = fo.colors.value.split(";");
for(var i = stops.length - 1; i >= 0; --i){
var t = stops[i].match(/\S+/g);
if(!t || t.length != 2){ continue; }
fillStyle.colors.push({offset: dojox.gfx.vml._parseFloat(t[0]), color: new dojo.Color(t[1])});
}
}else if(fo.on && fo.type == "tile"){
var fillStyle = dojo.clone(dojox.gfx.defaultPattern);
fillStyle.width = dojox.gfx.pt2px(fo.size.x); // from pt
fillStyle.height = dojox.gfx.pt2px(fo.size.y); // from pt
fillStyle.x = fo.origin.x * fillStyle.width;
fillStyle.y = fo.origin.y * fillStyle.height;
fillStyle.src = fo.src;
}else if(fo.on && r.fillcolor){
// a color object !
fillStyle = new dojo.Color(r.fillcolor+"");
fillStyle.a = fo.opacity;
}
object.fillStyle = fillStyle;
};
 
var attachStroke = function(object) {
// summary: deduces a stroke style from a node.
// object: dojox.gfx.Shape: an VML shape
var r = object.rawNode;
if(!r.stroked){
object.strokeStyle = null;
return;
}
var strokeStyle = object.strokeStyle = dojo.clone(dojox.gfx.defaultStroke),
rs = r.stroke;
strokeStyle.color = new dojo.Color(r.strokecolor.value);
strokeStyle.width = dojox.gfx.normalizedLength(r.strokeweight+"");
strokeStyle.color.a = rs.opacity;
strokeStyle.cap = this._translate(this._capMapReversed, rs.endcap);
strokeStyle.join = rs.joinstyle == "miter" ? rs.miterlimit : rs.joinstyle;
strokeStyle.style = rs.dashstyle;
};
 
var attachTransform = function(object) {
// summary: deduces a transformation matrix from a node.
// object: dojox.gfx.Shape: an VML shape
var s = rawNode.skew, sm = s.matrix, so = s.offset;
object.matrix = dojox.gfx.matrix.normalize({
xx: sm.xtox,
xy: sm.ytox,
yx: sm.xtoy,
yy: sm.ytoy,
dx: dojox.gfx.pt2px(so.x),
dy: dojox.gfx.pt2px(so.y)
});
};
 
var attachGroup = function(object){
// summary: reconstructs all group shape parameters from a node (VML).
// object: dojox.gfx.Shape: an VML shape
// attach the background
object.bgNode = object.rawNode.firstChild; // TODO: check it first
};
var attachRect = function(object){
// summary: builds a rectangle shape from a node.
// object: dojox.gfx.Shape: an VML shape
// a workaround for the VML's arcsize bug: cannot read arcsize of an instantiated node
var r = object.rawNode, arcsize = r.outerHTML.match(/arcsize = \"(\d*\.?\d+[%f]?)\"/)[1],
style = r.style, width = parseFloat(style.width), height = parseFloat(style.height);
arcsize = (arcsize.indexOf("%") >= 0) ? parseFloat(arcsize) / 100 : dojox.gfx.vml._parseFloat(arcsize);
// make an object
object.shape = dojox.gfx.makeParameters(dojox.gfx.defaultRect, {
x: parseInt(style.left),
y: parseInt(style.top),
width: width,
height: height,
r: Math.min(width, height) * arcsize
});
};
 
var attachEllipse = function(object){
// summary: builds an ellipse shape from a node.
// object: dojox.gfx.Shape: an VML shape
var style = object.rawNode.style,
rx = parseInt(style.width ) / 2,
ry = parseInt(style.height) / 2;
object.shape = dojox.gfx.makeParameters(dojox.gfx.defaultEllipse, {
cx: parseInt(style.left) + rx,
cy: parseInt(style.top ) + ry,
rx: rx,
ry: ry
});
};
 
var attachCircle = function(object){
// summary: builds a circle shape from a node.
// object: dojox.gfx.Shape: an VML shape
var style = object.rawNode.style, r = parseInt(style.width) / 2;
object.shape = dojox.gfx.makeParameters(dojox.gfx.defaultCircle, {
cx: parseInt(style.left) + r,
cy: parseInt(style.top) + r,
r: r
});
};
 
var attachLine = function(object){
// summary: builds a line shape from a node.
// object: dojox.gfx.Shape: an VML shape
var shape = object.shape = dojo.clone(dojox.gfx.defaultLine),
p = object.rawNode.path.v.match(dojox.gfx.pathVmlRegExp);
do{
if(p.length < 7 || p[0] != "m" || p[3] != "l" || p[6] != "e"){ break; }
shape.x1 = parseInt(p[1]);
shape.y1 = parseInt(p[2]);
shape.x2 = parseInt(p[4]);
shape.y2 = parseInt(p[5]);
}while(false);
};
 
var attachPolyline = function(object){
// summary: builds a polyline/polygon shape from a node.
// object: dojox.gfx.Shape: an VML shape
var shape = object.shape = dojo.clone(dojox.gfx.defaultPolyline),
p = object.rawNode.path.v.match(dojox.gfx.pathVmlRegExp);
do{
if(p.length < 3 || p[0] != "m"){ break; }
var x = parseInt(p[0]), y = parseInt(p[1]);
if(isNaN(x) || isNaN(y)){ break; }
shape.points.push({x: x, y: y});
if(p.length < 6 || p[3] != "l"){ break; }
for(var i = 4; i < p.length; i += 2){
x = parseInt(p[i]);
y = parseInt(p[i + 1]);
if(isNaN(x) || isNaN(y)){ break; }
shape.points.push({x: x, y: y});
}
}while(false);
};
 
var attachImage = function(object){
// summary: builds an image shape from a node.
// object: dojox.gfx.Shape: an VML shape
object.shape = dojo.clone(dojox.gfx.defaultImage);
object.shape.src = object.rawNode.firstChild.src;
};
 
var attachImageTransform = function(object) {
// summary: deduces a transformation matrix from a node.
// object: dojox.gfx.Shape: an VML shape
var m = object.rawNode.filters["DXImageTransform.Microsoft.Matrix"];
object.matrix = dojox.gfx.matrix.normalize({
xx: m.M11,
xy: m.M12,
yx: m.M21,
yy: m.M22,
dx: m.Dx,
dy: m.Dy
});
};
 
var attachText = function(object){
// summary: builds a text shape from a node.
// object: dojox.gfx.Shape: an VML shape
var shape = object.shape = dojo.clone(dojox.gfx.defaultText),
r = object.rawNode, p = r.path.v.match(dojox.gfx.pathVmlRegExp);
do{
if(!p || p.length != 7){ break; }
var c = r.childNodes, i = 0;
for(; i < c.length && c[i].tagName != "textpath"; ++i);
if(i >= c.length){ break; }
var s = c[i].style;
shape.text = c[i].string;
switch(s["v-text-align"]){
case "left":
shape.x = parseInt(p[1]);
shape.align = "start";
break;
case "center":
shape.x = (parseInt(p[1]) + parseInt(p[4])) / 2;
shape.align = "middle";
break;
case "right":
shape.x = parseInt(p[4]);
shape.align = "end";
break;
}
shape.y = parseInt(p[2]);
shape.decoration = s["text-decoration"];
shape.rotated = s["v-rotate-letters"].toLowerCase() in dojox.gfx.vml._bool;
shape.kerning = s["v-text-kern"].toLowerCase() in dojox.gfx.vml._bool;
return;
}while(false);
object.shape = null;
};
 
var attachFont = function(object){
// summary: deduces a font style from a node.
// object: dojox.gfx.Shape: an VML shape
var fontStyle = object.fontStyle = dojo.clone(dojox.gfx.defaultFont),
c = object.rawNode.childNodes, i = 0;
for(; i < c.length && c[i].tagName == "textpath"; ++i);
if(i >= c.length){
object.fontStyle = null;
return;
}
var s = c[i].style;
fontStyle.style = s.fontstyle;
fontStyle.variant = s.fontvariant;
fontStyle.weight = s.fontweight;
fontStyle.size = s.fontsize;
fontStyle.family = s.fontfamily;
};
var attachTextTransform = function(object) {
// summary: deduces a transformation matrix from a node.
// object: dojox.gfx.Shape: an VML shape
attachTransform(object);
var matrix = object.matrix, fs = object.fontStyle;
// see comments in _getRealMatrix()
if(matrix && fs){
object.matrix = dojox.gfx.matrix.multiply(matrix, {dy: dojox.gfx.normalizedLength(fs.size) * 0.35});
}
};
 
var attachPath = function(object){
// summary: builds a path shape from a Node.
// object: dojox.gfx.Shape: an VML shape
var shape = object.shape = dojo.clone(dojox.gfx.defaultPath),
p = rawNode.path.v.match(dojox.gfx.pathVmlRegExp),
t = [], skip = false, map = dojox.gfx.Path._pathVmlToSvgMap;
for(var i = 0; i < p.length; ++p){
var s = p[i];
if(s in map) {
skip = false;
t.push(map[s]);
} else if(!skip){
var n = parseInt(s);
if(isNaN(n)){
skip = true;
}else{
t.push(n);
}
}
}
var l = t.length;
if(l >= 4 && t[l - 1] == "" && t[l - 2] == 0 && t[l - 3] == 0 && t[l - 4] == "l"){
t.splice(l - 4, 4);
}
if(l){
shape.path = t.join(" ");
}
};
})();
/trunk/api/js/dojo1.0/dojox/gfx/README
New file
0,0 → 1,102
-------------------------------------------------------------------------------
dojox.gfx
-------------------------------------------------------------------------------
Version 1.100
Release date: 08/01/2006
-------------------------------------------------------------------------------
Project state:
beta
HTMLCanvas renderer: experimental
-------------------------------------------------------------------------------
Credits
Eugene Lazutkin (eugene.lazutkin@gmail.com)
Kun Xi (bookstack@gmail.com)
Chris Mitchell (ccmitchellusa@gmail.com) HTML Canvas
-------------------------------------------------------------------------------
Project description
 
Implementation of simple portable 2D graphics library.
-------------------------------------------------------------------------------
Dependencies:
 
Dojo Core
-------------------------------------------------------------------------------
Documentation
 
Currently it can be found here: http://docs.google.com/Doc?id=d764479_1hnb2tn
 
HTMLCanvas Renderer Status
 
To use canvas rendering, insert 'canvas' at the beginning of the gfxRenderers list in your
djConfig, for example:
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="parseOnLoad: true, gfxRenderer: 'canvas,svg,silverlight,vml'"></script>
canvas currently will only render on non-IE browsers (see dojox/gfx.js for where the renderer is loaded);
although it should be possible to use an IE canvas implementation (like Google's); however, it will be very slow.
 
The following tests can be made to work with HTML Canvas with minor testcase modification:
dojox/gfx/tests
test_gfx.html-Bugs #1
test_arc.html
test_bezier.html
test_pattern.html
test_gradient.html
test_linearGradient.html
test_image1.html - Limitation #3
test_transform.html - Bug #1
test_poly.html - Bug #1
dojox/gfx/demos
butterfly.html - Bug #1
lion.html - Bug #1
tiger.html - Bug #1
circles.html - No event processing yet :(
creator.html
dojox/chart
test_pie2d.html - Dojo Charts on iPhone anyone? :)
test_chart2d.html -
 
// To make charts work, the following line needs to be added to the end of the
// Chart2D.js render() method (prior to return)
if(this.surface.render){this.surface.render()};
 
Known Limitations:
1) event handling- plan is to capture all events at canvas, perform intersect/hit
tests (not implemented) against scene graph, then propogate event to top-most
intersected shape. HtmlCanvas shape need intersectsStroke and intersectsBounds,
and intersects (region).
2) SVG and VML are "live" scene graphs; eg. any state change to objects in the
scene automatically get rendered in next engine render pass. For canvas, it's
procedural, and current implementation requires application to call surface.render()
whenever scene needs to be updated. Plan is to do dirty region checking based
on bounding boxes (currently not properly computed), and track dirty areas anytime
state changes (invalidate) separate from render phase.
Add the following call where changes to the scene graph are complete and you want to
render:
 
if (surface.render){surface.render();}
 
4) Text/Text Paths - Text shape is implemented using DIV overlays. Many text styles are not
applied, and outline/fills are not possible. This is due to limitations in Canvas spec.
Firefox 3.0 has proprietary text functions that we could test for and use once FF3 is out.
No luck on Safari.
3) No Image skewing - Limitation of Canvas
Known Bugs:
1) Matrix xformations (applied from root to shape leaf nodes) not quite right--but very close.
Canvas does not have a built in transformation function that allows skewing. Need to
track skew matrix with Shape, and perform other trans/rot/scale transformations without
using canvas transform functions.
 
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/gfx.js
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/gfx/*
 
Install into the following directory structure:
/dojox/gfx/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
/trunk/api/js/dojo1.0/dojox/gfx/svg_attach.js
New file
0,0 → 1,224
dojo.require("dojox.gfx.svg");
 
dojo.experimental("dojox.gfx.svg_attach");
 
(function(){
dojox.gfx.attachNode = function(node){
// summary: creates a shape from a Node
// node: Node: an SVG node
if(!node) return null;
var s = null;
switch(node.tagName.toLowerCase()){
case dojox.gfx.Rect.nodeType:
s = new dojox.gfx.Rect(node);
attachRect(s);
break;
case dojox.gfx.Ellipse.nodeType:
s = new dojox.gfx.Ellipse(node);
attachShape(s, dojox.gfx.defaultEllipse);
break;
case dojox.gfx.Polyline.nodeType:
s = new dojox.gfx.Polyline(node);
attachShape(s, dojox.gfx.defaultPolyline);
break;
case dojox.gfx.Path.nodeType:
s = new dojox.gfx.Path(node);
attachShape(s, dojox.gfx.defaultPath);
break;
case dojox.gfx.Circle.nodeType:
s = new dojox.gfx.Circle(node);
attachShape(s, dojox.gfx.defaultCircle);
break;
case dojox.gfx.Line.nodeType:
s = new dojox.gfx.Line(node);
attachShape(s, dojox.gfx.defaultLine);
break;
case dojox.gfx.Image.nodeType:
s = new dojox.gfx.Image(node);
attachShape(s, dojox.gfx.defaultImage);
break;
case dojox.gfx.Text.nodeType:
var t = node.getElementsByTagName("textPath");
if(t && t.length){
s = new dojox.gfx.TextPath(node);
attachShape(s, dojox.gfx.defaultPath);
attachTextPath(s);
}else{
s = new dojox.gfx.Text(node);
attachText(s);
}
attachFont(s);
break;
default:
//console.debug("FATAL ERROR! tagName = " + node.tagName);
return null;
}
if(!(s instanceof dojox.gfx.Image)){
attachFill(s);
attachStroke(s);
}
attachTransform(s);
return s; // dojox.gfx.Shape
};
dojox.gfx.attachSurface = function(node){
// summary: creates a surface from a Node
// node: Node: an SVG node
var s = new dojox.gfx.Surface();
s.rawNode = node;
var def_elems = node.getElementsByTagName("defs");
if(def_elems.length == 0){
return null; // dojox.gfx.Surface
}
s.defNode = def_elems[0];
return s; // dojox.gfx.Surface
};
 
var attachFill = function(object){
// summary: deduces a fill style from a node.
// object: dojox.gfx.Shape: an SVG shape
var fill = object.rawNode.getAttribute("fill");
if(fill == "none"){
object.fillStyle = null;
return;
}
var fillStyle = null, gradient = dojox.gfx.svg.getRef(fill);
if(ref){
switch(gradient.tagName.toLowerCase()){
case "lineargradient":
fillStyle = _getGradient(dojox.gfx.defaultLinearGradient, gradient);
dojo.forEach(["x1", "y1", "x2", "y2"], function(x){
fillStyle[x] = gradient.getAttribute(x);
});
break;
case "radialgradient":
fillStyle = _getGradient(dojox.gfx.defaultRadialGradient, gradient);
dojo.forEach(["cx", "cy", "r"], function(x){
fillStyle[x] = gradient.getAttribute(x);
});
fillStyle.cx = gradient.getAttribute("cx");
fillStyle.cy = gradient.getAttribute("cy");
fillStyle.r = gradient.getAttribute("r");
break;
case "pattern":
fillStyle = dojo.lang.shallowCopy(dojox.gfx.defaultPattern, true);
dojo.forEach(["x", "y", "width", "height"], function(x){
fillStyle[x] = gradient.getAttribute(x);
});
fillStyle.src = gradient.firstChild.getAttributeNS(dojox.gfx.svg.xmlns.xlink, "href");
break;
}
}else{
fillStyle = new dojo.Color(fill);
var opacity = rawNode.getAttribute("fill-opacity");
if(opacity != null){ fillStyle.a = opacity; }
}
object.fillStyle = fillStyle;
};
var _getGradient = function(defaultGradient, gradient){
var fillStyle = dojo.clone(defaultGradient);
fillStyle.colors = [];
for(var i = 0; i < gradient.childNodes.length; ++i){
fillStyle.colors.push({
offset: gradient.childNodes[i].getAttribute("offset"),
color: new dojo.Color(gradient.childNodes[i].getAttribute("stop-color"))
});
}
return fillStyle;
};
 
var attachStroke = function(object){
// summary: deduces a stroke style from a node.
// object: dojox.gfx.Shape: an SVG shape
var rawNode = object.rawNode, stroke = rawNode.getAttribute("stroke");
if(stroke == null || stroke == "none"){
object.strokeStyle = null;
return;
}
var strokeStyle = object.strokeStyle = dojo.clone(dojox.gfx.defaultStroke);
var color = new dojo.Color(stroke);
if(color){
strokeStyle.color = color;
strokeStyle.color.a = rawNode.getAttribute("stroke-opacity");
strokeStyle.width = rawNode.getAttribute("stroke-width");
strokeStyle.cap = rawNode.getAttribute("stroke-linecap");
strokeStyle.join = rawNode.getAttribute("stroke-linejoin");
if(strokeStyle.join == "miter"){
strokeStyle.join = rawNode.getAttribute("stroke-miterlimit");
}
strokeStyle.style = rawNode.getAttribute("dojoGfxStrokeStyle");
}
};
 
var attachTransform = function(object){
// summary: deduces a transformation matrix from a node.
// object: dojox.gfx.Shape: an SVG shape
var matrix = object.rawNode.getAttribute("transform");
if(matrix.match(/^matrix\(.+\)$/)){
var t = matrix.slice(7, -1).split(",");
object.matrix = dojox.gfx.matrix.normalize({
xx: parseFloat(t[0]), xy: parseFloat(t[2]),
yx: parseFloat(t[1]), yy: parseFloat(t[3]),
dx: parseFloat(t[4]), dy: parseFloat(t[5])
});
}else{
object.matrix = null;
}
};
var attachFont = function(object){
// summary: deduces a font style from a Node.
// object: dojox.gfx.Shape: an SVG shape
var fontStyle = object.fontStyle = dojo.clone(dojox.gfx.defaultFont),
r = object.rawNode;
fontStyle.style = r.getAttribute("font-style");
fontStyle.variant = r.getAttribute("font-variant");
fontStyle.weight = r.getAttribute("font-weight");
fontStyle.size = r.getAttribute("font-size");
fontStyle.family = r.getAttribute("font-family");
};
 
var attachShape = function(object, def){
// summary: builds a shape from a node.
// object: dojox.gfx.Shape: an SVG shape
// def: Object: a default shape template
var shape = object.shape = dojo.clone(def), r = object.rawNode;
for(var i in shape) {
shape[i] = r.getAttribute(i);
}
};
var attachRect = function(object){
// summary: builds a rectangle shape from a node.
// object: dojox.gfx.Shape: an SVG shape
attachShape(object, dojox.gfx.defaultRect);
object.shape.r = Math.min(object.rawNode.getAttribute("rx"), object.rawNode.getAttribute("ry"));
};
 
var attachText = function(object){
// summary: builds a text shape from a node.
// object: dojox.gfx.Shape: an SVG shape
var shape = object.shape = dojo.clone(dojox.gfx.defaultText),
r = object.rawNode;
shape.x = r.getAttribute("x");
shape.y = r.getAttribute("y");
shape.align = r.getAttribute("text-anchor");
shape.decoration = r.getAttribute("text-decoration");
shape.rotated = parseFloat(r.getAttribute("rotate")) != 0;
shape.kerning = r.getAttribute("kerning") == "auto";
shape.text = r.firstChild.nodeValue;
};
 
var attachTextPath = function(object){
// summary: builds a textpath shape from a node.
// object: dojox.gfx.Shape: an SVG shape
var shape = object.shape = dojo.clone(dojox.gfx.defaultTextPath),
r = object.rawNode;
shape.align = r.getAttribute("text-anchor");
shape.decoration = r.getAttribute("text-decoration");
shape.rotated = parseFloat(r.getAttribute("rotate")) != 0;
shape.kerning = r.getAttribute("kerning") == "auto";
shape.text = r.firstChild.nodeValue;
};
})();
/trunk/api/js/dojo1.0/dojox/rpc/yahoo.smd
New file
0,0 → 1,268
{
"SMDVersion":".1",
"objectName":"yahoo",
"serviceType":"JSON-P",
"required": {
"appId": "dojotoolkit",
"output": "json"
},
"methods":[
//
// MAPS
//
{
// http://developer.yahoo.com/maps/rest/V1/mapImage.html
"name":"mapImage",
"serviceURL": "http://api.local.yahoo.com/MapsService/V1/mapImage",
"parameters":[
{ "name":"street", "type":"STRING" },
{ "name":"city", "type":"STRING" },
{ "name":"zip", "type":"INTEGER" },
{ "name":"location", "type":"STRING" },
{ "name":"longitude", "type":"FLOAT" },
{ "name":"latitude", "type":"FLOAT" },
{ "name":"image_type", "type":"STRING" },
{ "name":"image_width", "type":"INTEGER" },
{ "name":"image_height", "type":"INTEGER" },
{ "name":"zoom", "type":"INTEGER" },
{ "name":"radius", "type":"INTEGER" }
]
},
{
// http://developer.yahoo.com/traffic/rest/V1/index.html
"name":"trafficData",
"serviceURL": "http://api.local.yahoo.com/MapsService/V1/trafficData",
"parameters":[
{ "name":"street", "type":"STRING" },
{ "name":"city", "type":"STRING" },
{ "name":"zip", "type":"INTEGER" },
{ "name":"location", "type":"STRING" },
{ "name":"longitude", "type":"FLOAT" },
{ "name":"latitude", "type":"FLOAT" },
{ "name":"severity", "type":"INTEGER" },
{ "name":"include_map", "type":"INTEGER" },
{ "name":"image_type", "type":"STRING" },
{ "name":"image_width", "type":"INTEGER" },
{ "name":"image_height", "type":"INTEGER" },
{ "name":"zoom", "type":"INTEGER" },
{ "name":"radius", "type":"INTEGER" }
]
},
//
// LOCAL SEARCH
//
{
// http://developer.yahoo.com/search/local/V3/localSearch.html
"name":"localSearch",
"serviceURL": "http://api.local.yahoo.com/LocalSearchService/V3/localSearch",
"parameters":[
{ "name":"street", "type":"STRING" },
{ "name":"city", "type":"STRING" },
{ "name":"zip", "type":"INTEGER" },
{ "name":"location", "type":"STRING" },
{ "name":"listing_id", "type":"STRING" },
{ "name":"sort", "type":"STRING" }, // "relevence", "title", "distance", or "rating"
{ "name":"start", "type":"INTEGER" },
{ "name":"radius", "type":"FLOAT" },
{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
{ "name":"longitude", "type":"FLOAT" },
{ "name":"latitude", "type":"FLOAT" },
{ "name":"category", "type":"INTEGER" },
{ "name":"omit_category", "type":"INTEGER" },
{ "name":"minimum_rating", "type":"INTEGER" }
]
},
//
// WEB SEARCH
//
{
// http://developer.yahoo.com/search/web/V1/webSearch.html
"name":"webSearch",
"serviceURL": "http://api.search.yahoo.com/WebSearchService/V1/webSearch",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // defaults to "all"
{ "name":"region", "type":"STRING" }, // defaults to "us"
{ "name":"results", "type":"INTEGER" }, // defaults to 10
{ "name":"start", "type":"INTEGER" }, // defaults to 1
{ "name":"format", "type":"STRING" }, // defaults to "any", can be "html", "msword", "pdf", "ppt", "rst", "txt", or "xls"
{ "name":"adult_ok", "type":"INTEGER" }, // defaults to null
{ "name":"similar_ok", "type":"INTEGER" }, // defaults to null
{ "name":"language", "type":"STRING" }, // defaults to null
{ "name":"country", "type":"STRING" }, // defaults to null
{ "name":"site", "type":"STRING" }, // defaults to null
{ "name":"subscription", "type":"STRING" }, // defaults to null
{ "name":"license", "type":"STRING" } // defaults to "any"
]
},
{
// http://developer.yahoo.com/search/web/V1/spellingSuggestion.html
"name":"spellingSuggestion",
"serviceURL": "http://api.search.yahoo.com/WebSearchService/V1/spellingSuggestion",
"parameters":[ { "name":"query", "type":"STRING" } ]
},
{
// http://developer.yahoo.com/search/web/V1/relatedSuggestion.html
"name":"spellingSuggestion",
"serviceURL": "http://api.search.yahoo.com/WebSearchService/V1/relatedSuggestion",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"results", "type":"INTEGER" } // 1-50, defaults to 10
]
},
{
// http://developer.yahoo.com/search/content/V1/termExtraction.html
"name":"termExtraction",
"serviceURL": "http://search.yahooapis.com/ContentAnalysisService/V1/termExtraction",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"context", "type":"STRING" },
{ "name":"results", "type":"INTEGER" } // 1-50, defaults to 10
]
},
{
// http://developer.yahoo.com/search/web/V1/contextSearch.html
"name":"contextSearch",
"serviceURL": "http://search.yahooapis.com/WebSearchService/V1/contextSearch",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"context", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // defaults to "all"
{ "name":"results", "type":"INTEGER" }, // defaults to 10
{ "name":"start", "type":"INTEGER" }, // defaults to 1
{ "name":"format", "type":"STRING" }, // defaults to "any", can be "html", "msword", "pdf", "ppt", "rst", "txt", or "xls"
{ "name":"adult_ok", "type":"INTEGER" }, // defaults to null
{ "name":"similar_ok", "type":"INTEGER" }, // defaults to null
{ "name":"language", "type":"STRING" }, // defaults to null
{ "name":"country", "type":"STRING" }, // defaults to null
{ "name":"site", "type":"STRING" }, // defaults to null
{ "name":"license", "type":"STRING" } // defaults to "any", could be "cc_any", "cc_commercial", "cc_modifiable"
]
},
//
// IMAGE SEARCH
//
{
// http://developer.yahoo.com/search/image/V1/imageSearch.html
"name":"imageSearch",
"serviceURL": "http://api.search.yahoo.com/ImageSearchService/V1/imageSearch",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // defaults to "all", can by "any" or "phrase"
{ "name":"results", "type":"INTEGER" }, // defaults to 10
{ "name":"start", "type":"INTEGER" }, // defaults to 1
{ "name":"format", "type":"STRING" }, // defaults to "any", can be "bmp", "gif", "jpeg", or "png"
{ "name":"adult_ok", "type":"INTEGER" }, // defaults to null
{ "name":"coloration", "type":"STRING" }, // "any", "color", or "bw"
{ "name":"site", "type":"STRING" } // defaults to null
]
},
//
// SITE EXPLORER
//
{
// http://developer.yahoo.com/search/siteexplorer/V1/inlinkData.html
"name":"inlinkData",
"serviceURL": "http://api.search.yahoo.com/SiteExplorerService/V1/inlinkData",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // defaults to "all", can by "any" or "phrase"
{ "name":"entire_site", "type":"INTEGER" }, // defaults to null
{ "name":"omit_inlinks", "type":"STRING" }, // "domain" or "subdomain", defaults to null
{ "name":"results", "type":"INTEGER" }, // defaults to 50
{ "name":"start", "type":"INTEGER" }, // defaults to 1
{ "name":"site", "type":"STRING" } // defaults to null
]
},
{
// http://developer.yahoo.com/search/siteexplorer/V1/pageData.html
"name":"pageData",
"serviceURL": "http://api.search.yahoo.com/SiteExplorerService/V1/pageData",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // defaults to "all", can by "any" or "phrase"
{ "name":"domain_only", "type":"INTEGER" }, // defaults to null
{ "name":"results", "type":"INTEGER" }, // defaults to 50
{ "name":"start", "type":"INTEGER" }, // defaults to 1
{ "name":"site", "type":"STRING" } // defaults to null
]
},
//
// MUSIC SEARCH
//
{
// http://developer.yahoo.com/search/audio/V1/artistSearch.html
"name":"artistSearch",
"serviceURL": "http://api.search.yahoo.com/AudioSearchService/V1/artistSearch",
"parameters":[
{ "name":"artist", "type":"STRING" },
{ "name":"artistid", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // "all", "any", or "phrase"
{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
{ "name":"start", "type":"INTEGER" } // defaults to 1
]
},
{
// http://developer.yahoo.com/search/audio/V1/albumSearch.html
"name":"albumSearch",
"serviceURL": "http://api.search.yahoo.com/AudioSearchService/V1/albumSearch",
"parameters":[
{ "name":"artist", "type":"STRING" },
{ "name":"artistid", "type":"STRING" },
{ "name":"album", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // "all", "any", or "phrase"
{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
{ "name":"start", "type":"INTEGER" } // defaults to 1
]
},
{
// http://developer.yahoo.com/search/audio/V1/songSearch.html
"name":"songSearch",
"serviceURL": "http://api.search.yahoo.com/AudioSearchService/V1/songSearch",
"parameters":[
{ "name":"artist", "type":"STRING" },
{ "name":"artistid", "type":"STRING" },
{ "name":"album", "type":"STRING" },
{ "name":"albumid", "type":"STRING" },
{ "name":"song", "type":"STRING" },
{ "name":"songid", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // "all", "any", or "phrase"
{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
{ "name":"start", "type":"INTEGER" } // defaults to 1
]
},
{
// http://developer.yahoo.com/search/audio/V1/songDownloadLocation.html
"name":"songDownloadLocation",
"serviceURL": "http://api.search.yahoo.com/AudioSearchService/V1/songDownloadLocation",
"parameters":[
{ "name":"songid", "type":"STRING" },
// "source" can contain:
// audiolunchbox artistdirect buymusic dmusic
// emusic epitonic garageband itunes yahoo
// livedownloads mp34u msn musicmatch mapster passalong
// rhapsody soundclick theweb
{ "name":"source", "type":"STRING" },
{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
{ "name":"start", "type":"INTEGER" } // defaults to 1
]
},
//
// NEWS SEARCH
//
{
// http://developer.yahoo.com/search/news/V1/newsSearch.html
"name":"newsSearch",
"serviceURL": "http://api.search.yahoo.com/NewsSearchService/V1/newsSearch",
"parameters":[
{ "name":"query", "type":"STRING" },
{ "name":"type", "type":"STRING" }, // defaults to "all"
{ "name":"results", "type":"INTEGER" }, // defaults to 10
{ "name":"start", "type":"INTEGER" }, // defaults to 1
{ "name":"sort", "type":"STRING" }, // "rank" or "date"
{ "name":"language", "type":"STRING" }, // defaults to null
{ "name":"site", "type":"STRING" } // defaults to null
]
}
]
}
/trunk/api/js/dojo1.0/dojox/rpc/README
New file
0,0 → 1,40
-------------------------------------------------------------------------------
DojoX RPC Extras
-------------------------------------------------------------------------------
Version 1.0
Release date: 07/01/2007
-------------------------------------------------------------------------------
Project state:
yahoo.smd: stable
-------------------------------------------------------------------------------
Project authors
Dustin Machi
-------------------------------------------------------------------------------
Project description
 
Extra utilities for use with dojo.rpc as well as additional smd descriptions
for specific services.
-------------------------------------------------------------------------------
Dependencies:
 
Dojo Core (package loader, dojo.rpc).
-------------------------------------------------------------------------------
Documentation
 
See RPC documentation at http://dojotoolkit.org/
 
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/rpc/*
 
Install into the following directory structure:
/dojox/rpc/
 
...which should be at the same level as your Dojo checkout.
 
The use of the actual utilities varies, but typically additional software
will be included with dojo.require() and smd files for services can be loaded
manually with an xhr request or can be provided by url to the service when created
 
/trunk/api/js/dojo1.0/dojox/grid/README
New file
0,0 → 1,39
-------------------------------------------------------------------------------
dojox.grid
-------------------------------------------------------------------------------
Version 1.00
Release date: 10/04/2007
-------------------------------------------------------------------------------
Project state:
beta
-------------------------------------------------------------------------------
Credits
Scott J. Miles (sjmiles@activegrid.com)
Steve Orvell (sorvell@activegrid.com)
-------------------------------------------------------------------------------
Project description
 
TurboGrid has been made available in Dojo and is now the dojox.grid!
 
-------------------------------------------------------------------------------
Dependencies:
 
Dojo Core
Dijit Templated Widget
-------------------------------------------------------------------------------
Documentation
 
None available for this version yet.
 
See http://www.turboajax.com/products/turbogrid/ for legacy documentation.
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/grid/*
 
Install into the following directory structure:
/dojox/grid/
 
...which should be at the same level as your Dojo checkout.
-------------------------------------------------------------------------------
/trunk/api/js/dojo1.0/dojox/grid/Grid.js
New file
0,0 → 1,222
if(!dojo._hasResource["dojox.grid.Grid"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid.Grid"] = true;
dojo.provide("dojox.grid.Grid");
dojo.require("dojox.grid.VirtualGrid");
dojo.require("dojox.grid._data.model");
dojo.require("dojox.grid._data.editors");
 
dojo.declare('dojox.Grid', dojox.VirtualGrid, {
// summary:
// A grid widget with virtual scrolling, cell editing, complex rows,
// sorting, fixed columns, sizeable columns, etc.
// description:
// Grid is a subclass of VirtualGrid, providing binding to a data
// store.
// example:
// define the grid structure:
// | var structure = [ // array of view objects
// | { cells: [// array of rows, a row is an array of cells
// | [ { name: "Alpha", width: 6 },
// | { name: "Beta" },
// | { name: "Gamma", get: formatFunction }
// | ]
// | ]}
// | ];
//
// define a grid data model
// | var model = new dojox.grid.data.table(null, data);
// |
// | <div id="grid" model="model" structure="structure"
// | dojoType="dojox.VirtualGrid"></div>
//
 
// model:
// string or object grid data model
model: 'dojox.grid.data.Table',
// life cycle
postCreate: function(){
if(this.model){
var m = this.model;
if(dojo.isString(m)){
m = dojo.getObject(m);
}
this.model = (dojo.isFunction(m)) ? new m() : m;
this._setModel(this.model);
}
this.inherited(arguments);
},
destroy: function(){
this.setModel(null);
this.inherited(arguments);
},
// structure
_structureChanged: function() {
this.indexCellFields();
this.inherited(arguments);
},
// model
_setModel: function(inModel){
// if(!inModel){ return; }
this.model = inModel;
if(this.model){
this.model.observer(this);
this.model.measure();
this.indexCellFields();
}
},
setModel: function(inModel){
// summary:
// set the grid's data model
// inModel:
// model object, usually an instance of a dojox.grid.data.Model
// subclass
if(this.model){
this.model.notObserver(this);
}
this._setModel(inModel);
},
// data socket (called in cell's context)
get: function(inRowIndex){
return this.grid.model.getDatum(inRowIndex, this.fieldIndex);
},
// model modifications
modelAllChange: function(){
this.rowCount = (this.model ? this.model.getRowCount() : 0);
this.updateRowCount(this.rowCount);
},
modelRowChange: function(inData, inRowIndex){
this.updateRow(inRowIndex);
},
modelDatumChange: function(inDatum, inRowIndex, inFieldIndex){
this.updateRow(inRowIndex);
},
modelFieldsChange: function() {
this.indexCellFields();
this.render();
},
// model insertion
modelInsertion: function(inRowIndex){
this.updateRowCount(this.model.getRowCount());
},
// model removal
modelRemoval: function(inKeys){
this.updateRowCount(this.model.getRowCount());
},
// cells
getCellName: function(inCell){
var v = this.model.fields.values, i = inCell.fieldIndex;
return i>=0 && i<v.length && v[i].name || this.inherited(arguments);
},
indexCellFields: function(){
var cells = this.layout.cells;
for(var i=0, c; cells && (c=cells[i]); i++){
if(dojo.isString(c.field)){
c.fieldIndex = this.model.fields.indexOf(c.field);
}
}
},
// utility
refresh: function(){
// summary:
// re-render the grid, getting new data from the model
this.edit.cancel();
this.model.measure();
},
// sorting
canSort: function(inSortInfo){
var f = this.getSortField(inSortInfo);
// 0 is not a valid sort field
return f && this.model.canSort(f);
},
getSortField: function(inSortInfo){
// summary:
// retrieves the model field on which to sort data.
// inSortInfo: int
// 1-based grid column index; positive if sort is ascending, otherwise negative
var c = this.getCell(this.getSortIndex(inSortInfo));
// we expect c.fieldIndex == -1 for non model fields
// that yields a getSortField value of 0, which can be detected as invalid
return (c.fieldIndex+1) * (this.sortInfo > 0 ? 1 : -1);
},
sort: function(){
this.edit.apply();
this.model.sort(this.getSortField());
},
// row editing
addRow: function(inRowData, inIndex){
this.edit.apply();
var i = inIndex || -1;
if(i<0){
i = this.selection.getFirstSelected() || 0;
}
if(i<0){
i = 0;
}
this.model.insert(inRowData, i);
this.model.beginModifyRow(i);
// begin editing row
// FIXME: add to edit
for(var j=0, c; ((c=this.getCell(j)) && !c.editor); j++){}
if(c&&c.editor){
this.edit.setEditCell(c, i);
}
},
removeSelectedRows: function(){
this.edit.apply();
var s = this.selection.getSelected();
if(s.length){
this.model.remove(s);
this.selection.clear();
}
},
//: protected
// editing
canEdit: function(inCell, inRowIndex){
// summary:
// determines if a given cell may be edited
// inCell: grid cell
// inRowIndex: grid row index
// returns: true if given cell may be edited
return (this.model.canModify ? this.model.canModify(inRowIndex) : true);
},
doStartEdit: function(inCell, inRowIndex){
var edit = this.canEdit(inCell, inRowIndex);
if(edit){
this.model.beginModifyRow(inRowIndex);
this.onStartEdit(inCell, inRowIndex);
}
return edit;
},
doApplyCellEdit: function(inValue, inRowIndex, inFieldIndex){
this.model.setDatum(inValue, inRowIndex, inFieldIndex);
this.onApplyCellEdit(inValue, inRowIndex, inFieldIndex);
},
doCancelEdit: function(inRowIndex){
this.model.cancelModifyRow(inRowIndex);
this.onCancelEdit.apply(this, arguments);
},
doApplyEdit: function(inRowIndex){
this.model.endModifyRow(inRowIndex);
this.onApplyEdit(inRowIndex);
},
// Perform row styling
styleRowState: function(inRow){
if(this.model.getState){
var states=this.model.getState(inRow.index), c='';
for(var i=0, ss=["inflight", "error", "inserting"], s; s=ss[i]; i++){
if(states[s]){
c = ' dojoxGrid-row-' + s;
break;
}
}
inRow.customClasses += c;
}
},
onStyleRow: function(inRow){
this.styleRowState(inRow);
this.inherited(arguments);
},
junk: 0
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/tests/test_tundra_edit.html
New file
0,0 → 1,140
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test dojox.Grid Editing</title>
<style>
@import "../_grid/tundraGrid.css";
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
 
.dojoxGrid-row-editing td {
background-color: #F4FFF4;
}
.dojoxGrid input, .dojoxGrid select, .dojoxGrid textarea {
margin: 0;
padding: 0;
border-style: none;
width: 100%;
font-size: 100%;
font-family: inherit;
}
.dojoxGrid input {
}
.dojoxGrid select {
}
.dojoxGrid textarea {
}
 
#controls {
padding: 6px 0;
}
#controls button {
margin-left: 10px;
}
.myGrid {
width: 850px;
height: 350px;
border: 1px solid silver;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug:false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>
<script type="text/javascript">
// ==========================================================================
// Create a data model
// ==========================================================================
data = [
[ "normal", false, "new", 'But are not followed by two hexadecimal', 29.91, 10, false ],
[ "important", false, "new", 'Because a % sign always indicates', 9.33, -5, false ],
[ "important", false, "read", 'Signs can be selectively', 19.34, 0, true ],
[ "note", false, "read", 'However the reserved characters', 15.63, 0, true ],
[ "normal", false, "replied", 'It is therefore necessary', 24.22, 5.50, true ],
[ "important", false, "replied", 'To problems of corruption by', 9.12, -3, true ],
[ "note", false, "replied", 'Which would simply be awkward in', 12.15, -4, false ]
];
var rows = 10000;
for(var i=0, l=data.length; i<rows-l; i++){
data.push(data[i%l].slice(0));
}
model = new dojox.grid.data.Table(null, data);
 
// ==========================================================================
// Tie some UI to the data model
// ==========================================================================
model.observer(this);
modelChange = function(){
dojo.byId("rowCount").innerHTML = 'Row count: ' + model.count;
}
 
// ==========================================================================
// Custom formatter
// ==========================================================================
formatMoney = function(inDatum){
return isNaN(inDatum) ? '...' : '$' + parseFloat(inDatum).toFixed(2);
}
 
// ==========================================================================
// Grid structure
// ==========================================================================
statusCell = {
field: 2,
name: 'Status',
styles: 'text-align: center;',
editor: dojox.grid.editors.Select,
options: [ "new", "read", "replied" ]
};
 
gridLayout = [
{
type: 'dojox.GridRowView', width: '20px'
},
{
defaultCell: { width: 8, editor: dojox.grid.editors.Input, styles: 'text-align: right;' },
rows: [
[
{ name: 'Id', width: 3, get: function(inRowIndex){ return inRowIndex+1;} },
{ name: 'Priority', styles: 'text-align: center;', editor: dojox.grid.editors.Select, options: ["normal", "note", "important"]},
{ name: 'Mark', width: 3, styles: 'text-align: center;', editor: dojox.grid.editors.Bool },
statusCell,
{ name: 'Message', styles: '', width: '100%' },
{ name: 'Amount', formatter: formatMoney }
]
]
}
];
// ==========================================================================
// UI Action
// ==========================================================================
addRow = function() {
grid.addRow([ "normal", false, "new", 'Now is the time for all good men to come to the aid of their party.', 99.99, 9.99, false ]);
}
</script>
</head>
<body class="tundra">
<h1>dojox.Grid Basic Editing test</h1>
<br />
<div id="controls">
<button onclick="grid.refresh()">Refresh</button>
<button onclick="grid.edit.focusEditor()">Focus Editor</button>
<button onclick="grid.focus.next()">Next Focus</button>
<button onclick="addRow()">Add Row</button>
<button onclick="grid.removeSelectedRows()">Remove</button>
<button onclick="grid.edit.apply()">Apply</button>
<button onclick="grid.edit.cancel()">Cancel</button>
<button onclick="grid.singleClickEdit = !grid.singleClickEdit">Toggle singleClickEdit</button>
</div>
<br />
<div jsId="grid" class="myGrid"
dojoType="dojox.Grid" model="model"
structure="gridLayout"></div>
<br />
<div id="rowCount"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_sizing.html
New file
0,0 → 1,154
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>dojox.Grid Sizing Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../_grid/tundraGrid.css";
/*
@import "../_grid/Grid.css";
body {
font-size: 0.9em;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
*/
.heading {
font-weight: bold;
padding-bottom: 0.25em;
}
#container {
width: 400px;
height: 200px;
border: 4px double #333;
}
#grid {
border: 1px solid #333;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug:false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>
<script type="text/javascript">
data = [
[ "normal", false, "new", 'But are not followed by two hexadecimal', 29.91, 10, false ],
[ "important", false, "new", 'Because a % sign always indicates', 9.33, -5, false ],
[ "important", false, "read", 'Signs can be selectively', 19.34, 0, true ],
[ "note", false, "read", 'However the reserved characters', 15.63, 0, true ],
[ "normal", false, "replied", 'It is therefore necessary', 24.22, 5.50, true ],
[ "important", false, "replied", 'To problems of corruption by', 9.12, -3, true ],
[ "note", false, "replied", 'Which would simply be awkward in', 12.15, -4, false ]
];
model = new dojox.grid.data.table(null, data);
// grid structure
// a grid view is a group of columns
// a special view providing selection feedback
var rowBar = {type: 'dojox.GridRowView', width: '20px'};
// a view without scrollbars
var leftView = {
noscroll: true,
cells: [[
{name: 'Column 0'},
{name: 'Column 1'}
]]};
var middleView = {
cells: [[
{name: 'Column 2'},
{name: 'Column 3'},
{name: 'Column 4'},
{name: 'Column 5'},
{name: 'Column 6'},
]]};
// a grid structure is an array of views.
var structure = [ rowBar, leftView, middleView];
// get can return data for each cell of the grid
function get(inRowIndex) {
return [this.index, inRowIndex].join(', ');
}
function resizeInfo() {
setTimeout(function() {
dojo.byId('gridWidth').value = grid.domNode.clientWidth;
dojo.byId('gridHeight').value = grid.domNode.clientHeight;
}, 1);
}
function resizeGrid() {
grid.autoHeight = false;
grid.autoWidth = false;
var
w = Number(dojo.byId('gridWidth').value),
h = Number(dojo.byId('gridHeight').value);
dojo.contentBox(grid.domNode, {w: w, h: h});
grid.update();
}
function fitWidth() {
grid.autoWidth = true;
grid.autoHeight = false;
grid.update();
}
function fitHeight() {
grid.autoWidth = false;
grid.autoHeight = true;
grid.update();
}
function fitBoth() {
grid.autoWidth = true;
grid.autoHeight = true;
grid.update();
}
function sizeDefault() {
grid.autoWidth = false;
grid.autoHeight = false;
grid.domNode.style.width = '';
grid.domNode.style.height = 0;
grid.update();
}
dojo.addOnLoad(function() {
window["grid"] = dijit.byId("grid");
dojo.byId('gridWidth').value = 500;
dojo.byId('gridHeight').value = 200;
dojo.connect(grid, 'update', resizeInfo);
resizeGrid();
window["grid1"] = dijit.byId("grid1");
});
</script>
</head>
<body class="tundra">
<div class="heading">dojox.Grid Sizing Test</div>
Grid width: <input id="gridWidth" type="text">&nbsp;
and height: <input id="gridHeight" type="text">&nbsp;
<button onclick="resizeGrid()">Resize Grid</button><br><br>
<button onclick="fitWidth()">Fit Data Width</button>&nbsp;
<button onclick="fitHeight()">Fit Data Height</button>&nbsp;
<button onclick="fitBoth()">Fit Data Width & Height</button>
<button onclick="sizeDefault()">DefaultSize</button><br><br>
<div id="grid" dojoType="dojox.Grid" model="model" structure="structure" elasticView="2"></div>
<p>Grid fits to a sized container by default:</p>
<div id="container">
<div id="grid1" dojoType="dojox.VirtualGrid" get="get" structure="structure" rowCount="10" elasticView="2"></div>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/images/open.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/grid/tests/images/open.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/grid/tests/images/flatScreen.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/grid/tests/images/flatScreen.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/grid/tests/images/closed.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/grid/tests/images/closed.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/grid/tests/test_events.html
New file
0,0 → 1,172
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test dojox.Grid Events</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../_grid/Grid.css";
body,td,th {
font-family: Geneva, Arial, Helvetica, sans-serif;
}
#grid {
border: 1px solid;
border-top-color: #F6F4EB;
border-right-color: #ACA899;
border-bottom-color: #ACA899;
border-left-color: #F6F4EB;
}
#grid {
width: 50em;
height: 20em;
padding: 1px;
overflow: hidden;
font-size: small;
}
h3 {
margin: 10px 0 2px 0;
}
.fade {
/*background-image:url(images/fade.gif);*/
}
.no-fade {
/*background-image: none;*/
}
#eventGrid {
float: right;
font-size: small;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>
<script type="text/javascript">
// events to track
var eventRows = [
{ name: 'onCellClick' },
{ name: 'onRowClick', properties: ['rowIndex'] },
{ name: 'onCellDblClick' },
{ name: 'onRowDblClick', properties: ['rowIndex'] },
{ name: 'onCellMouseOver' },
{ name: 'onCellMouseOut' },
{ name: 'onRowMouseOver' },
{ name: 'onRowMouseOut' },
{ name: 'onHeaderCellClick' },
{ name: 'onHeaderClick', properties: ['rowIndex'] },
{ name: 'onHeaderCellDblClick' },
{ name: 'onHeaderDblClick', properties: ['rowIndex'] },
{ name: 'onHeaderCellMouseOver' },
{ name: 'onHeaderCellMouseOut' },
{ name: 'onHeaderMouseOver' },
{ name: 'onHeaderMouseOut' },
{ name: 'onKeyDown', properties: ['keyCode'] },
{ name: 'onCellContextMenu' },
{ name: 'onRowContextMenu', properties: ['rowIndex'] },
{ name: 'onHeaderCellContextMenu' },
{ name: 'onHeaderContextMenu', properties: ['rowIndex'] }
];
getEventName = function(inRowIndex) {
return eventRows[inRowIndex].name;
};
getEventData = function(inRowIndex) {
var d = eventRows[inRowIndex].data;
var r = [];
if (d)
for (var i in d)
r.push(d[i]);
else
r.push('na')
return r.join(', ');
}
// grid structure for event tracking grid.
var eventView = {
noscroll: true,
cells: [[
{ name: 'Event', get: getEventName, width: 12 },
{ name: 'Data', get: getEventData, width: 10 }
]]
}
var eventLayout = [ eventView ];
var fade = function(inNode) {
if (!inNode || !inNode.style) return;
var c = 150, step = 5, delay = 20;
var animate = function() {
c = Math.min(c + step, 255);
inNode.style.backgroundColor = "rgb(" + c + ", " + c + ", 255)";
if (c < 255) window.setTimeout(animate, delay);
}
animate();
}
// setup a fade on a row. Must do this way to avoid caching of fade gif
updateRowFade = function(inRowIndex) {
var n = eventGrid.views.views[0].getRowNode(inRowIndex);
fade(n);
}
// store data about event. By default track event.rowIndex and event.cell.index, but eventRows can specify params, which are event properties to track.
setEventData = function(inIndex, inEvent) {
var eRow = eventRows[inIndex];
eRow.data = {};
var properties = eRow.properties;
if (properties)
for (var i=0, l=properties.length, p; (p=properties[i] || i < l); i++)
eRow.data[p] = inEvent[p];
else
eRow.data = {
row: (inEvent.rowIndex != undefined ? Number(inEvent.rowIndex) : 'na'),
cell: (inEvent.cell && inEvent.cell.index != undefined ? inEvent.cell.index : 'na')
}
eventGrid.updateRow(inIndex);
updateRowFade(inIndex);
}
// setup grid events for all events being tracked.
setGridEvents = function() {
var makeEvent = function(inIndex, inName) {
return function(e) {
setEventData(inIndex, e);
dojox.VirtualGrid.prototype[inName].apply(this, arguments);
}
}
for (var i=0, e; (e=eventRows[i]); i++)
grid[e.name] = makeEvent(i, e.name);
}
// Grid structure
var layout = [// array of view objects
{ type: 'dojox.GridRowView', width: '20px' },
{ noscroll: true, cells: [// array of rows, a row is an array of cells
[{ name: "Alpha", value: '<input type="checkbox"></input>', rowSpan: 2, width: 6, styles: 'text-align:center;' }, { name: "Alpha2", value: "Alpha2" }],
[{ name: "Alpha3", value: "Alpha3" }]
]},
{ cells: [
[{ name: "Beta", value: 'simple'}, { name: "Beta2", value: "Beta2" }, { name: "Beta3", value: "Beta3" }, { name: "Beta4", value: "Beta4" }, { name: "Beta5", value: "Beta5" }],
[{ name: "Summary", colSpan: 5, value: 'Summary' }]
]},
{ noscroll: true, cells: [
[{ name: "Gamma", value: "Gamma" }, { name: "Gamma2", value: "<button>Radiate</button>", styles: 'text-align:center;' }]]
}];
dojo.addOnLoad(function() {
window["grid"] = dijit.byId("grid");
window["eventGrid"] = dijit.byId("eventGrid");
grid.rows.defaultRowHeight = 4;
setGridEvents();
eventGrid.updateRowCount(eventRows.length);
dojo.debug = console.log;
});
</script>
</head>
<body>
<h3>dojox.Grid Event Tracking</h3>
<div id="eventGrid" autoWidth="true" autoHeight="true" structure="eventLayout" dojoType="dojox.VirtualGrid"></div>
<div id="grid" rowCount="100" dojoType="dojox.VirtualGrid"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_dojo_data_model.html
New file
0,0 → 1,85
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>dojox.Grid with Dojo.Data via binding</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../_grid/tundraGrid.css";
#grid, #grid2 {
width: 65em;
height: 25em;
padding: 1px;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug: true, debugAtAllCosts: false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojox.data.CsvStore");
dojo.require("dojo.parser");
</script>
<script type="text/javascript">
function getRow(inRowIndex){
return ' ' + inRowIndex;
}
var layoutMovies = [
// view 0
{ type: 'dojox.GridRowView', width: '20px' },
// view 1
{ cells: [[{ name: "Row", get: getRow, width: 5}]], noscroll: true},
// view 2
{ cells: [[
{ field: "Title", width: 'auto' },
{ field: "Year", width: 5 },
{ field: "Producer", width: 20 }
]]}
];
var layoutCountries = [
// view 0
{ type: 'dojox.GridRowView', width: '20px' },
// view 1
{ cells: [[{ name: "Row", get: getRow, width: 5}]], noscroll: true},
// view 2
{ cells: [[
{ field: 0, width: 'auto' },
{ width: 8 }
]]}
];
</script>
</head>
<body class="tundra">
<h5>dojox.Grid using Dojo.Data stores via simple binding</h5>
<span dojoType="dojox.data.CsvStore"
jsId="csvStore" url="support/movies.csv">
</span>
<span dojoType="dojox.grid.data.DojoData"
jsId="dataModel"
store="csvStore"
rowsPerPage="5"
query="{ Title: '*' }"
clientSort="true">
</span>
<div id="grid" dojoType="dojox.Grid" elasticView="2"
model="dataModel" structure="layoutMovies">
</div>
 
<span dojoType="dojo.data.ItemFileReadStore"
jsId="jsonStore" url="../../../dijit/tests/_data/countries.json">
</span>
<span dojoType="dojox.grid.data.DojoData"
jsId="dataModel2"
rowsPerPage="20"
store="jsonStore"
query="{ name : '*' }">
</span>
<div id="grid2" dojoType="dojox.Grid" elasticView="2"
model="dataModel2" structure="layoutCountries">
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_yahoo_images.html
New file
0,0 → 1,140
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>dojox.Grid - Image Search Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style>
@import "../_grid/Grid.css";
body {
font-size: 0.9em;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.grid {
height: 30em;
width: 51em;
border: 1px solid silver;
}
#info {
width: 700px;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>
<script type="text/javascript" src="yahooSearch.js"></script>
<script type="text/javascript">
// model fields
imageFields = [
{ name: 'Title', na: '' },
{ name: 'Thumbnail', na: ''},
{ name: 'Summary', na: '' },
{ name: 'Url', na: '' },
{ name: 'FileSize', na: ''},
{ name: 'Height', na: ''},
{ name: 'Width', na: ''}
];
// create data model
var model = new dojox.grid.data.yahooSearch(imageFields, null, "searchInput");
model.url = 'http://search.yahooapis.com/ImageSearchService/V1/imageSearch';
model.observer(this);
// report some model send/receive status
model.onSend = function(inParams) {
dojo.byId('sendInfo').innerHTML = dojo.string.substitute('Request rows ${0} to ${1}.&nbsp&nbsp;', [inParams.start, inParams.start + inParams.results -1]);
}
model.onReceive = function(inData) {
dojo.byId('receiveInfo').innerHTML = dojo.string.substitute('Receive rows ${0} to ${1}.&nbsp&nbsp;', [inData.firstResultPosition, inData.firstResultPosition + inData.totalResultsReturned-1]);
}
 
 
// Define grid structure
// remove the height from the header image cell / row cells have a default height so there's less adjustment when thumb comes in.
beforeImageRow = function(inRowIndex, inSubRows) {
inSubRows[0].hidden = (inRowIndex == -1);
}
var imageLayout = [
{ onBeforeRow: beforeImageRow,
cells: [
[ { name: 'Image', cellStyles: "height: 100px;", styles: "text-align: center;", width: 12, field: 3, extraField: 1, formatter: formatImage },
{ name: 'Image', cellStyles: "height: 100px;", styles: "text-align: center;", width: 12, field: 3, extraField: 1, formatter: formatImage },
{ name: 'Image', cellStyles: "height: 100px;", styles: "text-align: center;", width: 12, field: 3, extraField: 1, formatter: formatImage },
{ name: 'Image', cellStyles: "height: 100px;", styles: "text-align: center;", width: 12, field: 3, extraField: 1, formatter: formatImage }
]
]}
];
// Create grid subclass to function as we need to display images only.
// adds indirection between model row and grid row.
dojo.declare("dojox.ImageGrid", dojox.Grid, {
postCreate: function() {
this.inherited(arguments);
this.modelDatumChange = this.modelRowChange;
this.colCount = this.layout.cells.length;
},
getDataRowIndex: function(inCell, inRowIndex) {
var r = inCell.index + Math.floor(inRowIndex * this.colCount);
return r;
},
// called in cell context
get: function(inRowIndex) {
var r = this.grid.getDataRowIndex(this, inRowIndex);
return dojox.Grid.prototype.get.call(this, r);
},
modelAllChange: function(){
this.rowCount = Math.ceil(this.model.getRowCount() / this.colCount);
this.updateRowCount(this.rowCount);
},
modelRowChange: function(inData, inRowIndex) {
if (inRowIndex % this.colCount == this.colCount - 1 || inRowIndex == this.model.count - 1)
this.updateRow(Math.floor(inRowIndex / this.colCount));
}
});
getCellData = function(inCell, inRowIndex, inField) {
var m = inCell.grid.model, r = inCell.grid.getDataRowIndex(inCell, inRowIndex);
return m.getDatum(r, inField);
}
// execute search
doSearch = function() {
model.clearData();
model.setRowCount(0);
grid.render();
grid.resize();
model.requestRows();
}
keypress = function(e) {
if (e.keyCode == dojo.keys.ENTER)
doSearch();
}
dojo.addOnLoad(function() {
dojo.connect(dojo.byId("searchInput"), "keypress", keypress);
doSearch();
});
</script>
</head>
<body>
<div style="font-weight: bold; padding-bottom: 0.25em;">dojox.Grid - Image Search Test</div>
<input id="searchInput" type="text" value="apple">&nbsp;&nbsp;
<button onclick="doSearch()">Search</button><br>
<br>
<div jsId="grid" class="grid" structure="imageLayout" dojoType="dojox.ImageGrid" model="model"></div>
<br>
<div id="info">
<div id="rowCount" style="float: left"></div>
<div style="float: right">
<div id="sendInfo" style="text-align: right"></div>
<div id="receiveInfo" style="text-align: right"></div>
</div>
</div>
<br /><br />
<p>Note: requires PHP for proxy.</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_yahoo_search.html
New file
0,0 → 1,142
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>dojox.Grid - Yahoo Search Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style>
@import "../_grid/Grid.css";
body {
font-size: 0.9em;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.grid {
height: 30em;
}
#info {
width: 700px;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>
<script type="text/javascript" src="yahooSearch.js"></script>
<script type="text/javascript">
webFields = [
{ name: 'Title', na: '' },
{ name: 'ModificationDate', na: ''},
{ name: 'Summary', na: '&nbsp;' },
{ name: 'Url', na: '' },
{ name: 'MimeType', na: '&nbsp;'},
{ name: 'DisplayUrl', na: '&nbsp;'}
];
imageFields = [
{ name: 'Title', na: '' },
{ name: 'Thumbnail', na: ''},
{ name: 'Summary', na: '' },
{ name: 'Url', na: '' },
{ name: 'FileSize', na: ''},
{ name: 'Height', na: ''},
{ name: 'Width', na: ''}
];
 
var model = new dojox.grid.data.yahooSearch(imageFields, null, "searchInput");
model.observer(this);
// report some model send/receive status
model.onSend = function(inParams) {
dojo.byId('sendInfo').innerHTML = dojo.string.substitute('Request rows ${0} to ${1}.&nbsp&nbsp;', [inParams.start, inParams.start + inParams.results -1] );
}
model.onReceive = function(inData) {
dojo.byId('receiveInfo').innerHTML = dojo.string.substitute('Receive rows ${0} to ${1}.&nbsp&nbsp;', [inData.firstResultPosition, inData.firstResultPosition + inData.totalResultsReturned-1]);
}
 
var webLayout = [
{ type: 'dojox.GridRowView', width: '20px' },
{ noscroll: true,
cells: [
[ { name: 'Row', width: 3, styles: 'text-align: center;', get: function(inRowIndex) { return inRowIndex + 1 } }]
]
},
{ cells: [
[ { name: 'Site', width: 30, field: 3, extraField: 0, formatter: formatLink }, { name: 'Date', width: 10, field: 1, formatter: formatDate} ],
[ { name: 'Display Url', width: 30, field: 5, styles: 'color: green; size: small;' }, { name: 'Type', width: 10, field: 4, styles: ' font-style: italic; color: gray; size: small;'} ],
[ { name: 'Summary', width: 40, colSpan: 2, field: 2 } ]
]}
];
// remove the height from the header image cell / row cells have a default height so there's less adjustment when thumb comes in.
beforeImageRow = function(inRowIndex, inSubRow) {
inSubRow[0][0].cellStyles = (inRowIndex == -1 ? '' : 'height: 100px;');
inSubRow[1][0].cellStyles = (inRowIndex == -1 ? '' : 'vertical-align: top; height: 75px;');
}
var imageLayout = [
{ type: 'dojox.GridRowView', width: '20px' },
{ noscroll: true,
cells: [
[ { name: 'Row', width: 3, styles: 'text-align: center;', get: function(inRowIndex) { return inRowIndex + 1 } }]
]
},
{ onBeforeRow: beforeImageRow,
cells: [
[ { name: 'Image', cellStyles: "height: 100px;", styles: "text-align: center;", width: 13, rowSpan: 2, field: 3, extraField: 1, formatter: formatImage },
{ name: 'Title', cellStyles: "height: 10px;", width: 14, field: 3, extraField: 0, formatter: formatLink },
{ name: 'Size', width: 8, field: 4, styles: "font-style: italic; text-align: center;" },
{ name: 'Dimensions', width: 8, field: 6, extraField: 5, styles: "text-align: center;", formatter: formatDimensions }
],
[ { name: 'Summary', cellStyles: "vertical-align: top; height: 75px;", colSpan: 3, field: 2 } ]
]}
];
// execute search
doSearch = function() {
var web = dojo.byId('webRb').checked;
model.setRowCount(0);
model.clear();
model.fields.set(web ? webFields : imageFields);
model.url = 'http://search.yahooapis.com/' + (web ? 'WebSearchService/V1/webSearch' : 'ImageSearchService/V1/imageSearch');
grid.scrollToRow(0);
grid.setStructure(web ? webLayout : imageLayout);
model.requestRows();
}
// do search on enter...
keypress = function(e) {
if (e.keyCode == dojo.keys.ENTER)
doSearch();
}
 
dojo.addOnLoad(function() {
dojo.byId('webRb').checked = "checked";
dojo.connect(dojo.byId("searchInput"), "keypress", keypress);
doSearch();
});
 
</script>
</head>
<body>
<div style="font-weight: bold; padding-bottom: 0.25em;">dojox.Grid - Yahoo Search Test</div>
<div style="padding-bottom: 3px;">
<label><input id="webRb" type="radio" name="searchType" checked>Web</label>&nbsp;&nbsp;
<label><input id="imageRb" type="radio" name="searchType">Images</label>
</div>
<input id="searchInput" type="text" value="apple">&nbsp;&nbsp;
<button onclick="doSearch()">Search</button><br><br>
<div jsId="grid" class="grid" autoWidth="true" structure="webLayout" dojoType="dojox.Grid" model="model" elasticView="1"></div>
<br>
<div id="info">
<div id="rowCount" style="float: left"></div>
<div style="float: right">
<div id="sendInfo" style="text-align: right"></div>
<div id="receiveInfo" style="text-align: right"></div>
</div>
</div>
<br /><br />
<p>Note: requires PHP for proxy.</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_change_structure.html
New file
0,0 → 1,125
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>dojox.Grid Change Structure Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../_grid/Grid.css";
body {
font-size: 0.9em;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.heading {
font-weight: bold;
padding-bottom: 0.25em;
}
#grid {
border: 1px solid #333;
width: 48em;
height: 30em;
}
#grid .dojoxGrid-cell {
text-align: center;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>
<script type="text/javascript">
 
// get can return data for a cell of the grid
function get(inRowIndex) {
return [this.index, inRowIndex].join(', ');
}
 
// grid structure
// a grid view is a group of columns
// a special view providing selection feedback
var rowBar = {type: 'dojox.GridRowView', width: '20px' };
// a view without scrollbars
var view0 = {
noscroll: true,
cells: [[
{name: 'Alpha', value: '<input name="" type="checkbox" value="0">'},
{name: 'Beta', get: get, width: 4.5}
]]};
var view1 = {
cells: [[
{name: 'Apple', value: '<button>Apple</button>'},
{name: 'Banana', get: get},
{name: 'Beans', value: 'Happy to be grid!'},
{name: 'Kiwi', get: get},
{name: 'Orange', value: '<img src="images/flatScreen.gif" height="48" width="48">'},
{name: 'Pear', get: get},
{name: 'Tomato', width: 20, value: '<input name="" type="file">'},
]]};
var view2 = {
noscroll: true,
cells: [
[
{name: 'Alpha', value: '<input name="" type="checkbox" value="0">', rowSpan: 2},
{name: 'Beta', get: get, width: 4.5}
], [
{name: 'Gamma', get: get}
],
[
{name: 'Epsilon', value: '<button>Epsilon</button>', colSpan: 2}
]
]
}
var view3 = {
cells: [
[
{name: 'Apple', value: '<button>Apple</button>', rowSpan: 3},
{name: 'Banana', get: get, width: 20},
{name: 'Kiwi', get: get, width: 20},
{name: 'Pear', get: get, width: 20},
],
[
{name: 'Beans', value: 'Happy to be grid!'},
{name: 'Orange', value: '<img src="images/flatScreen.gif" height="48" width="48">'},
{name: 'Tomato', value: '<input name="" type="file">'}
], [
{name: 'Zuchini', value: '<span style="letter-spacing: 10em;">wide</span>', colSpan: 3}
]
]};
// a grid structure is an array of views.
// By default the middle view will be 'elastic', sized to fit the remaining space left by other views
// grid.elasticView can also be manually set
var structure = [ rowBar, view0, view1 ];
var structure2 = [ rowBar, view2, view3 ];
var l2 = false;
toggleStructure = function() {
l2 = !l2;
grid.scrollToRow(0);
grid.setStructure(l2 ? structure2 : structure);
}
dojo.addOnLoad(function() {
window["grid"] = dijit.byId("grid");
});
</script>
</head>
<body>
<div class="heading">dojox.VirtualGrid Change Structure Example</div>
<p>
<button onclick="toggleStructure()">Change Structure</button>
</p>
<div id="grid" dojoType="dojox.VirtualGrid" structure="structure" rowCount="100000" elasticView="2"></div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_edit_dijit.html
New file
0,0 → 1,138
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test dojox.Grid Editing</title>
<style type="text/css">
@import "../_grid/tundraGrid.css";
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
#controls button {
margin-left: 10px;
}
#grid {
width: 850px;
height: 350px;
border: 1px solid silver;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojox.grid._data.dijitEditors");
dojo.require("dojo.parser");
 
// ==========================================================================
// Create a data model
// ==========================================================================
s = (new Date()).getTime();
data = [
[ "normal", false, "new", 'But are not followed by two hexadecimal', 29.91, 10, false, s],
[ "important", false, "new", 'Because a % sign always indicates', 9.33, -5, false, s ],
[ "important", false, "read", 'Signs can be selectively', 19.34, 0, true, s ],
[ "note", false, "read", 'However the reserved characters', 15.63, 0, true, s ],
[ "normal", false, "replied", 'It is therefore necessary', 24.22, 5.50, true, s ],
[ "important", false, "replied", 'To problems of corruption by', 9.12, -3, true, s ],
[ "note", false, "replied", 'Which would simply be awkward in', 12.15, -4, false, s ]
];
var rows = 100;
for(var i=0, l=data.length; i<rows; i++){
data.push(data[i%l].slice(0));
}
model = new dojox.grid.data.Table(null, data);
// ==========================================================================
// Tie some UI to the data model
// ==========================================================================
model.observer(this);
modelChange = function(){
dojo.byId("rowCount").innerHTML = 'Row count: ' + model.count;
}
/*
modelInsertion = modelDatumChange = function(a1, a2, a3){
console.debug(a1, a2, a3);
}
*/
// ==========================================================================
// Custom formatters
// ==========================================================================
formatCurrency = function(inDatum){
return isNaN(inDatum) ? '...' : dojo.currency.format(inDatum, this.constraint);
}
formatDate = function(inDatum){
return dojo.date.locale.format(new Date(inDatum), this.constraint);
}
// ==========================================================================
// Grid structure
// ==========================================================================
statusCell = {
field: 2, name: 'Status',
styles: 'text-align: center;',
editor: dojox.grid.editors.Select,
options: [ "new", "read", "replied" ]
};
 
gridLayout = [{
type: 'dojox.GridRowView', width: '20px'
},{
defaultCell: { width: 8, editor: dojox.grid.editors.Input, styles: 'text-align: right;' },
rows: [[
{ name: 'Id',
get: function(inRowIndex) { return inRowIndex+1;},
editor: dojox.grid.editors.Dijit,
editorClass: "dijit.form.NumberSpinner" },
{ name: 'Date', width: 10, field: 7,
editor: dojox.grid.editors.DateTextBox,
formatter: formatDate,
constraint: {formatLength: 'long', selector: "date"}},
{ name: 'Priority', styles: 'text-align: center;', field: 0,
editor: dojox.grid.editors.ComboBox,
options: ["normal", "note", "important"], width: 10},
{ name: 'Mark', width: 3, styles: 'text-align: center;',
editor: dojox.grid.editors.CheckBox},
statusCell,
{ name: 'Message', styles: '', width: '100%',
editor: dojox.grid.editors.Editor, editorToolbar: true },
{ name: 'Amount', formatter: formatCurrency, constraint: {currency: 'EUR'},
editor: dojox.grid.editors.Dijit, editorClass: "dijit.form.CurrencyTextBox" },
{ name: 'Amount', field: 4, formatter: formatCurrency, constraint: {currency: 'EUR'},
editor: dojox.grid.editors.Dijit, editorClass: "dijit.form.HorizontalSlider", width: 10}
]]
}];
// ==========================================================================
// UI Action
// ==========================================================================
addRow = function(){
grid.addRow([
"normal", false, "new",
'Now is the time for all good men to come to the aid of their party.',
99.99, 9.99, false
]);
}
</script>
</head>
<body>
<h1>dojox.Grid Basic Editing test</h1>
<br />
<div id="controls">
<button onclick="grid.refresh()">Refresh</button>
<button onclick="grid.edit.focusEditor()">Focus Editor</button>
<button onclick="grid.focus.next()">Next Focus</button>
<button onclick="addRow()">Add Row</button>
<button onclick="grid.removeSelectedRows()">Remove</button>
<button onclick="grid.edit.apply()">Apply</button>
<button onclick="grid.edit.cancel()">Cancel</button>
<button onclick="grid.singleClickEdit = !grid.singleClickEdit">Toggle singleClickEdit</button>
</div>
<br />
<div id="grid" jsId="grid" dojoType="dojox.Grid" model="model" structure="gridLayout"></div>
<br />
<div id="rowCount"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/support/movies.csv
New file
0,0 → 1,9
Title, Year, Producer
City of God, 2002, Katia Lund
Rain,, Christine Jeffs
2001: A Space Odyssey, , Stanley Kubrick
"This is a ""fake"" movie title", 1957, Sidney Lumet
Alien, 1979 , Ridley Scott
"The Sequel to ""Dances With Wolves.""", 1982, Ridley Scott
"Caine Mutiny, The", 1954, "Dymtryk ""the King"", Edward"
 
/trunk/api/js/dojo1.0/dojox/grid/tests/support/data.php
New file
0,0 → 1,379
<?php
// db settings
$dbserver = 'localhost';
$dbuser = 'root';
$dbpassword = 'root';
error_reporting(E_ALL);
/*
Simple protocol:
- Inputs via POST variables.
- Output is a string that can be evaluated into a JSON
First element of the array contains return status.
This simplified tutorial code should not be deployed without a security review.
*/
@include "json.php";
// set up response encoding
header("Content-Type: text/html; charset=utf-8");
 
// util
function getPostString($inName) {
// make sure input strings are 'clean'
return mysql_real_escape_string(@$_POST[$inName]);
}
// used for json encoding
$json = new Services_JSON();
function echoJson($inData) {
global $json;
// delay in ms
$delay = getPostString('delay');
if (!empty($delay))
usleep($delay * 1000);
echo '/* ' . $json->encode($inData) . ' */';
}
function error($inMessage) {
$inMessage = str_replace('"', '\\"', $inMessage);
error_log($inMessage);
//echo '/* ({error: true, message: "' . $inMessage . '"}) */';
echoJson(array('error' => true, 'message' => $inMessage));
exit;
}
 
 
function getArray($inResult, $inArray="true") {
$o = Array();
while ($row = ($inArray ? mysql_fetch_row($inResult) : mysql_fetch_object($inResult)))
$o[] = $row;
return $o;
}
// connect to DB
mysql_connect($dbserver, $dbuser, $dbpassword);
 
// select DB
$database = getPostString("database");
$database = ($database ? $database : $db);
if (!mysql_select_db($database))
error('failed to select db: ' . mysql_error());
 
// select table
$table = getPostString("table");
$table = ($table ? $table : $dbtable);
 
// cache
$colCache = NULL;
$pkCache = NULL;
 
// set UTF8 output (MySql > 4.0)
mysql_query("SET NAMES UTF8");
// server, database, table meta data
function getDatabases() {
$result = mysql_query("SHOW DATABASES");
$output = Array();
while ($row = mysql_fetch_row($result)) {
$r = strtolower($row[0]);
if ($r != 'mysql' && $r != 'information_schema')
$output[] = $row[0];
}
return $output;
}
function getTables() {
global $database;
$result = mysql_query("SHOW TABLES FROM $database");
$output = Array();
while ($row = mysql_fetch_row($result))
$output[] = $row[0];
return $output;
}
function getColumns() {
global $table, $colCache;
if (!$colCache) {
$result = mysql_query("SHOW COLUMNS FROM `$table`");
return getArray($result, false);
$colCache = getArray($result, false);
}
return $colCache;
}
// returns object: $this->name, $this->index
function getPk() {
global $pkCache;
if (!$pkCache) {
$k = '';
$columns = getColumns();
for ($i=0; $i < count($columns); $i++) {
$c = $columns[$i];
if ($c->Key == 'PRI') {
$k = $c->Field;
break;
}
}
$pkCache->index = $i;
$pkCache->name = $k;
}
return $pkCache;
}
function getTableInfo() {
global $table, $database;
$c = getColumns();
$r = rowcount();
return array("count" => $r, "columns" => $c, "database" => $database, "table" => $table);
}
function getOldPostPkValue() {
$pk = getPk();
return getPostString('_o' . $pk->index);
}
function getNewPostPkValue() {
$pk = getPk();
return getPostString('_' . $pk->index);
}
function getPostColumns() {
$columns = getColumns();
for ($i=0, $a=array(), $p; (($p=getPostString("_".$i)) != ''); $i++) {
$r = new stdClass();
$r->name = $columns[$i]->Field;
$r->value = $p;
$a[] = $r;
}
return $a;
}
function getOrderBy() {
$ob = getPostString("orderby");
if (is_numeric($ob)) {
$columns = getColumns();
$ob = $columns[intval($ob)-1]->Field;
}
return $ob;
}
function getWhere() {
$w = getPostString("where");
return ($w ? " WHERE $w" : "");
}
// basic operations
function rowcount() {
global $table;
$query = "SELECT COUNT(*) FROM `$table`" . getWhere();
$result = mysql_query($query);
if (!$result)
error("failed to perform query: $query. " . mysql_error());
if ($row = mysql_fetch_row($result))
return $row[0];
else
return 0;
}
function select($inQuery = '') {
global $table;
// built limit clause
$lim = (int)getPostString("limit");
$off = (int)getPostString("offset");
$limit = ($lim || $off ? " LIMIT $off, $lim" : "");
// build order by clause
$desc = (boolean)getPostString("desc");
$ob = getOrderBy();
$orderby = ($ob ? " ORDER BY `" . $ob . "`" . ($desc ? " DESC" : "") : "");
// build query
$query = ($inQuery ? $inQuery : "SELECT * FROM `$table`" . getWhere() . $orderby . $limit);
// execute query
if (!$result = mysql_query($query))
error("failed to perform query: $query. " . mysql_error());
// fetch each result row
return getArray($result);
}
 
function reflectRow() {
global $table;
$pk = getPk();
$key = getNewPostPkValue();
$where = "`$pk->name`=\"$key\"";
return select("SELECT * FROM `$table` WHERE $where LIMIT 1");
}
function update() {
// build set clause
for ($i=0, $set = array(), $cols = getPostColumns(), $v; ($v=$cols[$i]); $i++)
$set[] = "`$v->name` = '$v->value'";
$set = implode(', ', $set);
// our table
global $table;
// build query
$pk = getPk();
$pkValue = getOldPostPkValue();
$query = "UPDATE `$table` SET $set WHERE `$pk->name` = '$pkValue' LIMIT 1";
// execute query
if (!mysql_query($query))
error("failed to perform query: [$query]. " .
"MySql says: [" . mysql_error() ."]");
else {
return reflectRow();
}
}
function insert() {
global $table;
// build values clause
for ($i=0, $values = array(), $cols = getPostColumns(), $v; ($v=$cols[$i]); $i++)
$values[] = $v->value;
$values = '"' . implode('", "', $values) . '"';
// build query
$query = "INSERT INTO `$table` VALUES($values)";
// execute query
if (!mysql_query($query))
error("failed to perform query: [$query]. " .
"MySql says: [" . mysql_error() ."]");
else {
return reflectRow();
}
}
function delete() {
global $table;
// build query
$n = getPostString("count");
$pk = getPk();
for ($i = 0, $deleted=array(); $i < $n; $i++) {
$key = getPostString("_$i");
array_push($deleted, $key);
$query = "DELETE FROM `$table` WHERE `$pk->name`=\"$key\" LIMIT 1";
// execute query
if (!mysql_query($query) || mysql_affected_rows() != 1)
error("failed to perform query: [$query]. " .
"Affected rows: " . mysql_affected_rows() .". " .
"MySql says: [" . mysql_error() ."]");
}
return $deleted;
}
// find (full text search)
function findData($inFindCol, $inFind, $inOrderBy, $inFullText) {
global $table;
$where = ($inFullText ? "WHERE MATCH(`$inFindCol`) AGAINST ('$inFind')" : "WHERE $inFindCol LIKE '$inFind'");
$query = "SELECT * FROM $table $where $inOrderBy";
$result = mysql_query($query);
// return rows
return getArray($result);
}
// binary search through sorted data, supports start point ($inFindFrom) and direction ($inFindForward)
function findRow($inData, $inFindFrom=-1, $inFindForward) {
$b = -1;
$l = count($inData);
if (!$inData)
return $b;
if (!$inFindFrom==-1 || $l < 2)
$b = 0;
else {
// binary search
$t = $l-1;
$b = 0;
while ($b <= $t) {
$p = floor(($b+$t)/2);
$d = $inData[$p][0];
if ($d < $inFindFrom)
$b = $p + 1;
else if ($d > $inFindFrom)
$t = $p - 1;
else {
$b = $p;
break;
}
}
if ($inFindFrom == $inData[$b][0]) {
// add or subtract 1
$b = ($inFindForward ? ($b+1 > $l-1 ? 0 : $b+1) : ($b-1 < 0 ? $l-1 : $b-1) );
}
else if (!$inFindForward)
// subtract 1
$b = ($b-1 < 0 ? $l-1 : $b-1);
}
return $inData[$b][0];
}
function buildFindWhere($inFindData, $inKey, $inCol) {
$o = Array();
foreach($inFindData as $row)
$o[] = $inCol . "='" . $row[$inKey] . "'";
return (count($o) ? ' WHERE ' . implode(' OR ', $o) : '');
}
function find($inFindCol, $inFind='', $inOb='', $inFindFrom=0, $inFindForward=true, $inFullText=true) {
global $table;
// build order by clause
$desc = (boolean)getPostString("desc");
if (!$inOb)
$inOb = getOrderBy();
if ($inOb)
$inOb = "`" . $inOb . "`" ;
$orderby = ($inOb ? " ORDER BY $inOb " . ($desc ? " DESC" : "") : "");
// update inputs from post
if (!$inFind)
$inFind = getPostString('findText');
if (!$inFindCol)
$inFindCol = getPostString('findCol');
if (empty($inFindFrom))
$inFindFrom = getPostString('findFrom');
$ff = getPostString('findForward');
if ($ff)
$inFindForward = (strtolower($ff) == 'true' ? true : false);
$ft = getPostString('findFullText');
if ($ft)
$inFullText = (strtolower($ft) == 'true' ? true : false);
// get find data
$f = findData($inFindCol, $inFind, $orderby, $inFullText);
$pk = getPk();
 
// execute query
$where = buildFindWhere($f, $pk->index, 'f');
$query = "SELECT Row, f FROM (SELECT @row := @row + 1 AS Row, $pk->name as f FROM `$table` $orderby) AS tempTable $where";
mysql_query('SET @row = -1;');
if (!$result = mysql_query($query))
error("failed to perform query: $query. " . mysql_error());
// return row number
return findRow(getArray($result), $inFindFrom, $inFindForward);
}
// our command list
$cmds = array(
"count" => "rowcount",
"select" => "select",
"update" => "update",
"insert" => "insert",
"delete" => "delete",
"find" => "find",
"databases" => "getDatabases",
"tables" => "getTables",
"columns" => "getColumns",
"info" => "getTableInfo"
);
// process input params
$cmd = @$_POST["command"];
//$cmd="select";
// dispatch command
$func = @$cmds[$cmd];
if (function_exists($func))
echoJson(call_user_func($func));
else
error("bad command");
?>
/trunk/api/js/dojo1.0/dojox/grid/tests/support/json.php
New file
0,0 → 1,794
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 
/**
* Converts to and from JSON format.
*
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
*
* This package provides a simple encoder and decoder for JSON notation. It
* is intended for use with client-side Javascript applications that make
* use of HTTPRequest to perform server communication functions - data can
* be encoded into JSON notation for use in a client-side javascript, or
* decoded from incoming Javascript requests. JSON format is native to
* Javascript, and can be directly eval()'ed with no further parsing
* overhead
*
* All strings should be in ASCII or UTF-8 format!
*
* LICENSE: Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met: Redistributions of source code must retain the
* above copyright notice, this list of conditions and the following
* disclaimer. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @category
* @package Services_JSON
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
 
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_SLICE', 1);
 
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_STR', 2);
 
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_ARR', 4);
 
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_OBJ', 8);
 
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_CMT', 16);
 
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_LOOSE_TYPE', 10);
 
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_STRICT_TYPE', 11);
 
/**
* Encodings
*/
define('SERVICES_JSON_ISO_8859_1', 'iso-8859-1');
define('SERVICES_JSON_UTF_8', 'utf-8');
 
/**
* Converts to and from JSON format.
*
* Brief example of use:
*
* <code>
* // create a new instance of Services_JSON
* $json = new Services_JSON();
*
* // convert a complexe value to JSON notation, and send it to the browser
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
* $output = $json->encode($value);
*
* print($output);
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
*
* // accept incoming POST data, assumed to be in JSON notation
* $input = file_get_contents('php://input', 1000000);
* $value = $json->decode($input);
* </code>
*/
class Services_JSON
{
/**
* constructs a new JSON instance
*
//>> SJM2005
* @param string $encoding Strings are input/output in this encoding
* @param int $encode Encode input is expected in this character encoding
//<< SJM2005
*
* @param int $use object behavior: when encoding or decoding,
* be loose or strict about object/array usage
*
* possible values:
* - SERVICES_JSON_STRICT_TYPE: strict typing, default.
* "{...}" syntax creates objects in decode().
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
* "{...}" syntax creates associative arrays in decode().
*/
function Services_JSON($encoding = SERVICES_JSON_UTF_8, $use = SERVICES_JSON_STRICT_TYPE)
{
//>> SJM2005
$this->encoding = $encoding;
//<< SJM2005
$this->use = $use;
}
 
/**
* convert a string from one UTF-16 char to one UTF-8 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf16 UTF-16 character
* @return string UTF-8 character
* @access private
*/
function utf162utf8($utf16)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding'))
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
 
switch(true) {
case ((0x7F & $bytes) == $bytes):
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x7F & $bytes);
 
case (0x07FF & $bytes) == $bytes:
// return a 2-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xC0 | (($bytes >> 6) & 0x1F))
. chr(0x80 | ($bytes & 0x3F));
 
case (0xFFFF & $bytes) == $bytes:
// return a 3-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xE0 | (($bytes >> 12) & 0x0F))
. chr(0x80 | (($bytes >> 6) & 0x3F))
. chr(0x80 | ($bytes & 0x3F));
}
 
// ignoring UTF-32 for now, sorry
return '';
}
 
/**
* convert a string from one UTF-8 char to one UTF-16 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf8 UTF-8 character
* @return string UTF-16 character
* @access private
*/
function utf82utf16($utf8)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding'))
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
switch(strlen($utf8)) {
case 1:
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return $ut8;
 
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6))
| (0x3F & ord($utf8{1})));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4))
| (0x0F & (ord($utf8{1}) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6))
| (0x7F & ord($utf8{2})));
}
 
// ignoring UTF-32 for now, sorry
return '';
}
 
/**
* encodes an arbitrary variable into JSON format
*
* @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior.
* if var is a strng, note that encode() always expects it
* to be in ASCII or UTF-8 format!
*
* @return string JSON string representation of input var
* @access public
*/
function encode($var)
{
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false';
case 'NULL':
return 'null';
case 'integer':
return (int) $var;
case 'double':
case 'float':
return (float) $var;
case 'string':
//>> SJM2005
if ($this->encoding == SERVICES_JSON_UTF_8)
;
else if ($this->encoding == SERVICES_JSON_ISO_8859_1)
$var = utf8_encode($var);
else if (!function_exists('mb_convert_encoding'))
die('Requested encoding requires mb_strings extension.');
else
$var = mb_convert_encoding($var, "utf-8", $this->encoding);
//<< SJM2005
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
$ascii = '';
$strlen_var = strlen($var);
 
/*
* Iterate over every character in the string,
* escaping with a slash or encoding to UTF-8 where necessary
*/
for ($c = 0; $c < $strlen_var; ++$c) {
$ord_var_c = ord($var{$c});
switch (true) {
case $ord_var_c == 0x08:
$ascii .= '\b';
break;
case $ord_var_c == 0x09:
$ascii .= '\t';
break;
case $ord_var_c == 0x0A:
$ascii .= '\n';
break;
case $ord_var_c == 0x0C:
$ascii .= '\f';
break;
case $ord_var_c == 0x0D:
$ascii .= '\r';
break;
 
case $ord_var_c == 0x22:
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
$ascii .= '\\'.$var{$c};
break;
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
$ascii .= $var{$c};
break;
case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF0) == 0xE0):
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF8) == 0xF0):
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFC) == 0xF8):
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFE) == 0xFC):
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}),
ord($var{$c + 5}));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
}
}
return '"'.$ascii.'"';
case 'array':
/*
* As per JSON spec if any array key is not an integer
* we must treat the the whole array as an object. We
* also try to catch a sparsely populated associative
* array with numeric keys here because some JS engines
* will create an array with empty indexes up to
* max_index which can cause memory issues and because
* the keys, which may be relevant, will be remapped
* otherwise.
*
* As per the ECMA and JSON specification an object may
* have any string as a property. Unfortunately due to
* a hole in the ECMA specification if the key is a
* ECMA reserved word or starts with a digit the
* parameter is only accessible using ECMAScript's
* bracket notation.
*/
// treat as a JSON object
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
return '{' .
join(',', array_map(array($this, 'name_value'),
array_keys($var),
array_values($var)))
. '}';
}
 
// treat it like a regular array
return '[' . join(',', array_map(array($this, 'encode'), $var)) . ']';
case 'object':
$vars = get_object_vars($var);
return '{' .
join(',', array_map(array($this, 'name_value'),
array_keys($vars),
array_values($vars)))
. '}';
 
default:
return '';
}
}
/**
* array-walking function for use in generating JSON-formatted name-value pairs
*
* @param string $name name of key to use
* @param mixed $value reference to an array element to be encoded
*
* @return string JSON-formatted name-value pair, like '"name":value'
* @access private
*/
function name_value($name, $value)
{
return $this->encode(strval($name)) . ':' . $this->encode($value);
}
 
/**
* reduce a string by removing leading and trailing comments and whitespace
*
* @param $str string string value to strip of comments and whitespace
*
* @return string string value stripped of comments and whitespace
* @access private
*/
function reduce_string($str)
{
$str = preg_replace(array(
// eliminate single line comments in '// ...' form
'#^\s*//(.+)$#m',
// eliminate multi-line comments in '/* ... */' form, at start of string
'#^\s*/\*(.+)\*/#Us',
// eliminate multi-line comments in '/* ... */' form, at end of string
'#/\*(.+)\*/\s*$#Us'
), '', $str);
// eliminate extraneous space
return trim($str);
}
 
/**
* decodes a JSON string into appropriate variable
*
* @param string $str JSON-formatted string
*
* @return mixed number, boolean, string, array, or object
* corresponding to given JSON input string.
* See argument 1 to Services_JSON() above for object-output behavior.
* Note that decode() always returns strings
* in ASCII or UTF-8 format!
* @access public
*/
function decode($str)
{
$str = $this->reduce_string($str);
switch (strtolower($str)) {
case 'true':
return true;
 
case 'false':
return false;
case 'null':
return null;
default:
if (is_numeric($str)) {
// Lookie-loo, it's a number
 
// This would work on its own, but I'm trying to be
// good about returning integers where appropriate:
// return (float)$str;
 
// Return float or int, as appropriate
return ((float)$str == (integer)$str)
? (integer)$str
: (float)$str;
} elseif (preg_match('/^("|\').+(\1)$/s', $str, $m) && $m[1] == $m[2]) {
// STRINGS RETURNED IN UTF-8 FORMAT
$delim = substr($str, 0, 1);
$chrs = substr($str, 1, -1);
$utf8 = '';
$strlen_chrs = strlen($chrs);
for ($c = 0; $c < $strlen_chrs; ++$c) {
$substr_chrs_c_2 = substr($chrs, $c, 2);
$ord_chrs_c = ord($chrs{$c});
switch (true) {
case $substr_chrs_c_2 == '\b':
$utf8 .= chr(0x08);
++$c;
break;
case $substr_chrs_c_2 == '\t':
$utf8 .= chr(0x09);
++$c;
break;
case $substr_chrs_c_2 == '\n':
$utf8 .= chr(0x0A);
++$c;
break;
case $substr_chrs_c_2 == '\f':
$utf8 .= chr(0x0C);
++$c;
break;
case $substr_chrs_c_2 == '\r':
$utf8 .= chr(0x0D);
++$c;
break;
 
case $substr_chrs_c_2 == '\\"':
case $substr_chrs_c_2 == '\\\'':
case $substr_chrs_c_2 == '\\\\':
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
$utf8 .= $chrs{++$c};
}
break;
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
//echo ' matching single escaped unicode character from ' . substr($chrs, $c, 6);
// single, escaped unicode character
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
. chr(hexdec(substr($chrs, ($c + 4), 2)));
$utf8 .= $this->utf162utf8($utf16);
$c += 5;
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$c};
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 2);
++$c;
break;
case ($ord_chrs_c & 0xF0) == 0xE0:
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 3);
$c += 2;
break;
case ($ord_chrs_c & 0xF8) == 0xF0:
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 4);
$c += 3;
break;
case ($ord_chrs_c & 0xFC) == 0xF8:
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 5);
$c += 4;
break;
case ($ord_chrs_c & 0xFE) == 0xFC:
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 6);
$c += 5;
break;
 
}
 
}
//>> SJM2005
if ($this->encoding == SERVICES_JSON_UTF_8)
return $utf8;
if ($this->encoding == SERVICES_JSON_ISO_8859_1)
return utf8_decode($utf8);
else if (!function_exists('mb_convert_encoding'))
die('Requested encoding requires mb_strings extension.');
else
return mb_convert_encoding($utf8, $this->encoding, SERVICES_JSON_UTF_8);
//<< SJM2005
return $utf8;
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
if ($str{0} == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
if ($this->use == SERVICES_JSON_LOOSE_TYPE) {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = array();
} else {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = new stdClass();
}
}
array_push($stk, array('what' => SERVICES_JSON_SLICE,
'where' => 0,
'delim' => false));
 
$chrs = substr($str, 1, -1);
$chrs = $this->reduce_string($chrs);
if ($chrs == '') {
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
 
} else {
return $obj;
 
}
}
 
//print("\nparsing {$chrs}\n");
$strlen_chrs = strlen($chrs);
for ($c = 0; $c <= $strlen_chrs; ++$c) {
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
if (reset($stk) == SERVICES_JSON_IN_ARR) {
// we are in an array, so just push an element onto the stack
array_push($arr, $this->decode($slice));
 
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
// we are in an object, so figure
// out the property name and set an
// element in an associative array,
// for now
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// "name":value pair
$key = $this->decode($parts[1]);
$val = $this->decode($parts[2]);
 
if ($this->use == SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// name:value pair, where name is unquoted
$key = $parts[1];
$val = $this->decode($parts[2]);
 
if ($this->use == SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
}
 
}
 
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
//print("Found start of string at {$c}\n");
 
//>> SAO2006
/*} elseif (($chrs{$c} == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
(($chrs{$c - 1} != '\\') ||
($chrs{$c - 1} == '\\' && $chrs{$c - 2} == '\\'))) {*/
} elseif ($chrs{$c} == $top['delim'] &&
$top['what'] == SERVICES_JSON_IN_STR) {
//print("Found potential end of string at {$c}\n");
// verify quote is not escaped: it has no or an even number of \\ before it.
for ($i=0; ($chrs{$c - ($i+1)} == '\\'); $i++);
/*$i = 0;
while ( $chrs{$c - ($i+1)} == '\\')
$i++;*/
//print("Found {$i} \ before delim\n");
if ($i % 2 != 0)
{
//print("delim escaped, not end of string\n");
continue;
}
//>> SAO2006
// found a quote, we're in a string, and it's not escaped
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
 
} elseif (($chrs{$c} == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");
 
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
} elseif (($chrs{$c} == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");
 
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
} elseif (($substr_chrs_c_2 == '/*') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a comment start, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
$c++;
//print("Found start of comment at {$c}\n");
 
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
// found a comment end, and we're in one now
array_pop($stk);
$c++;
for ($i = $top['where']; $i <= $c; ++$i)
$chrs = substr_replace($chrs, ' ', $i, 1);
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
}
}
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
 
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
return $obj;
 
}
}
}
}
}
 
/*function hex($s)
{
$l = strlen($s);
for ($i=0; $i < $l; $i++)
//echo '['.(ord($s{$i})).']';
echo '['.bin2hex($s{$i}).']';
}
//$d = '["hello world\\""]';
$d = '["\\\\\\"hello world,\\\\\\""]';
//$d = '["\\\\", "\\\\"]';
hex($d);
$test = new Services_JSON();
echo('<pre>');
print_r($d . "\n");
print_r($test->decode($d));
echo('</pre>');
*/
?>
/trunk/api/js/dojo1.0/dojox/grid/tests/support/testtbl.sql
New file
0,0 → 1,944
/*
MySQL Data Transfer
Source Host: localhost
Source Database: test
Target Host: localhost
Target Database: test
Date: 12/14/2006 12:13:30 PM
*/
 
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for testtbl
-- ----------------------------
CREATE TABLE `testtbl` (
`Id` int(10) unsigned NOT NULL,
`Name` varchar(45) NOT NULL default '',
`Message` varchar(255) default NULL,
`Date` date default '2005-01-01',
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='InnoDB free: 4096 kB; InnoDB free: 4096 kB; InnoDB free: 409';
 
-- ----------------------------
-- Records
-- ----------------------------
INSERT INTO `testtbl` VALUES ('363', ' Lopez, Felipe', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('364', ' Lopez, Javy', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('365', ' Lopez, L', ' 0.27', '2005-01-01');
INSERT INTO `testtbl` VALUES ('366', ' Lopez, Luis', ' 0.244', '2005-01-01');
INSERT INTO `testtbl` VALUES ('367', ' Lopez, Mendy', ' 0.241', '2005-01-01');
INSERT INTO `testtbl` VALUES ('368', ' Loretta, Mark', ' 0.289', '2005-01-01');
INSERT INTO `testtbl` VALUES ('369', ' Lowell, Mike', ' 0.283', '2005-01-01');
INSERT INTO `testtbl` VALUES ('370', ' Lugo, Julio', ' 0.263', '2005-01-01');
INSERT INTO `testtbl` VALUES ('371', ' Lunar, Fernando', ' 0.246', '2005-01-01');
INSERT INTO `testtbl` VALUES ('372', ' Mabry, John', ' 0.208', '2005-01-01');
INSERT INTO `testtbl` VALUES ('373', ' Machado, Robert', ' 0.222', '2005-01-01');
INSERT INTO `testtbl` VALUES ('374', ' Macias, Jose', ' 0.268', '2005-01-01');
INSERT INTO `testtbl` VALUES ('375', ' Mackowiak, Rob', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('376', ' Magadan, Dave', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('377', ' Magee, Wendell', ' 0.213', '2005-01-01');
INSERT INTO `testtbl` VALUES ('378', ' Magruder, Chris', ' 0.172', '2005-01-01');
INSERT INTO `testtbl` VALUES ('379', ' Marrero, Eli', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('380', ' Martin, Al', ' 0.24', '2005-01-01');
INSERT INTO `testtbl` VALUES ('381', ' Martinez, Dave', ' 0.287', '2005-01-01');
INSERT INTO `testtbl` VALUES ('382', ' Martinez, Edgar', ' 0.306', '2005-01-01');
INSERT INTO `testtbl` VALUES ('383', ' Martinez, Felix', ' 0.247', '2005-01-01');
INSERT INTO `testtbl` VALUES ('384', ' Martinez, Ramon', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('385', ' Martinez, Ramone', ' 0.253', '2005-01-01');
INSERT INTO `testtbl` VALUES ('386', ' Martinez, Sandy', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('387', ' Martinez, Tino', ' 0.28', '2005-01-01');
INSERT INTO `testtbl` VALUES ('388', ' Mateo, Henry', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('389', ' Mateo, Ruben', ' 0.248', '2005-01-01');
INSERT INTO `testtbl` VALUES ('390', ' Matheny, Mike', ' 0.218', '2005-01-01');
INSERT INTO `testtbl` VALUES ('391', ' Matos, Luis', ' 0.214', '2005-01-01');
INSERT INTO `testtbl` VALUES ('392', ' Mattess, Troy', ' 0.467', '2005-01-01');
INSERT INTO `testtbl` VALUES ('393', ' Matthews, Gary', ' 0.227', '2005-01-01');
INSERT INTO `testtbl` VALUES ('394', ' Maurer, Dave', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('395', ' Maxwell, Jason', ' 0.191', '2005-01-01');
INSERT INTO `testtbl` VALUES ('396', ' Mayne, Brent', ' 0.285', '2005-01-01');
INSERT INTO `testtbl` VALUES ('397', ' McCarty, David', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('398', ' McCracken, Quinton', ' 0.219', '2005-01-01');
INSERT INTO `testtbl` VALUES ('399', ' McDonald, Donzell', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('400', ' McDonald, John', ' 0.091', '2005-01-01');
INSERT INTO `testtbl` VALUES ('401', ' McDonald, Keith', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('402', ' McEwing, Joe', ' 0.283', '2005-01-01');
INSERT INTO `testtbl` VALUES ('403', ' McGriff, Fred', ' 0.306', '2005-01-01');
INSERT INTO `testtbl` VALUES ('404', ' McGuire, Ryan', ' 0.185', '2005-01-01');
INSERT INTO `testtbl` VALUES ('405', ' McGwire, Mark', ' 0.187', '2005-01-01');
INSERT INTO `testtbl` VALUES ('406', ' McLemore, Mark', ' 0.286', '2005-01-01');
INSERT INTO `testtbl` VALUES ('407', ' McMillon, Billy', ' 0.217', '2005-01-01');
INSERT INTO `testtbl` VALUES ('408', ' McRae, Scott', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('409', ' Meares, Pat', ' 0.211', '2005-01-01');
INSERT INTO `testtbl` VALUES ('410', ' Melhuse, Adam', ' 0.183', '2005-01-01');
INSERT INTO `testtbl` VALUES ('411', ' Mendez, Donaldo', ' 0.153', '2005-01-01');
INSERT INTO `testtbl` VALUES ('412', ' Menechino, Frank', ' 0.242', '2005-01-01');
INSERT INTO `testtbl` VALUES ('413', ' Merced, Orlando', ' 0.263', '2005-01-01');
INSERT INTO `testtbl` VALUES ('414', ' Merloni, Lou', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('415', ' Meyers, Chad', ' 0.118', '2005-01-01');
INSERT INTO `testtbl` VALUES ('416', ' Michaels, Jason', ' 0.167', '2005-01-01');
INSERT INTO `testtbl` VALUES ('417', ' Mientkiewicz, Doug', ' 0.306', '2005-01-01');
INSERT INTO `testtbl` VALUES ('418', ' Millar, Kevin', ' 0.314', '2005-01-01');
INSERT INTO `testtbl` VALUES ('419', ' Miller, Corky', ' 0.184', '2005-01-01');
INSERT INTO `testtbl` VALUES ('420', ' Miller, Damian', ' 0.271', '2005-01-01');
INSERT INTO `testtbl` VALUES ('421', ' Minor, Damion', ' 0.156', '2005-01-01');
INSERT INTO `testtbl` VALUES ('422', ' Minor, Ryan', ' 0.158', '2005-01-01');
INSERT INTO `testtbl` VALUES ('423', ' Mirabelli, Doug', ' 0.226', '2005-01-01');
INSERT INTO `testtbl` VALUES ('424', ' Moeller, Chad', ' 0.232', '2005-01-01');
INSERT INTO `testtbl` VALUES ('425', ' Mohr, Dustan', ' 0.235', '2005-01-01');
INSERT INTO `testtbl` VALUES ('426', ' Molina, Ben', ' 0.262', '2005-01-01');
INSERT INTO `testtbl` VALUES ('427', ' Molina, Jose', ' 0.27', '2005-01-01');
INSERT INTO `testtbl` VALUES ('428', ' Mondesi, Raul', ' 0.252', '2005-01-01');
INSERT INTO `testtbl` VALUES ('429', ' Monroe, Craig', ' 0.212', '2005-01-01');
INSERT INTO `testtbl` VALUES ('430', ' Mora, Melvin', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('431', ' Mordecai, Mike', ' 0.28', '2005-01-01');
INSERT INTO `testtbl` VALUES ('432', ' Morris, Warren', ' 0.204', '2005-01-01');
INSERT INTO `testtbl` VALUES ('433', ' Mottola, Chad', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('434', ' Mouton, James', ' 0.246', '2005-01-01');
INSERT INTO `testtbl` VALUES ('435', ' Mouton, Lyle', ' 0.059', '2005-01-01');
INSERT INTO `testtbl` VALUES ('436', ' Mueller, Bill', ' 0.295', '2005-01-01');
INSERT INTO `testtbl` VALUES ('437', ' Munson, Eric', ' 0.152', '2005-01-01');
INSERT INTO `testtbl` VALUES ('438', ' Murray, Calvin', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('439', ' Myers, Greg', ' 0.224', '2005-01-01');
INSERT INTO `testtbl` VALUES ('440', ' Nevin, Phil', ' 0.306', '2005-01-01');
INSERT INTO `testtbl` VALUES ('441', ' Newhan, David', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('442', ' Nieves, Jose', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('443', ' Nixon, Trot', ' 0.28', '2005-01-01');
INSERT INTO `testtbl` VALUES ('444', ' Norton, Greg', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('445', ' Nunez, Abraham', ' 0.262', '2005-01-01');
INSERT INTO `testtbl` VALUES ('446', ' Ochoa, Alex', ' 0.276', '2005-01-01');
INSERT INTO `testtbl` VALUES ('447', ' Offerman, Jose', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('448', ' Ojeda, Augie', ' 0.201', '2005-01-01');
INSERT INTO `testtbl` VALUES ('449', ' O\\\'Leary, Troy', ' 0.24', '2005-01-01');
INSERT INTO `testtbl` VALUES ('450', ' Olerud, John', ' 0.302', '2005-01-01');
INSERT INTO `testtbl` VALUES ('451', ' Oliver, Joe', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('452', ' O\\\'Neill, Paul', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('453', ' Ordaz, Luis', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('454', ' Ordonez, Magglio', ' 0.305', '2005-01-01');
INSERT INTO `testtbl` VALUES ('455', ' Ordonez, Rey', ' 0.247', '2005-01-01');
INSERT INTO `testtbl` VALUES ('456', ' Ortega, Bill', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('457', ' Ortiz, David', ' 0.234', '2005-01-01');
INSERT INTO `testtbl` VALUES ('458', ' Ortiz, Hector', ' 0.247', '2005-01-01');
INSERT INTO `testtbl` VALUES ('459', ' Ortiz, Jose', ' 0.24', '2005-01-01');
INSERT INTO `testtbl` VALUES ('460', ' Osik, Keith', ' 0.208', '2005-01-01');
INSERT INTO `testtbl` VALUES ('461', ' Overbay, Lyle', ' 0.5', '2005-01-01');
INSERT INTO `testtbl` VALUES ('462', ' Owens, Eric', ' 0.253', '2005-01-01');
INSERT INTO `testtbl` VALUES ('463', ' Palmeiro, Orlando', ' 0.243', '2005-01-01');
INSERT INTO `testtbl` VALUES ('464', ' Palmeiro, Rafael', ' 0.273', '2005-01-01');
INSERT INTO `testtbl` VALUES ('465', ' Palmer, Dean', ' 0.222', '2005-01-01');
INSERT INTO `testtbl` VALUES ('466', ' Paquette, Craig', ' 0.282', '2005-01-01');
INSERT INTO `testtbl` VALUES ('467', ' Patterson, Corey', ' 0.221', '2005-01-01');
INSERT INTO `testtbl` VALUES ('468', ' Patterson, Jarrod', ' 0.268', '2005-01-01');
INSERT INTO `testtbl` VALUES ('469', ' Paul, Josh', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('470', ' Payton, Jay', ' 0.255', '2005-01-01');
INSERT INTO `testtbl` VALUES ('471', ' Pena, Angel', ' 0.204', '2005-01-01');
INSERT INTO `testtbl` VALUES ('472', ' Pena, Carlos', ' 0.258', '2005-01-01');
INSERT INTO `testtbl` VALUES ('473', ' Pena, Elvis', ' 0.225', '2005-01-01');
INSERT INTO `testtbl` VALUES ('474', ' Perez, Eddie', ' 0.3', '2005-01-01');
INSERT INTO `testtbl` VALUES ('475', ' Perez, Neifi', ' 0.279', '2005-01-01');
INSERT INTO `testtbl` VALUES ('476', ' Perez, Robert', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('477', ' Perez, Santiago', ' 0.198', '2005-01-01');
INSERT INTO `testtbl` VALUES ('478', ' Perez, Thomas', ' 0.304', '2005-01-01');
INSERT INTO `testtbl` VALUES ('479', ' Perez, Timoniel', ' 0.247', '2005-01-01');
INSERT INTO `testtbl` VALUES ('480', ' Perry, Herbert', ' 0.256', '2005-01-01');
INSERT INTO `testtbl` VALUES ('481', ' Peters, Chris', ' 0.091', '2005-01-01');
INSERT INTO `testtbl` VALUES ('482', ' Petrick, Ben', ' 0.238', '2005-01-01');
INSERT INTO `testtbl` VALUES ('483', ' Phelps, Josh', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('484', ' Phillips, Jason', ' 0.143', '2005-01-01');
INSERT INTO `testtbl` VALUES ('485', ' Piatt, Adam', ' 0.211', '2005-01-01');
INSERT INTO `testtbl` VALUES ('486', ' Piazza, Mike', ' 0.3', '2005-01-01');
INSERT INTO `testtbl` VALUES ('487', ' Pickering, Calvin', ' 0.278', '2005-01-01');
INSERT INTO `testtbl` VALUES ('488', ' Pierre, Juan', ' 0.327', '2005-01-01');
INSERT INTO `testtbl` VALUES ('489', ' Pierzynski, A.J.', ' 0.289', '2005-01-01');
INSERT INTO `testtbl` VALUES ('490', ' Podsednik, Scott', ' 0.167', '2005-01-01');
INSERT INTO `testtbl` VALUES ('491', ' Polanco, Placido', ' 0.307', '2005-01-01');
INSERT INTO `testtbl` VALUES ('492', ' Porter, Bo', ' 0.23', '2005-01-01');
INSERT INTO `testtbl` VALUES ('493', ' Posada, Jorge', ' 0.277', '2005-01-01');
INSERT INTO `testtbl` VALUES ('494', ' Powell, Dante', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('495', ' Pratt, Todd', ' 0.185', '2005-01-01');
INSERT INTO `testtbl` VALUES ('496', ' Pride, Curtis', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('497', ' Prince, Tom', ' 0.219', '2005-01-01');
INSERT INTO `testtbl` VALUES ('498', ' Pujols, Albert', ' 0.329', '2005-01-01');
INSERT INTO `testtbl` VALUES ('499', ' Punto, Nick', ' 0.4', '2005-01-01');
INSERT INTO `testtbl` VALUES ('500', ' Quevado, Ruben', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('501', ' Quinn, Mark', ' 0.269', '2005-01-01');
INSERT INTO `testtbl` VALUES ('502', ' Raines, Tim', ' 0.174', '2005-01-01');
INSERT INTO `testtbl` VALUES ('503', ' Raines, Tim', ' 0.303', '2005-01-01');
INSERT INTO `testtbl` VALUES ('504', ' Ramirez, Aramis', ' 0.3', '2005-01-01');
INSERT INTO `testtbl` VALUES ('505', ' Ramirez, Julio', ' 0.081', '2005-01-01');
INSERT INTO `testtbl` VALUES ('506', ' Ramirez, Manny', ' 0.306', '2005-01-01');
INSERT INTO `testtbl` VALUES ('507', ' Randa, Joe', ' 0.253', '2005-01-01');
INSERT INTO `testtbl` VALUES ('508', ' Ransom, Cody', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('509', ' Reboulet, Jeff', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('510', ' Redman, Tim', ' 0.224', '2005-01-01');
INSERT INTO `testtbl` VALUES ('511', ' Redmond, Mike', ' 0.312', '2005-01-01');
INSERT INTO `testtbl` VALUES ('512', ' Reese, Pokey', ' 0.224', '2005-01-01');
INSERT INTO `testtbl` VALUES ('513', ' Relaford, Desi', ' 0.302', '2005-01-01');
INSERT INTO `testtbl` VALUES ('514', ' Renteria, Edgar', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('515', ' Richard, Chris', ' 0.265', '2005-01-01');
INSERT INTO `testtbl` VALUES ('516', ' Riggs, Adam', ' 0.194', '2005-01-01');
INSERT INTO `testtbl` VALUES ('517', ' Rios, Armando', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('518', ' Ripken, Cal', ' 0.239', '2005-01-01');
INSERT INTO `testtbl` VALUES ('519', ' Rivas, Luis', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('520', ' Rivera, Juan', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('521', ' Rivera, Mike', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('522', ' Rivera, Ruben', ' 0.255', '2005-01-01');
INSERT INTO `testtbl` VALUES ('523', ' Roberts, Brian', ' 0.253', '2005-01-01');
INSERT INTO `testtbl` VALUES ('524', ' Roberts, Dave', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('525', ' Robinson, Kerry', ' 0.285', '2005-01-01');
INSERT INTO `testtbl` VALUES ('526', ' Rodriguez, Alex', ' 0.318', '2005-01-01');
INSERT INTO `testtbl` VALUES ('527', ' Rodriguez, Henry', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('528', ' Rodriguez, Ivan', ' 0.308', '2005-01-01');
INSERT INTO `testtbl` VALUES ('529', ' Rolen, Scott', ' 0.289', '2005-01-01');
INSERT INTO `testtbl` VALUES ('530', ' Rollins, Jimmy', ' 0.274', '2005-01-01');
INSERT INTO `testtbl` VALUES ('531', ' Rolls, Damian', ' 0.262', '2005-01-01');
INSERT INTO `testtbl` VALUES ('532', ' Rowand, Aaron', ' 0.293', '2005-01-01');
INSERT INTO `testtbl` VALUES ('533', ' Ruffin, Johnny', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('534', ' Ryan, Rob', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('535', ' Sadler, Donnie', ' 0.162', '2005-01-01');
INSERT INTO `testtbl` VALUES ('536', ' Saenz, Olmedo', ' 0.22', '2005-01-01');
INSERT INTO `testtbl` VALUES ('537', ' Salmon, Tim', ' 0.227', '2005-01-01');
INSERT INTO `testtbl` VALUES ('538', ' Sanchez, Alex', ' 0.206', '2005-01-01');
INSERT INTO `testtbl` VALUES ('539', ' Sanchez, Rey', ' 0.281', '2005-01-01');
INSERT INTO `testtbl` VALUES ('540', ' Sandberg, Jared', ' 0.206', '2005-01-01');
INSERT INTO `testtbl` VALUES ('541', ' Sanders, Anthony', ' 0.176', '2005-01-01');
INSERT INTO `testtbl` VALUES ('542', ' Sanders, Deion', ' 0.173', '2005-01-01');
INSERT INTO `testtbl` VALUES ('543', ' Sanders, Reggie', ' 0.263', '2005-01-01');
INSERT INTO `testtbl` VALUES ('544', ' Santana, Pedro', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('545', ' Santangelo, F.P.', ' 0.197', '2005-01-01');
INSERT INTO `testtbl` VALUES ('546', ' Santiago, Benito', ' 0.262', '2005-01-01');
INSERT INTO `testtbl` VALUES ('547', ' Santos, Angel', ' 0.125', '2005-01-01');
INSERT INTO `testtbl` VALUES ('548', ' Saturria, Luis', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('549', ' Schneider, Brian', ' 0.317', '2005-01-01');
INSERT INTO `testtbl` VALUES ('550', ' Schourek, Pete', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('551', ' Seabol, Scott', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('552', ' Sefcik, Kevin', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('553', ' Segui, David', ' 0.301', '2005-01-01');
INSERT INTO `testtbl` VALUES ('554', ' Seguignol, Fernando', ' 0.14', '2005-01-01');
INSERT INTO `testtbl` VALUES ('555', ' Selby, Bill', ' 0.228', '2005-01-01');
INSERT INTO `testtbl` VALUES ('556', ' Servais, Scott', ' 0.375', '2005-01-01');
INSERT INTO `testtbl` VALUES ('557', ' Sexson, Richie', ' 0.271', '2005-01-01');
INSERT INTO `testtbl` VALUES ('558', ' Sheets, Andy', ' 0.196', '2005-01-01');
INSERT INTO `testtbl` VALUES ('559', ' Sheffield, Gary', ' 0.311', '2005-01-01');
INSERT INTO `testtbl` VALUES ('560', ' Sheldon, Scott', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('561', ' Shinjo, Tsuyoshi', ' 0.268', '2005-01-01');
INSERT INTO `testtbl` VALUES ('562', ' Shumpert, Terry', ' 0.289', '2005-01-01');
INSERT INTO `testtbl` VALUES ('563', ' Sierra, Ruben', ' 0.291', '2005-01-01');
INSERT INTO `testtbl` VALUES ('564', ' Simmons, Brian', ' 0.178', '2005-01-01');
INSERT INTO `testtbl` VALUES ('565', ' Simon, Randall', ' 0.305', '2005-01-01');
INSERT INTO `testtbl` VALUES ('566', ' Singleton, Chris', ' 0.298', '2005-01-01');
INSERT INTO `testtbl` VALUES ('567', ' Smith, Bobby', ' 0.105', '2005-01-01');
INSERT INTO `testtbl` VALUES ('568', ' Smith, Jason', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('569', ' Smith, Mark', ' 0.242', '2005-01-01');
INSERT INTO `testtbl` VALUES ('570', ' Snow, J.T.', ' 0.246', '2005-01-01');
INSERT INTO `testtbl` VALUES ('571', ' Sojo, Luis', ' 0.165', '2005-01-01');
INSERT INTO `testtbl` VALUES ('572', ' Soriano, Alfonso', ' 0.268', '2005-01-01');
INSERT INTO `testtbl` VALUES ('573', ' Sosa, Juan', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('574', ' Sosa, Sammy', ' 0.328', '2005-01-01');
INSERT INTO `testtbl` VALUES ('575', ' Spencer, Shane', ' 0.258', '2005-01-01');
INSERT INTO `testtbl` VALUES ('576', ' Spiers, Bill', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('577', ' Spiezio, Scott', ' 0.271', '2005-01-01');
INSERT INTO `testtbl` VALUES ('578', ' Spivey, Junior', ' 0.258', '2005-01-01');
INSERT INTO `testtbl` VALUES ('579', ' Sprague, Ed', ' 0.298', '2005-01-01');
INSERT INTO `testtbl` VALUES ('580', ' Stairs, Matt', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('581', ' Stevens, Lee', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('582', ' Stewart, Shannon', ' 0.316', '2005-01-01');
INSERT INTO `testtbl` VALUES ('583', ' Stinnett, Kelly', ' 0.257', '2005-01-01');
INSERT INTO `testtbl` VALUES ('584', ' Stynes, Chris', ' 0.28', '2005-01-01');
INSERT INTO `testtbl` VALUES ('585', ' Surhoff, B.J.', ' 0.271', '2005-01-01');
INSERT INTO `testtbl` VALUES ('586', ' Sutton, Larry', ' 0.119', '2005-01-01');
INSERT INTO `testtbl` VALUES ('587', ' Suzuki, Ichiro', ' 0.35', '2005-01-01');
INSERT INTO `testtbl` VALUES ('588', ' Sweeney, Mark', ' 0.258', '2005-01-01');
INSERT INTO `testtbl` VALUES ('589', ' Sweeney, Mike', ' 0.304', '2005-01-01');
INSERT INTO `testtbl` VALUES ('590', ' Tapani, Kevin', ' 0.24', '2005-01-01');
INSERT INTO `testtbl` VALUES ('591', ' Tatis, Fernando', ' 0.255', '2005-01-01');
INSERT INTO `testtbl` VALUES ('592', ' Taubensee, Eddie', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('593', ' Taylor, Reggie', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('594', ' Tejada, Miguel', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('595', ' Thomas, Frank', ' 0.221', '2005-01-01');
INSERT INTO `testtbl` VALUES ('596', ' Thome, Jim', ' 0.291', '2005-01-01');
INSERT INTO `testtbl` VALUES ('597', ' Thompson, Ryan', ' 0.29', '2005-01-01');
INSERT INTO `testtbl` VALUES ('598', ' Toca, Jorge', ' 0.176', '2005-01-01');
INSERT INTO `testtbl` VALUES ('599', ' Torrealba, Steve', ' 0.5', '2005-01-01');
INSERT INTO `testtbl` VALUES ('600', ' Torrealba, Yorvit', ' 0.5', '2005-01-01');
INSERT INTO `testtbl` VALUES ('601', ' Tracy, Andy', ' 0.109', '2005-01-01');
INSERT INTO `testtbl` VALUES ('602', ' Trammell, Bubba', ' 0.261', '2005-01-01');
INSERT INTO `testtbl` VALUES ('603', ' Truby, Chris', ' 0.206', '2005-01-01');
INSERT INTO `testtbl` VALUES ('604', ' Tucker, Michael', ' 0.252', '2005-01-01');
INSERT INTO `testtbl` VALUES ('605', ' Tyner, Jason', ' 0.28', '2005-01-01');
INSERT INTO `testtbl` VALUES ('606', ' Uribe, Juan', ' 0.3', '2005-01-01');
INSERT INTO `testtbl` VALUES ('607', ' Valdez, Mario', ' 0.278', '2005-01-01');
INSERT INTO `testtbl` VALUES ('608', ' Valent, Eric', ' 0.098', '2005-01-01');
INSERT INTO `testtbl` VALUES ('609', ' Valentin, John', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('610', ' Valentin, Jose', ' 0.258', '2005-01-01');
INSERT INTO `testtbl` VALUES ('611', ' VanderWal, John', ' 0.27', '2005-01-01');
INSERT INTO `testtbl` VALUES ('612', ' Varitek, Jason', ' 0.293', '2005-01-01');
INSERT INTO `testtbl` VALUES ('613', ' Vaughn, Greg', ' 0.233', '2005-01-01');
INSERT INTO `testtbl` VALUES ('614', ' Vazquez, Ramon', ' 0.229', '2005-01-01');
INSERT INTO `testtbl` VALUES ('615', ' Velandia, Jorge', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('616', ' Velarde, Randy', ' 0.278', '2005-01-01');
INSERT INTO `testtbl` VALUES ('617', ' Ventura, Robin', ' 0.237', '2005-01-01');
INSERT INTO `testtbl` VALUES ('618', ' Veras, Quilvio', ' 0.252', '2005-01-01');
INSERT INTO `testtbl` VALUES ('619', ' Vidro, Jose', ' 0.319', '2005-01-01');
INSERT INTO `testtbl` VALUES ('620', ' Vina, Fernando', ' 0.303', '2005-01-01');
INSERT INTO `testtbl` VALUES ('621', ' Vizcaino, Jose', ' 0.277', '2005-01-01');
INSERT INTO `testtbl` VALUES ('622', ' Vizquel, Omar', ' 0.255', '2005-01-01');
INSERT INTO `testtbl` VALUES ('623', ' Wakeland, Chris', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('624', ' Walbeck, Matt', ' 1', '2005-01-01');
INSERT INTO `testtbl` VALUES ('625', ' Walker, Larry', ' 0.35', '2005-01-01');
INSERT INTO `testtbl` VALUES ('626', ' Walker, Todd', ' 0.296', '2005-01-01');
INSERT INTO `testtbl` VALUES ('627', ' Ward, Daryle', ' 0.263', '2005-01-01');
INSERT INTO `testtbl` VALUES ('628', ' Ward, Turner', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('629', ' Wehner, John', ' 0.196', '2005-01-01');
INSERT INTO `testtbl` VALUES ('630', ' Wells, Vernon', ' 0.313', '2005-01-01');
INSERT INTO `testtbl` VALUES ('631', ' White, Devon', ' 0.277', '2005-01-01');
INSERT INTO `testtbl` VALUES ('632', ' White, Rondell', ' 0.307', '2005-01-01');
INSERT INTO `testtbl` VALUES ('633', ' Whiteside, Matt', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('634', ' Wilkerson, Brad', ' 0.205', '2005-01-01');
INSERT INTO `testtbl` VALUES ('635', ' Wilkins, Rick', ' 0.182', '2005-01-01');
INSERT INTO `testtbl` VALUES ('636', ' Williams, Bernie', ' 0.307', '2005-01-01');
INSERT INTO `testtbl` VALUES ('637', ' Williams, Gerald', ' 0.201', '2005-01-01');
INSERT INTO `testtbl` VALUES ('638', ' Williams, Matt', ' 0.275', '2005-01-01');
INSERT INTO `testtbl` VALUES ('639', ' Wilson, Craig', ' 0.31', '2005-01-01');
INSERT INTO `testtbl` VALUES ('640', ' Wilson, Dan', ' 0.265', '2005-01-01');
INSERT INTO `testtbl` VALUES ('641', ' Wilson, Enrique', ' 0.211', '2005-01-01');
INSERT INTO `testtbl` VALUES ('642', ' Wilson, Jack', ' 0.223', '2005-01-01');
INSERT INTO `testtbl` VALUES ('643', ' Wilson, Preston', ' 0.274', '2005-01-01');
INSERT INTO `testtbl` VALUES ('644', ' Wilson, Tom', ' 0.19', '2005-01-01');
INSERT INTO `testtbl` VALUES ('645', ' Wilson, Vance', ' 0.298', '2005-01-01');
INSERT INTO `testtbl` VALUES ('646', ' Winn, Randy', ' 0.273', '2005-01-01');
INSERT INTO `testtbl` VALUES ('647', ' Witt, Kevin', ' 0.185', '2005-01-01');
INSERT INTO `testtbl` VALUES ('648', ' Womack, Tony', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('649', ' Woodward, Chris', ' 0.19', '2005-01-01');
INSERT INTO `testtbl` VALUES ('650', ' Wooten, Shawn', ' 0.312', '2005-01-01');
INSERT INTO `testtbl` VALUES ('651', ' Young, Dmitri', ' 0.302', '2005-01-01');
INSERT INTO `testtbl` VALUES ('652', ' Young, Eric', ' 0.279', '2005-01-01');
INSERT INTO `testtbl` VALUES ('653', ' Young, Kevin', ' 0.232', '2005-01-01');
INSERT INTO `testtbl` VALUES ('654', ' Young, Mike', ' 0.249', '2005-01-01');
INSERT INTO `testtbl` VALUES ('655', ' Zaun, Greg', ' 0.32', '2005-01-01');
INSERT INTO `testtbl` VALUES ('656', ' Zeile, Todd', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('657', ' Zuleta, Julio', ' 0.217', '2005-01-01');
INSERT INTO `testtbl` VALUES ('658', ' Abernathy, Brent', ' 0.242', '2005-01-01');
INSERT INTO `testtbl` VALUES ('659', ' Abreu, Bob', ' 0.308', '2005-01-01');
INSERT INTO `testtbl` VALUES ('660', ' Agbayani, Benny', ' 0.227', '2005-01-01');
INSERT INTO `testtbl` VALUES ('661', ' Alcantara, Israel', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('662', ' Aldridge, Cory', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('663', ' Alfonzo, Edgardo', ' 0.308', '2005-01-01');
INSERT INTO `testtbl` VALUES ('664', ' Alicea, Luis', ' 0.228', '2005-01-01');
INSERT INTO `testtbl` VALUES ('665', ' Allen, Chad', ' 0.1', '2005-01-01');
INSERT INTO `testtbl` VALUES ('666', ' Allen, Luke', ' 0.143', '2005-01-01');
INSERT INTO `testtbl` VALUES ('667', ' Alomar, Roberto', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('668', ' Alomar, Sandy', ' 0.279', '2005-01-01');
INSERT INTO `testtbl` VALUES ('669', ' Alou, Moises', ' 0.275', '2005-01-01');
INSERT INTO `testtbl` VALUES ('670', ' Alvarez, Tony', ' 0.308', '2005-01-01');
INSERT INTO `testtbl` VALUES ('671', ' Amezaga, Alfredo', ' 0.538', '2005-01-01');
INSERT INTO `testtbl` VALUES ('672', ' Anderson, Brady', ' 0.163', '2005-01-01');
INSERT INTO `testtbl` VALUES ('673', ' Anderson, Garret', ' 0.306', '2005-01-01');
INSERT INTO `testtbl` VALUES ('674', ' Anderson, Marlon', ' 0.258', '2005-01-01');
INSERT INTO `testtbl` VALUES ('675', ' Andrews, Shane', ' 0.077', '2005-01-01');
INSERT INTO `testtbl` VALUES ('676', ' Arias, Alex', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('677', ' Aurilia, Rich', ' 0.257', '2005-01-01');
INSERT INTO `testtbl` VALUES ('678', ' Ausmus, Brad', ' 0.257', '2005-01-01');
INSERT INTO `testtbl` VALUES ('679', ' Aven, Bruce', ' 0.118', '2005-01-01');
INSERT INTO `testtbl` VALUES ('680', ' Baerga, Carlos', ' 0.286', '2005-01-01');
INSERT INTO `testtbl` VALUES ('681', ' Bagwell, Jeff', ' 0.291', '2005-01-01');
INSERT INTO `testtbl` VALUES ('682', ' Bako, Paul', ' 0.235', '2005-01-01');
INSERT INTO `testtbl` VALUES ('683', ' Banks, Brian', ' 0.321', '2005-01-01');
INSERT INTO `testtbl` VALUES ('684', ' Barajas, Rod', ' 0.234', '2005-01-01');
INSERT INTO `testtbl` VALUES ('685', ' Bard, Josh', ' 0.222', '2005-01-01');
INSERT INTO `testtbl` VALUES ('686', ' Barker, Kevin', ' 0.158', '2005-01-01');
INSERT INTO `testtbl` VALUES ('687', ' Barrett, Michael', ' 0.263', '2005-01-01');
INSERT INTO `testtbl` VALUES ('688', ' Batista, Tony', ' 0.244', '2005-01-01');
INSERT INTO `testtbl` VALUES ('689', ' Bautista, Danny', ' 0.325', '2005-01-01');
INSERT INTO `testtbl` VALUES ('690', ' Bell, David', ' 0.261', '2005-01-01');
INSERT INTO `testtbl` VALUES ('691', ' Bell, Jay', ' 0.163', '2005-01-01');
INSERT INTO `testtbl` VALUES ('692', ' Belle, Albert', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('693', ' Bellhorn, Mark', ' 0.258', '2005-01-01');
INSERT INTO `testtbl` VALUES ('694', ' Belliard, Ron', ' 0.211', '2005-01-01');
INSERT INTO `testtbl` VALUES ('695', ' Bellinger, Clay', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('696', ' Beltran, Carlos', ' 0.273', '2005-01-01');
INSERT INTO `testtbl` VALUES ('697', ' Beltre, Adrian', ' 0.257', '2005-01-01');
INSERT INTO `testtbl` VALUES ('698', ' Benard, Marvin', ' 0.276', '2005-01-01');
INSERT INTO `testtbl` VALUES ('699', ' Benjamin, Mike', ' 0.15', '2005-01-01');
INSERT INTO `testtbl` VALUES ('700', ' Bennett, Gary', ' 0.265', '2005-01-01');
INSERT INTO `testtbl` VALUES ('701', ' Berg, David', ' 0.27', '2005-01-01');
INSERT INTO `testtbl` VALUES ('702', ' Berger, Brandon', ' 0.201', '2005-01-01');
INSERT INTO `testtbl` VALUES ('703', ' Bergeron, Peter', ' 0.187', '2005-01-01');
INSERT INTO `testtbl` VALUES ('704', ' Berkman, Lance', ' 0.292', '2005-01-01');
INSERT INTO `testtbl` VALUES ('705', ' Berroa, Angel', ' 0.227', '2005-01-01');
INSERT INTO `testtbl` VALUES ('706', ' Bigbie, Larry', ' 0.176', '2005-01-01');
INSERT INTO `testtbl` VALUES ('707', ' Biggio, Craig', ' 0.253', '2005-01-01');
INSERT INTO `testtbl` VALUES ('708', ' Blake, Casey', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('709', ' Blalock, Hank', ' 0.211', '2005-01-01');
INSERT INTO `testtbl` VALUES ('710', ' Blanco, Henry', ' 0.204', '2005-01-01');
INSERT INTO `testtbl` VALUES ('711', ' Bloomquist, Willie', ' 0.455', '2005-01-01');
INSERT INTO `testtbl` VALUES ('712', ' Blum, Geoff', ' 0.283', '2005-01-01');
INSERT INTO `testtbl` VALUES ('713', ' Bocachica, Hiram', ' 0.22', '2005-01-01');
INSERT INTO `testtbl` VALUES ('714', ' Bonds, Barry', ' 0.37', '2005-01-01');
INSERT INTO `testtbl` VALUES ('715', ' Boone, Aaron', ' 0.241', '2005-01-01');
INSERT INTO `testtbl` VALUES ('716', ' Boone, Bret', ' 0.278', '2005-01-01');
INSERT INTO `testtbl` VALUES ('717', ' Borchard, Joe', ' 0.222', '2005-01-01');
INSERT INTO `testtbl` VALUES ('718', ' Borders, Pat', ' 0.5', '2005-01-01');
INSERT INTO `testtbl` VALUES ('719', ' Bordick, Mike', ' 0.232', '2005-01-01');
INSERT INTO `testtbl` VALUES ('720', ' Bradley, Milton', ' 0.249', '2005-01-01');
INSERT INTO `testtbl` VALUES ('721', ' Bragg, Darren', ' 0.269', '2005-01-01');
INSERT INTO `testtbl` VALUES ('722', ' Branyan, Russell', ' 0.228', '2005-01-01');
INSERT INTO `testtbl` VALUES ('723', ' Brito, Juan', ' 0.304', '2005-01-01');
INSERT INTO `testtbl` VALUES ('724', ' Broussard, Ben', ' 0.241', '2005-01-01');
INSERT INTO `testtbl` VALUES ('725', ' Brown, Adrian', ' 0.216', '2005-01-01');
INSERT INTO `testtbl` VALUES ('726', ' Brown, Dermal', ' 0.235', '2005-01-01');
INSERT INTO `testtbl` VALUES ('727', ' Brown, Kevin', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('728', ' Brown, Roosevelt', ' 0.211', '2005-01-01');
INSERT INTO `testtbl` VALUES ('729', ' Buchanan, Brian', ' 0.269', '2005-01-01');
INSERT INTO `testtbl` VALUES ('730', ' Burks, Ellis', ' 0.301', '2005-01-01');
INSERT INTO `testtbl` VALUES ('731', ' Burnitz, Jeromy', ' 0.215', '2005-01-01');
INSERT INTO `testtbl` VALUES ('732', ' Burrell, Pat', ' 0.282', '2005-01-01');
INSERT INTO `testtbl` VALUES ('733', ' Burroughs, Sean', ' 0.271', '2005-01-01');
INSERT INTO `testtbl` VALUES ('734', ' Bush, Homer', ' 0.227', '2005-01-01');
INSERT INTO `testtbl` VALUES ('735', ' Butler, Brent', ' 0.259', '2005-01-01');
INSERT INTO `testtbl` VALUES ('736', ' Byrd, Marlon', ' 0.229', '2005-01-01');
INSERT INTO `testtbl` VALUES ('737', ' Byrnes, Eric', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('738', ' Cabrera, Jolbert', ' 0.143', '2005-01-01');
INSERT INTO `testtbl` VALUES ('739', ' Cabrera, Orlando', ' 0.263', '2005-01-01');
INSERT INTO `testtbl` VALUES ('740', ' Cairo, Miguel', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('741', ' Cameron, Mike', ' 0.239', '2005-01-01');
INSERT INTO `testtbl` VALUES ('742', ' Canizaro, Jay', ' 0.214', '2005-01-01');
INSERT INTO `testtbl` VALUES ('743', ' Cardona, Javier', ' 0.103', '2005-01-01');
INSERT INTO `testtbl` VALUES ('744', ' Carroll, Jamey', ' 0.31', '2005-01-01');
INSERT INTO `testtbl` VALUES ('745', ' Caruso, Mike', ' 0.1', '2005-01-01');
INSERT INTO `testtbl` VALUES ('746', ' Casanova, Raul', ' 0.182', '2005-01-01');
INSERT INTO `testtbl` VALUES ('747', ' Casey, Sean', ' 0.261', '2005-01-01');
INSERT INTO `testtbl` VALUES ('748', ' Cash, Kevin', ' 0.143', '2005-01-01');
INSERT INTO `testtbl` VALUES ('749', ' Castilla, Vinny', ' 0.232', '2005-01-01');
INSERT INTO `testtbl` VALUES ('750', ' Castillo, Alberto', ' 0.135', '2005-01-01');
INSERT INTO `testtbl` VALUES ('751', ' Castillo, Luis', ' 0.305', '2005-01-01');
INSERT INTO `testtbl` VALUES ('752', ' Castro, Juan', ' 0.22', '2005-01-01');
INSERT INTO `testtbl` VALUES ('753', ' Castro, Ramon', ' 0.238', '2005-01-01');
INSERT INTO `testtbl` VALUES ('754', ' Catalanotto, Frank', ' 0.269', '2005-01-01');
INSERT INTO `testtbl` VALUES ('755', ' Cedeno, Roger', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('756', ' Cepicky, Matt', ' 0.216', '2005-01-01');
INSERT INTO `testtbl` VALUES ('757', ' Chavez, Endy', ' 0.296', '2005-01-01');
INSERT INTO `testtbl` VALUES ('758', ' Chavez, Eric', ' 0.275', '2005-01-01');
INSERT INTO `testtbl` VALUES ('759', ' Chavez, Raul', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('760', ' Chen, Chin-Feng', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('761', ' Choi, Hee Seop', ' 0.18', '2005-01-01');
INSERT INTO `testtbl` VALUES ('762', ' Christensen, McKay', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('763', ' Christenson, Ryan', ' 0.155', '2005-01-01');
INSERT INTO `testtbl` VALUES ('764', ' Cintron, Alex', ' 0.213', '2005-01-01');
INSERT INTO `testtbl` VALUES ('765', ' Cirillo, Jeff', ' 0.249', '2005-01-01');
INSERT INTO `testtbl` VALUES ('766', ' Clark, Brady', ' 0.192', '2005-01-01');
INSERT INTO `testtbl` VALUES ('767', ' Clark, Howie', ' 0.302', '2005-01-01');
INSERT INTO `testtbl` VALUES ('768', ' Clark, Tony', ' 0.207', '2005-01-01');
INSERT INTO `testtbl` VALUES ('769', ' Clayton, Royce', ' 0.251', '2005-01-01');
INSERT INTO `testtbl` VALUES ('770', ' Colangelo, Mike', ' 0.174', '2005-01-01');
INSERT INTO `testtbl` VALUES ('771', ' Colbrunn, Greg', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('772', ' Coleman, Michael', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('773', ' Collier, Lou', ' 0.091', '2005-01-01');
INSERT INTO `testtbl` VALUES ('774', ' Conine, Jeff', ' 0.273', '2005-01-01');
INSERT INTO `testtbl` VALUES ('775', ' Conti, Jason', ' 0.257', '2005-01-01');
INSERT INTO `testtbl` VALUES ('776', ' Coolbaugh, Mike', ' 0.083', '2005-01-01');
INSERT INTO `testtbl` VALUES ('777', ' Coomer, Ron', ' 0.264', '2005-01-01');
INSERT INTO `testtbl` VALUES ('778', ' Cora, Alex', ' 0.291', '2005-01-01');
INSERT INTO `testtbl` VALUES ('779', ' Cordero, Wil', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('780', ' Cordova, Marty', ' 0.253', '2005-01-01');
INSERT INTO `testtbl` VALUES ('781', ' Cota, Humberto', ' 0.294', '2005-01-01');
INSERT INTO `testtbl` VALUES ('782', ' Counsell, Craig', ' 0.282', '2005-01-01');
INSERT INTO `testtbl` VALUES ('783', ' Cox, Steve', ' 0.254', '2005-01-01');
INSERT INTO `testtbl` VALUES ('784', ' Crawford, Carl', ' 0.259', '2005-01-01');
INSERT INTO `testtbl` VALUES ('785', ' Crede, Joe', ' 0.285', '2005-01-01');
INSERT INTO `testtbl` VALUES ('786', ' Crespo, Cesar', ' 0.172', '2005-01-01');
INSERT INTO `testtbl` VALUES ('787', ' Crisp, Covelli', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('788', ' Cruz, Deivi', ' 0.263', '2005-01-01');
INSERT INTO `testtbl` VALUES ('789', ' Cruz, Ivan', ' 0.357', '2005-01-01');
INSERT INTO `testtbl` VALUES ('790', ' Cruz, Jacob', ' 0.273', '2005-01-01');
INSERT INTO `testtbl` VALUES ('791', ' Cruz, Jose', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('792', ' Cuddyer, Michael', ' 0.259', '2005-01-01');
INSERT INTO `testtbl` VALUES ('793', ' Cust, Jack', ' 0.169', '2005-01-01');
INSERT INTO `testtbl` VALUES ('794', ' Damon, Johnny', ' 0.286', '2005-01-01');
INSERT INTO `testtbl` VALUES ('795', ' Daubach, Brian', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('796', ' DaVanon, Jeff', ' 0.167', '2005-01-01');
INSERT INTO `testtbl` VALUES ('797', ' Davis, Ben', ' 0.259', '2005-01-01');
INSERT INTO `testtbl` VALUES ('798', ' Davis, J.J.', ' 0.1', '2005-01-01');
INSERT INTO `testtbl` VALUES ('799', ' Dawkins, Travis', ' 0.125', '2005-01-01');
INSERT INTO `testtbl` VALUES ('800', ' DeHaan, Kory', ' 0.091', '2005-01-01');
INSERT INTO `testtbl` VALUES ('801', ' Delgado, Carlos', ' 0.277', '2005-01-01');
INSERT INTO `testtbl` VALUES ('802', ' Delgado, Wilson', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('803', ' Dellucci, David', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('804', ' DeRosa, Mark', ' 0.297', '2005-01-01');
INSERT INTO `testtbl` VALUES ('805', ' DeShields, Delino', ' 0.192', '2005-01-01');
INSERT INTO `testtbl` VALUES ('806', ' Diaz, Einar', ' 0.206', '2005-01-01');
INSERT INTO `testtbl` VALUES ('807', ' Diaz, Juan Carlos', ' 0.286', '2005-01-01');
INSERT INTO `testtbl` VALUES ('808', ' DiFelice, Mike', ' 0.23', '2005-01-01');
INSERT INTO `testtbl` VALUES ('809', ' Donnels, Chris', ' 0.238', '2005-01-01');
INSERT INTO `testtbl` VALUES ('810', ' Drew, J.D.', ' 0.252', '2005-01-01');
INSERT INTO `testtbl` VALUES ('811', ' Dunn, Adam', ' 0.249', '2005-01-01');
INSERT INTO `testtbl` VALUES ('812', ' Dunston, Shawon', ' 0.231', '2005-01-01');
INSERT INTO `testtbl` VALUES ('813', ' Dunwoody, Todd', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('814', ' Durazo, Erubiel', ' 0.261', '2005-01-01');
INSERT INTO `testtbl` VALUES ('815', ' Durham, Ray', ' 0.289', '2005-01-01');
INSERT INTO `testtbl` VALUES ('816', ' Dye, Jermaine', ' 0.252', '2005-01-01');
INSERT INTO `testtbl` VALUES ('817', ' Easley, Damion', ' 0.224', '2005-01-01');
INSERT INTO `testtbl` VALUES ('818', ' Echevarria, Angel', ' 0.306', '2005-01-01');
INSERT INTO `testtbl` VALUES ('819', ' Eckstein, David', ' 0.293', '2005-01-01');
INSERT INTO `testtbl` VALUES ('820', ' Edmonds, Jim', ' 0.311', '2005-01-01');
INSERT INTO `testtbl` VALUES ('821', ' Ellis, Mark', ' 0.272', '2005-01-01');
INSERT INTO `testtbl` VALUES ('822', ' Encarnacion, Juan', ' 0.271', '2005-01-01');
INSERT INTO `testtbl` VALUES ('823', ' Encarnacion, Mario', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('824', ' Ensberg, Morgan', ' 0.242', '2005-01-01');
INSERT INTO `testtbl` VALUES ('825', ' Erstad, Darin', ' 0.283', '2005-01-01');
INSERT INTO `testtbl` VALUES ('826', ' Escalona, Felix', ' 0.217', '2005-01-01');
INSERT INTO `testtbl` VALUES ('827', ' Escobar, Alex', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('828', ' Estalella, Bobby', ' 0.205', '2005-01-01');
INSERT INTO `testtbl` VALUES ('829', ' Estrada, Johnny', ' 0.118', '2005-01-01');
INSERT INTO `testtbl` VALUES ('830', ' Everett, Adam', ' 0.193', '2005-01-01');
INSERT INTO `testtbl` VALUES ('831', ' Everett, Carl', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('832', ' Fabregas, Jorge', ' 0.181', '2005-01-01');
INSERT INTO `testtbl` VALUES ('833', ' Fasano, Sal', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('834', ' Febles, Carlos', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('835', ' Feliz, Pedro', ' 0.253', '2005-01-01');
INSERT INTO `testtbl` VALUES ('836', ' Fick, Robert', ' 0.27', '2005-01-01');
INSERT INTO `testtbl` VALUES ('837', ' Figgins, Chone', ' 0.167', '2005-01-01');
INSERT INTO `testtbl` VALUES ('838', ' Finley, Steve', ' 0.287', '2005-01-01');
INSERT INTO `testtbl` VALUES ('839', ' Flaherty, John', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('840', ' Fletcher, Darrin', ' 0.22', '2005-01-01');
INSERT INTO `testtbl` VALUES ('841', ' Flores, Jose', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('842', ' Floyd, Cliff', ' 0.288', '2005-01-01');
INSERT INTO `testtbl` VALUES ('843', ' Fordyce, Brook', ' 0.231', '2005-01-01');
INSERT INTO `testtbl` VALUES ('844', ' Fox, Andy', ' 0.251', '2005-01-01');
INSERT INTO `testtbl` VALUES ('845', ' Franco, Julio', ' 0.284', '2005-01-01');
INSERT INTO `testtbl` VALUES ('846', ' Franco, Matt', ' 0.317', '2005-01-01');
INSERT INTO `testtbl` VALUES ('847', ' Fryman, Travis', ' 0.217', '2005-01-01');
INSERT INTO `testtbl` VALUES ('848', ' Fullmer, Brad', ' 0.289', '2005-01-01');
INSERT INTO `testtbl` VALUES ('849', ' Furcal, Rafael', ' 0.275', '2005-01-01');
INSERT INTO `testtbl` VALUES ('850', ' Galarraga, Andres', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('851', ' Gant, Ron', ' 0.262', '2005-01-01');
INSERT INTO `testtbl` VALUES ('852', ' Garcia, Jesse', ' 0.197', '2005-01-01');
INSERT INTO `testtbl` VALUES ('853', ' Garcia, Karim', ' 0.297', '2005-01-01');
INSERT INTO `testtbl` VALUES ('854', ' Garcia, Luis', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('855', ' Garciaparra, Nomar', ' 0.31', '2005-01-01');
INSERT INTO `testtbl` VALUES ('856', ' German, Esteban', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('857', ' Giambi, Jason', ' 0.314', '2005-01-01');
INSERT INTO `testtbl` VALUES ('858', ' Giambi, Jeremy', ' 0.259', '2005-01-01');
INSERT INTO `testtbl` VALUES ('859', ' Gibbons, Jay', ' 0.247', '2005-01-01');
INSERT INTO `testtbl` VALUES ('860', ' Gil, Benji', ' 0.285', '2005-01-01');
INSERT INTO `testtbl` VALUES ('861', ' Gil, Geronimo', ' 0.232', '2005-01-01');
INSERT INTO `testtbl` VALUES ('862', ' Giles, Brian', ' 0.298', '2005-01-01');
INSERT INTO `testtbl` VALUES ('863', ' Giles, Marcus', ' 0.23', '2005-01-01');
INSERT INTO `testtbl` VALUES ('864', ' Ginter, Keith', ' 0.235', '2005-01-01');
INSERT INTO `testtbl` VALUES ('865', ' Gipson, Charles', ' 0.236', '2005-01-01');
INSERT INTO `testtbl` VALUES ('866', ' Girardi, Joe', ' 0.226', '2005-01-01');
INSERT INTO `testtbl` VALUES ('867', ' Glanville, Doug', ' 0.249', '2005-01-01');
INSERT INTO `testtbl` VALUES ('868', ' Glaus, Troy', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('869', ' Gload, Ross', ' 0.258', '2005-01-01');
INSERT INTO `testtbl` VALUES ('870', ' Gomez, Alexis', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('871', ' Gomez, Chris', ' 0.265', '2005-01-01');
INSERT INTO `testtbl` VALUES ('872', ' Gonzalez, Alex', ' 0.225', '2005-01-01');
INSERT INTO `testtbl` VALUES ('873', ' Gonzalez, Alex', ' 0.248', '2005-01-01');
INSERT INTO `testtbl` VALUES ('874', ' Gonzalez, Juan', ' 0.282', '2005-01-01');
INSERT INTO `testtbl` VALUES ('875', ' Gonzalez, Luis', ' 0.288', '2005-01-01');
INSERT INTO `testtbl` VALUES ('876', ' Gonzalez, Raul', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('877', ' Gonzalez, Wiki', ' 0.22', '2005-01-01');
INSERT INTO `testtbl` VALUES ('878', ' Goodwin, Tom', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('879', ' Grabowski, Jason', ' 0.375', '2005-01-01');
INSERT INTO `testtbl` VALUES ('880', ' Grace, Mark', ' 0.252', '2005-01-01');
INSERT INTO `testtbl` VALUES ('881', ' Graffanino, Tony', ' 0.262', '2005-01-01');
INSERT INTO `testtbl` VALUES ('882', ' Green, Nick', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('883', ' Green, Shawn', ' 0.285', '2005-01-01');
INSERT INTO `testtbl` VALUES ('884', ' Greene, Todd', ' 0.268', '2005-01-01');
INSERT INTO `testtbl` VALUES ('885', ' Greer, Rusty', ' 0.296', '2005-01-01');
INSERT INTO `testtbl` VALUES ('886', ' Grieve, Ben', ' 0.251', '2005-01-01');
INSERT INTO `testtbl` VALUES ('887', ' Griffey, Ken', ' 0.264', '2005-01-01');
INSERT INTO `testtbl` VALUES ('888', ' Grissom, Marquis', ' 0.277', '2005-01-01');
INSERT INTO `testtbl` VALUES ('889', ' Grudzielanek, Mark', ' 0.271', '2005-01-01');
INSERT INTO `testtbl` VALUES ('890', ' Guerrero, Vladimir', ' 0.336', '2005-01-01');
INSERT INTO `testtbl` VALUES ('891', ' Guerrero, Wilton', ' 0.221', '2005-01-01');
INSERT INTO `testtbl` VALUES ('892', ' Guiel, Aaron', ' 0.233', '2005-01-01');
INSERT INTO `testtbl` VALUES ('893', ' Guillen, Carlos', ' 0.261', '2005-01-01');
INSERT INTO `testtbl` VALUES ('894', ' Guillen, Jose', ' 0.238', '2005-01-01');
INSERT INTO `testtbl` VALUES ('895', ' Gutierrez, Ricky', ' 0.275', '2005-01-01');
INSERT INTO `testtbl` VALUES ('896', ' Guzman, Christian', ' 0.273', '2005-01-01');
INSERT INTO `testtbl` VALUES ('897', ' Hafner, Travis', ' 0.242', '2005-01-01');
INSERT INTO `testtbl` VALUES ('898', ' Hairston, Jerry', ' 0.268', '2005-01-01');
INSERT INTO `testtbl` VALUES ('899', ' Hall, Bill', ' 0.194', '2005-01-01');
INSERT INTO `testtbl` VALUES ('900', ' Hall, Toby', ' 0.258', '2005-01-01');
INSERT INTO `testtbl` VALUES ('901', ' Halter, Shane', ' 0.239', '2005-01-01');
INSERT INTO `testtbl` VALUES ('902', ' Hammonds, Jeffrey', ' 0.257', '2005-01-01');
INSERT INTO `testtbl` VALUES ('903', ' Hansen, Dave', ' 0.292', '2005-01-01');
INSERT INTO `testtbl` VALUES ('904', ' Harris, Lenny', ' 0.305', '2005-01-01');
INSERT INTO `testtbl` VALUES ('905', ' Harris, Willie', ' 0.233', '2005-01-01');
INSERT INTO `testtbl` VALUES ('906', ' Hart, Jason', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('907', ' Haselman, Bill', ' 0.246', '2005-01-01');
INSERT INTO `testtbl` VALUES ('908', ' Hatteberg, Scott', ' 0.28', '2005-01-01');
INSERT INTO `testtbl` VALUES ('909', ' Helms, Wes', ' 0.243', '2005-01-01');
INSERT INTO `testtbl` VALUES ('910', ' Helton, Todd', ' 0.329', '2005-01-01');
INSERT INTO `testtbl` VALUES ('911', ' Henderson, Rickey', ' 0.223', '2005-01-01');
INSERT INTO `testtbl` VALUES ('912', ' Henson, Drew', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('913', ' Hermansen, Chad', ' 0.207', '2005-01-01');
INSERT INTO `testtbl` VALUES ('914', ' Hernandez, Jose', ' 0.288', '2005-01-01');
INSERT INTO `testtbl` VALUES ('915', ' Hernandez, Ramon', ' 0.233', '2005-01-01');
INSERT INTO `testtbl` VALUES ('916', ' Hidalgo, Richard', ' 0.235', '2005-01-01');
INSERT INTO `testtbl` VALUES ('917', ' Higginson, Bobby', ' 0.282', '2005-01-01');
INSERT INTO `testtbl` VALUES ('918', ' Hill, Bobby', ' 0.253', '2005-01-01');
INSERT INTO `testtbl` VALUES ('919', ' Hillenbrand, Shea', ' 0.293', '2005-01-01');
INSERT INTO `testtbl` VALUES ('920', ' Hinch, A.J.', ' 0.249', '2005-01-01');
INSERT INTO `testtbl` VALUES ('921', ' Hinske, Eric', ' 0.279', '2005-01-01');
INSERT INTO `testtbl` VALUES ('922', ' Hocking, Denny', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('923', ' Hollandsworth, Todd', ' 0.284', '2005-01-01');
INSERT INTO `testtbl` VALUES ('924', ' Hollins, Dave', ' 0.118', '2005-01-01');
INSERT INTO `testtbl` VALUES ('925', ' Hoover, Paul', ' 0.176', '2005-01-01');
INSERT INTO `testtbl` VALUES ('926', ' Houston, Tyler', ' 0.281', '2005-01-01');
INSERT INTO `testtbl` VALUES ('927', ' Hubbard, Trenidad', ' 0.209', '2005-01-01');
INSERT INTO `testtbl` VALUES ('928', ' Huckaby, Ken', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('929', ' Hudson, Orlando', ' 0.276', '2005-01-01');
INSERT INTO `testtbl` VALUES ('930', ' Huff, Aubrey', ' 0.313', '2005-01-01');
INSERT INTO `testtbl` VALUES ('931', ' Hundley, Todd', ' 0.211', '2005-01-01');
INSERT INTO `testtbl` VALUES ('932', ' Hunter, Brian L.', ' 0.269', '2005-01-01');
INSERT INTO `testtbl` VALUES ('933', ' Hunter, Torii', ' 0.289', '2005-01-01');
INSERT INTO `testtbl` VALUES ('934', ' Hyzdu, Adam', ' 0.232', '2005-01-01');
INSERT INTO `testtbl` VALUES ('935', ' Ibanez, Raul', ' 0.294', '2005-01-01');
INSERT INTO `testtbl` VALUES ('936', ' Infante, Omar', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('937', ' Inge, Brandon', ' 0.202', '2005-01-01');
INSERT INTO `testtbl` VALUES ('938', ' Izturis, Cesar', ' 0.232', '2005-01-01');
INSERT INTO `testtbl` VALUES ('939', ' Jackson, Damian', ' 0.257', '2005-01-01');
INSERT INTO `testtbl` VALUES ('940', ' Jackson, Ryan', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('941', ' Jenkins, Geoff', ' 0.243', '2005-01-01');
INSERT INTO `testtbl` VALUES ('942', ' Jensen, Marcus', ' 0.114', '2005-01-01');
INSERT INTO `testtbl` VALUES ('943', ' Jeter, Derek', ' 0.297', '2005-01-01');
INSERT INTO `testtbl` VALUES ('944', ' Jimenez, D\\\'Angelo', ' 0.252', '2005-01-01');
INSERT INTO `testtbl` VALUES ('945', ' Johnson, Charles', ' 0.217', '2005-01-01');
INSERT INTO `testtbl` VALUES ('946', ' Johnson, Mark', ' 0.209', '2005-01-01');
INSERT INTO `testtbl` VALUES ('947', ' Johnson, Mark P.', ' 0.137', '2005-01-01');
INSERT INTO `testtbl` VALUES ('948', ' Johnson, Nick', ' 0.243', '2005-01-01');
INSERT INTO `testtbl` VALUES ('949', ' Johnson, Russ', ' 0.216', '2005-01-01');
INSERT INTO `testtbl` VALUES ('950', ' Jones, Andruw', ' 0.264', '2005-01-01');
INSERT INTO `testtbl` VALUES ('951', ' Jones, Chipper', ' 0.327', '2005-01-01');
INSERT INTO `testtbl` VALUES ('952', ' Jones, Jacque', ' 0.3', '2005-01-01');
INSERT INTO `testtbl` VALUES ('953', ' Jordan, Brian', ' 0.285', '2005-01-01');
INSERT INTO `testtbl` VALUES ('954', ' Jose, Felix', ' 0.263', '2005-01-01');
INSERT INTO `testtbl` VALUES ('955', ' Justice, David', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('956', ' Kapler, Gabe', ' 0.279', '2005-01-01');
INSERT INTO `testtbl` VALUES ('957', ' Karros, Eric', ' 0.271', '2005-01-01');
INSERT INTO `testtbl` VALUES ('958', ' Kearns, Austin', ' 0.315', '2005-01-01');
INSERT INTO `testtbl` VALUES ('959', ' Kelly, Kenny', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('960', ' Kendall, Jason', ' 0.283', '2005-01-01');
INSERT INTO `testtbl` VALUES ('961', ' Kennedy, Adam', ' 0.312', '2005-01-01');
INSERT INTO `testtbl` VALUES ('962', ' Kent, Jeff', ' 0.313', '2005-01-01');
INSERT INTO `testtbl` VALUES ('963', ' Kielty, Bobby', ' 0.291', '2005-01-01');
INSERT INTO `testtbl` VALUES ('964', ' Kingsale, Eugene', ' 0.283', '2005-01-01');
INSERT INTO `testtbl` VALUES ('965', ' Kinkade, Mike', ' 0.38', '2005-01-01');
INSERT INTO `testtbl` VALUES ('966', ' Klassen, Danny', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('967', ' Klesko, Ryan', ' 0.3', '2005-01-01');
INSERT INTO `testtbl` VALUES ('968', ' Knoblauch, Chuck', ' 0.21', '2005-01-01');
INSERT INTO `testtbl` VALUES ('969', ' Konerko, Paul', ' 0.304', '2005-01-01');
INSERT INTO `testtbl` VALUES ('970', ' Koskie, Corey', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('971', ' Kotsay, Mark', ' 0.292', '2005-01-01');
INSERT INTO `testtbl` VALUES ('972', ' Kreuter, Chad', ' 0.263', '2005-01-01');
INSERT INTO `testtbl` VALUES ('973', ' Lamb, David', ' 0.1', '2005-01-01');
INSERT INTO `testtbl` VALUES ('974', ' Lamb, Mike', ' 0.283', '2005-01-01');
INSERT INTO `testtbl` VALUES ('975', ' Lampkin, Tom', ' 0.217', '2005-01-01');
INSERT INTO `testtbl` VALUES ('976', ' Lane, Jason', ' 0.29', '2005-01-01');
INSERT INTO `testtbl` VALUES ('977', ' Langerhans, Ryan', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('978', ' Lankford, Ray', ' 0.224', '2005-01-01');
INSERT INTO `testtbl` VALUES ('979', ' Larkin, Barry', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('980', ' LaRocca, Greg', ' 0.269', '2005-01-01');
INSERT INTO `testtbl` VALUES ('981', ' Larson, Brandon', ' 0.275', '2005-01-01');
INSERT INTO `testtbl` VALUES ('982', ' LaRue, Jason', ' 0.249', '2005-01-01');
INSERT INTO `testtbl` VALUES ('983', ' Lawrence, Joe', ' 0.18', '2005-01-01');
INSERT INTO `testtbl` VALUES ('984', ' Lawton, Matt', ' 0.236', '2005-01-01');
INSERT INTO `testtbl` VALUES ('985', ' LeCroy, Matt', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('986', ' Ledee, Ricky', ' 0.227', '2005-01-01');
INSERT INTO `testtbl` VALUES ('987', ' Lee, Carlos', ' 0.264', '2005-01-01');
INSERT INTO `testtbl` VALUES ('988', ' Lee, Derrek', ' 0.27', '2005-01-01');
INSERT INTO `testtbl` VALUES ('989', ' Lee, Travis', ' 0.265', '2005-01-01');
INSERT INTO `testtbl` VALUES ('990', ' Leon, Jose', ' 0.247', '2005-01-01');
INSERT INTO `testtbl` VALUES ('991', ' Lesher, Brian', ' 0.132', '2005-01-01');
INSERT INTO `testtbl` VALUES ('992', ' Lewis, Darren', ' 0.241', '2005-01-01');
INSERT INTO `testtbl` VALUES ('993', ' Lieberthal, Mike', ' 0.279', '2005-01-01');
INSERT INTO `testtbl` VALUES ('994', ' Liefer, Jeff', ' 0.23', '2005-01-01');
INSERT INTO `testtbl` VALUES ('995', ' Little, Mark', ' 0.208', '2005-01-01');
INSERT INTO `testtbl` VALUES ('996', ' Lo Duca, Paul', ' 0.281', '2005-01-01');
INSERT INTO `testtbl` VALUES ('997', ' Lockhart, Keith', ' 0.216', '2005-01-01');
INSERT INTO `testtbl` VALUES ('998', ' Lofton, Kenny', ' 0.261', '2005-01-01');
INSERT INTO `testtbl` VALUES ('999', ' Lombard, George', ' 0.241', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1000', ' Long, Terrence', ' 0.24', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1001', ' Lopez, Felipe', ' 0.227', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1002', ' Lopez, Javy', ' 0.233', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1003', ' Lopez, Luis', ' 0.197', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1004', ' Lopez, Mendy', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1005', ' Loretta, Mark', ' 0.304', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1006', ' Lowell, Mike', ' 0.276', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1007', ' Ludwick, Ryan', ' 0.235', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1008', ' Lugo, Julio', ' 0.261', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1009', ' Lunar, Fernando', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1010', ' Lunsford, Trey', ' 0.667', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1011', ' Mabry, John', ' 0.276', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1012', ' Machado, Robert', ' 0.261', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1013', ' Macias, Jose', ' 0.249', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1014', ' Mackowiak, Rob', ' 0.244', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1015', ' Magee, Wendell', ' 0.271', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1016', ' Magruder, Chris', ' 0.217', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1017', ' Mahoney, Mike', ' 0.207', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1018', ' Malloy, Marty', ' 0.12', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1019', ' Marrero, Eli', ' 0.262', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1020', ' Martinez, Dave', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1021', ' Martinez, Edgar', ' 0.277', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1022', ' Martinez, Ramon', ' 0.271', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1023', ' Martinez, Tino', ' 0.262', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1024', ' Martinez, Victor', ' 0.281', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1025', ' Mateo, Henry', ' 0.174', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1026', ' Mateo, Ruben', ' 0.256', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1027', ' Matheny, Mike', ' 0.244', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1028', ' Matos, Julios', ' 0.238', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1029', ' Matos, Luis', ' 0.129', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1030', ' Matthews, Gary', ' 0.275', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1031', ' Mayne, Brent', ' 0.236', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1032', ' McCarty, David', ' 0.136', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1033', ' McCracken, Quinton', ' 0.309', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1034', ' McDonald, Donzell', ' 0.182', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1035', ' McDonald, John', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1036', ' McEwing, Joe', ' 0.199', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1037', ' McGriff, Fred', ' 0.273', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1038', ' McGuire, Ryan', ' 0.077', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1039', ' McKay, Cody', ' 0.667', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1040', ' McKeel, Walt', ' 0.308', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1041', ' McLemore, Mark', ' 0.27', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1042', ' Meares, Pat', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1043', ' Meluskey, Mitch', ' 0.222', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1044', ' Mench, Kevin', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1045', ' Menechino, Frank', ' 0.205', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1046', ' Merced, Orlando', ' 0.287', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1047', ' Merloni, Lou', ' 0.247', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1048', ' Michaels, Jason', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1049', ' Mientkiewicz, Doug', ' 0.261', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1050', ' Millar, Kevin', ' 0.306', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1051', ' Miller, Corky', ' 0.254', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1052', ' Miller, Damian', ' 0.249', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1053', ' Minor, Damon', ' 0.237', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1054', ' Mirabelli, Doug', ' 0.225', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1055', ' Moeller, Chad', ' 0.286', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1056', ' Mohr, Dustan', ' 0.269', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1057', ' Molina, Ben', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1058', ' Molina, Izzy', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1059', ' Molina, Jose', ' 0.271', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1060', ' Mondesi, Raul', ' 0.232', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1061', ' Monroe, Craig', ' 0.12', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1062', ' Mora, Melvin', ' 0.233', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1063', ' Mordecai, Mike', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1064', ' Moriarty, Mike', ' 0.188', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1065', ' Morris, Warren', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1066', ' Mueller, Bill', ' 0.262', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1067', ' Munson, Eric', ' 0.186', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1068', ' Murray, Calvin', ' 0.146', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1069', ' Myers, Greg', ' 0.222', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1070', ' Nelson, Bryant', ' 0.265', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1071', ' Nevin, Phil', ' 0.285', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1072', ' Nieves, Jose', ' 0.289', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1073', ' Nieves, Wil', ' 0.181', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1074', ' Nixon, Trot', ' 0.256', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1075', ' Norton, Greg', ' 0.22', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1076', ' Nunez, Abraham', ' 0.233', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1077', ' Nunez, Abraham', ' 0.118', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1078', ' O\\\'Leary, Troy', ' 0.286', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1079', ' Ochoa, Alex', ' 0.261', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1080', ' Offerman, Jose', ' 0.232', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1081', ' Ojeda, Augie', ' 0.186', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1082', ' Olerud, John', ' 0.3', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1083', ' Olivo, Miguel', ' 0.211', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1084', ' Ordaz, Luis', ' 0.223', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1085', ' Ordonez, Magglio', ' 0.32', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1086', ' Ordonez, Rey', ' 0.254', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1087', ' Orie, Kevin', ' 0.281', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1088', ' Ortiz, David', ' 0.272', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1089', ' Ortiz, Hector', ' 0.214', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1090', ' Ortiz, Jose', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1091', ' Osik, Keith', ' 0.16', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1092', ' Overbay, Lyle', ' 0.1', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1093', ' Owens, Eric', ' 0.27', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1094', ' Ozuna, Pablo', ' 0.277', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1095', ' Palmeiro, Orlando', ' 0.3', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1096', ' Palmeiro, Rafael', ' 0.273', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1097', ' Palmer, Dean', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1098', ' Paquette, Craig', ' 0.194', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1099', ' Patterson, Corey', ' 0.253', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1100', ' Paul, Josh', ' 0.24', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1101', ' Payton, Jay', ' 0.303', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1102', ' Pelaez, Alex', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1103', ' Pellow, Kip', ' 0.238', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1104', ' Pena, Carlos', ' 0.242', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1105', ' Pena, Wily Mo', ' 0.222', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1106', ' Perez, Eddie', ' 0.214', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1107', ' Perez, Eduardo', ' 0.201', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1108', ' Perez, Neifi', ' 0.236', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1109', ' Perez, Timoniel', ' 0.295', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1110', ' Perez, Tomas', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1111', ' Perry, Chan', ' 0.091', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1112', ' Perry, Herbert', ' 0.276', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1113', ' Petrick, Ben', ' 0.211', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1114', ' Phelps, Josh', ' 0.309', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1115', ' Phillips, Brandon', ' 0.258', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1116', ' Phillips, Jason', ' 0.368', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1117', ' Piatt, Adam', ' 0.234', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1118', ' Piazza, Mike', ' 0.28', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1119', ' Pickering, Calvin', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1120', ' Pierre, Juan', ' 0.287', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1121', ' Pierzynski, A.J.', ' 0.3', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1122', ' Podsednik, Scott', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1123', ' Polanco, Placido', ' 0.288', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1124', ' Posada, Jorge', ' 0.268', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1125', ' Pratt, Todd', ' 0.311', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1126', ' Prince, Tom', ' 0.224', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1127', ' Pujols, Albert', ' 0.314', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1128', ' Punto, Nick', ' 0.167', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1129', ' Quinn, Mark', ' 0.237', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1130', ' Raines, Tim', ' 0.191', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1131', ' Ramirez, Aramis', ' 0.234', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1132', ' Ramirez, Julio', ' 0.281', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1133', ' Ramirez, Manny', ' 0.349', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1134', ' Randa, Joe', ' 0.282', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1135', ' Ransom, Cody', ' 0.667', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1136', ' Reboulet, Jeff', ' 0.208', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1137', ' Redmond, Mike', ' 0.305', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1138', ' Reese, Pokey', ' 0.264', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1139', ' Relaford, Desi', ' 0.267', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1140', ' Renteria, Edgar', ' 0.305', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1141', ' Restovich, Mike', ' 0.308', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1142', ' Richard, Chris', ' 0.232', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1143', ' Rios, Armando', ' 0.264', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1144', ' Rivas, Luis', ' 0.256', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1145', ' Rivera, Juan', ' 0.265', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1146', ' Rivera, Mike', ' 0.227', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1147', ' Rivera, Ruben', ' 0.209', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1148', ' Roberts, Brian', ' 0.227', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1149', ' Roberts, Dave', ' 0.277', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1150', ' Robinson, Kerry', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1151', ' Rodriguez, Alex', ' 0.3', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1152', ' Rodriguez, Henry', ' 0.05', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1153', ' Rodriguez, Ivan', ' 0.314', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1154', ' Rogers, Ed', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1155', ' Rolen, Scott', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1156', ' Rollins, Jimmy', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1157', ' Rolls, Damian', ' 0.292', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1158', ' Romano, Jason', ' 0.253', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1159', ' Ross, David', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1160', ' Rowand, Aaron', ' 0.258', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1161', ' Ruan, Wilken', ' 0.273', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1162', ' Rushford, Jim', ' 0.143', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1163', ' Ryan, Mike', ' 0.091', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1164', ' Sadler, Donnie', ' 0.163', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1165', ' Saenz, Olmedo', ' 0.276', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1166', ' Salazar, Oscar', ' 0.19', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1167', ' Salmon, Tim', ' 0.286', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1168', ' Sanchez, Alex', ' 0.289', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1169', ' Sanchez, Freddy', ' 0.188', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1170', ' Sanchez, Rey', ' 0.286', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1171', ' Sandberg, Jared', ' 0.229', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1172', ' Sanders, Reggie', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1173', ' Santiago, Benito', ' 0.278', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1174', ' Santiago, Ramon', ' 0.243', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1175', ' Schneider, Brian', ' 0.275', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1176', ' Scutaro, Marcos', ' 0.222', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1177', ' Sears, Todd', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1178', ' Segui, David', ' 0.263', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1179', ' Selby, Bill', ' 0.214', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1180', ' Sexson, Richie', ' 0.279', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1181', ' Sheets, Andy', ' 0.248', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1182', ' Sheffield, Gary', ' 0.307', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1183', ' Shinjo, Tsuyoshi', ' 0.238', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1184', ' Shumpert, Terry', ' 0.235', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1185', ' Sierra, Ruben', ' 0.27', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1186', ' Simon, Randall', ' 0.301', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1187', ' Singleton, Chris', ' 0.262', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1188', ' Smith, Bobby', ' 0.175', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1189', ' Smith, Jason', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1190', ' Snead, Esix', ' 0.308', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1191', ' Snelling, Chris', ' 0.148', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1192', ' Snow, J.T.', ' 0.246', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1193', ' Snyder, Earl', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1194', ' Soriano, Alfonso', ' 0.3', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1195', ' Sosa, Sammy', ' 0.288', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1196', ' Spencer, Shane', ' 0.247', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1197', ' Spiezio, Scott', ' 0.285', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1198', ' Spivey, Junior', ' 0.301', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1199', ' Stairs, Matt', ' 0.244', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1200', ' Stevens, Lee', ' 0.204', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1201', ' Stewart, Shannon', ' 0.303', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1202', ' Stinnett, Kelly', ' 0.226', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1203', ' Stynes, Chris', ' 0.241', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1204', ' Surhoff, B.J.', ' 0.293', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1205', ' Sutton, Larry', ' 0.105', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1206', ' Suzuki, Ichiro', ' 0.321', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1207', ' Swann, Pedro', ' 0.083', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1208', ' Sweeney, Mark', ' 0.169', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1209', ' Sweeney, Mike', ' 0.34', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1210', ' Taguchi, So', ' 0.4', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1211', ' Tarasco, Tony', ' 0.25', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1212', ' Tatis, Fernando', ' 0.228', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1213', ' Taubensee, Eddie', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1214', ' Taylor, Reggie', ' 0.254', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1215', ' Tejada, Miguel', ' 0.308', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1216', ' Thames, Marcus', ' 0.231', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1217', ' Thomas, Frank', ' 0.252', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1218', ' Thome, Jim', ' 0.304', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1219', ' Thompson, Ryan', ' 0.248', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1220', ' Thurston, Joe', ' 0.462', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1221', ' Toca, Jorge', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1222', ' Torcato, Tony', ' 0.273', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1223', ' Torrealba, Steve', ' 0.059', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1224', ' Torrealba, Yorvit', ' 0.279', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1225', ' Torres, Andres', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1226', ' Trammell, Bubba', ' 0.243', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1227', ' Truby, Chris', ' 0.215', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1228', ' Tucker, Michael', ' 0.248', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1229', ' Tyner, Jason', ' 0.214', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1230', ' Ugueto, Luis', ' 0.217', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1231', ' Uribe, Juan', ' 0.24', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1232', ' Valdez, Mario', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1233', ' Valent, Eric', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1234', ' Valentin, Javier', ' 0.5', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1235', ' Valentin, John', ' 0.24', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1236', ' Valentin, Jose', ' 0.249', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1237', ' Vander Wal, John', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1238', ' Varitek, Jason', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1239', ' Vaughn, Greg', ' 0.163', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1240', ' Vaughn, Mo', ' 0.259', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1241', ' Vazquez, Ramon', ' 0.274', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1242', ' Velarde, Randy', ' 0.226', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1243', ' Ventura, Robin', ' 0.247', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1244', ' Vidro, Jose', ' 0.315', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1245', ' Vina, Fernando', ' 0.27', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1246', ' Vizcaino, Jose', ' 0.303', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1247', ' Vizquel, Omar', ' 0.275', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1248', ' Walbeck, Matt', ' 0.235', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1249', ' Walker, Larry', ' 0.338', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1250', ' Walker, Todd', ' 0.299', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1251', ' Ward, Daryle', ' 0.276', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1252', ' Wathan, Dusty', ' 0.6', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1253', ' Wells, Vernon', ' 0.275', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1254', ' Werth, Jayson', ' 0.261', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1255', ' Wesson, Barry', ' 0.2', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1256', ' White, Rondell', ' 0.24', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1257', ' Widger, Chris', ' 0.297', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1258', ' Wigginton, Ty', ' 0.302', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1259', ' Wilkerson, Brad', ' 0.266', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1260', ' Williams, Bernie', ' 0.333', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1261', ' Williams, Gerald', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1262', ' Williams, Matt', ' 0.26', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1263', ' Wilson, Craig', ' 0.264', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1264', ' Wilson, Dan', ' 0.295', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1265', ' Wilson, Enrique', ' 0.181', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1266', ' Wilson, Jack', ' 0.252', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1267', ' Wilson, Preston', ' 0.243', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1268', ' Wilson, Tom', ' 0.257', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1269', ' Wilson, Vance', ' 0.245', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1270', ' Winn, Randy', ' 0.298', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1271', ' Wise, DeWayne', ' 0.179', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1272', ' Womack, Tony', ' 0.271', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1273', ' Woodward, Chris', ' 0.276', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1274', ' Wooten, Shawn', ' 0.292', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1275', ' Wright, Ron', ' 0', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1276', ' Young, Dmitri', ' 0.284', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1277', ' Young, Eric', ' 0.28', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1278', ' Young, Kevin', ' 0.246', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1279', ' Young, Michael', ' 0.262', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1280', ' Zaun, Greg', ' 0.222', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1281', ' Zeile, Todd', ' 0.273', '2005-01-01');
INSERT INTO `testtbl` VALUES ('1282', ' Zinter, Alan', ' 0.136', '2005-01-01');
/trunk/api/js/dojo1.0/dojox/grid/tests/support/yahoo_search.js
New file
0,0 → 1,131
// model that works with Yahoo Search API
dojo.declare("dojox.grid.data.yahooSearch", dojox.grid.data.dynamic,
function(inFields, inData) {
this.rowsPerPage = 20;
this.fieldNames = [];
for (var i=0, f; (f=inFields[i]); i++)
this.fieldNames.push(f.name);
}, {
clearData: function() {
turbo.widgets.TurboGrid.data.dynamic.prototype.clearData.apply(this, arguments);
},
// server send / receive
encodeParam: function(inName, inValue) {
return turbo.printf('&%s=%s', inName, inValue);
},
getParams: function(inParams) {
var url = this.url;
url += '?appid=turboajax';
inParams = inParams || {};
inParams.output = 'json';
inParams.results = this.rowsPerPage;
inParams.query = turbo.$('searchInput').value.replace(/ /g, '+');
for (var i in inParams)
if (inParams[i] != undefined)
url += this.encodeParam(i, inParams[i]);
return url;
},
send: function(inAsync, inParams, inOnReceive, inOnError) {
var p = this.getParams(inParams);
dojo.io.bind({
url: "support/proxy.php",
method: "post",
content: {url: p },
contentType: "application/x-www-form-urlencoded; charset=utf-8",
mimetype: 'text/json',
sync: !inAsync,
load: turbo.bindArgs(this, "receive", inOnReceive, inOnError),
error: turbo.bindArgs(this, "error", inOnError)
});
this.onSend(inParams);
},
receive: function(inOnReceive, inOnError, inEvt, inData) {
try {
inData = inData.ResultSet;
inOnReceive(inData);
this.onReceive(inData);
} catch(e) {
if (inOnError)
inOnError(inData);
}
},
error: function(inOnError, inTyp, inErr) {
var m = 'io error: ' + inErr.message;
alert(m);
if (inOnError)
inOnError(m);
},
fetchRowCount: function(inCallback) {
this.send(true, inCallback );
},
// request data
requestRows: function(inRowIndex, inCount) {
inRowIndex = (inRowIndex == undefined ? 0 : inRowIndex);
var params = {
start: inRowIndex + 1
}
this.send(true, params, turbo.bindArgs(this, this.processRows));
},
// server callbacks
processRows: function(inData) {
for (var i=0, l=inData.totalResultsReturned, s=inData.firstResultPosition; i<l; i++) {
this.setRow(inData.Result[i], s - 1 + i);
}
// yahoo says 1000 is max results to return
var c = Math.min(1000, inData.totalResultsAvailable);
if (this.count != c) {
this.setRowCount(c);
this.allChange();
this.onInitializeData(inData);
}
},
getDatum: function(inRowIndex, inColIndex) {
var row = this.getRow(inRowIndex);
var field = this.fields.get(inColIndex);
return (inColIndex == undefined ? row : (row ? row[field.name] : field.na));
},
// events
onInitializeData: turbo.nop,
onSend: turbo.nop,
onReceive: turbo.nop
});
 
// report
modelChange = function() {
var n = turbo.$('rowCount');
if (n)
n.innerHTML = turbo.printf('about %s row(s)', model.count);
}
 
 
// some data formatters
formatLink = function(inData, inRowIndex) {
if (!inData[0] || !inData[1])
return '&nbsp;';
return turbo.supplant('<a target="_blank" href="{href}">{text}</a>', {href: inData[0], text: inData[1] });
};
 
formatImage = function(inData, inRowIndex) {
if (!inData[0] || !inData[1])
return '&nbsp;';
var o = {
href: inData[0],
src: inData[1].Url,
width: inData[1].Width,
height: inData[1].Height
}
return turbo.supplant('<a href="{href}" target="_blank"><img border=0 src="{src}" width="{width}" height="{height}"></a>', o);
};
 
formatDate = function(inDatum, inRowIndex) {
if (inDatum == '')
return '&nbsp;';
var d = new Date(inDatum * 1000);
return turbo.printf('%s/%s/%s', d.getMonth(), d.getDate(), d.getFullYear());
};
 
formatDimensions = function(inData, inRowIndex) {
if (!inData[0] || !inData[1])
return '&nbsp;';
return inData[0] + ' x ' + inData[1];
}
/trunk/api/js/dojo1.0/dojox/grid/tests/support/test_data.js
New file
0,0 → 1,30
// example sample data and code
(function(){
// some sample data
// global var "data"
data = [
[ "normal", false, "new", 'But are not followed by two hexadecimal', 29.91, 10, false ],
[ "important", false, "new", 'Because a % sign always indicates', 9.33, -5, false ],
[ "important", false, "read", 'Signs can be selectively', 19.34, 0, true ],
[ "note", false, "read", 'However the reserved characters', 15.63, 0, true ],
[ "normal", false, "replied", 'It is therefore necessary', 24.22, 5.50, true ],
[ "important", false, "replied", 'To problems of corruption by', 9.12, -3, true ],
[ "note", false, "replied", 'Which would simply be awkward in', 12.15, -4, false ]
];
var rows = 100;
for(var i=0, l=data.length; i<rows-l; i++){
data.push(data[i%l].slice(0));
}
 
// global var "model"
model = new dojox.grid.data.Table(null, data);
 
// simple display of row info; based on model observation
// global var "modelChange"
modelChange = function(){
var n = dojo.byId('rowCount');
if(n){
n.innerHTML = Number(model.getRowCount()) + ' row(s)';
}
}
})();
/trunk/api/js/dojo1.0/dojox/grid/tests/support/proxy.php
New file
0,0 → 1,27
<?php
 
// Open the Curl session
if (!$_POST['url'])
exit;
 
$session = curl_init(($_POST['url']));
 
 
$postvars = file_get_contents('php://input');
 
// Don't return HTTP headers. Do return the contents of the call
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
 
// Make the call
$response = curl_exec($session);
 
//header("Content-Type: text/html; charset=utf-8");
header("Content-Type: application/xml;");
 
// expects a json response and filters it
echo "/*" . $response . "*/";
curl_close($session);
 
?>
 
/trunk/api/js/dojo1.0/dojox/grid/tests/test_mysql_edit.html
New file
0,0 → 1,157
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html debug="true">
<head>
<title>dojox.Grid Test: Mysql Table Editing</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style>
@import "../_grid/tundraGrid.css";
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
 
.grid {
height: 30em;
}
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
<!--<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojox.grid._data.dijitEditors");
dojo.require("dojox.grid.tests.databaseModel");
dojo.require("dojo.parser");
</script>-->
<!-- Debugging -->
<script type="text/javascript" src="../_grid/lib.js"></script>
<script type="text/javascript" src="../_grid/drag.js"></script>
<script type="text/javascript" src="../_grid/scroller.js"></script>
<script type="text/javascript" src="../_grid/builder.js"></script>
<script type="text/javascript" src="../_grid/cell.js"></script>
<script type="text/javascript" src="../_grid/layout.js"></script>
<script type="text/javascript" src="../_grid/rows.js"></script>
<script type="text/javascript" src="../_grid/focus.js"></script>
<script type="text/javascript" src="../_grid/selection.js"></script>
<script type="text/javascript" src="../_grid/edit.js"></script>
<script type="text/javascript" src="../_grid/view.js"></script>
<script type="text/javascript" src="../_grid/views.js"></script>
<script type="text/javascript" src="../_grid/rowbar.js"></script>
<script type="text/javascript" src="../_grid/publicEvents.js"></script>
<script type="text/javascript" src="../VirtualGrid.js"></script>
<script type="text/javascript" src="../_data/fields.js"></script>
<script type="text/javascript" src="../_data/model.js"></script>
<script type="text/javascript" src="../_data/editors.js"></script>
<script type="text/javascript" src="../_data/dijitEditors.js"></script>
<script type="text/javascript" src="../Grid.js"></script>
<script type="text/javascript" src="databaseModel.js"></script>
<script type="text/javascript">
var model = new dojox.grid.data.DbTable(null, null, 'support/data.php', "test", "testtbl");
// simple display of row info; based on model observing.
modelChange = function() {
dojo.byId('rowCount').innerHTML = model.count + ' row(s)';
}
model.observer(this);
// yay, let's deal with MySql date types, at least a little bit...
// NOTE: supports only default date formatting YYYY-MM-DD HH:MM:SS or YY-MM-DD HH:MM:SS
mysqlDateToJsDate = function(inMysqlDateTime, inDateDelim, inTimeDelim) {
var dt = inMysqlDateTime.split(' '), d = dt[0], t = dt[1], r;
d = d&&d.split(inDateDelim||'-');
t = t&&t.split(inTimeDelim||':');
if (d && d.length == 3) {
r = new Date();
r.setYear(d[0]);
r.setMonth(parseInt(d[1])-1);
r.setDate(d[2]);
}
if (t && t.length == 3) {
r = r || new Date();
r.setHours(t[0]);
r.setMinutes(t[1]);
r.setSeconds(t[2]);
}
return r || new Date(inMysqlDateTime);
}
jsDateToMySqlDate = function(inDate) {
var
d = new Date(inDate),
y = d.getFullYear(),
m = dojo.string.pad(d.getMonth() + 1),
dd = dojo.string.pad(d.getDate())
return dojo.string.substitute("${0}-${1}-${2}",[y, m, dd]);
};
// custom simple MySql date formatter
formatMySqlDate = function(inDatum) {
return inDatum != dojox.grid.na ? dojo.date.locale.format(mysqlDateToJsDate(inDatum), this.constraint) : dojox.grid.na;
}
// custom simple MySql date editor
dojo.declare("mySqlDateEditor", dojox.grid.editors.DateTextBox, {
format: function(inDatum, inRowIndex){
inDatum = mysqlDateToJsDate(inDatum);
return this.inherited(arguments, [inDatum, inRowIndex]);
},
getValue: function(inRowIndex){
var v = this.editor.getValue(), fv = jsDateToMySqlDate(v);
return fv;
}
});
var gridLayout = [
{ type: "dojox.GridRowView", width: "20px" },
{
defaultCell: { width: 6, editor: dojox.grid.editors.Dijit },
cells: [[
{ name: 'Id', styles: 'text-align: right;', editorClass: "dijit.form.NumberTextBox" },
{ name: 'Name', width: 20},
{ name: 'Message', styles: 'text-align: right;'},
{ name: 'Date',
editor: mySqlDateEditor,
formatter: formatMySqlDate,
constraint: {selector: "date"},
width: 10,
styles: 'text-align:right;'}
]]}
];
 
function waitMessage() {
alert('Edit in progress, please wait.');
}
function getDefaultRow() {
return ['', '', '', jsDateToMySqlDate(new Date())];
}
function addRow() {
if(model.canModify()){
grid.addRow(getDefaultRow());
}else{
waitMessage();
}
}
function removeSelected(){
if(model.canModify()){
grid.removeSelectedRows();
}else{
waitMessage();
}
}
</script>
</head>
<body class="tundra">
<h1>dojox.Grid Test: Mysql Table Editing</h1>
<br>
<button onclick="addRow()">Add Row</button>&nbsp;&nbsp;
<button onclick="removeSelected()">Remove Selected</button>&nbsp;&nbsp;
<button onclick="grid.edit.apply()">Apply Edit</button>&nbsp;&nbsp;
<button onclick="grid.edit.cancel()">Cancel Edit</button>&nbsp;&nbsp;
<button onclick="grid.refresh()">Refresh</button>
<br><br>
<div jsId="grid" class="grid" structure="gridLayout" dojoType="dojox.Grid" model="model" singleClickEdit="true" autoWidth="true"></div>
<div id="rowCount"></div>
<p>Note: This test requires MySql and PHP and works with the database table available in support/testtbl.sql.</p>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/yahooSearch.js
New file
0,0 → 1,143
// model that works with Yahoo Search API
dojo.declare("dojox.grid.data.yahooSearch", dojox.grid.data.dynamic,
function(inFields, inData, inSearchNode) {
this.rowsPerPage = 20;
this.searchNode = inSearchNode;
this.fieldNames = [];
for (var i=0, f; (f=inFields[i]); i++)
this.fieldNames.push(f.name);
}, {
// server send / receive
encodeParam: function(inName, inValue) {
return dojo.string.substitute('&${0}=${1}', [inName, inValue]);
},
getQuery: function() {
return dojo.byId(this.searchNode).value.replace(/ /g, '+');
},
getParams: function(inParams) {
var url = this.url;
url += '?appid=foo';
inParams = inParams || {};
inParams.output = 'json';
inParams.results = this.rowsPerPage;
inParams.query = this.getQuery();
for (var i in inParams)
if (inParams[i] != undefined)
url += this.encodeParam(i, inParams[i]);
return url;
},
send: function(inAsync, inParams, inOnReceive, inOnError) {
var
p = this.getParams(inParams),
d = dojo.xhrPost({
url: "support/proxy.php",
content: {url: p },
contentType: "application/x-www-form-urlencoded; charset=utf-8",
handleAs: 'json-comment-filtered',
sync: !inAsync
});
d.addCallbacks(dojo.hitch(this, "receive", inOnReceive, inOnError), dojo.hitch(this, "error", inOnError));
this.onSend(inParams);
return d;
},
receive: function(inOnReceive, inOnError, inData) {
try {
inData = inData.ResultSet;
inOnReceive(inData);
this.onReceive(inData);
} catch(e) {
if (inOnError)
inOnError(inData);
}
},
error: function(inOnError, inErr) {
var m = 'io error: ' + inErr.message;
alert(m);
if (inOnError)
inOnError(m);
},
fetchRowCount: function(inCallback) {
this.send(true, inCallback );
},
// request data
requestRows: function(inRowIndex, inCount) {
inRowIndex = (inRowIndex == undefined ? 0 : inRowIndex);
var params = {
start: inRowIndex + 1
}
this.send(true, params, dojo.hitch(this, this.processRows));
},
// server callbacks
processRows: function(inData) {
for (var i=0, l=inData.totalResultsReturned, s=inData.firstResultPosition; i<l; i++) {
this.setRow(inData.Result[i], s - 1 + i);
}
// yahoo says 1000 is max results to return
var c = Math.min(1000, inData.totalResultsAvailable);
if (this.count != c) {
this.setRowCount(c);
this.allChange();
this.onInitializeData(inData);
}
},
getDatum: function(inRowIndex, inColIndex) {
var row = this.getRow(inRowIndex);
var field = this.fields.get(inColIndex);
return (inColIndex == undefined ? row : (row ? row[field.name] : field.na));
},
// events
onInitializeData: function() {
},
onSend: function() {
},
onReceive: function() {
}
});
 
// report
modelChange = function() {
var n = dojo.byId('rowCount');
if (n)
n.innerHTML = dojo.string.substitute('about ${0} row(s)', [model.count]);
}
 
 
// some data formatters
getCellData = function(inCell, inRowIndex, inField) {
var m = inCell.grid.model;
return m.getDatum(inRowIndex, inField);
}
 
formatLink = function(inData, inRowIndex) {
if (!inData)
return '&nbsp;';
var text = getCellData(this, inRowIndex, this.extraField);
return dojo.string.substitute('<a target="_blank" href="${href}">${text}</a>', {href: inData, text: text });
};
 
formatImage = function(inData, inRowIndex) {
if (!inData)
return '&nbsp;';
var info = getCellData(this, inRowIndex, this.extraField);
var o = {
href: inData,
src: info.Url,
width: info.Width,
height: info.Height
}
return dojo.string.substitute('<a href="${href}" target="_blank"><img border=0 src="${src}" width="${width}" height="${height}"></a>', o);
};
 
formatDate = function(inDatum, inRowIndex) {
if (!inDatum)
return '&nbsp;';
var d = new Date(inDatum * 1000);
return dojo.string.substitute("${0}/${1}/${2}",[d.getMonth()+1, d.getDate(), d.getFullYear()])
};
 
formatDimensions = function(inData, inRowIndex) {
if (!inData)
return '&nbsp;';
var w = inData, h = getCellData(this, inRowIndex, this.extraField);
return w + ' x ' + h;
}
/trunk/api/js/dojo1.0/dojox/grid/tests/test_expand.html
New file
0,0 → 1,108
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test dojox.Grid Expand Rows</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../_grid/Grid.css";
body {
font-size: 0.9em;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.heading {
font-weight: bold;
padding-bottom: 0.25em;
}
.bigHello {
height: 110px;
line-height: 110px;
text-align: center;
font-weight: bold;
font-size: 30px;
}
#grid {
border: 1px solid #333;
height: 30em;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>
<script type="text/javascript">
// grid structure
// a grid view is a group of columns
// a special view providing selection feedback
var rowBar = {type: 'dojox.GridRowView', width: '20px' };
// inRow is an array of subRows. we hide the summary subRow except for every nth row
function onBeforeRow(inDataIndex, inRow) {
inRow[1].hidden = (!this.grid || !this.grid.expandedRows || !this.grid.expandedRows[inDataIndex]);
}
var view = {
onBeforeRow: onBeforeRow,
cells: [
[
{ name: 'Whatever', width: 4.5, get: getCheck, styles: 'text-align: center;' },
{name: 'Column 0'},
{name: 'Column 1'},
{name: 'Column 2'},
{name: 'Column 3'},
{name: 'Column 4'}
],
[ { name: 'Detail', colSpan: 6, get: getDetail } ]
]
};
// a grid structure is an array of views.
var structure = [ rowBar, view ];
// get can return data for each cell of the grid
function get(inRowIndex) {
return [this.index, inRowIndex].join(', ');
}
function getDetail(inRowIndex) {
if (this.grid.expandedRows[inRowIndex]) {
var n = (inRowIndex % 2);
switch (n) {
case 0:
return 'Hello World!';
default:
return '<div class="bigHello">Hello World!</div>';
}
} else
return '';
}
function toggle(inIndex, inShow) {
grid.expandedRows[inIndex] = inShow;
grid.updateRow(inIndex);
}
function getCheck(inRowIndex) {
if (!this.grid.expandedRows)
this.grid.expandedRows = [ ];
var image = (this.grid.expandedRows[inRowIndex] ? 'open.gif' : 'closed.gif');
var show = (this.grid.expandedRows[inRowIndex] ? 'false' : 'true')
return '<img src="images/' + image + '" onclick="toggle(' + inRowIndex + ', ' + show + ')" height="11" width="11">';
}
 
dojo.addOnLoad(function() {
window["grid"] = dijit.byId("grid");
});
</script>
</head>
<body>
<div class="heading">dojox.Grid Expand Row Example</div>
 
<div id="grid" dojoType="dojox.VirtualGrid" get="get" structure="structure" rowCount="100000" autoWidth="true"></div>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_grid_layout.html
New file
0,0 → 1,113
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.Grid in Layout Demo</title>
<style type="text/css">
@import "../_grid/Grid.css";
@import "../_grid/tundraGrid.css";
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
 
html, body{
width: 100%; /* make the body expand to fill the visible window */
height: 100%;
padding: 0 0 0 0;
margin: 0 0 0 0;
overflow: hidden;
}
.dijitSplitPane{
margin: 5px;
}
/* make grid containers overflow hidden */
body .dijitContentPane {
overflow: hidden;
}
#rightPane {
margin: 0;
}
</style>
 
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="parseOnLoad: true, isDebug: false"></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
 
<script type="text/javascript">
dojo.require("dijit.layout.LayoutContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.LinkPane");
dojo.require("dijit.layout.SplitContainer");
dojo.require("dijit.layout.TabContainer");
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
</script>
<script type="text/javascript" src="support/test_data.js"></script>
<script type="text/javascript">
// a grid view is a group of columns
var view1 = {
cells: [[
{name: 'Column 0'}, {name: 'Column 1'}, {name: 'Column 2'}, {name: 'Column 3', width: "150px"}, {name: 'Column 4'}
],[
{name: 'Column 5'}, {name: 'Column 6'}, {name: 'Column 7'}, {name: 'Column 8', field: 3, colSpan: 2}
]]
};
// a grid layout is an array of views.
var layout = [ view1 ];
var layout2 = [ {
cells: [[
{name: 'Alpha'}, {name: 'Beta'}, {name: 'Gamma'}, {name: 'Delta', width: "150px"}, {name: 'Epsilon'}, {name: 'Nexilon'}, {name: 'Zeta'}, {name: 'Eta', field: 0}, {name: 'Omega' }
]]
}
];
//
dojo.addOnLoad(function(){
dijit.byId("grid3").update();
});
</script>
</head>
<body class="tundra">
<div id="outer" dojoType="dijit.layout.LayoutContainer"
style="width: 100%; height: 100%;">
<div id="topBar" dojoType="dijit.layout.ContentPane" layoutAlign="top"
style="background-color: #274383; color: white;">
top bar
</div>
<div id="bottomBar" dojoType="dijit.layout.ContentPane" layoutAlign="bottom"
style="background-color: #274383; color: white;">
bottom bar
</div>
<div id="horizontalSplit" dojoType="dijit.layout.SplitContainer"
orientation="horizontal"
sizerWidth="5"
activeSizing="0"
layoutAlign="client"
>
<div id="leftPane" dojoType="dijit.layout.ContentPane"
sizeMin="20" sizeShare="20">
Left side
</div>
 
<div id="rightPane"
dojoType="dijit.layout.SplitContainer"
orientation="vertical"
sizerWidth="5"
activeSizing="0"
sizeMin="50" sizeShare="80"
>
<div id="mainTabContainer" dojoType="dijit.layout.TabContainer" sizeMin="20" sizeShare="70">
<div id="grid1" dojoType="dojox.Grid" model="model" title="Tab 1"></div>
<div id="grid2" dojoType="dojox.Grid" model="model" structure="layout2" title="Tab 2"></div>
</div>
<div id="bottomRight" dojoType="dijit.layout.ContentPane" sizeMin="20" sizeShare="30">
<div id="grid3" dojoType="dojox.Grid" model="model" structure="layout2"></div>
</div>
</div>
</div>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_grid_tooltip_menu.html
New file
0,0 → 1,162
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test dojox.Grid Basic</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../_grid/Grid.css";
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
body {
font-size: 0.9em;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.heading {
font-weight: bold;
padding-bottom: 0.25em;
}
#grid {
border: 1px solid #333;
width: 35em;
height: 30em;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dijit.Tooltip");
dojo.require("dijit.Menu");
dojo.require("dijit.ColorPalette");
dojo.require("dojo.parser");
</script>
<script type="text/javascript" src="support/test_data.js"></script>
<script type="text/javascript">
// a grid view is a group of columns
var view1 = {
cells: [[
{name: 'Column 0'}, {name: 'Column 1'}, {name: 'Column 2'}, {name: 'Column 3', width: "150px"}, {name: 'Column 4'}
],[
{name: 'Column 5'}, {name: 'Column 6'}, {name: 'Column 7'}, {name: 'Column 8', field: 3, colSpan: 2}
]]
};
// a grid layout is an array of views.
var layout = [ view1 ];
dojo.addOnLoad(function() {
window["grid"] = dijit.byId("grid");
var
showTooltip = function(e) {
if(gridTooltipEnabled){
var msg = "This is cell " + e.rowIndex + ", " + e.cellIndex;
dijit.showTooltip(msg, e.cellNode);
}
},
hideTooltip = function(e) {
dijit.hideTooltip(e.cellNode);
// FIXME: make sure that pesky tooltip doesn't reappear!
// would be nice if there were a way to hide tooltip without regard to aroundNode.
dijit._masterTT._onDeck=null;
}
// cell tooltip
dojo.connect(grid, "onCellMouseOver", showTooltip);
dojo.connect(grid, "onCellMouseOut", hideTooltip);
// header cell tooltip
dojo.connect(grid, "onHeaderCellMouseOver", showTooltip);
dojo.connect(grid, "onHeaderCellMouseOut", hideTooltip);
 
// grid menu
window["gridMenu"] = dijit.byId("gridMenu");
gridMenu.bindDomNode(grid.domNode);
// prevent grid methods from killing the context menu event by implementing our own handler
grid.onCellContextMenu = function(e) {
cellNode = e.cellNode;
};
grid.onHeaderContextMenu = function(e) {
cellNode = e.cellNode;
};
});
function reportCell() {
if(cellNode){
alert("Cell contents: " + cellNode.innerHTML);
cellNode = null;
}
}
gridTooltipEnabled = true;
function toggleTooltip(button){
gridTooltipEnabled = !gridTooltipEnabled;
button.value = gridTooltipEnabled ? "Disable Grid Tooltip" : "Enable Grid Tooltip";
}
gridMenuEnabled = true;
function toggleMenu(button){
gridMenuEnabled = !gridMenuEnabled;
button.value = gridMenuEnabled ? "Disable Grid Menu" : "Enable Grid Menu";
gridMenu[gridMenuEnabled ? "bindDomNode" : "unBindDomNode"](grid.domNode);
}
</script>
</head>
<body>
<div dojoType="dijit.Menu" id="gridMenu" style="display: none;">
<div dojoType="dijit.MenuItem" onClick="reportCell">See cell text...</div>
<div dojoType="dijit.MenuItem" disabled="true">Disabled Item</div>
<div dojoType="dijit.MenuSeparator"></div>
<div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCut"
onClick="alert('not actually cutting anything, just a test!')">Cut</div>
<div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCopy"
onClick="alert('not actually copying anything, just a test!')">Copy</div>
<div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconPaste"
onClick="alert('not actually pasting anything, just a test!')">Paste</div>
<div dojoType="dijit.MenuSeparator"></div>
</div>
<div dojoType="dijit.Menu" id="submenu1" contextMenuForWindow="true" style="display: none;">
<div dojoType="dijit.MenuItem" onClick="alert('Hello world');">Enabled Item</div>
<div dojoType="dijit.MenuItem" disabled="true">Disabled Item</div>
<div dojoType="dijit.MenuSeparator"></div>
<div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCut"
onClick="alert('not actually cutting anything, just a test!')">Cut</div>
<div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCopy"
onClick="alert('not actually copying anything, just a test!')">Copy</div>
<div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconPaste"
onClick="alert('not actually pasting anything, just a test!')">Paste</div>
<div dojoType="dijit.MenuSeparator"></div>
<div dojoType="dijit.PopupMenuItem">
<span>Enabled Submenu</span>
<div dojoType="dijit.Menu" id="submenu2">
<div dojoType="dijit.MenuItem" onClick="alert('Submenu 1!')">Submenu Item One</div>
<div dojoType="dijit.MenuItem" onClick="alert('Submenu 2!')">Submenu Item Two</div>
<div dojoType="dijit.PopupMenuItem">
<span>Deeper Submenu</span>
<div dojoType="dijit.Menu" id="submenu4"">
<div dojoType="dijit.MenuItem" onClick="alert('Sub-submenu 1!')">Sub-sub-menu Item One</div>
<div dojoType="dijit.MenuItem" onClick="alert('Sub-submenu 2!')">Sub-sub-menu Item Two</div>
</div>
</div>
</div>
</div>
<div dojoType="dijit.PopupMenuItem" disabled="true">
<span>Disabled Submenu</span>
<div dojoType="dijit.Menu" id="submenu3" style="display: none;">
<div dojoType="dijit.MenuItem" onClick="alert('Submenu 1!')">Submenu Item One</div>
<div dojoType="dijit.MenuItem" onClick="alert('Submenu 2!')">Submenu Item Two</div>
</div>
</div>
<div dojoType="dijit.PopupMenuItem">
<span>Different popup</span>
<div dojoType="dijit.ColorPalette"></div>
</div>
</div>
<div class="heading">dojox.Grid Basic Test</div>
<p>
<input type="button" onclick="toggleTooltip(this)" value="Disable Grid Tooltip">&nbsp;&nbsp;
<input type="button" onclick="toggleMenu(this)" value="Disable Grid Menu">&nbsp;&nbsp;<br />
Note: when the grid menu is disabled, the document's dijit context menu should be shown over the grid.
</p>
<div id="grid" dojoType="dojox.Grid" model="model" structure="layout"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_dojo_data.html
New file
0,0 → 1,139
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>dojox.Grid with Dojo.Data via binding</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../_grid/Grid.css";
body {
font-size: 1em;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
#grid {
width: 65em;
height: 25em;
padding: 1px;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojox.data.CsvStore");
/*dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");*/
</script>
<!-- Debugging -->
<script type="text/javascript" src="../_grid/lib.js"></script>
<script type="text/javascript" src="../_grid/drag.js"></script>
<script type="text/javascript" src="../_grid/scroller.js"></script>
<script type="text/javascript" src="../_grid/builder.js"></script>
<script type="text/javascript" src="../_grid/cell.js"></script>
<script type="text/javascript" src="../_grid/layout.js"></script>
<script type="text/javascript" src="../_grid/rows.js"></script>
<script type="text/javascript" src="../_grid/focus.js"></script>
<script type="text/javascript" src="../_grid/selection.js"></script>
<script type="text/javascript" src="../_grid/edit.js"></script>
<script type="text/javascript" src="../_grid/view.js"></script>
<script type="text/javascript" src="../_grid/views.js"></script>
<script type="text/javascript" src="../_grid/rowbar.js"></script>
<script type="text/javascript" src="../_grid/publicEvents.js"></script>
<script type="text/javascript" src="../VirtualGrid.js"></script>
<script type="text/javascript" src="../_data/fields.js"></script>
<script type="text/javascript" src="../_data/model.js"></script>
<script type="text/javascript" src="../_data/editors.js"></script>
<script type="text/javascript" src="../Grid.js"></script>
<script type="text/javascript">
dojox.grid.data.HashMixin = {
getFieldName: function(inIndex){
var n = this.fields.get(inIndex);
return (n)&&(n.name);
},
_get: function(inRowIndex, inColIndex){
var row = this.data[inRowIndex];
var n = this.getFieldName(inColIndex);
return (inColIndex == undefined || !n ? row : row[n]);
},
getDatum: function(inRowIndex, inColIndex){
return this._get(inRowIndex, inColIndex);
},
getRow: function(inRowIndex){
return this._get(inRowIndex);
},
setDatum: function(inDatum, inRowIndex, inColIndex){
var n = this.getFieldName(inColIndex);
if(n){
this.data[inRowIndex][n] = inDatum;
}
},
// get items based on field names
createComparator: function(inField, inIndex, inSubCompare){
return function(a, b){
var c = inField.name;
var ineq = inField.compare(a[c], b[c]);
return (ineq ? (inIndex > 0 ? ineq : -ineq) : (inSubCompare && inSubCompare(a, b)));
}
},
makeComparator: function(inIndices){
var result = null;
for(var i=inIndices.length-1, col; i>=0; i--){
col = Math.abs(inIndices[i]) - 1;
if(col >= 0){
result = this.createComparator(this.fields.get(col), inIndices[i], result);
}
}
return result;
}
}
 
dojo.declare("dojox.grid.data.Itemhash", dojox.grid.data.table, dojox.grid.data.HashMixin);
 
function getRow(inRowIndex){
return ' ' + inRowIndex;
}
var layout2 = [
{ type: 'dojox.GridRowView', width: '20px' },
{ cells: [[{ name: "Row", get: getRow, width: 5}]], noscroll: true},
{ cells: [[
{ name: "Title", field: 0 },
{ name: "Year", field: 1, width: 20 },
{ name: "Producer", field: 2, width: 'auto' }
]]}
];
updateGrid = function(inItems, inResult){
//var m = new dojox.grid.data.table(null, csvStore._dataArray);
var m = new dojox.grid.data.Itemhash();
var f = csvStore.getAttributes(inItems[0]);
var i = 0;
var fields = [];
dojo.forEach(f, function(a) {
fields.push({name: a});
});
m.fields.set(fields);
model = m;
dojo.forEach(inItems, function(item) {
var row = {};
dojo.forEach(fields, function(a) {
row[a.name] = csvStore.getValue(item, a.name)||"";
});
m.setRow(row, i++);
});
grid.setModel(m);
}
dojo.addOnLoad(function(){
csvStore = new dojox.data.CsvStore({url:"support/movies.csv"});
csvStore.fetch({ onComplete: updateGrid, onError: function() { console.log(arguments)}});
});
</script>
</head>
<body>
<h5>dojox.Grid using Dojo.Data stores via simple binding</h5>
<div jsId="grid" dojoType="dojox.Grid"
elasticView="2" structure="layout2"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_edit.html
New file
0,0 → 1,150
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test dojox.Grid Editing</title>
<style>
@import "../_grid/Grid.css";
body {
font-family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
}
.dojoxGrid-row-editing td {
background-color: #F4FFF4;
}
.dojoxGrid input, .dojoxGrid select, .dojoxGrid textarea {
margin: 0;
padding: 0;
border-style: none;
width: 100%;
font-size: 100%;
font-family: inherit;
}
.dojoxGrid input {
}
.dojoxGrid select {
}
.dojoxGrid textarea {
}
#controls {
padding: 6px 0;
}
#grid {
width: 850px;
height: 350px;
border: 1px solid silver;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
<!--<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>-->
<!-- Debugging -->
<script type="text/javascript" src="../_grid/lib.js"></script>
<script type="text/javascript" src="../_grid/drag.js"></script>
<script type="text/javascript" src="../_grid/scroller.js"></script>
<script type="text/javascript" src="../_grid/builder.js"></script>
<script type="text/javascript" src="../_grid/cell.js"></script>
<script type="text/javascript" src="../_grid/layout.js"></script>
<script type="text/javascript" src="../_grid/rows.js"></script>
<script type="text/javascript" src="../_grid/focus.js"></script>
<script type="text/javascript" src="../_grid/selection.js"></script>
<script type="text/javascript" src="../_grid/edit.js"></script>
<script type="text/javascript" src="../_grid/view.js"></script>
<script type="text/javascript" src="../_grid/views.js"></script>
<script type="text/javascript" src="../_grid/rowbar.js"></script>
<script type="text/javascript" src="../_grid/publicEvents.js"></script>
<script type="text/javascript" src="../VirtualGrid.js"></script>
<script type="text/javascript" src="../_data/fields.js"></script>
<script type="text/javascript" src="../_data/model.js"></script>
<script type="text/javascript" src="../_data/editors.js"></script>
<script type="text/javascript" src="../Grid.js"></script>
<script type="text/javascript">
// ==========================================================================
// Create a data model
// ==========================================================================
data = [
[ "normal", false, "new", 'But are not followed by two hexadecimal', 29.91, 10, false ],
[ "important", false, "new", 'Because a % sign always indicates', 9.33, -5, false ],
[ "important", false, "read", 'Signs can be selectively', 19.34, 0, true ],
[ "note", false, "read", 'However the reserved characters', 15.63, 0, true ],
[ "normal", false, "replied", 'It is therefore necessary', 24.22, 5.50, true ],
[ "important", false, "replied", 'To problems of corruption by', 9.12, -3, true ],
[ "note", false, "replied", 'Which would simply be awkward in', 12.15, -4, false ]
];
var rows = 10000;
for(var i=0, l=data.length; i<rows-l; i++){
data.push(data[i%l].slice(0));
}
model = new dojox.grid.data.Table(null, data);
// ==========================================================================
// Tie some UI to the data model
// ==========================================================================
model.observer(this);
modelChange = function() {
dojo.byId("rowCount").innerHTML = 'Row count: ' + model.count;
}
// ==========================================================================
// Custom formatter
// ==========================================================================
formatMoney = function(inDatum) {
return isNaN(inDatum) ? '...' : '$' + parseFloat(inDatum).toFixed(2);
}
// ==========================================================================
// Grid structure
// ==========================================================================
statusCell = { field: 2, name: 'Status', styles: 'text-align: center;', editor: dojox.grid.editors.Select, options: [ "new", "read", "replied" ] };
gridLayout = [{
type: 'dojox.GridRowView', width: '20px'
},{
defaultCell: { width: 8, editor: dojox.grid.editors.Input, styles: 'text-align: right;' },
rows: [[
{ name: 'Id', width: 3, get: function(inRowIndex) { return inRowIndex+1;} },
{ name: 'Priority', styles: 'text-align: center;', editor: dojox.grid.editors.Select, options: ["normal", "note", "important"]},
{ name: 'Mark', width: 3, styles: 'text-align: center;', editor: dojox.grid.editors.Bool },
statusCell,
{ name: 'Message', styles: '', width: '100%' },
{ name: 'Amount', formatter: formatMoney },
{ name: 'Amount', field: 4, formatter: formatMoney }
]]
},{
defaultCell: { width: 4, editor: dojox.grid.editors.Input, styles: 'text-align: right;' },
rows: [[
{ name: 'Mark', width: 3, field: 1, styles: 'text-align: center;', editor: dojox.grid.editors.Bool},
statusCell,
{ name: 'Amount', field: 4, formatter: formatMoney},
{ name: 'Detail', value: 'Detail'}
]]
}];
// ==========================================================================
// UI Action
// ==========================================================================
addRow = function(){
grid.addRow([ "normal", false, "new", 'Now is the time for all good men to come to the aid of their party.', 99.99, 9.99, false ]);
}
</script>
</head>
<body>
<h2>
dojox.Grid Basic Editing test
</h2>
<div id="controls">
<button onclick="grid.refresh()">Refresh</button>&nbsp;&nbsp;&nbsp;
<button onclick="grid.edit.focusEditor()">Focus Editor</button>
<button onclick="grid.focus.next()">Next Focus</button>&nbsp;&nbsp;&nbsp;
<button onclick="addRow()">Add Row</button>
<button onclick="grid.removeSelectedRows()">Remove</button>&nbsp;&nbsp;&nbsp;
<button onclick="grid.edit.apply()">Apply</button>
<button onclick="grid.edit.cancel()">Cancel</button>&nbsp;&nbsp;&nbsp;
<button onclick="grid.singleClickEdit = !grid.singleClickEdit">Toggle singleClickEdit</button>&nbsp;
</div>
<br />
<div id="grid" dojoType="dojox.Grid"
jsId="grid"
model="model" structure="gridLayout"></div>
<br />
<div id="rowCount"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_grid.html
New file
0,0 → 1,67
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test dojox.Grid Basic</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../_grid/Grid.css";
body {
font-size: 0.9em;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.heading {
font-weight: bold;
padding-bottom: 0.25em;
}
#grid {
border: 1px solid #333;
width: 35em;
height: 30em;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
<!--<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>-->
<!-- Debugging -->
<script type="text/javascript" src="../_grid/lib.js"></script>
<script type="text/javascript" src="../_grid/drag.js"></script>
<script type="text/javascript" src="../_grid/scroller.js"></script>
<script type="text/javascript" src="../_grid/builder.js"></script>
<script type="text/javascript" src="../_grid/cell.js"></script>
<script type="text/javascript" src="../_grid/layout.js"></script>
<script type="text/javascript" src="../_grid/rows.js"></script>
<script type="text/javascript" src="../_grid/focus.js"></script>
<script type="text/javascript" src="../_grid/selection.js"></script>
<script type="text/javascript" src="../_grid/edit.js"></script>
<script type="text/javascript" src="../_grid/view.js"></script>
<script type="text/javascript" src="../_grid/views.js"></script>
<script type="text/javascript" src="../_grid/rowbar.js"></script>
<script type="text/javascript" src="../_grid/publicEvents.js"></script>
<script type="text/javascript" src="../VirtualGrid.js"></script>
<script type="text/javascript" src="../_data/fields.js"></script>
<script type="text/javascript" src="../_data/model.js"></script>
<script type="text/javascript" src="../_data/editors.js"></script>
<script type="text/javascript" src="../Grid.js"></script>
<script type="text/javascript" src="support/test_data.js"></script>
<script type="text/javascript">
// a grid view is a group of columns
var view1 = {
cells: [[
{name: 'Column 0'}, {name: 'Column 1'}, {name: 'Column 2'}, {name: 'Column 3', width: "150px"}, {name: 'Column 4'}
],[
{name: 'Column 5'}, {name: 'Column 6'}, {name: 'Column 7'}, {name: 'Column 8', field: 3, colSpan: 2}
]]
};
// a grid layout is an array of views.
var layout = [ view1 ];
</script>
</head>
<body>
<div class="heading">dojox.Grid Basic Test</div>
<div id="grid" dojoType="dojox.Grid" model="model" structure="layout"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_grid_programmatic_layout.html
New file
0,0 → 1,75
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test dojox.Grid Programmatic Instantiation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../_grid/tundraGrid.css";
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
.heading {
font-weight: bold;
padding-bottom: 0.25em;
}
#grid {
width: 100%;
height: 100%;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug:false, debugAtAllCosts: false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>
<script type="text/javascript" src="support/test_data.js"></script>
<script type="text/javascript">
dojo.addOnLoad(function(){
// a grid view is a group of columns
var view1 = {
cells: [
[
{name: 'Column 0'},
{name: 'Column 1'},
{name: 'Column 2'},
{name: 'Column 3', width: "150px"},
{name: 'Column 4'}
],
[
{name: 'Column 5'},
{name: 'Column 6'},
{name: 'Column 7'},
{name: 'Column 8', field: 3, colSpan: 2}
]
]
};
// a grid layout is an array of views.
var layout = [ view1 ];
 
var grid = new dojox.Grid({
title: "tab 1",
id: "grid",
model: model,
structure: layout
});
dijit.byId("mainTabContainer").addChild(grid, 0);
grid.render();
});
</script>
</head>
<body class="tundra">
<div class="heading">dojox.Grid Programmatic Instantiation Test</div>
<div id="mainTabContainer" dojoType="dijit.layout.TabContainer"
style="height: 300px; width: 100%;">
<div dojoType="dijit.layout.ContentPane" title="Tab 2">
... stuff ...
</div>
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_styling.html
New file
0,0 → 1,132
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>dojox.Grid Styling Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../_grid/Grid.css";
body {
font-size: 0.9em;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.heading {
font-weight: bold;
padding-bottom: 0.25em;
}
#grid {
border: 1px solid #333;
width: 45em;
height: 30em;
}
#grid .dojoxGrid-row {
border: none;
}
#grid .dojoxGrid-row-table {
border-collapse: collapse;
}
#grid .dojoxGrid-cell {
border: none;
padding: 10px;
}
.selectedRow .dojoxGrid-cell {
background-color: #003366;
color: white;
}
.specialRow .dojoxGrid-cell {
background-color: dimgray;
}
.selectedRow.specialRow .dojoxGrid-cell {
text-decoration: line-through;
/* duplicate selection background-color so has precendence over specialRow background-color */
background-color: #003366;
}
/* in the yellow column, assign specific decoration for special rows that are selected */
.selectedRow.specialRow .yellowColumnData {
text-decoration: line-through underline;
}
.yellowColumn {
color: #006666;
}
.overRow .dojoxGrid-cell {
text-decoration: underline;
}
.greenColumn {
color: yellow;
background-color: #006666;
font-style: italic;
}
.yellowColumnData {
background-color: yellow;
text-decoration: underline;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>
<script type="text/javascript" src="support/test_data.js"></script>
<script type="text/javascript">
// grid structure
// a grid view is a group of columns
// a view without scrollbars
var leftView = {
noscroll: true,
cells: [[
{name: 'Column 0', width: 5, headerStyles: 'padding-bottom: 2px;', styles: 'border-bottom: 1px dashed #333; border-right: 1px dashed #333; padding: 6px;'},
{name: 'Column 1', width: 5, headerStyles: 'padding-bottom: 2px;', styles: 'text-align: right; border-bottom: 1px dashed #333; border-right: 1px dashed #333; padding: 6px;'}
]]};
var middleView = {
cells: [[
{name: 'Column 2'},
{name: 'Column 3', headerStyles: 'background-image: none; background-color: #003333;', classes: 'greenColumn'},
{name: 'Column 4', cellClasses: 'yellowColumnData', classes: 'yellowColumn', styles: 'text-align: center;' },
{name: 'Column 5', headerStyles: 'background-image: none; background-color: #003333;', classes: 'greenColumn'},
{name: 'Column 6'},
{name: 'Column 7'},
]]};
// a grid structure is an array of views.
var structure = [ leftView, middleView ];
function onStyleRow(inRow) {
with (inRow) {
var i = index % 10;
var special = (i > 2 && i < 6);
if (odd)
customStyles += ' color: orange;';
if (selected)
customClasses += ' selectedRow';
if (special)
customClasses += ' specialRow';
if (over)
customClasses += ' overRow';
if (!over && !selected)
dojox.Grid.prototype.onStyleRow.apply(this, arguments);
}
}
dojo.addOnLoad(function() {
window["grid"] = dijit.byId('grid');
});
</script>
</head>
<body>
<div class="heading">dojox.Grid Styling Example</div>
<div id="grid" dojoType="dojox.Grid" onStyleRow="onStyleRow" model="model" structure="structure"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_dojo_data_notification.html
New file
0,0 → 1,116
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>dojox.Grid with Dojo.Data via binding</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../_grid/tundraGrid.css";
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
#grid, #grid2, #grid3 {
width: 65em;
height: 25em;
padding: 1px;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug: true, debugAtAllCosts: false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.editors");
dojo.require("dojox.grid._data.model");
dojo.require("dojox.data.CsvStore");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.require("dojo.parser");
</script>
<script type="text/javascript">
function getRow(inRowIndex){
return ' ' + inRowIndex;
}
 
var iEditor = dojox.grid.editors.Input;
var layoutMovies = [
// view 0
{ type: 'dojox.GridRowView', width: '20px' },
// view 1
{ cells: [[{ name: "Row", get: getRow, width: 5}]], noscroll: true},
// view 2
{ cells: [[
{ field: "Title", editor: iEditor, width: 'auto' },
{ field: "Year", editor: iEditor, width: 5 },
{ field: "Producer", editor: iEditor, width: 20 }
]]}
];
 
var layoutCountries = [
// view 0
{ type: 'dojox.GridRowView', width: '20px' },
// view 1
{ cells: [[{ name: "Row", get: getRow, width: 5}]], noscroll: true},
// view 2
{ cells: [[
{ field: "name", name: "Name", width: 'auto' },
{ field: "type", name: "Type", editor: iEditor, width: 'auto' },
]]}
];
</script>
</head>
<body class="tundra">
<h1>dojox.Grid using Dojo.Data stores via simple binding</h1>
<!--
<br>
<span dojoType="dojox.data.CsvStore"
jsId="csvStore" url="support/movies.csv">
</span>
<span dojoType="dojox.grid.data.DojoData"
jsId="dataModel"
store="csvStore"
rowsPerPage="5"
query="{ Title: '*' }"
clientSort="true">
</span>
<div id="grid" dojoType="dojox.Grid" elasticView="2"
model="dataModel" structure="layoutMovies">
</div>
-->
<br>
<h3>Update some of the types</h3>
<button onclick="updateCountryTypes();">Go!</button>
<script>
function updateCountryTypes(){
// get everything starting with "A"
jsonStore.fetch({
query: { name: "A*" },
onComplete: function(items, result){
// change 'em!
dojo.forEach(items, function(item){
jsonStore.setValue(item, "type", "thinger");
// console.debug(item);
});
}
});
}
</script>
 
<span dojoType="dojo.data.ItemFileWriteStore"
jsId="jsonStore" url="../../../dijit/tests/_data/countries.json">
</span>
<span dojoType="dojox.grid.data.DojoData"
jsId="dataModel2"
rowsPerPage="20"
store="jsonStore"
clientSort="true"
query="{ name : '*' }">
</span>
<div id="grid2" dojoType="dojox.Grid" elasticView="2"
model="dataModel2" structure="layoutCountries">
</div>
 
<div id="grid3" dojoType="dojox.Grid" elasticView="2"
model="dataModel2" structure="layoutCountries">
</div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_grid_programmatic.html
New file
0,0 → 1,66
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test dojox.Grid Programmatic Instantiation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../_grid/tundraGrid.css";
.heading {
font-weight: bold;
padding-bottom: 0.25em;
}
#grid {
border: 1px solid #333;
width: 50em;
height: 30em;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug:false, debugAtAllCosts: false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>
<script type="text/javascript" src="support/test_data.js"></script>
<script type="text/javascript">
dojo.addOnLoad(function(){
// a grid view is a group of columns
var view1 = {
cells: [
[
{name: 'Column 0'},
{name: 'Column 1'},
{name: 'Column 2'},
{name: 'Column 3', width: "150px"},
{name: 'Column 4'}
],
[
{name: 'Column 5'},
{name: 'Column 6'},
{name: 'Column 7'},
{name: 'Column 8', field: 3, colSpan: 2}
]
]
};
// a grid layout is an array of views.
var layout = [ view1 ];
 
var grid = new dojox.Grid({
"id": "grid",
"model": model,
"structure": layout
});
dojo.byId("gridContainer").appendChild(grid.domNode);
grid.render();
});
</script>
</head>
<body class="tundra">
<div class="heading">dojox.Grid Programmatic Instantiation Test</div>
<div id="gridContainer"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/databaseModel.js
New file
0,0 → 1,337
if(!dojo._hasResource["dojox.grid.tests.databaseModel"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid.tests.databaseModel"] = true;
dojo.provide("dojox.grid.tests.databaseModel");
dojo.require("dojox.grid._data.model");
 
// Provides a sparse array that is also traversable inorder
// with basic Array:
// - iterating by index is slow for large sparse arrays
// - for...in iteration is in order of element creation
// maintains a secondary index for interating
// over sparse elements inorder
dojo.declare("dojox.grid.Sparse", null, {
constructor: function() {
this.clear();
},
clear: function() {
this.indices = [];
this.values = [];
},
length: function() {
return this.indices.length;
},
set: function(inIndex, inValue) {
for (var i=0,l=this.indices.length; i<l; i++) {
if (this.indices[i] >= inIndex)
break;
}
if (this.indices[i] != inIndex)
this.indices.splice(i, 0, inIndex);
this.values[inIndex] = inValue;
},
get: function(inIndex) {
return this.values[inIndex];
},
remove: function(inIndex) {
for (var i=0,l=this.indices.length; i<l; i++)
if (this.indices[i] == inIndex) {
this.indices.splice(i, 1);
break;
}
delete this.values[inIndex];
},
inorder: function(inFor) {
for (var i=0,l=this.indices.length, ix; i<l; i++) {
ix = this.indices[i];
if (inFor(this.values[ix], ix) === false)
break;
}
}
});
 
// sample custom model implementation that works with mysql server.
dojo.declare("dojox.grid.data.DbTable", dojox.grid.data.Dynamic, {
delayedInsertCommit: true,
constructor: function(inFields, inData, inServer, inDatabase, inTable) {
this.server = inServer;
this.database = inDatabase;
this.table = inTable;
this.stateNames = ['inflight', 'inserting', 'removing', 'error'];
this.clearStates();
this.clearSort();
},
clearData: function() {
this.cache = [ ];
this.clearStates();
this.inherited(arguments);
},
clearStates: function() {
this.states = {};
for (var i=0, s; (s=this.stateNames[i]); i++) {
delete this.states[s];
this.states[s] = new dojox.grid.Sparse();
}
},
// row state information
getState: function(inRowIndex) {
for (var i=0, r={}, s; (s=this.stateNames[i]); i++)
r[s] = this.states[s].get(inRowIndex);
return r;
},
setState: function(inRowIndex, inState, inValue) {
this.states[inState].set(inRowIndex, inValue||true);
},
clearState: function(inRowIndex, inState) {
if (arguments.length == 1) {
for (var i=0, s; (s=this.stateNames[i]); i++)
this.states[s].remove(inRowIndex);
} else {
for (var i=1, l=arguments.length, arg; (i<l) &&((arg=arguments[i])!=undefined); i++)
this.states[arg].remove(inRowIndex);
}
},
setStateForIndexes: function(inRowIndexes, inState, inValue) {
for (var i=inRowIndexes.length-1, k; (i>=0) && ((k=inRowIndexes[i])!=undefined); i--)
this.setState(k, inState, inValue);
},
clearStateForIndexes: function(inRowIndexes, inState) {
for (var i=inRowIndexes.length-1, k; (i>=0) && ((k=inRowIndexes[i])!=undefined); i--)
this.clearState(k, inState);
},
//$ Return boolean stating whether or not an operation is in progress that may change row indexing.
isAddRemoving: function() {
return Boolean(this.states['inserting'].length() || this.states['removing'].length());
},
isInflight: function() {
return Boolean(this.states['inflight'].length());
},
//$ Return boolean stating if the model is currently undergoing any type of edit.
isEditing: function() {
for (var i=0, r={}, s; (s=this.stateNames[i]); i++)
if (this.states[s].length())
return true;
},
//$ Return true if ok to modify the given row. Override as needed, using model editing state information.
canModify: function(inRowIndex) {
return !this.getState(inRowIndex).inflight && !(this.isInflight() && this.isAddRemoving());
},
// server send / receive
getSendParams: function(inParams) {
var p = {
database: this.database || '',
table: this.table || ''
}
return dojo.mixin(p, inParams || {});
},
send: function(inAsync, inParams, inCallbacks) {
//console.log('send', inParams.command);
var p = this.getSendParams(inParams);
var d = dojo.xhrPost({
url: this.server,
content: p,
handleAs: 'json-comment-filtered',
contentType: "application/x-www-form-urlencoded; charset=utf-8",
sync: !inAsync
});
d.addCallbacks(dojo.hitch(this, "receive", inCallbacks), dojo.hitch(this, "receiveError", inCallbacks));
return d;
},
_callback: function(cb, eb, data) {
try{ cb && cb(data); }
catch(e){ eb && eb(data, e); }
},
receive: function(inCallbacks, inData) {
inCallbacks && this._callback(inCallbacks.callback, inCallbacks.errback, inData);
},
receiveError: function(inCallbacks, inErr) {
this._callback(inCallbacks.errback, null, inErr)
},
encodeRow: function(inParams, inRow, inPrefix) {
for (var i=0, l=inRow.length; i < l; i++)
inParams['_' + (inPrefix ? inPrefix : '') + i] = (inRow[i] ? inRow[i] : '');
},
measure: function() {
this.send(true, { command: 'info' }, { callback: dojo.hitch(this, this.callbacks.info) });
},
fetchRowCount: function(inCallbacks) {
this.send(true, { command: 'count' }, inCallbacks);
},
// server commits
commitEdit: function(inOldData, inNewData, inRowIndex, inCallbacks) {
this.setState(inRowIndex, "inflight", true);
var params = {command: 'update'};
this.encodeRow(params, inOldData, 'o');
this.encodeRow(params, inNewData);
this.send(true, params, inCallbacks);
},
commitInsert: function(inRowIndex, inNewData, inCallbacks) {
this.setState(inRowIndex, "inflight", true);
var params = {command: 'insert'};
this.encodeRow(params, inNewData);
this.send(true, params, inCallbacks);
},
// NOTE: supported only in tables with pk
commitDelete: function(inRows, inCallbacks) {
var params = {
command: 'delete',
count: inRows.length
}
var pk = this.getPkIndex();
if (pk < 0)
return;
for (var i=0; i < inRows.length; i++) {
params['_' + i] = inRows[i][pk];
}
this.send(true, params, inCallbacks);
},
getUpdateCallbacks: function(inRowIndex) {
return {
callback: dojo.hitch(this, this.callbacks.update, inRowIndex),
errback: dojo.hitch(this, this.callbacks.updateError, inRowIndex)
};
},
// primary key from fields
getPkIndex: function() {
for (var i=0, l=this.fields.count(), f; (i<l) && (f=this.fields.get(i)); i++)
if (f.Key = 'PRI')
return i;
return -1;
},
// model implementations
update: function(inOldData, inNewData, inRowIndex) {
var cbs = this.getUpdateCallbacks(inRowIndex);
if (this.getState(inRowIndex).inserting)
this.commitInsert(inRowIndex, inNewData, cbs);
else
this.commitEdit(this.cache[inRowIndex] || inOldData, inNewData, inRowIndex, cbs);
// set push data immediately to model so reflectd while committing
this.setRow(inNewData, inRowIndex);
},
insert: function(inData, inRowIndex) {
this.setState(inRowIndex, 'inserting', true);
if (!this.delayedInsertCommit)
this.commitInsert(inRowIndex, inData, this.getUpdateCallbacks(inRowIndex));
return this.inherited(arguments);
},
remove: function(inRowIndexes) {
var rows = [];
for (var i=0, r=0, indexes=[]; (r=inRowIndexes[i]) !== undefined; i++)
if (!this.getState(r).inserting) {
rows.push(this.getRow(r));
indexes.push(r);
this.setState(r, 'removing');
}
var cbs = {
callback: dojo.hitch(this, this.callbacks.remove, indexes),
errback: dojo.hitch(this, this.callbacks.removeError, indexes)
};
this.commitDelete(rows, cbs);
dojox.grid.data.Dynamic.prototype.remove.apply(this, arguments);
},
cancelModifyRow: function(inRowIndex) {
if (this.isDelayedInsert(inRowIndex)) {
this.removeInsert(inRowIndex);
} else
this.finishUpdate(inRowIndex);
},
finishUpdate: function(inRowIndex, inData) {
this.clearState(inRowIndex);
var d = (inData&&inData[0]) || this.cache[inRowIndex];
if (d)
this.setRow(d, inRowIndex);
delete this.cache[inRowIndex];
},
isDelayedInsert: function(inRowIndex) {
return (this.delayedInsertCommit && this.getState(inRowIndex).inserting);
},
removeInsert: function(inRowIndex) {
this.clearState(inRowIndex);
dojox.grid.data.Dynamic.prototype.remove.call(this, [inRowIndex]);
},
// request data
requestRows: function(inRowIndex, inCount) {
var params = {
command: 'select',
orderby: this.sortField,
desc: (this.sortDesc ? "true" : ''),
offset: inRowIndex,
limit: inCount
}
this.send(true, params, {callback: dojo.hitch(this, this.callbacks.rows, inRowIndex)});
},
// sorting
canSort: function () {
return true;
},
setSort: function(inSortIndex) {
this.sortField = this.fields.get(Math.abs(inSortIndex) - 1).name || inSortIndex;
this.sortDesc = (inSortIndex < 0);
},
sort: function(inSortIndex) {
this.setSort(inSortIndex);
this.clearData();
},
clearSort: function(){
this.sortField = '';
this.sortDesc = false;
},
endModifyRow: function(inRowIndex){
var cache = this.cache[inRowIndex];
var m = false;
if(cache){
var data = this.getRow(inRowIndex);
if(!dojox.grid.arrayCompare(cache, data)){
m = true;
this.update(cache, data, inRowIndex);
}
}
if (!m)
this.cancelModifyRow(inRowIndex);
},
// server callbacks (called with this == model)
callbacks: {
update: function(inRowIndex, inData) {
console.log('received update', arguments);
if (inData.error)
this.updateError(inData)
else
this.finishUpdate(inRowIndex, inData);
},
updateError: function(inRowIndex) {
this.clearState(inRowIndex, 'inflight');
this.setState(inRowIndex, "error", "update failed: " + inRowIndex);
this.rowChange(this.getRow(inRowIndex), inRowIndex);
},
remove: function(inRowIndexes) {
this.clearStateForIndexes(inRowIndexes);
},
removeError: function(inRowIndexes) {
this.clearStateForIndexes(inRowIndexes);
alert('Removal error. Please refresh.');
},
rows: function(inRowIndex, inData) {
//this.beginUpdate();
for (var i=0, l=inData.length; i<l; i++)
this.setRow(inData[i], inRowIndex + i);
//this.endUpdate();
//this.allChange();
},
count: function(inRowCount) {
this.count = Number(inRowCount);
this.clearData();
},
info: function(inInfo) {
this.fields.clear();
for (var i=0, c; (c=inInfo.columns[i]); i++) {
c.name = c.Field;
this.fields.set(i, c);
}
this.table = inInfo.table;
this.database = inInfo.database;
this.notify("MetaData", arguments);
this.callbacks.count.call(this, inInfo.count);
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/tests/test_subgrid.html
New file
0,0 → 1,180
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>dojox.Grid Subgrid Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</meta>
<style>
@import "../../../dojo/resources/dojo.css";
@import "../_grid/tundraGrid.css";
body { font-size: 1.0em; }
#grid {
height: 400px;
border: 1px solid silver;
}
.text-oneline {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.text-scrolling {
height: 4em;
overflow: auto;
}
.text-scrolling {
width: 21.5em;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug:true, debugAtAllCosts: false, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>
<script type="text/javascript">
data = [
[ '3 stars', 'Averagia', 'Averagia', 8.99, 'An authentic experience defined by the intense layer of frothy, real facts. This combination package includes special T DISCS that work with your system to produce a perfectly serene experience. $8.99 per package. Please choose Regular (#NS1) or Decaffeinated (#NS4).' ],
[ '2 stars', 'Cheapy', 'Cheapy', 6.29, 'Power and subtlety intersect for an experience with real character. Imported from Europe just for you. 16 T DISCS per package. $6.29 per package. #NJ4.' ],
[ '4 stars', 'Luxuria', 'Luxuria', 6.49, 'A bold statement from the respected European brand Luxuria, topped with delicate zanthum. Imported exclusively for you. 18 T DISCS per package. $6.49 per package. #N42.</div>' ],
[ '5 stars', 'Ultimo', 'Ultimo', 4.59, "A rich sensation of delicious experience, brought to you by one of Europe's oldest brands. A pure indulgence. 8 T DISCS per package. $4.59 per package. #NJ0." ]
];
 
getDetailData = function(inRowIndex) {
var row = data[this.grid.dataRow % data.length];
switch (this.index) {
case 0:
return row[0]; //'<img src="images/sample/' + row[0] + '" width="109" height="75">';
case 1:
return (100000000 + this.grid.dataRow).toString().slice(1);
case 2:
return row[3];
case 3:
return row[1];
case 4:
return row[2];
case 5:
return row[4];
default:
return row[this.index];
}
}
getName = function(inRowIndex) {
var row = data[inRowIndex % data.length];
return row[2];
}
// Main grid structure
var gridCells = [
{ type: 'dojox.GridRowView', width: '20px' },
{
onBeforeRow: function(inDataIndex, inSubRows) {
inSubRows[1].hidden = !detailRows[inDataIndex];
},
cells: [[
{ name: '', width: 3, get: getCheck, styles: 'text-align: center;' }, { name: 'Name', get: getName, width: 40 },
], [
{ name: '', get: getDetail, colSpan: 2, styles: 'padding: 0; margin: 0;'}
]]
}
];
// html for the +/- cell
function getCheck(inRowIndex) {
var image = (detailRows[inRowIndex] ? 'open.gif' : 'closed.gif');
var show = (detailRows[inRowIndex] ? 'false' : 'true')
return '<img height="11" width="11" src="images/' + image + '" onclick="toggleDetail(' + inRowIndex + ', ' + show + ')">';
}
// provide html for the Detail cell in the master grid
function getDetail(inRowIndex) {
var cell = this;
// we can affect styles and content here, but we have to wait to access actual nodes
setTimeout(function() { buildSubgrid(inRowIndex, cell); }, 1);
// look for a subgrid
var subGrid = dijit.byId(makeSubgridId(inRowIndex));
var h = (subGrid ? subGrid.cacheHeight : "120") + "px";
// insert a placeholder
return '<div style="height: ' + h + '; background-color: white;"></div>';
}
// the Detail cell contains a subgrid which we set up below
var subGridCells = [{
noscroll: true,
cells: [
[{ name: "Rating", rowSpan: 2, width: 10, noresize: true, styles: 'text-align:center;' },
{ name: "Sku" },
{ name: "Price" },
{ name: "Vendor" },
{ name: "Name", width: "auto" }],
[{ name: "Description", colSpan: 4 }]
]}];
 
var subGridProps = {
structure: subGridCells,
rowCount: 1,
autoHeight: true,
autoRender: false,
"get": getDetailData
};
// identify subgrids by their row indices
function makeSubgridId(inRowIndex) {
return grid.widgetId + "_subGrid_" + inRowIndex;
}
// if a subgrid exists at inRowIndex, detach it from the DOM
function detachSubgrid(inRowIndex) {
var subGrid = dijit.byId(makeSubgridId(inRowIndex));
if (subGrid)
dojox.grid.removeNode(subGrid.domNode);
}
// render a subgrid into inCell at inRowIndex
function buildSubgrid(inRowIndex, inCell) {
var n = inCell.getNode(inRowIndex).firstChild;
var id = makeSubgridId(inRowIndex);
var subGrid = dijit.byId(id);
if (subGrid) {
n.appendChild(subGrid.domNode);
} else {
subGridProps.dataRow = inRowIndex;
subGridProps.widgetId = id;
subGrid = new dojox.VirtualGrid(subGridProps, n);
}
if (subGrid) {
subGrid.render();
subGrid.cacheHeight = subGrid.domNode.offsetHeight;
inCell.grid.rowHeightChanged(inRowIndex);
}
}
// destroy subgrid at inRowIndex
function destroySubgrid(inRowIndex) {
var subGrid = dijit.byId(makeSubgridId(inRowIndex));
if (subGrid) subGrid.destroy();
}
// when user clicks the +/-
detailRows = [];
function toggleDetail(inIndex, inShow) {
if (!inShow) detachSubgrid(inIndex);
detailRows[inIndex] = inShow;
grid.updateRow(inIndex);
}
dojo.addOnLoad(function() {
window["grid"] = dijit.byId("grid");
dojo.connect(grid, 'rowRemoved', destroySubgrid);
});
</script>
</head>
<body class="tundra">
<div style="font-weight: bold; padding-bottom: 0.25em;">dojox.Grid showing sub-grid.</div>
<div id="grid" dojoType="dojox.VirtualGrid" structure="gridCells" rowCount="100000" autoWidth="true"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/tests/test_keyboard.html
New file
0,0 → 1,91
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test dojox.Grid Basic</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css">
@import "../_grid/Grid.css";
body {
font-size: 0.9em;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.heading {
font-weight: bold;
padding-bottom: 0.25em;
}
#grid {
border: 1px solid #333;
width: 35em;
height: 30em;
}
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script>
<!--<script type="text/javascript">
dojo.require("dojox.grid.Grid");
dojo.require("dojox.grid._data.model");
dojo.require("dojo.parser");
</script>-->
<!-- Debugging -->
<script type="text/javascript" src="../_grid/lib.js"></script>
<script type="text/javascript" src="../_grid/drag.js"></script>
<script type="text/javascript" src="../_grid/scroller.js"></script>
<script type="text/javascript" src="../_grid/builder.js"></script>
<script type="text/javascript" src="../_grid/cell.js"></script>
<script type="text/javascript" src="../_grid/layout.js"></script>
<script type="text/javascript" src="../_grid/rows.js"></script>
<script type="text/javascript" src="../_grid/focus.js"></script>
<script type="text/javascript" src="../_grid/selection.js"></script>
<script type="text/javascript" src="../_grid/edit.js"></script>
<script type="text/javascript" src="../_grid/view.js"></script>
<script type="text/javascript" src="../_grid/views.js"></script>
<script type="text/javascript" src="../_grid/rowbar.js"></script>
<script type="text/javascript" src="../_grid/publicEvents.js"></script>
<script type="text/javascript" src="../VirtualGrid.js"></script>
<script type="text/javascript" src="../_data/fields.js"></script>
<script type="text/javascript" src="../_data/model.js"></script>
<script type="text/javascript" src="../_data/editors.js"></script>
<script type="text/javascript" src="../Grid.js"></script>
<script type="text/javascript" src="support/test_data.js"></script>
<script type="text/javascript">
// a grid view is a group of columns
var view1 = {
cells: [[
{name: 'Column 0'}, {name: 'Column 1'}, {name: 'Column 2'}, {name: 'Column 3', width: "150px"}, {name: 'Column 4'},
{name: 'Column 5'}, {name: 'Column 6'}, {name: 'Column 7', field: 0}, {name: 'Column 8'},
{name: 'Column 9'}, {name: 'Column 10'}, {name: 'Column 11', field: 0}, {name: 'Column 12', width: "150px"}, {name: 'Column 13'},
{name: 'Column 14'}, {name: 'Column 15'}, {name: 'Column 16', field: 0}, {name: 'Column 17'}
]]
};
// a grid layout is an array of views.
var layout = [ view1 ];
function keyDown(e) {
switch(e.keyCode){
case dojo.keys.LEFT_ARROW:
console.log('left arrow!');
break;
case dojo.keys.RIGHT_ARROW:
console.log('right arrow!');
break;
case dojo.keys.ENTER:
console.log('enter!');
break;
}
}
dojo.addOnLoad(function() {
window["grid"] = dijit.byId("grid");
dojo.connect(grid, "onKeyDown", keyDown);
});
</script>
</head>
<body>
<div class="heading">dojox.Grid Basic Test</div>
<div id="grid" dojoType="dojox.Grid" model="model" structure="layout"></div>
</body>
</html>
/trunk/api/js/dojo1.0/dojox/grid/_grid/edit.js
New file
0,0 → 1,213
if(!dojo._hasResource["dojox.grid._grid.edit"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._grid.edit"] = true;
dojo.provide("dojox.grid._grid.edit");
 
dojo.declare("dojox.grid.edit", null, {
// summary:
// Controls grid cell editing process. Owned by grid and used internally for editing.
constructor: function(inGrid){
this.grid = inGrid;
this.connections = [];
if(dojo.isIE){
this.connections.push(dojo.connect(document.body, "onfocus", dojo.hitch(this, "_boomerangFocus")));
}
},
info: {},
destroy: function(){
dojo.forEach(this.connections, function(c){
dojo.disconnect(c);
});
},
cellFocus: function(inCell, inRowIndex){
// summary:
// invoke editing when cell is focused
// inCell: cell object
// grid cell object
// inRowIndex: int
// grid row index
if(this.grid.singleClickEdit || this.isEditRow(inRowIndex)){
// if same row or quick editing, edit
this.setEditCell(inCell, inRowIndex);
}else{
// otherwise, apply any pending row edits
this.apply();
}
// if dynamic or static editing...
if(this.isEditing() || (inCell && (inCell.editor||0).alwaysOn)){
// let the editor focus itself as needed
this._focusEditor(inCell, inRowIndex);
}
},
rowClick: function(e){
if(this.isEditing() && !this.isEditRow(e.rowIndex)){
this.apply();
}
},
styleRow: function(inRow){
if(inRow.index == this.info.rowIndex){
inRow.customClasses += ' dojoxGrid-row-editing';
}
},
dispatchEvent: function(e){
var c = e.cell, ed = c && c.editor;
return ed && ed.dispatchEvent(e.dispatch, e);
},
// Editing
isEditing: function(){
// summary:
// indicates editing state of the grid.
// returns:
// true if grid is actively editing
return this.info.rowIndex !== undefined;
},
isEditCell: function(inRowIndex, inCellIndex){
// summary:
// indicates if the given cell is being edited.
// inRowIndex: int
// grid row index
// inCellIndex: int
// grid cell index
// returns:
// true if given cell is being edited
return (this.info.rowIndex === inRowIndex) && (this.info.cell.index == inCellIndex);
},
isEditRow: function(inRowIndex){
// summary:
// indicates if the given row is being edited.
// inRowIndex: int
// grid row index
// returns:
// true if given row is being edited
return this.info.rowIndex === inRowIndex;
},
setEditCell: function(inCell, inRowIndex){
// summary:
// set the given cell to be edited
// inRowIndex: int
// grid row index
// inCell: object
// grid cell object
if(!this.isEditCell(inRowIndex, inCell.index)){
this.start(inCell, inRowIndex, this.isEditRow(inRowIndex) || inCell.editor);
}
},
_focusEditor: function(inCell, inRowIndex){
dojox.grid.fire(inCell.editor, "focus", [inRowIndex]);
},
focusEditor: function(){
if(this.isEditing()){
this._focusEditor(this.info.cell, this.info.rowIndex);
}
},
// implement fix for focus boomerang effect on IE
_boomerangWindow: 500,
_shouldCatchBoomerang: function(){
return this._catchBoomerang > new Date().getTime();
},
_boomerangFocus: function(){
//console.log("_boomerangFocus");
if(this._shouldCatchBoomerang()){
// make sure we don't utterly lose focus
this.grid.focus.focusGrid();
// let the editor focus itself as needed
this.focusEditor();
// only catch once
this._catchBoomerang = 0;
}
},
_doCatchBoomerang: function(){
// give ourselves a few ms to boomerang IE focus effects
if(dojo.isIE){this._catchBoomerang = new Date().getTime() + this._boomerangWindow;}
},
// end boomerang fix API
start: function(inCell, inRowIndex, inEditing){
this.grid.beginUpdate();
this.editorApply();
if(this.isEditing() && !this.isEditRow(inRowIndex)){
this.applyRowEdit();
this.grid.updateRow(inRowIndex);
}
if(inEditing){
this.info = { cell: inCell, rowIndex: inRowIndex };
this.grid.doStartEdit(inCell, inRowIndex);
this.grid.updateRow(inRowIndex);
}else{
this.info = {};
}
this.grid.endUpdate();
// make sure we don't utterly lose focus
this.grid.focus.focusGrid();
// let the editor focus itself as needed
this._focusEditor(inCell, inRowIndex);
// give ourselves a few ms to boomerang IE focus effects
this._doCatchBoomerang();
},
_editorDo: function(inMethod){
var c = this.info.cell
//c && c.editor && c.editor[inMethod](c, this.info.rowIndex);
c && c.editor && c.editor[inMethod](this.info.rowIndex);
},
editorApply: function(){
this._editorDo("apply");
},
editorCancel: function(){
this._editorDo("cancel");
},
applyCellEdit: function(inValue, inCell, inRowIndex){
this.grid.doApplyCellEdit(inValue, inRowIndex, inCell.fieldIndex);
},
applyRowEdit: function(){
this.grid.doApplyEdit(this.info.rowIndex);
},
apply: function(){
// summary:
// apply a grid edit
if(this.isEditing()){
this.grid.beginUpdate();
this.editorApply();
this.applyRowEdit();
this.info = {};
this.grid.endUpdate();
this.grid.focus.focusGrid();
this._doCatchBoomerang();
}
},
cancel: function(){
// summary:
// cancel a grid edit
if(this.isEditing()){
this.grid.beginUpdate();
this.editorCancel();
this.info = {};
this.grid.endUpdate();
this.grid.focus.focusGrid();
this._doCatchBoomerang();
}
},
save: function(inRowIndex, inView){
// summary:
// save the grid editing state
// inRowIndex: int
// grid row index
// inView: object
// grid view
var c = this.info.cell;
if(this.isEditRow(inRowIndex) && (!inView || c.view==inView) && c.editor){
c.editor.save(c, this.info.rowIndex);
}
},
restore: function(inView, inRowIndex){
// summary:
// restores the grid editing state
// inRowIndex: int
// grid row index
// inView: object
// grid view
var c = this.info.cell;
if(this.isEditRow(inRowIndex) && c.view == inView && c.editor){
c.editor.restore(c, this.info.rowIndex);
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/scroller.js
New file
0,0 → 1,485
if(!dojo._hasResource['dojox.grid._grid.scroller']){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource['dojox.grid._grid.scroller'] = true;
dojo.provide('dojox.grid._grid.scroller');
 
dojo.declare('dojox.grid.scroller.base', null, {
// summary:
// virtual scrollbox, abstract class
// Content must in /rows/
// Rows are managed in contiguous sets called /pages/
// There are a fixed # of rows per page
// The minimum rendered unit is a page
constructor: function(){
this.pageHeights = [];
this.stack = [];
},
// specified
rowCount: 0, // total number of rows to manage
defaultRowHeight: 10, // default height of a row
keepRows: 100, // maximum number of rows that should exist at one time
contentNode: null, // node to contain pages
scrollboxNode: null, // node that controls scrolling
// calculated
defaultPageHeight: 0, // default height of a page
keepPages: 10, // maximum number of pages that should exists at one time
pageCount: 0,
windowHeight: 0,
firstVisibleRow: 0,
lastVisibleRow: 0,
// private
page: 0,
pageTop: 0,
// init
init: function(inRowCount, inKeepRows, inRowsPerPage){
switch(arguments.length){
case 3: this.rowsPerPage = inRowsPerPage;
case 2: this.keepRows = inKeepRows;
case 1: this.rowCount = inRowCount;
}
this.defaultPageHeight = this.defaultRowHeight * this.rowsPerPage;
//this.defaultPageHeight = this.defaultRowHeight * Math.min(this.rowsPerPage, this.rowCount);
this.pageCount = Math.ceil(this.rowCount / this.rowsPerPage);
this.keepPages = Math.max(Math.ceil(this.keepRows / this.rowsPerPage), 2);
this.invalidate();
if(this.scrollboxNode){
this.scrollboxNode.scrollTop = 0;
this.scroll(0);
this.scrollboxNode.onscroll = dojo.hitch(this, 'onscroll');
}
},
// updating
invalidate: function(){
this.invalidateNodes();
this.pageHeights = [];
this.height = (this.pageCount ? (this.pageCount - 1)* this.defaultPageHeight + this.calcLastPageHeight() : 0);
this.resize();
},
updateRowCount: function(inRowCount){
this.invalidateNodes();
this.rowCount = inRowCount;
// update page count, adjust document height
oldPageCount = this.pageCount;
this.pageCount = Math.ceil(this.rowCount / this.rowsPerPage);
if(this.pageCount < oldPageCount){
for(var i=oldPageCount-1; i>=this.pageCount; i--){
this.height -= this.getPageHeight(i);
delete this.pageHeights[i]
}
}else if(this.pageCount > oldPageCount){
this.height += this.defaultPageHeight * (this.pageCount - oldPageCount - 1) + this.calcLastPageHeight();
}
this.resize();
},
// abstract interface
pageExists: function(inPageIndex){
},
measurePage: function(inPageIndex){
},
positionPage: function(inPageIndex, inPos){
},
repositionPages: function(inPageIndex){
},
installPage: function(inPageIndex){
},
preparePage: function(inPageIndex, inPos, inReuseNode){
},
renderPage: function(inPageIndex){
},
removePage: function(inPageIndex){
},
pacify: function(inShouldPacify){
},
// pacification
pacifying: false,
pacifyTicks: 200,
setPacifying: function(inPacifying){
if(this.pacifying != inPacifying){
this.pacifying = inPacifying;
this.pacify(this.pacifying);
}
},
startPacify: function(){
this.startPacifyTicks = new Date().getTime();
},
doPacify: function(){
var result = (new Date().getTime() - this.startPacifyTicks) > this.pacifyTicks;
this.setPacifying(true);
this.startPacify();
return result;
},
endPacify: function(){
this.setPacifying(false);
},
// default sizing implementation
resize: function(){
if(this.scrollboxNode){
this.windowHeight = this.scrollboxNode.clientHeight;
}
dojox.grid.setStyleHeightPx(this.contentNode, this.height);
},
calcLastPageHeight: function(){
if(!this.pageCount){
return 0;
}
var lastPage = this.pageCount - 1;
var lastPageHeight = ((this.rowCount % this.rowsPerPage)||(this.rowsPerPage)) * this.defaultRowHeight;
this.pageHeights[lastPage] = lastPageHeight;
return lastPageHeight;
},
updateContentHeight: function(inDh){
this.height += inDh;
this.resize();
},
updatePageHeight: function(inPageIndex){
if(this.pageExists(inPageIndex)){
var oh = this.getPageHeight(inPageIndex);
var h = (this.measurePage(inPageIndex))||(oh);
this.pageHeights[inPageIndex] = h;
if((h)&&(oh != h)){
this.updateContentHeight(h - oh)
this.repositionPages(inPageIndex);
}
}
},
rowHeightChanged: function(inRowIndex){
this.updatePageHeight(Math.floor(inRowIndex / this.rowsPerPage));
},
// scroller core
invalidateNodes: function(){
while(this.stack.length){
this.destroyPage(this.popPage());
}
},
createPageNode: function(){
var p = document.createElement('div');
p.style.position = 'absolute';
//p.style.width = '100%';
p.style.left = '0';
return p;
},
getPageHeight: function(inPageIndex){
var ph = this.pageHeights[inPageIndex];
return (ph !== undefined ? ph : this.defaultPageHeight);
},
// FIXME: this is not a stack, it's a FIFO list
pushPage: function(inPageIndex){
return this.stack.push(inPageIndex);
},
popPage: function(){
return this.stack.shift();
},
findPage: function(inTop){
var i = 0, h = 0;
for(var ph = 0; i<this.pageCount; i++, h += ph){
ph = this.getPageHeight(i);
if(h + ph >= inTop){
break;
}
}
this.page = i;
this.pageTop = h;
},
buildPage: function(inPageIndex, inReuseNode, inPos){
this.preparePage(inPageIndex, inReuseNode);
this.positionPage(inPageIndex, inPos);
// order of operations is key below
this.installPage(inPageIndex);
this.renderPage(inPageIndex);
// order of operations is key above
this.pushPage(inPageIndex);
},
needPage: function(inPageIndex, inPos){
var h = this.getPageHeight(inPageIndex), oh = h;
if(!this.pageExists(inPageIndex)){
this.buildPage(inPageIndex, (this.keepPages)&&(this.stack.length >= this.keepPages), inPos);
h = this.measurePage(inPageIndex) || h;
this.pageHeights[inPageIndex] = h;
if(h && (oh != h)){
this.updateContentHeight(h - oh)
}
}else{
this.positionPage(inPageIndex, inPos);
}
return h;
},
onscroll: function(){
this.scroll(this.scrollboxNode.scrollTop);
},
scroll: function(inTop){
this.startPacify();
this.findPage(inTop);
var h = this.height;
var b = this.getScrollBottom(inTop);
for(var p=this.page, y=this.pageTop; (p<this.pageCount)&&((b<0)||(y<b)); p++){
y += this.needPage(p, y);
}
this.firstVisibleRow = this.getFirstVisibleRow(this.page, this.pageTop, inTop);
this.lastVisibleRow = this.getLastVisibleRow(p - 1, y, b);
// indicates some page size has been updated
if(h != this.height){
this.repositionPages(p-1);
}
this.endPacify();
},
getScrollBottom: function(inTop){
return (this.windowHeight >= 0 ? inTop + this.windowHeight : -1);
},
// events
processNodeEvent: function(e, inNode){
var t = e.target;
while(t && (t != inNode) && t.parentNode && (t.parentNode.parentNode != inNode)){
t = t.parentNode;
}
if(!t || !t.parentNode || (t.parentNode.parentNode != inNode)){
return false;
}
var page = t.parentNode;
e.topRowIndex = page.pageIndex * this.rowsPerPage;
e.rowIndex = e.topRowIndex + dojox.grid.indexInParent(t);
e.rowTarget = t;
return true;
},
processEvent: function(e){
return this.processNodeEvent(e, this.contentNode);
},
dummy: 0
});
 
dojo.declare('dojox.grid.scroller', dojox.grid.scroller.base, {
// summary:
// virtual scroller class, makes no assumption about shape of items being scrolled
constructor: function(){
this.pageNodes = [];
},
// virtual rendering interface
renderRow: function(inRowIndex, inPageNode){
},
removeRow: function(inRowIndex){
},
// page node operations
getDefaultNodes: function(){
return this.pageNodes;
},
getDefaultPageNode: function(inPageIndex){
return this.getDefaultNodes()[inPageIndex];
},
positionPageNode: function(inNode, inPos){
inNode.style.top = inPos + 'px';
},
getPageNodePosition: function(inNode){
return inNode.offsetTop;
},
repositionPageNodes: function(inPageIndex, inNodes){
var last = 0;
for(var i=0; i<this.stack.length; i++){
last = Math.max(this.stack[i], last);
}
//
var n = inNodes[inPageIndex];
var y = (n ? this.getPageNodePosition(n) + this.getPageHeight(inPageIndex) : 0);
//console.log('detected height change, repositioning from #%d (%d) @ %d ', inPageIndex + 1, last, y, this.pageHeights[0]);
//
for(var p=inPageIndex+1; p<=last; p++){
n = inNodes[p];
if(n){
//console.log('#%d @ %d', inPageIndex, y, this.getPageNodePosition(n));
if(this.getPageNodePosition(n) == y){
return;
}
//console.log('placing page %d at %d', p, y);
this.positionPage(p, y);
}
y += this.getPageHeight(p);
}
},
invalidatePageNode: function(inPageIndex, inNodes){
var p = inNodes[inPageIndex];
if(p){
delete inNodes[inPageIndex];
this.removePage(inPageIndex, p);
dojox.grid.cleanNode(p);
p.innerHTML = '';
}
return p;
},
preparePageNode: function(inPageIndex, inReusePageIndex, inNodes){
var p = (inReusePageIndex === null ? this.createPageNode() : this.invalidatePageNode(inReusePageIndex, inNodes));
p.pageIndex = inPageIndex;
p.id = 'page-' + inPageIndex;
inNodes[inPageIndex] = p;
},
// implementation for page manager
pageExists: function(inPageIndex){
return Boolean(this.getDefaultPageNode(inPageIndex));
},
measurePage: function(inPageIndex){
return this.getDefaultPageNode(inPageIndex).offsetHeight;
},
positionPage: function(inPageIndex, inPos){
this.positionPageNode(this.getDefaultPageNode(inPageIndex), inPos);
},
repositionPages: function(inPageIndex){
this.repositionPageNodes(inPageIndex, this.getDefaultNodes());
},
preparePage: function(inPageIndex, inReuseNode){
this.preparePageNode(inPageIndex, (inReuseNode ? this.popPage() : null), this.getDefaultNodes());
},
installPage: function(inPageIndex){
this.contentNode.appendChild(this.getDefaultPageNode(inPageIndex));
},
destroyPage: function(inPageIndex){
var p = this.invalidatePageNode(inPageIndex, this.getDefaultNodes());
dojox.grid.removeNode(p);
},
// rendering implementation
renderPage: function(inPageIndex){
var node = this.pageNodes[inPageIndex];
for(var i=0, j=inPageIndex*this.rowsPerPage; (i<this.rowsPerPage)&&(j<this.rowCount); i++, j++){
this.renderRow(j, node);
}
},
removePage: function(inPageIndex){
for(var i=0, j=inPageIndex*this.rowsPerPage; i<this.rowsPerPage; i++, j++){
this.removeRow(j);
}
},
// scroll control
getPageRow: function(inPage){
return inPage * this.rowsPerPage;
},
getLastPageRow: function(inPage){
return Math.min(this.rowCount, this.getPageRow(inPage + 1)) - 1;
},
getFirstVisibleRowNodes: function(inPage, inPageTop, inScrollTop, inNodes){
var row = this.getPageRow(inPage);
var rows = dojox.grid.divkids(inNodes[inPage]);
for(var i=0,l=rows.length; i<l && inPageTop<inScrollTop; i++, row++){
inPageTop += rows[i].offsetHeight;
}
return (row ? row - 1 : row);
},
getFirstVisibleRow: function(inPage, inPageTop, inScrollTop){
if(!this.pageExists(inPage)){
return 0;
}
return this.getFirstVisibleRowNodes(inPage, inPageTop, inScrollTop, this.getDefaultNodes());
},
getLastVisibleRowNodes: function(inPage, inBottom, inScrollBottom, inNodes){
var row = this.getLastPageRow(inPage);
var rows = dojox.grid.divkids(inNodes[inPage]);
for(var i=rows.length-1; i>=0 && inBottom>inScrollBottom; i--, row--){
inBottom -= rows[i].offsetHeight;
}
return row + 1;
},
getLastVisibleRow: function(inPage, inBottom, inScrollBottom){
if(!this.pageExists(inPage)){
return 0;
}
return this.getLastVisibleRowNodes(inPage, inBottom, inScrollBottom, this.getDefaultNodes());
},
findTopRowForNodes: function(inScrollTop, inNodes){
var rows = dojox.grid.divkids(inNodes[this.page]);
for(var i=0,l=rows.length,t=this.pageTop,h; i<l; i++){
h = rows[i].offsetHeight;
t += h;
if(t >= inScrollTop){
this.offset = h - (t - inScrollTop);
return i + this.page * this.rowsPerPage;
}
}
return -1;
},
findScrollTopForNodes: function(inRow, inNodes){
var rowPage = Math.floor(inRow / this.rowsPerPage);
var t = 0;
for(var i=0; i<rowPage; i++){
t += this.getPageHeight(i);
}
this.pageTop = t;
this.needPage(rowPage, this.pageTop);
var rows = dojox.grid.divkids(inNodes[rowPage]);
var r = inRow - this.rowsPerPage * rowPage;
for(var i=0,l=rows.length; i<l && i<r; i++){
t += rows[i].offsetHeight;
}
return t;
},
findTopRow: function(inScrollTop){
return this.findTopRowForNodes(inScrollTop, this.getDefaultNodes());
},
findScrollTop: function(inRow){
return this.findScrollTopForNodes(inRow, this.getDefaultNodes());
},
dummy: 0
});
 
dojo.declare('dojox.grid.scroller.columns', dojox.grid.scroller, {
// summary:
// Virtual scroller class that scrolls list of columns. Owned by grid and used internally
// for virtual scrolling.
constructor: function(inContentNodes){
this.setContentNodes(inContentNodes);
},
// nodes
setContentNodes: function(inNodes){
this.contentNodes = inNodes;
this.colCount = (this.contentNodes ? this.contentNodes.length : 0);
this.pageNodes = [];
for(var i=0; i<this.colCount; i++){
this.pageNodes[i] = [];
}
},
getDefaultNodes: function(){
return this.pageNodes[0] || [];
},
scroll: function(inTop) {
if(this.colCount){
dojox.grid.scroller.prototype.scroll.call(this, inTop);
}
},
// resize
resize: function(){
if(this.scrollboxNode){
this.windowHeight = this.scrollboxNode.clientHeight;
}
for(var i=0; i<this.colCount; i++){
dojox.grid.setStyleHeightPx(this.contentNodes[i], this.height);
}
},
// implementation for page manager
positionPage: function(inPageIndex, inPos){
for(var i=0; i<this.colCount; i++){
this.positionPageNode(this.pageNodes[i][inPageIndex], inPos);
}
},
preparePage: function(inPageIndex, inReuseNode){
var p = (inReuseNode ? this.popPage() : null);
for(var i=0; i<this.colCount; i++){
this.preparePageNode(inPageIndex, p, this.pageNodes[i]);
}
},
installPage: function(inPageIndex){
for(var i=0; i<this.colCount; i++){
this.contentNodes[i].appendChild(this.pageNodes[i][inPageIndex]);
}
},
destroyPage: function(inPageIndex){
for(var i=0; i<this.colCount; i++){
dojox.grid.removeNode(this.invalidatePageNode(inPageIndex, this.pageNodes[i]));
}
},
// rendering implementation
renderPage: function(inPageIndex){
var nodes = [];
for(var i=0; i<this.colCount; i++){
nodes[i] = this.pageNodes[i][inPageIndex];
}
//this.renderRows(inPageIndex*this.rowsPerPage, this.rowsPerPage, nodes);
for(var i=0, j=inPageIndex*this.rowsPerPage; (i<this.rowsPerPage)&&(j<this.rowCount); i++, j++){
this.renderRow(j, nodes);
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/selection.js
New file
0,0 → 1,185
if(!dojo._hasResource['dojox.grid._grid.selection']){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource['dojox.grid._grid.selection'] = true;
dojo.provide('dojox.grid._grid.selection');
 
dojo.declare("dojox.grid.selection", null, {
// summary:
// Manages row selection for grid. Owned by grid and used internally
// for selection. Override to implement custom selection.
constructor: function(inGrid){
this.grid = inGrid;
this.selected = [];
},
multiSelect: true,
selected: null,
updating: 0,
selectedIndex: -1,
onCanSelect: function(inIndex){
return this.grid.onCanSelect(inIndex);
},
onCanDeselect: function(inIndex){
return this.grid.onCanDeselect(inIndex);
},
onSelected: function(inIndex){
return this.grid.onSelected(inIndex);
},
onDeselected: function(inIndex){
return this.grid.onDeselected(inIndex);
},
//onSetSelected: function(inIndex, inSelect) { };
onChanging: function(){
},
onChanged: function(){
return this.grid.onSelectionChanged();
},
isSelected: function(inIndex){
return this.selected[inIndex];
},
getFirstSelected: function(){
for(var i=0, l=this.selected.length; i<l; i++){
if(this.selected[i]){
return i;
}
}
return -1;
},
getNextSelected: function(inPrev){
for(var i=inPrev+1, l=this.selected.length; i<l; i++){
if(this.selected[i]){
return i;
}
}
return -1;
},
getSelected: function(){
var result = [];
for(var i=0, l=this.selected.length; i<l; i++){
if(this.selected[i]){
result.push(i);
}
}
return result;
},
getSelectedCount: function(){
var c = 0;
for(var i=0; i<this.selected.length; i++){
if(this.selected[i]){
c++;
}
}
return c;
},
beginUpdate: function(){
if(this.updating == 0){
this.onChanging();
}
this.updating++;
},
endUpdate: function(){
this.updating--;
if(this.updating == 0){
this.onChanged();
}
},
select: function(inIndex){
this.unselectAll(inIndex);
this.addToSelection(inIndex);
},
addToSelection: function(inIndex){
inIndex = Number(inIndex);
if(this.selected[inIndex]){
this.selectedIndex = inIndex;
}else{
if(this.onCanSelect(inIndex) !== false){
this.selectedIndex = inIndex;
this.beginUpdate();
this.selected[inIndex] = true;
this.grid.onSelected(inIndex);
//this.onSelected(inIndex);
//this.onSetSelected(inIndex, true);
this.endUpdate();
}
}
},
deselect: function(inIndex){
inIndex = Number(inIndex);
if(this.selectedIndex == inIndex){
this.selectedIndex = -1;
}
if(this.selected[inIndex]){
if(this.onCanDeselect(inIndex) === false){
return;
}
this.beginUpdate();
delete this.selected[inIndex];
this.grid.onDeselected(inIndex);
//this.onDeselected(inIndex);
//this.onSetSelected(inIndex, false);
this.endUpdate();
}
},
setSelected: function(inIndex, inSelect){
this[(inSelect ? 'addToSelection' : 'deselect')](inIndex);
},
toggleSelect: function(inIndex){
this.setSelected(inIndex, !this.selected[inIndex])
},
insert: function(inIndex){
this.selected.splice(inIndex, 0, false);
if(this.selectedIndex >= inIndex){
this.selectedIndex++;
}
},
remove: function(inIndex){
this.selected.splice(inIndex, 1);
if(this.selectedIndex >= inIndex){
this.selectedIndex--;
}
},
unselectAll: function(inExcept){
for(var i in this.selected){
if((i!=inExcept)&&(this.selected[i]===true)){
this.deselect(i);
}
}
},
shiftSelect: function(inFrom, inTo){
var s = (inFrom >= 0 ? inFrom : inTo), e = inTo;
if(s > e){
e = s;
s = inTo;
}
for(var i=s; i<=e; i++){
this.addToSelection(i);
}
},
clickSelect: function(inIndex, inCtrlKey, inShiftKey){
this.beginUpdate();
if(!this.multiSelect){
this.select(inIndex);
}else{
var lastSelected = this.selectedIndex;
if(!inCtrlKey){
this.unselectAll(inIndex);
}
if(inShiftKey){
this.shiftSelect(lastSelected, inIndex);
}else if(inCtrlKey){
this.toggleSelect(inIndex);
}else{
this.addToSelection(inIndex)
}
}
this.endUpdate();
},
clickSelectEvent: function(e){
this.clickSelect(e.rowIndex, e.ctrlKey, e.shiftKey);
},
clear: function(){
this.beginUpdate();
this.unselectAll();
this.endUpdate();
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/builder.js
New file
0,0 → 1,433
if(!dojo._hasResource["dojox.grid._grid.builder"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._grid.builder"] = true;
dojo.provide("dojox.grid._grid.builder");
dojo.require("dojox.grid._grid.drag");
 
dojo.declare("dojox.grid.Builder", null, {
// summary:
// Base class to produce html for grid content.
// Also provide event decoration, providing grid related information inside the event object
// passed to grid events.
constructor: function(inView){
this.view = inView;
this.grid = inView.grid;
},
view: null,
// boilerplate HTML
_table: '<table class="dojoxGrid-row-table" border="0" cellspacing="0" cellpadding="0" role="wairole:presentation">',
// generate starting tags for a cell
generateCellMarkup: function(inCell, inMoreStyles, inMoreClasses, isHeader){
var result = [], html;
if (isHeader){
html = [ '<th tabIndex="-1" role="wairole:columnheader"' ];
}else{
html = [ '<td tabIndex="-1" role="wairole:gridcell"' ];
}
inCell.colSpan && html.push(' colspan="', inCell.colSpan, '"');
inCell.rowSpan && html.push(' rowspan="', inCell.rowSpan, '"');
html.push(' class="dojoxGrid-cell ');
inCell.classes && html.push(inCell.classes, ' ');
inMoreClasses && html.push(inMoreClasses, ' ');
// result[0] => td opener, style
result.push(html.join(''));
// SLOT: result[1] => td classes
result.push('');
html = ['" idx="', inCell.index, '" style="'];
html.push(inCell.styles, inMoreStyles||'');
inCell.unitWidth && html.push('width:', inCell.unitWidth, ';');
// result[2] => markup
result.push(html.join(''));
// SLOT: result[3] => td style
result.push('');
html = [ '"' ];
inCell.attrs && html.push(" ", inCell.attrs);
html.push('>');
// result[4] => td postfix
result.push(html.join(''));
// SLOT: result[5] => content
result.push('');
// result[6] => td closes
result.push('</td>');
return result;
},
// cell finding
isCellNode: function(inNode){
return Boolean(inNode && inNode.getAttribute && inNode.getAttribute("idx"));
},
getCellNodeIndex: function(inCellNode){
return inCellNode ? Number(inCellNode.getAttribute("idx")) : -1;
},
getCellNode: function(inRowNode, inCellIndex){
for(var i=0, row; row=dojox.grid.getTr(inRowNode.firstChild, i); i++){
for(var j=0, cell; cell=row.cells[j]; j++){
if(this.getCellNodeIndex(cell) == inCellIndex){
return cell;
}
}
}
},
findCellTarget: function(inSourceNode, inTopNode){
var n = inSourceNode;
while(n && !this.isCellNode(n) && (n!=inTopNode)){
n = n.parentNode;
}
return n!=inTopNode ? n : null
},
// event decoration
baseDecorateEvent: function(e){
e.dispatch = 'do' + e.type;
e.grid = this.grid;
e.sourceView = this.view;
e.cellNode = this.findCellTarget(e.target, e.rowNode);
e.cellIndex = this.getCellNodeIndex(e.cellNode);
e.cell = (e.cellIndex >= 0 ? this.grid.getCell(e.cellIndex) : null);
},
// event dispatch
findTarget: function(inSource, inTag){
var n = inSource;
while(n && !(inTag in n) && (n!=this.domNode)){
n = n.parentNode;
}
return (n != this.domNode) ? n : null;
},
findRowTarget: function(inSource){
return this.findTarget(inSource, dojox.grid.rowIndexTag);
},
isIntraNodeEvent: function(e){
try{
return (e.cellNode && e.relatedTarget && dojo.isDescendant(e.relatedTarget, e.cellNode));
}catch(x){
// e.relatedTarget has permission problem in FF if it's an input: https://bugzilla.mozilla.org/show_bug.cgi?id=208427
return false;
}
},
isIntraRowEvent: function(e){
try{
var row = e.relatedTarget && this.findRowTarget(e.relatedTarget);
return !row && (e.rowIndex==-1) || row && (e.rowIndex==row.gridRowIndex);
}catch(x){
// e.relatedTarget on INPUT has permission problem in FF: https://bugzilla.mozilla.org/show_bug.cgi?id=208427
return false;
}
},
dispatchEvent: function(e){
if(e.dispatch in this){
return this[e.dispatch](e);
}
},
// dispatched event handlers
domouseover: function(e){
if(e.cellNode && (e.cellNode!=this.lastOverCellNode)){
this.lastOverCellNode = e.cellNode;
this.grid.onMouseOver(e);
}
this.grid.onMouseOverRow(e);
},
domouseout: function(e){
if(e.cellNode && (e.cellNode==this.lastOverCellNode) && !this.isIntraNodeEvent(e, this.lastOverCellNode)){
this.lastOverCellNode = null;
this.grid.onMouseOut(e);
if(!this.isIntraRowEvent(e)){
this.grid.onMouseOutRow(e);
}
}
}
});
 
dojo.declare("dojox.grid.contentBuilder", dojox.grid.Builder, {
// summary:
// Produces html for grid data content. Owned by grid and used internally
// for rendering data. Override to implement custom rendering.
update: function(){
this.prepareHtml();
},
// cache html for rendering data rows
prepareHtml: function(){
var defaultGet=this.grid.get, rows=this.view.structure.rows;
for(var j=0, row; (row=rows[j]); j++){
for(var i=0, cell; (cell=row[i]); i++){
cell.get = cell.get || (cell.value == undefined) && defaultGet;
cell.markup = this.generateCellMarkup(cell, cell.cellStyles, cell.cellClasses, false);
}
}
},
// time critical: generate html using cache and data source
generateHtml: function(inDataIndex, inRowIndex){
var
html = [ this._table ],
v = this.view,
obr = v.onBeforeRow,
rows = v.structure.rows;
obr && obr(inRowIndex, rows);
for(var j=0, row; (row=rows[j]); j++){
if(row.hidden || row.header){
continue;
}
html.push(!row.invisible ? '<tr>' : '<tr class="dojoxGrid-invisible">');
for(var i=0, cell, m, cc, cs; (cell=row[i]); i++){
m = cell.markup, cc = cell.customClasses = [], cs = cell.customStyles = [];
// content (format can fill in cc and cs as side-effects)
m[5] = cell.format(inDataIndex);
// classes
m[1] = cc.join(' ');
// styles
m[3] = cs.join(';');
// in-place concat
html.push.apply(html, m);
}
html.push('</tr>');
}
html.push('</table>');
return html.join('');
},
decorateEvent: function(e){
e.rowNode = this.findRowTarget(e.target);
if(!e.rowNode){return false};
e.rowIndex = e.rowNode[dojox.grid.rowIndexTag];
this.baseDecorateEvent(e);
e.cell = this.grid.getCell(e.cellIndex);
return true;
}
});
 
dojo.declare("dojox.grid.headerBuilder", dojox.grid.Builder, {
// summary:
// Produces html for grid header content. Owned by grid and used internally
// for rendering data. Override to implement custom rendering.
bogusClickTime: 0,
overResizeWidth: 4,
minColWidth: 1,
_table: '<table class="dojoxGrid-row-table" border="0" cellspacing="0" cellpadding="0" role="wairole:presentation"',
update: function(){
this.tableMap = new dojox.grid.tableMap(this.view.structure.rows);
},
generateHtml: function(inGetValue, inValue){
var html = [this._table], rows = this.view.structure.rows;
// render header with appropriate width, if possible so that views with flex columns are correct height
if(this.view.viewWidth){
html.push([' style="width:', this.view.viewWidth, ';"'].join(''));
}
html.push('>');
dojox.grid.fire(this.view, "onBeforeRow", [-1, rows]);
for(var j=0, row; (row=rows[j]); j++){
if(row.hidden){
continue;
}
html.push(!row.invisible ? '<tr>' : '<tr class="dojoxGrid-invisible">');
for(var i=0, cell, markup; (cell=row[i]); i++){
cell.customClasses = [];
cell.customStyles = [];
markup = this.generateCellMarkup(cell, cell.headerStyles, cell.headerClasses, true);
// content
markup[5] = (inValue != undefined ? inValue : inGetValue(cell));
// styles
markup[3] = cell.customStyles.join(';');
// classes
markup[1] = cell.customClasses.join(' '); //(cell.customClasses ? ' ' + cell.customClasses : '');
html.push(markup.join(''));
}
html.push('</tr>');
}
html.push('</table>');
return html.join('');
},
// event helpers
getCellX: function(e){
var x = e.layerX;
if(dojo.isMoz){
var n = dojox.grid.ascendDom(e.target, dojox.grid.makeNotTagName("th"));
x -= (n && n.offsetLeft) || 0;
//x -= getProp(ascendDom(e.target, mkNotTagName("td")), "offsetLeft") || 0;
}
var n = dojox.grid.ascendDom(e.target, function(){
if(!n || n == e.cellNode){
return false;
}
// Mozilla 1.8 (FF 1.5) has a bug that makes offsetLeft = -parent border width
// when parent has border, overflow: hidden, and is positioned
// handle this problem here ... not a general solution!
x += (n.offsetLeft < 0 ? 0 : n.offsetLeft);
return true;
});
return x;
},
// event decoration
decorateEvent: function(e){
this.baseDecorateEvent(e);
e.rowIndex = -1;
e.cellX = this.getCellX(e);
return true;
},
// event handlers
// resizing
prepareLeftResize: function(e){
var i = dojox.grid.getTdIndex(e.cellNode);
e.cellNode = (i ? e.cellNode.parentNode.cells[i-1] : null);
e.cellIndex = (e.cellNode ? this.getCellNodeIndex(e.cellNode) : -1);
return Boolean(e.cellNode);
},
canResize: function(e){
if(!e.cellNode || e.cellNode.colSpan > 1){
return false;
}
var cell = this.grid.getCell(e.cellIndex);
return !cell.noresize && !cell.isFlex();
},
overLeftResizeArea: function(e){
return (e.cellIndex>0) && (e.cellX < this.overResizeWidth) && this.prepareLeftResize(e);
},
overRightResizeArea: function(e){
return e.cellNode && (e.cellX >= e.cellNode.offsetWidth - this.overResizeWidth);
},
domousemove: function(e){
//console.log(e.cellIndex, e.cellX, e.cellNode.offsetWidth);
var c = (this.overRightResizeArea(e) ? 'e-resize' : (this.overLeftResizeArea(e) ? 'w-resize' : ''));
if(c && !this.canResize(e)){
c = 'not-allowed';
}
e.sourceView.headerNode.style.cursor = c || ''; //'default';
},
domousedown: function(e){
if(!dojox.grid.drag.dragging){
if((this.overRightResizeArea(e) || this.overLeftResizeArea(e)) && this.canResize(e)){
this.beginColumnResize(e);
}
//else{
// this.beginMoveColumn(e);
//}
}
},
doclick: function(e) {
if (new Date().getTime() < this.bogusClickTime) {
dojo.stopEvent(e);
return true;
}
},
// column resizing
beginColumnResize: function(e){
dojo.stopEvent(e);
var spanners = [], nodes = this.tableMap.findOverlappingNodes(e.cellNode);
for(var i=0, cell; (cell=nodes[i]); i++){
spanners.push({ node: cell, index: this.getCellNodeIndex(cell), width: cell.offsetWidth });
//console.log("spanner: " + this.getCellNodeIndex(cell));
}
var drag = {
view: e.sourceView,
node: e.cellNode,
index: e.cellIndex,
w: e.cellNode.clientWidth,
spanners: spanners
};
//console.log(drag.index, drag.w);
dojox.grid.drag.start(e.cellNode, dojo.hitch(this, 'doResizeColumn', drag), dojo.hitch(this, 'endResizeColumn', drag), e);
},
doResizeColumn: function(inDrag, inEvent){
var w = inDrag.w + inEvent.deltaX;
if(w >= this.minColWidth){
for(var i=0, s, sw; (s=inDrag.spanners[i]); i++){
sw = s.width + inEvent.deltaX;
s.node.style.width = sw + 'px';
inDrag.view.setColWidth(s.index, sw);
//console.log('setColWidth', '#' + s.index, sw + 'px');
}
inDrag.node.style.width = w + 'px';
inDrag.view.setColWidth(inDrag.index, w);
}
if(inDrag.view.flexCells && !inDrag.view.testFlexCells()){
var t = dojox.grid.findTable(inDrag.node);
t && (t.style.width = '');
}
},
endResizeColumn: function(inDrag){
this.bogusClickTime = new Date().getTime() + 30;
setTimeout(dojo.hitch(inDrag.view, "update"), 50);
}
});
 
dojo.declare("dojox.grid.tableMap", null, {
// summary:
// Maps an html table into a structure parsable for information about cell row and col spanning.
// Used by headerBuilder
constructor: function(inRows){
this.mapRows(inRows);
},
map: null,
// map table topography
mapRows: function(inRows){
//console.log('mapRows');
// # of rows
var rowCount = inRows.length;
if(!rowCount){
return;
}
// map which columns and rows fill which cells
this.map = [ ];
for(var j=0, row; (row=inRows[j]); j++){
this.map[j] = [];
}
for(var j=0, row; (row=inRows[j]); j++){
for(var i=0, x=0, cell, colSpan, rowSpan; (cell=row[i]); i++){
while (this.map[j][x]){x++};
this.map[j][x] = { c: i, r: j };
rowSpan = cell.rowSpan || 1;
colSpan = cell.colSpan || 1;
for(var y=0; y<rowSpan; y++){
for(var s=0; s<colSpan; s++){
this.map[j+y][x+s] = this.map[j][x];
}
}
x += colSpan;
}
}
//this.dumMap();
},
dumpMap: function(){
for(var j=0, row, h=''; (row=this.map[j]); j++,h=''){
for(var i=0, cell; (cell=row[i]); i++){
h += cell.r + ',' + cell.c + ' ';
}
console.log(h);
}
},
// find node's map coords by it's structure coords
getMapCoords: function(inRow, inCol){
for(var j=0, row; (row=this.map[j]); j++){
for(var i=0, cell; (cell=row[i]); i++){
if(cell.c==inCol && cell.r == inRow){
return { j: j, i: i };
}
//else{console.log(inRow, inCol, ' : ', i, j, " : ", cell.r, cell.c); };
}
}
return { j: -1, i: -1 };
},
// find a node in inNode's table with the given structure coords
getNode: function(inTable, inRow, inCol){
var row = inTable && inTable.rows[inRow];
return row && row.cells[inCol];
},
_findOverlappingNodes: function(inTable, inRow, inCol){
var nodes = [];
var m = this.getMapCoords(inRow, inCol);
//console.log("node j: %d, i: %d", m.j, m.i);
var row = this.map[m.j];
for(var j=0, row; (row=this.map[j]); j++){
if(j == m.j){ continue; }
with(row[m.i]){
//console.log("overlaps: r: %d, c: %d", r, c);
var n = this.getNode(inTable, r, c);
if(n){ nodes.push(n); }
}
}
//console.log(nodes);
return nodes;
},
findOverlappingNodes: function(inNode){
return this._findOverlappingNodes(dojox.grid.findTable(inNode), dojox.grid.getTrIndex(inNode.parentNode), dojox.grid.getTdIndex(inNode));
}
});
 
dojox.grid.rowIndexTag = "gridRowIndex";
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/rows.js
New file
0,0 → 1,66
if(!dojo._hasResource["dojox.grid._grid.rows"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._grid.rows"] = true;
dojo.provide("dojox.grid._grid.rows");
 
dojo.declare("dojox.grid.rows", null, {
// Stores information about grid rows. Owned by grid and used internally.
constructor: function(inGrid){
this.grid = inGrid;
},
linesToEms: 2,
defaultRowHeight: 1, // lines
overRow: -2,
// metrics
getHeight: function(inRowIndex){
return '';
},
getDefaultHeightPx: function(){
// summmary:
// retrieves the default row height
// returns: int, default row height
return 32;
//return Math.round(this.defaultRowHeight * this.linesToEms * this.grid.contentPixelToEmRatio);
},
// styles
prepareStylingRow: function(inRowIndex, inRowNode){
return {
index: inRowIndex,
node: inRowNode,
odd: Boolean(inRowIndex&1),
selected: this.grid.selection.isSelected(inRowIndex),
over: this.isOver(inRowIndex),
customStyles: "",
customClasses: "dojoxGrid-row"
}
},
styleRowNode: function(inRowIndex, inRowNode){
var row = this.prepareStylingRow(inRowIndex, inRowNode);
this.grid.onStyleRow(row);
this.applyStyles(row);
},
applyStyles: function(inRow){
with(inRow){
node.className = customClasses;
var h = node.style.height;
dojox.grid.setStyleText(node, customStyles + ';' + (node._style||''));
node.style.height = h;
}
},
updateStyles: function(inRowIndex){
this.grid.updateRowStyles(inRowIndex);
},
// states and events
setOverRow: function(inRowIndex){
var last = this.overRow;
this.overRow = inRowIndex;
if((last!=this.overRow)&&(last >=0)){
this.updateStyles(last);
}
this.updateStyles(this.overRow);
},
isOver: function(inRowIndex){
return (this.overRow == inRowIndex);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/images/tabEnabled_rotated.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/grid/_grid/images/tabEnabled_rotated.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/grid/_grid/images/grid_sort_down.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/grid/_grid/images/grid_sort_down.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/grid/_grid/images/tabHover_rotated.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/grid/_grid/images/tabHover_rotated.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/grid/_grid/images/grid_dx_gradient.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/grid/_grid/images/grid_dx_gradient.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/grid/_grid/images/grid_sort_up.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/api/js/dojo1.0/dojox/grid/_grid/images/grid_sort_up.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/api/js/dojo1.0/dojox/grid/_grid/rowbar.js
New file
0,0 → 1,51
if(!dojo._hasResource["dojox.grid._grid.rowbar"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._grid.rowbar"] = true;
dojo.provide("dojox.grid._grid.rowbar");
dojo.require("dojox.grid._grid.view");
 
dojo.declare('dojox.GridRowView', dojox.GridView, {
// summary:
// Custom grid view. If used in a grid structure, provides a small selectable region for grid rows.
defaultWidth: "3em",
noscroll: true,
padBorderWidth: 2,
buildRendering: function(){
this.inherited('buildRendering', arguments);
this.scrollboxNode.style.overflow = "hidden";
this.headerNode.style.visibility = "hidden";
},
getWidth: function(){
return this.viewWidth || this.defaultWidth;
},
buildRowContent: function(inRowIndex, inRowNode){
var w = this.contentNode.offsetWidth - this.padBorderWidth
inRowNode.innerHTML = '<table style="width:' + w + 'px;" role="wairole:presentation"><tr><td class="dojoxGrid-rowbar-inner"></td></tr></table>';
},
renderHeader: function(){
},
resize: function(){
this.resizeHeight();
},
// styling
doStyleRowNode: function(inRowIndex, inRowNode){
var n = [ "dojoxGrid-rowbar" ];
if(this.grid.rows.isOver(inRowIndex)){
n.push("dojoxGrid-rowbar-over");
}
if(this.grid.selection.isSelected(inRowIndex)){
n.push("dojoxGrid-rowbar-selected");
}
inRowNode.className = n.join(" ");
},
// event handlers
domouseover: function(e){
this.grid.onMouseOverRow(e);
},
domouseout: function(e){
if(!this.isIntraRowEvent(e)){
this.grid.onMouseOutRow(e);
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/views.js
New file
0,0 → 1,235
if(!dojo._hasResource["dojox.grid._grid.views"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._grid.views"] = true;
dojo.provide("dojox.grid._grid.views");
 
dojo.declare('dojox.grid.views', null, {
// summary:
// A collection of grid views. Owned by grid and used internally for managing grid views.
// Grid creates views automatically based on grid's layout structure.
// Users should typically not need to access individual views or the views collection directly.
constructor: function(inGrid){
this.grid = inGrid;
},
defaultWidth: 200,
views: [],
// operations
resize: function(){
this.onEach("resize");
},
render: function(){
this.onEach("render");
this.normalizeHeaderNodeHeight();
},
// views
addView: function(inView){
inView.idx = this.views.length;
this.views.push(inView);
},
destroyViews: function(){
for (var i=0, v; v=this.views[i]; i++)
v.destroy();
this.views = [];
},
getContentNodes: function(){
var nodes = [];
for(var i=0, v; v=this.views[i]; i++){
nodes.push(v.contentNode);
}
return nodes;
},
forEach: function(inCallback){
for(var i=0, v; v=this.views[i]; i++){
inCallback(v, i);
}
},
onEach: function(inMethod, inArgs){
inArgs = inArgs || [];
for(var i=0, v; v=this.views[i]; i++){
if(inMethod in v){
v[inMethod].apply(v, inArgs);
}
}
},
// layout
normalizeHeaderNodeHeight: function(){
var rowNodes = [];
for(var i=0, v; (v=this.views[i]); i++){
if(v.headerContentNode.firstChild){
rowNodes.push(v.headerContentNode)
};
}
this.normalizeRowNodeHeights(rowNodes);
},
normalizeRowNodeHeights: function(inRowNodes){
var h = 0;
for(var i=0, n, o; (n=inRowNodes[i]); i++){
h = Math.max(h, (n.firstChild.clientHeight)||(n.firstChild.offsetHeight));
}
h = (h >= 0 ? h : 0);
//
var hpx = h + 'px';
for(var i=0, n; (n=inRowNodes[i]); i++){
if(n.firstChild.clientHeight!=h){
n.firstChild.style.height = hpx;
}
}
//
//console.log('normalizeRowNodeHeights ', h);
//
// querying the height here seems to help scroller measure the page on IE
if(inRowNodes&&inRowNodes[0]){
inRowNodes[0].parentNode.offsetHeight;
}
},
renormalizeRow: function(inRowIndex){
var rowNodes = [];
for(var i=0, v, n; (v=this.views[i])&&(n=v.getRowNode(inRowIndex)); i++){
n.firstChild.style.height = '';
rowNodes.push(n);
}
this.normalizeRowNodeHeights(rowNodes);
},
getViewWidth: function(inIndex){
return this.views[inIndex].getWidth() || this.defaultWidth;
},
measureHeader: function(){
this.forEach(function(inView){
inView.headerContentNode.style.height = '';
});
var h = 0;
this.forEach(function(inView){
//console.log('headerContentNode', inView.headerContentNode.offsetHeight, inView.headerContentNode.offsetWidth);
h = Math.max(inView.headerNode.offsetHeight, h);
});
return h;
},
measureContent: function(){
var h = 0;
this.forEach(function(inView) {
h = Math.max(inView.domNode.offsetHeight, h);
});
return h;
},
findClient: function(inAutoWidth){
// try to use user defined client
var c = this.grid.elasticView || -1;
// attempt to find implicit client
if(c < 0){
for(var i=1, v; (v=this.views[i]); i++){
if(v.viewWidth){
for(i=1; (v=this.views[i]); i++){
if(!v.viewWidth){
c = i;
break;
}
}
break;
}
}
}
// client is in the middle by default
if(c < 0){
c = Math.floor(this.views.length / 2);
}
return c;
},
_arrange: function(l, t, w, h){
var i, v, vw, len = this.views.length;
// find the client
var c = (w <= 0 ? len : this.findClient());
// layout views
var setPosition = function(v, l, t){
with(v.domNode.style){
left = l + 'px';
top = t + 'px';
}
with(v.headerNode.style){
left = l + 'px';
top = 0;
}
}
// for views left of the client
for(i=0; (v=this.views[i])&&(i<c); i++){
// get width
vw = this.getViewWidth(i);
// process boxes
v.setSize(vw, h);
setPosition(v, l, t);
vw = v.domNode.offsetWidth;
// update position
l += vw;
}
// next view (is the client, i++ == c)
i++;
// start from the right edge
var r = w;
// for views right of the client (iterated from the right)
for(var j=len-1; (v=this.views[j])&&(i<=j); j--){
// get width
vw = this.getViewWidth(j);
// set size
v.setSize(vw, h);
// measure in pixels
vw = v.domNode.offsetWidth;
// update position
r -= vw;
// set position
setPosition(v, r, t);
}
if(c<len){
v = this.views[c];
// position the client box between left and right boxes
vw = Math.max(1, r-l);
// set size
v.setSize(vw + 'px', h);
setPosition(v, l, t);
}
return l;
},
arrange: function(l, t, w, h){
var w = this._arrange(l, t, w, h);
this.resize();
return w;
},
// rendering
renderRow: function(inRowIndex, inNodes){
var rowNodes = [];
for(var i=0, v, n, rowNode; (v=this.views[i])&&(n=inNodes[i]); i++){
rowNode = v.renderRow(inRowIndex);
n.appendChild(rowNode);
rowNodes.push(rowNode);
}
this.normalizeRowNodeHeights(rowNodes);
},
rowRemoved: function(inRowIndex){
this.onEach("rowRemoved", [ inRowIndex ]);
},
// updating
updateRow: function(inRowIndex, inHeight){
for(var i=0, v; v=this.views[i]; i++){
v.updateRow(inRowIndex, inHeight);
}
this.renormalizeRow(inRowIndex);
},
updateRowStyles: function(inRowIndex){
this.onEach("updateRowStyles", [ inRowIndex ]);
},
// scrolling
setScrollTop: function(inTop){
var top = inTop;
for(var i=0, v; v=this.views[i]; i++){
top = v.setScrollTop(inTop);
}
return top;
//this.onEach("setScrollTop", [ inTop ]);
},
getFirstScrollingView: function(){
for(var i=0, v; (v=this.views[i]); i++){
if(v.hasScrollbar()){
return v;
}
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/Grid.css
New file
0,0 → 1,245
.dojoxGrid {
position: relative;
background-color: #EBEADB;
font-family: Geneva, Arial, Helvetica, sans-serif;
-moz-outline-style: none;
outline: none;
}
 
.dojoxGrid table {
padding: 0;
}
 
.dojoxGrid td {
-moz-outline: none;
}
 
/* master header */
 
.dojoxGrid-master-header {
position: relative;
}
 
/* master view */
 
.dojoxGrid-master-view {
position: relative;
}
 
/* views */
 
.dojoxGrid-view {
position: absolute;
overflow: hidden;
}
 
/* header */
 
.dojoxGrid-header {
position: absolute;
overflow: hidden;
}
 
.dojoxGrid-header {
background-color: #E8E1CF;
}
 
.dojoxGrid-header table {
text-align: center;
}
 
.dojoxGrid-header .dojoxGrid-cell-content {
text-align: center;
}
 
.dojoxGrid-header .dojoxGrid-cell {
border: 1px solid;
border-color: #F6F4EB #ACA899 #ACA899 #F6F4EB;
background: url(images/grid_dx_gradient.gif) #E8E1CF top repeat-x;
padding-bottom: 2px;
}
 
.dojoxGrid-header .dojoxGrid-cell-over {
background-image: none;
background-color: white;
border-bottom-color: #FEBE47;
margin-bottom: 0;
padding-bottom: 0;
border-bottom-width: 3px;
}
 
.dojoxGrid-sort-down {
background: url(images/grid_sort_down.gif) left no-repeat;
padding-left:16px;
margin-left:4px;
}
 
.dojoxGrid-sort-up {
background: url(images/grid_sort_up.gif) left no-repeat;
padding-left:16px;
margin-left:4px;
}
 
/* content */
 
.dojoxGrid-scrollbox {
position: relative;
overflow: scroll;
background-color: white;
width: 100%;
}
 
.dojoxGrid-content {
position: relative;
overflow: hidden;
-moz-outline-style: none;
outline: none;
}
 
/* rowbar */
 
.dojoxGrid-rowbar {
border: 1px solid;
border-color: #F6F4EB #ACA899 #ACA899 #F6F4EB;
border-top: none;
background: url(images/grid_dx_gradient.gif) #E8E1CF top repeat-x;
}
 
.dojoxGrid-rowbar-inner {
border-top: 1px solid #F6F4EB;
}
 
.dojoxGrid-rowbar-over {
background-image: none;
background-color: white;
border-top-color: #FEBE47;
border-bottom-color: #FEBE47;
}
 
.dojoxGrid-rowbar-selected {
background-color: #D9E8F9;
background-image: none;
/*background-image: url(images/grid_green_dot.gif);*/
background-position: center;
background-repeat: no-repeat;
}
 
/* rows */
 
.dojoxGrid-row {
position: relative;
width: 9000em;
}
 
.dojoxGrid-row {
/*border: 1px solid #E8E4D8;*/
border: 1px solid #E8E4D8;
border-color: #F8F7F1;
/*padding: 0 0 1px 0;*/
border-left: none;
border-right: none;
background-color: white;
border-top: none;
}
 
.dojoxGrid-row-over {
border-top-color: #FEBE47;
border-bottom-color: #FEBE47;
/*border-bottom-width: 2px;
padding-bottom: 0;*/
/*background-color: #FFDD9D;*/
/*background-color: #FDFDFD;*/
}
 
.dojoxGrid-row-odd {
background-color: #FFFDF3;
/*background-color: #F9F7E8;*/
}
 
.dojoxGrid-row-selected {
background-color: #D9E8F9;
}
 
.dojoxGrid-row-table {
table-layout: fixed;
width: 0;
}
 
.dojoxGrid-invisible {
visibility: hidden;
}
 
.Xdojo-ie .dojoxGrid-invisible {
display: none;
}
 
.dojoxGrid-invisible td, .dojoxGrid-header .dojoxGrid-invisible td {
border-top-width: 0;
border-bottom-width: 0;
padding-top: 0;
padding-bottom: 0;
height: 0;
overflow: hidden;
}
 
/* cells */
 
.dojoxGrid-cell {
border: 1px solid;
border-color: #EBEADB;
border-right-color: #D5CDB5;
padding: 3px 3px 3px 3px;
text-align: left;
overflow: hidden;
}
 
.dojoxGrid-cell-focus {
border: 1px dashed blue;
}
 
.dojoxGrid-cell-over {
border: 1px dotted #FEBE47;
}
 
.dojoxGrid-cell-focus.dojoxGrid-cell-over {
border: 1px dotted green;
}
 
.dojoxGrid-cell-clip {
width: 100%;
overflow: hidden;
white-space:nowrap;
text-overflow: ellipsis;
}
 
/* editing */
 
.dojoxGrid-row-editing td {
background-color: #F4FFF4;
}
 
.dojoxGrid-row-inserting td {
background-color: #F4FFF4;
}
.dojoxGrid-row-inflight td {
background-color: #F2F7B7;
}
.dojoxGrid-row-error td {
background-color: #F8B8B6;
}
 
.dojoxGrid-input, .dojoxGrid-select, .dojoxGrid-textarea {
margin: 0;
padding: 0;
border-style: none;
width: 100%;
font-size: 100%;
font-family: inherit;
}
 
.dojoxGrid-hidden-focus {
position: absolute;
left: -1000px;
top: -1000px;
height: 0px, width: 0px;
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/publicEvents.js
New file
0,0 → 1,333
if(!dojo._hasResource["dojox.grid._grid.publicEvents"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._grid.publicEvents"] = true;
dojo.provide("dojox.grid._grid.publicEvents");
 
dojox.grid.publicEvents = {
// summary:
// VirtualGrid mixin that provides default implementations for grid events.
// dojo.connect to events to retain default implementation or override them for custom handling.
//cellOverClass: string
// css class to apply to grid cells over which the cursor is placed.
cellOverClass: "dojoxGrid-cell-over",
// top level handlers (more specified handlers below)
onKeyEvent: function(e){
this.dispatchKeyEvent(e);
},
onContentEvent: function(e){
this.dispatchContentEvent(e);
},
onHeaderEvent: function(e){
this.dispatchHeaderEvent(e);
},
onStyleRow: function(inRow){
// summary:
// Perform row styling on a given row. Called whenever row styling is updated.
// inRow: object
// Object containing row state information: selected, true if the row is selcted; over:
// true of the mouse is over the row; odd: true if the row is odd. Use customClasses and
// customStyles to control row css classes and styles; both properties are strings.
with(inRow){
customClasses += (odd?" dojoxGrid-row-odd":"") + (selected?" dojoxGrid-row-selected":"") + (over?" dojoxGrid-row-over":"");
}
this.focus.styleRow(inRow);
this.edit.styleRow(inRow);
},
onKeyDown: function(e){
// summary:
// grid key event handler. By default enter begins editing and applies edits, escape cancels and edit,
// tab, shift-tab, and arrow keys move grid cell focus.
if(e.altKey || e.ctrlKey || e.metaKey ){
return;
}
switch(e.keyCode){
case dojo.keys.ESCAPE:
this.edit.cancel();
break;
case dojo.keys.ENTER:
if (!e.shiftKey) {
var isEditing = this.edit.isEditing();
this.edit.apply();
if(!isEditing){
this.edit.setEditCell(this.focus.cell, this.focus.rowIndex);
}
}
break;
case dojo.keys.TAB:
this.focus[e.shiftKey ? 'previousKey' : 'nextKey'](e);
break;
case dojo.keys.LEFT_ARROW:
if(!this.edit.isEditing()){
this.focus.move(0, -1);
}
break;
case dojo.keys.RIGHT_ARROW:
if(!this.edit.isEditing()){
this.focus.move(0, 1);
}
break;
case dojo.keys.UP_ARROW:
if(!this.edit.isEditing()){
this.focus.move(-1, 0);
}
break;
case dojo.keys.DOWN_ARROW:
if(!this.edit.isEditing()){
this.focus.move(1, 0);
}
break;
}
},
onMouseOver: function(e){
// summary:
// event fired when mouse is over the grid.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
e.rowIndex == -1 ? this.onHeaderCellMouseOver(e) : this.onCellMouseOver(e);
},
onMouseOut: function(e){
// summary:
// event fired when mouse moves out of the grid.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
e.rowIndex == -1 ? this.onHeaderCellMouseOut(e) : this.onCellMouseOut(e);
},
onMouseOverRow: function(e){
// summary:
// event fired when mouse is over any row (data or header).
// e: decorated event object
// contains reference to grid, cell, and rowIndex
if(!this.rows.isOver(e.rowIndex)){
this.rows.setOverRow(e.rowIndex);
e.rowIndex == -1 ? this.onHeaderMouseOver(e) : this.onRowMouseOver(e);
}
},
onMouseOutRow: function(e){
// summary:
// event fired when mouse moves out of any row (data or header).
// e: decorated event object
// contains reference to grid, cell, and rowIndex
if(this.rows.isOver(-1)){
this.onHeaderMouseOut(e);
}else if(!this.rows.isOver(-2)){
this.rows.setOverRow(-2);
this.onRowMouseOut(e);
}
},
// cell events
onCellMouseOver: function(e){
// summary:
// event fired when mouse is over a cell.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
dojo.addClass(e.cellNode, this.cellOverClass);
},
onCellMouseOut: function(e){
// summary:
// event fired when mouse moves out of a cell.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
dojo.removeClass(e.cellNode, this.cellOverClass);
},
onCellClick: function(e){
// summary:
// event fired when a cell is clicked.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
this.focus.setFocusCell(e.cell, e.rowIndex);
this.onRowClick(e);
},
onCellDblClick: function(e){
// summary:
// event fired when a cell is double-clicked.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
this.edit.setEditCell(e.cell, e.rowIndex);
this.onRowDblClick(e);
},
onCellContextMenu: function(e){
// summary:
// event fired when a cell context menu is accessed via mouse right click.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
this.onRowContextMenu(e);
},
onCellFocus: function(inCell, inRowIndex){
// summary:
// event fired when a cell receives focus.
// inCell: object
// cell object containing properties of the grid column.
// inRowIndex: int
// index of the grid row
this.edit.cellFocus(inCell, inRowIndex);
},
// row events
onRowClick: function(e){
// summary:
// event fired when a row is clicked.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
this.edit.rowClick(e);
this.selection.clickSelectEvent(e);
},
onRowDblClick: function(e){
// summary:
// event fired when a row is double clicked.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
},
onRowMouseOver: function(e){
// summary:
// event fired when mouse moves over a data row.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
},
onRowMouseOut: function(e){
// summary:
// event fired when mouse moves out of a data row.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
},
onRowContextMenu: function(e){
// summary:
// event fired when a row context menu is accessed via mouse right click.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
dojo.stopEvent(e);
},
// header events
onHeaderMouseOver: function(e){
// summary:
// event fired when mouse moves over the grid header.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
},
onHeaderMouseOut: function(e){
// summary:
// event fired when mouse moves out of the grid header.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
},
onHeaderCellMouseOver: function(e){
// summary:
// event fired when mouse moves over a header cell.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
dojo.addClass(e.cellNode, this.cellOverClass);
},
onHeaderCellMouseOut: function(e){
// summary:
// event fired when mouse moves out of a header cell.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
dojo.removeClass(e.cellNode, this.cellOverClass);
},
onHeaderClick: function(e){
// summary:
// event fired when the grid header is clicked.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
},
onHeaderCellClick: function(e){
// summary:
// event fired when a header cell is clicked.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
this.setSortIndex(e.cell.index);
this.onHeaderClick(e);
},
onHeaderDblClick: function(e){
// summary:
// event fired when the grid header is double clicked.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
},
onHeaderCellDblClick: function(e){
// summary:
// event fired when a header cell is double clicked.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
this.onHeaderDblClick(e);
},
onHeaderCellContextMenu: function(e){
// summary:
// event fired when a header cell context menu is accessed via mouse right click.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
this.onHeaderContextMenu(e);
},
onHeaderContextMenu: function(e){
// summary:
// event fired when the grid header context menu is accessed via mouse right click.
// e: decorated event object
// contains reference to grid, cell, and rowIndex
dojo.stopEvent(e);
},
// editing
onStartEdit: function(inCell, inRowIndex){
// summary:
// event fired when editing is started for a given grid cell
// inCell: object
// cell object containing properties of the grid column.
// inRowIndex: int
// index of the grid row
},
onApplyCellEdit: function(inValue, inRowIndex, inFieldIndex){
// summary:
// event fired when editing is applied for a given grid cell
// inValue: string
// value from cell editor
// inRowIndex: int
// index of the grid row
// inFieldIndex: int
// index in the grid's data model
},
onCancelEdit: function(inRowIndex){
// summary:
// event fired when editing is cancelled for a given grid cell
// inRowIndex: int
// index of the grid row
},
onApplyEdit: function(inRowIndex){
// summary:
// event fired when editing is applied for a given grid row
// inRowIndex: int
// index of the grid row
},
onCanSelect: function(inRowIndex){
// summary:
// event to determine if a grid row may be selected
// inRowIndex: int
// index of the grid row
// returns:
// true if the row can be selected
return true // boolean;
},
onCanDeselect: function(inRowIndex){
// summary:
// event to determine if a grid row may be deselected
// inRowIndex: int
// index of the grid row
// returns:
// true if the row can be deselected
return true // boolean;
},
onSelected: function(inRowIndex){
// summary:
// event fired when a grid row is selected
// inRowIndex: int
// index of the grid row
this.updateRowStyles(inRowIndex);
},
onDeselected: function(inRowIndex){
// summary:
// event fired when a grid row is deselected
// inRowIndex: int
// index of the grid row
this.updateRowStyles(inRowIndex);
},
onSelectionChanged: function(){
}
}
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/lib.js
New file
0,0 → 1,220
if(!dojo._hasResource["dojox.grid._grid.lib"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._grid.lib"] = true;
dojo.provide("dojox.grid._grid.lib");
 
dojo.isNumber = function(v){
return (typeof v == 'number') || (v instanceof Number);
}
 
// summary:
// grid utility library
 
dojo.mixin(dojox.grid, {
na: '...',
nop: function() {
},
getTdIndex: function(td){
return td.cellIndex >=0 ? td.cellIndex : dojo.indexOf(td.parentNode.cells, td);
},
getTrIndex: function(tr){
return tr.rowIndex >=0 ? tr.rowIndex : dojo.indexOf(tr.parentNode.childNodes, tr);
},
getTr: function(rowOwner, index){
return rowOwner && ((rowOwner.rows||0)[index] || rowOwner.childNodes[index]);
},
getTd: function(rowOwner, rowIndex, cellIndex){
return (dojox.grid.getTr(inTable, rowIndex)||0)[cellIndex];
},
findTable: function(node){
for (var n=node; n && n.tagName!='TABLE'; n=n.parentNode);
return n;
},
ascendDom: function(inNode, inWhile){
for (var n=inNode; n && inWhile(n); n=n.parentNode);
return n;
},
makeNotTagName: function(inTagName){
var name = inTagName.toUpperCase();
return function(node){ return node.tagName != name; };
},
fire: function(ob, ev, args){
var fn = ob && ev && ob[ev];
return fn && (args ? fn.apply(ob, args) : ob[ev]());
},
// from lib.js
setStyleText: function(inNode, inStyleText){
if(inNode.style.cssText == undefined){
inNode.setAttribute("style", inStyleText);
}else{
inNode.style.cssText = inStyleText;
}
},
getStyleText: function(inNode, inStyleText){
return (inNode.style.cssText == undefined ? inNode.getAttribute("style") : inNode.style.cssText);
},
setStyle: function(inElement, inStyle, inValue){
if(inElement && inElement.style[inStyle] != inValue){
inElement.style[inStyle] = inValue;
}
},
setStyleHeightPx: function(inElement, inHeight){
if(inHeight >= 0){
dojox.grid.setStyle(inElement, 'height', inHeight + 'px');
}
},
mouseEvents: [ 'mouseover', 'mouseout', /*'mousemove',*/ 'mousedown', 'mouseup', 'click', 'dblclick', 'contextmenu' ],
keyEvents: [ 'keyup', 'keydown', 'keypress' ],
funnelEvents: function(inNode, inObject, inMethod, inEvents){
var evts = (inEvents ? inEvents : dojox.grid.mouseEvents.concat(dojox.grid.keyEvents));
for (var i=0, l=evts.length; i<l; i++){
dojo.connect(inNode, 'on' + evts[i], inObject, inMethod);
}
},
removeNode: function(inNode){
inNode = dojo.byId(inNode);
inNode && inNode.parentNode && inNode.parentNode.removeChild(inNode);
return inNode;
},
getScrollbarWidth: function(){
if(this._scrollBarWidth){
return this._scrollBarWidth;
}
this._scrollBarWidth = 18;
try{
var e = document.createElement("div");
e.style.cssText = "top:0;left:0;width:100px;height:100px;overflow:scroll;position:absolute;visibility:hidden;";
document.body.appendChild(e);
this._scrollBarWidth = e.offsetWidth - e.clientWidth;
document.body.removeChild(e);
delete e;
}catch (ex){}
return this._scrollBarWidth;
},
// needed? dojo has _getProp
getRef: function(name, create, context){
var obj=context||dojo.global, parts=name.split("."), prop=parts.pop();
for(var i=0, p; obj&&(p=parts[i]); i++){
obj = (p in obj ? obj[p] : (create ? obj[p]={} : undefined));
}
return { obj: obj, prop: prop };
},
getProp: function(name, create, context){
with(dojox.grid.getRef(name, create, context)){
return (obj)&&(prop)&&(prop in obj ? obj[prop] : (create ? obj[prop]={} : undefined));
}
},
indexInParent: function(inNode){
var i=0, n, p=inNode.parentNode;
while(n = p.childNodes[i++]){
if(n == inNode){
return i - 1;
}
}
return -1;
},
cleanNode: function(inNode){
if(!inNode){
return;
}
var filter = function(inW){
return inW.domNode && dojo.isDescendant(inW.domNode, inNode, true);
}
var ws = dijit.registry.filter(filter);
for(var i=0, w; (w=ws[i]); i++){
w.destroy();
}
delete ws;
},
getTagName: function(inNodeOrId){
var node = dojo.byId(inNodeOrId);
return (node && node.tagName ? node.tagName.toLowerCase() : '');
},
nodeKids: function(inNode, inTag){
var result = [];
var i=0, n;
while(n = inNode.childNodes[i++]){
if(dojox.grid.getTagName(n) == inTag){
result.push(n);
}
}
return result;
},
divkids: function(inNode){
return dojox.grid.nodeKids(inNode, 'div');
},
focusSelectNode: function(inNode){
try{
dojox.grid.fire(inNode, "focus");
dojox.grid.fire(inNode, "select");
}catch(e){// IE sux bad
}
},
whenIdle: function(/*inContext, inMethod, args ...*/){
setTimeout(dojo.hitch.apply(dojo, arguments), 0);
},
arrayCompare: function(inA, inB){
for(var i=0,l=inA.length; i<l; i++){
if(inA[i] != inB[i]){return false;}
}
return (inA.length == inB.length);
},
arrayInsert: function(inArray, inIndex, inValue){
if(inArray.length <= inIndex){
inArray[inIndex] = inValue;
}else{
inArray.splice(inIndex, 0, inValue);
}
},
arrayRemove: function(inArray, inIndex){
inArray.splice(inIndex, 1);
},
arraySwap: function(inArray, inI, inJ){
var cache = inArray[inI];
inArray[inI] = inArray[inJ];
inArray[inJ] = cache;
},
initTextSizePoll: function(inInterval) {
var f = document.createElement("div");
with (f.style) {
top = "0px";
left = "0px";
position = "absolute";
visibility = "hidden";
}
f.innerHTML = "TheQuickBrownFoxJumpedOverTheLazyDog";
document.body.appendChild(f);
var fw = f.offsetWidth;
var job = function() {
if (f.offsetWidth != fw) {
fw = f.offsetWidth;
dojox.grid.textSizeChanged();
}
}
window.setInterval(job, inInterval||200);
dojox.grid.initTextSizePoll = dojox.grid.nop;
},
textSizeChanged: function() {
}
});
 
dojox.grid.jobs = {
cancel: function(inHandle){
if(inHandle){
window.clearTimeout(inHandle);
}
},
jobs: [],
job: function(inName, inDelay, inJob){
dojox.grid.jobs.cancelJob(inName);
var job = function(){
delete dojox.grid.jobs.jobs[inName];
inJob();
}
dojox.grid.jobs.jobs[inName] = setTimeout(job, inDelay);
},
cancelJob: function(inName){
dojox.grid.jobs.cancel(dojox.grid.jobs.jobs[inName]);
}
}
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/view.js
New file
0,0 → 1,259
if(!dojo._hasResource["dojox.grid._grid.view"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._grid.view"] = true;
dojo.provide("dojox.grid._grid.view");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dojox.grid._grid.builder");
 
dojo.declare('dojox.GridView', [dijit._Widget, dijit._Templated], {
// summary:
// A collection of grid columns. A grid is comprised of a set of views that stack horizontally.
// Grid creates views automatically based on grid's layout structure.
// Users should typically not need to access individual views directly.
defaultWidth: "18em",
// viewWidth: string
// width for the view, in valid css unit
viewWidth: "",
templateString: '<div class="dojoxGrid-view"><div class="dojoxGrid-header" dojoAttachPoint="headerNode"><div style="width: 9000em"><div dojoAttachPoint="headerContentNode"></div></div></div><input type="checkbox" class="dojoxGrid-hidden-focus" dojoAttachPoint="hiddenFocusNode" /><input type="checkbox" class="dojoxGrid-hidden-focus" /><div class="dojoxGrid-scrollbox" dojoAttachPoint="scrollboxNode"><div class="dojoxGrid-content" dojoAttachPoint="contentNode" hidefocus="hidefocus"></div></div></div>',
themeable: false,
classTag: 'dojoxGrid',
marginBottom: 0,
rowPad: 2,
postMixInProperties: function(){
this.rowNodes = [];
},
postCreate: function(){
dojo.connect(this.scrollboxNode, "onscroll", dojo.hitch(this, "doscroll"));
dojox.grid.funnelEvents(this.contentNode, this, "doContentEvent", [ 'mouseover', 'mouseout', 'click', 'dblclick', 'contextmenu' ]);
dojox.grid.funnelEvents(this.headerNode, this, "doHeaderEvent", [ 'dblclick', 'mouseover', 'mouseout', 'mousemove', 'mousedown', 'click', 'contextmenu' ]);
this.content = new dojox.grid.contentBuilder(this);
this.header = new dojox.grid.headerBuilder(this);
},
destroy: function(){
dojox.grid.removeNode(this.headerNode);
this.inherited("destroy", arguments);
},
// focus
focus: function(){
if(dojo.isSafari || dojo.isOpera){
this.hiddenFocusNode.focus();
}else{
this.scrollboxNode.focus();
}
},
setStructure: function(inStructure){
var vs = this.structure = inStructure;
// FIXME: similar logic is duplicated in layout
if(vs.width && dojo.isNumber(vs.width)){
this.viewWidth = vs.width + 'em';
}else{
this.viewWidth = vs.width || this.viewWidth; //|| this.defaultWidth;
}
this.onBeforeRow = vs.onBeforeRow;
this.noscroll = vs.noscroll;
if(this.noscroll){
this.scrollboxNode.style.overflow = "hidden";
}
// bookkeeping
this.testFlexCells();
// accomodate new structure
this.updateStructure();
},
testFlexCells: function(){
// FIXME: cheater, this function does double duty as initializer and tester
this.flexCells = false;
for(var j=0, row; (row=this.structure.rows[j]); j++){
for(var i=0, cell; (cell=row[i]); i++){
cell.view = this;
this.flexCells = this.flexCells || cell.isFlex();
}
}
return this.flexCells;
},
updateStructure: function(){
// header builder needs to update table map
this.header.update();
// content builder needs to update markup cache
this.content.update();
},
getScrollbarWidth: function(){
return (this.noscroll ? 0 : dojox.grid.getScrollbarWidth());
},
getColumnsWidth: function(){
return this.headerContentNode.firstChild.offsetWidth;
},
getWidth: function(){
return this.viewWidth || (this.getColumnsWidth()+this.getScrollbarWidth()) +'px';
},
getContentWidth: function(){
return Math.max(0, dojo._getContentBox(this.domNode).w - this.getScrollbarWidth()) + 'px';
},
render: function(){
this.scrollboxNode.style.height = '';
this.renderHeader();
},
renderHeader: function(){
this.headerContentNode.innerHTML = this.header.generateHtml(this._getHeaderContent);
},
// note: not called in 'view' context
_getHeaderContent: function(inCell){
var n = inCell.name || inCell.grid.getCellName(inCell);
if(inCell.index != inCell.grid.getSortIndex()){
return n;
}
return [ '<div class="', inCell.grid.sortInfo > 0 ? 'dojoxGrid-sort-down' : 'dojoxGrid-sort-up', '">', n, '</div>' ].join('');
},
resize: function(){
this.resizeHeight();
this.resizeWidth();
},
hasScrollbar: function(){
return (this.scrollboxNode.clientHeight != this.scrollboxNode.offsetHeight);
},
resizeHeight: function(){
if(!this.grid.autoHeight){
var h = this.domNode.clientHeight;
if(!this.hasScrollbar()){ // no scrollbar is rendered
h -= dojox.grid.getScrollbarWidth();
}
dojox.grid.setStyleHeightPx(this.scrollboxNode, h);
}
},
resizeWidth: function(){
if(this.flexCells){
// the view content width
this.contentWidth = this.getContentWidth();
this.headerContentNode.firstChild.style.width = this.contentWidth;
}
// FIXME: it should be easier to get w from this.scrollboxNode.clientWidth,
// but clientWidth seemingly does not include scrollbar width in some cases
var w = this.scrollboxNode.offsetWidth - this.getScrollbarWidth();
w = Math.max(w, this.getColumnsWidth()) + 'px';
with(this.contentNode){
style.width = '';
offsetWidth;
style.width = w;
}
},
setSize: function(w, h){
with(this.domNode.style){
if(w){
width = w;
}
height = (h >= 0 ? h + 'px' : '');
}
with(this.headerNode.style){
if(w){
width = w;
}
}
},
renderRow: function(inRowIndex, inHeightPx){
var rowNode = this.createRowNode(inRowIndex);
this.buildRow(inRowIndex, rowNode, inHeightPx);
this.grid.edit.restore(this, inRowIndex);
return rowNode;
},
createRowNode: function(inRowIndex){
var node = document.createElement("div");
node.className = this.classTag + '-row';
node[dojox.grid.rowIndexTag] = inRowIndex;
this.rowNodes[inRowIndex] = node;
return node;
},
buildRow: function(inRowIndex, inRowNode){
this.buildRowContent(inRowIndex, inRowNode);
this.styleRow(inRowIndex, inRowNode);
},
buildRowContent: function(inRowIndex, inRowNode){
inRowNode.innerHTML = this.content.generateHtml(inRowIndex, inRowIndex);
if(this.flexCells){
// FIXME: accessing firstChild here breaks encapsulation
inRowNode.firstChild.style.width = this.contentWidth;
}
},
rowRemoved:function(inRowIndex){
this.grid.edit.save(this, inRowIndex);
delete this.rowNodes[inRowIndex];
},
getRowNode: function(inRowIndex){
return this.rowNodes[inRowIndex];
},
getCellNode: function(inRowIndex, inCellIndex){
var row = this.getRowNode(inRowIndex);
if(row){
return this.content.getCellNode(row, inCellIndex);
}
},
// styling
styleRow: function(inRowIndex, inRowNode){
inRowNode._style = dojox.grid.getStyleText(inRowNode);
this.styleRowNode(inRowIndex, inRowNode);
},
styleRowNode: function(inRowIndex, inRowNode){
if(inRowNode){
this.doStyleRowNode(inRowIndex, inRowNode);
}
},
doStyleRowNode: function(inRowIndex, inRowNode){
this.grid.styleRowNode(inRowIndex, inRowNode);
},
// updating
updateRow: function(inRowIndex, inHeightPx, inPageNode){
var rowNode = this.getRowNode(inRowIndex);
if(rowNode){
rowNode.style.height = '';
this.buildRow(inRowIndex, rowNode);
}
return rowNode;
},
updateRowStyles: function(inRowIndex){
this.styleRowNode(inRowIndex, this.getRowNode(inRowIndex));
},
// scrolling
lastTop: 0,
doscroll: function(inEvent){
this.headerNode.scrollLeft = this.scrollboxNode.scrollLeft;
// 'lastTop' is a semaphore to prevent feedback-loop with setScrollTop below
var top = this.scrollboxNode.scrollTop;
if(top != this.lastTop){
this.grid.scrollTo(top);
}
},
setScrollTop: function(inTop){
// 'lastTop' is a semaphore to prevent feedback-loop with doScroll above
this.lastTop = inTop;
this.scrollboxNode.scrollTop = inTop;
return this.scrollboxNode.scrollTop;
},
// event handlers (direct from DOM)
doContentEvent: function(e){
if(this.content.decorateEvent(e)){
this.grid.onContentEvent(e);
}
},
doHeaderEvent: function(e){
if(this.header.decorateEvent(e)){
this.grid.onHeaderEvent(e);
}
},
// event dispatch(from Grid)
dispatchContentEvent: function(e){
return this.content.dispatchEvent(e);
},
dispatchHeaderEvent: function(e){
return this.header.dispatchEvent(e);
},
// column resizing
setColWidth: function(inIndex, inWidth){
this.grid.setCellWidth(inIndex, inWidth + 'px');
},
update: function(){
var left = this.scrollboxNode.scrollLeft;
this.content.update();
this.grid.update();
this.scrollboxNode.scrollLeft = left;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/drag.js
New file
0,0 → 1,113
if(!dojo._hasResource["dojox.grid._grid.drag"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._grid.drag"] = true;
dojo.provide("dojox.grid._grid.drag");
 
// summary:
// utility functions for dragging as used in grid.
// begin closure
(function(){
 
var dgdrag = dojox.grid.drag = {};
 
dgdrag.dragging = false;
dgdrag.hysteresis = 2;
 
dgdrag.capture = function(inElement) {
//console.debug('dojox.grid.drag.capture');
if (inElement.setCapture)
inElement.setCapture();
else {
document.addEventListener("mousemove", inElement.onmousemove, true);
document.addEventListener("mouseup", inElement.onmouseup, true);
document.addEventListener("click", inElement.onclick, true);
}
}
 
dgdrag.release = function(inElement) {
//console.debug('dojox.grid.drag.release');
if(inElement.releaseCapture){
inElement.releaseCapture();
}else{
document.removeEventListener("click", inElement.onclick, true);
document.removeEventListener("mouseup", inElement.onmouseup, true);
document.removeEventListener("mousemove", inElement.onmousemove, true);
}
}
 
dgdrag.start = function(inElement, inOnDrag, inOnEnd, inEvent, inOnStart){
if(/*dgdrag.elt ||*/ !inElement || dgdrag.dragging){
console.debug('failed to start drag: bad input node or already dragging');
return;
}
dgdrag.dragging = true;
dgdrag.elt = inElement;
dgdrag.events = {
drag: inOnDrag || dojox.grid.nop,
end: inOnEnd || dojox.grid.nop,
start: inOnStart || dojox.grid.nop,
oldmove: inElement.onmousemove,
oldup: inElement.onmouseup,
oldclick: inElement.onclick
};
dgdrag.positionX = (inEvent && ('screenX' in inEvent) ? inEvent.screenX : false);
dgdrag.positionY = (inEvent && ('screenY' in inEvent) ? inEvent.screenY : false);
dgdrag.started = (dgdrag.position === false);
inElement.onmousemove = dgdrag.mousemove;
inElement.onmouseup = dgdrag.mouseup;
inElement.onclick = dgdrag.click;
dgdrag.capture(dgdrag.elt);
}
 
dgdrag.end = function(){
//console.debug("dojox.grid.drag.end");
dgdrag.release(dgdrag.elt);
dgdrag.elt.onmousemove = dgdrag.events.oldmove;
dgdrag.elt.onmouseup = dgdrag.events.oldup;
dgdrag.elt.onclick = dgdrag.events.oldclick;
dgdrag.elt = null;
try{
if(dgdrag.started){
dgdrag.events.end();
}
}finally{
dgdrag.dragging = false;
}
}
 
dgdrag.calcDelta = function(inEvent){
inEvent.deltaX = inEvent.screenX - dgdrag.positionX;
inEvent.deltaY = inEvent.screenY - dgdrag.positionY;
}
 
dgdrag.hasMoved = function(inEvent){
return Math.abs(inEvent.deltaX) + Math.abs(inEvent.deltaY) > dgdrag.hysteresis;
}
 
dgdrag.mousemove = function(inEvent){
inEvent = dojo.fixEvent(inEvent);
dojo.stopEvent(inEvent);
dgdrag.calcDelta(inEvent);
if((!dgdrag.started)&&(dgdrag.hasMoved(inEvent))){
dgdrag.events.start(inEvent);
dgdrag.started = true;
}
if(dgdrag.started){
dgdrag.events.drag(inEvent);
}
}
 
dgdrag.mouseup = function(inEvent){
//console.debug("dojox.grid.drag.mouseup");
dojo.stopEvent(dojo.fixEvent(inEvent));
dgdrag.end();
}
 
dgdrag.click = function(inEvent){
dojo.stopEvent(dojo.fixEvent(inEvent));
//dgdrag.end();
}
 
})();
// end closure
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/layout.js
New file
0,0 → 1,75
if(!dojo._hasResource["dojox.grid._grid.layout"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._grid.layout"] = true;
dojo.provide("dojox.grid._grid.layout");
dojo.require("dojox.grid._grid.cell");
 
dojo.declare("dojox.grid.layout", null, {
// summary:
// Controls grid cell layout. Owned by grid and used internally.
constructor: function(inGrid){
this.grid = inGrid;
},
// flat array of grid cells
cells: null,
// structured array of grid cells
structure: null,
// default cell width
defaultWidth: '6em',
// methods
setStructure: function(inStructure){
this.fieldIndex = 0;
this.cells = [];
var s = this.structure = [];
for(var i=0, viewDef, rows; (viewDef=inStructure[i]); i++){
s.push(this.addViewDef(viewDef));
}
this.cellCount = this.cells.length;
},
addViewDef: function(inDef){
this._defaultCellProps = inDef.defaultCell || {};
return dojo.mixin({}, inDef, {rows: this.addRowsDef(inDef.rows || inDef.cells)});
},
addRowsDef: function(inDef){
var result = [];
for(var i=0, row; inDef && (row=inDef[i]); i++){
result.push(this.addRowDef(i, row));
}
return result;
},
addRowDef: function(inRowIndex, inDef){
var result = [];
for(var i=0, def, cell; (def=inDef[i]); i++){
cell = this.addCellDef(inRowIndex, i, def);
result.push(cell);
this.cells.push(cell);
}
return result;
},
addCellDef: function(inRowIndex, inCellIndex, inDef){
var w = 0;
if(inDef.colSpan > 1){
w = 0;
}else if(!isNaN(inDef.width)){
w = inDef.width + "em";
}else{
w = inDef.width || this.defaultWidth;
}
// fieldIndex progresses linearly from the last indexed field
// FIXME: support generating fieldIndex based a text field name (probably in Grid)
var fieldIndex = inDef.field != undefined ? inDef.field : (inDef.get ? -1 : this.fieldIndex);
if((inDef.field != undefined) || !inDef.get){
this.fieldIndex = (inDef.field > -1 ? inDef.field : this.fieldIndex) + 1;
}
return new dojox.grid.cell(
dojo.mixin({}, this._defaultCellProps, inDef, {
grid: this.grid,
subrow: inRowIndex,
layoutIndex: inCellIndex,
index: this.cells.length,
fieldIndex: fieldIndex,
unitWidth: w
}));
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/cell.js
New file
0,0 → 1,66
if(!dojo._hasResource["dojox.grid._grid.cell"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._grid.cell"] = true;
dojo.provide("dojox.grid._grid.cell");
 
dojo.declare("dojox.grid.cell", null, {
// summary:
// Respresents a grid cell and contains information about column options and methods
// for retrieving cell related information.
// Each column in a grid layout has a cell object and most events and many methods
// provide access to these objects.
styles: '',
constructor: function(inProps){
dojo.mixin(this, inProps);
if(this.editor){this.editor = new this.editor(this);}
},
// data source
format: function(inRowIndex){
// summary:
// provides the html for a given grid cell.
// inRowIndex: int
// grid row index
// returns: html for a given grid cell
var f, i=this.grid.edit.info, d=this.get ? this.get(inRowIndex) : this.value;
if(this.editor && (this.editor.alwaysOn || (i.rowIndex==inRowIndex && i.cell==this))){
return this.editor.format(d, inRowIndex);
}else{
return (f = this.formatter) ? f.call(this, d, inRowIndex) : d;
}
},
// utility
getNode: function(inRowIndex){
// summary:
// gets the dom node for a given grid cell.
// inRowIndex: int
// grid row index
// returns: dom node for a given grid cell
return this.view.getCellNode(inRowIndex, this.index);
},
isFlex: function(){
var uw = this.unitWidth;
return uw && (uw=='auto' || uw.slice(-1)=='%');
},
// edit support
applyEdit: function(inValue, inRowIndex){
this.grid.edit.applyCellEdit(inValue, this, inRowIndex);
},
cancelEdit: function(inRowIndex){
this.grid.doCancelEdit(inRowIndex);
},
_onEditBlur: function(inRowIndex){
if(this.grid.edit.isEditCell(inRowIndex, this.index)){
//console.log('editor onblur', e);
this.grid.edit.apply();
}
},
registerOnBlur: function(inNode, inRowIndex){
if(this.commitOnBlur){
dojo.connect(inNode, "onblur", function(e){
// hack: if editor still thinks this editor is current some ms after it blurs, assume we've focused away from grid
setTimeout(dojo.hitch(this, "_onEditBlur", inRowIndex), 250);
});
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/focus.js
New file
0,0 → 1,204
if(!dojo._hasResource["dojox.grid._grid.focus"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._grid.focus"] = true;
dojo.provide("dojox.grid._grid.focus");
 
// focus management
dojo.declare("dojox.grid.focus", null, {
// summary:
// Controls grid cell focus. Owned by grid and used internally for focusing.
// Note: grid cell actually receives keyboard input only when cell is being edited.
constructor: function(inGrid){
this.grid = inGrid;
this.cell = null;
this.rowIndex = -1;
dojo.connect(this.grid.domNode, "onfocus", this, "doFocus");
},
tabbingOut: false,
focusClass: "dojoxGrid-cell-focus",
focusView: null,
initFocusView: function(){
this.focusView = this.grid.views.getFirstScrollingView();
},
isFocusCell: function(inCell, inRowIndex){
// summary:
// states if the given cell is focused
// inCell: object
// grid cell object
// inRowIndex: int
// grid row index
// returns:
// true of the given grid cell is focused
return (this.cell == inCell) && (this.rowIndex == inRowIndex);
},
isLastFocusCell: function(){
return (this.rowIndex == this.grid.rowCount-1) && (this.cell.index == this.grid.layout.cellCount-1);
},
isFirstFocusCell: function(){
return (this.rowIndex == 0) && (this.cell.index == 0);
},
isNoFocusCell: function(){
return (this.rowIndex < 0) || !this.cell;
},
_focusifyCellNode: function(inBork){
var n = this.cell && this.cell.getNode(this.rowIndex);
if(n){
dojo.toggleClass(n, this.focusClass, inBork);
this.scrollIntoView();
try{
if(!this.grid.edit.isEditing())
dojox.grid.fire(n, "focus");
}catch(e){}
}
},
scrollIntoView: function() {
if(!this.cell){
return;
}
var
c = this.cell,
s = c.view.scrollboxNode,
sr = {
w: s.clientWidth,
l: s.scrollLeft,
t: s.scrollTop,
h: s.clientHeight
},
n = c.getNode(this.rowIndex),
r = c.view.getRowNode(this.rowIndex),
rt = this.grid.scroller.findScrollTop(this.rowIndex);
// place cell within horizontal view
if(n.offsetLeft + n.offsetWidth > sr.l + sr.w){
s.scrollLeft = n.offsetLeft + n.offsetWidth - sr.w;
}else if(n.offsetLeft < sr.l){
s.scrollLeft = n.offsetLeft;
}
// place cell within vertical view
if(rt + r.offsetHeight > sr.t + sr.h){
this.grid.setScrollTop(rt + r.offsetHeight - sr.h);
}else if(rt < sr.t){
this.grid.setScrollTop(rt);
}
},
styleRow: function(inRow){
if(inRow.index == this.rowIndex){
this._focusifyCellNode(true);
}
},
setFocusIndex: function(inRowIndex, inCellIndex){
// summary:
// focuses the given grid cell
// inRowIndex: int
// grid row index
// inCellIndex: int
// grid cell index
this.setFocusCell(this.grid.getCell(inCellIndex), inRowIndex);
},
setFocusCell: function(inCell, inRowIndex){
// summary:
// focuses the given grid cell
// inCell: object
// grid cell object
// inRowIndex: int
// grid row index
if(inCell && !this.isFocusCell(inCell, inRowIndex)){
this.tabbingOut = false;
this.focusGrid();
this._focusifyCellNode(false);
this.cell = inCell;
this.rowIndex = inRowIndex;
this._focusifyCellNode(true);
}
// even if this cell isFocusCell, the document focus may need to be rejiggered
// call opera on delay to prevent keypress from altering focus
if(dojo.isOpera){
setTimeout(dojo.hitch(this.grid, 'onCellFocus', this.cell, this.rowIndex), 1);
}else{
this.grid.onCellFocus(this.cell, this.rowIndex);
}
},
next: function(){
// summary:
// focus next grid cell
var row=this.rowIndex, col=this.cell.index+1, cc=this.grid.layout.cellCount-1, rc=this.grid.rowCount-1;
if(col > cc){
col = 0;
row++;
}
if(row > rc){
col = cc;
row = rc;
}
this.setFocusIndex(row, col);
},
previous: function(){
// summary:
// focus previous grid cell
var row=(this.rowIndex || 0), col=(this.cell.index || 0) - 1;
if(col < 0){
col = this.grid.layout.cellCount-1;
row--;
}
if(row < 0){
row = 0;
col = 0;
}
this.setFocusIndex(row, col);
},
move: function(inRowDelta, inColDelta) {
// summary:
// focus grid cell based on position relative to current focus
// inRowDelta: int
// vertical distance from current focus
// inColDelta: int
// horizontal distance from current focus
var
rc = this.grid.rowCount-1,
cc = this.grid.layout.cellCount-1,
r = this.rowIndex,
i = this.cell.index,
row = Math.min(rc, Math.max(0, r+inRowDelta)),
col = Math.min(cc, Math.max(0, i+inColDelta));
this.setFocusIndex(row, col);
if(inRowDelta){
this.grid.updateRow(r);
}
},
previousKey: function(e){
if(this.isFirstFocusCell()){
this.tabOut(this.grid.domNode);
}else{
dojo.stopEvent(e);
this.previous();
}
},
nextKey: function(e) {
if(this.isLastFocusCell()){
this.tabOut(this.grid.lastFocusNode);
}else{
dojo.stopEvent(e);
this.next();
}
},
tabOut: function(inFocusNode){
this.tabbingOut = true;
inFocusNode.focus();
},
focusGrid: function(){
dojox.grid.fire(this.focusView, "focus");
this._focusifyCellNode(true);
},
doFocus: function(e){
// trap focus only for grid dom node
if(e && e.target != e.currentTarget){
return;
}
// do not focus for scrolling if grid is about to blur
if(!this.tabbingOut && this.isNoFocusCell()){
// establish our virtual-focus, if necessary
this.setFocusIndex(0, 0);
}
this.tabbingOut = false;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/_grid/tundraGrid.css
New file
0,0 → 1,253
.tundra .dojoxGrid {
position: relative;
background-color: #e9e9e9;
font-size: 0.85em; /* inherit font-family from dojo.css */
-moz-outline-style: none;
outline: none;
}
 
.tundra .dojoxGrid table {
padding: 0;
}
 
.tundra .dojoxGrid td {
-moz-outline: none;
}
 
/* master header */
 
.tundra .dojoxGrid-master-header {
position: relative;
}
 
/* master view */
 
.tundra .dojoxGrid-master-view {
position: relative;
}
 
/* views */
 
.tundra .dojoxGrid-view {
position: absolute;
overflow: hidden;
}
 
/* header */
 
.tundra .dojoxGrid-header {
position: absolute;
overflow: hidden;
}
 
.tundra .dojoxGrid-header {
background-color: #e9e9e9;
}
 
.tundra .dojoxGrid-header table {
text-align: center;
}
 
.tundra .dojoxGrid-header .dojoxGrid-cell-content {
text-align: center;
}
 
.tundra .dojoxGrid-header .dojoxGrid-cell {
border: 1px solid transparent;
/* border-color: #F6F4EB #ACA899 #ACA899 #F6F4EB; */
border-color: white #ACA899 #919191 white;
background: url(../../../dijit/themes/tundra/images/tabEnabled.png) #e9e9e9 repeat-x top;
padding-bottom: 2px;
}
 
.tundra .dojoxGrid-header .dojoxGrid-cell-over {
background: url(../../../dijit/themes/tundra/images/tabHover.png) #e9e9e9 repeat-x top;
}
 
.tundra .dojoxGrid-sort-down {
background: url(../../../dijit/themes/tundra/images/arrowDown.png) right no-repeat;
padding-left: 0px;
margin-left: 0px;
}
 
.tundra .dojoxGrid-sort-up {
background: url(../../../dijit/themes/tundra/images/arrowUp.png) right no-repeat;
padding-left: 0px;
margin-left: 0px;
}
 
/* content */
 
.tundra .dojoxGrid-scrollbox {
position: relative;
overflow: scroll;
background-color: #fefefe;
width: 100%;
}
 
.tundra .dojoxGrid-content {
position: relative;
overflow: hidden;
-moz-outline-style: none;
outline: none;
}
 
/* rowbar */
 
.tundra .dojoxGrid-rowbar {
border: none;
/*
border-color: #F6F4EB #ACA899 #ACA899 #F6F4EB;
*/
background: url(images/tabEnabled_rotated.png) #e9e9e9 repeat-y right;
border-right: 1px solid #cccccc;
padding: 0px;
}
 
.tundra .dojoxGrid-rowbar-inner {
border: none;
border-bottom: 1px solid #cccccc;
}
 
.tundra .dojoxGrid-rowbar-over {
background: url(images/tabHover_rotated.png) #e9e9e9 repeat-y right;
}
 
.tundra .dojoxGrid-rowbar-selected {
background-color: #D9E8F9;
background-image: none;
background: url(../../../dijit/themes/tundra/images/tabDisabled.png) #dddddd repeat-x top;
border-right: 1px solid #cccccc;
background-position: center;
background-repeat: no-repeat;
}
 
/* rows */
 
.tundra .dojoxGrid-row {
position: relative;
width: 9000em;
}
 
.tundra .dojoxGrid-row {
border: none;
border-left: none;
border-right: none;
background-color: white;
border-top: none;
}
 
.tundra .dojoxGrid-row-over {
border-top-color: #cccccc;
border-bottom-color: #cccccc;
}
 
.tundra .dojoxGrid-row-over .dojoxGrid-cell {
/* background-color: #e9e9e9; */
background: url(../../../dijit/themes/tundra/images/tabEnabled.png) #e9e9e9 repeat-x top;
}
 
.tundra .dojoxGrid-row-odd {
background-color: #f2f5f9;
/*background-color: #F9F7E8;*/
}
 
.tundra .dojoxGrid-row-selected {
background-color: #D9E8F9;
/*
background: url(../../../dijit/themes/tundra/images/tabDisabled.png) #dddddd repeat-x top;
*/
}
 
.tundra .dojoxGrid-row-table {
table-layout: fixed;
width: 0;
}
 
.tundra .dojoxGrid-invisible {
visibility: hidden;
}
 
.tundra .Xdojo-ie .dojoxGrid-invisible {
display: none;
}
 
.tundra .dojoxGrid-invisible td, .dojoxGrid-header .dojoxGrid-invisible td {
border-top-width: 0;
border-bottom-width: 0;
padding-top: 0;
padding-bottom: 0;
height: 0;
overflow: hidden;
}
 
/* cells */
 
.tundra .dojoxGrid-cell {
border: 1px solid transparent;
border-right: 1px solid #D5CDB5;
padding: 3px 3px 3px 3px;
text-align: left;
overflow: hidden;
}
 
.dj_ie6 .tundra .dojoxGrid-cell {
border: 1px solid white;
border-right: 1px solid #D5CDB5;
}
 
.tundra .dojoxGrid-cell-focus {
border: 1px dotted #a6a6a6;
}
 
.tundra .dojoxGrid-cell-over {
border: 1px dotted #a6a6a6;
}
 
.tundra .dojoxGrid-cell-focus.dojoxGrid-cell-over {
border: 1px dotted #595959;
}
 
.tundra .dojoxGrid-cell-clip {
width: 100%;
overflow: hidden;
white-space:nowrap;
text-overflow: ellipsis;
}
 
/* editing */
 
/* FIXME: these colors are off! */
.tundra .dojoxGrid-row-editing td {
/* background-color: #F4FFF4; */
background: #f1f6fc url(../../../dijit/themes/tundra/images/buttonHover.png) repeat-x bottom;
/* padding: 0px 3px 0px 3px; */
}
 
.tundra .dojoxGrid-row-inserting td {
background-color: #F4FFF4;
}
.tundra .dojoxGrid-row-inflight td {
background-color: #F2F7B7;
}
.tundra .dojoxGrid-row-error td {
background-color: #F8B8B6;
}
 
.tundra .dojoxGrid-input,
.tundra .dojoxGrid-select,
.tundra .dojoxGrid-textarea {
margin: 0;
padding: 0px;
border-style: none;
width: 100%;
font-size: 100%;
font-family: inherit;
}
 
.dojoxGrid-hidden-focus {
position: absolute;
left: -1000px;
top: -1000px;
height: 0px, width: 0px;
}
/trunk/api/js/dojo1.0/dojox/grid/VirtualGrid.js
New file
0,0 → 1,631
if(!dojo._hasResource["dojox.grid.VirtualGrid"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid.VirtualGrid"] = true;
dojo.provide("dojox.grid.VirtualGrid");
dojo.require("dojox.grid._grid.lib");
dojo.require("dojox.grid._grid.scroller");
dojo.require("dojox.grid._grid.view");
dojo.require("dojox.grid._grid.views");
dojo.require("dojox.grid._grid.layout");
dojo.require("dojox.grid._grid.rows");
dojo.require("dojox.grid._grid.focus");
dojo.require("dojox.grid._grid.selection");
dojo.require("dojox.grid._grid.edit");
dojo.require("dojox.grid._grid.rowbar");
dojo.require("dojox.grid._grid.publicEvents");
 
dojo.declare('dojox.VirtualGrid',
[ dijit._Widget, dijit._Templated ],
{
// summary:
// A grid widget with virtual scrolling, cell editing, complex rows,
// sorting, fixed columns, sizeable columns, etc.
//
// description:
// VirtualGrid provides the full set of grid features without any
// direct connection to a data store.
//
// The grid exposes a get function for the grid, or optionally
// individual columns, to populate cell contents.
//
// The grid is rendered based on its structure, an object describing
// column and cell layout.
//
// example:
// A quick sample:
//
// define a get function
// | function get(inRowIndex){ // called in cell context
// | return [this.index, inRowIndex].join(', ');
// | }
//
// define the grid structure:
// | var structure = [ // array of view objects
// | { cells: [// array of rows, a row is an array of cells
// | [
// | { name: "Alpha", width: 6 },
// | { name: "Beta" },
// | { name: "Gamma", get: get }]
// | ]}
// | ];
//
// | <div id="grid"
// | rowCount="100" get="get"
// | structure="structure"
// | dojoType="dojox.VirtualGrid"></div>
 
templateString: '<div class="dojoxGrid" hidefocus="hidefocus" role="wairole:grid"><div class="dojoxGrid-master-header" dojoAttachPoint="headerNode"></div><div class="dojoxGrid-master-view" dojoAttachPoint="viewsNode"></div><span dojoAttachPoint="lastFocusNode" tabindex="0"></span></div>',
// classTag: string
// css class applied to the grid's domNode
classTag: 'dojoxGrid',
get: function(inRowIndex){
/* summary: Default data getter.
description:
Provides data to display in a grid cell. Called in grid cell context.
So this.cell.index is the column index.
inRowIndex: integer
row for which to provide data
returns:
data to display for a given grid cell.
*/
},
// settings
// rowCount: int
// Number of rows to display.
rowCount: 5,
// keepRows: int
// Number of rows to keep in the rendering cache.
keepRows: 75,
// rowsPerPage: int
// Number of rows to render at a time.
rowsPerPage: 25,
// autoWidth: boolean
// If autoWidth is true, grid width is automatically set to fit the data.
autoWidth: false,
// autoHeight: boolean
// If autoHeight is true, grid height is automatically set to fit the data.
autoHeight: false,
// autoRender: boolean
// If autoRender is true, grid will render itself after initialization.
autoRender: true,
// defaultHeight: string
// default height of the grid, measured in any valid css unit.
defaultHeight: '15em',
// structure: object or string
// View layout defintion. Can be set to a layout object, or to the (string) name of a layout object.
structure: '',
// elasticView: int
// Override defaults and make the indexed grid view elastic, thus filling available horizontal space.
elasticView: -1,
// singleClickEdit: boolean
// Single-click starts editing. Default is double-click
singleClickEdit: false,
// private
sortInfo: 0,
themeable: true,
// initialization
buildRendering: function(){
this.inherited(arguments);
// reset get from blank function (needed for markup parsing) to null, if not changed
if(this.get == dojox.VirtualGrid.prototype.get){
this.get = null;
}
if(!this.domNode.getAttribute('tabIndex')){
this.domNode.tabIndex = "0";
}
this.createScroller();
this.createLayout();
this.createViews();
this.createManagers();
dojox.grid.initTextSizePoll();
this.connect(dojox.grid, "textSizeChanged", "textSizeChanged");
dojox.grid.funnelEvents(this.domNode, this, 'doKeyEvent', dojox.grid.keyEvents);
this.connect(this, "onShow", "renderOnIdle");
},
postCreate: function(){
// replace stock styleChanged with one that triggers an update
this.styleChanged = this._styleChanged;
this.setStructure(this.structure);
},
destroy: function(){
this.domNode.onReveal = null;
this.domNode.onSizeChange = null;
this.edit.destroy();
this.views.destroyViews();
this.inherited(arguments);
},
styleChanged: function(){
this.setStyledClass(this.domNode, '');
},
_styleChanged: function(){
this.styleChanged();
this.update();
},
textSizeChanged: function(){
setTimeout(dojo.hitch(this, "_textSizeChanged"), 1);
},
_textSizeChanged: function(){
if(this.domNode){
this.views.forEach(function(v){
v.content.update();
});
this.render();
}
},
sizeChange: function(){
dojox.grid.jobs.job(this.id + 'SizeChange', 50, dojo.hitch(this, "update"));
},
renderOnIdle: function() {
setTimeout(dojo.hitch(this, "render"), 1);
},
// managers
createManagers: function(){
// summary:
// create grid managers for various tasks including rows, focus, selection, editing
// row manager
this.rows = new dojox.grid.rows(this);
// focus manager
this.focus = new dojox.grid.focus(this);
// selection manager
this.selection = new dojox.grid.selection(this);
// edit manager
this.edit = new dojox.grid.edit(this);
},
// virtual scroller
createScroller: function(){
this.scroller = new dojox.grid.scroller.columns();
this.scroller.renderRow = dojo.hitch(this, "renderRow");
this.scroller.removeRow = dojo.hitch(this, "rowRemoved");
},
// layout
createLayout: function(){
this.layout = new dojox.grid.layout(this);
},
// views
createViews: function(){
this.views = new dojox.grid.views(this);
this.views.createView = dojo.hitch(this, "createView");
},
createView: function(inClass){
var c = eval(inClass);
var view = new c({ grid: this });
this.viewsNode.appendChild(view.domNode);
this.headerNode.appendChild(view.headerNode);
this.views.addView(view);
return view;
},
buildViews: function(){
for(var i=0, vs; (vs=this.layout.structure[i]); i++){
this.createView(vs.type || "dojox.GridView").setStructure(vs);
}
this.scroller.setContentNodes(this.views.getContentNodes());
},
setStructure: function(inStructure){
// summary:
// Install a new structure and rebuild the grid.
// inStructure: Object
// Structure object defines the grid layout and provides various
// options for grid views and columns
// description:
// A grid structure is an array of view objects. A view object can
// specify a view type (view class), width, noscroll (boolean flag
// for view scrolling), and cells. Cells is an array of objects
// corresponding to each grid column. The view cells object is an
// array of subrows comprising a single row. Each subrow is an
// array of column objects. A column object can have a name,
// width, value (default), get function to provide data, styles,
// and span attributes (rowSpan, colSpan).
 
this.views.destroyViews();
this.structure = inStructure;
if((this.structure)&&(dojo.isString(this.structure))){
this.structure=dojox.grid.getProp(this.structure);
}
if(!this.structure){
this.structure=window["layout"];
}
if(!this.structure){
return;
}
this.layout.setStructure(this.structure);
this._structureChanged();
},
_structureChanged: function() {
this.buildViews();
if(this.autoRender){
this.render();
}
},
// sizing
resize: function(){
// summary:
// Update the grid's rendering dimensions and resize it
// FIXME: If grid is not sized explicitly, sometimes bogus scrollbars
// can appear in our container, which may require an extra call to 'resize'
// to sort out.
// if we have set up everything except the DOM, we cannot resize
if(!this.domNode.parentNode){
return;
}
// useful measurement
var padBorder = dojo._getPadBorderExtents(this.domNode);
// grid height
if(this.autoHeight){
this.domNode.style.height = 'auto';
this.viewsNode.style.height = '';
}else if(this.flex > 0){
}else if(this.domNode.clientHeight <= padBorder.h){
if(this.domNode.parentNode == document.body){
this.domNode.style.height = this.defaultHeight;
}else{
this.fitTo = "parent";
}
}
if(this.fitTo == "parent"){
var h = dojo._getContentBox(this.domNode.parentNode).h;
dojo.marginBox(this.domNode, { h: Math.max(0, h) });
}
// header height
var t = this.views.measureHeader();
this.headerNode.style.height = t + 'px';
// content extent
var l = 1, h = (this.autoHeight ? -1 : Math.max(this.domNode.clientHeight - t, 0) || 0);
if(this.autoWidth){
// grid width set to total width
this.domNode.style.width = this.views.arrange(l, 0, 0, h) + 'px';
}else{
// views fit to our clientWidth
var w = this.domNode.clientWidth || (this.domNode.offsetWidth - padBorder.w);
this.views.arrange(l, 0, w, h);
}
// virtual scroller height
this.scroller.windowHeight = h;
// default row height (FIXME: use running average(?), remove magic #)
this.scroller.defaultRowHeight = this.rows.getDefaultHeightPx() + 1;
this.postresize();
},
resizeHeight: function(){
var t = this.views.measureHeader();
this.headerNode.style.height = t + 'px';
// content extent
var h = (this.autoHeight ? -1 : Math.max(this.domNode.clientHeight - t, 0) || 0);
//this.views.arrange(0, 0, 0, h);
this.views.onEach('setSize', [0, h]);
this.views.onEach('resizeHeight');
this.scroller.windowHeight = h;
},
// render
render: function(){
// summary:
// Render the grid, headers, and views. Edit and scrolling states are reset. To retain edit and
// scrolling states, see Update.
 
if(!this.domNode){return;}
//
this.update = this.defaultUpdate;
this.scroller.init(this.rowCount, this.keepRows, this.rowsPerPage);
this.prerender();
this.setScrollTop(0);
this.postrender();
},
prerender: function(){
this.views.render();
this.resize();
},
postrender: function(){
this.postresize();
this.focus.initFocusView();
// make rows unselectable
dojo.setSelectable(this.domNode, false);
},
postresize: function(){
// views are position absolute, so they do not inflate the parent
if(this.autoHeight){
this.viewsNode.style.height = this.views.measureContent() + 'px';
}
},
// private, used internally to render rows
renderRow: function(inRowIndex, inNodes){
this.views.renderRow(inRowIndex, inNodes);
},
// private, used internally to remove rows
rowRemoved: function(inRowIndex){
this.views.rowRemoved(inRowIndex);
},
invalidated: null,
updating: false,
beginUpdate: function(){
// summary:
// Use to make multiple changes to rows while queueing row updating.
// NOTE: not currently supporting nested begin/endUpdate calls
this.invalidated = [];
this.updating = true;
},
endUpdate: function(){
// summary:
// Use after calling beginUpdate to render any changes made to rows.
this.updating = false;
var i = this.invalidated;
if(i.all){
this.update();
}else if(i.rowCount != undefined){
this.updateRowCount(i.rowCount);
}else{
for(r in i){
this.updateRow(Number(r));
}
}
this.invalidated = null;
},
// update
defaultUpdate: function(){
// note: initial update calls render and subsequently this function.
if(this.updating){
this.invalidated.all = true;
return;
}
//this.edit.saveState(inRowIndex);
this.prerender();
this.scroller.invalidateNodes();
this.setScrollTop(this.scrollTop);
this.postrender();
//this.edit.restoreState(inRowIndex);
},
update: function(){
// summary:
// Update the grid, retaining edit and scrolling states.
this.render();
},
updateRow: function(inRowIndex){
// summary:
// Render a single row.
// inRowIndex: int
// index of the row to render
inRowIndex = Number(inRowIndex);
if(this.updating){
this.invalidated[inRowIndex]=true;
return;
}
this.views.updateRow(inRowIndex, this.rows.getHeight(inRowIndex));
this.scroller.rowHeightChanged(inRowIndex);
},
updateRowCount: function(inRowCount){
//summary:
// Change the number of rows.
// inRowCount: int
// Number of rows in the grid.
if(this.updating){
this.invalidated.rowCount = inRowCount;
return;
}
this.rowCount = inRowCount;
this.scroller.updateRowCount(inRowCount);
this.setScrollTop(this.scrollTop);
this.resize();
},
updateRowStyles: function(inRowIndex){
// summary:
// Update the styles for a row after it's state has changed.
this.views.updateRowStyles(inRowIndex);
},
rowHeightChanged: function(inRowIndex){
// summary:
// Update grid when the height of a row has changed. Row height is handled automatically as rows
// are rendered. Use this function only to update a row's height outside the normal rendering process.
// inRowIndex: int
// index of the row that has changed height
this.views.renormalizeRow(inRowIndex);
this.scroller.rowHeightChanged(inRowIndex);
},
// fastScroll: boolean
// flag modifies vertical scrolling behavior. Defaults to true but set to false for slower
// scroll performance but more immediate scrolling feedback
fastScroll: true,
delayScroll: false,
// scrollRedrawThreshold: int
// pixel distance a user must scroll vertically to trigger grid scrolling.
scrollRedrawThreshold: (dojo.isIE ? 100 : 50),
// scroll methods
scrollTo: function(inTop){
// summary:
// Vertically scroll the grid to a given pixel position
// inTop: int
// vertical position of the grid in pixels
if(!this.fastScroll){
this.setScrollTop(inTop);
return;
}
var delta = Math.abs(this.lastScrollTop - inTop);
this.lastScrollTop = inTop;
if(delta > this.scrollRedrawThreshold || this.delayScroll){
this.delayScroll = true;
this.scrollTop = inTop;
this.views.setScrollTop(inTop);
dojox.grid.jobs.job('dojoxGrid-scroll', 200, dojo.hitch(this, "finishScrollJob"));
}else{
this.setScrollTop(inTop);
}
},
finishScrollJob: function(){
this.delayScroll = false;
this.setScrollTop(this.scrollTop);
},
setScrollTop: function(inTop){
this.scrollTop = this.views.setScrollTop(inTop);
this.scroller.scroll(this.scrollTop);
},
scrollToRow: function(inRowIndex){
// summary:
// Scroll the grid to a specific row.
// inRowIndex: int
// grid row index
this.setScrollTop(this.scroller.findScrollTop(inRowIndex) + 1);
},
// styling (private, used internally to style individual parts of a row)
styleRowNode: function(inRowIndex, inRowNode){
if(inRowNode){
this.rows.styleRowNode(inRowIndex, inRowNode);
}
},
// cells
getCell: function(inIndex){
// summary:
// retrieves the cell object for a given grid column.
// inIndex: int
// grid column index of cell to retrieve
// returns:
// a grid cell
return this.layout.cells[inIndex];
},
setCellWidth: function(inIndex, inUnitWidth) {
this.getCell(inIndex).unitWidth = inUnitWidth;
},
getCellName: function(inCell){
return "Cell " + inCell.index;
},
// sorting
canSort: function(inSortInfo){
// summary:
// determines if the grid can be sorted
// inSortInfo: int
// Sort information, 1-based index of column on which to sort, positive for an ascending sort
// and negative for a descending sort
// returns:
// true if grid can be sorted on the given column in the given direction
},
sort: function(){
},
getSortAsc: function(inSortInfo){
// summary:
// returns true if grid is sorted in an ascending direction.
inSortInfo = inSortInfo == undefined ? this.sortInfo : inSortInfo;
return Boolean(inSortInfo > 0);
},
getSortIndex: function(inSortInfo){
// summary:
// returns the index of the column on which the grid is sorted
inSortInfo = inSortInfo == undefined ? this.sortInfo : inSortInfo;
return Math.abs(inSortInfo) - 1;
},
setSortIndex: function(inIndex, inAsc){
// summary:
// Sort the grid on a column in a specified direction
// inIndex: int
// Column index on which to sort.
// inAsc: boolean
// If true, sort the grid in ascending order, otherwise in descending order
var si = inIndex +1;
if(inAsc != undefined){
si *= (inAsc ? 1 : -1);
} else if(this.getSortIndex() == inIndex){
si = -this.sortInfo;
}
this.setSortInfo(si);
},
setSortInfo: function(inSortInfo){
if(this.canSort(inSortInfo)){
this.sortInfo = inSortInfo;
this.sort();
this.update();
}
},
// DOM event handler
doKeyEvent: function(e){
e.dispatch = 'do' + e.type;
this.onKeyEvent(e);
},
// event dispatch
//: protected
_dispatch: function(m, e){
if(m in this){
return this[m](e);
}
},
dispatchKeyEvent: function(e){
this._dispatch(e.dispatch, e);
},
dispatchContentEvent: function(e){
this.edit.dispatchEvent(e) || e.sourceView.dispatchContentEvent(e) || this._dispatch(e.dispatch, e);
},
dispatchHeaderEvent: function(e){
e.sourceView.dispatchHeaderEvent(e) || this._dispatch('doheader' + e.type, e);
},
dokeydown: function(e){
this.onKeyDown(e);
},
doclick: function(e){
if(e.cellNode){
this.onCellClick(e);
}else{
this.onRowClick(e);
}
},
dodblclick: function(e){
if(e.cellNode){
this.onCellDblClick(e);
}else{
this.onRowDblClick(e);
}
},
docontextmenu: function(e){
if(e.cellNode){
this.onCellContextMenu(e);
}else{
this.onRowContextMenu(e);
}
},
doheaderclick: function(e){
if(e.cellNode){
this.onHeaderCellClick(e);
}else{
this.onHeaderClick(e);
}
},
doheaderdblclick: function(e){
if(e.cellNode){
this.onHeaderCellDblClick(e);
}else{
this.onHeaderDblClick(e);
}
},
doheadercontextmenu: function(e){
if(e.cellNode){
this.onHeaderCellContextMenu(e);
}else{
this.onHeaderContextMenu(e);
}
},
// override to modify editing process
doStartEdit: function(inCell, inRowIndex){
this.onStartEdit(inCell, inRowIndex);
},
doApplyCellEdit: function(inValue, inRowIndex, inFieldIndex){
this.onApplyCellEdit(inValue, inRowIndex, inFieldIndex);
},
doCancelEdit: function(inRowIndex){
this.onCancelEdit(inRowIndex);
},
doApplyEdit: function(inRowIndex){
this.onApplyEdit(inRowIndex);
},
// row editing
addRow: function(){
// summary:
// add a row to the grid.
this.updateRowCount(this.rowCount+1);
},
removeSelectedRows: function(){
// summary:
// remove the selected rows from the grid.
this.updateRowCount(Math.max(0, this.rowCount - this.selection.getSelected().length));
this.selection.clear();
}
});
 
dojo.mixin(dojox.VirtualGrid.prototype, dojox.grid.publicEvents);
 
}
/trunk/api/js/dojo1.0/dojox/grid/_data/model.js
New file
0,0 → 1,600
if(!dojo._hasResource['dojox.grid._data.model']){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource['dojox.grid._data.model'] = true;
dojo.provide('dojox.grid._data.model');
dojo.require('dojox.grid._data.fields');
 
dojo.declare("dojox.grid.data.Model", null, {
// summary:
// Base abstract grid data model.
// Makes no assumptions about the structure of grid data.
constructor: function(inFields, inData){
this.observers = [];
this.fields = new dojox.grid.data.Fields();
if(inFields){
this.fields.set(inFields);
}
this.setData(inData);
},
count: 0,
updating: 0,
// observers
observer: function(inObserver, inPrefix){
this.observers.push({o: inObserver, p: inPrefix||'model' });
},
notObserver: function(inObserver){
for(var i=0, m, o; (o=this.observers[i]); i++){
if(o.o==inObserver){
this.observers.splice(i, 1);
return;
}
}
},
notify: function(inMsg, inArgs){
if(!this.isUpdating()){
var a = inArgs || [];
for(var i=0, m, o; (o=this.observers[i]); i++){
m = o.p + inMsg, o = o.o;
(m in o)&&(o[m].apply(o, a));
}
}
},
// updates
clear: function(){
this.fields.clear();
this.clearData();
},
beginUpdate: function(){
this.updating++;
},
endUpdate: function(){
if(this.updating){
this.updating--;
}
/*if(this.updating){
if(!(--this.updating)){
this.change();
}
}
}*/
},
isUpdating: function(){
return Boolean(this.updating);
},
// data
clearData: function(){
this.setData(null);
},
// observer events
change: function(){
this.notify("Change", arguments);
},
insertion: function(/* index */){
this.notify("Insertion", arguments);
this.notify("Change", arguments);
},
removal: function(/* keys */){
this.notify("Removal", arguments);
this.notify("Change", arguments);
},
// insert
insert: function(inData /*, index */){
if(!this._insert.apply(this, arguments)){
return false;
}
this.insertion.apply(this, dojo._toArray(arguments, 1));
return true;
},
// remove
remove: function(inData /*, index */){
if(!this._remove.apply(this, arguments)){
return false;
}
this.removal.apply(this, arguments);
return true;
},
// sort
canSort: function(/* (+|-)column_index+1, ... */){
return this.sort != null;
},
makeComparator: function(inIndices){
var idx, col, field, result = null;
for(var i=inIndices.length-1; i>=0; i--){
idx = inIndices[i];
col = Math.abs(idx) - 1;
if(col >= 0){
field = this.fields.get(col);
result = this.generateComparator(field.compare, field.key, idx > 0, result);
}
}
return result;
},
sort: null,
dummy: 0
});
 
dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, {
// observer events
allChange: function(){
this.notify("AllChange", arguments);
this.notify("Change", arguments);
},
rowChange: function(){
this.notify("RowChange", arguments);
},
datumChange: function(){
this.notify("DatumChange", arguments);
},
// copyRow: function(inRowIndex); // abstract
// update
beginModifyRow: function(inRowIndex){
if(!this.cache[inRowIndex]){
this.cache[inRowIndex] = this.copyRow(inRowIndex);
}
},
endModifyRow: function(inRowIndex){
var cache = this.cache[inRowIndex];
if(cache){
var data = this.getRow(inRowIndex);
if(!dojox.grid.arrayCompare(cache, data)){
this.update(cache, data, inRowIndex);
}
delete this.cache[inRowIndex];
}
},
cancelModifyRow: function(inRowIndex){
var cache = this.cache[inRowIndex];
if(cache){
this.setRow(cache, inRowIndex);
delete this.cache[inRowIndex];
}
},
generateComparator: function(inCompare, inField, inTrueForAscend, inSubCompare){
return function(a, b){
var ineq = inCompare(a[inField], b[inField]);
return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b);
}
}
});
 
dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, {
// summary:
// Basic grid data model for static data in the form of an array of rows
// that are arrays of cell data
constructor: function(){
this.cache = [];
},
colCount: 0, // tables introduce cols
data: null,
cache: null,
// morphology
measure: function(){
this.count = this.getRowCount();
this.colCount = this.getColCount();
this.allChange();
//this.notify("Measure");
},
getRowCount: function(){
return (this.data ? this.data.length : 0);
},
getColCount: function(){
return (this.data && this.data.length ? this.data[0].length : this.fields.count());
},
badIndex: function(inCaller, inDescriptor){
console.debug('dojox.grid.data.Table: badIndex');
},
isGoodIndex: function(inRowIndex, inColIndex){
return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount)));
},
// access
getRow: function(inRowIndex){
return this.data[inRowIndex];
},
copyRow: function(inRowIndex){
return this.getRow(inRowIndex).slice(0);
},
getDatum: function(inRowIndex, inColIndex){
return this.data[inRowIndex][inColIndex];
},
get: function(){
throw('Plain "get" no longer supported. Use "getRow" or "getDatum".');
},
setData: function(inData){
this.data = (inData || []);
this.allChange();
},
setRow: function(inData, inRowIndex){
this.data[inRowIndex] = inData;
this.rowChange(inData, inRowIndex);
this.change();
},
setDatum: function(inDatum, inRowIndex, inColIndex){
this.data[inRowIndex][inColIndex] = inDatum;
this.datumChange(inDatum, inRowIndex, inColIndex);
},
set: function(){
throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".');
},
setRows: function(inData, inRowIndex){
for(var i=0, l=inData.length, r=inRowIndex; i<l; i++, r++){
this.setRow(inData[i], r);
}
},
// update
update: function(inOldData, inNewData, inRowIndex){
//delete this.cache[inRowIndex];
//this.setRow(inNewData, inRowIndex);
return true;
},
// insert
_insert: function(inData, inRowIndex){
dojox.grid.arrayInsert(this.data, inRowIndex, inData);
this.count++;
return true;
},
// remove
_remove: function(inKeys){
for(var i=inKeys.length-1; i>=0; i--){
dojox.grid.arrayRemove(this.data, inKeys[i]);
}
this.count -= inKeys.length;
return true;
},
// sort
sort: function(/* (+|-)column_index+1, ... */){
this.data.sort(this.makeComparator(arguments));
},
swap: function(inIndexA, inIndexB){
dojox.grid.arraySwap(this.data, inIndexA, inIndexB);
this.rowChange(this.getRow(inIndexA), inIndexA);
this.rowChange(this.getRow(inIndexB), inIndexB);
this.change();
},
dummy: 0
});
 
dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, {
constructor: function(inFields, inData, inKey){
if(!inFields){
this.autoAssignFields();
}
},
autoAssignFields: function(){
var d = this.data[0], i = 0;
for(var f in d){
this.fields.get(i++).key = f;
}
},
getDatum: function(inRowIndex, inColIndex){
return this.data[inRowIndex][this.fields.get(inColIndex).key];
}
});
 
dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, {
// summary:
// Grid data model for dynamic data such as data retrieved from a server.
// Retrieves data automatically when requested and provides notification when data is received
constructor: function(){
this.page = [];
this.pages = [];
},
page: null,
pages: null,
rowsPerPage: 100,
requests: 0,
bop: -1,
eop: -1,
// data
clearData: function(){
this.pages = [];
this.bop = this.eop = -1;
this.setData([]);
},
getRowCount: function(){
return this.count;
},
getColCount: function(){
return this.fields.count();
},
setRowCount: function(inCount){
this.count = inCount;
this.change();
},
// paging
requestsPending: function(inBoolean){
},
rowToPage: function(inRowIndex){
return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex);
},
pageToRow: function(inPageIndex){
return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex);
},
requestRows: function(inRowIndex, inCount){
// summary:
// stub. Fill in to perform actual data row fetching logic. The
// returning logic must provide the data back to the system via
// setRow
},
rowsProvided: function(inRowIndex, inCount){
this.requests--;
if(this.requests == 0){
this.requestsPending(false);
}
},
requestPage: function(inPageIndex){
var row = this.pageToRow(inPageIndex);
var count = Math.min(this.rowsPerPage, this.count - row);
if(count > 0){
this.requests++;
this.requestsPending(true);
setTimeout(dojo.hitch(this, "requestRows", row, count), 1);
//this.requestRows(row, count);
}
},
needPage: function(inPageIndex){
if(!this.pages[inPageIndex]){
this.pages[inPageIndex] = true;
this.requestPage(inPageIndex);
}
},
preparePage: function(inRowIndex, inColIndex){
if(inRowIndex < this.bop || inRowIndex >= this.eop){
var pageIndex = this.rowToPage(inRowIndex);
this.needPage(pageIndex);
this.bop = pageIndex * this.rowsPerPage;
this.eop = this.bop + (this.rowsPerPage || this.count);
}
},
isRowLoaded: function(inRowIndex){
return Boolean(this.data[inRowIndex]);
},
// removal
removePages: function(inRowIndexes){
for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){
this.pages[this.rowToPage(r)] = false;
}
this.bop = this.eop =-1;
},
remove: function(inRowIndexes){
this.removePages(inRowIndexes);
dojox.grid.data.Table.prototype.remove.apply(this, arguments);
},
// access
getRow: function(inRowIndex){
var row = this.data[inRowIndex];
if(!row){
this.preparePage(inRowIndex);
}
return row;
},
getDatum: function(inRowIndex, inColIndex){
var row = this.getRow(inRowIndex);
return (row ? row[inColIndex] : this.fields.get(inColIndex).na);
},
setDatum: function(inDatum, inRowIndex, inColIndex){
var row = this.getRow(inRowIndex);
if(row){
row[inColIndex] = inDatum;
this.datumChange(inDatum, inRowIndex, inColIndex);
}else{
console.debug('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on an non-loaded row');
}
},
// sort
canSort: function(){
return false;
}
});
 
// FIXME: deprecated: (included for backward compatibility only)
dojox.grid.data.table = dojox.grid.data.Table;
dojox.grid.data.dynamic = dojox.grid.data.Dyanamic;
 
// we treat dojo.data stores as dynamic stores because no matter how they got
// here, they should always fill that contract
dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, {
// summary:
// A grid data model for dynamic data retreived from a store which
// implements the dojo.data API set. Retrieves data automatically when
// requested and provides notification when data is received
// description:
// This store subclasses the Dynamic grid data object in order to
// provide paginated data access support, notification and view
// updates for stores which support those features, and simple
// field/column mapping for all dojo.data stores.
constructor: function(inFields, inData, args){
this.count = 1;
this._rowIdentities = {};
if(args){
dojo.mixin(this, args);
}
if(this.store){
// NOTE: we assume Read and Identity APIs for all stores!
var f = this.store.getFeatures();
this._canNotify = f['dojo.data.api.Notification'];
this._canWrite = f['dojo.data.api.Write'];
 
if(this._canNotify){
dojo.connect(this.store, "onSet", this, "_storeDatumChange");
}
}
},
markupFactory: function(args, node){
return new dojox.grid.data.DojoData(null, null, args);
},
query: { name: "*" }, // default, stupid query
store: null,
_canNotify: false,
_canWrite: false,
_rowIdentities: {},
clientSort: false,
// data
setData: function(inData){
this.store = inData;
this.data = [];
this.allChange();
},
setRowCount: function(inCount){
//console.debug("inCount:", inCount);
this.count = inCount;
this.allChange();
},
beginReturn: function(inCount){
if(this.count != inCount){
// this.setRowCount(0);
// this.clear();
// console.debug(this.count, inCount);
this.setRowCount(inCount);
}
},
_setupFields: function(dataItem){
// abort if we already have setup fields
if(this.fields._nameMaps){
return;
}
// set up field/index mappings
var m = {};
//console.debug("setting up fields", m);
var fields = dojo.map(this.store.getAttributes(dataItem),
function(item, idx){
m[item] = idx;
m[idx+".idx"] = item;
// name == display name, key = property name
return { name: item, key: item };
},
this
);
this.fields._nameMaps = m;
// console.debug("new fields:", fields);
this.fields.set(fields);
this.notify("FieldsChange");
},
_getRowFromItem: function(item){
// gets us the row object (and row index) of an item
},
processRows: function(items, store){
// console.debug(arguments);
if(!items){ return; }
this._setupFields(items[0]);
dojo.forEach(items, function(item, idx){
var row = {};
row.__dojo_data_item = item;
dojo.forEach(this.fields.values, function(a){
row[a.name] = this.store.getValue(item, a.name)||"";
}, this);
// FIXME: where else do we need to keep this in sync?
this._rowIdentities[this.store.getIdentity(item)] = store.start+idx;
this.setRow(row, store.start+idx);
}, this);
// FIXME:
// Q: scott, steve, how the hell do we actually get this to update
// the visible UI for these rows?
// A: the goal is that Grid automatically updates to reflect changes
// in model. In this case, setRow -> rowChanged -> (observed by) Grid -> modelRowChange -> updateRow
},
// request data
requestRows: function(inRowIndex, inCount){
var row = inRowIndex || 0;
var params = {
start: row,
count: this.rowsPerPage,
query: this.query,
onBegin: dojo.hitch(this, "beginReturn"),
// onItem: dojo.hitch(console, "debug"),
onComplete: dojo.hitch(this, "processRows") // add to deferred?
}
// console.debug("requestRows:", row, this.rowsPerPage);
this.store.fetch(params);
},
getDatum: function(inRowIndex, inColIndex){
//console.debug("getDatum", inRowIndex, inColIndex);
var row = this.getRow(inRowIndex);
var field = this.fields.values[inColIndex];
return row && field ? row[field.name] : field ? field.na : '?';
//var idx = row && this.fields._nameMaps[inColIndex+".idx"];
//return (row ? row[idx] : this.fields.get(inColIndex).na);
},
setDatum: function(inDatum, inRowIndex, inColIndex){
var n = this.fields._nameMaps[inColIndex+".idx"];
// console.debug("setDatum:", "n:"+n, inDatum, inRowIndex, inColIndex);
if(n){
this.data[inRowIndex][n] = inDatum;
this.datumChange(inDatum, inRowIndex, inColIndex);
}
},
// modification, update and store eventing
copyRow: function(inRowIndex){
var row = {};
var backstop = {};
var src = this.getRow(inRowIndex);
for(var x in src){
if(src[x] != backstop[x]){
row[x] = src[x];
}
}
return row;
},
_attrCompare: function(cache, data){
dojo.forEach(this.fields.values, function(a){
if(cache[a.name] != data[a.name]){ return false; }
}, this);
return true;
},
endModifyRow: function(inRowIndex){
var cache = this.cache[inRowIndex];
if(cache){
var data = this.getRow(inRowIndex);
if(!this._attrCompare(cache, data)){
this.update(cache, data, inRowIndex);
}
delete this.cache[inRowIndex];
}
},
cancelModifyRow: function(inRowIndex){
// console.debug("cancelModifyRow", arguments);
var cache = this.cache[inRowIndex];
if(cache){
this.setRow(cache, inRowIndex);
delete this.cache[inRowIndex];
}
},
_storeDatumChange: function(item, attr, oldVal, newVal){
// the store has changed some data under us, need to update the display
var rowId = this._rowIdentities[this.store.getIdentity(item)];
var row = this.getRow(rowId);
row[attr] = newVal;
var colId = this.fields._nameMaps[attr];
this.notify("DatumChange", [ newVal, rowId, colId ]);
},
datumChange: function(value, rowIdx, colIdx){
if(this._canWrite){
// we're chaning some data, which means we need to write back
var row = this.getRow(rowIdx);
var field = this.fields._nameMaps[colIdx+".idx"];
this.store.setValue(row.__dojo_data_item, field, value);
// we don't need to call DatumChange, an eventing store will tell
// us about the row change events
}else{
// we can't write back, so just go ahead and change our local copy
// of the data
this.notify("DatumChange", arguments);
}
},
insertion: function(/* index */){
console.debug("Insertion", arguments);
this.notify("Insertion", arguments);
this.notify("Change", arguments);
},
removal: function(/* keys */){
console.debug("Removal", arguments);
this.notify("Removal", arguments);
this.notify("Change", arguments);
},
// sort
canSort: function(){
// Q: Return true and re-issue the queries?
// A: Return true only. Re-issue the query in 'sort'.
return this.clientSort;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/_data/fields.js
New file
0,0 → 1,104
if(!dojo._hasResource["dojox.grid._data.fields"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._data.fields"] = true;
dojo.provide("dojox.grid._data.fields");
 
dojo.declare("dojox.grid.data.Mixer", null, {
// summary:
// basic collection class that provides a default value for items
constructor: function(){
this.defaultValue = {};
this.values = [];
},
count: function(){
return this.values.length;
},
clear: function(){
this.values = [];
},
build: function(inIndex){
var result = dojo.mixin({owner: this}, this.defaultValue);
result.key = inIndex;
this.values[inIndex] = result;
return result;
},
getDefault: function(){
return this.defaultValue;
},
setDefault: function(inField /*[, inField2, ... inFieldN] */){
for(var i=0, a; (a = arguments[i]); i++){
dojo.mixin(this.defaultValue, a);
}
},
get: function(inIndex){
return this.values[inIndex] || this.build(inIndex);
},
_set: function(inIndex, inField /*[, inField2, ... inFieldN] */){
// each field argument can be a single field object of an array of field objects
var v = this.get(inIndex);
for(var i=1; i<arguments.length; i++){
dojo.mixin(v, arguments[i]);
}
this.values[inIndex] = v;
},
set: function(/* inIndex, inField [, inField2, ... inFieldN] | inArray */){
if(arguments.length < 1){
return;
}
var a = arguments[0];
if(!dojo.isArray(a)){
this._set.apply(this, arguments);
}else{
if(a.length && a[0]["default"]){
this.setDefault(a.shift());
}
for(var i=0, l=a.length; i<l; i++){
this._set(i, a[i]);
}
}
},
insert: function(inIndex, inProps){
if (inIndex >= this.values.length){
this.values[inIndex] = inProps;
}else{
this.values.splice(inIndex, 0, inProps);
}
},
remove: function(inIndex){
this.values.splice(inIndex, 1);
},
swap: function(inIndexA, inIndexB){
dojox.grid.arraySwap(this.values, inIndexA, inIndexB);
},
move: function(inFromIndex, inToIndex){
dojox.grid.arrayMove(this.values, inFromIndex, inToIndex);
}
});
 
dojox.grid.data.compare = function(a, b){
return (a > b ? 1 : (a == b ? 0 : -1));
}
 
dojo.declare('dojox.grid.data.Field', null, {
constructor: function(inName){
this.name = inName;
this.compare = dojox.grid.data.compare;
},
na: dojox.grid.na
});
 
dojo.declare('dojox.grid.data.Fields', dojox.grid.data.Mixer, {
constructor: function(inFieldClass){
var fieldClass = inFieldClass ? inFieldClass : dojox.grid.data.Field;
this.defaultValue = new fieldClass();
},
indexOf: function(inKey){
for(var i=0; i<this.values.length; i++){
var v = this.values[i];
if(v && v.key == inKey){return i;}
}
return -1;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/grid/_data/editors.js
New file
0,0 → 1,239
if(!dojo._hasResource["dojox.grid._data.editors"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._data.editors"] = true;
dojo.provide("dojox.grid._data.editors");
dojo.provide("dojox.grid.editors");
 
dojo.declare("dojox.grid.editors.Base", null, {
// summary:
// base grid editor class. Other grid editors should inherited from this class.
constructor: function(inCell){
this.cell = inCell;
},
//private
_valueProp: "value",
_formatPending: false,
format: function(inDatum, inRowIndex){
// summary:
// formats the cell for editing
// inDatum: anything
// cell data to edit
// inRowIndex: int
// grid row index
// returns: string of html to place in grid cell
},
//protected
needFormatNode: function(inDatum, inRowIndex){
this._formatPending = true;
dojox.grid.whenIdle(this, "_formatNode", inDatum, inRowIndex);
},
cancelFormatNode: function(){
this._formatPending = false;
},
//private
_formatNode: function(inDatum, inRowIndex){
if(this._formatPending){
this._formatPending = false;
// make cell selectable
dojo.setSelectable(this.cell.grid.domNode, true);
this.formatNode(this.getNode(inRowIndex), inDatum, inRowIndex);
}
},
//protected
getNode: function(inRowIndex){
return (this.cell.getNode(inRowIndex) || 0).firstChild || 0;
},
formatNode: function(inNode, inDatum, inRowIndex){
// summary:
// format the editing dom node. Use when editor is a widget.
// inNode: dom node
// dom node for the editor
// inDatum: anything
// cell data to edit
// inRowIndex: int
// grid row index
if(dojo.isIE){
// IE sux bad
dojox.grid.whenIdle(this, "focus", inRowIndex, inNode);
}else{
this.focus(inRowIndex, inNode);
}
},
dispatchEvent: function(m, e){
if(m in this){
return this[m](e);
}
},
//public
getValue: function(inRowIndex){
// summary:
// returns value entered into editor
// inRowIndex: int
// grid row index
// returns:
// value of editor
return this.getNode(inRowIndex)[this._valueProp];
},
setValue: function(inRowIndex, inValue){
// summary:
// set the value of the grid editor
// inRowIndex: int
// grid row index
// inValue: anything
// value of editor
var n = this.getNode(inRowIndex);
if(n){
n[this._valueProp] = inValue
};
},
focus: function(inRowIndex, inNode){
// summary:
// focus the grid editor
// inRowIndex: int
// grid row index
// inNode: dom node
// editor node
dojox.grid.focusSelectNode(inNode || this.getNode(inRowIndex));
},
save: function(inRowIndex){
// summary:
// save editor state
// inRowIndex: int
// grid row index
this.value = this.value || this.getValue(inRowIndex);
//console.log("save", this.value, inCell.index, inRowIndex);
},
restore: function(inRowIndex){
// summary:
// restore editor state
// inRowIndex: int
// grid row index
this.setValue(inRowIndex, this.value);
//console.log("restore", this.value, inCell.index, inRowIndex);
},
//protected
_finish: function(inRowIndex){
// summary:
// called when editing is completed to clean up editor
// inRowIndex: int
// grid row index
dojo.setSelectable(this.cell.grid.domNode, false);
this.cancelFormatNode(this.cell);
},
//public
apply: function(inRowIndex){
// summary:
// apply edit from cell editor
// inRowIndex: int
// grid row index
this.cell.applyEdit(this.getValue(inRowIndex), inRowIndex);
this._finish(inRowIndex);
},
cancel: function(inRowIndex){
// summary:
// cancel cell edit
// inRowIndex: int
// grid row index
this.cell.cancelEdit(inRowIndex);
this._finish(inRowIndex);
}
});
dojox.grid.editors.base = dojox.grid.editors.Base; // back-compat
 
dojo.declare("dojox.grid.editors.Input", dojox.grid.editors.Base, {
// summary
// grid cell editor that provides a standard text input box
constructor: function(inCell){
this.keyFilter = this.keyFilter || this.cell.keyFilter;
},
// keyFilter: object
// optional regex for disallowing keypresses
keyFilter: null,
format: function(inDatum, inRowIndex){
this.needFormatNode(inDatum, inRowIndex);
return '<input class="dojoxGrid-input" type="text" value="' + inDatum + '">';
},
formatNode: function(inNode, inDatum, inRowIndex){
this.inherited(arguments);
// FIXME: feels too specific for this interface
this.cell.registerOnBlur(inNode, inRowIndex);
},
doKey: function(e){
if(this.keyFilter){
var key = String.fromCharCode(e.charCode);
if(key.search(this.keyFilter) == -1){
dojo.stopEvent(e);
}
}
},
_finish: function(inRowIndex){
this.inherited(arguments);
var n = this.getNode(inRowIndex);
try{
dojox.grid.fire(n, "blur");
}catch(e){}
}
});
dojox.grid.editors.input = dojox.grid.editors.Input; // back compat
 
dojo.declare("dojox.grid.editors.Select", dojox.grid.editors.Input, {
// summary:
// grid cell editor that provides a standard select
// options: text of each item
// values: value for each item
// returnIndex: editor returns only the index of the selected option and not the value
constructor: function(inCell){
this.options = this.options || this.cell.options;
this.values = this.values || this.cell.values || this.options;
},
format: function(inDatum, inRowIndex){
this.needFormatNode(inDatum, inRowIndex);
var h = [ '<select class="dojoxGrid-select">' ];
for (var i=0, o, v; (o=this.options[i])&&(v=this.values[i]); i++){
h.push("<option", (inDatum==o ? ' selected' : ''), /*' value="' + v + '"',*/ ">", o, "</option>");
}
h.push('</select>');
return h.join('');
},
getValue: function(inRowIndex){
var n = this.getNode(inRowIndex);
if(n){
var i = n.selectedIndex, o = n.options[i];
return this.cell.returnIndex ? i : o.value || o.innerHTML;
}
}
});
dojox.grid.editors.select = dojox.grid.editors.Select; // back compat
 
dojo.declare("dojox.grid.editors.AlwaysOn", dojox.grid.editors.Input, {
// summary:
// grid cell editor that is always on, regardless of grid editing state
// alwaysOn: boolean
// flag to use editor to format grid cell regardless of editing state.
alwaysOn: true,
_formatNode: function(inDatum, inRowIndex){
this.formatNode(this.getNode(inRowIndex), inDatum, inRowIndex);
},
applyStaticValue: function(inRowIndex){
var e = this.cell.grid.edit;
e.applyCellEdit(this.getValue(inRowIndex), this.cell, inRowIndex);
e.start(this.cell, inRowIndex, true);
}
});
dojox.grid.editors.alwaysOn = dojox.grid.editors.AlwaysOn; // back-compat
 
dojo.declare("dojox.grid.editors.Bool", dojox.grid.editors.AlwaysOn, {
// summary:
// grid cell editor that provides a standard checkbox that is always on
_valueProp: "checked",
format: function(inDatum, inRowIndex){
return '<input class="dojoxGrid-input" type="checkbox"' + (inDatum ? ' checked="checked"' : '') + ' style="width: auto" />';
},
doclick: function(e){
if(e.target.tagName == 'INPUT'){
this.applyStaticValue(e.rowIndex);
}
}
});
dojox.grid.editors.bool = dojox.grid.editors.Bool; // back-compat
 
}
/trunk/api/js/dojo1.0/dojox/grid/_data/dijitEditors.js
New file
0,0 → 1,152
if(!dojo._hasResource["dojox.grid._data.dijitEditors"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.grid._data.dijitEditors"] = true;
dojo.provide("dojox.grid._data.dijitEditors");
dojo.require("dojox.grid._data.editors");
dojo.require("dijit.form.DateTextBox");
dojo.require("dijit.form.TimeTextBox");
dojo.require("dijit.form.ComboBox");
dojo.require("dijit.form.CheckBox");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.NumberSpinner");
dojo.require("dijit.form.NumberTextBox");
dojo.require("dijit.form.CurrencyTextBox");
dojo.require("dijit.form.Slider");
dojo.require("dijit.Editor");
 
dojo.declare("dojox.grid.editors.Dijit", dojox.grid.editors.base, {
editorClass: "dijit.form.TextBox",
constructor: function(inCell){
this.editor = null;
this.editorClass = dojo.getObject(this.cell.editorClass || this.editorClass);
},
format: function(inDatum, inRowIndex){
this.needFormatNode(inDatum, inRowIndex);
return "<div></div>";
},
getValue: function(inRowIndex){
return this.editor.getValue();
},
setValue: function(inRowIndex, inValue){
if(this.editor&&this.editor.setValue){
this.editor.setValue(inValue);
}else{
this.inherited(arguments);
}
},
getEditorProps: function(inDatum){
return dojo.mixin({}, this.cell.editorProps||{}, {
constraints: dojo.mixin({}, this.cell.constraint) || {}, //TODO: really just for ValidationTextBoxes
value: inDatum
});
},
createEditor: function(inNode, inDatum, inRowIndex){
return new this.editorClass(this.getEditorProps(inDatum), inNode);
 
},
attachEditor: function(inNode, inDatum, inRowIndex){
inNode.appendChild(this.editor.domNode);
this.setValue(inRowIndex, inDatum);
},
formatNode: function(inNode, inDatum, inRowIndex){
if(!this.editorClass){
return inDatum;
}
if(!this.editor){
this.editor = this.createEditor.apply(this, arguments);
}else{
this.attachEditor.apply(this, arguments);
}
this.sizeEditor.apply(this, arguments);
this.cell.grid.rowHeightChanged(inRowIndex);
this.focus();
},
sizeEditor: function(inNode, inDatum, inRowIndex){
var
p = this.cell.getNode(inRowIndex),
box = dojo.contentBox(p);
dojo.marginBox(this.editor.domNode, {w: box.w});
},
focus: function(inRowIndex, inNode){
if(this.editor){
setTimeout(dojo.hitch(this.editor, function(){
dojox.grid.fire(this, "focus");
}), 0);
}
},
_finish: function(inRowIndex){
this.inherited(arguments);
dojox.grid.removeNode(this.editor.domNode);
}
});
 
dojo.declare("dojox.grid.editors.ComboBox", dojox.grid.editors.Dijit, {
editorClass: "dijit.form.ComboBox",
getEditorProps: function(inDatum){
var items=[];
dojo.forEach(this.cell.options, function(o){
items.push({name: o, value: o});
});
var store = new dojo.data.ItemFileReadStore({data: {identifier:"name", items: items}});
return dojo.mixin({}, this.cell.editorProps||{}, {
value: inDatum,
store: store
});
},
getValue: function(){
var e = this.editor;
// make sure to apply the displayed value
e.setDisplayedValue(e.getDisplayedValue());
return e.getValue();
}
});
 
dojo.declare("dojox.grid.editors.DateTextBox", dojox.grid.editors.Dijit, {
editorClass: "dijit.form.DateTextBox",
setValue: function(inRowIndex, inValue){
if(this.editor){
this.editor.setValue(new Date(inValue));
}else{
this.inherited(arguments);
}
},
getEditorProps: function(inDatum){
return dojo.mixin(this.inherited(arguments), {
value: new Date(inDatum)
});
}
});
 
 
dojo.declare("dojox.grid.editors.CheckBox", dojox.grid.editors.Dijit, {
editorClass: "dijit.form.CheckBox",
getValue: function(){
return this.editor.checked;
}
});
 
 
dojo.declare("dojox.grid.editors.Editor", dojox.grid.editors.Dijit, {
editorClass: "dijit.Editor",
getEditorProps: function(inDatum){
return dojo.mixin({}, this.cell.editorProps||{}, {
height: this.cell.editorHeight || "100px"
});
},
createEditor: function(inNode, inDatum, inRowIndex){
// editor needs its value set after creation
var editor = new this.editorClass(this.getEditorProps(inDatum), inNode);
editor.setValue(inDatum);
return editor;
},
formatNode: function(inNode, inDatum, inRowIndex){
this.inherited(arguments);
// FIXME: seem to need to reopen the editor and display the toolbar
var e = this.editor;
e.open();
if(this.cell.editorToolbar){
dojo.place(e.toolbar.domNode, e.editingArea, "before");
}
}
});
 
}
/trunk/api/js/dojo1.0/dojox/off.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.off"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.off"] = true;
dojo.provide("dojox.off");
dojo.require("dojox.off._common");
 
}
/trunk/api/js/dojo1.0/dojox/cometd.js
New file
0,0 → 1,7
if(!dojo._hasResource["dojox.cometd"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.cometd"] = true;
// stub loader for the cometd module since no implementation code is allowed to live in top-level files
dojo.provide("dojox.cometd");
dojo.require("dojox._cometd.cometd");
 
}
/trunk/api/js/dojo1.0/dojox/presentation.js
New file
0,0 → 1,6
if(!dojo._hasResource["dojox.presentation"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.presentation"] = true;
dojo.provide("dojox.presentation");
dojo.require("dojox.presentation._base");
 
}
/trunk/api/js/dojo1.0/dojox/timing/Sequence.js
New file
0,0 → 1,145
if(!dojo._hasResource["dojox.timing.Sequence"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.timing.Sequence"] = true;
dojo.provide("dojox.timing.Sequence");
dojo.experimental("dojox.timing.Sequence"); // in case it gets moved/renamed somewhere soon
 
dojo.declare("dojox.timing.Sequence",null,{
// summary:
// This class provides functionality to really sequentialize
// function calls. You need to provide a list of functions and
// some parameters for each (like: pauseBefore) and they will
// be run one after another. This can be very useful for slideshows
// or alike things.
//
// description:
// This array will contain the sequence defines resolved, so that
// ie. repeat:10 will result in 10 elements in the sequence, so
// the repeat handling is easier and we don't need to handle that
// many extra cases. Also the doneFunction, if given is added at the
// end of the resolved-sequences.
 
// _defsResolved: Array
// The resolved sequence, for easier handling.
_defsResolved: [],
 
// This is the time to wait before goOn() calls _go(), which
// mostly results from a pauseAfter for a function that returned
// false and is later continued by the external goOn() call.
// The time to wait needs to be waited in goOn() where the
// sequence is continued.
 
// _goOnPause: Integer
// The pause to wait before really going on.
_goOnPause: 0,
 
_running: false,
go: function(/* Array */defs, /* function|Array? */doneFunction){
// summary:
//
// defs: Array
// the sequence of actions
// doneFunction: Function|Array?
// The function to call when done
this._running = true;
var self = this;
dojo.forEach(defs, function(cur){
if(cur.repeat > 1){
var repeat = cur.repeat;
for(var j=0; j<repeat ;j++){
cur.repeat = 1;
self._defsResolved.push(cur);
}
}else{
self._defsResolved.push(cur);
}
});
var last = defs[defs.length-1];
if (doneFunction) {
self._defsResolved.push({func: doneFunction});
}
// stop the sequence, this actually just sets this._running to false
self._defsResolved.push({func: [this.stop, this]});
this._curId = 0;
this._go();
},
 
_go: function(){
// summary: Execute one task of this._defsResolved.
//
// if _running was set to false stop the sequence, this is the
// case when i.e. stop() was called.
if(!this._running){
return;
}
var cur = this._defsResolved[this._curId];
this._curId += 1;
// create the function to call, the func property might be an array, which means
// [function, context, parameter1, parameter2, ...]
function resolveAndCallFunc(func) {
var ret = null;
if(dojo.isArray(func)){
// Two elements might only be given when the function+context
// is given, this is nice for using this, ie: [this.func, this]
if(func.length>2){
ret = func[0].apply(func[1], func.slice(2));
}else{
ret = func[0].apply(func[1]);
}
}else{
ret = func();
}
return ret;
}
 
if(this._curId >= this._defsResolved.length){
resolveAndCallFunc(cur.func); // call the last function, since it is the doneFunction we dont need to handle pause stuff
// don't go on and call this._go() again, we are done
return;
}
var self = this;
if(cur.pauseAfter){
if(resolveAndCallFunc(cur.func)!==false){
window.setTimeout(function() {self._go()}, cur.pauseAfter);
}else{
this._goOnPause = cur.pauseAfter;
}
}else if(cur.pauseBefore){
var x = function(){
if(resolveAndCallFunc(cur.func)!==false){
self._go()
}
};
window.setTimeout(x, cur.pauseBefore);
}else{
if(resolveAndCallFunc(cur.func)!==false){
this._go();
}
}
},
 
goOn: function(){
// summary: This method just provides a hook from the outside, so that
// an interrupted sequence can be continued.
if(this._goOnPause){
var self = this;
setTimeout(function(){ self._go() }, this._goOnPause);
this._goOnPause = 0; // reset it, so if the next one doesnt set it we dont use the old pause
}else{ this._go(); }
},
stop: function(){
// summary: Stop the currently running sequence.
// description:
// This can only interrupt the sequence not the last function that
// had been started. If the last function was i.e. a slideshow
// that is handled inside a function that you have given as
// one sequence item it cant be stopped, since it is not controlled
// by this object here. In this case it would be smarter to
// run the slideshow using a sequence object so you can also stop
// it using this method.
this._running = false;
}
});
 
}
/trunk/api/js/dojo1.0/dojox/timing/_base.js
New file
0,0 → 1,58
if(!dojo._hasResource["dojox.timing._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.timing._base"] = true;
dojo.provide("dojox.timing._base");
dojo.experimental("dojox.timing");
 
dojox.timing.Timer = function(/*int*/ interval){
// summary: Timer object executes an "onTick()" method repeatedly at a specified interval.
// repeatedly at a given interval.
// interval: Interval between function calls, in milliseconds.
this.timer = null;
this.isRunning = false;
this.interval = interval;
 
this.onStart = null;
this.onStop = null;
};
 
dojo.extend(dojox.timing.Timer, {
onTick : function(){
// summary: Method called every time the interval passes. Override to do something useful.
},
setInterval : function(interval){
// summary: Reset the interval of a timer, whether running or not.
// interval: New interval, in milliseconds.
if (this.isRunning){
window.clearInterval(this.timer);
}
this.interval = interval;
if (this.isRunning){
this.timer = window.setInterval(dojo.hitch(this, "onTick"), this.interval);
}
},
start : function(){
// summary: Start the timer ticking.
// description: Calls the "onStart()" handler, if defined.
// Note that the onTick() function is not called right away,
// only after first interval passes.
if (typeof this.onStart == "function"){
this.onStart();
}
this.isRunning = true;
this.timer = window.setInterval(dojo.hitch(this, "onTick"), this.interval);
},
stop : function(){
// summary: Stop the timer.
// description: Calls the "onStop()" handler, if defined.
if (typeof this.onStop == "function"){
this.onStop();
}
this.isRunning = false;
window.clearInterval(this.timer);
}
});
 
}
/trunk/api/js/dojo1.0/dojox/timing/ThreadPool.js
New file
0,0 → 1,157
if(!dojo._hasResource["dojox.timing.ThreadPool"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.timing.ThreadPool"] = true;
dojo.provide("dojox.timing.ThreadPool");
dojo.require("dojox.timing");
 
dojo.experimental("dojox.timing.ThreadPool");
 
// dojox.timing.Timer is included as part of _base
/********************************************************************
This is a port of the original System.Threading.ThreadPool from
the f(m) class library.
Donated to the Dojo toolkit by the author :)
*********************************************************************/
(function(){
var t=dojox.timing;
t.threadStates={
UNSTARTED:"unstarted",
STOPPED:"stopped",
PENDING:"pending",
RUNNING:"running",
SUSPENDED:"suspended",
WAITING:"waiting",
COMPLETE:"complete",
ERROR:"error"
};
 
// Before rar says a word, we actually *use* these numbers for a purpose :)
t.threadPriorities={
LOWEST:1,
BELOWNORMAL:2,
NORMAL:3,
ABOVENORMAL:4,
HIGHEST:5
};
t.Thread=function(/* Function */fn, /* dojox.timing.threadPriorities? */priority){
var self=this;
this.state=t.threadStates.UNSTARTED;
this.priority=priority||t.threadPriorities.NORMAL;
this.lastError=null;
this.func=fn; // for lookup purposes.
this.invoke=function(){
self.state=t.threadStates.RUNNING;
try{
fn(this);
self.state=t.threadStates.COMPLETE;
}catch(e){
self.lastError=e;
self.state=t.threadStates.ERROR;
}
};
};
 
// TODO: allow for changing of maxThreads and tick interval
t.ThreadPool=new (function(/* Number */mxthrs, /* Number */intvl){
var self=this;
var maxThreads=mxthrs;
var availableThreads=maxThreads;
var interval=intvl;
var fireInterval=Math.floor((interval/2)/maxThreads);
var queue=[];
var timers=new Array(maxThreads+1);
var timer=new dojox.timing.Timer();
var invoke=function(){
var tracker=timers[0]={};
for(var i=0; i<timers.length; i++){
window.clearTimeout(timers[i]);
var thread=queue.shift();
if(typeof(thread)=="undefined"){ break; }
tracker["thread-"+i]=thread;
timers[i]=window.setTimeout(thread.invoke,(fireInterval*i));
}
availableThreads=maxThreads-(i-1);
};
 
// public methods
this.getMaxThreads=function(){ return maxThreads; };
this.getAvailableThreads=function(){ return availableThreads; };
this.getTickInterval=function(){ return interval; };
this.queueUserWorkItem=function(/* Function || dojox.timing.Thread */fn){
var item=fn;
if(item instanceof Function){
item=new t.Thread(item);
}
var idx=queue.length;
for(var i=0; i<queue.length; i++){
if(queue[i].priority<item.priority){
idx=i;
break;
}
}
if(idx<queue.length){
queue.splice(idx, 0, item);
} else {
queue.push(item);
}
return true;
};
this.removeQueuedUserWorkItem=function(/* Function || dojox.timing.Thread */item){
if(item instanceof Function){
var idx=-1;
for(var i=0; i<queue.length; i++){
if(queue[i].func==item){
idx=i;
break;
}
}
if(idx>-1){
queue.splice(idx,1);
return true;
}
return false;
}
 
var idx=-1;
for(var i=0; i<queue.length; i++){
if(queue[i]==item){
idx=i;
break;
}
}
if(idx>-1){
queue.splice(idx,1);
return true;
}
return false;
};
this.start=function(){ timer.start(); };
this.stop=function(){ timer.stop(); };
this.abort=function(){
this.stop();
for(var i=1; i<timers.length; i++){
if(timers[i]){
window.clearTimeout(timers[i]);
}
}
for(var thread in timers[0]){
this.queueUserWorkItem(thread);
}
timers[0]={};
};
this.reset=function(){
this.abort();
queue=[];
};
this.sleep=function(/* Number */nSleep){
timer.stop();
window.setTimeout(timer.start, nSleep);
};
 
// dedicate the timer to us.
timer.onTick=self.invoke;
})(16, 5000);
})();
 
}
/trunk/api/js/dojo1.0/dojox/timing/README
New file
0,0 → 1,58
-------------------------------------------------------------------------------
DojoX Timing
-------------------------------------------------------------------------------
Version 0.1.0
Release date: 08/08/2007
-------------------------------------------------------------------------------
Project state:
expermental
-------------------------------------------------------------------------------
Credits
Tom Trenka (ttrenka AT gmail.com): original Timer, Streamer, Thread and ThreadPool
Wolfram Kriesing (http://wolfram.kriesing.de/blog/): Sequence
Jonathan Bond-Caron (jbondc AT gmail.com): port of Timer and Streamer
Pete Higgins (phiggins AT gmail.com): port of Sequence
-------------------------------------------------------------------------------
Project description
 
DojoX Timing is a project that deals with any kind of advanced use of timing
constructs. The central object, dojox.timing.Timer (included by default), is
a simple object that fires a callback on each tick of the timer, as well as
when starting or stopping it. The interval of each tick is settable, but the
default is 1 second--useful for driving something such as a clock.
 
dojox.timing.Streamer is an object designed to facilitate streaming/buffer-type
scenarios; it takes an input and an output function, will execute the output
function onTick, and run the input function when the internal buffer gets
beneath a certain threshold of items. This can be useful for something timed--
such as updating a data plot at every N interval, and getting new data from
a source when there's less than X data points in the internal buffer (think
real-time data updating).
 
dojox.timing.Sequencer is an object, similar to Streamer, that will allow you
to set up a set of functions to be executed in a specific order, at specific
intervals.
 
The DojoX Timing ThreadPool is a port from the original implementation in the
f(m) library. It allows a user to feed a set of callback functions (wrapped
in a Thread constructor) to a pool for background processing.
-------------------------------------------------------------------------------
Dependencies:
 
DojoX Timing only relies on the Dojo Base.
-------------------------------------------------------------------------------
Documentation
 
TBD.
-------------------------------------------------------------------------------
Installation instructions
 
Grab the following from the Dojo SVN Repository:
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/timing.js
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/timing/*
 
Install into the following directory structure:
/dojox/timing.js
/dojox/timing/
 
...which should be at the same level as your Dojo checkout.
/trunk/api/js/dojo1.0/dojox/timing/Streamer.js
New file
0,0 → 1,94
if(!dojo._hasResource["dojox.timing.Streamer"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.timing.Streamer"] = true;
dojo.provide("dojox.timing.Streamer");
 
dojo.require("dojox.timing._base");
 
dojox.timing.Streamer = function(
/* function */input,
/* function */output,
/* int */interval,
/* int */minimum,
/* array */initialData
){
// summary
// Streamer will take an input function that pushes N datapoints into a
// queue, and will pass the next point in that queue out to an
// output function at the passed interval; this way you can emulate
// a constant buffered stream of data.
// input: the function executed when the internal queue reaches minimumSize
// output: the function executed on internal tick
// interval: the interval in ms at which the output function is fired.
// minimum: the minimum number of elements in the internal queue.
 
var self = this;
var queue = [];
 
// public properties
this.interval = interval || 1000;
this.minimumSize = minimum || 10; // latency usually == interval * minimumSize
this.inputFunction = input || function(q){ };
this.outputFunction = output || function(point){ };
 
// more setup
var timer = new dojox.timing.Timer(this.interval);
var tick = function(){
self.onTick(self);
 
if(queue.length < self.minimumSize){
self.inputFunction(queue);
}
 
var obj = queue.shift();
while(typeof(obj) == "undefined" && queue.length > 0){
obj = queue.shift();
}
// check to see if the input function needs to be fired
// stop before firing the output function
// TODO: relegate this to the output function?
if(typeof(obj) == "undefined"){
self.stop();
return;
}
 
// call the output function.
self.outputFunction(obj);
};
 
this.setInterval = function(/* int */ms){
// summary
// sets the interval in milliseconds of the internal timer
this.interval = ms;
timer.setInterval(ms);
};
 
this.onTick = function(/* dojox.timing.Streamer */obj){ };
// wrap the timer functions so that we can connect to them if needed.
this.start = function(){
// summary
// starts the Streamer
if(typeof(this.inputFunction) == "function" && typeof(this.outputFunction) == "function"){
timer.start();
return;
}
throw new Error("You cannot start a Streamer without an input and an output function.");
};
this.onStart = function(){ };
this.stop = function(){
// summary
// stops the Streamer
timer.stop();
};
this.onStop = function(){ };
 
// finish initialization
timer.onTick = this.tick;
timer.onStart = this.onStart;
timer.onStop = this.onStop;
if(initialData){
queue.concat(initialData);
}
};
 
}
/trunk/api/js/dojo1.0/dojox/timing/tests/test_Sequence.html
New file
0,0 → 1,80
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.timing.Sequence class</title>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true" ></script>
<script type="text/javascript" src="../Sequence.js"></script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript">
// dojo.require("dojox.timing.Sequence");
 
var seqObj = null; var outputNode = null;
 
dojo.addOnLoad(function(){
outputNode = dojo.byId('logBox');
seqObj = new dojox.timing.Sequence({});
});
 
function runSequence(){
outputNode.innerHTML = "";
seqObj.go(seq, function() { logMsg('done') });
};
 
function logMsg(msg){
outputNode.innerHTML += msg + "<br>";
}
function showMessage(msg) {
logMsg(msg);
}
 
function returnWhenDone() {
logMsg("in returnWhenDone");
window.setTimeout(continueSequence,1000);
return false;
}
function continueSequence() {
// continue the sequence run
seqObj.goOn();
}
 
// this is our example sequence array:
var seq = [
{func: [showMessage, window, "i am first"], pauseAfter: 1000},
{func: [showMessage, window, "after 1000ms pause this should be seen"], pauseAfter: 2000},
{func: [showMessage, window, "another 2000ms pause and 1000ms pause before"], pauseAfter: 1000},
{func: [showMessage, window, "repeat 10 times and pause 100ms after"], repeat: 10, pauseAfter: 100},
{func: returnWhenDone} // no array, just a function to call
];
 
 
 
</script>
</head>
<body class="tundra">
 
<h1>dojox.timing.Sequence tests</h1>
<br>(example code in page source)<br>
<input type="button" onClick="runSequence()" value="Run Sequence">
 
<h3>Sequence output:</h3>
<div id="logBox" style="width:420px; height:250px; overflow:auto; border:1px solid #ccc;">
</div>
 
<p>TODO: maybe need to put an _Animation sequence example here? seems much more robust
than using chains and combines with delays and durations to hack timing ... also, need
examples for stop() and other methods of class</p>
 
 
</body>
</html>
/trunk/api/js/dojo1.0/dojox/timing/tests/test_ThreadPool.html
New file
0,0 → 1,16
<html>
<head>
<title>Quick Thread Pool Test</title>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true" ></script>
<script type="text/javascript" src="../ThreadPool.js"></script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
</style>
<script type="text/javascript">
dojo.require("dojox.timing.ThreadPool");
</script>
</head>
<body>
testing.
</body>
</html>