Commit 9722e744 authored by Tristan Cavelier's avatar Tristan Cavelier

simplify code

parent f5a9d52f
...@@ -36,8 +36,7 @@ ...@@ -36,8 +36,7 @@
scrollTop: window.pageYOffset, scrollTop: window.pageYOffset,
scrollLeft: window.pageXOffset scrollLeft: window.pageXOffset
}; };
element.className = (element.className || "") + element.classList.add("ui-content-maximize");
" " + gadget.props.maximize_classname;
// XXX tell sub gadget that now it is maximized (call subgadget.onMaximizeChange?) // XXX tell sub gadget that now it is maximized (call subgadget.onMaximizeChange?)
// this way the parent gadget can decide to set the sub gadget unmaximized later // this way the parent gadget can decide to set the sub gadget unmaximized later
// for instance: if the user clicks on a button that changes the ui, the maximized // for instance: if the user clicks on a button that changes the ui, the maximized
...@@ -50,15 +49,12 @@ ...@@ -50,15 +49,12 @@
gadget.props.maximize_restore_state.gadget_scope !== subgadget_scope) { gadget.props.maximize_restore_state.gadget_scope !== subgadget_scope) {
return false; // do not raise, like html5 requestFullScreen return false; // do not raise, like html5 requestFullScreen
} }
var maximized_element_list = gadget.props.element.querySelectorAll( var maximized_element_list =
"." + gadget.props.maximize_classname gadget.props.element.querySelectorAll(".ui-content-maximize");
);
if ([].indexOf.call(maximized_element_list, element) < 0) { if ([].indexOf.call(maximized_element_list, element) < 0) {
return false; // do not raise, like html5 requestFullScreen return false; // do not raise, like html5 requestFullScreen
} }
element.className = (element.className || "") element.classList.remove("ui-content-maximize");
.replace(gadget.props.maximize_classname_search_regexp, " ")
.replace(/(?:^\s+|\s+$)/g, ""); // remove trailing spaces
window.scrollTo( window.scrollTo(
gadget.props.maximize_restore_state.scrollLeft, gadget.props.maximize_restore_state.scrollLeft,
gadget.props.maximize_restore_state.scrollTop gadget.props.maximize_restore_state.scrollTop
...@@ -81,10 +77,7 @@ ...@@ -81,10 +77,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Init local properties // Init local properties
.ready(function (g) { .ready(function (g) {
g.props = { g.props = {};
maximize_classname: "ui-content-maximize",
maximize_classname_search_regexp: /(?:^|\s)ui-content-maximize(?:\s|$)/
};
}) })
// Assign the element to a variable // Assign the element to a variable
......
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