Fix eslint warnings.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
/* eslint no-console:0 */
|
||||
/* global require */
|
||||
|
||||
function importAll(r) {
|
||||
r.keys().forEach(r);
|
||||
@@ -36,4 +37,4 @@ export { default as Dtext } from '../src/javascripts/dtext.js';
|
||||
export { default as Note } from '../src/javascripts/notes.js';
|
||||
export { default as PostModeMenu } from '../src/javascripts/post_mode_menu.js';
|
||||
export { default as Utility } from '../src/javascripts/utility.js';
|
||||
export { default as Ugoira } from '../src/javascripts/ugoira.js';
|
||||
export { default as Ugoira } from '../src/javascripts/ugoira.js';
|
||||
|
||||
@@ -63,15 +63,16 @@ ArtistCommentary.initialize_edit_commentary_dialog = function() {
|
||||
}
|
||||
|
||||
ArtistCommentary.fetch_commentary = function() {
|
||||
var commentary = "";
|
||||
Utility.notice("Fetching artist commentary...");
|
||||
|
||||
var type = $('#fetch-commentary select[name="commentary_source_type"]').val();
|
||||
if (type === "Source") {
|
||||
var source = $('#fetch-commentary input[name="commentary_source"]').val();
|
||||
var commentary = ArtistCommentary.from_source(source);
|
||||
commentary = ArtistCommentary.from_source(source);
|
||||
} else if (type === "Post") {
|
||||
var id = $('#fetch-commentary input[name="commentary_post_id"]').val();
|
||||
var commentary = ArtistCommentary.from_post_id(id);
|
||||
commentary = ArtistCommentary.from_post_id(id);
|
||||
}
|
||||
|
||||
commentary.then(ArtistCommentary.fill_commentary).then(function (success) {
|
||||
@@ -120,13 +121,13 @@ ArtistCommentary.merge_commentaries = function(description, commentary) {
|
||||
var normalized_source = $("#image-container").data().normalizedSource;
|
||||
|
||||
if ((commentary.original_description && description) &&
|
||||
(commentary.original_description != description)) {
|
||||
(commentary.original_description !== description)) {
|
||||
return description
|
||||
+ "\n\n[tn]\nSource: " + normalized_source + "\n[/tn]"
|
||||
+ "\n\nh6. " + (commentary.original_title || "Untitled")
|
||||
+ "\n\n" + commentary.original_description
|
||||
+ "\n\n[tn]\nSource: " + commentary.source + "\n[/tn]";
|
||||
} else if (commentary.source != post_source) {
|
||||
} else if (commentary.source !== post_source) {
|
||||
return commentary.original_description + "\n\n[tn]\nSource: " + commentary.source + "\n[/tn]";
|
||||
} else {
|
||||
return commentary.original_description || description;
|
||||
|
||||
@@ -14,10 +14,10 @@ Artist.initialize_check_name = function() {
|
||||
if ($("#artist_name").val().length > 0) {
|
||||
$("#check-name-result").html("");
|
||||
|
||||
$.getJSON("/artists?search[name]=" + escape($("#artist_name").val()), function(data) {
|
||||
if (data.length === 0) {
|
||||
$.getJSON("/wiki_pages/" + escape($("#artist_name").val()), function(data) {
|
||||
if (data !== null) {
|
||||
$.getJSON("/artists?search[name]=" + escape($("#artist_name").val()), function(artists) {
|
||||
if (artists.length === 0) {
|
||||
$.getJSON("/wiki_pages/" + escape($("#artist_name").val()), function(wiki_pages) {
|
||||
if (wiki_pages !== null) {
|
||||
$("#check-name-result").html("<a href='/wiki_pages/" + escape($("#artist_name").val()) + "'>A wiki page with this name already exists</a>. You must either move the wiki page or pick another artist name.")
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3,9 +3,12 @@ import SavedSearch from './saved_searches'
|
||||
|
||||
let Autocomplete = {};
|
||||
|
||||
Autocomplete.AUTOCOMPLETE_VERSION = 1;
|
||||
Autocomplete.PREFIXES = /^(-|~|<%= TagCategory.mapping.keys.map {|category| category + ':'}.join('|') %>)(.*)$/i;
|
||||
Autocomplete.METATAGS = /^(<%= Tag::METATAGS %>):(.*)$/i;
|
||||
Autocomplete.METATAGS = <%= Tag::METATAGS.to_json.html_safe %>;
|
||||
Autocomplete.TAG_CATEGORIES = <%= TagCategory.mapping.to_json.html_safe %>;
|
||||
|
||||
Autocomplete.TAG_PREFIXES = "-|~|" + Object.keys(Autocomplete.TAG_CATEGORIES).map(category => category + ":").join("|");
|
||||
Autocomplete.TAG_PREFIXES_REGEX = new RegExp("^(" + Autocomplete.TAG_PREFIXES + ")(.*)$", "i");
|
||||
Autocomplete.METATAGS_REGEX = new RegExp("^(" + Autocomplete.METATAGS + "):(.*)$", "i");
|
||||
|
||||
Autocomplete.initialize_all = function() {
|
||||
if (Utility.meta("enable-auto-complete") === "true") {
|
||||
@@ -42,16 +45,15 @@ Autocomplete.initialize_mention_autocomplete = function($fields) {
|
||||
},
|
||||
source: function(req, resp) {
|
||||
var cursor = this.element.get(0).selectionStart;
|
||||
var i;
|
||||
var name = null;
|
||||
|
||||
for (i=cursor; i>=1; --i) {
|
||||
if (req.term[i-1] === " ") {
|
||||
for (var i = cursor; i >= 1; --i) {
|
||||
if (req.term[i - 1] === " ") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.term[i-1] === "@") {
|
||||
if (i == 1 || /[ \r\n]/.test(req.term[i-2])) {
|
||||
if (req.term[i - 1] === "@") {
|
||||
if (i === 1 || /[ \r\n]/.test(req.term[i - 2])) {
|
||||
name = req.term.substring(i, cursor);
|
||||
break;
|
||||
} else {
|
||||
@@ -63,8 +65,6 @@ Autocomplete.initialize_mention_autocomplete = function($fields) {
|
||||
if (name) {
|
||||
Autocomplete.user_source(name, resp, "@");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -99,7 +99,7 @@ Autocomplete.initialize_tag_autocomplete = function() {
|
||||
return;
|
||||
}
|
||||
|
||||
switch(metatag) {
|
||||
switch (metatag) {
|
||||
case "md5":
|
||||
case "width":
|
||||
case "height":
|
||||
@@ -117,7 +117,7 @@ Autocomplete.initialize_tag_autocomplete = function() {
|
||||
case "pixiv_id":
|
||||
case "pixiv":
|
||||
<% TagCategory.short_name_list.each do |category| %>
|
||||
case "<%= category %>tags":
|
||||
case "<%= category %>tags": // eslint-disable-line
|
||||
<% end %>
|
||||
resp([]);
|
||||
return;
|
||||
@@ -194,7 +194,7 @@ Autocomplete.initialize_artist_autocomplete = function($fields) {
|
||||
type: "tag",
|
||||
label: artist.name.replace(/_/g, " "),
|
||||
value: artist.name,
|
||||
category: <%= Tag.categories.artist %>,
|
||||
category: Autocomplete.TAG_CATEGORIES.artist,
|
||||
};
|
||||
}));
|
||||
}
|
||||
@@ -250,9 +250,7 @@ Autocomplete.normal_source = function(term, resp) {
|
||||
return window.Danbooru.Autocomplete.normal_source(term, resp);
|
||||
}
|
||||
|
||||
var key = "ac-" + term.replace(/\./g,'\uFFFF');
|
||||
|
||||
$.ajax({
|
||||
return $.ajax({
|
||||
url: "/tags/autocomplete.json",
|
||||
data: {
|
||||
"search[name_matches]": term,
|
||||
@@ -288,12 +286,14 @@ Autocomplete.parse_query = function(text, caret) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (match = term.match(Autocomplete.PREFIXES)) {
|
||||
match = term.match(Autocomplete.TAG_PREFIXES_REGEX);
|
||||
if (match) {
|
||||
metatag = match[1].toLowerCase();
|
||||
term = match[2];
|
||||
}
|
||||
|
||||
if (match = term.match(Autocomplete.METATAGS)) {
|
||||
|
||||
match = term.match(Autocomplete.METATAGS_REGEX);
|
||||
if (match) {
|
||||
metatag = match[1].toLowerCase();
|
||||
term = match[2];
|
||||
}
|
||||
@@ -307,8 +307,7 @@ Autocomplete.insert_completion = function(input, completion) {
|
||||
var before_caret_text = input.value.substring(0, input.selectionStart).trim();
|
||||
var after_caret_text = input.value.substring(input.selectionStart).trim();
|
||||
|
||||
var prefixes = "-|~|" + "<%= TagCategory.mapping.keys.map {|category| category + ':'}.join('|') %>";
|
||||
var regexp = new RegExp("(" + prefixes + ")?\\S+$", "g");
|
||||
var regexp = new RegExp("(" + Autocomplete.TAG_PREFIXES + ")?\\S+$", "g");
|
||||
before_caret_text = before_caret_text.replace(regexp, "$1") + completion + " ";
|
||||
|
||||
input.value = before_caret_text + after_caret_text;
|
||||
@@ -357,12 +356,12 @@ Autocomplete.render_item = function(list, item) {
|
||||
}
|
||||
|
||||
if (item.post_count !== undefined) {
|
||||
var count;
|
||||
if (item.post_count >= 1000) {
|
||||
count = Math.floor(item.post_count / 1000) + "k";
|
||||
} else {
|
||||
count = item.post_count;
|
||||
var count = item.post_count;
|
||||
|
||||
if (count >= 1000) {
|
||||
count = Math.floor(count / 1000) + "k";
|
||||
}
|
||||
|
||||
var $post_count = $("<span/>").addClass("post-count").css("float", "right").text(count);
|
||||
$link.append($post_count);
|
||||
}
|
||||
@@ -440,7 +439,7 @@ Autocomplete.user_source = function(term, resp, metatag) {
|
||||
return window.Danbooru.Autocomplete.user_source(term, resp, metatag);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
return $.ajax({
|
||||
url: "/users.json",
|
||||
data: {
|
||||
"search[order]": "post_upload_count",
|
||||
@@ -450,8 +449,8 @@ Autocomplete.user_source = function(term, resp, metatag) {
|
||||
},
|
||||
method: "get",
|
||||
success: function(data) {
|
||||
var prefix;
|
||||
var display_name;
|
||||
var prefix = "";
|
||||
var display_name = null;
|
||||
|
||||
if (metatag === "@") {
|
||||
prefix = "@";
|
||||
@@ -478,7 +477,7 @@ Autocomplete.pool_source = function(term, resp, metatag) {
|
||||
return window.Danbooru.Autocomplete.pool_source(term, resp, metatag);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
return $.ajax({
|
||||
url: "/pools.json",
|
||||
data: {
|
||||
"search[order]": "post_count",
|
||||
@@ -505,7 +504,7 @@ Autocomplete.favorite_group_source = function(term, resp, metatag) {
|
||||
return window.Danbooru.Autocomplete.favorite_group_source(term, resp, metatag);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
return $.ajax({
|
||||
url: "/favorite_groups.json",
|
||||
data: {
|
||||
"search[name_matches]": term,
|
||||
|
||||
@@ -112,7 +112,7 @@ Blacklist.apply = function() {
|
||||
|
||||
$.each(this.posts(), function(i, post) {
|
||||
var post_count = 0;
|
||||
$.each(Blacklist.entries, function(i, entry) {
|
||||
$.each(Blacklist.entries, function(j, entry) {
|
||||
if (Blacklist.post_match(post, entry)) {
|
||||
entry.hits += 1;
|
||||
count += 1;
|
||||
@@ -192,7 +192,7 @@ Blacklist.initialize_all = function() {
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
if ($("#blacklist-box").length == 0) {
|
||||
if ($("#blacklist-box").length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ Comment.quote = function(e) {
|
||||
var $link = $(e.target);
|
||||
var $div = $link.closest("div.comments-for-post").find(".new-comment");
|
||||
var $textarea = $div.find("textarea");
|
||||
var msg = data["quoted_response"];
|
||||
var msg = data.quoted_response;
|
||||
if ($textarea.val().length > 0) {
|
||||
msg = $textarea.val() + "\n\n" + msg;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,6 @@ $(function() {
|
||||
});
|
||||
});
|
||||
|
||||
global.submitInvisibleRecaptchaForm = function () {
|
||||
window.submitInvisibleRecaptchaForm = function () {
|
||||
document.getElementById("signup-form").submit();
|
||||
}
|
||||
|
||||
@@ -31,11 +31,11 @@ Cookie.raw_get = function(name) {
|
||||
for (var i = 0; i < ca.length; ++i) {
|
||||
var c = ca[i];
|
||||
|
||||
while (c.charAt(0) == " ") {
|
||||
while (c.charAt(0) === " ") {
|
||||
c = c.substring(1, c.length);
|
||||
}
|
||||
|
||||
if (c.indexOf(nameEq) == 0) {
|
||||
if (c.indexOf(nameEq) === 0) {
|
||||
return c.substring(nameEq.length, c.length);
|
||||
}
|
||||
}
|
||||
@@ -56,9 +56,9 @@ Cookie.unescape = function(val) {
|
||||
}
|
||||
|
||||
Cookie.initialize = function() {
|
||||
if (this.get("hide-upgrade-account") != "1") {
|
||||
$("#upgrade-account").show();
|
||||
}
|
||||
if (this.get("hide-upgrade-account") !== "1") {
|
||||
$("#upgrade-account").show();
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
@@ -21,7 +21,7 @@ FavoriteGroup.initialize_add_to_favgroup_dialog = function() {
|
||||
});
|
||||
|
||||
var open_favgroup_dialog = function(e) {
|
||||
if (Utility.meta("current-user-id") == "") { // anonymous
|
||||
if (Utility.meta("current-user-id") === "") { // anonymous
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@ Favorite.initialize_all = function() {
|
||||
|
||||
Favorite.hide_or_show_add_to_favorites_link = function() {
|
||||
var current_user_id = Utility.meta("current-user-id");
|
||||
if (current_user_id == "") {
|
||||
if (current_user_id === "") {
|
||||
$("#add-to-favorites").hide();
|
||||
$("#remove-from-favorites").hide();
|
||||
$("#add-fav-button").hide();
|
||||
$("#remove-fav-button").hide();
|
||||
return;
|
||||
}
|
||||
if ($("#image-container").length && $("#image-container").data("is-favorited") == true) {
|
||||
if ($("#image-container").length && $("#image-container").data("is-favorited") === true) {
|
||||
$("#add-to-favorites").hide();
|
||||
$("#add-fav-button").hide();
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,7 @@ import Utility from './utility'
|
||||
let ForumPost = {};
|
||||
|
||||
ForumPost.initialize_all = function() {
|
||||
if ($("#c-forum-topics #a-show,#c-forum-posts #a-show").length) {;
|
||||
if ($("#c-forum-topics #a-show,#c-forum-posts #a-show").length) {
|
||||
this.initialize_edit_links();
|
||||
|
||||
Utility.keydown("e", "edit", function(e) {
|
||||
@@ -44,4 +44,4 @@ $(document).ready(function() {
|
||||
ForumPost.initialize_all();
|
||||
});
|
||||
|
||||
export default ForumPost
|
||||
export default ForumPost
|
||||
|
||||
@@ -26,4 +26,4 @@ $(document).ready(function() {
|
||||
JanitorTrials.initialize_all();
|
||||
});
|
||||
|
||||
export default JanitorTrials
|
||||
export default JanitorTrials
|
||||
|
||||
@@ -66,4 +66,4 @@ $(function() {
|
||||
}
|
||||
});
|
||||
|
||||
export default ModQueue
|
||||
export default ModQueue
|
||||
|
||||
@@ -5,7 +5,7 @@ let NewsUpdate = {};
|
||||
NewsUpdate.initialize = function() {
|
||||
var key = $("#news-updates").data("id");
|
||||
|
||||
if (Cookie.get("news-ticker") == key) {
|
||||
if (Cookie.get("news-ticker") === key) {
|
||||
$("#news-updates").hide();
|
||||
} else {
|
||||
$("#news-updates").show();
|
||||
@@ -27,4 +27,4 @@ $(function() {
|
||||
NewsUpdate.initialize();
|
||||
});
|
||||
|
||||
export default NewsUpdate
|
||||
export default NewsUpdate
|
||||
|
||||
@@ -113,18 +113,18 @@ let Note = {
|
||||
return;
|
||||
}
|
||||
|
||||
var $this = $(this);
|
||||
var $note_box_inner = $(e.currentTarget);
|
||||
|
||||
if (e.type === "mouseover") {
|
||||
Note.Body.show($note_box_inner.data("id"));
|
||||
if (Note.editing) {
|
||||
var $this = $(this);
|
||||
$this.resizable("enable");
|
||||
$this.draggable("enable");
|
||||
}
|
||||
} else if (e.type === "mouseout") {
|
||||
Note.Body.hide($note_box_inner.data("id"));
|
||||
if (Note.editing) {
|
||||
var $this = $(this);
|
||||
$this.resizable("disable");
|
||||
$this.draggable("disable");
|
||||
}
|
||||
@@ -191,7 +191,7 @@ let Note = {
|
||||
return;
|
||||
}
|
||||
// Hide notes while rescaling, to prevent unnecessary reflowing
|
||||
var was_visible = container.style.display != 'none';
|
||||
var was_visible = container.style.display !== 'none';
|
||||
if (was_visible) {
|
||||
container.style.display = 'none';
|
||||
}
|
||||
@@ -239,14 +239,6 @@ let Note = {
|
||||
var $image = $("#image");
|
||||
var doc_width = $image.offset().left + $image.width();
|
||||
|
||||
/*while ($note_body[0].clientHeight < $note_body[0].scrollHeight) {
|
||||
$note_body.css({height: $note_body.height() + 5});
|
||||
}
|
||||
|
||||
while ($note_body[0].clientWidth < $note_body[0].scrollWidth) {
|
||||
$note_body.css({width: $note_body.width() + 5});
|
||||
}*/
|
||||
|
||||
if ($note_body.offset().left + $note_body.width() > doc_width) {
|
||||
$note_body.css({
|
||||
left: $note_body.position().left - 10 - ($note_body.offset().left + $note_body.width() - doc_width)
|
||||
@@ -286,10 +278,13 @@ let Note = {
|
||||
var golden_ratio = 1.6180339887;
|
||||
var last = 0;
|
||||
var x = 0;
|
||||
var lo = 0;
|
||||
var hi = 0;
|
||||
|
||||
if ((w / h) < golden_ratio) {
|
||||
var lo = 140;
|
||||
var hi = 400;
|
||||
lo = 140;
|
||||
hi = 400;
|
||||
|
||||
do {
|
||||
last = w;
|
||||
x = (lo + hi) / 2;
|
||||
@@ -304,8 +299,8 @@ let Note = {
|
||||
}
|
||||
} while ((lo < hi) && (w > last));
|
||||
} else if ($note_body[0].scrollWidth <= $note_body.width()) {
|
||||
var lo = 20;
|
||||
var hi = w;
|
||||
lo = 20;
|
||||
hi = w;
|
||||
|
||||
do {
|
||||
x = (lo + hi) / 2;
|
||||
@@ -466,14 +461,16 @@ let Note = {
|
||||
},
|
||||
|
||||
success_handler: function(data, status, xhr) {
|
||||
var $note_box = null;
|
||||
|
||||
if (data.html_id) { // new note
|
||||
var $note_body = Note.Body.find(data.html_id);
|
||||
var $note_box = Note.Box.find(data.html_id);
|
||||
$note_box = Note.Box.find(data.html_id);
|
||||
$note_body.data("id", String(data.id)).attr("data-id", data.id);
|
||||
$note_box.data("id", String(data.id)).attr("data-id", data.id);
|
||||
$note_box.find(".note-box-inner-border").removeClass("unsaved");
|
||||
} else {
|
||||
var $note_box = Note.Box.find(data.id);
|
||||
$note_box = Note.Box.find(data.id);
|
||||
$note_box.find(".note-box-inner-border").removeClass("unsaved");
|
||||
}
|
||||
},
|
||||
@@ -574,7 +571,7 @@ let Note = {
|
||||
start: function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (Utility.meta("current-user-id") == "") {
|
||||
if (Utility.meta("current-user-id") === "") {
|
||||
Utility.notice("You must be logged in to edit notes");
|
||||
return;
|
||||
}
|
||||
@@ -654,7 +651,7 @@ let Note = {
|
||||
var offset = $image.offset();
|
||||
var limitX1 = $image.width() - Note.TranslationMode.Drag.dragStartX + offset.left - 1;
|
||||
var limitX2 = offset.left - Note.TranslationMode.Drag.dragStartX;
|
||||
var limitY1 = $image.height()- Note.TranslationMode.Drag.dragStartY + offset.top - 1;
|
||||
var limitY1 = $image.height() - Note.TranslationMode.Drag.dragStartY + offset.top - 1;
|
||||
var limitY2 = offset.top - Note.TranslationMode.Drag.dragStartY;
|
||||
|
||||
if (Note.TranslationMode.Drag.dragDistanceX > limitX1) {
|
||||
@@ -709,8 +706,8 @@ let Note = {
|
||||
$(window).off("mousemove");
|
||||
|
||||
if (Note.TranslationMode.Drag.dragging) {
|
||||
$('#note-preview').css({display:'none'});
|
||||
Note.TranslationMode.create_note(e, Note.TranslationMode.Drag.x, Note.TranslationMode.Drag.y, Note.TranslationMode.Drag.w-1, Note.TranslationMode.Drag.h-1);
|
||||
$('#note-preview').css({ display: 'none' });
|
||||
Note.TranslationMode.create_note(e, Note.TranslationMode.Drag.x, Note.TranslationMode.Drag.y, Note.TranslationMode.Drag.w - 1, Note.TranslationMode.Drag.h - 1);
|
||||
Note.TranslationMode.Drag.dragging = false; /* border of the note is pixel-perfect on the preview border */
|
||||
} else { /* no dragging -> toggle display of notes */
|
||||
Note.Box.toggle_all();
|
||||
@@ -796,7 +793,7 @@ let Note = {
|
||||
},
|
||||
|
||||
initialize_all: function() {
|
||||
if ($("#c-posts #a-show #image").length == 0 || $("video#image").length) {
|
||||
if ($("#c-posts #a-show #image").length === 0 || $("video#image").length) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -809,7 +806,7 @@ let Note = {
|
||||
},
|
||||
|
||||
initialize_shortcuts: function() {
|
||||
if ($("#note-locked-notice").length == 0) {
|
||||
if ($("#note-locked-notice").length === 0) {
|
||||
$("#translate").click(Note.TranslationMode.toggle);
|
||||
Utility.keydown("n", "translation_mode", Note.TranslationMode.toggle);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ Pool.initialize_simple_edit = function() {
|
||||
$.ajax({
|
||||
type: "put",
|
||||
url: e.target.action,
|
||||
data: $("#sortable").sortable("serialize") + "&" + $(e.target).serialize()
|
||||
data: $("#sortable").sortable("serialize") + "&" + $(e.target).serialize()
|
||||
});
|
||||
e.preventDefault();
|
||||
});
|
||||
@@ -62,4 +62,4 @@ $(document).ready(function() {
|
||||
Pool.initialize_all();
|
||||
});
|
||||
|
||||
export default Pool
|
||||
export default Pool
|
||||
|
||||
@@ -22,20 +22,19 @@ PostModeMenu.initialize_shortcuts = function() {
|
||||
}
|
||||
|
||||
PostModeMenu.show_notice = function(i) {
|
||||
Utility.notice("Switched to tag script #" + i + ". To switch tag scripts, use the number keys.");
|
||||
Utility.notice("Switched to tag script #" + i + ". To switch tag scripts, use the number keys.");
|
||||
}
|
||||
|
||||
PostModeMenu.change_tag_script = function(e) {
|
||||
if ($("#mode-box select").val() === "tag-script") {
|
||||
var old_tag_script_id = Cookie.get("current_tag_script_id") || "1";
|
||||
var old_tag_script = $("#tag-script-field").val();
|
||||
|
||||
|
||||
var new_tag_script_id = String.fromCharCode(e.which);
|
||||
var new_tag_script = Cookie.get("tag-script-" + new_tag_script_id);
|
||||
|
||||
|
||||
$("#tag-script-field").val(new_tag_script);
|
||||
Cookie.put("current_tag_script_id", new_tag_script_id);
|
||||
if (old_tag_script_id != new_tag_script_id) {
|
||||
if (old_tag_script_id !== new_tag_script_id) {
|
||||
PostModeMenu.show_notice(new_tag_script_id);
|
||||
}
|
||||
|
||||
@@ -145,7 +144,7 @@ PostModeMenu.open_edit = function(post_id) {
|
||||
$("#post_tag_string").val($post.data("tags") + " ").focus().selectEnd();
|
||||
|
||||
/* Set height of tag edit box to fit content. */
|
||||
$("#post_tag_string").height(80); // min height: 80px.
|
||||
$("#post_tag_string").height(80); // min height: 80px.
|
||||
var padding = $("#post_tag_string").innerHeight() - $("#post_tag_string").height();
|
||||
var height = $("#post_tag_string").prop("scrollHeight") - padding;
|
||||
$("#post_tag_string").height(height);
|
||||
|
||||
@@ -35,4 +35,4 @@ $(document).ready(function() {
|
||||
PostPopular.initialize_all();
|
||||
});
|
||||
|
||||
export default PostPopular
|
||||
export default PostPopular
|
||||
|
||||
@@ -133,4 +133,4 @@ PostTooltip.on_disable_tooltips = function (event) {
|
||||
|
||||
$(document).ready(PostTooltip.initialize);
|
||||
|
||||
export default PostTooltip
|
||||
export default PostTooltip
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* global addthis */
|
||||
|
||||
import Utility from './utility'
|
||||
import Hammer from 'hammerjs'
|
||||
import RelatedTag from './related_tag.js.erb'
|
||||
@@ -79,7 +81,7 @@ Post.initialize_gestures = function() {
|
||||
}
|
||||
}
|
||||
|
||||
Post.initialize_edit_dialog = function(e) {
|
||||
Post.initialize_edit_dialog = function() {
|
||||
$("#open-edit-dialog").button().show().click(function(e) {
|
||||
$(window).scrollTop($("#image").offset().top);
|
||||
Post.open_edit_dialog();
|
||||
@@ -104,11 +106,11 @@ Post.open_edit_dialog = function() {
|
||||
dialog.dialog({
|
||||
title: "Edit tags",
|
||||
width: $(window).width() * 0.6,
|
||||
position: {
|
||||
my: "right",
|
||||
at: "right-20",
|
||||
of: window
|
||||
},
|
||||
position: {
|
||||
my: "right",
|
||||
at: "right-20",
|
||||
of: window
|
||||
},
|
||||
drag: function(e, ui) {
|
||||
if (Utility.meta("enable-auto-complete") === "true") {
|
||||
$tag_string.data("uiAutocomplete").close();
|
||||
@@ -128,15 +130,15 @@ Post.open_edit_dialog = function() {
|
||||
if (dialog_widget.css("position") === "absolute") {
|
||||
pos.left -= $(window).scrollLeft();
|
||||
pos.top -= $(window).scrollTop();
|
||||
dialog_widget.offset(pos).css({position:"fixed"});
|
||||
dialog.dialog("option", "resize", function() { dialog_widget.css({position:"fixed"}); });
|
||||
dialog_widget.offset(pos).css({ position: "fixed" });
|
||||
dialog.dialog("option", "resize", function() { dialog_widget.css({ position: "fixed" }); });
|
||||
|
||||
pin_button.button("option", "icons", {primary: "ui-icon-pin-s"});
|
||||
} else {
|
||||
pos.left += $(window).scrollLeft();
|
||||
pos.top += $(window).scrollTop();
|
||||
dialog_widget.offset(pos).css({position:"absolute"});
|
||||
dialog.dialog("option", "resize", function() {});
|
||||
dialog_widget.offset(pos).css({ position: "absolute" });
|
||||
dialog.dialog("option", "resize", function() { /* do nothing */ });
|
||||
|
||||
pin_button.button("option", "icons", {primary: "ui-icon-pin-w"});
|
||||
}
|
||||
@@ -144,8 +146,7 @@ Post.open_edit_dialog = function() {
|
||||
|
||||
dialog.parent().mouseout(function(e) {
|
||||
dialog.parent().css({"opacity": 0.6, "transition": "opacity .2s ease"});
|
||||
})
|
||||
.mouseover(function(e) {
|
||||
}).mouseover(function(e) {
|
||||
dialog.parent().css({"opacity": 1});
|
||||
});
|
||||
|
||||
@@ -182,15 +183,17 @@ Post.swipe_prev = function(e) {
|
||||
}
|
||||
|
||||
Post.nav_prev = function(e) {
|
||||
var href = "";
|
||||
|
||||
if ($("#search-seq-nav").length) {
|
||||
var href = $("#search-seq-nav a[rel~=prev]").attr("href");
|
||||
href = $("#search-seq-nav a[rel~=prev]").attr("href");
|
||||
if (href) {
|
||||
location.href = href;
|
||||
}
|
||||
} else if ($(".paginator a[rel~=prev]").length) {
|
||||
location.href = $("a[rel~=prev]").attr("href");
|
||||
} else {
|
||||
var href = $("#pool-nav a.active[rel~=prev], #favgroup-nav a.active[rel~=prev]").attr("href");
|
||||
href = $("#pool-nav a.active[rel~=prev], #favgroup-nav a.active[rel~=prev]").attr("href");
|
||||
if (href) {
|
||||
location.href = href;
|
||||
}
|
||||
@@ -200,13 +203,15 @@ Post.nav_prev = function(e) {
|
||||
}
|
||||
|
||||
Post.nav_next = function(e) {
|
||||
var href = "";
|
||||
|
||||
if ($("#search-seq-nav").length) {
|
||||
var href = $("#search-seq-nav a[rel~=next]").attr("href");
|
||||
href = $("#search-seq-nav a[rel~=next]").attr("href");
|
||||
location.href = href;
|
||||
} else if ($(".paginator a[rel~=next]").length) {
|
||||
location.href = $(".paginator a[rel~=next]").attr("href");
|
||||
} else {
|
||||
var href = $("#pool-nav a.active[rel~=next], #favgroup-nav a.active[rel~=next]").attr("href");
|
||||
href = $("#pool-nav a.active[rel~=next], #favgroup-nav a.active[rel~=next]").attr("href");
|
||||
if (href) {
|
||||
location.href = href;
|
||||
}
|
||||
@@ -301,8 +306,7 @@ Post.toggle_relationship_preview = function(preview, preview_link) {
|
||||
if (preview.is(":visible")) {
|
||||
preview_link.html("« hide");
|
||||
Cookie.put("show-relationship-previews", "1");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
preview_link.html("show »");
|
||||
Cookie.put("show-relationship-previews", "0");
|
||||
}
|
||||
@@ -343,7 +347,7 @@ Post.expand_image = function(e) {
|
||||
$image.attr("src", $link.attr("href"));
|
||||
$image.css("opacity", "0.25");
|
||||
$image.width($image.data("original-width"));
|
||||
$image.height($image.data("original-height"));
|
||||
$image.height($image.data("original-height"));
|
||||
$image.on("load", function() {
|
||||
$image.css("opacity", "1");
|
||||
$notice.hide();
|
||||
@@ -384,14 +388,16 @@ Post.initialize_post_image_resize_links = function() {
|
||||
}
|
||||
|
||||
Post.resize_image_to_window = function($img) {
|
||||
var sidebar_width = 0;
|
||||
var client_width = 0;
|
||||
|
||||
if (($img.data("scale-factor") === 1) || ($img.data("scale-factor") === undefined)) {
|
||||
if ($(window).width() > 660) {
|
||||
var sidebar_width = $("#sidebar").width() || 0;
|
||||
var client_width = $(window).width() - sidebar_width - 75;
|
||||
sidebar_width = $("#sidebar").width() || 0;
|
||||
client_width = $(window).width() - sidebar_width - 75;
|
||||
} else {
|
||||
var client_width = $(window).width() - 2;
|
||||
client_width = $(window).width() - 2;
|
||||
}
|
||||
var client_height = $(window).height();
|
||||
|
||||
if ($img.width() > client_width) {
|
||||
var ratio = client_width / $img.data("original-width");
|
||||
@@ -473,7 +479,7 @@ Post.initialize_post_sections = function() {
|
||||
$("#share").show();
|
||||
addthis.init();
|
||||
$("#recommended").hide();
|
||||
}
|
||||
}
|
||||
|
||||
$("#post-sections li").removeClass("active");
|
||||
$(e.target).parent("li").addClass("active");
|
||||
@@ -525,7 +531,7 @@ Post.vote = function(score, id) {
|
||||
$(window).trigger("danbooru:notice", "Voting...");
|
||||
|
||||
$.post("/posts/" + id + "/votes.js", {
|
||||
score: score
|
||||
score: score
|
||||
});
|
||||
}
|
||||
|
||||
@@ -583,12 +589,10 @@ Post.approve = function(post_id) {
|
||||
Post.favorite = function (e) {
|
||||
if ($("#add-to-favorites").is(":visible")) {
|
||||
$("#add-to-favorites")[0].click();
|
||||
} else if (Utility.meta("current-user-id") === "") {
|
||||
$(window).trigger("danbooru:notice", "You must be logged in to favorite posts");
|
||||
} else {
|
||||
if (Utility.meta("current-user-id") == "") {
|
||||
$(window).trigger("danbooru:notice", "You must be logged in to favorite posts");
|
||||
} else {
|
||||
$(window).trigger("danbooru:notice", "You have already favorited this post");
|
||||
}
|
||||
$(window).trigger("danbooru:notice", "You have already favorited this post");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -690,4 +694,4 @@ $(document).ready(function() {
|
||||
Post.initialize_all();
|
||||
});
|
||||
|
||||
export default Post
|
||||
export default Post
|
||||
|
||||
@@ -15,18 +15,14 @@ RelatedTag.initialize_all = function() {
|
||||
RelatedTag.initialize_buttons = function() {
|
||||
this.common_bind("#related-tags-button", "");
|
||||
<% TagCategory.related_button_list.each do |category| %>
|
||||
RelatedTag.common_bind("#related-<%= category %>-button", "<%= category %>");
|
||||
RelatedTag.common_bind("#related-<%= category %>-button", "<%= category %>"); // eslint-disable-line indent
|
||||
<% end %>
|
||||
$("#find-artist-button").click(RelatedTag.find_artist);
|
||||
}
|
||||
|
||||
RelatedTag.tags_include = function(name) {
|
||||
var current = $("#upload_tag_string,#post_tag_string").val().toLowerCase().match(/\S+/g) || [];
|
||||
if ($.inArray(name.toLowerCase(), current) > -1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return $.inArray(name.toLowerCase(), current) > -1;
|
||||
}
|
||||
|
||||
RelatedTag.common_bind = function(button_name, category) {
|
||||
@@ -89,7 +85,7 @@ RelatedTag.current_tag = function() {
|
||||
}
|
||||
|
||||
b++;
|
||||
return string.slice(a, b);
|
||||
return string.slice(a, b);
|
||||
}
|
||||
|
||||
RelatedTag.process_response = function(data) {
|
||||
@@ -130,7 +126,7 @@ RelatedTag.build_all = function() {
|
||||
if (wiki_page_tags.length) {
|
||||
$dest.append(RelatedTag.build_html("wiki:" + query, wiki_page_tags, "wiki"));
|
||||
}
|
||||
$.each(other_wikis, function(i,wiki) {
|
||||
$.each(other_wikis, function(i, wiki) {
|
||||
$dest.append(RelatedTag.build_html("wiki:" + wiki.title, wiki.wiki_page_tags, "otherwiki" + i.toString()));
|
||||
});
|
||||
if (RelatedTag.recent_artists) {
|
||||
@@ -156,7 +152,7 @@ RelatedTag.build_all = function() {
|
||||
tags.push([artist.name, 1]);
|
||||
});
|
||||
}
|
||||
$dest.append(RelatedTag.build_html("artist", tags, "artist", true));
|
||||
$dest.append(RelatedTag.build_html("artist", tags, "artist", true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,9 +227,10 @@ RelatedTag.build_html = function(query, related_tags, name, is_wide_column) {
|
||||
);
|
||||
} else {
|
||||
var text = tag[0];
|
||||
var desc = "";
|
||||
if (text.match(/^ -http/)) {
|
||||
text = text.substring(1, 1000);
|
||||
var desc = text.replace(/^-https?:\/\//, "");
|
||||
desc = text.replace(/^-https?:\/\//, "");
|
||||
if (desc.length > 30) {
|
||||
desc = desc.substring(0, 30) + "...";
|
||||
}
|
||||
@@ -244,7 +241,7 @@ RelatedTag.build_html = function(query, related_tags, name, is_wide_column) {
|
||||
);
|
||||
} else if (text.match(/^ http/)) {
|
||||
text = text.substring(1, 1000);
|
||||
var desc = text.replace(/^https?:\/\//, "");
|
||||
desc = text.replace(/^https?:\/\//, "");
|
||||
if (desc.length > 30) {
|
||||
desc = desc.substring(0, 30) + "...";
|
||||
}
|
||||
@@ -284,7 +281,7 @@ RelatedTag.toggle_tag = function(e) {
|
||||
RelatedTag.process_artist(RelatedTag.recent_artist);
|
||||
}
|
||||
|
||||
//The timeout is needed on Chrome since it will clobber the field attribute otherwise
|
||||
// The timeout is needed on Chrome since it will clobber the field attribute otherwise
|
||||
setTimeout(function () { $field.prop('selectionStart', $field.val().length);}, 100);
|
||||
e.preventDefault();
|
||||
}
|
||||
@@ -295,7 +292,7 @@ RelatedTag.find_artist = function(e) {
|
||||
var referer_url = $("#upload_referer_url");
|
||||
$.get("/artists/finder.json", {"url": url.val(), "referer_url": referer_url.val()}, RelatedTag.process_artist);
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,12 +325,12 @@ RelatedTag.hide = function() {
|
||||
RelatedTag.disable_artist_url = function(e) {
|
||||
var url = e.currentTarget.href;
|
||||
$.each(RelatedTag.recent_artists[0].sorted_urls, function(k, v) {
|
||||
if (v["normalized_url"] === url || v["url"] === url) {
|
||||
if (v.normalized_url === url || v.url === url) {
|
||||
if (!confirm("This will mark the URL as inactive. Continue?")) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax("/artist_urls/" + v["id"], {
|
||||
|
||||
$.ajax("/artist_urls/" + v.id, {
|
||||
method: "PUT",
|
||||
data: {
|
||||
artist_url: {
|
||||
|
||||
@@ -17,4 +17,4 @@ SavedSearch.labels = function(term) {
|
||||
|
||||
$(SavedSearch.initialize_all);
|
||||
|
||||
export default SavedSearch
|
||||
export default SavedSearch
|
||||
|
||||
@@ -14,7 +14,7 @@ Shortcuts.initialize = function() {
|
||||
|
||||
if ($("#image").length) { // post page or bookmarklet upload page
|
||||
Utility.keydown("shift+e", "edit_dialog", function(e) {
|
||||
if (Utility.meta("current-user-id") == "") { // anonymous
|
||||
if (Utility.meta("current-user-id") === "") { // anonymous
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,4 +56,4 @@ $(document).ready(function() {
|
||||
Shortcuts.initialize();
|
||||
});
|
||||
|
||||
export default Shortcuts
|
||||
export default Shortcuts
|
||||
|
||||
@@ -16,10 +16,8 @@ TagScript.test = function(tags, predicate) {
|
||||
if ($.inArray(x.substr(1, 100), tags)) {
|
||||
is_true = false;
|
||||
}
|
||||
} else {
|
||||
if (!$.inArray(x, tags)) {
|
||||
is_true = false;
|
||||
}
|
||||
} else if (!$.inArray(x, tags)) {
|
||||
is_true = false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -57,4 +55,4 @@ TagScript.run = function(post_id, tag_script) {
|
||||
Post.update(post_id, {"post[old_tag_string]": old_tags, "post[tag_string]": $post.data("tags")});
|
||||
}
|
||||
|
||||
export default TagScript
|
||||
export default TagScript
|
||||
|
||||
@@ -50,7 +50,7 @@ Ugoira.create_player = (mime_type, frames, file_url) => {
|
||||
|
||||
$("#seek-slider").slider({
|
||||
min: 0,
|
||||
max: Ugoira.player._frameCount-1,
|
||||
max: Ugoira.player._frameCount - 1,
|
||||
start: (event, ui) => {
|
||||
// Need to pause while slider is being dragged or playback speed will bug out
|
||||
Ugoira.player.pause();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import Utility from './utility'
|
||||
import Post from './posts.js.erb'
|
||||
import Artist from './artists'
|
||||
import RelatedTag from './related_tag.js.erb'
|
||||
|
||||
let Upload = {};
|
||||
@@ -45,8 +44,8 @@ Upload.initialize_submit = function() {
|
||||
error_messages.push("Must specify a rating");
|
||||
}
|
||||
if (error_messages.length === 0) {
|
||||
$("#submit-button").prop("disabled","true");
|
||||
$("#submit-button").prop("value","Submitting...");
|
||||
$("#submit-button").prop("disabled", "true");
|
||||
$("#submit-button").prop("value", "Submitting...");
|
||||
$("#client-errors").hide();
|
||||
} else {
|
||||
$("#client-errors").html("<strong>Error</strong>: " + error_messages.join(", "));
|
||||
@@ -112,7 +111,7 @@ Upload.fetch_source_data = function(url, referer_url) {
|
||||
return $.getJSON("/source.json", { url: url, ref: referer_url })
|
||||
.then(Upload.fill_source_info)
|
||||
.catch(function(data) {
|
||||
$("#source-info span#loading-data").html("Error: " + data.responseJSON["message"])
|
||||
$("#source-info span#loading-data").html("Error: " + data.responseJSON.message)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ Utility.scroll_to = function(element) {
|
||||
}
|
||||
|
||||
var top = null;
|
||||
if (typeof(element) === "number") {
|
||||
if (typeof element === "number") {
|
||||
top = element;
|
||||
} else {
|
||||
top = element.offset().top - 10;
|
||||
@@ -76,8 +76,7 @@ Utility.intersect = function(a, b) {
|
||||
a = a.slice(0).sort();
|
||||
b = b.slice(0).sort();
|
||||
var result = [];
|
||||
while (a.length > 0 && b.length > 0)
|
||||
{
|
||||
while (a.length > 0 && b.length > 0) {
|
||||
if (a[0] < b[0]) {
|
||||
a.shift();
|
||||
} else if (a[0] > b[0]) {
|
||||
@@ -150,7 +149,7 @@ $.fn.selectRange = function(start, end) {
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.selectEnd = function(){
|
||||
$.fn.selectEnd = function() {
|
||||
if (this.length) {
|
||||
this.selectRange(this.val().length, this.val().length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user