Commit 1eaef318 authored by Vincent Bechu's avatar Vincent Bechu

[erp5_web_renderjs_ui] Handle rezize event in launcher

parent e34dcc97
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.js"></script> <script src="renderjs.js"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="erp5_launcher_nojqm.js"></script> <script src="erp5_launcher_nojqm.js"></script>
</head> </head>
......
...@@ -63,6 +63,12 @@ ...@@ -63,6 +63,12 @@
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item> <item>
<key> <string>content_md5</string> </key> <key> <string>content_md5</string> </key>
<value> <value>
...@@ -222,7 +228,7 @@ ...@@ -222,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>vincent</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -236,7 +242,7 @@ ...@@ -236,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.56670.55511.24746</string> </value> <value> <string>964.4178.47068.37000</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +260,7 @@ ...@@ -254,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1504529272.57</float> <float>1513004254.36</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*globals window, document, RSVP, rJS, /*globals window, document, RSVP, rJS,
URI, location, XMLHttpRequest, console, navigator*/ URI, location, XMLHttpRequest, console, navigator, loopEventListener*/
/*jslint indent: 2, maxlen: 80*/ /*jslint indent: 2, maxlen: 80*/
(function (window, document, RSVP, rJS, (function (window, document, RSVP, rJS,
XMLHttpRequest, location, console, navigator) { XMLHttpRequest, location, console, navigator, loopEventListener) {
"use strict"; "use strict";
var MAIN_SCOPE = "m"; var MAIN_SCOPE = "m";
...@@ -182,7 +182,8 @@ ...@@ -182,7 +182,8 @@
content_element: this.element.querySelector('.gadget-content'), content_element: this.element.querySelector('.gadget-content'),
setting_id: "setting/" + document.head.querySelector( setting_id: "setting/" + document.head.querySelector(
'script[data-renderjs-configuration="application_title"]' 'script[data-renderjs-configuration="application_title"]'
).textContent ).textContent,
panel_argument_list: {}
}; };
// Configure setting storage // Configure setting storage
...@@ -260,6 +261,9 @@ ...@@ -260,6 +261,9 @@
}) })
.push(function (router_gadget) { .push(function (router_gadget) {
return router_gadget.start(); return router_gadget.start();
})
.push(function () {
return gadget.listenResize();
}); });
}) })
...@@ -424,6 +428,7 @@ ...@@ -424,6 +428,7 @@
var gadget = this; var gadget = this;
initPanelOptions(gadget); initPanelOptions(gadget);
gadget.props.panel_argument_list = param_list[0]; gadget.props.panel_argument_list = param_list[0];
gadget.props.panel_argument_list.desktop = gadget.props.desktop;
}) })
.allowPublicAcquisition('triggerPanel', function () { .allowPublicAcquisition('triggerPanel', function () {
...@@ -583,6 +588,30 @@ ...@@ -583,6 +588,30 @@
}); });
}) })
.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;
gadget.props.panel_argument_list.desktop = desktop;
gadget.props.desktop = desktop;
return route(gadget, 'panel', 'close');
})
.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 // Handle sub gadgets services
///////////////////////////////// /////////////////////////////////
...@@ -601,4 +630,4 @@ ...@@ -601,4 +630,4 @@
}); });
}(window, document, RSVP, rJS, }(window, document, RSVP, rJS,
XMLHttpRequest, location, console, navigator)); XMLHttpRequest, location, console, navigator, loopEventListener));
\ No newline at end of file \ No newline at end of file
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>vincent</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.29105.23200.50073</string> </value> <value> <string>964.5299.35727.23022</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1511971674.78</float> <float>1513071009.13</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
<script src="rsvp.js" type="text/javascript"></script> <script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script> <script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.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"> <script id="panel-template-header" type="text/x-handlebars-template">
<div data-role="header" class="ui-bar-inherit"> <div data-role="header" class="ui-bar-inherit">
......
...@@ -220,7 +220,7 @@ ...@@ -220,7 +220,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>vincent</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>958.33121.48203.5614</string> </value> <value> <string>963.43879.9730.43520</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1491822419.47</float> <float>1512643569.15</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*jslint nomen: true, indent: 2, maxerr: 3, unparam: true */ /*jslint nomen: true, indent: 2, maxerr: 3, unparam: true */
/*global window, document, rJS, Handlebars, RSVP, Node, loopEventListener */ /*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"; "use strict";
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -75,7 +75,8 @@ ...@@ -75,7 +75,8 @@
workflow_list: workflow_list, workflow_list: workflow_list,
view_list: view_list, view_list: view_list,
global: true, global: true,
editable: options.editable || editable || false editable: options.editable || editable || false,
desktop: options.desktop || false
}); });
}); });
}) })
...@@ -132,7 +133,6 @@ ...@@ -132,7 +133,6 @@
.push(function () { .push(function () {
context.element.querySelector("div").appendChild(tmp_element); context.element.querySelector("div").appendChild(tmp_element);
return context.listenResize();
}); });
} }
...@@ -273,30 +273,6 @@ ...@@ -273,30 +273,6 @@
} }
}, false, false) }, 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) { .allowPublicAcquisition('notifyChange', function (argument_list, scope) {
if (scope === 'erp5_checkbox') { if (scope === 'erp5_checkbox') {
var context = this; var context = this;
...@@ -359,4 +335,4 @@ ...@@ -359,4 +335,4 @@
}, /*useCapture=*/false, /*preventDefault=*/true); }, /*useCapture=*/false, /*preventDefault=*/true);
}(window, document, rJS, Handlebars, RSVP, Node, loopEventListener)); }(window, document, rJS, Handlebars, RSVP, Node));
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>vincent</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.1708.1551.12032</string> </value> <value> <string>964.5689.59241.23961</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1501231473.84</float> <float>1513094084.97</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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