Skip to content

Commit

Permalink
Merge pull request #6 from LukeWCS/master
Browse files Browse the repository at this point in the history
2.2.15-pl12
  • Loading branch information
IMC-GER authored Nov 4, 2023
2 parents 29614a5 + 3de5b60 commit 68da45d
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 133 deletions.
47 changes: 0 additions & 47 deletions adm/style/acp_confirm.css

This file was deleted.

77 changes: 0 additions & 77 deletions adm/style/acp_confirm.js

This file was deleted.

41 changes: 41 additions & 0 deletions adm/style/acp_toggle.css → adm/style/acp_recenttopics.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
/* ACP ConfirmBox (JS) */

div[id$="_confirmbox"] {
max-width: 450px;
border: 2px solid skyblue;
margin: .75em .5em;
padding: .25em .5em;
border-radius: 5px;
-webkit-box-shadow: 2px 2px 10px 1px rgba(121, 162, 179, 0.5);
box-shadow: 2px 2px 10px 1px rgba(121, 162, 179, 0.5);
}

div[id$="_confirmbox"] h2 {
margin: 0 0 .25em 0;
}

div[id$="_confirmbox"] p:nth-of-type(2) {
text-align: center;
margin: 0;
padding: 0 4px 4px 4px;
}

div[id$="_confirmbox"] input[type="button"] {
padding: 3px 4px;
}

input[type="submit"]:disabled,
input[type="button"]:disabled,
input[class*="confirmbox_active"]:disabled {
opacity: .5;
cursor: not-allowed;
}

/*
phpBB ACP Toggles - A CSS class that makes it easy to display checkboxes as toggles.
Source : https://danklammer.com/articles/simple-css-toggle-switch/
Expand Down Expand Up @@ -49,3 +82,11 @@
left: 2px;
content: "\f00c";
}

/* RESPONSIVE */

@media (max-width: 700px) {
div[id$="_confirmbox"] {
margin-left: 0;
}
}
13 changes: 6 additions & 7 deletions adm/style/acp_recenttopics.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ <h1>{{ lang('RECENT_TOPICS') }}</h1>
<legend>{{ lang('ACP_SUBMIT_CHANGES') }}</legend>

<p class="submit-buttons">
<input class="button1" type="submit" id="submit" name="submit" value="{{ lang('SUBMIT') }}">
<input class="button2" type="reset" id="reset" name="reset" value="{{ lang('RESET') }}">
<input class="button1" type="submit" name="submit" value="{{ lang('SUBMIT') }}">
<input class="button2" type="reset" name="reset" value="{{ lang('RESET') }}">
</p>
</fieldset>

Expand All @@ -170,9 +170,8 @@ <h1>{{ lang('RECENT_TOPICS') }}</h1>

{% include 'overall_footer.html' %}

{% INCLUDECSS '@paybas_recenttopics/acp_toggle.css' %}
{% INCLUDECSS '@paybas_recenttopics/acp_confirm.css' %}
{% INCLUDEJS '@paybas_recenttopics/acp_confirm.js' %}
{% INCLUDECSS '@paybas_recenttopics/acp_recenttopics.css' %}
{% INCLUDEJS '@paybas_recenttopics/acp_recenttopics.js' %}

{% macro switch(name, checked = false) -%}
<input type="checkbox" class="toggle" name="{{ name }}" value="1"{{ checked ? ' checked' }}>
Expand All @@ -187,10 +186,10 @@ <h1>{{ lang('RECENT_TOPICS') }}</h1>
{%- endmacro %}

{% macro confirmbox(name, message, default = false) -%}
<div id="{{ name }}_confirmbox" data-default="{{ default }}" style="display: none;">
<div id="{{ name }}_confirmbox" data-default="{{ default ? 1 : 0 }}" style="display: none;">
<h2>{{ lang('CONFIRM') }}</h2>
<p>{{ message }}</p>
<p class="submit-buttons">
<p>
<input type="button" class="button1" name="{{ name }}_confirm_yes" value="{{ lang('YES') }}">&nbsp;
<input type="button" class="button2" name="{{ name }}_confirm_no" value="{{ lang('NO') }}">
</p>
Expand Down
81 changes: 81 additions & 0 deletions adm/style/acp_recenttopics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
*
* Recent Topics. An extension for the phpBB Forum Software package.
*
* @copyright (c) 2022, IMC, https://github.com/IMC-GER / LukeWCS, https://github.com/LukeWCS
* @copyright (c) 2017, Sajaki, https://www.avathar.be
* @copyright (c) 2015, PayBas
* @license GNU General Public License, version 2 (GPL-2.0-only)
*
* Based on the original NV Recent Topics by Joas Schilling (nickvergessen)
*/

var RecentTopics = {};

(function () { // IIFE start

'use strict';

class LukeWCSphpBBConfirmBox {
/*
* phpBB ConfirmBox class for checkboxes - v1.1.0
* @copyright (c) 2023, LukeWCS, https://www.wcsaga.org
* @license GNU General Public License, version 2 (GPL-2.0-only)
*/
constructor(submitSelector) {
this.$submitObject = $(submitSelector);
var _this = this;

$('div[id$="_confirmbox"]').each(function () {
var elementName = $(this)[0].id.replace('_confirmbox', '')

$('input[name="' + elementName + '"]') .on('change' , _this.Show);
$('input[name^="' + elementName + '_confirm_"]') .on('click' , _this.Button);
});
this.$submitObject.parents('form') .on('reset' , this.HideAll);
}

Show = (e) => {
var elementDefault = $('div[id="' + e.target.name + '_confirmbox"]').attr('data-default') == 1;
var $elementObject = $('input[name="' + e.target.name + '"]');

if ($elementObject.prop('checked') != elementDefault) {
$elementObject .prop('disabled', true)
$elementObject .addClass('confirmbox_active');
$('div[id="' + e.target.name + '_confirmbox"]') .show();
this.$submitObject .prop('disabled', true);
}
}

Button = (e) => {
var elementName = e.target.name.replace(/_confirm_.*/, '');
var elementDefault = $('div[id="' + elementName + '_confirmbox"]').attr('data-default') == 1;
var $elementObject = $('input[name="' + elementName + '"]');

if (e.target.name.endsWith('_confirm_no')) {
$elementObject.prop('checked', elementDefault);
}

$elementObject .prop('disabled', false);
$elementObject .removeClass('confirmbox_active');
$('div[id="' + elementName + '_confirmbox"]') .hide();
this.$submitObject .prop('disabled', $('input[class*="confirmbox_active"]').length);
}

HideAll = () => {
var $elementObject = $('input[class*="confirmbox_active"]');

$elementObject .prop('disabled', false);
$elementObject .removeClass('confirmbox_active');
$('div[id$="_confirmbox"]') .hide();
this.$submitObject .prop('disabled', false);
}
}

// Register events

$(window).ready(function() {
RecentTopics.ConfirmBox = new LukeWCSphpBBConfirmBox('input[name="submit"]');
});

})(); // IIFE end
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"type": "phpbb-extension",
"description": "Recent topics Extension for phpBB 3.3. Adds a list with a number of recent topics to the board index.",
"homepage": "https://github.com/sajaki/RecentTopics",
"version": "2.2.15-pl11",
"time": "2023-10-23",
"version": "2.2.15-pl12",
"time": "2023-11-03",
"license": "GPL-2.0-only",
"authors": [
{
Expand Down

0 comments on commit 68da45d

Please sign in to comment.