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
Romain Courteaud
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 @@
...
@@ -293,77 +293,77 @@
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// RenderJSGadget.declareGadget
// RenderJSGadget.declareGadget
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
RenderJSGadget
.
prototype
.
declareGadget
=
function
(
url
,
options
)
{
RenderJSGadget
var
queue
,
.
declareMethod
(
'
declareGadget
'
,
function
(
url
,
options
)
{
parent_gadget
=
this
,
var
queue
,
previous_loading_gadget_promise
=
loading_gadget_promise
;
parent_gadget
=
this
,
previous_loading_gadget_promise
=
loading_gadget_promise
;
if
(
options
===
undefined
)
{
if
(
options
===
undefined
)
{
options
=
{};
options
=
{};
}
}
if
(
options
.
sandbox
===
undefined
)
{
if
(
options
.
sandbox
===
undefined
)
{
options
.
sandbox
=
"
public
"
;
options
.
sandbox
=
"
public
"
;
}
}
// Change the global variable to update the loading queue
// Change the global variable to update the loading queue
queue
=
new
RSVP
.
Queue
()
queue
=
new
RSVP
.
Queue
()
// Wait for previous gadget loading to finish first
// Wait for previous gadget loading to finish first
.
push
(
function
()
{
.
push
(
function
()
{
return
previous_loading_gadget_promise
;
return
previous_loading_gadget_promise
;
})
})
.
push
(
undefined
,
function
()
{
.
push
(
undefined
,
function
()
{
// Forget previous declareGadget error
// Forget previous declareGadget error
return
;
return
;
})
})
.
push
(
function
()
{
.
push
(
function
()
{
var
method
;
var
method
;
if
(
options
.
sandbox
===
"
public
"
)
{
if
(
options
.
sandbox
===
"
public
"
)
{
method
=
privateDeclarePublicGadget
;
method
=
privateDeclarePublicGadget
;
}
else
if
(
options
.
sandbox
===
"
iframe
"
)
{
}
else
if
(
options
.
sandbox
===
"
iframe
"
)
{
method
=
privateDeclareIframeGadget
;
method
=
privateDeclareIframeGadget
;
}
else
{
}
else
{
throw
new
Error
(
"
Unsupported sandbox options '
"
+
throw
new
Error
(
"
Unsupported sandbox options '
"
+
options
.
sandbox
+
"
'
"
);
options
.
sandbox
+
"
'
"
);
}
}
return
method
(
url
,
options
);
return
method
(
url
,
options
);
})
})
// Set the HTML context
// Set the HTML context
.
push
(
function
(
gadget_instance
)
{
.
push
(
function
(
gadget_instance
)
{
var
i
;
var
i
;
// Define aq_parent to reach parent gadget
// Define aq_parent to reach parent gadget
gadget_instance
.
aq_parent
=
function
(
method_name
,
argument_list
)
{
gadget_instance
.
aq_parent
=
function
(
method_name
,
argument_list
)
{
return
parent_gadget
.
acquire
(
method_name
,
argument_list
);
return
parent_gadget
.
acquire
(
method_name
,
argument_list
);
};
};
// Drop the current loading klass info used by selector
// Drop the current loading klass info used by selector
gadget_loading_klass
=
undefined
;
gadget_loading_klass
=
undefined
;
// Trigger calling of all ready callback
// Trigger calling of all ready callback
function
ready_wrapper
()
{
function
ready_wrapper
()
{
return
gadget_instance
;
return
gadget_instance
;
}
}
for
(
i
=
0
;
i
<
gadget_instance
.
constructor
.
ready_list
.
length
;
for
(
i
=
0
;
i
<
gadget_instance
.
constructor
.
ready_list
.
length
;
i
+=
1
)
{
i
+=
1
)
{
// Put a timeout?
// Put a timeout?
queue
.
push
(
gadget_instance
.
constructor
.
ready_list
[
i
]);
queue
.
push
(
gadget_instance
.
constructor
.
ready_list
[
i
]);
// Always return the gadget instance after ready function
// Always return the gadget instance after ready function
queue
.
push
(
ready_wrapper
);
queue
.
push
(
ready_wrapper
);
}
}
// Store local reference to the gadget instance
// Store local reference to the gadget instance
if
(
options
.
scope
!==
undefined
)
{
if
(
options
.
scope
!==
undefined
)
{
parent_gadget
.
sub_gadget_dict
[
options
.
scope
]
=
gadget_instance
;
parent_gadget
.
sub_gadget_dict
[
options
.
scope
]
=
gadget_instance
;
}
}
return
gadget_instance
;
return
gadget_instance
;
})
})
.
push
(
undefined
,
function
(
e
)
{
.
push
(
undefined
,
function
(
e
)
{
// Drop the current loading klass info used by selector
// Drop the current loading klass info used by selector
// even in case of error
// even in case of error
gadget_loading_klass
=
undefined
;
gadget_loading_klass
=
undefined
;
throw
e
;
throw
e
;
});
});
loading_gadget_promise
=
queue
;
loading_gadget_promise
=
queue
;
return
loading_gadget_promise
;
return
loading_gadget_promise
;
};
})
RenderJSGadget
.
declareMethod
(
'
getDeclaredGadget
'
,
function
(
gadget_scope
)
{
.
declareMethod
(
'
getDeclaredGadget
'
,
function
(
gadget_scope
)
{
if
(
!
this
.
sub_gadget_dict
.
hasOwnProperty
(
gadget_scope
))
{
if
(
!
this
.
sub_gadget_dict
.
hasOwnProperty
(
gadget_scope
))
{
throw
new
Error
(
"
Gadget scope '
"
+
gadget_scope
+
"
' is not known.
"
);
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