diff --git a/public/bundles/v2.debug.js b/public/bundles/v2.debug.js index 684ec15..af5363a 100644 --- a/public/bundles/v2.debug.js +++ b/public/bundles/v2.debug.js @@ -748,4 +748,4 @@ Traitify.ui = { } }; -Traitify.ui.widget("tf-slide-deck", {"data":["slides"],"template":"
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Me
\n
Not Me
\n
\n Loading...\n Click to reload!\n
\n
\n
\n\n","scripts":["\n (function(me){\n me.traitify = Object()\n\n me.traitify.deferred = function(){\n return {\n thenCalls: Array(),\n catchCalls: Array(),\n then: function(callback){\n if(this.triggered){\n callback(this.args);\n }else{\n this.thenCalls.push(callback);\n }\n },\n catch: function(callback){\n if(this.triggered){\n callback(this.args);\n }else{\n this.catchCalls.push(callback);\n }\n },\n resolve: function(args){\n if(this.thenCalls && this.thenCalls.length != 0){\n for(i=0; i < this.thenCalls.length; i++){\n this.thenCalls[i](args);\n }\n }else{\n this.args = args;\n this.triggered = true;\n }\n },\n reject: function(args){\n if(this.catchCalls.length != 0){\n for(i=0; i < this.catchCalls.length; i++){\n this.catchCalls[i](args);\n }\n }else{\n this.args = args;\n this.triggered = true;\n }\n }\n }\n }\n me.traitify.Observable = function(item){\n item.ons = Object()\n item.on = function(key, callback){\n if(!item.ons[key]){\n item.ons[key] = Array();\n }\n item.ons[key].push(callback);\n }\n item.trigger = function(key, opts){\n if(item.ons[key] && typeof item.ons[key].length != 0){\n il = item.ons[key].length\n for(i=0; i < il; i++){\n item.ons[key][i](opts); \n }\n }\n }\n item.off = function(key){\n item.ons[key] = Array();\n }\n }\n me.traitify.Observable(me.traitify);\n var i, undefined, el = document.createElement('div'),\n transitions = {\n 'transition':'transitionend',\n 'OTransition':'otransitionend', // oTransitionEnd in very old Opera\n 'MozTransition':'transitionend',\n 'WebkitTransition':'webkitTransitionEnd'\n };\n\n for (i in transitions) {\n if (transitions.hasOwnProperty(i) && el.style[i] !== undefined) {\n transitionEnd = transitions[i];\n }\n }\n var $TF = function(item){\n if(typeof item == \"string\"){\n item = me.querySelector(item);\n }\n if(Traitify.oldIE){\n item.addEventListener = item.attachEvent;\n }\n item.hide = function(){\n if(!this.className.match(/tf-hidden/)){\n this.className = this.className + \" tf-hidden\";\n }\n }\n item.show = function(){\n this.className = this.className.replace(/ tf-hidden/, \"\");\n }\n return item;\n }\n me.traitify.slideResponses = Object();\n me.traitify.lastResponse = new Date();\n me.traitify.db = Object();\n me.traitify.db.set = function(key, value){\n key = me.traitify.assessmentId + \"-\" + key\n return sessionStorage.setItem(key, JSON.stringify(value));\n }\n me.traitify.db.get = function(key){\n key = me.traitify.assessmentId + \"-\" + key\n return JSON.parse(sessionStorage.getItem(key));\n }\n me.traitify.initialize = function(){\n self = $TF(this);\n /*\n * Set Available Nodes\n */\n this.nodes = Object()\n this.nodes.currentSlide = $TF(\".tf-slide.tf-current\");\n this.nodes.nextSlide = $TF(\".tf-slide.tf-next\");\n this.nodes.caption = $TF(\".tf-caption\");\n this.nodes.me = $TF(\".tf-me\");\n this.nodes.notMe = $TF(\".tf-not-me\");\n this.nodes.progressBarInner = $TF(\".tf-progress-bar-inner\");\n this.nodes.slides = $TF(\".tf-slides\");\n this.nodes.loading = $TF(\".tf-loading .tf-loading-content\");\n this.nodes.clickToReload = $TF(\".tf-loading .tf-click-content\");\n\n\n /*\n * Set Data\n */\n this.data.unPlayedSlides = this.data.slides.filter(function(slide){\n return !slide.completed_at && Object.keys(self.db.get(\"slideResponses\") || Object()).indexOf(slide.id) == -1\n })\n this.data.playedSlides = this.data.slides.filter(function(slide){\n return slide.completed_at || Object.keys(self.db.get(\"slideResponses\") || Object()).indexOf(slide.id) != -1\n })\n this.data.slides = this.data.playedSlides.concat(this.data.unPlayedSlides)\n this.index = this.data.playedSlides.length || 0\n\n /*\n * Resize\n */\n self.resizeTimer = false;\n window.addEventListener(\"resize\", function(){\n if(self.resizeTimeout){\n clearTimeout(self.resizeTimeout);\n }\n\n self.resizeTimeout = setTimeout(function(){\n self.trigger(\"resize\");\n self.resizeTimeout = false;\n }, 300);\n });\n\n self.on(\"resize\", function(){\n width = me.offsetWidth;\n className = self.nodes.slides.className;\n className = className.replace(/ min-width-1200/g, \"\");\n className = className.replace(/ min-width-720/g, \"\");\n className = className.replace(/ min-width-480/g, \"\");\n \n if(width > 1200){\n className += \" min-width-1200\";\n } else if (width > 720){\n className += \" min-width-720\";\n } else{\n className += \" min-width-480\";\n }\n self.nodes.slides.className = className;\n })\n self.trigger(\"resize\");\n\n /*\n * Transition\n */\n this.slideLock = false;\n this.events = Object();\n self.nodes.nextSlide.transitionend = function(){\n\n }\n self.nodes.nextSlide.addEventListener(transitionEnd, function(){\n self.nodes.nextSlide.transitionend();\n })\n\n this.events.animate = function(){\n if(!self.slideLock){\n promise = self.deferred();\n self.slideLock = true;\n self.nodes.nextSlide.transitionend = function(){\n self.slideLock = false;\n promise.resolve();\n }\n self.nodes.nextSlide.className = self.nodes.nextSlide.className.replace(\"tf-next\", \"\") + \" tf-current\";\n self.nodes.progressBarInner.style.width = Math.round((self.index / self.data.slides.length) * 100) + \"%\";\n return promise;\n }\n }\n self.nodes.progressBarInner.style.width = Math.round((self.index / self.data.slides.length) * 100) + \"%\";\n\n /*\n * Set Current Slide\n */\n this.events.setCurrentSlideData = function(){\n if( self.data.slides.length - self.index == 0){\n return true;\n }\n\n self.currentSlide = self.data.slides[self.index];\n /*\n * Set Caption\n */\n self.nodes.caption.innerHTML = self.currentSlide.caption;\n \n /*\n * Set Image\n */\n self.nodes.currentSlide.style.backgroundImage = \"url(\" + self.currentSlide.image_desktop_retina + \")\";\n\n /*\n * Set Focus\n */\n backgroundPosition = self.currentSlide.focus_x + \"% \" + self.currentSlide.focus_y + \"%\";\n self.nodes.currentSlide.style.backgroundPosition = backgroundPosition; \n }\n\n /*\n * Set Next Slide\n */\n this.events.setNextSlideData = function(){\n if( self.data.slides.length - self.index <= 1){\n return true;\n }\n\n self.nextSlide = self.data.slides[self.index + 1];\n /*\n * Set Image\n */\n self.nodes.nextSlide.style.backgroundImage = \"url(\" + self.nextSlide.image_desktop_retina + \")\";\n\n /*\n * Set Focus\n */\n backgroundPosition = self.nextSlide.focus_x + \"% \" + self.nextSlide.focus_y + \"%\";\n self.nodes.nextSlide.style.backgroundPosition = backgroundPosition;\n }\n\n this.events.setNextSlideData();\n this.events.setCurrentSlideData();\n\n /*\n * Advance Slide\n */\n this.events.advanceSlide = function(){\n if(!self.slideLock){\n if(((self.index - self.data.slides.length) <= 2 && self.index - self.data.slides.length != 0 ) || self.images[self.index + 2]){\n self.index++\n self.trigger(\"advanceSlide\", {value: true, slide: slide});\n\n self.events.animate().then(function(){\n self.events.setNextSlideData();\n self.nodes.nextSlide.className = self.nodes.nextSlide.className.replace(\"tf-current\", \"\") + \" tf-next\";\n self.events.setCurrentSlideData();\n })\n } else if(!self.nodes.slides.className.match(/tf-loading/)) {\n self.nodes.slides.className += \" tf-loading\";\n } \n }\n }\n this.on(\"advanceSlide\", function(params){\n slideResponses = self.db.get(\"slideResponses\") || Object();\n\n slideResponses[params.slide.id] = {\n value: params.value,\n responseTime: new Date() - self.lastResponse\n };\n\n self.lastResponse = new Date();\n self.db.set(\"slideResponses\", slideResponses);\n self.trigger(\"setSlides\");\n })\n\n this.on(\"setSlides\", function(){\n slideResponses = self.db.get(\"slideResponses\") || Object();\n\n srl = Object.keys(slideResponses).length;\n\n if(srl == self.data.slides.length){\n slides = Object.keys(slideResponses).map(function(slideId){\n return {\n id: slideId,\n response: slideResponses[slideId].value,\n time_taken: slideResponses[slideId].responseTime\n };\n })\n \n Traitify.addSlides(self.assessmentId, slides).then(function(){\n me.innerHTML = \"\";\n\n self.trigger(\"finish\")\n });\n }\n })\n\n this.trigger(\"setSlides\");\n\n /*\n * Me Trigger\n */\n this.on(\"me\", function(){\n slide = self.data.slides[self.index]\n\n self.events.advanceSlide();\n })\n\n /*\n * Not Me Trigger\n */\n this.on(\"notMe\",function(){\n slide = self.data.slides[self.index]\n\n self.events.advanceSlide();\n })\n\n /*\n * Me\n */\n this.nodes.me.onclick = function(){ \n self.trigger(\"me\")\n }\n\n /*\n * Not Me\n */\n this.nodes.notMe.onclick = function(){\n self.trigger(\"notMe\")\n }\n\n /*\n * Gui For Preload Images\n */\n self.imageSize = \"image_desktop_retina\"\n this.imageUrls = self.data.slides.map(function(slide){\n return slide[self.imageSize];\n })\n\n this.nodes.clickToReload.onclick = function(){\n self.trigger(\"clickReload\");\n }\n this.on(\"clickReload\", function(){\n self.imageTries[self.images.lastIndex] = 0;\n self.nodes.loading.show();\n self.nodes.clickToReload.hide();\n self.loadImage(self.images.lastIndex);\n })\n\n /*\n * NASTY IMAGE PRELOADING\n */\n this.imageTries = Object()\n this.images = Array();\n self.images.lastIndex = this.index;\n\n this.loadImage = function(i){\n if(self.imageUrls[i]){\n if(!self.imageTries[i]){\n self.imageTries[i]= 0;\n }\n self.images[i] = new Image();\n self.images[i].src = self.imageUrls[i];\n self.images[i].onerror = function(){\n self.imageTries[i]++;\n if(self.imageTries[i] < 30){\n setTimeout(function(){\n self.loadImage(i);\n }, 1000)\n }else{\n self.images.lastIndex = i;\n self.nodes.loading.hide();\n self.nodes.clickToReload.show();\n }\n }\n self.images[i].onload = function(){\n setTimeout(function(){\n self.loadImage(i + 1);\n }, 300)\n self.trigger(\"imageLoaded\");\n self.nodes.clickToReload.hide();\n self.images.lastIndex = i;\n\n self.nodes.slides.className = self.nodes.slides.className.replace(\" tf-loading\", \"\");\n }\n }\n }\n this.loadImage(self.index);\n }\n })(document.currentScript.parentNode);\n"]}) \ No newline at end of file +Traitify.ui.widget("tf-slide-deck", {"name":"tf-slide-deck","data":["slides"],"template":"
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Me
\n
Not Me
\n
\n Loading...\n Click to reload!\n
\n
\n
\n\n","scripts":["\n (function(me){\n me.traitify = Object()\n\n me.traitify.deferred = function(){\n return {\n thenCalls: Array(),\n catchCalls: Array(),\n then: function(callback){\n if(this.triggered){\n callback(this.args);\n }else{\n this.thenCalls.push(callback);\n }\n },\n catch: function(callback){\n if(this.triggered){\n callback(this.args);\n }else{\n this.catchCalls.push(callback);\n }\n },\n resolve: function(args){\n if(this.thenCalls && this.thenCalls.length != 0){\n for(i=0; i < this.thenCalls.length; i++){\n this.thenCalls[i](args);\n }\n }else{\n this.args = args;\n this.triggered = true;\n }\n },\n reject: function(args){\n if(this.catchCalls.length != 0){\n for(i=0; i < this.catchCalls.length; i++){\n this.catchCalls[i](args);\n }\n }else{\n this.args = args;\n this.triggered = true;\n }\n }\n }\n }\n me.traitify.Observable = function(item){\n item.ons = Object()\n item.on = function(key, callback){\n if(!item.ons[key]){\n item.ons[key] = Array();\n }\n item.ons[key].push(callback);\n }\n item.trigger = function(key, opts){\n if(item.ons[key] && typeof item.ons[key].length != 0){\n il = item.ons[key].length\n for(i=0; i < il; i++){\n item.ons[key][i](opts); \n }\n }\n }\n item.off = function(key){\n item.ons[key] = Array();\n }\n }\n me.traitify.Observable(me.traitify);\n var i, undefined, el = document.createElement('div'),\n transitions = {\n 'transition':'transitionend',\n 'OTransition':'otransitionend', // oTransitionEnd in very old Opera\n 'MozTransition':'transitionend',\n 'WebkitTransition':'webkitTransitionEnd'\n };\n\n for (i in transitions) {\n if (transitions.hasOwnProperty(i) && el.style[i] !== undefined) {\n transitionEnd = transitions[i];\n }\n }\n var $TF = function(item){\n if(typeof item == \"string\"){\n item = me.querySelector(item);\n }\n if(Traitify.oldIE){\n item.addEventListener = item.attachEvent;\n }\n item.hide = function(){\n if(!this.className.match(/tf-hidden/)){\n this.className = this.className + \" tf-hidden\";\n }\n }\n item.show = function(){\n this.className = this.className.replace(/ tf-hidden/, \"\");\n }\n return item;\n }\n me.traitify.slideResponses = Object();\n me.traitify.lastResponse = new Date();\n me.traitify.db = Object();\n me.traitify.db.set = function(key, value){\n key = me.traitify.assessmentId + \"-\" + key\n return sessionStorage.setItem(key, JSON.stringify(value));\n }\n me.traitify.db.get = function(key){\n key = me.traitify.assessmentId + \"-\" + key\n return JSON.parse(sessionStorage.getItem(key));\n }\n me.traitify.initialize = function(){\n self = $TF(this);\n /*\n * Set Available Nodes\n */\n this.nodes = Object()\n this.nodes.currentSlide = $TF(\".tf-slide.tf-current\");\n this.nodes.nextSlide = $TF(\".tf-slide.tf-next\");\n this.nodes.caption = $TF(\".tf-caption\");\n this.nodes.me = $TF(\".tf-me\");\n this.nodes.notMe = $TF(\".tf-not-me\");\n this.nodes.progressBarInner = $TF(\".tf-progress-bar-inner\");\n this.nodes.slides = $TF(\".tf-slides\");\n this.nodes.loading = $TF(\".tf-loading .tf-loading-content\");\n this.nodes.clickToReload = $TF(\".tf-loading .tf-click-content\");\n\n\n /*\n * Set Data\n */\n this.data.unPlayedSlides = this.data.slides.filter(function(slide){\n return !slide.completed_at && Object.keys(self.db.get(\"slideResponses\") || Object()).indexOf(slide.id) == -1\n })\n this.data.playedSlides = this.data.slides.filter(function(slide){\n return slide.completed_at || Object.keys(self.db.get(\"slideResponses\") || Object()).indexOf(slide.id) != -1\n })\n this.data.slides = this.data.playedSlides.concat(this.data.unPlayedSlides)\n this.index = this.data.playedSlides.length || 0\n\n /*\n * Resize\n */\n self.resizeTimer = false;\n window.addEventListener(\"resize\", function(){\n if(self.resizeTimeout){\n clearTimeout(self.resizeTimeout);\n }\n\n self.resizeTimeout = setTimeout(function(){\n self.trigger(\"resize\");\n self.resizeTimeout = false;\n }, 300);\n });\n\n self.on(\"resize\", function(){\n width = me.offsetWidth;\n className = self.nodes.slides.className;\n className = className.replace(/ min-width-1200/g, \"\");\n className = className.replace(/ min-width-720/g, \"\");\n className = className.replace(/ min-width-480/g, \"\");\n \n if(width > 1200){\n className += \" min-width-1200\";\n } else if (width > 720){\n className += \" min-width-720\";\n } else{\n className += \" min-width-480\";\n }\n self.nodes.slides.className = className;\n })\n self.trigger(\"resize\");\n\n /*\n * Transition\n */\n this.slideLock = false;\n this.events = Object();\n self.nodes.nextSlide.transitionend = function(){\n\n }\n self.nodes.nextSlide.addEventListener(transitionEnd, function(){\n self.nodes.nextSlide.transitionend();\n })\n\n this.events.animate = function(){\n if(!self.slideLock){\n promise = self.deferred();\n self.slideLock = true;\n self.nodes.nextSlide.transitionend = function(){\n self.slideLock = false;\n promise.resolve();\n }\n self.nodes.nextSlide.className = self.nodes.nextSlide.className.replace(\"tf-next\", \"\") + \" tf-current\";\n self.nodes.progressBarInner.style.width = Math.round((self.index / self.data.slides.length) * 100) + \"%\";\n return promise;\n }\n }\n self.nodes.progressBarInner.style.width = Math.round((self.index / self.data.slides.length) * 100) + \"%\";\n\n /*\n * Set Current Slide\n */\n this.events.setCurrentSlideData = function(){\n if( self.data.slides.length - self.index == 0){\n return true;\n }\n\n self.currentSlide = self.data.slides[self.index];\n /*\n * Set Caption\n */\n self.nodes.caption.innerHTML = self.currentSlide.caption;\n \n /*\n * Set Image\n */\n self.nodes.currentSlide.style.backgroundImage = \"url(\" + self.currentSlide.image_desktop_retina + \")\";\n\n /*\n * Set Focus\n */\n backgroundPosition = self.currentSlide.focus_x + \"% \" + self.currentSlide.focus_y + \"%\";\n self.nodes.currentSlide.style.backgroundPosition = backgroundPosition; \n }\n\n /*\n * Set Next Slide\n */\n this.events.setNextSlideData = function(){\n if( self.data.slides.length - self.index <= 1){\n return true;\n }\n\n self.nextSlide = self.data.slides[self.index + 1];\n /*\n * Set Image\n */\n self.nodes.nextSlide.style.backgroundImage = \"url(\" + self.nextSlide.image_desktop_retina + \")\";\n\n /*\n * Set Focus\n */\n backgroundPosition = self.nextSlide.focus_x + \"% \" + self.nextSlide.focus_y + \"%\";\n self.nodes.nextSlide.style.backgroundPosition = backgroundPosition;\n }\n\n this.events.setNextSlideData();\n this.events.setCurrentSlideData();\n\n /*\n * Advance Slide\n */\n this.events.advanceSlide = function(){\n if(!self.slideLock){\n if(((self.index - self.data.slides.length) <= 2 && self.index - self.data.slides.length != 0 ) || self.images[self.index + 2]){\n self.index++\n self.trigger(\"advanceSlide\", {value: true, slide: slide});\n\n self.events.animate().then(function(){\n self.events.setNextSlideData();\n self.nodes.nextSlide.className = self.nodes.nextSlide.className.replace(\"tf-current\", \"\") + \" tf-next\";\n self.events.setCurrentSlideData();\n })\n } else if(!self.nodes.slides.className.match(/tf-loading/)) {\n self.nodes.slides.className += \" tf-loading\";\n } \n }\n }\n this.on(\"advanceSlide\", function(params){\n slideResponses = self.db.get(\"slideResponses\") || Object();\n\n slideResponses[params.slide.id] = {\n value: params.value,\n responseTime: new Date() - self.lastResponse\n };\n\n self.lastResponse = new Date();\n self.db.set(\"slideResponses\", slideResponses);\n self.trigger(\"setSlides\");\n })\n\n this.on(\"setSlides\", function(){\n slideResponses = self.db.get(\"slideResponses\") || Object();\n\n srl = Object.keys(slideResponses).length;\n\n if(srl == self.data.slides.length){\n slides = Object.keys(slideResponses).map(function(slideId){\n return {\n id: slideId,\n response: slideResponses[slideId].value,\n time_taken: slideResponses[slideId].responseTime\n };\n })\n \n Traitify.addSlides(self.assessmentId, slides).then(function(){\n me.innerHTML = \"\";\n\n self.trigger(\"finish\")\n });\n }\n })\n\n this.trigger(\"setSlides\");\n\n /*\n * Me Trigger\n */\n this.on(\"me\", function(){\n slide = self.data.slides[self.index]\n\n self.events.advanceSlide();\n })\n\n /*\n * Not Me Trigger\n */\n this.on(\"notMe\",function(){\n slide = self.data.slides[self.index]\n\n self.events.advanceSlide();\n })\n\n /*\n * Me\n */\n this.nodes.me.onclick = function(){ \n self.trigger(\"me\")\n }\n\n /*\n * Not Me\n */\n this.nodes.notMe.onclick = function(){\n self.trigger(\"notMe\")\n }\n\n /*\n * Gui For Preload Images\n */\n self.imageSize = \"image_desktop_retina\"\n this.imageUrls = self.data.slides.map(function(slide){\n return slide[self.imageSize];\n })\n\n this.nodes.clickToReload.onclick = function(){\n self.trigger(\"clickReload\");\n }\n this.on(\"clickReload\", function(){\n self.imageTries[self.images.lastIndex] = 0;\n self.nodes.loading.show();\n self.nodes.clickToReload.hide();\n self.loadImage(self.images.lastIndex);\n })\n\n /*\n * NASTY IMAGE PRELOADING\n */\n this.imageTries = Object()\n this.images = Array();\n self.images.lastIndex = this.index;\n\n this.loadImage = function(i){\n if(self.imageUrls[i]){\n if(!self.imageTries[i]){\n self.imageTries[i]= 0;\n }\n self.images[i] = new Image();\n self.images[i].src = self.imageUrls[i];\n self.images[i].onerror = function(){\n self.imageTries[i]++;\n if(self.imageTries[i] < 30){\n setTimeout(function(){\n self.loadImage(i);\n }, 1000)\n }else{\n self.images.lastIndex = i;\n self.nodes.loading.hide();\n self.nodes.clickToReload.show();\n }\n }\n self.images[i].onload = function(){\n setTimeout(function(){\n self.loadImage(i + 1);\n }, 300)\n self.trigger(\"imageLoaded\");\n self.nodes.clickToReload.hide();\n self.images.lastIndex = i;\n\n self.nodes.slides.className = self.nodes.slides.className.replace(\" tf-loading\", \"\");\n }\n }\n }\n this.loadImage(self.index);\n }\n })(document.currentScript.parentNode);\n"]}) \ No newline at end of file diff --git a/public/js/templates/personality-types/personality-types.js b/public/js/templates/personality-types/personality-types.js index e25c5e4..19c5747 100644 --- a/public/js/templates/personality-types/personality-types.js +++ b/public/js/templates/personality-types/personality-types.js @@ -1 +1 @@ -Traitify.ui.widget("personality-types", {"data":["personality-types"],"template":"
\n {{#types}} \n
\n {{name}}\n
\n {{/types}}\n
\n","scripts":["\n (function(me){\n me.traitify = Object()\n\n me.traitify.Observable = function(item){\n item.ons = Object()\n item.on = function(key, callback){\n if(!item.ons[key]){\n item.ons[key] = Array();\n }\n item.ons[key].push(callback);\n }\n item.trigger = function(key, opts){\n if(item.ons[key] && typeof item.ons[key].length != 0){\n il = item.ons[key].length\n for(i=0; i < il; i++){\n item.ons[key][i](opts); \n }\n }\n }\n item.off = function(key){\n item.ons[key] = Array();\n }\n }\n me.traitify.Observable(me.traitify);\n\n var $TF = function(item){\n if(typeof item == \"string\"){\n item = me.querySelector(item);\n }\n if(Traitify.oldIE){\n item.addEventListener = item.attachEvent;\n }\n item.hide = function(){\n if(!this.className.match(/tf-hidden/)){\n this.className = this.className + \" tf-hidden\";\n }\n }\n item.show = function(){\n this.className = this.className.replace(/ tf-hidden/, \"\");\n }\n return item;\n }\n\n me.traitify.slideResponses = Object();\n me.traitify.lastResponse = new Date();\n me.traitify.db = Object();\n me.traitify.db.set = function(key, value){\n key = me.traitify.assessmentId + \"-\" + key\n return sessionStorage.setItem(key, JSON.stringify(value));\n }\n me.traitify.db.get = function(key){\n key = me.traitify.assessmentId + \"-\" + key\n return JSON.parse(sessionStorage.getItem(key));\n }\n me.traitify.initialize = function(){\n\n })\n })(document.currentScript.parentNode)\n"]}) \ No newline at end of file +Traitify.ui.widget("personality-types", {"name":"personality-types","data":["personality-types"],"template":"
\n {{#types}} \n
\n {{name}}\n
\n {{/types}}\n
\n","scripts":["\n (function(me){\n me.traitify = Object()\n\n me.traitify.Observable = function(item){\n item.ons = Object()\n item.on = function(key, callback){\n if(!item.ons[key]){\n item.ons[key] = Array();\n }\n item.ons[key].push(callback);\n }\n item.trigger = function(key, opts){\n if(item.ons[key] && typeof item.ons[key].length != 0){\n il = item.ons[key].length\n for(i=0; i < il; i++){\n item.ons[key][i](opts); \n }\n }\n }\n item.off = function(key){\n item.ons[key] = Array();\n }\n }\n me.traitify.Observable(me.traitify);\n\n var $TF = function(item){\n if(typeof item == \"string\"){\n item = me.querySelector(item);\n }\n if(Traitify.oldIE){\n item.addEventListener = item.attachEvent;\n }\n item.hide = function(){\n if(!this.className.match(/tf-hidden/)){\n this.className = this.className + \" tf-hidden\";\n }\n }\n item.show = function(){\n this.className = this.className.replace(/ tf-hidden/, \"\");\n }\n return item;\n }\n\n me.traitify.slideResponses = Object();\n me.traitify.lastResponse = new Date();\n me.traitify.db = Object();\n me.traitify.db.set = function(key, value){\n key = me.traitify.assessmentId + \"-\" + key\n return sessionStorage.setItem(key, JSON.stringify(value));\n }\n me.traitify.db.get = function(key){\n key = me.traitify.assessmentId + \"-\" + key\n return JSON.parse(sessionStorage.getItem(key));\n }\n me.traitify.initialize = function(){\n\n })\n })(document.currentScript.parentNode)\n"]}) \ No newline at end of file diff --git a/public/js/templates/slide-deck/slide-deck.js b/public/js/templates/slide-deck/slide-deck.js index d6f4dfd..2c806e6 100644 --- a/public/js/templates/slide-deck/slide-deck.js +++ b/public/js/templates/slide-deck/slide-deck.js @@ -1 +1 @@ -Traitify.ui.widget("tf-slide-deck", {"data":["slides"],"template":"
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Me
\n
Not Me
\n
\n Loading...\n Click to reload!\n
\n
\n
\n\n","scripts":["\n (function(me){\n me.traitify = Object()\n\n me.traitify.deferred = function(){\n return {\n thenCalls: Array(),\n catchCalls: Array(),\n then: function(callback){\n if(this.triggered){\n callback(this.args);\n }else{\n this.thenCalls.push(callback);\n }\n },\n catch: function(callback){\n if(this.triggered){\n callback(this.args);\n }else{\n this.catchCalls.push(callback);\n }\n },\n resolve: function(args){\n if(this.thenCalls && this.thenCalls.length != 0){\n for(i=0; i < this.thenCalls.length; i++){\n this.thenCalls[i](args);\n }\n }else{\n this.args = args;\n this.triggered = true;\n }\n },\n reject: function(args){\n if(this.catchCalls.length != 0){\n for(i=0; i < this.catchCalls.length; i++){\n this.catchCalls[i](args);\n }\n }else{\n this.args = args;\n this.triggered = true;\n }\n }\n }\n }\n me.traitify.Observable = function(item){\n item.ons = Object()\n item.on = function(key, callback){\n if(!item.ons[key]){\n item.ons[key] = Array();\n }\n item.ons[key].push(callback);\n }\n item.trigger = function(key, opts){\n if(item.ons[key] && typeof item.ons[key].length != 0){\n il = item.ons[key].length\n for(i=0; i < il; i++){\n item.ons[key][i](opts); \n }\n }\n }\n item.off = function(key){\n item.ons[key] = Array();\n }\n }\n me.traitify.Observable(me.traitify);\n var i, undefined, el = document.createElement('div'),\n transitions = {\n 'transition':'transitionend',\n 'OTransition':'otransitionend', // oTransitionEnd in very old Opera\n 'MozTransition':'transitionend',\n 'WebkitTransition':'webkitTransitionEnd'\n };\n\n for (i in transitions) {\n if (transitions.hasOwnProperty(i) && el.style[i] !== undefined) {\n transitionEnd = transitions[i];\n }\n }\n var $TF = function(item){\n if(typeof item == \"string\"){\n item = me.querySelector(item);\n }\n if(Traitify.oldIE){\n item.addEventListener = item.attachEvent;\n }\n item.hide = function(){\n if(!this.className.match(/tf-hidden/)){\n this.className = this.className + \" tf-hidden\";\n }\n }\n item.show = function(){\n this.className = this.className.replace(/ tf-hidden/, \"\");\n }\n return item;\n }\n me.traitify.slideResponses = Object();\n me.traitify.lastResponse = new Date();\n me.traitify.db = Object();\n me.traitify.db.set = function(key, value){\n key = me.traitify.assessmentId + \"-\" + key\n return sessionStorage.setItem(key, JSON.stringify(value));\n }\n me.traitify.db.get = function(key){\n key = me.traitify.assessmentId + \"-\" + key\n return JSON.parse(sessionStorage.getItem(key));\n }\n me.traitify.initialize = function(){\n self = $TF(this);\n /*\n * Set Available Nodes\n */\n this.nodes = Object()\n this.nodes.currentSlide = $TF(\".tf-slide.tf-current\");\n this.nodes.nextSlide = $TF(\".tf-slide.tf-next\");\n this.nodes.caption = $TF(\".tf-caption\");\n this.nodes.me = $TF(\".tf-me\");\n this.nodes.notMe = $TF(\".tf-not-me\");\n this.nodes.progressBarInner = $TF(\".tf-progress-bar-inner\");\n this.nodes.slides = $TF(\".tf-slides\");\n this.nodes.loading = $TF(\".tf-loading .tf-loading-content\");\n this.nodes.clickToReload = $TF(\".tf-loading .tf-click-content\");\n\n\n /*\n * Set Data\n */\n this.data.unPlayedSlides = this.data.slides.filter(function(slide){\n return !slide.completed_at && Object.keys(self.db.get(\"slideResponses\") || Object()).indexOf(slide.id) == -1\n })\n this.data.playedSlides = this.data.slides.filter(function(slide){\n return slide.completed_at || Object.keys(self.db.get(\"slideResponses\") || Object()).indexOf(slide.id) != -1\n })\n this.data.slides = this.data.playedSlides.concat(this.data.unPlayedSlides)\n this.index = this.data.playedSlides.length || 0\n\n /*\n * Resize\n */\n self.resizeTimer = false;\n window.addEventListener(\"resize\", function(){\n if(self.resizeTimeout){\n clearTimeout(self.resizeTimeout);\n }\n\n self.resizeTimeout = setTimeout(function(){\n self.trigger(\"resize\");\n self.resizeTimeout = false;\n }, 300);\n });\n\n self.on(\"resize\", function(){\n width = me.offsetWidth;\n className = self.nodes.slides.className;\n className = className.replace(/ min-width-1200/g, \"\");\n className = className.replace(/ min-width-720/g, \"\");\n className = className.replace(/ min-width-480/g, \"\");\n \n if(width > 1200){\n className += \" min-width-1200\";\n } else if (width > 720){\n className += \" min-width-720\";\n } else{\n className += \" min-width-480\";\n }\n self.nodes.slides.className = className;\n })\n self.trigger(\"resize\");\n\n /*\n * Transition\n */\n this.slideLock = false;\n this.events = Object();\n self.nodes.nextSlide.transitionend = function(){\n\n }\n self.nodes.nextSlide.addEventListener(transitionEnd, function(){\n self.nodes.nextSlide.transitionend();\n })\n\n this.events.animate = function(){\n if(!self.slideLock){\n promise = self.deferred();\n self.slideLock = true;\n self.nodes.nextSlide.transitionend = function(){\n self.slideLock = false;\n promise.resolve();\n }\n self.nodes.nextSlide.className = self.nodes.nextSlide.className.replace(\"tf-next\", \"\") + \" tf-current\";\n self.nodes.progressBarInner.style.width = Math.round((self.index / self.data.slides.length) * 100) + \"%\";\n return promise;\n }\n }\n self.nodes.progressBarInner.style.width = Math.round((self.index / self.data.slides.length) * 100) + \"%\";\n\n /*\n * Set Current Slide\n */\n this.events.setCurrentSlideData = function(){\n if( self.data.slides.length - self.index == 0){\n return true;\n }\n\n self.currentSlide = self.data.slides[self.index];\n /*\n * Set Caption\n */\n self.nodes.caption.innerHTML = self.currentSlide.caption;\n \n /*\n * Set Image\n */\n self.nodes.currentSlide.style.backgroundImage = \"url(\" + self.currentSlide.image_desktop_retina + \")\";\n\n /*\n * Set Focus\n */\n backgroundPosition = self.currentSlide.focus_x + \"% \" + self.currentSlide.focus_y + \"%\";\n self.nodes.currentSlide.style.backgroundPosition = backgroundPosition; \n }\n\n /*\n * Set Next Slide\n */\n this.events.setNextSlideData = function(){\n if( self.data.slides.length - self.index <= 1){\n return true;\n }\n\n self.nextSlide = self.data.slides[self.index + 1];\n /*\n * Set Image\n */\n self.nodes.nextSlide.style.backgroundImage = \"url(\" + self.nextSlide.image_desktop_retina + \")\";\n\n /*\n * Set Focus\n */\n backgroundPosition = self.nextSlide.focus_x + \"% \" + self.nextSlide.focus_y + \"%\";\n self.nodes.nextSlide.style.backgroundPosition = backgroundPosition;\n }\n\n this.events.setNextSlideData();\n this.events.setCurrentSlideData();\n\n /*\n * Advance Slide\n */\n this.events.advanceSlide = function(){\n if(!self.slideLock){\n if(((self.index - self.data.slides.length) <= 2 && self.index - self.data.slides.length != 0 ) || self.images[self.index + 2]){\n self.index++\n self.trigger(\"advanceSlide\", {value: true, slide: slide});\n\n self.events.animate().then(function(){\n self.events.setNextSlideData();\n self.nodes.nextSlide.className = self.nodes.nextSlide.className.replace(\"tf-current\", \"\") + \" tf-next\";\n self.events.setCurrentSlideData();\n })\n } else if(!self.nodes.slides.className.match(/tf-loading/)) {\n self.nodes.slides.className += \" tf-loading\";\n } \n }\n }\n this.on(\"advanceSlide\", function(params){\n slideResponses = self.db.get(\"slideResponses\") || Object();\n\n slideResponses[params.slide.id] = {\n value: params.value,\n responseTime: new Date() - self.lastResponse\n };\n\n self.lastResponse = new Date();\n self.db.set(\"slideResponses\", slideResponses);\n self.trigger(\"setSlides\");\n })\n\n this.on(\"setSlides\", function(){\n slideResponses = self.db.get(\"slideResponses\") || Object();\n\n srl = Object.keys(slideResponses).length;\n\n if(srl == self.data.slides.length){\n slides = Object.keys(slideResponses).map(function(slideId){\n return {\n id: slideId,\n response: slideResponses[slideId].value,\n time_taken: slideResponses[slideId].responseTime\n };\n })\n \n Traitify.addSlides(self.assessmentId, slides).then(function(){\n me.innerHTML = \"\";\n\n self.trigger(\"finish\")\n });\n }\n })\n\n this.trigger(\"setSlides\");\n\n /*\n * Me Trigger\n */\n this.on(\"me\", function(){\n slide = self.data.slides[self.index]\n\n self.events.advanceSlide();\n })\n\n /*\n * Not Me Trigger\n */\n this.on(\"notMe\",function(){\n slide = self.data.slides[self.index]\n\n self.events.advanceSlide();\n })\n\n /*\n * Me\n */\n this.nodes.me.onclick = function(){ \n self.trigger(\"me\")\n }\n\n /*\n * Not Me\n */\n this.nodes.notMe.onclick = function(){\n self.trigger(\"notMe\")\n }\n\n /*\n * Gui For Preload Images\n */\n self.imageSize = \"image_desktop_retina\"\n this.imageUrls = self.data.slides.map(function(slide){\n return slide[self.imageSize];\n })\n\n this.nodes.clickToReload.onclick = function(){\n self.trigger(\"clickReload\");\n }\n this.on(\"clickReload\", function(){\n self.imageTries[self.images.lastIndex] = 0;\n self.nodes.loading.show();\n self.nodes.clickToReload.hide();\n self.loadImage(self.images.lastIndex);\n })\n\n /*\n * NASTY IMAGE PRELOADING\n */\n this.imageTries = Object()\n this.images = Array();\n self.images.lastIndex = this.index;\n\n this.loadImage = function(i){\n if(self.imageUrls[i]){\n if(!self.imageTries[i]){\n self.imageTries[i]= 0;\n }\n self.images[i] = new Image();\n self.images[i].src = self.imageUrls[i];\n self.images[i].onerror = function(){\n self.imageTries[i]++;\n if(self.imageTries[i] < 30){\n setTimeout(function(){\n self.loadImage(i);\n }, 1000)\n }else{\n self.images.lastIndex = i;\n self.nodes.loading.hide();\n self.nodes.clickToReload.show();\n }\n }\n self.images[i].onload = function(){\n setTimeout(function(){\n self.loadImage(i + 1);\n }, 300)\n self.trigger(\"imageLoaded\");\n self.nodes.clickToReload.hide();\n self.images.lastIndex = i;\n\n self.nodes.slides.className = self.nodes.slides.className.replace(\" tf-loading\", \"\");\n }\n }\n }\n this.loadImage(self.index);\n }\n })(document.currentScript.parentNode);\n"]}) \ No newline at end of file +Traitify.ui.widget("tf-slide-deck", {"name":"tf-slide-deck","data":["slides"],"template":"
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Me
\n
Not Me
\n
\n Loading...\n Click to reload!\n
\n
\n
\n\n","scripts":["\n (function(me){\n me.traitify = Object()\n\n me.traitify.deferred = function(){\n return {\n thenCalls: Array(),\n catchCalls: Array(),\n then: function(callback){\n if(this.triggered){\n callback(this.args);\n }else{\n this.thenCalls.push(callback);\n }\n },\n catch: function(callback){\n if(this.triggered){\n callback(this.args);\n }else{\n this.catchCalls.push(callback);\n }\n },\n resolve: function(args){\n if(this.thenCalls && this.thenCalls.length != 0){\n for(i=0; i < this.thenCalls.length; i++){\n this.thenCalls[i](args);\n }\n }else{\n this.args = args;\n this.triggered = true;\n }\n },\n reject: function(args){\n if(this.catchCalls.length != 0){\n for(i=0; i < this.catchCalls.length; i++){\n this.catchCalls[i](args);\n }\n }else{\n this.args = args;\n this.triggered = true;\n }\n }\n }\n }\n me.traitify.Observable = function(item){\n item.ons = Object()\n item.on = function(key, callback){\n if(!item.ons[key]){\n item.ons[key] = Array();\n }\n item.ons[key].push(callback);\n }\n item.trigger = function(key, opts){\n if(item.ons[key] && typeof item.ons[key].length != 0){\n il = item.ons[key].length\n for(i=0; i < il; i++){\n item.ons[key][i](opts); \n }\n }\n }\n item.off = function(key){\n item.ons[key] = Array();\n }\n }\n me.traitify.Observable(me.traitify);\n var i, undefined, el = document.createElement('div'),\n transitions = {\n 'transition':'transitionend',\n 'OTransition':'otransitionend', // oTransitionEnd in very old Opera\n 'MozTransition':'transitionend',\n 'WebkitTransition':'webkitTransitionEnd'\n };\n\n for (i in transitions) {\n if (transitions.hasOwnProperty(i) && el.style[i] !== undefined) {\n transitionEnd = transitions[i];\n }\n }\n var $TF = function(item){\n if(typeof item == \"string\"){\n item = me.querySelector(item);\n }\n if(Traitify.oldIE){\n item.addEventListener = item.attachEvent;\n }\n item.hide = function(){\n if(!this.className.match(/tf-hidden/)){\n this.className = this.className + \" tf-hidden\";\n }\n }\n item.show = function(){\n this.className = this.className.replace(/ tf-hidden/, \"\");\n }\n return item;\n }\n me.traitify.slideResponses = Object();\n me.traitify.lastResponse = new Date();\n me.traitify.db = Object();\n me.traitify.db.set = function(key, value){\n key = me.traitify.assessmentId + \"-\" + key\n return sessionStorage.setItem(key, JSON.stringify(value));\n }\n me.traitify.db.get = function(key){\n key = me.traitify.assessmentId + \"-\" + key\n return JSON.parse(sessionStorage.getItem(key));\n }\n me.traitify.initialize = function(){\n self = $TF(this);\n /*\n * Set Available Nodes\n */\n this.nodes = Object()\n this.nodes.currentSlide = $TF(\".tf-slide.tf-current\");\n this.nodes.nextSlide = $TF(\".tf-slide.tf-next\");\n this.nodes.caption = $TF(\".tf-caption\");\n this.nodes.me = $TF(\".tf-me\");\n this.nodes.notMe = $TF(\".tf-not-me\");\n this.nodes.progressBarInner = $TF(\".tf-progress-bar-inner\");\n this.nodes.slides = $TF(\".tf-slides\");\n this.nodes.loading = $TF(\".tf-loading .tf-loading-content\");\n this.nodes.clickToReload = $TF(\".tf-loading .tf-click-content\");\n\n\n /*\n * Set Data\n */\n this.data.unPlayedSlides = this.data.slides.filter(function(slide){\n return !slide.completed_at && Object.keys(self.db.get(\"slideResponses\") || Object()).indexOf(slide.id) == -1\n })\n this.data.playedSlides = this.data.slides.filter(function(slide){\n return slide.completed_at || Object.keys(self.db.get(\"slideResponses\") || Object()).indexOf(slide.id) != -1\n })\n this.data.slides = this.data.playedSlides.concat(this.data.unPlayedSlides)\n this.index = this.data.playedSlides.length || 0\n\n /*\n * Resize\n */\n self.resizeTimer = false;\n window.addEventListener(\"resize\", function(){\n if(self.resizeTimeout){\n clearTimeout(self.resizeTimeout);\n }\n\n self.resizeTimeout = setTimeout(function(){\n self.trigger(\"resize\");\n self.resizeTimeout = false;\n }, 300);\n });\n\n self.on(\"resize\", function(){\n width = me.offsetWidth;\n className = self.nodes.slides.className;\n className = className.replace(/ min-width-1200/g, \"\");\n className = className.replace(/ min-width-720/g, \"\");\n className = className.replace(/ min-width-480/g, \"\");\n \n if(width > 1200){\n className += \" min-width-1200\";\n } else if (width > 720){\n className += \" min-width-720\";\n } else{\n className += \" min-width-480\";\n }\n self.nodes.slides.className = className;\n })\n self.trigger(\"resize\");\n\n /*\n * Transition\n */\n this.slideLock = false;\n this.events = Object();\n self.nodes.nextSlide.transitionend = function(){\n\n }\n self.nodes.nextSlide.addEventListener(transitionEnd, function(){\n self.nodes.nextSlide.transitionend();\n })\n\n this.events.animate = function(){\n if(!self.slideLock){\n promise = self.deferred();\n self.slideLock = true;\n self.nodes.nextSlide.transitionend = function(){\n self.slideLock = false;\n promise.resolve();\n }\n self.nodes.nextSlide.className = self.nodes.nextSlide.className.replace(\"tf-next\", \"\") + \" tf-current\";\n self.nodes.progressBarInner.style.width = Math.round((self.index / self.data.slides.length) * 100) + \"%\";\n return promise;\n }\n }\n self.nodes.progressBarInner.style.width = Math.round((self.index / self.data.slides.length) * 100) + \"%\";\n\n /*\n * Set Current Slide\n */\n this.events.setCurrentSlideData = function(){\n if( self.data.slides.length - self.index == 0){\n return true;\n }\n\n self.currentSlide = self.data.slides[self.index];\n /*\n * Set Caption\n */\n self.nodes.caption.innerHTML = self.currentSlide.caption;\n \n /*\n * Set Image\n */\n self.nodes.currentSlide.style.backgroundImage = \"url(\" + self.currentSlide.image_desktop_retina + \")\";\n\n /*\n * Set Focus\n */\n backgroundPosition = self.currentSlide.focus_x + \"% \" + self.currentSlide.focus_y + \"%\";\n self.nodes.currentSlide.style.backgroundPosition = backgroundPosition; \n }\n\n /*\n * Set Next Slide\n */\n this.events.setNextSlideData = function(){\n if( self.data.slides.length - self.index <= 1){\n return true;\n }\n\n self.nextSlide = self.data.slides[self.index + 1];\n /*\n * Set Image\n */\n self.nodes.nextSlide.style.backgroundImage = \"url(\" + self.nextSlide.image_desktop_retina + \")\";\n\n /*\n * Set Focus\n */\n backgroundPosition = self.nextSlide.focus_x + \"% \" + self.nextSlide.focus_y + \"%\";\n self.nodes.nextSlide.style.backgroundPosition = backgroundPosition;\n }\n\n this.events.setNextSlideData();\n this.events.setCurrentSlideData();\n\n /*\n * Advance Slide\n */\n this.events.advanceSlide = function(){\n if(!self.slideLock){\n if(((self.index - self.data.slides.length) <= 2 && self.index - self.data.slides.length != 0 ) || self.images[self.index + 2]){\n self.index++\n self.trigger(\"advanceSlide\", {value: true, slide: slide});\n\n self.events.animate().then(function(){\n self.events.setNextSlideData();\n self.nodes.nextSlide.className = self.nodes.nextSlide.className.replace(\"tf-current\", \"\") + \" tf-next\";\n self.events.setCurrentSlideData();\n })\n } else if(!self.nodes.slides.className.match(/tf-loading/)) {\n self.nodes.slides.className += \" tf-loading\";\n } \n }\n }\n this.on(\"advanceSlide\", function(params){\n slideResponses = self.db.get(\"slideResponses\") || Object();\n\n slideResponses[params.slide.id] = {\n value: params.value,\n responseTime: new Date() - self.lastResponse\n };\n\n self.lastResponse = new Date();\n self.db.set(\"slideResponses\", slideResponses);\n self.trigger(\"setSlides\");\n })\n\n this.on(\"setSlides\", function(){\n slideResponses = self.db.get(\"slideResponses\") || Object();\n\n srl = Object.keys(slideResponses).length;\n\n if(srl == self.data.slides.length){\n slides = Object.keys(slideResponses).map(function(slideId){\n return {\n id: slideId,\n response: slideResponses[slideId].value,\n time_taken: slideResponses[slideId].responseTime\n };\n })\n \n Traitify.addSlides(self.assessmentId, slides).then(function(){\n me.innerHTML = \"\";\n\n self.trigger(\"finish\")\n });\n }\n })\n\n this.trigger(\"setSlides\");\n\n /*\n * Me Trigger\n */\n this.on(\"me\", function(){\n slide = self.data.slides[self.index]\n\n self.events.advanceSlide();\n })\n\n /*\n * Not Me Trigger\n */\n this.on(\"notMe\",function(){\n slide = self.data.slides[self.index]\n\n self.events.advanceSlide();\n })\n\n /*\n * Me\n */\n this.nodes.me.onclick = function(){ \n self.trigger(\"me\")\n }\n\n /*\n * Not Me\n */\n this.nodes.notMe.onclick = function(){\n self.trigger(\"notMe\")\n }\n\n /*\n * Gui For Preload Images\n */\n self.imageSize = \"image_desktop_retina\"\n this.imageUrls = self.data.slides.map(function(slide){\n return slide[self.imageSize];\n })\n\n this.nodes.clickToReload.onclick = function(){\n self.trigger(\"clickReload\");\n }\n this.on(\"clickReload\", function(){\n self.imageTries[self.images.lastIndex] = 0;\n self.nodes.loading.show();\n self.nodes.clickToReload.hide();\n self.loadImage(self.images.lastIndex);\n })\n\n /*\n * NASTY IMAGE PRELOADING\n */\n this.imageTries = Object()\n this.images = Array();\n self.images.lastIndex = this.index;\n\n this.loadImage = function(i){\n if(self.imageUrls[i]){\n if(!self.imageTries[i]){\n self.imageTries[i]= 0;\n }\n self.images[i] = new Image();\n self.images[i].src = self.imageUrls[i];\n self.images[i].onerror = function(){\n self.imageTries[i]++;\n if(self.imageTries[i] < 30){\n setTimeout(function(){\n self.loadImage(i);\n }, 1000)\n }else{\n self.images.lastIndex = i;\n self.nodes.loading.hide();\n self.nodes.clickToReload.show();\n }\n }\n self.images[i].onload = function(){\n setTimeout(function(){\n self.loadImage(i + 1);\n }, 300)\n self.trigger(\"imageLoaded\");\n self.nodes.clickToReload.hide();\n self.images.lastIndex = i;\n\n self.nodes.slides.className = self.nodes.slides.className.replace(\" tf-loading\", \"\");\n }\n }\n }\n this.loadImage(self.index);\n }\n })(document.currentScript.parentNode);\n"]}) \ No newline at end of file