Changeset 3362973
- Timestamp:
- 09/17/2025 07:33:48 AM (5 months ago)
- Location:
- printess-editor/trunk
- Files:
-
- 4 edited
-
includes/js/printessEditor.js (modified) (8 diffs)
-
includes/js/printessWoocommerce.js (modified) (11 diffs)
-
printess.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
printess-editor/trunk/includes/js/printessEditor.js
r3341111 r3362973 507 507 console.error(e); 508 508 } 509 const iframe = document.getElementById("printess"); 510 if (iframe && !context.hidePricesInEditor) { 511 setTimeout(() => { 512 iframe.contentWindow.postMessage({ 513 cmd: "refreshPriceDisplay", 514 priceDisplay: priceInfo 515 }, "*"); 516 }, 0); 517 } 518 //BcUI 519 const component = this.getPrintessComponent(); 520 if (component && component.editor) { 521 component.editor.ui.refreshPriceDisplay(priceInfo); 509 if (!context.hidePricesInEditor) { 510 const iframe = document.getElementById("printess"); 511 if (iframe) { 512 setTimeout(() => { 513 iframe.contentWindow.postMessage({ 514 cmd: "refreshPriceDisplay", 515 priceDisplay: priceInfo 516 }, "*"); 517 }, 0); 518 } 519 //BcUI 520 const component = this.getPrintessComponent(); 521 if (component && component.editor) { 522 component.editor.ui.refreshPriceDisplay(priceInfo); 523 } 522 524 } 523 525 } … … 646 648 } 647 649 } 650 static closeAllHtmlDialogs() { 651 document.querySelectorAll(":not(printess-owned) dialog").forEach((x) => { 652 if (typeof x.close === "function") { 653 try { 654 x.close(); 655 } 656 catch (ex) { 657 console.error(ex); 658 } 659 } 660 }); 661 } 648 662 async showBcUiVersion(context, callbacks) { 649 663 const that = this; … … 651 665 let isSaveToken = context && context.templateNameOrSaveToken && context.templateNameOrSaveToken.indexOf("st:") === 0; 652 666 let pageCount = null; 667 let useCustomLoader = false; 653 668 let formFields = null; 654 669 let mergeTemplates = null; 670 PrintessEditor.closeAllHtmlDialogs(); 655 671 if (!isSaveToken) { 656 672 formFields = PrintessEditor.applyFormFieldMappings(context.getCurrentFormFieldValues(), context.getFormFieldMappings()); … … 666 682 } 667 683 } 684 const globalSettings = PrintessEditor.getGlobalShopSettings(); 685 if (globalSettings && globalSettings.customLoader && typeof globalSettings.customLoader.onShowLoader === "function") { 686 try { 687 globalSettings.customLoader.onShowLoader(); 688 useCustomLoader = true; 689 } 690 catch (e) { 691 console.error(e); 692 } 693 } 668 694 const startupParams = {}; 669 695 const loaderUrl = that.getLoaderUrl(this.Settings.editorUrl, this.Settings.editorVersion, startupParams); … … 713 739 } 714 740 await callbacks.onLoadAsync(context.templateNameOrSaveToken); 741 if (globalSettings && globalSettings.customLoader && typeof globalSettings.customLoader.onHideLoader === "function") { 742 try { 743 globalSettings.customLoader.onHideLoader(); 744 } 745 catch (e) { 746 console.error(e); 747 } 748 } 715 749 }, 1000); 716 750 printessComponent.editor.ui.show(); … … 725 759 } 726 760 const attachParams = { 761 suppressLoadingAnimation: useCustomLoader, 727 762 domain: that.Settings.apiDomain, 728 763 mergeTemplates: mergeTemplates, … … 785 820 that.hideBcUiVersion(context, true); 786 821 } 822 }, 823 loadingDoneCallback: () => { 824 if (globalSettings && globalSettings.customLoader && typeof globalSettings.customLoader.onHideLoader === "function") { 825 try { 826 globalSettings.customLoader.onHideLoader(); 827 } 828 catch (e) { 829 console.error(e); 830 } 831 } 787 832 } 788 833 }; … … 846 891 let isSaveToken = context && context.templateNameOrSaveToken && context.templateNameOrSaveToken.indexOf("st:") === 0; 847 892 this.visible = true; 893 PrintessEditor.closeAllHtmlDialogs(); 848 894 const callbacks = { 849 895 onBack: () => { -
printess-editor/trunk/includes/js/printessWoocommerce.js
r3341026 r3362973 1 const initPrintessWCEditor = function (printessSettings) { 1 function trapFocus(root) { 2 const keyboardFocusableElements = root.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]'); 3 const lastFocusableElement = keyboardFocusableElements[keyboardFocusableElements.length - 1]; 4 const firstFocusableElement = keyboardFocusableElements[0]; 5 firstFocusableElement.addEventListener("keydown", (e) => { 6 if (e.key === "Tab" && e.shiftKey && lastFocusableElement) { 7 e.preventDefault(); 8 lastFocusableElement.focus(); 9 } 10 }); 11 lastFocusableElement.addEventListener("keydown", (e) => { 12 if (e.key === "Tab" && !e.shiftKey && firstFocusableElement) { 13 e.preventDefault(); 14 firstFocusableElement.focus(); 15 } 16 }); 17 firstFocusableElement.focus(); 18 } 19 const initPrintessWCEditor = function (printessSettings) { 2 20 const CART_FORM_SELECTOR = "form.cart"; 3 21 let itemUsage = null; … … 197 215 const keyDownHandler = (e) => { 198 216 if (e.key === 'Enter' || e.keyCode === 13) { 199 e.preventDefault(); 200 e.stopPropagation(); 201 internalSaveCallback(); 217 // if a button is active, Enter should activate the button, not do anything else 218 if (!(document.activeElement instanceof HTMLButtonElement)) { 219 e.preventDefault(); 220 e.stopPropagation(); 221 internalSaveCallback(); 222 } 202 223 } 203 224 else if (e.key === 'Escape' || e.keyCode === 27) { … … 252 273 dialog.addEventListener("mouseup", cancelMouse); 253 274 dialog.addEventListener("mousemove", cancelMouse); 254 dialog.addEventListener("keydown", key UpHandler);255 dialog.addEventListener("keyup", key DownHandler);275 dialog.addEventListener("keydown", keyDownHandler); 276 dialog.addEventListener("keyup", keyUpHandler); 256 277 if (!dialog.getAttribute("data-initialized")) { 257 278 document.body.appendChild(dialog); … … 266 287 const cancelButton = document.getElementById("printess_cancel_button"); 267 288 if (cancelButton) { 289 cancelButton.type = "button"; 268 290 cancelButton.addEventListener("click", internalCancelCallback); 269 291 } 292 cancelButton.style.backgroundColor = "red"; 293 trapFocus(dialog); 270 294 }; 271 295 const postMessage = (cmd, properties) => { … … 293 317 } 294 318 } 319 trapFocus(overlay); 295 320 }; 296 321 const hideInformationOverlay = () => { … … 1198 1223 }, timeout); 1199 1224 } 1225 let previouslyFocused; 1200 1226 function showDialog(prefix, initialValue, callback) { 1201 1227 const textInput = document.getElementById(prefix + "_edit"); … … 1205 1231 const bodyElement = document.querySelector("body"); 1206 1232 let hide = null; 1233 previouslyFocused = document.activeElement; 1207 1234 const keyUpHandler = (e) => { 1208 1235 if (e.key === 'Enter' || e.keyCode === 13) { … … 1217 1244 const keyDownHandler = (e) => { 1218 1245 if (e.key === 'Enter' || e.keyCode === 13) { 1219 e.preventDefault(); 1220 e.stopPropagation(); 1221 hide(); 1222 if (typeof callback === "function") { 1223 callback(true, textInput.value); 1246 const activeDomElement = document.activeElement; 1247 // if a button is active, Enter should activate the button, not do anything else 1248 if (!(activeDomElement instanceof HTMLButtonElement) && activeDomElement.id === "printess_display_name_cancel_button") { 1249 e.preventDefault(); 1250 e.stopPropagation(); 1251 hide(); 1252 if (typeof callback === "function") { 1253 callback(true, textInput.value); 1254 } 1224 1255 } 1225 1256 } … … 1242 1273 if (dlg) { 1243 1274 dlg.style.display = "none"; 1244 dlg.removeEventListener("keydown", keyUpHandler); 1245 dlg.removeEventListener("keyup", keyDownHandler); 1275 dlg.removeEventListener("keyup", keyUpHandler); 1276 dlg.removeEventListener("keydown", keyDownHandler); 1277 } 1278 if (previouslyFocused && previouslyFocused instanceof HTMLElement) { 1279 previouslyFocused.focus(); 1246 1280 } 1247 1281 }; … … 1265 1299 } 1266 1300 if (cancelButton) { 1301 cancelButton.type = "button"; 1267 1302 cancelButton.addEventListener("click", cancelCallback); 1268 1303 } … … 1272 1307 if (dlg) { 1273 1308 dlg.style.display = "block"; 1274 dlg.addEventListener("key down", keyUpHandler);1275 dlg.addEventListener("key up", keyDownHandler);1309 dlg.addEventListener("keyup", keyUpHandler); 1310 dlg.addEventListener("keydown", keyDownHandler); 1276 1311 } 1312 trapFocus(dlg); 1277 1313 } 1278 1314 function printessRegisterCheckoutFilters(registerCheckoutFilters) { -
printess-editor/trunk/printess.php
r3343315 r3362973 5 5 * Plugin URI: https://printess.com/kb/integrations/woo-commerce/index.html 6 6 * Developer: Bastian Kröger ([email protected]); Alexander Oser ([email protected]) 7 * Version: 1.6. 587 * Version: 1.6.60 8 8 * Author: Printess 9 9 * Author URI: https://printess.com … … 14 14 * Tested up to: 6.8 15 15 * 16 * Woo: 10000:92401 7dfsfhsf8429842386wdff234sfd16 * Woo: 10000:924018dfsfhsf8429842386wdff234sfd 17 17 * WC requires at least: 5.8 18 18 * WC tested up to: 9.8.2 … … 157 157 158 158 foreach($cart_contents as $item_key => &$item) { 159 if(array_key_exists("printess-save-token", $item) ) {159 if(array_key_exists("printess-save-token", $item) && array_key_exists("printess-design-name", $item)) { 160 160 $item_save_token = $item["printess-save-token"]; 161 161 $item_design_name = $item["printess-design-name"]; … … 2258 2258 // Sort the cart items to newest item first. 2259 2259 $sorted_cart_contents = $cart_contents; // $b will be a different array. 2260 usort( 2261 $sorted_cart_contents, 2262 function ( $a, $b ) { 2263 if ( array_key_exists( 'printess_date_added', $a ) && array_key_exists( 'printess_date_added', $b ) ) { 2264 return strcmp( $a['printess_date_added'], $b['printess_date_added'] ) * -1; 2265 } elseif ( array_key_exists( 'printess_date_added', $a ) && ! array_key_exists( 'printess_date_added', $b ) ) { 2266 return -1; 2267 } elseif ( ! array_key_exists( 'printess_date_added', $a ) && array_key_exists( 'printess_date_added', $b ) ) { 2268 return 1; 2269 } else { 2270 return $sort_order[ $a->id ] < $sort_order[ $b->id ] ? -1 : 1; 2271 } 2272 } 2273 ); 2260 2261 try { 2262 usort( 2263 $sorted_cart_contents, 2264 function ( $a, $b ) { 2265 if ( array_key_exists( 'printess_date_added', $a ) && array_key_exists( 'printess_date_added', $b ) ) { 2266 return strcmp( $a['printess_date_added'], $b['printess_date_added'] ) * -1; 2267 } elseif ( array_key_exists( 'printess_date_added', $a ) && ! array_key_exists( 'printess_date_added', $b ) ) { 2268 return -1; 2269 } elseif ( ! array_key_exists( 'printess_date_added', $a ) && array_key_exists( 'printess_date_added', $b ) ) { 2270 return 1; 2271 } else { 2272 $a_id = -1; 2273 $b_id = -1; 2274 2275 if(property_exists($a, "id")) { 2276 $a_id = $a->id; 2277 } else if(is_array($a) && array_key_exists("id", $a)) { 2278 $a_id = $a["id"]; 2279 } else { 2280 //Give up and sort it at the end 2281 return 1; 2282 } 2283 2284 if(property_exists($b, "id")) { 2285 $a_id = $a->id; 2286 } else if(is_array($b) && array_key_exists("id", $b)) { 2287 $b_id = $b["id"]; 2288 } else { 2289 //Give up and sort it at the end 2290 return -1; 2291 } 2292 2293 return $sort_order[ $a_id ] < $sort_order[ $b_id ] ? -1 : 1; 2294 } 2295 } 2296 ); 2297 } catch( \Exception $ex) { 2298 $sorted_cart_contents = $cart_contents; 2299 } 2274 2300 2275 2301 $index = 0; -
printess-editor/trunk/readme.txt
r3343315 r3362973 318 318 = 1.6.58 = 319 319 - Fixed wrong BillingCity variable name that prevented billing city to be pushed into the buyer side of the editor. 320 321 = 1.6.59 = 322 - Fixed cart sorting for shopping cart items that are not of type object but of type array. 323 324 = 1.6.60 = 325 - Fixed wrong behaviour in PanelUi that did not hide the price when it was configured to be hidden. 326 - Saving dialog, saving reminder dialog and provide design name dialog are now accessible.
Note: See TracChangeset
for help on using the changeset viewer.