views: move inline javascript to app bundle.

This commit is contained in:
evazion
2020-01-26 18:56:44 -06:00
parent 2265721cb2
commit aeec46b212
8 changed files with 42 additions and 52 deletions

View File

@@ -20,6 +20,12 @@ ForumPost.initialize_edit_links = function() {
$("#edit_forum_topic_" + forum_topic_id).fadeToggle("fast");
e.preventDefault();
});
$(document).on("click.danbooru", "#c-forum-topics #a-show #new-response-link", function (e) {
$("#topic-response").show();
document.body.scrollIntoView(false);
e.preventDefault();
});
}
$(document).ready(function() {

View File

@@ -3,6 +3,7 @@ import Utility from './utility'
import Hammer from 'hammerjs'
import Cookie from './cookie'
import Note from './notes'
import Ugoira from './ugoira'
import Rails from '@rails/ujs'
let Post = {};
@@ -34,6 +35,7 @@ Post.initialize_all = function() {
this.initialize_post_image_resize_links();
this.initialize_post_image_resize_to_window_link();
this.initialize_recommended();
this.initialize_ugoira_player();
if (CurrentUser.data("always-resize-images") || (Utility.meta("viewport") && (window.screen.width <= 660))) {
$("#image-resize-to-window-link").click();
@@ -451,6 +453,16 @@ Post.initialize_post_sections = function() {
});
}
Post.initialize_ugoira_player = function() {
if ($("#ugoira-controls").length) {
let content_type = $("#image").data("ugoira-content-type");
let frames = $("#image").data("ugoira-frames");
let file_url = $("#image-container").data("file-url");
Ugoira.create_player(content_type, frames, file_url);
}
};
Post.resize_ugoira_controls = function() {
var $img = $("#image");
var width = Math.max($img.width(), 350);

View File

@@ -42,6 +42,8 @@ Upload.initialize_all = function() {
Upload.toggle_translation();
e.preventDefault();
});
$(document).on("click.danbooru", "#c-uploads #a-batch #link", Upload.batch_open_all);
}
if ($("#c-uploads #a-new").length) {
@@ -209,6 +211,10 @@ Upload.initialize_dropzone = function() {
});
};
Upload.batch_open_all = function() {
$(".upload-preview > a").each((_i, link) => window.open(link.href));
};
$(function() {
Upload.initialize_all();
});

View File

@@ -0,0 +1,18 @@
let User = {};
User.initialize_all = function() {
$(document).on("click.danbooru", "#c-users #a-edit #edit-options a", User.toggle_edit_tab);
}
User.toggle_edit_tab = function(e) {
let $target = $(e.target);
$("h2 a").removeClass("active");
$("#basic-settings-section,#advanced-settings-section").hide();
$target.addClass("active")
$($target.attr("href") + "-section").show();
e.preventDefault();
};
$(User.initialize_all);
export default User