@@ -18,7 +18,7 @@ var RecentTopicsNG = {};
1818
1919class LukeWCSphpBBConfirmBox {
2020/*
21- * phpBB ConfirmBox class for checkboxes and yes/no radio buttons - v1.4.3
21+ * phpBB ConfirmBox class for checkboxes and yes/no radio buttons - v1.5.1
2222* @copyright (c) 2023, LukeWCS, https://www.wcsaga.org
2323* @license GNU General Public License, version 2 (GPL-2.0-only)
2424*/
@@ -28,31 +28,29 @@ class LukeWCSphpBBConfirmBox {
2828 this . $formObject = this . $submitObject . parents ( 'form' ) ;
2929 this . animDuration = animDuration ;
3030
31- this . $formObject . find ( 'div[id$="_confirmbox"]' ) . each ( function ( ) {
32- const elementName = this . id . replace ( '_confirmbox' , '' ) ;
33-
34- $ ( 'input[name="' + elementName + '"]' ) . on ( 'change' , _this . #Show) ;
35- $ ( 'input[name^="' + elementName + '_confirm_"]' ) . on ( 'click' , _this . #Button) ;
31+ this . $formObject . find ( 'div.lukewcs_confirmbox' ) . each ( function ( ) {
32+ $ ( 'input[name="' + $ ( this ) . attr ( 'data-name' ) + '"]' ) . on ( 'change' , _this . #Show) ;
33+ $ ( this ) . find ( 'input[type="button"]' ) . on ( 'click' , _this . #Button) ;
3634 } ) ;
37- this . $formObject . on ( 'reset' , _this . HideAll ) ;
35+ this . $formObject . on ( 'reset' , _this . HideAll ) ;
3836 }
3937
4038 #Show = ( e ) => {
4139 const $elementObject = $ ( 'input[name="' + e . target . name + '"]' ) ;
42- const $confirmBoxObject = $ ( 'div[id ="' + e . target . name + '_confirmbox "]' ) ;
40+ const $confirmBoxObject = $ ( 'div.lukewcs_confirmbox[data-name ="' + e . target . name + '"]' ) ;
4341
4442 if ( $elementObject . prop ( 'checked' ) != $confirmBoxObject . attr ( 'data-default' ) ) {
4543 this . #changeBoxState( $elementObject , $confirmBoxObject , true ) ;
4644 }
4745 }
4846
4947 #Button = ( e ) => {
50- const elementName = e . target . name . replace ( / _ c o n f i r m _ . * / , ' ') ;
48+ const elementName = $ ( e . target ) . parents ( 'div.lukewcs_confirmbox' ) . attr ( 'data-name ') ;
5149 const $elementObject = $ ( 'input[name="' + elementName + '"]' ) ;
52- const $confirmBoxObject = $ ( 'div[id ="' + elementName + '_confirmbox "]' ) ;
50+ const $confirmBoxObject = $ ( 'div.lukewcs_confirmbox[data-name ="' + elementName + '"]' ) ;
5351 const elementType = $elementObject . attr ( 'type' ) ;
5452
55- if ( e . target . name . endsWith ( '_confirm_no' ) ) {
53+ if ( e . target . name == 'lukewcs_confirmbox_no' ) {
5654 if ( elementType == 'checkbox' ) {
5755 $elementObject . prop ( 'checked' , $confirmBoxObject . attr ( 'data-default' ) ) ;
5856 } else if ( elementType == 'radio' ) {
@@ -63,17 +61,17 @@ class LukeWCSphpBBConfirmBox {
6361 }
6462
6563 HideAll = ( ) => {
66- const $elementObject = this . $formObject . find ( 'input.confirmbox_active ' ) ;
67- const $confirmBoxObject = this . $formObject . find ( 'div[id$="_confirmbox"] ' ) ;
64+ const $elementObject = this . $formObject . find ( 'input.lukewcs_confirmbox_active ' ) ;
65+ const $confirmBoxObject = this . $formObject . find ( 'div.lukewcs_confirmbox ' ) ;
6866
6967 this . #changeBoxState( $elementObject , $confirmBoxObject , false ) ;
7068 }
7169
7270 #changeBoxState = ( $elementObject , $confirmBoxObject , showBox ) => {
7371 $elementObject . prop ( 'disabled' , ! ! showBox ) ;
74- $elementObject . toggleClass ( 'confirmbox_active ' , ! ! showBox ) ;
72+ $elementObject . toggleClass ( 'lukewcs_confirmbox_active ' , ! ! showBox ) ;
7573 $confirmBoxObject [ showBox ? 'show' : 'hide' ] ( this . animDuration ) ;
76- this . $submitObject . prop ( 'disabled' , showBox ?? this . $formObject . find ( 'input.confirmbox_active ' ) . length ) ;
74+ this . $submitObject . prop ( 'disabled' , showBox ?? this . $formObject . find ( 'input.lukewcs_confirmbox_active ' ) . length ) ;
7775 }
7876}
7977
0 commit comments