diff --git a/erpnext/selling/page/point_of_sale/pos_controller.js b/erpnext/selling/page/point_of_sale/pos_controller.js index 8f02c8d0fb2..9da530081e7 100644 --- a/erpnext/selling/page/point_of_sale/pos_controller.js +++ b/erpnext/selling/page/point_of_sale/pos_controller.js @@ -165,6 +165,7 @@ erpnext.PointOfSale.Controller = class { this.prepare_dom(); this.prepare_components(); this.prepare_menu(); + this.prepare_fullscreen_btn(); this.make_new_invoice(); } @@ -200,6 +201,39 @@ erpnext.PointOfSale.Controller = class { this.page.add_menu_item(__("Close the POS"), this.close_pos.bind(this), false, "Shift+Ctrl+C"); } + prepare_fullscreen_btn() { + this.page.page_actions.find(".custom-actions").empty(); + + this.page.add_button(__("Full Screen"), null, { btn_class: "btn-default fullscreen-btn" }); + + this.bind_fullscreen_events(); + } + + bind_fullscreen_events() { + this.$fullscreen_btn = this.page.page_actions.find(".fullscreen-btn"); + + this.$fullscreen_btn.on("click", function () { + if (!document.fullscreenElement) { + document.documentElement.requestFullscreen(); + } else if (document.exitFullscreen) { + document.exitFullscreen(); + } + }); + + $(document).on("fullscreenchange", this.handle_fullscreen_change_event.bind(this)); + } + + handle_fullscreen_change_event() { + let enable_fullscreen_label = __("Full Screen"); + let exit_fullscreen_label = __("Exit Full Screen"); + + if (document.fullscreenElement) { + this.$fullscreen_btn[0].innerText = exit_fullscreen_label; + } else { + this.$fullscreen_btn[0].innerText = enable_fullscreen_label; + } + } + open_form_view() { frappe.model.sync(this.frm.doc); frappe.set_route("Form", this.frm.doc.doctype, this.frm.doc.name);