Skip to content

Commit

Permalink
refactorized javascript, update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
jcvignoli committed Dec 21, 2024
1 parent d94d667 commit 1ae7a58
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 62 deletions.
1 change: 1 addition & 0 deletions dist/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ v.4.2.3
* [bug] If AMP plugin is used, showing the admin bar, as it needs it (exception for AMP added to Popup_Movie, Popup_Person, Popup_Search classes)
* [bug] "Click more" links in taxonomy pages and persons popups wasn't working (changed strategy from async to defer for lumiere_hide_show js in class Frontend, hopefully will work)
* [bug] If WP is displayed in any language but English, taxonomy copy in Lumière admin was dysfunctional (use of array_keys() in Copy_Template_taxonomy and Detect_New_Template_Taxo classes to get the untranslated job/item instead of translated one, the comparaison was made between the translated and English version of the words, in Data class also in method lumiere_data_display_taxo_fields() using $items_key and $items_value)
* [bug] HTML labels and select in WordPress block editions compliants with HTML specifications (block movie index.js and Widget_Selection class fixed)

v.4.2.2
* [feature] Compatibility with Intelly Related (IRP) post plugin. If a post that includes Lumiere movies is displayed, IRP won't be displayed. This feature can be overriden in advanced general options (new auto plugin IRP, new option var imdbirpdisplay in admin options)
Expand Down
2 changes: 1 addition & 1 deletion dist/assets/js/lumiere_classic_links.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/class/frontend/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function lumiere_popup_redirect_include( string $template ): string|Virtu

// Exit if trying to do bad things.
if ( $one_must_exist === null || ( strlen( $one_must_exist ) > 0 ) === false || ( $nonce_valid === false && current_user_can( 'administrator' ) === false ) ) {
wp_die( esc_html__( 'Lumière Movies: Wrong movie id.', 'lumiere-movies' ) );
wp_die( esc_html__( 'Lumière Movies: Wrong movie id or title.', 'lumiere-movies' ) );
}

// Set the title.
Expand Down
1 change: 1 addition & 0 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ v.4.2.3
* [bug] If AMP plugin is used, showing the admin bar, as it needs it (exception for AMP added to Popup_Movie, Popup_Person, Popup_Search classes)
* [bug] "Click more" links in taxonomy pages and persons popups wasn't working (changed strategy from async to defer for lumiere_hide_show js in class Frontend, hopefully will work)
* [bug] If WP is displayed in any language but English, taxonomy copy in Lumière admin was dysfunctional (use of array_keys() in Copy_Template_taxonomy and Detect_New_Template_Taxo classes to get the untranslated job/item instead of translated one, the comparaison was made between the translated and English version of the words, in Data class also in method lumiere_data_display_taxo_fields() using $items_key and $items_value)
* [bug] HTML labels and select in WordPress block editions compliants with HTML specifications (block movie index.js and Widget_Selection class fixed)

