(function() { Danbooru.Post = {}; Danbooru.Post.pending_update_count = 0; Danbooru.Post.initialize_all = function() { this.initialize_post_previews(); if ($("#c-posts").length) { this.initialize_shortcuts(); this.initialize_saved_searches(); } if ($("#c-posts").length && $("#a-index").length) { this.initialize_excerpt(); this.initialize_gestures(); } if ($("#c-posts").length && $("#a-show").length) { this.initialize_links(); this.initialize_post_relationship_previews(); this.initialize_favlist(); this.initialize_post_sections(); this.initialize_post_image_resize_links(); this.initialize_post_image_resize_to_window_link(); this.initialize_similar(); this.initialize_replace_image_dialog(); this.initialize_gestures(); if ((Danbooru.meta("always-resize-images") === "true") || ((Danbooru.Cookie.get("dm") != "1") && (window.innerWidth <= 660))) { $("#image-resize-to-window-link").click(); } } if ($("#image").length) { this.initialize_edit_dialog(); } } Danbooru.Post.initialize_gestures = function() { if (!window.matchMedia) { return; } var mq = window.matchMedia('(max-width: 660px)'); if (!mq.matches) { return; } var hasPrev = $("#a-show").length || $(".paginator a[rel~=prev]").length; var hasNext = $(".paginator a[rel~=next]").length; $("body").hammer().bind("panend", function(e) { var percentage = e.gesture.deltaX / window.innerWidth; var swipe = Math.abs(e.gesture.velocityX) > 0.5; if (Math.abs(e.gesture.deltaY) > 75) { return; } else if ((percentage > 0.3 || (percentage > 0.1 && swipe)) && hasPrev) { $("body").css({"transition-timing-function": "ease", "transition-duration": "0.3s", "opacity": "0", "transform": "translateX(150%)"}); $.timeout(300).done(function() {Danbooru.Post.swipe_prev(e)}); } else if (percentage < -0.3 || (percentage < -0.1 && swipe) && hasNext) { $("body").css({"transition-timing-function": "ease", "transition-duration": "0.3s", "opacity": "0", "transform": "translateX(-150%)"}); $.timeout(300).done(function() {Danbooru.Post.swipe_next(e)}); } else { $("body").css({"transition-timing-function": "ease", "transition-duration": "0.5s", "transform": "none"}); } }); } Danbooru.Post.initialize_edit_dialog = function(e) { $("#open-edit-dialog").button().show().click(function(e) { $(window).scrollTop($("#image").offset().top); Danbooru.Post.open_edit_dialog(); e.preventDefault(); }); $("#toggle-related-tags-link").click(function(e) { Danbooru.RelatedTag.toggle(); e.preventDefault(); }); } Danbooru.Post.open_edit_dialog = function() { var $tag_string = $("#post_tag_string,#upload_tag_string"); $("div.input").has($tag_string).prevAll().hide(); $("#open-edit-dialog").hide(); $("#toggle-related-tags-link").show().click(); var dialog = $("
").attr("id", "edit-dialog"); $("#form").appendTo(dialog); dialog.dialog({ title: "Edit tags", width: $(window).width() * 0.6, position: { my: "right", at: "right-20", of: window }, drag: function(e, ui) { if (Danbooru.meta("enable-auto-complete") === "true") { $tag_string.data("uiAutocomplete").close(); } }, close: Danbooru.Post.close_edit_dialog }); dialog.dialog("widget").draggable("option", "containment", "none"); var pin_button = $("