views: move inline javascript to app bundle.
This commit is contained in:
@@ -20,6 +20,12 @@ ForumPost.initialize_edit_links = function() {
|
|||||||
$("#edit_forum_topic_" + forum_topic_id).fadeToggle("fast");
|
$("#edit_forum_topic_" + forum_topic_id).fadeToggle("fast");
|
||||||
e.preventDefault();
|
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() {
|
$(document).ready(function() {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import Utility from './utility'
|
|||||||
import Hammer from 'hammerjs'
|
import Hammer from 'hammerjs'
|
||||||
import Cookie from './cookie'
|
import Cookie from './cookie'
|
||||||
import Note from './notes'
|
import Note from './notes'
|
||||||
|
import Ugoira from './ugoira'
|
||||||
import Rails from '@rails/ujs'
|
import Rails from '@rails/ujs'
|
||||||
|
|
||||||
let Post = {};
|
let Post = {};
|
||||||
@@ -34,6 +35,7 @@ Post.initialize_all = function() {
|
|||||||
this.initialize_post_image_resize_links();
|
this.initialize_post_image_resize_links();
|
||||||
this.initialize_post_image_resize_to_window_link();
|
this.initialize_post_image_resize_to_window_link();
|
||||||
this.initialize_recommended();
|
this.initialize_recommended();
|
||||||
|
this.initialize_ugoira_player();
|
||||||
|
|
||||||
if (CurrentUser.data("always-resize-images") || (Utility.meta("viewport") && (window.screen.width <= 660))) {
|
if (CurrentUser.data("always-resize-images") || (Utility.meta("viewport") && (window.screen.width <= 660))) {
|
||||||
$("#image-resize-to-window-link").click();
|
$("#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() {
|
Post.resize_ugoira_controls = function() {
|
||||||
var $img = $("#image");
|
var $img = $("#image");
|
||||||
var width = Math.max($img.width(), 350);
|
var width = Math.max($img.width(), 350);
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ Upload.initialize_all = function() {
|
|||||||
Upload.toggle_translation();
|
Upload.toggle_translation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on("click.danbooru", "#c-uploads #a-batch #link", Upload.batch_open_all);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($("#c-uploads #a-new").length) {
|
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() {
|
$(function() {
|
||||||
Upload.initialize_all();
|
Upload.initialize_all();
|
||||||
});
|
});
|
||||||
|
|||||||
18
app/javascript/src/javascripts/users.js
Normal file
18
app/javascript/src/javascripts/users.js
Normal 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
|
||||||
@@ -41,15 +41,3 @@
|
|||||||
<%= numbered_paginator(@forum_posts) %>
|
<%= numbered_paginator(@forum_posts) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% content_for(:html_header) do %>
|
|
||||||
<script>
|
|
||||||
$(function() {
|
|
||||||
$("#new-response-link").click(function(e) {
|
|
||||||
$("#topic-response").show();
|
|
||||||
document.body.scrollIntoView(false);
|
|
||||||
e.preventDefault();
|
|
||||||
})
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<% end %>
|
|
||||||
|
|||||||
@@ -35,15 +35,3 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% content_for(:html_header) do %>
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(function() {
|
|
||||||
Danbooru.Ugoira.create_player(
|
|
||||||
<%= raw @post.pixiv_ugoira_frame_data.content_type.to_json %>,
|
|
||||||
<%= raw @post.pixiv_ugoira_frame_data.data.to_json %>,
|
|
||||||
"<%= @post.file_url %>"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<% end %>
|
|
||||||
|
|||||||
@@ -35,15 +35,3 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% content_for(:html_header) do %>
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(function() {
|
|
||||||
$("#link").click(function() {
|
|
||||||
$(".upload-preview > a").each(function(i, v) {
|
|
||||||
window.open(v.href);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
<% end %>
|
|
||||||
|
|||||||
@@ -75,19 +75,3 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% content_for(:html_header) do %>
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(function() {
|
|
||||||
$("#advanced-settings-section").hide();
|
|
||||||
$("#edit-options a").on("click", function(e) {
|
|
||||||
var $target = $(e.target);
|
|
||||||
$("h2 a").removeClass("active");
|
|
||||||
$("#basic-settings-section,#advanced-settings-section").hide();
|
|
||||||
$target.addClass("active")
|
|
||||||
$($target.attr("href") + "-section").show();
|
|
||||||
e.preventDefault();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<% end %>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user