Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
erp5
Commits
3f1110c4
Commit
3f1110c4
authored
Jan 18, 2017
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_xhtml_style/erp5_web_renderjs_ui] Update renderJS 0.14.0
parent
7c8fc367
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2583 additions
and
2566 deletions
+2583
-2566
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_renderjs_js.js
...js_ui/PathTemplateItem/web_page_module/rjs_renderjs_js.js
+2350
-2331
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_renderjs_js.xml
...s_ui/PathTemplateItem/web_page_module/rjs_renderjs_js.xml
+2
-2
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/renderjs.js.js
...TemplateItem/portal_skins/erp5_xhtml_style/renderjs.js.js
+231
-233
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_renderjs_js.js
View file @
3f1110c4
...
...
@@ -1081,19 +1081,32 @@ if (typeof document.contains !== 'function') {
});
}
function
clearGadgetInternalParameters
(
g
)
{
g
.
__sub_gadget_dict
=
{};
createMonitor
(
g
);
function
clearGadgetInternalParameters
(
)
{
this
.
__sub_gadget_dict
=
{};
createMonitor
(
this
);
}
function
loadSubGadgetDOMDeclaration
(
g
)
{
var
element_list
=
g
.
element
.
querySelectorAll
(
'
[data-gadget-url]
'
),
function
loadSubGadgetDOMDeclaration
(
)
{
var
element_list
=
this
.
element
.
querySelectorAll
(
'
[data-gadget-url]
'
),
element
,
promise_list
=
[],
scope
,
url
,
sandbox
,
i
;
i
,
context
=
this
;
function
prepareReportGadgetDeclarationError
(
scope
)
{
return
function
(
error
)
{
var
aq_dict
=
context
.
__acquired_method_dict
||
{},
method_name
=
'
reportGadgetDeclarationError
'
;
if
(
aq_dict
.
hasOwnProperty
(
method_name
))
{
return
aq_dict
[
method_name
].
apply
(
context
,
[
arguments
,
scope
]);
}
throw
error
;
};
}
for
(
i
=
0
;
i
<
element_list
.
length
;
i
+=
1
)
{
element
=
element_list
[
i
];
...
...
@@ -1101,11 +1114,14 @@ if (typeof document.contains !== 'function') {
url
=
element
.
getAttribute
(
"
data-gadget-url
"
);
sandbox
=
element
.
getAttribute
(
"
data-gadget-sandbox
"
);
if
(
url
!==
null
)
{
promise_list
.
push
(
g
.
declareGadget
(
url
,
{
promise_list
.
push
(
context
.
declareGadget
(
url
,
{
element
:
element
,
scope
:
scope
||
undefined
,
sandbox
:
sandbox
||
undefined
}));
})
.
push
(
undefined
,
prepareReportGadgetDeclarationError
(
scope
))
);
}
}
...
...
@@ -1120,9 +1136,10 @@ if (typeof document.contains !== 'function') {
};
RenderJSGadget
.
setState
=
function
(
state_dict
)
{
var
json_state
=
JSON
.
stringify
(
state_dict
);
return
this
.
ready
(
function
()
{
this
.
__ready_list
.
unshift
(
function
()
{
this
.
state
=
JSON
.
parse
(
json_state
);
});
return
this
;
};
RenderJSGadget
.
onStateChange
=
function
(
callback
)
{
this
.
prototype
.
__state_change_callback
=
callback
;
...
...
@@ -1331,6 +1348,8 @@ if (typeof document.contains !== 'function') {
};
RenderJSGadget
.
declareAcquiredMethod
(
"
aq_reportServiceError
"
,
"
reportServiceError
"
);
RenderJSGadget
.
declareAcquiredMethod
(
"
aq_reportGadgetDeclarationError
"
,
"
reportGadgetDeclarationError
"
);
/////////////////////////////////////////////////////////////////
// RenderJSGadget.allowPublicAcquisition
...
...
@@ -1461,6 +1480,17 @@ if (typeof document.contains !== 'function') {
gadget_instance
=
new
RenderJSIframeGadget
();
setAqParent
(
gadget_instance
,
parent_gadget
);
iframe
=
document
.
createElement
(
"
iframe
"
);
iframe
.
addEventListener
(
'
error
'
,
function
(
error
)
{
iframe_loading_deferred
.
reject
(
error
);
});
iframe
.
addEventListener
(
'
load
'
,
function
()
{
return
RSVP
.
timeout
(
5000
)
.
fail
(
function
()
{
iframe_loading_deferred
.
reject
(
new
Error
(
'
Timeout while loading:
'
+
url
)
);
});
});
// gadget_instance.element.setAttribute("seamless", "seamless");
iframe
.
setAttribute
(
"
src
"
,
url
);
gadget_instance
.
__path
=
url
;
...
...
@@ -1524,18 +1554,7 @@ if (typeof document.contains !== 'function') {
trans
.
delayReturn
(
true
);
});
return
RSVP
.
any
([
iframe_loading_deferred
.
promise
,
// Timeout to prevent non renderJS embeddable gadget
// XXX Maybe using iframe.onload/onerror would be safer?
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
timeout
(
5000
);
})
.
push
(
undefined
,
function
()
{
throw
new
Error
(
'
Timeout while loading:
'
+
url
);
})
]);
return
iframe_loading_deferred
.
promise
;
}
/////////////////////////////////////////////////////////////////
...
...
@@ -2283,8 +2302,8 @@ if (typeof document.contains !== 'function') {
return
fct
.
call
(
g
,
g
);
};
}
TmpConstructor
.
ready
(
function
(
g
)
{
return
startService
(
g
);
TmpConstructor
.
ready
(
function
(
)
{
return
startService
(
this
);
});
loading_gadget_promise
.
push
(
ready_wrapper
);
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_renderjs_js.xml
View file @
3f1110c4
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
95
5.51226.25726.38263
</string>
</value>
<value>
<string>
95
6.46086.45265.8004
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
148
1043805.03
</float>
<float>
148
4732189.17
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/renderjs.js.js
View file @
3f1110c4
...
...
@@ -673,7 +673,7 @@ if (typeof document.contains !== 'function') {
* http://www.renderjs.org/documentation
*/
(
function
(
document
,
window
,
RSVP
,
DOMParser
,
Channel
,
MutationObserver
,
Node
,
FileReader
,
Blob
,
navigator
,
Event
)
{
Node
,
FileReader
,
Blob
,
navigator
,
Event
,
URL
)
{
"
use strict
"
;
function
readBlobAsDataURL
(
blob
)
{
...
...
@@ -789,10 +789,10 @@ if (typeof document.contains !== 'function') {
return
new
RSVP
.
Promise
(
resolver
,
canceller
);
}
var
gadget_model_dict
=
{},
var
gadget_model_d
efer_d
ict
=
{},
javascript_registration_dict
=
{},
stylesheet_registration_dict
=
{},
gadget_loading_klass
,
gadget_loading_klass
_list
=
[]
,
loading_klass_promise
,
renderJS
,
Monitor
,
...
...
@@ -1081,19 +1081,32 @@ if (typeof document.contains !== 'function') {
});
}
function
clearGadgetInternalParameters
(
g
)
{
g
.
__sub_gadget_dict
=
{};
createMonitor
(
g
);
function
clearGadgetInternalParameters
()
{
this
.
__sub_gadget_dict
=
{};
createMonitor
(
this
);
}
function
loadSubGadgetDOMDeclaration
(
g
)
{
var
element_list
=
g
.
element
.
querySelectorAll
(
'
[data-gadget-url]
'
),
function
loadSubGadgetDOMDeclaration
()
{
var
element_list
=
this
.
element
.
querySelectorAll
(
'
[data-gadget-url]
'
),
element
,
promise_list
=
[],
scope
,
url
,
sandbox
,
i
;
i
,
context
=
this
;
function
prepareReportGadgetDeclarationError
(
scope
)
{
return
function
(
error
)
{
var
aq_dict
=
context
.
__acquired_method_dict
||
{},
method_name
=
'
reportGadgetDeclarationError
'
;
if
(
aq_dict
.
hasOwnProperty
(
method_name
))
{
return
aq_dict
[
method_name
].
apply
(
context
,
[
arguments
,
scope
]);
}
throw
error
;
};
}
for
(
i
=
0
;
i
<
element_list
.
length
;
i
+=
1
)
{
element
=
element_list
[
i
];
...
...
@@ -1101,11 +1114,14 @@ if (typeof document.contains !== 'function') {
url
=
element
.
getAttribute
(
"
data-gadget-url
"
);
sandbox
=
element
.
getAttribute
(
"
data-gadget-sandbox
"
);
if
(
url
!==
null
)
{
promise_list
.
push
(
g
.
declareGadget
(
url
,
{
promise_list
.
push
(
context
.
declareGadget
(
url
,
{
element
:
element
,
scope
:
scope
||
undefined
,
sandbox
:
sandbox
||
undefined
}));
})
.
push
(
undefined
,
prepareReportGadgetDeclarationError
(
scope
))
);
}
}
...
...
@@ -1120,9 +1136,10 @@ if (typeof document.contains !== 'function') {
};
RenderJSGadget
.
setState
=
function
(
state_dict
)
{
var
json_state
=
JSON
.
stringify
(
state_dict
);
return
this
.
ready
(
function
()
{
this
.
__ready_list
.
unshift
(
function
()
{
this
.
state
=
JSON
.
parse
(
json_state
);
});
return
this
;
};
RenderJSGadget
.
onStateChange
=
function
(
callback
)
{
this
.
prototype
.
__state_change_callback
=
callback
;
...
...
@@ -1331,6 +1348,8 @@ if (typeof document.contains !== 'function') {
};
RenderJSGadget
.
declareAcquiredMethod
(
"
aq_reportServiceError
"
,
"
reportServiceError
"
);
RenderJSGadget
.
declareAcquiredMethod
(
"
aq_reportGadgetDeclarationError
"
,
"
reportGadgetDeclarationError
"
);
/////////////////////////////////////////////////////////////////
// RenderJSGadget.allowPublicAcquisition
...
...
@@ -1381,56 +1400,37 @@ if (typeof document.contains !== 'function') {
// privateDeclarePublicGadget
/////////////////////////////////////////////////////////////////
function
privateDeclarePublicGadget
(
url
,
options
,
parent_gadget
)
{
var
gadget_instance
;
if
(
options
.
element
===
undefined
)
{
options
.
element
=
document
.
createElement
(
"
div
"
);
}
function
loadDependency
(
method
,
url
)
{
return
function
()
{
return
method
(
url
);
};
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
renderJS
.
declareGadgetKlass
(
url
);
return
renderJS
.
declareGadgetKlass
(
url
)
// gadget loading should not be interrupted
// if not, gadget's definition will not be complete
//.then will return another promise
//so loading_klass_promise can't be cancel
.
then
(
function
(
result
)
{
return
result
;
});
})
// Get the gadget class and instanciate it
.
push
(
function
(
Klass
)
{
if
(
options
.
element
===
undefined
)
{
options
.
element
=
document
.
createElement
(
"
div
"
);
}
var
i
,
template_node_list
=
Klass
.
__template_element
.
body
.
childNodes
;
gadget_loading_klass
=
Klass
;
gadget_instance
,
template_node_list
=
Klass
.
__template_element
.
body
.
childNodes
,
fragment
=
document
.
createDocumentFragment
();
gadget_instance
=
new
Klass
();
gadget_instance
.
element
=
options
.
element
;
gadget_instance
.
state
=
{};
for
(
i
=
0
;
i
<
template_node_list
.
length
;
i
+=
1
)
{
gadget_instance
.
ele
ment
.
appendChild
(
frag
ment
.
appendChild
(
template_node_list
[
i
].
cloneNode
(
true
)
);
}
gadget_instance
.
element
.
appendChild
(
fragment
);
setAqParent
(
gadget_instance
,
parent_gadget
);
// Load dependencies if needed
return
RSVP
.
all
([
gadget_instance
.
getRequiredJSList
(),
gadget_instance
.
getRequiredCSSList
()
]);
})
// Load all JS/CSS
.
push
(
function
(
all_list
)
{
var
q
=
new
RSVP
.
Queue
(),
i
;
// Load JS
for
(
i
=
0
;
i
<
all_list
[
0
].
length
;
i
+=
1
)
{
q
.
push
(
loadDependency
(
renderJS
.
declareJS
,
all_list
[
0
][
i
]));
}
// Load CSS
for
(
i
=
0
;
i
<
all_list
[
1
].
length
;
i
+=
1
)
{
q
.
push
(
loadDependency
(
renderJS
.
declareCSS
,
all_list
[
1
][
i
]));
}
return
q
;
})
.
push
(
function
()
{
return
gadget_instance
;
});
}
...
...
@@ -1480,6 +1480,17 @@ if (typeof document.contains !== 'function') {
gadget_instance
=
new
RenderJSIframeGadget
();
setAqParent
(
gadget_instance
,
parent_gadget
);
iframe
=
document
.
createElement
(
"
iframe
"
);
iframe
.
addEventListener
(
'
error
'
,
function
(
error
)
{
iframe_loading_deferred
.
reject
(
error
);
});
iframe
.
addEventListener
(
'
load
'
,
function
()
{
return
RSVP
.
timeout
(
5000
)
.
fail
(
function
()
{
iframe_loading_deferred
.
reject
(
new
Error
(
'
Timeout while loading:
'
+
url
)
);
});
});
// gadget_instance.element.setAttribute("seamless", "seamless");
iframe
.
setAttribute
(
"
src
"
,
url
);
gadget_instance
.
__path
=
url
;
...
...
@@ -1543,18 +1554,7 @@ if (typeof document.contains !== 'function') {
trans
.
delayReturn
(
true
);
});
return
RSVP
.
any
([
iframe_loading_deferred
.
promise
,
// Timeout to prevent non renderJS embeddable gadget
// XXX Maybe using iframe.onload/onerror would be safer?
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
timeout
(
5000
);
})
.
push
(
undefined
,
function
()
{
throw
new
Error
(
'
Timeout while loading:
'
+
url
);
})
]);
return
iframe_loading_deferred
.
promise
;
}
/////////////////////////////////////////////////////////////////
...
...
@@ -1589,10 +1589,7 @@ if (typeof document.contains !== 'function') {
/////////////////////////////////////////////////////////////////
RenderJSGadget
.
declareMethod
(
'
declareGadget
'
,
function
(
url
,
options
)
{
var
queue
,
parent_gadget
=
this
,
local_loading_klass_promise
,
previous_loading_klass_promise
=
loading_klass_promise
;
var
parent_gadget
=
this
;
if
(
options
===
undefined
)
{
options
=
{};
...
...
@@ -1603,16 +1600,8 @@ if (typeof document.contains !== 'function') {
// transform url to absolute url if it is relative
url
=
renderJS
.
getAbsoluteURL
(
url
,
this
.
__path
);
// Change the global variable to update the loading queue
loading_klass_promise
=
new
RSVP
.
Queue
()
// Wait for previous gadget loading to finish first
.
push
(
function
()
{
return
previous_loading_klass_promise
;
})
.
push
(
undefined
,
function
()
{
// Forget previous declareGadget error
return
;
})
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
var
method
;
if
(
options
.
sandbox
===
"
public
"
)
{
...
...
@@ -1628,41 +1617,17 @@ if (typeof document.contains !== 'function') {
return
method
(
url
,
options
,
parent_gadget
);
})
// Set the HTML context
.
push
(
function
(
gadget_instance
)
{
// Drop the current loading klass info used by selector
gadget_loading_klass
=
undefined
;
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
;
});
//gadget loading should not be interrupted
//if not, gadget's definition will not be complete
//.then will return another promise
//so loading_klass_promise can't be cancel
local_loading_klass_promise
=
loading_klass_promise
.
then
(
function
(
gadget_instance
)
{
return
gadget_instance
;
});
queue
=
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
local_loading_klass_promise
;
})
// Set the HTML context
.
push
(
function
(
gadget_instance
)
{
var
i
,
scope
;
scope
,
queue
=
new
RSVP
.
Queue
();
// Trigger calling of all ready callback
function
ready_wrapper
()
{
return
gadget_instance
;
}
function
ready_executable_wrapper
(
fct
)
{
return
function
(
g
)
{
return
fct
.
call
(
g
,
g
);
return
function
()
{
return
fct
.
call
(
g
adget_instance
,
gadget_instance
);
};
}
for
(
i
=
0
;
i
<
gadget_instance
.
constructor
.
__ready_list
.
length
;
...
...
@@ -1702,9 +1667,8 @@ if (typeof document.contains !== 'function') {
// Always return the gadget instance after ready function
queue
.
push
(
ready_wrapper
);
return
gadget_instance
;
});
return
queue
;
});
})
.
declareMethod
(
'
getDeclaredGadget
'
,
function
(
gadget_scope
)
{
if
(
!
this
.
__sub_gadget_dict
.
hasOwnProperty
(
gadget_scope
))
{
...
...
@@ -1728,7 +1692,7 @@ if (typeof document.contains !== 'function') {
if
(
selector
===
window
)
{
// window is the 'this' value when loading a javascript file
// In this case, use the current loading gadget constructor
result
=
gadget_loading_klass
;
result
=
gadget_loading_klass
_list
[
0
]
;
}
if
(
result
===
undefined
)
{
throw
new
Error
(
"
Unknown selector '
"
+
selector
+
"
'
"
);
...
...
@@ -1754,18 +1718,8 @@ if (typeof document.contains !== 'function') {
// renderJS.getAbsoluteURL
/////////////////////////////////////////////////////////////////
renderJS
.
getAbsoluteURL
=
function
(
url
,
base_url
)
{
var
doc
,
base
,
link
,
html
=
"
<!doctype><html><head></head></html>
"
;
if
(
url
&&
base_url
&&
!
isAbsoluteOrDataURL
.
test
(
url
))
{
doc
=
(
new
DOMParser
()).
parseFromString
(
html
,
'
text/html
'
);
base
=
doc
.
createElement
(
'
base
'
);
link
=
doc
.
createElement
(
'
link
'
);
doc
.
head
.
appendChild
(
base
);
doc
.
head
.
appendChild
(
link
);
base
.
href
=
base_url
;
link
.
href
=
url
;
return
link
.
href
;
if
(
base_url
&&
url
)
{
return
new
URL
(
url
,
base_url
).
href
;
}
return
url
;
};
...
...
@@ -1773,26 +1727,36 @@ if (typeof document.contains !== 'function') {
/////////////////////////////////////////////////////////////////
// renderJS.declareJS
/////////////////////////////////////////////////////////////////
renderJS
.
declareJS
=
function
(
url
)
{
renderJS
.
declareJS
=
function
(
url
,
container
,
pop
)
{
// https://www.html5rocks.com/en/tutorials/speed/script-loading/
// Prevent infinite recursion if loading render.js
// more than once
var
result
;
if
(
javascript_registration_dict
.
hasOwnProperty
(
url
))
{
result
=
RSVP
.
resolve
();
}
else
{
javascript_registration_dict
[
url
]
=
null
;
result
=
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
var
newScript
;
newScript
=
document
.
createElement
(
'
script
'
);
newScript
.
async
=
false
;
newScript
.
type
=
'
text/javascript
'
;
newScript
.
src
=
url
;
newScript
.
onload
=
function
()
{
javascript_registration_dict
[
url
]
=
null
;
if
(
pop
===
true
)
{
// Drop the current loading klass info used by selector
gadget_loading_klass_list
.
shift
();
}
resolve
();
};
newScript
.
onerror
=
function
(
e
)
{
if
(
pop
===
true
)
{
// Drop the current loading klass info used by selector
gadget_loading_klass_list
.
shift
();
}
reject
(
e
);
};
document
.
head
.
appendChild
(
newScript
);
newScript
.
src
=
url
;
container
.
appendChild
(
newScript
);
});
}
return
result
;
...
...
@@ -1801,7 +1765,7 @@ if (typeof document.contains !== 'function') {
/////////////////////////////////////////////////////////////////
// renderJS.declareCSS
/////////////////////////////////////////////////////////////////
renderJS
.
declareCSS
=
function
(
url
)
{
renderJS
.
declareCSS
=
function
(
url
,
container
)
{
// https://github.com/furf/jquery-getCSS/blob/master/jquery.getCSS.js
// No way to cleanly check if a css has been loaded
// So, always resolve the promise...
...
...
@@ -1823,7 +1787,7 @@ if (typeof document.contains !== 'function') {
link
.
onerror
=
function
(
e
)
{
reject
(
e
);
};
document
.
head
.
appendChild
(
link
);
container
.
appendChild
(
link
);
});
}
return
result
;
...
...
@@ -1832,14 +1796,11 @@ if (typeof document.contains !== 'function') {
/////////////////////////////////////////////////////////////////
// renderJS.declareGadgetKlass
/////////////////////////////////////////////////////////////////
renderJS
.
declareGadgetKlass
=
function
(
url
)
{
var
result
;
function
parse
(
xhr
)
{
function
parse
(
xhr
,
url
)
{
var
tmp_constructor
,
key
,
parsed_html
;
if
(
!
gadget_model_dict
.
hasOwnProperty
(
url
))
{
// Class inheritance
tmp_constructor
=
function
()
{
RenderJSGadget
.
call
(
this
);
...
...
@@ -1882,27 +1843,60 @@ if (typeof document.contains !== 'function') {
tmp_constructor
.
prototype
[
'
__
'
+
key
]
=
parsed_html
[
key
];
}
}
gadget_model_dict
[
url
]
=
tmp_constructor
;
return
tmp_constructor
;
}
return
gadget_model_dict
[
url
];
renderJS
.
declareGadgetKlass
=
function
(
url
)
{
if
(
gadget_model_defer_dict
.
hasOwnProperty
(
url
))
{
// Return klass object if it already exists
return
gadget_model_defer_dict
[
url
].
promise
;
}
if
(
gadget_model_dict
.
hasOwnProperty
(
url
))
{
// Return klass object if it already exists
result
=
RSVP
.
resolve
(
gadget_model_dict
[
url
]);
}
else
{
var
tmp_constructor
,
defer
=
RSVP
.
defer
();
gadget_model_defer_dict
[
url
]
=
defer
;
// Change the global variable to update the loading queue
loading_klass_promise
=
defer
.
promise
;
// Fetch the HTML page and parse it
result
=
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
ajax
(
url
);
})
.
push
(
function
(
xhr
)
{
return
parse
(
xhr
);
});
.
push
(
function
(
result
)
{
tmp_constructor
=
parse
(
result
,
url
);
var
fragment
=
document
.
createDocumentFragment
(),
promise_list
=
[],
i
,
js_list
=
tmp_constructor
.
prototype
.
__required_js_list
,
css_list
=
tmp_constructor
.
prototype
.
__required_css_list
;
// Load JS
if
(
js_list
.
length
)
{
gadget_loading_klass_list
.
push
(
tmp_constructor
);
for
(
i
=
0
;
i
<
js_list
.
length
-
1
;
i
+=
1
)
{
promise_list
.
push
(
renderJS
.
declareJS
(
js_list
[
i
],
fragment
));
}
return
result
;
promise_list
.
push
(
renderJS
.
declareJS
(
js_list
[
i
],
fragment
,
true
));
}
// Load CSS
for
(
i
=
0
;
i
<
css_list
.
length
;
i
+=
1
)
{
promise_list
.
push
(
renderJS
.
declareCSS
(
css_list
[
i
],
fragment
));
}
document
.
head
.
appendChild
(
fragment
);
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
()
{
defer
.
resolve
(
tmp_constructor
);
return
tmp_constructor
;
})
.
push
(
undefined
,
function
(
e
)
{
// Drop the current loading klass info used by selector
// even in case of error
defer
.
reject
(
e
);
throw
e
;
});
};
/////////////////////////////////////////////////////////////////
...
...
@@ -1910,7 +1904,7 @@ if (typeof document.contains !== 'function') {
/////////////////////////////////////////////////////////////////
// For test purpose only
renderJS
.
clearGadgetKlassList
=
function
()
{
gadget_model_dict
=
{};
gadget_model_d
efer_d
ict
=
{};
javascript_registration_dict
=
{};
stylesheet_registration_dict
=
{};
};
...
...
@@ -1980,7 +1974,7 @@ if (typeof document.contains !== 'function') {
function
bootstrap
()
{
var
url
=
removeHash
(
window
.
location
.
href
),
tmp_c
onstructor
,
TmpC
onstructor
,
root_gadget
,
loading_gadget_promise
=
new
RSVP
.
Queue
(),
declare_method_count
=
0
,
...
...
@@ -1996,7 +1990,7 @@ if (typeof document.contains !== 'function') {
connection_ready
=
false
;
// Create the gadget class for the current url
if
(
gadget_model_dict
.
hasOwnProperty
(
url
))
{
if
(
gadget_model_d
efer_d
ict
.
hasOwnProperty
(
url
))
{
throw
new
Error
(
"
bootstrap should not be called twice
"
);
}
loading_klass_promise
=
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
...
...
@@ -2025,40 +2019,42 @@ if (typeof document.contains !== 'function') {
// tmp_constructor = RenderJSEmbeddedGadget
if
(
window
.
self
===
window
.
top
)
{
// XXX Copy/Paste from declareGadgetKlass
tmp_c
onstructor
=
function
()
{
TmpC
onstructor
=
function
()
{
RenderJSGadget
.
call
(
this
);
};
tmp_c
onstructor
.
declareMethod
=
RenderJSGadget
.
declareMethod
;
tmp_c
onstructor
.
declareJob
=
RenderJSGadget
.
declareJob
;
tmp_c
onstructor
.
declareAcquiredMethod
=
TmpC
onstructor
.
declareMethod
=
RenderJSGadget
.
declareMethod
;
TmpC
onstructor
.
declareJob
=
RenderJSGadget
.
declareJob
;
TmpC
onstructor
.
declareAcquiredMethod
=
RenderJSGadget
.
declareAcquiredMethod
;
tmp_c
onstructor
.
allowPublicAcquisition
=
TmpC
onstructor
.
allowPublicAcquisition
=
RenderJSGadget
.
allowPublicAcquisition
;
tmp_c
onstructor
.
__ready_list
=
RenderJSGadget
.
__ready_list
.
slice
();
tmp_c
onstructor
.
ready
=
RenderJSGadget
.
ready
;
tmp_c
onstructor
.
setState
=
RenderJSGadget
.
setState
;
tmp_c
onstructor
.
onStateChange
=
RenderJSGadget
.
onStateChange
;
tmp_c
onstructor
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
();
tmp_c
onstructor
.
declareService
=
TmpC
onstructor
.
__ready_list
=
RenderJSGadget
.
__ready_list
.
slice
();
TmpC
onstructor
.
ready
=
RenderJSGadget
.
ready
;
TmpC
onstructor
.
setState
=
RenderJSGadget
.
setState
;
TmpC
onstructor
.
onStateChange
=
RenderJSGadget
.
onStateChange
;
TmpC
onstructor
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
();
TmpC
onstructor
.
declareService
=
RenderJSGadget
.
declareService
;
tmp_c
onstructor
.
onEvent
=
TmpC
onstructor
.
onEvent
=
RenderJSGadget
.
onEvent
;
tmp_constructor
.
prototype
=
new
RenderJSGadget
();
tmp_constructor
.
prototype
.
constructor
=
tmp_constructor
;
tmp_constructor
.
prototype
.
__path
=
url
;
gadget_model_dict
[
url
]
=
tmp_constructor
;
TmpConstructor
.
prototype
=
new
RenderJSGadget
();
TmpConstructor
.
prototype
.
constructor
=
TmpConstructor
;
TmpConstructor
.
prototype
.
__path
=
url
;
gadget_model_defer_dict
[
url
]
=
{
promise
:
RSVP
.
resolve
(
TmpConstructor
)
};
// Create the root gadget instance and put it in the loading stack
root_gadget
=
new
gadget_model_dict
[
url
]
();
root_gadget
=
new
TmpConstructor
();
setAqParent
(
root_gadget
,
last_acquisition_gadget
);
}
else
{
// Create the root gadget instance and put it in the loading stack
tmp_c
onstructor
=
RenderJSEmbeddedGadget
;
tmp_c
onstructor
.
__ready_list
=
RenderJSGadget
.
__ready_list
.
slice
();
tmp_c
onstructor
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
();
tmp_c
onstructor
.
prototype
.
__path
=
url
;
TmpC
onstructor
=
RenderJSEmbeddedGadget
;
TmpC
onstructor
.
__ready_list
=
RenderJSGadget
.
__ready_list
.
slice
();
TmpC
onstructor
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
();
TmpC
onstructor
.
prototype
.
__path
=
url
;
root_gadget
=
new
RenderJSEmbeddedGadget
();
setAqParent
(
root_gadget
,
last_acquisition_gadget
);
...
...
@@ -2072,7 +2068,7 @@ if (typeof document.contains !== 'function') {
iframe_top_gadget
=
false
;
//Default: Define __aq_parent to inform parent window
root_gadget
.
__aq_parent
=
tmp_c
onstructor
.
prototype
.
__aq_parent
=
function
(
method_name
,
TmpC
onstructor
.
prototype
.
__aq_parent
=
function
(
method_name
,
argument_list
,
time_out
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
embedded_channel
.
call
({
...
...
@@ -2154,7 +2150,7 @@ if (typeof document.contains !== 'function') {
notifyDeclareMethod
(
"
getTitle
"
);
// Surcharge declareMethod to inform parent window
tmp_c
onstructor
.
declareMethod
=
function
(
name
,
callback
)
{
TmpC
onstructor
.
declareMethod
=
function
(
name
,
callback
)
{
var
result
=
RenderJSGadget
.
declareMethod
.
apply
(
this
,
[
name
,
callback
]
...
...
@@ -2163,41 +2159,43 @@ if (typeof document.contains !== 'function') {
return
result
;
};
tmp_c
onstructor
.
declareService
=
TmpC
onstructor
.
declareService
=
RenderJSGadget
.
declareService
;
tmp_c
onstructor
.
declareJob
=
TmpC
onstructor
.
declareJob
=
RenderJSGadget
.
declareJob
;
tmp_c
onstructor
.
onEvent
=
TmpC
onstructor
.
onEvent
=
RenderJSGadget
.
onEvent
;
tmp_c
onstructor
.
declareAcquiredMethod
=
TmpC
onstructor
.
declareAcquiredMethod
=
RenderJSGadget
.
declareAcquiredMethod
;
tmp_c
onstructor
.
allowPublicAcquisition
=
TmpC
onstructor
.
allowPublicAcquisition
=
RenderJSGadget
.
allowPublicAcquisition
;
iframe_top_gadget
=
true
;
}
tmp_c
onstructor
.
prototype
.
__acquired_method_dict
=
{};
gadget_loading_klass
=
tmp_constructor
;
TmpC
onstructor
.
prototype
.
__acquired_method_dict
=
{};
gadget_loading_klass
_list
.
push
(
TmpConstructor
)
;
function
init
()
{
// XXX HTML properties can only be set when the DOM is fully loaded
var
settings
=
renderJS
.
parseGadgetHTMLDocument
(
document
,
url
),
j
,
key
;
key
,
fragment
=
document
.
createDocumentFragment
();
for
(
key
in
settings
)
{
if
(
settings
.
hasOwnProperty
(
key
))
{
tmp_c
onstructor
.
prototype
[
'
__
'
+
key
]
=
settings
[
key
];
TmpC
onstructor
.
prototype
[
'
__
'
+
key
]
=
settings
[
key
];
}
}
tmp_c
onstructor
.
__template_element
=
document
.
createElement
(
"
div
"
);
TmpC
onstructor
.
__template_element
=
document
.
createElement
(
"
div
"
);
root_gadget
.
element
=
document
.
body
;
root_gadget
.
state
=
{};
for
(
j
=
0
;
j
<
root_gadget
.
element
.
childNodes
.
length
;
j
+=
1
)
{
tmp_constructor
.
__template_ele
ment
.
appendChild
(
frag
ment
.
appendChild
(
root_gadget
.
element
.
childNodes
[
j
].
cloneNode
(
true
)
);
}
TmpConstructor
.
__template_element
.
appendChild
(
fragment
);
RSVP
.
all
([
root_gadget
.
getRequiredJSList
(),
root_gadget
.
getRequiredCSSList
()])
.
then
(
function
(
all_list
)
{
...
...
@@ -2210,7 +2208,7 @@ if (typeof document.contains !== 'function') {
for
(
i
=
0
;
i
<
css_list
.
length
;
i
+=
1
)
{
stylesheet_registration_dict
[
css_list
[
i
]]
=
null
;
}
gadget_loading_klass
=
undefined
;
gadget_loading_klass
_list
.
shift
()
;
}).
then
(
function
()
{
// select the target node
...
...
@@ -2304,15 +2302,15 @@ if (typeof document.contains !== 'function') {
return
fct
.
call
(
g
,
g
);
};
}
tmp_constructor
.
ready
(
function
(
g
)
{
return
startService
(
g
);
TmpConstructor
.
ready
(
function
(
)
{
return
startService
(
this
);
});
loading_gadget_promise
.
push
(
ready_wrapper
);
for
(
i
=
0
;
i
<
tmp_c
onstructor
.
__ready_list
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
TmpC
onstructor
.
__ready_list
.
length
;
i
+=
1
)
{
// Put a timeout?
loading_gadget_promise
.
push
(
ready_executable_wrapper
(
tmp_c
onstructor
.
__ready_list
[
i
]))
.
push
(
ready_executable_wrapper
(
TmpC
onstructor
.
__ready_list
[
i
]))
// Always return the gadget instance after ready function
.
push
(
ready_wrapper
);
}
...
...
@@ -2349,4 +2347,4 @@ if (typeof document.contains !== 'function') {
bootstrap
();
}(
document
,
window
,
RSVP
,
DOMParser
,
Channel
,
MutationObserver
,
Node
,
FileReader
,
Blob
,
navigator
,
Event
));
FileReader
,
Blob
,
navigator
,
Event
,
URL
));
\ No newline at end of file
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