post mode menu fixes

This commit is contained in:
albert
2011-10-22 01:56:36 -04:00
parent 8a5f26f3e5
commit 02c0a0f1c6
8 changed files with 47 additions and 18 deletions

View File

@@ -24,6 +24,10 @@
Danbooru.PostModeMenu.initialize_edit_form = function() {
$("#quick-edit-div").hide();
$("#quick-edit-form input[value=Cancel]").click(function(e) {
$("#quick-edit-div").hide();
e.preventDefault();
});
$("#quick-edit-form").submit(function(e) {
$.ajax({
@@ -56,13 +60,13 @@
script = prompt("Enter a tag script", script);
if (script) {
Cookie.put("tag-script", script);
Danbooru.Cookie.put("tag-script", script);
$("#mode-box select").val("apply-tag-script");
} else {
$("#mode-box select").val("view");
}
this.change();
Danbooru.PostModeMenu.change();
}
}

View File

@@ -168,7 +168,7 @@
Danbooru.Post.update_data(data);
},
error: function(data, status, xhr) {
Danbooru.j_alert("Error: " + data.reason);
Danbooru.notice("Error: " + data.reason);
}
});
}

View File

@@ -11,11 +11,11 @@
$.each(split_pred, function(i, x) {
if (x[0] === "-") {
if (tags.include(x.substr(1, 100))) {
if ($.inArray(x.substr(1, 100), tags)) {
is_true = false;
}
} else {
if (!tags.include(x)) {
if (!$.inArray(x, tags)) {
is_true = false;
}
}
@@ -27,8 +27,8 @@
Danbooru.TagScript.process = function(tags, command) {
if (command.match(/^\[if/)) {
var match = command.match(/\[if\s+(.+?)\s*,\s*(.+?)\]/)
if (this.test(tags, match[1])) {
return this.process(tags, match[2]);
if (Danbooru.TagScript.test(tags, match[1])) {
return Danbooru.TagScript.process(tags, match[2]);
} else {
return tags;
}
@@ -37,20 +37,21 @@
} else if (command[0] === "-") {
return Danbooru.reject(tags, function(x) {return x === command.substr(1, 100)});
} else {
tags.push(command)
tags.push(command);
return tags;
}
}
Danbooru.TagScript.run = function(post_id, tag_script) {
var commands = this.parse(tag_script);
var post = $("#p_" + post_id);
var old_tags = post.data("tags");
var commands = Danbooru.TagScript.parse(tag_script);
var $post = $("#post_" + post_id);
var old_tags = $post.data("tags");
$.each(commands, function(i, x) {
post.data("tags", Danbooru.TagScript.process(post.data("tags"), x));
})
var array = $post.data("tags").match(/\S+/g);
$post.data("tags", Danbooru.TagScript.process(array, x).join(" "));
});
Danbooru.Post.update(post_id, {"post[old_tags]": old_tags, "post[tags]": post.data("tags")});
Danbooru.Post.update(post_id, {"post[old_tag_string]": old_tags, "post[tag_string]": $post.data("tags")});
}
})();