/* TimelineJS - ver. 2.36.0 - 2015-05-12 Copyright (c) 2012-2013 Northwestern University a project of the Northwestern University Knight Lab, originally created by Zach Wise https://github.com/NUKnightLab/TimelineJS This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ LazyLoad=function(doc){var env,head,pending={},pollCount=0,queue={css:[],js:[]},styleSheets=doc.styleSheets;function createNode(name,attrs){var node=doc.createElement(name),attr;for(attr in attrs){if(attrs.hasOwnProperty(attr)){node.setAttribute(attr,attrs[attr])}}return node}function finish(type){var p=pending[type],callback,urls;if(p){callback=p.callback;urls=p.urls;urls.shift();pollCount=0;if(!urls.length){callback&&callback.call(p.context,p.obj);pending[type]=null;queue[type].length&&load(type)}}}function getEnv(){var ua=navigator.userAgent;env={async:doc.createElement("script").async===true};(env.webkit=/AppleWebKit\//.test(ua))||(env.ie=/MSIE/.test(ua))||(env.opera=/Opera/.test(ua))||(env.gecko=/Gecko\//.test(ua))||(env.unknown=true)}function load(type,urls,callback,obj,context){var _finish=function(){finish(type)},isCSS=type==="css",nodes=[],i,len,node,p,pendingUrls,url;env||getEnv();if(urls){urls=typeof urls==="string"?[urls]:urls.concat();if(isCSS||env.async||env.gecko||env.opera){queue[type].push({urls:urls,callback:callback,obj:obj,context:context})}else{for(i=0,len=urls.length;i=0){if(styleSheets[i].href===css.urls[0]){finish("css");break}}pollCount+=1;if(css){if(pollCount<200){setTimeout(pollWebKit,50)}else{finish("css")}}}}return{css:function(urls,callback,obj,context){load("css",urls,callback,obj,context)},js:function(urls,callback,obj,context){load("js",urls,callback,obj,context)}}}(this.document);LoadLib=function(doc){var loaded=[];function isLoaded(url){var i=0,has_loaded=false;for(i=0;ineed;break}}}}catch(err){ready.jquery=false}if(!ready.jquery){LoadLib.js(path.jquery,onloaded_jquery)}else{onloaded_jquery()}function onloaded_jquery(){LoadLib.js(storyjs_e_config.js,onloaded_js)}function onloaded_js(){ready.js=true;if(storyjs_e_config.lang!="en"){LazyLoad.js(path.locale,onloaded_language)}else{ready.language=true}onloaded_check()}function onloaded_language(){ready.language=true;onloaded_check()}function onloaded_css(){ready.css=true;onloaded_check()}function onloaded_font_css(){ready.font.css=true;onloaded_check()}function onloaded_font_js(){ready.font.js=true;onloaded_check()}function onloaded_check(){if(ready.checks>40){return;alert("Error Loading Files")}else{ready.checks++;if(ready.js&&ready.css&&ready.font.css&&ready.font.js&&ready.language){if(!ready.finished){ready.finished=true;buildEmbed()}}else{ready.timeout=setTimeout("onloaded_check_again();",250)}}}this.onloaded_check_again=function(){onloaded_check()};function createEmbedDiv(){var embed_classname="storyjs-embed";t=document.createElement("div");if(storyjs_e_config.embed_id!=""){te=document.getElementById(storyjs_e_config.embed_id)}else{te=document.getElementById("timeline-embed")}te.appendChild(t);t.setAttribute("id",storyjs_e_config.id);if(storyjs_e_config.width.toString().match("%")){te.style.width=storyjs_e_config.width.split("%")[0]+"%"}else{storyjs_e_config.width=storyjs_e_config.width-2;te.style.width=storyjs_e_config.width+"px"}if(storyjs_e_config.height.toString().match("%")){te.style.height=storyjs_e_config.height;embed_classname+=" full-embed";te.style.height=storyjs_e_config.height.split("%")[0]+"%"}else if(storyjs_e_config.width.toString().match("%")){embed_classname+=" full-embed";storyjs_e_config.height=storyjs_e_config.height-16;te.style.height=storyjs_e_config.height+"px"}else{embed_classname+=" sized-embed";storyjs_e_config.height=storyjs_e_config.height-16;te.style.height=storyjs_e_config.height+"px"}te.setAttribute("class",embed_classname);te.setAttribute("className",embed_classname);t.style.position="relative"}function buildEmbed(){VMM.debug=storyjs_e_config.debug;storyjs_embedjs=new VMM.Timeline(storyjs_e_config.id);storyjs_embedjs.init(storyjs_e_config);if(isCDN){VMM.bindEvent(global,onHeadline,"HEADLINE")}}} ; TimelineJS = (function ($) { function Timeline (options, major, minor) { // This non-runnable library does not know it's own major+minor, therefore // we have tp provide it from runnable library using me var libraryPath = 'TimelineJS-' + major + '.' + minor; // Set this global variable to inform TimelineJS where all CSS/JS is placed window.embed_path = H5P.getLibraryPath(libraryPath) + '/'; createStoryJS(options); }; return Timeline; })(H5P.jQuery); ; /* global TimelineJS */ /** * Init a H5P object. **/ var H5P = H5P || {}; /** * * @param object params * The object defined in content.json * @param int contentId * The nodes vid */ H5P.Timeline = (function ($) { function C(options, contentId) { var self = this; var i; this.options = $.extend(true, {}, { timeline: { type: 'default', defaultZoomLevel: 0, language: 'en', height: 600 } }, options); // Need to create the URL for all H5P.Images if (this.options.timeline.date !== undefined) { var dates = this.options.timeline.date; for(i=0; i= 0; i--) { if(this.options.timeline.era[i].startDate === undefined || this.options.timeline.era[i].endDate === undefined) { this.options.timeline.era.splice(i,1); } } } /** * Set background image * @method setBackgroundImage * @param {Object} image Image object as part of H5P content jeson */ self.setBackgroundImage = function (image) { // Need to wait for timelinejs to be finished setTimeout(function () { var $slider = self.$container.find('.vco-slider'); if ($slider.length !== 0) { $slider.css('background-image', 'url(' + H5P.getPath(image.path, contentId) + ')'); } else { self.setBackgroundImage(image); } }, 200); }; self.on('enterFullScreen', function () { self.$container.css('height', '100%'); $(window).trigger('resize'); }); self.on('exitFullScreen', function () { self.$container.css('height', self.options.timeline.height + 'px'); $(window).trigger('resize'); }); } /** * Check if data provided is valid. * @method validate * @return {boolean} Valid or not */ C.prototype.validate = function () { if (this.options.timeline.date === undefined || this.options.timeline.date.length === 0) { return false; } for (var i = 0; i < this.options.timeline.date.length; i++) { var element = this.options.timeline.date[i]; if (element.startDate === undefined || element.headline === undefined) { return false; } } return true; }; /** * Attatch the Timeline HTML to a given target. **/ C.prototype.attach = function ($container) { var self = this; self.$container = $container; $container.addClass('h5p-timeline').css('height', self.options.timeline.height + 'px'); $container.append($('
', {id: 'h5p-timeline'})); // Need to set this to make timeline behave correctly: window.jQuery = $; if (self.validate()) { // Load library.json - need to inform TimelineJS which version it is $.getJSON(self.getLibraryFilePath('library.json'), function (data) { new TimelineJS({ type: 'timeline', width: '100%', height: '100%', source: self.options, lang: self.options.timeline.language, start_zoom_adjust: self.options.timeline.defaultZoomLevel, embed_id: 'h5p-timeline' }, data.preloadedDependencies[0].majorVersion, data.preloadedDependencies[0].minorVersion); // Add background image if any: if (self.options.timeline.backgroundImage !== undefined) { self.setBackgroundImage(self.options.timeline.backgroundImage); } }); } else { $container.append($('
', { html: 'Missing mandatory data - not able to draw the timeline. Please open this H5P in the editor, and make the necessary changes.', 'class': 'h5p-timeline-data-not-valid' })); } }; return C; })(H5P.jQuery); ;