Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
todomvc
Commits
adc123f3
Commit
adc123f3
authored
May 17, 2015
by
Arthur Verschaeve
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1302 from tastejs/sjs/fix-webrx
webrx fixes
parents
0b3a583c
b4cb63db
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
159 additions
and
34 deletions
+159
-34
examples/webrx/js/app.js
examples/webrx/js/app.js
+1
-4
examples/webrx/node_modules/todomvc-common/base.js
examples/webrx/node_modules/todomvc-common/base.js
+7
-2
examples/webrx/node_modules/webrx/dist/web.rx.js
examples/webrx/node_modules/webrx/dist/web.rx.js
+151
-28
No files found.
examples/webrx/js/app.js
View file @
adc123f3
...
...
@@ -123,12 +123,9 @@
// setup routing
var
self
=
this
;
// Configure the Base-Url for all states (in a production-setup you would probably
// pass this from server to client via a custom query-parameter or something similar)
wx
.
router
.
baseUrl
=
'
/examples/webrx/
'
;
wx
.
router
.
state
({
name
:
'
$
'
,
url
:
'
/examples/webrx/
'
,
onEnter
:
function
()
{
self
.
showMode
(
displayModeAll
);
}
...
...
examples/webrx/node_modules/todomvc-common/base.js
View file @
adc123f3
...
...
@@ -114,7 +114,12 @@
})({});
if
(
location
.
hostname
===
'
todomvc.com
'
)
{
window
.
_gaq
=
[[
'
_setAccount
'
,
'
UA-31081062-1
'
],[
'
_trackPageview
'
]];(
function
(
d
,
t
){
var
g
=
d
.
createElement
(
t
),
s
=
d
.
getElementsByTagName
(
t
)[
0
];
g
.
src
=
'
//www.google-analytics.com/ga.js
'
;
s
.
parentNode
.
insertBefore
(
g
,
s
)}(
document
,
'
script
'
));
(
function
(
i
,
s
,
o
,
g
,
r
,
a
,
m
){
i
[
'
GoogleAnalyticsObject
'
]
=
r
;
i
[
r
]
=
i
[
r
]
||
function
(){
(
i
[
r
].
q
=
i
[
r
].
q
||
[]).
push
(
arguments
)},
i
[
r
].
l
=
1
*
new
Date
();
a
=
s
.
createElement
(
o
),
m
=
s
.
getElementsByTagName
(
o
)[
0
];
a
.
async
=
1
;
a
.
src
=
g
;
m
.
parentNode
.
insertBefore
(
a
,
m
)
})(
window
,
document
,
'
script
'
,
'
https://www.google-analytics.com/analytics.js
'
,
'
ga
'
);
ga
(
'
create
'
,
'
UA-31081062-1
'
,
'
auto
'
);
ga
(
'
send
'
,
'
pageview
'
);
}
/* jshint ignore:end */
...
...
@@ -228,7 +233,7 @@
xhr
.
onload
=
function
(
e
)
{
var
parsedResponse
=
JSON
.
parse
(
e
.
target
.
responseText
);
if
(
parsedResponse
instanceof
Array
)
{
var
count
=
parsedResponse
.
length
var
count
=
parsedResponse
.
length
;
if
(
count
!==
0
)
{
issueLink
.
innerHTML
=
'
This app has
'
+
count
+
'
open issues
'
;
document
.
getElementById
(
'
issue-count
'
).
style
.
display
=
'
inline
'
;
...
...
examples/webrx/node_modules/webrx/dist/web.rx.js
View file @
adc123f3
var
wx
;
(
function
(
wx
)
{
"
use strict
"
;
})(
wx
||
(
wx
=
{}));
var
wx
;
(
function
(
wx
)
{
"
use strict
"
;
var
WeakMapEmulated
=
(
function
()
{
...
...
@@ -59,10 +63,6 @@ var wx;
"
use strict
"
;
})(
wx
||
(
wx
=
{}));
var
wx
;
(
function
(
wx
)
{
"
use strict
"
;
})(
wx
||
(
wx
=
{}));
var
wx
;
(
function
(
wx
)
{
var
internal
;
(
function
(
internal
)
{
...
...
@@ -104,7 +104,7 @@ var wx;
var
wx
;
(
function
(
wx
)
{
"
use strict
"
;
var
cssClassNameRegex
=
/
\S
+/g
;
var
regexCssClassName
=
/
\S
+/g
;
var
RxObsConstructor
=
Rx
.
Observable
;
wx
.
noop
=
function
()
{
};
...
...
@@ -163,6 +163,20 @@ var wx;
return
false
;
}
wx
.
isInUnitTest
=
isInUnitTest
;
function
getSearchParameters
(
query
)
{
query
=
query
||
wx
.
app
.
history
.
location
.
search
.
substr
(
1
);
if
(
query
)
{
var
result
=
{};
var
params
=
query
.
split
(
"
&
"
);
for
(
var
i
=
0
;
i
<
params
.
length
;
i
++
)
{
var
tmp
=
params
[
i
].
split
(
"
=
"
);
result
[
tmp
[
0
]]
=
decodeURIComponent
(
tmp
[
1
]);
}
return
result
;
}
return
{};
}
wx
.
getSearchParameters
=
getSearchParameters
;
function
args2Array
(
args
)
{
var
result
=
[];
for
(
var
i
=
0
,
len
=
args
.
length
;
i
<
len
;
i
++
)
{
...
...
@@ -246,7 +260,7 @@ var wx;
classNames
[
_i
-
2
]
=
arguments
[
_i
];
}
if
(
classNames
)
{
var
currentClassNames
=
node
.
className
.
match
(
cssClassNameRegex
)
||
[];
var
currentClassNames
=
node
.
className
.
match
(
regexCssClassName
)
||
[];
var
index
;
var
i
;
var
className
;
...
...
@@ -4581,6 +4595,100 @@ var wx;
wx
.
list
=
list
;
})(
wx
||
(
wx
=
{}));
var
wx
;
(
function
(
wx
)
{
"
use strict
"
;
var
MapEmulated
=
(
function
()
{
function
MapEmulated
()
{
this
.
cacheSentinel
=
{};
this
.
keys
=
[];
this
.
values
=
[];
this
.
cache
=
this
.
cacheSentinel
;
}
Object
.
defineProperty
(
MapEmulated
.
prototype
,
"
size
"
,
{
get
:
function
()
{
return
this
.
keys
.
length
;
},
enumerable
:
true
,
configurable
:
true
});
MapEmulated
.
prototype
.
has
=
function
(
key
)
{
if
(
key
===
this
.
cache
)
{
return
true
;
}
if
(
this
.
find
(
key
)
>=
0
)
{
this
.
cache
=
key
;
return
true
;
}
return
false
;
};
MapEmulated
.
prototype
.
get
=
function
(
key
)
{
var
index
=
this
.
find
(
key
);
if
(
index
>=
0
)
{
this
.
cache
=
key
;
return
this
.
values
[
index
];
}
return
undefined
;
};
MapEmulated
.
prototype
.
set
=
function
(
key
,
value
)
{
this
.
delete
(
key
);
this
.
keys
.
push
(
key
);
this
.
values
.
push
(
value
);
this
.
cache
=
key
;
return
this
;
};
MapEmulated
.
prototype
.
delete
=
function
(
key
)
{
var
index
=
this
.
find
(
key
);
if
(
index
>=
0
)
{
this
.
keys
.
splice
(
index
,
1
);
this
.
values
.
splice
(
index
,
1
);
this
.
cache
=
this
.
cacheSentinel
;
return
true
;
}
return
false
;
};
MapEmulated
.
prototype
.
clear
=
function
()
{
this
.
keys
.
length
=
0
;
this
.
values
.
length
=
0
;
this
.
cache
=
this
.
cacheSentinel
;
};
MapEmulated
.
prototype
.
forEach
=
function
(
callback
,
thisArg
)
{
var
size
=
this
.
size
;
for
(
var
i
=
0
;
i
<
size
;
++
i
)
{
var
key
=
this
.
keys
[
i
];
var
value
=
this
.
values
[
i
];
this
.
cache
=
key
;
callback
.
call
(
this
,
value
,
key
,
this
);
}
};
Object
.
defineProperty
(
MapEmulated
.
prototype
,
"
isEmulated
"
,
{
get
:
function
()
{
return
true
;
},
enumerable
:
true
,
configurable
:
true
});
MapEmulated
.
prototype
.
find
=
function
(
key
)
{
var
keys
=
this
.
keys
;
var
size
=
keys
.
length
;
for
(
var
i
=
0
;
i
<
size
;
++
i
)
{
if
(
keys
[
i
]
===
key
)
{
return
i
;
}
}
return
-
1
;
};
return
MapEmulated
;
})();
var
hasNativeSupport
=
typeof
Map
===
"
function
"
&&
Map
.
prototype
.
hasOwnProperty
(
"
forEach
"
)
&&
Map
.
prototype
.
hasOwnProperty
(
"
add
"
)
&&
Map
.
prototype
.
hasOwnProperty
(
"
clear
"
)
&&
Map
.
prototype
.
hasOwnProperty
(
"
devare
"
)
&&
Map
.
prototype
.
hasOwnProperty
(
"
has
"
);
function
createMap
(
disableNativeSupport
)
{
if
(
disableNativeSupport
||
!
hasNativeSupport
)
{
return
new
MapEmulated
();
}
return
new
Map
();
}
wx
.
createMap
=
createMap
;
})(
wx
||
(
wx
=
{}));
var
wx
;
(
function
(
wx
)
{
"
use strict
"
;
var
groupId
=
0
;
...
...
@@ -6642,7 +6750,6 @@ var wx;
var
Router
=
(
function
()
{
function
Router
(
domManager
)
{
var
_this
=
this
;
this
.
baseUrl
=
"
/
"
;
this
.
current
=
wx
.
property
();
this
.
states
=
{};
this
.
pathSeparator
=
"
.
"
;
...
...
@@ -6650,7 +6757,7 @@ var wx;
this
.
rootStateName
=
"
$
"
;
this
.
validPathRegExp
=
/^
[
a-zA-Z
]([\w
-_
]
*$
)
/
;
this
.
domManager
=
domManager
;
this
.
reset
();
this
.
reset
(
false
);
wx
.
app
.
history
.
onPopState
.
subscribe
(
function
(
e
)
{
var
state
=
e
.
state
;
var
stateName
=
state
.
stateName
;
...
...
@@ -6661,6 +6768,7 @@ var wx;
});
wx
.
app
.
title
.
changed
.
subscribe
(
function
(
x
)
{
document
.
title
=
x
;
if
(
_this
.
current
()
!=
null
)
_this
.
replaceHistoryState
(
_this
.
current
(),
x
);
});
}
...
...
@@ -6727,30 +6835,45 @@ var wx;
return
route
.
stringify
(
params
);
return
null
;
};
Router
.
prototype
.
reset
=
function
()
{
Router
.
prototype
.
reset
=
function
(
enterRootState
)
{
if
(
enterRootState
===
void
0
)
{
enterRootState
=
true
;
}
this
.
states
=
{};
this
.
root
=
this
.
registerStateInternal
({
name
:
this
.
rootStateName
,
route
:
wx
.
route
(
this
.
baseUrl
)
url
:
wx
.
route
(
"
/
"
)
});
if
(
enterRootState
)
this
.
go
(
this
.
rootStateName
,
{},
{
location
:
2
/* replace */
});
};
Router
.
prototype
.
sync
=
function
()
{
var
uri
=
wx
.
app
.
history
.
location
.
pathname
;
Router
.
prototype
.
sync
=
function
(
url
)
{
if
(
url
==
null
)
url
=
wx
.
app
.
history
.
location
.
pathname
;
var
keys
=
Object
.
keys
(
this
.
states
);
var
length
=
keys
.
length
;
var
params
;
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
var
state
=
this
.
states
[
keys
[
i
]];
var
route
=
this
.
getAbsoluteRouteForState
(
state
.
name
);
if
((
params
=
route
.
parse
(
ur
i
))
!=
null
)
{
if
((
params
=
route
.
parse
(
ur
l
))
!=
null
)
{
this
.
go
(
state
.
name
,
params
,
{
location
:
2
/* replace */
});
break
;
return
;
}
}
if
(
this
.
current
()
==
null
)
this
.
reload
();
};
Router
.
prototype
.
reload
=
function
()
{
this
.
go
(
this
.
current
().
name
,
this
.
current
().
params
,
{
force
:
true
,
location
:
false
});
var
state
;
var
params
;
if
(
this
.
current
()
!=
null
)
{
state
=
this
.
current
().
name
;
params
=
this
.
current
().
params
;
}
else
{
state
=
this
.
rootStateName
;
params
=
{};
}
this
.
go
(
state
,
params
,
{
force
:
true
,
location
:
2
/* replace */
});
};
Router
.
prototype
.
getViewComponent
=
function
(
viewName
)
{
var
_current
=
this
.
current
();
...
...
@@ -6794,16 +6917,16 @@ var wx;
}
state
=
wx
.
extend
(
state
,
{});
this
.
states
[
state
.
name
]
=
state
;
if
(
state
.
route
!=
null
)
{
if
(
typeof
state
.
route
===
"
string
"
)
{
state
.
route
=
wx
.
route
(
state
.
route
);
if
(
state
.
url
!=
null
)
{
if
(
typeof
state
.
url
===
"
string
"
)
{
state
.
url
=
wx
.
route
(
state
.
url
);
}
}
else
{
if
(
state
.
name
!==
this
.
rootStateName
)
state
.
route
=
wx
.
route
(
parts
[
parts
.
length
-
1
]);
state
.
url
=
wx
.
route
(
parts
[
parts
.
length
-
1
]);
else
state
.
route
=
wx
.
route
(
this
.
baseUrl
);
state
.
url
=
wx
.
route
(
"
/
"
);
}
if
(
state
.
name
===
this
.
rootStateName
)
this
.
root
=
state
;
...
...
@@ -6862,7 +6985,7 @@ var wx;
if
(
state
==
null
)
{
state
=
{
name
:
stateName
,
route
:
wx
.
route
(
stateName
)
url
:
wx
.
route
(
stateName
)
};
}
result
.
push
(
state
);
...
...
@@ -6874,14 +6997,14 @@ var wx;
var
result
=
null
;
hierarchy
.
forEach
(
function
(
state
)
{
if
(
result
!=
null
)
{
var
route
=
state
.
route
;
var
route
=
state
.
url
;
if
(
!
route
.
isAbsolute
)
result
=
result
.
concat
(
state
.
route
);
result
=
result
.
concat
(
state
.
url
);
else
result
=
route
;
}
else
{
result
=
state
.
route
;
result
=
state
.
url
;
}
});
return
result
;
...
...
@@ -6957,7 +7080,7 @@ var wx;
}
});
result
=
Object
.
keys
(
stateParams
);
result
=
result
.
concat
(
config
.
route
.
params
);
result
=
result
.
concat
(
config
.
url
.
params
);
}
return
result
;
};
...
...
@@ -6985,6 +7108,6 @@ var wx;
})(
wx
||
(
wx
=
{}));
var
wx
;
(
function
(
wx
)
{
wx
.
version
=
'
0.9.
79
'
;
wx
.
version
=
'
0.9.
83
'
;
})(
wx
||
(
wx
=
{}));
//# sourceMappingURL=web.rx.js.map
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment