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
f8019bd0
Commit
f8019bd0
authored
Jun 25, 2013
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap lines.
parent
3d0ee0c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
18 deletions
+34
-18
renderjs.js
renderjs.js
+34
-18
No files found.
renderjs.js
View file @
f8019bd0
/*! RenderJs v0.2 */
/*! RenderJs v0.2 */
/*global $, localStorage, jIO */
/*global $, localStorage, jIO */
/*jslint evil: true, indent: 2, maxerr: 3 */
/*jslint evil: true, indent: 2, maxerr: 3
, maxlen: 79
*/
"
use strict
"
;
"
use strict
"
;
/*
/*
* RenderJs - Generic Gadget library renderer.
* RenderJs - Generic Gadget library renderer.
...
@@ -64,7 +64,8 @@ var RenderJs = (function () {
...
@@ -64,7 +64,8 @@ var RenderJs = (function () {
RenderJs
.
bootstrap
(
$
(
'
body
'
));
RenderJs
.
bootstrap
(
$
(
'
body
'
));
}
}
var
root_gadget
=
RenderJs
.
GadgetIndex
.
getRootGadget
();
var
root_gadget
=
RenderJs
.
GadgetIndex
.
getRootGadget
();
if
(
RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND
||
RENDERJS_ENABLE_IMPLICIT_ROUTE_CREATE
)
{
if
(
RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND
||
RENDERJS_ENABLE_IMPLICIT_ROUTE_CREATE
)
{
// We might have a page without gadgets.
// We might have a page without gadgets.
// Be careful, right now we can be in this case because
// Be careful, right now we can be in this case because
// asynchronous gadget loading is not finished
// asynchronous gadget loading is not finished
...
@@ -93,7 +94,8 @@ var RenderJs = (function () {
...
@@ -93,7 +94,8 @@ var RenderJs = (function () {
var
gadget_id
,
is_gadget
;
var
gadget_id
,
is_gadget
;
gadget_id
=
root
.
attr
(
"
id
"
);
gadget_id
=
root
.
attr
(
"
id
"
);
is_gadget
=
root
.
attr
(
"
data-gadget
"
)
!==
undefined
;
is_gadget
=
root
.
attr
(
"
data-gadget
"
)
!==
undefined
;
// this will make RenderJs fire "ready" event when all gadgets are loaded.
// this will make RenderJs fire "ready" event when all
// gadgets are loaded.
RenderJs
.
setReady
(
false
);
RenderJs
.
setReady
(
false
);
if
(
is_gadget
&&
gadget_id
!==
undefined
)
{
if
(
is_gadget
&&
gadget_id
!==
undefined
)
{
// bootstart root gadget only if it is indeed a gadget
// bootstart root gadget only if it is indeed a gadget
...
@@ -129,7 +131,8 @@ var RenderJs = (function () {
...
@@ -129,7 +131,8 @@ var RenderJs = (function () {
* Set gadget data and recursively load it in case it holds another
* Set gadget data and recursively load it in case it holds another
* gadgets.
* gadgets.
*/
*/
// set current gadget as being loaded so gadget instance itself knows which gadget it is
// set current gadget as being loaded so gadget instance itself
// knows which gadget it is
setSelfGadget
(
RenderJs
.
GadgetIndex
.
getGadgetById
(
gadget
.
attr
(
"
id
"
)));
setSelfGadget
(
RenderJs
.
GadgetIndex
.
getGadgetById
(
gadget
.
attr
(
"
id
"
)));
gadget
.
append
(
data
);
gadget
.
append
(
data
);
// reset as no longer current gadget
// reset as no longer current gadget
...
@@ -141,12 +144,16 @@ var RenderJs = (function () {
...
@@ -141,12 +144,16 @@ var RenderJs = (function () {
getSelfGadget
:
function
()
{
getSelfGadget
:
function
()
{
/*
/*
* Get current gadget being loaded
* Get current gadget being loaded
* This function must be used with care as it relies on Javascript nature of being a single
* This function must be used with care as it relies on
* threaded application. Currently current gadget is set in a global RenderJs variable
* Javascript nature of being a single threaded application.
* before its HTML is inserted into DOM and if multiple threads were running (which is not the case currently)
* Currently current gadget is set in a global RenderJs variable
* this could lead to reace conditions and unreliable getSelfGadget results.
* before its HTML is inserted into DOM and if multiple threads
* Additionally this function is available only at gadget's script load time - i.e.
* were running (which is not the case currently)
* it can't be used in after that calls. In this case gagdget can save this value internally.
* this could lead to reace conditions and unreliable getSelfGadget
* results.
* Additionally this function is available only at gadget's script
* load time - i.e. it can't be used in after that calls.
* In this case gagdget can save this value internally.
*/
*/
return
current_gadget
;
return
current_gadget
;
},
},
...
@@ -321,7 +328,8 @@ var RenderJs = (function () {
...
@@ -321,7 +328,8 @@ var RenderJs = (function () {
}
}
}
}
});
});
// asynchronous update happens and respective thread will update status
// asynchronous update happens and respective thread will update
// status
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -473,7 +481,8 @@ var RenderJs = (function () {
...
@@ -473,7 +481,8 @@ var RenderJs = (function () {
visible_dom
.
removeClass
(
"
not_selected
"
);
visible_dom
.
removeClass
(
"
not_selected
"
);
},
},
addNewTabGadget
:
function
(
dom_id
,
gadget_id
,
gadget
,
gadget_data_handler
,
addNewTabGadget
:
function
(
dom_id
,
gadget_id
,
gadget
,
gadget_data_handler
,
gadget_data_source
,
bootstrap
)
{
gadget_data_source
,
bootstrap
)
{
/*
/*
* add new gadget and render it
* add new gadget and render it
...
@@ -696,12 +705,16 @@ var RenderJs = (function () {
...
@@ -696,12 +705,16 @@ var RenderJs = (function () {
*/
*/
var
dom_list
,
gadget_id
;
var
dom_list
,
gadget_id
;
if
(
force
===
1
)
{
if
(
force
===
1
)
{
// we explicitly want to re-init elements even if already this is done before
// we explicitly want to re-init elements even if already this
// is done before
dom_list
=
$
(
"
div[data-gadget-connection]
"
);
dom_list
=
$
(
"
div[data-gadget-connection]
"
);
}
else
{
}
else
{
// XXX: improve and save 'bound' on javascript representation of a gadget not DOM
// XXX: improve and save 'bound' on javascript representation
// of a gadget not DOM
dom_list
=
$
(
"
div[data-gadget-connection]
"
)
dom_list
=
$
(
"
div[data-gadget-connection]
"
)
.
filter
(
function
()
{
return
$
(
this
).
data
(
"
bound
"
)
!==
true
;
})
.
filter
(
function
()
{
return
$
(
this
).
data
(
"
bound
"
)
!==
true
;
})
.
data
(
'
bound
'
,
true
);
.
data
(
'
bound
'
,
true
);
}
}
dom_list
.
each
(
function
(
index
,
element
)
{
dom_list
.
each
(
function
(
index
,
element
)
{
...
@@ -812,7 +825,8 @@ var RenderJs = (function () {
...
@@ -812,7 +825,8 @@ var RenderJs = (function () {
RouteGadget
:
(
function
()
{
RouteGadget
:
(
function
()
{
/*
/*
* A gadget that defines possible routes (i.e. URL changes) between gadgets.
* A gadget that defines possible routes (i.e. URL changes)
* between gadgets.
*/
*/
var
route_list
=
[];
var
route_list
=
[];
return
{
return
{
...
@@ -852,13 +866,15 @@ var RenderJs = (function () {
...
@@ -852,13 +866,15 @@ var RenderJs = (function () {
// default is 1 -i.e.first level
// default is 1 -i.e.first level
priority
=
1
;
priority
=
1
;
}
}
RenderJs
.
RouteGadget
.
add
(
gadget_route
.
source
,
handler_func
,
priority
);
RenderJs
.
RouteGadget
.
add
(
gadget_route
.
source
,
handler_func
,
priority
);
});
});
},
},
add
:
function
(
path
,
handler_func
,
priority
)
{
add
:
function
(
path
,
handler_func
,
priority
)
{
/*
/*
* Add a route between path (hashable) and a handler function (part of Gadget's API).
* Add a route between path (hashable) and a handler function
* (part of Gadget's API).
*/
*/
var
body
=
$
(
"
body
"
);
var
body
=
$
(
"
body
"
);
body
body
...
...
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