Commit b631f7e1 authored by Vincent Bechu's avatar Vincent Bechu

[erp5_web_renderjs_ui] Handle rezize event in launcher

parent 90c86654
......@@ -24,6 +24,7 @@
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="erp5_launcher_nojqm.js"></script>
</head>
......
......@@ -63,6 +63,14 @@
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>classification/collaborative/team</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
......@@ -222,7 +230,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>vincent</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -236,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.56670.55511.24746</string> </value>
<value> <string>963.63718.35123.35584</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1504529272.57</float>
<float>1512644451.26</float>
<string>UTC</string>
</tuple>
</state>
......
/*globals window, document, RSVP, rJS,
URI, location, XMLHttpRequest, console, navigator*/
URI, location, XMLHttpRequest, console, navigator, loopEventListener*/
/*jslint indent: 2, maxlen: 80*/
(function (window, document, RSVP, rJS,
XMLHttpRequest, location, console, navigator) {
XMLHttpRequest, location, console, navigator, loopEventListener) {
"use strict";
var MAIN_SCOPE = "m";
......@@ -182,7 +182,8 @@
content_element: this.element.querySelector('.gadget-content'),
setting_id: "setting/" + document.head.querySelector(
'script[data-renderjs-configuration="application_title"]'
).textContent
).textContent,
panel_argument_list: {}
};
// Configure setting storage
......@@ -260,6 +261,9 @@
})
.push(function (router_gadget) {
return router_gadget.start();
})
.push(function () {
return gadget.listenResize();
});
})
......@@ -424,6 +428,7 @@
var gadget = this;
initPanelOptions(gadget);
gadget.props.panel_argument_list = param_list[0];
gadget.props.panel_argument_list.desktop = gadget.props.desktop;
})
.allowPublicAcquisition('triggerPanel', function () {
......@@ -583,6 +588,31 @@
});
})
.declareJob('listenResize', function () {
// resize should be only trigger after the render method
var result,
event,
gadget = this;
function extractSizeAndDispatch() {
return new RSVP.Queue()
.push(function () {
var desktop = window.matchMedia("(min-width: 85em)").matches,
method = desktop ? 'open' : 'close';
gadget.props.panel_argument_list.desktop = desktop;
gadget.props.desktop = desktop;
return route(gadget, 'panel', method);
})
.push(function () {
return updatePanel(gadget);
});
}
result = loopEventListener(window, 'resize', false,
extractSizeAndDispatch);
event = document.createEvent("Event");
event.initEvent('resize', true, true);
window.dispatchEvent(event);
return result;
})
/////////////////////////////////
// Handle sub gadgets services
/////////////////////////////////
......@@ -601,4 +631,4 @@
});
}(window, document, RSVP, rJS,
XMLHttpRequest, location, console, navigator));
\ No newline at end of file
XMLHttpRequest, location, console, navigator, loopEventListener));
\ No newline at end of file
......@@ -216,7 +216,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>vincent</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.29105.23200.50073</string> </value>
<value> <string>963.63870.21758.35942</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1511971674.78</float>
<float>1512652755.5</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,7 +12,6 @@
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script id="panel-template-header" type="text/x-handlebars-template">
<div data-role="header" class="ui-bar-inherit">
......
......@@ -220,7 +220,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>vincent</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.33121.48203.5614</string> </value>
<value> <string>963.43879.9730.43520</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1491822419.47</float>
<float>1512643569.15</float>
<string>UTC</string>
</tuple>
</state>
......
/*jslint nomen: true, indent: 2, maxerr: 3, unparam: true */
/*global window, document, rJS, Handlebars, RSVP, Node, loopEventListener */
(function (window, document, rJS, Handlebars, RSVP, Node, loopEventListener) {
(function (window, document, rJS, Handlebars, RSVP, Node) {
"use strict";
/////////////////////////////////////////////////////////////////
......@@ -49,6 +49,11 @@
visible: false
});
})
.declareMethod('open', function () {
return this.changeState({
visible: true
});
})
.declareMethod('render', function (options) {
var erp5_document = options.erp5_document,
......@@ -75,7 +80,8 @@
workflow_list: workflow_list,
view_list: view_list,
global: true,
editable: options.editable || editable || false
editable: options.editable || editable || false,
desktop: options.desktop || false
});
});
})
......@@ -132,7 +138,6 @@
.push(function () {
context.element.querySelector("div").appendChild(tmp_element);
return context.listenResize();
});
}
......@@ -273,30 +278,6 @@
}
}, false, false)
.declareJob('listenResize', function () {
// resize should be only trigger after the render method
// as displaying the panel rely on external gadget (for translation for example)
var result,
event,
context = this;
function extractSizeAndDispatch() {
if (window.matchMedia("(min-width: 85em)").matches) {
return context.changeState({
desktop: true
});
}
return context.changeState({
desktop: false
});
}
result = loopEventListener(window, 'resize', false,
extractSizeAndDispatch);
event = document.createEvent("Event");
event.initEvent('resize', true, true);
window.dispatchEvent(event);
return result;
})
.allowPublicAcquisition('notifyChange', function (argument_list, scope) {
if (scope === 'erp5_checkbox') {
var context = this;
......@@ -359,4 +340,4 @@
}, /*useCapture=*/false, /*preventDefault=*/true);
}(window, document, rJS, Handlebars, RSVP, Node, loopEventListener));
}(window, document, rJS, Handlebars, RSVP, Node));
......@@ -216,7 +216,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>vincent</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.1708.1551.12032</string> </value>
<value> <string>963.63751.63771.26828</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1501231473.84</float>
<float>1512646397.6</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment