Commit 3c7716b4 authored by Vincent Bechu's avatar Vincent Bechu

[erp5_officejs] Update officejs panels to use hide panel in desktop view

parent f2c3d48c
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Precompile templates while loading the first gadget instance // Precompile templates while loading the first gadget instance
var gadget_klass = rJS(window), var gadget_klass = rJS(window),
matchMedia = window.matchMedia("(min-width: 85em)"),
template_element = gadget_klass.__template_element, template_element = gadget_klass.__template_element,
panel_template_header = Handlebars.compile(template_element panel_template_header = Handlebars.compile(template_element
.getElementById("panel-template-header") .getElementById("panel-template-header")
...@@ -25,7 +26,7 @@ ...@@ -25,7 +26,7 @@
gadget_klass gadget_klass
.setState({ .setState({
visible: false, visible: false,
desktop: false desktop: matchMedia.matches
}) })
////////////////////////////////////////////// //////////////////////////////////////////////
// acquired method // acquired method
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
.declareAcquiredMethod("translate", "translate") .declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("setDesktopMode", "setDesktopMode")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -97,6 +99,14 @@ ...@@ -97,6 +99,14 @@
} }
} }
} }
if (modification_dict.hasOwnProperty('desktop') ||
modification_dict.hasOwnProperty("visible")) {
queue.push(function () {
return gadget.setDesktopMode(
gadget.state.visible && gadget.state.desktop
);
});
}
if (modification_dict.hasOwnProperty("global")) { if (modification_dict.hasOwnProperty("global")) {
queue queue
...@@ -246,13 +256,15 @@ ...@@ -246,13 +256,15 @@
event, event,
context = this; context = this;
function extractSizeAndDispatch() { function extractSizeAndDispatch() {
if (window.matchMedia("(min-width: 85em)").matches) { if (matchMedia.matches) {
return context.changeState({ return context.changeState({
desktop: true desktop: true,
visible: true
}); });
} }
return context.changeState({ return context.changeState({
desktop: false desktop: false,
visible: false
}); });
} }
result = loopEventListener(window, 'resize', false, result = loopEventListener(window, 'resize', false,
......
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,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>
...@@ -227,7 +227,7 @@ ...@@ -227,7 +227,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.9269.443.55364</string> </value> <value> <string>963.49595.35665.18636</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -245,7 +245,7 @@ ...@@ -245,7 +245,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1501746660.8</float> <float>1511882697.0</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Precompile templates while loading the first gadget instance // Precompile templates while loading the first gadget instance
var gadget_klass = rJS(window), var gadget_klass = rJS(window),
matchMedia = window.matchMedia("(min-width: 85em)"),
template_element = gadget_klass.__template_element, template_element = gadget_klass.__template_element,
panel_template_header = Handlebars.compile(template_element panel_template_header = Handlebars.compile(template_element
.getElementById("panel-template-header") .getElementById("panel-template-header")
...@@ -25,7 +26,7 @@ ...@@ -25,7 +26,7 @@
gadget_klass gadget_klass
.setState({ .setState({
visible: false, visible: false,
desktop: false desktop: matchMedia.matches
}) })
////////////////////////////////////////////// //////////////////////////////////////////////
// acquired method // acquired method
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
.declareAcquiredMethod("translate", "translate") .declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("setDesktopMode", "setDesktopMode")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -97,6 +99,14 @@ ...@@ -97,6 +99,14 @@
} }
} }
} }
if (modification_dict.hasOwnProperty('desktop') ||
modification_dict.hasOwnProperty("visible")) {
queue.push(function () {
return gadget.setDesktopMode(
gadget.state.visible && gadget.state.desktop
);
});
}
if (modification_dict.hasOwnProperty("global")) { if (modification_dict.hasOwnProperty("global")) {
queue queue
...@@ -271,13 +281,15 @@ ...@@ -271,13 +281,15 @@
event, event,
context = this; context = this;
function extractSizeAndDispatch() { function extractSizeAndDispatch() {
if (window.matchMedia("(min-width: 85em)").matches) { if (matchMedia.matches) {
return context.changeState({ return context.changeState({
desktop: true desktop: true,
visible: true
}); });
} }
return context.changeState({ return context.changeState({
desktop: false desktop: false,
visible: false
}); });
} }
result = loopEventListener(window, 'resize', false, result = loopEventListener(window, 'resize', false,
......
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,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>
...@@ -227,7 +227,7 @@ ...@@ -227,7 +227,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.6228.20782.273</string> </value> <value> <string>963.49595.22396.38980</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -245,7 +245,7 @@ ...@@ -245,7 +245,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1501682796.44</float> <float>1511882685.21</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Precompile templates while loading the first gadget instance // Precompile templates while loading the first gadget instance
var gadget_klass = rJS(window), var gadget_klass = rJS(window),
matchMedia = window.matchMedia("(min-width: 85em)"),
template_element = gadget_klass.__template_element, template_element = gadget_klass.__template_element,
panel_template_header = Handlebars.compile(template_element panel_template_header = Handlebars.compile(template_element
.getElementById("panel-template-header") .getElementById("panel-template-header")
...@@ -25,7 +26,7 @@ ...@@ -25,7 +26,7 @@
gadget_klass gadget_klass
.setState({ .setState({
visible: false, visible: false,
desktop: false desktop: matchMedia.matches
}) })
////////////////////////////////////////////// //////////////////////////////////////////////
// acquired method // acquired method
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
.declareAcquiredMethod("translate", "translate") .declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("setDesktopMode", "setDesktopMode")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -97,6 +99,14 @@ ...@@ -97,6 +99,14 @@
} }
} }
} }
if (modification_dict.hasOwnProperty('desktop') ||
modification_dict.hasOwnProperty("visible")) {
queue.push(function () {
return gadget.setDesktopMode(
gadget.state.visible && gadget.state.desktop
);
});
}
if (modification_dict.hasOwnProperty("global")) { if (modification_dict.hasOwnProperty("global")) {
queue queue
...@@ -273,13 +283,15 @@ ...@@ -273,13 +283,15 @@
event, event,
context = this; context = this;
function extractSizeAndDispatch() { function extractSizeAndDispatch() {
if (window.matchMedia("(min-width: 85em)").matches) { if (matchMedia.matches) {
return context.changeState({ return context.changeState({
desktop: true desktop: true,
visible: true
}); });
} }
return context.changeState({ return context.changeState({
desktop: false desktop: false,
visible: false
}); });
} }
result = loopEventListener(window, 'resize', false, result = loopEventListener(window, 'resize', false,
......
...@@ -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.39082.1332.7492</string> </value> <value> <string>963.49595.385.2423</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>1503907015.64</float> <float>1511882675.53</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Precompile templates while loading the first gadget instance // Precompile templates while loading the first gadget instance
var gadget_klass = rJS(window), var gadget_klass = rJS(window),
matchMedia = window.matchMedia("(min-width: 85em)"),
template_element = gadget_klass.__template_element, template_element = gadget_klass.__template_element,
panel_template_header = Handlebars.compile(template_element panel_template_header = Handlebars.compile(template_element
.getElementById("panel-template-header") .getElementById("panel-template-header")
...@@ -25,7 +26,7 @@ ...@@ -25,7 +26,7 @@
gadget_klass gadget_klass
.setState({ .setState({
visible: false, visible: false,
desktop: false desktop: matchMedia.matches
}) })
////////////////////////////////////////////// //////////////////////////////////////////////
// acquired method // acquired method
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
.declareAcquiredMethod("translate", "translate") .declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("setDesktopMode", "setDesktopMode")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -97,6 +99,14 @@ ...@@ -97,6 +99,14 @@
} }
} }
} }
if (modification_dict.hasOwnProperty('desktop') ||
modification_dict.hasOwnProperty("visible")) {
queue.push(function () {
return gadget.setDesktopMode(
gadget.state.visible && gadget.state.desktop
);
});
}
if (modification_dict.hasOwnProperty("global")) { if (modification_dict.hasOwnProperty("global")) {
queue queue
...@@ -271,13 +281,15 @@ ...@@ -271,13 +281,15 @@
event, event,
context = this; context = this;
function extractSizeAndDispatch() { function extractSizeAndDispatch() {
if (window.matchMedia("(min-width: 85em)").matches) { if (matchMedia.matches) {
return context.changeState({ return context.changeState({
desktop: true desktop: true,
visible: true
}); });
} }
return context.changeState({ return context.changeState({
desktop: false desktop: false,
visible: false
}); });
} }
result = loopEventListener(window, 'resize', false, result = loopEventListener(window, 'resize', false,
......
...@@ -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>962.22807.3679.17032</string> </value> <value> <string>963.49597.57331.30481</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>1506429553.2</float> <float>1511882794.78</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