v.4.2.2
* [feature] Compatibility with Intelly Related (IRP) post plugin. If a post that includes Lumiere movies is displayed, IRP won't be displayed. This feature can be overriden in advanced general options (new auto plugin IRP, new option var imdbirpdisplay in admin options)
Expand Down
89 changes: 30 additions & 59 deletions src/assets/js/lumiere_classic_links.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,34 @@
* This function on click on data "modal_window(.*)"
* 1- extracts info from data-(.*) <a> attribute
*/
document.addEventListener(
'DOMContentLoaded',
function () {

/** classic popup, people */

jQuery( 'a[data-modal_window_people]' ).click(
function(){
// vars from imdb-link-transformer.php
var tmppopupLarg = lumiere_vars.popupLarg;
var tmppopupLong = lumiere_vars.popupLong;
// var mid from the class data-highslidepeople to build the link
var modal_window_people = jQuery( this ).closest( 'a' ).data( 'modal_window_people' );
var modal_window_nonce = jQuery( this ).closest( 'a' ).data( 'modal_window_nonce' );

var url_imdbperso = lumiere_vars.urlpopup_person + '?mid=' + modal_window_people + '&_wpnonce=' + modal_window_nonce;

// classic popup
window.open( url_imdbperso, 'popup', 'resizable=yes, toolbar=no, scrollbars=yes, location=no, width=' + tmppopupLarg + ', height=' + tmppopupLong + ', top=5, left=5' )
}
);

/** classic popup, movie by title */

jQuery( 'a[data-modal_window_film]' ).click(
function(){
// vars from imdb-link-transformer.php
var tmppopupLarg = lumiere_vars.popupLarg;
var tmppopupLong = lumiere_vars.popupLong;
// var mid from the class data-highslidepeople to build the link
var modal_window_film = jQuery( this ).closest( 'a' ).data( 'modal_window_film' );
var modal_window_nonce = jQuery( this ).closest( 'a' ).data( 'modal_window_nonce' );

var url_imdbperso = lumiere_vars.urlpopup_film + '?film=' + modal_window_film + '&_wpnonce=' + modal_window_nonce;

// classic popup
window.open( url_imdbperso, 'popup', 'resizable=yes, toolbar=no, scrollbars=yes, location=no, width=' + tmppopupLarg + ', height=' + tmppopupLong + ', top=5, left=5' );
}
);

/** classic popup, movie by imdb id */

jQuery( 'a[data-modal_window_filmid]' ).click(
function(){
// vars from imdb-link-transformer.php
var tmppopupLarg = lumiere_vars.popupLarg;
var tmppopupLong = lumiere_vars.popupLong;
// var mid from the class data-highslidepeople to build the link
var modal_window_filmid = jQuery( this ).closest( 'a' ).data( 'modal_window_filmid' );
var modal_window_nonce = jQuery( this ).closest( 'a' ).data( 'modal_window_nonce' );

var url_imdbperso = lumiere_vars.urlpopup_film + '?mid=' + modal_window_filmid + '&_wpnonce=' + modal_window_nonce;

// classic popup
window.open( url_imdbperso, 'popup', 'resizable=yes, toolbar=no, scrollbars=yes, location=no, width=' + tmppopupLarg + ', height=' + tmppopupLong + ', top=5, left=5' );
}
);

document.addEventListener('DOMContentLoaded', function () {

/**
* Function to open a popup window with the specified URL and dimensions.
* @param {string} url - The URL to open in the popup.
* @param {number} width - The width of the popup window.
* @param {number} height - The height of the popup window.
*/
function openPopup(url, width, height) {
window.open(url, 'popup', `resizable=yes, toolbar=no, scrollbars=yes, location=no, width=${width}, height=${height}, top=5, left=5`);
}
);

/** People popup */
jQuery('a[data-modal_window_people]').click(function() {
const url = `${lumiere_vars.urlpopup_person}?mid=${jQuery(this).data('modal_window_people')}&_wpnonce=${jQuery(this).data('modal_window_nonce')}`;
openPopup(url, lumiere_vars.popupLarg, lumiere_vars.popupLong);
});

/** Movie by title popup */
jQuery('a[data-modal_window_film]').click(function() {
const url = `${lumiere_vars.urlpopup_film}?film=${jQuery(this).data('modal_window_film')}&_wpnonce=${jQuery(this).data('modal_window_nonce')}`;
openPopup(url, lumiere_vars.popupLarg, lumiere_vars.popupLong);
});

/** Movie by imdb id popup */
jQuery('a[data-modal_window_filmid]').click(function() {
const url = `${lumiere_vars.urlpopup_film}?mid=${jQuery(this).data('modal_window_filmid')}&_wpnonce=${jQuery(this).data('modal_window_nonce')}`;
openPopup(url, lumiere_vars.popupLarg, lumiere_vars.popupLong);
});

});
2 changes: 1 addition & 1 deletion src/class/frontend/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function lumiere_popup_redirect_include( string $template ): string|Virtu

// Exit if trying to do bad things.
if ( $one_must_exist === null || ( strlen( $one_must_exist ) > 0 ) === false || ( $nonce_valid === false && current_user_can( 'administrator' ) === false ) ) {
wp_die( esc_html__( 'Lumière Movies: Wrong movie id.', 'lumiere-movies' ) );
wp_die( esc_html__( 'Lumière Movies: Wrong movie id or title.', 'lumiere-movies' ) );
}

// Set the title.
Expand Down

0 comments on commit 1ae7a58

Please sign in to comment.