Skip to content

Commit

Permalink
Merge pull request joomla#11 from joomla-projects/default-tours
Browse files Browse the repository at this point in the history
Default Tours Feature
  • Loading branch information
khu5h1 authored Jan 9, 2023
2 parents a20fcde + 984979d commit 9c54246
Show file tree
Hide file tree
Showing 11 changed files with 649 additions and 114 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

37 changes: 32 additions & 5 deletions administrator/components/com_guidedtours/forms/step.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<field
name="step-no"
type="hidden"
label="COM_GUIDEDTOURS_STEPID_LABEL"
default="1"
/>

Expand Down Expand Up @@ -39,7 +38,6 @@
<field
name="tour_id"
type="hidden"
label="COM_GUIDEDTOURS_TOURID_LABEL"
class="readonly"
readonly="true"
/>
Expand All @@ -53,7 +51,7 @@
<field
name="title"
type="text"
label="Step Title"
label="COM_GUIDEDTOURS_STEP_TITLE"
required="true"
/>

Expand All @@ -80,13 +78,42 @@
<option value="-2">JTRASHED</option>
</field>

<field
name="type"
type="list"
label="COM_GUIDEDTOURS_TYPE_LABEL"
default="0"
description="COM_GUIDEDTOURS_TYPE_DESC"
validate="options"
>
<option value="0">COM_GUIDEDTOURS_FIELD_VALUE_NEXT_STEP</option>
<option value="1">COM_GUIDEDTOURS_FIELD_VALUE_REDIRECT</option>
<option value="2">COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVE_TOUR</option>
</field>

<field
name="url"
type="url"
label="COM_GUIDEDTOURS_URL_LABEL"
description="COM_GUIDEDTOURS_URL_DESC"
label="COM_GUIDEDTOURS_TYPE_REDIRECT_URL_LABEL"
description="COM_GUIDEDTOURS_TYPE_REDIRECT_URL_DESC"
showon="type:1"
filter="string"
/>

<field
name="interactivetour"
type="list"
label="COM_GUIDEDTOURS_TYPE_INTERACTIVE_TOUR_LABEL"
description="COM_GUIDEDTOURS_INTERACTIVE_TOUR_DESC"
showon="type:2"
filter="string"
validate="options"
>
<option value="1">COM_GUIDEDTOURS_TYPE_INTERACTIVE_TOUR_BUTTON_LABEL</option>
<option value="2">COM_GUIDEDTOURS_TYPE_INTERACTIVE_TOUR_TEXT_FIELD_LABEL</option>
<option value="3">COM_GUIDEDTOURS_TYPE_INTERACTIVE_TOUR_OTHERS_LABEL</option>
</field>

<field
name="checked_out"
type="hidden"
Expand Down
9 changes: 6 additions & 3 deletions administrator/components/com_guidedtours/guidedtours.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" method="upgrade">
<name>COM_GUIDEDTOURS</name>
<creationDate>June 2022</creationDate>
<author>Joomla! Project</author>
<creationDate>2022-06</creationDate>
<copyright>(C) 2022 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<version>4.1.0</version>
<description>COM_GUIDEDTOURS_XML_DESCRIPTION</description>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>4.3.0</version>
<description>COM_GUIDEDTOURS_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Component\Guidedtours</namespace>
<administration>
<filename>access.xml</filename>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ public function getListQuery()
$this->getState(
'list.select',
'a.*, (SELECT COUNT(' . $db->quoteName('description') . ') FROM '
. $db->quoteName('#__guidedtour_steps') . ' WHERE ' . $db->quoteName('tour_id') . ' = ' . $db->quoteName('a.id') . ') AS ' . $db->quoteName('steps')
. $db->quoteName('#__guidedtour_steps') . ' WHERE ' . $db->quoteName('tour_id') . ' = '
. $db->quoteName('a.id') . ') AS ' . $db->quoteName('steps')
)
);
$query->from('#__guidedtours AS a');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
<?php

