euscanwww: Favourite/Unfavourite template code refactored
* Now is more DRY, the JS code and the HTML code are in one place * It works even without JS Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
{% extends "euscan/_datatable.html" %}
|
||||
|
||||
{% load djeuscan_helpers %}
|
||||
{% load url from future %}
|
||||
{% load djeuscan_helpers %}
|
||||
{% load euscan_accounts_helpers %}
|
||||
|
||||
{% block title %}
|
||||
{{ block.super }} - Category: {{ category }}
|
||||
@ -22,13 +23,8 @@
|
||||
Category: {{ category }}
|
||||
|
||||
{% if user.is_authenticated %}
|
||||
<span class="pull-right">
|
||||
<button class="btn favourite-button {% if favourited %}hide{% endif %}" data-url="{% url "favourite_category" category %}">
|
||||
<img src="{{ STATIC_URL}}/img/watch-icon.png" alt="Watch" />
|
||||
</button>
|
||||
<button class="btn unfavourite-button {% if not favourited %}hide{% endif %}" data-url="{% url "unfavourite_category" category %}">
|
||||
<img src="{{ STATIC_URL}}/img/unwatch-icon.png" alt="Unwatch" />
|
||||
</button>
|
||||
<span class="pull-right padding-bottom10">
|
||||
{% favourite_buttons "category" category %}
|
||||
</span>
|
||||
{% endif %}
|
||||
</h2>
|
||||
@ -53,24 +49,7 @@
|
||||
<img alt="packages monthly" src="{% url "chart_category" category 'packages-monthly' %}" />
|
||||
</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$(".favourite-button").click(function() {
|
||||
$.post($(this).data("url"), function() {
|
||||
$(".unfavourite-button").removeClass("hide");
|
||||
$(".favourite-button").addClass("hide");
|
||||
});
|
||||
});
|
||||
|
||||
$(".unfavourite-button").click(function() {
|
||||
$.post($(this).data("url"), function() {
|
||||
$(".favourite-button").removeClass("hide");
|
||||
$(".unfavourite-button").addClass("hide");
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="{{ STATIC_URL }}js/favourite.js" type="text/javascript"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block menus %}
|
||||
|
@ -1,7 +1,8 @@
|
||||
{% extends "euscan/_datatable.html" %}
|
||||
|
||||
{% load djeuscan_helpers %}
|
||||
{% load url from future %}
|
||||
{% load djeuscan_helpers %}
|
||||
{% load euscan_accounts_helpers %}
|
||||
|
||||
{% block title %}
|
||||
{{ block.super }} - Herd: {{ herd.herd }}
|
||||
@ -21,13 +22,8 @@
|
||||
<h2>
|
||||
Herd: {{ herd.herd }}
|
||||
{% if user.is_authenticated %}
|
||||
<span class="pull-right">
|
||||
<button class="btn favourite-button {% if favourited %}hide{% endif %}" data-url="{% url "favourite_herd" herd.herd %}">
|
||||
<img src="{{ STATIC_URL}}/img/watch-icon.png" alt="Watch" />
|
||||
</button>
|
||||
<button class="btn unfavourite-button {% if not favourited %}hide{% endif %}" data-url="{% url "unfavourite_herd" herd.herd %}">
|
||||
<img src="{{ STATIC_URL}}/img/unwatch-icon.png" alt="Unwatch" />
|
||||
</button>
|
||||
<span class="pull-right padding-bottom10">
|
||||
{% favourite_buttons "herd" herd.herd %}
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
@ -51,24 +47,7 @@
|
||||
<img alt="packages monthly" src="{% url "chart_herd" herd.herd 'packages-monthly' %}" />
|
||||
</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$(".favourite-button").click(function() {
|
||||
$.post($(this).data("url"), function() {
|
||||
$(".unfavourite-button").removeClass("hide");
|
||||
$(".favourite-button").addClass("hide");
|
||||
});
|
||||
});
|
||||
|
||||
$(".unfavourite-button").click(function() {
|
||||
$.post($(this).data("url"), function() {
|
||||
$(".favourite-button").removeClass("hide");
|
||||
$(".unfavourite-button").addClass("hide");
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="{{ STATIC_URL }}js/favourite.js" type="text/javascript"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block menus %}
|
||||
|
@ -1,7 +1,8 @@
|
||||
{% extends "euscan/_datatable.html" %}
|
||||
|
||||
{% load djeuscan_helpers %}
|
||||
{% load url from future %}
|
||||
{% load djeuscan_helpers %}
|
||||
{% load euscan_accounts_helpers %}
|
||||
|
||||
{% block title %}
|
||||
{{ block.super }} - Maintainer: {{ maintainer.name }}
|
||||
@ -21,13 +22,8 @@
|
||||
<h2>
|
||||
Maintainer: {{ maintainer.name }} <{{ maintainer.email }}>
|
||||
{% if user.is_authenticated %}
|
||||
<span class="pull-right">
|
||||
<button class="btn favourite-button {% if favourited %}hide{% endif %}" data-url="{% url "favourite_maintainer" maintainer.email %}">
|
||||
<img src="{{ STATIC_URL}}/img/watch-icon.png" alt="Watch" />
|
||||
</button>
|
||||
<button class="btn unfavourite-button {% if not favourited %}hide{% endif %}" data-url="{% url "unfavourite_maintainer" maintainer.email %}">
|
||||
<img src="{{ STATIC_URL}}/img/unwatch-icon.png" alt="Unwatch" />
|
||||
</button>
|
||||
<span class="pull-right padding-bottom10">
|
||||
{% favourite_buttons "maintainer" maintainer.email %}
|
||||
</span>
|
||||
{% endif %}
|
||||
</h2>
|
||||
@ -52,24 +48,7 @@
|
||||
<img alt="packages monthly" src="{% url "chart_maintainer" maintainer.email 'packages-monthly' %}" />
|
||||
</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$(".favourite-button").click(function() {
|
||||
$.post($(this).data("url"), function() {
|
||||
$(".unfavourite-button").removeClass("hide");
|
||||
$(".favourite-button").addClass("hide");
|
||||
});
|
||||
});
|
||||
|
||||
$(".unfavourite-button").click(function() {
|
||||
$.post($(this).data("url"), function() {
|
||||
$(".favourite-button").removeClass("hide");
|
||||
$(".unfavourite-button").addClass("hide");
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="{{ STATIC_URL }}js/favourite.js" type="text/javascript"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block menus %}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
{% load url from future %}
|
||||
{% load djeuscan_helpers %}
|
||||
{% load euscan_accounts_helpers %}
|
||||
|
||||
{% block title %}
|
||||
{{ block.super }} - Overlay: {{ overlay }}
|
||||
@ -11,13 +12,8 @@
|
||||
<h2>
|
||||
Overlay: {{ overlay }}
|
||||
{% if user.is_authenticated %}
|
||||
<span class="pull-right">
|
||||
<button class="btn favourite-button {% if favourited %}hide{% endif %}" data-url="{% url "favourite_overlay" overlay %}">
|
||||
<img src="{{ STATIC_URL}}/img/watch-icon.png" alt="Watch" />
|
||||
</button>
|
||||
<button class="btn unfavourite-button {% if not favourited %}hide{% endif %}" data-url="{% url "unfavourite_overlay" overlay %}">
|
||||
<img src="{{ STATIC_URL}}/img/unwatch-icon.png" alt="Unwatch" />
|
||||
</button>
|
||||
<span class="pull-right padding-bottom10">
|
||||
{% favourite_buttons "overlay" overlay %}
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
@ -25,22 +21,5 @@
|
||||
|
||||
{% packages packages %}
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$(".favourite-button").click(function() {
|
||||
$.post($(this).data("url"), function() {
|
||||
$(".unfavourite-button").removeClass("hide");
|
||||
$(".favourite-button").addClass("hide");
|
||||
});
|
||||
});
|
||||
|
||||
$(".unfavourite-button").click(function() {
|
||||
$.post($(this).data("url"), function() {
|
||||
$(".favourite-button").removeClass("hide");
|
||||
$(".unfavourite-button").addClass("hide");
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="{{ STATIC_URL }}js/favourite.js" type="text/javascript"></script>
|
||||
{% endblock %}
|
||||
|
@ -1,7 +1,8 @@
|
||||
{% extends "euscan/_datatable.html" %}
|
||||
|
||||
{% load sub %}
|
||||
{% load url from future %}
|
||||
{% load sub %}
|
||||
{% load euscan_accounts_helpers %}
|
||||
|
||||
{% block meta %}
|
||||
{{ block.super }}
|
||||
@ -34,7 +35,7 @@
|
||||
{{ package.category }}/{{ package.name }}
|
||||
|
||||
{% if user.is_authenticated %}
|
||||
<span class="pull-right">
|
||||
<div class="pull-right">
|
||||
<form class="refresh-form inline"
|
||||
method="POST"
|
||||
action="{% url "refresh_package" package.category package.name %}">
|
||||
@ -46,13 +47,9 @@
|
||||
<button class="btn refresh-button-disabled disabled {% if not refresh_requested %}hide{% endif %}">
|
||||
<img src="{{ STATIC_URL}}/img/refresh-inactive.png" alt="Refresh" />
|
||||
</button>
|
||||
<button class="btn favourite-button {% if favourited %}hide{% endif %}" data-url="{% url "favourite_package" package.category package.name %}">
|
||||
<img src="{{ STATIC_URL}}/img/watch-icon.png" alt="Watch" />
|
||||
</button>
|
||||
<button class="btn unfavourite-button {% if not favourited %}hide{% endif %}" data-url="{% url "unfavourite_package" package.category package.name %}">
|
||||
<img src="{{ STATIC_URL}}/img/unwatch-icon.png" alt="Unwatch" />
|
||||
</button>
|
||||
</span>
|
||||
|
||||
{% favourite_buttons "package" package.category package.name %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</h2>
|
||||
|
||||
@ -84,22 +81,9 @@
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$(".favourite-button").click(function() {
|
||||
$.post($(this).data("url"), function() {
|
||||
$(".unfavourite-button").removeClass("hide");
|
||||
$(".favourite-button").addClass("hide");
|
||||
});
|
||||
});
|
||||
|
||||
$(".unfavourite-button").click(function() {
|
||||
$.post($(this).data("url"), function() {
|
||||
$(".favourite-button").removeClass("hide");
|
||||
$(".unfavourite-button").addClass("hide");
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="{{ STATIC_URL }}js/favourite.js" type="text/javascript"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
{% load url from future %}
|
||||
{% load djeuscan_helpers %}
|
||||
{% load euscan_accounts_helpers %}
|
||||
|
||||
{% block title %}
|
||||
{{ block.super }} - World Scan
|
||||
@ -23,13 +24,8 @@
|
||||
<h2>
|
||||
World scan:
|
||||
{% if user.is_authenticated %}
|
||||
<span class="pull-right">
|
||||
<button class="btn favourite-button {% if favourited %}hide{% endif %}" data-url="{% url "favourite_world" %}">
|
||||
<img src="{{ STATIC_URL}}/img/watch-icon.png" alt="Watch" />
|
||||
</button>
|
||||
<button class="btn unfavourite-button {% if not favourited %}hide{% endif %}" data-url="{% url "unfavourite_world" %}">
|
||||
<img src="{{ STATIC_URL}}/img/unwatch-icon.png" alt="Unwatch" />
|
||||
</button>
|
||||
<span class="pull-right padding-bottom10">
|
||||
{% favourite_buttons "world" %}
|
||||
</span>
|
||||
{% endif %}
|
||||
</h2>
|
||||
@ -37,23 +33,9 @@
|
||||
{% packages packages %}
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
var packages = [{{packages_ids|join:","}}];
|
||||
|
||||
$(".favourite-button").click(function() {
|
||||
$.post($(this).data("url"), {packages: packages}, function() {
|
||||
$(".unfavourite-button").removeClass("hide");
|
||||
$(".favourite-button").addClass("hide");
|
||||
});
|
||||
});
|
||||
|
||||
$(".unfavourite-button").click(function() {
|
||||
$.post($(this).data("url"), {packages: packages}, function() {
|
||||
$(".favourite-button").removeClass("hide");
|
||||
$(".unfavourite-button").addClass("hide");
|
||||
});
|
||||
});
|
||||
});
|
||||
window.packages = [{{ packages_ids|join:"," }}];
|
||||
</script>
|
||||
|
||||
<script src="{{ STATIC_URL }}js/favourite.js" type="text/javascript"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user