[refactor] improve page lock render

This commit is contained in:
Kuldeep M 2019-07-15 18:04:32 +01:00
parent c5f5e1b2d4
commit db89344153
5 changed files with 15 additions and 15 deletions

View File

@ -1181,7 +1181,7 @@
<script src="js/background.js"></script> <script src="js/background.js"></script>
<script src="js/layout.js"></script> <script src="js/layout.js"></script>
<script src="js/auto-suggest.js"></script> <script src="js/auto-suggest.js"></script>
<script src="js/page.js"></script> <script src="js/pagelock.js"></script>
<script src="js/edge.js"></script> <script src="js/edge.js"></script>
<script src="js/init.js"></script> <script src="js/init.js"></script>

View File

@ -5,7 +5,7 @@ var control = (function() {
type: "button", type: "button",
func: function() { func: function() {
menu.toggle(); menu.toggle();
page.update(); pagelock.render.toggle();
} }
}, { }, {
element: helper.e(".control-link-add"), element: helper.e(".control-link-add"),

View File

@ -11,7 +11,7 @@ var menu = (function() {
menuClose.addEventListener("click", function() { menuClose.addEventListener("click", function() {
close(); close();
shade.destroy(); shade.destroy();
page.update(); pagelock.render.toggle();
}, false); }, false);
}; };
@ -88,7 +88,7 @@ var menu = (function() {
shade.render({ shade.render({
action: function() { action: function() {
close(); close();
page.update(); pagelock.render.toggle();
} }
}); });
} else { } else {

View File

@ -105,7 +105,7 @@ var modal = (function() {
}; };
this.destroy(); this.destroy();
shade.destroy(); shade.destroy();
page.update(); pagelock.render.toggle();
}.bind(modal), false); }.bind(modal), false);
cancelButton.addEventListener("click", function(event) { cancelButton.addEventListener("click", function(event) {
if (options.cancelAction) { if (options.cancelAction) {
@ -113,7 +113,7 @@ var modal = (function() {
}; };
this.destroy(); this.destroy();
shade.destroy(); shade.destroy();
page.update(); pagelock.render.toggle();
}.bind(modal), false); }.bind(modal), false);
previousModal = modal; previousModal = modal;
shade.render({ shade.render({
@ -122,7 +122,7 @@ var modal = (function() {
options.cancelAction(); options.cancelAction();
}; };
modal.destroy(); modal.destroy();
page.update(); pagelock.render.toggle();
}, },
includeHeader: true includeHeader: true
}); });
@ -136,7 +136,7 @@ var modal = (function() {
destroy(); destroy();
}; };
_makeModal(); _makeModal();
page.update(); pagelock.render.toggle();
}; };
// exposed methods // exposed methods

View File

@ -1,6 +1,8 @@
var page = (function() { var pagelock = (function() {
var update = function() { var render = {};
render.toggle = function() {
var body = helper.e("body"); var body = helper.e("body");
var menu = state.get().menu; var menu = state.get().menu;
var modal = state.get().modal; var modal = state.get().modal;
@ -12,21 +14,19 @@ var page = (function() {
}; };
}; };
var lock = function() { render.lock = function() {
var body = helper.e("body"); var body = helper.e("body");
helper.addClass(body, "scroll-disabled"); helper.addClass(body, "scroll-disabled");
}; };
var unlock = function() { render.unlock = function() {
var body = helper.e("body"); var body = helper.e("body");
helper.removeClass(body, "scroll-disabled"); helper.removeClass(body, "scroll-disabled");
}; };
// exposed methods // exposed methods
return { return {
lock: lock, render: render
unlock: unlock,
update: update
}; };
})(); })();