envjs 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +5 -0
- data/lib/envjs/env.js +149 -146
- data/lib/envjs/static.js +11 -3
- data/lib/envjs.rb +1 -1
- data/src/event/event.js +10 -2
- data/src/html/option.js +1 -1
- data/src/window/event.js +156 -153
- metadata +6 -20
data/CHANGELOG.rdoc
CHANGED
data/lib/envjs/env.js
CHANGED
@@ -2153,169 +2153,172 @@ $w.removeEventListener = function(type, fn){
|
|
2153
2153
|
|
2154
2154
|
|
2155
2155
|
function __dispatchEvent__(target, event, bubbles){
|
2156
|
-
try{
|
2157
|
-
|
2156
|
+
try{
|
2157
|
+
$debug("dispatching event " + event.type);
|
2158
2158
|
|
2159
|
-
|
2160
|
-
|
2159
|
+
//the window scope defines the $event object, for IE(^^^) compatibility;
|
2160
|
+
$event = event;
|
2161
2161
|
|
2162
|
-
|
2163
|
-
|
2162
|
+
if (bubbles == undefined || bubbles == null)
|
2163
|
+
bubbles = true;
|
2164
2164
|
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
}
|
2169
|
-
//$debug("event target: " + event.target);
|
2170
|
-
var handled = false;
|
2171
|
-
if ( event.type && (target.nodeType ||
|
2172
|
-
target.window === window || // compares outer objects under TM (inner == outer, but !== (currently)
|
2173
|
-
target === window ||
|
2174
|
-
target.__proto__ === window ||
|
2175
|
-
target.$thisWindowsProxyObject === window)) {
|
2176
|
-
//$debug("nodeType: " + target.nodeType);
|
2177
|
-
if ( target.uuid && $events[target.uuid][event.type] ) {
|
2178
|
-
var _this = target;
|
2179
|
-
$debug('calling event handlers '+$events[target.uuid][event.type].length);
|
2180
|
-
$events[target.uuid][event.type].forEach(function(fn){
|
2181
|
-
$debug('calling event handler '+fn+' on target '+_this);
|
2182
|
-
handled = (fn(event) == false) || handled;
|
2183
|
-
});
|
2165
|
+
if (!event.target) {
|
2166
|
+
//$debug("no event target : "+event.target);
|
2167
|
+
event.target = target;
|
2184
2168
|
}
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2169
|
+
//$debug("event target: " + event.target);
|
2170
|
+
var handled = false;
|
2171
|
+
if ( event.type && (target.nodeType ||
|
2172
|
+
target.window === window || // compares outer objects under TM (inner == outer, but !== (currently)
|
2173
|
+
target === window ||
|
2174
|
+
target.__proto__ === window ||
|
2175
|
+
target.$thisWindowsProxyObject === window)) {
|
2176
|
+
//$debug("nodeType: " + target.nodeType);
|
2177
|
+
if ( target.uuid && $events[target.uuid][event.type] ) {
|
2178
|
+
var _this = target;
|
2179
|
+
$debug('calling event handlers '+$events[target.uuid][event.type].length);
|
2180
|
+
$events[target.uuid][event.type].forEach(function(fn){
|
2181
|
+
$debug('calling event handler '+fn+' on target '+_this);
|
2182
|
+
handled = (fn(event) == false) || handled;
|
2183
|
+
});
|
2184
|
+
}
|
2185
|
+
|
2186
|
+
if (target["on" + event.type]) {
|
2187
|
+
$debug('calling event handler on'+event.type+' on target '+target);
|
2188
|
+
handled = (target["on" + event.type](event) == false) || handled;
|
2189
|
+
}
|
2194
2190
|
|
2195
|
-
|
2196
|
-
|
2191
|
+
// SMP FIX: cancel/stop prop
|
2192
|
+
if (!handled && event.$preventDefault) {
|
2193
|
+
handled = true;
|
2194
|
+
}
|
2195
|
+
|
2196
|
+
// print(event.type,target,handled);
|
2197
2197
|
|
2198
|
-
|
2198
|
+
if (!handled && event.type == "click" && target instanceof HTMLAnchorElement && target.href ) {
|
2199
|
+
// window.location = target.href;
|
2199
2200
|
|
2200
|
-
|
2201
|
+
var url = target.href;
|
2201
2202
|
|
2202
|
-
|
2203
|
-
// print("return anchor only");
|
2204
|
-
skip = true;
|
2205
|
-
}
|
2203
|
+
var skip = false;
|
2206
2204
|
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
// I'm not sure why this code is here ... looking at the FSW
|
2212
|
-
// print("nu",now,url,to);
|
2213
|
-
to = to || $env.location(url,window.location.href);
|
2214
|
-
// print("nu",now,url,to);
|
2215
|
-
if (to && to.indexOf(now)===0 && to[now.length]==="#") {
|
2216
|
-
skip = true;
|
2217
|
-
}
|
2218
|
-
}
|
2219
|
-
if (!skip) {
|
2220
|
-
if (url && url.indexOf(now)===0 && url[now.length]==="#") {
|
2221
|
-
// print("return diff anchor only");
|
2222
|
-
skip = true;
|
2223
|
-
}
|
2224
|
-
}
|
2225
|
-
if (!skip) {
|
2226
|
-
// print($location, window.location.href === $location, $location.indexOf("#")>0);
|
2227
|
-
if (url === window.location.href && $location.indexOf("#")>0) {
|
2228
|
-
// print('returning same with anchor');
|
2229
|
-
skip = true;
|
2230
|
-
}
|
2231
|
-
}
|
2232
|
-
|
2233
|
-
if (!skip){
|
2234
|
-
$env.reload(window, target.href, {referer: window.location.href});
|
2235
|
-
}
|
2236
|
-
}
|
2205
|
+
if (url[0] === "#") {
|
2206
|
+
// print("return anchor only");
|
2207
|
+
skip = true;
|
2208
|
+
}
|
2237
2209
|
|
2238
|
-
|
2239
|
-
|
2240
|
-
|
2241
|
-
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2210
|
+
if (!skip) {
|
2211
|
+
var now = window.location.href.replace(/^file:\/\//,"").replace(/#.*/,"");
|
2212
|
+
var to = $master.first_script_window && $master.first_script_window.location.href;
|
2213
|
+
// var to = $env.location(url,window.location.href != "about:blank" ? window.location.href: undefined);
|
2214
|
+
// I'm not sure why this code is here ... looking at the FSW
|
2215
|
+
// print("nu",now,url,to);
|
2216
|
+
to = to || $env.location(url,window.location.href);
|
2217
|
+
// print("nu",now,url,to);
|
2218
|
+
if (to && to.indexOf(now)===0 && to[now.length]==="#") {
|
2219
|
+
skip = true;
|
2220
|
+
}
|
2221
|
+
}
|
2222
|
+
if (!skip) {
|
2223
|
+
if (url && url.indexOf(now)===0 && url[now.length]==="#") {
|
2224
|
+
// print("return diff anchor only");
|
2225
|
+
skip = true;
|
2226
|
+
}
|
2227
|
+
}
|
2228
|
+
if (!skip) {
|
2229
|
+
// print($location, window.location.href === $location, $location.indexOf("#")>0);
|
2230
|
+
if (url === window.location.href && $location.indexOf("#")>0) {
|
2231
|
+
// print('returning same with anchor');
|
2232
|
+
skip = true;
|
2233
|
+
}
|
2234
|
+
}
|
2259
2235
|
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2264
|
-
}
|
2236
|
+
if (!skip){
|
2237
|
+
$env.reload(window, target.href, {referer: window.location.href});
|
2238
|
+
}
|
2239
|
+
}
|
2265
2240
|
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2275
|
-
|
2276
|
-
|
2277
|
-
|
2278
|
-
|
2279
|
-
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
var action = target.action || window.location.href;
|
2287
|
-
if (data) {
|
2288
|
-
if (action.indexOf("?") < 0) {
|
2289
|
-
action = action + "?";
|
2241
|
+
if (!handled && event.type == "click" &&
|
2242
|
+
target.form &&
|
2243
|
+
( target instanceof HTMLInputElement || target instanceof HTMLTypeValueInputs ) &&
|
2244
|
+
( ( target.tagName === "INPUT" &&
|
2245
|
+
(target.type === "submit" ||
|
2246
|
+
target.type === "image" ) ) ||
|
2247
|
+
( target.tagName === "BUTTON" &&
|
2248
|
+
( !target.type ||
|
2249
|
+
target.type === "submit" ) ) ) ) {
|
2250
|
+
target.form.clk = target;
|
2251
|
+
try{
|
2252
|
+
target.form.submit();
|
2253
|
+
// __submit__(target.form);
|
2254
|
+
}catch(e){
|
2255
|
+
print("oopse",e);
|
2256
|
+
print(e.stack);
|
2257
|
+
e.backtrace && print(e.backtrace().join("\n"));
|
2258
|
+
throw e;
|
2259
|
+
};
|
2260
|
+
delete target.form.clk;
|
2290
2261
|
}
|
2291
|
-
|
2292
|
-
|
2262
|
+
|
2263
|
+
// print(event.type,target.type,target.constructor+"");
|
2264
|
+
// print("A",handled,event.type,target,target.type);
|
2265
|
+
if (!handled && event.type == "click" && target instanceof HTMLInputElement && ( target.type == "checkbox" || target.type == "radio" ) ) {
|
2266
|
+
target.checked = target.checked ? "" : "checked";
|
2293
2267
|
}
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
var
|
2298
|
-
|
2268
|
+
|
2269
|
+
if (!handled && (event.type == "submit") && target instanceof HTMLFormElement) {
|
2270
|
+
$env.unload($w);
|
2271
|
+
var proxy = $w.window;
|
2272
|
+
var data;
|
2273
|
+
var boundary;
|
2274
|
+
if (target.enctype === "multipart/form-data") {
|
2275
|
+
boundary = (new Date).getTime();
|
2276
|
+
}
|
2277
|
+
data = $master["static"].__formSerialize__(target,undefined,boundary);
|
2278
|
+
var options = {method: target.method || "get", referer: this.location.href};
|
2279
|
+
if (options.method === "post" || options.method === "put") {
|
2280
|
+
options.data = data;
|
2281
|
+
var undef;
|
2282
|
+
data = undef;
|
2283
|
+
}
|
2284
|
+
if (boundary) {
|
2285
|
+
options["Content-Type"] = "multipart/form-data; boundary="+boundary;
|
2286
|
+
} else {
|
2287
|
+
options["Content-Type"] = 'application/x-www-form-urlencoded';
|
2288
|
+
}
|
2289
|
+
var action = target.action || window.location.href;
|
2290
|
+
if (data) {
|
2291
|
+
if (action.indexOf("?") < 0) {
|
2292
|
+
action = action + "?";
|
2293
|
+
}
|
2294
|
+
if (action[action.length-1] != "?") {
|
2295
|
+
action = action + "&";
|
2296
|
+
}
|
2297
|
+
var params = unescape(data).split("&");
|
2298
|
+
var new_params = [];
|
2299
|
+
for(var pi=0; pi < params.length; pi++) {
|
2300
|
+
var pair = params[pi].split("=");
|
2301
|
+
new_params.push(escape(pair[0])+"="+escape(pair[1]));
|
2302
|
+
}
|
2303
|
+
action = action + new_params.join("&");
|
2304
|
+
}
|
2305
|
+
$env.reload(proxy, action, options );
|
2299
2306
|
}
|
2300
|
-
action = action + new_params.join("&");
|
2301
|
-
}
|
2302
|
-
$env.reload(proxy, action, options );
|
2303
|
-
}
|
2304
2307
|
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2308
|
+
}else{
|
2309
|
+
//$debug("non target: " + event.target + " \n this->"+target);
|
2310
|
+
}
|
2311
|
+
if (!handled && bubbles && target.parentNode){
|
2312
|
+
//$debug('bubbling to parentNode '+target.parentNode);
|
2313
|
+
__dispatchEvent__(target.parentNode, event, bubbles);
|
2314
|
+
}
|
2315
|
+
}catch(e){
|
2316
|
+
$warn("Exception while dispatching events: "+e);
|
2317
|
+
// print("oops e",e.stack);
|
2318
|
+
// print("oops e",e.backtrace && e.backtrace().join("\n"));
|
2319
|
+
// try { throw new Error("here"); } catch(x) { print("oops e",x.stack); }
|
2320
|
+
throw e;
|
2311
2321
|
}
|
2312
|
-
}catch(e){
|
2313
|
-
$warn("Exception while dispatching events: "+e);
|
2314
|
-
// print("oops e",e.stack);
|
2315
|
-
// print("oops e",e.backtrace && e.backtrace().join("\n"));
|
2316
|
-
// try { throw new Error("here"); } catch(x) { print("oops e",x.stack); }
|
2317
|
-
throw e;
|
2318
|
-
}
|
2319
2322
|
};
|
2320
2323
|
|
2321
2324
|
$env.__removeEventListener__ = __removeEventListener__;
|
data/lib/envjs/static.js
CHANGED
@@ -6770,7 +6770,7 @@ __extend__(HTMLOptionElement.prototype, {
|
|
6770
6770
|
}
|
6771
6771
|
HTMLInputCommon.prototype.setAttribute.call(this, 'selected', selectedValue);
|
6772
6772
|
var parent = this.parentNode;
|
6773
|
-
while (parent.tagName === "OPTGROUP") {
|
6773
|
+
while (parent && parent.tagName === "OPTGROUP") {
|
6774
6774
|
parent = parent.parentNode;
|
6775
6775
|
}
|
6776
6776
|
if (value) {
|
@@ -22073,6 +22073,7 @@ var Event = function(options){
|
|
22073
22073
|
$target = options.target?options.target:null,
|
22074
22074
|
$timestamp = options.timestamp?options.timestamp:new Date().getTime().toString(),
|
22075
22075
|
$type = options.type?options.type:"";
|
22076
|
+
this.$preventDefault = false;
|
22076
22077
|
return __extend__(this,{
|
22077
22078
|
get bubbles(){return $bubbles;},
|
22078
22079
|
get cancelable(){return $cancelable;},
|
@@ -22087,8 +22088,15 @@ var Event = function(options){
|
|
22087
22088
|
$bubbles=bubbles?bubbles:$bubbles;
|
22088
22089
|
$cancelable=cancelable?cancelable:$cancelable;
|
22089
22090
|
},
|
22090
|
-
|
22091
|
-
|
22091
|
+
stopPropagation: function(){
|
22092
|
+
if($cancelable){
|
22093
|
+
this.$cancelled = true;
|
22094
|
+
$bubbles = false;
|
22095
|
+
}
|
22096
|
+
},
|
22097
|
+
preventDefault: function(){
|
22098
|
+
this.$preventDefault = true;
|
22099
|
+
}
|
22092
22100
|
});
|
22093
22101
|
};
|
22094
22102
|
|
data/lib/envjs.rb
CHANGED
data/src/event/event.js
CHANGED
@@ -17,6 +17,7 @@ var Event = function(options){
|
|
17
17
|
$target = options.target?options.target:null,
|
18
18
|
$timestamp = options.timestamp?options.timestamp:new Date().getTime().toString(),
|
19
19
|
$type = options.type?options.type:"";
|
20
|
+
this.$preventDefault = false;
|
20
21
|
return __extend__(this,{
|
21
22
|
get bubbles(){return $bubbles;},
|
22
23
|
get cancelable(){return $cancelable;},
|
@@ -31,8 +32,15 @@ var Event = function(options){
|
|
31
32
|
$bubbles=bubbles?bubbles:$bubbles;
|
32
33
|
$cancelable=cancelable?cancelable:$cancelable;
|
33
34
|
},
|
34
|
-
|
35
|
-
|
35
|
+
stopPropagation: function(){
|
36
|
+
if($cancelable){
|
37
|
+
this.$cancelled = true;
|
38
|
+
$bubbles = false;
|
39
|
+
}
|
40
|
+
},
|
41
|
+
preventDefault: function(){
|
42
|
+
this.$preventDefault = true;
|
43
|
+
}
|
36
44
|
});
|
37
45
|
};
|
38
46
|
|
data/src/html/option.js
CHANGED
@@ -29,7 +29,7 @@ __extend__(HTMLOptionElement.prototype, {
|
|
29
29
|
}
|
30
30
|
HTMLInputCommon.prototype.setAttribute.call(this, 'selected', selectedValue);
|
31
31
|
var parent = this.parentNode;
|
32
|
-
while (parent.tagName === "OPTGROUP") {
|
32
|
+
while (parent && parent.tagName === "OPTGROUP") {
|
33
33
|
parent = parent.parentNode;
|
34
34
|
}
|
35
35
|
if (value) {
|
data/src/window/event.js
CHANGED
@@ -50,169 +50,172 @@ $w.removeEventListener = function(type, fn){
|
|
50
50
|
|
51
51
|
|
52
52
|
function __dispatchEvent__(target, event, bubbles){
|
53
|
-
try{
|
54
|
-
|
53
|
+
try{
|
54
|
+
$debug("dispatching event " + event.type);
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
//the window scope defines the $event object, for IE(^^^) compatibility;
|
57
|
+
$event = event;
|
58
58
|
|
59
|
-
|
60
|
-
|
59
|
+
if (bubbles == undefined || bubbles == null)
|
60
|
+
bubbles = true;
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
}
|
66
|
-
//$debug("event target: " + event.target);
|
67
|
-
var handled = false;
|
68
|
-
if ( event.type && (target.nodeType ||
|
69
|
-
target.window === window || // compares outer objects under TM (inner == outer, but !== (currently)
|
70
|
-
target === window ||
|
71
|
-
target.__proto__ === window ||
|
72
|
-
target.$thisWindowsProxyObject === window)) {
|
73
|
-
//$debug("nodeType: " + target.nodeType);
|
74
|
-
if ( target.uuid && $events[target.uuid][event.type] ) {
|
75
|
-
var _this = target;
|
76
|
-
$debug('calling event handlers '+$events[target.uuid][event.type].length);
|
77
|
-
$events[target.uuid][event.type].forEach(function(fn){
|
78
|
-
$debug('calling event handler '+fn+' on target '+_this);
|
79
|
-
handled = (fn(event) == false) || handled;
|
80
|
-
});
|
81
|
-
}
|
82
|
-
|
83
|
-
if (target["on" + event.type]) {
|
84
|
-
$debug('calling event handler on'+event.type+' on target '+target);
|
85
|
-
handled = (target["on" + event.type](event) == false) || handled;
|
62
|
+
if (!event.target) {
|
63
|
+
//$debug("no event target : "+event.target);
|
64
|
+
event.target = target;
|
86
65
|
}
|
66
|
+
//$debug("event target: " + event.target);
|
67
|
+
var handled = false;
|
68
|
+
if ( event.type && (target.nodeType ||
|
69
|
+
target.window === window || // compares outer objects under TM (inner == outer, but !== (currently)
|
70
|
+
target === window ||
|
71
|
+
target.__proto__ === window ||
|
72
|
+
target.$thisWindowsProxyObject === window)) {
|
73
|
+
//$debug("nodeType: " + target.nodeType);
|
74
|
+
if ( target.uuid && $events[target.uuid][event.type] ) {
|
75
|
+
var _this = target;
|
76
|
+
$debug('calling event handlers '+$events[target.uuid][event.type].length);
|
77
|
+
$events[target.uuid][event.type].forEach(function(fn){
|
78
|
+
$debug('calling event handler '+fn+' on target '+_this);
|
79
|
+
handled = (fn(event) == false) || handled;
|
80
|
+
});
|
81
|
+
}
|
82
|
+
|
83
|
+
if (target["on" + event.type]) {
|
84
|
+
$debug('calling event handler on'+event.type+' on target '+target);
|
85
|
+
handled = (target["on" + event.type](event) == false) || handled;
|
86
|
+
}
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
if (!handled && event.type == "click" && target instanceof HTMLAnchorElement && target.href ) {
|
93
|
-
// window.location = target.href;
|
94
|
-
|
95
|
-
var url = target.href;
|
96
|
-
|
97
|
-
var skip = false;
|
98
|
-
|
99
|
-
if (url[0] === "#") {
|
100
|
-
// print("return anchor only");
|
101
|
-
skip = true;
|
102
|
-
}
|
103
|
-
|
104
|
-
if (!skip) {
|
105
|
-
var now = window.location.href.replace(/^file:\/\//,"").replace(/#.*/,"");
|
106
|
-
var to = $master.first_script_window && $master.first_script_window.location.href;
|
107
|
-
// var to = $env.location(url,window.location.href != "about:blank" ? window.location.href: undefined);
|
108
|
-
// I'm not sure why this code is here ... looking at the FSW
|
109
|
-
// print("nu",now,url,to);
|
110
|
-
to = to || $env.location(url,window.location.href);
|
111
|
-
// print("nu",now,url,to);
|
112
|
-
if (to && to.indexOf(now)===0 && to[now.length]==="#") {
|
113
|
-
skip = true;
|
114
|
-
}
|
115
|
-
}
|
116
|
-
if (!skip) {
|
117
|
-
if (url && url.indexOf(now)===0 && url[now.length]==="#") {
|
118
|
-
// print("return diff anchor only");
|
119
|
-
skip = true;
|
120
|
-
}
|
121
|
-
}
|
122
|
-
if (!skip) {
|
123
|
-
// print($location, window.location.href === $location, $location.indexOf("#")>0);
|
124
|
-
if (url === window.location.href && $location.indexOf("#")>0) {
|
125
|
-
// print('returning same with anchor');
|
126
|
-
skip = true;
|
127
|
-
}
|
128
|
-
}
|
129
|
-
|
130
|
-
if (!skip){
|
131
|
-
$env.reload(window, target.href, {referer: window.location.href});
|
132
|
-
}
|
133
|
-
}
|
134
|
-
|
135
|
-
if (!handled && event.type == "click" &&
|
136
|
-
target.form &&
|
137
|
-
( target instanceof HTMLInputElement || target instanceof HTMLTypeValueInputs ) &&
|
138
|
-
( ( target.tagName === "INPUT" &&
|
139
|
-
(target.type === "submit" ||
|
140
|
-
target.type === "image" ) ) ||
|
141
|
-
( target.tagName === "BUTTON" &&
|
142
|
-
( !target.type ||
|
143
|
-
target.type === "submit" ) ) ) ) {
|
144
|
-
target.form.clk = target;
|
145
|
-
try{
|
146
|
-
target.form.submit();
|
147
|
-
// __submit__(target.form);
|
148
|
-
}catch(e){
|
149
|
-
print("oopse",e);
|
150
|
-
print(e.stack);
|
151
|
-
e.backtrace && print(e.backtrace().join("\n"));
|
152
|
-
throw e;
|
153
|
-
};
|
154
|
-
delete target.form.clk;
|
155
|
-
}
|
156
|
-
|
157
|
-
// print(event.type,target.type,target.constructor+"");
|
158
|
-
// print("A",handled,event.type,target,target.type);
|
159
|
-
if (!handled && event.type == "click" && target instanceof HTMLInputElement && ( target.type == "checkbox" || target.type == "radio" ) ) {
|
160
|
-
target.checked = target.checked ? "" : "checked";
|
161
|
-
}
|
162
|
-
|
163
|
-
if (!handled && (event.type == "submit") && target instanceof HTMLFormElement) {
|
164
|
-
$env.unload($w);
|
165
|
-
var proxy = $w.window;
|
166
|
-
var data;
|
167
|
-
var boundary;
|
168
|
-
if (target.enctype === "multipart/form-data") {
|
169
|
-
boundary = (new Date).getTime();
|
170
|
-
}
|
171
|
-
data = $master["static"].__formSerialize__(target,undefined,boundary);
|
172
|
-
var options = {method: target.method || "get", referer: this.location.href};
|
173
|
-
if (options.method === "post" || options.method === "put") {
|
174
|
-
options.data = data;
|
175
|
-
var undef;
|
176
|
-
data = undef;
|
177
|
-
}
|
178
|
-
if (boundary) {
|
179
|
-
options["Content-Type"] = "multipart/form-data; boundary="+boundary;
|
180
|
-
} else {
|
181
|
-
options["Content-Type"] = 'application/x-www-form-urlencoded';
|
182
|
-
}
|
183
|
-
var action = target.action || window.location.href;
|
184
|
-
if (data) {
|
185
|
-
if (action.indexOf("?") < 0) {
|
186
|
-
action = action + "?";
|
88
|
+
// SMP FIX: cancel/stop prop
|
89
|
+
if (!handled && event.$preventDefault) {
|
90
|
+
handled = true;
|
187
91
|
}
|
188
|
-
|
189
|
-
|
92
|
+
|
93
|
+
// print(event.type,target,handled);
|
94
|
+
|
95
|
+
if (!handled && event.type == "click" && target instanceof HTMLAnchorElement && target.href ) {
|
96
|
+
// window.location = target.href;
|
97
|
+
|
98
|
+
var url = target.href;
|
99
|
+
|
100
|
+
var skip = false;
|
101
|
+
|
102
|
+
if (url[0] === "#") {
|
103
|
+
// print("return anchor only");
|
104
|
+
skip = true;
|
105
|
+
}
|
106
|
+
|
107
|
+
if (!skip) {
|
108
|
+
var now = window.location.href.replace(/^file:\/\//,"").replace(/#.*/,"");
|
109
|
+
var to = $master.first_script_window && $master.first_script_window.location.href;
|
110
|
+
// var to = $env.location(url,window.location.href != "about:blank" ? window.location.href: undefined);
|
111
|
+
// I'm not sure why this code is here ... looking at the FSW
|
112
|
+
// print("nu",now,url,to);
|
113
|
+
to = to || $env.location(url,window.location.href);
|
114
|
+
// print("nu",now,url,to);
|
115
|
+
if (to && to.indexOf(now)===0 && to[now.length]==="#") {
|
116
|
+
skip = true;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
if (!skip) {
|
120
|
+
if (url && url.indexOf(now)===0 && url[now.length]==="#") {
|
121
|
+
// print("return diff anchor only");
|
122
|
+
skip = true;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
if (!skip) {
|
126
|
+
// print($location, window.location.href === $location, $location.indexOf("#")>0);
|
127
|
+
if (url === window.location.href && $location.indexOf("#")>0) {
|
128
|
+
// print('returning same with anchor');
|
129
|
+
skip = true;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
if (!skip){
|
134
|
+
$env.reload(window, target.href, {referer: window.location.href});
|
135
|
+
}
|
190
136
|
}
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
137
|
+
|
138
|
+
if (!handled && event.type == "click" &&
|
139
|
+
target.form &&
|
140
|
+
( target instanceof HTMLInputElement || target instanceof HTMLTypeValueInputs ) &&
|
141
|
+
( ( target.tagName === "INPUT" &&
|
142
|
+
(target.type === "submit" ||
|
143
|
+
target.type === "image" ) ) ||
|
144
|
+
( target.tagName === "BUTTON" &&
|
145
|
+
( !target.type ||
|
146
|
+
target.type === "submit" ) ) ) ) {
|
147
|
+
target.form.clk = target;
|
148
|
+
try{
|
149
|
+
target.form.submit();
|
150
|
+
// __submit__(target.form);
|
151
|
+
}catch(e){
|
152
|
+
print("oopse",e);
|
153
|
+
print(e.stack);
|
154
|
+
e.backtrace && print(e.backtrace().join("\n"));
|
155
|
+
throw e;
|
156
|
+
};
|
157
|
+
delete target.form.clk;
|
196
158
|
}
|
197
|
-
action = action + new_params.join("&");
|
198
|
-
}
|
199
|
-
$env.reload(proxy, action, options );
|
200
|
-
}
|
201
159
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
160
|
+
// print(event.type,target.type,target.constructor+"");
|
161
|
+
// print("A",handled,event.type,target,target.type);
|
162
|
+
if (!handled && event.type == "click" && target instanceof HTMLInputElement && ( target.type == "checkbox" || target.type == "radio" ) ) {
|
163
|
+
target.checked = target.checked ? "" : "checked";
|
164
|
+
}
|
165
|
+
|
166
|
+
if (!handled && (event.type == "submit") && target instanceof HTMLFormElement) {
|
167
|
+
$env.unload($w);
|
168
|
+
var proxy = $w.window;
|
169
|
+
var data;
|
170
|
+
var boundary;
|
171
|
+
if (target.enctype === "multipart/form-data") {
|
172
|
+
boundary = (new Date).getTime();
|
173
|
+
}
|
174
|
+
data = $master["static"].__formSerialize__(target,undefined,boundary);
|
175
|
+
var options = {method: target.method || "get", referer: this.location.href};
|
176
|
+
if (options.method === "post" || options.method === "put") {
|
177
|
+
options.data = data;
|
178
|
+
var undef;
|
179
|
+
data = undef;
|
180
|
+
}
|
181
|
+
if (boundary) {
|
182
|
+
options["Content-Type"] = "multipart/form-data; boundary="+boundary;
|
183
|
+
} else {
|
184
|
+
options["Content-Type"] = 'application/x-www-form-urlencoded';
|
185
|
+
}
|
186
|
+
var action = target.action || window.location.href;
|
187
|
+
if (data) {
|
188
|
+
if (action.indexOf("?") < 0) {
|
189
|
+
action = action + "?";
|
190
|
+
}
|
191
|
+
if (action[action.length-1] != "?") {
|
192
|
+
action = action + "&";
|
193
|
+
}
|
194
|
+
var params = unescape(data).split("&");
|
195
|
+
var new_params = [];
|
196
|
+
for(var pi=0; pi < params.length; pi++) {
|
197
|
+
var pair = params[pi].split("=");
|
198
|
+
new_params.push(escape(pair[0])+"="+escape(pair[1]));
|
199
|
+
}
|
200
|
+
action = action + new_params.join("&");
|
201
|
+
}
|
202
|
+
$env.reload(proxy, action, options );
|
203
|
+
}
|
204
|
+
|
205
|
+
}else{
|
206
|
+
//$debug("non target: " + event.target + " \n this->"+target);
|
207
|
+
}
|
208
|
+
if (!handled && bubbles && target.parentNode){
|
209
|
+
//$debug('bubbling to parentNode '+target.parentNode);
|
210
|
+
__dispatchEvent__(target.parentNode, event, bubbles);
|
211
|
+
}
|
212
|
+
}catch(e){
|
213
|
+
$warn("Exception while dispatching events: "+e);
|
214
|
+
// print("oops e",e.stack);
|
215
|
+
// print("oops e",e.backtrace && e.backtrace().join("\n"));
|
216
|
+
// try { throw new Error("here"); } catch(x) { print("oops e",x.stack); }
|
217
|
+
throw e;
|
208
218
|
}
|
209
|
-
}catch(e){
|
210
|
-
$warn("Exception while dispatching events: "+e);
|
211
|
-
// print("oops e",e.stack);
|
212
|
-
// print("oops e",e.backtrace && e.backtrace().join("\n"));
|
213
|
-
// try { throw new Error("here"); } catch(x) { print("oops e",x.stack); }
|
214
|
-
throw e;
|
215
|
-
}
|
216
219
|
};
|
217
220
|
|
218
221
|
$env.__removeEventListener__ = __removeEventListener__;
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 3
|
9
|
+
version: 0.3.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- John Resig
|
@@ -34,34 +34,20 @@ dependencies:
|
|
34
34
|
version: 2.0.0.pre3
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: gemcutter
|
39
|
-
prerelease: false
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
- 5
|
47
|
-
- 0
|
48
|
-
version: 0.5.0
|
49
|
-
type: :development
|
50
|
-
version_requirements: *id002
|
51
37
|
- !ruby/object:Gem::Dependency
|
52
38
|
name: hoe
|
53
39
|
prerelease: false
|
54
|
-
requirement: &
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
55
41
|
requirements:
|
56
42
|
- - ">="
|
57
43
|
- !ruby/object:Gem::Version
|
58
44
|
segments:
|
59
45
|
- 2
|
60
|
-
-
|
46
|
+
- 6
|
61
47
|
- 0
|
62
|
-
version: 2.
|
48
|
+
version: 2.6.0
|
63
49
|
type: :development
|
64
|
-
version_requirements: *
|
50
|
+
version_requirements: *id002
|
65
51
|
description: |-
|
66
52
|
A browser environment for javascript interpreters.
|
67
53
|
|