ソースを参照

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

Nathan Schneider 4 年 前
コミット
f2e2258524
2 ファイル変更19 行追加15 行削除
  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");
     }
   </script>
-  
+
+
   <!-- Stein database -->
   <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>

+ 7 - 14
_layouts/rule.html

@@ -4,15 +4,6 @@ layout: default
 # 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 -->
 <script>
   // Enter JavaScript-land!
@@ -61,7 +52,9 @@ layout: default
               name = module.getElementsByTagName("input")[0].value;
               module.getElementsByTagName("input")[0].remove();
               var customText = document.createElement("span");
-              customText.onClick = "moduleEditField(this.parentNode.id)";
+              customText.onclick = function() {
+                  moduleEditField(this.parentNode.id); 
+              }
               customText.id = "module-name";
               customText.append(name);              
               module.prepend(customText);
@@ -75,6 +68,9 @@ layout: default
       // pop it in!
       target.appendChild(module);
       // set up the editing field
+      module.children.item("module-name").onclick = function() {
+          moduleEditField(this.parentNode.id); 
+      }
       moduleEditField(module.id);
       // be sure the dummy text is gone
       if (document.contains(document.getElementById("drag-directions"))) {
@@ -594,8 +590,7 @@ layout: default
 		{% for module in site.data.modules %}
 		<span class="module" id="module-{{ module.id }}"
 			  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 }}">
             <img title="{{ module.type }}" draggable="false" class="module-logo"
                  {% if module.type == "structure" %}
@@ -768,5 +763,3 @@ layout: default
   </button>
 
 </article>
-
-