| 1 |
dojo.provide("util.docscripts.cheat.lib"); |
| 2 |
dojo.require("util.docscripts.cheat.floatup"); |
| 3 |
(function(){ |
| 4 |
|
| 5 |
var api = util.docscripts.cheat.lib; |
| 6 |
dojo.mixin(api, { |
| 7 |
|
| 8 |
varmap:{ |
| 9 |
|
| 10 |
"dojo":"d.", |
| 11 |
"dojo.NodeList.prototype":"$('.nodes').", |
| 12 |
"dojo.keys":" ", |
| 13 |
"dojo.fx":"d.fx.", |
| 14 |
"dojo.fx.easing":"", |
| 15 |
"dijit._Widget.prototype":"_Widget.", |
| 16 |
"dijit._Templated.prototype":"_Templated.", |
| 17 |
"dijit.WidgetSet.prototype":"dijit.registry.", |
| 18 |
"dojo.Animation.prototype":"anim.", |
| 19 |
"dojo.Color.prototype":"color.", |
| 20 |
"dojo.xhrArgs":"args." |
| 21 |
}, |
| 22 |
|
| 23 |
ignore:[ |
| 24 |
|
| 25 |
"keys", "NodeList", "fx", "prototype", "lib", |
| 26 |
|
| 27 |
|
| 28 |
"loaded", "unloaded", "loadInit", "windowUnloaded", "simulatedLoading", "floatup", |
| 29 |
"preamble", "WidgetSet", "registry", "inherited", "postscript", |
| 30 |
|
| 31 |
|
| 32 |
"add", "remove", |
| 33 |
|
| 34 |
|
| 35 |
"dijit", "form", "layout", "lang", "dir", "class", |
| 36 |
"declaredClass", "wai", "typematic", "popup", |
| 37 |
|
| 38 |
|
| 39 |
"r","g","b","a" |
| 40 |
], |
| 41 |
|
| 42 |
useful_privates:[ |
| 43 |
"_Widget", "_Templated", "_toArray" |
| 44 |
], |
| 45 |
|
| 46 |
tags: { |
| 47 |
dojo:{ |
| 48 |
"Effects":[ |
| 49 |
"anim", "animateProperty", "fadeIn", "fadeOut", "animate", "fx.chain", "fx.combine", |
| 50 |
"_Animation", "_Line", "Animation" |
| 51 |
], |
| 52 |
|
| 53 |
"Ajax":[ |
| 54 |
"xhr", "xhrGet", "xhrPost", "xhrPut", "xhrDelete", "rawXhrPut", "rawXhrPost", "contentHandlers" |
| 55 |
], |
| 56 |
|
| 57 |
"Language-Helpers":[ |
| 58 |
"isArray", "isFunction", "isString", "isObject", "isArrayLike", "unique", |
| 59 |
"eval", "isAlien", "trim", "Deferred", "_toArray", "replace", "when" |
| 60 |
], |
| 61 |
|
| 62 |
"Arrays":[ |
| 63 |
"at", "forEach", "indexOf", "map", "concat", "some", "every", "lastIndexOf", |
| 64 |
"qw", "filter", "splice", "slice", "end" |
| 65 |
], |
| 66 |
|
| 67 |
"Event-System":[ |
| 68 |
"connect", "publish", "subscribe", "pub", "sub", "unsubscribe", "disconnect", |
| 69 |
"fixEvent", "stopEvent", "connectPublisher", "isCopyKey", "mouseButtons", "on" |
| 70 |
], |
| 71 |
|
| 72 |
"NodeList-Events":[ |
| 73 |
"onmousedown", "onmouseenter", "onmouseleave", "onmousemove", "onmouseover", |
| 74 |
"onmouseout", "onblur", |
| 75 |
"onfocus", "onclick", "onchange", "onload", "onmousedown", "onmouseup", "onsubmit", |
| 76 |
"onerror", "onkeydown", "onkeypress", "onkeyup", "hover", "on" |
| 77 |
], |
| 78 |
|
| 79 |
"NodeList-Misc":[ |
| 80 |
"first", "last", "end", "_stash" |
| 81 |
], |
| 82 |
|
| 83 |
"Objects-OO":[ |
| 84 |
"mixin", "declare", "extend", "delegate", "hitch", "partial", "setObject", |
| 85 |
"getObject", "exists", "instantiate", "safeMixin" |
| 86 |
], |
| 87 |
|
| 88 |
"Package-System":[ |
| 89 |
"require", "provide", "load", "requireLocalization", "requireIf", "dfdLoad", |
| 90 |
"moduleUrl", "requireAfterIf", "registerModulePath", "platformRequire", "isAsync" |
| 91 |
], |
| 92 |
|
| 93 |
"Document-Lifecycle":[ |
| 94 |
"addOnLoad", "addOnUnload", "addOnWindowUnload","loaded", |
| 95 |
"unloaded", "loadInit", "windowUnloaded", "ready" |
| 96 |
], |
| 97 |
|
| 98 |
"DOM-Manipulation":[ |
| 99 |
"create", "wrap", "place", "byId", "query", "empty", "destroy", "generateId", "clone", |
| 100 |
"body", "append", "appendTo", "addContent", "adopt", "orphan" |
| 101 |
], |
| 102 |
|
| 103 |
"DOM-Attributes":[ |
| 104 |
"hasAttr", "removeAttr", "position", "getNodeProp", |
| 105 |
"setSelectable", "isDescendant", "val", "attr", "coords", "marginBox", "contentBox" |
| 106 |
], |
| 107 |
|
| 108 |
"Colors":[ |
| 109 |
"Color", "colorFromArray", "colorFromString", "blendColors", "colorFromRgb", "colorFromHex" |
| 110 |
], |
| 111 |
|
| 112 |
"Styles-CSS":[ |
| 113 |
"style", "addClass", "removeClass", "toggleClass", "replaceClass", "hasClass", "getComputedStyle", "boxModel", |
| 114 |
"show", "hide", "toggle", "hoverClass" |
| 115 |
], |
| 116 |
|
| 117 |
"JSON":[ |
| 118 |
"fromJson", "toJson", "toJsonIndentStr", "formToObject", "queryToObject", "formToQuery", |
| 119 |
"formToJson", "objectToQuery", "fieldToObject" |
| 120 |
], |
| 121 |
|
| 122 |
"Miscellaneous":[ |
| 123 |
"experimental", "deprecated", "config", "version", "locale", "baseUrl" |
| 124 |
], |
| 125 |
|
| 126 |
"Advanced-Scope":[ |
| 127 |
"conflict", "withDoc", "withGlobal", "setContext", "doc", "global" |
| 128 |
], |
| 129 |
|
| 130 |
"Sniffing":[ |
| 131 |
"isBrowser", "isFF", "isKhtml", "isMoz", "isMozilla", "isIE", "isOpera", "isBrowser", |
| 132 |
"isQuirks", "isWebKit", "isChrome", "isSafari", "isAIR", "isMac" |
| 133 |
] |
| 134 |
}, |
| 135 |
|
| 136 |
dijit:{ |
| 137 |
"Widget-Development":[ |
| 138 |
"create", "postCreate","buildRendering","inherited", |
| 139 |
"connect", "templateString", "templatePath", "widgetsInTemplate", |
| 140 |
"dojoAttachEvent", "dojoAttachPoint", "disconnect", "postMixInProperties", |
| 141 |
"attributeMap", "destroyRendering", "uninitialize", "_Widget", "_Templated" |
| 142 |
], |
| 143 |
|
| 144 |
"Dijit-Attributes":[ |
| 145 |
"domNode", "srcNodeRef", "containerNode", "titleNode", "focusNode", |
| 146 |
"style", "id", "title", "defaultDuration", "nodesWithKeyClick", "defaultDuration" |
| 147 |
], |
| 148 |
|
| 149 |
"Widget-Access":[ |
| 150 |
"byId", "byNode", "getEnclosingWidget", "findWidgets" |
| 151 |
], |
| 152 |
|
| 153 |
"Widget-Control":[ |
| 154 |
"placeAt", "attr", "toString", "destroy", "startup", "destroyRecursive", |
| 155 |
"destroyDescendants", "getDescendants", "getChildren", "setAttribute", |
| 156 |
"placeOnScreen", "placeOnScreenAroundNode", "placeOnScreenAroundRectangle", |
| 157 |
"placeOnScreenAroundElement" |
| 158 |
], |
| 159 |
|
| 160 |
"Widget-Events":[ |
| 161 |
"onClick", "onFocus", "onDblClick", "onKeyPress", "onMouseOver", "onBlur", |
| 162 |
"onKeyDown", "onKeyUp", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseMove", |
| 163 |
"onMouseUp", "onMouseDown" |
| 164 |
], |
| 165 |
|
| 166 |
"ARIA-A11y-i18n":[ |
| 167 |
"hasWaiRole", "getWaiRole", "setWaiRole", "hasWaiState", "removeWaiState", |
| 168 |
"removeWaiRole", "getWaiState", "setWaiState", "waiRole", "waiState", |
| 169 |
"isLeftToRight", "isFocusable", "getFocus", "isTabNavigable", "getFirstInTabbingOrder", |
| 170 |
"getLastInTabbingOrder", "focus" |
| 171 |
], |
| 172 |
|
| 173 |
"Dijit-Utils":[ |
| 174 |
"getUniqueId", "getDocumentWindow", "getViewport", "scrollIntoView", "BackgroundIframe", |
| 175 |
"registerIframe", "moveToBookmark", "getBookmark", "isCollapsed", "placementRegistry", |
| 176 |
"registerWin" |
| 177 |
] |
| 178 |
} |
| 179 |
}, |
| 180 |
|
| 181 |
getTag: function(key, part){ |
| 182 |
part = part || "dojo"; |
| 183 |
if(api.tags[part]){ |
| 184 |
|
| 185 |
for(var i in api.tags[part]){ |
| 186 |
if(dojo.indexOf(api.tags[part][i], key) >= 0){ |
| 187 |
return i; |
| 188 |
} |
| 189 |
} |
| 190 |
} |
| 191 |
return "Unknown-Tag"; |
| 192 |
}, |
| 193 |
|
| 194 |
getUl: function(tag){ |
| 195 |
|
| 196 |
|
| 197 |
var n = dojo.byId(tag); |
| 198 |
if(!n){ |
| 199 |
var x = dojo.place("<fieldset id='" +tag+ "'><div class='box'><legend align='center'>" + api._deslash(tag) + "</legend><ul></ul></div></fieldset>", "container"); |
| 200 |
n = dojo.query("ul", x)[0]; |
| 201 |
} |
| 202 |
return n; |
| 203 |
|
| 204 |
}, |
| 205 |
|
| 206 |
getSig: function(key, member, fn){ |
| 207 |
|
| 208 |
if(!dojo.isFunction(fn)){ |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
return key + member; |
| 227 |
} |
| 228 |
if(/^_?[A-Z]/.test(member)){ |
| 229 |
key = "<span class='sig'>new</span> " + key; |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
} |
| 237 |
|
| 238 |
return key + member + "<span class='sig'>" + fn.toString().replace(/function\s+/, "").split(")")[0] + ")" + "</span>"; |
| 239 |
}, |
| 240 |
|
| 241 |
save: function(){ |
| 242 |
dojo.xhrPost({ |
| 243 |
url:"cheat.php", |
| 244 |
content: { body: dojo.body().innerHTML }, |
| 245 |
load: function(response){ |
| 246 |
window.location.href = "./cheat.html"; |
| 247 |
}, |
| 248 |
error: function(er){ |
| 249 |
console.log("Error in saving:", er.responseText); |
| 250 |
} |
| 251 |
}); |
| 252 |
}, |
| 253 |
|
| 254 |
buildNav: function(){ |
| 255 |
|
| 256 |
dojo.query("#container fieldset").forEach(function(n){ |
| 257 |
|
| 258 |
var id = n.id; |
| 259 |
var mySize = dojo.query(n).query("li").length; |
| 260 |
|
| 261 |
dojo.place("<li><a href='#" + id + "'>" + api._deslash(id) + "</a> (" + mySize + ")</li>", "nav"); |
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
}).addClass("dijitInline"); |
| 266 |
|
| 267 |
}, |
| 268 |
|
| 269 |
addIn: function(strsomething, fs, base){ |
| 270 |
var d = dojo, something; |
| 271 |
if(d.isObject(strsomething)){ |
| 272 |
|
| 273 |
something = strsomething[strsomething]; |
| 274 |
}else if(dojo.exists(strsomething)){ |
| 275 |
something = dojo.getObject(strsomething); |
| 276 |
} |
| 277 |
if(!something){ return; } |
| 278 |
|
| 279 |
var k = api.varmap[strsomething] || (strsomething + "."); |
| 280 |
for(var i in something){ |
| 281 |
if( (!i.match(/^_/) || dojo.indexOf(api.useful_privates, i) >= 0) && dojo.indexOf(api.ignore, i) == -1 ){ |
| 282 |
var ul = fs || api.getUl(api.getTag(i, base)); |
| 283 |
dojo.place("<li>" + api.getSig(k, i, something[i]) + "</li>", ul); |
| 284 |
} |
| 285 |
|
| 286 |
} |
| 287 |
|
| 288 |
}, |
| 289 |
|
| 290 |
_deslash: function(str){ |
| 291 |
return str.replace(/-/g, " "); |
| 292 |
}, |
| 293 |
|
| 294 |
sortFields: function(id){ |
| 295 |
dojo.query("#" + id).floatup(); |
| 296 |
}, |
| 297 |
|
| 298 |
hasTag: function(tag){ |
| 299 |
return window.location.href.indexOf(tag) >= 0; |
| 300 |
} |
| 301 |
|
| 302 |
}); |
| 303 |
|
| 304 |
})(); |