Commits

Anonymous committed 36118f2

auto slug on edit when slug field is empty

  • Participants
  • Parent commits 1c7e186

Comments (0)

Files changed (2)

File c5t/core/templates/calendar/event/edit.mak

     });
     $("#tags").val(tagNames);
   });
+/* Start auto slug*/
+$('#title').blur(function () {
+  if($('#slug').val()==''){  // auto slug only when slug field is empty
+    var auto_slug = $('#title').val().trim();
+    auto_slug = auto_slug.replace(/[^a-zA-Z0-9-\s]/g,"").toLowerCase();
+    auto_slug = auto_slug.replace(/\s/g,'-');
+    while (auto_slug.indexOf( "--" ) != -1){
+      auto_slug = auto_slug.replace( "--", "-" )
+    }
+    $('#slug').val(auto_slug);
+  }
+});
+/* End of auto slug*/
 </script>

File c5t/core/templates/page/edit.mak

   $('#fileurl').val('');
   $('#data_error').text('');
 }
+/* End of Edit attached file */
+/* Start auto slug*/
+$('#title').blur(function () {
+  if($('#slug').val()==''){  // auto slug only when slug field is empty
+    var auto_slug = $('#title').val().trim();
+    auto_slug = auto_slug.replace(/[^a-zA-Z0-9-\s]/g,"").toLowerCase();
+    auto_slug = auto_slug.replace(/\s/g,'-');
+    while (auto_slug.indexOf( "--" ) != -1){
+      auto_slug = auto_slug.replace( "--", "-" )
+    }
+    $('#slug').val(auto_slug);
+  }
+});
+/* End of auto slug*/
 </script>