[Patchew-devel] [PATCH 05/17] mods: use classes instead of ids

Paolo Bonzini posted 17 patches 2 years, 5 months ago

[Patchew-devel] [PATCH 05/17] mods: use classes instead of ids

Posted by Paolo Bonzini 2 years, 5 months ago
ids should be unique, avoid duplicating them.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 mod.py                     | 12 ++++++------
 static/js/config-editor.js | 14 +++++++-------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/mod.py b/mod.py
index 7184211..7d43715 100644
--- a/mod.py
+++ b/mod.py
@@ -260,7 +260,7 @@ TMPL_ENUM = """
           {% endif %}
         {% endfor %}
     </select>
-    <div class="form-group" id="enum-desc">
+    <div class="form-group enum-desc">
     {% for opt, desc in schema.enums.items %}
       {% if opt == value %}
 """ + TMPL_ENUM_DESC + """
@@ -268,7 +268,7 @@ TMPL_ENUM = """
     {% endfor %}
     </div>
     {% for opt, desc in schema.enums.items %}
-        <div class="hidden" id="enum-desc-{{ opt }}">
+        <div class="hidden enum-desc-{{ opt }}">
 """ + TMPL_ENUM_DESC + """
         </div>
     {% endfor %}
@@ -276,7 +276,7 @@ TMPL_ENUM = """
 """
 
 TMPL_ARRAY = """
-<input type="hidden" name="property-prefix" id="property-prefix" value="{{ prefix }}">
+<input type="hidden" name="property-prefix" class="property-prefix" value="{{ prefix }}">
 {% for schema in members %}
     {{ schema }}
 {% endfor %}
@@ -293,8 +293,8 @@ TMPL_MAP_ITEM = """
 <div class="item panel panel-default">
     <div class="panel-heading panel-toggler" onclick="patchew_toggler_onclick(this)">
         {{ item_schema.title }}
-        <strong id="item-name">{{ item.name }}</strong>
-        <input type="hidden" value="{{ prefix }}{{ item.name }}." id="prefix" />
+        <strong class="item-name">{{ item.name }}</strong>
+        <input type="hidden" value="{{ prefix }}{{ item.name }}." class="prefix" />
     </div>
     <div class="panel-body panel-collapse collapse">
         {{ item.html }}
@@ -310,7 +310,7 @@ TMPL_MAP_ITEM = """
 
 TMPL_MAP = """
 <div id="{{ schema.name }}-container">
-    <script id="item-template" type="text/x-custom-template">
+    <script class="item-template" type="text/x-custom-template">
     """ + TMPL_MAP_ITEM + """
     </script>
     <div class="items">
diff --git a/static/js/config-editor.js b/static/js/config-editor.js
index f8c9454..56d0781 100644
--- a/static/js/config-editor.js
+++ b/static/js/config-editor.js
@@ -17,7 +17,7 @@ function save_done(btn, succeeded, error) {
 }
 
 function collect_properties(btn, check_required) {
-    prefix = $(btn).parent().parent().find("#property-prefix").val();
+    prefix = $(btn).parent().parent().find(".property-prefix").val();
     properties = {};
     $(btn).parent().parent().find(".project-property").each(function () {
         if (check_required && this.required && !this.value) {
@@ -89,16 +89,16 @@ function map_add_item(btn) {
         return;
     }
     container = $(btn).parent().parent();
-    tmpl = container.find("#item-template").html();
+    tmpl = container.find(".item-template").html();
     nt = $(tmpl)
-    nt.find("#item-name").html(name);
-    old = nt.find("#property-prefix").val();
-    nt.find("#property-prefix").val(old + name + ".");
+    nt.find(".item-name").html(name);
+    old = nt.find(".property-prefix").val();
+    nt.find(".property-prefix").val(old + name + ".");
     container.find(".items").append(nt);
 }
 function map_delete_item(btn) {
-    name = $(btn).parent().parent().parent().find("#item-name").html();
-    prefix = $(btn).parent().parent().parent().find("#prefix").val();
+    name = $(btn).parent().parent().parent().find(".item-name").html();
+    prefix = $(btn).parent().parent().parent().find(".prefix").val();
     if (!window.confirm("Really delete '" + name +"'?")) {
         return;
     }
-- 
2.21.0


_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel