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
76805e06
Commit
76805e06
authored
Apr 03, 2014
by
Romain Courteaud
🐸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Declare the method 'declareGadget'.
parent
e801e33b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
68 deletions
+68
-68
renderjs.js
renderjs.js
+68
-68
No files found.
renderjs.js
View file @
76805e06
...
...
@@ -293,77 +293,77 @@
/////////////////////////////////////////////////////////////////
// RenderJSGadget.declareGadget
/////////////////////////////////////////////////////////////////
RenderJSGadget
.
prototype
.
declareGadget
=
function
(
url
,
options
)
{
var
queue
,
parent_gadget
=
this
,
previous_loading_gadget_promise
=
loading_gadget_promise
;
RenderJSGadget
.
declareMethod
(
'
declareGadget
'
,
function
(
url
,
options
)
{
var
queue
,
parent_gadget
=
this
,
previous_loading_gadget_promise
=
loading_gadget_promise
;
if
(
options
===
undefined
)
{
options
=
{};
}
if
(
options
.
sandbox
===
undefined
)
{
options
.
sandbox
=
"
public
"
;
}
if
(
options
===
undefined
)
{
options
=
{};
}
if
(
options
.
sandbox
===
undefined
)
{
options
.
sandbox
=
"
public
"
;
}
// Change the global variable to update the loading queue
queue
=
new
RSVP
.
Queue
()
// Wait for previous gadget loading to finish first
.
push
(
function
()
{
return
previous_loading_gadget_promise
;
})
.
push
(
undefined
,
function
()
{
// Forget previous declareGadget error
return
;
})
.
push
(
function
()
{
var
method
;
if
(
options
.
sandbox
===
"
public
"
)
{
method
=
privateDeclarePublicGadget
;
}
else
if
(
options
.
sandbox
===
"
iframe
"
)
{
method
=
privateDeclareIframeGadget
;
}
else
{
throw
new
Error
(
"
Unsupported sandbox options '
"
+
options
.
sandbox
+
"
'
"
);
}
return
method
(
url
,
options
);
})
// Set the HTML context
.
push
(
function
(
gadget_instance
)
{
var
i
;
// Define aq_parent to reach parent gadget
gadget_instance
.
aq_parent
=
function
(
method_name
,
argument_list
)
{
return
parent_gadget
.
acquire
(
method_name
,
argument_list
);
};
// Drop the current loading klass info used by selector
gadget_loading_klass
=
undefined
;
// Trigger calling of all ready callback
function
ready_wrapper
()
{
return
gadget_instance
;
}
for
(
i
=
0
;
i
<
gadget_instance
.
constructor
.
ready_list
.
length
;
i
+=
1
)
{
// Put a timeout?
queue
.
push
(
gadget_instance
.
constructor
.
ready_list
[
i
]);
// Always return the gadget instance after ready function
queue
.
push
(
ready_wrapper
);
}
// Change the global variable to update the loading queue
queue
=
new
RSVP
.
Queue
()
// Wait for previous gadget loading to finish first
.
push
(
function
()
{
return
previous_loading_gadget_promise
;
})
.
push
(
undefined
,
function
()
{
// Forget previous declareGadget error
return
;
})
.
push
(
function
()
{
var
method
;
if
(
options
.
sandbox
===
"
public
"
)
{
method
=
privateDeclarePublicGadget
;
}
else
if
(
options
.
sandbox
===
"
iframe
"
)
{
method
=
privateDeclareIframeGadget
;
}
else
{
throw
new
Error
(
"
Unsupported sandbox options '
"
+
options
.
sandbox
+
"
'
"
);
}
return
method
(
url
,
options
);
})
// Set the HTML context
.
push
(
function
(
gadget_instance
)
{
var
i
;
// Define aq_parent to reach parent gadget
gadget_instance
.
aq_parent
=
function
(
method_name
,
argument_list
)
{
return
parent_gadget
.
acquire
(
method_name
,
argument_list
);
};
// Drop the current loading klass info used by selector
gadget_loading_klass
=
undefined
;
// Trigger calling of all ready callback
function
ready_wrapper
()
{
return
gadget_instance
;
}
for
(
i
=
0
;
i
<
gadget_instance
.
constructor
.
ready_list
.
length
;
i
+=
1
)
{
// Put a timeout?
queue
.
push
(
gadget_instance
.
constructor
.
ready_list
[
i
]);
// Always return the gadget instance after ready function
queue
.
push
(
ready_wrapper
);
}
// Store local reference to the gadget instance
if
(
options
.
scope
!==
undefined
)
{
parent_gadget
.
sub_gadget_dict
[
options
.
scope
]
=
gadget_instance
;
}
return
gadget_instance
;
})
.
push
(
undefined
,
function
(
e
)
{
// Drop the current loading klass info used by selector
// even in case of error
gadget_loading_klass
=
undefined
;
throw
e
;
});
loading_gadget_promise
=
queue
;
return
loading_gadget_promise
;
};
RenderJSGadget
// Store local reference to the gadget instance
if
(
options
.
scope
!==
undefined
)
{
parent_gadget
.
sub_gadget_dict
[
options
.
scope
]
=
gadget_instance
;
}
return
gadget_instance
;
})
.
push
(
undefined
,
function
(
e
)
{
// Drop the current loading klass info used by selector
// even in case of error
gadget_loading_klass
=
undefined
;
throw
e
;
});
loading_gadget_promise
=
queue
;
return
loading_gadget_promise
;
})
.
declareMethod
(
'
getDeclaredGadget
'
,
function
(
gadget_scope
)
{
if
(
!
this
.
sub_gadget_dict
.
hasOwnProperty
(
gadget_scope
))
{
throw
new
Error
(
"
Gadget scope '
"
+
gadget_scope
+
"
' is not known.
"
);
...
...
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