$(this).trigger('fluidbookready');
$(this).trigger('fluidbook.ready');
+ $(document).trigger('fluidbook.ready');
},
loadPlugins: function () {
$.each(this.datas.plugins, function (k, plugin) {
return;
},
pageTransition: function (pageNr) {
-
$(this).trigger('fluidbook.beforePageTransition');
-
this.tooltip.hideTooltip();
if (pageNr == undefined) {
}
}
pageNr = this.normalizePage(pageNr);
- if (this.firstTransition || pageNr === this.normalizePage(this.currentPage) || this.currentPage === -1 || !this.support.transitions2d || this.datas.mobileTransitions === 'none') {
+ if ($('#splash').length > 0 || this.firstTransition || pageNr === this.normalizePage(this.currentPage) || this.currentPage === -1 || !this.support.transitions2d || this.datas.mobileTransitions === 'none') {
this.firstTransition = false;
return this.pageTransition1D(pageNr);
}
SCORM_QUESTIONS = [];
SCORM_SUCCESS_STATUS = 'unknown';
SCORM_SUCCESS_SCORE = 0;
+SCORM_EVENTS_INITED = false;
+SCORM_INTERACTIONS_INITED = false;
+SCORM_LOCATION_INITED = false;
var _CMI12 = {
'location': 'cmi.core.lesson_location',
'exit': 'cmi.exit',
}
-$(function () {
- if (fluidbook) {
- initScorm();
- } else {
- for (var i = 1; i <= 5; i++) {
- setTimeout(function () {
- initScorm();
- }, 2000 * i);
- }
- }
-});
-
function initScorm() {
if (SCORM_INITED) {
return;
}
- console.log('init scrom');
+ console.log('init scorm');
SCORM_INITED = true;
pipwerks.SCORM.init();
- pipwerks.SCORM.API.get();
setScormValue('exit', 'suspend');
startScormTimer();
- initScormEvents();
- initScormInteractions();
+
+ $(document).on('fluidbook.ready', function () {
+ initScormEvents();
+ initScormInteractions();
+ });
}
function _cmi(key) {
}
function initScormEvents() {
+ if (SCORM_EVENTS_INITED) {
+ return;
+ }
+ SCORM_EVENTS_INITED = true;
+
+ console.log('init scorm events');
$(window).on('unload', function () {
finishScorm();
});
- $(fluidbook).on('fluidbook.splash.hide', function () {
- console.log('init scorm events');
- var currentLocation = getScormValue('location');
- try {
- if (currentLocation.indexOf('page_') === 0) {
- var e = currentPage.split('_');
- if (e.length == 2 && e[0] == 'page') {
- fluidbook.setCurrentPage(e[1]);
- }
- } else if (currentLocation.indexOf('{') === 0) {
- var location = JSON.parse(currentLocation);
- if (location.maxPage) {
- fluidbook.contentlock.setMaxPage(location.maxPage, true);
- }
- if (location.page) {
- fluidbook.setCurrentPage(location.page);
- }
+ if (SCORM_LOCATION_INITED) {
+ return;
+ }
+ SCORM_LOCATION_INITED = true;
+ var currentLocation = getScormValue('location');
+ try {
+ if (currentLocation.indexOf('page_') === 0) {
+ var e = currentPage.split('_');
+ if (e.length == 2 && e[0] == 'page') {
+ fluidbook.setCurrentPage(e[1]);
+ }
+ } else if (currentLocation.indexOf('{') === 0) {
+ var location = JSON.parse(currentLocation);
+ if (location.maxPage) {
+ fluidbook.contentlock.setMaxPage(location.maxPage, true);
+ }
+ if (location.page) {
+ fluidbook.setCurrentPage(location.page);
}
- } catch (err) {
- console.log(err);
}
+ } catch (err) {
+ console.log(err);
+ }
- $(fluidbook).on('fluidbook.page.navigation', function (e, page) {
- scormSaveCurrentPosition(page);
- });
- $(fluidbook).on('fluidbook.maxpage.set', function (e, page) {
- scormSaveCurrentPosition(undefined, page);
- });
+ $(fluidbook).on('fluidbook.page.navigation', function (e, page) {
+ scormSaveCurrentPosition(page);
+ });
+
+ $(fluidbook).on('fluidbook.maxpage.set', function (e, page) {
+ scormSaveCurrentPosition(undefined, page);
});
}
function initScormInteractions() {
+ if (SCORM_INTERACTIONS_INITED) {
+ return;
+ }
+ SCORM_INTERACTIONS_INITED = true;
if (fluidbook.datas.scorm_quizdata === '') {
return;
}