Move off WinBox to JSFrame
WinBox is nice, but it has this annoying bug that I don't feel like figuring out how to fix. JSFrame seems to work much better, although centering the window seems to be a chore. I'll figure it out soon enough. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -31,19 +31,21 @@
|
||||
{% block extrahead %}
|
||||
{{block.super}}
|
||||
<script src="{% static 'board/jquery.js' %}"></script>
|
||||
<script src="{% static 'board/winbox.bundle.js' %}"></script>
|
||||
<script src="{% static 'board/jsframe.min.js' %}"></script>
|
||||
<script src="{% static 'board/ban_window.js' %}"></script>
|
||||
{% endblock extrahead %}
|
||||
|
||||
{% block footer %}
|
||||
{{block.super}}
|
||||
<script>
|
||||
|
||||
function onLoad(e) {
|
||||
window.banWindow = null;
|
||||
}
|
||||
|
||||
$(".ban_link").on("click", (e) => { openBanWindow(e, $(e.target).attr("data-ban-url")); });
|
||||
$(window).on("load", onLoad);
|
||||
$(".ban_link").on("click", (e) => {
|
||||
e.preventDefault();
|
||||
openBanWindow($(e.target).attr("data-ban-url"));
|
||||
});
|
||||
$(window.top).on("load", (e) => {
|
||||
if (typeof window.top.jsFrame === "undefined") {
|
||||
window.top.jsFrame = new JSFrame();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -1,7 +1,11 @@
|
||||
{% extends "board/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load i18n static %}
|
||||
{# Title #}
|
||||
{% block title %}{% translate "Ban success" %}{% endblock %}
|
||||
{# Extra JS #}
|
||||
{% block extrajs %}
|
||||
<script src="{% static 'board/ban_window.js' %}"></script>
|
||||
{% endblock extrajs %}
|
||||
{# Body #}
|
||||
{% block content %}
|
||||
<div class="row" id="message">
|
||||
@@ -20,7 +24,10 @@ function isIframe() {
|
||||
|
||||
setTimeout(function() {
|
||||
if(isIframe()) {
|
||||
window.top.banWindow.close();
|
||||
let banWindow = getBanWindow();
|
||||
if(banWindow) {
|
||||
banWindow.closeFrame();
|
||||
}
|
||||
} else {
|
||||
window.close();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{% extends "board/base.html" %}
|
||||
{% load post_body %}
|
||||
{% load i18n %}
|
||||
{% load i18n post_body static %}
|
||||
|
||||
{% block title %}
|
||||
{% with title=board.url %}
|
||||
@@ -8,6 +7,10 @@
|
||||
{% endwith %}
|
||||
{% endblock title %}
|
||||
|
||||
{% block extrajs %}
|
||||
<script src="{% static 'board/report_window.js' %}"></script>
|
||||
{% endblock extrajs %}
|
||||
|
||||
{% block content %}
|
||||
{# board header #}
|
||||
<div class="row">
|
||||
@@ -59,49 +62,13 @@
|
||||
|
||||
<script>
|
||||
const REPLY_URL = "{% url 'board:reply_create' url=board.url id=post.id %}";
|
||||
const replyWindowName = "reply-window";
|
||||
|
||||
function openReplyWindow() {
|
||||
if(window.jsFrame.containsWindowName(replyWindowName)) {
|
||||
// if there's already a new reply window, don't override it and just let
|
||||
// it continue to exist.
|
||||
return;
|
||||
}
|
||||
|
||||
window.top.replyWindow = window.jsFrame.create({
|
||||
title: "New Reply",
|
||||
name: replyWindowName,
|
||||
width: 385,
|
||||
height: 350,
|
||||
x: "center",
|
||||
y: "center",
|
||||
url: REPLY_URL,
|
||||
});
|
||||
window.top.replyWindow.show();
|
||||
}
|
||||
|
||||
function replyTextbox() {
|
||||
return $("iframe").contents().find("#id_text");
|
||||
}
|
||||
|
||||
function replyAppend(toAdd) {
|
||||
let textbox = replyTextbox();
|
||||
if(textbox.length === 0) {
|
||||
return;
|
||||
}
|
||||
let caret = textbox[0].selectionStart;
|
||||
let text = textbox.val();
|
||||
textbox.val(text.substring(0, caret) + toAdd + text.substring(caret));
|
||||
textbox.focus();
|
||||
}
|
||||
|
||||
$("#create_reply").on("click", (e) => {
|
||||
e.preventDefault();
|
||||
openReplyWindow();
|
||||
openReplyWindow(REPLY_URL);
|
||||
});
|
||||
$(window).on("load", () => { window.top.replyWindow = null; });
|
||||
$(window).on("quote", (e, postId) => {
|
||||
openReplyWindow();
|
||||
openReplyWindow(REPLY_URL);
|
||||
let toAdd = ">>" + postId + "\n";
|
||||
let textbox = replyTextbox();
|
||||
if (typeof textbox === "undefined" || textbox.length === 0) {
|
||||
|
||||
@@ -18,8 +18,9 @@ function isIframe() {
|
||||
setTimeout(function() {
|
||||
if(isIframe()) {
|
||||
// check for possible windows
|
||||
if(typeof window.top.replyWindow !== "undefined" && window.top.replyWindow) {
|
||||
window.top.replyWindow.closeFrame();
|
||||
let replyWindow = getReplyWindow();
|
||||
if(replyWindow) {
|
||||
replyWindow.closeFrame();
|
||||
}
|
||||
} else {
|
||||
window.close();
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
{% extends "board/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load i18n static %}
|
||||
{# Title #}
|
||||
{% block title %}{% translate "Report success" %}{% endblock %}
|
||||
{# Extra JS #}
|
||||
{% block extrajs %}
|
||||
<script src="{% static 'board/report_window.js' %}"></script>
|
||||
{% endblock extrajs %}
|
||||
{# Body #}
|
||||
{% block content %}
|
||||
<div class="row" id="message">
|
||||
@@ -20,8 +24,9 @@ function isIframe() {
|
||||
|
||||
setTimeout(function() {
|
||||
if(isIframe()) {
|
||||
if(typeof window.top.reportWindow !== "undefined" && window.top.reportWindow) {
|
||||
window.top.reportWindow.closeFrame();
|
||||
let reportWindow = getReportWindow();
|
||||
if(reportWindow) {
|
||||
reportWindow.closeFrame();
|
||||
}
|
||||
} else {
|
||||
window.close();
|
||||
|
||||
Reference in New Issue
Block a user