this.tooltip = new FluidbookTooltip(this);
this.audiodescription = new FluidbookAudioDescription(this);
this.sound = new FluidbookSound(this);
+ if (this.datas.scorm_enable) {
+ this.scorm = new FluidbookScorm(this);
+ }
if (this.datas.form == 'bulle') {
this.form = new FluidbookBulleForm(this);
});
+
// ToDo: consider re-using existing popinOverlay div?
$('body').append('<div id="zoomPopupOverlay"></div><div id="zoomPopupWrapper"><a href="#" class="zoomPopupClose">' + getSpriteIcon('interface-close') + '</a></div>');
setTimeout(function () {
$("#zoomPopupOverlay").css('opacity', 1)
}, 10)
- }
+ },
+ triggerLinkById: function (id) {
+ var a = $('.link[data-id="' + id + '"] a:eq(0)');
+ a.get(0).click();
+ },
}
--- /dev/null
+function FluidbookScorm(fluidbook) {
+ this.fluidbook = fluidbook;
+ this.linksToComplete = [];
+ this.init();
+}
+
+FluidbookScorm.prototype = {
+ init: function () {
+ var $this = this;
+
+ if (this.fluidbook.datas.scorm_variables.linkstocomplete) {
+ this.linksToComplete = this.fluidbook.datas.scorm_variables.linkstocomplete.split(',');
+ }
+
+ $(document).on('click', 'a', function () {
+ var link = $(this).closest('.link[data-id]');
+ if (link.length > 0) {
+ var id = link.data('id');
+ $this.completeLink(id);
+ }
+ return true;
+ });
+ },
+
+ completeLink: function (id) {
+ var index = this.linksToComplete.indexOf(id);
+ if (index > -1) {
+ this.linksToComplete.splice(index, 1);
+ }
+ },
+
+ linksCompleted: function () {
+ return (this.linksToComplete.length == 0);
+ },
+
+ openLinkIfCompleteOrDisplayImage: function (openLink, openImage) {
+ var $this = this;
+ var id = this.linksCompleted() ? openLink : openImage;
+ if (!Array.isArray(id)) {
+ id = [id];
+ }
+ $.each(id, function (k, v) {
+ $this.fluidbook.links.triggerLinkById(v);
+ });
+
+ },
+};
\ No newline at end of file