| @@ -91,9 +91,9 @@ | ||
| 91 | 91 | elementor.hooks.addAction('panel/close_editor', function() { |
| 92 | 92 | observer.disconnect(); |
| 93 | 93 | }); |
| 94 | 94 | } catch (error) { |
| 95 | - console.error('Error when setting up observer:', error); | |
| 95 | + // console.error('Error when setting up observer:', error); | |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | }); |
| 99 | 99 | |
| @@ -122,9 +122,21 @@ | ||
| 122 | 122 | .king-addons-help-wrapper { |
| 123 | 123 | width: 100%; |
| 124 | 124 | max-width: 100%; |
| 125 | 125 | box-sizing: border-box; |
| 126 | + display: block; | |
| 127 | + flex: 0 0 100%; | |
| 128 | + min-width: 0; | |
| 126 | 129 | } |
| 130 | + | |
| 131 | + /* Ensure injected blocks sit under the Need Help link */ | |
| 132 | + #elementor-panel__editor__help.king-addons-help-injected { | |
| 133 | + flex-wrap: wrap; | |
| 134 | + } | |
| 135 | + | |
| 136 | + #elementor-panel__editor__help.king-addons-help-injected > #elementor-panel__editor__help__link { | |
| 137 | + flex: 0 0 100%; | |
| 138 | + } | |
| 127 | 139 | |
| 128 | 140 | .king-addons-bug-report { |
| 129 | 141 | background: #ffffff; |
| 130 | 142 | border: 1px solid #ddd; |
| @@ -186,8 +198,24 @@ | ||
| 186 | 198 | .king-addons-bug-report-copy-btn.copied { |
| 187 | 199 | background: #28a745; |
| 188 | 200 | } |
| 189 | 201 | |
| 202 | + /* Responsive: prevent overflow in narrow Elementor panels */ | |
| 203 | + @media (max-width: 420px) { | |
| 204 | + .king-addons-bug-report-email-section { | |
| 205 | + flex-direction: column; | |
| 206 | + align-items: stretch; | |
| 207 | + } | |
| 208 | + | |
| 209 | + .king-addons-bug-report-email-field { | |
| 210 | + width: 100%; | |
| 211 | + } | |
| 212 | + | |
| 213 | + .king-addons-bug-report-copy-btn { | |
| 214 | + width: 100%; | |
| 215 | + } | |
| 216 | + } | |
| 217 | + | |
| 190 | 218 | /* Promo block styles */ |
| 191 | 219 | .king-addons-promo-block { |
| 192 | 220 | background: linear-gradient(135deg, #93117e 0%, #d946ef 100%); |
| 193 | 221 | border-radius: 6px; |
| @@ -192,14 +220,15 @@ | ||
| 192 | 220 | background: linear-gradient(135deg, #93117e 0%, #d946ef 100%); |
| 193 | 221 | border-radius: 6px; |
| 194 | 222 | padding: 16px; |
| 195 | 223 | margin-top: 12px; |
| 196 | - margin-bottom: 0; | |
| 224 | + margin-bottom: 12px; | |
| 197 | 225 | color: white; |
| 198 | 226 | position: relative; |
| 199 | 227 | overflow: hidden; |
| 200 | 228 | width: 100%; |
| 201 | 229 | box-sizing: border-box; |
| 230 | + min-width: 0; | |
| 202 | 231 | } |
| 203 | 232 | |
| 204 | 233 | .king-addons-promo-block::before { |
| 205 | 234 | content: ''; |
| @@ -308,14 +337,14 @@ | ||
| 308 | 337 | } |
| 309 | 338 | `; |
| 310 | 339 | document.head.appendChild(style); |
| 311 | 340 | } catch (styleError) { |
| 312 | - console.error('Error when adding styles:', styleError); | |
| 341 | + // console.error('Error when adding styles:', styleError); | |
| 313 | 342 | } |
| 314 | 343 | } |
| 315 | 344 | |
| 316 | 345 | $(window).on('elementor:init', function() { |
| 317 | - console.log('elementor:init event fired for mega menu editor'); | |
| 346 | + // console.log('elementor:init event fired for mega menu editor'); | |
| 318 | 347 | const panelEl = document.getElementById('elementor-panel'); |
| 319 | 348 | |
| 320 | 349 | // Watch for newly-added .king-addons-pro-control elements |
| 321 | 350 | const observer = new MutationObserver(function(mutations) { |
| @@ -406,9 +435,9 @@ | ||
| 406 | 435 | copyBtn.textContent = 'Copy'; |
| 407 | 436 | copyBtn.classList.remove('copied'); |
| 408 | 437 | }, 2000); |
| 409 | 438 | }).catch(err => { |
| 410 | - console.error('Error copying email:', err); | |
| 439 | + // console.error('Error copying email:', err); | |
| 411 | 440 | alert('Failed to copy email address.'); |
| 412 | 441 | }); |
| 413 | 442 | }); |
| 414 | 443 | |
| @@ -423,9 +452,9 @@ | ||
| 423 | 452 | |
| 424 | 453 | const promoBlock = document.createElement('div'); |
| 425 | 454 | promoBlock.className = 'king-addons-promo-block'; |
| 426 | 455 | promoBlock.innerHTML = ` |
| 427 | - <div class="king-addons-promo-title">Unlock <span class="king-addons-promo-highlight">650+</span> premium templates and <span class="king-addons-promo-highlight">200+</span> advanced features for only <span class="king-addons-promo-highlight">$4.99</span>/month.</div> | |
| 456 | + <div class="king-addons-promo-title">Get <span class="king-addons-promo-highlight">4,000+</span> premium templates and sections, <span class="king-addons-promo-highlight">80+</span> widgets, <span class="king-addons-promo-highlight">200+</span> advanced features, and AI tools for Elementor. From <span class="king-addons-promo-highlight">$4</span>/mo, billed annually.</div> | |
| 428 | 457 | <div class="king-addons-promo-text">Upgrade now and boost your website's performance!</div> |
| 429 | 458 | <div class="king-addons-promo-small">Trusted by 20,000+ users</div> |
| 430 | 459 | <div class="king-addons-promo-buttons"> |
| 431 | 460 | <a href="https://kingaddons.com/pricing/?utm_source=kng-module-elementor-panel-upgrade&utm_medium=plugin&utm_campaign=kng" target="_blank" class="king-addons-promo-btn king-addons-promo-btn-primary">Upgrade Now</a> |
| @@ -434,54 +463,96 @@ | ||
| 434 | 463 | `; |
| 435 | 464 | return promoBlock; |
| 436 | 465 | } |
| 437 | 466 | |
| 438 | - function replaceBugReportInPanel() { | |
| 467 | + function updateHelpPanel(widgetType) { | |
| 439 | 468 | const helpSection = document.querySelector('#elementor-panel__editor__help'); |
| 440 | - if (helpSection) { | |
| 441 | - // Clear existing content and create wrapper | |
| 442 | - helpSection.innerHTML = ''; | |
| 443 | - | |
| 444 | - // Create wrapper div | |
| 445 | - const wrapper = document.createElement('div'); | |
| 469 | + if (!helpSection) { | |
| 470 | + return; | |
| 471 | + } | |
| 472 | + | |
| 473 | + const helpLink = helpSection.querySelector('#elementor-panel__editor__help__link'); | |
| 474 | + | |
| 475 | + const shouldShowPromo = !(typeof kingAddonsEditor !== 'undefined' && kingAddonsEditor.isPro); | |
| 476 | + const shouldShowBugReport = !!(widgetType && widgetType.startsWith('king-addons-')); | |
| 477 | + | |
| 478 | + let wrapper = helpSection.querySelector('.king-addons-help-wrapper'); | |
| 479 | + if (!wrapper) { | |
| 480 | + wrapper = document.createElement('div'); | |
| 446 | 481 | wrapper.className = 'king-addons-help-wrapper'; |
| 447 | - | |
| 448 | - // Add promo block only if not PRO user | |
| 449 | - const promoBlock = createPromoBlock(); | |
| 450 | - if (promoBlock) { | |
| 451 | - wrapper.appendChild(promoBlock); | |
| 482 | + helpSection.appendChild(wrapper); | |
| 483 | + } | |
| 484 | + | |
| 485 | + // Promo: show for ALL widgets when Pro is not active. | |
| 486 | + const existingPromo = wrapper.querySelector('.king-addons-promo-block'); | |
| 487 | + if (shouldShowPromo) { | |
| 488 | + if (!existingPromo) { | |
| 489 | + const promoBlock = createPromoBlock(); | |
| 490 | + if (promoBlock) { | |
| 491 | + wrapper.prepend(promoBlock); | |
| 492 | + } | |
| 452 | 493 | } |
| 453 | - | |
| 454 | - // Always add bug report section | |
| 455 | - wrapper.appendChild(createBugReportSection()); | |
| 456 | - | |
| 457 | - // Add wrapper to help section | |
| 458 | - helpSection.appendChild(wrapper); | |
| 494 | + } else if (existingPromo) { | |
| 495 | + existingPromo.remove(); | |
| 459 | 496 | } |
| 497 | + | |
| 498 | + // Bug report: only for King Addons widgets. | |
| 499 | + const existingBugReport = wrapper.querySelector('.king-addons-bug-report'); | |
| 500 | + if (shouldShowBugReport) { | |
| 501 | + if (!existingBugReport) { | |
| 502 | + wrapper.appendChild(createBugReportSection()); | |
| 503 | + } | |
| 504 | + } else if (existingBugReport) { | |
| 505 | + existingBugReport.remove(); | |
| 506 | + } | |
| 507 | + | |
| 508 | + // Clean up empty wrapper. | |
| 509 | + if (!wrapper.querySelector('.king-addons-promo-block') && !wrapper.querySelector('.king-addons-bug-report')) { | |
| 510 | + wrapper.remove(); | |
| 511 | + } | |
| 512 | + | |
| 513 | + // Place the Elementor "Need Help" link at the very end when we inject content. | |
| 514 | + // If bug-report is visible (King Addons widget), hide the link entirely. | |
| 515 | + const hasWrapper = !!helpSection.querySelector('.king-addons-help-wrapper'); | |
| 516 | + const hasBugReport = !!helpSection.querySelector('.king-addons-bug-report'); | |
| 517 | + if (helpLink) { | |
| 518 | + if (hasBugReport) { | |
| 519 | + helpLink.style.display = 'none'; | |
| 520 | + } else { | |
| 521 | + helpLink.style.display = ''; | |
| 522 | + } | |
| 523 | + | |
| 524 | + if (hasWrapper && helpLink.parentNode === helpSection) { | |
| 525 | + helpSection.appendChild(helpLink); | |
| 526 | + } | |
| 527 | + } | |
| 528 | + | |
| 529 | + // Toggle layout helper class only when we inject content. | |
| 530 | + if (hasWrapper) { | |
| 531 | + helpSection.classList.add('king-addons-help-injected'); | |
| 532 | + } else { | |
| 533 | + helpSection.classList.remove('king-addons-help-injected'); | |
| 534 | + } | |
| 460 | 535 | } |
| 461 | 536 | |
| 462 | - // Hook into Elementor panel events to replace help section for King Addons widgets | |
| 537 | + // Hook into Elementor panel events to inject promo (all widgets) + bug report (King Addons only) | |
| 463 | 538 | if (window.elementor) { |
| 464 | 539 | elementor.hooks.addAction('panel/open_editor/widget', function(panel, model, view) { |
| 465 | 540 | const widgetType = model.attributes.widgetType; |
| 466 | - | |
| 467 | - // Check if it's a King Addons widget | |
| 468 | - if (widgetType && widgetType.startsWith('king-addons-')) { | |
| 469 | - // Wait a bit for the panel to fully load, then replace the help section | |
| 470 | - setTimeout(() => { | |
| 471 | - replaceBugReportInPanel(); | |
| 472 | - }, 100); | |
| 473 | - } | |
| 541 | + | |
| 542 | + // Wait a bit for the panel to fully load, then update help panel. | |
| 543 | + setTimeout(() => { | |
| 544 | + updateHelpPanel(widgetType); | |
| 545 | + }, 100); | |
| 474 | 546 | }); |
| 475 | 547 | } |
| 476 | 548 | |
| 477 | - // Initial replacement if we're already on a King Addons widget | |
| 549 | + // Initial injection if we're already on a widget | |
| 478 | 550 | setTimeout(() => { |
| 479 | 551 | if (window.elementor && elementor.panel && elementor.panel.currentView) { |
| 480 | 552 | const currentModel = elementor.panel.currentView.model; |
| 481 | - if (currentModel && currentModel.attributes.widgetType && currentModel.attributes.widgetType.startsWith('king-addons-')) { | |
| 482 | - replaceBugReportInPanel(); | |
| 483 | - } | |
| 553 | + const widgetType = currentModel && currentModel.attributes ? currentModel.attributes.widgetType : ''; | |
| 554 | + updateHelpPanel(widgetType); | |
| 484 | 555 | } |
| 485 | 556 | }, 500); |
| 486 | 557 | })(); |
| 487 | 558 | }); |