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
cc102462
Commit
cc102462
authored
Sep 03, 2012
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
for interaction methods, use real function instead of creating one from strings
parent
e405bfe9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
8 deletions
+21
-8
OfficeJS/src/renderjs/renderjs.js
OfficeJS/src/renderjs/renderjs.js
+21
-8
No files found.
OfficeJS/src/renderjs/renderjs.js
View file @
cc102462
...
...
@@ -430,6 +430,21 @@ var RenderJs = (function () {
* Bind event between gadgets.
*/
gadget_id
=
gadget_dom
.
attr
(
"
id
"
);
var
createMethodInteraction
=
function
(
original_source_method_id
,
source_gadget_id
,
source_method_id
,
destination_gadget_id
,
destination_method_id
)
{
var
interaction
=
function
()
{
RenderJs
.
GadgetIndex
.
getGadgetById
(
source_gadget_id
)[
original_source_method_id
].
apply
(
null
,
arguments
);
RenderJs
.
GadgetIndex
.
getGadgetById
(
destination_gadget_id
)[
destination_method_id
]();
};
return
interaction
;
};
var
createTriggerInteraction
=
function
(
destination_gadget_id
,
destination_method_id
)
{
var
interaction
=
function
()
{
RenderJs
.
GadgetIndex
.
getGadgetById
(
destination_gadget_id
)[
destination_method_id
].
apply
(
null
,
arguments
);
};
return
interaction
;
};
gadget_dom
.
find
(
"
connect
"
).
each
(
function
(
key
,
value
){
var
source
,
source_gadget_id
,
source_method_id
,
source_gadget
,
destination
,
destination_gadget_id
,
destination_method_id
,
destination_gadget
,
func_body
,
func
;
...
...
@@ -445,17 +460,15 @@ var RenderJs = (function () {
if
(
source_gadget
.
hasOwnProperty
(
source_method_id
)){
// direct javascript use case
func_body
=
'
RenderJs.GadgetIndex.getGadgetById("
'
+
source_gadget_id
+
'
")["original_
'
+
source_method_id
+
'
"]();
'
;
func_body
=
func_body
+
'
\n
RenderJs.GadgetIndex.getGadgetById("
'
+
destination_gadget_id
+
'
")["
'
+
destination_method_id
+
'
"]();
'
;
func
=
new
Function
(
func_body
);
source_gadget
[
"
original_
"
+
source_method_id
]
=
source_gadget
[
source_method_id
];
source_gadget
[
source_method_id
]
=
func
;
var
original_source_method_id
=
"
original_
"
+
source_method_id
;
source_gadget
[
original_source_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
{
// this is a custom event attached to HTML gadget representation
func_body
=
'
RenderJs.GadgetIndex.getGadgetById("
'
+
destination_gadget_id
+
'
")["
'
+
destination_method_id
+
'
"]();
'
;
func
=
new
Function
(
func_body
);
source_gadget
.
dom
.
bind
(
source_method_id
,
func
);
var
interaction
=
createTriggerInteraction
(
destination_gadget_id
,
destination_method_id
);
source_gadget
.
dom
.
bind
(
source_method_id
,
interaction
);
}
}
);
...
...
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