Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
renderjs
Commits
4fdcc595
Commit
4fdcc595
authored
Feb 08, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renderJS: add check to prevent gadgets from multiple insertions or not being loaded
parent
11d56a4b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
11 deletions
+30
-11
examples/jqm_3/index.html
examples/jqm_3/index.html
+1
-1
examples/jqm_3/js/controller.js
examples/jqm_3/js/controller.js
+0
-1
examples/jqm_3/page2.html
examples/jqm_3/page2.html
+1
-1
renderjs.js
renderjs.js
+28
-8
No files found.
examples/jqm_3/index.html
View file @
4fdcc595
...
...
@@ -9,7 +9,7 @@
</head>
<body>
<div
data-role=
"page"
>
<div
data-role=
"page"
id=
"index"
>
<div
data-role=
"header"
>
<h1>
Example 3
</h1>
</div>
...
...
examples/jqm_3/js/controller.js
View file @
4fdcc595
...
...
@@ -11,7 +11,6 @@ define([], function () {
$
(
document
).
on
(
'
pagebeforeshow
'
,
'
div:jqmData(role="page")
'
,
function
()
{
// renderJS handler
RenderJs
.
init
();
RenderJs
.
bindReady
(
function
()
{
...
...
examples/jqm_3/page2.html
View file @
4fdcc595
...
...
@@ -9,7 +9,7 @@
</head>
<body>
<div
data-role=
"page"
>
<div
data-role=
"page"
id=
"page2"
>
<div
data-role=
"header"
>
<h1>
Example 3 - Page 2
</h1>
</div>
...
...
renderjs.js
View file @
4fdcc595
...
...
@@ -58,16 +58,19 @@ var RenderJs = (function () {
* Load all gadgets for this DOM element
* (including recursively contained ones)
*/
var
gadget_id
,
is_gadget
;
gadget_id
=
root
.
attr
(
"
id
"
)
;
is_gadget
=
root
.
attr
(
"
data-gadget
"
)
!==
undefined
;
var
all_gadgets_on_root
=
root
.
find
(
"
[data-gadget]
"
),
i
,
gadget_id
,
gadget
;
// this will make RenderJs fire "ready" event when all gadgets are loaded.
RenderJs
.
setReady
(
false
);
if
(
is_gadget
&&
gadget_id
!==
undefined
)
{
// bootstart root gadget only if it is indeed a gadget
RenderJs
.
loadGadget
(
root
);
for
(
i
=
0
;
i
<
all_gadgets_on_root
.
length
;
i
+=
1
)
{
gadget
=
$
(
all_gadgets_on_root
[
i
]);
gadget_id
=
gadget
.
attr
(
"
id
"
);
if
(
gadget_id
!==
undefined
)
{
// bootstart root gadget only if it is indeed a gadget
RenderJs
.
loadGadget
(
gadget
);
}
}
RenderJs
.
loadRecursiveGadget
(
root
);
},
loadRecursiveGadget
:
function
(
root
)
{
...
...
@@ -106,11 +109,26 @@ var RenderJs = (function () {
/*
* Load gadget's SPECs from URL
*/
var
url
,
gadget_id
,
gadget_property
,
cacheable
,
cache_id
,
var
url
,
gadget_id
,
gadget_property
,
cacheable
,
cache_id
,
i
,
gadget_index
,
gadget_index_id
,
app_cache
,
data
,
gadget_js
,
is_update_gadget_data_running
;
url
=
gadget
.
attr
(
"
data-gadget
"
);
gadget_id
=
gadget
.
attr
(
"
id
"
);
gadget_js
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
gadget_id
);
gadget_index
=
RenderJs
.
GadgetIndex
.
getGadgetList
();
for
(
i
=
0
;
i
<
gadget_index
.
length
;
i
+=
1
)
{
gadget_index_id
=
gadget_index
[
i
].
id
;
// stop here, if the gadget_id is already on the gadgetIndex
// but not when the gadget on the page has no childNodes
// (because it's back to unenhanced status = page reload)
if
(
gadget_index_id
===
gadget_id
&&
document
.
getElementById
(
gadget_index_id
).
hasChildNodes
()
)
{
return
;
}
}
if
(
gadget_js
===
undefined
)
{
// register gadget in javascript namespace if not already registered
gadget_js
=
new
RenderJs
.
Gadget
(
gadget_id
,
gadget
);
...
...
@@ -179,6 +197,8 @@ var RenderJs = (function () {
}
});
}
// labelled
gadget_js
.
status
=
"
rendered
"
;
}
else
{
// gadget is an inline (InteractorGadget or one using
...
...
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