Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
renderjs
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
Klaus Wölfel
renderjs
Commits
a8f1951c
Commit
a8f1951c
authored
Feb 21, 2013
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorize code. Make sure a JSON gadget can contain child nodes.
parent
d1919ba0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
renderjs.js
renderjs.js
+15
-7
test/renderjs_test.js
test/renderjs_test.js
+1
-1
No files found.
renderjs.js
View file @
a8f1951c
...
...
@@ -28,6 +28,13 @@ var RenderJs = (function () {
// a variable indicating if current gadget loading is over or not
var
is_ready
=
false
,
current_gadget
;
function
setSelfGadget
(
gadget
)
{
/*
* Only used internally to set current gadget being executed.
*/
current_gadget
=
gadget
;
}
return
{
init
:
function
()
{
...
...
@@ -103,10 +110,10 @@ var RenderJs = (function () {
* gadgets.
*/
// set current gadget as being loaded so gadget instance itself knows which gadget it is
current_gadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
gadget
.
attr
(
"
id
"
));
setSelfGadget
(
RenderJs
.
GadgetIndex
.
getGadgetById
(
gadget
.
attr
(
"
id
"
)
));
gadget
.
append
(
data
);
// reset as no longer current gadget
current_gadget
=
undefined
;
setSelfGadget
(
undefined
)
;
// a gadget may contain sub gadgets
RenderJs
.
loadRecursiveGadget
(
gadget
);
},
...
...
@@ -680,18 +687,19 @@ var RenderJs = (function () {
/*
* Inspect DOM and initialize this gadget
*/
var
dom_list
;
var
dom_list
,
gadget_id
;
if
(
force
===
1
)
{
// we explicitly want to re-init elements even if already this is done before
dom_list
=
$
(
"
div[data-gadget-connection]
"
);
}
else
{
// XXX: improve and save 'bound' on javascript representation of a gadget not DOM
dom_list
=
$
(
"
div[data-gadget-connection]
"
)
.
filter
(
function
()
{
return
$
(
this
).
data
(
"
bound
"
)
!==
true
;
})
.
data
(
'
bound
'
,
true
)
.
data
(
'
bound
'
,
true
)
;
}
dom_list
.
each
(
function
(
index
,
element
)
{
RenderJs
.
InteractionGadget
.
bind
(
$
(
element
));});
RenderJs
.
InteractionGadget
.
bind
(
$
(
element
));});
},
bind
:
function
(
gadget_dom
)
{
...
...
@@ -811,10 +819,10 @@ var RenderJs = (function () {
method_id
=
gadget_route
.
destination
.
split
(
'
.
'
)[
1
],
gadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
gadget_id
);
// set gadget value so getSelfGadget can work
current_gadget
=
gadget
;
setSelfGadget
(
gadget
)
;
gadget
[
method_id
].
apply
(
null
,
arguments
);
// reset as no longer needed
current_gadget
=
undefined
;
setSelfGadget
(
undefined
)
;
};
// add route itself
priority
=
gadget_route
.
priority
;
...
...
test/renderjs_test.js
View file @
a8f1951c
...
...
@@ -200,7 +200,7 @@ function setupRenderJSTest(){
module
(
"
GadgetDataHandler
"
);
test
(
'
GadgetDataHandler
'
,
function
()
{
cleanUp
();
$
(
"
#qunit-fixture
"
).
append
(
'
<div data-gadget="" id="json-gadget" data-gadget-source = "json/json_file.json" data-gadget-handler="parseJSONAndUpdateNameSpace"></div>
'
);
$
(
"
#qunit-fixture
"
).
append
(
'
<div data-gadget="" id="json-gadget" data-gadget-source = "json/json_file.json" data-gadget-handler="parseJSONAndUpdateNameSpace"><
p>some content</p><
/div>
'
);
RenderJs
.
bootstrap
(
$
(
"
#qunit-fixture
"
));
equal
(
''
,
first_name
);
equal
(
''
,
last_name
);
...
...
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