/**
* File Doc Comment_
* PHP version 5
* @package Joomla.Administrator
* @subpackage com_guidedtours
*
* @category Component
* @package Joomla.Administrator
* @author Joomla! <admin@joomla.org>
*
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @link admin@joomla.org
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Guidedtours\Administrator\Service\HTML;
Expand Down
2 changes: 2 additions & 0 deletions administrator/components/com_guidedtours/tmpl/step/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
<?php echo $this->form->renderField('step-no'); ?>
<?php echo $this->form->renderField('position'); ?>
<?php echo $this->form->renderField('target'); ?>
<?php echo $this->form->renderField('type'); ?>
<?php echo $this->form->renderField('url'); ?>
<?php echo $this->form->renderField('interactivetour'); ?>
<?php $this->form->setValue('tour_id', null, $tour_id); ?>
<?php echo $this->form->renderField('tour_id'); ?>

Expand Down
24 changes: 17 additions & 7 deletions administrator/language/en-GB/com_guidedtours.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; Joomla! Project
; Copyright (C) 2005 - 2019 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8

COM_GUIDEDTOURS="Guided Tour"
Expand Down Expand Up @@ -41,19 +41,29 @@ COM_GUIDEDTOURS_STEP_DESC="Step descending"
COM_GUIDEDTOURS_STEP_FILTER_SEARCH_DESC="Search in id, title and description. Prefix with ID: to search for step ID or DESCRIPTION: to search only description text."
COM_GUIDEDTOURS_STEP_ID="ID"
COM_GUIDEDTOURS_STEP_TITLE="Step Title"
COM_GUIDEDTOURS_STEPID_LABEL="Step ID"
COM_GUIDEDTOURS_STEPS="Steps"
COM_GUIDEDTOURS_STEPS_LIST="Guided Tours"
COM_GUIDEDTOURS_TARGET_DESC="Add the target item to attach your step element to. Options: .classname, #id or leave blank for a centered step."
COM_GUIDEDTOURS_TARGET_LABEL="Target"
COM_GUIDEDTOURS_TITLE="Guided Tours"
COM_GUIDEDTOURS_TOUR_ID="ID"
COM_GUIDEDTOURS_TOUR_TITLE="Tour Title"
COM_GUIDEDTOURS_TOURID_LABEL="Tour ID"
COM_GUIDEDTOURS_URL_DESC="Enter the Relative URL of the page from where you want to Start the Tour e.g administrator/index.php?option=com_guidedtours&view=tours for guided tour relative URL."
COM_GUIDEDTOURS_URL_LABEL="URL"
COM_GUIDEDTOURS_TYPE_REDIRECT_URL_DESC="Enter the Relative URL of the page from where you want to Start the Tour e.g administrator/index.php?option=com_guidedtours&view=tours for guided tour relative URL."
COM_GUIDEDTOURS_TYPE_REDIRECT_URL_LABEL="URL"
COM_GUIDEDTOURS_XML_DESCRIPTION="Component for managing Guided Tours functionality"
COM_GUIDEDTOURS="Guided Tours"
JDESCRIPTION_ASC="Description ascending"
JDESCRIPTION_DESC="Description ascending"
MOD_MENU_MANAGE_GUIDEDTOURS="Guided Tours"
MOD_MENU_MANAGE_GUIDEDTOURS="Guided Tours"
COM_GUIDEDTOURS_URL_LABEL = "URL"
COM_GUIDEDTOURS_URL_DESC = "Enter the Relative URL of the page from where you want to Start the Tour e.g administrator/index.php?option=com_guidedtours&view=tours for guided tour relative URL."
COM_GUIDEDTOURS_TYPE_LABEL = "Type"
COM_GUIDEDTOURS_TYPE_DESC = "Click on the type which you want to select for the tour"
COM_GUIDEDTOURS_FIELD_VALUE_REDIRECT = "Redirect"
COM_GUIDEDTOURS_FIELD_VALUE_NEXT_STEP = "Next Step"
COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVE_TOUR = "Interactive Tour"
COM_GUIDEDTOURS_INTERACTIVE_TOUR_DESC = "Click on the type of interactive step which you want to select"
COM_GUIDEDTOURS_TYPE_INTERACTIVE_TOUR_LABEL = "Interactive Step"
COM_GUIDEDTOURS_TYPE_INTERACTIVE_TOUR_BUTTON_LABEL = "Button"
COM_GUIDEDTOURS_TYPE_INTERACTIVE_TOUR_TEXT_FIELD_LABEL = "Text Field"
COM_GUIDEDTOURS_TYPE_INTERACTIVE_TOUR_OTHERS_LABEL = "Others"
103 changes: 88 additions & 15 deletions build/media_source/plg_system_tour/js/guide.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ function addStepToTourButton(tour, obj, tourId, index, buttons, uri) {
element: obj[tourId].steps[index].target,
on: obj[tourId].steps[index].position,
url: obj[tourId].steps[index].url,
type: obj[tourId].steps[index].type,
interactivetour: obj[tourId].steps[index].interactivetour,
},

buttons: buttons,
Expand All @@ -48,7 +50,9 @@ function addStepToTourButton(tour, obj, tourId, index, buttons, uri) {
show() {
var currentstepIndex = `${tour.currentStep.id}` - "0";
sessionStorage.setItem("currentStepId", currentstepIndex);
checkAndRedirect(uri + tour.currentStep.options.attachTo.url);
if (obj[tourId].steps[index].type == 1) {
checkAndRedirect(uri + tour.currentStep.options.attachTo.url);
}
},
},
});
Expand All @@ -66,7 +70,7 @@ function addInitialStepToTourButton(tour, obj, tourId) {
action() {
return tour.next();
},
text: "Next",
text: "Start",
},
],
id: obj[tourId].id,
Expand All @@ -81,25 +85,33 @@ function pushCompleteButton(buttons, tour) {
},
});
}
function pushNextButton(buttons, tour) {
function pushNextButton(buttons, tour, step_id, disabled = false) {
buttons.push({
text: "Next",
classes: "shepherd-button-primary",
classes: `shepherd-button-primary step-next-button-${step_id}`,
action: function () {
return tour.next();
},
disabled: disabled,
});
}
function enableButton(e) {
const ele = document.querySelector(
`.step-next-button-${e.currentTarget.step_id}`
);
ele.removeAttribute("disabled");
}
function pushBackButton(buttons, tour, prev_step) {
buttons.push({
text: "Back",
classes: "shepherd-button-secondary",
action: function () {
if(prev_step)
{
const paths = Joomla.getOptions('system.paths');
if (prev_step) {
const paths = Joomla.getOptions("system.paths");
sessionStorage.setItem("currentStepId", prev_step.id);
checkAndRedirect(paths.rootFull + prev_step.url);
if (prev_step.type == 1) {
checkAndRedirect(paths.rootFull + prev_step.url);
}
}
return tour.back();
},
Expand All @@ -109,7 +121,7 @@ function pushBackButton(buttons, tour, prev_step) {
Joomla = window.Joomla || {};
(function (Joomla, window) {
document.addEventListener("DOMContentLoaded", function () {
const paths = Joomla.getOptions('system.paths');
const paths = Joomla.getOptions("system.paths");
const uri = paths.rootFull;

let myTours = Joomla.getOptions("myTours");
Expand All @@ -126,14 +138,50 @@ Joomla = window.Joomla || {};
const tour = createTour();

if (sessionStorage.getItem("tourId")) {
let prev_step = '';
let prev_step = "";
addInitialStepToTourButton(tour, obj, tourId);
for (index = 0; index < obj[tourId].steps.length; index++) {
var buttons = [];
var len = obj[tourId].steps.length;

if (
obj[tourId] &&
obj[tourId].steps[index].target &&
obj[tourId] &&
obj[tourId].steps[index].type == 2
) {
const ele = document.querySelector(
obj[tourId].steps[index].target
);

if (ele) {
if (
obj[tourId] &&
obj[tourId].steps[index].interactivetour === 2
) {
ele.step_id = index;
ele.addEventListener("input", enableButton, enableButton);
}
if (
obj[tourId] &&
obj[tourId].steps[index].interactivetour === 1
)
ele.addEventListener("click", tour.next, tour.next);
}
}

pushBackButton(buttons, tour, prev_step);
if (index != len - 1) {
pushNextButton(buttons, tour);
let disabled = false;
if (obj[tourId] && obj[tourId].steps[index].interactivetour == 2)
disabled = true;
if (
(obj[tourId] && obj[tourId].steps[index].type !== 2) ||
(obj[tourId] &&
obj[tourId].steps[index].interactivetour == 2) ||
(obj[tourId] && obj[tourId].steps[index].interactivetour == 3)
)
pushNextButton(buttons, tour, index, disabled);
} else {
pushCompleteButton(buttons, tour);
}
Expand All @@ -147,16 +195,16 @@ Joomla = window.Joomla || {};
}
var tourId = sessionStorage.getItem("tourId");
var currentStepId = sessionStorage.getItem("currentStepId");
let prev_step = '';
let prev_step = "";

if (tourId) {
tourId = obj.findIndex((x) => x.id == tourId);
const tour = createTour();
var ind = 0;
if (currentStepId) {
ind = obj[tourId].steps.findIndex((x) => x.id == currentStepId);
if( ind > 0){
prev_step = obj[tourId].steps[ind-1]
if (ind > 0) {
prev_step = obj[tourId].steps[ind - 1];
}
} else {
ind = 0;
Expand All @@ -167,8 +215,33 @@ Joomla = window.Joomla || {};

pushBackButton(buttons, tour, prev_step);

if (
obj[tourId] &&
obj[tourId].steps[index].target &&
obj[tourId] &&
obj[tourId].steps[index].type == 2
) {
const ele = document.querySelector(obj[tourId].steps[index].target);
if (ele) {
if (obj[tourId] && obj[tourId].steps[index].interactivetour === 2) {
ele.step_id = index;
ele.addEventListener("input", enableButton, enableButton);
}
if (obj[tourId] && obj[tourId].steps[index].interactivetour === 1)
ele.addEventListener("click", tour.next, tour.next);
}
}

if (index != len - 1) {
pushNextButton(buttons, tour);
let disabled = false;
if (obj[tourId] && obj[tourId].steps[index].interactivetour == 2)
disabled = true;
if (
(obj[tourId] && obj[tourId].steps[index].type !== 2) ||
(obj[tourId] && obj[tourId].steps[index].interactivetour == 2) ||
(obj[tourId] && obj[tourId].steps[index].interactivetour == 3)
)
pushNextButton(buttons, tour, index, disabled);
} else {
pushCompleteButton(buttons, tour);
}
Expand Down
Loading

0 comments on commit 9c54246

Please sign in to comment.