-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
128 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const driver = window.driver.js.driver; | ||
|
||
const driverObj = driver( | ||
{ | ||
showProgress: true, | ||
progressText: '{{current}} ' + adminWizardTourSettings.translations.of + ' {{total}}', | ||
showButtons: [ | ||
'next', | ||
'previous', | ||
'close' | ||
], | ||
nextBtnText: adminWizardTourSettings.translations.next, | ||
prevBtnText: adminWizardTourSettings.translations.previous, | ||
doneBtnText: adminWizardTourSettings.translations.close, | ||
steps: [ | ||
{ element: '#frm-packetery-api_password', popover: { title: adminWizardTourSettings.translations.apiPassword.title, description: adminWizardTourSettings.translations.apiPassword.description } }, | ||
{ element: '#frm-packetery-sender', popover: { title: adminWizardTourSettings.translations.apiSender.title, description: adminWizardTourSettings.translations.apiSender.description } }, | ||
{ element: '.sidebar', popover: { title: 'Title', description: 'Description' } }, | ||
{ element: '.footer', popover: { title: 'Title', description: 'Description' } }, | ||
], | ||
onDestroyStarted: function () { | ||
if (!driverObj.hasNextStep() || window.confirm("Are you sure?")) { | ||
driverObj.destroy(); | ||
} | ||
} | ||
}); | ||
driverObj.drive(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
namespace Packetery\Module\Views; | ||
|
||
use Packetery\Module\Framework\WpAdapter; | ||
use Packetery\Module\Options\Page; | ||
use Packetery\Nette\Http\Request; | ||
|
||
class WizardAssetManager { | ||
/** | ||
* @var WpAdapter | ||
*/ | ||
private $wpAdapter; | ||
|
||
/** | ||
* @var AssetManager | ||
*/ | ||
private $assetManager; | ||
|
||
/** | ||
* @var Request | ||
*/ | ||
private $request; | ||
|
||
public function __construct( | ||
AssetManager $assetManager, | ||
Request $request, | ||
WpAdapter $wpAdapter | ||
) { | ||
$this->assetManager = $assetManager; | ||
$this->request = $request; | ||
$this->wpAdapter = $wpAdapter; | ||
} | ||
|
||
public function enqueueWizardAssets(): void { | ||
$page = $this->request->getQuery( 'page' ); | ||
$isWizardEnabled = $this->request->getQuery( 'wizard-enabled' ) === 'true'; | ||
$isWizardExampleTourEnabled = $this->request->getQuery( 'wizard-example-tour-enabled' ) === 'true'; | ||
|
||
if ( $page === Page::SLUG && $isWizardEnabled ) { | ||
$this->assetManager->enqueueStyle( 'packetery-driverjs-css', 'public/libs/driverjs-1.3.4/driver.css' ); | ||
$this->assetManager->enqueueScript( 'packetery-driverjs', 'public/libs/driverjs-1.3.4/driver.js.iife.js', true ); | ||
|
||
$adminWizardTourSettings = [ | ||
'translations' => [ | ||
'next' => $this->wpAdapter->__( 'Next', 'packeta' ), | ||
'previous' => $this->wpAdapter->__( 'Previous', 'packeta' ), | ||
'close' => $this->wpAdapter->__( 'Close', 'packeta' ), | ||
'of' => $this->wpAdapter->__( 'of', 'packeta' ), | ||
'apiPassword' => [ | ||
'title' => $this->wpAdapter->__( 'API password', 'packeta' ), | ||
'description' => sprintf( | ||
$this->wpAdapter->__( 'API password can be found at %s', 'packeta' ), | ||
'<a href="https://client.packeta.com/support" target="_blank">https://client.packeta.com/support<a/>' | ||
), | ||
], | ||
'apiSender' => [ | ||
'title' => $this->wpAdapter->__( 'Sender', 'packeta' ), | ||
'description' => sprintf( | ||
/* translators: 1: emphasis start 2: emphasis end 3: client section link start 4: client section link end */ | ||
esc_html__( 'Fill here %1$ssender label%2$s - you will find it in %3$sclient section%4$s - user information - field \'Indication\'.', 'packeta' ), | ||
'<strong>', | ||
'</strong>', | ||
'<a href="https://client.packeta.com/senders" target="_blank">', | ||
'</a>' | ||
), | ||
], | ||
], | ||
]; | ||
|
||
if ( $isWizardExampleTourEnabled ) { | ||
$this->assetManager->enqueueScript( | ||
'packetery-admin-wizard-tour', | ||
'public/js/tours/admin-wizard-example.js', | ||
true, | ||
[ | ||
'packetery-driverjs', | ||
] | ||
); | ||
|
||
$this->wpAdapter->localizeScript( 'packetery-admin-wizard-tour', 'adminWizardTourSettings', $adminWizardTourSettings ); | ||
} | ||
} | ||
} | ||
} |