+++ /dev/null
-<html>\r
-<head>\r
- <title>The source code</title>\r
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body onload="prettyPrint();">\r
- <pre class="prettyprint lang-js">/*\r
- * Ext JS Library 2.0.1\r
- * Copyright(c) 2006-2008, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-\r
-Ext.namespace('Ext.air', 'Ext.sql');\r
-\r
-Ext.Template.prototype.compile = function() {\r
- var fm = Ext.util.Format;\r
- var useF = this.disableFormats !== true;\r
-
- var prevOffset = 0;\r
- var arr = [];\r
- var tpl = this;\r
- var fn = function(m, name, format, args, offset, s){\r
- if (prevOffset != offset) {\r
- var action = {type: 1, value: s.substr(prevOffset, offset - prevOffset)};\r
- arr.push(action);\r
- }\r
- prevOffset = offset + m.length;\r
- if(format && useF){\r
- if (args) {\r
- var re = /^\s*['"](.*)["']\s*$/;\r
- args = args.split(/,(?=(?:[^"]*"[^"]*")*(?![^"]*"))/);\r
- for(var i = 0, len = args.length; i < len; i++){\r
- args[i] = args[i].replace(re, "$1");\r
- }\r
- args = [''].concat(args);\r
- } else {\r
- args = [''];\r
- }\r
- if(format.substr(0, 5) != "this."){\r
- var action = {type: 3, value:name, format: fm[format], args: args, scope: fm};\r
- arr.push(action); \r
- }else{\r
- var action = {type: 3, value:name, format:tpl[format.substr(5)], args:args, scope: tpl};\r
- arr.push(action); \r
- }\r
- }else{\r
- var action = {type: 2, value: name};\r
- arr.push(action); \r
- }\r
- return m;\r
- };\r
- \r
- var s = this.html.replace(this.re, fn);\r
- if (prevOffset != (s.length - 1)) {\r
- var action = {type: 1, value: s.substr(prevOffset, s.length - prevOffset)};\r
- arr.push(action);\r
- }\r
-\r
- this.compiled = function(values) {\r
- function applyValues(el) {\r
- switch (el.type) {\r
- case 1:\r
- return el.value;\r
- case 2:\r
- return (values[el.value] ? values[el.value] : '');\r
- default:\r
- el.args[0] = values[el.value];\r
- return el.format.apply(el.scope, el.args);\r
- }\r
- } \r
- return arr.map(applyValues).join('');\r
- }\r
- return this;\r
-};\r
-\r
-Ext.Template.prototype.call = function(fnName, value, allValues){\r
- return this[fnName](value, allValues);\r
-}\r
-\r
-\r
-Ext.DomQuery = function(){\r
- var cache = {}, simpleCache = {}, valueCache = {};\r
- var nonSpace = /\S/;\r
- var trimRe = /^\s+|\s+$/g;\r
- var tplRe = /\{(\d+)\}/g;\r
- var modeRe = /^(\s?[\/>+~]\s?|\s|$)/;\r
- var tagTokenRe = /^(#)?([\w-\*]+)/;\r
- var nthRe = /(\d*)n\+?(\d*)/, nthRe2 = /\D/;\r
-\r
- function child(p, index){\r
- var i = 0;\r
- var n = p.firstChild;\r
- while(n){\r
- if(n.nodeType == 1){\r
- if(++i == index){\r
- return n;\r
- }\r
- }\r
- n = n.nextSibling;\r
- }\r
- return null;\r
- };\r
-\r
- function next(n){\r
- while((n = n.nextSibling) && n.nodeType != 1);\r
- return n;\r
- };\r
-\r
- function prev(n){\r
- while((n = n.previousSibling) && n.nodeType != 1);\r
- return n;\r
- };\r
-\r
- function children(d){\r
- var n = d.firstChild, ni = -1;\r
- while(n){\r
- var nx = n.nextSibling;\r
- if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){\r
- d.removeChild(n);\r
- }else{\r
- n.nodeIndex = ++ni;\r
- }\r
- n = nx;\r
- }\r
- return this;\r
- };\r
-\r
- function byClassName(c, a, v){\r
- if(!v){\r
- return c;\r
- }\r
- var r = [], ri = -1, cn;\r
- for(var i = 0, ci; ci = c[i]; i++){\r
- if((' '+ci.className+' ').indexOf(v) != -1){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- };\r
-\r
- function attrValue(n, attr){\r
- if(!n.tagName && typeof n.length != "undefined"){\r
- n = n[0];\r
- }\r
- if(!n){\r
- return null;\r
- }\r
- if(attr == "for"){\r
- return n.htmlFor;\r
- }\r
- if(attr == "class" || attr == "className"){\r
- return n.className;\r
- }\r
- return n.getAttribute(attr) || n[attr];\r
-\r
- };\r
-\r
- function getNodes(ns, mode, tagName){\r
- var result = [], ri = -1, cs;\r
- if(!ns){\r
- return result;\r
- }\r
- tagName = tagName || "*";\r
- if(typeof ns.getElementsByTagName != "undefined"){\r
- ns = [ns];\r
- }\r
- if(!mode){\r
- for(var i = 0, ni; ni = ns[i]; i++){\r
- cs = ni.getElementsByTagName(tagName);\r
- for(var j = 0, ci; ci = cs[j]; j++){\r
- result[++ri] = ci;\r
- }\r
- }\r
- }else if(mode == "/" || mode == ">"){\r
- var utag = tagName.toUpperCase();\r
- for(var i = 0, ni, cn; ni = ns[i]; i++){\r
- cn = ni.children || ni.childNodes;\r
- for(var j = 0, cj; cj = cn[j]; j++){\r
- if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){\r
- result[++ri] = cj;\r
- }\r
- }\r
- }\r
- }else if(mode == "+"){\r
- var utag = tagName.toUpperCase();\r
- for(var i = 0, n; n = ns[i]; i++){\r
- while((n = n.nextSibling) && n.nodeType != 1);\r
- if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){\r
- result[++ri] = n;\r
- }\r
- }\r
- }else if(mode == "~"){\r
- for(var i = 0, n; n = ns[i]; i++){\r
- while((n = n.nextSibling) && (n.nodeType != 1 || (tagName == '*' || n.tagName.toLowerCase()!=tagName)));\r
- if(n){\r
- result[++ri] = n;\r
- }\r
- }\r
- }\r
- return result;\r
- };\r
-\r
- function concat(a, b){\r
- if(b.slice){\r
- return a.concat(b);\r
- }\r
- for(var i = 0, l = b.length; i < l; i++){\r
- a[a.length] = b[i];\r
- }\r
- return a;\r
- }\r
-\r
- function byTag(cs, tagName){\r
- if(cs.tagName || cs == document){\r
- cs = [cs];\r
- }\r
- if(!tagName){\r
- return cs;\r
- }\r
- var r = [], ri = -1;\r
- tagName = tagName.toLowerCase();\r
- for(var i = 0, ci; ci = cs[i]; i++){\r
- if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- };\r
-\r
- function byId(cs, attr, id){\r
- if(cs.tagName || cs == document){\r
- cs = [cs];\r
- }\r
- if(!id){\r
- return cs;\r
- }\r
- var r = [], ri = -1;\r
- for(var i = 0,ci; ci = cs[i]; i++){\r
- if(ci && ci.id == id){\r
- r[++ri] = ci;\r
- return r;\r
- }\r
- }\r
- return r;\r
- };\r
-\r
- function byAttribute(cs, attr, value, op, custom){\r
- var r = [], ri = -1, st = custom=="{";\r
- var f = Ext.DomQuery.operators[op];\r
- for(var i = 0, ci; ci = cs[i]; i++){\r
- var a;\r
- if(st){\r
- a = Ext.DomQuery.getStyle(ci, attr);\r
- }\r
- else if(attr == "class" || attr == "className"){\r
- a = ci.className;\r
- }else if(attr == "for"){\r
- a = ci.htmlFor;\r
- }else if(attr == "href"){\r
- a = ci.getAttribute("href", 2);\r
- }else{\r
- a = ci.getAttribute(attr);\r
- }\r
- if((f && f(a, value)) || (!f && a)){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- };\r
-\r
- function byPseudo(cs, name, value){\r
- return Ext.DomQuery.pseudos[name](cs, value);\r
- };\r
-\r
- \r
-
-
- eval("var batch = 30803;");\r
-\r
- var key = 30803;\r
-\r
- function nodup(cs){\r
- if(!cs){\r
- return [];\r
- }\r
- var len = cs.length, c, i, r = cs, cj, ri = -1;\r
- if(!len || typeof cs.nodeType != "undefined" || len == 1){\r
- return cs;\r
- }\r
- var d = ++key;\r
- cs[0]._nodup = d;\r
- for(i = 1; c = cs[i]; i++){\r
- if(c._nodup != d){\r
- c._nodup = d;\r
- }else{\r
- r = [];\r
- for(var j = 0; j < i; j++){\r
- r[++ri] = cs[j];\r
- }\r
- for(j = i+1; cj = cs[j]; j++){\r
- if(cj._nodup != d){\r
- cj._nodup = d;\r
- r[++ri] = cj;\r
- }\r
- }\r
- return r;\r
- }\r
- }\r
- return r;\r
- }\r
-\r
- function quickDiff(c1, c2){\r
- var len1 = c1.length;\r
- if(!len1){\r
- return c2;\r
- }\r
- var d = ++key;\r
- for(var i = 0; i < len1; i++){\r
- c1[i]._qdiff = d;\r
- }\r
- var r = [];\r
- for(var i = 0, len = c2.length; i < len; i++){\r
- if(c2[i]._qdiff != d){\r
- r[r.length] = c2[i];\r
- }\r
- }\r
- return r;\r
- }\r
-\r
- function quickId(ns, mode, root, id){\r
- if(ns == root){\r
- var d = root.ownerDocument || root;\r
- return d.getElementById(id);\r
- }\r
- ns = getNodes(ns, mode, "*");\r
- return byId(ns, null, id);\r
- }\r
-\r
- function search(path, root, type) {\r
- type = type || "select";\r
-
- var n = root || document;\r
-
- var q = path, mode, lq;\r
- var tk = Ext.DomQuery.matchers;\r
- var tklen = tk.length;\r
- var mm;\r
-\r
- var lmode = q.match(modeRe);\r
- if(lmode && lmode[1]){\r
- mode=lmode[1].replace(trimRe, "");\r
- q = q.replace(lmode[1], "");\r
- }\r
- while(path.substr(0, 1)=="/"){\r
- path = path.substr(1);\r
- }\r
- while(q && lq != q){\r
- lq = q;\r
- var tm = q.match(tagTokenRe);\r
- if(type == "select"){\r
- if(tm){\r
- if(tm[1] == "#"){\r
- n = quickId(n, mode, root, tm[2]);\r
- }else{\r
- n = getNodes(n, mode, tm[2]);\r
- }\r
- q = q.replace(tm[0], "");\r
- }else if(q.substr(0, 1) != '@'){\r
- n = getNodes(n, mode, "*");\r
- }\r
- }else{\r
- if(tm){\r
- if(tm[1] == "#"){\r
- n = byId(n, null, tm[2]);\r
- }else{\r
- n = byTag(n, tm[2]);\r
- }\r
- q = q.replace(tm[0], "");\r
- }\r
- }\r
- while(!(mm = q.match(modeRe))){\r
- var matched = false;\r
- for(var j = 0; j < tklen; j++){\r
- var t = tk[j];\r
- var m = q.match(t.re);\r
- if(m){\r
- switch(j) {\r
- case 0:\r
- n = byClassName(n, null, " " + m[1] +" ");\r
- break;\r
- case 1:\r
- n = byPseudo(n, m[1], m[2]);\r
- break;\r
- case 2:\r
- n = byAttribute(n, m[2], m[4], m[3], m[1]);\r
- break;\r
- case 3:\r
- n = byId(n, null, m[1]);\r
- break;\r
- case 4:\r
- return {firstChild:{nodeValue:attrValue(n, m[1])}};\r
- \r
- }\r
- q = q.replace(m[0], "");\r
- matched = true;\r
- break;\r
- }\r
- }\r
-\r
- if(!matched){\r
- throw 'Error parsing selector, parsing failed at "' + q + '"';\r
- }\r
- }\r
- if(mm[1]){\r
- mode=mm[1].replace(trimRe, "");\r
- q = q.replace(mm[1], "");\r
- }\r
- }\r
- return nodup(n);\r
- } \r
-\r
- return {\r
- getStyle : function(el, name){\r
- return Ext.fly(el).getStyle(name);\r
- },\r
- \r
- compile: function(path, type) {\r
- return function(root) {\r
- return search(path, root, type);\r
- }\r
- },\r
-\r
- \r
- select : function(path, root, type){\r
- if(!root || root == document){\r
- root = document;\r
- }\r
- if(typeof root == "string"){\r
- root = document.getElementById(root);\r
- }\r
- var paths = path.split(",");\r
- var results = [];\r
- for(var i = 0, len = paths.length; i < len; i++){\r
- var p = paths[i].replace(trimRe, "");\r
- if(!cache[p]){\r
- cache[p] = Ext.DomQuery.compile(p);\r
- if(!cache[p]){\r
- throw p + " is not a valid selector";\r
- }\r
- }\r
- var result = cache[p](root);\r
- if(result && result != document){\r
- results = results.concat(result);\r
- }\r
- }\r
- if(paths.length > 1){\r
- return nodup(results);\r
- }\r
- return results;\r
- },\r
-\r
- \r
- selectNode : function(path, root){\r
- return Ext.DomQuery.select(path, root)[0];\r
- },\r
-\r
- \r
- selectValue : function(path, root, defaultValue){\r
- path = path.replace(trimRe, "");\r
- if(!valueCache[path]){\r
- valueCache[path] = Ext.DomQuery.compile(path, "select");\r
- }\r
- var n = valueCache[path](root);\r
- n = n[0] ? n[0] : n;\r
- var v = (n && n.firstChild ? n.firstChild.nodeValue : null);\r
- return ((v === null||v === undefined||v==='') ? defaultValue : v);\r
- },\r
-\r
- \r
- selectNumber : function(path, root, defaultValue){\r
- var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);\r
- return parseFloat(v);\r
- },\r
-\r
- \r
- is : function(el, ss){\r
- if(typeof el == "string"){\r
- el = document.getElementById(el);\r
- }\r
- var isArray = Ext.isArray(el);\r
- var result = Ext.DomQuery.filter(isArray ? el : [el], ss);\r
- return isArray ? (result.length == el.length) : (result.length > 0);\r
- },\r
-\r
- \r
- filter : function(els, ss, nonMatches){\r
- ss = ss.replace(trimRe, "");\r
- if(!simpleCache[ss]){\r
- simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");\r
- }\r
- var result = simpleCache[ss](els);\r
- return nonMatches ? quickDiff(result, els) : result;\r
- },\r
-\r
- \r
- matchers : [{\r
- re: /^\.([\w-]+)/,\r
- select: 'n = byClassName(n, null, " {1} ");'\r
- }, {\r
- re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,\r
- select: 'n = byPseudo(n, "{1}", "{2}");'\r
- },{\r
- re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,\r
- select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'\r
- }, {\r
- re: /^#([\w-]+)/,\r
- select: 'n = byId(n, null, "{1}");'\r
- },{\r
- re: /^@([\w-]+)/,\r
- select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'\r
- }\r
- ],\r
-\r
- \r
- operators : {\r
- "=" : function(a, v){\r
- return a == v;\r
- },\r
- "!=" : function(a, v){\r
- return a != v;\r
- },\r
- "^=" : function(a, v){\r
- return a && a.substr(0, v.length) == v;\r
- },\r
- "$=" : function(a, v){\r
- return a && a.substr(a.length-v.length) == v;\r
- },\r
- "*=" : function(a, v){\r
- return a && a.indexOf(v) !== -1;\r
- },\r
- "%=" : function(a, v){\r
- return (a % v) == 0;\r
- },\r
- "|=" : function(a, v){\r
- return a && (a == v || a.substr(0, v.length+1) == v+'-');\r
- },\r
- "~=" : function(a, v){\r
- return a && (' '+a+' ').indexOf(' '+v+' ') != -1;\r
- }\r
- },\r
-\r
- \r
- pseudos : {\r
- "first-child" : function(c){\r
- var r = [], ri = -1, n;\r
- for(var i = 0, ci; ci = n = c[i]; i++){\r
- while((n = n.previousSibling) && n.nodeType != 1);\r
- if(!n){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- },\r
-\r
- "last-child" : function(c){\r
- var r = [], ri = -1, n;\r
- for(var i = 0, ci; ci = n = c[i]; i++){\r
- while((n = n.nextSibling) && n.nodeType != 1);\r
- if(!n){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- },\r
-\r
- "nth-child" : function(c, a) {\r
- var r = [], ri = -1;\r
- var m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a);\r
- var f = (m[1] || 1) - 0, l = m[2] - 0;\r
- for(var i = 0, n; n = c[i]; i++){\r
- var pn = n.parentNode;\r
- if (batch != pn._batch) {\r
- var j = 0;\r
- for(var cn = pn.firstChild; cn; cn = cn.nextSibling){\r
- if(cn.nodeType == 1){\r
- cn.nodeIndex = ++j;\r
- }\r
- }\r
- pn._batch = batch;\r
- }\r
- if (f == 1) {\r
- if (l == 0 || n.nodeIndex == l){\r
- r[++ri] = n;\r
- }\r
- } else if ((n.nodeIndex + l) % f == 0){\r
- r[++ri] = n;\r
- }\r
- }\r
-\r
- return r;\r
- },\r
-\r
- "only-child" : function(c){\r
- var r = [], ri = -1;;\r
- for(var i = 0, ci; ci = c[i]; i++){\r
- if(!prev(ci) && !next(ci)){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- },\r
-\r
- "empty" : function(c){\r
- var r = [], ri = -1;\r
- for(var i = 0, ci; ci = c[i]; i++){\r
- var cns = ci.childNodes, j = 0, cn, empty = true;\r
- while(cn = cns[j]){\r
- ++j;\r
- if(cn.nodeType == 1 || cn.nodeType == 3){\r
- empty = false;\r
- break;\r
- }\r
- }\r
- if(empty){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- },\r
-\r
- "contains" : function(c, v){\r
- var r = [], ri = -1;\r
- for(var i = 0, ci; ci = c[i]; i++){\r
- if((ci.textContent||ci.innerText||'').indexOf(v) != -1){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- },\r
-\r
- "nodeValue" : function(c, v){\r
- var r = [], ri = -1;\r
- for(var i = 0, ci; ci = c[i]; i++){\r
- if(ci.firstChild && ci.firstChild.nodeValue == v){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- },\r
-\r
- "checked" : function(c){\r
- var r = [], ri = -1;\r
- for(var i = 0, ci; ci = c[i]; i++){\r
- if(ci.checked == true){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- },\r
-\r
- "not" : function(c, ss){\r
- return Ext.DomQuery.filter(c, ss, true);\r
- },\r
-\r
- "any" : function(c, selectors){\r
- var ss = selectors.split('|');\r
- var r = [], ri = -1, s;\r
- for(var i = 0, ci; ci = c[i]; i++){\r
- for(var j = 0; s = ss[j]; j++){\r
- if(Ext.DomQuery.is(ci, s)){\r
- r[++ri] = ci;\r
- break;\r
- }\r
- }\r
- }\r
- return r;\r
- },\r
-\r
- "odd" : function(c){\r
- return this["nth-child"](c, "odd");\r
- },\r
-\r
- "even" : function(c){\r
- return this["nth-child"](c, "even");\r
- },\r
-\r
- "nth" : function(c, a){\r
- return c[a-1] || [];\r
- },\r
-\r
- "first" : function(c){\r
- return c[0] || [];\r
- },\r
-\r
- "last" : function(c){\r
- return c[c.length-1] || [];\r
- },\r
-\r
- "has" : function(c, ss){\r
- var s = Ext.DomQuery.select;\r
- var r = [], ri = -1;\r
- for(var i = 0, ci; ci = c[i]; i++){\r
- if(s(ss, ci).length > 0){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- },\r
-\r
- "next" : function(c, ss){\r
- var is = Ext.DomQuery.is;\r
- var r = [], ri = -1;\r
- for(var i = 0, ci; ci = c[i]; i++){\r
- var n = next(ci);\r
- if(n && is(n, ss)){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- },\r
-\r
- "prev" : function(c, ss){\r
- var is = Ext.DomQuery.is;\r
- var r = [], ri = -1;\r
- for(var i = 0, ci; ci = c[i]; i++){\r
- var n = prev(ci);\r
- if(n && is(n, ss)){\r
- r[++ri] = ci;\r
- }\r
- }\r
- return r;\r
- }\r
- }\r
- };\r
-}();\r
-\r
-Ext.query = Ext.DomQuery.select;\r
-\r
-Date.precompileFormats = function(s){\r
- var formats = s.split('|');\r
- for(var i = 0, len = formats.length;i < len;i++){\r
- Date.createNewFormat(formats[i]);\r
- Date.createParser(formats[i]);\r
- }\r
-}\r
-\r
-Date.precompileFormats("D n/j/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|YmdHis|F d, Y|l, F d, Y|H:i:s|g:i A|g:ia|g:iA|g:i a|g:i A|h:i|g:i|H:i|ga|ha|gA|h a|g a|g A|gi|hi|gia|hia|g|H|m/d/y|m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d|Y-m-d H:i:s|d/m/y|d/m/Y|d-m-y|d-m-Y|d/m|d-m|dm|dmy|dmY|Y-m-d|l|D m/d|D m/d/Y|m/d/Y");\r
-\r
-
-Ext.ColorPalette.prototype.tpl = new Ext.XTemplate(\r
- '<tpl for="."><a href="#" class="color-{.}" hidefocus="on"><em><span style="background:#{.}" unselectable="on"> </span></em></a></tpl>'\r
-);\r
-\r
-\r
-\r
-\r
-\r
-
-\r
-Ext.air.FileProvider = function(config){\r
- Ext.air.FileProvider.superclass.constructor.call(this);\r
- \r
- this.defaultState = {\r
- mainWindow : {\r
- width:780,\r
- height:580,\r
- x:10,\r
- y:10\r
- }\r
- };\r
- \r
- Ext.apply(this, config);\r
- this.state = this.readState();\r
- \r
- var provider = this;\r
- air.NativeApplication.nativeApplication.addEventListener('exiting', function(){\r
- provider.saveState();\r
- });\r
-};\r
-\r
-Ext.extend(Ext.air.FileProvider, Ext.state.Provider, {\r
- file: 'extstate.data',\r
- \r
-
- readState : function(){\r
- var stateFile = air.File.applicationStorageDirectory.resolvePath(this.file);\r
- if(!stateFile.exists){\r
- return this.defaultState || {};\r
- }\r
- \r
- var stream = new air.FileStream();\r
- stream.open(stateFile, air.FileMode.READ);\r
- \r
- var stateData = stream.readObject();\r
- stream.close();\r
- \r
- return stateData || this.defaultState || {};\r
- },\r
-\r
-
- saveState : function(name, value){\r
- var stateFile = air.File.applicationStorageDirectory.resolvePath(this.file);\r
- var stream = new air.FileStream();\r
- stream.open(stateFile, air.FileMode.WRITE);\r
- stream.writeObject(this.state);\r
- stream.close();\r
- }\r
-});
-Ext.air.NativeObservable = Ext.extend(Ext.util.Observable, {\r
- addListener : function(name){\r
- this.proxiedEvents = this.proxiedEvents || {};\r
- if(!this.proxiedEvents[name]){\r
- var instance = this;\r
- var f = function(){\r
- var args = Array.prototype.slice.call(arguments, 0);\r
- args.unshift(name);\r
- instance.fireEvent.apply(instance, args);\r
- };\r
- this.proxiedEvents[name] = f;\r
- this.getNative().addEventListener(name, f);\r
- }\r
- Ext.air.NativeObservable.superclass.addListener.apply(this, arguments);\r
- }\r
-});\r
-\r
-Ext.air.NativeObservable.prototype.on = Ext.air.NativeObservable.prototype.addListener;
-\r
-Ext.air.NativeWindow = function(config){\r
- Ext.apply(this, config);\r
- \r
- this.id = this.id || Ext.uniqueId();\r
- \r
- this.addEvents(\r
- 'close', \r
- 'closing',\r
- 'move',\r
- 'moving',\r
- 'resize',\r
- 'resizing',\r
- 'displayStateChange',\r
- 'displayStateChanging'\r
- );\r
- \r
- Ext.air.NativeWindow.superclass.constructor.call(this);\r
- \r
- if(!this.instance){\r
- var options = new air.NativeWindowInitOptions();\r
- options.systemChrome = this.chrome;\r
- options.type = this.type;\r
- options.resizable = this.resizable;\r
- options.minimizable = this.minimizable;\r
- options.maximizable = this.maximizable;\r
- options.transparent = this.transparent;\r
- \r
- this.loader = window.runtime.flash.html.HTMLLoader.createRootWindow(false, options, false);\r
- this.loader.load(new air.URLRequest(this.file));\r
- \r
- this.instance = this.loader.window.nativeWindow;\r
- }else{\r
- this.loader = this.instance.stage.getChildAt(0);\r
- }\r
- \r
- var provider = Ext.state.Manager;\r
- var b = air.Screen.mainScreen.visibleBounds;\r
- \r
- var state = provider.get(this.id) || {};\r
- provider.set(this.id, state);\r
- \r
- var win = this.instance;\r
- \r
- var width = Math.max(state.width || this.width, 100);\r
- var height = Math.max(state.height || this.height, 100);\r
- \r
- var centerX = b.x + ((b.width/2)-(width/2));\r
- var centerY = b.y + ((b.height/2)-(height/2));\r
- \r
- var x = !Ext.isEmpty(state.x, false) ? state.x : (!Ext.isEmpty(this.x, false) ? this.x : centerX);\r
- var y = !Ext.isEmpty(state.y, false) ? state.y : (!Ext.isEmpty(this.y, false) ? this.y : centerY);\r
- \r
- win.width = width;\r
- win.height = height;\r
- win.x = x;\r
- win.y = y;\r
- \r
- win.addEventListener('move', function(){\r
- if(win.displayState != air.NativeWindowDisplayState.MINIMIZED && win.width > 100 && win.height > 100) {\r
- state.x = win.x;\r
- state.y = win.y;\r
- }\r
- }); \r
- win.addEventListener('resize', function(){\r
- if (win.displayState != air.NativeWindowDisplayState.MINIMIZED && win.width > 100 && win.height > 100) {\r
- state.width = win.width;\r
- state.height = win.height;\r
- }\r
- });\r
- \r
- Ext.air.NativeWindowManager.register(this);\r
- this.on('close', this.unregister, this);\r
- \r
- if(this.minimizeToTray){\r
- this.initMinimizeToTray(this.trayIcon, this.trayMenu);\r
- }\r
- \r
-};\r
-\r
-Ext.extend(Ext.air.NativeWindow, Ext.air.NativeObservable, {\r
- chrome: 'standard',
- type: 'normal',
- width:600,\r
- height:400,\r
- resizable: true,\r
- minimizable: true,\r
- maximizable: true,\r
- transparent: false,\r
- \r
- getNative : function(){\r
- return this.instance;\r
- },\r
- \r
- getCenterXY : function(){\r
- var b = air.Screen.mainScreen.visibleBounds;\r
- return {\r
- x: b.x + ((b.width/2)-(this.width/2)),\r
- y: b.y + ((b.height/2)-(this.height/2))\r
- };\r
- },\r
- \r
- show :function(){\r
- if(this.trayed){\r
- Ext.air.SystemTray.hideIcon();\r
- this.trayed = false;\r
- }\r
- this.instance.visible = true;\r
- },\r
- \r
- activate : function(){\r
- this.show();\r
- this.instance.activate();\r
- },\r
- \r
- hide :function(){\r
- this.instance.visible = false;\r
- },\r
- \r
- close : function(){\r
- this.instance.close(); \r
- },\r
- \r
- isMinimized :function(){\r
- return this.instance.displayState == air.NativeWindowDisplayState.MINIMIZED;\r
- },\r
- \r
- isMaximized :function(){\r
- return this.instance.displayState == air.NativeWindowDisplayState.MAXIMIZED;\r
- },\r
- \r
- moveTo : function(x, y){\r
- this.x = this.instance.x = x;\r
- this.y = this.instance.y = y; \r
- },\r
- \r
- resize : function(width, height){\r
- this.width = this.instance.width = width;\r
- this.height = this.instance.height = height; \r
- },\r
- \r
- unregister : function(){\r
- Ext.air.NativeWindowManager.unregister(this);\r
- },\r
- \r
- initMinimizeToTray : function(icon, menu){\r
- var tray = Ext.air.SystemTray;\r
- tray.setIcon(icon, this.trayTip);\r
- this.on('displayStateChanging', function(e){\r
- if(e.afterDisplayState == 'minimized'){\r
- e.preventDefault();\r
- this.hide();\r
- tray.showIcon();\r
- this.trayed = true;\r
- }\r
- }, this);\r
- \r
- tray.on('click', function(){\r
- this.activate();\r
- }, this);\r
- \r
- if(menu){\r
- tray.setMenu(menu);\r
- }\r
- }\r
-});\r
-\r
-Ext.air.NativeWindow.getRootWindow = function(){\r
- return air.NativeApplication.nativeApplication.openedWindows[0];\r
-};\r
-\r
-Ext.air.NativeWindow.getRootHtmlWindow = function(){\r
- return Ext.air.NativeWindow.getRootWindow().stage.getChildAt(0).window;\r
-};\r
-\r
-Ext.air.NativeWindowGroup = function(){\r
- var list = {};\r
-\r
- return {\r
- register : function(win){\r
- list[win.id] = win;\r
- },\r
-\r
- unregister : function(win){\r
- delete list[win.id];\r
- },\r
-\r
- get : function(id){\r
- return list[id];\r
- },\r
-\r
- closeAll : function(){\r
- for(var id in list){\r
- if(list.hasOwnProperty(id)){\r
- list[id].close();\r
- }\r
- }\r
- },\r
-\r
- \r
- each : function(fn, scope){\r
- for(var id in list){\r
- if(list.hasOwnProperty(id)){\r
- if(fn.call(scope || list[id], list[id]) === false){\r
- return;\r
- }\r
- }\r
- }\r
- }\r
- };\r
-};\r
-\r
-\r
-Ext.air.NativeWindowManager = new Ext.air.NativeWindowGroup();
-
-Ext.sql.Connection = function(config){\r
- Ext.apply(this, config);\r
- Ext.sql.Connection.superclass.constructor.call(this);\r
-\r
- this.addEvents({\r
- open : true,\r
- close: true\r
- });\r
-};\r
-\r
-Ext.extend(Ext.sql.Connection, Ext.util.Observable, {\r
- maxResults: 10000,\r
- openState : false,\r
-\r
-
- open : function(file){\r
- },\r
-\r
- close : function(){\r
- },\r
-\r
- exec : function(sql){\r
- },\r
-\r
- execBy : function(sql, args){\r
- },\r
-\r
- query : function(sql){\r
- },\r
-\r
- queryBy : function(sql, args){\r
- },\r
-\r
-
- isOpen : function(){\r
- return this.openState;\r
- },\r
-\r
- getTable : function(name, keyName){\r
- return new Ext.sql.Table(this, name, keyName);\r
- },\r
-\r
- createTable : function(o){\r
- var tableName = o.name;\r
- var keyName = o.key;\r
- var fs = o.fields;\r
- if(!Ext.isArray(fs)){
- fs = fs.items;\r
- }\r
- var buf = [];\r
- for(var i = 0, len = fs.length; i < len; i++){\r
- var f = fs[i], s = f.name;\r
- switch(f.type){\r
- case "int":\r
- case "bool":\r
- case "boolean":\r
- s += ' INTEGER';\r
- break;\r
- case "float":\r
- s += ' REAL';\r
- break;\r
- default:\r
- s += ' TEXT';\r
- }\r
- if(f.allowNull === false || f.name == keyName){\r
- s += ' NOT NULL';\r
- }\r
- if(f.name == keyName){\r
- s += ' PRIMARY KEY';\r
- }\r
- if(f.unique === true){\r
- s += ' UNIQUE';\r
- }\r
-\r
- buf[buf.length] = s;\r
- }\r
- var sql = ['CREATE TABLE IF NOT EXISTS ', tableName, ' (', buf.join(','), ')'].join('');\r
- this.exec(sql);\r
- }\r
-});\r
-\r
-\r
-Ext.sql.Connection.getInstance = function(db, config){\r
- if(Ext.isAir){
- return new Ext.sql.AirConnection(config);\r
- } else {
- return new Ext.sql.GearsConnection(config);\r
- }\r
-};
-Ext.sql.Table = function(conn, name, keyName){\r
- this.conn = conn;\r
- this.name = name;\r
- this.keyName = keyName;\r
-};\r
-\r
-Ext.sql.Table.prototype = {\r
- update : function(o){\r
- var clause = this.keyName + " = ?";\r
- return this.updateBy(o, clause, [o[this.keyName]]);\r
- },\r
-\r
- updateBy : function(o, clause, args){\r
- var sql = "UPDATE " + this.name + " set ";\r
- var fs = [], a = [];\r
- for(var key in o){\r
- if(o.hasOwnProperty(key)){\r
- fs[fs.length] = key + ' = ?';\r
- a[a.length] = o[key];\r
- }\r
- }\r
- for(var key in args){\r
- if(args.hasOwnProperty(key)){\r
- a[a.length] = args[key];\r
- }\r
- }\r
- sql = [sql, fs.join(','), ' WHERE ', clause].join('');\r
- return this.conn.execBy(sql, a);\r
- },\r
-\r
- insert : function(o){\r
- var sql = "INSERT into " + this.name + " ";\r
- var fs = [], vs = [], a = [];\r
- for(var key in o){\r
- if(o.hasOwnProperty(key)){\r
- fs[fs.length] = key;\r
- vs[vs.length] = '?';\r
- a[a.length] = o[key];\r
- }\r
- }\r
- sql = [sql, '(', fs.join(','), ') VALUES (', vs.join(','), ')'].join('');\r
- return this.conn.execBy(sql, a);\r
- },\r
-\r
- lookup : function(id){\r
- return this.selectBy('where ' + this.keyName + " = ?", [id])[0] || null;\r
- },\r
-\r
- exists : function(id){\r
- return !!this.lookup(id);\r
- },\r
-\r
- save : function(o){\r
- if(this.exists(o[this.keyName])){\r
- this.update(o);\r
- }else{\r
- this.insert(o);\r
- }\r
- },\r
-\r
- select : function(clause){\r
- return this.selectBy(clause, null);\r
- },\r
-\r
- selectBy : function(clause, args){\r
- var sql = "select * from " + this.name;\r
- if(clause){\r
- sql += ' ' + clause;\r
- }\r
- args = args || {};\r
- return this.conn.queryBy(sql, args);\r
- },\r
-\r
- remove : function(clause){\r
- this.deleteBy(clause, null);\r
- },\r
-\r
- removeBy : function(clause, args){\r
- var sql = "delete from " + this.name;\r
- if(clause){\r
- sql += ' where ' + clause;\r
- }\r
- args = args || {};\r
- this.conn.execBy(sql, args);\r
- }\r
-};
-Ext.sql.Proxy = function(conn, table, keyName, store, readonly){\r
- Ext.sql.Proxy.superclass.constructor.call(this);\r
- this.conn = conn;\r
- this.table = this.conn.getTable(table, keyName);\r
- this.store = store;\r
-\r
- if (readonly !== true) {\r
- this.store.on('add', this.onAdd, this);\r
- this.store.on('update', this.onUpdate, this);\r
- this.store.on('remove', this.onRemove, this);\r
- }\r
-};\r
-\r
-Ext.sql.Proxy.DATE_FORMAT = 'Y-m-d H:i:s';\r
-\r
-Ext.extend(Ext.sql.Proxy, Ext.data.DataProxy, {\r
- load : function(params, reader, callback, scope, arg){\r
- if(!this.conn.isOpen()){
- this.conn.on('open', function(){\r
- this.load(params, reader, callback, scope, arg);\r
- }, this, {single:true});\r
- return;\r
- };\r
- if(this.fireEvent("beforeload", this, params, reader, callback, scope, arg) !== false){\r
- var clause = params.where || '';\r
- var args = params.args || [];\r
- var group = params.groupBy;\r
- var sort = params.sort;\r
- var dir = params.dir;\r
-\r
- if(group || sort){\r
- clause += ' ORDER BY ';\r
- if(group && group != sort){\r
- clause += group + ' ASC, ';\r
- }\r
- clause += sort + ' ' + (dir || 'ASC');\r
- }\r
-\r
- var rs = this.table.selectBy(clause, args);\r
- this.onLoad({callback:callback, scope:scope, arg:arg, reader: reader}, rs);\r
- }else{\r
- callback.call(scope||this, null, arg, false);\r
- }\r
- },\r
-\r
- onLoad : function(trans, rs, e, stmt){\r
- if(rs === false){\r
- this.fireEvent("loadexception", this, null, trans.arg, e);\r
- trans.callback.call(trans.scope||window, null, trans.arg, false);\r
- return;\r
- }\r
- var result = trans.reader.readRecords(rs);\r
- this.fireEvent("load", this, rs, trans.arg);\r
- trans.callback.call(trans.scope||window, result, trans.arg, true);\r
- },\r
-\r
- processData : function(o){\r
- var fs = this.store.fields;\r
- var r = {};\r
- for(var key in o){\r
- var f = fs.key(key), v = o[key];\r
- if(f){\r
- if(f.type == 'date'){\r
- r[key] = v ? v.format(Ext.sql.Proxy.DATE_FORMAT,10) : '';\r
- }else if(f.type == 'boolean'){\r
- r[key] = v ? 1 : 0;\r
- }else{\r
- r[key] = v;\r
- }\r
- }\r
- }\r
- return r;\r
- },\r
-\r
- onUpdate : function(ds, record){\r
- var changes = record.getChanges();\r
- var kn = this.table.keyName;\r
- this.table.updateBy(this.processData(changes), kn + ' = ?', [record.data[kn]]);\r
- record.commit(true);\r
- },\r
-\r
- onAdd : function(ds, records, index){\r
- for(var i = 0, len = records.length; i < len; i++){\r
- this.table.insert(this.processData(records[i].data));\r
- }\r
- },\r
-\r
- onRemove : function(ds, record, index){\r
- var kn = this.table.keyName;\r
- this.table.removeBy(kn + ' = ?', [record.data[kn]]);\r
- }\r
-});
- Ext.sql.AirConnection = Ext.extend(Ext.sql.Connection, {\r
-
- open : function(db){\r
- this.conn = new air.SQLConnection();\r
- var file = air.File.applicationDirectory.resolvePath(db);\r
- this.conn.open(file);\r
- this.openState = true;\r
- this.fireEvent('open', this);\r
- },\r
-\r
- close : function(){\r
- this.conn.close();\r
- this.fireEvent('close', this);\r
- },\r
-\r
- createStatement : function(type){\r
- var stmt = new air.SQLStatement();\r
- stmt.sqlConnection = this.conn;\r
- return stmt;\r
- },\r
-\r
- exec : function(sql){\r
- var stmt = this.createStatement('exec');\r
- stmt.text = sql;\r
- stmt.execute();\r
- },\r
-\r
- execBy : function(sql, args){\r
- var stmt = this.createStatement('exec');\r
- stmt.text = sql;\r
- this.addParams(stmt, args);\r
- stmt.execute();\r
- },\r
-\r
- query : function(sql){\r
- var stmt = this.createStatement('query');\r
- stmt.text = sql;\r
- stmt.execute(this.maxResults);\r
- return this.readResults(stmt.getResult());\r
- },\r
-\r
- queryBy : function(sql, args){\r
- var stmt = this.createStatement('query');\r
- stmt.text = sql;\r
- this.addParams(stmt, args);\r
- stmt.execute(this.maxResults);\r
- return this.readResults(stmt.getResult());\r
- },\r
-\r
- addParams : function(stmt, args){\r
- if(!args){ return; }\r
- for(var key in args){\r
- if(args.hasOwnProperty(key)){\r
- if(!isNaN(key)){\r
- var v = args[key];\r
- if(Ext.isDate(v)){\r
- v = v.format(Ext.sql.Proxy.DATE_FORMAT);\r
- }\r
- stmt.parameters[parseInt(key)] = v;\r
- }else{\r
- stmt.parameters[':' + key] = args[key];\r
- }\r
- }\r
- }\r
- return stmt;\r
- },\r
-\r
- readResults : function(rs){\r
- var r = [];\r
- if(rs && rs.data){\r
- var len = rs.data.length;\r
- for(var i = 0; i < len; i++) {\r
- r[r.length] = rs.data[i];\r
- }\r
- }\r
- return r;\r
- }\r
-});
-Ext.air.SystemTray = function(){\r
- var app = air.NativeApplication.nativeApplication;\r
- var icon, isWindows = false, bitmaps;\r
- \r
-
- if(air.NativeApplication.supportsSystemTrayIcon) {\r
- icon = app.icon;\r
- isWindows = true;\r
- }\r
- \r
-
- if(air.NativeApplication.supportsDockIcon) {\r
- icon = app.icon;\r
- }\r
- \r
- return {\r
- \r
- setIcon : function(icon, tooltip, initWithIcon){\r
- if(!icon){
- return;\r
- }\r
- var loader = new air.Loader();\r
- loader.contentLoaderInfo.addEventListener(air.Event.COMPLETE, function(e){\r
- bitmaps = new runtime.Array(e.target.content.bitmapData);\r
- if (initWithIcon) {\r
- icon.bitmaps = bitmaps;\r
- }\r
- });\r
- loader.load(new air.URLRequest(icon));\r
- if(tooltip && air.NativeApplication.supportsSystemTrayIcon) {\r
- app.icon.tooltip = tooltip;\r
- }\r
- },\r
- \r
- bounce : function(priority){\r
- icon.bounce(priority);\r
- },\r
- \r
- on : function(eventName, fn, scope){\r
- icon.addEventListener(eventName, function(){\r
- fn.apply(scope || this, arguments);\r
- });\r
- },\r
- \r
- hideIcon : function(){\r
- if(!icon){
- return;\r
- }\r
- icon.bitmaps = [];\r
- },\r
- \r
- showIcon : function(){\r
- if(!icon){
- return;\r
- }\r
- icon.bitmaps = bitmaps;\r
- },\r
- \r
- setMenu: function(actions, _parentMenu){\r
- if(!icon){
- return;\r
- }\r
- var menu = new air.NativeMenu();\r
- \r
- for (var i = 0, len = actions.length; i < len; i++) {\r
- var a = actions[i];\r
- if(a == '-'){\r
- menu.addItem(new air.NativeMenuItem("", true));\r
- }else{\r
- var item = menu.addItem(Ext.air.MenuItem(a));\r
- if(a.menu || (a.initialConfig && a.initialConfig.menu)){\r
- item.submenu = Ext.air.SystemTray.setMenu(a.menu || a.initialConfig.menu, menu);\r
- }\r
- }\r
- \r
- if(!_parentMenu){\r
- icon.menu = menu;\r
- }\r
- }\r
- \r
- return menu;\r
- }\r
- }; \r
-}();
-
-\r
-Ext.air.DragType = {\r
- TEXT : 'text/plain',\r
- HTML : 'text/html',\r
- URL : 'text/uri-list',\r
- BITMAP : 'image/x-vnd.adobe.air.bitmap',\r
- FILES : 'application/x-vnd.adobe.air.file-list'\r
-};\r
-\r
-Ext.apply(Ext.EventObjectImpl.prototype, {\r
- hasFormat : function(format){\r
- if (this.browserEvent.dataTransfer) {\r
- for (var i = 0, len = this.browserEvent.dataTransfer.types.length; i < len; i++) {\r
- if(this.browserEvent.dataTransfer.types[i] == format) {\r
- return true;\r
- }\r
- }\r
- }\r
- return false;\r
- },\r
- \r
- getData : function(type){\r
- return this.browserEvent.dataTransfer.getData(type);\r
- }\r
-});\r
-\r
-\r
-
-Ext.air.Sound = {\r
- play : function(file, startAt){\r
- var soundFile = air.File.applicationDirectory.resolvePath(file);\r
- var sound = new air.Sound();\r
- sound.load(new air.URLRequest(soundFile.url));\r
- sound.play(startAt);\r
- }\r
-};\r
-
-
-Ext.air.SystemMenu = function(){\r
- var menu;\r
-
- if(air.NativeWindow.supportsMenu && nativeWindow.systemChrome != air.NativeWindowSystemChrome.NONE) {\r
- menu = new air.NativeMenu();\r
- nativeWindow.menu = menu;\r
- }\r
- \r
-
- if(air.NativeApplication.supportsMenu) {\r
- menu = air.NativeApplication.nativeApplication.menu;\r
- }\r
-\r
- function find(menu, text){\r
- for(var i = 0, len = menu.items.length; i < len; i++){\r
- if(menu.items[i]['label'] == text){\r
- return menu.items[i];\r
- }\r
- }\r
- return null;\r
- }\r
-\r
- return {\r
- add: function(text, actions, mindex){\r
-\r
- var item = find(menu, text);\r
- if(!item){\r
- item = menu.addItem(new air.NativeMenuItem(text));\r
- item.mnemonicIndex = mindex || 0;\r
-\r
- item.submenu = new air.NativeMenu();\r
- }\r
- for (var i = 0, len = actions.length; i < len; i++) {\r
- item.submenu.addItem(actions[i] == '-' ? new air.NativeMenuItem("", true) : Ext.air.MenuItem(actions[i]));\r
- }\r
- return item.submenu;\r
- },\r
- \r
- get : function(){\r
- return menu;\r
- }\r
- }; \r
-}();\r
-\r
-
-Ext.air.MenuItem = function(action){\r
- if(!action.isAction){\r
- action = new Ext.Action(action);\r
- }\r
- var cfg = action.initialConfig;\r
- var nativeItem = new air.NativeMenuItem(cfg.itemText || cfg.text);\r
- \r
- nativeItem.enabled = !cfg.disabled;\r
-\r
- if(!Ext.isEmpty(cfg.checked)){\r
- nativeItem.checked = cfg.checked;\r
- }\r
-\r
- var handler = cfg.handler;\r
- var scope = cfg.scope;\r
- \r
- nativeItem.addEventListener(air.Event.SELECT, function(){\r
- handler.call(scope || window, cfg);\r
- });\r
- \r
- action.addComponent({\r
- setDisabled : function(v){\r
- nativeItem.enabled = !v;\r
- },\r
- \r
- setText : function(v){\r
- nativeItem.label = v;\r
- },\r
- \r
- setVisible : function(v){\r
-
- nativeItem.enabled = !v;\r
- },\r
- \r
- setHandler : function(newHandler, newScope){\r
- handler = newHandler;\r
- scope = newScope;\r
- },\r
-
- on : function(){}\r
- });\r
- \r
- return nativeItem;\r
-}\r
-
-</pre> \r
-</body>\r
-</html>
\ No newline at end of file