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

@@ -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);