From e0beab922fd4a2f6a64b8a9946ebfe6e45a35725 Mon Sep 17 00:00:00 2001 From: Fay Cross Date: Wed, 14 Nov 2012 15:52:25 +0000 Subject: [PATCH] html5: fixed line breaks bug, fixed bugs on newWindow, embedDiv and title pages, completed textVideo page, new xerteModel page added git-svn-id: https://xerteonlinetoolkits.googlecode.com/svn/trunk@495 912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641 --- .../Nottingham/common_html5/js/xenith.js | 6 +- .../common_html5/mediaelement/mediaPlayer.js | 26 +++++++-- .../Nottingham/models_html5/embedDiv.html | 5 +- .../Nottingham/models_html5/newWindow.html | 5 -- .../Nottingham/models_html5/textVideo.html | 57 +++++++------------ .../Nottingham/models_html5/title.html | 2 +- .../Nottingham/models_html5/xerteModel.html | 35 ++++++++++++ 7 files changed, 80 insertions(+), 56 deletions(-) create mode 100644 modules/xerte/parent_templates/Nottingham/models_html5/xerteModel.html diff --git a/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js b/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js index b1e0017dcb..9fc4145ffb 100644 --- a/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js +++ b/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js @@ -111,7 +111,7 @@ $(document).ready(function() { } else { newString += text.substring(indexAttr[i - 1].end, indexAttr[i].start); } - newString += text.substring(indexAttr[i].start, indexAttr[i].end).replace(/\n/g, " "); + newString += text.substring(indexAttr[i].start, indexAttr[i].end).replace(/(\n|\r|\r\n)/g, " "); if (i == indexAttr.length - 1) { newString += text.substring(indexAttr[i].end, text.length); } @@ -191,7 +191,7 @@ function x_setUp() { $x_nextBtn = $("#x_nextBtn"); $x_background = $("#x_background"); - $x_body.css("font-size", Number(x_params.textSize) + "pt"); + $x_body.css("font-size", Number(x_params.textSize) - 2 + "pt"); if (screen.width <= 550) { x_browserInfo.mobile = true; @@ -922,7 +922,7 @@ function x_scaleImg(img, maxW, maxH, scale, firstScale, setH) { // function swaps line breaks in xml text attributes and CDATA to br tags function x_addLineBreaks(text) { - return text.replace(/\n/g, "
"); + return text.replace(/(\n|\r|\r\n)/g, "
"); } function x_addPageLinks(pageText, returnMethod) { diff --git a/modules/xerte/parent_templates/Nottingham/common_html5/mediaelement/mediaPlayer.js b/modules/xerte/parent_templates/Nottingham/common_html5/mediaelement/mediaPlayer.js index ca4f71e6df..6a6275a1ec 100644 --- a/modules/xerte/parent_templates/Nottingham/common_html5/mediaelement/mediaPlayer.js +++ b/modules/xerte/parent_templates/Nottingham/common_html5/mediaelement/mediaPlayer.js @@ -3,9 +3,7 @@ $.fn.mediaPlayer = function(options) { var defaults = { type :"audio", - source :"", - autoPlay :false, - autoNavigate :false + source :"" }; var opts = $.extend({}, defaults, options); @@ -26,14 +24,14 @@ } opts.source = eval(opts.source); - var fileType = opts.type + "/" + opts.source.substring(opts.source.indexOf(".")+1); this.append('<' + opts.type + ' preload="metadata"' + dimensionsString + '>'); + this.find(opts.type).mediaelementplayer({ startVolume: x_volume, alwaysShowControls: true, pauseOtherPlayers: true, - success: function (mediaElement, domObject) { + success: function (mediaElement, domObject) { if (opts.autoNavigate == "true" && x_currentPage + 1 != x_pages.length) { // go to next page when media played to end mediaElement.addEventListener("ended", function() { $x_nextBtn.trigger("click"); @@ -65,7 +63,25 @@ if (opts.autoPlay == "true") { // autoplay media (won't work on iOS on 1st load) mediaElement.play(); } + + if (opts.startEndFrame != undefined) { // start / end playing video at specified frame + var startFrame = opts.startEndFrame[0]; + var endFrame = opts.startEndFrame[1]; + if (startFrame != 0) { + mediaElement.addEventListener("canplay", function() { + mediaElement.setCurrentTime(startFrame); + }); + } + if (endFrame != 0) { + mediaElement.addEventListener("timeupdate", function(e) { + if (mediaElement.currentTime > endFrame) { + mediaElement.pause(); + } + }, false); + } + } } }); } + })(jQuery); \ No newline at end of file diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/embedDiv.html b/modules/xerte/parent_templates/Nottingham/models_html5/embedDiv.html index b8630651c8..3bcea3fa35 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/embedDiv.html +++ b/modules/xerte/parent_templates/Nottingham/models_html5/embedDiv.html @@ -31,6 +31,7 @@ } else { // use iframe to load web page var iFrameTag = ''; $pageContents.html(iFrameTag); + $pageContents.addClass("centerAlign"); } // call this function in every model once everything's loaded @@ -39,10 +40,6 @@ diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/newWindow.html b/modules/xerte/parent_templates/Nottingham/models_html5/newWindow.html index 05ab62815d..d444483d36 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/newWindow.html +++ b/modules/xerte/parent_templates/Nottingham/models_html5/newWindow.html @@ -1,6 +1,4 @@ diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/title.html b/modules/xerte/parent_templates/Nottingham/models_html5/title.html index cf4a727b23..d24e2d05de 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/title.html +++ b/modules/xerte/parent_templates/Nottingham/models_html5/title.html @@ -18,7 +18,7 @@ var vConstrain = x_currentPageXML.getAttribute("bgImageVConstrain"); var hConstrain = x_currentPageXML.getAttribute("bgImageHConstrain"); - var alpha = 50; + var alpha = 100; if (x_currentPageXML.getAttribute("bgImageAlpha") != undefined) { alpha = x_currentPageXML.getAttribute("bgImageAlpha"); } diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/xerteModel.html b/modules/xerte/parent_templates/Nottingham/models_html5/xerteModel.html new file mode 100644 index 0000000000..c5d4e491ef --- /dev/null +++ b/modules/xerte/parent_templates/Nottingham/models_html5/xerteModel.html @@ -0,0 +1,35 @@ + + + + +
+ +
\ No newline at end of file