Browse Source

Fixed module text field issue, new effort to fix mobile drag-and-drop (by moving code to header)

Nathan Schneider 4 years ago
parent
commit
f2e2258524
2 changed files with 19 additions and 15 deletions
  1. 12 1
      _includes/head.html
  2. 7 14
      _layouts/rule.html

+ 12 - 1
_includes/head.html

@@ -33,8 +33,19 @@
         window.location.replace("https://communityrule.info");
         window.location.replace("https://communityrule.info");
     }
     }
   </script>
   </script>
-  
+
+
   <!-- Stein database -->
   <!-- Stein database -->
   <script src="https://unpkg.com/stein-js-client"></script>
   <script src="https://unpkg.com/stein-js-client"></script>
 
 
+  <!-- enable drag/drop for mobile github.com/timruffles/mobile-drag-drop -->
+  <link rel="stylesheet" href="/assets/mobile-drag-drop/default.css">
+  <script src="/assets/mobile-drag-drop/index.min.js"></script>
+  <script>
+    (event)=> {
+        event.preventDefault();
+    }
+    window.addEventListener( 'touchmove', function() {});
+  </script>
+  
 </head>
 </head>

+ 7 - 14
_layouts/rule.html

@@ -4,15 +4,6 @@ layout: default
 # Follow comments below in various sections for further explanation
 # Follow comments below in various sections for further explanation
 ---
 ---
 
 
-<!-- enable drag/drop for mobile github.com/timruffles/mobile-drag-drop -->
-<link rel="stylesheet" href="/assets/mobile-drag-drop/default.css">
-<script src="/assets/mobile-drag-drop/index.min.js"></script>
-<script>
-  (event)=> {
-      event.preventDefault();
-  }
-</script>
-
 <!-- the main event -->
 <!-- the main event -->
 <script>
 <script>
   // Enter JavaScript-land!
   // Enter JavaScript-land!
@@ -61,7 +52,9 @@ layout: default
               name = module.getElementsByTagName("input")[0].value;
               name = module.getElementsByTagName("input")[0].value;
               module.getElementsByTagName("input")[0].remove();
               module.getElementsByTagName("input")[0].remove();
               var customText = document.createElement("span");
               var customText = document.createElement("span");
-              customText.onClick = "moduleEditField(this.parentNode.id)";
+              customText.onclick = function() {
+                  moduleEditField(this.parentNode.id); 
+              }
               customText.id = "module-name";
               customText.id = "module-name";
               customText.append(name);              
               customText.append(name);              
               module.prepend(customText);
               module.prepend(customText);
@@ -75,6 +68,9 @@ layout: default
       // pop it in!
       // pop it in!
       target.appendChild(module);
       target.appendChild(module);
       // set up the editing field
       // set up the editing field
+      module.children.item("module-name").onclick = function() {
+          moduleEditField(this.parentNode.id); 
+      }
       moduleEditField(module.id);
       moduleEditField(module.id);
       // be sure the dummy text is gone
       // be sure the dummy text is gone
       if (document.contains(document.getElementById("drag-directions"))) {
       if (document.contains(document.getElementById("drag-directions"))) {
@@ -594,8 +590,7 @@ layout: default
 		{% for module in site.data.modules %}
 		{% for module in site.data.modules %}
 		<span class="module" id="module-{{ module.id }}"
 		<span class="module" id="module-{{ module.id }}"
 			  draggable="true" ondragstart="drag(event)">
 			  draggable="true" ondragstart="drag(event)">
-		  <span id="module-name"
-                onclick="moduleEditField(this.parentNode.id)">{{ module.name }}</span>
+		  <span id="module-name">{{ module.name }}</span>
           <a target="_blank" href="{{ module.url }}">
           <a target="_blank" href="{{ module.url }}">
             <img title="{{ module.type }}" draggable="false" class="module-logo"
             <img title="{{ module.type }}" draggable="false" class="module-logo"
                  {% if module.type == "structure" %}
                  {% if module.type == "structure" %}
@@ -768,5 +763,3 @@ layout: default
   </button>
   </button>
 
 
 </article>
 </article>
-
-