Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
dc9702f4
Commit
dc9702f4
authored
Sep 03, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RenderJs source code re-indented correctly
parent
42731279
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
474 additions
and
429 deletions
+474
-429
OfficeJS/src/renderjs/renderjs.js
OfficeJS/src/renderjs/renderjs.js
+474
-429
No files found.
OfficeJS/src/renderjs/renderjs.js
View file @
dc9702f4
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
// still it's possible to override this and use explicit gadget rendering
// still it's possible to override this and use explicit gadget rendering
var
RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING
=
true
;
var
RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING
=
true
;
// Add required by RenderJs jstorage library only if used HTML application uses requirejs
// Add required by RenderJs jstorage library only if used HTML application
// uses requirejs
if
(
typeof
require
!==
'
undefined
'
)
{
if
(
typeof
require
!==
'
undefined
'
)
{
require
([
"
../../../../lib/jstorage/jstorage.js
"
],
function
(
util
)
{
require
([
"
../../../../lib/jstorage/jstorage.js
"
],
function
(
util
)
{
});
});
...
@@ -14,19 +15,15 @@ if (typeof console === "undefined" || typeof console.log === "undefined") {
...
@@ -14,19 +15,15 @@ if (typeof console === "undefined" || typeof console.log === "undefined") {
console
.
log
=
function
()
{};
console
.
log
=
function
()
{};
}
}
/*
/*
* Generic Gadget library renderer
* Generic Gadget library renderer
*/
*/
var
RenderJs
=
(
function
()
{
var
RenderJs
=
(
function
()
{
// a variable indicating if current gadget loading is over or not
// a variable indicating if current gadget loading is over or not
var
is_ready
=
false
;
var
is_ready
=
false
;
return
{
return
{
bootstrap
:
function
(
root
)
{
bootstrap
:
function
(
root
){
/* initial load application gadget */
/* initial load application gadget */
RenderJs
.
loadGadgetFromUrl
(
root
);
RenderJs
.
loadGadgetFromUrl
(
root
);
RenderJs
.
load
(
root
);
RenderJs
.
load
(
root
);
...
@@ -42,7 +39,7 @@ var RenderJs = (function () {
...
@@ -42,7 +39,7 @@ var RenderJs = (function () {
});
});
},
},
updateAndRecurse
:
function
(
gadget
,
data
)
{
updateAndRecurse
:
function
(
gadget
,
data
)
{
/* Update current gadget and recurse down */
/* Update current gadget and recurse down */
gadget
.
append
(
data
);
gadget
.
append
(
data
);
// a gadget may contain sub gadgets
// a gadget may contain sub gadgets
...
@@ -51,7 +48,8 @@ var RenderJs = (function () {
...
@@ -51,7 +48,8 @@ var RenderJs = (function () {
loadGadgetFromUrl
:
function
(
gadget
)
{
loadGadgetFromUrl
:
function
(
gadget
)
{
/* Load gadget's SPECs from URL */
/* Load gadget's SPECs from URL */
var
url
,
gadget_id
,
gadget_property
,
cacheable
,
cache_id
,
app_cache
,
data
,
gadget_js
;
var
url
,
gadget_id
,
gadget_property
,
cacheable
,
cache_id
,
app_cache
,
data
,
gadget_js
;
url
=
gadget
.
attr
(
"
data-gadget
"
);
url
=
gadget
.
attr
(
"
data-gadget
"
);
gadget_id
=
gadget
.
attr
(
"
id
"
);
gadget_id
=
gadget
.
attr
(
"
id
"
);
...
@@ -61,50 +59,56 @@ var RenderJs = (function () {
...
@@ -61,50 +59,56 @@ var RenderJs = (function () {
// XXX: update Gadget's instance with contents of "data-gadget-property"
// XXX: update Gadget's instance with contents of "data-gadget-property"
if
(
url
!==
undefined
&&
url
!==
""
){
if
(
url
!==
undefined
&&
url
!==
""
){
cacheable
=
gadget
.
attr
(
"
data-gadget-cacheable
"
);
cacheable
=
gadget
.
attr
(
"
data-gadget-cacheable
"
);
cache_id
=
gadget
.
attr
(
"
data-gadget-cache-id
"
);
cache_id
=
gadget
.
attr
(
"
data-gadget-cache-id
"
);
if
(
cacheable
!==
undefined
&&
cache_id
!==
undefined
){
if
(
cacheable
!==
undefined
&&
cache_id
!==
undefined
){
cacheable
=
Boolean
(
parseInt
(
cacheable
));
cacheable
=
Boolean
(
parseInt
(
cacheable
));
}
}
//cacheable = false ; // to develop faster
//cacheable = false ; // to develop faster
if
(
cacheable
)
{
if
(
cacheable
)
{
// get from cache if possible, use last part from URL as cache_key
// get from cache if possible, use last part from URL as
// cache_key
app_cache
=
RenderJs
.
Cache
.
get
(
cache_id
,
undefined
);
app_cache
=
RenderJs
.
Cache
.
get
(
cache_id
,
undefined
);
if
(
app_cache
===
undefined
||
app_cache
===
null
){
if
(
app_cache
===
undefined
||
app_cache
===
null
){
// not in cache so we pull from network and cache
// not in cache so we pull from network and cache
$
.
ajax
({
url
:
url
,
$
.
ajax
({
yourCustomData
:
{
"
gadget_id
"
:
gadget_id
,
"
cache_id
"
:
cache_id
},
url
:
url
,
yourCustomData
:
{
"
gadget_id
"
:
gadget_id
,
"
cache_id
"
:
cache_id
},
success
:
function
(
data
)
{
success
:
function
(
data
)
{
cache_id
=
this
.
yourCustomData
.
cache_id
;
cache_id
=
this
.
yourCustomData
.
cache_id
;
gadget_id
=
this
.
yourCustomData
.
gadget_id
;
gadget_id
=
this
.
yourCustomData
.
gadget_id
;
RenderJs
.
Cache
.
set
(
cache_id
,
data
);
RenderJs
.
Cache
.
set
(
cache_id
,
data
);
RenderJs
.
GadgetIndex
.
getGadgetById
(
gadget_id
).
setReady
();
RenderJs
.
GadgetIndex
.
getGadgetById
(
gadget_id
).
setReady
();
RenderJs
.
updateAndRecurse
(
gadget
,
data
);
RenderJs
.
updateAndRecurse
(
gadget
,
data
);
RenderJs
.
checkAndTriggerReady
();
RenderJs
.
checkAndTriggerReady
();
}});
}
}
else
{
});
}
else
{
// get from cache
// get from cache
data
=
app_cache
;
data
=
app_cache
;
gadget_js
.
setReady
();
gadget_js
.
setReady
();
this
.
updateAndRecurse
(
gadget
,
data
);
this
.
updateAndRecurse
(
gadget
,
data
);
this
.
checkAndTriggerReady
();
this
.
checkAndTriggerReady
();
}
}
}
}
else
{
else
{
// not to be cached
// not to be cached
$
.
ajax
({
url
:
url
,
$
.
ajax
({
url
:
url
,
yourCustomData
:
{
"
gadget_id
"
:
gadget_id
},
yourCustomData
:
{
"
gadget_id
"
:
gadget_id
},
success
:
function
(
data
)
{
success
:
function
(
data
)
{
gadget_id
=
this
.
yourCustomData
.
gadget_id
;
gadget_id
=
this
.
yourCustomData
.
gadget_id
;
RenderJs
.
GadgetIndex
.
getGadgetById
(
gadget_id
).
setReady
();
RenderJs
.
GadgetIndex
.
getGadgetById
(
gadget_id
).
setReady
();
RenderJs
.
updateAndRecurse
(
gadget
,
data
);
RenderJs
.
updateAndRecurse
(
gadget
,
data
);
RenderJs
.
checkAndTriggerReady
();
RenderJs
.
checkAndTriggerReady
();
}});
}
}
});
}
}
else
{
}
else
{
// gadget is an inline one so no need to load it from network
// gadget is an inline one so no need to load it from network
gadget_js
.
setReady
();
gadget_js
.
setReady
();
RenderJs
.
checkAndTriggerReady
();
RenderJs
.
checkAndTriggerReady
();
...
@@ -125,15 +129,16 @@ var RenderJs = (function () {
...
@@ -125,15 +129,16 @@ var RenderJs = (function () {
is_ready
=
value
;
is_ready
=
value
;
},
},
checkAndTriggerReady
:
function
()
{
checkAndTriggerReady
:
function
()
{
/*
/*
* Trigger "ready" event only if all gadgets were marked as "ready"
* Trigger "ready" event only if all gadgets were marked as "ready"
*/
*/
var
is_gadget_list_loaded
;
var
is_gadget_list_loaded
;
is_gadget_list_loaded
=
RenderJs
.
GadgetIndex
.
isGadgetListLoaded
();
is_gadget_list_loaded
=
RenderJs
.
GadgetIndex
.
isGadgetListLoaded
();
if
(
is_gadget_list_loaded
){
if
(
is_gadget_list_loaded
)
{
if
(
!
RenderJs
.
isReady
())
{
if
(
!
RenderJs
.
isReady
())
{
RenderJs
.
GadgetIndex
.
getRootGadget
().
getDom
().
trigger
(
"
ready
"
);
RenderJs
.
GadgetIndex
.
getRootGadget
().
getDom
().
trigger
(
"
ready
"
);
RenderJs
.
setReady
(
true
);
RenderJs
.
setReady
(
true
);
}
}
//is_ready = true;
//is_ready = true;
...
@@ -143,41 +148,49 @@ var RenderJs = (function () {
...
@@ -143,41 +148,49 @@ var RenderJs = (function () {
update
:
function
(
root
)
{
update
:
function
(
root
)
{
/* update gadget with data from remote source */
/* update gadget with data from remote source */
root
.
find
(
"
[gadget]
"
).
each
(
function
(
i
,
v
){
RenderJs
.
updateGadgetData
(
$
(
this
));});
root
.
find
(
"
[gadget]
"
).
each
(
function
(
i
,
v
)
{
RenderJs
.
updateGadgetData
(
$
(
this
));
});
},
},
updateGadgetWithDataHandler
:
function
(
result
)
{
updateGadgetWithDataHandler
:
function
(
result
)
{
var
data_handler
;
var
data_handler
;
data_handler
=
this
.
yourCustomData
.
data_handler
;
data_handler
=
this
.
yourCustomData
.
data_handler
;
if
(
data_handler
!==
undefined
){
if
(
data_handler
!==
undefined
){
eval
(
data_handler
+
"
(result)
"
);
eval
(
data_handler
+
"
(result)
"
);
}
}
},
},
updateGadgetData
:
function
(
gadget
)
{
updateGadgetData
:
function
(
gadget
)
{
/* Do real gagdet update here */
/* Do real gagdet update here */
var
data_source
,
data_handler
;
var
data_source
,
data_handler
;
data_source
=
gadget
.
attr
(
"
data-gadget-source
"
);
data_source
=
gadget
.
attr
(
"
data-gadget-source
"
);
data_handler
=
gadget
.
attr
(
"
data-gadget-handler
"
);
data_handler
=
gadget
.
attr
(
"
data-gadget-handler
"
);
// acquire data and pass it to method handler
// acquire data and pass it to method handler
if
(
data_source
!==
undefined
&&
data_source
!==
""
){
if
(
data_source
!==
undefined
&&
data_source
!==
""
){
$
.
ajax
({
url
:
data_source
,
$
.
ajax
({
url
:
data_source
,
dataType
:
"
json
"
,
dataType
:
"
json
"
,
yourCustomData
:
{
"
data_handler
"
:
data_handler
},
yourCustomData
:
{
"
data_handler
"
:
data_handler
},
success
:
RenderJs
.
updateGadgetWithDataHandler
});}
success
:
RenderJs
.
updateGadgetWithDataHandler
});
}
},
},
addGadget
:
function
(
dom_id
,
gadget
,
gadget_data_handler
,
gadget_data_source
)
{
addGadget
:
function
(
dom_id
,
gadget
,
gadget_data_handler
,
gadget_data_source
)
{
/*
/*
* add new gadget and render it
* add new gadget and render it
*/
*/
var
html_string
;
var
html_string
;
tab_container
=
$
(
'
#
'
+
dom_id
);
tab_container
=
$
(
'
#
'
+
dom_id
);
tab_container
.
empty
();
tab_container
.
empty
();
html_string
=
[
'
<div class="gadget"
'
,
html_string
=
[
'
<div class="gadget"
'
,
'
data-gadget="
'
+
gadget
+
'
"
'
,
'
data-gadget="
'
+
gadget
+
'
"
'
,
'
data-gadget-handler="
'
+
gadget_data_handler
+
'
"
'
,
'
data-gadget-handler="
'
+
gadget_data_handler
+
'
"
'
,
'
data-gadget-source="
'
+
gadget_data_source
+
'
"></div>
'
].
join
(
'
\n
'
);
'
data-gadget-source="
'
+
gadget_data_source
+
'
"></div>
'
].
join
(
'
\n
'
);
tab_container
.
append
(
html_string
);
tab_container
.
append
(
html_string
);
tab_gadget
=
tab_container
.
find
(
"
.gadget
"
);
tab_gadget
=
tab_container
.
find
(
"
.gadget
"
);
...
@@ -185,28 +198,30 @@ var RenderJs = (function () {
...
@@ -185,28 +198,30 @@ var RenderJs = (function () {
RenderJs
.
setReady
(
false
);
RenderJs
.
setReady
(
false
);
RenderJs
.
loadGadgetFromUrl
(
tab_gadget
);
RenderJs
.
loadGadgetFromUrl
(
tab_gadget
);
// clear previous events
// clear previous events
RenderJs
.
GadgetIndex
.
getRootGadget
().
getDom
().
bind
(
"
ready
"
,
function
(){
RenderJs
.
GadgetIndex
.
getRootGadget
().
getDom
().
bind
(
"
ready
"
,
function
(){
if
(
!
is_ready
){
if
(
!
is_ready
){
RenderJs
.
updateGadgetData
(
tab_gadget
);
RenderJs
.
updateGadgetData
(
tab_gadget
);
is_ready
=
true
;
is_ready
=
true
;
}
}
});
}
);
return
tab_gadget
;
return
tab_gadget
;
},
},
Cache
:
(
function
()
{
Cache
:
(
function
()
{
/*
/*
* Generic cache implementation that can fall back to local namespace storage
* Generic cache implementation that can fall back to local
* if no "modern" storage like localStorage is available
* namespace storage if no "modern" storage like localStorage
* is available
*/
*/
return
{
return
{
ROOT_CACHE_ID
:
'
APP_CACHE
'
,
ROOT_CACHE_ID
:
'
APP_CACHE
'
,
getCacheId
:
function
(
cache_id
)
{
getCacheId
:
function
(
cache_id
)
{
/* We should have a way to 'purge' localStorage by setting a ROOT_CACHE_ID in all browser
/*
* instances
* We should have a way to 'purge' localStorage by setting a
* ROOT_CACHE_ID in all browser instances
*/
*/
return
this
.
ROOT_CACHE_ID
+
cache_id
;
return
this
.
ROOT_CACHE_ID
+
cache_id
;
},
},
...
@@ -221,8 +236,7 @@ var RenderJs = (function () {
...
@@ -221,8 +236,7 @@ var RenderJs = (function () {
localStorage
.
setItem
(
mod
,
mod
);
localStorage
.
setItem
(
mod
,
mod
);
localStorage
.
removeItem
(
mod
);
localStorage
.
removeItem
(
mod
);
return
true
;
return
true
;
}
}
catch
(
e
)
{
catch
(
e
)
{
return
false
;
return
false
;
}
}
},
},
...
@@ -231,22 +245,25 @@ var RenderJs = (function () {
...
@@ -231,22 +245,25 @@ var RenderJs = (function () {
/* Get cache key value */
/* Get cache key value */
cache_id
=
this
.
getCacheId
(
cache_id
);
cache_id
=
this
.
getCacheId
(
cache_id
);
if
(
this
.
hasLocalStorage
())
{
if
(
this
.
hasLocalStorage
())
{
return
this
.
LocalStorageCachePlugin
.
get
(
cache_id
,
default_value
);
return
this
.
LocalStorageCachePlugin
.
get
(
cache_id
,
default_value
);
}
}
//fallback to javscript namespace cache
//fallback to javscript namespace cache
return
this
.
NameSpaceStorageCachePlugin
.
get
(
cache_id
,
default_value
);
return
this
.
NameSpaceStorageCachePlugin
.
get
(
cache_id
,
default_value
);
},
},
set
:
function
(
cache_id
,
data
)
{
set
:
function
(
cache_id
,
data
)
{
/* Set cache key value */
/* Set cache key value */
cache_id
=
this
.
getCacheId
(
cache_id
);
cache_id
=
this
.
getCacheId
(
cache_id
);
if
(
this
.
hasLocalStorage
()){
if
(
this
.
hasLocalStorage
())
{
this
.
LocalStorageCachePlugin
.
set
(
cache_id
,
data
);}
this
.
LocalStorageCachePlugin
.
set
(
cache_id
,
data
);
else
{
}
else
{
this
.
NameSpaceStorageCachePlugin
.
set
(
cache_id
,
data
);}
this
.
NameSpaceStorageCachePlugin
.
set
(
cache_id
,
data
);
}
},
},
LocalStorageCachePlugin
:
(
function
()
{
LocalStorageCachePlugin
:
(
function
()
{
/*
/*
* This plugin saves using HTML5 localStorage.
* This plugin saves using HTML5 localStorage.
*/
*/
...
@@ -260,13 +277,13 @@ var RenderJs = (function () {
...
@@ -260,13 +277,13 @@ var RenderJs = (function () {
/* Set cache key value */
/* Set cache key value */
$
.
jStorage
.
set
(
cache_id
,
data
);
$
.
jStorage
.
set
(
cache_id
,
data
);
}
}
}}()),
}
}()),
NameSpaceStorageCachePlugin
:
(
function
()
{
NameSpaceStorageCachePlugin
:
(
function
()
{
/*
/*
* This plugin saves within current page namespace.
* This plugin saves within current page namespace.
*/
*/
var
namespace
=
{};
var
namespace
=
{};
return
{
return
{
...
@@ -284,7 +301,7 @@ var RenderJs = (function () {
...
@@ -284,7 +301,7 @@ var RenderJs = (function () {
}}()),
}}()),
Gadget
:
(
function
(
id
,
dom
)
{
Gadget
:
(
function
(
id
,
dom
)
{
/*
/*
* Javascript Gadget representation
* Javascript Gadget representation
*/
*/
...
@@ -315,41 +332,41 @@ var RenderJs = (function () {
...
@@ -315,41 +332,41 @@ var RenderJs = (function () {
};
};
}),
}),
TabbularGadget
:
(
function
()
{
TabbularGadget
:
(
function
()
{
/*
/*
* Generic tabular gadget
* Generic tabular gadget
*/
*/
return
{
return
{
toggleVisibility
:
function
(
visible_dom
)
{
toggleVisibility
:
function
(
visible_dom
)
{
/*
/*
* Set tab as active visually and mark as not active rest.
* Set tab as active visually and mark as not active rest.
*/
*/
$
(
"
.selected
"
).
addClass
(
"
not_selected
"
);
$
(
"
.selected
"
).
removeClass
(
"
selected
"
);
$
(
"
.selected
"
).
addClass
(
"
not_selected
"
);
$
(
"
.selected
"
).
removeClass
(
"
selected
"
);
visible_dom
.
addClass
(
"
selected
"
);
visible_dom
.
addClass
(
"
selected
"
);
visible_dom
.
removeClass
(
"
not_selected
"
);
visible_dom
.
removeClass
(
"
not_selected
"
);
},
},
addNewTabGadget
:
function
(
dom_id
,
gadget
,
gadget_data_handler
,
gadget_data_source
)
{
addNewTabGadget
:
function
(
dom_id
,
gadget
,
gadget_data_handler
,
gadget_data_source
)
{
/*
/*
* add new gadget and render it
* add new gadget and render it
*/
*/
tab_gadget
=
RenderJs
.
addGadget
(
dom_id
,
gadget
,
gadget_data_handler
,
gadget_data_source
)
tab_gadget
=
RenderJs
.
addGadget
(
dom_id
,
gadget
,
gadget_data_handler
,
gadget_data_source
);
// XXX: we should unregister all gadgets (if any we replace now in DOM)
// XXX: we should unregister all gadgets (if any we replace now in DOM)
}
}
}
}()),
}}()),
GadgetIndex
:
(
function
()
{
GadgetIndex
:
(
function
()
{
/*
/*
* Generic gadget index placeholder
* Generic gadget index placeholder
*/
*/
var
gadget_list
=
[];
var
gadget_list
=
[];
return
{
return
{
getGadgetList
:
function
()
{
getGadgetList
:
function
()
{
/*
/*
* Return list of registered gadgets
* Return list of registered gadgets
...
@@ -369,7 +386,7 @@ var RenderJs = (function () {
...
@@ -369,7 +386,7 @@ var RenderJs = (function () {
* Unregister gadget
* Unregister gadget
*/
*/
var
index
=
$
.
inArray
(
gadget
,
gadget_list
);
var
index
=
$
.
inArray
(
gadget
,
gadget_list
);
if
(
index
!==
-
1
)
{
if
(
index
!==
-
1
)
{
gadget_list
.
splice
(
index
,
1
);
gadget_list
.
splice
(
index
,
1
);
}
}
},
},
...
@@ -382,9 +399,11 @@ var RenderJs = (function () {
...
@@ -382,9 +399,11 @@ var RenderJs = (function () {
gadget
=
undefined
;
gadget
=
undefined
;
$
(
RenderJs
.
GadgetIndex
.
getGadgetList
()).
each
(
$
(
RenderJs
.
GadgetIndex
.
getGadgetList
()).
each
(
function
(
index
,
value
)
{
function
(
index
,
value
)
{
if
(
value
.
getId
()
===
gadget_id
)
{
if
(
value
.
getId
()
===
gadget_id
)
{
gadget
=
value
;
gadget
=
value
;
}});
}
}
);
return
gadget
;
return
gadget
;
},
},
...
@@ -397,16 +416,18 @@ var RenderJs = (function () {
...
@@ -397,16 +416,18 @@ var RenderJs = (function () {
isGadgetListLoaded
:
function
()
{
isGadgetListLoaded
:
function
()
{
/*
/*
* Return True if all gadgets were loaded from network or cache
* Return True if all gadgets were loaded from network or
* cache
*/
*/
var
result
;
var
result
;
result
=
true
;
result
=
true
;
$
(
this
.
getGadgetList
()).
each
(
$
(
this
.
getGadgetList
()).
each
(
function
(
index
,
value
)
{
function
(
index
,
value
)
{
if
(
value
.
isReady
()
===
false
)
{
if
(
value
.
isReady
()
===
false
)
{
result
=
false
;
result
=
false
;
}
}
});
}
);
return
result
;
return
result
;
},
},
...
@@ -416,66 +437,90 @@ var RenderJs = (function () {
...
@@ -416,66 +437,90 @@ var RenderJs = (function () {
*/
*/
// XXX:
// XXX:
}
}
}
}
}()),
}()),
InteractionGadget
:
(
function
()
{
InteractionGadget
:
(
function
()
{
/*
/*
* Basic gadget interaction gadget implementation.
* Basic gadget interaction gadget implementation.
*/
*/
return
{
return
{
bind
:
function
(
gadget_dom
){
bind
:
function
(
gadget_dom
){
/*
/*
* Bind event between gadgets.
* Bind event between gadgets.
*/
*/
gadget_id
=
gadget_dom
.
attr
(
"
id
"
);
var
createMethodInteraction
=
function
(
original_source_method_id
,
source_gadget_id
,
var
createMethodInteraction
=
function
(
original_source_method_id
,
source_gadget_id
,
source_method
_id
,
source_method_id
,
destination_gadget
_id
,
destination_gadget_id
,
destination_method_id
)
{
destination_method_id
)
{
var
interaction
=
function
()
{
var
interaction
=
function
()
{
RenderJs
.
GadgetIndex
.
getGadgetById
(
source_gadget_id
)[
original_source_method_id
].
apply
(
null
,
arguments
);
RenderJs
.
GadgetIndex
.
getGadgetById
(
RenderJs
.
GadgetIndex
.
getGadgetById
(
destination_gadget_id
)[
destination_method_id
]();
source_gadget_id
)[
original_source_method_id
].
apply
(
null
,
arguments
);
RenderJs
.
GadgetIndex
.
getGadgetById
(
destination_gadget_id
)[
destination_method_id
]();
};
};
return
interaction
;
return
interaction
;
};
},
var
createTriggerInteraction
=
function
(
destination_gadget_id
,
destination_method_id
)
{
createTriggerInteraction
=
function
(
var
interaction
=
function
()
{
destination_gadget_id
,
destination_method_id
)
{
RenderJs
.
GadgetIndex
.
getGadgetById
(
destination_gadget_id
)[
destination_method_id
].
apply
(
null
,
arguments
);
var
interaction
=
function
()
{
RenderJs
.
GadgetIndex
.
getGadgetById
(
destination_gadget_id
)[
destination_method_id
].
apply
(
null
,
arguments
);
};
};
return
interaction
;
return
interaction
;
};
};
gadget_dom
.
find
(
"
connect
"
).
each
(
function
(
key
,
value
){
gadget_id
=
gadget_dom
.
attr
(
"
id
"
);
var
source
,
source_gadget_id
,
source_method_id
,
source_gadget
,
destination
,
destination_gadget_id
,
gadget_dom
.
find
(
"
connect
"
).
each
(
function
(
key
,
value
)
{
destination_method_id
,
destination_gadget
,
func_body
,
func
;
var
source
,
source_gadget_id
,
source_method_id
,
source_gadget
,
destination
,
destination_gadget_id
,
destination_method_id
,
destination_gadget
,
original_source_method_id
,
func_body
,
func
;
source
=
$
(
value
).
attr
(
"
source
"
).
split
(
"
.
"
);
source
=
$
(
value
).
attr
(
"
source
"
).
split
(
"
.
"
);
source_gadget_id
=
source
[
0
];
source_gadget_id
=
source
[
0
];
source_method_id
=
source
[
1
];
source_method_id
=
source
[
1
];
source_gadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
source_gadget_id
);
source_gadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
source_gadget_id
);
destination
=
$
(
value
).
attr
(
"
destination
"
).
split
(
"
.
"
);
destination
=
$
(
value
).
attr
(
"
destination
"
).
split
(
"
.
"
);
destination_gadget_id
=
destination
[
0
];
destination_gadget_id
=
destination
[
0
];
destination_method_id
=
destination
[
1
];
destination_method_id
=
destination
[
1
];
destination_gadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
destination_gadget_id
);
destination_gadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
destination_gadget_id
);
if
(
source_gadget
.
hasOwnProperty
(
source_method_id
)){
if
(
source_gadget
.
hasOwnProperty
(
source_method_id
)){
// direct javascript use case
// direct javascript use case
var
original_source_method_id
=
"
original_
"
+
source_method_id
;
original_source_method_id
=
"
original_
"
+
source_gadget
[
original_source_method_id
]
=
source_gadget
[
source_method_id
];
source_method_id
;
source_gadget
[
source_method_id
]
=
createMethodInteraction
(
original_source_method_id
,
source_gadget_id
,
source_method_id
,
source_gadget
[
original_source_method_id
]
=
destination_gadget_id
,
destination_method_id
);
source_gadget
[
source_method_id
];
source_gadget
[
source_method_id
]
=
createMethodInteraction
(
original_source_method_id
,
source_gadget_id
,
source_method_id
,
destination_gadget_id
,
destination_method_id
);
}
}
else
{
else
{
// this is a custom event attached to HTML gadget representation
// this is a custom event attached to HTML gadget
var
interaction
=
createTriggerInteraction
(
destination_gadget_id
,
destination_method_id
);
// representation
source_gadget
.
dom
.
bind
(
source_method_id
,
interaction
);
source_gadget
.
dom
.
bind
(
source_method_id
,
createTriggerInteraction
(
destination_gadget_id
,
destination_method_id
)
);
}
}
});
}
}
);
}
}
}
}())
}())
}
}
}());
}());
// impliticly call RenderJs bootstrap
// impliticly call RenderJs bootstrap
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
...
...
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