feat: full screen on pos (backport #45404) (#45418)

feat: full screen on pos (#45404)

* feat: full screen on pos

* refactor: variables for label

* fix: refactor and handled button label change

* refactor: rename enable fullscreen label

(cherry picked from commit 78c7c1c631)

Co-authored-by: Diptanil Saha <diptanil@frappe.io>
This commit is contained in:
mergify[bot]
2025-01-24 12:40:25 +05:30
committed by GitHub
parent 6c10393164
commit aca8d663dd

View File

@@ -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);