Set the plugin configuration - refs #7279
parent
36836206e8
commit
222261d16f
@ -1,84 +1,86 @@ |
|||||||
<script type="text/javascript"> |
{% if tour.show_tour %} |
||||||
var chamiloTour = (function() { |
<script type="text/javascript"> |
||||||
var intro = null; |
var chamiloTour = (function() { |
||||||
var $btnStart = null; |
var intro = null; |
||||||
|
var $btnStart = null; |
||||||
|
|
||||||
var setSteps = function (stepsData) { |
var setSteps = function (stepsData) { |
||||||
var steps = new Array(); |
var steps = new Array(); |
||||||
|
|
||||||
$.each(stepsData, function () { |
$.each(stepsData, function () { |
||||||
var step = this; |
var step = this; |
||||||
|
|
||||||
if (step.element) { |
if (step.element) { |
||||||
if ($(step.element).length > 0) { |
if ($(step.element).length > 0) { |
||||||
|
steps.push(step); |
||||||
|
} |
||||||
|
} else { |
||||||
steps.push(step); |
steps.push(step); |
||||||
} |
} |
||||||
} else { |
}); |
||||||
steps.push(step); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
return steps; |
return steps; |
||||||
}; |
}; |
||||||
|
|
||||||
return { |
return { |
||||||
init: function(pageClass) { |
init: function(pageClass) { |
||||||
$.getJSON('{{ tour.web_path.steps_ajax }}', { |
$.getJSON('{{ tour.web_path.steps_ajax }}', { |
||||||
'page_class': pageClass |
'page_class': pageClass |
||||||
}, function(response) { |
}, function(response) { |
||||||
intro = introJs(); |
intro = introJs(); |
||||||
intro.setOptions({ |
intro.setOptions({ |
||||||
steps: setSteps(response), |
steps: setSteps(response), |
||||||
nextLabel: '{{ 'Next' | get_lang }}', |
nextLabel: '{{ 'Next' | get_lang }}', |
||||||
prevLabel: '{{ 'Prev' | get_lang }}', |
prevLabel: '{{ 'Prev' | get_lang }}', |
||||||
skipLabel: '{{ 'Skip' | get_lang }}', |
skipLabel: '{{ 'Skip' | get_lang }}', |
||||||
doneLabel: '{{ 'Done' | get_lang }}' |
doneLabel: '{{ 'Done' | get_lang }}' |
||||||
}); |
}); |
||||||
intro.oncomplete(function () { |
intro.oncomplete(function () { |
||||||
$.post('{{ tour.web_path.save_ajax }}', { |
$.post('{{ tour.web_path.save_ajax }}', { |
||||||
page_class: pageClass |
page_class: pageClass |
||||||
}, function () { |
}, function () { |
||||||
$btnStart.remove(); |
$btnStart.remove(); |
||||||
|
}); |
||||||
}); |
}); |
||||||
}); |
|
||||||
|
|
||||||
$btnStart = $('<button>', { |
$btnStart = $('<button>', { |
||||||
class: 'btn btn-primary btn-large', |
class: 'btn btn-primary btn-large', |
||||||
text: '{{ 'StartButtonText' | get_lang }}', |
text: '{{ 'StartButtonText' | get_lang }}', |
||||||
click: function(e) { |
click: function(e) { |
||||||
e.preventDefault(); |
e.preventDefault(); |
||||||
|
|
||||||
intro.start(); |
intro.start(); |
||||||
} |
} |
||||||
}).appendTo('#tour-button-cotainer'); |
}).appendTo('#tour-button-cotainer'); |
||||||
}); |
}); |
||||||
} |
} |
||||||
}; |
}; |
||||||
})(); |
})(); |
||||||
|
|
||||||
$(document).on('ready', function() { |
$(document).on('ready', function() { |
||||||
var pages = {{ tour.pages }}; |
var pages = {{ tour.pages }}; |
||||||
|
|
||||||
$.each(pages, function(index, page) { |
$.each(pages, function(index, page) { |
||||||
var thereIsSelectedPage = $(page.pageClass).length > 0; |
var thereIsSelectedPage = $(page.pageClass).length > 0; |
||||||
|
|
||||||
if (thereIsSelectedPage && page.show) { |
if (thereIsSelectedPage && page.show) { |
||||||
$('<link>', { |
$('<link>', { |
||||||
href: '{{ tour.web_path.intro_css }}', |
href: '{{ tour.web_path.intro_css }}', |
||||||
rel: 'stylesheet' |
rel: 'stylesheet' |
||||||
}).appendTo('head'); |
}).appendTo('head'); |
||||||
|
|
||||||
$('<link>', { |
$('<link>', { |
||||||
href: '{{ tour.web_path.intro_theme_css }}', |
href: '{{ tour.web_path.intro_theme_css }}', |
||||||
rel: 'stylesheet' |
rel: 'stylesheet' |
||||||
}).appendTo('head'); |
}).appendTo('head'); |
||||||
|
|
||||||
$.getScript('{{ tour.web_path.intro_js }}', function() { |
$.getScript('{{ tour.web_path.intro_js }}', function() { |
||||||
chamiloTour.init(page.pageClass); |
chamiloTour.init(page.pageClass); |
||||||
}); |
}); |
||||||
} |
} |
||||||
|
}); |
||||||
}); |
}); |
||||||
}); |
</script> |
||||||
</script> |
|
||||||
|
|
||||||
<div id="tour-button-cotainer"></div> |
<div id="tour-button-cotainer"></div> |
||||||
|
{% endif %} |
||||||
|
Loading…
Reference in new issue