uki 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.gitmodules +3 -0
- data/LICENSE +20 -0
- data/Rakefile +23 -0
- data/Readme.rdoc +9 -0
- data/VERSION +1 -0
- data/bin/uki +102 -0
- data/frameworks/jspec/lib/images/bg.png +0 -0
- data/frameworks/jspec/lib/images/hr.png +0 -0
- data/frameworks/jspec/lib/images/loading.gif +0 -0
- data/frameworks/jspec/lib/images/sprites.bg.png +0 -0
- data/frameworks/jspec/lib/images/sprites.png +0 -0
- data/frameworks/jspec/lib/images/vr.png +0 -0
- data/frameworks/jspec/lib/jspec.css +149 -0
- data/frameworks/jspec/lib/jspec.growl.js +115 -0
- data/frameworks/jspec/lib/jspec.jquery.js +72 -0
- data/frameworks/jspec/lib/jspec.js +1756 -0
- data/frameworks/jspec/lib/jspec.shell.js +39 -0
- data/frameworks/jspec/lib/jspec.timers.js +90 -0
- data/frameworks/jspec/lib/jspec.xhr.js +195 -0
- data/frameworks/uki/README.rdoc +179 -0
- data/frameworks/uki/compiler.jar +0 -0
- data/frameworks/uki/run.rb +2 -0
- data/frameworks/uki/spec/commands/example_command.rb +19 -0
- data/frameworks/uki/spec/dom.html +39 -0
- data/frameworks/uki/spec/support/images/bg.png +0 -0
- data/frameworks/uki/spec/support/images/hr.png +0 -0
- data/frameworks/uki/spec/support/images/loading.gif +0 -0
- data/frameworks/uki/spec/support/images/sprites.bg.png +0 -0
- data/frameworks/uki/spec/support/images/sprites.png +0 -0
- data/frameworks/uki/spec/support/images/vr.png +0 -0
- data/frameworks/uki/spec/support/jspec.css +149 -0
- data/frameworks/uki/spec/support/jspec.js +1773 -0
- data/frameworks/uki/spec/support/jspec.xhr.js +193 -0
- data/frameworks/uki/spec/support/spec.helper.js +1 -0
- data/frameworks/uki/spec/unit/background.spec.js +29 -0
- data/frameworks/uki/spec/unit/builder.spec.js +51 -0
- data/frameworks/uki/spec/unit/data/model.spec.js +29 -0
- data/frameworks/uki/spec/unit/dom/dnd.spec.js +71 -0
- data/frameworks/uki/spec/unit/dom/event.spec.js +78 -0
- data/frameworks/uki/spec/unit/dom.spec.js +28 -0
- data/frameworks/uki/spec/unit/geometry.spec.js +79 -0
- data/frameworks/uki/spec/unit/selector.spec.js +140 -0
- data/frameworks/uki/spec/unit/theme/template.spec.js +31 -0
- data/frameworks/uki/spec/unit/utils.spec.js +176 -0
- data/frameworks/uki/spec/unit/view/base.spec.js +86 -0
- data/frameworks/uki/spec/unit/view/container.spec.js +73 -0
- data/frameworks/uki/spec/unit/view.spec.js +13 -0
- data/frameworks/uki/src/airport.js +1 -0
- data/frameworks/uki/src/uki-core/attachment.js +175 -0
- data/frameworks/uki/src/uki-core/background/css.js +37 -0
- data/frameworks/uki/src/uki-core/background/cssBox.js +73 -0
- data/frameworks/uki/src/uki-core/background/multi.js +20 -0
- data/frameworks/uki/src/uki-core/background/null.js +10 -0
- data/frameworks/uki/src/uki-core/background/rows.js +77 -0
- data/frameworks/uki/src/uki-core/background/sliced9.js +206 -0
- data/frameworks/uki/src/uki-core/background.js +35 -0
- data/frameworks/uki/src/uki-core/builder.js +68 -0
- data/frameworks/uki/src/uki-core/collection.js +278 -0
- data/frameworks/uki/src/uki-core/const.js +17 -0
- data/frameworks/uki/src/uki-core/dom/dnd.js +93 -0
- data/frameworks/uki/src/uki-core/dom/event.js +194 -0
- data/frameworks/uki/src/uki-core/dom/nativeLayout.js +18 -0
- data/frameworks/uki/src/uki-core/dom/offset.js +130 -0
- data/frameworks/uki/src/uki-core/dom/w3cdnd.js +333 -0
- data/frameworks/uki/src/uki-core/dom.js +109 -0
- data/frameworks/uki/src/uki-core/geometry.js +658 -0
- data/frameworks/uki/src/uki-core/image.js +90 -0
- data/frameworks/uki/src/uki-core/selector.js +201 -0
- data/frameworks/uki/src/uki-core/theme/base.js +39 -0
- data/frameworks/uki/src/uki-core/theme/template.js +26 -0
- data/frameworks/uki/src/uki-core/theme.js +45 -0
- data/frameworks/uki/src/uki-core/uki.js +45 -0
- data/frameworks/uki/src/uki-core/utils.js +399 -0
- data/frameworks/uki/src/uki-core/view/base.js +480 -0
- data/frameworks/uki/src/uki-core/view/container.js +155 -0
- data/frameworks/uki/src/uki-core/view/focusable.js +93 -0
- data/frameworks/uki/src/uki-core/view/observable.js +66 -0
- data/frameworks/uki/src/uki-core/view/styleable.js +70 -0
- data/frameworks/uki/src/uki-core/view/utils.js +66 -0
- data/frameworks/uki/src/uki-core/view.js +21 -0
- data/frameworks/uki/src/uki-core.js +36 -0
- data/frameworks/uki/src/uki-data/data.js +1 -0
- data/frameworks/uki/src/uki-data/model.js +28 -0
- data/frameworks/uki/src/uki-data/observable.js +34 -0
- data/frameworks/uki/src/uki-data.js +1 -0
- data/frameworks/uki/src/uki-more/more/utils.js +20 -0
- data/frameworks/uki/src/uki-more/more/view/listContainer.js +4 -0
- data/frameworks/uki/src/uki-more/more/view/multiselectList.js +196 -0
- data/frameworks/uki/src/uki-more/more/view/radioButton.js +27 -0
- data/frameworks/uki/src/uki-more/more/view/splitTable.js +79 -0
- data/frameworks/uki/src/uki-more/more/view/toggleButton.js +24 -0
- data/frameworks/uki/src/uki-more/more/view/treeList/render.js +53 -0
- data/frameworks/uki/src/uki-more/more/view/treeList.js +110 -0
- data/frameworks/uki/src/uki-more/more/view.js +2 -0
- data/frameworks/uki/src/uki-more/more.js +1 -0
- data/frameworks/uki/src/uki-more.js +4 -0
- data/frameworks/uki/src/uki-theamless.js +15 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/down-c.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/down-c.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/down-h.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/down-h.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/down-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/down-v.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-c.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-h.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-v.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/focusRing.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover-c.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover-c.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover-h.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover-h.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover-v.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal-c.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal-c.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal-h.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal-h.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal-v.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/checkbox/checkbox.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/checkbox/focus.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/checkbox/normal.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/checkbox/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/panel/dark-h.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/panel/dark-h.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/panel/dark-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/panel/dark.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/popup/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/radio/focus.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/radio/normal.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/radio/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/radio/radio.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/shadow/large-c.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/shadow/large-h.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/shadow/large-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/shadow/large-v.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/shadow/large.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/bar-m.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/bar-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/bar-v.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/bar-v.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/bar.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/focus.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/handle.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/splitPane/horizontal.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/splitPane/horizontal.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/splitPane/vertical.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/x.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport.js +322 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/down-c.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/down-c.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/down-h.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/down-m.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/down-v.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/down.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing-c.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing-h.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing-m.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing-v.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/normal-c.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/normal-c.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/normal-h.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/normal-m.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/normal-v.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/checkbox/focus.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/checkbox/normal.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/checkbox/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/panel/normal-h.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/panel/normal-m.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/panel/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/popup/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/radio/focus.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/radio/normal.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/radio/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/shadow/large-c.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/shadow/large-h.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/shadow/large-m.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/shadow/large-v.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/shadow/large.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/bar-m.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/bar-m.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/bar-v.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/bar-v.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/bar.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/handle.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/handle.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/splitPane/horizontal.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/splitPane/horizontal.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/splitPane/vertical.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/x.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo.js +217 -0
- data/frameworks/uki/src/uki-view/view/box.js +1 -0
- data/frameworks/uki/src/uki-view/view/button.js +126 -0
- data/frameworks/uki/src/uki-view/view/checkbox.js +36 -0
- data/frameworks/uki/src/uki-view/view/flow.js +48 -0
- data/frameworks/uki/src/uki-view/view/image.js +9 -0
- data/frameworks/uki/src/uki-view/view/label.js +123 -0
- data/frameworks/uki/src/uki-view/view/list/render.js +23 -0
- data/frameworks/uki/src/uki-view/view/list.js +442 -0
- data/frameworks/uki/src/uki-view/view/popup.js +113 -0
- data/frameworks/uki/src/uki-view/view/radio.js +57 -0
- data/frameworks/uki/src/uki-view/view/scrollPane.js +139 -0
- data/frameworks/uki/src/uki-view/view/slider.js +154 -0
- data/frameworks/uki/src/uki-view/view/splitPane.js +213 -0
- data/frameworks/uki/src/uki-view/view/table/column.js +96 -0
- data/frameworks/uki/src/uki-view/view/table/header.js +53 -0
- data/frameworks/uki/src/uki-view/view/table/render.js +25 -0
- data/frameworks/uki/src/uki-view/view/table.js +71 -0
- data/frameworks/uki/src/uki-view/view/textField.js +145 -0
- data/frameworks/uki/src/uki-view/view/toolbar.js +93 -0
- data/frameworks/uki/src/uki-view.js +15 -0
- data/frameworks/uki/src/uki.js +2 -0
- data/frameworks/uki/thin.yaml +11 -0
- data/frameworks/uki/uki.rb +38 -0
- data/frameworks/uki/uki.ru +2 -0
- data/lib/uki/include_js.rb +50 -0
- data/lib/uki/project.rb +207 -0
- data/lib/uki/routes.rb +20 -0
- data/lib/uki/server.rb +42 -0
- data/lib/uki.rb +9 -0
- data/templates/index.html.erb +10 -0
- data/templates/model.js.erb +5 -0
- data/templates/myapp.js.erb +44 -0
- data/templates/package.js.erb +3 -0
- data/templates/spec.html.erb +23 -0
- data/templates/spec.js.erb +6 -0
- data/templates/view.js.erb +10 -0
- data/uki.gemspec +281 -0
- metadata +317 -0
@@ -0,0 +1,193 @@
|
|
1
|
+
|
2
|
+
// JSpec - XHR - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
|
3
|
+
|
4
|
+
(function(){
|
5
|
+
|
6
|
+
// --- Original XMLHttpRequest
|
7
|
+
|
8
|
+
var OriginalXMLHttpRequest = 'XMLHttpRequest' in this ?
|
9
|
+
XMLHttpRequest :
|
10
|
+
function(){}
|
11
|
+
var OriginalActiveXObject = 'ActiveXObject' in this ?
|
12
|
+
ActiveXObject :
|
13
|
+
undefined
|
14
|
+
|
15
|
+
// --- MockXMLHttpRequest
|
16
|
+
|
17
|
+
var MockXMLHttpRequest = function() {
|
18
|
+
this.requestHeaders = {}
|
19
|
+
}
|
20
|
+
|
21
|
+
MockXMLHttpRequest.prototype = {
|
22
|
+
status: 0,
|
23
|
+
async: true,
|
24
|
+
readyState: 0,
|
25
|
+
responseText: '',
|
26
|
+
abort: function(){},
|
27
|
+
onreadystatechange: function(){},
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Return response headers hash.
|
31
|
+
*/
|
32
|
+
|
33
|
+
getAllResponseHeaders : function(){
|
34
|
+
return this.responseHeaders
|
35
|
+
},
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Return case-insensitive value for header _name_.
|
39
|
+
*/
|
40
|
+
|
41
|
+
getResponseHeader : function(name) {
|
42
|
+
return this.responseHeaders[name.toLowerCase()]
|
43
|
+
},
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Set case-insensitive _value_ for header _name_.
|
47
|
+
*/
|
48
|
+
|
49
|
+
setRequestHeader : function(name, value) {
|
50
|
+
this.requestHeaders[name.toLowerCase()] = value
|
51
|
+
},
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Open mock request.
|
55
|
+
*/
|
56
|
+
|
57
|
+
open : function(method, url, async, user, password) {
|
58
|
+
this.user = user
|
59
|
+
this.password = password
|
60
|
+
this.url = url
|
61
|
+
this.readyState = 1
|
62
|
+
this.method = method.toUpperCase()
|
63
|
+
if (async != undefined) this.async = async
|
64
|
+
if (this.async) this.onreadystatechange()
|
65
|
+
},
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Send request _data_.
|
69
|
+
*/
|
70
|
+
|
71
|
+
send : function(data) {
|
72
|
+
var self = this
|
73
|
+
this.data = data
|
74
|
+
this.readyState = 4
|
75
|
+
if (this.method == 'HEAD') this.responseText = null
|
76
|
+
this.responseHeaders['content-length'] = (this.responseText || '').length
|
77
|
+
if(this.async) this.onreadystatechange()
|
78
|
+
lastRequest = function(){
|
79
|
+
return self
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
// --- Response status codes
|
85
|
+
|
86
|
+
JSpec.statusCodes = {
|
87
|
+
100: 'Continue',
|
88
|
+
101: 'Switching Protocols',
|
89
|
+
200: 'OK',
|
90
|
+
201: 'Created',
|
91
|
+
202: 'Accepted',
|
92
|
+
203: 'Non-Authoritative Information',
|
93
|
+
204: 'No Content',
|
94
|
+
205: 'Reset Content',
|
95
|
+
206: 'Partial Content',
|
96
|
+
300: 'Multiple Choice',
|
97
|
+
301: 'Moved Permanently',
|
98
|
+
302: 'Found',
|
99
|
+
303: 'See Other',
|
100
|
+
304: 'Not Modified',
|
101
|
+
305: 'Use Proxy',
|
102
|
+
307: 'Temporary Redirect',
|
103
|
+
400: 'Bad Request',
|
104
|
+
401: 'Unauthorized',
|
105
|
+
402: 'Payment Required',
|
106
|
+
403: 'Forbidden',
|
107
|
+
404: 'Not Found',
|
108
|
+
405: 'Method Not Allowed',
|
109
|
+
406: 'Not Acceptable',
|
110
|
+
407: 'Proxy Authentication Required',
|
111
|
+
408: 'Request Timeout',
|
112
|
+
409: 'Conflict',
|
113
|
+
410: 'Gone',
|
114
|
+
411: 'Length Required',
|
115
|
+
412: 'Precondition Failed',
|
116
|
+
413: 'Request Entity Too Large',
|
117
|
+
414: 'Request-URI Too Long',
|
118
|
+
415: 'Unsupported Media Type',
|
119
|
+
416: 'Requested Range Not Satisfiable',
|
120
|
+
417: 'Expectation Failed',
|
121
|
+
422: 'Unprocessable Entity',
|
122
|
+
500: 'Internal Server Error',
|
123
|
+
501: 'Not Implemented',
|
124
|
+
502: 'Bad Gateway',
|
125
|
+
503: 'Service Unavailable',
|
126
|
+
504: 'Gateway Timeout',
|
127
|
+
505: 'HTTP Version Not Supported'
|
128
|
+
}
|
129
|
+
|
130
|
+
/**
|
131
|
+
* Mock XMLHttpRequest requests.
|
132
|
+
*
|
133
|
+
* mockRequest().and_return('some data', 'text/plain', 200, { 'X-SomeHeader' : 'somevalue' })
|
134
|
+
*
|
135
|
+
* @return {hash}
|
136
|
+
* @api public
|
137
|
+
*/
|
138
|
+
|
139
|
+
function mockRequest() {
|
140
|
+
return { and_return : function(body, type, status, headers) {
|
141
|
+
XMLHttpRequest = MockXMLHttpRequest
|
142
|
+
ActiveXObject = false
|
143
|
+
status = status || 200
|
144
|
+
headers = headers || {}
|
145
|
+
headers['content-type'] = type
|
146
|
+
JSpec.extend(XMLHttpRequest.prototype, {
|
147
|
+
responseText: body,
|
148
|
+
responseHeaders: headers,
|
149
|
+
status: status,
|
150
|
+
statusText: JSpec.statusCodes[status]
|
151
|
+
})
|
152
|
+
}}
|
153
|
+
}
|
154
|
+
|
155
|
+
/**
|
156
|
+
* Unmock XMLHttpRequest requests.
|
157
|
+
*
|
158
|
+
* @api public
|
159
|
+
*/
|
160
|
+
|
161
|
+
function unmockRequest() {
|
162
|
+
XMLHttpRequest = OriginalXMLHttpRequest
|
163
|
+
ActiveXObject = OriginalActiveXObject
|
164
|
+
}
|
165
|
+
|
166
|
+
JSpec.include({
|
167
|
+
name: 'Mock XHR',
|
168
|
+
|
169
|
+
// --- Utilities
|
170
|
+
|
171
|
+
utilities : {
|
172
|
+
mockRequest: mockRequest,
|
173
|
+
unmockRequest: unmockRequest
|
174
|
+
},
|
175
|
+
|
176
|
+
// --- Hooks
|
177
|
+
|
178
|
+
afterSpec : function() {
|
179
|
+
unmockRequest()
|
180
|
+
},
|
181
|
+
|
182
|
+
// --- DSLs
|
183
|
+
|
184
|
+
DSLs : {
|
185
|
+
snake : {
|
186
|
+
mock_request: mockRequest,
|
187
|
+
unmock_request: unmockRequest,
|
188
|
+
last_request: function(){ return lastRequest() }
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
})
|
193
|
+
})()
|
@@ -0,0 +1 @@
|
|
1
|
+
// write your helper methods here
|
@@ -0,0 +1,29 @@
|
|
1
|
+
describe 'uki.background'
|
2
|
+
|
3
|
+
it 'should unserialize themed backgrounds'
|
4
|
+
b = uki.background('theme(panel)')
|
5
|
+
b.should.be_an_instance_of uki.background.Sliced9
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should unserialize cssBox backgrounds'
|
9
|
+
b = uki.background('cssBox(border: 1px solid red;background:#CCCCCC)')
|
10
|
+
b.should.be_an_instance_of uki.background.CssBox
|
11
|
+
// IE reorders elements
|
12
|
+
b._container.style.border.should.include 'solid'
|
13
|
+
b._container.style.border.should.include '1px'
|
14
|
+
b._container.style.border.should.include 'red'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should unserialize rows backgrounds'
|
18
|
+
b = uki.background('rows(30, #CCCCCC, #FFFFFF)')
|
19
|
+
b.should.be_an_instance_of uki.background.Rows
|
20
|
+
b._colors.should.eql ['#CCCCCC', '#FFFFFF']
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should unserialize simple css backgrounds'
|
24
|
+
b = uki.background('#CCCCCC')
|
25
|
+
b.should.be_an_instance_of uki.background.Css
|
26
|
+
b._options.background.should.be '#CCCCCC'
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
describe 'uki.build'
|
2
|
+
it 'should create single view'
|
3
|
+
var c = uki.build([{
|
4
|
+
view: new uki.view.Base()
|
5
|
+
}])[0];
|
6
|
+
|
7
|
+
c.should.not.be_null
|
8
|
+
c.should.be_type 'object'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should create view from path'
|
12
|
+
var c = uki.build([{
|
13
|
+
view: 'uki.view.Base'
|
14
|
+
}])[0];
|
15
|
+
|
16
|
+
c.should.not.be_null
|
17
|
+
c.should.be_type 'object'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should create view from should path'
|
21
|
+
var c = uki.build([{
|
22
|
+
view: 'Base'
|
23
|
+
}])[0];
|
24
|
+
|
25
|
+
c.should.not.be_null
|
26
|
+
c.should.be_type 'object'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should create view from a function call'
|
30
|
+
var c = uki.build([{
|
31
|
+
view: function() { return new uki.view.Base(); }
|
32
|
+
}])[0];
|
33
|
+
|
34
|
+
c.should.not.be_null
|
35
|
+
c.should.be_type 'object'
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should create view from an object'
|
39
|
+
var c = uki.build([{
|
40
|
+
view: new uki.view.Base()
|
41
|
+
}])[0];
|
42
|
+
|
43
|
+
c.should.be_an_instance_of uki.view.Base
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should not update precreated views'
|
47
|
+
var c = uki.build([new uki.view.Base()])[0]
|
48
|
+
c.should.be_an_instance_of uki.view.Base
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
describe 'uki.data.Model'
|
2
|
+
|
3
|
+
before_each
|
4
|
+
model = new uki.data.Model();
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'should allow event binding'
|
8
|
+
uki.isFunction(model.bind).should.be_true
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should update model'
|
12
|
+
model.change({ firstName: 'John', lastName: 'Smith' })
|
13
|
+
model.firstName.should.be 'John'
|
14
|
+
model.lastName.should.be 'Smith'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should notify of changed fields'
|
18
|
+
model.bind('change', function(e) {
|
19
|
+
e.fields.should.eql ['name']
|
20
|
+
e.changes.name.should.not.be_null
|
21
|
+
});
|
22
|
+
model.change({ name: 'something' });
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should use 2 params call'
|
26
|
+
model.change('name', 'John Smith')
|
27
|
+
model.name.should.be 'John Smith'
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
describe 'DnD'
|
2
|
+
before_each
|
3
|
+
dom = uki.createElement('div', '', '<span>1<u>2</u></span><b>3</b>')
|
4
|
+
u = dom.getElementsByTagName('u')[0]
|
5
|
+
b = dom.getElementsByTagName('b')[0]
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'uki.dom.DataTransfer'
|
9
|
+
before_each
|
10
|
+
dt = new uki.dom.DataTransfer();
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should set data'
|
14
|
+
dt.setData('text/plain', 'value')
|
15
|
+
dt.getData('text/plain').should.be 'value'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should add data to types list'
|
19
|
+
dt.setData('text/plain', 'value')
|
20
|
+
dt.setData('text/html', '<b>value</b>')
|
21
|
+
dt.types.should.eql ['text/plain', 'text/html']
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should remove single data element'
|
25
|
+
dt.setData('text/plain', 'value')
|
26
|
+
dt.setData('text/html', '<b>value</b>')
|
27
|
+
dt.clearData('text/html')
|
28
|
+
dt.types.should.eql ['text/plain']
|
29
|
+
dt.getData('text/html').should.be_undefined
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should remove all data'
|
33
|
+
dt.setData('text/plain', 'value')
|
34
|
+
dt.setData('text/html', '<b>value</b>')
|
35
|
+
|
36
|
+
dt.clearData()
|
37
|
+
|
38
|
+
dt.types.should.eql []
|
39
|
+
dt.getData('text/html').should.be_undefined
|
40
|
+
dt.getData('text/plain').should.be_undefined
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should convert uki views to dom nodes'
|
44
|
+
dt.setDragImage(uki({ view: 'Label', rect: '0 0 100 100', anchors: 'left top' }))
|
45
|
+
dt._dragImage.tagName.should.be 'DIV'
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should remove drag image after cleanup'
|
49
|
+
dt.setDragImage(uki({ view: 'Label', rect: '0 0 100 100', anchors: 'left top' }))
|
50
|
+
dt.cleanup()
|
51
|
+
dt._dragImage.should.be_undefined
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'uki.dom.DataTransferWrapper'
|
56
|
+
before_each
|
57
|
+
domDataTransfer = new uki.dom.DataTransfer();
|
58
|
+
dt = new uki.dom.DataTransferWrapper(domDataTransfer);
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should convert uki views to dom nodes'
|
62
|
+
var image
|
63
|
+
domDataTransfer.setDragImage = function(i) {
|
64
|
+
image = i
|
65
|
+
};
|
66
|
+
dt.setDragImage(uki({ view: 'Label', rect: '0 0 100 100', anchors: 'left top' }))
|
67
|
+
image.tagName.should.be 'DIV'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
describe 'uki.dom.Event'
|
2
|
+
|
3
|
+
before_each
|
4
|
+
dom = uki.createElement('div', '', '<span>1<u>2</u></span><b>3</b>')
|
5
|
+
u = dom.getElementsByTagName('u')[0]
|
6
|
+
b = dom.getElementsByTagName('b')[0]
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should handle dom events'
|
10
|
+
uki.dom.probe(dom, function() { // safari won't bubble unless dom attached to document
|
11
|
+
called = false
|
12
|
+
uki.dom.bind(dom, 'click', function() {
|
13
|
+
called = true;
|
14
|
+
});
|
15
|
+
triggerEvent(u, 'click', {});
|
16
|
+
called.should.be_true
|
17
|
+
});
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should handle several types with single handler'
|
21
|
+
uki.dom.probe(dom, function() {
|
22
|
+
called = []
|
23
|
+
uki.dom.bind(dom, 'click mouseup', function(e) {
|
24
|
+
called.push(e.type);
|
25
|
+
});
|
26
|
+
triggerEvent(u, 'click', {});
|
27
|
+
triggerEvent(u, 'mouseup', {});
|
28
|
+
called.should.eql ['click', 'mouseup']
|
29
|
+
});
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should support preventDefault in all browsers'
|
33
|
+
uki.dom.probe(dom, function() { // safari won't bubble unless dom attached to document
|
34
|
+
called = false
|
35
|
+
uki.dom.bind(dom, 'click', function(e) {
|
36
|
+
called = true;
|
37
|
+
e.preventDefault.should.not.be_null
|
38
|
+
});
|
39
|
+
triggerEvent(u, 'click', {});
|
40
|
+
called.should.be_true
|
41
|
+
});
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should support stopPropagation in all browsers'
|
45
|
+
uki.dom.probe(dom, function() { // safari won't bubble unless dom attached to document
|
46
|
+
called = false
|
47
|
+
uki.dom.bind(dom, 'click', function(e) {
|
48
|
+
called = true;
|
49
|
+
e.stopPropagation.should.not.be_null
|
50
|
+
});
|
51
|
+
triggerEvent(u, 'click', {});
|
52
|
+
called.should.be_true
|
53
|
+
});
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should support mouseenter in all browser'
|
57
|
+
uki.dom.probe(dom, function() { // safari won't bubble unless dom attached to document
|
58
|
+
called = false
|
59
|
+
uki.dom.bind(dom, 'mouseenter', function(e) {
|
60
|
+
called = true;
|
61
|
+
});
|
62
|
+
triggerEvent(u, 'mouseover', {relatedTarget: 'b'});
|
63
|
+
called.should.be_true
|
64
|
+
});
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should support mouseleave in all browser'
|
68
|
+
uki.dom.probe(dom, function() { // safari won't bubble unless dom attached to document
|
69
|
+
called = false
|
70
|
+
uki.dom.bind(dom, 'mouseleave', function(e) {
|
71
|
+
called = true;
|
72
|
+
});
|
73
|
+
triggerEvent(u, 'mouseout', {relatedTarget: 'b'});
|
74
|
+
called.should.be_true
|
75
|
+
});
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
describe 'uki.dom'
|
2
|
+
it 'should create elements with style'
|
3
|
+
x = uki.createElement('div', 'margin: 2px;border: 1px solid red');
|
4
|
+
// IE reorders elements
|
5
|
+
x.style.border.should.include 'solid'
|
6
|
+
x.style.border.should.include '1px'
|
7
|
+
x.style.border.should.include 'red'
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should create stylesheets'
|
11
|
+
x = uki.createElement('div')
|
12
|
+
x.className = 'test' + uki.dom.guid++
|
13
|
+
uki.dom.createStylesheet('.' + x.className + ' { display: inline !important; }')
|
14
|
+
uki.dom.probe(x, function() {
|
15
|
+
uki.dom.computedStyle(x).display.should.be 'inline'
|
16
|
+
});
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should check if element contains another one'
|
20
|
+
x = uki.createElement('div', '', '<span><b>1</b></span>')
|
21
|
+
uki.dom.contains(x, x.firstChild).should.be_true
|
22
|
+
uki.dom.contains(x, x.firstChild.firstChild).should.be_true
|
23
|
+
uki.dom.contains(document.body, x).should.be_false
|
24
|
+
uki.dom.probe(x, function() {
|
25
|
+
uki.dom.contains(document.body, x).should.be_true
|
26
|
+
})
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
describe 'uki.Geometry'
|
2
|
+
Rect = uki.geometry.Rect;
|
3
|
+
Size = uki.geometry.Size;
|
4
|
+
Point = uki.geometry.Point;
|
5
|
+
Inset = uki.geometry.Inset;
|
6
|
+
|
7
|
+
describe 'Point'
|
8
|
+
it 'should serialize to string'
|
9
|
+
s = new Point(-1, 12)
|
10
|
+
(s + '').should.be '-1 12'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should unserialize from string'
|
14
|
+
Point.fromString('10 -11').should.eql new Point(10, -11)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'Size'
|
19
|
+
it 'should serialize to string'
|
20
|
+
s = new Size(10, 20)
|
21
|
+
(s + '').should.be '10 20'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should unserialize from string'
|
25
|
+
Size.fromString('20 21').should.eql new Size(20, 21)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'Rect'
|
30
|
+
it 'should serialize to string'
|
31
|
+
s = new Rect(10, 11, 21, 22)
|
32
|
+
(s + '').should.be '10 11 21 22'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should unserialize from string'
|
36
|
+
Rect.fromString('10 11 21 22').should.eql new Rect(10, 11, 21, 22)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should create iteself from Point and Size'
|
40
|
+
s = new Rect(new Point(10, 11), new Size(12, 13))
|
41
|
+
s.should.eql new Rect(10, 11, 12, 13)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should create itself from coords'
|
45
|
+
Rect.fromCoords(10, 20, 100, 200).should.eql new Rect(10, 20, 90, 180)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should create itself from 2 Points'
|
49
|
+
Rect.fromCoords(new Point(10, 20), new Point(100, 200)).should.eql new Rect(10, 20, 90, 180)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should serialize to coords string'
|
53
|
+
r = new Rect(10, 11, 21, 22);
|
54
|
+
r.toCoordsString().should.be '10 11 31 33'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'Inset'
|
59
|
+
it 'should create itself from 4 offsets'
|
60
|
+
var i = new Inset(0, 1, 2, 3);
|
61
|
+
(i + '').should.be '0 1 2 3'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should create itself from 2 offsets'
|
65
|
+
i = new Inset(2, 4);
|
66
|
+
(i + '').should.be '2 4 2 4'
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should create itself from zerros'
|
70
|
+
i = new Inset(2, 4, 0, 0);
|
71
|
+
(i + '').should.be '2 4 0 0'
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should unserialize from string'
|
75
|
+
i = Inset.fromString('1 2 3 4');
|
76
|
+
(i + '').should.be '1 2 3 4'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|