-
Notifications
You must be signed in to change notification settings - Fork 22
/
script.js
executable file
·32 lines (26 loc) · 1.09 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
jQuery(document).ready(function() {
// Start with disabled submit button
jQuery(".addnewpage :submit").prop("disabled", true);
// Then enable it when a title is entered
jQuery(".addnewpage input[name='title']").keyup(function(){
var $submit = jQuery(this).parent("form").find(":submit");
if (jQuery(this).val().length > 0) {
$submit.removeAttr("disabled");
} else {
// For when the user deletes the text
$submit.attr("disabled", "disabled");
}
}).keyup();
// Change the form's page-ID field on submit
jQuery(".addnewpage form").submit(function(e) {
// Build the new page ID and save in hidden form field
var ns = jQuery(this).find("[name='np_cat']");
var title = jQuery(this).find("input[name='title']");
var id = ns.val()+":"+title.val();
jQuery(this).find("input[name='id']").val(id);
// Clean up the form vars, just to make the resultant URL a bit nicer
ns.prop("disabled", true);
title.prop("disabled", true);
return true;
});
});