Some improvements in tour

This commit is contained in:
James Cole 2015-07-12 12:45:41 +02:00
parent 50752a5bfe
commit 9c09353559
5 changed files with 59 additions and 26 deletions

View File

@ -6,12 +6,12 @@ use Config;
use FireflyIII\Models\Tag;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Input;
use Log;
use Preferences;
use Route;
use Session;
use Steam;
use Log;
/**
* Class HomeController
*
@ -84,6 +84,7 @@ class HomeController extends Controller
$frontPage = Preferences::get('frontPageAccounts', []);
$start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
$showTour = Preferences::get('tour', true)->data;
$accounts = $repository->getFrontpageAccounts($frontPage);
$savings = $repository->getSavingsAccounts();
@ -114,7 +115,9 @@ class HomeController extends Controller
}
}
return view('index', compact('count', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal', 'piggyBankAccounts'));
return view(
'index', compact('count', 'showTour', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal', 'piggyBankAccounts')
);
}
/**

View File

@ -12,6 +12,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
use Preferences;
use Response;
use Session;
use Steam;
@ -24,21 +25,23 @@ use Steam;
class JsonController extends Controller
{
public function endTour()
{
Preferences::set('tour', false);
return Response::json(true);
}
/**
*
*/
public function tour()
{
$headers = [
'main-content',
'sidebar-toggle',
'account-menu',
'budget-menu',
'report-menu',
'transaction-menu',
'option-menu',
'main-content-end'
];
$pref = Preferences::get('tour', true);
if (!$pref) {
abort(404);
}
$headers = ['main-content', 'sidebar-toggle', 'account-menu', 'budget-menu', 'report-menu', 'transaction-menu', 'option-menu', 'main-content-end'];
$steps = [];
foreach ($headers as $header) {
$steps[] = [
@ -59,20 +62,21 @@ class JsonController extends Controller
$steps[7]['orphan'] = true;
$steps[7]['backdrop'] = true;
$template ='<div class="popover" role="tooltip">
$template
= '<div class="popover" role="tooltip">
<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">&laquo; '.trans('firefly.prev').'</button>
<button class="btn btn-sm btn-default" data-role="next">'.trans('firefly.next').' &raquo;</button>
<button class="btn btn-sm btn-default" data-role="prev">&laquo; ' . trans('firefly.prev') . '</button>
<button class="btn btn-sm btn-default" data-role="next">' . trans('firefly.next') . ' &raquo;</button>
<button class="btn btn-sm btn-default"
data-role="pause-resume"
data-pause-text="Pause"
data-resume-text="Resume">'.trans('firefly.pause').'</button>
data-resume-text="Resume">' . trans('firefly.pause') . '</button>
</div>
<button class="btn btn-sm btn-default" data-role="end">'.trans('firefly.end-tour').'</button>
<button class="btn btn-sm btn-default" data-role="end">' . trans('firefly.end-tour') . '</button>
</div>
</div>';

View File

@ -297,6 +297,8 @@ Route::group(
Route::get('/json/categories', ['uses' => 'JsonController@categories', 'as' => 'json.categories']);
Route::get('/json/tags', ['uses' => 'JsonController@tags', 'as' => 'json.tags']);
Route::get('/json/tour', ['uses' => 'JsonController@tour', 'as' => 'json.tour']);
Route::post('/json/end-tour', ['uses' => 'JsonController@endTour']);
Route::get('/json/box/in', ['uses' => 'JsonController@boxIn', 'as' => 'json.box.in']);
Route::get('/json/box/out', ['uses' => 'JsonController@boxOut', 'as' => 'json.box.out']);
Route::get('/json/box/bills-unpaid', ['uses' => 'JsonController@boxBillsUnpaid', 'as' => 'json.box.paid']);

View File

@ -1,4 +1,4 @@
/* globals $, columnChart, google, lineChart, pieChart, stackedColumnChart, areaChart */
/* globals $, columnChart,showTour, Tour, google, lineChart, pieChart, stackedColumnChart, areaChart */
$(function () {
"use strict";
@ -9,18 +9,32 @@ $(function () {
// do chart JS stuff.
drawChart();
}
$.getJSON('json/tour').success(function (data) {
var tour = new Tour({steps: data.steps, template: data.template});
// Initialize the tour
tour.init();
// Start the tour
tour.start();
});
if (showTour) {
$.getJSON('json/tour').success(function (data) {
var tour = new Tour(
{
steps: data.steps,
template: data.template,
onEnd: endTheTour
});
// Initialize the tour
tour.init();
// Start the tour
tour.start();
}).fail(function () {
console.log('Already had tour.');
});
}
});
function endTheTour() {
"use strict";
$.post('json/end-tour', {_token: token});
}
function drawChart() {
"use strict";
areaChart('chart/account/frontpage', 'accounts-chart');

View File

@ -241,6 +241,16 @@
{% endblock %}
{% block scripts %}
<!-- show tour? -->
<script type="text/javascript">
{% if showTour %}
var showTour = true;
{% else %}
var showTour = false;
{% endif %}
</script>
<!-- load the libraries and scripts necessary for Google Charts: -->
{% if Config.get('firefly.chart') == 'google' %}
<script type="text/javascript" src="https://www.google.com/jsapi"></script>