From ee555f5f41d8c9f2f4439e4cadf775c97f9b91b4 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 13 Jul 2017 23:17:47 -0700 Subject: [PATCH] Also provide a display_element_map in addition to edit_element_map. --- frontends/etiquette_flask/static/common.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontends/etiquette_flask/static/common.js b/frontends/etiquette_flask/static/common.js index 23f4c6e..2ca1997 100644 --- a/frontends/etiquette_flask/static/common.js +++ b/frontends/etiquette_flask/static/common.js @@ -91,7 +91,9 @@ function Editor(elements, on_open, on_save, on_cancel) this.display_elements = []; this.edit_elements = []; + this.can_use_element_map = true; + this.display_element_map = {}; this.edit_element_map = {}; this.misc_data = {}; @@ -112,20 +114,24 @@ function Editor(elements, on_open, on_save, on_cancel) } edit_element.classList.add("editor_input"); edit_element.classList.add("hidden"); + if (display_element.dataset.editorPlaceholder !== undefined) { edit_element.placeholder = display_element.dataset.editorPlaceholder; } + if (this.can_use_element_map) { if (display_element.dataset.editorId !== undefined) { + this.display_element_map[display_element.dataset.editorId] = display_element; this.edit_element_map[display_element.dataset.editorId] = edit_element; } else { this.can_use_element_map = false; this.edit_element_map = null; + this.display_element_map = null; } } @@ -147,11 +153,11 @@ function Editor(elements, on_open, on_save, on_cancel) { if (this.can_use_element_map) { - func(self, self.edit_element_map); + func(self, self.edit_element_map, self.display_element_map); } else { - func(self, self.edit_elements); + func(self, self.edit_elements, self.display_elements); } } return bound;