" +
"| " +
"" +
" | " +
"
";
cp.passwordDiv.innerHTML = lInnerHTML;
document.getElementById("checkPwdButton").onclick = checkIfCorrectPassword;
var inputElem = document.getElementById(lPwdTxtBoxVarName)
inputElem.focus();
inputElem.onkeyup = function(e)
{
if(e.keyCode == 13)
checkIfCorrectPassword();
};
showHideOtherControls(false);
},
handlePreloader: function()
{
var lHasPreloader = cp.model.data[this.main.id].preloader;
var lProjMainData = cp.model.data[this.main.id];
var lPreloaderImageSrc = lProjMainData.preloaderFileName;
if((lPreloaderImageSrc != undefined) && (lPreloaderImageSrc != '') && lHasPreloader)
{
var lPreloaderPercentage = lProjMainData.preloaderPercentage;
cp.preloaderImage.src = lPreloaderImageSrc;
if(lPreloaderImageSrc.indexOf('defaultloading.png') != -1)
cp.preloaderImage.defaultImage = true;
else
cp("loadingString").style.display = 'none';
}
else
{
cp.preloaderImage.style.display = 'none';
}
this.preloadProjectAssets();
},
preloadProjectAssets: function()
{
var lProjectAssets = cp.model.projectImages;
if(!lProjectAssets)
return;
if(lProjectAssets.length == 0)
return;
cp.movie.im.loadImages(-1, lProjectAssets, true, true);
},
rewind: function()
{
this.stage.handleRewindForFramesets();
this.stage.RemoveFeedbacks(cp.FeedbackCloseReason.SLIDE_CHANGE);
cp.movie.stage.itemsNotLoaded = [];
this.jumpToFrame(1);
if ( ! cp.movie.stage.hasItemsLoaded() )
cp.movie.pause(cp.ReasonForPause.WAIT_FOR_RESOURCES);
else
this.play();
},
_parseElements: function()
{
var child = this.element.firstChild;
for( ; child; child = child.nextSibling)
{
if (child.nodeType != Node.ELEMENT_NODE)
continue;
var classNames = (child.className + "").split(" ");
var isTimeline = classNames.indexOf("cp-timeline") != -1;
if (!isTimeline)
{
//console.error("cp-movie ", this.element, " should only contain cp-timelines. Invalid element: ", child);
continue;
}
var isMain = classNames.indexOf("cp-main") != -1;
var isSymbol = classNames.indexOf("cp-symbol") != -1;
if (isSymbol)
this.symbols[child.id] = child;
if (isMain)
{
if (this.main != null) {
//console.error("Already got a main old value: ", this.main, " new value " + child);
}
this.main = child;
}
}
if (this.main == null)
{
//console.error("No cp-main defined for movie ", this.element);
return;
}
this.stage = cp.parseTimeline(this.main);
if (debug)
{
var self = this;
var pauseButton = document.createElement("input");
pauseButton.setAttribute("type", "button");
pauseButton.value = "Play " + self.element.id;
document.body.appendChild(pauseButton);
pauseButton.onclick = function()
{
self.pause(cp.ReasonForPause.PLAYBAR_ACTION);
if (self.paused)
pauseButton.value = "Play " + self.element.id;
else
pauseButton.value = "Pause " + self.element.id;
}
}
},
resetFPS: function()
{
if (cpInfoFPS == 0)
{
//console.error("Framerate is zero.");
return;
}
this.POLL_INTERVAL = 1000 / cpInfoFPS;
if(this.interval)
{
clearInterval(this.interval);
this.interval = 0;
}
var self = this;
this.interval = setInterval(function()
{
self._onEnterFrame();
}, this.POLL_INTERVAL);
},
startTimer: function()
{
if (this.interval)
return;
this.stage.start();
this.element.style.display = "block";
this.resetFPS();
},
stop: function()
{
this.stage.reset();
this.element.style.display = "none";
var playbar = document.getElementById("playbar");
if(playbar['pause']!=undefined)
playbar.pause();
},
play: function(reasonForPlay)
{
if(cp.verbose)
cp.log('movie.play deleting pendingPlay');
delete this.pendingPlay;
if(this.virgin)
{
if(cp.verbose)
cp.log('movie virgin play');
this.virgin = false;
/*var lPlaybackController = cp.movie.playbackController;
if(lPlaybackController)
lPlaybackController.RestoreQuizState(); */
if(cp.IDEVICE == cp.device)
loadMediaAndBeginMovie();
else
beginMovie();
return true;
}
if(!this.paused)
return false;
if(this.waitingForResources())
{
if(cp.verbose)
cp.log('set pendingPlay = true. movie cannot play since resources not available');
this.pendingPlay = true;
return false;
}
if(cp.verbose)
cp.log('movie play');
this.am.ssp = 0;
var playbar = document.getElementById("playbar");
if(playbar['play']!=undefined)
playbar.play();
if(cpInfoCurrentFrame==1 && ! this.tocPlaybarHandlerSet )
{
if ( playbar.animator )
playbar.animator.startTimer();
var slideDiv = this.stage.getSlideDiv();
if (slideDiv)
{
this.tocPlaybarHandlerSet = true;
if(cp.device == cp.IDEVICE)
{
if ( playbar.animator || ( cp.model.data.project.hasTOC && cp.model.data.tocProperties.overlay ) ) {
slideDiv.ontouchstart = cp.handleMouseOver;
slideDiv.ontouchend = cp.handleMouseOut;
slideDiv.touchstartX = null;
slideDiv.isMoving = false;
if(cp.model.data.project.hasTOC && cp.model.data.tocProperties.overlay)
{
slideDiv.showTOC = true;
slideDiv.swipeDir = cp.model.data.tocProperties.position;
}
}
}
else
{
if ( playbar.animator ) {
slideDiv.onmouseover = cp.handleMouseOver;
slideDiv.onmouseout = cp.handleMouseOut;
}
}
}
}
this.now = new Date();
if(this.startTime == undefined)
{
this.startTime = this.now;
cp.em.fireEvent('CPMovieStart');
}
else
{
cp.em.fireEvent('CPMovieResume',reasonForPlay);
}
this.paused = false;
this.stage.updateToFrame(cpInfoCurrentFrame);
RegisterForUpdateTimeBasedSystemVariables();
return true;
},
pause: function(reasonForPause)
{
if(this.paused)
return;
if(cp.verbose)
cp.log('movie pause ' + reasonForPause);
this.reasonForPause = reasonForPause;
if(cp.verbose)
cp.log('movie.pause deleting pendingPlay');
delete this.pendingPlay;
UnregisterForUpdateTimeBasedSystemVariables();
var playbar = document.getElementById("playbar");
if(playbar['pause']!=undefined)
playbar.pause();
if(reasonForPause == cp.ReasonForPause.MOVIE_ENDED && playbar.animator)
{
playbar.animator.showPlaybar(true);
}
this.paused = true;
this.stage.updateToFrame(cpInfoCurrentFrame);
if(this.am)
this.am.pause(reasonForPause);
if(this.vdm)
this.vdm.pause(reasonForPause);
cp.em.fireEvent('CPMoviePause',reasonForPause);
},
blockUI: function()
{
if(!this.blockedUI)
{
this.blockedUI = true;
cp('blockUserInteraction').style.display = 'block';
cp('blockUserInteraction').style.width = '100%';
cp('blockUserInteraction').style.height = '100%';
this.preloadRot = 0;
}
else
{
if(cp.preloaderImage && cp.preloaderImage.defaultImage)
{
this.preloadRot = (this.preloadRot + 20)%360;
applyTransform(cp.preloaderImage, 'rotate(' + this.preloadRot + 'deg)');
}
}
},
unblockUI: function()
{
if(this.blockedUI)
{
this.blockedUI = false;
cp('blockUserInteraction').style.display = 'none';
}
},
_jumpToFrame: function()
{
var tmp = this._jumpFrame;
if(tmp)
{
delete this._jumpFrame;
setCpInfoCurrentFrame(tmp);
this.stage.updateFrame(cp.Timeline.ReasonForUpdate.JUMP);
}
},
jumpToFrame: function(frame)
{
if(this.waitingForResources())
{
if(cp.verbose)
cp.log('movie cannot jumpToFrame since resources not available');
this.pendingJump = frame;
return false;
}
if(frame == "cpInfoLastVisitedSlide")
frame = this.cpInfoLastVisitedSlideStartFrame;
var indexOfSlideToJumpTo = cp.movie.stage.getSlideIndexForFrame(frame);
if(!this.stage.canUpdateToFrame(frame, indexOfSlideToJumpTo))
{
if(cp.verbose)
cp.log('movie cannotUpdateToFrame '+ frame);
return false;
}
if(this.pm.isLoading())
{
if(cp.verbose)
cp.log('movie cannot jumpToFrame since prefetchManager is loading');
this.pendingJump = frame;
return false;
}
this._jumpFrame = frame;
this.pause(cp.ReasonForPause.WAIT_FOR_RESOURCES);
return this.pm.loadSlideAssets(indexOfSlideToJumpTo);
},
executeAction: function(str)
{
if(cp.verbose)
cp.log('execute action str [' + str + ']');
if(str && str != '')
{
try
{
eval(str);
}
catch(e)
{
cp.log(e);
}
}
},
mousePath: function(object, frame)
{
if (frame < object.afrom || frame > object.ato)
return;
var deltaFrame = object.ato - object.afrom;
if(deltaFrame == 0)
return;
// Now, we need to reach the end point sometime before reaching to point.
var subFrameNo = Math.floor( cpInfoFPS * 0.5 );
deltaFrame -= subFrameNo;
if (deltaFrame <= 0)
deltaFrame = 0;
var mpa = this.motionPathArgs;
var bounds = mpa.b;
var deltax = bounds[2] - bounds[0];
var deltay = bounds[3] - bounds[1];
var slideFrame = frame - object.afrom;
// Now, for all the calculations regarding mouse paths.
var lStartX = bounds[0];
var lStartY = bounds[1];
var lEndX = bounds[2];
var lEndY = bounds[3];
var bx = lEndX;
var by = lStartY;
var lPower = 1.0;
if (mpa.s == 1)
lPower = 0.5;
var leftPos = lEndX;
var topPos = lEndY;
if (deltaFrame > 0 && slideFrame < deltaFrame) {
var straighMouse = (0 == mpa.t) || (0 == deltax) || (0 == deltay);
var mu = Math.pow(slideFrame/deltaFrame,lPower);
if (straighMouse) {
leftPos = (lStartX + deltax * mu);
topPos = (lStartY + deltay * mu);
}
else {
var musqd = mu * mu;
var muInverse = 1 -mu;
var muInverseSqd = muInverse * muInverse;
leftPos = ((lStartX * muInverseSqd) + (2 * bx * muInverse * mu) + (lEndX * musqd));
topPos = ((lStartY * muInverseSqd) + (2 * by * muInverse * mu) + (lEndY * musqd));
}
}
object.children[0].element.left = leftPos;
object.children[0].element.style.left = leftPos + "px";
object.children[0].element.top = topPos;
object.children[0].element.style.top = topPos + "px";
},
waitingForResources: function()
{
if((this.im && this.im.imagesNotLoaded()) ||
(this.stage && !this.stage.hasItemsLoaded()) ||
(this.am && this.am.numAudiosWaiting > 0) ||
(this.vdm && this.vdm.numVideosWaiting > 0) ||
(this.ms && this.ms.pendingItems() > 0))
return true;
return false;
},
resetAllWaitingResources: function()
{
if(this.im)
this.im.reset();
if(this.stage)
this.stage.itemsNotLoaded = [];
if(this.am)
this.am.numAudiosWaiting = 0;
if(this.vdm)
this.vdm.numVideosWaiting = 0;
if(this.ms)
this.ms.reset();
this.waitedForResources = 0;
},
_onEnterFrame: function()
{
this.am.updateAudioViews();
this.vdm.updateVideoViews();
if(this.waitingForResources())
{
this.waitedForResources += this.POLL_INTERVAL;//not accurate, but doesn't matter
//if(cp.verbose)
// cp.log('waitedFor ' + this.waitedForResources + ' mS');
if(this.waitedForResources >= this.MAX_WAIT_TIME)
{
if(cp.verbose)
cp.log('waited too long...given up waiting! Paused = ' + this.paused + ' reason = ' + this.reasonForPause + ' pendingPlay = ' + this.pendingPlay);
this.resetAllWaitingResources();
this.unblockUI();
if((this.paused && this.reasonForPause == cp.ReasonForPause.WAIT_FOR_RESOURCES) || this.pendingPlay)
{
this.play();
}
return;
}
else if(this.waitedForResources >= this.MIN_WAIT_TIME_TO_BLOCK_UI)
{
this.pause(cp.ReasonForPause.WAIT_FOR_RESOURCES);
this.blockUI();
return;
}
else if(this.waitedForResources >= this.MIN_WAIT_TIME_TO_PAUSE_MOVIE)
{
this.pause(cp.ReasonForPause.WAIT_FOR_RESOURCES);
return;
}
return;
}
else
{
if(this.waitedForResources > 0)
{
if(cp.verbose)
cp.log('finished waiting! Paused = ' + this.paused + ' reason = ' + this.reasonForPause + ' pendingPlay = ' + this.pendingPlay);
}
this.waitedForResources = 0;
this.unblockUI();
if((this.paused && this.reasonForPause == cp.ReasonForPause.WAIT_FOR_RESOURCES) || this.pendingPlay)
{
this.play();
return;
}
}
if(this._jumpFrame)
{
this._jumpToFrame();
return;
}
var tmp = this.pendingJump;
if(tmp)
{
if(cp.verbose)
cp.log('jumping to pending jump frame ' + tmp);
delete this.pendingJump;
this.jumpToFrame(tmp);
return;
}
if (this.paused)
{
this.stage.UpdateFeedbacks();
this.stage.updateFrameCurrentOnPause();
return;
}
var beforeUpdate = new Date();
this.stage.UpdateFeedbacks();
this.stage.updateFrame(cp.Timeline.ReasonForUpdate.PROGRESS);
var afterUpdate = new Date();
if(this.paused)
return;
var elapsedFrames = 0;
if(cp.disablePaceMaker)
{
elapsedFrames = 1;
}
else
{
if(1 == this.speed && this.am.pace)
{
elapsedFrames = Math.round(this.am.pace - cpInfoCurrentFrame);
this.now = new Date();
}
else
{
var then = this.now;
var now = new Date();
elapsedFrames = Math.round(((now.getTime() - then.getTime() - (afterUpdate.getTime() - beforeUpdate.getTime()))*cpInfoFPS)/1000.0);
if(elapsedFrames > 0)
{
this.now = now;
}
}
}
if(cp.verbose)
cp.log("elapsed frames = " + elapsedFrames);
this.stage.attemptToAdvanceCurrentFrameByOffset(elapsedFrames);
},
registerQuizVariableSetters: function()
{
if(!cp.movie.playbackController)
return;
var lQuizController = cp.movie.playbackController.GetQuizController();
if(!lQuizController)
return;
lQuizController.quizInScopeSetter = setCpInQuizScope;
lQuizController.quizScopeSlideSetter = setCpQuizScopeSlide;
},
initLMS: function()
{
if (this.playbackController)
{
var loadingResumeData = this.playbackController.GetLoadingResumeDataBln();
//if (loadingResumeData)
// m_VarHandle.rdcmndPause = 1;
if (!this.m_hasIsTrackedBeenSet)
{
if (!this.playbackController.GetIsTrackedFlag())
{
this.playbackController.SetIsTracked(false);
this.m_hasIsTrackedBeenSet = true;
}
else //if (m_currSlide)
{
this.playbackController.SetIsTracked(true);
this.m_hasIsTrackedBeenSet = true;
}
loadingResumeData = this.playbackController.GetLoadingResumeDataBln();
//if (loadingResumeData)
// m_VarHandle.rdcmndPause = 1;
}
}
},
resumeMovieSpecificValue: function()
{
if(!this.playbackController)
return;
var lRestoringFrame = this.playbackController.GetRestoredQuizSlide();
if(lRestoringFrame >=0)
setCpInfoCurrentFrame(lRestoringFrame);
}
}
})();
function playPause(fromPlaybar)
{
var reason;
if(cp.movie.paused)
{
if (fromPlaybar == true)
reason = cp.ReasonForPlay.PLAYBAR_ACTION;
cp.movie.play(reason);
}
else
{
if (fromPlaybar == true)
reason = cp.ReasonForPause.PLAYBAR_ACTION;
cp.movie.pause(reason);
}
}
function goToPreviousSlide()
{
cp.jumpToPreviousSlide()
}
function goToNextSlide()
{
cp.jumpToNextSlide();
}
function jumpToSlide(uid)
{
cpCmndGotoSlideByUIDAndResume = uid;
}
function rewind()
{
cpCmndRewindAndPlay = 1;
}
function showHideCC()
{
if(cpCmndCC)
cpCmndCC = 0;
else
cpCmndCC = 1;
}
function showHideTOC()
{
var toc = document.getElementById('toc');
if(toc!=undefined && toc.animator)
{
if(toc.animator.direction == 0)
toc.animator.showTOC();
else
toc.animator.hideTOC();
}
}
function fastForward()
{
cpCmndFastForward = 1;
}
function shouldMoveTo(frame)
{
return cp.movie.stage.canUpdateToFrame(frame);
}
function showValue(frame)
{
showHideElements();
cp.movie.pause(cp.ReasonForPause.SHOW_VALUE_AT_FRAME);
cp.movie.jumpToFrame(frame);
}
function showHideFeedbackCaptionsClickHandler (div,shouldExecuteAction, item)
{
var object = item;
if (! object) {
var slideDivData = cp.model.data[div.id];
object = slideDivData['topMostObjectInteractiveObject'];
}
if (! object)
return false;
var divdata = cp.model.data[object];
if ( divdata && undefined != divdata.val ) // means TEB.
return false; // TEB has it's own handler.
return cp.clickFailureHandler(divdata, shouldExecuteAction);
}
function vTEB( tebDivName )
{
var divdata = cp.model.data[ tebDivName ];
if ( undefined == divdata || divdata.handled )
return false;
var currentAttempt = 0;
var cAttempt = divdata[ 'currentAttempt' ];
if ( undefined != cAttempt )
currentAttempt = cAttempt;
var maxAttempts = divdata[ 'ma' ];
currentAttempt = currentAttempt + 1;
divdata[ 'currentAttempt' ] = currentAttempt;
var isCorrect = cp.isTEBValueCorrect( tebDivName, divdata );
var successCaption = divdata[ 'osc' ];
var successAction = divdata[ 'oca' ];
var failureCaption = divdata[ 'ofc' ];
var failureAction = divdata[ 'ofa' ];
var captionToBeShown = false;
var caption = '';
var isCaptionVisible = false;
var action = '';
var pauseMovie = false;
var feedback = null;
var feedbackType = cp.FeedbackType.SUCCESS;
if ( isCorrect ) {
caption = successCaption;
action = successAction;
pauseMovie = ( divdata.pfc == 1 );
SubmitInteractions(tebDivName, true, currentAttempt);
}
else {
feedbackType = cp.FeedbackType.FAILURE;
caption = failureCaption;
action = failureAction;
SubmitInteractions(tebDivName, false, currentAttempt);
}
if ( caption.length > 2 )
captionToBeShown = true;
var shouldExecuteAction = ( maxAttempts != -1 && currentAttempt >= maxAttempts ) || isCorrect;
if ( ! divdata.handled )
divdata.handled = shouldExecuteAction;
if ( captionToBeShown ) {
if ( ! shouldExecuteAction )
action = '';
feedback = new cp.Feedback( caption, action, pauseMovie, feedbackType );
feedback.show();
}
else if ( shouldExecuteAction )
cp.movie.executeAction( action );
return isCorrect;
}
function TEBValidator( div )
{
var button_divdata = cp.model.data[ div.id ];
if ( button_divdata )
vTEB( button_divdata[ 'vid' ] );
}
function hyperlinkClick( div )
{
var hyperLink_divData = cp.model.data[div.id];
if (hyperLink_divData)
{
var actionString = hyperLink_divData['oca'];
if(cp.movie.paused)
{
actionString = actionString.replace("cpCmndResume = 1;", "");
}
cp.movie.executeAction(actionString);
}
}
function clickHandler (div)
{
var divdata = cp.model.data[div.id];
cp.clickSuccessHandler(divdata);
}
function ch(div){return clickHandler(div);}
function SubmitInteractions(objName,isCorrect,currentAttempt)
{
var lClickItemData = cp.model.data[objName];
var objType = lClickItemData.type;
if ( ! lClickItemData )
return;
var shouldIncludeInQuiz = ((lClickItemData['siq'] != undefined) && (lClickItemData['siq']));
if(shouldIncludeInQuiz)
{
var lQuestionObj = getQuestionObject(objName);
if(lQuestionObj)
{
if(!cp.movie.playbackController)
return;
var lQuizController = cp.movie.playbackController.GetQuizController();
if(!lQuizController)
return;
var lIsDone = false;
if(!lQuizController.GetIsInReviewMode() && !lQuizController.GetIsQuizCompleted())
lQuestionObj.setCurrentAttempt(currentAttempt + 1);
var lCorrectValues;
var lCurrentValues;
if(lQuestionObj.getInteractionType() == "fill-in")
{
var inputFieldName = objName + '_inputField';
var input = document.getElementById( inputFieldName );
if ( ! input )
return false;
lCorrectValues = lClickItemData['exp'];
lCurrentValue = input.value;
}
else
{
lCorrectValues = ['1'];
if(isCorrect)
lCurrentValue = '1';
else
lCurrentValue = '0';
}
lQuestionObj.questionData['cal'] = lCorrectValues;
lQuestionObj.setSelectedAnswers(lCurrentValue);
if(isCorrect)
{
lIsDone = true
}
else
{
if(lQuestionObj.getCurrentAttempt() >= lQuestionObj.getNumberOfAttempts())
lIsDone = true;
}
var shouldAddToTotal = ((lClickItemData['sat'] != undefined) && (lClickItemData['sat']));
lQuestionObj.setShouldAddToTotal(shouldAddToTotal);
if(!lQuizController.GetIsInReviewMode() && !lQuizController.GetIsQuizCompleted())
{
if(lIsDone)
{
if(isCorrect)
lQuestionObj.setQuestionStatus(lQuestionObj.QuestionStatusEnum.CORRECT);
else
lQuestionObj.setQuestionStatus(lQuestionObj.QuestionStatusEnum.INCORRECT);
lQuestionObj.endQuestion(true);
}
}
}
}
var evtArgs = {
itemname: objName,
frameNumber: cpInfoCurrentFrame,
objecttype: objType,
issuccess: isCorrect,
slideNumber: cpInfoCurrentSlideIndex + 1,
includedInQuiz:shouldIncludeInQuiz
};
if (lQuestionObj)
evtArgs.questioneventdata = lQuestionObj.getQuestionEventData()
cp.em.fireEvent('CPInteractiveItemSubmit',evtArgs);
}
function hotspotQuestionSlideHandler(e)
{
var lScaledPosition = getScaledPosition(e.pageX, e.pageY);
var x = lScaledPosition.X;
var y = lScaledPosition.Y;
//x -= cp.movie.offset;
//y -= cp.movie.topOffset;
var currDiv = e.currentTarget;
var children = currDiv.childNodes;
var currElement = children[0];
var currElementDivData = cp.model.data[currElement.id];
var lQuestionObj = getQuestionObject(currElement.id);
if(lQuestionObj)
lQuestionObj.hotspotQuestionHandler(currDiv, x, y);
}
function handleClickExternal(e)
{
function IsNonQuestionInteractiveObject(obj)
{
// For the moment, handle only click box.
return cp.kCPOTClickBoxItem == obj.type || cp.kCPOTScorableButtonItem == obj.type || cp.kCPOTAutoShape == obj.type;
}
function createClickTimer( currElem, clickItem, attempt )
{
var elem = currElem;
var cItem = clickItem;
var currentAttempt = attempt;
function handleClickInternal()
{
cp.stopClickTimer();
currentAttempt = currentAttempt + 1;
cItem[ 'currentAttempt' ] = currentAttempt;
var maxAttempts = cItem[ 'ma' ];
var canvasItem = cItem[ 'mdi' ];
var isVisible = (cp.model.data[canvasItem].visible);
var shouldExecuteAction = (maxAttempts != -1 && currentAttempt >= maxAttempts) && (isVisible);
var retVal = showHideFeedbackCaptionsClickHandler( currElem, shouldExecuteAction, cp.model.data[canvasItem].dn);
if ( IsNonQuestionInteractiveObject( cItem ) && ! cItem.handled )
cItem.handled = shouldExecuteAction;
return retVal;
}
if ( ! cp.isClickTimerRunning() )
cp.startClickTimer( 500, handleClickInternal );
}
function ShouldHandle( obj )
{
// For autoshape on hotspot question, we need to handle only when autoshape is on top.
if ( ! obj || cp.kCPOTAutoShape != obj.type )
return true; // handle.
var currSlide = cp.movie.stage.currentSlide;
var isHotspot = false;
var areQuestionSlideOptionsDisabled = false;
var sFrom = 0, sTo = 0;
if ( currSlide ) {
sFrom = currSlide.from;
sTo = currSlide.to;
if ( currSlide.st == "Question Slide" ) {
if ( currSlide.qs ) {
var data = cp.model.data[ currSlide.qs ];
if ( data && data.qtp == 'Hotspot' )
isHotspot = true;
var lQuestionObj = getQuestionObject(currSlide.qs);
if(lQuestionObj && lQuestionObj.shouldDisableOptions())
areQuestionSlideOptionsDisabled = true;
}
}
}
if ( ! isHotspot )
return true; // not hot spot, so default behaviour.
if(areQuestionSlideOptionsDisabled)
return true; // if answer options are to be disabled on any question slide, smart button actions can be handled.
if ( ! obj.rp )
return false; // not rest of project, on hot spot, so no handling.
if ( ! obj.rpa )
return false; // not above, so no handling.
// This autoshape is rest of project and above, but starts at this slide.
var objfrom = obj.from;
if ( obj.from > sFrom )
return false; // Starts on this slide.
return true; // handle
}
if ( cp.isClickTimerRunning() )
return false;
var lScaledPosition = getScaledPosition(e.pageX, e.pageY);
var x = lScaledPosition.X;
var y = lScaledPosition.Y;
//x -= cp.movie.offset;
//y -= cp.movie.topOffset;
var clickItem = null;
var currDiv = e.currentTarget;
var children = currDiv.childNodes;
var shouldShowFailure = false;
var clickItemId = '';
var firstFailureClickItem = null;
var firstFailureClickItemId = '';
var maxAttempts = -1;
var currentAttempt = 0;
var failureMaxAttempts = -1;
var failureCurrentAttempt = 0;
var failureElemDivData = null;
for(var i=children.length - 1; i >= 0; --i)
{
var currElement = children[i];
if(currElement.nodeName != 'DIV')
continue;
if(currElement.style.display != 'block')
continue;
currElementDivData = cp.model.data[currElement.id];
var canvasItem = currElementDivData['mdi'];
if(!cp.model.data[canvasItem].visible)
continue;
if(!currElementDivData['pa'])
continue;
if(undefined != currElementDivData['val'])
continue;
var drawingItemForCurrElement = currElementDivData['mdi'];
drawingItemDivData = cp.model.data[drawingItemForCurrElement];
currentAttempt = 0;
maxAttempts = -1;
var cAttempt = currElementDivData ['currentAttempt'];
if (cAttempt != undefined)
currentAttempt = cAttempt;
maxAttempts = currElementDivData ['ma'];
clickItem = currElementDivData;
clickItemId = currElement.id;
if (undefined != clickItem.amc && ! clickItem.amc) {
if ( cp.device != cp.IDEVICE ) // For idevice we don't honour this.
continue; // No mouse click allowed.
}
var projectData = cp.model.data['project'];
var minX = parseFloat(currElement.style.left);
var minY = parseFloat(currElement.style.top);
var maxX = parseFloat(currElement.style.left) + parseFloat(currElement.style.width);
var maxY = parseFloat(currElement.style.top) + parseFloat(currElement.style.height);
if ( currElement.effectX ) {
minX += currElement.effectX;
maxX += currElement.effectX;
}
if ( currElement.effectY ) {
minY += currElement.effectY;
maxY += currElement.effectY;
}
var rot = 0;
if(currElement.rotateAngle)
rot = currElement.rotateAngle;
var IsPointWithin = function()
{
var tempX = x;
var tempY = y;
tempX -= (minX + maxX)/2;
tempY -= (minY + maxY)/2;
var newX = tempX*Math.cos((Math.PI*(-rot))/180) - tempY*Math.sin((Math.PI*(-rot))/180);
var newY = tempX*Math.sin((Math.PI*(-rot))/180) + tempY*Math.cos((Math.PI*(-rot))/180);
newX += (minX + maxX)/2;
newY += (minY + maxY)/2;
if((newX >= minX && newX <= maxX) && (newY >= minY && newY <= maxY))
return true;
return false;
};
if(IsPointWithin())
{
if(currElementDivData['iqb'])
return true; // Question buttons - have been handled separately.
if(currElementDivData['vid'])
return true; // TEB button - has already been handled.
if(currElementDivData['enabled'])
{
if ( clickItem.actionInProgress )
return false;
if ( clickItem.dclk || clickItem.rclk ) {
// Can only be wrong.
createClickTimer( currElement, clickItem, currentAttempt );
return false;
}
if ( ! ShouldHandle( clickItem ) )
return false;
var clickHandlerFunctionName = currElementDivData['chfn'];
SubmitInteractions(currElement.id, true, currentAttempt);
var oldSlide = cp.movie.stage.currentSlide;
clickHandlerFunctionName(currElement); // can cause slide jump.
var newSlide = cp.movie.stage.currentSlide;
if ( oldSlide == newSlide && IsNonQuestionInteractiveObject( clickItem ) )
clickItem.handled = true;
return true;
}
shouldShowFailure = false;
break;
}
else if ( currElementDivData['vid'] ) // TEB button. No handling needed.
continue;
else {
shouldShowFailure = true;
if ( null == firstFailureClickItem ) {
// Now check whether this really has failure action. For failure action:
// a) failure caption should be there OR
// b) attempts should not be infinite.
if ( clickItem.ofc || clickItem.ma != -1 ) {
firstFailureClickItemId = clickItemId;
firstFailureClickItem = clickItem;
failureCurrentAttempt = currentAttempt;
failureMaxAttempts = maxAttempts;
failureElemDivData = currElementDivData;
}
}
}
}
if ( shouldShowFailure ) {
if ( firstFailureClickItem ) {
clickItem = firstFailureClickItem;
clickItemId = firstFailureClickItemId;
currentAttempt = failureCurrentAttempt;
maxAttempts = failureMaxAttempts;
currElementDivData = failureElemDivData;
}
if ( clickItem && clickItem.actionInProgress )
return false;
if(clickItem)
{
currentAttempt = currentAttempt + 1;
clickItem .currentAttempt = currentAttempt;
var lItemId;
var lItemCanvas;
if(clickItem.mdi)
lItemCanvas = cp.model.data[clickItem.mdi];
if(lItemCanvas)
lItemId = lItemCanvas.dn;
SubmitInteractions(lItemId, false, currentAttempt - 1);
}
var canvasItem = currElementDivData['mdi'];
var isVisible = (cp.model.data[canvasItem].visible);
var shouldExecuteAction = (maxAttempts != -1 && currentAttempt >= maxAttempts) && (isVisible);
var itemForHandling = '';
if ( clickItem && IsNonQuestionInteractiveObject( clickItem ) )
itemForHandling = clickItemId;
showHideFeedbackCaptionsClickHandler(children[0],shouldExecuteAction, itemForHandling);
if (clickItem && IsNonQuestionInteractiveObject( clickItem ) && ! clickItem.handled )
clickItem.handled = shouldExecuteAction;
}
return false;
}
function handleClick(e)
{
var handled = handleClickExternal(e);
if(!handled)
{
var currDiv = e.currentTarget;
var children = currDiv.childNodes;
var currElement = children[0];
if(!currElement)
return;
if(currElement.nodeName != 'DIV')
return;
if(currElement.style.display != 'block')
return;
var lQuestionObjName = getQuestionObjectName(currElement.id);
var lQuestionObjData = cp.model.data[lQuestionObjName];
if(lQuestionObjData)
{
if(lQuestionObjData['qtp'] == 'Hotspot')
hotspotQuestionSlideHandler(e);
}
}
}
function showInfoDialog()
{
var lPausedByInfo = false;
if(!cp.movie.paused)
{
cp.movie.pause(cp.ReasonForPause.PLAYBAR_ACTION);
lPausedByInfo = true;
}
var infoBGImage = cp.movie.im.m_projectImages["assets/playbar/PlaybarIcons/infobg.png"];
var lInfoDialog = document.createElement("div");
cp.project.appendChild(lInfoDialog);
lInfoDialog.id = "infoDialog";
lInfoDialog.style.position = "absolute";
lInfoDialog.style.backgroundImage = "url(" + infoBGImage.src + ")";
lInfoDialog.style.left = (cp.model.data.project.w - infoBGImage.nativeImage.width)/2 + "px";
lInfoDialog.style.top = (cp.model.data.project.h - infoBGImage.nativeImage.height)/2 + "px";
lInfoDialog.style.width = infoBGImage.nativeImage.width + "px";
lInfoDialog.style.height = infoBGImage.nativeImage.height + "px";
var lInfoCloseButton = document.createElement("div");
lInfoCloseButton.onclick = function(e){cp.project.removeChild(lInfoDialog);if(lPausedByInfo)cp.movie.play();};
lInfoCloseButton.style.cursor = "pointer";
lInfoCloseButton.style.backgroundColor = "#ffffff";
lInfoCloseButton.style.opacity = 0;
lInfoCloseButton.style.left = "170px";
lInfoCloseButton.style.top = "5px";
lInfoCloseButton.style.width = "15px";
lInfoCloseButton.style.height = "15px";
lInfoCloseButton.style.position = "absolute";
lInfoCloseButton.style.display = "block";
lInfoDialog.appendChild(lInfoCloseButton);
var lInformationDiv = document.createElement("div");
var lInfoStr = "