Build TourModule

This commit is contained in:
Andy Strobel 2014-08-11 23:46:07 +02:00
parent 00718cd310
commit 3f6382200a
12 changed files with 519 additions and 31 deletions

View File

@ -21,4 +21,12 @@ class TourModule extends HWebModule
$event->sender->addWidget('application.modules_core.tour.widgets.TourWidget', array(), array());
}
public static function onDashboardSidebarInit($event)
{
$event->sender->addWidget('application.modules_core.tour.widgets.TourDashboardWidget', array(), array('sortOrder' => 0));
}
}

View File

@ -9,7 +9,7 @@ Yii::app()->moduleManager->register(array(
),
// Events to Catch
'events' => array(
array('class' => 'DashboardSidebarWidget', 'event' => 'onInit', 'callback' => array('TourModule', 'onDashboardSidebarInit')),
),
));
?>

View File

@ -9,10 +9,26 @@
*/
class TourController extends Controller {
public function actionSeen() {
/**
* Update user settings for completed tours
*/
public function actionTourCompleted() {
// get section parameter from completed tour
$section = Yii::app()->request->getParam('section');
// set tour status to seen for current user
Yii::app()->user->getModel()->setSetting("seen", "true", "tour");
Yii::app()->user->getModel()->setSetting($section, 1, "tour");
}
/*
* Update user settings for hiding tour panel on dashboard
*/
public function actionHidePanel() {
// set tour status to seen for current user
Yii::app()->user->getModel()->setSetting('hideTourPanel', 1, "tour");
}
}

View File

@ -0,0 +1,50 @@
<?php
/**
* HumHub
* Copyright © 2014 The HumHub Project
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*/
/**
* @author andystrobel
*/
class TourDashboardWidget extends HWidget
{
public function run()
{
// check if tour is activated for new users
if (HSetting::Get('enable', 'tour') == 1) {
// save in variable, if the tour panel is activated or not
$hideTourPanel = Yii::app()->user->getModel()->getSetting("hideTourPanel", "tour");
// if panel is not deactivated...
if ($hideTourPanel != 1) {
// get the first space in database (should be the welcome space)
$space = Space::model()->find();
// ...render view
$this->render('tourPanel', array('space' => $space));
}
}
}
}

View File

@ -7,35 +7,89 @@
* @since 0.5
* @author andystrobel
*/
class TourWidget extends HWidget {
class TourWidget extends HWidget
{
/**
* Executes the widgets
*/
public function run() {
public function run()
{
// check if tour is activated for new users
if (HSetting::Get('enable', 'tour') == 1) {
// save in variable, if this user seen the tour already
$tourSeen = Yii::app()->user->getModel()->getSetting("seen", "tour");
// save in variable, if the tour panel is activated or not
$hideTourPanel = Yii::app()->user->getModel()->getSetting("hideTourPanel", "tour");
// if not...
if ($tourSeen != "true") {
if ($hideTourPanel != 1) {
// save current module and controller id's
$currentModuleId = Yii::app()->controller->module->id;
$currentControllerId = Yii::app()->controller->id;
// check current page
if ($currentModuleId == "dashboard" && $currentControllerId == "dashboard") {
// load resource files
$this->loadResources();
// render tour view
$this->render('welcome_interface', array());
}
// check current page
if ($currentModuleId == "space" && $currentControllerId == "space" && isset($_GET['tour'])) {
// load resource files
$this->loadResources();
// render tour view
$this->render('spaces', array());
}
// check current page
if ($currentModuleId == "user" && $currentControllerId == "profile" && isset($_GET['tour'])) {
// load resource files
$this->loadResources();
// render tour view
$this->render('profile', array());
}
// check current page
if ($currentModuleId == "admin" && $currentControllerId == "module" && isset($_GET['tour'])) {
// load resource files
$this->loadResources();
// render tour view
$this->render('administration', array());
}
// ...load resources
$assetPrefix = Yii::app()->assetManager->publish(dirname(__FILE__) . '/../resources', true, 0, defined('YII_DEBUG'));
Yii::app()->clientScript->registerScriptFile($assetPrefix . '/bootstrap-tour.min.js');
Yii::app()->clientScript->registerCssFile($assetPrefix . '/bootstrap-tour.min.css');
// ... render widget view
$this->render('index', array());
}
}
}
/**
* load needed resources files
*/
public function loadResources()
{
$assetPrefix = Yii::app()->assetManager->publish(dirname(__FILE__) . '/../resources', true, 0, defined('YII_DEBUG'));
Yii::app()->clientScript->registerScriptFile($assetPrefix . '/bootstrap-tour.min.js');
Yii::app()->clientScript->registerCssFile($assetPrefix . '/bootstrap-tour.min.css');
}
}
?>

View File

@ -0,0 +1,48 @@
<script type="text/javascript">
// Create a new tour
var administrationTour = new Tour({
//storage: false,
template: '<div class="popover tour"> <div class="arrow"></div> <h3 class="popover-title"></h3> <div class="popover-content"></div> <div class="popover-navigation"> <div class="btn-group"> <button class="btn btn-sm btn-default" data-role="prev"><?php echo Yii::t('TourModule.base', '« Prev'); ?></button> <button class="btn btn-sm btn-default" data-role="next"><?php echo Yii::t('TourModule.base', 'Next »'); ?></button> </div> <button class="btn btn-sm btn-default" data-role="end"><?php echo Yii::t('TourModule.base', 'End tour'); ?></button> </div> </div>',
name: 'administration',
onEnd: function (tour) {
tourCompleted();
}
});
// Add tour steps
administrationTour.addSteps([
{
// step 0
orphan: true,
backdrop: true,
title: "<?php echo Yii::t('TourModule.widgets_views_administration', '<strong>Welcome</strong> to %appName%', array('%appName%' => Yii::app()->name)); ?>",
content: "<?php echo Yii::t('TourModule.widgets_views_administration', "This is a brief introduction of %appName% to give you an overview about the most important functions... Let's go!", array('%appName%' => Yii::app()->name)); ?>"
}
]);
// Initialize tour plugin
administrationTour.init();
// start the tour
administrationTour.restart();
/**
* Set tour as seen
*/
function tourCompleted() {
// load user spaces
$.ajax({
'url': '<?php echo Yii::app()->createAbsoluteUrl('//tour/tour/TourCompleted', array('section' => 'administration')); ?>',
'cache': false,
'data': jQuery(this).parents("form").serialize()
}).done(function () {
// redirect to dashboard
window.location.href="<?php echo Yii::app()->createUrl('//dashboard/dashboard'); ?>";
});
}
</script>

View File

@ -0,0 +1,48 @@
<script type="text/javascript">
// Create a new tour
var profileTour = new Tour({
//storage: false,
template: '<div class="popover tour"> <div class="arrow"></div> <h3 class="popover-title"></h3> <div class="popover-content"></div> <div class="popover-navigation"> <div class="btn-group"> <button class="btn btn-sm btn-default" data-role="prev"><?php echo Yii::t('TourModule.base', '« Prev'); ?></button> <button class="btn btn-sm btn-default" data-role="next"><?php echo Yii::t('TourModule.base', 'Next »'); ?></button> </div> <button class="btn btn-sm btn-default" data-role="end"><?php echo Yii::t('TourModule.base', 'End tour'); ?></button> </div> </div>',
name: 'profile',
onEnd: function (tour) {
tourCompleted();
}
});
// Add tour steps
profileTour.addSteps([
{
// step 0
orphan: true,
backdrop: true,
title: "<?php echo Yii::t('TourModule.widgets_views_profile', '<strong>Welcome</strong> to %appName%', array('%appName%' => Yii::app()->name)); ?>",
content: "<?php echo Yii::t('TourModule.widgets_views_profile', "This is a brief introduction of %appName% to give you an overview about the most important functions... Let's go!", array('%appName%' => Yii::app()->name)); ?>"
}
]);
// Initialize tour plugin
profileTour.init();
// start the tour
profileTour.restart();
/**
* Set tour as seen
*/
function tourCompleted() {
// load user spaces
$.ajax({
'url': '<?php echo Yii::app()->createAbsoluteUrl('//tour/tour/TourCompleted', array('section' => 'profile')); ?>',
'cache': false,
'data': jQuery(this).parents("form").serialize()
}).done(function () {
// redirect to dashboard
window.location.href="<?php echo Yii::app()->createUrl('//dashboard/dashboard'); ?>";
});
}
</script>

View File

@ -0,0 +1,48 @@
<script type="text/javascript">
// Create a new tour
var spacesTour = new Tour({
//storage: false,
template: '<div class="popover tour"> <div class="arrow"></div> <h3 class="popover-title"></h3> <div class="popover-content"></div> <div class="popover-navigation"> <div class="btn-group"> <button class="btn btn-sm btn-default" data-role="prev"><?php echo Yii::t('TourModule.base', '« Prev'); ?></button> <button class="btn btn-sm btn-default" data-role="next"><?php echo Yii::t('TourModule.base', 'Next »'); ?></button> </div> <button class="btn btn-sm btn-default" data-role="end"><?php echo Yii::t('TourModule.base', 'End tour'); ?></button> </div> </div>',
name: 'spaces',
onEnd: function (tour) {
tourCompleted();
}
});
// Add tour steps
spacesTour.addSteps([
{
// step 0
orphan: true,
backdrop: true,
title: "<?php echo Yii::t('TourModule.widgets_views_spaces', '<strong>Welcome</strong> to %appName%', array('%appName%' => Yii::app()->name)); ?>",
content: "<?php echo Yii::t('TourModule.widgets_views_spaces', "This is a brief introduction of %appName% to give you an overview about the most important functions... Let's go!", array('%appName%' => Yii::app()->name)); ?>"
}
]);
// Initialize tour plugin
spacesTour.init();
// start the tour
spacesTour.restart();
/**
* Set tour as seen
*/
function tourCompleted() {
// load user spaces
$.ajax({
'url': '<?php echo Yii::app()->createAbsoluteUrl('//tour/tour/TourCompleted', array('section' => 'spaces')); ?>',
'cache': false,
'data': jQuery(this).parents("form").serialize()
}).done(function () {
// redirect to dashboard
window.location.href="<?php echo Yii::app()->createUrl('//dashboard/dashboard'); ?>";
});
}
</script>

View File

@ -0,0 +1,41 @@
<div class="panel panel-default panel-tour">
<div class="panel-heading">
<?php echo Yii::t('TourModule.widgets_views_tourPanel', '<strong>Getting</strong> Started'); ?>
<!-- load modal confirm widget -->
<?php $this->widget('application.widgets.ModalConfirmWidget', array(
'uniqueID' => 'hide-panel-button',
'linkOutput' => 'button',
'title' => '<strong>Hide</strong> tour panel',
'message' => 'This action will remove the tour panel from your dashboard. You can reactivate it under<br>Account settings <i class="fa fa-caret-right"></i> Settings.',
'buttonTrue' => 'Ok',
'buttonFalse' => 'Cancel',
'class' => 'pull-right btn btn-sm btn-danger',
'linkContent' => Yii::t('TourModule.widgets_views_tourPanel', 'Hide Panel'),
'linkHref' => $this->createUrl("//tour/tour/hidePanel", array("ajax" => 1)),
'confirmJS' => '$(".panel-tour").slideToggle("slow")'
)); ?>
</div>
<div class="panel-body">
<p>
Text für die folgenden Touren
</p>
<?php
$interface = Yii::app()->user->getModel()->getSetting("interface", "tour");
$spaces = Yii::app()->user->getModel()->getSetting("spaces", "tour");
$profile = Yii::app()->user->getModel()->getSetting("profile", "tour");
$administration = Yii::app()->user->getModel()->getSetting("administration", "tour");
?>
<ul class="tour-list">
<li id="interface_entry" class="<?php if ($interface == 1) : ?>completed<?php endif; ?>"><a href="javascript:startInterfaceTour();"><i class="fa fa-play-circle-o"></i> Interface</a></li>
<li class="<?php if ($spaces == 1) : ?>completed<?php endif; ?>"><a id="interface-tour-link" href="<?php echo Yii::app()->createUrl('//space/space', array('sguid' => $space->guid, 'tour' => 'true'))?>"><i class="fa fa-play-circle-o"></i> Spaces</a></li>
<li class="<?php if ($profile == 1) : ?>completed<?php endif; ?>"><a href="<?php echo Yii::app()->createUrl('//user/profile', array('uguid' => Yii::app()->user->guid,'tour' => 'true'))?>"><i class="fa fa-play-circle-o"></i> User profile</a></li>
<?php if (Yii::app()->user->isAdmin() == true) : ?>
<li class="<?php if ($administration == 1) : ?>completed<?php endif; ?>"><a href="<?php echo Yii::app()->createUrl('//admin/module/listOnline', array('tour' => 'true'))?>"><i class="fa fa-play-circle-o"></i> Administration</a></li>
<?php endif;?>
</ul>
</div>
</div>

View File

@ -0,0 +1,134 @@
<div class="modal" id="welcomeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog animated fadeIn">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"
id="myModalLabel"><?php echo Yii::t('TourModule.widgets.views.welcom', '<strong>Welcome</strong> to %appName%', array('%appName%' => Yii::app()->name)) ?></h4>
</div>
<div class="modal-body">
Duis in lectus aliquet, facilisis nibh sit amet, porttitor nulla. In placerat fringilla nunc, a
sollicitudin orci dignissim quis. Donec gravida commodo aliquam. Nulla porta elit vitae eros vehicula,
vitae luctus nulla fringilla. Aliquam faucibus, neque non ultricies molestie, dolor est consectetur
nulla, vitae ultrices ante enim id lorem. Nam sodales metus lacus, vehicula euismod quam varius a. Nulla
massa turpis, convallis a odio ut, venenatis vehicula nunc. Donec leo orci, ultrices vitae sapien at,
eleifend lacinia dui. Etiam quis scelerisque velit. Morbi at viverra diam, nec convallis lectus.<br><br>
Nunc eleifend ornare vulputate. Ut a enim interdum, dictum eros in, pretium leo. Nullam ut lorem
iaculis, iaculis mauris id, iaculis mi.
</div>
<div class="modal-footer">
<hr>
<br>
<a href="#" class="btn btn-info">javascript:welcomeModalSeen();</a> <a class="btn btn-primary"
href="javascript:welcomeModalSeen();"
data-dismis="modal">Close</a>
</div>
</div>
</div>
</div>
<!-- end: Modal -->
<script type="text/javascript">
<?php
// check if the welcome screen was already shown
$welcome = Yii::app()->user->getModel()->getSetting("welcome", "tour");
// If not ...
if ($welcome != 1) :
?>
// show welcome modal
$('#welcomeModal').modal("show");
<?php endif; ?>
/**
* Set welcome modal as seen
*/
function welcomeModalSeen() {
// load user spaces
$.ajax({
'url': '<?php echo Yii::app()->createAbsoluteUrl('tour/tour/TourCompleted', array('section' => 'welcome')); ?>',
'cache': false,
'data': jQuery(this).parents("form").serialize()
}).done(function () {
// hide modal
$('#welcomeModal').modal('hide')
});
}
</script>
<script type="text/javascript">
<?php
// check if the welcome screen was already shown
$interface = Yii::app()->user->getModel()->getSetting("interface", "tour");
// If not ...
if ($interface != 1) :
?>
// start tour
startInterfaceTour();
<?php endif; ?>
function startInterfaceTour() {
// Create a new tour
var interfaceTour = new Tour({
//storage: false,
template: '<div class="popover tour"> <div class="arrow"></div> <h3 class="popover-title"></h3> <div class="popover-content"></div> <div class="popover-navigation"> <div class="btn-group"> <button class="btn btn-sm btn-default" data-role="prev"><?php echo Yii::t('TourModule.base', '« Prev'); ?></button> <button class="btn btn-sm btn-default" data-role="next"><?php echo Yii::t('TourModule.base', 'Next »'); ?></button> </div> <button class="btn btn-sm btn-default" data-role="end"><?php echo Yii::t('TourModule.base', 'End tour'); ?></button> </div> </div>',
name: 'interface',
onEnd: function (tour) {
tourCompleted();
}
});
// Add tour steps
interfaceTour.addSteps([
{
// step 0
orphan: true,
backdrop: true,
title: "<?php echo Yii::t('TourModule.widgets_views_welcome_interface', '<strong>Welcome</strong> to %appName%', array('%appName%' => Yii::app()->name)); ?>",
content: "<?php echo Yii::t('TourModule.widgets_views_welcome_interface', "This is a brief introduction of %appName% to give you an overview about the most important functions... Let's go!", array('%appName%' => Yii::app()->name)); ?>"
}
]);
// Initialize tour plugin
interfaceTour.init();
// start the tour
interfaceTour.restart();
}
/**
* Set tour as seen
*/
function tourCompleted() {
// load user spaces
$.ajax({
'url': '<?php echo Yii::app()->createAbsoluteUrl('//tour/tour/TourCompleted', array('section' => 'interface')); ?>',
'cache': false,
'data': jQuery(this).parents("form").serialize()
}).done(function () {
// cross out welcome tour entry
$('#interface_entry').addClass('completed');
});
}
</script>

View File

@ -1091,6 +1091,24 @@ ul.tag_input.focus {
.wallFilterPanel .dropdown-menu li a:hover {
color: #fff !important;
}
ul.tour-list {
list-style: none;
margin-bottom: 0;
padding-left: 10px;
}
ul.tour-list li {
padding-top: 5px;
}
ul.tour-list li a {
color: #4cd9c0;
}
ul.tour-list li a .fa {
width: 16px;
}
ul.tour-list li.completed a {
color: #bebebe;
text-decoration: line-through;
}
.errorMessage {
color: #ff8989;
}

View File

@ -539,12 +539,11 @@ h4 {
.popover {
border: 1px solid rgba(0,0,0,0.15);
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
-webkit-box-shadow: 0 6px 12px rgba(0,0,0,0.175);
-moz-box-shadow: 0 6px 12px rgba(0,0,0,0.175);
box-shadow: 0 6px 12px rgba(0,0,0,0.175);
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
-moz-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
.popover-title {
background: none;
@ -1446,6 +1445,33 @@ ul.tag_input.focus {
}
// TourModule
ul.tour-list {
list-style: none;
margin-bottom: 0;
padding-left: 10px;
li {
padding-top: 5px;
a {
color: @colorInfo2;
.fa {
width: 16px;
}
}
}
li.completed {
a {
color: @colorFont4;
text-decoration: line-through;
}
}
}
//
// 7) Yii Components
// --------------------------------------------------
@ -1500,21 +1526,18 @@ img.bounceIn {
}
}*/
.outside {
.text {
color: #ffffff;
font-size: 12px;
margin-bottom: 15px;
a {
.text {
color: #ffffff;
text-decoration: underline;
font-size: 12px;
margin-bottom: 15px;
a {
color: #ffffff;
text-decoration: underline;
}
}
}
h1, h2 {
color: #ffffff !important;
@ -1564,7 +1587,7 @@ img.bounceIn {
background-position: top center;
border-radius: 3px;
border: 3px solid #ffffff;
.install-header-title {
padding: 6% 30px 0 30px;
}